diff --git a/extensions/tf2/AMBuilder b/extensions/tf2/AMBuilder
index 8d0b53e9..0ae5aea0 100644
--- a/extensions/tf2/AMBuilder
+++ b/extensions/tf2/AMBuilder
@@ -17,6 +17,7 @@ binary.AddSourceFiles('extensions/tf2', [
'util.cpp',
'criticals.cpp',
'holiday.cpp',
+ 'gameplayrules.cpp'
'CDetour/detours.cpp',
'sdk/smsdk_ext.cpp',
'asm/asm.c'
diff --git a/extensions/tf2/Makefile b/extensions/tf2/Makefile
index 9c1df180..25e3fd19 100644
--- a/extensions/tf2/Makefile
+++ b/extensions/tf2/Makefile
@@ -19,7 +19,7 @@ PROJECT = game.tf2
USEMETA = true
OBJECTS = sdk/smsdk_ext.cpp extension.cpp natives.cpp RegNatives.cpp criticals.cpp \
- holiday.cpp util.cpp CDetour/detours.cpp asm/asm.c
+ holiday.cpp gameplayrules.cpp util.cpp CDetour/detours.cpp asm/asm.c
##############################################
### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ###
diff --git a/extensions/tf2/extension.cpp b/extensions/tf2/extension.cpp
index ff71b55d..e96c56ca 100644
--- a/extensions/tf2/extension.cpp
+++ b/extensions/tf2/extension.cpp
@@ -37,6 +37,7 @@
#include "sm_trie_tpl.h"
#include "criticals.h"
#include "holiday.h"
+#include "gameplayrules.h"
#include "CDetour/detours.h"
/**
@@ -110,11 +111,14 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
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_waitingPlayersStartForward = forwards->CreateForward("TF2_OnWaitingForPlayersStart", ET_Ignore, 0, NULL);
+ g_waitingPlayersEndForward = forwards->CreateForward("TF2_OnWaitingForPlayersEnd", ET_Ignore, 0, NULL);
g_pCVar = icvar;
m_CritDetoursEnabled = false;
m_GetHolidayDetourEnabled = false;
+ m_RulesDetoursEnabled = false;
return true;
}
@@ -159,6 +163,8 @@ void TF2Tools::SDK_OnUnload()
forwards->ReleaseForward(g_critForward);
forwards->ReleaseForward(g_getHolidayForward);
+ forwards->ReleaseForward(g_waitingPlayersStartForward);
+ forwards->ReleaseForward(g_waitingPlayersEndForward);
}
void TF2Tools::SDK_OnAllLoaded()
@@ -311,6 +317,14 @@ void TF2Tools::OnPluginLoaded(IPlugin *plugin)
InitialiseGetHolidayDetour();
m_GetHolidayDetourEnabled = true;
}
+ if (!m_RulesDetoursEnabled)
+ {
+ if(g_waitingPlayersStartForward->GetFunctionCount() || g_waitingPlayersEndForward->GetFunctionCount())
+ {
+ InitialiseRulesDetours();
+ m_RulesDetoursEnabled = true;
+ }
+ }
}
void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
@@ -325,6 +339,14 @@ void TF2Tools::OnPluginUnloaded(IPlugin *plugin)
RemoveGetHolidayDetour();
m_GetHolidayDetourEnabled = false;
}
+ if (m_RulesDetoursEnabled)
+ {
+ if(!g_waitingPlayersStartForward->GetFunctionCount() || !g_waitingPlayersEndForward->GetFunctionCount())
+ {
+ RemoveRulesDetours();
+ m_RulesDetoursEnabled = false;
+ }
+ }
}
int FindResourceEntity()
{
diff --git a/extensions/tf2/extension.h b/extensions/tf2/extension.h
index dd1d374c..8a99ee79 100644
--- a/extensions/tf2/extension.h
+++ b/extensions/tf2/extension.h
@@ -114,6 +114,7 @@ public:
private:
bool m_CritDetoursEnabled;
bool m_GetHolidayDetourEnabled;
+ bool m_RulesDetoursEnabled;
};
enum TFClassType
diff --git a/extensions/tf2/gameplayrules.cpp b/extensions/tf2/gameplayrules.cpp
new file mode 100644
index 00000000..e03fd0ca
--- /dev/null
+++ b/extensions/tf2/gameplayrules.cpp
@@ -0,0 +1,83 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod Team Fortress 2 Extension
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#include "gameplayrules.h"
+
+CDetour *setInWaitingForPlayersDetour = NULL;
+
+IForward *g_waitingPlayersStartForward = NULL;
+IForward *g_waitingPlayersEndForward = NULL;
+
+DETOUR_DECL_MEMBER1(SetInWaitingForPlayers, void, bool, bWaitingForPlayers)
+{
+ DETOUR_MEMBER_CALL(SetInWaitingForPlayers)(bWaitingForPlayers);
+
+ if (bWaitingForPlayers)
+ {
+ if (!g_waitingPlayersStartForward)
+ {
+ g_pSM->LogMessage(myself, "Invalid Forward");
+ }
+ else
+ {
+ g_waitingPlayersStartForward->Execute(NULL);
+ }
+ }
+ else
+ {
+ if (!g_waitingPlayersEndForward)
+ {
+ g_pSM->LogMessage(myself, "Invalid Forward");
+ }
+ else
+ {
+ g_waitingPlayersEndForward->Execute(NULL);
+ }
+ }
+}
+
+void InitialiseRulesDetours()
+{
+ setInWaitingForPlayersDetour = DETOUR_CREATE_MEMBER(SetInWaitingForPlayers, "SetInWaitingForPlayers");
+
+ if (setInWaitingForPlayersDetour != NULL)
+ {
+ setInWaitingForPlayersDetour->EnableDetour();
+ return;
+ }
+
+ g_pSM->LogError(myself, "No Gameplay Rules detours could be initialized - Disabled Gameplay Rules functions");
+}
+
+void RemoveRulesDetours()
+{
+ setInWaitingForPlayersDetour->Destroy();
+}
\ No newline at end of file
diff --git a/extensions/tf2/gameplayrules.h b/extensions/tf2/gameplayrules.h
new file mode 100644
index 00000000..56dcd46d
--- /dev/null
+++ b/extensions/tf2/gameplayrules.h
@@ -0,0 +1,46 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod Team Fortress 2 Extension
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#ifndef _INCLUDE_SOURCEMOD_GAMEPLAY_RULES_H_
+#define _INCLUDE_SOURCEMOD_GAMEPLAY_RULES_H_
+
+#include "extension.h"
+#include
+#include
+#include "CDetour/detours.h"
+
+void InitialiseRulesDetours();
+void RemoveRulesDetours();
+
+extern IForward *g_waitingPlayersStartForward;
+extern IForward *g_waitingPlayersEndForward;
+
+#endif //_INCLUDE_SOURCEMOD_GAMEPLAY_RULES_H_
\ No newline at end of file
diff --git a/extensions/tf2/msvc9/tf2.vcproj b/extensions/tf2/msvc9/tf2.vcproj
index d9a1d677..28e35db6 100644
--- a/extensions/tf2/msvc9/tf2.vcproj
+++ b/extensions/tf2/msvc9/tf2.vcproj
@@ -59,6 +59,7 @@
+
+
@@ -224,6 +229,10 @@
RelativePath="..\extension.h"
>
+
+
diff --git a/plugins/include/tf2.inc b/plugins/include/tf2.inc
index 8aa9c3fc..7944d830 100644
--- a/plugins/include/tf2.inc
+++ b/plugins/include/tf2.inc
@@ -280,6 +280,20 @@ forward Action:TF2_OnGetHoliday(&TFHoliday:holiday);
*/
native bool:TF2_IsPlayerInDuel(client);
+/**
+ * Called when the server enters the Waiting for Players round state
+ *
+ * @noreturn
+ */
+forward TF2_OnWaitingForPlayersStart();
+
+/**
+ * Called when the server exits the Waiting for Players round state
+ *
+ * @noreturn
+ */
+forward TF2_OnWaitingForPlayersEnd();
+
/**
* Do not edit below this line!
*/