mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-09 19:38:29 +00:00
I really don't feel like writing a comment because I don't know what I've just done
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4018
This commit is contained in:
parent
2617dfe79a
commit
096dfb6a6f
@ -217,10 +217,6 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
|||||||
//Everything's done.
|
//Everything's done.
|
||||||
g_GameDll.loaded = true;
|
g_GameDll.loaded = true;
|
||||||
|
|
||||||
//Get call class, etc
|
|
||||||
g_GameDll.serverDll = serverDll;
|
|
||||||
g_GameDll.serverDll_CC = SH_GET_CALLCLASS(IServerGameDLL, serverDll);
|
|
||||||
|
|
||||||
//Initialize our console hooks
|
//Initialize our console hooks
|
||||||
ConCommandBaseMgr::OneTimeInit(static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor));
|
ConCommandBaseMgr::OneTimeInit(static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor));
|
||||||
|
|
||||||
@ -243,28 +239,42 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The engine uses the DLL even after it has call DLLShutdown, so we unload it
|
||||||
|
// when it unloads us
|
||||||
|
#if defined _WIN32
|
||||||
|
BOOL WINAPI DllMain(
|
||||||
|
HINSTANCE hinstDLL,
|
||||||
|
DWORD fdwReason,
|
||||||
|
LPVOID lpvReserved
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (fdwReason == DLL_PROCESS_DETACH)
|
||||||
|
{
|
||||||
|
if (g_GameDll.lib && g_GameDll.loaded)
|
||||||
|
//dlclose(g_GameDll.lib);
|
||||||
|
memset(&g_GameDll, 0, sizeof(GameDllInfo));
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#elif defined __linux__
|
||||||
|
void __attribute__ ((destructor)) app_fini(void)
|
||||||
|
{
|
||||||
|
if (g_GameDll.lib && g_GameDll.loaded)
|
||||||
|
dlclose(g_GameDll.lib);
|
||||||
|
memset(&g_GameDll, 0, sizeof(GameDllInfo));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void CServerGameDLL::DLLShutdown()
|
void CServerGameDLL::DLLShutdown()
|
||||||
{
|
{
|
||||||
//cancel if we're shutting down already
|
//Call the original function
|
||||||
if (bInShutdown)
|
m_pOrig->DLLShutdown();
|
||||||
return;
|
|
||||||
|
|
||||||
//we're not re-entrant
|
|
||||||
bInShutdown = true;
|
|
||||||
|
|
||||||
//Call the original function through its call class
|
|
||||||
g_GameDll.serverDll_CC->DLLShutdown();
|
|
||||||
|
|
||||||
//Unload plugins
|
//Unload plugins
|
||||||
g_PluginMngr.UnloadAll();
|
g_PluginMngr.UnloadAll();
|
||||||
|
|
||||||
// Shutdown sourcehook now
|
// Shutdown sourcehook now
|
||||||
SH_RELEASE_CALLCLASS(g_GameDll.serverDll_CC);
|
|
||||||
g_SourceHook.CompleteShutdown();
|
g_SourceHook.CompleteShutdown();
|
||||||
|
|
||||||
//Unload the DLL forcefully
|
|
||||||
dlclose(g_GameDll.lib);
|
|
||||||
memset(&g_GameDll, 0, sizeof(GameDllInfo));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int LoadPluginsFromFile(const char *file)
|
int LoadPluginsFromFile(const char *file)
|
||||||
|
|||||||
@ -55,8 +55,6 @@ struct GameDllInfo
|
|||||||
bool loaded;
|
bool loaded;
|
||||||
HINSTANCE lib;
|
HINSTANCE lib;
|
||||||
CreateInterfaceFn factory;
|
CreateInterfaceFn factory;
|
||||||
IServerGameDLL *serverDll_CC;
|
|
||||||
IServerGameDLL *serverDll;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** @brief Stores information about the HL2 Engine pointers */
|
/** @brief Stores information about the HL2 Engine pointers */
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user