diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index 1cdc033..9e95bec 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -3713,30 +3713,35 @@ int SV_CalcPing(client_t *cl) return 0; } -/* ../engine/sv_main.c:4991 */ -void SV_FullClientUpdate(client_t *cl, sizebuf_t *sb) +void EXT_FUNC SV_WriteFullClientUpdate_internal(IGameClient *client, char *info, size_t maxlen, sizebuf_t *sb, IGameClient *receiver) { - unsigned int i; - char info[MAX_INFO_STRING]; + client_t* cl = client->GetClient(); MD5Context_t ctx; unsigned char digest[16]; - i = cl - g_psvs.clients; - Q_strncpy(info, cl->userinfo, sizeof(info) - 1); - info[sizeof(info) - 1] = 0; - Info_RemovePrefixedKeys(info, '_'); - MD5Init(&ctx); MD5Update(&ctx, (unsigned char*)cl->hashedcdkey, sizeof(cl->hashedcdkey)); MD5Final(digest, &ctx); MSG_WriteByte(sb, svc_updateuserinfo); - MSG_WriteByte(sb, i); + MSG_WriteByte(sb, cl - g_psvs.clients); MSG_WriteLong(sb, cl->userid); MSG_WriteString(sb, info); MSG_WriteBuf(sb, sizeof(digest), digest); } +/* ../engine/sv_main.c:4991 */ +void SV_FullClientUpdate(client_t *cl, sizebuf_t *sb) +{ + char info[MAX_INFO_STRING]; + + Q_strncpy(info, cl->userinfo, sizeof(info) - 1); + info[sizeof(info) - 1] = 0; + Info_RemovePrefixedKeys(info, '_'); + + g_RehldsHookchains.m_SV_WriteFullClientUpdate.callChain(SV_WriteFullClientUpdate_internal, GetRehldsApiClient(cl), info, MAX_INFO_STRING, sb, GetRehldsApiClient((sb == &g_psv.reliable_datagram) ? NULL : host_client)); +} + void EXT_FUNC SV_EmitEvents_api(IGameClient *cl, packet_entities_t *pack, sizebuf_t *ms) { SV_EmitEvents_internal(cl->GetClient(), pack, ms); diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 57e5c43..5f93e1c 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -137,6 +137,10 @@ typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_Remove_I; typedef IVoidHookChain IRehldsHook_PF_BuildSoundMsg_I; typedef IVoidHookChainRegistry IRehldsHookRegistry_PF_BuildSoundMsg_I; +//SV_WriteFullClientUpdate hook +typedef IVoidHookChain IRehldsHook_SV_WriteFullClientUpdate; +typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteFullClientUpdate; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -166,6 +170,7 @@ public: virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0; virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0; virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0; + virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0; }; struct RehldsFuncs_t { diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 7b56673..1d051a0 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -249,6 +249,10 @@ IRehldsHookRegistry_PF_BuildSoundMsg_I* CRehldsHookchains::PF_BuildSoundMsg_I() return &m_PF_BuildSoundMsg_I; } +IRehldsHookRegistry_SV_WriteFullClientUpdate* CRehldsHookchains::SV_WriteFullClientUpdate() { + return &m_SV_WriteFullClientUpdate; +} + 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 fdfdc9b..a3b0cac 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -131,6 +131,10 @@ typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_PF_Remove_I; typedef IVoidHookChainImpl CRehldsHook_PF_BuildSoundMsg_I; typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_PF_BuildSoundMsg_I; +//SV_WriteFullClientUpdate hook +typedef IVoidHookChainImpl CRehldsHook_SV_WriteFullClientUpdate; +typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_WriteFullClientUpdate; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -158,6 +162,7 @@ public: CRehldsHookRegistry_SV_StartSound m_SV_StartSound; CRehldsHookRegistry_PF_Remove_I m_PF_Remove_I; CRehldsHookRegistry_PF_BuildSoundMsg_I m_PF_BuildSoundMsg_I; + CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate; public: virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -185,6 +190,7 @@ public: virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound(); virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I(); virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I(); + virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index 8eea115..768091f 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -205,6 +205,9 @@ void Rehlds_Interfaces_InitClients() IGameClient* GetRehldsApiClient(client_t* cl) { + if (cl == NULL) + return NULL; //I think it's logical. + int idx = cl - g_psvs.clients; if (idx < 0 || idx >= g_psvs.maxclients) {