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_options.cpp $
16 * Revision 1.6 2005/10/02 09:30:10 taylor
17 * sync up rest of big-endian network changes. it should at least be as good as what's in FS2_Open now, only better :)
19 * Revision 1.5 2004/06/11 01:34:41 tigital
20 * byte-swapping changes for bigendian systems
22 * Revision 1.4 2003/05/25 02:30:43 taylor
25 * Revision 1.3 2002/06/09 04:41:23 relnev
26 * added copyright header
28 * Revision 1.2 2002/05/26 20:22:48 theoddone33
29 * Most of network/ works
31 * Revision 1.1.1.1 2002/05/03 03:28:10 root
35 * 22 8/27/99 12:32a Dave
36 * Allow the user to specify a local port through the launcher.
38 * 21 8/22/99 1:19p Dave
39 * Fixed up http proxy code. Cleaned up scoring code. Reverse the order in
40 * which d3d cards are detected.
42 * 20 8/04/99 6:01p Dave
43 * Oops. Make sure standalones log in.
45 * 19 7/09/99 9:51a Dave
46 * Added thick polyline code.
48 * 18 5/03/99 8:32p Dave
49 * New version of multi host options screen.
51 * 17 4/25/99 7:43p Dave
52 * Misc small bug fixes. Made sun draw properly.
54 * 16 4/20/99 6:39p Dave
55 * Almost done with artillery targeting. Added support for downloading
56 * images on the PXO screen.
58 * 15 3/10/99 6:50p Dave
59 * Changed the way we buffer packets for all clients. Optimized turret
60 * fired packets. Did some weapon firing optimizations.
62 * 14 3/09/99 6:24p Dave
63 * More work on object update revamping. Identified several sources of
64 * unnecessary bandwidth.
66 * 13 3/08/99 7:03p Dave
67 * First run of new object update system. Looks very promising.
69 * 12 2/21/99 6:01p Dave
70 * Fixed standalone WSS packets.
72 * 11 2/19/99 2:55p Dave
73 * Temporary checking to report the winner of a squad war match.
75 * 10 2/12/99 6:16p Dave
76 * Pre-mission Squad War code is 95% done.
78 * 9 2/11/99 3:08p Dave
79 * PXO refresh button. Very preliminary squad war support.
81 * 8 11/20/98 11:16a Dave
82 * Fixed up IPX support a bit. Making sure that switching modes and
83 * loading/saving pilot files maintains proper state.
85 * 7 11/19/98 4:19p Dave
86 * Put IPX sockets back in psnet. Consolidated all multiplayer config
89 * 6 11/19/98 8:03a Dave
90 * Full support for D3-style reliable sockets. Revamped packet lag/loss
91 * system, made it receiver side and at the lowest possible level.
93 * 5 11/17/98 11:12a Dave
94 * Removed player identification by address. Now assign explicit id #'s.
96 * 4 10/13/98 9:29a Dave
97 * Started neatening up freespace.h. Many variables renamed and
98 * reorganized. Added AlphaColors.[h,cpp]
100 * 3 10/07/98 6:27p Dave
101 * Globalized mission and campaign file extensions. Removed Silent Threat
102 * special code. Moved \cache \players and \multidata into the \data
105 * 2 10/07/98 10:53a Dave
108 * 1 10/07/98 10:50a Dave
110 * 20 9/10/98 1:17p Dave
111 * Put in code to flag missions and campaigns as being MD or not in Fred
112 * and Freespace. Put in multiplayer support for filtering out MD
113 * missions. Put in multiplayer popups for warning of non-valid missions.
115 * 19 7/07/98 2:49p Dave
118 * 18 6/04/98 11:04a Allender
119 * object update level stuff. Don't reset to high when becoming an
120 * observer of any type. default to low when guy is a dialup customer
122 * 17 5/24/98 3:45a Dave
123 * Minor object update fixes. Justify channel information on PXO. Add a
124 * bunch of configuration stuff for the standalone.
126 * 16 5/19/98 1:35a Dave
127 * Tweaked pxo interface. Added rankings url to pxo.cfg. Make netplayer
128 * local options update dynamically in netgames.
130 * 15 5/08/98 5:05p Dave
131 * Go to the join game screen when quitting multiplayer. Fixed mission
132 * text chat bugs. Put mission type symbols on the create game list.
133 * Started updating standalone gui controls.
135 * 14 5/06/98 12:36p Dave
136 * Make sure clients can leave the debrief screen easily at all times. Fix
137 * respawn count problem.
139 * 13 5/03/98 7:04p Dave
140 * Make team vs. team work mores smoothly with standalone. Change how host
141 * interacts with standalone for picking missions. Put in a time limit for
142 * ingame join ship select. Fix ingame join ship select screen for Vasudan
145 * 12 5/03/98 2:52p Dave
146 * Removed multiplayer furball mode.
148 * 11 4/23/98 6:18p Dave
149 * Store ETS values between respawns. Put kick feature in the text
150 * messaging system. Fixed text messaging system so that it doesn't
151 * process or trigger ship controls. Other UI fixes.
153 * 10 4/22/98 5:53p Dave
154 * Large reworking of endgame sequencing. Updated multi host options
155 * screen for new artwork. Put in checks for host or team captains leaving
158 * 9 4/16/98 11:39p Dave
159 * Put in first run of new multiplayer options screen. Still need to
160 * complete final tab.
162 * 8 4/13/98 4:50p Dave
163 * Maintain status of weapon bank/links through respawns. Put # players on
164 * create game mission list. Make observer not have engine sounds. Make
165 * oberver pivot point correct. Fixed respawn value getting reset every
166 * time host options screen started.
168 * 7 4/09/98 11:01p Dave
169 * Put in new multi host options screen. Tweaked multiplayer options a
172 * 6 4/09/98 5:43p Dave
173 * Remove all command line processing from the demo. Began work fixing up
174 * the new multi host options screen.
176 * 5 4/06/98 6:37p Dave
177 * Put in max_observers netgame server option. Make sure host is always
178 * defaulted to alpha 1 or zeta 1. Changed create game so that MAX_PLAYERS
179 * can always join but need to be kicked before commit can happen. Put in
180 * support for server ending a game and notifying clients of a special
183 * 4 4/04/98 4:22p Dave
184 * First rev of UDP reliable sockets is done. Seems to work well if not
187 * 3 4/03/98 1:03a Dave
188 * First pass at unreliable guaranteed delivery packets.
190 * 2 3/31/98 4:51p Dave
191 * Removed medals screen and multiplayer buttons from demo version. Put in
192 * new pilot popup screen. Make ships in mp team vs. team have proper team
193 * ids. Make mp respawns a permanent option saved in the player file.
195 * 1 3/30/98 6:24p Dave
202 #include "osregistry.h"
204 #include "multimsgs.h"
205 #include "freespace.h"
206 #include "stand_server.h"
207 #include "multiutil.h"
208 #include "multi_voice.h"
209 #include "multi_options.h"
210 #include "multi_team.h"
211 #include "multi_fstracker.h"
214 // ----------------------------------------------------------------------------------
215 // MULTI OPTIONS DEFINES/VARS
219 #define MULTI_OPTION_SERVER 0 // server update follows
220 #define MULTI_OPTION_LOCAL 1 // local netplayer options follow
221 #define MULTI_OPTION_START_GAME 2 // host's start game options on the standalone server
222 #define MULTI_OPTION_MISSION 3 // host's mission selection stuff on a standalone server
225 #define MULTI_CFG_FILE NOX("multi.cfg")
226 multi_global_options Multi_options_g;
228 char Multi_options_proxy[512] = "";
229 ushort Multi_options_proxy_port = 0;
231 // ----------------------------------------------------------------------------------
232 // MULTI OPTIONS FUNCTIONS
236 void multi_options_read_config_fs1();
239 // load in the config file
240 #define NEXT_TOKEN() do { tok = strtok(NULL, "\n"); if(tok != NULL){ drop_leading_white_space(tok); drop_trailing_white_space(tok); } } while(0);
241 #define SETTING(s) ( !SDL_strcasecmp(tok, s) )
242 void multi_options_read_config()
244 // set default value for the global multi options
245 memset(&Multi_options_g, 0, sizeof(multi_global_options));
246 Multi_options_g.protocol = NET_TCP;
248 Multi_options_g.pxo = 1;
251 // do we have a forced port via commandline or registry?
252 ushort forced_port = (ushort)os_config_read_uint("Network", "ForcePort", 0);
253 Multi_options_g.port = (Cmdline_network_port >= 0) ? (ushort)Cmdline_network_port : forced_port == 0 ? (ushort)DEFAULT_GAME_PORT : forced_port;
255 Multi_options_g.log = (Cmdline_multi_log) ? 1 : 0;
256 Multi_options_g.datarate_cap = OO_HIGH_RATE_DEFAULT;
257 SDL_strlcpy(Multi_options_g.user_tracker_ip, "", SDL_arraysize(Multi_options_g.user_tracker_ip));
258 SDL_strlcpy(Multi_options_g.game_tracker_ip, "", SDL_arraysize(Multi_options_g.game_tracker_ip));
259 SDL_strlcpy(Multi_options_g.pxo_ip, "", SDL_arraysize(Multi_options_g.pxo_ip));
260 SDL_strlcpy(Multi_options_g.pxo_rank_url, "", SDL_arraysize(Multi_options_g.pxo_rank_url));
261 SDL_strlcpy(Multi_options_g.pxo_create_url, "", SDL_arraysize(Multi_options_g.pxo_create_url));
262 SDL_strlcpy(Multi_options_g.pxo_verify_url, "", SDL_arraysize(Multi_options_g.pxo_verify_url));
263 SDL_strlcpy(Multi_options_g.pxo_banner_url, "", SDL_arraysize(Multi_options_g.pxo_banner_url));
266 Multi_options_g.std_max_players = -1;
267 Multi_options_g.std_datarate = OBJ_UPDATE_HIGH;
268 Multi_options_g.std_voice = 1;
269 memset(Multi_options_g.std_passwd, 0, STD_PASSWD_LEN);
270 memset(Multi_options_g.std_pname, 0, STD_NAME_LEN);
271 Multi_options_g.std_framecap = 30;
278 // read in the config file
279 in = cfopen(MULTI_CFG_FILE, "rt", CFILE_NORMAL, CF_TYPE_DATA);
281 // if we failed to open the config file, user default settings
283 nprintf(("Network","Failed to open network config file, using default settings\n"));
288 // read in the game info
292 // parse the first line
293 tok = strtok(str," \t");
297 drop_leading_white_space(tok);
298 drop_trailing_white_space(tok);
303 // all possible options
304 // only standalone cares about the following options
308 Multi_options_g.pxo = 1;
311 SDL_strlcpy(Multi_fs_tracker_channel, tok, SDL_arraysize(Multi_fs_tracker_channel));
314 if(SETTING("+name")){
315 // set the standalone server's permanent name
318 SDL_strlcpy(Multi_options_g.std_pname, tok, STD_NAME_LEN);
321 if(SETTING("+no_voice")){
322 // standalone won't allow voice transmission
323 Multi_options_g.std_voice = 0;
325 if(SETTING("+max_players")){
326 // set the max # of players on the standalone
329 if(!((atoi(tok) < 1) || (atoi(tok) > MAX_PLAYERS))){
330 Multi_options_g.std_max_players = atoi(tok);
341 if(SETTING("+passwd")){
342 // set the standalone host password
345 SDL_strlcpy(Multi_options_g.std_passwd, tok, STD_PASSWD_LEN);
350 if(SETTING("+low_update")){
351 // set standalone to low updates
352 Multi_options_g.std_datarate = OBJ_UPDATE_LOW;
354 if(SETTING("+med_update")){
355 // set standalone to medium updates
356 Multi_options_g.std_datarate = OBJ_UPDATE_MEDIUM;
358 if(SETTING("+high_update")){
359 // set standalone to high updates
360 Multi_options_g.std_datarate = OBJ_UPDATE_HIGH;
362 if(SETTING("+lan_update")){
363 // set standalone to high updates
364 Multi_options_g.std_datarate = OBJ_UPDATE_LAN;
368 // common to all modes
369 if(SETTING("+user_server")){
370 // ip addr of user tracker
373 SDL_strlcpy(Multi_options_g.user_tracker_ip, tok, SDL_arraysize(Multi_options_g.user_tracker_ip));
376 if(SETTING("+game_server")){
377 // ip addr of game tracker
380 SDL_strlcpy(Multi_options_g.game_tracker_ip, tok, SDL_arraysize(Multi_options_g.game_tracker_ip));
383 if(SETTING("+chat_server")){
384 // ip addr of pxo chat server
387 SDL_strlcpy(Multi_options_g.pxo_ip, tok, SDL_arraysize(Multi_options_g.pxo_ip));
390 if(SETTING("+rank_url")){
391 // url of pilot rankings page
394 SDL_strlcpy(Multi_options_g.pxo_rank_url, tok, SDL_arraysize(Multi_options_g.pxo_rank_url));
397 if(SETTING("+create_url")){
398 // url of pxo account create page
401 SDL_strlcpy(Multi_options_g.pxo_create_url, tok, SDL_arraysize(Multi_options_g.pxo_create_url));
404 if(SETTING("+verify_url")){
405 // url of pxo account verify page
408 SDL_strlcpy(Multi_options_g.pxo_verify_url, tok, SDL_arraysize(Multi_options_g.pxo_verify_url));
411 if(SETTING("+banner_url")){
412 // url of pxo account verify page
415 SDL_strlcpy(Multi_options_g.pxo_banner_url, tok, SDL_arraysize(Multi_options_g.pxo_banner_url));
418 if(SETTING("+datarate")){
419 // set the max datarate for high updates
422 if(atoi(tok) >= 4000){
423 Multi_options_g.datarate_cap = atoi(tok);
427 if(SETTING("+http_proxy")){
428 // get the proxy server
431 char *ip = strtok(tok, ":");
433 SDL_strlcpy(Multi_options_proxy, ip, SDL_arraysize(Multi_options_proxy));
435 ip = strtok(NULL, "");
437 Multi_options_proxy_port = (ushort)atoi(ip);
439 SDL_strlcpy(Multi_options_proxy, "", SDL_arraysize(Multi_options_proxy));
445 // close the config file
449 multi_options_read_config_fs1();
454 void multi_options_read_config_fs1()
461 // FS1 demo is single-player only, so don't bother with this
467 // read in the pxo config file
468 in = cfopen("pxo.cfg", "rt", CFILE_NORMAL, CF_TYPE_DATA);
471 // first line should be user tracker
472 if ( cfgets(str, 512, in) ) {
473 drop_leading_white_space(str);
474 drop_trailing_white_space(str);
476 SDL_strlcpy(Multi_options_g.user_tracker_ip, str, SDL_arraysize(Multi_options_g.user_tracker_ip));
479 // next line should be game tracker
480 if ( cfgets(str, 512, in) ) {
481 drop_leading_white_space(str);
482 drop_trailing_white_space(str);
484 SDL_strlcpy(Multi_options_g.game_tracker_ip, str, SDL_arraysize(Multi_options_g.game_tracker_ip));
487 // next, irc/chat server
488 if ( cfgets(str, 512, in) ) {
489 drop_leading_white_space(str);
490 drop_trailing_white_space(str);
492 SDL_strlcpy(Multi_options_g.pxo_ip, str, SDL_arraysize(Multi_options_g.pxo_ip));
495 // web link: rankings
496 if ( cfgets(str, 512, in) ) {
497 drop_leading_white_space(str);
498 drop_trailing_white_space(str);
500 SDL_strlcpy(Multi_options_g.pxo_rank_url, str, SDL_arraysize(Multi_options_g.pxo_rank_url));
503 // web link: register/create account
504 if ( cfgets(str, 512, in) ) {
505 drop_leading_white_space(str);
506 drop_trailing_white_space(str);
508 SDL_strlcpy(Multi_options_g.pxo_create_url, str, SDL_arraysize(Multi_options_g.pxo_create_url));
511 // web link: verify account/user
512 if ( cfgets(str, 512, in) ) {
513 drop_leading_white_space(str);
514 drop_trailing_white_space(str);
516 SDL_strlcpy(Multi_options_g.pxo_verify_url, str, SDL_arraysize(Multi_options_g.pxo_verify_url));
523 // maybe read standalone config
525 // read in the config file
526 in = cfopen("std.cfg", "rt", CFILE_NORMAL, CF_TYPE_DATA);
530 // read in the game info
534 // parse the first line
535 tok = strtok(str," \t");
539 drop_leading_white_space(tok);
540 drop_trailing_white_space(tok);
552 if(SETTING("+name")){
553 // set the standalone server's permanent name
556 SDL_strlcpy(Multi_options_g.std_pname, tok, STD_NAME_LEN);
559 if(SETTING("+no_voice")){
560 // standalone won't allow voice transmission
561 Multi_options_g.std_voice = 0;
563 if(SETTING("+max_players")){
564 // set the max # of players on the standalone
567 if(!((atoi(tok) < 1) || (atoi(tok) > MAX_PLAYERS))){
568 Multi_options_g.std_max_players = atoi(tok);
579 if(SETTING("+passwd")){
580 // set the standalone host password
583 SDL_strlcpy(Multi_options_g.std_passwd, tok, STD_PASSWD_LEN);
588 if(SETTING("+low_update")){
589 // set standalone to low updates
590 Multi_options_g.std_datarate = OBJ_UPDATE_LOW;
592 if(SETTING("+med_update")){
593 // set standalone to medium updates
594 Multi_options_g.std_datarate = OBJ_UPDATE_MEDIUM;
596 if(SETTING("+high_update")){
597 // set standalone to high updates
598 Multi_options_g.std_datarate = OBJ_UPDATE_HIGH;
600 if(SETTING("+lan_update")){
601 // set standalone to high updates
602 Multi_options_g.std_datarate = OBJ_UPDATE_LAN;
613 // set netgame defaults
614 // NOTE : should be used when creating a newpilot
615 void multi_options_set_netgame_defaults(multi_server_options *options)
617 // any player can do squadmate messaging
618 options->squad_set = MSO_SQUAD_ANY;
620 // only the host can end the game
621 options->endgame_set = MSO_END_HOST;
623 // allow ingame file xfer and custom pilot pix
624 options->flags = (MSO_FLAG_INGAME_XFER | MSO_FLAG_ACCEPT_PIX);
626 // set the default time limit to be -1 (no limit)
627 options->mission_time_limit = fl2f(-1.0f);
629 // set the default max kills for a mission
630 options->kill_limit = 9999;
632 // set the default # of respawns
633 options->respawn = 2;
635 // set the default # of max observers
636 options->max_observers = 2;
638 // set the default netgame qos
639 options->voice_qos = 10;
641 // set the default token timeout
642 options->voice_token_wait = 2000; // he must wait 2 seconds between voice gets
644 // set the default max voice record time
645 options->voice_record_time = 5000;
648 // set local netplayer defaults
649 // NOTE : should be used when creating a newpilot
650 void multi_options_set_local_defaults(multi_local_options *options)
652 // accept pix by default and broadcast on the local subnet
653 options->flags = (MLO_FLAG_ACCEPT_PIX | MLO_FLAG_LOCAL_BROADCAST);
655 // set the object update level based on the type of network connection specified by the user
656 // at install (or launcher) time.
657 if ( Psnet_connection == NETWORK_CONNECTION_DIALUP ) {
658 options->obj_update_level = OBJ_UPDATE_LOW;
660 options->obj_update_level = OBJ_UPDATE_HIGH;
664 // fill in the passed netgame options struct with the data from my player file data (only host/server should do this)
665 void multi_options_netgame_load(multi_server_options *options)
668 memcpy(options,&Player->m_server_options,sizeof(multi_server_options));
672 // fill in the passed local options struct with the data from my player file data (all machines except standalone should do this)
673 void multi_options_local_load(multi_local_options *options, net_player *pxo_pl)
676 memcpy(options,&Player->m_local_options,sizeof(multi_local_options));
679 // stuff pxo squad info
682 SDL_strlcpy(pxo_pl->p_info.pxo_squad_name, Multi_tracker_squad_name, LOGIN_LEN);
687 // update everyone on the current netgame options
688 void multi_options_update_netgame()
690 ubyte data[MAX_PACKET_SIZE],code;
693 SDL_assert(Net_player->flags & NETINFO_FLAG_GAME_HOST);
695 // build the header and add the opcode
696 BUILD_HEADER(OPTIONS_UPDATE);
697 code = MULTI_OPTION_SERVER;
700 // add the netgame options
701 Netgame.options.flags = INTEL_INT( Netgame.options.flags );
702 Netgame.options.respawn = INTEL_INT( Netgame.options.respawn );
703 Netgame.options.voice_token_wait = INTEL_INT( Netgame.options.voice_token_wait );
704 Netgame.options.voice_record_time = INTEL_INT( Netgame.options.voice_record_time );
705 Netgame.options.kill_limit= INTEL_INT( Netgame.options.kill_limit );
706 Netgame.options.mission_time_limit = (fix)INTEL_INT( Netgame.options.mission_time_limit );
707 ADD_DATA(Netgame.options);
710 if(Net_player->flags & NETINFO_FLAG_AM_MASTER){
711 multi_io_send_to_all_reliable(data, packet_size);
713 multi_io_send_reliable(Net_player, data, packet_size);
717 // update everyone with my local settings
718 void multi_options_update_local()
720 ubyte data[MAX_PACKET_SIZE],code;
723 // if i'm the server, don't do anything
724 if(Net_player->flags & NETINFO_FLAG_AM_MASTER){
728 // build the header and add the opcode
729 BUILD_HEADER(OPTIONS_UPDATE);
730 code = MULTI_OPTION_LOCAL;
733 // add the netgame options
734 Net_player->p_info.options.flags = INTEL_INT( Net_player->p_info.options.flags );
735 Net_players->p_info.options.obj_update_level = INTEL_INT( Net_player->p_info.options.obj_update_level );
736 ADD_DATA(Net_player->p_info.options);
739 multi_io_send_reliable(Net_player, data, packet_size);
742 // update the standalone with the settings I have picked at the "start game" screen
743 void multi_options_update_start_game(netgame_info *ng)
745 ubyte data[MAX_PACKET_SIZE],code;
748 // should be a host on a standalone
749 SDL_assert((Net_player->flags & NETINFO_FLAG_GAME_HOST) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER));
752 BUILD_HEADER(OPTIONS_UPDATE);
753 code = MULTI_OPTION_START_GAME;
756 // add the start game options
757 ADD_STRING(ng->name);
759 ADD_INT(ng->security);
761 // add mode-specific data
763 case NG_MODE_PASSWORD:
764 ADD_STRING(ng->passwd);
766 case NG_MODE_RANK_ABOVE:
767 case NG_MODE_RANK_BELOW:
768 ADD_INT(ng->rank_base);
772 // send to the standalone server
773 multi_io_send_reliable(Net_player, data, packet_size);
776 // update the standalone with the mission settings I have picked (mission filename, etc)
777 void multi_options_update_mission(netgame_info *ng, int campaign_mode)
779 ubyte data[MAX_PACKET_SIZE],code;
782 // should be a host on a standalone
783 SDL_assert((Net_player->flags & NETINFO_FLAG_GAME_HOST) && !(Net_player->flags & NETINFO_FLAG_AM_MASTER));
786 BUILD_HEADER(OPTIONS_UPDATE);
787 code = MULTI_OPTION_MISSION;
790 // type (coop or team vs. team)
791 ADD_INT(ng->type_flags);
794 ADD_UINT(ng->respawn);
796 // add the mission/campaign filename
797 code = (ubyte)campaign_mode;
800 ADD_STRING(ng->campaign_name);
802 ADD_STRING(ng->mission_name);
805 // send to the server
806 multi_io_send_reliable(Net_player, data, packet_size);
810 // ----------------------------------------------------------------------------------
811 // MULTI OPTIONS FUNCTIONS
814 // process an incoming multi options packet
815 void multi_options_process_packet(unsigned char *data, header *hinfo)
818 multi_local_options bogus;
819 int idx,player_index;
821 int offset = HEADER_LENGTH;
823 // find out who is sending this data
824 player_index = find_player_id(hinfo->id);
826 // get the packet code
829 // get the start game options
830 case MULTI_OPTION_START_GAME:
831 SDL_assert(Game_mode & GM_STANDALONE_SERVER);
833 // get the netgame name
834 GET_STRING(Netgame.name);
836 // get the netgame mode
837 GET_INT(Netgame.mode);
839 // get the security #
840 GET_INT(Netgame.security);
842 // get mode specific data
843 switch(Netgame.mode){
844 case NG_MODE_PASSWORD:
845 GET_STRING(Netgame.passwd);
847 case NG_MODE_RANK_ABOVE:
848 case NG_MODE_RANK_BELOW:
849 GET_INT(Netgame.rank_base);
853 // update standalone stuff
854 std_connect_set_gamename(Netgame.name);
855 std_multi_update_netgame_info_controls();
858 // get mission choice options
859 case MULTI_OPTION_MISSION:
861 char title[NAME_LENGTH+1];
862 int campaign_type,max_players;
866 SDL_assert(Game_mode & GM_STANDALONE_SERVER);
868 // coop or team vs. team mode
869 GET_INT(ng.type_flags);
870 if((ng.type_flags & NG_TYPE_TEAM) && !(Netgame.type_flags & NG_TYPE_TEAM)){
873 // if squad war was switched on
874 if((ng.type_flags & NG_TYPE_SW) && !(Netgame.type_flags & NG_TYPE_SW)){
875 mprintf(("STANDALONE TURNED ON SQUAD WAR!!\n"));
877 Netgame.type_flags = ng.type_flags;
880 GET_UINT(Netgame.respawn);
888 GET_STRING(ng.campaign_name);
890 // set the netgame max players here if the filename has changed
891 if(strcmp(Netgame.campaign_name,ng.campaign_name)){
893 if(!mission_campaign_get_info(ng.campaign_name,title,&campaign_type,&max_players)){
894 Netgame.max_players = 0;
896 Netgame.max_players = max_players;
899 SDL_strlcpy(Netgame.campaign_name, ng.campaign_name, SDL_arraysize(Netgame.campaign_name));
902 Netgame.campaign_mode = 1;
904 // put brackets around the campaign name
905 if(Game_mode & GM_STANDALONE_SERVER){
906 SDL_snprintf(str, SDL_arraysize(str), "(%s)", Netgame.campaign_name);
907 std_multi_set_standalone_mission_name(str);
912 GET_STRING(ng.mission_name);
914 if(strcmp(Netgame.mission_name,ng.mission_name)){
915 if(strlen(ng.mission_name)){
916 Netgame.max_players = mission_parse_get_multi_mission_info( ng.mission_name );
918 // setting this to -1 will prevent us from being seen on the network
919 Netgame.max_players = -1;
921 SDL_strlcpy(Netgame.mission_name, ng.mission_name, SDL_arraysize(Netgame.mission_name));
922 SDL_strlcpy(Game_current_mission_filename, Netgame.mission_name, SDL_arraysize(Game_current_mission_filename));
925 Netgame.campaign_mode = 0;
927 // set the mission name
928 if(Game_mode & GM_STANDALONE_SERVER){
929 std_multi_set_standalone_mission_name(Netgame.mission_name);
933 send_netgame_update_packet();
936 // get the netgame options
937 case MULTI_OPTION_SERVER:
938 GET_DATA(Netgame.options);
939 Netgame.options.flags = INTEL_INT( Netgame.options.flags );
940 Netgame.options.respawn = INTEL_INT( Netgame.options.respawn );
941 Netgame.options.voice_token_wait = INTEL_INT( Netgame.options.voice_token_wait );
942 Netgame.options.voice_record_time = INTEL_INT( Netgame.options.voice_record_time );
943 Netgame.options.kill_limit = INTEL_INT( Netgame.options.kill_limit );
944 Netgame.options.mission_time_limit = (fix)INTEL_INT( Netgame.options.mission_time_limit );
946 // if we're a standalone set for no sound, do so here
947 if((Game_mode & GM_STANDALONE_SERVER) && !Multi_options_g.std_voice){
948 Netgame.options.flags |= MSO_FLAG_NO_VOICE;
950 // maybe update the quality of sound
951 multi_voice_maybe_update_vars(Netgame.options.voice_qos,Netgame.options.voice_record_time);
954 // set the skill level
955 Game_skill_level = Netgame.options.skill_level;
957 if((Game_mode & GM_STANDALONE_SERVER) && !(Game_mode & GM_CAMPAIGN_MODE)){
958 Netgame.respawn = Netgame.options.respawn;
961 // if we have the "temp closed" flag toggle
962 if(Netgame.options.flags & MLO_FLAG_TEMP_CLOSED){
963 Netgame.flags ^= NG_FLAG_TEMP_CLOSED;
965 Netgame.options.flags &= ~(MLO_FLAG_TEMP_CLOSED);
967 // if i'm the standalone server, I should rebroadcast to all other players
968 if(Game_mode & GM_STANDALONE_SERVER){
969 for(idx=0;idx<MAX_PLAYERS;idx++){
970 if(MULTI_CONNECTED(Net_players[idx]) && (Net_player != &Net_players[idx]) && (&Net_players[idx] != &Net_players[player_index]) ){
971 multi_io_send_reliable(&Net_players[idx], data, offset);
975 send_netgame_update_packet();
979 // local netplayer options
980 case MULTI_OPTION_LOCAL:
981 if(player_index == -1){
982 GET_DATA(bogus); //data not used, so don't swap!
984 GET_DATA(Net_players[player_index].p_info.options);
985 Net_players[player_index].p_info.options.flags = INTEL_INT( Net_players[player_index].p_info.options.flags );
986 Net_players[player_index].p_info.options.obj_update_level = INTEL_INT( Net_players[player_index].p_info.options.obj_update_level );