mirror of
https://github.com/fortressforever/fortressforever-2013.git
synced 2024-11-22 12:32:08 +00:00
Added our own server DLL interface class (CFF_SV_DLL_Interface) that inherits from CServerGameDLL
* Deleted ff_sv_gameinterface.cpp/.h, moved that code into ff_sv_dll_interface.cpp Initialized g_GameScriptManager when server/client dlls call Init
This commit is contained in:
parent
9aa4479a03
commit
939411c752
13 changed files with 217 additions and 55 deletions
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
50
mp/src/game/server/ff/ff_sv_dll_interface.cpp
Normal file
50
mp/src/game/server/ff/ff_sv_dll_interface.cpp
Normal file
|
@ -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 );
|
112
mp/src/game/server/ff/ff_sv_dll_interface.h
Normal file
112
mp/src/game/server/ff/ff_sv_dll_interface.h
Normal file
|
@ -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
|
|
@ -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
|
||||
}
|
||||
|
|
@ -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
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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"
|
||||
{
|
||||
|
|
|
@ -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<CTriggerMultiple> > 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" );
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue