mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-20 13:54:14 +01:00
SourceMM will now reload new plugins on mapchange
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4040
This commit is contained in:
parent
fa375405eb
commit
ee8a24229c
@ -24,6 +24,8 @@
|
||||
* @file sourcemm.cpp
|
||||
*/
|
||||
|
||||
SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, 0);
|
||||
|
||||
CServerGameDLL g_TempGameDLL;
|
||||
CServerGameEnts g_TempGameEnts;
|
||||
CServerGameClients g_TempGameClients;
|
||||
@ -36,6 +38,7 @@ std::string g_ModPath;
|
||||
std::string g_BinPath;
|
||||
PluginId g_PLID = Pl_Console; //Technically, SourceMM is the "Console" plugin... :p
|
||||
bool bInShutdown = false;
|
||||
bool bInFirstLevel = true;
|
||||
|
||||
///////////////////////////////////
|
||||
// Main code for HL2 Interaction //
|
||||
@ -222,9 +225,9 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
|
||||
//Now it's safe to load plugins.
|
||||
#if defined WIN32 || defined _WIN32
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s\\%s", g_ModPath.c_str(), "metaplugins.ini");
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s\\addons\\metamod\\%s", g_ModPath.c_str(), "metaplugins.ini");
|
||||
#else
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), "metaplugins.ini");
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s/addons/metamod/%s", g_ModPath.c_str(), "metaplugins.ini");
|
||||
#endif
|
||||
|
||||
LoadPluginsFromFile(full_path);
|
||||
@ -232,6 +235,12 @@ bool CServerGameDLL::DLLInit(CreateInterfaceFn engineFactory, CreateInterfaceFn
|
||||
//All plugins are now loaded.
|
||||
g_PluginMngr.SetAllLoaded();
|
||||
|
||||
//Like metamod, reload plugins at the end of the map.
|
||||
//This is so plugins can hook everything on load, BUT, new plugins will be reloaded
|
||||
// if the server is shut down (silly, but rare case).
|
||||
bInFirstLevel = true;
|
||||
SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelShutdown, serverDll, LevelShutdown_handler, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -401,3 +410,21 @@ void LogMessage(const char *msg, ...)
|
||||
|
||||
g_Engine.engine->LogPrint(buffer);
|
||||
}
|
||||
|
||||
void LevelShutdown_handler(void)
|
||||
{
|
||||
if (!bInFirstLevel)
|
||||
{
|
||||
char full_path[255];
|
||||
#if defined WIN32 || defined _WIN32
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s\\addons\\metamod\\%s", g_ModPath.c_str(), "metaplugins.ini");
|
||||
#else
|
||||
snprintf(full_path, sizeof(full_path)-1, "%s/addons/metamod/%s", g_ModPath.c_str(), "metaplugins.ini");
|
||||
#endif
|
||||
LoadPluginsFromFile(full_path);
|
||||
} else {
|
||||
bInFirstLevel = false;
|
||||
}
|
||||
|
||||
RETURN_META(MRES_IGNORED);
|
||||
}
|
||||
|
@ -89,4 +89,7 @@ extern SourceHook::ISourceHook *g_SHPtr;
|
||||
/** @brief We have our own internal plugin id... */
|
||||
extern PluginId g_PLID;
|
||||
|
||||
/** @brief Hook for LevelShutdown */
|
||||
void LevelShutdown_handler(void);
|
||||
|
||||
#endif //_INCLUDE_SOURCEMM_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user