|
crimson@3151
|
1 |
/** |
|
crimson@3151
|
2 |
* vim: set ts=4 : |
|
crimson@3151
|
3 |
* ============================================================================= |
|
crimson@3151
|
4 |
* SourceMod Team Fortress 2 Extension |
|
crimson@3151
|
5 |
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. |
|
crimson@3151
|
6 |
* ============================================================================= |
|
crimson@3151
|
7 |
* |
|
crimson@3151
|
8 |
* This program is free software; you can redistribute it and/or modify it under |
|
crimson@3151
|
9 |
* the terms of the GNU General Public License, version 3.0, as published by the |
|
crimson@3151
|
10 |
* Free Software Foundation. |
|
crimson@3151
|
11 |
* |
|
crimson@3151
|
12 |
* This program is distributed in the hope that it will be useful, but WITHOUT |
|
crimson@3151
|
13 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|
crimson@3151
|
14 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
|
crimson@3151
|
15 |
* details. |
|
crimson@3151
|
16 |
* |
|
crimson@3151
|
17 |
* You should have received a copy of the GNU General Public License along with |
|
crimson@3151
|
18 |
* this program. If not, see <http://www.gnu.org/licenses/>. |
|
crimson@3151
|
19 |
* |
|
crimson@3151
|
20 |
* As a special exception, AlliedModders LLC gives you permission to link the |
|
crimson@3151
|
21 |
* code of this program (as well as its derivative works) to "Half-Life 2," the |
|
crimson@3151
|
22 |
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software |
|
crimson@3151
|
23 |
* by the Valve Corporation. You must obey the GNU General Public License in |
|
crimson@3151
|
24 |
* all respects for all other code used. Additionally, AlliedModders LLC grants |
|
crimson@3151
|
25 |
* this exception to all derivative works. AlliedModders LLC defines further |
|
crimson@3151
|
26 |
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), |
|
crimson@3151
|
27 |
* or <http://www.sourcemod.net/license.php>. |
|
crimson@3151
|
28 |
* |
|
crimson@3151
|
29 |
* Version: $Id$ |
|
crimson@3151
|
30 |
*/ |
|
crimson@3151
|
31 |
|
|
crimson@3151
|
32 |
#include "gameplayrules.h" |
|
crimson@3151
|
33 |
|
|
crimson@3151
|
34 |
CDetour *setInWaitingForPlayersDetour = NULL; |
|
crimson@3151
|
35 |
|
|
crimson@3151
|
36 |
IForward *g_waitingPlayersStartForward = NULL; |
|
crimson@3151
|
37 |
IForward *g_waitingPlayersEndForward = NULL; |
|
crimson@3151
|
38 |
|
|
crimson@3151
|
39 |
DETOUR_DECL_MEMBER1(SetInWaitingForPlayers, void, bool, bWaitingForPlayers) |
|
crimson@3151
|
40 |
{ |
|
crimson@3151
|
41 |
DETOUR_MEMBER_CALL(SetInWaitingForPlayers)(bWaitingForPlayers); |
|
crimson@3151
|
42 |
|
|
crimson@3151
|
43 |
if (bWaitingForPlayers) |
|
crimson@3151
|
44 |
{ |
|
crimson@3151
|
45 |
if (!g_waitingPlayersStartForward) |
|
crimson@3151
|
46 |
{ |
|
crimson@3151
|
47 |
g_pSM->LogMessage(myself, "Invalid Forward"); |
|
crimson@3151
|
48 |
} |
|
crimson@3151
|
49 |
else |
|
crimson@3151
|
50 |
{ |
|
crimson@3151
|
51 |
g_waitingPlayersStartForward->Execute(NULL); |
|
crimson@3151
|
52 |
} |
|
crimson@3151
|
53 |
} |
|
crimson@3151
|
54 |
else |
|
crimson@3151
|
55 |
{ |
|
crimson@3151
|
56 |
if (!g_waitingPlayersEndForward) |
|
crimson@3151
|
57 |
{ |
|
crimson@3151
|
58 |
g_pSM->LogMessage(myself, "Invalid Forward"); |
|
crimson@3151
|
59 |
} |
|
crimson@3151
|
60 |
else |
|
crimson@3151
|
61 |
{ |
|
crimson@3151
|
62 |
g_waitingPlayersEndForward->Execute(NULL); |
|
crimson@3151
|
63 |
} |
|
crimson@3151
|
64 |
} |
|
crimson@3151
|
65 |
} |
|
crimson@3151
|
66 |
|
|
skamonkey@3159
|
67 |
bool InitialiseRulesDetours() |
|
crimson@3151
|
68 |
{ |
|
crimson@3151
|
69 |
setInWaitingForPlayersDetour = DETOUR_CREATE_MEMBER(SetInWaitingForPlayers, "SetInWaitingForPlayers"); |
|
crimson@3151
|
70 |
|
|
crimson@3151
|
71 |
if (setInWaitingForPlayersDetour != NULL) |
|
crimson@3151
|
72 |
{ |
|
crimson@3151
|
73 |
setInWaitingForPlayersDetour->EnableDetour(); |
|
skamonkey@3159
|
74 |
return true; |
|
crimson@3151
|
75 |
} |
|
crimson@3151
|
76 |
|
|
crimson@3151
|
77 |
g_pSM->LogError(myself, "No Gameplay Rules detours could be initialized - Disabled Gameplay Rules functions"); |
|
skamonkey@3159
|
78 |
return false; |
|
crimson@3151
|
79 |
} |
|
crimson@3151
|
80 |
|
|
crimson@3151
|
81 |
void RemoveRulesDetours() |
|
crimson@3151
|
82 |
{ |
|
crimson@3151
|
83 |
setInWaitingForPlayersDetour->Destroy(); |
|
pred@3154
|
84 |
} |