Preserve sanctity of SteamWorksGameServer::Reset(void) from ba825b9a6e.

This commit is contained in:
Kyle Sanderson
2016-04-25 15:38:13 -07:00
parent 401ee13b8f
commit 44430b167c
2 changed files with 27 additions and 19 deletions
+16 -9
View File
@@ -49,6 +49,7 @@ SteamWorksGameServer::~SteamWorksGameServer()
void SteamWorksGameServer::Reset(void) void SteamWorksGameServer::Reset(void)
{ {
this->m_pClient = NULL;
this->m_pGameServer = NULL; this->m_pGameServer = NULL;
this->m_pUtils = NULL; this->m_pUtils = NULL;
this->m_pNetworking = NULL; this->m_pNetworking = NULL;
@@ -68,18 +69,25 @@ ISteamClient *SteamWorksGameServer::GetSteamClient(void)
Thanks CS:GO team! @:| Thanks CS:GO team! @:|
*/ */
static ISteamClient *pSteamClient = NULL; if (this->m_pClient == NULL)
if (pSteamClient == NULL)
{ {
const char *pLibSteamPath = g_SteamWorks.pSWGameServer->GetLibraryPath(); const char *pLibSteamPath = g_SteamWorks.pSWGameServer->GetLibraryPath();
ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
void *(*pGSInternalCreateAddress)(const char *) = NULL; void *(*pGSInternalCreateAddress)(const char *) = NULL;
const char *pGSInternalFuncName = "SteamGameServerInternal_CreateInterface";
if (g_SteamWorks.pSWGameData)
{
IGameConfig *pConfig = g_SteamWorks.pSWGameData->GetGameData();
if (pConfig != NULL)
{
pConfig->GetMemSig(pGSInternalFuncName, &pGSInternalCreateAddress);
}
}
ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
if (pLibrary != NULL) if (pLibrary != NULL)
{ {
const char *pGSInternalFuncName = "SteamGameServerInternal_CreateInterface";
if (pGSInternalCreateAddress == NULL) if (pGSInternalCreateAddress == NULL)
{ {
pGSInternalCreateAddress = reinterpret_cast<void *(*)(const char *)>(pLibrary->GetSymbolAddress(pGSInternalFuncName)); pGSInternalCreateAddress = reinterpret_cast<void *(*)(const char *)>(pLibrary->GetSymbolAddress(pGSInternalFuncName));
@@ -89,10 +97,10 @@ ISteamClient *SteamWorksGameServer::GetSteamClient(void)
} }
if (pGSInternalCreateAddress != NULL) if (pGSInternalCreateAddress != NULL)
pSteamClient = static_cast<ISteamClient *>((*pGSInternalCreateAddress)(STEAMCLIENT_INTERFACE_VERSION)); this->m_pClient = static_cast<ISteamClient *>((*pGSInternalCreateAddress)(STEAMCLIENT_INTERFACE_VERSION));
} }
return pSteamClient; return this->m_pClient;
} }
ISteamGameServer *SteamWorksGameServer::GetGameServer(void) ISteamGameServer *SteamWorksGameServer::GetGameServer(void)
@@ -223,10 +231,9 @@ const char *SteamWorksGameServer::GetLibraryPath(void)
pLibSteamPath = "./bin/steam_api.dll"; /* Naming from SteamTools. */ pLibSteamPath = "./bin/steam_api.dll"; /* Naming from SteamTools. */
#endif #endif
IGameConfig *pConfig = NULL;
if (g_SteamWorks.pSWGameData) if (g_SteamWorks.pSWGameData)
{ {
pConfig = g_SteamWorks.pSWGameData->GetGameData(); IGameConfig *pConfig = g_SteamWorks.pSWGameData->GetGameData();
if (pConfig) if (pConfig)
{ {
const char *kvLibSteamAPI = pConfig->GetKeyValue("LibSteamAPI"); const char *kvLibSteamAPI = pConfig->GetKeyValue("LibSteamAPI");
+11 -10
View File
@@ -49,25 +49,26 @@ SteamWorksGSDetours::SteamWorksGSDetours()
{ {
const char *pLibSteamPath = g_SteamWorks.pSWGameServer->GetLibraryPath(); const char *pLibSteamPath = g_SteamWorks.pSWGameServer->GetLibraryPath();
void *pSteamSafeInitAddress = NULL;
void *pSteamShutdownAddress = NULL;
const char *pInitSafeFuncName = "SteamGameServer_InitSafe";
const char *pShutdownFuncName = "SteamGameServer_Shutdown";
IGameConfig *pConfig = NULL; IGameConfig *pConfig = NULL;
if (g_SteamWorks.pSWGameData) if (g_SteamWorks.pSWGameData)
{ {
pConfig = g_SteamWorks.pSWGameData->GetGameData(); pConfig = g_SteamWorks.pSWGameData->GetGameData();
}
ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
void *pSteamSafeInitAddress = NULL;
void *pSteamShutdownAddress = NULL;
if (pLibrary != NULL)
{
const char *pInitSafeFuncName = "SteamGameServer_InitSafe";
const char *pShutdownFuncName = "SteamGameServer_Shutdown";
if (pConfig != NULL) if (pConfig != NULL)
{ {
pConfig->GetMemSig(pShutdownFuncName, &pSteamShutdownAddress); pConfig->GetMemSig(pShutdownFuncName, &pSteamShutdownAddress);
pConfig->GetMemSig(pInitSafeFuncName, &pSteamSafeInitAddress); pConfig->GetMemSig(pInitSafeFuncName, &pSteamSafeInitAddress);
} }
}
ILibrary *pLibrary = libsys->OpenLibrary(pLibSteamPath, NULL, 0);
if (pLibrary != NULL)
{
if (pSteamShutdownAddress == NULL) if (pSteamShutdownAddress == NULL)
{ {
pSteamShutdownAddress = pLibrary->GetSymbolAddress(pShutdownFuncName); pSteamShutdownAddress = pLibrary->GetSymbolAddress(pShutdownFuncName);