diff --git a/mp/src/game/client/ff/ff_cl_dll_interface.cpp b/mp/src/game/client/ff/ff_cl_dll_interface.cpp index 3d35a7b5..ca02754c 100644 --- a/mp/src/game/client/ff/ff_cl_dll_interface.cpp +++ b/mp/src/game/client/ff/ff_cl_dll_interface.cpp @@ -10,8 +10,9 @@ int CFF_CL_DLL_Interface::Init( CreateInterfaceFn appSystemFactory, CreateInterf { int ret = BaseClass::Init( appSystemFactory, physicsFactory, pGlobals ); - // initialize UI Lua VM + // start the Lua VM g_UIScriptManager.Init(); + g_GameScriptManager.Init(); // Test steam API uint32 appId = steamapicontext->SteamUtils()->GetAppID(); @@ -39,8 +40,9 @@ int CFF_CL_DLL_Interface::Init( CreateInterfaceFn appSystemFactory, CreateInterf void CFF_CL_DLL_Interface::Shutdown( void ) { - // shutdown UI Lua VM + // close the Lua VM g_UIScriptManager.Shutdown(); + g_GameScriptManager.Shutdown(); BaseClass::Shutdown(); } diff --git a/mp/src/game/server/ai_playerally.cpp b/mp/src/game/server/ai_playerally.cpp index ac644805..927fac88 100644 --- a/mp/src/game/server/ai_playerally.cpp +++ b/mp/src/game/server/ai_playerally.cpp @@ -11,12 +11,20 @@ #include "saverestore_utlmap.h" #include "eventqueue.h" #include "ai_behavior_lead.h" +#ifndef FF #include "gameinterface.h" +#else +#include "ff_sv_dll_interface.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifndef FF extern CServerGameDLL g_ServerGameDLL; +#else +extern CFF_SV_DLL_Interface g_sServerGameDLL; +#endif extern ConVar rr_debugresponses; diff --git a/mp/src/game/server/ff/ff_sv_dll_interface.cpp b/mp/src/game/server/ff/ff_sv_dll_interface.cpp new file mode 100644 index 00000000..4f4e8a9f --- /dev/null +++ b/mp/src/game/server/ff/ff_sv_dll_interface.cpp @@ -0,0 +1,50 @@ +#include "cbase.h" +#include "ff_sv_dll_interface.h" + +#include "ff_sh_scriptman.h" + +bool CFF_SV_DLL_Interface::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn fileSystemFactory, CGlobalVars *pGlobals) +{ + bool ret = BaseClass::DLLInit( engineFactory, physicsFactory, fileSystemFactory, pGlobals ); + + // start the Lua VM + g_GameScriptManager.Init(); + + return ret; +} + +void CFF_SV_DLL_Interface::DLLShutdown( void ) +{ + // close the Lua VM + g_GameScriptManager.Shutdown(); + + BaseClass::DLLShutdown(); +} + +/** Sets player limits, required implementation +*/ +void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const +{ + minplayers = 2; + maxplayers = MAX_PLAYERS; // TODO: currently 33 + defaultMaxPlayers = 16; +} + +/** Called after all entities are loaded, required implementation +*/ +void CServerGameDLL::LevelInit_ParseAllEntities( const char *pMapEntities ) +{ + // FF TODO: FF map entity parse for stuff to keep around after reset +} + +#define INTERFACEVERSION_SERVERGAMEDLL_VERSION_8 "ServerGameDLL008" +#define INTERFACEVERSION_SERVERGAMEDLL "ServerGameDLL009" +#define INTERFACEVERSION_SERVERGAMEDLL_INT 9 + +CFF_SV_DLL_Interface g_ServerGameDLL; +// INTERFACEVERSION_SERVERGAMEDLL_VERSION_8 is compatible with the latest since we're only adding things to the end, so expose that as well. +EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CFF_SV_DLL_Interface, IServerGameDLL008, INTERFACEVERSION_SERVERGAMEDLL_VERSION_8, g_ServerGameDLL ); +EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CFF_SV_DLL_Interface, IServerGameDLL, INTERFACEVERSION_SERVERGAMEDLL, g_ServerGameDLL); + +// When bumping the version to this interface, check that our assumption is still valid and expose the older version in the same way +COMPILE_TIME_ASSERT( INTERFACEVERSION_SERVERGAMEDLL_INT == 9 ); \ No newline at end of file diff --git a/mp/src/game/server/ff/ff_sv_dll_interface.h b/mp/src/game/server/ff/ff_sv_dll_interface.h new file mode 100644 index 00000000..e417cd93 --- /dev/null +++ b/mp/src/game/server/ff/ff_sv_dll_interface.h @@ -0,0 +1,112 @@ +#ifndef FF_SV_DLL_INTERFACE_H +#define FF_SV_DLL_INTERFACE_H +#pragma once + +#include "gameinterface.h" + +class CFF_SV_DLL_Interface : public CServerGameDLL +{ + // squeek: I couldn't get DECLARE_CLASS_NOBASE to compile in CServerGameDLL, so I couldn't use DECLARE_CLASS here + // this works but it could potentially have negative consequences + DECLARE_CLASS_GAMEROOT( CFF_SV_DLL_Interface, CServerGameDLL ); + + // <-- Extended functions (meaning the BaseClass function is always called) + virtual bool DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn fileSystemFactory, CGlobalVars *pGlobals); + virtual void DLLShutdown( void ); + // --> Extended functions + + // --> Not yet implemented in CServerGameDLL but required + //virtual void GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const; + //virtual void LevelInit_ParseAllEntities( const char *pMapEntities ); + // <-- + + /* +public: + virtual bool DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn physicsFactory, + CreateInterfaceFn fileSystemFactory, CGlobalVars *pGlobals); + virtual void DLLShutdown( void ); + // Get the simulation interval (must be compiled with identical values into both client and game .dll for MOD!!!) + virtual bool ReplayInit( CreateInterfaceFn fnReplayFactory ); + virtual float GetTickInterval( void ) const; + virtual bool GameInit( void ); + virtual void GameShutdown( void ); + virtual bool LevelInit( const char *pMapName, char const *pMapEntities, char const *pOldLevel, char const *pLandmarkName, bool loadGame, bool background ); + virtual void ServerActivate( edict_t *pEdictList, int edictCount, int clientMax ); + virtual void LevelShutdown( void ); + virtual void GameFrame( bool simulating ); // could be called multiple times before sending data to clients + virtual void PreClientUpdate( bool simulating ); // called after all GameFrame() calls, before sending data to clients + + virtual ServerClass* GetAllServerClasses( void ); + virtual const char *GetGameDescription( void ); + virtual void CreateNetworkStringTables( void ); + + // Save/restore system hooks + virtual CSaveRestoreData *SaveInit( int size ); + virtual void SaveWriteFields( CSaveRestoreData *, char const* , void *, datamap_t *, typedescription_t *, int ); + virtual void SaveReadFields( CSaveRestoreData *, char const* , void *, datamap_t *, typedescription_t *, int ); + virtual void SaveGlobalState( CSaveRestoreData * ); + virtual void RestoreGlobalState( CSaveRestoreData * ); + virtual int CreateEntityTransitionList( CSaveRestoreData *, int ); + virtual void BuildAdjacentMapList( void ); + + virtual void PreSave( CSaveRestoreData * ); + virtual void Save( CSaveRestoreData * ); + virtual void GetSaveComment( char *comment, int maxlength, float flMinutes, float flSeconds, bool bNoTime = false ); +#ifdef _XBOX + virtual void GetTitleName( const char *pMapName, char* pTitleBuff, int titleBuffSize ); +#endif + virtual void WriteSaveHeaders( CSaveRestoreData * ); + + virtual void ReadRestoreHeaders( CSaveRestoreData * ); + virtual void Restore( CSaveRestoreData *, bool ); + virtual bool IsRestoring(); + + // Retrieve info needed for parsing the specified user message + virtual bool GetUserMessageInfo( int msg_type, char *name, int maxnamelength, int& size ); + + virtual CStandardSendProxies* GetStandardSendProxies(); + + virtual void PostInit(); + virtual void Think( bool finalTick ); + + virtual void OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity, EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue ); + + virtual void PreSaveGameLoaded( char const *pSaveName, bool bInGame ); + + // Returns true if the game DLL wants the server not to be made public. + // Used by commentary system to hide multiplayer commentary servers from the master. + virtual bool ShouldHideServer( void ); + + virtual void InvalidateMdlCache(); + + virtual void SetServerHibernation( bool bHibernating ); + + float m_fAutoSaveDangerousTime; + float m_fAutoSaveDangerousMinHealthToCommit; + bool m_bIsHibernating; + + // Called after the steam API has been activated post-level startup + virtual void GameServerSteamAPIActivated( void ); + + // Called after the steam API has been shutdown post-level startup + virtual void GameServerSteamAPIShutdown( void ); + + // interface to the new GC based lobby system + virtual IServerGCLobby *GetServerGCLobby() OVERRIDE; + + virtual const char *GetServerBrowserMapOverride() OVERRIDE; + virtual const char *GetServerBrowserGameData() OVERRIDE; + +private: + + // This can just be a wrapper on MapEntity_ParseAllEntities, but CS does some tricks in here + // with the entity list. + void LevelInit_ParseAllEntities( const char *pMapEntities ); + void LoadMessageOfTheDay(); + void LoadSpecificMOTDMsg( const ConVar &convar, const char *pszStringName ); + */ +}; + +extern CFF_SV_DLL_Interface g_ServerGameDLL; + +#endif \ No newline at end of file diff --git a/mp/src/game/server/ff/ff_sv_gameinterface.cpp b/mp/src/game/server/ff/ff_sv_gameinterface.cpp deleted file mode 100644 index d7157932..00000000 --- a/mp/src/game/server/ff/ff_sv_gameinterface.cpp +++ /dev/null @@ -1,34 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -// -// Purpose: -// -//=============================================================================// - -#include "cbase.h" -#include "gameinterface.h" -#include "mapentities.h" -#include "ff_sv_gameinterface.h" - -// memdbgon must be the last include file in a .cpp file!!! -#include "tier0/memdbgon.h" - -// -------------------------------------------------------------------------------------------- // -// Mod-specific CServerGameClients implementation. -// -------------------------------------------------------------------------------------------- // - -void CServerGameClients::GetPlayerLimits( int& minplayers, int& maxplayers, int &defaultMaxPlayers ) const -{ - minplayers = 2; - maxplayers = MAX_PLAYERS; // TODO: currently 33 - defaultMaxPlayers = 16; -} - -// -------------------------------------------------------------------------------------------- // -// Mod-specific CServerGameDLL implementation. -// -------------------------------------------------------------------------------------------- // - -void CServerGameDLL::LevelInit_ParseAllEntities( const char *pMapEntities ) -{ - // TODO: FF map entity parse for stuff to keep around after reset -} - diff --git a/mp/src/game/server/ff/ff_sv_gameinterface.h b/mp/src/game/server/ff/ff_sv_gameinterface.h deleted file mode 100644 index 40a8fd2b..00000000 --- a/mp/src/game/server/ff/ff_sv_gameinterface.h +++ /dev/null @@ -1,10 +0,0 @@ -//========= Copyright Valve Corporation, All rights reserved. ============// -#ifndef FF_SV_GAMEINTERFACE_H -#define FF_SV_GAMEINTERFACE_H -#ifdef _WIN32 -#pragma once -#endif - -#include "gameinterface.h" - -#endif \ No newline at end of file diff --git a/mp/src/game/server/gameinterface.cpp b/mp/src/game/server/gameinterface.cpp index b4d09bae..d4f87d25 100644 --- a/mp/src/game/server/gameinterface.cpp +++ b/mp/src/game/server/gameinterface.cpp @@ -125,6 +125,10 @@ extern ConVar tf_mm_servermode; #include "portal_player.h" #endif +#ifdef FF +#include "ff_sv_dll_interface.h" +#endif + #if defined( REPLAY_ENABLED ) #include "replay/ireplaysystem.h" #endif @@ -557,6 +561,7 @@ void DrawAllDebugOverlays( void ) DrawMessageEntities(); } +#ifndef FF // FF exposes its own interface CServerGameDLL g_ServerGameDLL; // INTERFACEVERSION_SERVERGAMEDLL_VERSION_8 is compatible with the latest since we're only adding things to the end, so expose that as well. EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CServerGameDLL, IServerGameDLL008, INTERFACEVERSION_SERVERGAMEDLL_VERSION_8, g_ServerGameDLL ); @@ -564,6 +569,7 @@ EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CServerGameDLL, IServerGameDLL, INTERFACEVERSI // When bumping the version to this interface, check that our assumption is still valid and expose the older version in the same way COMPILE_TIME_ASSERT( INTERFACEVERSION_SERVERGAMEDLL_INT == 9 ); +#endif bool CServerGameDLL::DLLInit( CreateInterfaceFn appSystemFactory, CreateInterfaceFn physicsFactory, CreateInterfaceFn fileSystemFactory, diff --git a/mp/src/game/server/logicentities.cpp b/mp/src/game/server/logicentities.cpp index a53298b0..705388b2 100644 --- a/mp/src/game/server/logicentities.cpp +++ b/mp/src/game/server/logicentities.cpp @@ -13,13 +13,21 @@ #include "ndebugoverlay.h" #include "saverestore_utlvector.h" #include "vstdlib/random.h" +#ifndef FF #include "gameinterface.h" +#else +#include "ff_sv_dll_interface.h" +#endif // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifndef FF extern CServerGameDLL g_ServerGameDLL; +#else +extern CFF_SV_DLL_Interface g_sServerGameDLL; +#endif //----------------------------------------------------------------------------- diff --git a/mp/src/game/server/player.cpp b/mp/src/game/server/player.cpp index 2738e40a..91a58a0c 100644 --- a/mp/src/game/server/player.cpp +++ b/mp/src/game/server/player.cpp @@ -64,7 +64,11 @@ #include "hintsystem.h" #include "env_debughistory.h" #include "fogcontroller.h" +#ifndef FF #include "gameinterface.h" +#else +#include "ff_sv_dll_interface.h" +#endif #include "hl2orange.spa.h" #include "dt_utlvector_send.h" #include "vote_controller.h" @@ -120,7 +124,11 @@ extern ConVar sv_maxunlag; extern ConVar sv_turbophysics; extern ConVar *sv_maxreplay; +#ifndef FF extern CServerGameDLL g_ServerGameDLL; +#else +extern CFF_SV_DLL_Interface g_sServerGameDLL; +#endif // TIME BASED DAMAGE AMOUNT // tweak these values based on gameplay feedback: diff --git a/mp/src/game/server/server_ff.vpc b/mp/src/game/server/server_ff.vpc index 153c9060..9b9aed90 100644 --- a/mp/src/game/server/server_ff.vpc +++ b/mp/src/game/server/server_ff.vpc @@ -32,8 +32,8 @@ $Project "Server (FF)" $Folder "Game" { $File "FF\ff_sv_client.cpp" - $File "FF\ff_sv_gameinterface.cpp" - $File "FF\ff_sv_gameinterface.h" + $File "ff\ff_sv_dll_interface.cpp" + $File "ff\ff_sv_dll_interface.h" } $Folder "Player" { diff --git a/mp/src/game/server/triggers.cpp b/mp/src/game/server/triggers.cpp index c57a9b64..56c300fe 100644 --- a/mp/src/game/server/triggers.cpp +++ b/mp/src/game/server/triggers.cpp @@ -32,7 +32,11 @@ #include "in_buttons.h" #include "ai_behavior_follow.h" #include "ai_behavior_lead.h" +#ifndef FF #include "gameinterface.h" +#else +#include "ff_sv_dll_interface.h" +#endif #ifdef HL2_DLL #include "hl2_player.h" @@ -48,7 +52,12 @@ ConVar g_debug_transitions( "g_debug_transitions", "0", FCVAR_NONE, "Set to 1 an // Doesn't need saving, the triggers re-add themselves on restore. CUtlVector< CHandle > g_hWeaponFireTriggers; -extern CServerGameDLL g_ServerGameDLL; +#ifndef FF +extern CServerGameDLL g_ServerGameDLL; +#else +extern CFF_SV_DLL_Interface g_sServerGameDLL; +#endif + extern bool g_fGameOver; ConVar showtriggers( "showtriggers", "0", FCVAR_CHEAT, "Shows trigger brushes" ); diff --git a/mp/src/game/shared/ff/ff_sh_gamerules.cpp b/mp/src/game/shared/ff/ff_sh_gamerules.cpp index 1fdbf881..8d89314f 100644 --- a/mp/src/game/shared/ff/ff_sh_gamerules.cpp +++ b/mp/src/game/shared/ff/ff_sh_gamerules.cpp @@ -30,7 +30,7 @@ #include "weapon_hl2mpbasehlmpcombatweapon.h" #include "team.h" #include "voice_gamemgr.h" - #include "ff_sv_gameinterface.h" + #include "ff_sv_dll_interface.h" #include "hl2mp_cvars.h" #ifdef DEBUG diff --git a/mp/src/game/shared/ff/ff_sh_scriptman.cpp b/mp/src/game/shared/ff/ff_sh_scriptman.cpp index 44959acd..f9c4b75d 100644 --- a/mp/src/game/shared/ff/ff_sh_scriptman.cpp +++ b/mp/src/game/shared/ff/ff_sh_scriptman.cpp @@ -27,12 +27,15 @@ // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" +#ifdef CLIENT_DLL +#define LUA_CURRENT_CONTEXT "Client" +#else +#define LUA_CURRENT_CONTEXT "Server" +#endif -#ifdef FF // custom game modes made so damn easy ConVar sv_mapluasuffix( "sv_mapluasuffix", "0", FCVAR_NOTIFY, "Have a custom lua file (game mode) loaded when the map loads. If this suffix string is set, maps\\mapname__suffix__.lua (if it exists) is used instead of maps\\mapname.lua. To reset this cvar, make it 0."); ConVar sv_luaglobalscript( "sv_globalluascript", "0", FCVAR_NOTIFY, "Load a custom lua file globally after map scripts. Will overwrite map script. Will be loaded from maps\\globalscripts. To disable, set to 0."); -#endif ///////////////////////////////////////////////////////////////////////////// using namespace luabind; @@ -86,13 +89,13 @@ void CFF_SH_ScriptManager::Init() } // initialize VM - Msg("[SCRIPT] Attempting to start up the entity system...\n"); + Msg("[SCRIPT:%s] Attempting to start the Lua VM...\n", LUA_CURRENT_CONTEXT); L = lua_open(); // no need to continue if VM failed to initialize if(!L) { - Msg("[SCRIPT] Unable to initialize Lua VM.\n"); + Msg("[SCRIPT:%s] Unable to initialize Lua VM.\n", LUA_CURRENT_CONTEXT); return; } @@ -108,7 +111,7 @@ void CFF_SH_ScriptManager::Init() // initialize game-specific library //FF_TODO: CFFLuaLib::Init(L); - Msg("[SCRIPT] Entity system initialization successful.\n"); + Msg("[SCRIPT:%s] Lua VM initialization successful.\n", LUA_CURRENT_CONTEXT); } void CFF_SH_ScriptManager::LevelInit(const char* szMapName)