mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-04 02:55:50 +03:00
Merge pull request #62 from theAsmodai/master
Implemented SV_WriteFullClientUpdate callback
This commit is contained in:
commit
8d73400168
@ -3713,30 +3713,35 @@ int SV_CalcPing(client_t *cl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a874a> ../engine/sv_main.c:4991 */
|
void EXT_FUNC SV_WriteFullClientUpdate_internal(IGameClient *client, char *info, size_t maxlen, sizebuf_t *sb, IGameClient *receiver)
|
||||||
void SV_FullClientUpdate(client_t *cl, sizebuf_t *sb)
|
|
||||||
{
|
{
|
||||||
unsigned int i;
|
client_t* cl = client->GetClient();
|
||||||
char info[MAX_INFO_STRING];
|
|
||||||
MD5Context_t ctx;
|
MD5Context_t ctx;
|
||||||
unsigned char digest[16];
|
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);
|
MD5Init(&ctx);
|
||||||
MD5Update(&ctx, (unsigned char*)cl->hashedcdkey, sizeof(cl->hashedcdkey));
|
MD5Update(&ctx, (unsigned char*)cl->hashedcdkey, sizeof(cl->hashedcdkey));
|
||||||
MD5Final(digest, &ctx);
|
MD5Final(digest, &ctx);
|
||||||
|
|
||||||
MSG_WriteByte(sb, svc_updateuserinfo);
|
MSG_WriteByte(sb, svc_updateuserinfo);
|
||||||
MSG_WriteByte(sb, i);
|
MSG_WriteByte(sb, cl - g_psvs.clients);
|
||||||
MSG_WriteLong(sb, cl->userid);
|
MSG_WriteLong(sb, cl->userid);
|
||||||
MSG_WriteString(sb, info);
|
MSG_WriteString(sb, info);
|
||||||
MSG_WriteBuf(sb, sizeof(digest), digest);
|
MSG_WriteBuf(sb, sizeof(digest), digest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* <a874a> ../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)
|
void EXT_FUNC SV_EmitEvents_api(IGameClient *cl, packet_entities_t *pack, sizebuf_t *ms)
|
||||||
{
|
{
|
||||||
SV_EmitEvents_internal(cl->GetClient(), pack, ms);
|
SV_EmitEvents_internal(cl->GetClient(), pack, ms);
|
||||||
|
@ -137,6 +137,10 @@ typedef IVoidHookChainRegistry<edict_t *> IRehldsHookRegistry_PF_Remove_I;
|
|||||||
typedef IVoidHookChain<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHook_PF_BuildSoundMsg_I;
|
typedef IVoidHookChain<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHook_PF_BuildSoundMsg_I;
|
||||||
typedef IVoidHookChainRegistry<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHookRegistry_PF_BuildSoundMsg_I;
|
typedef IVoidHookChainRegistry<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> IRehldsHookRegistry_PF_BuildSoundMsg_I;
|
||||||
|
|
||||||
|
//SV_WriteFullClientUpdate hook
|
||||||
|
typedef IVoidHookChain<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHook_SV_WriteFullClientUpdate;
|
||||||
|
typedef IVoidHookChainRegistry<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> IRehldsHookRegistry_SV_WriteFullClientUpdate;
|
||||||
|
|
||||||
class IRehldsHookchains {
|
class IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
virtual ~IRehldsHookchains() { }
|
virtual ~IRehldsHookchains() { }
|
||||||
@ -166,6 +170,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0;
|
virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound() = 0;
|
||||||
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;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RehldsFuncs_t {
|
struct RehldsFuncs_t {
|
||||||
|
@ -249,6 +249,10 @@ IRehldsHookRegistry_PF_BuildSoundMsg_I* CRehldsHookchains::PF_BuildSoundMsg_I()
|
|||||||
return &m_PF_BuildSoundMsg_I;
|
return &m_PF_BuildSoundMsg_I;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRehldsHookRegistry_SV_WriteFullClientUpdate* CRehldsHookchains::SV_WriteFullClientUpdate() {
|
||||||
|
return &m_SV_WriteFullClientUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||||
{
|
{
|
||||||
return REHLDS_API_VERSION_MAJOR;
|
return REHLDS_API_VERSION_MAJOR;
|
||||||
|
@ -131,6 +131,10 @@ typedef IVoidHookChainRegistryImpl<edict_t *> CRehldsHookRegistry_PF_Remove_I;
|
|||||||
typedef IVoidHookChainImpl<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> CRehldsHook_PF_BuildSoundMsg_I;
|
typedef IVoidHookChainImpl<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> CRehldsHook_PF_BuildSoundMsg_I;
|
||||||
typedef IVoidHookChainRegistryImpl<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> CRehldsHookRegistry_PF_BuildSoundMsg_I;
|
typedef IVoidHookChainRegistryImpl<edict_t *, int, const char *, float, float, int, int, int, int, const float *, edict_t *> CRehldsHookRegistry_PF_BuildSoundMsg_I;
|
||||||
|
|
||||||
|
//SV_WriteFullClientUpdate hook
|
||||||
|
typedef IVoidHookChainImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHook_SV_WriteFullClientUpdate;
|
||||||
|
typedef IVoidHookChainRegistryImpl<IGameClient *, char *, size_t, sizebuf_t *, IGameClient *> CRehldsHookRegistry_SV_WriteFullClientUpdate;
|
||||||
|
|
||||||
class CRehldsHookchains : public IRehldsHookchains {
|
class CRehldsHookchains : public IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||||
@ -158,6 +162,7 @@ public:
|
|||||||
CRehldsHookRegistry_SV_StartSound m_SV_StartSound;
|
CRehldsHookRegistry_SV_StartSound m_SV_StartSound;
|
||||||
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;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||||
@ -185,6 +190,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound();
|
virtual IRehldsHookRegistry_SV_StartSound* SV_StartSound();
|
||||||
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();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CRehldsHookchains g_RehldsHookchains;
|
extern CRehldsHookchains g_RehldsHookchains;
|
||||||
|
@ -205,6 +205,9 @@ void Rehlds_Interfaces_InitClients()
|
|||||||
|
|
||||||
IGameClient* GetRehldsApiClient(client_t* cl)
|
IGameClient* GetRehldsApiClient(client_t* cl)
|
||||||
{
|
{
|
||||||
|
if (cl == NULL)
|
||||||
|
return NULL; //I think it's logical.
|
||||||
|
|
||||||
int idx = cl - g_psvs.clients;
|
int idx = cl - g_psvs.clients;
|
||||||
if (idx < 0 || idx >= g_psvs.maxclients)
|
if (idx < 0 || idx >= g_psvs.maxclients)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user