2
0
mirror of https://github.com/rehlds/rehlds.git synced 2025-01-16 16:48:13 +03:00

Merge pull request #217 from WPMGPRoSToTeMa/master

Added SV_UpdateUserInfo to API
This commit is contained in:
theAsmodai 2016-06-16 00:11:39 +03:00 committed by GitHub
commit 50e19c8b46
5 changed files with 23 additions and 8 deletions

View File

@ -53,6 +53,9 @@
// the server sends this value back // the server sends this value back
#define S2C_CHALLENGE 'A' // + challenge value #define S2C_CHALLENGE 'A' // + challenge value
// Send a userid, client remote address, is this server secure and engine build number
#define S2C_CONNECTION 'B'
// HLMaster rejected a server's connection because the server needs to be updated // HLMaster rejected a server's connection because the server needs to be updated
#define M2S_REQUESTRESTART 'O' #define M2S_REQUESTRESTART 'O'

View File

@ -730,6 +730,7 @@ void SV_EmitPings(client_t *client, sizebuf_t *msg);
void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg); void SV_WriteEntitiesToClient(client_t *client, sizebuf_t *msg);
void SV_CleanupEnts(void); void SV_CleanupEnts(void);
qboolean SV_SendClientDatagram(client_t *client); qboolean SV_SendClientDatagram(client_t *client);
void SV_UpdateUserInfo(client_t *pClient);
void SV_UpdateToReliableMessages(void); void SV_UpdateToReliableMessages(void);
void SV_SkipUpdates(void); void SV_SkipUpdates(void);
void SV_SendClientMessages(void); void SV_SendClientMessages(void);

View File

@ -2497,7 +2497,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
#endif // REHLDS_FIXES #endif // REHLDS_FIXES
bIsSecure = Steam_GSBSecure(); bIsSecure = Steam_GSBSecure();
Netchan_OutOfBandPrint(NS_SERVER, adr, "%c %i \"%s\" %i %i", 66, host_client->userid, NET_AdrToString(host_client->netchan.remote_address), bIsSecure, build_number()); Netchan_OutOfBandPrint(NS_SERVER, adr, "%c %i \"%s\" %i %i", S2C_CONNECTION, host_client->userid, NET_AdrToString(host_client->netchan.remote_address), bIsSecure, build_number());
Log_Printf("\"%s<%i><%s><>\" connected, address \"%s\"\n", name, host_client->userid, SV_GetClientIDString(host_client), NET_AdrToString(host_client->netchan.remote_address)); Log_Printf("\"%s<%i><%s><>\" connected, address \"%s\"\n", name, host_client->userid, SV_GetClientIDString(host_client), NET_AdrToString(host_client->netchan.remote_address));
#ifdef REHLDS_FIXES #ifdef REHLDS_FIXES
Q_strncpy(host_client->userinfo, userinfo, MAX_INFO_STRING - 1); Q_strncpy(host_client->userinfo, userinfo, MAX_INFO_STRING - 1);
@ -4692,6 +4692,14 @@ qboolean SV_SendClientDatagram(client_t *client)
return TRUE; return TRUE;
} }
void SV_UpdateUserInfo(client_t *pClient)
{
pClient->sendinfo = FALSE;
pClient->sendinfo_time = realtime + 1.0;
SV_ExtractFromUserinfo(pClient);
SV_FullClientUpdate(pClient, &g_psv.reliable_datagram);
}
/* <a981c> ../engine/sv_main.c:6062 */ /* <a981c> ../engine/sv_main.c:6062 */
void SV_UpdateToReliableMessages(void) void SV_UpdateToReliableMessages(void)
{ {
@ -4715,10 +4723,7 @@ void SV_UpdateToReliableMessages(void)
if (client->sendinfo && client->sendinfo_time <= realtime) if (client->sendinfo && client->sendinfo_time <= realtime)
#endif // REHLDS_FIXES #endif // REHLDS_FIXES
{ {
client->sendinfo = FALSE; SV_UpdateUserInfo(client);
client->sendinfo_time = realtime + 1.0;
SV_ExtractFromUserinfo(client);
SV_FullClientUpdate(client, &g_psv.reliable_datagram);
} }
if (!client->fakeclient && (client->active || client->connected)) if (!client->fakeclient && (client->active || client->connected))

View File

@ -35,7 +35,7 @@
#include "model.h" #include "model.h"
#define REHLDS_API_VERSION_MAJOR 2 #define REHLDS_API_VERSION_MAJOR 2
#define REHLDS_API_VERSION_MINOR 12 #define REHLDS_API_VERSION_MINOR 13
//Steam_NotifyClientConnect hook //Steam_NotifyClientConnect hook
typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect; typedef IHookChain<qboolean, IGameClient*, const void*, unsigned int> IRehldsHook_Steam_NotifyClientConnect;
@ -280,6 +280,7 @@ struct RehldsFuncs_t {
void(*Steam_NotifyClientDisconnect)(IGameClient* cl); void(*Steam_NotifyClientDisconnect)(IGameClient* cl);
void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch); void(*SV_StartSound)(int recipients, edict_t *entity, int channel, const char *sample, int volume, float attenuation, int flags, int pitch);
bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin); bool(*SV_EmitSound2)(edict_t *entity, IGameClient *receiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin);
void (* SV_UpdateUserInfo)(IGameClient *pGameClient);
}; };
class IRehldsApi { class IRehldsApi {

View File

@ -133,6 +133,10 @@ void EXT_FUNC SV_StartSound_api(int recipients, edict_t *entity, int channel, co
SV_StartSound(recipients, entity, channel, sample, volume, attenuation, flags, pitch); SV_StartSound(recipients, entity, channel, sample, volume, attenuation, flags, pitch);
} }
void EXT_FUNC SV_UpdateUserInfo_api(IGameClient *pGameClient) {
SV_UpdateUserInfo(pGameClient->GetClient());
}
void* EXT_FUNC Rehlds_GetPluginApi(const char *name) { void* EXT_FUNC Rehlds_GetPluginApi(const char *name) {
auto api = FindPluginApiByName(name); auto api = FindPluginApiByName(name);
return api ? api->impl : NULL; return api ? api->impl : NULL;
@ -200,7 +204,8 @@ RehldsFuncs_t g_RehldsApiFuncs =
&Steam_NotifyClientConnect_api, &Steam_NotifyClientConnect_api,
&Steam_NotifyClientDisconnect_api, &Steam_NotifyClientDisconnect_api,
&SV_StartSound_api, &SV_StartSound_api,
&SV_EmitSound2_api &SV_EmitSound2_api,
&SV_UpdateUserInfo_api
}; };
bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin) bool EXT_FUNC SV_EmitSound2_internal(edict_t *entity, IGameClient *pReceiver, int channel, const char *sample, float volume, float attenuation, int flags, int pitch, int emitFlags, const float *pOrigin)