diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index fb4a597..11271a3 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -4915,7 +4915,7 @@ int SV_ModelIndex(const char *name) } /* ../engine/sv_main.c:6529 */ -void SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) +void EXT_FUNC SV_AddResource(resourcetype_t type, const char *name, int size, unsigned char flags, int index) { resource_t *r; if (g_psv.num_resources >= MAX_RESOURCE_LIST) diff --git a/rehlds/engine/sv_user.cpp b/rehlds/engine/sv_user.cpp index 96d0851..b969bb0 100644 --- a/rehlds/engine/sv_user.cpp +++ b/rehlds/engine/sv_user.cpp @@ -106,6 +106,10 @@ clc_func_t sv_clcfuncs[12]; #endif //HOOK_ENGINE +bool EXT_FUNC SV_CheckConsistencyResponce_API(IGameClient *client, resource_t *res, uint32 hash) { + return (hash != *(uint32 *)&res->rgucMD5_hash[0]); +} + /* ../engine/sv_user.c:94 */ void SV_ParseConsistencyResponse(client_t *pSenderClient) { @@ -143,9 +147,7 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient) if (!Q_memcmp(resbuffer, nullbuffer, sizeof(resbuffer))) { uint32 hash = MSG_ReadBits(32); - g_RehldsHookchains.m_GenericFileConsistencyResponce.callChain(NULL, GetRehldsApiClient(pSenderClient), r, hash); - - if (hash != *(uint32 *)&r->rgucMD5_hash[0]) + if (g_RehldsHookchains.m_SV_CheckConsistencyResponce.callChain(SV_CheckConsistencyResponce_API, GetRehldsApiClient(pSenderClient), r, hash)) c = idx + 1; } else diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index f8ac00f..d8fe084 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -141,9 +141,9 @@ typedef IVoidHookChainRegistry IRehldsHook_SV_WriteFullClientUpdate; typedef IVoidHookChainRegistry IRehldsHookRegistry_SV_WriteFullClientUpdate; -//SV_GenericFileConsistencyResponce hook -typedef IVoidHookChain IRehldsHook_GenericFileConsistencyResponce; -typedef IVoidHookChainRegistry IRehldsHookRegistry_GenericFileConsistencyResponce; +//SV_CheckConsistencyResponce hook +typedef IHookChain IRehldsHook_SV_CheckConsistencyResponce; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CheckConsistencyResponce; class IRehldsHookchains { public: @@ -175,7 +175,7 @@ public: 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; - virtual IRehldsHookRegistry_GenericFileConsistencyResponce* GenericFileConsistencyResponce() = 0; + virtual IRehldsHookRegistry_SV_CheckConsistencyResponce* SV_CheckConsistencyResponce() = 0; }; struct RehldsFuncs_t { @@ -211,6 +211,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); }; class IRehldsApi { diff --git a/rehlds/public/rehlds/rehlds_interfaces.h b/rehlds/public/rehlds/rehlds_interfaces.h index ce46d55..9d5de98 100644 --- a/rehlds/public/rehlds/rehlds_interfaces.h +++ b/rehlds/public/rehlds/rehlds_interfaces.h @@ -113,4 +113,6 @@ public: virtual sizebuf_t* GetReliableDatagram() = 0; virtual void SetModelName(const char* modelname) = 0; + virtual void SetConsistencyNum(int num) = 0; + virtual int GetConsistencyNum() = 0; }; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 5a3bd97..6807620 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -121,7 +121,8 @@ RehldsFuncs_t g_RehldsApiFuncs = &MSG_EndBitWriting_api, &SZ_GetSpace, &GetCvarVars_api, - &SV_GetChallenge + &SV_GetChallenge, + &SV_AddResource }; sizebuf_t* EXT_FUNC GetNetMessage_api() @@ -259,8 +260,8 @@ IRehldsHookRegistry_SV_WriteFullClientUpdate* CRehldsHookchains::SV_WriteFullCli return &m_SV_WriteFullClientUpdate; } -IRehldsHookRegistry_GenericFileConsistencyResponce* CRehldsHookchains::GenericFileConsistencyResponce() { - return &m_GenericFileConsistencyResponce; +IRehldsHookRegistry_SV_CheckConsistencyResponce* CRehldsHookchains::SV_CheckConsistencyResponce() { + return &m_SV_CheckConsistencyResponce; } int EXT_FUNC CRehldsApi::GetMajorVersion() diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 2c700fb..6f1e27c 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -135,9 +135,9 @@ typedef IVoidHookChainRegistryImpl CRehldsHook_SV_WriteFullClientUpdate; typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_SV_WriteFullClientUpdate; -//SV_WriteFullClientUpdate hook -typedef IVoidHookChainImpl CRehldsHook_GenericFileConsistencyResponce; -typedef IVoidHookChainRegistryImpl CRehldsHookRegistry_GenericFileConsistencyResponce; +//SV_CheckConsistencyResponce hook +typedef IHookChainImpl CRehldsHook_SV_CheckConsistencyResponce; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CheckConsistencyResponce; class CRehldsHookchains : public IRehldsHookchains { public: @@ -167,7 +167,7 @@ public: CRehldsHookRegistry_PF_Remove_I m_PF_Remove_I; CRehldsHookRegistry_PF_BuildSoundMsg_I m_PF_BuildSoundMsg_I; CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate; - CRehldsHookRegistry_GenericFileConsistencyResponce m_GenericFileConsistencyResponce; + CRehldsHookRegistry_SV_CheckConsistencyResponce m_SV_CheckConsistencyResponce; public: virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -196,7 +196,7 @@ public: virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I(); virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I(); virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate(); - virtual IRehldsHookRegistry_GenericFileConsistencyResponce* GenericFileConsistencyResponce(); + virtual IRehldsHookRegistry_SV_CheckConsistencyResponce* SV_CheckConsistencyResponce(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index 2f7c068..8a532aa 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -191,6 +191,14 @@ sizebuf_t* EXT_FUNC CRehldsServerData::GetReliableDatagram() { return &g_psv.reliable_datagram; } +void EXT_FUNC CRehldsServerData::SetConsistencyNum(int num) { + g_psv.num_consistency = num; +} + +int EXT_FUNC CRehldsServerData::GetConsistencyNum() { + return g_psv.num_consistency; +} + void Rehlds_Interfaces_FreeClients() { if (g_GameClients == NULL) diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index 5224b1f..cdc99e6 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -99,6 +99,8 @@ public: virtual sizebuf_t* GetReliableDatagram(); virtual void SetModelName(const char* modelname); + virtual void SetConsistencyNum(int num); + virtual int GetConsistencyNum(); }; extern CGameClient** g_GameClients;