diff --git a/core/gamedll_bridge.cpp b/core/gamedll_bridge.cpp index 0743bef..c5adc20 100644 --- a/core/gamedll_bridge.cpp +++ b/core/gamedll_bridge.cpp @@ -38,7 +38,8 @@ public: virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength) { server = (IServerGameDLL *) info->isgd; - g_Metamod.SetGameDLLInfo((CreateInterfaceFn) info->gsFactory, + g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, + info->dllInterfaceName, info->dllVersion, true); g_Metamod.SetVSPListener(info->vsp_listener_path); diff --git a/core/metamod.cpp b/core/metamod.cpp index d57bab3..bfe44d0 100644 --- a/core/metamod.cpp +++ b/core/metamod.cpp @@ -69,6 +69,7 @@ static String metamod_path; static String full_bin_path; static int vsp_version = 0; static int gamedll_version = 0; +static const char *gamedll_interface_name = nullptr; static int engine_build = SOURCE_ENGINE_UNKNOWN; static List gamedll_list; static bool is_gamedll_loaded = false; @@ -1018,9 +1019,10 @@ bool MetamodSource::IsLoadedAsGameDLL() return is_gamedll_loaded; } -void MetamodSource::SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded) +void MetamodSource::SetGameDLLInfo(CreateInterfaceFn serverFactory, const char *pGameDllIfaceName, int version, bool loaded) { gamedll_info.factory = serverFactory; + gamedll_interface_name = pGameDllIfaceName; gamedll_version = version; is_gamedll_loaded = loaded; } @@ -1086,6 +1088,11 @@ size_t MetamodSource::GetFullPluginPath(const char *plugin, char *buffer, size_t return num; } +const char *MetamodSource::GetGameDLLInterfaceName() const +{ + return gamedll_interface_name; +} + static bool ProcessVDF(const char *path, bool &skipped) { diff --git a/core/metamod.h b/core/metamod.h index 468c61f..b1446bb 100644 --- a/core/metamod.h +++ b/core/metamod.h @@ -93,7 +93,8 @@ public: const char *GetVDFDir(); void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand); void NotifyVSPListening(IServerPluginCallbacks *callbacks, int version); - void SetGameDLLInfo(CreateInterfaceFn serverFactory, int version, bool loaded); + const char* GetGameDLLInterfaceName() const; + void SetGameDLLInfo(CreateInterfaceFn serverFactory, const char *pGameDllIfaceName, int version, bool loaded); void SetVSPListener(const char *path); size_t GetFullPluginPath(const char *plugin, char *buffer, size_t len); }; diff --git a/core/metamod_console.cpp b/core/metamod_console.cpp index 8cadd8a..0fd08ac 100644 --- a/core/metamod_console.cpp +++ b/core/metamod_console.cpp @@ -119,7 +119,7 @@ bool Command_Meta(IMetamodSourceCommandInfo *info) CONMSG(" Description: %s\n", provider->GetGameDescription()); CONMSG(" Mod Path: %s\n", g_Metamod.GetBaseDir()); CONMSG(" DLL Path: %s\n", g_Metamod.GetGameBinaryPath()); - CONMSG(" Interface: ServerGameDLL%03d\n", g_Metamod.GetGameDLLVersion()); + CONMSG(" Interface: %s\n", g_Metamod.GetGameDLLInterfaceName()); CONMSG(" Engine: %s\n", provider->GetEngineDescription()); // Display user messages diff --git a/core/vsp_bridge.cpp b/core/vsp_bridge.cpp index 40a7f35..ee385b3 100644 --- a/core/vsp_bridge.cpp +++ b/core/vsp_bridge.cpp @@ -43,6 +43,7 @@ SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false); ConCommand *g_plugin_unload = NULL; bool g_bIsTryingToUnload; SourceHook::String vsp_desc("Metamod:Source"); +static char gamedll_iface_name[128] = { 0 }; #if SOURCE_ENGINE >= SE_ORANGEBOX void InterceptPluginUnloads(const CCommand &args) @@ -84,13 +85,12 @@ public: pGlobals = playerInfoManager->GetGlobalVars(); - char gamedll_iface[24]; for (unsigned int i = 3; i <= 50; i++) { - UTIL_Format(gamedll_iface, sizeof(gamedll_iface), "ServerGameDLL%03d", i); - if ((server = (IServerGameDLL *)info->gsFactory(gamedll_iface, NULL)) != NULL) + UTIL_Format(gamedll_iface_name, sizeof(gamedll_iface_name), "ServerGameDLL%03d", i); + if ((server = (IServerGameDLL *)info->gsFactory(gamedll_iface_name, NULL)) != NULL) { - g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, i, false); + g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory, gamedll_iface_name, i, false); break; } } diff --git a/loader/gamedll.cpp b/loader/gamedll.cpp index 8bf062b..82d476a 100644 --- a/loader/gamedll.cpp +++ b/loader/gamedll.cpp @@ -50,6 +50,7 @@ static void *gamedll_lib = NULL; static IServerGameDLL *gamedll_iface = NULL; static ISource2ServerConfig *config_iface = NULL; static QueryValveInterface gamedll_qvi = NULL; +static char gamedll_iface_name[128] = { 0 }; static int gamedll_version = 0; static int isgd_shutdown_index = -1; #if defined _WIN32 @@ -361,6 +362,7 @@ public: { g_bridge_info.pGlobals = nullptr;// pGlobals; g_bridge_info.dllVersion = gamedll_version; + g_bridge_info.dllInterfaceName = gamedll_iface_name; g_bridge_info.isgd = gamedll_iface; g_bridge_info.gsFactory = gamedll_qvi; g_bridge_info.vsp_listener_path = mm_path; @@ -497,6 +499,7 @@ public: g_bridge_info.fsFactory = (QueryValveInterface)fileSystemFactory; g_bridge_info.pGlobals = pGlobals; g_bridge_info.dllVersion = gamedll_version; + g_bridge_info.dllInterfaceName = gamedll_iface_name; g_bridge_info.isgd = gamedll_iface; g_bridge_info.gsFactory = gamedll_qvi; g_bridge_info.vsp_listener_path = mm_path; @@ -807,9 +810,10 @@ mm_GameDllRequest(const char *name, int *ret) return ptr; } } - else if (strncmp(name, "Source2Server0", 14) == 0) + else if (strncmp(name, "Source2Server", 13) == 0 && atoi(&name[13]) != 0) { gamedll_iface = (IServerGameDLL *)gamedll_qvi(name, ret); + strncpy(gamedll_iface_name, name, sizeof(gamedll_iface_name)); gamedll_version = atoi(&name[13]); mm_PatchDllInit(true); @@ -856,6 +860,7 @@ mm_GameDllRequest(const char *name, int *ret) mm_FreeCachedLibraries(); gamedll_lib = lib; gamedll_iface = (IServerGameDLL *)ptr; + strncpy(gamedll_iface_name, name, sizeof(gamedll_iface_name)); gamedll_qvi = qvi; gamedll_version = atoi(&name[13]); mm_PatchDllInit(true); diff --git a/loader/loader_bridge.h b/loader/loader_bridge.h index 07570ce..3fcd8df 100644 --- a/loader/loader_bridge.h +++ b/loader/loader_bridge.h @@ -53,6 +53,7 @@ struct gamedll_bridge_info QueryValveInterface gsFactory; void * pGlobals; unsigned int dllVersion; + const char * dllInterfaceName; void * isgd; const char * vsp_listener_path; };