core/ConsoleDetours.cpp
changeset 2842 06e7fe7e106e
parent 2841 dde3dd0b4b8b
child 2843 bf16cf249d3d
     1.1 --- a/core/ConsoleDetours.cpp	Wed Oct 28 00:37:34 2009 -0700
     1.2 +++ b/core/ConsoleDetours.cpp	Wed Oct 28 00:50:48 2009 -0700
     1.3 @@ -284,6 +284,23 @@
     1.4  	Patch cgc;
     1.5  
     1.6  public:
     1.7 + 	static void DelayedActivation(void *inparam)
     1.8 + 	{
     1.9 + 		GenericCommandHooker *cdtrs = reinterpret_cast<GenericCommandHooker*>(inparam);
    1.10 + 		/* Safe to re-enter because the frame queue is lock+swapped. */
    1.11 + 		if ((!cdtrs->ces.applied || !cdtrs->cgc.applied) &&
    1.12 + 		    g_HL2.PeekCommandStack() != NULL)
    1.13 + 		{
    1.14 + 			g_SourceMod.AddFrameAction(GenericCommandHooker::DelayedActivation, cdtrs);
    1.15 + 			return;
    1.16 + 		}
    1.17 + 
    1.18 + 		if (!cdtrs->ces.applied)
    1.19 + 			cdtrs->ApplyPatch(&cdtrs->ces);
    1.20 + 		if (!cdtrs->cgc.applied)
    1.21 + 			cdtrs->ApplyPatch(&cdtrs->cgc);
    1.22 + 	}
    1.23 +
    1.24  	bool Enable()
    1.25  	{
    1.26  		const char *platform = NULL;
    1.27 @@ -321,6 +338,12 @@
    1.28  		if (!PrepPatch("CGameClient::ExecuteString", "CGC", platform, &cgc))
    1.29  			return false;
    1.30  
    1.31 + 		if (g_HL2.PeekCommandStack() != NULL)
    1.32 + 		{
    1.33 + 			g_SourceMod.AddFrameAction(GenericCommandHooker::DelayedActivation, this);
    1.34 + 			return true;
    1.35 + 		}
    1.36 +
    1.37  		ApplyPatch(&ces);
    1.38  		ApplyPatch(&cgc);
    1.39