Skip to content

Commit

Permalink
server single player code removal - refs #31
Browse files Browse the repository at this point in the history
  • Loading branch information
IR4T4 committed May 4, 2012
1 parent d8566e6 commit 0364a57
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 205 deletions.
18 changes: 5 additions & 13 deletions src/server/sv_bot.c
Expand Up @@ -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);
}

/*
Expand Down
130 changes: 10 additions & 120 deletions src/server/sv_ccmds.c
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand All @@ -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
}
Expand Down
22 changes: 8 additions & 14 deletions src/server/sv_client.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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]);
}
}
Expand Down
28 changes: 4 additions & 24 deletions src/server/sv_init.c
Expand Up @@ -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)
Expand Down Expand Up @@ -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 <num>"
// 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)
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 0 additions & 22 deletions src/server/sv_main.c
Expand Up @@ -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)))
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 0364a57

Please sign in to comment.