mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-06 03:55:32 +03:00
Merge pull request #95 from s1lentq/master
ReHLDS API: Added some functions
This commit is contained in:
commit
8aa0f4cc19
@ -4915,7 +4915,7 @@ int SV_ModelIndex(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* <a9992> ../engine/sv_main.c:6529 */
|
/* <a9992> ../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;
|
resource_t *r;
|
||||||
if (g_psv.num_resources >= MAX_RESOURCE_LIST)
|
if (g_psv.num_resources >= MAX_RESOURCE_LIST)
|
||||||
|
@ -106,6 +106,10 @@ clc_func_t sv_clcfuncs[12];
|
|||||||
|
|
||||||
#endif //HOOK_ENGINE
|
#endif //HOOK_ENGINE
|
||||||
|
|
||||||
|
bool EXT_FUNC SV_CheckConsistencyResponce_API(IGameClient *client, resource_t *res, uint32 hash) {
|
||||||
|
return (hash != *(uint32 *)&res->rgucMD5_hash[0]);
|
||||||
|
}
|
||||||
|
|
||||||
/* <bf76a> ../engine/sv_user.c:94 */
|
/* <bf76a> ../engine/sv_user.c:94 */
|
||||||
void SV_ParseConsistencyResponse(client_t *pSenderClient)
|
void SV_ParseConsistencyResponse(client_t *pSenderClient)
|
||||||
{
|
{
|
||||||
@ -143,9 +147,7 @@ void SV_ParseConsistencyResponse(client_t *pSenderClient)
|
|||||||
if (!Q_memcmp(resbuffer, nullbuffer, sizeof(resbuffer)))
|
if (!Q_memcmp(resbuffer, nullbuffer, sizeof(resbuffer)))
|
||||||
{
|
{
|
||||||
uint32 hash = MSG_ReadBits(32);
|
uint32 hash = MSG_ReadBits(32);
|
||||||
g_RehldsHookchains.m_GenericFileConsistencyResponce.callChain(NULL, GetRehldsApiClient(pSenderClient), r, hash);
|
if (g_RehldsHookchains.m_SV_CheckConsistencyResponce.callChain(SV_CheckConsistencyResponce_API, GetRehldsApiClient(pSenderClient), r, hash))
|
||||||
|
|
||||||
if (hash != *(uint32 *)&r->rgucMD5_hash[0])
|
|
||||||
c = idx + 1;
|
c = idx + 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -141,9 +141,9 @@ typedef IVoidHookChainRegistry<edict_t *, int, const char *, float, float, int,
|
|||||||
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
|
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
|
||||||
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
|
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
|
||||||
|
|
||||||
//SV_GenericFileConsistencyResponce hook
|
//SV_CheckConsistencyResponce hook
|
||||||
typedef IVoidHookChain<IGameClient *, resource_t *, uint32> IRehldsHook_GenericFileConsistencyResponce;
|
typedef IHookChain<bool, IGameClient *, resource_t *, uint32> IRehldsHook_SV_CheckConsistencyResponce;
|
||||||
typedef IVoidHookChainRegistry<IGameClient *, resource_t *, uint32> IRehldsHookRegistry_GenericFileConsistencyResponce;
|
typedef IHookChainRegistry<bool, IGameClient *, resource_t *, uint32> IRehldsHookRegistry_SV_CheckConsistencyResponce;
|
||||||
|
|
||||||
class IRehldsHookchains {
|
class IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
@ -175,7 +175,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0;
|
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I() = 0;
|
||||||
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0;
|
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I() = 0;
|
||||||
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
|
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate() = 0;
|
||||||
virtual IRehldsHookRegistry_GenericFileConsistencyResponce* GenericFileConsistencyResponce() = 0;
|
virtual IRehldsHookRegistry_SV_CheckConsistencyResponce* SV_CheckConsistencyResponce() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RehldsFuncs_t {
|
struct RehldsFuncs_t {
|
||||||
@ -211,6 +211,7 @@ struct RehldsFuncs_t {
|
|||||||
void*(*SZ_GetSpace)(sizebuf_t *buf, int length);
|
void*(*SZ_GetSpace)(sizebuf_t *buf, int length);
|
||||||
cvar_t*(*GetCvarVars)();
|
cvar_t*(*GetCvarVars)();
|
||||||
int (*SV_GetChallenge)(const netadr_t& adr);
|
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 {
|
class IRehldsApi {
|
||||||
|
@ -113,4 +113,6 @@ public:
|
|||||||
virtual sizebuf_t* GetReliableDatagram() = 0;
|
virtual sizebuf_t* GetReliableDatagram() = 0;
|
||||||
|
|
||||||
virtual void SetModelName(const char* modelname) = 0;
|
virtual void SetModelName(const char* modelname) = 0;
|
||||||
|
virtual void SetConsistencyNum(int num) = 0;
|
||||||
|
virtual int GetConsistencyNum() = 0;
|
||||||
};
|
};
|
||||||
|
@ -121,7 +121,8 @@ RehldsFuncs_t g_RehldsApiFuncs =
|
|||||||
&MSG_EndBitWriting_api,
|
&MSG_EndBitWriting_api,
|
||||||
&SZ_GetSpace,
|
&SZ_GetSpace,
|
||||||
&GetCvarVars_api,
|
&GetCvarVars_api,
|
||||||
&SV_GetChallenge
|
&SV_GetChallenge,
|
||||||
|
&SV_AddResource
|
||||||
};
|
};
|
||||||
|
|
||||||
sizebuf_t* EXT_FUNC GetNetMessage_api()
|
sizebuf_t* EXT_FUNC GetNetMessage_api()
|
||||||
@ -259,8 +260,8 @@ IRehldsHookRegistry_SV_WriteFullClientUpdate* CRehldsHookchains::SV_WriteFullCli
|
|||||||
return &m_SV_WriteFullClientUpdate;
|
return &m_SV_WriteFullClientUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
IRehldsHookRegistry_GenericFileConsistencyResponce* CRehldsHookchains::GenericFileConsistencyResponce() {
|
IRehldsHookRegistry_SV_CheckConsistencyResponce* CRehldsHookchains::SV_CheckConsistencyResponce() {
|
||||||
return &m_GenericFileConsistencyResponce;
|
return &m_SV_CheckConsistencyResponce;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||||
|
@ -135,9 +135,9 @@ typedef IVoidHookChainRegistryImpl<edict_t *, int, const char *, float, float, i
|
|||||||
typedef IVoidHookChainImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHook_SV_WriteFullClientUpdate;
|
typedef IVoidHookChainImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHook_SV_WriteFullClientUpdate;
|
||||||
typedef IVoidHookChainRegistryImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHookRegistry_SV_WriteFullClientUpdate;
|
typedef IVoidHookChainRegistryImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHookRegistry_SV_WriteFullClientUpdate;
|
||||||
|
|
||||||
//SV_WriteFullClientUpdate hook
|
//SV_CheckConsistencyResponce hook
|
||||||
typedef IVoidHookChainImpl<IGameClient *, resource_t *, uint32> CRehldsHook_GenericFileConsistencyResponce;
|
typedef IHookChainImpl<bool, IGameClient *, resource_t *, uint32> CRehldsHook_SV_CheckConsistencyResponce;
|
||||||
typedef IVoidHookChainRegistryImpl<IGameClient *, resource_t *, uint32> CRehldsHookRegistry_GenericFileConsistencyResponce;
|
typedef IHookChainRegistryImpl<bool, IGameClient *, resource_t *, uint32> CRehldsHookRegistry_SV_CheckConsistencyResponce;
|
||||||
|
|
||||||
class CRehldsHookchains : public IRehldsHookchains {
|
class CRehldsHookchains : public IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
@ -167,7 +167,7 @@ public:
|
|||||||
CRehldsHookRegistry_PF_Remove_I m_PF_Remove_I;
|
CRehldsHookRegistry_PF_Remove_I m_PF_Remove_I;
|
||||||
CRehldsHookRegistry_PF_BuildSoundMsg_I m_PF_BuildSoundMsg_I;
|
CRehldsHookRegistry_PF_BuildSoundMsg_I m_PF_BuildSoundMsg_I;
|
||||||
CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate;
|
CRehldsHookRegistry_SV_WriteFullClientUpdate m_SV_WriteFullClientUpdate;
|
||||||
CRehldsHookRegistry_GenericFileConsistencyResponce m_GenericFileConsistencyResponce;
|
CRehldsHookRegistry_SV_CheckConsistencyResponce m_SV_CheckConsistencyResponce;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||||
@ -196,7 +196,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I();
|
virtual IRehldsHookRegistry_PF_Remove_I* PF_Remove_I();
|
||||||
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I();
|
virtual IRehldsHookRegistry_PF_BuildSoundMsg_I* PF_BuildSoundMsg_I();
|
||||||
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate();
|
virtual IRehldsHookRegistry_SV_WriteFullClientUpdate* SV_WriteFullClientUpdate();
|
||||||
virtual IRehldsHookRegistry_GenericFileConsistencyResponce* GenericFileConsistencyResponce();
|
virtual IRehldsHookRegistry_SV_CheckConsistencyResponce* SV_CheckConsistencyResponce();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CRehldsHookchains g_RehldsHookchains;
|
extern CRehldsHookchains g_RehldsHookchains;
|
||||||
|
@ -191,6 +191,14 @@ sizebuf_t* EXT_FUNC CRehldsServerData::GetReliableDatagram() {
|
|||||||
return &g_psv.reliable_datagram;
|
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()
|
void Rehlds_Interfaces_FreeClients()
|
||||||
{
|
{
|
||||||
if (g_GameClients == NULL)
|
if (g_GameClients == NULL)
|
||||||
|
@ -99,6 +99,8 @@ public:
|
|||||||
virtual sizebuf_t* GetReliableDatagram();
|
virtual sizebuf_t* GetReliableDatagram();
|
||||||
|
|
||||||
virtual void SetModelName(const char* modelname);
|
virtual void SetModelName(const char* modelname);
|
||||||
|
virtual void SetConsistencyNum(int num);
|
||||||
|
virtual int GetConsistencyNum();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CGameClient** g_GameClients;
|
extern CGameClient** g_GameClients;
|
||||||
|
Loading…
Reference in New Issue
Block a user