extensions/tf2/extension.cpp
changeset 3056 4e1591dceb8d
parent 2790 6dd851ba15fd
child 3151 aef99299f88b
     1.1 --- a/extensions/tf2/extension.cpp	Sun Jun 27 19:17:25 2010 -0400
     1.2 +++ b/extensions/tf2/extension.cpp	Mon Jun 28 17:48:14 2010 -0400
     1.3 @@ -36,6 +36,7 @@
     1.4  #include "iplayerinfo.h"
     1.5  #include "sm_trie_tpl.h"
     1.6  #include "criticals.h"
     1.7 +#include "holiday.h"
     1.8  #include "CDetour/detours.h"
     1.9  
    1.10  /**
    1.11 @@ -108,10 +109,12 @@
    1.12  	playerhelpers->RegisterCommandTargetProcessor(this);
    1.13  
    1.14  	g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef);
    1.15 +	g_getHolidayForward = forwards->CreateForward("TF2_OnGetHoliday", ET_Event, 1, NULL, Param_CellByRef);
    1.16  
    1.17  	g_pCVar = icvar;
    1.18  
    1.19 -	m_DetoursEnabled = false;
    1.20 +	m_CritDetoursEnabled = false;
    1.21 +	m_GetHolidayDetourEnabled = false;
    1.22  
    1.23  	return true;
    1.24  }
    1.25 @@ -155,6 +158,7 @@
    1.26  	plsys->RemovePluginsListener(this);
    1.27  
    1.28  	forwards->ReleaseForward(g_critForward);
    1.29 +	forwards->ReleaseForward(g_getHolidayForward);
    1.30  }
    1.31  
    1.32  void TF2Tools::SDK_OnAllLoaded()
    1.33 @@ -297,19 +301,29 @@
    1.34  
    1.35  void TF2Tools::OnPluginLoaded(IPlugin *plugin)
    1.36  {
    1.37 -	if (!m_DetoursEnabled && g_critForward->GetFunctionCount())
    1.38 +	if (!m_CritDetoursEnabled && g_critForward->GetFunctionCount())
    1.39  	{
    1.40 -		InitialiseDetours();
    1.41 -		m_DetoursEnabled = true;
    1.42 +		InitialiseCritDetours();
    1.43 +		m_CritDetoursEnabled = true;
    1.44 +	}
    1.45 +	if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
    1.46 +	{
    1.47 +		InitialiseGetHolidayDetour();
    1.48 +		m_GetHolidayDetourEnabled = true;
    1.49  	}
    1.50  }
    1.51  
    1.52  void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
    1.53  {
    1.54 -	if (m_DetoursEnabled && !g_critForward->GetFunctionCount())
    1.55 +	if (m_CritDetoursEnabled && !g_critForward->GetFunctionCount())
    1.56  	{
    1.57 -		RemoveDetours();
    1.58 -		m_DetoursEnabled = false;
    1.59 +		RemoveCritDetours();
    1.60 +		m_CritDetoursEnabled = false;
    1.61 +	}
    1.62 +	if (m_GetHolidayDetourEnabled && !g_getHolidayForward->GetFunctionCount())
    1.63 +	{
    1.64 +		RemoveGetHolidayDetour();
    1.65 +		m_GetHolidayDetourEnabled = false;
    1.66  	}
    1.67  }
    1.68  int FindResourceEntity()