2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-01 01:25:38 +03:00

Merge pull request #95 from s1lentq/master

ReHLDS API: Added some functions
This commit is contained in:
theAsmodai 2015-11-08 19:49:42 +03:00
commit 8aa0f4cc19
8 changed files with 32 additions and 16 deletions

View File

@ -4915,7 +4915,7 @@ int SV_ModelIndex(const char *name)
}
/* <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;
if (g_psv.num_resources >= MAX_RESOURCE_LIST)

View File

@ -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]);
}
/* <bf76a> ../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

View File

@ -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 IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
//SV_GenericFileConsistencyResponce hook
typedef IVoidHookChain<IGameClient *, resource_t *, uint32> IRehldsHook_GenericFileConsistencyResponce;
typedef IVoidHookChainRegistry<IGameClient *, resource_t *, uint32> IRehldsHookRegistry_GenericFileConsistencyResponce;
//SV_CheckConsistencyResponce hook
typedef IHookChain<bool, IGameClient *, resource_t *, uint32> IRehldsHook_SV_CheckConsistencyResponce;
typedef IHookChainRegistry<bool, IGameClient *, resource_t *, uint32> 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 {

View File

@ -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;
};

View File

@ -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()

View File

@ -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 IVoidHookChainRegistryImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHookRegistry_SV_WriteFullClientUpdate;
//SV_WriteFullClientUpdate hook
typedef IVoidHookChainImpl<IGameClient *, resource_t *, uint32> CRehldsHook_GenericFileConsistencyResponce;
typedef IVoidHookChainRegistryImpl<IGameClient *, resource_t *, uint32> CRehldsHookRegistry_GenericFileConsistencyResponce;
//SV_CheckConsistencyResponce hook
typedef IHookChainImpl<bool, IGameClient *, resource_t *, uint32> CRehldsHook_SV_CheckConsistencyResponce;
typedef IHookChainRegistryImpl<bool, IGameClient *, resource_t *, uint32> 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;

View File

@ -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)

View File

@ -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;