1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-20 13:54:14 +01:00

Replace hardcoded "ServerGameDLL" part of iface name in meta game output

This commit is contained in:
Nick Hastings 2023-05-21 15:27:46 -04:00
parent bf62e8e59c
commit ee9243c82f
7 changed files with 24 additions and 9 deletions

View File

@ -38,7 +38,8 @@ public:
virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength) virtual bool DLLInit_Pre(const gamedll_bridge_info *info, char *buffer, size_t maxlength)
{ {
server = (IServerGameDLL *) info->isgd; server = (IServerGameDLL *) info->isgd;
g_Metamod.SetGameDLLInfo((CreateInterfaceFn) info->gsFactory, g_Metamod.SetGameDLLInfo((CreateInterfaceFn)info->gsFactory,
info->dllInterfaceName,
info->dllVersion, info->dllVersion,
true); true);
g_Metamod.SetVSPListener(info->vsp_listener_path); g_Metamod.SetVSPListener(info->vsp_listener_path);

View File

@ -69,6 +69,7 @@ static String metamod_path;
static String full_bin_path; static String full_bin_path;
static int vsp_version = 0; static int vsp_version = 0;
static int gamedll_version = 0; static int gamedll_version = 0;
static const char *gamedll_interface_name = nullptr;
static int engine_build = SOURCE_ENGINE_UNKNOWN; static int engine_build = SOURCE_ENGINE_UNKNOWN;
static List<game_dll_t *> gamedll_list; static List<game_dll_t *> gamedll_list;
static bool is_gamedll_loaded = false; static bool is_gamedll_loaded = false;
@ -1018,9 +1019,10 @@ bool MetamodSource::IsLoadedAsGameDLL()
return is_gamedll_loaded; 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_info.factory = serverFactory;
gamedll_interface_name = pGameDllIfaceName;
gamedll_version = version; gamedll_version = version;
is_gamedll_loaded = loaded; is_gamedll_loaded = loaded;
} }
@ -1086,6 +1088,11 @@ size_t MetamodSource::GetFullPluginPath(const char *plugin, char *buffer, size_t
return num; return num;
} }
const char *MetamodSource::GetGameDLLInterfaceName() const
{
return gamedll_interface_name;
}
static bool static bool
ProcessVDF(const char *path, bool &skipped) ProcessVDF(const char *path, bool &skipped)
{ {

View File

@ -93,7 +93,8 @@ public:
const char *GetVDFDir(); const char *GetVDFDir();
void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand); void UnregisterConCommandBase(PluginId id, ConCommandBase *pCommand);
void NotifyVSPListening(IServerPluginCallbacks *callbacks, int version); 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); void SetVSPListener(const char *path);
size_t GetFullPluginPath(const char *plugin, char *buffer, size_t len); size_t GetFullPluginPath(const char *plugin, char *buffer, size_t len);
}; };

View File

@ -119,7 +119,7 @@ bool Command_Meta(IMetamodSourceCommandInfo *info)
CONMSG(" Description: %s\n", provider->GetGameDescription()); CONMSG(" Description: %s\n", provider->GetGameDescription());
CONMSG(" Mod Path: %s\n", g_Metamod.GetBaseDir()); CONMSG(" Mod Path: %s\n", g_Metamod.GetBaseDir());
CONMSG(" DLL Path: %s\n", g_Metamod.GetGameBinaryPath()); 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()); CONMSG(" Engine: %s\n", provider->GetEngineDescription());
// Display user messages // Display user messages

View File

@ -43,6 +43,7 @@ SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
ConCommand *g_plugin_unload = NULL; ConCommand *g_plugin_unload = NULL;
bool g_bIsTryingToUnload; bool g_bIsTryingToUnload;
SourceHook::String vsp_desc("Metamod:Source"); SourceHook::String vsp_desc("Metamod:Source");
static char gamedll_iface_name[128] = { 0 };
#if SOURCE_ENGINE >= SE_ORANGEBOX #if SOURCE_ENGINE >= SE_ORANGEBOX
void InterceptPluginUnloads(const CCommand &args) void InterceptPluginUnloads(const CCommand &args)
@ -84,13 +85,12 @@ public:
pGlobals = playerInfoManager->GetGlobalVars(); pGlobals = playerInfoManager->GetGlobalVars();
char gamedll_iface[24];
for (unsigned int i = 3; i <= 50; i++) for (unsigned int i = 3; i <= 50; i++)
{ {
UTIL_Format(gamedll_iface, sizeof(gamedll_iface), "ServerGameDLL%03d", i); UTIL_Format(gamedll_iface_name, sizeof(gamedll_iface_name), "ServerGameDLL%03d", i);
if ((server = (IServerGameDLL *)info->gsFactory(gamedll_iface, NULL)) != NULL) 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; break;
} }
} }

