Merge pull request #62 from theAsmodai/master

Implemented SV_WriteFullClientUpdate callback
This commit is contained in:
dreamstalker 2015-07-16 16:30:32 +04:00
commit 8d73400168
5 changed files with 33 additions and 10 deletions

View File

@ -3713,30 +3713,35 @@ int SV_CalcPing(client_t *cl)
return 0;
}
/* <a874a> ../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);
}
/* <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)
{
SV_EmitEvents_internal(cl->GetClient(), pack, ms);

View File

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

View File

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

View File

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

View File

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