mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-17 09:07:54 +03:00
Merge pull request #45 from theAsmodai/master
Added client_t<>index conversion functions to ReHLDS API.
This commit is contained in:
commit
9bbb2537c5
@ -85,6 +85,10 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifndef REHLDS_SELF
|
||||||
|
struct client_t;
|
||||||
|
#endif
|
||||||
|
|
||||||
class IRehldsServerStatic {
|
class IRehldsServerStatic {
|
||||||
public:
|
public:
|
||||||
virtual ~IRehldsServerStatic() { }
|
virtual ~IRehldsServerStatic() { }
|
||||||
@ -92,6 +96,8 @@ public:
|
|||||||
virtual int GetMaxClients() = 0;
|
virtual int GetMaxClients() = 0;
|
||||||
virtual bool IsLogActive() = 0;
|
virtual bool IsLogActive() = 0;
|
||||||
virtual IGameClient* GetClient(int id) = 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 {
|
class IRehldsServerData {
|
||||||
|
@ -136,6 +136,25 @@ IGameClient* EXT_FUNC CRehldsServerStatic::GetClient(int id)
|
|||||||
return g_GameClients[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() {
|
const char* EXT_FUNC CRehldsServerData::GetModelName() {
|
||||||
|
@ -86,6 +86,8 @@ public:
|
|||||||
virtual int GetMaxClients();
|
virtual int GetMaxClients();
|
||||||
virtual bool IsLogActive();
|
virtual bool IsLogActive();
|
||||||
virtual IGameClient* GetClient(int id);
|
virtual IGameClient* GetClient(int id);
|
||||||
|
virtual client_t* GetClient_t(int id);
|
||||||
|
virtual int GetIndexOfClient_t(client_t* client);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CRehldsServerData : public IRehldsServerData {
|
class CRehldsServerData : public IRehldsServerData {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user