From 0364a57abe2365a20828b8c11fafd4c4e5772da8 Mon Sep 17 00:00:00 2001 From: IR4T4 Date: Fri, 4 May 2012 22:14:52 +0200 Subject: [PATCH] server single player code removal - refs #31 --- src/server/sv_bot.c | 18 ++---- src/server/sv_ccmds.c | 130 +++------------------------------------ src/server/sv_client.c | 22 +++---- src/server/sv_init.c | 28 ++------- src/server/sv_main.c | 22 ------- src/server/sv_net_chan.c | 19 +++--- 6 files changed, 34 insertions(+), 205 deletions(-) diff --git a/src/server/sv_bot.c b/src/server/sv_bot.c index e12524fda..367c419ce 100644 --- a/src/server/sv_bot.c +++ b/src/server/sv_bot.c @@ -651,21 +651,13 @@ int SV_BotLibSetup(void) bot_norcd = Cvar_Get("bot_norcd", "0", 0); botlib_export->BotLibVarSet("bot_norcd", bot_norcd->string); - // RF, set AAS routing max per frame - if (SV_GameIsSinglePlayer()) - { - bot_frameroutingupdates = Cvar_Get("bot_frameroutingupdates", "9999999", 0); - } - else // more restrictive in multiplayer - { - bot_frameroutingupdates = Cvar_Get("bot_frameroutingupdates", "1000", 0); - } + // RF, set AAS routing max per frame - restrictive in multiplayer + // TODO #3: remove all bot_ cvars + bot_frameroutingupdates = Cvar_Get("bot_frameroutingupdates", "1000", 0); + botlib_export->BotLibVarSet("bot_frameroutingupdates", bot_frameroutingupdates->string); -// START Arnout changes, 28-08-2002. -// added single player - return botlib_export->BotLibSetup((SV_GameIsSinglePlayer() || SV_GameIsCoop())); -// END Arnout changes, 28-08-2002. + return botlib_export->BotLibSetup(qfalse); } /* diff --git a/src/server/sv_ccmds.c b/src/server/sv_ccmds.c index 73e1f296c..09fb50884 100644 --- a/src/server/sv_ccmds.c +++ b/src/server/sv_ccmds.c @@ -159,12 +159,9 @@ static void SV_Map_f(void) { char *cmd; char *map; - char smapname[MAX_QPATH]; char mapname[MAX_QPATH]; qboolean killBots, cheat, buildScript; char expanded[MAX_QPATH]; - int savegameTime = -1; - char *cl_profileStr = Cvar_VariableString("cl_profile"); map = Cmd_Argv(1); if (!map) @@ -183,102 +180,9 @@ static void SV_Map_f(void) buildScript = Cvar_VariableIntegerValue("com_buildScript"); - if (SV_GameIsSinglePlayer()) - { - if (!buildScript && sv_reloading->integer && sv_reloading->integer != RELOAD_NEXTMAP) // game is in 'reload' mode, don't allow starting new maps yet. - { - return; - } - - // Trap a savegame load - if (strstr(map, ".sav")) - { - // open the savegame, read the mapname, and copy it to the map string - char savemap[MAX_QPATH]; - char savedir[MAX_QPATH]; - byte *buffer; - int size, csize; - - if (com_gameInfo.usesProfiles && cl_profileStr[0]) - { - Com_sprintf(savedir, sizeof(savedir), "profiles/%s/save/", cl_profileStr); - } - else - { - Q_strncpyz(savedir, "save/", sizeof(savedir)); - } - - if (!(strstr(map, savedir) == map)) - { - Com_sprintf(savemap, sizeof(savemap), "%s%s", savedir, map); - } - else - { - strcpy(savemap, map); - } - - size = FS_ReadFile(savemap, NULL); - if (size < 0) - { - Com_Printf("Can't find savegame %s\n", savemap); - return; - } - - //buffer = Hunk_AllocateTempMemory(size); - FS_ReadFile(savemap, (void **)&buffer); - - if (Q_stricmp(savemap, va("%scurrent.sav", savedir)) != 0) - { - // copy it to the current savegame file - FS_WriteFile(va("%scurrent.sav", savedir), buffer, size); - // make sure it is the correct size - csize = FS_ReadFile(va("%scurrent.sav", savedir), NULL); - if (csize != size) - { - Hunk_FreeTempMemory(buffer); - FS_Delete(va("%scurrent.sav", savedir)); -// TTimo -#ifdef __linux__ - Com_Error(ERR_DROP, "Unable to save game.\n\nPlease check that you have at least 5mb free of disk space in your home directory."); -#else - Com_Error(ERR_DROP, "Insufficient free disk space.\n\nPlease free at least 5mb of free space on game drive."); -#endif - return; - } - } - - // set the cvar, so the game knows it needs to load the savegame once the clients have connected - Cvar_Set("savegame_loading", "1"); - // set the filename - Cvar_Set("savegame_filename", savemap); - - // the mapname is at the very start of the savegame file - Com_sprintf(savemap, sizeof(savemap), "%s", ( char * )(buffer + sizeof(int))); // skip the version - Q_strncpyz(smapname, savemap, sizeof(smapname)); - map = smapname; - - savegameTime = *( int * )(buffer + sizeof(int) + MAX_QPATH); - - if (savegameTime >= 0) - { - svs.time = savegameTime; - } - - Hunk_FreeTempMemory(buffer); - } - else - { - Cvar_Set("savegame_loading", "0"); // make sure it's turned off - // set the filename - Cvar_Set("savegame_filename", ""); - } - } - else - { - Cvar_Set("savegame_loading", "0"); // make sure it's turned off - // set the filename - Cvar_Set("savegame_filename", ""); - } + Cvar_Set("savegame_loading", "0"); // make sure it's turned off + // set the filename + Cvar_Set("savegame_filename", ""); // make sure the level exists before trying to change, so that // a typo at the server console won't end the game @@ -392,13 +296,10 @@ NERVE - SMF */ static qboolean SV_TransitionGameState(gamestate_t new_gs, gamestate_t old_gs, int delay) { - if (!SV_GameIsSinglePlayer() && !SV_GameIsCoop()) + // we always do a warmup before starting match + if (old_gs == GS_INTERMISSION && new_gs == GS_PLAYING) { - // we always do a warmup before starting match - if (old_gs == GS_INTERMISSION && new_gs == GS_PLAYING) - { - new_gs = GS_WARMUP; - } + new_gs = GS_WARMUP; } // check if its a valid state transition @@ -476,20 +377,13 @@ static void SV_MapRestart_f(void) // NERVE - SMF - read in gamestate or just default to GS_PLAYING old_gs = atoi(Cvar_VariableString("gamestate")); - if (SV_GameIsSinglePlayer() || SV_GameIsCoop()) + if (Cmd_Argc() > 2) { - new_gs = GS_PLAYING; + new_gs = atoi(Cmd_Argv(2)); } else { - if (Cmd_Argc() > 2) - { - new_gs = atoi(Cmd_Argv(2)); - } - else - { - new_gs = GS_PLAYING; - } + new_gs = GS_PLAYING; } if (!SV_TransitionGameState(new_gs, old_gs, delay)) @@ -597,10 +491,6 @@ static void SV_MapRestart_f(void) if (client->netchan.remoteAddress.type == NA_BOT) { - if (SV_GameIsSinglePlayer() || SV_GameIsCoop()) - { - continue; // dont carry across bots in single player - } isBot = qtrue; } else @@ -618,7 +508,7 @@ static void SV_MapRestart_f(void) // this generally shouldn't happen, because the client // was connected before the level change SV_DropClient(client, denied); - if ((!SV_GameIsSinglePlayer()) || (!isBot)) + if (!isBot) { Com_Printf("SV_MapRestart_f(%d): dropped client %i - denied!\n", delay, i); // bk010125 } diff --git a/src/server/sv_client.c b/src/server/sv_client.c index a4f6003bc..bf3df0928 100644 --- a/src/server/sv_client.c +++ b/src/server/sv_client.c @@ -61,12 +61,6 @@ void SV_GetChallenge(netadr_t from) int oldestTime; challenge_t *challenge; - // ignore if we are in single player - if (SV_GameIsSinglePlayer()) - { - return; - } - if (SV_TempBanIsBanned(from)) { NET_OutOfBandPrint(NS_SERVER, from, "print\n%s\n", sv_tempbanmessage->string); @@ -619,7 +613,7 @@ void SV_DropClient(client_t *drop, const char *reason) SV_CloseDownload(drop); } - if ((!SV_GameIsSinglePlayer()) || (!isBot)) + if (!isBot) { // tell everyone why they got dropped @@ -1935,14 +1929,14 @@ static void SV_UserMove(client_t *cl, msg_t *msg, qboolean delta) //if ( cmds[i].serverTime > svs.time + 3000 ) { // continue; //} - if (!SV_GameIsSinglePlayer()) // We need to allow this in single player, where loadgame's can cause the player to freeze after reloading if we do this check - { // don't execute if this is an old cmd which is already executed - // these old cmds are included when cl_packetdup > 0 - if (cmds[i].serverTime <= cl->lastUsercmd.serverTime) // Q3_MISSIONPACK - { // if ( cmds[i].serverTime > cmds[cmdCount-1].serverTime ) { - continue; // from just before a map_restart - } + + // don't execute if this is an old cmd which is already executed + // these old cmds are included when cl_packetdup > 0 + if (cmds[i].serverTime <= cl->lastUsercmd.serverTime) // Q3_MISSIONPACK + { // if ( cmds[i].serverTime > cmds[cmdCount-1].serverTime ) { + continue; // from just before a map_restart } + SV_ClientThink(cl, &cmds[i]); } } diff --git a/src/server/sv_init.c b/src/server/sv_init.c index d5788d1d9..cc6a523d7 100644 --- a/src/server/sv_init.c +++ b/src/server/sv_init.c @@ -124,10 +124,13 @@ void SV_UpdateConfigStrings(void) // RF, re-enabled // Arnout: removed hardcoded gametype // Arnout: added coop + // Ir4T4: fully disabled never true for MP - FIXME: do we have to send to OB ? + /* if ((SV_GameIsSinglePlayer() || SV_GameIsCoop()) && client->gentity && (client->gentity->r.svFlags & SVF_BOT)) { continue; } + */ len = strlen(sv.configstrings[index]); if (len >= maxChunkSize) @@ -286,20 +289,6 @@ void SV_BoundMaxClients(int minimum) Cvar_Get("sv_maxclients", "20", 0); // NERVE - SMF - changed to 20 from 8 #endif - // START xkan, 10/03/2002 - // allow many bots in single player. note that this pretty much means all previous - // settings will be ignored (including the one set through "seta sv_maxclients " - // in user profile's wolfconfig_mp.cfg). also that if the user subsequently start - // the server in multiplayer mode, the number of clients will still be the number - // set here, which may be wrong - we can certainly just set it to a sensible number - // when it is not in single player mode in the else part of the if statement when - // necessary - if (SV_GameIsSinglePlayer() || SV_GameIsCoop()) - { - Cvar_Set("sv_maxclients", "64"); - } - // END xkan, 10/03/2002 - sv_maxclients->modified = qfalse; if (sv_maxclients->integer < minimum) @@ -639,17 +628,8 @@ void SV_SpawnServer(char *server, qboolean killBots) // set nextmap to the same map, but it may be overriden // by the game startup or another console command Cvar_Set("nextmap", "map_restart 0"); -// Cvar_Set( "nextmap", va("map %s", server) ); - // Ridah - // DHM - Nerve :: We want to use the completion bar in multiplayer as well - // Arnout: just always use it -// if( !SV_GameIsSinglePlayer() ) { SV_SetExpectedHunkUsage(va("maps/%s.bsp", server)); -// } else { - // just set it to a negative number,so the cgame knows not to draw the percent bar -// Cvar_Set( "com_expectedhunkusage", "-1" ); -// } // make sure we are not paused Cvar_Set("cl_paused", "0"); @@ -718,7 +698,7 @@ void SV_SpawnServer(char *server, qboolean killBots) if (svs.clients[i].netchan.remoteAddress.type == NA_BOT) { - if (killBots || SV_GameIsSinglePlayer() || SV_GameIsCoop()) + if (killBots) { SV_DropClient(&svs.clients[i], ""); continue; diff --git a/src/server/sv_main.c b/src/server/sv_main.c index 186cf4506..cdf3d8493 100644 --- a/src/server/sv_main.c +++ b/src/server/sv_main.c @@ -249,11 +249,6 @@ void SV_MasterHeartbeat(const char *message) netenabled = Cvar_VariableIntegerValue("net_enabled"); - if (SV_GameIsSinglePlayer()) - { - return; // no heartbeats for SP - } - // "dedicated 1" is for lan play, "dedicated 2" is for inet public play if (!com_dedicated || com_dedicated->integer != 2 || !(netenabled & (NET_ENABLEV4 | NET_ENABLEV6))) { @@ -361,11 +356,6 @@ void SV_MasterGameCompleteStatus() static netadr_t adr[MAX_MASTER_SERVERS]; int i; - if (SV_GameIsSinglePlayer()) - { - return; // no master game status for SP - } - // "dedicated 1" is for lan play, "dedicated 2" is for inet public play if (!com_dedicated || com_dedicated->integer != 2) { @@ -640,12 +630,6 @@ static void SVC_Status(netadr_t from) char infostring[MAX_INFO_STRING]; static leakyBucket_t bucket; - // ignore if we are in single player - if (SV_GameIsSinglePlayer()) - { - return; - } - // Prevent using getstatus as an amplifier if (SVC_RateLimitAddress(from, 10, 1000)) { @@ -706,12 +690,6 @@ void SVC_Info(netadr_t from) char *weaprestrict; char *balancedteams; - // ignore if we are in single player - if (SV_GameIsSinglePlayer()) - { - return; - } - /* * Check whether Cmd_Argv(1) has a sane length. This was not done in the original Quake3 version which led * to the Infostring bug discovered by Luigi Auriemma. See http://aluigi.altervista.org/ for the advisory. diff --git a/src/server/sv_net_chan.c b/src/server/sv_net_chan.c index e918239f3..d66c6d070 100644 --- a/src/server/sv_net_chan.c +++ b/src/server/sv_net_chan.c @@ -175,10 +175,8 @@ void SV_Netchan_TransmitNextFragment(client_t *client) client->netchan_end_queue = NULL; } - if (!SV_GameIsSinglePlayer()) - { - SV_Netchan_Encode(client, &netbuf->msg, netbuf->lastClientCommandString); - } + SV_Netchan_Encode(client, &netbuf->msg, netbuf->lastClientCommandString); + Netchan_Transmit(&client->netchan, netbuf->msg.cursize, netbuf->msg.data); Z_Free(netbuf); @@ -259,10 +257,8 @@ void SV_Netchan_Transmit(client_t *client, msg_t *msg) //int length, const } else { - if (!SV_GameIsSinglePlayer()) - { - SV_Netchan_Encode(client, msg, client->lastClientCommandString); - } + SV_Netchan_Encode(client, msg, client->lastClientCommandString); + Netchan_Transmit(&client->netchan, msg->cursize, msg->data); } } @@ -280,9 +276,8 @@ qboolean SV_Netchan_Process(client_t *client, msg_t *msg) { return qfalse; } - if (!SV_GameIsSinglePlayer()) - { - SV_Netchan_Decode(client, msg); - } + + SV_Netchan_Decode(client, msg); + return qtrue; }