1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-03-22 13:19:40 +01: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:
Pavol Marko 2005-04-18 16:18:02 +00:00
parent 2617dfe79a
commit 096dfb6a6f
2 changed files with 29 additions and 21 deletions

View File

@ -217,10 +217,6 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
//Everything's done.
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
ConCommandBaseMgr::OneTimeInit(static_cast<IConCommandBaseAccessor *>(&g_SMConVarAccessor));
@ -243,28 +239,42 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
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()
{
//cancel if we're shutting down already
if (bInShutdown)
return;
//we're not re-entrant
bInShutdown = true;
//Call the original function through its call class
g_GameDll.serverDll_CC->DLLShutdown();
//Call the original function
m_pOrig->DLLShutdown();
//Unload plugins
g_PluginMngr.UnloadAll();
//Shutdown sourcehook now
SH_RELEASE_CALLCLASS(g_GameDll.serverDll_CC);
// Shutdown sourcehook now
g_SourceHook.CompleteShutdown();
//Unload the DLL forcefully
dlclose(g_GameDll.lib);
memset(&g_GameDll, 0, sizeof(GameDllInfo));
}
int LoadPluginsFromFile(const char *file)

View File

@ -55,8 +55,6 @@ struct GameDllInfo
bool loaded;
HINSTANCE lib;
CreateInterfaceFn factory;
IServerGameDLL *serverDll_CC;
IServerGameDLL *serverDll;
};
/** @brief Stores information about the HL2 Engine pointers */