mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-17 00:58:18 +03:00
Added client_t<>index conversion functions to ReHLDS API.
This commit is contained in:
parent
b0e4e5fa4f
commit
c1daf838c3
@ -85,6 +85,10 @@ public:
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifndef REHLDS_SELF
|
||||
struct client_t;
|
||||
#endif
|
||||
|
||||
class IRehldsServerStatic {
|
||||
public:
|
||||
virtual ~IRehldsServerStatic() { }
|
||||
@ -92,6 +96,8 @@ public:
|
||||
virtual int GetMaxClients() = 0;
|
||||
virtual bool IsLogActive() = 0;
|
||||
virtual IGameClient* GetClient(int id) = 0;
|
||||
virtual client_t* GetClient_t(int id) = 0;
|
||||
virtual int GetIndexOfClient_t(client_t* client) = 0;
|
||||
};
|
||||
|
||||
class IRehldsServerData {
|
||||
|
@ -136,6 +136,25 @@ IGameClient* EXT_FUNC CRehldsServerStatic::GetClient(int id)
|
||||
return g_GameClients[id];
|
||||
}
|
||||
|
||||
client_t* EXT_FUNC CRehldsServerStatic::GetClient_t(int id)
|
||||
{
|
||||
if (id < 0 || id >= g_psvs.maxclients)
|
||||
Sys_Error(__FUNCTION__": invalid id provided: %d", id);
|
||||
|
||||
return &g_psvs.clients[id];
|
||||
}
|
||||
|
||||
int EXT_FUNC CRehldsServerStatic::GetIndexOfClient_t(client_t* client)
|
||||
{
|
||||
if (client < g_psvs.clients || client >= &g_psvs.clients[g_psvs.maxclients])
|
||||
return -1;
|
||||
|
||||
if (((size_t)client - (size_t)g_psvs.clients) % sizeof(client_t))
|
||||
return -1;
|
||||
|
||||
return int(client - g_psvs.clients);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char* EXT_FUNC CRehldsServerData::GetModelName() {
|
||||
|
@ -86,6 +86,8 @@ public:
|
||||
virtual int GetMaxClients();
|
||||
virtual bool IsLogActive();
|
||||
virtual IGameClient* GetClient(int id);
|
||||
virtual client_t* GetClient_t(int id);
|
||||
virtual int GetIndexOfClient_t(client_t* client);
|
||||
};
|
||||
|
||||
class CRehldsServerData : public IRehldsServerData {
|
||||
|
Loading…
x
Reference in New Issue
Block a user