extensions/tf2/extension.cpp
changeset 3533 f35b66137b06
parent 3499 814b231e4483
child 3630 b72450a8be42
     1.1 --- a/extensions/tf2/extension.cpp	Mon May 28 00:58:59 2012 +0100
     1.2 +++ b/extensions/tf2/extension.cpp	Mon May 28 01:14:46 2012 +0100
     1.3 @@ -39,6 +39,7 @@
     1.4  #include "holiday.h"
     1.5  #include "conditions.h"
     1.6  #include "gameplayrules.h"
     1.7 +#include "teleporter.h"
     1.8  #include "CDetour/detours.h"
     1.9  
    1.10  /**
    1.11 @@ -117,6 +118,7 @@
    1.12  	g_removeCondForward = forwards->CreateForward("TF2_OnConditionRemoved", ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
    1.13  	g_waitingPlayersStartForward = forwards->CreateForward("TF2_OnWaitingForPlayersStart", ET_Ignore, 0, NULL);
    1.14  	g_waitingPlayersEndForward = forwards->CreateForward("TF2_OnWaitingForPlayersEnd", ET_Ignore, 0, NULL);
    1.15 +	g_teleportForward = forwards->CreateForward("TF2_OnPlayerTeleport", ET_Hook, 3, NULL, Param_Cell, Param_Cell, Param_CellByRef);
    1.16  
    1.17  	g_pCVar = icvar;
    1.18  
    1.19 @@ -124,6 +126,7 @@
    1.20  	m_IsHolidayDetourEnabled = false;
    1.21  	m_CondChecksEnabled = false;
    1.22  	m_RulesDetoursEnabled = false;
    1.23 +	m_TeleportDetourEnabled = false;
    1.24  
    1.25  	return true;
    1.26  }
    1.27 @@ -173,6 +176,7 @@
    1.28  	forwards->ReleaseForward(g_removeCondForward);
    1.29  	forwards->ReleaseForward(g_waitingPlayersStartForward);
    1.30  	forwards->ReleaseForward(g_waitingPlayersEndForward);
    1.31 +	forwards->ReleaseForward(g_teleportForward);
    1.32  }
    1.33  
    1.34  void TF2Tools::SDK_OnAllLoaded()
    1.35 @@ -338,6 +342,11 @@
    1.36  	{
    1.37  		m_RulesDetoursEnabled = InitialiseRulesDetours();
    1.38  	}
    1.39 +
    1.40 +	if (!m_TeleportDetourEnabled && g_teleportForward->GetFunctionCount())
    1.41 +	{
    1.42 +		m_TeleportDetourEnabled = InitialiseTeleporterDetour();
    1.43 +	}
    1.44  }
    1.45  
    1.46  void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
    1.47 @@ -368,6 +377,11 @@
    1.48  			m_RulesDetoursEnabled = false;
    1.49  		}
    1.50  	}
    1.51 +	if (m_TeleportDetourEnabled && !g_teleportForward->GetFunctionCount())
    1.52 +	{
    1.53 +		RemoveTeleporterDetour();
    1.54 +		m_TeleportDetourEnabled = false;
    1.55 +	}
    1.56  }
    1.57  
    1.58  void TF2Tools::OnClientPutInServer(int client)