FF Diff Viewer

Comparing 2006 Base SDK to Fortress Forever 2.46

dlls/gameinterface.cpp

777879808182
#include "sceneentity.h" #include "appframework/IAppSystemGroup.h" #include "scenefilecache/ISceneFileCache.h" #if !defined( _RETAIL ) #ifdef _XBOX
777879808182838485868788
#include "sceneentity.h" #include "appframework/IAppSystemGroup.h" #include "scenefilecache/ISceneFileCache.h" #include "ff_gamerules.h" #include "ff_scriptman.h" #include "ff_luacontext.h" #include "ff_scheduleman.h" #include "ff_timerman.h" #include "util.h" #if !defined( _RETAIL ) #ifdef _XBOX
909192939495
#include "bot/bot.h" #endif IUploadGameStats *gamestatsuploader = NULL; // memdbgon must be the last include file in a .cpp file!!!
96979899100101102103
#include "bot/bot.h" #endif #include "omnibot_interface.h" IUploadGameStats *gamestatsuploader = NULL; // memdbgon must be the last include file in a .cpp file!!!
536537538539540541
// init the cvar list first in case inits want to reference them InitializeCvars(); sv_cheats = (ConVar*) ConCommandBase::FindCommand( "sv_cheats" ); if ( !sv_cheats )
544545546547548549550551552553554555556557558559560561562563
// init the cvar list first in case inits want to reference them InitializeCvars(); // --> Mirv: Default max_updaterate to tickrate ConVar *sv_maxupdaterate = cvar->FindVar("sv_maxupdaterate"); ConVar *sv_maxcmdrate = cvar->FindVar("sv_maxcmdrate"); int nTickRate = 66; if (CommandLine()->CheckParm("-tickrate")) { nTickRate = CommandLine()->ParmValue("-tickrate", 0); nTickRate = clamp(nTickRate, 10, 66); } sv_maxupdaterate->SetValue(nTickRate); sv_maxcmdrate->SetValue(nTickRate); // <-- Mirv sv_cheats = (ConVar*) ConCommandBase::FindCommand( "sv_cheats" ); if ( !sv_cheats )
581582583584585586587
gameeventmanager->LoadEventsFromFile("resource/ModEvents.res"); #ifdef CSTRIKE_DLL // BOTPORT: TODO: move these ifdefs out InstallBotControl(); #endif if ( !IGameSystem::InitAllSystems() )
603604605606607608609
gameeventmanager->LoadEventsFromFile("resource/ModEvents.res"); #ifdef CSTRIKE_DLL // BOTPORT: TODO: move these ifdefs out //InstallBotControl(); #endif if ( !IGameSystem::InitAllSystems() )
606607608609610611
// create the Navigation Mesh interface TheNavMesh = new CNavMesh; // init the gamestatsupload connection gamestatsuploader->InitConnection(); #endif
628629630631632633634635
// create the Navigation Mesh interface TheNavMesh = new CNavMesh; Omnibot::omnibot_interface::OnDLLInit(); // init the gamestatsupload connection gamestatsuploader->InitConnection(); #endif
633634635636637638
void CServerGameDLL::DLLShutdown( void ) { // Due to dependencies, these are not autogamesystems ModelSoundsCacheShutdown();
657658659660661662663
void CServerGameDLL::DLLShutdown( void ) { Omnibot::omnibot_interface::OnDLLShutdown(); // Due to dependencies, these are not autogamesystems ModelSoundsCacheShutdown();
687688689690691692693694695696697698699700701
{ float tickinterval = DEFAULT_TICK_INTERVAL; #if defined( CSTRIKE_DLL ) // in CS reduce tickrate/sec by defualt tickinterval *= 2; #endif // override if tick rate specified in command line if ( CommandLine()->CheckParm( "-tickrate" ) ) { float tickrate = CommandLine()->ParmValue( "-tickrate", 0 ); if ( tickrate > 10 ) tickinterval = 1.0f / tickrate; }
712713714715716717718719720721722723724725726727728729730
{ float tickinterval = DEFAULT_TICK_INTERVAL; //#if defined( CSTRIKE_DLL ) // in CS reduce tickrate/sec by defualt tickinterval *= 2; //#endif // override if tick rate specified in command line if ( CommandLine()->CheckParm( "-tickrate" ) ) { float tickrate = CommandLine()->ParmValue( "-tickrate", 0 ); // Jiggles: Bad stuff happens if the tickrate is set too high if ( tickrate > 66 ) tickrate = 66.0f; if ( tickrate > 10 ) tickinterval = 1.0f / tickrate; }
797798799800801802
ResetWindspeed(); UpdateChapterRestrictions( pMapName ); // IGameSystem::LevelInitPreEntityAllSystems() is called when the world is precached // That happens either in LoadGameState() or in MapEntity_ParseAllEntities() if ( loadGame )
826827828829830831832833834835836837838
ResetWindspeed(); UpdateChapterRestrictions( pMapName ); // Added: Initialize Lua stuff _scheduleman.Init(); _timerman.Init(); _scriptman.LevelInit(pMapName); Omnibot::omnibot_interface::LevelInit(); // IGameSystem::LevelInitPreEntityAllSystems() is called when the world is precached // That happens either in LoadGameState() or in MapEntity_ParseAllEntities() if ( loadGame )
865866867868869870
g_AIFriendliesTalkSemaphore.Release(); g_AIFoesTalkSemaphore.Release(); g_OneWayTransition = false; return true; }
901902903904905906907908909910911912913914915916917918919920
g_AIFriendliesTalkSemaphore.Release(); g_AIFoesTalkSemaphore.Release(); g_OneWayTransition = false; CFFLuaSC hStartup; _scriptman.RunPredicates_LUA(NULL, &hStartup, "startup"); FFGameRules()->UpdateSpawnPoints(); // --> Mirv: Automatically execute map config char szExecMapConfig[128]; Q_snprintf(szExecMapConfig, 127, "exec %.20s.cfg\n", pMapName); engine->ServerCommand(szExecMapConfig); engine->ServerExecute(); // <-- Mirv return true; }
929930931932933934935936937
#ifndef _XBOX // load the Navigation Mesh for this map TheNavMesh->Load(); #endif #ifdef CSTRIKE_DLL // BOTPORT: TODO: move these ifdefs out TheBots->ServerActivate(); #endif
9799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018
#ifndef _XBOX // load the Navigation Mesh for this map // We... don't use this -Mulch //NavErrorType navErr = TheNavMesh->Load(); #endif /* const char *pErrMsg = "Ok"; switch(navErr) { case NAV_CANT_ACCESS_FILE: pErrMsg = "Can't access file!"; break; case NAV_INVALID_FILE: pErrMsg = "Invalid file!"; break; case NAV_BAD_FILE_VERSION: pErrMsg = "Bad file version!"; break; case NAV_FILE_OUT_OF_DATE: pErrMsg = "File out of date!"; break; case NAV_CORRUPT_DATA: pErrMsg = "Corrupt Data!"; break; } if(navErr != NAV_OK) { Warning("NAV MESH STATUS: %s\n", pErrMsg); //TheNavMesh->BeginGeneration(); } */ // Omni-bot: Initialize the bot interface Omnibot::omnibot_interface::InitBotInterface(); #ifdef CSTRIKE_DLL // BOTPORT: TODO: move these ifdefs out TheBots->ServerActivate(); #endif
985986987988989990
GameStartFrame(); #ifndef _XBOX TheNavMesh->Update(); gamestatsuploader->UpdateConnection();
10661067106810691070107110721073
GameStartFrame(); #ifndef _XBOX // Omni-bot: Update the bot interface Omnibot::omnibot_interface::UpdateBotInterface(); TheNavMesh->Update(); gamestatsuploader->UpdateConnection();
110711081109111011111112
// Called when a level is shutdown (including changing levels) void CServerGameDLL::LevelShutdown( void ) { IGameSystem::LevelShutdownPreEntityAllSystems(); // YWB:
119011911192119311941195119611971198
// Called when a level is shutdown (including changing levels) void CServerGameDLL::LevelShutdown( void ) { // Omni-bot: Shut down the bot interface Omnibot::omnibot_interface::ShutdownBotInterface(); IGameSystem::LevelShutdownPreEntityAllSystems(); // YWB:
111511161117111811191120
gEntList.Clear(); IGameSystem::LevelShutdownPostEntityAllSystems(); // In case we quit out during initial load
1201120212031204120512061207120812091210
gEntList.Clear(); _scriptman.LevelShutdown(); _scheduleman.Shutdown(); _timerman.Shutdown(); IGameSystem::LevelShutdownPostEntityAllSystems(); // In case we quit out during initial load
151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540
} static ConVar motdfile( "motdfile", "motd.txt", 0, "The MOTD file to load.", ValidateMOTDFilename ); void CServerGameDLL::LoadMessageOfTheDay() { #ifndef _XBOX char data[2048]; int length = filesystem->Size( motdfile.GetString(), "GAME" ); if ( length <= 0 || length >= (sizeof(data)-1) ) { DevMsg("Invalid file size for %s\n", motdfile.GetString() ); return; } FileHandle_t hFile = filesystem->Open( motdfile.GetString(), "rb", "GAME" ); if ( hFile == FILESYSTEM_INVALID_HANDLE ) return; filesystem->Read( data, length, hFile ); filesystem->Close( hFile ); data[length] = 0; g_pStringTableInfoPanel->AddString( "motd", length+1, data ); #endif }
1601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655
} static ConVar motdfile( "motdfile", "motd.txt", 0, "The MOTD file to load.", ValidateMOTDFilename ); static ConVar hostfile( "hostfile", "host.txt", 0, "The host file to load.", ValidateMOTDFilename ); void CServerGameDLL::LoadMessageOfTheDay() { #ifndef _XBOX char data[2048]; // add motd.txt int length = filesystem->Size( motdfile.GetString(), "GAME" ); if ( length <= 0 || length >= (sizeof(data)-1) ) { DevMsg("Invalid file size for %s\n", motdfile.GetString() ); } else { FileHandle_t hFile = filesystem->Open( motdfile.GetString(), "rb", "GAME" ); if ( hFile != FILESYSTEM_INVALID_HANDLE ) { filesystem->Read( data, length, hFile ); filesystem->Close( hFile ); data[length] = 0; g_pStringTableInfoPanel->AddString( "motd", length+1, data ); } } // add host.txt length = filesystem->Size( hostfile.GetString(), "GAME" ); if ( length <= 0 || length >= (sizeof(data)-1) ) { DevMsg("Invalid file size for %s\n", hostfile.GetString() ); } else { FileHandle_t hFile = filesystem->Open( hostfile.GetString(), "rb", "GAME" ); if ( hFile != FILESYSTEM_INVALID_HANDLE ) { filesystem->Read( data, length, hFile ); filesystem->Close( hFile ); data[length] = 0; g_pStringTableInfoPanel->AddString( "host", length+1, data ); } } #endif }
192919301931193219331934
CServerGameClients g_ServerGameClients; EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CServerGameClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS, g_ServerGameClients ); //----------------------------------------------------------------------------- // Purpose: called when a player tries to connect to the server
204420452046204720482049205020512052
CServerGameClients g_ServerGameClients; EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CServerGameClients, IServerGameClients, INTERFACEVERSION_SERVERGAMECLIENTS, g_ServerGameClients ); // Jon: reading from a file now //extern const char *MOD_SERVER_VERSION; char *GetModVersion(); //----------------------------------------------------------------------------- // Purpose: called when a player tries to connect to the server
194219431944194519461947
//----------------------------------------------------------------------------- bool CServerGameClients::ClientConnect( edict_t *pEdict, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) { return g_pGameRules->ClientConnected( pEdict, pszName, pszAddress, reject, maxrejectlen ); }
2060206120622063206420652066
//----------------------------------------------------------------------------- bool CServerGameClients::ClientConnect( edict_t *pEdict, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen ) { engine->ClientCommand(pEdict, UTIL_VarArgs("sync_version %s\n", GetModVersion())); return g_pGameRules->ClientConnected( pEdict, pszName, pszAddress, reject, maxrejectlen ); }
195119521953195419551956
//----------------------------------------------------------------------------- void CServerGameClients::ClientActive( edict_t *pEdict, bool bLoadGame ) { MDLCACHE_CRITICAL_SECTION(); ::ClientActive( pEdict, bLoadGame );
20702071207220732074207520762077
//----------------------------------------------------------------------------- void CServerGameClients::ClientActive( edict_t *pEdict, bool bLoadGame ) { engine->ClientCommand(pEdict, UTIL_VarArgs("sync_version %s\n", GetModVersion())); MDLCACHE_CRITICAL_SECTION(); ::ClientActive( pEdict, bLoadGame );
19871988198919901991199219931994
{ if ( !g_fGameOver ) { player->SetMaxSpeed( 0.0f ); CSound *pSound; pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEdict ) ); {
210821092110211121122113
{ if ( !g_fGameOver ) { CSound *pSound; pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEdict ) ); {
200920102011201220132014
{ g_pGameRules->ClientDisconnected( pEdict ); } } // Make sure all Untouch()'s are called for this client leaving
2128212921302131213221332134213521362137
{ g_pGameRules->ClientDisconnected( pEdict ); } // --> FF: moved this SetMaxSpeed call below ClientDisconnected player->SetMaxSpeed( 0.0f ); // <-- FF: moved this SetMaxSpeed call below ClientDisconnected } // Make sure all Untouch()'s are called for this client leaving
203620372038203920402041
::ClientCommand(player); } //----------------------------------------------------------------------------- // Purpose: called after the player changes userinfo - gives dll a chance to modify // it before it gets sent into the rest of the engine->
21592160216121622163216421652166
::ClientCommand(player); } static ConVar *pMaxUpdateRate = NULL; //----------------------------------------------------------------------------- // Purpose: called after the player changes userinfo - gives dll a chance to modify // it before it gets sent into the rest of the engine->
205720582059206020612062206320642065206620672068
// get network setting for prediction & lag compensation player->m_nUpdateRate = Q_atoi( QUICKGETCVARVALUE("cl_updaterate") ); bool useInterpolation = Q_atoi( QUICKGETCVARVALUE("cl_interpolate") ) != 0; if ( useInterpolation ) { player->m_fLerpTime = Q_atof( QUICKGETCVARVALUE("cl_interp") ); } else {
2182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206
// get network setting for prediction & lag compensation player->m_nUpdateRate = Q_atoi( QUICKGETCVARVALUE("cl_updaterate") ); // --> Mirv: This seems like a wise idea #undef min if (!pMaxUpdateRate) pMaxUpdateRate = cvar->FindVar("sv_maxupdaterate"); player->m_nUpdateRate = std::min(player->m_nUpdateRate, pMaxUpdateRate->GetInt()); // <-- Mirv bool useInterpolation = Q_atoi( QUICKGETCVARVALUE("cl_interpolate") ) != 0; if ( useInterpolation ) { // --> Mirv: Use our new ratio thing //player->m_fLerpTime = Q_atof( QUICKGETCVARVALUE("cl_interp") ); // We use cl_interp_ratio / update rate to calculate the interpolation required. float flRatio = Q_atof(QUICKGETCVARVALUE("cl_interp_ratio")); player->m_fLerpTime = flRatio / (float) player->m_nUpdateRate; // <-- Mirv } else {