From 6dff682b035a643569f1a0690b79b641cff5c6b8 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 20 Feb 2022 18:22:25 +0200 Subject: [PATCH 01/46] Added SV_CheckUserInfo hook --- rehlds/engine/server.h | 1 + rehlds/engine/sv_main.cpp | 5 +++++ rehlds/public/rehlds/rehlds_api.h | 5 +++++ rehlds/rehlds/rehlds_api_impl.cpp | 5 +++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ 5 files changed, 22 insertions(+) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 53792cf2b..2bf880f3d 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -498,6 +498,7 @@ int SV_CheckKeyInfo_internal(netadr_t *adr, char *protinfo, unsigned short *port int SV_CheckForDuplicateSteamID(client_t *client); qboolean SV_CheckForDuplicateNames(char *userinfo, qboolean bIsReconnecting, int nExcludeSlot); int SV_CheckUserInfo(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name); +int SV_CheckUserInfo_internal(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name); int SV_FindEmptySlot(netadr_t *adr, int *pslot, client_t ** ppClient); void SV_ConnectClient(void); void SV_ConnectClient_internal(void); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 9c9ce2966..5c4e633d7 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -2115,6 +2115,11 @@ void SV_ReplaceSpecialCharactersInName(char *newname, const char *oldname) #endif int SV_CheckUserInfo(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name) +{ + return g_RehldsHookchains.m_SV_CheckUserInfo.callChain(SV_CheckUserInfo_internal, adr, userinfo, bIsReconnecting, nReconnectSlot, name); +} + +int EXT_FUNC SV_CheckUserInfo_internal(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name) { const char *s; char newname[MAX_NAME]; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 876752a6b..ea6fe7109 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -67,6 +67,10 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_SVC_GetChallenge_ typedef IHookChain IRehldsHook_SV_CheckKeyInfo; typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckKeyInfo; +//SV_CheckUserInfo hook +typedef IHookChain IRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; + //SV_CheckIPRestrictions hook typedef IHookChain IRehldsHook_SV_CheckIPRestrictions; typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckIPRestrictions; @@ -239,6 +243,7 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0; virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0; virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0; + virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo() = 0; virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0; virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0; virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 1124e057e..8c85645c6 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -684,6 +684,11 @@ IRehldsHookRegistry_SV_CheckKeyInfo* CRehldsHookchains::SV_CheckKeyInfo() return &m_SV_CheckKeyInfo; } +IRehldsHookRegistry_SV_CheckUserInfo* CRehldsHookchains::SV_CheckUserInfo() +{ + return &m_SV_CheckUserInfo; +} + IRehldsHookRegistry_SV_CheckIPRestrictions* CRehldsHookchains::SV_CheckIPRestrictions() { return &m_SV_CheckIPRestrictions; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 19929c9e5..6dfbf39cc 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -62,6 +62,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SVC_GetChalle typedef IHookChainImpl CRehldsHook_SV_CheckKeyInfo; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckKeyInfo; +//SV_CheckUserInfo hook +typedef IHookChainImpl CRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckUserInfo; + //SV_CheckIPRestrictions hook typedef IHookChainImpl CRehldsHook_SV_CheckIPRestrictions; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckIPRestrictions; @@ -231,6 +235,7 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_SV_CheckProtocol m_SV_CheckProtocol; CRehldsHookRegistry_SVC_GetChallenge_mod m_SVC_GetChallenge_mod; CRehldsHookRegistry_SV_CheckKeyInfo m_SV_CheckKeyInfo; + CRehldsHookRegistry_SV_CheckUserInfo m_SV_CheckUserInfo; CRehldsHookRegistry_SV_CheckIPRestrictions m_SV_CheckIPRestrictions; CRehldsHookRegistry_SV_FinishCertificateCheck m_SV_FinishCertificateCheck; CRehldsHookRegistry_Steam_NotifyBotConnect m_Steam_NotifyBotConnect; @@ -280,6 +285,7 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol(); EXT_FUNC virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo(); + EXT_FUNC virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions(); EXT_FUNC virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck(); EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect(); From c4c4e8228b5688ffb436c5282837d0b7579ec492 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 20 Feb 2022 18:24:25 +0200 Subject: [PATCH 02/46] Fixed an error --- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 6dfbf39cc..1c8d9a5b9 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -63,8 +63,8 @@ typedef IHookChainImpl CRehl typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckKeyInfo; //SV_CheckUserInfo hook -typedef IHookChainImpl CRehldsHook_SV_CheckUserInfo; -typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckUserInfo; +typedef IHookChainImpl CRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckUserInfo; //SV_CheckIPRestrictions hook typedef IHookChainImpl CRehldsHook_SV_CheckIPRestrictions; From 97a85651df331f77aab9ed26f4e65fd9edf8dfb9 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 26 Feb 2022 15:37:00 +0200 Subject: [PATCH 03/46] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e9f100cc..f0b0f6e32 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -243,7 +243,7 @@ jobs: publish: name: 'Publish' runs-on: ubuntu-latest - needs: [windows, testdemos, linux] + needs: [windows, linux] steps: - name: Deploying linux artifacts From 20d8d10f70c709c371b7a69934a96324739bba09 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 27 Feb 2022 19:10:22 +0200 Subject: [PATCH 04/46] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f0b0f6e32..8a61cc5d3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,7 +14,7 @@ on: jobs: windows: name: 'Windows' - runs-on: windows-latest + runs-on: windows-2019 env: solution: 'msvc/ReHLDS.sln' From e0d2455e5354f4f71ead293c5dd71be0eb90f914 Mon Sep 17 00:00:00 2001 From: Adrian Cirstea <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 27 Feb 2022 20:16:13 +0200 Subject: [PATCH 05/46] Update build.yml --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a61cc5d3..ddedaf4a3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -243,7 +243,7 @@ jobs: publish: name: 'Publish' runs-on: ubuntu-latest - needs: [windows, linux] + needs: [windows, testdemos, linux] steps: - name: Deploying linux artifacts From a5a4bc2e3a44afd047fced2fa84bb0ac0fbb8f50 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sun, 27 Feb 2022 20:19:23 +0200 Subject: [PATCH 06/46] Fixed function's defs positioning --- rehlds/public/rehlds/rehlds_api.h | 9 ++++----- rehlds/rehlds/rehlds_api_impl.cpp | 9 ++++----- rehlds/rehlds/rehlds_api_impl.h | 12 ++++++------ 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index ea6fe7109..05c6f42b9 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -67,10 +67,6 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_SVC_GetChallenge_ typedef IHookChain IRehldsHook_SV_CheckKeyInfo; typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckKeyInfo; -//SV_CheckUserInfo hook -typedef IHookChain IRehldsHook_SV_CheckUserInfo; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; - //SV_CheckIPRestrictions hook typedef IHookChain IRehldsHook_SV_CheckIPRestrictions; typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckIPRestrictions; @@ -231,6 +227,9 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_ED_Free; typedef IHookChain IRehldsHook_Con_Printf; typedef IHookChainRegistry IRehldsHookRegistry_Con_Printf; +//SV_CheckUserInfo hook +typedef IHookChain IRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; class IRehldsHookchains { public: @@ -243,7 +242,6 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol() = 0; virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod() = 0; virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo() = 0; - virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo() = 0; virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions() = 0; virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck() = 0; virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect() = 0; @@ -284,6 +282,7 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0; virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0; virtual IRehldsHookRegistry_Con_Printf* Con_Printf() = 0; + virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 8c85645c6..ba0576b33 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -684,11 +684,6 @@ IRehldsHookRegistry_SV_CheckKeyInfo* CRehldsHookchains::SV_CheckKeyInfo() return &m_SV_CheckKeyInfo; } -IRehldsHookRegistry_SV_CheckUserInfo* CRehldsHookchains::SV_CheckUserInfo() -{ - return &m_SV_CheckUserInfo; -} - IRehldsHookRegistry_SV_CheckIPRestrictions* CRehldsHookchains::SV_CheckIPRestrictions() { return &m_SV_CheckIPRestrictions; @@ -856,6 +851,10 @@ IRehldsHookRegistry_Con_Printf* CRehldsHookchains::Con_Printf() { return &m_Con_Printf; } +IRehldsHookRegistry_SV_CheckUserInfo* CRehldsHookchains::SV_CheckUserInfo() { + return &m_SV_CheckUserInfo; +} + 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 1c8d9a5b9..e8386c8f2 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -62,10 +62,6 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SVC_GetChalle typedef IHookChainImpl CRehldsHook_SV_CheckKeyInfo; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckKeyInfo; -//SV_CheckUserInfo hook -typedef IHookChainImpl CRehldsHook_SV_CheckUserInfo; -typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckUserInfo; - //SV_CheckIPRestrictions hook typedef IHookChainImpl CRehldsHook_SV_CheckIPRestrictions; typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckIPRestrictions; @@ -226,6 +222,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_ED_Free; typedef IHookChainImpl CRehldsHook_Con_Printf; typedef IHookChainRegistryImpl CRehldsHookRegistry_Con_Printf; +//SV_CheckUserInfo hook +typedef IHookChainImpl CRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckUserInfo; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -235,7 +235,6 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_SV_CheckProtocol m_SV_CheckProtocol; CRehldsHookRegistry_SVC_GetChallenge_mod m_SVC_GetChallenge_mod; CRehldsHookRegistry_SV_CheckKeyInfo m_SV_CheckKeyInfo; - CRehldsHookRegistry_SV_CheckUserInfo m_SV_CheckUserInfo; CRehldsHookRegistry_SV_CheckIPRestrictions m_SV_CheckIPRestrictions; CRehldsHookRegistry_SV_FinishCertificateCheck m_SV_FinishCertificateCheck; CRehldsHookRegistry_Steam_NotifyBotConnect m_Steam_NotifyBotConnect; @@ -276,6 +275,7 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_ED_Alloc m_ED_Alloc; CRehldsHookRegistry_ED_Free m_ED_Free; CRehldsHookRegistry_Con_Printf m_Con_Printf; + CRehldsHookRegistry_SV_CheckUserInfo m_SV_CheckUserInfo; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -285,7 +285,6 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_SV_CheckProtocol* SV_CheckProtocol(); EXT_FUNC virtual IRehldsHookRegistry_SVC_GetChallenge_mod* SVC_GetChallenge_mod(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckKeyInfo* SV_CheckKeyInfo(); - EXT_FUNC virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo(); EXT_FUNC virtual IRehldsHookRegistry_SV_CheckIPRestrictions* SV_CheckIPRestrictions(); EXT_FUNC virtual IRehldsHookRegistry_SV_FinishCertificateCheck* SV_FinishCertificateCheck(); EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyBotConnect* Steam_NotifyBotConnect(); @@ -326,6 +325,7 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc(); EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free(); EXT_FUNC virtual IRehldsHookRegistry_Con_Printf* Con_Printf(); + EXT_FUNC virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo(); }; extern CRehldsHookchains g_RehldsHookchains; From fda7f7e47cd76d4611a9589d3a62d610e4c10b82 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 19:25:25 +0200 Subject: [PATCH 07/46] Implemented PF_precache_* hooks - PF_precache_sound_I - PF_precache_model_I - PF_precache_generic_I --- rehlds/engine/pr_cmds.cpp | 23 +++++++++++++++++++---- rehlds/engine/pr_cmds.h | 3 +++ rehlds/engine/server.h | 1 + rehlds/engine/sv_main.cpp | 5 +++++ rehlds/public/rehlds/rehlds_api.h | 19 +++++++++++++++++++ rehlds/rehlds/rehlds_api_impl.cpp | 16 ++++++++++++++++ rehlds/rehlds/rehlds_api_impl.h | 24 ++++++++++++++++++++++++ 7 files changed, 87 insertions(+), 4 deletions(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index df82bce5f..10b082ae4 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1010,7 +1010,12 @@ qboolean EXT_FUNC PR_IsEmptyString(const char *s) return s[0] < ' '; } -int EXT_FUNC PF_precache_sound_I(const char *s) +int PF_precache_sound_I(const char *s) +{ + return g_RehldsHookchains.m_PF_precache_sound_I.callChain(PF_precache_sound_I_internal, s); +} + +int EXT_FUNC PF_precache_sound_I_internal(const char *s) { if (!s) Host_Error("%s: NULL pointer", __func__); @@ -1376,7 +1381,12 @@ int SV_LookupModelIndex(const char *name) return 0; } -int EXT_FUNC PF_precache_model_I(const char *s) +int PF_precache_model_I(const char *s) +{ + return g_RehldsHookchains.m_PF_precache_model_I.callChain(PF_precache_model_I_internal, s); +} + +int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; if (!s) @@ -1445,8 +1455,13 @@ int EXT_FUNC PF_precache_model_I(const char *s) } } +int PF_precache_generic_I(const char *s) +{ + return g_RehldsHookchains.m_PF_precache_generic_I.callChain(PF_precache_generic_I_internal, s); +} + #ifdef REHLDS_FIXES -int EXT_FUNC PF_precache_generic_I(const char *s) +int EXT_FUNC PF_precache_generic_I_internal(const char *s) { if (!s) Host_Error("%s: NULL pointer", __func__); @@ -1493,7 +1508,7 @@ int EXT_FUNC PF_precache_generic_I(const char *s) return g_rehlds_sv.precachedGenericResourceCount++; } #else // REHLDS_FIXES -int EXT_FUNC PF_precache_generic_I(const char *s) +int EXT_FUNC PF_precache_generic_I_internal(const char *s) { if (!s) Host_Error("%s: NULL pointer", __func__); diff --git a/rehlds/engine/pr_cmds.h b/rehlds/engine/pr_cmds.h index e7c20bc01..76df85563 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -120,6 +120,7 @@ edict_t *FindEntityByString(edict_t *pEdictStartSearchAfter, const char *pszFiel int GetEntityIllum(edict_t *pEnt); qboolean PR_IsEmptyString(const char *s); int PF_precache_sound_I(const char *s); +int PF_precache_sound_I_internal(const char *s); unsigned short EV_Precache(int type, const char *psz); void EV_PlayReliableEvent_api(IGameClient *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); void EV_PlayReliableEvent(client_t *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); @@ -127,7 +128,9 @@ void EV_PlayReliableEvent_internal(client_t *cl, int entindex, unsigned short ev void EV_Playback(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); void EV_SV_Playback(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); int PF_precache_model_I(const char *s); +int PF_precache_model_I_internal(const char *s); int PF_precache_generic_I(const char *s); +int PF_precache_generic_I_internal(const char *s); int PF_IsMapValid_I(const char *mapname); int PF_NumberOfEntities_I(void); char *PF_GetInfoKeyBuffer_I(edict_t *e); diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 53792cf2b..2bf880f3d 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -498,6 +498,7 @@ int SV_CheckKeyInfo_internal(netadr_t *adr, char *protinfo, unsigned short *port int SV_CheckForDuplicateSteamID(client_t *client); qboolean SV_CheckForDuplicateNames(char *userinfo, qboolean bIsReconnecting, int nExcludeSlot); int SV_CheckUserInfo(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name); +int SV_CheckUserInfo_internal(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name); int SV_FindEmptySlot(netadr_t *adr, int *pslot, client_t ** ppClient); void SV_ConnectClient(void); void SV_ConnectClient_internal(void); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 9c9ce2966..5c4e633d7 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -2115,6 +2115,11 @@ void SV_ReplaceSpecialCharactersInName(char *newname, const char *oldname) #endif int SV_CheckUserInfo(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name) +{ + return g_RehldsHookchains.m_SV_CheckUserInfo.callChain(SV_CheckUserInfo_internal, adr, userinfo, bIsReconnecting, nReconnectSlot, name); +} + +int EXT_FUNC SV_CheckUserInfo_internal(netadr_t *adr, char *userinfo, qboolean bIsReconnecting, int nReconnectSlot, char *name) { const char *s; char newname[MAX_NAME]; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 876752a6b..8ac765a11 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -227,6 +227,21 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_ED_Free; typedef IHookChain IRehldsHook_Con_Printf; typedef IHookChainRegistry IRehldsHookRegistry_Con_Printf; +//SV_CheckUserInfo hook +typedef IHookChain IRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; + +//PF_precache_generic_I hook +typedef IHookChain IRehldsHook_PF_precache_generic_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_generic_I; + +//PF_precache_model_I hook +typedef IHookChain IRehldsHook_PF_precache_model_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; + +//PF_precache_sound_I hook +typedef IHookChain IRehldsHook_PF_precache_sound_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sound_I; class IRehldsHookchains { public: @@ -279,6 +294,10 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc() = 0; virtual IRehldsHookRegistry_ED_Free* ED_Free() = 0; virtual IRehldsHookRegistry_Con_Printf* Con_Printf() = 0; + virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo() = 0; + virtual IRehldsHookRegistry_PF_precache_generic_I* PF_precache_generic_I() = 0; + virtual IRehldsHookRegistry_PF_precache_model_I* PF_precache_model_I() = 0; + virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 1124e057e..99496ead1 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -851,6 +851,22 @@ IRehldsHookRegistry_Con_Printf* CRehldsHookchains::Con_Printf() { return &m_Con_Printf; } +IRehldsHookRegistry_SV_CheckUserInfo* CRehldsHookchains::SV_CheckUserInfo() { + return &m_SV_CheckUserInfo; +} + +IRehldsHookRegistry_PF_precache_generic_I* CRehldsHookchains::PF_precache_generic_I() { + return &m_PF_precache_generic_I; +} + +IRehldsHookRegistry_PF_precache_model_I* CRehldsHookchains::PF_precache_model_I() { + return &m_PF_precache_model_I; +} + +IRehldsHookRegistry_PF_precache_sound_I* CRehldsHookchains::PF_precache_sound_I() { + return &m_PF_precache_sound_I; +} + 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 19929c9e5..568f87437 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -222,6 +222,22 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_ED_Free; typedef IHookChainImpl CRehldsHook_Con_Printf; typedef IHookChainRegistryImpl CRehldsHookRegistry_Con_Printf; +//SV_CheckUserInfo hook +typedef IHookChainImpl CRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckUserInfo; + +//PF_precache_generic_I hook +typedef IHookChainImpl CRehldsHook_PF_precache_generic_I; +typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_generic_I; + +//PF_precache_model_I hook +typedef IHookChainImpl CRehldsHook_PF_precache_model_I; +typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_model_I; + +//PF_precache_sound_I hook +typedef IHookChainImpl CRehldsHook_PF_precache_sound_I; +typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_sound_I; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -271,6 +287,10 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_ED_Alloc m_ED_Alloc; CRehldsHookRegistry_ED_Free m_ED_Free; CRehldsHookRegistry_Con_Printf m_Con_Printf; + CRehldsHookRegistry_SV_CheckUserInfo m_SV_CheckUserInfo; + CRehldsHookRegistry_PF_precache_generic_I m_PF_precache_generic_I; + CRehldsHookRegistry_PF_precache_model_I m_PF_precache_model_I; + CRehldsHookRegistry_PF_precache_sound_I m_PF_precache_sound_I; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -320,6 +340,10 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_ED_Alloc* ED_Alloc(); EXT_FUNC virtual IRehldsHookRegistry_ED_Free* ED_Free(); EXT_FUNC virtual IRehldsHookRegistry_Con_Printf* Con_Printf(); + EXT_FUNC virtual IRehldsHookRegistry_SV_CheckUserInfo* SV_CheckUserInfo(); + EXT_FUNC virtual IRehldsHookRegistry_PF_precache_generic_I* PF_precache_generic_I(); + EXT_FUNC virtual IRehldsHookRegistry_PF_precache_model_I* PF_precache_model_I(); + EXT_FUNC virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I(); }; extern CRehldsHookchains g_RehldsHookchains; From 422fd600b4ee41a1dfe2b95f800e71eacb35b289 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 19:55:31 +0200 Subject: [PATCH 08/46] Testing EXT_FUNC --- rehlds/engine/pr_cmds.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 10b082ae4..d7aa7cd75 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1010,7 +1010,7 @@ qboolean EXT_FUNC PR_IsEmptyString(const char *s) return s[0] < ' '; } -int PF_precache_sound_I(const char *s) +int EXT_FUNC PF_precache_sound_I(const char *s) { return g_RehldsHookchains.m_PF_precache_sound_I.callChain(PF_precache_sound_I_internal, s); } @@ -1381,7 +1381,7 @@ int SV_LookupModelIndex(const char *name) return 0; } -int PF_precache_model_I(const char *s) +int EXT_FUNC PF_precache_model_I(const char *s) { return g_RehldsHookchains.m_PF_precache_model_I.callChain(PF_precache_model_I_internal, s); } @@ -1455,7 +1455,7 @@ int EXT_FUNC PF_precache_model_I_internal(const char *s) } } -int PF_precache_generic_I(const char *s) +int EXT_FUNC PF_precache_generic_I(const char *s) { return g_RehldsHookchains.m_PF_precache_generic_I.callChain(PF_precache_generic_I_internal, s); } From 46130dd3475fcf06fc8e05536f4117da7dc8ab1a Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:24:24 +0200 Subject: [PATCH 09/46] Update pr_cmds.cpp --- rehlds/engine/pr_cmds.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index d7aa7cd75..7b2bd54dd 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1389,6 +1389,7 @@ int EXT_FUNC PF_precache_model_I(const char *s) int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; + Con_Printf("Model: %s", char); if (!s) Host_Error("%s: NULL pointer", __func__); From 019141a52644eac6f6665fc67f3f5dbc5f23aeff Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:26:16 +0200 Subject: [PATCH 10/46] Update pr_cmds.cpp --- rehlds/engine/pr_cmds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 7b2bd54dd..4544645e0 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1389,7 +1389,7 @@ int EXT_FUNC PF_precache_model_I(const char *s) int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; - Con_Printf("Model: %s", char); + Con_Printf("Model: %s", s); if (!s) Host_Error("%s: NULL pointer", __func__); From 7a842ccaec788e2369d254b664feed6ac9c31903 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:39:26 +0200 Subject: [PATCH 11/46] Test without const --- rehlds/engine/pr_cmds.cpp | 4 ++-- rehlds/engine/pr_cmds.h | 4 ++-- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 4544645e0..f748c78f8 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1381,12 +1381,12 @@ int SV_LookupModelIndex(const char *name) return 0; } -int EXT_FUNC PF_precache_model_I(const char *s) +int EXT_FUNC PF_precache_model_I(char *s) { return g_RehldsHookchains.m_PF_precache_model_I.callChain(PF_precache_model_I_internal, s); } -int EXT_FUNC PF_precache_model_I_internal(const char *s) +int EXT_FUNC PF_precache_model_I_internal(char *s) { int iOptional = 0; Con_Printf("Model: %s", s); diff --git a/rehlds/engine/pr_cmds.h b/rehlds/engine/pr_cmds.h index 76df85563..2e49994b6 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -127,8 +127,8 @@ void EV_PlayReliableEvent(client_t *cl, int entindex, unsigned short eventindex, void EV_PlayReliableEvent_internal(client_t *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); void EV_Playback(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); void EV_SV_Playback(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); -int PF_precache_model_I(const char *s); -int PF_precache_model_I_internal(const char *s); +int PF_precache_model_I(char *s); +int PF_precache_model_I_internal(char *s); int PF_precache_generic_I(const char *s); int PF_precache_generic_I_internal(const char *s); int PF_IsMapValid_I(const char *mapname); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 8ac765a11..3acd7e7e9 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -236,8 +236,8 @@ typedef IHookChain IRehldsHook_PF_precache_generic_I; typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_generic_I; //PF_precache_model_I hook -typedef IHookChain IRehldsHook_PF_precache_model_I; -typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; +typedef IHookChain IRehldsHook_PF_precache_model_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; //PF_precache_sound_I hook typedef IHookChain IRehldsHook_PF_precache_sound_I; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 568f87437..8b81be89a 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -231,8 +231,8 @@ typedef IHookChainImpl CRehldsHook_PF_precache_generic_I; typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_generic_I; //PF_precache_model_I hook -typedef IHookChainImpl CRehldsHook_PF_precache_model_I; -typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_model_I; +typedef IHookChainImpl CRehldsHook_PF_precache_model_I; +typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_model_I; //PF_precache_sound_I hook typedef IHookChainImpl CRehldsHook_PF_precache_sound_I; From 2afe585634b4f7afc241c711dcaeab0cf2f5b10b Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 20:43:15 +0200 Subject: [PATCH 12/46] Update eiface.h --- rehlds/public/rehlds/eiface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/public/rehlds/eiface.h b/rehlds/public/rehlds/eiface.h index 59680bc6f..d22e364e2 100644 --- a/rehlds/public/rehlds/eiface.h +++ b/rehlds/public/rehlds/eiface.h @@ -105,7 +105,7 @@ typedef struct // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s { - int (*pfnPrecacheModel) (const char* s); + int (*pfnPrecacheModel) (char* s); int (*pfnPrecacheSound) (const char* s); void (*pfnSetModel) (edict_t *e, const char *m); int (*pfnModelIndex) (const char *m); From caa778fc64fd8d4d4926dd10d9eb34ba738bcf46 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 4 Mar 2022 21:12:29 +0200 Subject: [PATCH 13/46] Update pr_cmds.cpp --- rehlds/engine/pr_cmds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index f748c78f8..06607af55 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1381,7 +1381,7 @@ int SV_LookupModelIndex(const char *name) return 0; } -int EXT_FUNC PF_precache_model_I(char *s) +int PF_precache_model_I(char *s) { return g_RehldsHookchains.m_PF_precache_model_I.callChain(PF_precache_model_I_internal, s); } From a10dd39faa54858a6b8bee9b1d7c2cb83a891025 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 10:55:24 +0200 Subject: [PATCH 14/46] Revert "Update pr_cmds.cpp" This reverts commit 019141a52644eac6f6665fc67f3f5dbc5f23aeff. --- rehlds/engine/pr_cmds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 06607af55..fc4b2f563 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1389,7 +1389,7 @@ int PF_precache_model_I(char *s) int EXT_FUNC PF_precache_model_I_internal(char *s) { int iOptional = 0; - Con_Printf("Model: %s", s); + Con_Printf("Model: %s", char); if (!s) Host_Error("%s: NULL pointer", __func__); From ea17a1ef50cc4b1000ac74df22b2117998051085 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 10:57:05 +0200 Subject: [PATCH 15/46] Revert const changes --- rehlds/engine/pr_cmds.cpp | 4 ++-- rehlds/engine/pr_cmds.h | 4 ++-- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index fc4b2f563..7b2bd54dd 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1381,12 +1381,12 @@ int SV_LookupModelIndex(const char *name) return 0; } -int PF_precache_model_I(char *s) +int EXT_FUNC PF_precache_model_I(const char *s) { return g_RehldsHookchains.m_PF_precache_model_I.callChain(PF_precache_model_I_internal, s); } -int EXT_FUNC PF_precache_model_I_internal(char *s) +int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; Con_Printf("Model: %s", char); diff --git a/rehlds/engine/pr_cmds.h b/rehlds/engine/pr_cmds.h index 2e49994b6..76df85563 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -127,8 +127,8 @@ void EV_PlayReliableEvent(client_t *cl, int entindex, unsigned short eventindex, void EV_PlayReliableEvent_internal(client_t *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); void EV_Playback(int flags, const edict_t *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); void EV_SV_Playback(int flags, int clientindex, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2); -int PF_precache_model_I(char *s); -int PF_precache_model_I_internal(char *s); +int PF_precache_model_I(const char *s); +int PF_precache_model_I_internal(const char *s); int PF_precache_generic_I(const char *s); int PF_precache_generic_I_internal(const char *s); int PF_IsMapValid_I(const char *mapname); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 3acd7e7e9..8ac765a11 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -236,8 +236,8 @@ typedef IHookChain IRehldsHook_PF_precache_generic_I; typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_generic_I; //PF_precache_model_I hook -typedef IHookChain IRehldsHook_PF_precache_model_I; -typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; +typedef IHookChain IRehldsHook_PF_precache_model_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; //PF_precache_sound_I hook typedef IHookChain IRehldsHook_PF_precache_sound_I; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 8b81be89a..568f87437 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -231,8 +231,8 @@ typedef IHookChainImpl CRehldsHook_PF_precache_generic_I; typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_generic_I; //PF_precache_model_I hook -typedef IHookChainImpl CRehldsHook_PF_precache_model_I; -typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_model_I; +typedef IHookChainImpl CRehldsHook_PF_precache_model_I; +typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_model_I; //PF_precache_sound_I hook typedef IHookChainImpl CRehldsHook_PF_precache_sound_I; From d61cf70a1a54824175c564a764663a64711d8e2c Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 10:58:33 +0200 Subject: [PATCH 16/46] Update pr_cmds.cpp --- rehlds/engine/pr_cmds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 7b2bd54dd..4544645e0 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1389,7 +1389,7 @@ int EXT_FUNC PF_precache_model_I(const char *s) int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; - Con_Printf("Model: %s", char); + Con_Printf("Model: %s", s); if (!s) Host_Error("%s: NULL pointer", __func__); From 88f37a18b715db247e074df00766f3656c2f4335 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 11:00:29 +0200 Subject: [PATCH 17/46] Update eiface.h --- rehlds/public/rehlds/eiface.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/public/rehlds/eiface.h b/rehlds/public/rehlds/eiface.h index d22e364e2..59680bc6f 100644 --- a/rehlds/public/rehlds/eiface.h +++ b/rehlds/public/rehlds/eiface.h @@ -105,7 +105,7 @@ typedef struct // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s { - int (*pfnPrecacheModel) (char* s); + int (*pfnPrecacheModel) (const char* s); int (*pfnPrecacheSound) (const char* s); void (*pfnSetModel) (edict_t *e, const char *m); int (*pfnModelIndex) (const char *m); From fc49dae4f58d259b3883b39251cae5d2ff682a7a Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 11:01:22 +0200 Subject: [PATCH 18/46] Update pr_cmds.cpp --- rehlds/engine/pr_cmds.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index 4544645e0..de614e112 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1389,7 +1389,7 @@ int EXT_FUNC PF_precache_model_I(const char *s) int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; - Con_Printf("Model: %s", s); + Con_Printf("Model: %s\n", s); if (!s) Host_Error("%s: NULL pointer", __func__); From 319cb33b5d2b35f9a7e2e497bc8b1e79d1f69cb2 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 11:25:04 +0200 Subject: [PATCH 19/46] Update pr_cmds.cpp --- rehlds/engine/pr_cmds.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index de614e112..d7aa7cd75 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1389,7 +1389,6 @@ int EXT_FUNC PF_precache_model_I(const char *s) int EXT_FUNC PF_precache_model_I_internal(const char *s) { int iOptional = 0; - Con_Printf("Model: %s\n", s); if (!s) Host_Error("%s: NULL pointer", __func__); From 9c11a46bda21b2699e4f27a73a3168e7af386412 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 13:50:57 +0200 Subject: [PATCH 20/46] Added EV_Precache and SV_AddResource hooks and update API minor version --- rehlds/engine/pr_cmds.cpp | 5 +++++ rehlds/engine/pr_cmds.h | 1 + rehlds/engine/sv_main.cpp | 5 +++++ rehlds/public/rehlds/rehlds_api.h | 12 +++++++++++- rehlds/rehlds/rehlds_api_impl.cpp | 8 ++++++++ rehlds/rehlds/rehlds_api_impl.h | 12 ++++++++++++ rehlds/version/version.h | 2 +- 7 files changed, 43 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index d7aa7cd75..e1d956a7e 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1063,6 +1063,11 @@ int EXT_FUNC PF_precache_sound_I_internal(const char *s) } unsigned short EXT_FUNC EV_Precache(int type, const char *psz) +{ + return g_RehldsHookchains.m_EV_Precache.callChain(EV_Precache_internal, type, psz); +} + +unsigned short EXT_FUNC EV_Precache_internal(int type, const char *psz) { if (!psz) Host_Error("%s: NULL pointer", __func__); diff --git a/rehlds/engine/pr_cmds.h b/rehlds/engine/pr_cmds.h index 76df85563..a7d424c23 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -122,6 +122,7 @@ qboolean PR_IsEmptyString(const char *s); int PF_precache_sound_I(const char *s); int PF_precache_sound_I_internal(const char *s); unsigned short EV_Precache(int type, const char *psz); +unsigned short EV_Precache_internal(int type, const char *psz); void EV_PlayReliableEvent_api(IGameClient *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); void EV_PlayReliableEvent(client_t *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); void EV_PlayReliableEvent_internal(client_t *cl, int entindex, unsigned short eventindex, float delay, event_args_t *pargs); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 5c4e633d7..b6cb86c54 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5126,6 +5126,11 @@ int SV_ModelIndex(const char *name) } void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) +{ + g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_internal, type, name, size, flags, index); +} + +void EXT_FUNC SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { resource_t *r; #ifdef REHLDS_FIXES diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 8ac765a11..cc1debe3a 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -37,7 +37,7 @@ #include "pr_dlls.h" #define REHLDS_API_VERSION_MAJOR 3 -#define REHLDS_API_VERSION_MINOR 11 +#define REHLDS_API_VERSION_MINOR 12 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -243,6 +243,14 @@ typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_mod typedef IHookChain IRehldsHook_PF_precache_sound_I; typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sound_I; +//EV_Precache hook +typedef IHookChain IRehldsHook_EV_Precache; +typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; + +//SV_AddResource hook +typedef IVoidHookChain IRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -298,6 +306,8 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_PF_precache_generic_I* PF_precache_generic_I() = 0; virtual IRehldsHookRegistry_PF_precache_model_I* PF_precache_model_I() = 0; virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I() = 0; + virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0; + virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 99496ead1..6d5b2fab7 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -867,6 +867,14 @@ IRehldsHookRegistry_PF_precache_sound_I* CRehldsHookchains::PF_precache_sound_I( return &m_PF_precache_sound_I; } +IRehldsHookRegistry_EV_Precache* CRehldsHookchains::EV_Precache() { + return &m_EV_Precache; +} + +IRehldsHookRegistry_SV_AddResource* CRehldsHookchains::SV_AddResource(){ + return &m_SV_AddResource; +} + 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 568f87437..0a4e2eced 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -238,6 +238,14 @@ typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache typedef IHookChainImpl CRehldsHook_PF_precache_sound_I; typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_sound_I; +//EV_Precache hook +typedef IHookChainImpl CRehldsHook_EV_Precache; +typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; + +//SV_AddResource hook +typedef IHookChainImpl CRehldsHook_SV_AddResource; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -291,6 +299,8 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_PF_precache_generic_I m_PF_precache_generic_I; CRehldsHookRegistry_PF_precache_model_I m_PF_precache_model_I; CRehldsHookRegistry_PF_precache_sound_I m_PF_precache_sound_I; + CRehldsHookRegistry_EV_Precache m_EV_Precache; + CRehldsHookRegistry_SV_AddResource m_SV_AddResource; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -344,6 +354,8 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_PF_precache_generic_I* PF_precache_generic_I(); EXT_FUNC virtual IRehldsHookRegistry_PF_precache_model_I* PF_precache_model_I(); EXT_FUNC virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I(); + EXT_FUNC virtual IRehldsHookRegistry_EV_Precache* EV_Precache(); + EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/version/version.h b/rehlds/version/version.h index 0b177c4c1..9c1ad7184 100644 --- a/rehlds/version/version.h +++ b/rehlds/version/version.h @@ -6,5 +6,5 @@ #pragma once #define VERSION_MAJOR 3 -#define VERSION_MINOR 11 +#define VERSION_MINOR 12 #define VERSION_MAINTENANCE 0 From 20c3b68ae294fdb77fc22abed526a5964021bb65 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 13:57:27 +0200 Subject: [PATCH 21/46] Forgot a comma --- rehlds/public/rehlds/rehlds_api.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index cc1debe3a..da50cb2d3 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -245,7 +245,7 @@ typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sou //EV_Precache hook typedef IHookChain IRehldsHook_EV_Precache; -typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; +typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; //SV_AddResource hook typedef IVoidHookChain IRehldsHook_SV_AddResource; From 6055e08d4ce7c8bd35e7bf81ad83be181a9ef588 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:03:49 +0200 Subject: [PATCH 22/46] Added SV_AddResource_internal and fixed pointers --- rehlds/engine/server.h | 1 + rehlds/public/rehlds/rehlds_api.h | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 2bf880f3d..2b10515a8 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -570,6 +570,7 @@ void SV_SendClientMessages(void); void SV_ExtractFromUserinfo(client_t *cl); int SV_ModelIndex(const char *name); void SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index); +void SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index); size_t SV_CountResourceByType(resourcetype_t type, resource_t **pResourceList = nullptr, size_t nListMax = 0, size_t *nWidthFileNameMax = nullptr); void SV_CreateGenericResources(void); void SV_CreateResourceList(void); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index da50cb2d3..eeb8cb682 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -228,28 +228,28 @@ typedef IHookChain IRehldsHook_Con_Printf; typedef IHookChainRegistry IRehldsHookRegistry_Con_Printf; //SV_CheckUserInfo hook -typedef IHookChain IRehldsHook_SV_CheckUserInfo; -typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; +typedef IHookChain IRehldsHook_SV_CheckUserInfo; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckUserInfo; //PF_precache_generic_I hook -typedef IHookChain IRehldsHook_PF_precache_generic_I; -typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_generic_I; +typedef IHookChain IRehldsHook_PF_precache_generic_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_generic_I; //PF_precache_model_I hook -typedef IHookChain IRehldsHook_PF_precache_model_I; -typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; +typedef IHookChain IRehldsHook_PF_precache_model_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_model_I; //PF_precache_sound_I hook -typedef IHookChain IRehldsHook_PF_precache_sound_I; -typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sound_I; +typedef IHookChain IRehldsHook_PF_precache_sound_I; +typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sound_I; //EV_Precache hook -typedef IHookChain IRehldsHook_EV_Precache; -typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; +typedef IHookChain IRehldsHook_EV_Precache; +typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; //SV_AddResource hook -typedef IVoidHookChain IRehldsHook_SV_AddResource; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; +typedef IVoidHookChain IRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; class IRehldsHookchains { public: From 91422ac4d72789dfc501b98b32a634da612affd6 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:11:34 +0200 Subject: [PATCH 23/46] Added SV_AddResource_hook, fixed chain EV_Precache --- rehlds/engine/sv_main.cpp | 7 ++++++- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index b6cb86c54..943563cc1 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5125,9 +5125,14 @@ int SV_ModelIndex(const char *name) Sys_Error("%s: SV_ModelIndex: model %s not precached", __func__, name); } +void EXT_FUNC SV_AddResource_hook(resourcetype_t type, const char *name, int size, unsigned char flags, int index) +{ + SV_AddResource_internal(type, name, size, flags, index) +} + void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { - g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_internal, type, name, size, flags, index); + g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); } void EXT_FUNC SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index) diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index eeb8cb682..cf153aaf4 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -244,8 +244,8 @@ typedef IHookChain IRehldsHook_PF_precache_sound_I; typedef IHookChainRegistry IRehldsHookRegistry_PF_precache_sound_I; //EV_Precache hook -typedef IHookChain IRehldsHook_EV_Precache; -typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; +typedef IHookChain IRehldsHook_EV_Precache; +typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; //SV_AddResource hook typedef IVoidHookChain IRehldsHook_SV_AddResource; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 0a4e2eced..fe5af5fd3 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -239,8 +239,8 @@ typedef IHookChainImpl CRehldsHook_PF_precache_sound_I; typedef IHookChainRegistryImpl CRehldsHookRegistry_PF_precache_sound_I; //EV_Precache hook -typedef IHookChainImpl CRehldsHook_EV_Precache; -typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; +typedef IHookChainImpl CRehldsHook_EV_Precache; +typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; //SV_AddResource hook typedef IHookChainImpl CRehldsHook_SV_AddResource; From 8738d87c3ceb312a5c1280396388ec1767268c50 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:24:27 +0200 Subject: [PATCH 24/46] Reworked SV_AddResource for Rehlds API --- rehlds/engine/sv_main.cpp | 6 +++++- rehlds/public/rehlds/rehlds_api.h | 2 +- rehlds/rehlds/rehlds_api_impl.cpp | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 943563cc1..c8aa72b08 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5127,9 +5127,13 @@ int SV_ModelIndex(const char *name) void EXT_FUNC SV_AddResource_hook(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { - SV_AddResource_internal(type, name, size, flags, index) + SV_AddResource_internal(type, name, size, flags, index); } +void EXT_FUNC SV_AddResource_api(resourcetype_t type, const char *name, int size, unsigned char flags, int index) +{ + g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); + void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index cf153aaf4..94ce0dc27 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -343,7 +343,7 @@ struct RehldsFuncs_t { void*(*SZ_GetSpace)(sizebuf_t *buf, int length); cvar_t*(*GetCvarVars)(); int (*SV_GetChallenge)(const netadr_t& adr); - void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); + void (*AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); int(*MSG_ReadShort)(); int(*MSG_ReadBuf)(int iSize, void *pbuf); void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf); diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 6d5b2fab7..cd1eeeab4 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -493,7 +493,7 @@ RehldsFuncs_t g_RehldsApiFuncs = &SZ_GetSpace, &GetCvarVars_api, &SV_GetChallenge, - &SV_AddResource, + &SV_AddResource_api, &MSG_ReadShort_api, &MSG_ReadBuf_api, &MSG_WriteBuf_api, From 02ff23a52f043c33fe392c7cb70fc872396cd71f Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:26:55 +0200 Subject: [PATCH 25/46] Update server.h --- rehlds/engine/server.h | 1 + 1 file changed, 1 insertion(+) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 2b10515a8..469927a17 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -569,6 +569,7 @@ void SV_SkipUpdates(void); void SV_SendClientMessages(void); void SV_ExtractFromUserinfo(client_t *cl); int SV_ModelIndex(const char *name); +void SV_AddResource_api(resourcetype_t type, const char *name, int size, unsigned char flags, int index); void SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index); void SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index); size_t SV_CountResourceByType(resourcetype_t type, resource_t **pResourceList = nullptr, size_t nListMax = 0, size_t *nWidthFileNameMax = nullptr); From e7283b8d1c26696de53d3be615cfc26ef776b6e4 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:29:15 +0200 Subject: [PATCH 26/46] Update sv_main.cpp --- rehlds/engine/sv_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index c8aa72b08..bc1a5de90 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5139,7 +5139,7 @@ void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, un g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); } -void EXT_FUNC SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index) +void SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { resource_t *r; #ifdef REHLDS_FIXES From 77fc883bbd25c47325919670ed5cc1601d2d3c4c Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:31:19 +0200 Subject: [PATCH 27/46] Forgot a bracket --- rehlds/engine/sv_main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index bc1a5de90..c8058d7ab 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5133,6 +5133,7 @@ void EXT_FUNC SV_AddResource_hook(resourcetype_t type, const char *name, int siz void EXT_FUNC SV_AddResource_api(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); +} void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { From f99855f99e228d1b1ec612f9d4c6fcf50f97261a Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:32:34 +0200 Subject: [PATCH 28/46] Fixed API call --- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index fe5af5fd3..064d9a245 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -243,8 +243,8 @@ typedef IHookChainImpl CRehldsHook_EV_Precache typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; //SV_AddResource hook -typedef IHookChainImpl CRehldsHook_SV_AddResource; -typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; +typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; class CRehldsHookchains : public IRehldsHookchains { public: From ab03021b731a44630112fbcba21a7bbf0f6c6f96 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:38:27 +0200 Subject: [PATCH 29/46] Reverted RehldsFuncs_t's SV_AddResource API --- rehlds/engine/server.h | 1 - rehlds/engine/sv_main.cpp | 5 ----- rehlds/public/rehlds/rehlds_api.h | 2 +- rehlds/rehlds/rehlds_api_impl.cpp | 2 +- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index 469927a17..2b10515a8 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -569,7 +569,6 @@ void SV_SkipUpdates(void); void SV_SendClientMessages(void); void SV_ExtractFromUserinfo(client_t *cl); int SV_ModelIndex(const char *name); -void SV_AddResource_api(resourcetype_t type, const char *name, int size, unsigned char flags, int index); void SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index); void SV_AddResource_internal(resourcetype_t type, const char *name, int size, unsigned char flags, int index); size_t SV_CountResourceByType(resourcetype_t type, resource_t **pResourceList = nullptr, size_t nListMax = 0, size_t *nWidthFileNameMax = nullptr); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index c8058d7ab..cb67538e0 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -5130,11 +5130,6 @@ void EXT_FUNC SV_AddResource_hook(resourcetype_t type, const char *name, int siz SV_AddResource_internal(type, name, size, flags, index); } -void EXT_FUNC SV_AddResource_api(resourcetype_t type, const char *name, int size, unsigned char flags, int index) -{ - g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); -} - void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { g_RehldsHookchains.m_SV_AddResource.callChain(SV_AddResource_hook, type, name, size, flags, index); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 94ce0dc27..cf153aaf4 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -343,7 +343,7 @@ struct RehldsFuncs_t { void*(*SZ_GetSpace)(sizebuf_t *buf, int length); cvar_t*(*GetCvarVars)(); int (*SV_GetChallenge)(const netadr_t& adr); - void (*AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); + void (*SV_AddResource)(resourcetype_t type, const char *name, int size, unsigned char flags, int index); int(*MSG_ReadShort)(); int(*MSG_ReadBuf)(int iSize, void *pbuf); void(*MSG_WriteBuf)(sizebuf_t *sb, int iSize, void *buf); diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index cd1eeeab4..6d5b2fab7 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -493,7 +493,7 @@ RehldsFuncs_t g_RehldsApiFuncs = &SZ_GetSpace, &GetCvarVars_api, &SV_GetChallenge, - &SV_AddResource_api, + &SV_AddResource, &MSG_ReadShort_api, &MSG_ReadBuf_api, &MSG_WriteBuf_api, diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 064d9a245..fe5af5fd3 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -243,8 +243,8 @@ typedef IHookChainImpl CRehldsHook_EV_Precache typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; //SV_AddResource hook -typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; -typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; +typedef IHookChainImpl CRehldsHook_SV_AddResource; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; class CRehldsHookchains : public IRehldsHookchains { public: From 3f616044c6ed2a989ce738f8ff40406a80a5fad4 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:42:00 +0200 Subject: [PATCH 30/46] Updated chains --- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index cf153aaf4..356376e57 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -248,8 +248,8 @@ typedef IHookChain IRehldsHook_EV_Precache; typedef IHookChainRegistry IRehldsHookRegistry_EV_Precache; //SV_AddResource hook -typedef IVoidHookChain IRehldsHook_SV_AddResource; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; +typedef IVoidHookChain IRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; class IRehldsHookchains { public: diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index fe5af5fd3..064d9a245 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -243,8 +243,8 @@ typedef IHookChainImpl CRehldsHook_EV_Precache typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; //SV_AddResource hook -typedef IHookChainImpl CRehldsHook_SV_AddResource; -typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; +typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; class CRehldsHookchains : public IRehldsHookchains { public: From 90fabe81cca67860fa7e4b9bd83b175a6300e0fd Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 5 Mar 2022 14:43:50 +0200 Subject: [PATCH 31/46] Update rehlds_api_impl.h --- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 064d9a245..eef7837d6 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -243,8 +243,8 @@ typedef IHookChainImpl CRehldsHook_EV_Precache typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; //SV_AddResource hook -typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; -typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; +typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; class CRehldsHookchains : public IRehldsHookchains { public: From f436216854099ae3785c851031b25fbf05d06ccd Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Fri, 11 Mar 2022 17:05:59 +0200 Subject: [PATCH 32/46] Implement `SV_ClientPrintf` hook --- rehlds/engine/host.cpp | 19 +++++++++++-------- rehlds/engine/host.h | 1 + rehlds/public/rehlds/rehlds_api.h | 5 +++++ rehlds/rehlds/rehlds_api_impl.cpp | 4 ++++ rehlds/rehlds/rehlds_api_impl.h | 6 ++++++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index f30cfad65..3b1534c56 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -351,19 +351,22 @@ void Host_WriteCustomConfig(void) void SV_ClientPrintf(const char *fmt, ...) { + char Dest[4096]; va_list va; - char string[1024]; + va_start(va, fmt); + Q_vsnprintf(Dest, sizeof(Dest), fmt, va); + va_end(va); + + g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, Dest); +} + +void SV_ClientPrintf_internal(const char *Dest) +{ if (!host_client->fakeclient) { - va_start(va, fmt); - Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va); - va_end(va); - - string[ARRAYSIZE(string) - 1] = 0; - MSG_WriteByte(&host_client->netchan.message, svc_print); - MSG_WriteString(&host_client->netchan.message, string); + MSG_WriteString(&host_client->netchan.message, Dest); } } diff --git a/rehlds/engine/host.h b/rehlds/engine/host.h index fa656f7c6..cfe84abfd 100644 --- a/rehlds/engine/host.h +++ b/rehlds/engine/host.h @@ -85,6 +85,7 @@ NOXREF void Info_WriteVars(FileHandle_t fp); void Host_WriteConfiguration(void); void Host_WriteCustomConfig(void); void SV_ClientPrintf(const char *fmt, ...); +void SV_ClientPrintf_internal(const char *Dest); void SV_BroadcastPrintf(const char *fmt, ...); void Host_ClientCommands(const char *fmt, ...); void SV_DropClient_api(IGameClient* cl, bool crash, const char* fmt, ...); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 356376e57..39763f378 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -251,6 +251,10 @@ typedef IHookChainRegistry IRehldsHookRegistr typedef IVoidHookChain IRehldsHook_SV_AddResource; typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; +//SV_ClientPrintf hook +typedef IHookChain IRehldsHook_SV_ClientPrintf; +typedef IHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -308,6 +312,7 @@ class IRehldsHookchains { virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I() = 0; virtual IRehldsHookRegistry_EV_Precache* EV_Precache() = 0; virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource() = 0; + virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 6d5b2fab7..5a41c1e96 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -875,6 +875,10 @@ IRehldsHookRegistry_SV_AddResource* CRehldsHookchains::SV_AddResource(){ return &m_SV_AddResource; } +IRehldsHookRegistry_SV_ClientPrintf* CRehldsHookchains::SV_ClientPrintf(){ + return &m_SV_ClientPrintf; +} + 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 eef7837d6..37c30ebff 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -246,6 +246,10 @@ typedef IHookChainRegistryImpl CRehldsHookRegi typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; +//SV_ClientPrintf hook +typedef IHookChainImpl CRehldsHook_SV_ClientPrintf; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -301,6 +305,7 @@ class CRehldsHookchains : public IRehldsHookchains { CRehldsHookRegistry_PF_precache_sound_I m_PF_precache_sound_I; CRehldsHookRegistry_EV_Precache m_EV_Precache; CRehldsHookRegistry_SV_AddResource m_SV_AddResource; + CRehldsHookRegistry_SV_ClientPrintf m_SV_ClientPrintf; public: EXT_FUNC virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -356,6 +361,7 @@ class CRehldsHookchains : public IRehldsHookchains { EXT_FUNC virtual IRehldsHookRegistry_PF_precache_sound_I* PF_precache_sound_I(); EXT_FUNC virtual IRehldsHookRegistry_EV_Precache* EV_Precache(); EXT_FUNC virtual IRehldsHookRegistry_SV_AddResource* SV_AddResource(); + EXT_FUNC virtual IRehldsHookRegistry_SV_ClientPrintf* SV_ClientPrintf(); }; extern CRehldsHookchains g_RehldsHookchains; From 169f5110d7d96c858176bd88f84cdc3dc5188b2c Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Thu, 17 Mar 2022 20:51:43 +0200 Subject: [PATCH 33/46] Changed `SV_ClientPrintf` chain type to void --- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 39763f378..debea3317 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -252,8 +252,8 @@ typedef IVoidHookChain IR typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; //SV_ClientPrintf hook -typedef IHookChain IRehldsHook_SV_ClientPrintf; -typedef IHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; +typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; class IRehldsHookchains { public: diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 37c30ebff..28b1c3e74 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -247,8 +247,8 @@ typedef IVoidHookChainImpl typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; //SV_ClientPrintf hook -typedef IHookChainImpl CRehldsHook_SV_ClientPrintf; -typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; +typedef IVoidHookChainImpl CRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; class CRehldsHookchains : public IRehldsHookchains { public: From fdfbc6bab285ee470d9c3adb422c5ed0081e12a6 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 19:56:59 +0200 Subject: [PATCH 34/46] Revert `SV_ClientPrintf` code refactor --- rehlds/engine/host.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 3b1534c56..7afaca2da 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -354,22 +354,22 @@ void SV_ClientPrintf(const char *fmt, ...) char Dest[4096]; va_list va; - va_start(va, fmt); - Q_vsnprintf(Dest, sizeof(Dest), fmt, va); - va_end(va); - - g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, Dest); -} - -void SV_ClientPrintf_internal(const char *Dest) -{ if (!host_client->fakeclient) { - MSG_WriteByte(&host_client->netchan.message, svc_print); - MSG_WriteString(&host_client->netchan.message, Dest); + va_start(va, fmt); + Q_vsnprintf(Dest, sizeof(Dest), fmt, va); + va_end(va); + + g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, Dest); } } +void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) +{ + MSG_WriteByte(&host_client->netchan.message, svc_print); + MSG_WriteString(&host_client->netchan.message, Dest); +} + void SV_BroadcastPrintf(const char *fmt, ...) { va_list argptr; From 66696a2056684048319ffc47d0df2bd69cfc42c0 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:00:48 +0200 Subject: [PATCH 35/46] Update host.cpp --- rehlds/engine/host.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 7afaca2da..25389d7f7 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -351,16 +351,16 @@ void Host_WriteCustomConfig(void) void SV_ClientPrintf(const char *fmt, ...) { - char Dest[4096]; + char string[4096]; va_list va; if (!host_client->fakeclient) { va_start(va, fmt); - Q_vsnprintf(Dest, sizeof(Dest), fmt, va); + Q_vsnprintf(string, sizeof(string), fmt, va); va_end(va); - g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, Dest); + g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, string); } } From 4cd0aa428b1b247f061c410e2c5525c6e8e8613d Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:01:21 +0200 Subject: [PATCH 36/46] Update host.cpp --- rehlds/engine/host.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 25389d7f7..4bc8ccfde 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -351,13 +351,13 @@ void Host_WriteCustomConfig(void) void SV_ClientPrintf(const char *fmt, ...) { - char string[4096]; va_list va; + char string[4096]; if (!host_client->fakeclient) { va_start(va, fmt); - Q_vsnprintf(string, sizeof(string), fmt, va); + Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va); va_end(va); g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, string); From 260a9727306a3c5e0926293e32c01cbae333ef17 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:03:31 +0200 Subject: [PATCH 37/46] Update host.cpp --- rehlds/engine/host.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 4bc8ccfde..380ce871c 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -366,6 +366,9 @@ void SV_ClientPrintf(const char *fmt, ...) void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) { + // This should be here because of hookchain. The real value could be changed. + Dest[ARRAYSIZE(Dest) - 1] = 0; + MSG_WriteByte(&host_client->netchan.message, svc_print); MSG_WriteString(&host_client->netchan.message, Dest); } From 01c063796e9ebf4310ae2d4a96ed0bade24dd340 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:07:17 +0200 Subject: [PATCH 38/46] Removed `const` string type in order to resize the string. --- rehlds/engine/host.cpp | 2 +- rehlds/engine/host.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 380ce871c..66684d842 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -364,7 +364,7 @@ void SV_ClientPrintf(const char *fmt, ...) } } -void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) +void EXT_FUNC SV_ClientPrintf_internal(char *Dest) { // This should be here because of hookchain. The real value could be changed. Dest[ARRAYSIZE(Dest) - 1] = 0; diff --git a/rehlds/engine/host.h b/rehlds/engine/host.h index cfe84abfd..4d558c54b 100644 --- a/rehlds/engine/host.h +++ b/rehlds/engine/host.h @@ -85,7 +85,7 @@ NOXREF void Info_WriteVars(FileHandle_t fp); void Host_WriteConfiguration(void); void Host_WriteCustomConfig(void); void SV_ClientPrintf(const char *fmt, ...); -void SV_ClientPrintf_internal(const char *Dest); +void SV_ClientPrintf_internal(char *Dest); void SV_BroadcastPrintf(const char *fmt, ...); void Host_ClientCommands(const char *fmt, ...); void SV_DropClient_api(IGameClient* cl, bool crash, const char* fmt, ...); From c2e8472a8bfafc327a793bd869da34af1f30ec99 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:12:08 +0200 Subject: [PATCH 39/46] Changes according to var type --- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index debea3317..178d2b0b9 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -252,8 +252,8 @@ typedef IVoidHookChain IR typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; //SV_ClientPrintf hook -typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; +typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; class IRehldsHookchains { public: diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 28b1c3e74..51a211d32 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -247,8 +247,8 @@ typedef IVoidHookChainImpl typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; //SV_ClientPrintf hook -typedef IVoidHookChainImpl CRehldsHook_SV_ClientPrintf; -typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; +typedef IVoidHookChainImpl CRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; class CRehldsHookchains : public IRehldsHookchains { public: From abdb9914d67177052e3ce8da4f49a2a3a62382a4 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:39:08 +0200 Subject: [PATCH 40/46] Fixing function's functionality --- rehlds/engine/host.cpp | 7 +++++-- rehlds/public/rehlds/rehlds_api.h | 4 ++-- rehlds/rehlds/rehlds_api_impl.h | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 66684d842..aab760ab1 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -364,10 +364,13 @@ void SV_ClientPrintf(const char *fmt, ...) } } -void EXT_FUNC SV_ClientPrintf_internal(char *Dest) +void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) { + char string[4096]; + + Q_memcpy(Dest, string, ARRAYSIZE(string) - 1) // This should be here because of hookchain. The real value could be changed. - Dest[ARRAYSIZE(Dest) - 1] = 0; + string[ARRAYSIZE(string) - 1] = 0; MSG_WriteByte(&host_client->netchan.message, svc_print); MSG_WriteString(&host_client->netchan.message, Dest); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 178d2b0b9..debea3317 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -252,8 +252,8 @@ typedef IVoidHookChain IR typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_AddResource; //SV_ClientPrintf hook -typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; -typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; +typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; class IRehldsHookchains { public: diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 51a211d32..28b1c3e74 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -247,8 +247,8 @@ typedef IVoidHookChainImpl typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; //SV_ClientPrintf hook -typedef IVoidHookChainImpl CRehldsHook_SV_ClientPrintf; -typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; +typedef IVoidHookChainImpl CRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; class CRehldsHookchains : public IRehldsHookchains { public: From 7d8c0a2e195f2c58887e64d00a4e0e1f94420542 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:41:43 +0200 Subject: [PATCH 41/46] Update host.cpp --- rehlds/engine/host.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index aab760ab1..88bd78cc4 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -368,7 +368,7 @@ void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) { char string[4096]; - Q_memcpy(Dest, string, ARRAYSIZE(string) - 1) + Q_memcpy(string, Dest, ARRAYSIZE(string) - 1) // This should be here because of hookchain. The real value could be changed. string[ARRAYSIZE(string) - 1] = 0; From 07372edd52dbd10683719ebdedb006a64f9a1ab7 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:45:31 +0200 Subject: [PATCH 42/46] Update host.cpp --- rehlds/engine/host.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 88bd78cc4..93377e4fe 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -368,12 +368,12 @@ void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) { char string[4096]; - Q_memcpy(string, Dest, ARRAYSIZE(string) - 1) + Q_memcpy(string, Dest, ARRAYSIZE(string) - 1); // This should be here because of hookchain. The real value could be changed. string[ARRAYSIZE(string) - 1] = 0; MSG_WriteByte(&host_client->netchan.message, svc_print); - MSG_WriteString(&host_client->netchan.message, Dest); + MSG_WriteString(&host_client->netchan.message, string); } void SV_BroadcastPrintf(const char *fmt, ...) From 0183e2a8039cb7f7cee8c15003713119e0dff828 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Mon, 21 Mar 2022 20:50:05 +0200 Subject: [PATCH 43/46] Update host.cpp / .h --- rehlds/engine/host.cpp | 4 ++-- rehlds/engine/host.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 93377e4fe..a504a4fb8 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -352,7 +352,7 @@ void Host_WriteCustomConfig(void) void SV_ClientPrintf(const char *fmt, ...) { va_list va; - char string[4096]; + char string[1024]; if (!host_client->fakeclient) { @@ -366,7 +366,7 @@ void SV_ClientPrintf(const char *fmt, ...) void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) { - char string[4096]; + char string[1024]; Q_memcpy(string, Dest, ARRAYSIZE(string) - 1); // This should be here because of hookchain. The real value could be changed. diff --git a/rehlds/engine/host.h b/rehlds/engine/host.h index 4d558c54b..cfe84abfd 100644 --- a/rehlds/engine/host.h +++ b/rehlds/engine/host.h @@ -85,7 +85,7 @@ NOXREF void Info_WriteVars(FileHandle_t fp); void Host_WriteConfiguration(void); void Host_WriteCustomConfig(void); void SV_ClientPrintf(const char *fmt, ...); -void SV_ClientPrintf_internal(char *Dest); +void SV_ClientPrintf_internal(const char *Dest); void SV_BroadcastPrintf(const char *fmt, ...); void Host_ClientCommands(const char *fmt, ...); void SV_DropClient_api(IGameClient* cl, bool crash, const char* fmt, ...); From ad70fbb87dfbc31c35c08f275d0b7c46b3180c70 Mon Sep 17 00:00:00 2001 From: ShadowsAdi <54354938+ShadowsAdi@users.noreply.github.com> Date: Sat, 16 Apr 2022 00:13:16 +0300 Subject: [PATCH 44/46] Moved vars declaration after `host_client` check --- rehlds/engine/host.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index a504a4fb8..8ac776707 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -351,16 +351,16 @@ void Host_WriteCustomConfig(void) void SV_ClientPrintf(const char *fmt, ...) { - va_list va; - char string[1024]; - if (!host_client->fakeclient) { + va_list va; + char Dest[1024]; + va_start(va, fmt); - Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va); + Q_vsnprintf(Dest, ARRAYSIZE(Dest) - 1, fmt, va); va_end(va); - g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, string); + g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, Dest); } } From 4a5baca4c34b820b4cf7e0bdd549a5b9c0e9d54e Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Mon, 19 Sep 2022 13:05:23 +0300 Subject: [PATCH 45/46] revert variable naming in SV_ClientPrintf --- rehlds/engine/host.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index 8ac776707..cf9354c4c 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -354,13 +354,13 @@ void SV_ClientPrintf(const char *fmt, ...) if (!host_client->fakeclient) { va_list va; - char Dest[1024]; + char string[1024]; va_start(va, fmt); - Q_vsnprintf(Dest, ARRAYSIZE(Dest) - 1, fmt, va); + Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va); va_end(va); - g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, Dest); + g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, string); } } From d46fccb35447b2d46e899ab12856fa339e2aa305 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Mon, 19 Sep 2022 13:57:58 +0300 Subject: [PATCH 46/46] `SV_ClientPrintf_internal`: more safe string copy --- rehlds/engine/host.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index cf9354c4c..3416efdf7 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -368,10 +368,7 @@ void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) { char string[1024]; - Q_memcpy(string, Dest, ARRAYSIZE(string) - 1); - // This should be here because of hookchain. The real value could be changed. - string[ARRAYSIZE(string) - 1] = 0; - + Q_strlcpy(string, Dest, min(strlen(Dest) + 1, sizeof(string))); MSG_WriteByte(&host_client->netchan.message, svc_print); MSG_WriteString(&host_client->netchan.message, string); }