TF2 ext fixes for TF2 holiday system changes (bug 5150, r=asherkin).

This commit is contained in:
Nicholas Hastings
2011-10-28 19:07:40 -04:00
parent e7f5f4a6af
commit ee42f09b8d
6 changed files with 49 additions and 39 deletions
+8 -8
View File
@@ -112,7 +112,7 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
playerhelpers->AddClientListener(this);
g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef);
g_getHolidayForward = forwards->CreateForward("TF2_OnGetHoliday", ET_Event, 1, NULL, Param_CellByRef);
g_isHolidayForward = forwards->CreateForward("TF2_OnIsHolidayActive", ET_Event, 2, NULL, Param_Cell, Param_CellByRef);
g_addCondForward = forwards->CreateForward("TF2_OnConditionAdded", ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
g_removeCondForward = forwards->CreateForward("TF2_OnConditionRemoved", ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
g_waitingPlayersStartForward = forwards->CreateForward("TF2_OnWaitingForPlayersStart", ET_Ignore, 0, NULL);
@@ -121,7 +121,7 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
g_pCVar = icvar;
m_CritDetoursEnabled = false;
m_GetHolidayDetourEnabled = false;
m_IsHolidayDetourEnabled = false;
m_CondChecksEnabled = false;
m_RulesDetoursEnabled = false;
@@ -168,7 +168,7 @@ void TF2Tools::SDK_OnUnload()
plsys->RemovePluginsListener(this);
forwards->ReleaseForward(g_critForward);
forwards->ReleaseForward(g_getHolidayForward);
forwards->ReleaseForward(g_isHolidayForward);
forwards->ReleaseForward(g_addCondForward);
forwards->ReleaseForward(g_removeCondForward);
forwards->ReleaseForward(g_waitingPlayersStartForward);
@@ -320,9 +320,9 @@ void TF2Tools::OnPluginLoaded(IPlugin *plugin)
m_CritDetoursEnabled = InitialiseCritDetours();
}
if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
if (!m_IsHolidayDetourEnabled && g_isHolidayForward->GetFunctionCount())
{
m_GetHolidayDetourEnabled = InitialiseGetHolidayDetour();
m_IsHolidayDetourEnabled = InitialiseIsHolidayDetour();
}
if (!m_CondChecksEnabled
@@ -347,10 +347,10 @@ void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
RemoveCritDetours();
m_CritDetoursEnabled = false;
}
if (m_GetHolidayDetourEnabled && !g_getHolidayForward->GetFunctionCount())
if (m_IsHolidayDetourEnabled && !g_isHolidayForward->GetFunctionCount())
{
RemoveGetHolidayDetour();
m_GetHolidayDetourEnabled = false;
RemoveIsHolidayDetour();
m_IsHolidayDetourEnabled = false;
}
if (m_CondChecksEnabled)
{
+1 -1
View File
@@ -118,7 +118,7 @@ public:
#endif
private:
bool m_CritDetoursEnabled;
bool m_GetHolidayDetourEnabled;
bool m_IsHolidayDetourEnabled;
bool m_CondChecksEnabled;
bool m_RulesDetoursEnabled;
};
+17 -16
View File
@@ -31,48 +31,49 @@
#include "holiday.h"
CDetour *getHolidayDetour = NULL;
CDetour *isHolidayDetour = NULL;
IForward *g_getHolidayForward = NULL;
IForward *g_isHolidayForward = NULL;
DETOUR_DECL_STATIC0(GetHoliday, int)
DETOUR_DECL_STATIC1(IsHolidayActive, bool, int, holiday)
{
int actualres = DETOUR_STATIC_CALL(GetHoliday)();
if (!g_getHolidayForward)
bool actualres = DETOUR_STATIC_CALL(IsHolidayActive)(holiday);
if (!g_isHolidayForward)
{
g_pSM->LogMessage(myself, "Invalid Forward");
return actualres;
}
cell_t result = 0;
int newres = actualres;
cell_t newres = actualres ? 1 : 0;
g_getHolidayForward->PushCellByRef(&newres);
g_getHolidayForward->Execute(&result);
g_isHolidayForward->PushCell(holiday);
g_isHolidayForward->PushCellByRef(&newres);
g_isHolidayForward->Execute(&result);
if (result == Pl_Changed)
{
return newres;
return (newres == 0) ? false : true;
}
return actualres;
}
bool InitialiseGetHolidayDetour()
bool InitialiseIsHolidayDetour()
{
getHolidayDetour = DETOUR_CREATE_STATIC(GetHoliday, "GetHoliday");
isHolidayDetour = DETOUR_CREATE_STATIC(IsHolidayActive, "IsHolidayActive");
if (getHolidayDetour != NULL)
if (isHolidayDetour != NULL)
{
getHolidayDetour->EnableDetour();
isHolidayDetour->EnableDetour();
return true;
}
g_pSM->LogError(myself, "GetHoliday detour failed");
g_pSM->LogError(myself, "IsHolidayActive detour failed");
return false;
}
void RemoveGetHolidayDetour()
void RemoveIsHolidayDetour()
{
getHolidayDetour->Destroy();
isHolidayDetour->Destroy();
}
+3 -3
View File
@@ -37,9 +37,9 @@
#include <jit/x86/x86_macros.h>
#include "CDetour/detours.h"
bool InitialiseGetHolidayDetour();
void RemoveGetHolidayDetour();
bool InitialiseIsHolidayDetour();
void RemoveIsHolidayDetour();
extern IForward *g_getHolidayForward;
extern IForward *g_isHolidayForward;
#endif //_INCLUDE_SOURCEMOD_HOLIDAY_H_