1.1 --- a/sourcemm/sourcemm.cpp Sat Apr 23 17:40:33 2005 +0000
1.2 +++ b/sourcemm/sourcemm.cpp Mon Apr 25 18:54:19 2005 +0000
1.3 @@ -24,6 +24,8 @@
1.4 * @file sourcemm.cpp
1.5 */
1.6
1.7 +SH_DECL_HOOK0_void(IServerGameDLL, LevelShutdown, SH_NOATTRIB, 0);
1.8 +
1.9 CServerGameDLL g_TempGameDLL;
1.10 CServerGameEnts g_TempGameEnts;
1.11 CServerGameClients g_TempGameClients;
1.12 @@ -36,6 +38,7 @@
1.13 std::string g_BinPath;
1.14 PluginId g_PLID = Pl_Console; //Technically, SourceMM is the "Console" plugin... :p
1.15 bool bInShutdown = false;
1.16 +bool bInFirstLevel = true;
1.17
1.18 ///////////////////////////////////
1.19 // Main code for HL2 Interaction //
1.20 @@ -222,9 +225,9 @@
1.21
1.22 //Now it's safe to load plugins.
1.23 #if defined WIN32 || defined _WIN32
1.24 - snprintf(full_path, sizeof(full_path)-1, "%s\\%s", g_ModPath.c_str(), "metaplugins.ini");
1.25 + snprintf(full_path, sizeof(full_path)-1, "%s\\addons\\metamod\\%s", g_ModPath.c_str(), "metaplugins.ini");
1.26 #else
1.27 - snprintf(full_path, sizeof(full_path)-1, "%s/%s", g_ModPath.c_str(), "metaplugins.ini");
1.28 + snprintf(full_path, sizeof(full_path)-1, "%s/addons/metamod/%s", g_ModPath.c_str(), "metaplugins.ini");
1.29 #endif
1.30
1.31 LoadPluginsFromFile(full_path);
1.32 @@ -232,6 +235,12 @@
1.33 //All plugins are now loaded.
1.34 g_PluginMngr.SetAllLoaded();
1.35
1.36 + //Like metamod, reload plugins at the end of the map.
1.37 + //This is so plugins can hook everything on load, BUT, new plugins will be reloaded
1.38 + // if the server is shut down (silly, but rare case).
1.39 + bInFirstLevel = true;
1.40 + SH_ADD_HOOK_STATICFUNC(IServerGameDLL, LevelShutdown, serverDll, LevelShutdown_handler, false);
1.41 +
1.42 return true;
1.43 }
1.44 }
1.45 @@ -401,3 +410,21 @@
1.46
1.47 g_Engine.engine->LogPrint(buffer);
1.48 }
1.49 +
1.50 +void LevelShutdown_handler(void)
1.51 +{
1.52 + if (!bInFirstLevel)
1.53 + {
1.54 + char full_path[255];
1.55 +#if defined WIN32 || defined _WIN32
1.56 + snprintf(full_path, sizeof(full_path)-1, "%s\\addons\\metamod\\%s", g_ModPath.c_str(), "metaplugins.ini");
1.57 +#else
1.58 + snprintf(full_path, sizeof(full_path)-1, "%s/addons/metamod/%s", g_ModPath.c_str(), "metaplugins.ini");
1.59 +#endif
1.60 + LoadPluginsFromFile(full_path);
1.61 + } else {
1.62 + bInFirstLevel = false;
1.63 + }
1.64 +
1.65 + RETURN_META(MRES_IGNORED);
1.66 +}