diff --git a/rehlds/engine/host.cpp b/rehlds/engine/host.cpp index f30cfad65..3416efdf7 100644 --- a/rehlds/engine/host.cpp +++ b/rehlds/engine/host.cpp @@ -351,22 +351,28 @@ void Host_WriteCustomConfig(void) void SV_ClientPrintf(const char *fmt, ...) { - va_list va; - char string[1024]; - if (!host_client->fakeclient) { + va_list va; + char string[1024]; + 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); + g_RehldsHookchains.m_SV_ClientPrintf.callChain(SV_ClientPrintf_internal, string); } } +void EXT_FUNC SV_ClientPrintf_internal(const char *Dest) +{ + char string[1024]; + + 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); +} + void SV_BroadcastPrintf(const char *fmt, ...) { va_list argptr; 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/engine/pr_cmds.cpp b/rehlds/engine/pr_cmds.cpp index df82bce5f..e1d956a7e 100644 --- a/rehlds/engine/pr_cmds.cpp +++ b/rehlds/engine/pr_cmds.cpp @@ -1011,6 +1011,11 @@ qboolean EXT_FUNC PR_IsEmptyString(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); +} + +int EXT_FUNC PF_precache_sound_I_internal(const char *s) { if (!s) Host_Error("%s: NULL pointer", __func__); @@ -1058,6 +1063,11 @@ int EXT_FUNC PF_precache_sound_I(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__); @@ -1377,6 +1387,11 @@ int SV_LookupModelIndex(const char *name) } 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(const char *s) { int iOptional = 0; if (!s) @@ -1445,8 +1460,13 @@ int EXT_FUNC PF_precache_model_I(const char *s) } } -#ifdef REHLDS_FIXES 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); +} + +#ifdef REHLDS_FIXES +int EXT_FUNC PF_precache_generic_I_internal(const char *s) { if (!s) Host_Error("%s: NULL pointer", __func__); @@ -1493,7 +1513,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..a7d424c23 100644 --- a/rehlds/engine/pr_cmds.h +++ b/rehlds/engine/pr_cmds.h @@ -120,14 +120,18 @@ 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); +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); 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..2b10515a8 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); @@ -569,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/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 9c9ce2966..cb67538e0 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]; @@ -5120,7 +5125,17 @@ 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_hook, type, name, size, flags, index); +} + +void 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 876752a6b..debea3317 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; @@ -227,6 +227,33 @@ 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; + +//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; + +//SV_ClientPrintf hook +typedef IVoidHookChain IRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_ClientPrintf; class IRehldsHookchains { public: @@ -279,6 +306,13 @@ 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; + 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 1124e057e..5a41c1e96 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -851,6 +851,34 @@ 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; +} + +IRehldsHookRegistry_EV_Precache* CRehldsHookchains::EV_Precache() { + return &m_EV_Precache; +} + +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 19929c9e5..28b1c3e74 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -222,6 +222,34 @@ 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; + +//EV_Precache hook +typedef IHookChainImpl CRehldsHook_EV_Precache; +typedef IHookChainRegistryImpl CRehldsHookRegistry_EV_Precache; + +//SV_AddResource hook +typedef IVoidHookChainImpl CRehldsHook_SV_AddResource; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_AddResource; + +//SV_ClientPrintf hook +typedef IVoidHookChainImpl CRehldsHook_SV_ClientPrintf; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_ClientPrintf; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -271,6 +299,13 @@ 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; + 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(); @@ -320,6 +355,13 @@ 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(); + 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; 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