TF2 ext fixes for TF2 holiday system changes (bug 5150, r=asherkin).
TF2 ext fixes for TF2 holiday system changes (
bug 5150, r=asherkin).
1.1 --- a/extensions/tf2/extension.cpp Fri Oct 28 11:24:08 2011 -0400
1.2 +++ b/extensions/tf2/extension.cpp Fri Oct 28 19:07:40 2011 -0400
1.3 @@ -112,7 +112,7 @@
1.4 playerhelpers->AddClientListener(this);
1.5
1.6 g_critForward = forwards->CreateForward("TF2_CalcIsAttackCritical", ET_Hook, 4, NULL, Param_Cell, Param_Cell, Param_String, Param_CellByRef);
1.7 - g_getHolidayForward = forwards->CreateForward("TF2_OnGetHoliday", ET_Event, 1, NULL, Param_CellByRef);
1.8 + g_isHolidayForward = forwards->CreateForward("TF2_OnIsHolidayActive", ET_Event, 2, NULL, Param_Cell, Param_CellByRef);
1.9 g_addCondForward = forwards->CreateForward("TF2_OnConditionAdded", ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
1.10 g_removeCondForward = forwards->CreateForward("TF2_OnConditionRemoved", ET_Ignore, 2, NULL, Param_Cell, Param_Cell);
1.11 g_waitingPlayersStartForward = forwards->CreateForward("TF2_OnWaitingForPlayersStart", ET_Ignore, 0, NULL);
1.12 @@ -121,7 +121,7 @@
1.13 g_pCVar = icvar;
1.14
1.15 m_CritDetoursEnabled = false;
1.16 - m_GetHolidayDetourEnabled = false;
1.17 + m_IsHolidayDetourEnabled = false;
1.18 m_CondChecksEnabled = false;
1.19 m_RulesDetoursEnabled = false;
1.20
1.21 @@ -168,7 +168,7 @@
1.22 plsys->RemovePluginsListener(this);
1.23
1.24 forwards->ReleaseForward(g_critForward);
1.25 - forwards->ReleaseForward(g_getHolidayForward);
1.26 + forwards->ReleaseForward(g_isHolidayForward);
1.27 forwards->ReleaseForward(g_addCondForward);
1.28 forwards->ReleaseForward(g_removeCondForward);
1.29 forwards->ReleaseForward(g_waitingPlayersStartForward);
1.30 @@ -320,9 +320,9 @@
1.31 m_CritDetoursEnabled = InitialiseCritDetours();
1.32 }
1.33
1.34 - if (!m_GetHolidayDetourEnabled && g_getHolidayForward->GetFunctionCount())
1.35 + if (!m_IsHolidayDetourEnabled && g_isHolidayForward->GetFunctionCount())
1.36 {
1.37 - m_GetHolidayDetourEnabled = InitialiseGetHolidayDetour();
1.38 + m_IsHolidayDetourEnabled = InitialiseIsHolidayDetour();
1.39 }
1.40
1.41 if (!m_CondChecksEnabled
1.42 @@ -347,10 +347,10 @@
1.43 RemoveCritDetours();
1.44 m_CritDetoursEnabled = false;
1.45 }
1.46 - if (m_GetHolidayDetourEnabled && !g_getHolidayForward->GetFunctionCount())
1.47 + if (m_IsHolidayDetourEnabled && !g_isHolidayForward->GetFunctionCount())
1.48 {
1.49 - RemoveGetHolidayDetour();
1.50 - m_GetHolidayDetourEnabled = false;
1.51 + RemoveIsHolidayDetour();
1.52 + m_IsHolidayDetourEnabled = false;
1.53 }
1.54 if (m_CondChecksEnabled)
1.55 {
2.1 --- a/extensions/tf2/extension.h Fri Oct 28 11:24:08 2011 -0400
2.2 +++ b/extensions/tf2/extension.h Fri Oct 28 19:07:40 2011 -0400
2.3 @@ -118,7 +118,7 @@
2.4 #endif
2.5 private:
2.6 bool m_CritDetoursEnabled;
2.7 - bool m_GetHolidayDetourEnabled;
2.8 + bool m_IsHolidayDetourEnabled;
2.9 bool m_CondChecksEnabled;
2.10 bool m_RulesDetoursEnabled;
2.11 };
3.1 --- a/extensions/tf2/holiday.cpp Fri Oct 28 11:24:08 2011 -0400
3.2 +++ b/extensions/tf2/holiday.cpp Fri Oct 28 19:07:40 2011 -0400
3.3 @@ -31,48 +31,49 @@
3.4
3.5 #include "holiday.h"
3.6
3.7 -CDetour *getHolidayDetour = NULL;
3.8 +CDetour *isHolidayDetour = NULL;
3.9
3.10 -IForward *g_getHolidayForward = NULL;
3.11 +IForward *g_isHolidayForward = NULL;
3.12
3.13 -DETOUR_DECL_STATIC0(GetHoliday, int)
3.14 +DETOUR_DECL_STATIC1(IsHolidayActive, bool, int, holiday)
3.15 {
3.16 - int actualres = DETOUR_STATIC_CALL(GetHoliday)();
3.17 - if (!g_getHolidayForward)
3.18 + bool actualres = DETOUR_STATIC_CALL(IsHolidayActive)(holiday);
3.19 + if (!g_isHolidayForward)
3.20 {
3.21 g_pSM->LogMessage(myself, "Invalid Forward");
3.22 return actualres;
3.23 }
3.24
3.25 cell_t result = 0;
3.26 - int newres = actualres;
3.27 + cell_t newres = actualres ? 1 : 0;
3.28
3.29 - g_getHolidayForward->PushCellByRef(&newres);
3.30 - g_getHolidayForward->Execute(&result);
3.31 + g_isHolidayForward->PushCell(holiday);
3.32 + g_isHolidayForward->PushCellByRef(&newres);
3.33 + g_isHolidayForward->Execute(&result);
3.34
3.35 if (result == Pl_Changed)
3.36 {
3.37 - return newres;
3.38 + return (newres == 0) ? false : true;
3.39 }
3.40
3.41 return actualres;
3.42 }
3.43
3.44 -bool InitialiseGetHolidayDetour()
3.45 +bool InitialiseIsHolidayDetour()
3.46 {
3.47 - getHolidayDetour = DETOUR_CREATE_STATIC(GetHoliday, "GetHoliday");
3.48 + isHolidayDetour = DETOUR_CREATE_STATIC(IsHolidayActive, "IsHolidayActive");
3.49
3.50 - if (getHolidayDetour != NULL)
3.51 + if (isHolidayDetour != NULL)
3.52 {
3.53 - getHolidayDetour->EnableDetour();
3.54 + isHolidayDetour->EnableDetour();
3.55 return true;
3.56 }
3.57
3.58 - g_pSM->LogError(myself, "GetHoliday detour failed");
3.59 + g_pSM->LogError(myself, "IsHolidayActive detour failed");
3.60 return false;
3.61 }
3.62
3.63 -void RemoveGetHolidayDetour()
3.64 +void RemoveIsHolidayDetour()
3.65 {
3.66 - getHolidayDetour->Destroy();
3.67 + isHolidayDetour->Destroy();
3.68 }
4.1 --- a/extensions/tf2/holiday.h Fri Oct 28 11:24:08 2011 -0400
4.2 +++ b/extensions/tf2/holiday.h Fri Oct 28 19:07:40 2011 -0400
4.3 @@ -37,9 +37,9 @@
4.4 #include <jit/x86/x86_macros.h>
4.5 #include "CDetour/detours.h"
4.6
4.7 -bool InitialiseGetHolidayDetour();
4.8 -void RemoveGetHolidayDetour();
4.9 +bool InitialiseIsHolidayDetour();
4.10 +void RemoveIsHolidayDetour();
4.11
4.12 -extern IForward *g_getHolidayForward;
4.13 +extern IForward *g_isHolidayForward;
4.14
4.15 #endif //_INCLUDE_SOURCEMOD_HOLIDAY_H_
5.1 --- a/gamedata/sm-tf2.games.txt Fri Oct 28 11:24:08 2011 -0400
5.2 +++ b/gamedata/sm-tf2.games.txt Fri Oct 28 19:07:40 2011 -0400
5.3 @@ -99,12 +99,12 @@
5.4 "linux" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer"
5.5 "mac" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer"
5.6 }
5.7 - "GetHoliday"
5.8 + "IsHolidayActive"
5.9 {
5.10 "library" "server"
5.11 - "windows" "\x81\xEC\x2A\x2A\x2A\x2A\x53\x55\x56\x57\x6A\x00\xE8\x2A\x2A\x2A\x2A\x89"
5.12 - "linux" "@_Z15UTIL_GetHolidayv"
5.13 - "mac" "@_Z15UTIL_GetHolidayv"
5.14 + "windows" "\x80\x2A\x2A\x2A\x2A\x2A\x00\x75\x2A\xE8\x2A\x2A\x2A\x2A\x8B\x54\x2A\x2A\x8B"
5.15 + "linux" "@_Z20UTIL_IsHolidayActivei"
5.16 + "mac" "@_Z20UTIL_IsHolidayActivei"
5.17 }
5.18 "MakeBleed"
5.19 {
6.1 --- a/plugins/include/tf2.inc Fri Oct 28 11:24:08 2011 -0400
6.2 +++ b/plugins/include/tf2.inc Fri Oct 28 19:07:40 2011 -0400
6.3 @@ -121,8 +121,10 @@
6.4 enum TFHoliday
6.5 {
6.6 TFHoliday_None = 1,
6.7 + TFHoliday_Birthday,
6.8 TFHoliday_Halloween,
6.9 - TFHoliday_Birthday
6.10 + TFHoliday_FullMoon,
6.11 + TFHoliday_HalloweenOrFullMoon,
6.12 };
6.13
6.14 enum TFObjectType
6.15 @@ -278,14 +280,21 @@
6.16 forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result);
6.17
6.18 /**
6.19 - * Called when the game checks to see if the current day is one of its tracked holidays
6.20 + * @deprecated No longer called. Use TF2_OnIsHolidayActive.
6.21 + */
6.22 +#pragma deprecated No longer called. Use TF2_OnIsHolidayActive.
6.23 +forward Action:TF2_OnGetHoliday(&TFHoliday:holiday);
6.24 +
6.25 +/**
6.26 + * Called at various times when the game checks to see if the given holiday is active.
6.27 + * Return Plugin_Continue to let the original calculation or return a higher
6.28 + * action to override the decision with the value of 'result'
6.29 *
6.30 - * @note Change the value of holiday and return Plugin_Changed to override.
6.31 - * Return Plugin_Continue for no change.
6.32 - *
6.33 - * @param holiday Current Holiday
6.34 + * @param holiday Holiday being checked.
6.35 + * @param result Buffer param for the result of the decision.
6.36 + * @return Plugin_Continue for original calculation, higher value to use 'result'.
6.37 */
6.38 -forward Action:TF2_OnGetHoliday(&TFHoliday:holiday);
6.39 +forward Action:TF2_OnIsHolidayActive(TFHoliday:holiday, &bool:result);
6.40
6.41 /**
6.42 * Returns whether or not a client (Player) is in a duel.