diff --git a/extensions/tf2/extension.cpp b/extensions/tf2/extension.cpp index e08092a1..419d4e1f 100644 --- a/extensions/tf2/extension.cpp +++ b/extensions/tf2/extension.cpp @@ -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) { diff --git a/extensions/tf2/extension.h b/extensions/tf2/extension.h index 644723ce..71187733 100644 --- a/extensions/tf2/extension.h +++ b/extensions/tf2/extension.h @@ -118,7 +118,7 @@ public: #endif private: bool m_CritDetoursEnabled; - bool m_GetHolidayDetourEnabled; + bool m_IsHolidayDetourEnabled; bool m_CondChecksEnabled; bool m_RulesDetoursEnabled; }; diff --git a/extensions/tf2/holiday.cpp b/extensions/tf2/holiday.cpp index 5ce1b632..bab5a62b 100644 --- a/extensions/tf2/holiday.cpp +++ b/extensions/tf2/holiday.cpp @@ -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(); } diff --git a/extensions/tf2/holiday.h b/extensions/tf2/holiday.h index 5075062c..cef2f672 100644 --- a/extensions/tf2/holiday.h +++ b/extensions/tf2/holiday.h @@ -37,9 +37,9 @@ #include #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_ diff --git a/gamedata/sm-tf2.games.txt b/gamedata/sm-tf2.games.txt index aff1cb58..258354de 100644 --- a/gamedata/sm-tf2.games.txt +++ b/gamedata/sm-tf2.games.txt @@ -99,12 +99,12 @@ "linux" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer" "mac" "@_ZN15CTFPlayerShared10StunPlayerEffiP9CTFPlayer" } - "GetHoliday" + "IsHolidayActive" { "library" "server" - "windows" "\x81\xEC\x2A\x2A\x2A\x2A\x53\x55\x56\x57\x6A\x00\xE8\x2A\x2A\x2A\x2A\x89" - "linux" "@_Z15UTIL_GetHolidayv" - "mac" "@_Z15UTIL_GetHolidayv" + "windows" "\x80\x2A\x2A\x2A\x2A\x2A\x00\x75\x2A\xE8\x2A\x2A\x2A\x2A\x8B\x54\x2A\x2A\x8B" + "linux" "@_Z20UTIL_IsHolidayActivei" + "mac" "@_Z20UTIL_IsHolidayActivei" } "MakeBleed" { diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc index ae7c03dc..3cf9976a 100644 --- a/plugins/include/tf2.inc +++ b/plugins/include/tf2.inc @@ -121,8 +121,10 @@ enum TFCond enum TFHoliday { TFHoliday_None = 1, + TFHoliday_Birthday, TFHoliday_Halloween, - TFHoliday_Birthday + TFHoliday_FullMoon, + TFHoliday_HalloweenOrFullMoon, }; enum TFObjectType @@ -278,15 +280,22 @@ native TFClassType:TF2_GetClass(const String:classname[]); forward Action:TF2_CalcIsAttackCritical(client, weapon, String:weaponname[], &bool:result); /** - * Called when the game checks to see if the current day is one of its tracked holidays - * - * @note Change the value of holiday and return Plugin_Changed to override. - * Return Plugin_Continue for no change. - * - * @param holiday Current Holiday + * @deprecated No longer called. Use TF2_OnIsHolidayActive. */ +#pragma deprecated No longer called. Use TF2_OnIsHolidayActive. forward Action:TF2_OnGetHoliday(&TFHoliday:holiday); +/** + * Called at various times when the game checks to see if the given holiday is active. + * Return Plugin_Continue to let the original calculation or return a higher + * action to override the decision with the value of 'result' + * + * @param holiday Holiday being checked. + * @param result Buffer param for the result of the decision. + * @return Plugin_Continue for original calculation, higher value to use 'result'. + */ +forward Action:TF2_OnIsHolidayActive(TFHoliday:holiday, &bool:result); + /** * Returns whether or not a client (Player) is in a duel. *