From a43c452428fb3a35aec82f52e091da83004bf7b9 Mon Sep 17 00:00:00 2001 From: asmodai Date: Wed, 2 Mar 2016 20:20:14 +0300 Subject: [PATCH] Added Cvar_DirectSet hookchain --- rehlds/engine/cvar.cpp | 7 ++++++- rehlds/public/rehlds/rehlds_api.h | 9 +++++++-- rehlds/rehlds/rehlds_api_impl.cpp | 4 ++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/cvar.cpp b/rehlds/engine/cvar.cpp index a45cd23..13b3811 100644 --- a/rehlds/engine/cvar.cpp +++ b/rehlds/engine/cvar.cpp @@ -186,7 +186,7 @@ NOXREF const char *Cvar_CompleteVariable(const char *search, int forward) } /* <18805> ../engine/cvar.c:198 */ -void Cvar_DirectSet(struct cvar_s *var, const char *value) +void EXT_FUNC Cvar_DirectSet_internal(struct cvar_s *var, const char *value) { if (!var || !value) { @@ -310,6 +310,11 @@ void Cvar_DirectSet(struct cvar_s *var, const char *value) var->value = (float)Q_atof(var->string); } +void Cvar_DirectSet(struct cvar_s *var, const char *value) +{ + g_RehldsHookchains.m_Cvar_DirectSet.callChain(Cvar_DirectSet_internal, var, value); +} + /* <188e9> ../engine/cvar.c:347 */ void Cvar_Set(const char *var_name, const char *value) { diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index d3df263..4dc28eb 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -35,7 +35,7 @@ #include "model.h" #define REHLDS_API_VERSION_MAJOR 2 -#define REHLDS_API_VERSION_MINOR 8 +#define REHLDS_API_VERSION_MINOR 9 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -169,6 +169,10 @@ typedef IHookChainRegistry IRehldsHookRegistry_SV_TransferConsistencyInfo; typedef IHookChain IRehldsHook_Steam_GSBUpdateUserData; typedef IHookChainRegistry IRehldsHookRegistry_Steam_GSBUpdateUserData; +//Cvar_DirectSet hook +typedef IVoidHookChain IRehldsHook_Cvar_DirectSet; +typedef IVoidHookChainRegistry IRehldsHookRegistry_Cvar_DirectSet; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -206,6 +210,7 @@ public: virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID() = 0; virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo() = 0; virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData() = 0; + virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0; }; struct RehldsFuncs_t { @@ -251,7 +256,7 @@ struct RehldsFuncs_t { void*(*GetPluginApi)(const char *name); void(*RegisterPluginApi)(const char *name, void *impl); qboolean(*SV_FileInConsistencyList)(const char *filename, struct consistency_s **ppconsist); - qboolean(*Steam_NotifyClientConnect_api)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key); + qboolean(*Steam_NotifyClientConnect)(IGameClient *cl, const void *pvSteam2Key, unsigned int ucbSteam2Key); void(*Steam_NotifyClientDisconnect)(IGameClient* cl); }; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 068e982..423be48 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -360,6 +360,10 @@ IRehldsHookRegistry_Steam_GSBUpdateUserData* CRehldsHookchains::Steam_GSBUpdateU return &m_Steam_GSBUpdateUserData; } +IRehldsHookRegistry_Cvar_DirectSet* CRehldsHookchains::Cvar_DirectSet() { + return &m_Cvar_DirectSet; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index d7ec4a0..04e60e9 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -163,6 +163,10 @@ typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_TransferConsistencyIn typedef IHookChainImpl CRehldsHook_Steam_GSBUpdateUserData; typedef IHookChainRegistryImpl CRehldsHookRegistry_Steam_GSBUpdateUserData; +//Cvar_DirectSet hook +typedef IVoidHookChainImpl CRehldsHook_Cvar_DirectSet; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_Cvar_DirectSet; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -198,6 +202,7 @@ public: CRehldsHookRegistry_Steam_GSGetSteamID m_Steam_GSGetSteamID; CRehldsHookRegistry_SV_TransferConsistencyInfo m_SV_TransferConsistencyInfo; CRehldsHookRegistry_Steam_GSBUpdateUserData m_Steam_GSBUpdateUserData; + CRehldsHookRegistry_Cvar_DirectSet m_Cvar_DirectSet; public: virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -233,6 +238,7 @@ public: virtual IRehldsHookRegistry_Steam_GSGetSteamID* Steam_GSGetSteamID(); virtual IRehldsHookRegistry_SV_TransferConsistencyInfo* SV_TransferConsistencyInfo(); virtual IRehldsHookRegistry_Steam_GSBUpdateUserData* Steam_GSBUpdateUserData(); + virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet(); }; extern CRehldsHookchains g_RehldsHookchains;