From 39c3ad0194f461c92c3f35c9421f5fa82c2b9c77 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Sat, 23 Aug 2008 20:32:35 +0000 Subject: [PATCH] Fixed bug 1750 and bug 1801. Orange Box changes the command processing heuristics without telling anyone, it looks like executing commands during the command buffer processing causes insertion to the beginning of the stream rather than end. Moving our callbacks to occur in a new frame seems to alleviate this. --HG-- branch : sourcemod-1.0.x extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/branches/sourcemod-1.0.x%402471 --- core/CoreConfig.cpp | 22 +++++++++++++++------- core/CoreConfig.h | 3 ++- core/frame_hooks.cpp | 8 ++++++++ core/frame_hooks.h | 4 +++- 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index 2b0fc95c..89b68447 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -40,6 +40,7 @@ #include "Logger.h" #include "PluginSys.h" #include "ForwardSys.h" +#include "frame_hooks.h" #ifdef PLATFORM_WINDOWS ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file"); @@ -102,9 +103,11 @@ void CheckAndFinalizeConfigs() if ((g_bServerExecd || g_ServerCfgFile == NULL) && g_bGotServerStart) { - /* Order is important here. We need to buffer things before we send the command out. */ - g_pOnAutoConfigsBuffered->Execute(NULL); - engine->ServerCommand("sm internal 1\n"); +#if defined ORANGEBOX_BUILD + g_PendingInternalPush = true; +#else + SM_InternalCmdTrigger(); +#endif } } @@ -502,10 +505,6 @@ void SM_ExecuteAllConfigs() } iter->Release(); -#if defined ORANGEBOX_BUILD - engine->ServerExecute(); -#endif - g_bGotServerStart = true; CheckAndFinalizeConfigs(); } @@ -522,3 +521,12 @@ void SM_ConfigsExecuted_Global() g_pOnServerCfg->Execute(NULL); g_pOnConfigsExecuted->Execute(NULL); } + +void SM_InternalCmdTrigger() +{ + /* Order is important here. We need to buffer things before we send the command out. */ + g_pOnAutoConfigsBuffered->Execute(NULL); + engine->ServerCommand("sm internal 1\n"); + g_PendingInternalPush = false; +} + diff --git a/core/CoreConfig.h b/core/CoreConfig.h index 2de99a33..5b1c605d 100644 --- a/core/CoreConfig.h +++ b/core/CoreConfig.h @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -68,6 +68,7 @@ extern void SM_ExecuteAllConfigs(); extern void SM_ExecuteForPlugin(IPluginContext *ctx); extern void SM_ConfigsExecuted_Global(); extern void SM_ConfigsExecuted_Plugin(unsigned int serial); +extern void SM_InternalCmdTrigger(); extern CoreConfig g_CoreConfig; diff --git a/core/frame_hooks.cpp b/core/frame_hooks.cpp index 4573af5a..fa7a98f4 100644 --- a/core/frame_hooks.cpp +++ b/core/frame_hooks.cpp @@ -35,9 +35,11 @@ #include "MenuStyle_Valve.h" #include "MenuStyle_Radio.h" #include "PlayerManager.h" +#include "CoreConfig.h" float g_LastMenuTime = 0.0f; float g_LastAuthCheck = 0.0f; +bool g_PendingInternalPush = false; void RunFrameHooks(bool simulating) { @@ -45,6 +47,12 @@ void RunFrameHooks(bool simulating) g_DBMan.RunFrame(); g_HL2.ProcessFakeCliCmdQueue(); g_HL2.ProcessDelayedKicks(); + + if (g_PendingInternalPush) + { + SM_InternalCmdTrigger(); + } + g_SourceMod.ProcessGameFrameHooks(simulating); float curtime = *g_pUniversalTime; diff --git a/core/frame_hooks.h b/core/frame_hooks.h index f99d560c..8e27acd5 100644 --- a/core/frame_hooks.h +++ b/core/frame_hooks.h @@ -2,7 +2,7 @@ * vim: set ts=4 : * ============================================================================= * SourceMod - * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved. + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. * ============================================================================= * * This program is free software; you can redistribute it and/or modify it under @@ -32,6 +32,8 @@ #ifndef _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_ #define _INCLUDE_SOURCEMOD_FRAME_HOOKS_H_ +extern bool g_PendingInternalPush; + void RunFrameHooks(bool simulating); #endif //_INCLUDE_SOURCEMOD_FRAME_HOOKS_H_