extensions/tf2/holiday.cpp
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 3438 07a1b8a8a2ba
permissions -rw-r--r--
Update CS:GO team score gamedata.
skamonkey@3056
     1
/**
skamonkey@3056
     2
 * vim: set ts=4 :
skamonkey@3056
     3
 * =============================================================================
skamonkey@3056
     4
 * SourceMod Team Fortress 2 Extension
skamonkey@3056
     5
 * Copyright (C) 2004-2008 AlliedModders LLC.  All rights reserved.
skamonkey@3056
     6
 * =============================================================================
skamonkey@3056
     7
 *
skamonkey@3056
     8
 * This program is free software; you can redistribute it and/or modify it under
skamonkey@3056
     9
 * the terms of the GNU General Public License, version 3.0, as published by the
skamonkey@3056
    10
 * Free Software Foundation.
skamonkey@3056
    11
 * 
skamonkey@3056
    12
 * This program is distributed in the hope that it will be useful, but WITHOUT
skamonkey@3056
    13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
skamonkey@3056
    14
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
skamonkey@3056
    15
 * details.
skamonkey@3056
    16
 *
skamonkey@3056
    17
 * You should have received a copy of the GNU General Public License along with
skamonkey@3056
    18
 * this program.  If not, see <http://www.gnu.org/licenses/>.
skamonkey@3056
    19
 *
skamonkey@3056
    20
 * As a special exception, AlliedModders LLC gives you permission to link the
skamonkey@3056
    21
 * code of this program (as well as its derivative works) to "Half-Life 2," the
skamonkey@3056
    22
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
skamonkey@3056
    23
 * by the Valve Corporation.  You must obey the GNU General Public License in
skamonkey@3056
    24
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
skamonkey@3056
    25
 * this exception to all derivative works.  AlliedModders LLC defines further
skamonkey@3056
    26
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
skamonkey@3056
    27
 * or <http://www.sourcemod.net/license.php>.
skamonkey@3056
    28
 *
skamonkey@3056
    29
 * Version: $Id$
skamonkey@3056
    30
 */
skamonkey@3056
    31
skamonkey@3056
    32
#include "holiday.h"
skamonkey@3056
    33
skamonkey@3426
    34
CDetour *isHolidayDetour = NULL;
skamonkey@3056
    35
skamonkey@3426
    36
IForward *g_isHolidayForward = NULL;
skamonkey@3056
    37
skamonkey@3426
    38
DETOUR_DECL_STATIC1(IsHolidayActive, bool, int, holiday)
skamonkey@3056
    39
{
skamonkey@3426
    40
	bool actualres = DETOUR_STATIC_CALL(IsHolidayActive)(holiday);
skamonkey@3426
    41
	if (!g_isHolidayForward)
skamonkey@3056
    42
	{
skamonkey@3056
    43
		g_pSM->LogMessage(myself, "Invalid Forward");
skamonkey@3056
    44
		return actualres;
skamonkey@3056
    45
	}
skamonkey@3056
    46
skamonkey@3056
    47
	cell_t result = 0;
skamonkey@3426
    48
	cell_t newres = actualres ? 1 : 0;
skamonkey@3056
    49
skamonkey@3426
    50
	g_isHolidayForward->PushCell(holiday);
skamonkey@3426
    51
	g_isHolidayForward->PushCellByRef(&newres);
skamonkey@3426
    52
	g_isHolidayForward->Execute(&result);
skamonkey@3056
    53
	
skamonkey@3438
    54
	if (result > Pl_Continue)
skamonkey@3056
    55
	{
skamonkey@3426
    56
		return (newres == 0) ? false : true;
skamonkey@3056
    57
	}
skamonkey@3056
    58
skamonkey@3056
    59
	return actualres;
skamonkey@3056
    60
}
skamonkey@3056
    61
skamonkey@3426
    62
bool InitialiseIsHolidayDetour()
skamonkey@3056
    63
{
skamonkey@3426
    64
	isHolidayDetour = DETOUR_CREATE_STATIC(IsHolidayActive, "IsHolidayActive");
skamonkey@3056
    65
skamonkey@3426
    66
	if (isHolidayDetour != NULL)
skamonkey@3056
    67
	{
skamonkey@3426
    68
		isHolidayDetour->EnableDetour();
skamonkey@3159
    69
		return true;
skamonkey@3056
    70
	}
skamonkey@3056
    71
skamonkey@3426
    72
	g_pSM->LogError(myself, "IsHolidayActive detour failed");
skamonkey@3159
    73
	return false;
skamonkey@3056
    74
}
skamonkey@3056
    75
skamonkey@3426
    76
void RemoveIsHolidayDetour()
skamonkey@3056
    77
{
skamonkey@3426
    78
	isHolidayDetour->Destroy();
skamonkey@3057
    79
}