mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
Attempt at fixing some bugs related to gamedll shutdown
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4083
This commit is contained in:
parent
5f2a28d33d
commit
5f6e613e01
@ -30,11 +30,11 @@ CPluginManager::CPluginManager()
|
||||
|
||||
CPluginManager::~CPluginManager()
|
||||
{
|
||||
if (m_Plugins.size())
|
||||
/*if (m_Plugins.size())
|
||||
{
|
||||
UnloadAll();
|
||||
m_Plugins.clear();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
CPluginManager::CPlugin::CPlugin() : m_Lib(NULL), m_API(NULL), m_Id(0), m_Source(0)
|
||||
@ -388,30 +388,23 @@ bool CPluginManager::_Unpause(CPluginManager::CPlugin *pl, char *error, size_t m
|
||||
bool CPluginManager::UnloadAll()
|
||||
{
|
||||
PluginIter i;
|
||||
bool status = true;
|
||||
|
||||
std::list<SourceMM::CPluginManager::CPlugin *> remqueue;
|
||||
|
||||
for (i=m_Plugins.begin(); i!=m_Plugins.end(); i++)
|
||||
remqueue.push_back( (*i) );
|
||||
|
||||
char error[128];
|
||||
bool status = true;
|
||||
|
||||
for (i=remqueue.begin(); i!=remqueue.end(); i++)
|
||||
{
|
||||
if ( (*i) )
|
||||
{
|
||||
if ( (*i)->m_API )
|
||||
{
|
||||
if ( !(*i)->m_API->Unload(NULL, 0) )
|
||||
status = false;
|
||||
|
||||
UnregAllConCmds( (*i) );
|
||||
|
||||
//Unlink from SourceHook
|
||||
g_SourceHook.UnloadPlugin( (*i)->m_Id );
|
||||
|
||||
//Free the DLL
|
||||
dlclose( (*i)->m_Lib );
|
||||
}
|
||||
delete (*i);
|
||||
}
|
||||
if ( !_Unload( (*i), true, error, sizeof(error)-1) )
|
||||
status = false;
|
||||
}
|
||||
|
||||
m_Plugins.clear();
|
||||
remqueue.clear();
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -256,6 +256,18 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
return false;
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
//Unload plugins
|
||||
g_PluginMngr.UnloadAll();
|
||||
|
||||
// Shutdown sourcehook now
|
||||
g_SourceHook.CompleteShutdown();
|
||||
|
||||
// Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly
|
||||
g_SMConVarAccessor.MarkCommandsAsGameDLL();
|
||||
}
|
||||
|
||||
// The engine uses the DLL even after it has call DLLShutdown, so we unload it
|
||||
// when it unloads us
|
||||
#if defined _WIN32
|
||||
@ -267,6 +279,8 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
{
|
||||
if (fdwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
if (!bInShutdown)
|
||||
Shutdown();
|
||||
if (g_GameDll.lib && g_GameDll.loaded)
|
||||
dlclose(g_GameDll.lib);
|
||||
memset(&g_GameDll, 0, sizeof(GameDllInfo));
|
||||
@ -276,6 +290,8 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
#elif defined __linux__
|
||||
void __attribute__ ((destructor)) app_fini(void)
|
||||
{
|
||||
if (!bInShutdown())
|
||||
Shutdown();
|
||||
if (g_GameDll.lib && g_GameDll.loaded)
|
||||
dlclose(g_GameDll.lib);
|
||||
memset(&g_GameDll, 0, sizeof(GameDllInfo));
|
||||
@ -284,17 +300,12 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
|
||||
void CServerGameDLL::DLLShutdown()
|
||||
{
|
||||
Shutdown();
|
||||
|
||||
//Call the original function
|
||||
m_pOrig->DLLShutdown();
|
||||
|
||||
//Unload plugins
|
||||
g_PluginMngr.UnloadAll();
|
||||
|
||||
// Shutdown sourcehook now
|
||||
g_SourceHook.CompleteShutdown();
|
||||
|
||||
// Add the FCVAR_GAMEDLL flag to our cvars so the engine removes them properly
|
||||
g_SMConVarAccessor.MarkCommandsAsGameDLL();
|
||||
bInShutdown = true;
|
||||
}
|
||||
|
||||
int LoadPluginsFromFile(const char *file)
|
||||
|
@ -31,12 +31,13 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="tier0.lib"
|
||||
OutputFile="$(OutDir)/sourcemm.dll"
|
||||
AdditionalDependencies="tier0.lib vstdlib.lib"
|
||||
OutputFile="$(OutDir)/server.dll"
|
||||
LinkIncremental="2"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile="$(OutDir)/sourcemm.pdb"
|
||||
SubSystem="2"
|
||||
EnableCOMDATFolding="1"
|
||||
ImportLibrary="$(OutDir)/sourcemm.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
|
Loading…
x
Reference in New Issue
Block a user