FS2_Open
Open source remastering of the Freespace 2 engine
multi.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) Volition, Inc. 1999. All rights reserved.
3  *
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 the
6  * source.
7  *
8 */
9 
10 
11 
12 
13 #include "network/multi.h"
14 #include "network/multiutil.h"
15 #include "network/multimsgs.h"
16 #include "ship/ship.h"
17 #include "io/timer.h"
18 #include "playerman/player.h"
19 #include "mission/missionparse.h"
22 #include "freespace2/freespace.h"
23 #include "osapi/osapi.h"
24 #include "network/stand_gui.h"
25 #include "network/multi_xfer.h"
26 #include "network/multiui.h"
27 #include "network/multi_ingame.h"
28 #include "popup/popup.h"
29 #include "missionui/chatbox.h"
31 #include "network/multi_data.h"
32 #include "network/multi_kick.h"
33 #include "network/multi_campaign.h"
34 #include "network/multi_voice.h"
35 #include "network/multi_team.h"
36 #include "network/multi_respawn.h"
37 #include "network/multi_pmsg.h"
38 #include "network/multi_endgame.h"
40 #include "network/multi_pause.h"
41 #include "mission/missiongoals.h"
42 #include "network/multi_log.h"
43 #include "network/multi_rate.h"
44 #include "hud/hudescort.h"
45 #include "hud/hudmessage.h"
46 #include "globalincs/alphacolors.h"
47 #include "globalincs/pstypes.h"
48 #include "cfile/cfile.h"
49 #include "fs2netd/fs2netd_client.h"
50 #include "pilotfile/pilotfile.h"
51 #include "debugconsole/console.h"
52 #include "network/psnet2.h"
53 
54 
55 
56 // ----------------------------------------------------------------------------------------
57 // Basic module scope defines
58 //
59 //
60 
61 // timestamp defines
62 #define NETGAME_SEND_TIME 2 // time between sending netgame update packets
63 #define STATE_SEND_TIME 2 // time between sending netplayer state packets
64 #define GAMEINFO_SEND_TIME 3 // time between sending game information packets
65 #define PING_SEND_TIME 2 // time between player pings
66 #define BYTES_SENT_TIME 5 // every five seconds
67 
68 // local network buffer stuff
69 #define MAX_NET_BUFFER (1024 * 16) // define and variable declaration for our local tcp buffer
70 #define NUM_REENTRANT_LEVELS 3
71 
72 // time (in fixed seconds) to put up dialog about no contect from server
73 #define MULTI_SERVER_MAX_TIMEOUT (F1_0 * 4) // after this number of milliseoncds, stop client simulation
74 #define MULTI_SERVER_MAX_TIMEOUT_LARGE (F1_0 * 40) // done anytime not in mission
75 #define MULTI_SERVER_WAIT_TIME (F1_0 * 60) // wait 60 seconds to reconnect with the server
76 #define MULTI_SERVER_GONE 1
77 #define MULTI_SERVER_ALIVE 2
78 
79 // define for when to show "slow network" icon
80 #define MULTI_SERVER_SLOW_PING_TIME 700 // when average ping time to server reaches this -- display hud icon
81 
82 // update times for clients ships based on object update level
83 #define MULTI_CLIENT_UPDATE_TIME 333
84 
86 
87 // ----------------------------------------------------------------------------------------
88 // Multiplayer vars
89 //
90 //
91 
92 // net player vars
93 net_player Net_players[MAX_PLAYERS]; // array of all netplayers in the game
94 net_player *Net_player; // pointer to console's net_player entry
95 
96 // netgame vars
97 netgame_info Netgame; // netgame information
98 int Multi_mission_loaded = 0; // flag, so that we don't load the mission more than once client side
99 int Ingame_join_net_signature = -1; // signature for the player obj for use when joining ingame
100 int Multi_button_info_ok = 0; // flag saying it is ok to apply critical button info on a client machine
101 int Multi_button_info_id = 0; // identifier of the stored button info to be applying
102 
103 // low level networking vars
106 int HEADER_LENGTH; // 1 byte (packet type)
107 
108 // misc data
109 active_game* Active_game_head; // linked list of active games displayed on Join screen
110 int Active_game_count; // for interface screens as well
111 CFILE* Multi_chat_stream; // for streaming multiplayer chat strings to a file
112 int Multi_has_cd = 0; // if this machine has a cd or not (call multi_common_verify_cd() to set this)
113 int Multi_connection_speed; // connection speed of this machine.
114 int Multi_num_players_at_start = 0; // the # of players present (kept track of only on the server) at the very start of the mission
115 short Multi_id_num = 0; // for assigning player id #'s
116 
117 // permanent server list
118 server_item* Game_server_head; // list of permanent game servers to be querying
119 
120 // timestamp data
121 int Netgame_send_time = -1; // timestamp used to send netgame info to players before misison starts
122 int State_send_time = -1; // timestamp used to send state information to the host before a mission starts
123 int Gameinfo_send_time = -1; // timestamp used by master to send game information to clients
124 int Next_ping_time = -1; // when we should next ping all
125 int Multi_server_check_count = 0; // var to keep track of reentrancy when checking server status
126 int Next_bytes_time = -1; // bytes sent
127 
128 // how often each player gets updated
129 int Multi_client_update_times[MAX_PLAYERS]; // client update packet timestamp
130 
131 // local network buffer data
134 
139 
140 LOCAL fix Multi_server_wait_start; // variable to hold start time when waiting to reestablish with server
141 
142 // non API master tracker vars
148 
149 // current file checksum
152 
153 
154 // -------------------------------------------------------------------------------------------------
155 // multi_init() is called only once, at game start-up. Get player address + port, initialize the
156 // network players list.
157 //
158 //
159 
161 {
162  int idx;
163 
164  // read in config file
166 
167  Assert( Net_player == NULL );
168  Multi_id_num = 0;
169 
170  // clear out all netplayers
171  memset(Net_players, 0, sizeof(net_player) * MAX_PLAYERS);
172  for(idx=0; idx<MAX_PLAYERS; idx++){
173  Net_players[idx].reliable_socket = INVALID_SOCKET;
174  }
175 
176  // initialize the local netplayer
177  Net_player = &Net_players[0];
178  Net_player->tracker_player_id = Multi_tracker_id;
179  Net_player->m_player = Player;
180  Net_player->flags = 0;
181  Net_player->s_info.xfer_handle = -1;
182  Net_player->player_id = multi_get_new_id();
183  Net_player->client_cinfo_seq = 0;
184  Net_player->client_server_seq = 0;
185 
186  // get our connection speed
188 
189  // initialize other stuff
190  multi_log_init();
191 
192  // load up common multiplayer icons
193  if (!Is_standalone)
195 }
196 
197 // this is an important function which re-initializes any variables required in multiplayer games.
198 // Always make sure globals you add are re-initialized here !!!!
200 {
201  // initialize this variable right away. Used in game_level_init for init'ing the player
206 
207  // server-client critical stuff
210 
211  // Ingame join stuff
213 
214  // Netgame stuff
216 
217  // team select stuff
218  Multi_ts_inited = 0;
219 
220  // load send stuff
221  Multi_mission_loaded = 0; // client side
222 
223  // restricted game stuff
225 
226  // respawn stuff
228 
229  // reentrant variable
230  Multi_read_count = 0;
231 
232  // unset the "have cd" var
233  // NOTE: we unset this here because we are going to be calling multi_common_verify_cd()
234  // immediately after this (in multi_level_init() to re-check the status)
235  Multi_has_cd = 0;
236 
237  // current file checksum
240 
241  Active_game_head = NULL;
242  Game_server_head = NULL;
243 
244  // only the server should ever care about this
245  Multi_id_num = 0;
246 }
247 
248 // -------------------------------------------------------------------------------------------------
249 // multi_level_init() is called whenever the player starts a multiplayer game
250 //
251 //
252 
254 {
255  int idx;
256 
257  // NETLOG
258  ml_string(NOX("multi_level_init()"));
259 
260  // initialize the Net_players array
261  for ( idx = 0; idx < MAX_PLAYERS; idx++) {
262  // close all sockets down just for good measure
263  psnet_rel_close_socket(&Net_players[idx].reliable_socket);
264 
265  memset(&Net_players[idx],0,sizeof(net_player));
266  Net_players[idx].reliable_socket = INVALID_SOCKET;
267 
268  Net_players[idx].s_info.xfer_handle = -1;
269  Net_players[idx].p_info.team = 0;
270  }
271 
272  // initialize the Players array
273  for (idx=0;idx<MAX_PLAYERS;idx++) {
274  if (Player == &Players[idx]) {
275  continue;
276  }
277  Players[idx].reset();
278  }
279 
280  multi_vars_init();
281 
282  // initialize the fake lag/loss system
283 #ifdef MULTI_USE_LAG
284  multi_lag_init();
285 #endif
286 
287  // initialize the kick system
288  multi_kick_init();
289 
290  // initialize all file xfer stuff
292 
293  // close the chatbox (if one exists)
294  chatbox_close();
295 
296  // reset the data xfer system
298 
299  // initialize the voice system
301 
302  // intialize the pause system
304 
305  // initialize endgame stuff
307 
308  // initialize respawning
310 
311  // initialize all netgame timestamps
313 
314  // flush psnet sockets
315  psnet_flush();
316 }
317 
318 // multi_check_listen() calls low level psnet routine to see if we have a connection from a client we
319 // should accept.
321 {
322  int i;
323  net_addr addr;
325 
326  // call psnet routine which calls select to see if we need to check for a connect from a client
327  // by passing addr, we are telling check_for_listen to do the accept and return who it was from in
328  // addr. The
329  sock = psnet_rel_check_for_listen(&addr);
330  if ( sock != INVALID_SOCKET ) {
331  // be sure that my address and the server address are set correctly.
332  if ( !psnet_same(&Psnet_my_addr, &Net_player->p_info.addr) ){
333  Net_player->p_info.addr = Psnet_my_addr;
334  }
335 
336  if ( !psnet_same(&Psnet_my_addr, &(Netgame.server_addr)) ){
337  Netgame.server_addr = Psnet_my_addr;
338  }
339 
340  // the connection was accepted in check_for_listen. Find the netplayer whose address we connected
341  // with and assign the socket descriptor.
342  // Updated to utilize psnet_same() for address comparison so the port is also taken into account.
343  // This allows multiple players using NAT to access a remote server simultneously.
344  for (i = 0; i < MAX_PLAYERS; i++ ) {
345  if ( (Net_players[i].flags & NETINFO_FLAG_CONNECTED) && (psnet_same(&addr, &(Net_players[i].p_info.addr))) ) {
346  // mark this flag so we know he's "fully" connected
347  Net_players[i].flags |= NETINFO_FLAG_RELIABLE_CONNECTED;
348  Net_players[i].reliable_socket = sock;
349 
350  // send player information to the joiner
351  send_accept_player_data( &Net_players[i], (Net_players[i].flags & NETINFO_FLAG_INGAME_JOIN)?1:0 );
352 
353  // send a netgame update so the new client has all the necessary settings
355 
356  // if this is a team vs. team game, send an update
357  if(Netgame.type_flags & NG_TYPE_TEAM){
359  }
360 
361  // NETLOG
362  ml_printf(NOX("Accepted TCP connection from %s"), Net_players[i].m_player == NULL ? NOX("Unknown") : Net_players[i].m_player->callsign);
363  break;
364  }
365  }
366 
367  // if we didn't find a player, close the socket
368  if ( i == MAX_PLAYERS ) {
369  nprintf(("Network", "Got accept on my listen socket, but unknown player. Closing socket.\n"));
370  psnet_rel_close_socket(&sock);
371  }
372  }
373 }
374 
375 // returns true is server hasn't been heard from in N seconds. false otherwise
377 {
378  fix this_time, last_time, max;
379 
380  // get the last time we have heard from the server. If greater than some default, then maybe
381  // display some icon on the HUD indicating slow network connection. if greater than some higher
382  // max, stop simulating on the client side until we hear from the server again.
383  this_time = timer_get_fixed_seconds();
384  last_time = Netgame.server->last_heard_time;
385  // check for wrap! must return 0
386  if ( last_time > this_time )
387  return 0;
388 
389  this_time -= last_time;
390 
391  // if in mission, use the smaller timeout value. Outside of mission, use a large one.
392  if ( MULTI_IN_MISSION ){
394  } else {
396  }
397 
398  if ( this_time > max){
399  return 1;
400  } else {
401  return 0;
402  }
403 }
404 
405 void multi_process_incoming(); // prototype for function later in this module
406 
407 // function to process network data in hopes of getting info back from server
409 {
410  int is_dead;
411 
412  is_dead = multi_client_server_dead();
413 
414  // if the server is back alive, tell our popup
415  if ( !is_dead ){
416  return MULTI_SERVER_ALIVE;
417  }
418 
419  // on release version -- keep popup active for 60 seconds, then bail
420 #ifdef NDEBUG
421  fix this_time = timer_get_fixed_seconds();
422  // if the timer wrapped:
423  if ( this_time < Multi_server_wait_start ) {
425  return FALSE;
426  }
427  // check to see if timeout expired
428  this_time -= Multi_server_wait_start;
429  if ( this_time > MULTI_SERVER_WAIT_TIME ){
430  return MULTI_SERVER_GONE;
431  }
432 #endif
433 
434  return FALSE;
435 }
436 
437 // function called by multiplayer clients to stop simulating when they have not heard from the server
438 // in a while.
440 {
441  int rval;
442 
444 
445  // this function can get called while in the popup code below. So we include this check as a
446  // reentrancy check.
448  return;
449 
450  // make sure we have a valid server
451  if(Netgame.server == NULL){
452  return;
453  }
454 
457  Netgame.flags |= NG_FLAG_SERVER_LOST;
458  } else {
459  Netgame.flags &= ~(NG_FLAG_SERVER_LOST);
460  }
461 
462  if(Netgame.flags & NG_FLAG_SERVER_LOST) {
463  if(!(Game_mode & GM_IN_MISSION) && !popup_active()){
464  // need to start a popup
466  rval = popup_till_condition( multi_client_wait_on_server, XSTR("Cancel",641), XSTR("Contact lost with server. Stopping simulation until contact reestablished. Press Cancel to exit game.",642) );
467 
468  if ( !rval || (rval == MULTI_SERVER_GONE) ) {
470  }
471  Netgame.flags &= ~(NG_FLAG_SERVER_LOST);
472  }
473  }
474 
476 }
477 
478 
479 // -------------------------------------------------------------------------------------------------
480 // process_packet_normal() will determine what sort of packet it is, and send it to the appropriate spot.
481 // Prelimiary verification of the magic number and checksum are done here.
482 //
483 
485 {
486  switch ( data[0] ) {
487 
488  case JOIN:
489  process_join_packet(data, header_info);
490  break;
491 
492  case GAME_CHAT:
493  process_game_chat_packet( data, header_info );
494  break;
495 
496  case NOTIFY_NEW_PLAYER:
497  process_new_player_packet(data, header_info);
498  break;
499 
500  case HUD_MSG:
501  process_hud_message(data, header_info);
502  break;
503 
504  case MISSION_MESSAGE:
505  process_mission_message_packet( data, header_info );
506  break;
507 
508  case LEAVE_GAME:
509  process_leave_game_packet(data, header_info);
510  break;
511 
512  case GAME_QUERY:
513  process_game_query(data, header_info);
514  break;
515 
516  case GAME_ACTIVE:
517  process_game_active_packet(data, header_info);
518  break;
519 
520  case GAME_INFO:
521  process_game_info_packet( data, header_info );
522  break;
523 
524  case SECONDARY_FIRED_AI:
525  process_secondary_fired_packet(data, header_info, 0);
526  break;
527 
528  case SECONDARY_FIRED_PLR:
529  process_secondary_fired_packet(data, header_info, 1);
530  break;
531 
533  process_countermeasure_fired_packet( data, header_info );
534  break;
535 
536  case FIRE_TURRET_WEAPON:
537  process_turret_fired_packet( data, header_info );
538  break;
539 
540  case GAME_UPDATE:
541  process_netgame_update_packet( data, header_info );
542  break;
543 
544  case UPDATE_DESCRIPT:
545  process_netgame_descript_packet( data, header_info );
546  break;
547 
548  case NETPLAYER_UPDATE:
549  process_netplayer_update_packet( data, header_info );
550  break;
551 
552  case ACCEPT :
553  process_accept_packet(data, header_info);
554  break;
555 
556  case OBJECT_UPDATE:
557  multi_oo_process_update(data, header_info);
558  break;
559 
560  case SHIP_KILL:
561  process_ship_kill_packet( data, header_info );
562  break;
563 
564  case WING_CREATE:
565  process_wing_create_packet( data, header_info );
566  break;
567 
568  case SHIP_CREATE:
569  process_ship_create_packet( data, header_info );
570  break;
571 
572  case SHIP_DEPART:
573  process_ship_depart_packet( data, header_info );
574  break;
575 
576  case MISSION_LOG_ENTRY:
577  process_mission_log_packet( data, header_info );
578  break;
579 
580  case PING:
581  process_ping_packet(data, header_info);
582  break;
583 
584  case PONG:
585  process_pong_packet(data, header_info);
586  break;
587 
588  case XFER_PACKET:
589  Assert(header_info->id >= 0);
590  int np_index;
592  sock = INVALID_SOCKET;
593 
594  // if I'm the server of the game, find out who this came from
595  if((Net_player != NULL) && (Net_player->flags & NETINFO_FLAG_AM_MASTER)){
596  np_index = find_player_id(header_info->id);
597  if(np_index >= 0){
598  sock = Net_players[np_index].reliable_socket;
599  }
600  }
601  // otherwise always use my own socket
602  else if(Net_player != NULL){
603  sock = Net_player->reliable_socket;
604  }
605 
607  break;
608 
609  case MISSION_REQUEST:
610  process_mission_request_packet(data,header_info);
611  break;
612 
613  case MISSION_ITEM:
614  process_mission_item_packet(data,header_info);
615  break;
616 
617  case MULTI_PAUSE_REQUEST:
618  process_multi_pause_packet(data, header_info);
619  break;
620 
621  case INGAME_NAK:
622  process_ingame_nak(data, header_info);
623  break;
624 
625  case SHIPS_INGAME_PACKET:
626  process_ingame_ships_packet(data, header_info);
627  break;
628 
629  case WINGS_INGAME_PACKET:
630  process_ingame_wings_packet(data, header_info);
631  break;
632 
633  case MISSION_END:
634  process_endgame_packet(data, header_info);
635  break;
636 
637  case FORCE_MISSION_END:
638  process_force_end_mission_packet(data, header_info);
639  break;
640 
641  case OBSERVER_UPDATE:
642  process_observer_update_packet(data, header_info);
643  break;
644 
645  case NETPLAYER_SLOTS_P:
646  process_netplayer_slot_packet(data, header_info);
647  break;
648 
649  case SHIP_STATUS_CHANGE:
650  process_ship_status_packet(data, header_info);
651  break;
652 
653  case PLAYER_ORDER_PACKET:
654  process_player_order_packet(data, header_info);
655  break;
656 
657  case INGAME_SHIP_UPDATE:
658  process_ingame_ship_update_packet(data, header_info);
659  break;
660 
661  case INGAME_SHIP_REQUEST:
662  process_ingame_ship_request_packet(data, header_info);
663  break;
664 
665  case FILE_SIG_INFO:
666  process_file_sig_packet(data, header_info);
667  break;
668 
669  case RESPAWN_NOTICE:
670  multi_respawn_process_packet(data,header_info);
671  break;
672 
673  case SUBSYSTEM_DESTROYED:
674  process_subsystem_destroyed_packet( data, header_info );
675  break;
676 
677  case LOAD_MISSION_NOW :
678  process_netplayer_load_packet(data, header_info);
679  break;
680 
681  case FILE_SIG_REQUEST :
682  process_file_sig_request(data, header_info);
683  break;
684 
685  case JUMP_INTO_GAME:
686  process_jump_into_mission_packet(data, header_info);
687  break;
688 
689  case CLIENT_REPAIR_INFO:
690  process_repair_info_packet(data,header_info);
691  break;
692 
693  case MISSION_SYNC_DATA:
694  process_mission_sync_packet(data,header_info);
695  break;
696 
697  case STORE_MISSION_STATS:
698  process_store_stats_packet(data, header_info);
699  break;
700 
701  case DEBRIS_UPDATE:
702  process_debris_update_packet(data, header_info);
703  break;
704 
705  case SHIP_WSTATE_CHANGE:
706  process_ship_weapon_change( data, header_info );
707  break;
708 
709  case WSS_UPDATE_PACKET:
710  process_wss_update_packet(data, header_info);
711  break;
712 
713  case WSS_REQUEST_PACKET:
714  process_wss_request_packet( data, header_info );
715  break;
716 
717  case FIRING_INFO:
718  process_firing_info_packet( data, header_info );
719  break;
720 
721  case CARGO_REVEALED:
722  process_cargo_revealed_packet( data, header_info);
723  break;
724 
725  case CARGO_HIDDEN:
726  process_cargo_hidden_packet( data, header_info);
727  break;
728 
730  process_subsystem_cargo_revealed_packet( data, header_info);
731  break;
732 
733  case SUBSYS_CARGO_HIDDEN:
734  process_subsystem_cargo_hidden_packet( data, header_info);
735  break;
736 
737  case MISSION_GOAL_INFO:
738  process_mission_goal_info_packet(data, header_info);
739  break;
740 
741  case KICK_PLAYER:
742  process_player_kick_packet(data, header_info);
743  break;
744 
745  case PLAYER_SETTINGS:
746  process_player_settings_packet(data, header_info);
747  break;
748 
749  case DENY:
750  process_deny_packet(data, header_info);
751  break;
752 
753  case POST_SYNC_DATA:
754  process_post_sync_data_packet(data, header_info);
755  break;
756 
757  case WSS_SLOTS_DATA:
758  process_wss_slots_data_packet(data,header_info);
759  break;
760 
761  case SHIELD_EXPLOSION:
762  process_shield_explosion_packet( data, header_info );
763  break;
764 
765  case PLAYER_STATS:
766  process_player_stats_block_packet(data, header_info);
767  break;
768 
769  case SLOT_UPDATE:
770  process_pslot_update_packet(data,header_info);
771  break;
772 
773  case AI_INFO_UPDATE:
774  process_ai_info_update_packet( data, header_info );
775  break;
776 
777  case CAMPAIGN_UPDATE :
778  multi_campaign_process_update(data,header_info);
779  break;
780 
782  multi_campaign_process_ingame_start(data,header_info);
783  break;
784 
785  case VOICE_PACKET :
786  multi_voice_process_packet(data,header_info);
787  break;
788 
789  case TEAM_UPDATE :
790  multi_team_process_packet(data,header_info);
791  break;
792 
793  case ASTEROID_INFO:
794  process_asteroid_info(data, header_info);
795  break;
796 
797  case HOST_RESTR_QUERY:
798  process_host_restr_packet(data, header_info);
799  break;
800 
801  case OPTIONS_UPDATE:
802  multi_options_process_packet(data,header_info);
803  break;
804 
805  case SQUADMSG_PLAYER:
806  multi_msg_process_squadmsg_packet(data,header_info);
807  break;
808 
809  case NETGAME_END_ERROR:
810  process_netgame_end_error_packet(data,header_info);
811  break;
812 
814  process_countermeasure_success_packet( data, header_info );
815  break;
816 
817  case CLIENT_UPDATE:
818  process_client_update_packet(data, header_info);
819  break;
820 
821  case COUNTDOWN:
822  process_countdown_packet(data, header_info);
823  break;
824 
825  case DEBRIEF_INFO:
826  process_debrief_info( data, header_info );
827  break;
828 
829  case ACCEPT_PLAYER_DATA:
830  process_accept_player_data( data, header_info );
831  break;
832 
834  process_homing_weapon_info( data, header_info );
835  break;
836 
837  case EMP_EFFECT:
838  process_emp_effect(data, header_info);
839  break;
840 
841  case REINFORCEMENT_AVAIL:
842  process_reinforcement_avail( data, header_info );
843  break;
844 
845  case CHANGE_IFF:
846  process_change_iff_packet(data, header_info);
847  break;
848 
849  case CHANGE_IFF_COLOR:
850  process_change_iff_color_packet(data, header_info);
851  break;
852 
853  case CHANGE_AI_CLASS:
854  process_change_ai_class_packet(data, header_info);
855  break;
856 
857  case PRIMARY_FIRED_NEW:
858  process_NEW_primary_fired_packet(data, header_info);
859  break;
860 
861  case COUNTERMEASURE_NEW:
862  process_NEW_countermeasure_fired_packet(data, header_info);
863  break;
864 
865  case BEAM_FIRED:
866  process_beam_fired_packet(data, header_info);
867  break;
868 
869  case SW_STD_QUERY:
870  process_sw_query_packet(data, header_info);
871  break;
872 
873  case EVENT_UPDATE:
874  process_event_update_packet(data, header_info);
875  break;
876 
877  case VARIABLE_UPDATE:
878  process_variable_update_packet(data, header_info);
879  break;
880 
882  process_weapon_or_ammo_changed_packet(data, header_info);
883  break;
884 
885  case OBJECT_UPDATE_NEW:
886  multi_oo_process_update(data, header_info);
887  break;
888 
889  case WEAPON_DET:
890  process_weapon_detonate_packet(data, header_info);
891  break;
892 
893  case FLAK_FIRED:
894  process_flak_fired_packet(data, header_info);
895  break;
896 
897  case NETPLAYER_PAIN:
898  process_player_pain_packet(data, header_info);
899  break;
900 
901  case LIGHTNING_PACKET:
902  process_lightning_packet(data, header_info);
903  break;
904 
905  case BYTES_SENT:
906  process_bytes_recvd_packet(data, header_info);
907  break;
908 
909  case TRANSFER_HOST:
910  process_host_captain_change_packet(data, header_info);
911  break;
912 
913  case SELF_DESTRUCT:
914  process_self_destruct_packet(data, header_info);
915  break;
916 
917  case SEXP:
918  process_sexp_packet(data, header_info);
919  break;
920 
921  default:
922  nprintf(("Network", "Received packet with unknown type %d\n", data[0] ));
923  header_info->bytes_processed = 10000;
924  break;
925 
926  } // end switch
927 }
928 
929 
930 
931 // Takes a bunch of messages, check them for validity,
932 // and pass them to multi_process_data.
933 // --------------------^
934 // this should be process_packet() I think, or with the new code
935 // process_tracker_packet() as defined in MultiTracker.[h,cpp]
936 void multi_process_bigdata(ubyte *data, int len, net_addr *from_addr, int reliable)
937 {
938  int type, bytes_processed;
939  int player_num;
940  header header_info;
941  ubyte *buf;
942 
943  // the only packets we will process from an unknown player are GAME_QUERY, GAME_INFO, JOIN, PING, PONG, ACCEPT, and GAME_ACTIVE packets
944  player_num = find_player(from_addr);
945 
946  // find the player who sent the message and mark the last_heard time for this player
947  // check to see if netplayer is null (it may be in cases such as getting lists of games from the tracker)
948  if(player_num >= 0){
949  Net_players[player_num].last_heard_time = timer_get_fixed_seconds();
950  }
951 
952  // store fields that were passed along in the message
953  // store header information that was captured from the network-layer header
954  memcpy(header_info.addr, from_addr->addr, 6);
955  header_info.port = from_addr->port;
956  if(player_num >= 0){
957  header_info.id = Net_players[player_num].player_id;
958  } else {
959  header_info.id = -1;
960  }
961 
962  bytes_processed = 0;
963  while( (bytes_processed >= 0) && (bytes_processed < len) ) {
964 
965  buf = &(data[bytes_processed]);
966 
967  type = buf[0];
968 
969  // if its coming from an unknown source, there are only certain packets we will actually process
970  if((player_num == -1) && !multi_is_valid_unknown_packet((ubyte)type)){
971  return ;
972  }
973 
974  if ( (type<0) || (type > MAX_TYPE_ID )) {
975  nprintf( ("Network", "multi_process_bigdata: Invalid packet type %d!\n", type ));
976  return;
977  }
978 
979  // perform any special processing checks here
980  process_packet_normal(buf,&header_info);
981 
982  // MWA -- magic number was removed from header on 8/4/97. Replaced with bytes_processed
983  // variable which gets stuffed whenever a packet is processed.
984  bytes_processed += header_info.bytes_processed;
985  }
986 
987  // if this is not reliable data and we have a valid player
988  if(Net_player != NULL){
989  if(!MULTIPLAYER_MASTER && !reliable && (Game_mode & GM_IN_MISSION)){
990  Net_player->cl_bytes_recvd += len;
991  }
992  }
993 }
994 
995 // process all reliable socket details
997 {
998  int idx;
999  int sock_status;
1000 
1001  // run reliable sockets
1002  psnet_rel_work();
1003 
1004 
1005  // server operations
1006  if ( MULTIPLAYER_MASTER ){
1007  // listen for new reliable socket connections
1008  multi_check_listen();
1009 
1010  // check for any broken sockets and delete any players
1011  for(idx=0; idx<MAX_PLAYERS; idx++){
1012  // players who _should_ be validly connected
1013  if((idx != MY_NET_PLAYER_NUM) && MULTI_CONNECTED(Net_players[idx])){
1014  // if this guy's socket is broken or disconnected, kill him
1015  sock_status = psnet_rel_get_status(Net_players[idx].reliable_socket);
1016  if((sock_status == RNF_UNUSED) || (sock_status == RNF_BROKEN) || (sock_status == RNF_DISCONNECTED)){
1017  ml_string("Shutting down rel socket because of disconnect!");
1018  delete_player(idx);
1019  }
1020 
1021  // if we're still waiting for this guy to connect on his reliable socket and he's timed out, boot him
1022  if(Net_players[idx].s_info.reliable_connect_time != -1){
1023  // if he's connected
1024  if(Net_players[idx].reliable_socket != INVALID_SOCKET){
1025  Net_players[idx].s_info.reliable_connect_time = -1;
1026  }
1027  // if he's timed out
1028  else if(((time(NULL) - Net_players[idx].s_info.reliable_connect_time) > MULTI_RELIABLE_CONNECT_WAIT) && (Net_players[idx].reliable_socket == INVALID_SOCKET)){
1029  ml_string("Player timed out while connecting on reliable socket!");
1030  delete_player(idx);
1031  }
1032  }
1033  }
1034  }
1035  }
1036  // clients should detect broken sockets
1037  else {
1038  extern unsigned int Serverconn;
1039  if(Serverconn != 0xffffffff){
1040  int status = psnet_rel_get_status(Serverconn);
1041  if(status == RNF_BROKEN){
1042  mprintf(("CLIENT SOCKET DISCONNECTED\n"));
1043 
1044  // quit the game
1045  if(!multi_endgame_ending()){
1047  }
1048  }
1049  }
1050  }
1051 }
1052 
1053 // multi_process_incoming reads incoming data off the unreliable and reliable ports and sends
1054 // the data to process_big_data
1056 {
1057  int size;
1058  ubyte *data, *savep;
1059  net_addr from_addr;
1060 
1062  savep = net_buffer[Multi_read_count];
1063 
1064  Multi_read_count++;
1065 
1066  data = savep;
1067 
1068  // get the other net players data
1069  while( (size = psnet_get(data, &from_addr))>0 ) {
1070  // ingame joiners will ignore UDP packets until they are have picked a ship and are in the mission
1071  if( (Net_player->flags & NETINFO_FLAG_INGAME_JOIN) && (Net_player->state != NETPLAYER_STATE_INGAME_SHIP_SELECT) ){
1072  nprintf(("Network","Tossing UDP like a good little ingame joiner...\n"));
1073  }
1074  // otherwise process incoming data normally
1075  else {
1076  multi_process_bigdata(data, size, &from_addr, 0);
1077  }
1078  } // end while
1079 
1080  // read reliable sockets for data
1081  data = savep;
1082  int idx;
1083 
1084  if(Net_player->flags & NETINFO_FLAG_AM_MASTER){
1085  for (idx=0;idx<MAX_PLAYERS;idx++) {
1086  if((Net_players[idx].flags & NETINFO_FLAG_CONNECTED) && (Net_player != NULL) && (Net_player->player_id != Net_players[idx].player_id)){
1087  while( (size = psnet_rel_get(Net_players[idx].reliable_socket, data, MAX_NET_BUFFER)) > 0){
1088  multi_process_bigdata(data, size, &Net_players[idx].p_info.addr, 1);
1089  }
1090  }
1091  }
1092  } else {
1093  // if I'm not the master of the game, read reliable data from my connection with the server
1094  if((Net_player->reliable_socket != INVALID_SOCKET) && (Net_player->reliable_socket != 0)){
1095  while( (size = psnet_rel_get(Net_player->reliable_socket,data, MAX_NET_BUFFER)) > 0){
1096  multi_process_bigdata(data, size, &Netgame.server_addr, 1);
1097  }
1098  }
1099  }
1100 
1101  Multi_read_count--;
1102 }
1103 
1104 // -------------------------------------------------------------------------------------------------
1105 // multi_do_frame() is called once per game loop do update all the multiplayer objects, and send
1106 // the player data to all the other net players.
1107 //
1108 //
1109 
1110 int eye_tog = 1;
1111 DCF(eye_tog, "Toggles setting of the local player eyepoint on every frame (Multiplayer)")
1112 {
1113  if (dc_optional_string_either("status", "--status") || dc_optional_string_either("?", "--?")) {
1114  dc_printf("proper eye stuff is %s\n", eye_tog ? "ON" : "OFF");
1115  return;
1116  }
1117 
1118  eye_tog = !eye_tog;
1119  dc_printf("proper eye stuff is %s\n", eye_tog ? "ON" : "OFF");
1120 }
1121 
1123 {
1125 
1126  // always set the local player eye position/orientation here so we know its valid throughout all multiplayer
1127  // function calls
1128  if((Net_player != NULL) && eye_tog){
1129  camid cid = player_get_cam();
1130  if(cid.isValid())
1131  {
1132  camera *cam = cid.getCamera();
1133  cam->get_info(&Net_player->s_info.eye_pos, &Net_player->s_info.eye_orient);
1134  }
1135  }
1136 
1137  // send all buffered packets from the previous frame
1139 
1140  // datarate tracking
1142 
1143  // always process any pending endgame details
1145 
1146  // process all reliable socket details, including :
1147  // 1.) Listening for new pending reliable connections (server)
1148  // 2.) Checking for broken sockets (server/client)
1149  // 3.) Checking for clients who haven't fully connected
1151 
1152  // get the other net players data
1154 
1155  // process object update datarate stuff (for clients and server both)
1157 
1158  // clients should check when last time they heard from sever was -- if too long, then
1159  // pause the simulation so wait for it to possibly come back
1160  if ( (MULTIPLAYER_CLIENT) && (Net_player->flags & NETINFO_FLAG_CONNECTED) ){
1162  }
1163 
1164  // everybody pings all the time
1165  if((Next_ping_time < 0) || ((time(NULL) - Next_ping_time) > PING_SEND_TIME) ){
1166  if( (Net_player->flags & NETINFO_FLAG_AM_MASTER) ){
1168  }
1169 
1170  // ping everyone
1172  Next_ping_time = (int) time(NULL);
1173  }
1174 
1175  // if I am the master, and we are not yet actually playing the mission, send off netgame
1176  // status to all other players in the game. If I am not the master of the game, and we
1177  // are not in the game, then send out my netplayer status to the host
1178  if ( (Net_player->flags & NETINFO_FLAG_CONNECTED) && !(Game_mode & GM_IN_MISSION)){
1179  if ( Net_player->flags & NETINFO_FLAG_AM_MASTER ) {
1180  if ( (Netgame_send_time < 0) || ((time(NULL) - Netgame_send_time) > NETGAME_SEND_TIME) ) {
1182 
1183  Netgame_send_time = (int) time(NULL);
1184  }
1185  } else {
1186  if ( (State_send_time < 0) || ((time(NULL) - State_send_time) > STATE_SEND_TIME) ){
1187  // observers shouldn't send an update state packet
1188  if ( !(Net_player->flags & NETINFO_FLAG_OBSERVER) ){
1190  }
1191 
1192  State_send_time = (int) time(NULL);
1193  }
1194  }
1195  }
1196  else if ( (Net_player->flags & NETINFO_FLAG_CONNECTED) && (Game_mode & GM_IN_MISSION) ) {
1197  // if I am connected and am in the mission, do things that need to be done on a regular basis
1198  if ( Net_player->flags & NETINFO_FLAG_AM_MASTER ) {
1199  if ( (Gameinfo_send_time < 0) || ((time(NULL) - Gameinfo_send_time) > GAMEINFO_SEND_TIME)){
1201 
1202  Gameinfo_send_time = (int) time(NULL);
1203  }
1204 
1205  // for any potential respawns
1208 
1209  // for any potential ingame joiners
1211  } else {
1212  // the clients need to do some processing of stuff as well
1213  }
1214  }
1215 
1216  // check to see if we're waiting on confirmation for a restricted ingame join
1217  if(Multi_restr_query_timestamp != -1){
1218  // if it has elapsed, unset the ingame join flag
1221  Netgame.flags &= ~(NG_FLAG_INGAME_JOINING);
1222  }
1223  }
1224 
1225  // while in the mission, send my PlayerControls to the host so that he can process
1226  // my movement
1227  if ( Game_mode & GM_IN_MISSION ) {
1228  // tickers
1229  extern void oo_update_time();
1230  oo_update_time();
1231 
1232 
1233  if ( !(Net_player->flags & NETINFO_FLAG_AM_MASTER)){
1234  if(Net_player->flags & NETINFO_FLAG_OBSERVER){
1235  // if the rate limiting system says its ok
1237  // send my observer position/object update
1239  }
1240  } else if ( !(Player_ship->flags & SF_DEPARTING ) ){
1241  // if the rate limiting system says its ok
1243  // use the new method
1245  }
1246  }
1247 
1248  // bytes received info
1249  if( (Next_bytes_time < 0) || ((time(NULL) - Next_bytes_time) > BYTES_SENT_TIME) ){
1250  if(Net_player != NULL){
1251  send_bytes_recvd_packet(Net_player);
1252 
1253  // reset bytes recvd
1254  Net_player->cl_bytes_recvd = 0;
1255  }
1256 
1257  // reset timestamp
1258  Next_bytes_time = (int) time(NULL);
1259  }
1260  } else {
1261  // sending new objects from here is dependent on having objects only created after
1262  // the game is done moving the objects. I think that I can enforce this.
1263  multi_oo_process();
1264 
1265  // evaluate whether the time limit has been reached or max kills has been reached
1266  // Commented out by Sandeep 4/12/98, was causing problems with testing.
1267  if( ((f2fl(Netgame.options.mission_time_limit) > 0.0f) && (Missiontime > Netgame.options.mission_time_limit)) ||
1269 
1270  // make sure we don't do this more than once
1271  if(Netgame.game_state == NETGAME_STATE_IN_MISSION){
1273  }
1274  }
1275  }
1276  }
1277 
1278  // periodically send a client update packet to all clients
1279  if((Net_player != NULL) && (Net_player->flags & NETINFO_FLAG_AM_MASTER)){
1280  int idx;
1281  for(idx=0;idx<MAX_PLAYERS;idx++){
1282  if(MULTI_CONNECTED(Net_players[idx]) && (Net_player != &Net_players[idx])){
1284 
1285  send_client_update_packet(&Net_players[idx]);
1286 
1288  }
1289  }
1290  }
1291  }
1292 
1293 
1294  // process any kicked player details
1296 
1297  // do any file xfer details
1298  multi_xfer_do();
1299 
1300  // process any player data details (wav files, pilot pics, etc)
1301  multi_data_do();
1302 
1303  // do any voice details
1305 
1306  // process any player messaging details
1307  multi_msg_process();
1308 
1309  // if on the standalone, do any gui stuff
1311  std_do_gui_frame();
1312  }
1313 
1314  // dogfight nonstandalone players should recalc the escort list every frame
1315  if(!(Game_mode & GM_STANDALONE_SERVER) && (Netgame.type_flags & NG_TYPE_DOGFIGHT) && MULTI_IN_MISSION){
1317  }
1318 
1319  // do fs2netd stuff
1320  fs2netd_do_frame();
1321 }
1322 
1323 // -------------------------------------------------------------------------------------------------
1324 // multi_pause_do_frame() is called once per game loop do update all the multiplayer objects, and send
1325 // the player data to all the other net players when the multiplayer game is paused. It only will do
1326 // checking for a few specialized packets (MULTI_UNPAUSE, etc)
1327 //
1328 
1330 {
1332 
1333  // always set the local player eye position/orientation here so we know its valid throughout all multiplayer
1334  // function calls
1335  // if((Net_player != NULL) && eye_tog){
1336  // player_get_eye(&Net_player->s_info.eye_pos, &Net_player->s_info.eye_orient);
1337  // }
1338 
1339  // send all buffered packets from the previous frame
1341 
1342  // always process any pending endgame details
1344 
1345  // process all reliable socket details, including :
1346  // 1.) Listening for new pending reliable connections (server)
1347  // 2.) Checking for broken sockets (server/client)
1348  // 3.) Checking for clients who haven't fully connected
1350 
1351  // these timestamps and handlers shoul be evaluated in the pause state
1352  if ( Net_player->flags & NETINFO_FLAG_AM_MASTER ) {
1353  if ( (Gameinfo_send_time < 0) || ((time(NULL) - Gameinfo_send_time) > GAMEINFO_SEND_TIME) ){
1355 
1356  Gameinfo_send_time = (int) time(NULL);
1357  }
1358  }
1359 
1360  // everybody pings all the time
1361  if((Next_ping_time < 0) || ((time(NULL) - Next_ping_time) > PING_SEND_TIME) ){
1363 
1364  Next_ping_time = (int) time(NULL);
1365  }
1366 
1367  // periodically send a client update packet to all clients
1368  if(Net_player->flags & NETINFO_FLAG_AM_MASTER){
1369  int idx;
1370 
1371  for(idx=0;idx<MAX_PLAYERS;idx++){
1372  if(MULTI_CONNECTED(Net_players[idx]) && (Net_player != &Net_players[idx])){
1374 
1375  send_client_update_packet(&Net_players[idx]);
1376 
1378  }
1379  }
1380  }
1381 
1382  // for any potential ingame joiners
1384  }
1385 
1386  // do any file xfer details
1387  multi_xfer_do();
1388 
1389  // process any player data details (wav files, pilot pics, etc)
1390  multi_data_do();
1391 
1392  // get the other net players data
1394 
1395  // do any voice details
1397 
1398  // process any player messaging details
1400 
1401  // process any kicked player details
1403 
1404  // process any pending endgame details
1406 
1407  // process object update stuff (for clients and server both)
1408  if(MULTIPLAYER_MASTER){
1409  multi_oo_process();
1410  }
1411 
1412  // if on the standalone, do any gui stuff
1414  std_do_gui_frame();
1415  }
1416 }
1417 
1418 
1419 
1420 
1421 // --------------------------------------------------------------------------------
1422 // standalone_main_init() the standalone equivalent of the main menu
1423 //
1424 
1425 extern int sock_inited;
1426 float frame_time = (float)1.0/(float)30.0;
1427 
1429 {
1431 
1433 
1434  // NETLOG
1435  ml_string(NOX("Standalone server initializing"));
1436 
1437  // read in config file
1438  // multi_options_read_config();
1439 #ifdef _WIN32
1440  // if we failed to startup on our desired protocol, fail
1443  MessageBox((HWND)os_get_window(), XSTR("You have selected TCP/IP for multiplayer FreeSpace, but the TCP socket is already in use. Check for another instance and/or use the \"-port <port_num>\" command line option to select an available port.", 1620), "Error", MB_OK);
1444  }
1445  else {
1446  MessageBox((HWND)os_get_window(), XSTR("You have selected TCP/IP for multiplayer FreeSpace, but the TCP/IP protocol was not detected on your machine.", 362), "Error", MB_OK);
1447  }
1448 
1449  exit(1);
1450  }
1451 #endif // ifdef _WIN32
1452 
1453 
1454  // set the protocol
1456  switch (Multi_options_g.protocol) {
1457  case NET_TCP:
1460  break;
1461 
1462  default:
1463  Int3();
1464  } // end switch
1465 
1466  HEADER_LENGTH = 1;
1467 
1468  // clear out the Netgame structure and start filling in the values
1469  // NOTE : these values are not incredibly important since they will be overwritten by the host when he joins
1470  memset( &Netgame, 0, sizeof(Netgame) );
1471  Netgame.game_state = NETGAME_STATE_FORMING; // game is currently starting up
1472  Netgame.security = 0;
1473  Netgame.server_addr = Psnet_my_addr;
1474 
1475  The_mission.Reset( );
1476 
1477  // reinitialize all systems
1478  multi_level_init();
1479 
1480  // intialize endgame stuff
1482 
1483  // clear the file xfer system
1484  multi_xfer_reset();
1486 
1487  // reset timer
1488  timestamp_reset();
1489 
1490  // setup a blank pilot (this is a standalone usage only!)
1491  Pilot.load_player(NULL);
1492 
1493  // setup the netplayer for the standalone
1494  Net_player = &Net_players[0];
1495  Net_player->tracker_player_id = -1;
1497  Net_player->state = NETPLAYER_STATE_WAITING;
1498  Net_player->m_player = Player;
1499  strcpy_s(Player->callsign, "server");
1500  Net_player->p_info.addr = Psnet_my_addr;
1501  Net_player->s_info.xfer_handle = -1;
1502  Net_player->player_id = multi_get_new_id();
1503  Netgame.server = Net_player;
1504 
1505  // maybe flag the game as having a hacked ships.tbl
1506  /*if(!Game_ships_tbl_valid){
1507  Netgame.flags |= NG_FLAG_HACKED_SHIPS_TBL;
1508  }
1509  // maybe flag the game as having a hacked weapons.tbl
1510  if(!Game_weapons_tbl_valid){
1511  Netgame.flags |= NG_FLAG_HACKED_WEAPONS_TBL;
1512  }*/
1513 
1514  // hacked data
1515  if(game_hacked_data()){
1516  Net_player->flags |= NETINFO_FLAG_HAXOR;
1517  }
1518 
1519  // setup debug flags
1520  Netgame.debug_flags = 0;
1521 
1522  // setup the default game name for the standalone
1524 
1525  // set netgame default options
1527 
1528  // set local netplayer default options
1530 
1531  // set our object update level from the standalone default
1533  switch(Net_player->p_info.options.obj_update_level){
1534  case OBJ_UPDATE_LOW:
1535  nprintf(("Network","STANDALONE USING LOW UPDATES\n"));
1536  break;
1537  case OBJ_UPDATE_MEDIUM:
1538  nprintf(("Network","STANDALONE USING MEDIUM UPDATES\n"));
1539  break;
1540  case OBJ_UPDATE_HIGH:
1541  nprintf(("Network","STANDALONE USING HIGH UPDATE\n"));
1542  break;
1543  case OBJ_UPDATE_LAN:
1544  nprintf(("Network","STANDALONE USING LAN UPDATE\n"));
1545  break;
1546  }
1547 
1548  // clear out various things
1549  psnet_flush();
1550  game_flush();
1551  ship_init();
1552 
1554  std_set_standalone_fps((float)0);
1556 
1557  // load my missions and campaigns
1560 
1561  // if this is a tracker game then we have some extra tasks to perform
1562  if (MULTI_IS_TRACKER_GAME) {
1563  // disconnect and prepare for reset if we are already connected
1565 
1566  // login (duh!)
1567  if ( fs2netd_login() ) {
1568  // validate missions
1570 
1571  // advertise our game to the server
1573 
1574  // set tracker id
1575  Net_player->tracker_player_id = Multi_tracker_id;
1576  }
1577  }
1578 }
1579 
1580 
1581 // --------------------------------------------------------------------------------
1582 // standalone_main_do()
1583 //
1584 
1585 // DESCRIPTION : the standalone server will wait in this state until the host of the game
1586 // is "Waiting". That is, his state==NETPLAYER_STATE_WAITING, and he has finished
1587 // doing everything and wants to play the game. Once this happens, we will jump
1588 // into GS_STATE_MULTI_SERVER_WAIT
1589 
1591 {
1592 
1593  Sleep(10); // since nothing will really be going on here, we can afford to give some time
1594  // back to the operating system.
1595 
1596  // kind of a do-nothing spin state.
1597  // The standalone will eventually move into the GS_STATE_MULTI_MISSION_SYNC state when a host connects and
1598  // attempts to start a game
1599 }
1600 
1601 // --------------------------------------------------------------------------------
1602 // standalone_main_close()
1603 //
1604 
1606 {
1608 }
1609 
1611 {
1612  int idx;
1613 
1614  // NETLOG
1615  ml_string(NOX("Standalone resetting"));
1616 
1617  // shut all game stuff down
1618  game_level_close();
1619 
1620  // reinitialize the gui
1622 
1623  // close down all sockets
1624  for(idx=0;idx<MAX_PLAYERS;idx++){
1625 
1626  // 6/25/98 -- MWA -- call delete_player here to remove the player. This closes down the socket
1627  // and marks the player as not connected anymore. It is probably cleaner to do this.
1628  if ( &Net_players[idx] != Net_player ) {
1629  delete_player( idx );
1630  }
1631  }
1632 
1633  // make sure we go to the proper state.
1636  }
1638 }
1639 
1640 // --------------------------------------------------------------------------------
1641 // multi_server_wait_init() do stuff like setting the status bits correctly
1642 //
1643 
1645 {
1647  std_multi_add_goals(); // fill in the goals for the mission into the tree view
1649 
1650  // create the bogus standalone object
1652 }
1653 
1654 
1655 // --------------------------------------------------------------------------------
1656 // multi_server_wait_do_frame() wait for everyone to log in or the host to send commands
1657 //
1658 
1659 // DESCRIPTION : we will be in this state once the host of the game is waiting for everyone
1660 // to be finished and ready to go, at which point, we will will tell everyone
1661 // to enter the game, and we will start simulating ourselves. Note that most of
1662 // this code is lifted from multi_wait_do_frame()
1664 {
1665 }
1666 
1667 // --------------------------------------------------------------------------------
1668 // multi_server_wait_close() cleanup
1669 //
1670 
1672 {
1673  std_debug_set_standalone_state_string("Wait Close / Game Play");
1674 
1675  // all players should reset sequencing
1676  int idx;
1677  for(idx=0;idx<MAX_PLAYERS;idx++){
1678  if(Net_player->flags & NETINFO_FLAG_CONNECTED){
1679  Net_players[idx].client_cinfo_seq = 0;
1680  Net_players[idx].client_server_seq = 0;
1681  }
1682  }
1683 }
1684 
1685 
1686 // this is an artificial state which will push the standalone into the main state without it having to go through
1687 // the init function (which would disconnect everyone and generally just screw things up)
1688 // it will also eventually do tracker stats update
1691 {
1692  std_debug_set_standalone_state_string("Postgame / Send Stats");
1693 
1694  // NETLOG
1695  ml_string(NOX("Standlone entering postgame"));
1696 
1698 
1699  // handle campaign stuff
1700  if ( Game_mode & GM_CAMPAIGN_MODE ) {
1701  // MUST store goals and events first - may be used to evaluate next mission
1702  // store goals and events
1704 
1705  // evaluate next mission
1707  }
1708 
1709  // always set my state to be "DEBRIEF_ACCEPT"
1710  Net_player->state = NETPLAYER_STATE_DEBRIEF_ACCEPT;
1711 
1712  // mark stats as not being store yet
1713  Netgame.flags &= ~(NG_FLAG_STORED_MT_STATS);
1714 
1715  Multi_debrief_server_framecount = 0;
1716 
1717  // reset network timestamps
1719 }
1720 
1722 {
1723  // wait until everyone is in the debriefing
1728  }
1729 
1730  // process server debriefing details
1731  if(Netgame.game_state == NETGAME_STATE_DEBRIEF){
1733  }
1734 }
1735 
1737 {
1738 }
1739 
1740 
1742 {
1743  int i;
1744 
1745  for ( i = 0 ; i < MAX_PLAYERS; i++ ){
1747  }
1748  Netgame_send_time = -1;
1749  Gameinfo_send_time = -1;
1750  Next_ping_time = -1;
1751  State_send_time = -1;
1752  Next_bytes_time = -1;
1753 
1755 
1756  // do for all players so that ingame joiners work properly.
1757  for (i = 0; i < MAX_PLAYERS; i++ ) {
1760 
1761  Net_players[i].s_info.voice_token_timestamp = -1;
1762  }
1763 
1764  // reset standalone gui timestamps (these are not game critical, so there is not much danger)
1766 
1767  // initialize all object update timestamps
1769 }
1770 
1771 // netgame debug flags for debug console stuff
1772 DCF(netd, "change netgame debug flags (Mulitplayer)")
1773 {
1774  int value;
1775  dc_stuff_int(&value);
1776 
1777  // if we're the server, change flags
1778  if ((Net_player != NULL) && (Net_player->flags & NETINFO_FLAG_AM_MASTER) && (value <= 7)) {
1779  Netgame.debug_flags ^= (1 << value);
1780  }
1781 
1782  // display network flags
1783  dc_printf("BITS\n");
1784 }
1785 
1786 // display any multiplayer/networking information here
1788 {
1789  int sx = gr_screen.center_offset_x + gr_screen.center_w - 200;
1790  int sy = gr_screen.center_offset_y + 20;
1791  int dy = gr_get_font_height() + 1;
1792  int idx;
1793 
1794  // not multiplayer
1795  if(!(Game_mode & GM_MULTIPLAYER)){
1796  return;
1797  }
1798 
1799  // HUD is turned off
1800  if (!HUD_draw) {
1801  return;
1802  }
1803 
1804  // message window is open
1806  return;
1807  }
1808 
1810 
1811  // server or client
1812  if(MULTIPLAYER_MASTER){
1813  gr_string(sx, sy, "SERVER", GR_RESIZE_NONE); sy += dy;
1814 
1815  for(idx=0; idx<MAX_PLAYERS; idx++){
1816  if(MULTI_CONNECTED(Net_players[idx]) && (Net_player != &Net_players[idx]) && (Net_players[idx].m_player != NULL)){
1817  if(Net_players[idx].sv_last_pl < 0){
1818  gr_printf_no_resize(sx, sy, "%s: %d, %d pl", Net_players[idx].m_player->callsign, Net_players[idx].sv_bytes_sent, 0);
1819  sy += dy;
1820  } else {
1821  gr_printf_no_resize(sx, sy, "%s: %d, %d pl", Net_players[idx].m_player->callsign, Net_players[idx].sv_bytes_sent, Net_players[idx].sv_last_pl);
1822  sy += dy;
1823  }
1824  }
1825  }
1826  } else {
1827  gr_string(sx, sy, "CLIENT", GR_RESIZE_NONE); sy += dy;
1828 
1829  // display PL
1830  if(Net_player != NULL){
1831  if(Net_player->cl_last_pl < 0){
1832  gr_printf_no_resize(sx, sy, "PL: %d %d pl\n", Net_player->cl_bytes_recvd, 0);
1833  sy += dy;
1834  } else {
1835  gr_printf_no_resize(sx, sy, "PL: %d %d pl\n", Net_player->cl_bytes_recvd, Net_player->cl_last_pl);
1836  sy += dy;
1837  }
1838  }
1839  }
1840 }
#define MULTI_TRACKER_STRING_LEN
Definition: multi.h:791
void game_flush()
Definition: fredstubs.cpp:83
int Multi_button_info_ok
Definition: multi.cpp:100
int Multi_client_update_times[MAX_PLAYERS]
Definition: multi.cpp:129
pilotfile Pilot
Definition: pilotfile.cpp:7
#define TRANSFER_HOST
Definition: multi.h:220
#define NETPLAYER_STATE_DEBRIEF
Definition: multi.h:691
void multi_data_do()
Definition: multi_data.cpp:103
int timestamp(int delta_ms)
Definition: timer.cpp:226
void multi_update_valid_missions()
Definition: multiutil.cpp:3041
#define GAME_INFO
Definition: multi.h:218
int multi_xfer_process_packet(unsigned char *data, PSNET_SOCKET_RELIABLE who)
Definition: multi_xfer.cpp:652
#define MULTIPLAYER_CLIENT
Definition: multi.h:132
#define SUBSYSTEM_DESTROYED
Definition: multi.h:170
void * HWND
Definition: config.h:104
#define MY_NET_PLAYER_NUM
Definition: multi.h:127
#define NET_TCP
Definition: psnet2.h:29
#define NETGAME_STATE_DEBRIEF
Definition: multi.h:669
int i
Definition: multi_pxo.cpp:466
fix Missiontime
Definition: systemvars.cpp:19
ushort client_server_seq
Definition: multi.h:468
char Multi_tracker_squad_name[MULTI_TRACKER_STRING_LEN+1]
Definition: multi.cpp:145
void fs2netd_gameserver_start()
#define timestamp_elapsed_safe(_a, _b)
Definition: timer.h:114
void multi_standalone_wait_init()
Definition: multi.cpp:1644
#define SUBSYS_CARGO_HIDDEN
Definition: multi.h:267
void process_ship_create_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2666
void multi_pause_reset()
void process_ai_info_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5055
int flags
Definition: player.h:104
int Multi_mission_loaded
Definition: multi.cpp:98
int Game_mode
Definition: systemvars.cpp:24
void multi_voice_process_packet(ubyte *data, header *hinfo)
#define NETPLAYER_UPDATE
Definition: multi.h:257
void process_ship_kill_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2557
void process_packet_normal(ubyte *data, header *header_info)
Definition: multi.cpp:484
#define SHIP_STATUS_CHANGE
Definition: multi.h:203
void process_ping_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3466
void multi_options_set_local_defaults(multi_local_options *options)
net_player * Net_player
Definition: multi.cpp:94
#define PLAYER_ORDER_PACKET
Definition: multi.h:204
ushort client_cinfo_seq
Definition: multi.h:467
int ADDRESS_LENGTH
Definition: multi.cpp:104
int Next_bytes_time
Definition: multi.cpp:126
#define MULTI_IN_MISSION
Definition: multi.h:718
void process_change_iff_color_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7546
#define MULTI_SERVER_WAIT_TIME
Definition: multi.cpp:75
int Netgame_send_time
Definition: multi.cpp:121
#define NETINFO_FLAG_DO_NETWORKING
Definition: multi.h:610
void standalone_main_init()
Definition: multi.cpp:1428
CFILE * Multi_chat_stream
Definition: multi.cpp:111
int find_player(net_addr *addr)
Definition: multiutil.cpp:431
#define PING_SEND_TIME
Definition: multi.cpp:65
void process_observer_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3976
uint PSNET_SOCKET_RELIABLE
Definition: multi_xfer.h:20
player * m_player
Definition: multi.h:459
int security
Definition: multi.h:499
#define DEBRIS_SIG_MIN
Definition: multi.h:741
int Multi_restr_query_timestamp
Definition: multi.cpp:135
void multi_standalone_postgame_do()
Definition: multi.cpp:1721
void multi_reset_timestamps()
Definition: multi.cpp:1741
#define COUNTDOWN
Definition: multi.h:261
void send_netplayer_update_packet(net_player *pl)
Definition: multimsgs.cpp:2308
void process_game_chat_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:717
void process_ingame_ship_request_packet(ubyte *data, header *hinfo)
int gameseq_get_state(void)
Definition: fredstubs.cpp:60
Assert(pm!=NULL)
void multi_ping_send_all()
Definition: multi_ping.cpp:114
void process_countdown_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7232
#define mprintf(args)
Definition: pstypes.h:238
void process_variable_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8205
void process_homing_weapon_info(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7357
void standalone_main_close()
Definition: multi.cpp:1605
#define NETINFO_FLAG_OBSERVER
Definition: multi.h:605
void process_ingame_ships_packet(ubyte *data, header *hinfo)
__inline void gr_string(int x, int y, const char *string, int resize_mode=GR_RESIZE_FULL)
Definition: 2d.h:769
int HUD_draw
Definition: hud.cpp:78
void process_turret_fired_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3264
void process_force_end_mission_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3837
void process_mission_request_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3635
int multi_kill_limit_reached()
Definition: multiutil.cpp:2872
int multi_netplayer_state_check(int state, int ignore_standalone)
Definition: multiutil.cpp:1433
void multi_do_frame()
Definition: multi.cpp:1122
void psnet_rel_work()
Definition: psnet2.cpp:1187
void process_repair_info_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4873
void process_flak_fired_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8313
void process_subsystem_cargo_hidden_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4650
int Multi_display_netinfo
Definition: multi.cpp:85
void process_mission_message_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3431
#define RNF_BROKEN
Definition: psnet2.h:100
void multi_standalone_reset_all()
Definition: multi.cpp:1610
int Multi_button_info_id
Definition: multi.cpp:101
#define VOICE_PACKET
Definition: multi.h:247
#define RNF_UNUSED
Definition: psnet2.h:98
void process_debris_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5317
int find_player_id(short player_id)
Definition: multiutil.cpp:465
void ml_string(const char *string, int add_time)
Definition: multi_log.cpp:131
#define KICK_PLAYER
Definition: multi.h:177
#define JUMP_INTO_GAME
Definition: multi.h:164
#define SQUADMSG_PLAYER
Definition: multi.h:236
int update_lock_time
Definition: player.h:188
#define CHANGE_IFF_COLOR
Definition: multi.h:275
int Tcp_active
Definition: psnet2.cpp:60
#define DENY
Definition: multi.h:214
Definition: cfile.h:28
#define MULTI_END_ERROR_CONTACT_LOST
Definition: multi_endgame.h:44
int multi_get_connection_speed()
Definition: multiutil.cpp:2999
int center_offset_y
Definition: 2d.h:364
void process_countermeasure_success_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6958
#define INVALID_SOCKET
Definition: psnet2.h:53
int multi_client_server_dead()
Definition: multi.cpp:376
void process_wing_create_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2735
void process_host_captain_change_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8580
void timestamp_reset()
Definition: timer.cpp:201
#define f2fl(fx)
Definition: floating.h:37
#define GAME_CHAT
Definition: multi.h:228
int Multi_has_cd
Definition: multi.cpp:112
void psnet_flush()
Definition: psnet2.cpp:927
int update_dumbfire_time
Definition: player.h:187
#define FILE_SIG_INFO
Definition: multi.h:160
int psnet_get(void *data, net_addr *from_addr)
Definition: psnet2.cpp:881
#define OPTIONS_UPDATE
Definition: multi.h:192
void ship_init()
Definition: ship.cpp:5086
int Multi_server_check_count
Definition: multi.cpp:125
int center_w
Definition: 2d.h:363
void gr_set_color_fast(color *dst)
Definition: 2d.cpp:1197
void send_netgame_update_packet(net_player *pl)
Definition: multimsgs.cpp:2008
void process_sexp_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8730
#define FIRING_INFO
Definition: multi.h:156
uint flags
Definition: ship.h:644
void debrief_multi_server_stuff()
#define LIGHTNING_PACKET
Definition: multi.h:251
void multi_respawn_handle_invul_players()
#define NETPLAYER_PAIN
Definition: multi.h:180
int flags
Definition: multi.h:463
void reset()
ubyte addr[6]
Definition: psnet2.h:41
GLsizeiptr size
Definition: Glext.h:5496
#define Int3()
Definition: pstypes.h:292
void process_store_stats_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5268
#define OBJ_UPDATE_LAN
Definition: multi_options.h:20
void multi_oo_send_control_info()
Definition: multi_obj.cpp:1436
#define SHIP_CREATE
Definition: multi.h:243
void process_NEW_primary_fired_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7686
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: Glext.h:7308
void standalone_main_do()
Definition: multi.cpp:1590
#define GR_RESIZE_NONE
Definition: 2d.h:681
#define OBJECT_UPDATE_NEW
Definition: multi.h:181
void process_debrief_info(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7284
void multi_xfer_force_dir(int cf_type)
Definition: multi_xfer.cpp:394
#define WINGS_INGAME_PACKET
Definition: multi.h:232
#define CF_TYPE_MULTI_CACHE
Definition: cfile.h:73
char callsign[CALLSIGN_LEN+1]
Definition: player.h:91
void fs2netd_disconnect()
int game_state
Definition: multi.h:498
LOCAL ubyte Multi_read_count
Definition: multi.cpp:133
int psnet_same(net_addr *a1, net_addr *a2)
Definition: psnet2.cpp:785
#define SECONDARY_FIRED_PLR
Definition: multi.h:200
#define ASTEROID_SIG_MIN
Definition: multi.h:744
#define GAME_ACTIVE
Definition: multi.h:254
void process_new_player_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:1063
void get_info(vec3d *position, matrix *orientation)
Definition: camera.cpp:295
GLenum type
Definition: Gl.h:1492
void multi_create_list_load_missions()
Definition: multiui.cpp:4438
void multi_endgame_process()
ushort Next_asteroid_signature
Definition: multiutil.cpp:89
#define DCF(function_name, help_text)
The potent DCF macro, used to define new debug commands for the console.
Definition: console.h:60
void multi_handle_end_mission_request()
Definition: multiutil.cpp:2218
unsigned int Serverconn
Definition: psnet2.cpp:215
void multi_voice_process()
void process_netgame_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2063
int multi_oo_cirate_can_send()
Definition: multi_obj.cpp:1753
#define MULTI_SERVER_ALIVE
Definition: multi.cpp:77
bool isValid()
Definition: camera.cpp:851
#define MISSION_GOAL_INFO
Definition: multi.h:178
int PORT_LENGTH
Definition: multi.cpp:105
void process_host_restr_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6858
int multi_endgame_ending()
void process_NEW_countermeasure_fired_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7797
player Players[MAX_PLAYERS]
int Next_ping_time
Definition: multi.cpp:124
int tracker_player_id
Definition: multi.h:461
uint os_get_window()
Definition: osapi.cpp:208
void process_shield_explosion_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6347
void multi_process_bigdata(ubyte *data, int len, net_addr *from_addr, int reliable)
Definition: multi.cpp:936
void process_beam_fired_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7908
void process_secondary_fired_packet(ubyte *data, header *hinfo, int from_player)
process a packet indicating a secondary weapon was fired
Definition: multimsgs.cpp:3047
typedef int(SCP_EXT_CALLCONV *SCPDLL_PFVERSION)(SCPDLL_Version *)
void process_pong_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3483
void multi_options_read_config()
void process_game_active_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:1935
void send_bytes_recvd_packet(net_player *pl)
Definition: multimsgs.cpp:8513
int game_hacked_data()
Definition: fredstubs.cpp:208
#define XFER_PACKET
Definition: multi.h:246
void chatbox_reset_timestamps()
Definition: chatbox.cpp:1195
void process_hud_message(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:857
int bytes_processed
Definition: multi.h:386
void multi_client_check_server()
Definition: multi.cpp:439
net_player_info p_info
Definition: multi.h:473
void multi_oo_process_update(ubyte *data, header *hinfo)
Definition: multi_obj.cpp:1357
bool fs2netd_login()
int type_flags
Definition: multi.h:493
char Multi_tracker_passwd[MULTI_TRACKER_STRING_LEN+1]
Definition: multi.cpp:144
#define SHIP_DEPART
Definition: multi.h:230
#define MAX_TYPE_ID
Definition: multi.h:277
void multi_campaign_process_ingame_start(ubyte *data, header *hinfo)
#define NETINFO_FLAG_AM_MASTER
Definition: multi.h:599
void multi_options_process_packet(unsigned char *data, header *hinfo)
void ml_printf(const char *format,...)
Definition: multi_log.cpp:112
#define MISSION_SYNC_DATA
Definition: multi.h:171
void process_pslot_update_packet(ubyte *data, header *hinfo)
void process_lightning_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8491
int state
Definition: multi.h:464
void process_netplayer_load_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4709
void multi_level_init()
Definition: multi.cpp:253
void process_event_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8072
#define nprintf(args)
Definition: pstypes.h:239
multi_server_options options
Definition: multi.h:514
#define GM_MULTIPLAYER
Definition: systemvars.h:18
void send_client_update_packet(net_player *pl)
Definition: multimsgs.cpp:6975
PSNET_SOCKET_RELIABLE reliable_socket
Definition: multi.h:465
void process_reinforcement_avail(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7468
void multi_process_incoming()
Definition: multi.cpp:1055
#define GAMEINFO_SEND_TIME
Definition: multi.cpp:64
fix last_heard_time
Definition: multi.h:470
#define STORE_MISSION_STATS
Definition: multi.h:172
netgame_info Netgame
Definition: multi.cpp:97
#define HOMING_WEAPON_UPDATE
Definition: multi.h:208
#define ACCEPT_PLAYER_DATA
Definition: multi.h:222
void multi_team_send_update()
Definition: multi_team.cpp:696
#define MISSION_END
Definition: multi.h:233
void multi_respawn_init()
void multi_log_init()
Definition: multi_log.cpp:81
void process_endgame_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3891
#define COUNTERMEASURE_FIRED
Definition: multi.h:201
dc_stuff_int & value
Definition: multi.cpp:1775
void multi_respawn_check_ai()
#define SUBSYS_CARGO_REVEALED
Definition: multi.h:182
#define NG_TYPE_TEAM
Definition: multi.h:650
#define NG_FLAG_STORED_MT_STATS
Definition: multi.h:642
#define WSS_REQUEST_PACKET
Definition: multi.h:175
int Multi_num_players_at_start
Definition: multi.cpp:114
#define INGAME_SHIP_UPDATE
Definition: multi.h:157
#define WSAEADDRINUSE
Definition: config.h:137
#define NETINFO_FLAG_MISSION_OK
Definition: multi.h:608
void process_countermeasure_fired_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3178
void process_ship_status_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4205
void process_weapon_or_ammo_changed_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8122
#define NETGAME_END_ERROR
Definition: multi.h:248
#define NETINFO_FLAG_INGAME_JOIN
Definition: multi.h:604
#define FIRE_TURRET_WEAPON
Definition: multi.h:202
#define PRIMARY_FIRED_NEW
Definition: multi.h:195
#define FLAK_FIRED
Definition: multi.h:209
void process_multi_pause_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3729
#define MB_OK
Definition: config.h:179
#define STATE_SEND_TIME
Definition: multi.cpp:63
void multi_xfer_reset()
Definition: multi_xfer.cpp:185
#define RNF_DISCONNECTED
Definition: psnet2.h:101
char Multi_tracker_id_string[255]
Definition: multi.cpp:147
net_player_server_info s_info
Definition: multi.h:472
void multi_kick_init()
Definition: multi_kick.cpp:56
int Multi_connection_speed
Definition: multi.cpp:113
#define MAX_PLAYERS
Definition: pstypes.h:32
short player_id
Definition: multi.h:460
void multi_standalone_wait_close()
Definition: multi.cpp:1671
#define NETINFO_FLAG_HAXOR
Definition: multi.h:624
#define FORCE_MISSION_END
Definition: multi.h:238
bool dc_optional_string_either(const char *str1, const char *str2)
Searches for an optional string and it's alias.
void process_game_query(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2277
#define EVENT_UPDATE
Definition: multi.h:197
ubyte debug_flags
Definition: multi.h:516
#define NETINFO_FLAG_RELIABLE_CONNECTED
Definition: multi.h:620
void process_subsystem_destroyed_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4506
void process_netplayer_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2390
short port
Definition: multi.h:389
void multi_pause_do_frame()
Definition: multi.cpp:1329
void process_cargo_hidden_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2901
int psnet_use_protocol(int protocol)
Definition: psnet2.cpp:596
void process_wss_request_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5389
void multi_team_process_packet(unsigned char *data, header *hinfo)
Definition: multi_team.cpp:628
#define CARGO_REVEALED
Definition: multi.h:167
void multi_standalone_postgame_init()
Definition: multi.cpp:1690
int idx
Definition: multiui.cpp:761
#define CARGO_HIDDEN
Definition: multi.h:266
void multi_file_xfer_notify(int handle)
Definition: multiutil.cpp:2327
void process_player_settings_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5642
int State_send_time
Definition: multi.cpp:122
#define MULTI_SERVER_GONE
Definition: multi.cpp:76
#define MULTI_SERVER_MAX_TIMEOUT
Definition: multi.cpp:73
void process_client_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7072
void multi_xfer_init(void(*multi_xfer_recv_callback)(int handle))
Definition: multi_xfer.cpp:154
void send_observer_update_packet()
Definition: multimsgs.cpp:3938
void process_firing_info_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5537
long fix
Definition: pstypes.h:54
#define RESPAWN_NOTICE
Definition: multi.h:161
unsigned char ubyte
Definition: pstypes.h:62
ushort Multi_current_file_checksum
Definition: multi.cpp:150
net_addr addr
Definition: multi.h:453
void std_reset_timestamps()
const char * XSTR(const char *str, int index)
Definition: localize.cpp:851
void oo_update_time()
Definition: multi_obj.cpp:2014
void multi_lag_init()
Definition: multilag.cpp:100
#define NETGAME_SEND_TIME
Definition: multi.cpp:62
int eye_tog
Definition: multi.cpp:1110
int cl_last_pl
Definition: multi.h:482
#define INGAME_NAK
Definition: multi.h:234
#define CHANGE_IFF
Definition: multi.h:264
ship * Player_ship
Definition: ship.cpp:124
#define GM_IN_MISSION
Definition: systemvars.h:23
int Multi_tracker_id
Definition: multi.cpp:146
#define LOAD_MISSION_NOW
Definition: multi.h:162
void process_sw_query_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8050
#define VARIABLE_UPDATE
Definition: multi.h:272
#define NOX(s)
Definition: pstypes.h:473
void std_debug_set_standalone_state_string(char *str)
#define EMP_EFFECT
Definition: multi.h:263
void process_self_destruct_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8663
void process_ship_weapon_change(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4117
#define GM_STANDALONE_SERVER
Definition: systemvars.h:27
void multi_create_standalone_object()
Definition: multiutil.cpp:1569
int Multi_ts_inited
void multi_oo_process()
Definition: multi_obj.cpp:1336
#define MISSION_MESSAGE
Definition: multi.h:229
#define MULTI_END_NOTIFY_NONE
Definition: multi_endgame.h:32
void process_change_ai_class_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7593
GLbitfield flags
Definition: Glext.h:6722
void multi_xfer_do()
Definition: multi_xfer.cpp:170
short Multi_id_num
Definition: multi.cpp:115
#define SECONDARY_FIRED_AI
Definition: multi.h:199
void process_mission_sync_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5194
#define HOST_RESTR_QUERY
Definition: multi.h:191
#define WSS_UPDATE_PACKET
Definition: multi.h:176
#define NETGAME_STATE_IN_MISSION
Definition: multi.h:666
void dc_stuff_int(int *i)
Stuffs an int to the given variable. Supports binary (0b), hexadecimal (0x), and octal (0o) formats...
#define MISSION_ITEM
Definition: multi.h:217
#define NETINFO_FLAG_CONNECTED
Definition: multi.h:598
int Multi_debrief_server_framecount
Definition: multiui.cpp:8617
#define PROMPT_NONE
Definition: multi_endgame.h:26
void process_mission_item_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3653
void PSNET_TOP_LAYER_PROCESS()
Definition: psnet2.cpp:360
void mission_goal_fail_incomplete()
#define SHIP_WSTATE_CHANGE
Definition: multi.h:174
net_addr server_addr
Definition: multi.h:503
void process_ingame_ship_update_packet(ubyte *data, header *hinfo)
#define NPERM_SIG_MIN
Definition: multi.h:747
#define SW_STD_QUERY
Definition: multi.h:224
int multi_quit_game(int prompt, int notify_code, int err_code, int wsa_error)
#define WEAPON_DET
Definition: multi.h:240
void std_multi_set_standalone_missiontime(float mission_time)
void send_game_info_packet()
Definition: multimsgs.cpp:3753
void process_netgame_end_error_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6927
#define NETPLAYER_STATE_WAITING
Definition: multi.h:684
#define POST_SYNC_DATA
Definition: multi.h:184
#define SF_DEPARTING
Definition: ship.h:475
#define PLAYER_STATS
Definition: multi.h:187
void process_subsystem_cargo_revealed_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4581
#define OBJECT_UPDATE
Definition: multi.h:258
void multi_msg_process_squadmsg_packet(unsigned char *data, header *hinfo)
Definition: multi_pmsg.cpp:725
ushort Next_non_perm_signature
Definition: multiutil.cpp:90
typedef float(SCP_EXT_CALLCONV *SCPTRACKIR_PFFLOATVOID)()
void chatbox_close()
Definition: chatbox.cpp:634
#define BYTES_SENT_TIME
Definition: multi.cpp:66
join_request Multi_restr_join_request
Definition: multi.cpp:136
void process_leave_game_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:1724
dc_printf("proper eye stuff is %s\n", eye_tog?"ON":"OFF")
void mission_campaign_eval_next_mission()
void process_bytes_recvd_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8529
void mission_campaign_store_goals_and_events_and_variables()
float frame_time
Definition: multi.cpp:1426
#define NETPLAYER_SLOTS_P
Definition: multi.h:155
int Multi_join_restr_mode
Definition: multi.cpp:138
Definition: pstypes.h:606
void process_post_sync_data_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5969
void process_game_info_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3769
void game_level_close()
Definition: fredstubs.cpp:182
void std_do_gui_frame()
void multi_endgame_init()
void multi_handle_ingame_joiners()
void Reset()
Definition: missionparse.h:172
void process_wss_update_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5467
void process_player_order_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4307
#define AI_INFO_UPDATE
Definition: multi.h:205
#define REINFORCEMENT_AVAIL
Definition: multi.h:250
void process_ship_depart_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2790
void delete_player(int player_num, int kicked_reason)
Definition: multiutil.cpp:862
LOCAL ubyte net_buffer[NUM_REENTRANT_LEVELS][MAX_NET_BUFFER]
Definition: multi.cpp:132
#define MULTI_CONNECTED(np)
Definition: multi.h:136
bool load_player(const char *callsign, player *_p=NULL)
Definition: plr.cpp:779
#define OBJ_UPDATE_MEDIUM
Definition: multi_options.h:18
#define LEAVE_GAME
Definition: multi.h:227
#define ACCEPT
Definition: multi.h:213
#define SHIP_KILL
Definition: multi.h:241
fix timer_get_fixed_seconds()
Definition: timer.cpp:116
player * Player
#define OBSERVER_UPDATE
Definition: multi.h:235
#define NETPLAYER_STATE_DEBRIEF_ACCEPT
Definition: multi.h:703
void process_asteroid_info(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6734
#define INGAME_SHIP_REQUEST
Definition: multi.h:158
#define MULTI_RELIABLE_CONNECT_WAIT
Definition: multi.h:109
void process_player_kick_packet(ubyte *data, header *hinfo)
Definition: multi_kick.cpp:228
int psnet_rel_get(PSNET_SOCKET socketid, ubyte *buffer, int max_len)
Definition: psnet2.cpp:1152
class camera * getCamera()
Definition: camera.cpp:833
screen gr_screen
Definition: 2d.cpp:46
Definition: multi.h:385
void process_deny_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5701
void process_ingame_nak(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3798
short multi_get_new_id()
Definition: multiutil.cpp:3167
unsigned short ushort
Definition: pstypes.h:63
LOCAL fix Multi_server_wait_start
Definition: multi.cpp:140
void process_netplayer_slot_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4046
void hud_setup_escort_list(int level)
Definition: hudescort.cpp:651
camid player_get_cam()
void multi_data_reset()
Definition: multi_data.cpp:68
int gr_get_font_height()
Definition: font.cpp:187
int center_offset_x
Definition: 2d.h:364
void std_connect_set_gamename(char *name)
int HEADER_LENGTH
Definition: multi.cpp:106
#define NG_FLAG_SERVER_LOST
Definition: multi.h:639
#define MULTI_CLIENT_UPDATE_TIME
Definition: multi.cpp:83
void Sleep(int mili)
#define MULTIPLAYER_MASTER
Definition: multi.h:130
#define DEBRIEF_INFO
Definition: multi.h:262
An overhauled/updated debug console to allow monitoring, testing, and general debugging of new featur...
#define SELF_DESTRUCT
Definition: multi.h:210
#define BYTES_SENT
Definition: multi.h:252
#define OBJ_UPDATE_HIGH
Definition: multi_options.h:19
int psnet_rel_get_status(PSNET_SOCKET_RELIABLE socketid)
Definition: psnet2.cpp:1542
void multi_kick_process()
Definition: multi_kick.cpp:64
#define NETPLAYER_STATE_INGAME_SHIP_SELECT
Definition: multi.h:690
#define MULTI_PAUSE_REQUEST
Definition: multi.h:219
int MessageBox(HWND h, const char *s1, const char *s2, int i)
GLenum GLsizei GLenum GLenum const GLvoid * data
Definition: Gl.h:1509
int Active_game_count
Definition: multi.cpp:110
void multi_check_listen()
Definition: multi.cpp:320
void send_accept_player_data(net_player *npp, int is_ingame)
Definition: multimsgs.cpp:1196
#define CHANGE_AI_CLASS
Definition: multi.h:269
int Multi_current_file_length
Definition: multi.cpp:151
#define timestamp_elapsed(stamp)
Definition: timer.h:102
ubyte addr[6]
Definition: multi.h:388
void multi_init()
Definition: multi.cpp:160
short id
Definition: multi.h:390
void process_emp_effect(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7431
#define MULTI_SERVER_MAX_TIMEOUT_LARGE
Definition: multi.cpp:74
int psnet_rel_check_for_listen(net_addr *from_addr)
Definition: psnet2.cpp:1555
int multi_client_wait_on_server()
Definition: multi.cpp:408
#define PONG
Definition: multi.h:245
color Color_normal
Definition: alphacolors.cpp:28
#define IP_ADDRESS_LENGTH
Definition: multi.h:93
void process_accept_player_data(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:1269
void multi_oo_gameplay_init()
Definition: multi_obj.cpp:1386
void multi_process_reliable_details()
Definition: multi.cpp:996
#define OBJ_UPDATE_LOW
Definition: multi_options.h:17
void process_change_iff_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:7504
#define WEAPON_OR_AMMO_CHANGED
Definition: multi.h:273
void multi_standalone_postgame_close()
Definition: multi.cpp:1736
#define UPDATE_DESCRIPT
Definition: multi.h:260
void multi_standalone_wait_do()
Definition: multi.cpp:1663
GLenum GLsizei len
Definition: Glext.h:6283
#define IP_PORT_LENGTH
Definition: multi.h:94
#define GAME_UPDATE
Definition: multi.h:256
net_addr Psnet_my_addr
Definition: psnet2.cpp:52
active_game * Active_game_head
Definition: multi.cpp:109
#define MAX_NET_BUFFER
Definition: multi.cpp:69
Definition: camera.h:18
void process_weapon_detonate_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8252
#define MISSION_LOG_ENTRY
Definition: multi.h:259
#define SHIP_SIG_MIN
Definition: multi.h:735
#define WSS_SLOTS_DATA
Definition: multi.h:186
server_item * Game_server_head
Definition: multi.cpp:118
int Tcp_failure_code
Definition: psnet2.cpp:63
int sock_inited
int multi_is_valid_unknown_packet(ubyte type)
Definition: multiutil.cpp:1563
void process_accept_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:1553
void process_player_pain_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:8429
void multi_voice_init()
void process_jump_into_mission_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4774
void multi_load_common_icons()
Definition: multiui.cpp:337
#define BEAM_FIRED
Definition: multi.h:223
#define SLOT_UPDATE
Definition: multi.h:188
void _cdecl gr_printf_no_resize(int x, int y, const char *format,...)
Definition: font.cpp:342
void process_cargo_revealed_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2849
mission The_mission
#define PLAYER_SETTINGS
Definition: multi.h:185
void process_wss_slots_data_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6234
#define NOTIFY_NEW_PLAYER
Definition: multi.h:215
int cl_bytes_recvd
Definition: multi.h:481
void multi_io_send_buffered_packets()
Definition: multimsgs.cpp:544
void multi_oo_rate_process()
Definition: multi_obj.cpp:1604
void psnet_rel_close_socket(PSNET_SOCKET_RELIABLE *sockp)
Definition: psnet2.cpp:1008
void multi_debrief_server_process()
Definition: multiui.cpp:8947
net_addr Multi_restr_addr
Definition: multi.cpp:137
ushort Next_ship_signature
Definition: multiutil.cpp:88
#define PING
Definition: multi.h:244
GLenum const GLvoid * addr
Definition: Glext.h:9092
#define NETGAME_STATE_FORMING
Definition: multi.h:664
void multi_create_list_load_campaigns()
Definition: multiui.cpp:4522
void process_mission_goal_info_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:5588
void process_player_stats_block_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:6530
void multi_respawn_process_packet(ubyte *data, header *hinfo)
void process_join_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:903
#define HUD_MSG
Definition: multi.h:226
#define FALSE
Definition: pstypes.h:400
#define MULTI_IS_TRACKER_GAME
Definition: multi.h:146
#define LOCAL
Definition: pstypes.h:37
#define WING_CREATE
Definition: multi.h:242
net_player Net_players[MAX_PLAYERS]
Definition: multi.cpp:93
int sv_bytes_sent
Definition: multi.h:477
short port
Definition: psnet2.h:42
int sv_last_pl
Definition: multi.h:478
void std_reset_standalone_gui()
#define MISSION_REQUEST
Definition: multi.h:216
void gameseq_post_event(int event)
#define CAMPAIGN_UPDATE
Definition: multi.h:206
void multi_rate_process()
#define JOIN
Definition: multi.h:212
#define PLAYER_FLAGS_MSG_MODE
Definition: player.h:37
#define GM_CAMPAIGN_MODE
Definition: systemvars.h:29
void process_file_sig_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4432
char Multi_tracker_login[MULTI_TRACKER_STRING_LEN+1]
Definition: multi.cpp:143
net_player * server
Definition: multi.h:505
#define COUNTERMEASURE_NEW
Definition: multi.h:196
#define CLIENT_REPAIR_INFO
Definition: multi.h:166
void multi_msg_process()
Definition: multi_pmsg.cpp:125
multi_global_options Multi_options_g
void multi_vars_init()
Definition: multi.cpp:199
int flags
Definition: multi.h:495
ushort Next_debris_signature
Definition: multiutil.cpp:91
void multi_display_netinfo()
Definition: multi.cpp:1787
void fs2netd_do_frame()
void process_file_sig_request(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:4461
void process_ingame_wings_packet(ubyte *data, header *hinfo)
#define DEBRIS_UPDATE
Definition: multi.h:173
int Ingame_join_net_signature
Definition: multi.cpp:99
multi_local_options options
Definition: multi.h:452
void std_set_standalone_fps(float fps)
void std_multi_add_goals()
#define COUNTERMEASURE_SUCCESS
Definition: multi.h:249
void process_netgame_descript_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:2193
#define NG_TYPE_DOGFIGHT
Definition: multi.h:651
void multi_campaign_process_update(ubyte *data, header *hinfo)
#define NUM_REENTRANT_LEVELS
Definition: multi.cpp:70
void process_mission_log_packet(ubyte *data, header *hinfo)
Definition: multimsgs.cpp:3376
#define SEXP
Definition: multi.h:274
#define strcpy_s(...)
Definition: safe_strings.h:67
#define GAME_QUERY
Definition: multi.h:255
int Is_standalone
Definition: systemvars.cpp:59
#define ASTEROID_INFO
Definition: multi.h:179
int Gameinfo_send_time
Definition: multi.cpp:123
void multi_options_set_netgame_defaults(multi_server_options *options)
#define TEAM_UPDATE
Definition: multi.h:189
#define SHIELD_EXPLOSION
Definition: multi.h:168
#define FILE_SIG_REQUEST
Definition: multi.h:163
#define NG_FLAG_INGAME_JOINING
Definition: multi.h:640
#define CLIENT_UPDATE
Definition: multi.h:193
#define SHIPS_INGAME_PACKET
Definition: multi.h:231
#define CAMPAIGN_UPDATE_INGAME
Definition: multi.h:207