extensions/tf2/extension.cpp
changeset 3151 aef99299f88b
parent 3056 4e1591dceb8d
child 3159 608c56ebced9
     1.1 --- a/extensions/tf2/extension.cpp	Fri Nov 19 17:39:53 2010 +1300
     1.2 +++ b/extensions/tf2/extension.cpp	Fri Nov 19 17:58:46 2010 +1300
     1.3 @@ -37,6 +37,7 @@
     1.4  #include "sm_trie_tpl.h"
     1.5  #include "criticals.h"
     1.6  #include "holiday.h"
     1.7 +#include "gameplayrules.h"
     1.8  #include "CDetour/detours.h"
     1.9  
    1.10  /**
    1.11 @@ -110,11 +111,14 @@
    1.12  
    1.13  	g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef);
    1.14  	g_getHolidayForward = forwards->CreateForward("TF2_OnGetHoliday", ET_Event, 1, NULL, Param_CellByRef);
    1.15 +	g_waitingPlayersStartForward = forwards->CreateForward("TF2_OnWaitingForPlayersStart", ET_Ignore, 0, NULL);
    1.16 +	g_waitingPlayersEndForward = forwards->CreateForward("TF2_OnWaitingForPlayersEnd", ET_Ignore, 0, NULL);
    1.17  
    1.18  	g_pCVar = icvar;
    1.19  
    1.20  	m_CritDetoursEnabled = false;
    1.21  	m_GetHolidayDetourEnabled = false;
    1.22 +	m_RulesDetoursEnabled = false;
    1.23  
    1.24  	return true;
    1.25  }
    1.26 @@ -159,6 +163,8 @@
    1.27  
    1.28  	forwards->ReleaseForward(g_critForward);
    1.29  	forwards->ReleaseForward(g_getHolidayForward);
    1.30 +	forwards->ReleaseForward(g_waitingPlayersStartForward);
    1.31 +	forwards->ReleaseForward(g_waitingPlayersEndForward);
    1.32  }
    1.33  
    1.34  void TF2Tools::SDK_OnAllLoaded()
    1.35 @@ -311,6 +317,14 @@
    1.36  		InitialiseGetHolidayDetour();
    1.37  		m_GetHolidayDetourEnabled = true;
    1.38  	}
    1.39 +	if (!m_RulesDetoursEnabled)
    1.40 +	{
    1.41 +		if(g_waitingPlayersStartForward->GetFunctionCount() || g_waitingPlayersEndForward->GetFunctionCount())
    1.42 +		{
    1.43 +			InitialiseRulesDetours();
    1.44 +			m_RulesDetoursEnabled = true;
    1.45 +		}
    1.46 +	}
    1.47  }
    1.48  
    1.49  void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
    1.50 @@ -325,6 +339,14 @@
    1.51  		RemoveGetHolidayDetour();
    1.52  		m_GetHolidayDetourEnabled = false;
    1.53  	}
    1.54 +	if (m_RulesDetoursEnabled)
    1.55 +	{
    1.56 +		if(!g_waitingPlayersStartForward->GetFunctionCount() || !g_waitingPlayersEndForward->GetFunctionCount())
    1.57 +		{
    1.58 +			RemoveRulesDetours();
    1.59 +			m_RulesDetoursEnabled = false;
    1.60 +		}
    1.61 +	}
    1.62  }
    1.63  int FindResourceEntity()
    1.64  {