View File

@ -50,6 +50,7 @@ static void *gamedll_lib = NULL;
static IServerGameDLL *gamedll_iface = NULL; static IServerGameDLL *gamedll_iface = NULL;
static ISource2ServerConfig *config_iface = NULL; static ISource2ServerConfig *config_iface = NULL;
static QueryValveInterface gamedll_qvi = NULL; static QueryValveInterface gamedll_qvi = NULL;
static char gamedll_iface_name[128] = { 0 };
static int gamedll_version = 0; static int gamedll_version = 0;
static int isgd_shutdown_index = -1; static int isgd_shutdown_index = -1;
#if defined _WIN32 #if defined _WIN32
@ -361,6 +362,7 @@ public:
{ {
g_bridge_info.pGlobals = nullptr;// pGlobals; g_bridge_info.pGlobals = nullptr;// pGlobals;
g_bridge_info.dllVersion = gamedll_version; g_bridge_info.dllVersion = gamedll_version;
g_bridge_info.dllInterfaceName = gamedll_iface_name;
g_bridge_info.isgd = gamedll_iface; g_bridge_info.isgd = gamedll_iface;
g_bridge_info.gsFactory = gamedll_qvi; g_bridge_info.gsFactory = gamedll_qvi;
g_bridge_info.vsp_listener_path = mm_path; g_bridge_info.vsp_listener_path = mm_path;
@ -497,6 +499,7 @@ public:
g_bridge_info.fsFactory = (QueryValveInterface)fileSystemFactory; g_bridge_info.fsFactory = (QueryValveInterface)fileSystemFactory;
g_bridge_info.pGlobals = pGlobals; g_bridge_info.pGlobals = pGlobals;
g_bridge_info.dllVersion = gamedll_version; g_bridge_info.dllVersion = gamedll_version;
g_bridge_info.dllInterfaceName = gamedll_iface_name;
g_bridge_info.isgd = gamedll_iface; g_bridge_info.isgd = gamedll_iface;
g_bridge_info.gsFactory = gamedll_qvi; g_bridge_info.gsFactory = gamedll_qvi;
g_bridge_info.vsp_listener_path = mm_path; g_bridge_info.vsp_listener_path = mm_path;
@ -807,9 +810,10 @@ mm_GameDllRequest(const char *name, int *ret)
return ptr; 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); gamedll_iface = (IServerGameDLL *)gamedll_qvi(name, ret);
strncpy(gamedll_iface_name, name, sizeof(gamedll_iface_name));
gamedll_version = atoi(&name[13]); gamedll_version = atoi(&name[13]);
mm_PatchDllInit(true); mm_PatchDllInit(true);
@ -856,6 +860,7 @@ mm_GameDllRequest(const char *name, int *ret)
mm_FreeCachedLibraries(); mm_FreeCachedLibraries();
gamedll_lib = lib; gamedll_lib = lib;
gamedll_iface = (IServerGameDLL *)ptr; gamedll_iface = (IServerGameDLL *)ptr;
strncpy(gamedll_iface_name, name, sizeof(gamedll_iface_name));
gamedll_qvi = qvi; gamedll_qvi = qvi;
gamedll_version = atoi(&name[13]); gamedll_version = atoi(&name[13]);
mm_PatchDllInit(true); mm_PatchDllInit(true);

View File

@ -53,6 +53,7 @@ struct gamedll_bridge_info
QueryValveInterface gsFactory; QueryValveInterface gsFactory;
void * pGlobals; void * pGlobals;
unsigned int dllVersion; unsigned int dllVersion;
const char * dllInterfaceName;
void * isgd; void * isgd;
const char * vsp_listener_path; const char * vsp_listener_path;
}; };