skamonkey@3056: /** skamonkey@3056: * vim: set ts=4 : skamonkey@3056: * ============================================================================= skamonkey@3056: * SourceMod Team Fortress 2 Extension skamonkey@3056: * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. skamonkey@3056: * ============================================================================= skamonkey@3056: * skamonkey@3056: * This program is free software; you can redistribute it and/or modify it under skamonkey@3056: * the terms of the GNU General Public License, version 3.0, as published by the skamonkey@3056: * Free Software Foundation. skamonkey@3056: * skamonkey@3056: * This program is distributed in the hope that it will be useful, but WITHOUT skamonkey@3056: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS skamonkey@3056: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more skamonkey@3056: * details. skamonkey@3056: * skamonkey@3056: * You should have received a copy of the GNU General Public License along with skamonkey@3056: * this program. If not, see . skamonkey@3056: * skamonkey@3056: * As a special exception, AlliedModders LLC gives you permission to link the skamonkey@3056: * code of this program (as well as its derivative works) to "Half-Life 2," the skamonkey@3056: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software skamonkey@3056: * by the Valve Corporation. You must obey the GNU General Public License in skamonkey@3056: * all respects for all other code used. Additionally, AlliedModders LLC grants skamonkey@3056: * this exception to all derivative works. AlliedModders LLC defines further skamonkey@3056: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), skamonkey@3056: * or . skamonkey@3056: * skamonkey@3056: * Version: $Id$ skamonkey@3056: */ skamonkey@3056: skamonkey@3056: #include "holiday.h" skamonkey@3056: skamonkey@3426: CDetour *isHolidayDetour = NULL; skamonkey@3056: skamonkey@3426: IForward *g_isHolidayForward = NULL; skamonkey@3056: skamonkey@3426: DETOUR_DECL_STATIC1(IsHolidayActive, bool, int, holiday) skamonkey@3056: { skamonkey@3426: bool actualres = DETOUR_STATIC_CALL(IsHolidayActive)(holiday); skamonkey@3426: if (!g_isHolidayForward) skamonkey@3056: { skamonkey@3056: g_pSM->LogMessage(myself, "Invalid Forward"); skamonkey@3056: return actualres; skamonkey@3056: } skamonkey@3056: skamonkey@3056: cell_t result = 0; skamonkey@3426: cell_t newres = actualres ? 1 : 0; skamonkey@3056: skamonkey@3426: g_isHolidayForward->PushCell(holiday); skamonkey@3426: g_isHolidayForward->PushCellByRef(&newres); skamonkey@3426: g_isHolidayForward->Execute(&result); skamonkey@3056: skamonkey@3438: if (result > Pl_Continue) skamonkey@3056: { skamonkey@3426: return (newres == 0) ? false : true; skamonkey@3056: } skamonkey@3056: skamonkey@3056: return actualres; skamonkey@3056: } skamonkey@3056: skamonkey@3426: bool InitialiseIsHolidayDetour() skamonkey@3056: { skamonkey@3426: isHolidayDetour = DETOUR_CREATE_STATIC(IsHolidayActive, "IsHolidayActive"); skamonkey@3056: skamonkey@3426: if (isHolidayDetour != NULL) skamonkey@3056: { skamonkey@3426: isHolidayDetour->EnableDetour(); skamonkey@3159: return true; skamonkey@3056: } skamonkey@3056: skamonkey@3426: g_pSM->LogError(myself, "IsHolidayActive detour failed"); skamonkey@3159: return false; skamonkey@3056: } skamonkey@3056: skamonkey@3426: void RemoveIsHolidayDetour() skamonkey@3056: { skamonkey@3426: isHolidayDetour->Destroy(); skamonkey@3057: }