From 7b6f2863a94a415e31fd833101f42d70536f8b3f Mon Sep 17 00:00:00 2001 From: Matt Woodrow Date: Tue, 12 May 2009 13:54:06 +1200 Subject: [PATCH] Added PlayerRunCmd hook to sdktools (bug 3289, r=dvander) --- extensions/sdktools/Makefile | 8 +- extensions/sdktools/extension.cpp | 8 ++ extensions/sdktools/extension.h | 1 + extensions/sdktools/hooks.cpp | 153 ++++++++++++++++++++++ extensions/sdktools/hooks.h | 56 ++++++++ extensions/sdktools/msvc9/sdktools.vcproj | 28 ++-- extensions/sdktools/sdk/smsdk_config.h | 2 +- extensions/sdktools/voice.cpp | 3 + gamedata/sdktools.games/engine.l4d.txt | 5 + gamedata/sdktools.games/game.cstrike.txt | 5 + gamedata/sdktools.games/game.tf.txt | 5 + plugins/include/sdktools.inc | 1 + plugins/include/sdktools_hooks.inc | 49 +++++++ 13 files changed, 309 insertions(+), 15 deletions(-) create mode 100644 extensions/sdktools/hooks.cpp create mode 100644 extensions/sdktools/hooks.h create mode 100644 plugins/include/sdktools_hooks.inc diff --git a/extensions/sdktools/Makefile b/extensions/sdktools/Makefile index 1b9215a9..1d0e063f 100644 --- a/extensions/sdktools/Makefile +++ b/extensions/sdktools/Makefile @@ -20,7 +20,7 @@ USEMETA = true OBJECTS = sdk/smsdk_ext.cpp extension.cpp vdecoder.cpp vcallbuilder.cpp vcaller.cpp \ vnatives.cpp vsound.cpp tenatives.cpp trnatives.cpp tempents.cpp vstringtable.cpp \ vhelpers.cpp vglobals.cpp voice.cpp inputnatives.cpp teamnatives.cpp output.cpp \ - outputnatives.cpp + outputnatives.cpp hooks.cpp ############################################## ### CONFIGURE ANY OTHER FLAGS/OPTIONS HERE ### @@ -39,7 +39,7 @@ ifeq "$(ENGINE)" "original" HL2LIB = $(HL2SDK)/linux_sdk CFLAGS += -DSOURCE_ENGINE=1 METAMOD = $(MMSOURCE17)/core-legacy - INCLUDE += -I$(HL2SDK)/public/dlls + INCLUDE += -I$(HL2SDK)/public/dlls -I$(HL2SDK)/game_shared SRCDS = $(SRCDS_BASE) override ENGSET = true endif @@ -49,7 +49,7 @@ ifeq "$(ENGINE)" "orangebox" HL2LIB = $(HL2SDK)/lib/linux CFLAGS += -DSOURCE_ENGINE=3 METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common + INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared SRCDS = $(SRCDS_BASE)/orangebox override ENGSET = true endif @@ -59,7 +59,7 @@ ifeq "$(ENGINE)" "left4dead" HL2LIB = $(HL2SDK)/lib/linux CFLAGS += -DSOURCE_ENGINE=4 METAMOD = $(MMSOURCE17)/core - INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common + INCLUDE += -I$(HL2SDK)/public/game/server -I$(HL2SDK)/common -I$(HL2SDK)/game/shared SRCDS = $(SRCDS_BASE)/l4d override ENGSET = true endif diff --git a/extensions/sdktools/extension.cpp b/extensions/sdktools/extension.cpp index 0cc78a1f..2e54f6b2 100644 --- a/extensions/sdktools/extension.cpp +++ b/extensions/sdktools/extension.cpp @@ -38,6 +38,7 @@ #include "tempents.h" #include "vsound.h" #include "output.h" +#include "hooks.h" #include /** @@ -186,6 +187,7 @@ void SDKTools::SDK_OnUnload() g_TEManager.Shutdown(); s_TempEntHooks.Shutdown(); s_SoundHooks.Shutdown(); + g_Hooks.Shutdown(); gameconfs->CloseGameConfigFile(g_pGameConf); playerhelpers->RemoveClientListener(&g_SdkTools); @@ -254,6 +256,7 @@ void SDKTools::SDK_OnAllLoaded() g_TEManager.Initialize(); s_TempEntHooks.Initialize(); s_SoundHooks.Initialize(); + g_Hooks.Initialize(); InitializeValveGlobals(); } @@ -379,6 +382,11 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info) return true; } +void SDKTools::OnClientPutInServer(int client) +{ + g_Hooks.OnClientPutInServer(client); +} + class SDKTools_API : public ISDKTools { public: diff --git a/extensions/sdktools/extension.h b/extensions/sdktools/extension.h index 7e64aae4..22e1d411 100644 --- a/extensions/sdktools/extension.h +++ b/extensions/sdktools/extension.h @@ -82,6 +82,7 @@ public: public: //IConCommandBaseAccessor bool RegisterConCommandBase(ConCommandBase *pVar); public: //IClientListner + void OnClientPutInServer(int client); void OnClientDisconnecting(int client); public: // IVoiceServer bool OnSetClientListening(int iReceiver, int iSender, bool bListen); diff --git a/extensions/sdktools/hooks.cpp b/extensions/sdktools/hooks.cpp new file mode 100644 index 00000000..ae0daa46 --- /dev/null +++ b/extensions/sdktools/hooks.cpp @@ -0,0 +1,153 @@ +/** +* vim: set ts=4 : +* ============================================================================= +* SourceMod SDKTools 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 "hooks.h" +#include "extension.h" + +CHookManager g_Hooks; + +SH_DECL_MANUALHOOK2_void(PlayerRunCmdHook, 0, 0, 0, CUserCmd *, IMoveHelper *); + +CHookManager::CHookManager() +{ + m_usercmdsFwd = NULL; +} + +void CHookManager::Initialize() +{ + int offset; + if (g_pGameConf->GetOffset("PlayerRunCmd", &offset)) + { + SH_MANUALHOOK_RECONFIGURE(PlayerRunCmdHook, offset, 0, 0); + } + + m_usercmdsFwd = forwards->CreateForward("OnPlayerRunCmd", ET_Event, 6, NULL, Param_Cell, Param_CellByRef, Param_CellByRef, Param_Array, Param_Array, Param_CellByRef); +} + +void CHookManager::Shutdown() +{ + forwards->ReleaseForward(m_usercmdsFwd); +} + +void CHookManager::OnClientPutInServer(int client) +{ + edict_t *pEdict = PEntityOfEntIndex(client); + if (!pEdict) + { + return; + } + + IServerUnknown *pUnknown = pEdict->GetUnknown(); + if (!pUnknown) + { + return; + } + + CBaseEntity *pEntity = pUnknown->GetBaseEntity(); + if (!pEntity) + { + return; + } + + SH_ADD_MANUALHOOK_MEMFUNC(PlayerRunCmdHook, pEntity, this, &CHookManager::PlayerRunCmd, false); +} + +void CHookManager::OnClientDisconnecting(int client) +{ + edict_t *pEdict = PEntityOfEntIndex(client); + if (!pEdict) + { + return; + } + + CBaseEntity *pEntity = pEdict->GetUnknown()->GetBaseEntity(); + if (!pEntity) + { + return; + } + + SH_REMOVE_MANUALHOOK_MEMFUNC(PlayerRunCmdHook, pEntity, this, &CHookManager::PlayerRunCmd, false); +} + +void CHookManager::PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper) +{ + if (m_usercmdsFwd->GetFunctionCount() == 0) + { + RETURN_META(MRES_IGNORED); + } + + CBaseEntity *pEntity = META_IFACEPTR(CBaseEntity); + + if (!pEntity) + { + RETURN_META(MRES_IGNORED); + } + + edict_t *pEdict = gameents->BaseEntityToEdict(pEntity); + + if (!pEdict) + { + RETURN_META(MRES_IGNORED); + } + + int client = IndexOfEdict(pEdict); + + + cell_t result = 0; + /* Impulse is a byte so we copy it back manually */ + cell_t impulse = ucmd->impulse; + cell_t vel[3] = {sp_ftoc(ucmd->forwardmove), sp_ftoc(ucmd->sidemove), sp_ftoc(ucmd->upmove)}; + cell_t angles[3] = {sp_ftoc(ucmd->viewangles.x), sp_ftoc(ucmd->viewangles.y), sp_ftoc(ucmd->viewangles.z)}; + + m_usercmdsFwd->PushCell(client); + m_usercmdsFwd->PushCellByRef(&ucmd->buttons); + m_usercmdsFwd->PushCellByRef(&impulse); + m_usercmdsFwd->PushArray(vel, 3, SM_PARAM_COPYBACK); + m_usercmdsFwd->PushArray(angles, 3, SM_PARAM_COPYBACK); + m_usercmdsFwd->PushCellByRef(&ucmd->weaponselect); + m_usercmdsFwd->Execute(&result); + + ucmd->impulse = impulse; + ucmd->forwardmove = sp_ctof(vel[0]); + ucmd->sidemove = sp_ctof(vel[1]); + ucmd->upmove = sp_ctof(vel[2]); + ucmd->viewangles.x = sp_ctof(angles[0]); + ucmd->viewangles.y = sp_ctof(angles[1]); + ucmd->viewangles.z = sp_ctof(angles[2]); + + + if (result == Pl_Handled) + { + RETURN_META(MRES_SUPERCEDE); + } + + RETURN_META(MRES_IGNORED); +} diff --git a/extensions/sdktools/hooks.h b/extensions/sdktools/hooks.h new file mode 100644 index 00000000..a8f3a596 --- /dev/null +++ b/extensions/sdktools/hooks.h @@ -0,0 +1,56 @@ +/** +* vim: set ts=4 : +* ============================================================================= +* SourceMod SDKTools 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_HOOKS_H_ +#define _INCLUDE_HOOKS_H_ + +#include "basehandle.h" +#undef ARRAYSIZE +#include "usercmd.h" +#include "extension.h" + +class CHookManager +{ +public: + CHookManager(); + void Initialize(); + void Shutdown(); + void OnClientPutInServer(int client); + void OnClientDisconnecting(int client); + void PlayerRunCmd(CUserCmd *ucmd, IMoveHelper *moveHelper); + +private: + IForward *m_usercmdsFwd; +}; + +extern CHookManager g_Hooks; + +#endif // _INCLUDE_HOOKS_H_ diff --git a/extensions/sdktools/msvc9/sdktools.vcproj b/extensions/sdktools/msvc9/sdktools.vcproj index 5b982d28..0a9eddb5 100644 --- a/extensions/sdktools/msvc9/sdktools.vcproj +++ b/extensions/sdktools/msvc9/sdktools.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\game_shared";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -124,7 +124,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\game_shared";"$(MMSOURCE17)\core-legacy";"$(MMSOURCE17)\core-legacy\sourcehook"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" @@ -205,7 +205,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)\common";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)\common";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\game\shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -287,7 +287,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)\common";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKOB)\common";"$(HL2SDKOB)\public";"$(HL2SDKOB)\public\engine";"$(HL2SDKOB)\public\game\server";"$(HL2SDKOB)\public\mathlib";"$(HL2SDKOB)\public\tier0";"$(HL2SDKOB)\public\tier1";"$(HL2SDKOB)\game\shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=3" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" @@ -368,7 +368,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\game_shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -450,7 +450,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK)\public";"$(HL2SDK)\public\dlls";"$(HL2SDK)\public\engine";"$(HL2SDK)\public\mathlib";"$(HL2SDK)\public\tier0";"$(HL2SDK)\public\tier1";"$(HL2SDK)\game_shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" @@ -531,7 +531,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKL4D)\common";"$(HL2SDKL4D)\public";"$(HL2SDKL4D)\public\engine";"$(HL2SDKL4D)\public\game\server";"$(HL2SDKL4D)\public\mathlib";"$(HL2SDKL4D)\public\tier0";"$(HL2SDKL4D)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKL4D)\common";"$(HL2SDKL4D)\public";"$(HL2SDKL4D)\public\engine";"$(HL2SDKL4D)\public\game\server";"$(HL2SDKL4D)\public\mathlib";"$(HL2SDKL4D)\public\tier0";"$(HL2SDKL4D)\public\tier1";"$(HL2SDKL4D)\game\shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -613,7 +613,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKL4D)\common";"$(HL2SDKL4D)\public";"$(HL2SDKL4D)\public\engine";"$(HL2SDKL4D)\public\game\server";"$(HL2SDKL4D)\public\mathlib";"$(HL2SDKL4D)\public\tier0";"$(HL2SDKL4D)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDKL4D)\common";"$(HL2SDKL4D)\public";"$(HL2SDKL4D)\public\engine";"$(HL2SDKL4D)\public\game\server";"$(HL2SDKL4D)\public\mathlib";"$(HL2SDKL4D)\public\tier0";"$(HL2SDKL4D)\public\tier1";"$(HL2SDKL4D)\game\shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=4" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" @@ -694,7 +694,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" Optimization="0" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK-DARKM)\public";"$(HL2SDK-DARKM)\public\dlls";"$(HL2SDK-DARKM)\public\engine";"$(HL2SDK-DARKM)\public\mathlib";"$(HL2SDK-DARKM)\public\tier0";"$(HL2SDK-DARKM)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK-DARKM)\public";"$(HL2SDK-DARKM)\public\dlls";"$(HL2SDK-DARKM)\public\engine";"$(HL2SDK-DARKM)\public\mathlib";"$(HL2SDK-DARKM)\public\tier0";"$(HL2SDK-DARKM)\public\tier1";"$(HL2SDK-DARKM\game_shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" MinimalRebuild="true" BasicRuntimeChecks="3" @@ -776,7 +776,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/MP /D SE_EPISODEONE=1 /D SE_DARKMESSIAH=2 /D SE_ORANGEBOX=3 /D SE_LEFT4DEAD=4" FavorSizeOrSpeed="1" - AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK-DARKM)\public";"$(HL2SDK-DARKM)\public\dlls";"$(HL2SDK-DARKM)\public\engine";"$(HL2SDK-DARKM)\public\mathlib";"$(HL2SDK-DARKM)\public\tier0";"$(HL2SDK-DARKM)\public\tier1";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" + AdditionalIncludeDirectories="..;..\sdk;..\..\..\public;..\..\..\public\extensions;..\..\..\public\sourcepawn;"$(HL2SDK-DARKM)\public";"$(HL2SDK-DARKM)\public\dlls";"$(HL2SDK-DARKM)\public\engine";"$(HL2SDK-DARKM)\public\mathlib";"$(HL2SDK-DARKM)\public\tier0";"$(HL2SDK-DARKM)\public\tier1";"$(HL2SDK-DARKM)\game_shared";"$(MMSOURCE17)\core";"$(MMSOURCE17)\core\sourcehook"" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;SDK_EXPORTS;_CRT_SECURE_NO_DEPRECATE;SOURCEMOD_BUILD;SOURCE_ENGINE=2" RuntimeLibrary="0" EnableEnhancedInstructionSet="0" @@ -844,6 +844,10 @@ RelativePath="..\extension.cpp" > + + @@ -926,6 +930,10 @@ RelativePath="..\extension.h" > + + diff --git a/extensions/sdktools/sdk/smsdk_config.h b/extensions/sdktools/sdk/smsdk_config.h index c4b14539..e5f0de91 100644 --- a/extensions/sdktools/sdk/smsdk_config.h +++ b/extensions/sdktools/sdk/smsdk_config.h @@ -61,7 +61,7 @@ #define SMEXT_CONF_METAMOD /** Enable interfaces you want to use here by uncommenting lines */ -//#define SMEXT_ENABLE_FORWARDSYS +#define SMEXT_ENABLE_FORWARDSYS #define SMEXT_ENABLE_HANDLESYS #define SMEXT_ENABLE_PLAYERHELPERS //#define SMEXT_ENABLE_DBMANAGER diff --git a/extensions/sdktools/voice.cpp b/extensions/sdktools/voice.cpp index 28ed4f50..8915cfa4 100644 --- a/extensions/sdktools/voice.cpp +++ b/extensions/sdktools/voice.cpp @@ -30,6 +30,7 @@ */ #include +#include #define SPEAK_NORMAL 0 #define SPEAK_MUTED 1 @@ -116,6 +117,8 @@ bool SDKTools::OnSetClientListening(int iReceiver, int iSender, bool bListen) void SDKTools::OnClientDisconnecting(int client) { + g_Hooks.OnClientDisconnecting(client); + int max_clients = playerhelpers->GetMaxClients(); if (g_VoiceHookCount == 0) diff --git a/gamedata/sdktools.games/engine.l4d.txt b/gamedata/sdktools.games/engine.l4d.txt index d8fc3dfa..6cd4aa61 100644 --- a/gamedata/sdktools.games/engine.l4d.txt +++ b/gamedata/sdktools.games/engine.l4d.txt @@ -365,6 +365,11 @@ "windows" "31" "linux" "32" } + "PlayerRunCmd" + { + "windows" "427" + "linux" "428" + } } } } diff --git a/gamedata/sdktools.games/game.cstrike.txt b/gamedata/sdktools.games/game.cstrike.txt index d2f71aed..bd6df222 100644 --- a/gamedata/sdktools.games/game.cstrike.txt +++ b/gamedata/sdktools.games/game.cstrike.txt @@ -104,6 +104,11 @@ "windows" "32" "linux" "33" } + "PlayerRunCmd" + { + "windows" "347" + "linux" "348" + } } } } \ No newline at end of file diff --git a/gamedata/sdktools.games/game.tf.txt b/gamedata/sdktools.games/game.tf.txt index babacce5..b39c83e5 100644 --- a/gamedata/sdktools.games/game.tf.txt +++ b/gamedata/sdktools.games/game.tf.txt @@ -96,6 +96,11 @@ "windows" "31" "linux" "32" } + "PlayerRunCmd" + { + "windows" "368" + "linux" "369" + } } } } \ No newline at end of file diff --git a/plugins/include/sdktools.inc b/plugins/include/sdktools.inc index f0f67720..9e72614e 100644 --- a/plugins/include/sdktools.inc +++ b/plugins/include/sdktools.inc @@ -48,6 +48,7 @@ #include #include #include +#include enum SDKCallType { diff --git a/plugins/include/sdktools_hooks.inc b/plugins/include/sdktools_hooks.inc new file mode 100644 index 00000000..67762b72 --- /dev/null +++ b/plugins/include/sdktools_hooks.inc @@ -0,0 +1,49 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod (C)2004-2009 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This file is part of the SourceMod/SourcePawn SDK. + * + * 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$ + */ + +#if defined _sdktools_hooks_included + #endinput +#endif +#define _sdktools_hooks_included + +/** + * @brief Called when a clients movement buttons are being processed + * + * @param client Index of the client. + * @param buttons Copyback buffer containing the current commands (as bitflags - see entity_prop_stocks.inc). + * @param impulse Copyback buffer containing the current impulse command. + * @param vel Players desired velocity. + * @param angles Players desired view angles. + * @param weapon Entity index of the new weapon if player switches weapon, 0 otherwise. + * @return Plugin_Handled to block the commands from being processed, Plugin_Continue otherwise. + */ +forward Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon); \ No newline at end of file