From 40e0857a297ccd141e31af12dc23b968cc6d17fe Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 21 May 2008 02:12:12 +0000 Subject: [PATCH] added a forward that helps prevent against race conditions in map config plugins --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%402162 --- core/CoreConfig.cpp | 5 +++++ plugins/include/sourcemod.inc | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 0075c537..87b238c9 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -49,6 +49,7 @@ ConVar sm_corecfgfile("sm_corecfgfile", "addons/sourcemod/configs/core.cfg", 0, IForward *g_pOnServerCfg = NULL; IForward *g_pOnConfigsExecuted = NULL; +IForward *g_pOnAutoConfigsBuffered = NULL; CoreConfig g_CoreConfig; bool g_bConfigsExecd = false; @@ -57,6 +58,7 @@ void CoreConfig::OnSourceModAllInitialized() g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this); g_pOnServerCfg = g_Forwards.CreateForward("OnServerCfg", ET_Ignore, 0, NULL); g_pOnConfigsExecuted = g_Forwards.CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL); + g_pOnAutoConfigsBuffered = g_Forwards.CreateForward("OnAutoConfigsBuffered", ET_Ignore, 0, NULL); } void CoreConfig::OnSourceModShutdown() @@ -64,6 +66,7 @@ void CoreConfig::OnSourceModShutdown() g_RootMenu.RemoveRootConsoleCommand("config", this); g_Forwards.ReleaseForward(g_pOnServerCfg); g_Forwards.ReleaseForward(g_pOnConfigsExecuted); + g_Forwards.ReleaseForward(g_pOnAutoConfigsBuffered); } void CoreConfig::OnSourceModLevelChange(const char *mapName) @@ -403,6 +406,8 @@ void SM_ExecuteAllConfigs() } iter->Release(); + g_pOnAutoConfigsBuffered->Execute(NULL); + engine->ServerCommand("sm internal 1\n"); } diff --git a/plugins/include/sourcemod.inc b/plugins/include/sourcemod.inc index 8d1c4e68..a65281fb 100644 --- a/plugins/include/sourcemod.inc +++ b/plugins/include/sourcemod.inc @@ -168,6 +168,23 @@ forward OnMapEnd(); */ forward OnConfigsExecuted(); +/** + * This is called once, right after OnMapStart() but any time before + * OnConfigsExecuted(). It is called after the "exec sourcemod.cfg" + * command and all AutoExecConfig() exec commands have been added to + * the ServerCommand() buffer. + * + * If you need to load per-map settings that override default values, + * adding commands to the ServerCommand() buffer here will guarantee + * that they're set before OnConfigsExecuted(). + * + * Unlike OnMapStart() and OnConfigsExecuted(), this is not called on + * late loads that occur after OnMapStart(). + * + * @noreturn + */ +forward OnAutoConfigsBuffered(); + /** * @deprecated Use OnConfigsExecuted() instead. */