diff --git a/core/logic/intercom.h b/core/logic/intercom.h index 524481cb..586fb2ed 100644 --- a/core/logic/intercom.h +++ b/core/logic/intercom.h @@ -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 - 42) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 43) #if defined SM_LOGIC class IVEngineServer @@ -302,12 +302,14 @@ public: virtual const char *GetCvarString(ConVar *cvar) = 0; virtual bool GetCvarBool(ConVar* cvar) = 0; + // Game description functions. + virtual bool GetGameName(char *buffer, size_t maxlength) = 0; + virtual const char *GetGameDescription() = 0; + virtual const char *GetSourceEngineName() = 0; + virtual bool SymbolsAreHidden() = 0; + void (*LogToGame)(const char *message); void (*ConPrint)(const char *message); - bool (*GetGameName)(char *buffer, size_t maxlength); - const char * (*GetGameDescription)(); - const char * (*GetSourceEngineName)(); - bool (*SymbolsAreHidden)(); const char * (*GetCoreConfigValue)(const char*); bool (*IsMapLoading)(); bool (*IsMapRunning)(); diff --git a/core/logic_bridge.cpp b/core/logic_bridge.cpp index f85dfe33..455d73cc 100644 --- a/core/logic_bridge.cpp +++ b/core/logic_bridge.cpp @@ -310,99 +310,6 @@ static void conprint(const char *message) META_CONPRINT(message); } -static bool get_game_name(char *buffer, size_t maxlength) -{ - KeyValues *pGameInfo = new KeyValues("GameInfo"); - if (g_HL2.KVLoadFromFile(pGameInfo, basefilesystem, "gameinfo.txt")) - { - const char *str; - if ((str = pGameInfo->GetString("game", NULL)) != NULL) - { - strncopy(buffer, str, maxlength); - pGameInfo->deleteThis(); - return true; - } - } - pGameInfo->deleteThis(); - return false; -} - -static const char *get_game_description() -{ - return SERVER_CALL(GetGameDescription)(); -} - -static const char *get_source_engine_name() -{ -#if !defined SOURCE_ENGINE -# error "Unknown engine type" -#endif -#if SOURCE_ENGINE == SE_EPISODEONE - return "original"; -#elif SOURCE_ENGINE == SE_DARKMESSIAH - return "darkmessiah"; -#elif SOURCE_ENGINE == SE_ORANGEBOX - return "orangebox"; -#elif SOURCE_ENGINE == SE_BLOODYGOODTIME - return "bloodygoodtime"; -#elif SOURCE_ENGINE == SE_EYE - return "eye"; -#elif SOURCE_ENGINE == SE_CSS - return "css"; -#elif SOURCE_ENGINE == SE_HL2DM - return "hl2dm"; -#elif SOURCE_ENGINE == SE_DODS - return "dods"; -#elif SOURCE_ENGINE == SE_SDK2013 - return "sdk2013"; -#elif SOURCE_ENGINE == SE_BMS - return "bms"; -#elif SOURCE_ENGINE == SE_TF2 - return "tf2"; -#elif SOURCE_ENGINE == SE_LEFT4DEAD - return "left4dead"; -#elif SOURCE_ENGINE == SE_NUCLEARDAWN - return "nucleardawn"; -#elif SOURCE_ENGINE == SE_CONTAGION - return "contagion"; -#elif SOURCE_ENGINE == SE_LEFT4DEAD2 - return "left4dead2"; -#elif SOURCE_ENGINE == SE_ALIENSWARM - return "alienswarm"; -#elif SOURCE_ENGINE == SE_PORTAL2 - return "portal2"; -#elif SOURCE_ENGINE == SE_BLADE - return "blade"; -#elif SOURCE_ENGINE == SE_INSURGENCY - return "insurgency"; -#elif SOURCE_ENGINE == SE_CSGO - return "csgo"; -#elif SOURCE_ENGINE == SE_DOTA - return "dota"; -#endif -} - -static bool symbols_are_hidden() -{ -#if (SOURCE_ENGINE == SE_CSS) \ - || (SOURCE_ENGINE == SE_HL2DM) \ - || (SOURCE_ENGINE == SE_DODS) \ - || (SOURCE_ENGINE == SE_SDK2013) \ - || (SOURCE_ENGINE == SE_BMS) \ - || (SOURCE_ENGINE == SE_TF2) \ - || (SOURCE_ENGINE == SE_LEFT4DEAD) \ - || (SOURCE_ENGINE == SE_NUCLEARDAWN) \ - || (SOURCE_ENGINE == SE_LEFT4DEAD2) \ - || (SOURCE_ENGINE == SE_INSURGENCY) \ - || (SOURCE_ENGINE == SE_BLADE) \ - || (SOURCE_ENGINE == SE_CSGO) \ - || (SOURCE_ENGINE == SE_DOTA) - return true; -#else - return false; -#endif -} - static const char* get_core_config_value(const char* key) { return g_CoreConfig.GetCoreConfigValue(key); @@ -610,10 +517,6 @@ public: this->spe2 = &g_pSourcePawn2; this->LogToGame = log_to_game; this->ConPrint = conprint; - this->GetGameName = get_game_name; - this->GetGameDescription = get_game_description; - this->GetSourceEngineName = get_source_engine_name; - this->SymbolsAreHidden = symbols_are_hidden; this->GetCoreConfigValue = get_core_config_value; this->IsMapLoading = is_map_loading; this->IsMapRunning = is_map_running; @@ -642,6 +545,10 @@ public: ConVar *FindConVar(const char *name) override; const char *GetCvarString(ConVar *cvar) override; bool GetCvarBool(ConVar* cvar) override; + bool GetGameName(char *buffer, size_t maxlength) override; + const char *GetGameDescription() override; + const char *GetSourceEngineName() override; + bool SymbolsAreHidden() override; } sCoreProviderImpl; ConVar *CoreProviderImpl::FindConVar(const char *name) @@ -659,6 +566,99 @@ bool CoreProviderImpl::GetCvarBool(ConVar* cvar) return cvar->GetBool(); } +bool CoreProviderImpl::GetGameName(char *buffer, size_t maxlength) +{ + KeyValues *pGameInfo = new KeyValues("GameInfo"); + if (g_HL2.KVLoadFromFile(pGameInfo, basefilesystem, "gameinfo.txt")) + { + const char *str; + if ((str = pGameInfo->GetString("game", NULL)) != NULL) + { + strncopy(buffer, str, maxlength); + pGameInfo->deleteThis(); + return true; + } + } + pGameInfo->deleteThis(); + return false; +} + +const char *CoreProviderImpl::GetGameDescription() +{ + return SERVER_CALL(GetGameDescription)(); +} + +const char *CoreProviderImpl::GetSourceEngineName() +{ +#if !defined SOURCE_ENGINE +# error "Unknown engine type" +#endif +#if SOURCE_ENGINE == SE_EPISODEONE + return "original"; +#elif SOURCE_ENGINE == SE_DARKMESSIAH + return "darkmessiah"; +#elif SOURCE_ENGINE == SE_ORANGEBOX + return "orangebox"; +#elif SOURCE_ENGINE == SE_BLOODYGOODTIME + return "bloodygoodtime"; +#elif SOURCE_ENGINE == SE_EYE + return "eye"; +#elif SOURCE_ENGINE == SE_CSS + return "css"; +#elif SOURCE_ENGINE == SE_HL2DM + return "hl2dm"; +#elif SOURCE_ENGINE == SE_DODS + return "dods"; +#elif SOURCE_ENGINE == SE_SDK2013 + return "sdk2013"; +#elif SOURCE_ENGINE == SE_BMS + return "bms"; +#elif SOURCE_ENGINE == SE_TF2 + return "tf2"; +#elif SOURCE_ENGINE == SE_LEFT4DEAD + return "left4dead"; +#elif SOURCE_ENGINE == SE_NUCLEARDAWN + return "nucleardawn"; +#elif SOURCE_ENGINE == SE_CONTAGION + return "contagion"; +#elif SOURCE_ENGINE == SE_LEFT4DEAD2 + return "left4dead2"; +#elif SOURCE_ENGINE == SE_ALIENSWARM + return "alienswarm"; +#elif SOURCE_ENGINE == SE_PORTAL2 + return "portal2"; +#elif SOURCE_ENGINE == SE_BLADE + return "blade"; +#elif SOURCE_ENGINE == SE_INSURGENCY + return "insurgency"; +#elif SOURCE_ENGINE == SE_CSGO + return "csgo"; +#elif SOURCE_ENGINE == SE_DOTA + return "dota"; +#endif +} + +bool CoreProviderImpl::SymbolsAreHidden() +{ +#if (SOURCE_ENGINE == SE_CSS) \ + || (SOURCE_ENGINE == SE_HL2DM) \ + || (SOURCE_ENGINE == SE_DODS) \ + || (SOURCE_ENGINE == SE_SDK2013) \ + || (SOURCE_ENGINE == SE_BMS) \ + || (SOURCE_ENGINE == SE_TF2) \ + || (SOURCE_ENGINE == SE_LEFT4DEAD) \ + || (SOURCE_ENGINE == SE_NUCLEARDAWN) \ + || (SOURCE_ENGINE == SE_LEFT4DEAD2) \ + || (SOURCE_ENGINE == SE_INSURGENCY) \ + || (SOURCE_ENGINE == SE_BLADE) \ + || (SOURCE_ENGINE == SE_CSGO) \ + || (SOURCE_ENGINE == SE_DOTA) + return true; +#else + return false; +#endif +} + void InitLogicBridge() { serverGlobals.universalTime = g_pUniversalTime;