Virtualize ConVar bridge functions.
This commit is contained in:
parent
0f9e5234fe
commit
9366882ac4
core
@ -52,7 +52,7 @@ using namespace SourceHook;
|
||||
* Add 1 to the RHS of this expression to bump the intercom file
|
||||
* This is to prevent mismatching core/logic binaries
|
||||
*/
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 41)
|
||||
#define SM_LOGIC_MAGIC (0x0F47C0DE - 42)
|
||||
|
||||
#if defined SM_LOGIC
|
||||
class IVEngineServer
|
||||
@ -289,12 +289,21 @@ public:
|
||||
IMenuManager *menus;
|
||||
ISourcePawnEngine **spe1;
|
||||
ISourcePawnEngine2 **spe2;
|
||||
/* Functions */
|
||||
ConVar * (*FindConVar)(const char*);
|
||||
const char *gamesuffix;
|
||||
/* Data */
|
||||
ServerGlobals *serverGlobals;
|
||||
void * serverFactory;
|
||||
void * engineFactory;
|
||||
void * matchmakingDSFactory;
|
||||
SMGlobalClass * listeners;
|
||||
|
||||
// ConVar functions.
|
||||
virtual ConVar *FindConVar(const char *name) = 0;
|
||||
virtual const char *GetCvarString(ConVar *cvar) = 0;
|
||||
virtual bool GetCvarBool(ConVar* cvar) = 0;
|
||||
|
||||
void (*LogToGame)(const char *message);
|
||||
void (*ConPrint)(const char *message);
|
||||
const char * (*GetCvarString)(ConVar*);
|
||||
bool (*GetCvarBool)(ConVar*);
|
||||
bool (*GetGameName)(char *buffer, size_t maxlength);
|
||||
const char * (*GetGameDescription)();
|
||||
const char * (*GetSourceEngineName)();
|
||||
@ -316,13 +325,6 @@ public:
|
||||
int (*MaxClients)();
|
||||
int (*GetGlobalTarget)();
|
||||
void (*ConsolePrintVa)(const char *fmt, va_list ap);
|
||||
const char *gamesuffix;
|
||||
/* Data */
|
||||
ServerGlobals *serverGlobals;
|
||||
void * serverFactory;
|
||||
void * engineFactory;
|
||||
void * matchmakingDSFactory;
|
||||
SMGlobalClass * listeners;
|
||||
};
|
||||
|
||||
struct sm_logic_t
|
||||
|
@ -300,11 +300,6 @@ static ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity
|
||||
static ConVar sm_immunity_mode("sm_immunity_mode", "1", FCVAR_SPONLY, "Mode for deciding immunity protection");
|
||||
static ConVar sm_datetime_format("sm_datetime_format", "%m/%d/%Y - %H:%M:%S", 0, "Default formatting time rules");
|
||||
|
||||
static ConVar *find_convar(const char *name)
|
||||
{
|
||||
return icvar->FindVar(name);
|
||||
}
|
||||
|
||||
static void log_to_game(const char *message)
|
||||
{
|
||||
Engine_LogPrintWrapper(message);
|
||||
@ -315,16 +310,6 @@ static void conprint(const char *message)
|
||||
META_CONPRINT(message);
|
||||
}
|
||||
|
||||
static const char *get_cvar_string(ConVar* cvar)
|
||||
{
|
||||
return cvar->GetString();
|
||||
}
|
||||
|
||||
static bool get_cvar_bool(ConVar* cvar)
|
||||
{
|
||||
return cvar->GetBool();
|
||||
}
|
||||
|
||||
static bool get_game_name(char *buffer, size_t maxlength)
|
||||
{
|
||||
KeyValues *pGameInfo = new KeyValues("GameInfo");
|
||||
@ -623,11 +608,8 @@ public:
|
||||
this->menus = &g_Menus;
|
||||
this->spe1 = &g_pSourcePawn;
|
||||
this->spe2 = &g_pSourcePawn2;
|
||||
this->FindConVar = find_convar;
|
||||
this->LogToGame = log_to_game;
|
||||
this->ConPrint = conprint;
|
||||
this->GetCvarString = get_cvar_string;
|
||||
this->GetCvarBool = get_cvar_bool;
|
||||
this->GetGameName = get_game_name;
|
||||
this->GetGameDescription = get_game_description;
|
||||
this->GetSourceEngineName = get_source_engine_name;
|
||||
@ -656,8 +638,27 @@ public:
|
||||
this->matchmakingDSFactory = nullptr;
|
||||
this->listeners = nullptr;
|
||||
}
|
||||
|
||||
ConVar *FindConVar(const char *name) override;
|
||||
const char *GetCvarString(ConVar *cvar) override;
|
||||
bool GetCvarBool(ConVar* cvar) override;
|
||||
} sCoreProviderImpl;
|
||||
|
||||
ConVar *CoreProviderImpl::FindConVar(const char *name)
|
||||
{
|
||||
return icvar->FindVar(name);
|
||||
}
|
||||
|
||||
const char *CoreProviderImpl::GetCvarString(ConVar* cvar)
|
||||
{
|
||||
return cvar->GetString();
|
||||
}
|
||||
|
||||
bool CoreProviderImpl::GetCvarBool(ConVar* cvar)
|
||||
{
|
||||
return cvar->GetBool();
|
||||
}
|
||||
|
||||
void InitLogicBridge()
|
||||
{
|
||||
serverGlobals.universalTime = g_pUniversalTime;
|
||||
|
Loading…
Reference in New Issue
Block a user