2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Network/Multi.h $
15 * Header file which contains type definitions for multiplayer, and support for high-level
16 * multiplayer functions.
19 * Revision 1.5 2003/05/25 02:30:42 taylor
22 * Revision 1.4 2002/06/09 04:41:14 relnev
23 * added copyright header
25 * Revision 1.3 2002/06/02 06:02:59 relnev
28 * Revision 1.2 2002/05/26 21:27:53 theoddone33
29 * More progress (I hate psnet2)
31 * Revision 1.1.1.1 2002/05/03 03:28:12 root
35 * 47 8/30/99 5:01p Dave
36 * Made d3d do less state changing in the nebula. Use new chat server for
39 * 46 8/26/99 8:51p Dave
40 * Gave multiplayer TvT messaging a heavy dose of sanity. Cheat codes.
42 * 45 8/24/99 10:11a Dave
45 * 44 8/24/99 1:49a Dave
46 * Fixed client-side afterburner stuttering. Added checkbox for no version
47 * checking on PXO join. Made button info passing more friendly between
50 * 43 8/22/99 5:53p Dave
51 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
52 * instead of ship designations for multiplayer players.
54 * 42 8/22/99 1:19p Dave
55 * Fixed up http proxy code. Cleaned up scoring code. Reverse the order in
56 * which d3d cards are detected.
58 * 41 8/19/99 10:59a Dave
59 * Packet loss detection.
61 * 40 8/04/99 2:24a Dave
62 * Fixed escort gauge ordering for dogfight.
64 * 39 7/30/99 7:01p Dave
65 * Dogfight escort gauge. Fixed up laser rendering in Glide.
67 * 38 7/26/99 5:50p Dave
68 * Revised ingame join. Better? We'll see....
70 * 37 7/22/99 7:17p Dave
71 * Fixed excessive whacks in multiplayer.
73 * 36 7/08/99 10:53a Dave
74 * New multiplayer interpolation scheme. Not 100% done yet, but still
75 * better than the old way.
77 * 35 7/03/99 5:50p Dave
78 * Make rotated bitmaps draw properly in padlock views.
80 * 34 6/07/99 9:51p Dave
81 * Consolidated all multiplayer ports into one.
83 * 33 5/17/99 9:32a Dave
84 * Bumped up server version.
86 * 32 5/14/99 1:59p Andsager
87 * Multiplayer message for subsystem cargo revealed.
89 * 31 4/29/99 3:02p Dave
91 * 30 4/29/99 2:29p Dave
92 * Made flak work much better in multiplayer.
94 * 29 4/28/99 11:13p Dave
95 * Temporary checkin of artillery code.
97 * 28 4/25/99 7:43p Dave
98 * Misc small bug fixes. Made sun draw properly.
100 * 27 4/21/99 6:15p Dave
101 * Did some serious housecleaning in the beam code. Made it ready to go
102 * for anti-fighter "pulse" weapons. Fixed collision pair creation. Added
103 * a handy macro for recalculating collision pairs for a given object.
105 * 26 4/09/99 2:21p Dave
106 * Multiplayer beta stuff. CD checking.
108 * 25 3/10/99 6:50p Dave
109 * Changed the way we buffer packets for all clients. Optimized turret
110 * fired packets. Did some weapon firing optimizations.
112 * 24 3/08/99 7:03p Dave
113 * First run of new object update system. Looks very promising.
115 * 23 3/01/99 7:39p Dave
116 * Added prioritizing ship respawns. Also fixed respawns in TvT so teams
117 * don't mix respawn points.
119 * 22 2/25/99 4:19p Dave
120 * Added multiplayer_beta defines. Added cd_check define. Fixed a few
121 * release build warnings. Added more data to the squad war request and
124 * 21 2/23/99 2:29p Dave
125 * First run of oldschool dogfight mode.
127 * 20 2/19/99 11:42a Dave
128 * Put in model rendering autocentering.
130 * 19 2/17/99 2:10p Dave
131 * First full run of squad war. All freespace and tracker side stuff
134 * 18 2/12/99 6:16p Dave
135 * Pre-mission Squad War code is 95% done.
137 * 17 2/11/99 3:08p Dave
138 * PXO refresh button. Very preliminary squad war support.
140 * 16 2/08/99 5:07p Dave
141 * FS2 chat server support. FS2 specific validated missions.
143 * 15 1/29/99 2:08a Dave
144 * Fixed beam weapon collisions with players. Reduced size of scoring
145 * struct for multiplayer. Disabled PXO.
147 * 14 1/14/99 12:48a Dave
148 * Todo list bug fixes. Made a pass at putting briefing icons back into
149 * FRED. Sort of works :(
151 * 13 1/12/99 5:45p Dave
152 * Moved weapon pipeline in multiplayer to almost exclusively client side.
153 * Very good results. Bandwidth goes down, playability goes up for crappy
154 * connections. Fixed object update problem for ship subsystems.
156 * 12 1/12/99 4:07a Dave
157 * Put in barracks code support for selecting squad logos. Properly
158 * distribute squad logos in a multiplayer game.
160 * 11 12/14/98 12:13p Dave
161 * Spiffed up xfer system a bit. Put in support for squad logo file xfer.
164 * 10 12/03/98 5:22p Dave
165 * Ported over Freespace 1 multiplayer ships.tbl and weapons.tbl
168 * 9 11/19/98 4:19p Dave
169 * Put IPX sockets back in psnet. Consolidated all multiplayer config
172 * 8 11/19/98 8:03a Dave
173 * Full support for D3-style reliable sockets. Revamped packet lag/loss
174 * system, made it receiver side and at the lowest possible level.
176 * 7 11/17/98 11:12a Dave
177 * Removed player identification by address. Now assign explicit id #'s.
179 * 6 11/12/98 12:13a Dave
180 * Tidied code up for multiplayer test. Put in network support for flak
183 * 5 11/05/98 5:55p Dave
184 * Big pass at reducing #includes
186 * 4 10/19/98 11:15a Dave
187 * Changed requirements for stats storing in PXO mode.
189 * 3 10/07/98 6:27p Dave
190 * Globalized mission and campaign file extensions. Removed Silent Threat
191 * special code. Moved \cache \players and \multidata into the \data
194 * 2 10/07/98 10:53a Dave
197 * 1 10/07/98 10:50a Dave
199 * 257 9/20/98 7:19p Dave
200 * Added CHANGE_IFF packet.
202 * 256 9/16/98 6:54p Dave
203 * Upped max sexpression nodes to 1800 (from 1600). Changed FRED to sort
204 * the ship list box. Added code so that tracker stats are not stored with
207 * 255 9/15/98 7:24p Dave
208 * Minor UI changes. Localized bunch of new text.
210 * 254 9/15/98 4:03p Dave
211 * Changed readyroom and multi screens to display "st" icon for all
212 * missions with mission disk content (not necessarily just those that
213 * come with Silent Threat).
215 * 253 9/11/98 5:08p Dave
216 * More tweaks to kick notification system.
218 * 252 9/11/98 2:05p Allender
219 * make reinforcements work correctly in multiplayer games. There still
220 * may be a team vs team issue that I haven't thought of yet :-(
222 * 251 9/04/98 3:51p Dave
223 * Put in validated mission updating and application during stats
226 * 250 8/31/98 2:06p Dave
227 * Make cfile sort the ordering or vp files. Added support/checks for
228 * recognizing "mission disk" players.
230 * 249 8/25/98 1:48p Dave
231 * First rev of EMP effect. Player side stuff basically done. Next comes
234 * 248 8/12/98 4:53p Dave
235 * Put in 32 bit checksumming for PXO missions. No validation on the
236 * actual tracker yet, though.
238 * 247 7/24/98 9:27a Dave
239 * Tidied up endgame sequencing by removing several old flags and
240 * standardizing _all_ endgame stuff with a single function call.
242 * 246 7/10/98 5:04p Dave
243 * Fix connection speed bug on standalone server.
245 * 245 7/10/98 11:52a Allender
246 * changes to the connection type
248 * 244 7/10/98 1:13a Allender
249 * lots of small multiplayer update changes. Code in launcher to specify
250 * connection speed. A couple of small fixes regarding empty mission
251 * files. Time out players after 10 second when they don't connect on
252 * their reliable socket.
254 * 243 7/07/98 2:56p Dave
256 * 242 7/02/98 6:16p Dave
257 * Make rear facing prediction much better. Tweak update levels and
258 * viewcone values. Make sure observers send targeting info correctly.
260 * 241 6/30/98 2:17p Dave
261 * Revised object update system. Removed updates for all weapons. Put
262 * button info back into control info packet.
264 * 240 6/22/98 8:36a Allender
265 * revamping of homing weapon system. don't send as object updates
268 * 239 6/17/98 10:56a Dave
269 * Put in debug code for detecting potential tracker stats update
272 * 238 6/12/98 2:49p Dave
273 * Patch 1.02 changes.
275 * 237 6/10/98 2:56p Dave
276 * Substantial changes to reduce bandwidth and latency problems.
278 * 236 6/04/98 10:06p Allender
279 * upped packet version
281 * 235 6/04/98 11:46a Dave
282 * Drastically reduce size/rate of client control info update packets. Put
283 * in rate limiting for object updating from server.
292 #include "psnet.h" // for PSNET_SOCKET
294 #include "multi_ping.h"
295 #include "missionparse.h"
296 #include "multi_options.h"
298 // ----------------------------------------------------------------------------------------
305 // defines for checking PXO valid missions
307 // NEVER COMMENT OUT THIS LINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
308 #define PXO_CHECK_VALID_MISSIONS // always check for valid missions in a debug build
310 // #define PXO_CHECK_VALID_MISSIONS // comment this in and out as necessary (for testing or not)
313 // name of the validated mission file for PXO missions
314 #define MULTI_VALID_MISSION_FILE "mvalid.cfg"
316 // name of the file which contains known TCP addresses
317 #define IP_CONFIG_FNAME "tcp.cfg"
319 // server version and compatible version
320 // to join a game - your LOCAL.MULTI_FS_SERVER_COMPATIBLE_VERSION must be >= GAME_SERVER.MULTI_FS_SERVER_VERSION
321 // Version #. Please put the date down when you up these values
322 // NOTE: always keep SERVER_VERSION and SERVER_COMPATIBLE_VERSION the same
324 // version 32 - 1/29/99
325 // version 33 - 2/22/99
326 // version 34 - 4/8/99
327 // version 35 - 4/21/99
328 // version 36 - 4/28/99
329 // version 37 - 4/29/99
330 // version 38 - 5/17/77
331 // version 39 - 7/3/99
332 // version 40 - 7/7/99
333 // version 41 - 7/22/99
334 // version 42 - 7/26/99 (ingame join stuff)
335 // version 43 - 7/30/99
336 // version 44 - 8/24/99
337 // version 46 - 8/30/99
338 // version 70+ for FS1 - 1/16/03
341 #define MULTI_FS_SERVER_VERSION 70
343 #define MULTI_FS_SERVER_VERSION 46
345 #define MULTI_FS_SERVER_COMPATIBLE_VERSION MULTI_FS_SERVER_VERSION
347 // version defines (i.e. demo, full version, special OEM version
348 // id's should not be > 255!!!!
349 #define NG_VERSION_ID_FULL 1
351 // set the next define to be what version you want to build for.
352 #define NG_VERSION_ID NG_VERSION_ID_FULL
354 // the max # of active players (flying ships)
355 #define MULTI_MAX_PLAYERS 12
357 // the total max # of connections (players + observers + (possibly)standalone server)
358 #define MULTI_MAX_CONNECTIONS 16
360 // the max # of observers ever allowed
361 #define MAX_OBSERVERS 4
365 // string length defines
366 #define MAX_GAMENAME_LEN 32 // maximum length in characters of a game name
367 #define DESCRIPT_LENGTH 512 // maximum length of a mission description (as specified by Fred)
368 #define MAX_PASSWD_LEN 16 // maximum length of the password for a netgame
370 // low level networking defines
371 #define IP_ADDRESS_LENGTH 4 // length of the address field for an IP address
372 #define IP_PORT_LENGTH 2 // length of the port field for an IP address
373 #define IPX_ADDRESS_LENGTH 6 // length of the address field for an IPX address
374 #define IPX_PORT_LENGTH 2 // length of the port field for an IPX address
377 #define RESPAWN_ANARCHY (0xffffffff)// respawn setting for an "anarchy" style game
378 #define MP_SINGLE 0 // not playing a campaign - single mission
379 #define MP_CAMPAIGN 1 // playing a campaign
382 #define RESPAWN_INVUL_TIMESTAMP 5000 // how long a player is invulnerable after he respawns
383 #define MAX_RESPAWN_POINTS 25 // the max # of respawn points we'll keep track of for any mission
385 // player information defines
386 #define BUTTON_INFO_SAVE_COUNT 30 // how many buttons infos we keep track of for sending critical keypresses to the server
387 #define MAX_PINGS 10 // how many pings we keep track of for averaging player pings
388 #define OBJECT_UDPATE_DIFF_TOLERANCE 40000 // how big of a difference in sequence numbers (control_info and object_updates) before we reset
390 // reliable connect wait
391 #define MULTI_RELIABLE_CONNECT_WAIT 15
393 // tracker mission validation status
394 #define MVALID_STATUS_UNKNOWN -1
395 #define MVALID_STATUS_VALID 0
396 #define MVALID_STATUS_INVALID 1
398 // ----------------------------------------------------------------------------------------
401 // ----------------------------------------------------------------------------------------
406 // netplayer management
407 #define NET_PLAYER_INDEX(np) (np-Net_players)
408 #define NET_PLAYER_NUM(np) (NET_PLAYER_INDEX(np))
409 #define MY_NET_PLAYER_NUM (NET_PLAYER_INDEX(Net_player))
411 // determine what the status of this machine is
412 #define MULTIPLAYER_MASTER ( (Game_mode & GM_MULTIPLAYER) && (Net_player->flags & NETINFO_FLAG_AM_MASTER) )
413 #define MULTIPLAYER_HOST ( (Game_mode & GM_MULTIPLAYER) && (Net_player->flags & NETINFO_FLAG_GAME_HOST) )
414 #define MULTIPLAYER_CLIENT ( (Game_mode & GM_MULTIPLAYER) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER) )
415 #define MULTIPLAYER_STANDALONE ( (Game_mode & GM_MULTIPLAYER) && (Net_players[0].flags & NETINFO_FLAG_AM_MASTER) && !(Net_players[0].flags & NETINFO_FLAG_GAME_HOST) )
417 // determine the status of the passed player
418 #define MULTI_CONNECTED(np) (np.flags & NETINFO_FLAG_CONNECTED)
419 #define MULTI_HOST(np) (np.flags & NETINFO_FLAG_GAME_HOST)
420 #define MULTI_SERVER(np) (np.flags & NETINFO_FLAG_AM_MASTER)
421 #define MULTI_STANDALONE(np) ((np.flags & NETINFO_FLAG_AM_MASTER) && !(np.flags & NETINFO_FLAG_GAME_HOST))
422 #define MULTI_OBSERVER(np) (np.flags & NETINFO_FLAG_OBSERVER)
423 #define MULTI_TEMP_OBSERVER(np) ((np.flags & NETINFO_FLAG_OBSERVER) && (np.flags & NETINFO_FLAG_OBS_PLAYER))
424 #define MULTI_PERM_OBSERVER(np) ((np.flags & NETINFO_FLAG_OBSERVER) && !(np.flags & NETINFO_FLAG_OBS_PLAYER))
426 // are we playing on a master tracker registered server
427 #define MULTI_IS_TRACKER_GAME (0)
428 // ----------------------------------------------------------------------------------------
431 // ----------------------------------------------------------------------------------------
432 // Packet definitions and additional packet data types
436 #define NETPLAYER_SLOTS_P 0x01 // data telling clients what player has what object number ...
437 #define FIRING_INFO 0x02 // firing info packet
438 #define INGAME_SHIP_UPDATE 0x03 // ship status-like update for ingame joiners choosing ships.
439 #define INGAME_SHIP_REQUEST 0x04 // used for requesting a replying (confirm or no) ships for an ingame joiner
440 #define TEAM_SELECT_UPDATE 0x05 // update from host to players in team select regarding who has what ship
441 #define FILE_SIG_INFO 0x06 // file signature info ( as calculated by get_bigass_file_signature() )
442 #define RESPAWN_NOTICE 0x07 // from client to server, or server to client
443 #define LOAD_MISSION_NOW 0x08 // clients should load the mission and return an ack
444 #define FILE_SIG_REQUEST 0x09 // request from server to client for filesig info
445 #define JUMP_INTO_GAME 0x0A // from server to client telling him to jump into the mission
446 #define RESPAWN_POINTS 0x0B // from server to ingame joiners, giving respawn data
447 #define CLIENT_REPAIR_INFO 0x0C // passing various data to clients indicating their repair status
448 #define CARGO_REVEALED 0x0E // cargo is known
449 #define SHIELD_EXPLOSION 0x0F // shield explosion
451 #define SUBSYSTEM_DESTROYED 0x10 // update about a subsystem update
452 #define MISSION_SYNC_DATA 0x11 // this is a unique packet from the host to the server in a standalone game
453 #define STORE_MISSION_STATS 0x12 // sent to client indicating the host has hit "accept" and they should update their alltime stats
454 #define DEBRIS_UPDATE 0x13 // debris position, velocity, orientation, etc update
455 #define SHIP_WSTATE_CHANGE 0x14 // used to tell clients that a ship's primary/secondary state changed
456 #define WSS_REQUEST_PACKET 0x15 // from client to server, requesting to do an operation
457 #define WSS_UPDATE_PACKET 0x16 // from server to client, given any update
458 #define KICK_PLAYER 0x17 // kick a specific player (sent to server by those who are allowed to do this)
459 #define MISSION_GOAL_INFO 0x18 // update of mission goal info
460 #define ASTEROID_INFO 0x19 // update of asteroid stuff
461 #define NETPLAYER_PAIN 0x1A // to notify the player of hits which he may not otherwise see
462 #define OBJECT_UPDATE_NEW 0x1B
463 #define SUBSYS_CARGO_REVEALED 0X1C // Capital ship cargo subsystem is known
465 #define POST_SYNC_DATA 0x20 // a very large packet containing all the data players will need before going into the mission itself
466 #define PLAYER_SETTINGS 0x21 // player settings for each individual net player
467 #define WSS_SLOTS_DATA 0x22 // all weapon slots information for the starting wings (needs to be synched)
468 #define PLAYER_STATS 0x23 // stats for a given player
469 #define SLOT_UPDATE 0x24 // an player slot position update in multiplayer ship/team select
470 #define TEAM_UPDATE 0x25 // used for performing misc operations on pregame interface screens for team vs. team games
471 #define INGAME_EXTRA 0x26 // extra data for ingame joiners
472 #define HOST_RESTR_QUERY 0x27 // query the host when a player joins a restricted game
473 #define OPTIONS_UPDATE 0x28 // options (netgame or local) update packet
474 #define CLIENT_UPDATE 0x29 // sent from server to client periodically to update important info (pause status, etc)
475 #define CD_VERIFY 0x2A // cd verification update
476 #define PRIMARY_FIRED_NEW 0x2B // for client-side firing - highly streamlined
477 #define COUNTERMEASURE_NEW 0x2C // for client-side firing
478 #define EVENT_UPDATE 0x2D // event change
480 #define SECONDARY_FIRED_AI 0xA0 // fired a secondary weapon (ai ship)
481 #define SECONDARY_FIRED_PLR 0xA1 // fired a secondary weapon (player ship)
482 #define COUNTERMEASURE_FIRED 0xA2 // countermeasure was fired
483 #define FIRE_TURRET_WEAPON 0xA3 // a turret weapon was fired
484 #define SHIP_STATUS_CHANGE 0xA4 // any of the relevant ship status buttons have been hit (need ack from server)
485 #define PLAYER_ORDER_PACKET 0xA5 // ship and wing commands sent from client to server
486 #define AI_INFO_UPDATE 0xA6 // update ai information for the given ship
487 #define CAMPAIGN_UPDATE 0xA7 // one of several campaign informational packets
488 #define CAMPAIGN_UPDATE_INGAME 0xA8 // campaign info for ingame joiner
489 #define HOMING_WEAPON_UPDATE 0xA9 // update homing object and subsystem for homing missile
490 #define FLAK_FIRED 0xAA // flak gun fired
491 #define SELF_DESTRUCT 0xAB // self destruct
493 #define JOIN 0xB1 // a join request to a server
494 #define ACCEPT 0xB2 // acceptance of a join packet
495 #define DENY 0xB3 // a join request is denied
496 #define NOTIFY_NEW_PLAYER 0xB4 // notify players of a new player
497 #define MISSION_REQUEST 0xB5 // request a list of missions on the master.
498 #define MISSION_ITEM 0xB6 // a bundle of mission filenames
499 #define GAME_INFO 0xB7 // game information packet for an active server
500 #define MULTI_PAUSE_REQUEST 0xB8 // send a request to the server to pause or unpause the game
501 #define TRANSFER_HOST 0xB9 // transfer host status to the receiver
502 #define CHANGE_SERVER_ADDR 0xBA // change your host_addr to this value
503 #define ACCEPT_PLAYER_DATA 0xBB // player data -- sent after guy is accepted
504 #define BEAM_FIRED 0xBC // a beam weapon was fired
505 #define SW_STD_QUERY 0xBD // query from host to standalone server to query PXO about a squad war match
507 #define HUD_MSG 0xC1 // a hud message
508 #define LEAVE_GAME 0xC2 // indication that a player is leaving the game
509 #define GAME_CHAT 0xC3 // this chat packet used for Freespace
510 #define MISSION_MESSAGE 0xC4 // a message (squadmate, etc)
511 #define SHIP_DEPART 0xC5 // a ship has left the building
512 #define SHIPS_INGAME_PACKET 0xC6 // ingame join ship data packet
513 #define WINGS_INGAME_PACKET 0xC7 // ingame join wing data packet
514 #define MISSION_END 0xC8 // sent from host(master) to clients indicating they should go to the debriefing
515 #define INGAME_NAK 0xC9 // opposite of INGAME_ACK. Uses the ACK_* defines as well.
516 #define OBSERVER_UPDATE 0xCA // sent from observers to server to give position and orientation
517 #define SQUADMSG_PLAYER 0xCB // a squadmate message command has been sent to a netplayer
518 #define OBJ_UPDATE_SYNC 0xCC // object update timebase syncing code
520 #define WEAPON_DET 0xD1 // a weapon has detonated, possibly with child weapons
521 #define SHIP_KILL 0xD2 // a ship was killed
522 #define WING_CREATE 0xD3 // create and warp in a wing of ships
523 #define SHIP_CREATE 0xD4 // create and wrap in a ship
524 #define PING 0xD5 // ping
525 #define PONG 0xD6 // pong
526 #define XFER_PACKET 0xD7 // file xfer data of one kind or another
527 #define VOICE_PACKET 0xD8 // a voice streaming packet of one kind or another
528 #define NETGAME_END_ERROR 0xD9 // the netgame has been ended by the server because of an error (passed error code)
529 #define COUNTERMEASURE_SUCCESS 0xDA // countermeasure was successful for this player.
530 #define REINFORCEMENT_AVAIL 0xDB // a reinforcement is available
531 #define LIGHTNING_PACKET 0xDC // lightning bolt packet for multiplayer nebula
532 #define BYTES_SENT 0xDD // how much data we've sent/received
534 #define GAME_ACTIVE 0xE1 // info on an active game server
535 #define GAME_QUERY 0xE2 // request for a list of active game servers
536 #define GAME_UPDATE 0xE3 // update info on an active game server
537 #define NETPLAYER_UPDATE 0xE4 // a player update packet
538 #define OBJECT_UPDATE 0xE6 // an object update packet from server to all clients
539 #define MISSION_LOG_ENTRY 0xE7 // ad an item into the mission log
540 #define UPDATE_DESCRIPT 0xE8 // update the netgame description
541 #define COUNTDOWN 0xE9 // countdown timer for starting a game (pretty benign)
542 #define DEBRIEF_INFO 0xEA // end of mission debriefing information
543 #define EMP_EFFECT 0xEB // EMP effect (mission disk only)
544 #define CHANGE_IFF 0xEC // change iff (1.04+ only)
546 #define MAX_TYPE_ID 0xFF // better not try to send > 255 in a single byte buddy
548 // ingame ack data codes
549 #define ACK_RESPAWN_POINTS 0x1 // from ingame joiner to server, indicating he got the respawn points packet
550 #define ACK_FILE_ACCEPTED 0x2 // server to client saying their file is valid
551 #define ACK_FILE_REJECTED 0x3 // server to client saying their file is not valid
553 // join request denial codes
554 #define JOIN_DENY_JR_STATE 0 // join request is rejected because the game is not in the proper state
555 #define JOIN_DENY_JR_TRACKER_INVAL 1 // join request is rejected because the game is an MT game and the passed player info is invalid
556 #define JOIN_DENY_JR_PASSWD 2 // join request is rejected because the game is password protected and the password sent is incorrect
557 #define JOIN_DENY_JR_CLOSED 3 // join request is rejected because the game is closed and is currently ingame
558 #define JOIN_DENY_JR_RANK_HIGH 4 // join request is rejected because the game is rank based and the passed rank is too high
559 #define JOIN_DENY_JR_RANK_LOW 5 // join request is rejected because the game is rank based and the passed rank is too low
560 #define JOIN_DENY_JR_DUP 6 // join request is denied because there is an exiting netplayer with matching characteristics
561 #define JOIN_DENY_JR_FULL 7 // join request is denied because the game is full
562 #define JOIN_DENY_JR_TEMP_CLOSED 8 // join request is denied because the _forming_ netgame has been toggled closed
563 #define JOIN_DENY_JR_BANNED 9 // join request is denied because the player has been banned for the duration of the game
564 #define JOIN_DENY_JR_NOOBS 10 // join request is denied because observers are not allowed
565 #define JOIN_DENY_JR_INGAME_JOIN 11 // join request is denied because someone else is already ingame joining
566 #define JOIN_DENY_JR_BAD_VERSION 12 // incompatible version types
567 #define JOIN_QUERY_RESTRICTED 13 // poll the host of the game to see if he accepts this player
568 #define JOIN_DENY_JR_TYPE 14 // cannot ingame join anything but dogfight games
571 #define REPAIR_INFO_BEGIN 0x1 // server to client - set your REPAIRING flags
572 #define REPAIR_INFO_END 0x2 // server to client - unset your REPAIRING flags
573 #define REPAIR_INFO_UPDATE 0x3 // server to client - here's some repair update info (not currently used)
574 #define REPAIR_INFO_QUEUE 0x4 // server to client - client is queued for rearming.
575 #define REPAIR_INFO_ABORT 0x5 // server to client - client has aborted a rearm/repair
576 #define REPAIR_INFO_BROKEN 0x6 // server to client - client is breaking repair -- might be reestablished
577 #define REPAIR_INFO_WARP_ADD 0x7 // server to client - add client onto list of people for arriving support ship
578 #define REPAIR_INFO_WARP_REMOVE 0x8 // server to client - remove client from list of people for arriving support ship
579 #define REPAIR_INFO_ONWAY 0x9 // server to client - repair ship on way
580 #define REPAIR_INFO_KILLED 0xa // server to client - repair ship was killed on way to rearm player
581 #define REPAIR_INFO_COMPLETE 0xb // server to client - repair of your ship is complete
583 // debris update codes
584 #define DEBRIS_UPDATE_UPDATE 0x1 // update a piece
585 #define DEBRIS_UPDATE_REMOVE 0x2 // remove a piece of debris
586 #define DEBRIS_UPDATE_NUKE 0x3 // blow up a piece of debris
587 #define DEBRIS_UPDATE_CREATE_HULL 0x4 // create a piece of debris
589 // weapon select/ship select update packets
590 #define WSS_WEAPON_SELECT 0x1 // ship select stuff
591 #define WSS_SHIP_SELECT 0x2 // weapon select stuff
593 // accept packet codes
594 #define ACCEPT_INGAME (1<<0) // accept the player as an ingame joiner
595 #define ACCEPT_HOST (1<<1) // accept the player as the host of the game
596 #define ACCEPT_OBSERVER (1<<2) // accept the player as an observer
597 #define ACCEPT_CLIENT (1<<3) // accept the player as a normal, non ingame join, non host player
599 // accept player data codes
600 #define APD_NEXT 0 // there is still more player data
601 #define APD_END_PACKET 1 // end of this packet
602 #define APD_END_DATA 2 // end of the data
604 // ingame ship request codes
605 #define INGAME_SR_REQUEST 0x1 // request for the ship with the given net signature
606 #define INGAME_SR_CONFIRM 0x2 // confirmation to the client that he can use the requested ship
607 #define INGAME_SR_DENY 0x3 // deny the request the ingame joiner made for the ship
608 #define INGAME_PLAYER_CHOICE 0x4 // sent to other players informing them of ingame joiners choice
610 // ai info update codes
611 #define AI_UPDATE_DOCK 0x1 // server tells clients which ships are now docked
612 #define AI_UPDATE_UNDOCK 0x2 // server tells clients which ships have undocked
613 #define AI_UPDATE_ORDERS 0x3 // server tells clients about new AI order for the ship
615 // requests to the standalong
616 #define MISSION_LIST_REQUEST 0x1 // ask for list of missions
617 #define CAMPAIGN_LIST_REQUEST 0x2 // ask for list of campaigns
620 #define ASTEROID_CREATE 0x1 // create an asteroid
621 #define ASTEROID_THROW 0x2 // throw an asteroid
622 #define ASTEROID_HIT 0x3 // asteroid hit occured
624 // commands for squadmate messages
625 #define SQUAD_MSG_SHIP 0x1
626 #define SQUAD_MSG_WING 0x2
627 #define SQUAD_MSG_ALL 0x3
628 #define SQUAD_MSG_REINFORCEMENT 0x4
630 // SW_STD_QUERY codes
631 #define SW_STD_START 0x1 // from host to standalone saying "query the tracker"
632 #define SW_STD_OK 0x2 // from standalone to host - "everything is cool"
633 #define SW_STD_BAD 0x3 // from standalone to host - "everything is bad"
635 // stats block packet
636 #define STATS_MISSION 0 // all stats for the mission, for one player
637 #define STATS_ALLTIME 1 // alltime stats, for one player
638 #define STATS_MISSION_KILLS 2 // mission kills and assists
639 #define STATS_DOGFIGHT_KILLS 3 // same as mission kills, but also sends per-player kills
642 // ----------------------------------------------------------------------------------------
645 // ----------------------------------------------------------------------------------------
646 // Multiplayer structure definitions
650 // definition of header packet used in any protocol
651 typedef struct header {
652 int bytes_processed; // used to determine how many bytes this packet was
653 ubyte net_id[4]; // obtained from network layer header
654 ubyte addr[6]; // obtained from network-layer header
655 short port; // obtained from network-layer header
656 short id; // will be stuffed with player_id (short)
659 // NETPLAYER INFORMATION THE SERVER AND THE INDIVIDUAL CLIENT MUST HAVE
660 typedef struct net_player_server_info {
661 ping_struct ping; // evaluated by the ping module
662 int wing_index_backup; // in case of fail on the last packet
663 int wing_index; // index of the next wing data item to be sent
664 int ingame_join_flags; // status flags for an ingame joiner
665 int invul_timestamp; // invulnerability flag timestamp (for respawning after dying)
666 button_info last_buttons[BUTTON_INFO_SAVE_COUNT]; // button info for sending critical control packets to the server
667 int last_buttons_id[BUTTON_INFO_SAVE_COUNT]; //
668 fix last_buttons_time[BUTTON_INFO_SAVE_COUNT];//
669 int num_last_buttons; //
670 fix last_full_update_time; // time when server last updated this player position/orientation
671 int xfer_handle; // handle to the file xfer handle (-1 if no file xfer is taking place)
672 int kick_timestamp; // timestamp with which we'll disconnect a player if he hasn't reponded to a kick packet
673 int kick_reason; // reason he was kicked
674 int voice_token_timestamp; // timestamp set when a player loses a token (so we can prevent him from getting it again too quickly)
675 time_t reliable_connect_time; // after sending an accept packet, wait for this long for the guy to connect on the reliable socket
677 // weapon select/linking information (maintained on the server and passed on respawn to all clients)
678 char cur_primary_bank; // currently selected primary bank
679 char cur_secondary_bank; // currently selected secondary bank
680 ubyte cur_link_status; // if (1<<0) - primaries linked. if (1<<1) - secondaries are linked
682 // information regarding the current view position of this player.
683 vector eye_pos; // eye position and orientation
687 ushort ship_ets; // ets settings (sigh......)
689 // tracker information
690 int tracker_security_last; // this is the value returned when getting tracker data. it must be used when "sending" tracker data
691 unsigned int tracker_checksum; // tracker checksum
693 // common targeting information
696 // rate limiting information
697 int rate_stamp; // rate limiting timestamp
698 int rate_bytes; // bytes sent this "second"
700 // firing info (1<<0) for primary fire, (1<<1) for secondary fired, (1<<2) for countermeasure fired, (1<<3) for afterburner on
701 // basically, we set these bits if necessary between control info sends from the client. once sent, these values are
702 // cleared until the next send time
705 // buffered packet info
706 ubyte unreliable_buffer[MAX_PACKET_SIZE]; // buffer used to buffer unreliable packets before sending as a single UDP packet
707 int unreliable_buffer_size; // length (in bytes) of data in unreliable send_buffer
708 ubyte reliable_buffer[MAX_PACKET_SIZE]; // buffer used to buffer reliable packets before sending as a single UDP packet
709 int reliable_buffer_size; // length (in bytes) of data in reliable send_buffer
710 } net_player_server_info;
712 // NETPLAYER INFORMATION ALL COMPUTERS IN THE GAME MUST HAVE
713 typedef struct net_player_info {
714 p_object *p_objp; // pointer to parse object for my ship -- used with respawns
715 int team; // valid for team v. team games -- which team is this guy on
716 int ship_index; // index into the ship choices in team select/ship select (out of 12 choices)
717 int ship_class; // the ship class of the players ship
718 multi_local_options options; // players options settings
720 char pxo_squad_name[LOGIN_LEN]; // PXO squadron name
723 // NETPLAYER COMMON INFORMATION
724 typedef struct net_player {
725 player_t *player; // stuff pertaining directly to the player (callsign, etc).
726 short player_id; // player id (always use this instead of ip address for identification purposes)
727 int tracker_player_id; // the tracker id for this player, only matters in
729 int flags; // tells us interesting information about this player
730 int state; // one of the NETGAME_STATE_* flags below -- used for sequencing
731 PSNET_SOCKET_RELIABLE reliable_socket; // reliable socket to server
733 ushort client_cinfo_seq; // sequence # for client control info packets
734 ushort client_server_seq; // sequence # for incoming object update packets
736 fix last_heard_time; // time when last heard from this player
738 net_player_server_info s_info; // server critical info
739 net_player_info p_info; // player critical info
741 // bytes sent and received
743 int sv_bytes_sent; // bytes we've sent to this guy (on the server)
744 int sv_last_pl; // packet loss
747 int cl_bytes_recvd; // bytes we've received (as a client)
748 int cl_last_pl; // packet loss
751 // structure which describes the state of the multiplayer game currently being played
752 typedef struct netgame_info {
753 char name[MAX_GAMENAME_LEN+1]; // name of the netgame (host can set this!)
754 char mission_name[NAME_LENGTH+1]; // current mission name (filename)
755 char title[NAME_LENGTH+1]; // title of the mission (as appears in the mission file)
756 char campaign_name[NAME_LENGTH+1]; // current campaign name
757 char passwd[MAX_PASSWD_LEN+1]; // password for the game
758 int version_info; // version info for this game.
759 int type_flags; // see NG_TYPE_* defines
760 int mode; // see NG_MODE_* defines
761 int flags; // see NG_FLAG_* defines
762 int rank_base; // used to compare against connecting players (rank above/rank below)
764 int game_state; // state (briefing, in mission, etc) this game is in
765 int security; // some random number that should hopefully be unique for each game started
766 // I'm also using this value to use as a starting base for the net_signature
767 // for object synchronization.
768 float ping_time; // ping time to this server
769 net_addr_t server_addr; // address of the server
771 net_player *server; // pointer to the server
775 int campaign_mode; // 0 == single mission mode, 1 == starting campaign
777 ushort server_update_seq; // the current object update reference count (server-side only)
778 int server_update_frame_ref; // used to determine when we should increment the server_update_seq value
780 multi_server_options options; // server options settings
782 ubyte debug_flags; // special debug flags (see NETD_FLAG_* defines)
785 // netgame debug flags
786 // #define NETD_FLAG_CLIENT_FIRING (1<<0) // client side firing of primaries and countermeasures
787 // #define NETD_FLAG_CLIENT_NODAMAGE (1<<1) // client never applies damage himself. he simply waits for blanket updates
788 #define NETD_FLAG_OBJ_NEW (1<<2) // new style of object updating
790 // structure for active games -- kind of like Descent, but using the linked list thing, we will
791 // be able to support many more games in the list.
792 #define AG_FLAG_COOP (1<<0) // is a coop game
793 #define AG_FLAG_TEAMS (1<<1) // is a team vs. team game
794 #define AG_FLAG_DOGFIGHT (1<<2) // is a dogfight game
795 #define AG_FLAG_FORMING (1<<3) // game is currently forming
796 #define AG_FLAG_BRIEFING (1<<4) // game is in the briefing state
797 #define AG_FLAG_DEBRIEF (1<<5) // game is in the debriefing state
798 #define AG_FLAG_PAUSE (1<<6) // game is paused
799 #define AG_FLAG_IN_MISSION (1<<7) // game is in mission
800 #define AG_FLAG_PASSWD (1<<8) // is a password protected game
801 #define AG_FLAG_STANDALONE (1<<9) // this is a standalone server
802 #define AG_FLAG_CAMPAIGN (1<<10) // the server is playing in campaign mode
804 // flags for defining the connection speed
805 #define AG_FLAG_CONNECTION_SPEED_MASK ((1<<12)|(1<<13)|(1<<14)) // mask for the connection speed
807 #define AG_FLAG_VALID_MISSION (1<<15) // the mission is a "valid" tracker mission
809 #define AG_FLAG_CONNECTION_BIT 12 // number of bits to shift right or left to get speed
811 #define AG_FLAG_TYPE_MASK (AG_FLAG_COOP|AG_FLAG_TEAMS|AG_FLAG_DOGFIGHT)
812 #define AG_FLAG_STATE_MASK (AG_FLAG_FORMING|AG_FLAG_BRIEFING|AG_FLAG_DEBRIEF|AG_FLAG_PAUSE|AG_FLAG_IN_MISSION)
814 typedef struct active_game {
815 active_game *next, *prev; // next and previous elements in the list
816 int heard_from_timer; // when we last heard from the game
818 char name[MAX_GAMENAME_LEN+1];
819 char mission_name[NAME_LENGTH+1];
820 char title[NAME_LENGTH+1];
822 net_addr_t server_addr;
823 ushort flags; // see above AG_FLAG_* defines
824 ubyte version,comp_version; // version and compatible version
825 ping_struct ping; // ping time to the server
828 // permanent server list (read from tcp.cfg)
829 typedef struct server_item {
830 server_item *next, *prev;
832 net_addr_t server_addr;
835 // sent to the server on a join request with various data
836 #define JOIN_FLAG_AS_OBSERVER (1<<0) // wants to join as an aboserver
837 #define JOIN_FLAG_HAS_CD (1<<1) // currently has a CD in the drive
838 #define JOIN_FLAG_HAXOR (1<<2) // if the player has hacked data
839 typedef struct join_request {
840 char passwd[MAX_PASSWD_LEN+1]; // password for a password protected game
841 char callsign[CALLSIGN_LEN+1]; // player's callsign
842 char image_filename[MAX_FILENAME_LEN+1]; // player's image filename
843 char squad_filename[MAX_FILENAME_LEN+1]; // player's squad filename
844 ubyte player_rank; // the rank of the requesting player
845 ubyte flags; // misc flags associated with this guy
846 int tracker_id; // player's tracker ID #
847 multi_local_options player_options; // player's options
848 ubyte version, comp_version; // local version and comp_version
850 // multiplayer squad war info
851 char pxo_squad_name[LOGIN_LEN]; // squad name
854 // network buffer for sending and receiving packets
855 typedef struct network_buffer {
856 int size; // size of the buffer
857 ubyte data[MAX_PACKET_SIZE]; // MAX_PACKET_SIZE from psnet.h
859 // -------------------------------------------------------------------------------------
862 // ----------------------------------------------------------------------------------------
863 // Multiplayer structure flags/settings
867 // flags used for the net_player structure
868 #define NETINFO_FLAG_CONNECTED (1<<0) // if this player connected
869 #define NETINFO_FLAG_AM_MASTER (1<<1) // is this player the master
870 #define NETINFO_FLAG_MT_CONNECTED (1<<2) // if everything is hunky dory with the tracker connection
871 #define NETINFO_FLAG_MT_FAILED (1<<3) // all attempts to connect have failed
872 #define NETINFO_FLAG_MT_STARTUP (1<<4) // the initial state (ie, we haven't tried anything yet)
873 #define NETINFO_FLAG_GAME_HOST (1<<5) // I'm the host
874 #define NETINFO_FLAG_INGAME_JOIN (1<<6) // means he is still in the process of joining ingame
875 #define NETINFO_FLAG_OBSERVER (1<<7) // means he's an observer
876 #define NETINFO_FLAG_OBS_PLAYER (1<<8) // means he's an observer, but he was formerly a player (should show his stats)
877 #define NETINFO_FLAG_LIMBO (1<<9) // (client side) means he has to choose whether to be an observer or quit (no more respawns)
878 #define NETINFO_FLAG_MISSION_OK (1<<10) // this client's mission has been verified
879 #define NETINFO_FLAG_RESPAWNING (1<<11) // so that we wait on a keypress, or other user input before respawning
880 #define NETINFO_FLAG_DO_NETWORKING (1<<12) // set when we can send/receive data
881 #define NETINFO_FLAG_TEAM_LOCKED (1<<13) // if this is set, only the host can modify the team settings for this player
882 #define NETINFO_FLAG_TEAM_CAPTAIN (1<<14) // this player is the captain of his team
883 #define NETINFO_FLAG_KICKED (1<<15) // this player was kicked
884 #define NETINFO_FLAG_ACCEPT_INGAME (1<<16) // accepted ingame
885 #define NETINFO_FLAG_ACCEPT_HOST (1<<17) // accetped as host
886 #define NETINFO_FLAG_ACCEPT_OBSERVER (1<<18) // accepted as observer
887 #define NETINFO_FLAG_ACCEPT_CLIENT (1<<19) // accepted as client
888 #define NETINFO_FLAG_WARPING_OUT (1<<20) // clients keep track of this for themselves to know if they should be leaving
889 #define NETINFO_FLAG_HAS_CD (1<<21) // the player has a CD in the drive
890 #define NETINFO_FLAG_RELIABLE_CONNECTED (1<<22) // reliable socket is now active
891 #define NETINFO_FLAG_MT_GET_FAILED (1<<23) // set during MT stats update process indicating we didn't properly get his stats
892 #define NETINFO_FLAG_MT_SEND_FAILED (1<<24) // set during MT stats update process indicating we didn't properly send his stats
893 #define NETINFO_FLAG_MT_DONE (1<<25) // set when a player has been processed for stats (fail, succeed, or otherwise)
894 #define NETINFO_FLAG_HAXOR (1<<26) // the player has some form of hacked client data
896 #define NETPLAYER_IS_OBSERVER(player) (player->flags & (NETINFO_FLAG_OBSERVER|NETINFO_FLAG_OBS_PLAYER))
897 #define NETPLAYER_IS_DEAD(player) (player->flags & (NETINFO_FLAG_LIMBO|NETINFO_FLAG_RESPAWNING))
900 #define NG_MODE_OPEN 1 // an open game
901 #define NG_MODE_CLOSED 2 // a closed game
902 #define NG_MODE_PASSWORD 3 // a password protected game
903 #define NG_MODE_RESTRICTED 4 // a restricted game
904 #define NG_MODE_RANK_ABOVE 5 // ranks above a certain rank are allowed
905 #define NG_MODE_RANK_BELOW 6 // ranks below a certain rank are allowed
907 // netgame option flags
908 #define NG_FLAG_TEMP_CLOSED (1<<0) // a forming netgame is temporarily closed (should not be checked otherwise)
909 #define NG_FLAG_SERVER_LOST (1<<1) // client has temporarily lost contact with the server
910 #define NG_FLAG_INGAME_JOINING (1<<2) // someone is ingame joining.
911 #define NG_FLAG_INGAME_JOINING_CRITICAL (1<<3) // someone is ingame joining and at the critical point where we cannot do certain things.
912 #define NG_FLAG_STORED_MT_STATS (1<<4) // stored tracker stats in the debriefing already
913 #define NG_FLAG_HACKED_SHIPS_TBL (1<<5) // set when the server is playing with a hacked ships.tbl (only needed to notify hosts playing on a standalone)
914 #define NG_FLAG_HACKED_WEAPONS_TBL (1<<6) // set when the server is playing with a hacked weapons.tbl (only needed to notify hosts playing on a standalone)
916 // netgame type flags
917 #define NG_TYPE_COOP (1<<0) // cooperative mode
918 #define NG_TYPE_TVT (1<<1) // team vs. team mode
919 #define NG_TYPE_SW (1<<2) // squad war
920 #define NG_TYPE_TEAM ( NG_TYPE_TVT | NG_TYPE_SW )
921 #define NG_TYPE_DOGFIGHT (1<<3) // plain old dogfight mode
923 // state defines for netgame states
924 #define NETGAME_STATE_FORMING 1 // players are joining, host is selecting missions, etc
925 #define NETGAME_STATE_BRIEFING 2 // players are reading the mission briefing
926 #define NETGAME_STATE_IN_MISSION 3 // the mission itself is being played
927 #define NETGAME_STATE_SERVER_TRANSFER 4 // server status is being transferred from one computer to another
928 #define NETGAME_STATE_PAUSED 5 // the netgame is paused
929 #define NETGAME_STATE_DEBRIEF 6 // the debriefing screen
930 #define NETGAME_STATE_MISSION_SYNC 7 // client/server data sync screens before and after the briefing stage
931 #define NETGAME_STATE_ENDGAME 8 // game is moving from gameplay to the debriefing state
932 #define NETGAME_STATE_STD_HOST_SETUP 9 // the host is on the setup netgame screen for the standalone server
933 #define NETGAME_STATE_HOST_SETUP 10 // the host is on the setup netgame screen _non_ standalone
935 // state defines for netplayer states
936 #define NETPLAYER_STATE_JOINING 0 // joining the netgame
937 #define NETPLAYER_STATE_JOINED 1 // has joined and opened a reliable socket connection
938 #define NETPLAYER_STATE_MISSION_LOADING 2 // in the process of loading the mission
939 #define NETPLAYER_STATE_MISSION_LOADED 3 // mission loaded
940 #define NETPLAYER_STATE_BRIEFING 4 // in the briefing
941 #define NETPLAYER_STATE_SHIP_SELECT 5 // in the ship selection screen
942 #define NETPLAYER_STATE_WEAPON_SELECT 6 // in the weapon selection screen
943 #define NETPLAYER_STATE_DATA_LOAD 7 // loading specific data (textures, etc)
944 #define NETPLAYER_STATE_WAITING 8 // waiting to do something (like enter the mission)
945 #define NETPLAYER_STATE_SLOT_ACK 9 // got player ship slot packets
946 #define NETPLAYER_STATE_IN_MISSION 10 // in the mission itself
947 #define NETPLAYER_STATE_INGAME_SHIPS 11 // player is receiving ingame join ship data
948 #define NETPLAYER_STATE_INGAME_WINGS 12 // player is receiving ingame join wing data
949 #define NETPLAYER_STATE_INGAME_RPTS 13 // player is receiving ingame join respawn data
950 #define NETPLAYER_STATE_INGAME_SHIP_SELECT 14 // player is in the ship select screen for ingame join
951 #define NETPLAYER_STATE_DEBRIEF 15 // player is in the debrief state (screen)
952 #define NETPLAYER_STATE_MISSION_SYNC 16 // player is in the mission sync screen
953 #define NETPLAYER_STATE_STD_HOST_SETUP 17 // the host is on the setup netgame screen for the standalone server
954 #define NETPLAYER_STATE_HOST_SETUP 18 // the host is on the setup netgame screen _non_ standalone
955 #define NETPLAYER_STATE_SETTINGS_ACK 19 // the player has received the player settings data for all players
956 #define NETPLAYER_STATE_SLOTS_ACK 20 // the player has received wss slots data (ingame join only)
957 #define NETPLAYER_STATE_POST_DATA_ACK 21 // the player has received the post briefing data block
958 #define NETPLAYER_STATE_WSS_ACK 22 // have received weapon slot information
959 #define NETPLAYER_STATE_FLAG_ACK 23 // the player has received his flag change information
960 #define NETPLAYER_STATE_MT_STATS 24 // the server is in the process of requesting or updating stats from the MT
961 #define NETPLAYER_STATE_MISSION_XFER 25 // the player is in the process of receiving a mission file
962 #define NETPLAYER_STATE_INGAME_STUFF 26 // received ingame "stuff" happens just before ship selection
963 #define NETPLAYER_STATE_DEBRIEF_ACCEPT 27 // the player has hit the accept button in the debrief and is good to go
964 #define NETPLAYER_STATE_DEBRIEF_REPLAY 28 // set on the host instead of NETPLAYER_STATE_DEBRIEF_ACCEPT to indicate he wants to replay the mission
965 #define NETPLAYER_STATE_CPOOL_ACK 29 // player has acked all campaign pool status data
966 #define NETPLAYER_STATE_INGAME_CINFO 30 // player has received campaign information (ingame join only)
968 // defines for connection speed
969 #define CONNECTION_SPEED_NONE -1 // not really used except for error checking
971 #define CONNECTION_SPEED_288 0
972 #define CONNECTION_SPEED_56K 1
973 #define CONNECTION_SPEED_SISDN 2
974 #define CONNECTION_SPEED_CABLE 3
975 #define CONNECTION_SPEED_T1 4
977 // use this to check and see whether a netgame is anywhere in mission (paused, etc, etc)
978 #define MULTI_IN_MISSION ( (Netgame.game_state == NETGAME_STATE_IN_MISSION) || (Netgame.game_state == NETGAME_STATE_PAUSED) )
980 extern int Multi_connection_speed;
982 // -------------------------------------------------------------------------------------
985 // ----------------------------------------------------------------------------------------
986 // Multiplayer global vars
991 extern net_player Net_players[MAX_PLAYERS]; // array of all netplayers in the game
992 extern net_player *Net_player; // pointer to console's net_player entry
994 // network object management
995 #define SHIP_SIG_MIN 1
996 #define SHIP_SIG_MAX (0x2fff)
998 #define STANDALONE_SHIP_SIG (SHIP_SIG_MAX+1)
999 #define REAL_SHIP_SIG_MAX (0x3fff)
1001 #define DEBRIS_SIG_MIN (REAL_SHIP_SIG_MAX+1)
1002 #define DEBRIS_SIG_MAX (0x5fff)
1004 #define ASTEROID_SIG_MIN (DEBRIS_SIG_MAX+1)
1005 #define ASTEROID_SIG_MAX (0x7fff)
1007 #define NPERM_SIG_MIN (ASTEROID_SIG_MAX+1)
1008 #define NPERM_SIG_MAX (0xffff)
1010 extern ushort Next_ship_signature; // next network signature to assign to an object
1011 extern ushort Next_asteroid_signature; // next asteroid signature
1012 extern ushort Next_non_perm_signature; // next non-permanent signature
1013 extern ushort Next_debris_signature; // next debris signature
1016 extern netgame_info Netgame; // netgame information
1017 extern int Multi_mission_loaded; // flag, so that we dont' load the mission more than once client side
1018 extern ushort Multi_ingame_join_sig; // signature for the player obj for use when joining ingame
1019 extern int Multi_button_info_ok; // flag saying it is ok to apply critical button info on a client machine
1020 extern int Multi_button_info_id; // identifier of the stored button info to be applying
1022 // low level networking vars
1023 extern int ADDRESS_LENGTH; // will be 6 for IPX, 4 for IP
1024 extern int PORT_LENGTH; // will be 2 for IPX, 2 for IP
1025 extern int HEADER_LENGTH; // 1 byte (packet type)
1028 extern active_game* Active_game_head; // linked list of active games displayed on Join screen
1029 extern int Active_game_count; // for interface screens as well
1030 extern CFILE* Multi_chat_stream; // for streaming multiplayer chat strings to a file
1031 extern int Multi_has_cd; // if this machine has a cd or not (call multi_common_verify_cd() to set this)
1032 extern int Multi_num_players_at_start; // the # of players present (kept track of only on the server) at the very start of the mission
1033 extern short Multi_id_num; // for assigning player id #'s
1035 // permanent server list
1036 extern server_item* Game_server_head; // list of permanent game servers to be querying
1038 // restricted game vars
1039 #define MULTI_QUERY_RESTR_STAMP 5000 // 5 seconds to reply
1040 #define MULTI_JOIN_RESTR_MODE_1 0 // mode 1 - normal restricted join
1041 #define MULTI_JOIN_RESTR_MODE_2 1 // mode 2 - team vs. team, only team 0 has ships
1042 #define MULTI_JOIN_RESTR_MODE_3 2 // mode 3 - team vs. team, only team 1 has ships
1043 #define MULTI_JOIN_RESTR_MODE_4 3 // mode 4 - team vs. team, both teams have ships
1045 extern int Multi_restr_query_timestamp; // timestamp for querying the host to see if he will allow a new player to join ingame
1046 extern join_request Multi_restr_join_request; // join request for the query
1047 extern net_addr_t Multi_restr_addr; // net address of the join request
1048 extern int Multi_join_restr_mode; // what mode we're in
1050 // non API master tracker vars
1051 extern char Multi_tracker_login[100];
1052 extern char Multi_tracker_passwd[100];
1053 extern char Multi_tracker_squad_name[100];
1054 extern int Multi_tracker_id;
1055 extern char Multi_tracker_id_string[255];
1057 // current file checksum
1058 extern ushort Multi_current_file_checksum;
1059 extern int Multi_current_file_length;
1062 // ----------------------------------------------------------------------------------------
1063 // Multiplayer main functions
1067 // module handling functions -------------------
1069 // called at game startup
1072 // called whenever a netgame is started
1073 void multi_level_init();
1075 // reset all relevant main networking loop timestamps
1076 void multi_reset_timestamps();
1078 // returns true is server hasn't been heard from in N seconds. false otherwise
1079 int multi_client_server_dead();
1082 // netgame data processing functions -----------
1084 // do all network processing for this game frame
1085 void multi_do_frame();
1087 // analog of multi_do_frame() called when netgame is in the pause state
1088 void multi_pause_do_frame();
1090 // process all incoming packets
1091 // void multi_process_bigdata(ubyte* data, int size, net_addr* from_addr);
1093 // process all reliable socket details
1094 void multi_process_reliable_details();
1097 // standalone handling functions ---------------
1099 // initialize the standalone
1100 void standalone_main_init();
1102 // do frame for the main standalone state
1103 void standalone_main_do();
1105 // close for the main standalone state
1106 void standalone_main_close();
1108 // reset all standalone stuff, including gui, networking, netgame, etc, and go into the main state
1109 void multi_standalone_reset_all();
1111 // init for the wait mode of the standalone (when waiting for players to finish the briefing)
1112 void multi_standalone_wait_init();
1114 // do frame for the standalone wait state (when waiting for players to finish the briefing)
1115 void multi_standalone_wait_do();
1117 // close for the standalone wait state (when waiting for players to finish the briefing)
1118 void multi_standalone_wait_close();
1120 // init for the standalone postgame state (when players are in the debriefing)
1121 void multi_standalone_postgame_init();
1123 // do frame for the standalone postgame state (when players are in the debriefing)
1124 void multi_standalone_postgame_do();
1126 // close for the standalone postgame state (when players are in the debriefing_
1127 void multi_standalone_postgame_close();