From 39ed87570bdb2f86969d4be821c94b722dc71179 Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Wed, 26 Jun 2013 15:22:04 -0700 Subject: First version of the SOurce SDK 2013 --- mp/src/game/server/game.cpp | 111 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 mp/src/game/server/game.cpp (limited to 'mp/src/game/server/game.cpp') diff --git a/mp/src/game/server/game.cpp b/mp/src/game/server/game.cpp new file mode 100644 index 00000000..8cc79541 --- /dev/null +++ b/mp/src/game/server/game.cpp @@ -0,0 +1,111 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: +// +// $NoKeywords: $ +// +//=============================================================================// +#include "cbase.h" +#include "game.h" +#include "physics.h" + +// memdbgon must be the last include file in a .cpp file!!! +#include "tier0/memdbgon.h" + +void MapCycleFileChangedCallback( IConVar *var, const char *pOldString, float flOldValue ) +{ + if ( Q_stricmp( pOldString, mapcyclefile.GetString() ) != 0 ) + { + if ( GameRules() ) + { + // For multiplayer games, forces the mapcyclefile to be reloaded + GameRules()->ResetMapCycleTimeStamp(); + } + } +} + +ConVar displaysoundlist( "displaysoundlist","0" ); +ConVar mapcyclefile( "mapcyclefile", "mapcycle.txt", FCVAR_NONE, "Name of the .txt file used to cycle the maps on multiplayer servers ", MapCycleFileChangedCallback ); +ConVar servercfgfile( "servercfgfile","server.cfg" ); +ConVar lservercfgfile( "lservercfgfile","listenserver.cfg" ); + +// multiplayer server rules +ConVar teamplay( "mp_teamplay","0", FCVAR_NOTIFY ); +ConVar falldamage( "mp_falldamage","0", FCVAR_NOTIFY ); +ConVar weaponstay( "mp_weaponstay","0", FCVAR_NOTIFY ); +ConVar forcerespawn( "mp_forcerespawn","1", FCVAR_NOTIFY ); +ConVar footsteps( "mp_footsteps","1", FCVAR_NOTIFY ); +#ifdef CSTRIKE +ConVar flashlight( "mp_flashlight","1", FCVAR_NOTIFY ); +#else +ConVar flashlight( "mp_flashlight","0", FCVAR_NOTIFY ); +#endif +ConVar aimcrosshair( "mp_autocrosshair","1", FCVAR_NOTIFY ); +ConVar decalfrequency( "decalfrequency","10", FCVAR_NOTIFY ); +ConVar teamlist( "mp_teamlist","hgrunt;scientist", FCVAR_NOTIFY ); +ConVar teamoverride( "mp_teamoverride","1" ); +ConVar defaultteam( "mp_defaultteam","0" ); +ConVar allowNPCs( "mp_allowNPCs","1", FCVAR_NOTIFY ); + +// Engine Cvars +const ConVar *g_pDeveloper = NULL; + + +ConVar suitvolume( "suitvolume", "0.25", FCVAR_ARCHIVE ); + +class CGameDLL_ConVarAccessor : public IConCommandBaseAccessor +{ +public: + virtual bool RegisterConCommandBase( ConCommandBase *pCommand ) + { + // Remember "unlinked" default value for replicated cvars + bool replicated = pCommand->IsFlagSet( FCVAR_REPLICATED ); + const char *defvalue = NULL; + if ( replicated && !pCommand->IsCommand() ) + { + defvalue = ( ( ConVar * )pCommand)->GetDefault(); + } + + // Link to engine's list instead + cvar->RegisterConCommand( pCommand ); + + // Apply any command-line values. + const char *pValue = cvar->GetCommandLineValue( pCommand->GetName() ); + if( pValue ) + { + if ( !pCommand->IsCommand() ) + { + ( ( ConVar * )pCommand )->SetValue( pValue ); + } + } + else + { + // NOTE: If not overridden at the command line, then if it's a replicated cvar, make sure that it's + // value is the server's value. This solves a problem where think_limit is defined in shared + // code but the value is inside and #if defined( _DEBUG ) block and if you have a debug game .dll + // and a release client, then the limiit was coming from the client even though the server value + // was the one that was important during debugging. Now the server trumps the client value for + // replicated ConVars by setting the value here after the ConVar has been linked. + if ( replicated && defvalue && !pCommand->IsCommand() ) + { + ConVar *var = ( ConVar * )pCommand; + var->SetValue( defvalue ); + } + } + + return true; + } +}; + +static CGameDLL_ConVarAccessor g_ConVarAccessor; + +// Register your console variables here +// This gets called one time when the game is initialied +void InitializeCvars( void ) +{ + // Register cvars here: + ConVar_Register( FCVAR_GAMEDLL, &g_ConVarAccessor ); + + g_pDeveloper = cvar->FindVar( "developer" ); +} + -- cgit v1.2.3