mirror of
https://github.com/rehlds/rehlds.git
synced 2025-01-01 01:25:38 +03:00
ReHLDS API: Add hook SV_CreatePacketEntities, global net_from and int… (#212)
ReHLDS API: Add hook SV_CreatePacketEntities, global net_from and interface SteamGameServer
This commit is contained in:
parent
312a03f9aa
commit
caf2960504
@ -719,6 +719,7 @@ void SV_WriteDeltaHeader(int num, qboolean remove, qboolean custom, int *numbase
|
|||||||
void SV_InvokeCallback(void);
|
void SV_InvokeCallback(void);
|
||||||
int SV_FindBestBaseline(int index, entity_state_t ** baseline, entity_state_t *to, int num, qboolean custom);
|
int SV_FindBestBaseline(int index, entity_state_t ** baseline, entity_state_t *to, int num, qboolean custom);
|
||||||
int SV_CreatePacketEntities(sv_delta_t type, client_t *client, packet_entities_t *to, sizebuf_t *msg);
|
int SV_CreatePacketEntities(sv_delta_t type, client_t *client, packet_entities_t *to, sizebuf_t *msg);
|
||||||
|
int SV_CreatePacketEntities_internal(sv_delta_t type, client_t *client, packet_entities_t *to, sizebuf_t *msg);
|
||||||
void SV_EmitPacketEntities(client_t *client, packet_entities_t *to, sizebuf_t *msg);
|
void SV_EmitPacketEntities(client_t *client, packet_entities_t *to, sizebuf_t *msg);
|
||||||
qboolean SV_ShouldUpdatePing(client_t *client);
|
qboolean SV_ShouldUpdatePing(client_t *client);
|
||||||
NOXREF qboolean SV_HasEventsInQueue(client_t *client);
|
NOXREF qboolean SV_HasEventsInQueue(client_t *client);
|
||||||
|
@ -2385,7 +2385,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
|
|||||||
Steam_NotifyClientDisconnect(client);
|
Steam_NotifyClientDisconnect(client);
|
||||||
if ((client->active || client->spawned) && client->edict)
|
if ((client->active || client->spawned) && client->edict)
|
||||||
gEntityInterface.pfnClientDisconnect(client->edict);
|
gEntityInterface.pfnClientDisconnect(client->edict);
|
||||||
|
|
||||||
Con_Printf("%s:reconnect\n", NET_AdrToString(adr));
|
Con_Printf("%s:reconnect\n", NET_AdrToString(adr));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2468,7 +2468,7 @@ void EXT_FUNC SV_ConnectClient_internal(void)
|
|||||||
if (g_modfuncs.m_pfnConnectClient)
|
if (g_modfuncs.m_pfnConnectClient)
|
||||||
g_modfuncs.m_pfnConnectClient(nClientSlot);
|
g_modfuncs.m_pfnConnectClient(nClientSlot);
|
||||||
|
|
||||||
Netchan_Setup(NS_SERVER, &host_client->netchan, adr, client - g_psvs.clients, client, SV_GetFragmentSize);
|
Netchan_Setup(NS_SERVER, &host_client->netchan, adr, client - g_psvs.clients, client, SV_GetFragmentSize);
|
||||||
host_client->next_messageinterval = 5.0;
|
host_client->next_messageinterval = 5.0;
|
||||||
host_client->next_messagetime = realtime + 0.05;
|
host_client->next_messagetime = realtime + 0.05;
|
||||||
host_client->delta_sequence = -1;
|
host_client->delta_sequence = -1;
|
||||||
@ -4241,8 +4241,18 @@ int SV_FindBestBaseline(int index, entity_state_t ** baseline, entity_state_t *t
|
|||||||
return index - bestfound;
|
return index - bestfound;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* <a8e01> ../engine/sv_main.c:5525 */
|
int EXT_FUNC SV_CreatePacketEntities_api(sv_delta_t type, IGameClient *client, packet_entities_t *to, sizebuf_t *msg)
|
||||||
|
{
|
||||||
|
return SV_CreatePacketEntities_internal(type, client->GetClient(), to, msg);
|
||||||
|
}
|
||||||
|
|
||||||
int SV_CreatePacketEntities(sv_delta_t type, client_t *client, packet_entities_t *to, sizebuf_t *msg)
|
int SV_CreatePacketEntities(sv_delta_t type, client_t *client, packet_entities_t *to, sizebuf_t *msg)
|
||||||
|
{
|
||||||
|
return g_RehldsHookchains.m_SV_CreatePacketEntities.callChain(SV_CreatePacketEntities_api, type, GetRehldsApiClient(client), to, msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* <a8e01> ../engine/sv_main.c:5525 */
|
||||||
|
int SV_CreatePacketEntities_internal(sv_delta_t type, client_t *client, packet_entities_t *to, sizebuf_t *msg)
|
||||||
{
|
{
|
||||||
packet_entities_t *from;
|
packet_entities_t *from;
|
||||||
int oldindex;
|
int oldindex;
|
||||||
|
@ -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 11
|
#define REHLDS_API_VERSION_MINOR 12
|
||||||
|
|
||||||
//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;
|
||||||
@ -181,6 +181,10 @@ typedef IVoidHookChainRegistry<IGameClient *, usercmd_t *, int, int, int> IRehld
|
|||||||
typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f;
|
typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f;
|
||||||
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
|
typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f;
|
||||||
|
|
||||||
|
//SV_CreatePacketEntities hook
|
||||||
|
typedef IHookChain<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHook_SV_CreatePacketEntities;
|
||||||
|
typedef IHookChainRegistry<int, enum sv_delta_s, IGameClient *, struct packet_entities_s *, struct sizebuf_s *> IRehldsHookRegistry_SV_CreatePacketEntities;
|
||||||
|
|
||||||
class IRehldsHookchains {
|
class IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
virtual ~IRehldsHookchains() { }
|
virtual ~IRehldsHookchains() { }
|
||||||
@ -221,6 +225,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0;
|
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0;
|
||||||
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
|
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0;
|
||||||
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
|
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0;
|
||||||
|
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RehldsFuncs_t {
|
struct RehldsFuncs_t {
|
||||||
@ -283,4 +288,4 @@ public:
|
|||||||
virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
|
virtual IRehldsFlightRecorder* GetFlightRecorder() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
|
#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001"
|
||||||
|
@ -126,4 +126,7 @@ public:
|
|||||||
virtual double GetTime() = 0;
|
virtual double GetTime() = 0;
|
||||||
virtual void SetResourcesNum(int num) = 0;
|
virtual void SetResourcesNum(int num) = 0;
|
||||||
virtual struct resource_s *GetResource(int index) = 0;
|
virtual struct resource_s *GetResource(int index) = 0;
|
||||||
|
virtual void SetName(const char* name) = 0;
|
||||||
|
virtual class ISteamGameServer *GetSteamGameServer() = 0;
|
||||||
|
virtual struct netadr_s *GetNetFrom() = 0;
|
||||||
};
|
};
|
||||||
|
@ -372,6 +372,10 @@ IRehldsHookRegistry_SV_Spawn_f* CRehldsHookchains::SV_Spawn_f() {
|
|||||||
return &m_SV_Spawn_f;
|
return &m_SV_Spawn_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IRehldsHookRegistry_SV_CreatePacketEntities* CRehldsHookchains::SV_CreatePacketEntities() {
|
||||||
|
return &m_SV_CreatePacketEntities;
|
||||||
|
}
|
||||||
|
|
||||||
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
int EXT_FUNC CRehldsApi::GetMajorVersion()
|
||||||
{
|
{
|
||||||
return REHLDS_API_VERSION_MAJOR;
|
return REHLDS_API_VERSION_MAJOR;
|
||||||
|
@ -175,6 +175,10 @@ typedef IVoidHookChainRegistryImpl<IGameClient *, usercmd_t *, int, int, int> CR
|
|||||||
typedef IVoidHookChainImpl<> CRehldsHook_SV_Spawn_f;
|
typedef IVoidHookChainImpl<> CRehldsHook_SV_Spawn_f;
|
||||||
typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Spawn_f;
|
typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Spawn_f;
|
||||||
|
|
||||||
|
//SV_CreatePacketEntities hook
|
||||||
|
typedef IHookChainImpl<int, sv_delta_t, IGameClient *, packet_entities_t *, sizebuf_t *> CRehldsHook_SV_CreatePacketEntities;
|
||||||
|
typedef IHookChainRegistryImpl<int, sv_delta_t, IGameClient *, packet_entities_t *, sizebuf_t *> CRehldsHookRegistry_SV_CreatePacketEntities;
|
||||||
|
|
||||||
class CRehldsHookchains : public IRehldsHookchains {
|
class CRehldsHookchains : public IRehldsHookchains {
|
||||||
public:
|
public:
|
||||||
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect;
|
||||||
@ -213,6 +217,7 @@ public:
|
|||||||
CRehldsHookRegistry_Cvar_DirectSet m_Cvar_DirectSet;
|
CRehldsHookRegistry_Cvar_DirectSet m_Cvar_DirectSet;
|
||||||
CRehldsHookRegistry_SV_EstablishTimeBase m_SV_EstablishTimeBase;
|
CRehldsHookRegistry_SV_EstablishTimeBase m_SV_EstablishTimeBase;
|
||||||
CRehldsHookRegistry_SV_Spawn_f m_SV_Spawn_f;
|
CRehldsHookRegistry_SV_Spawn_f m_SV_Spawn_f;
|
||||||
|
CRehldsHookRegistry_SV_CreatePacketEntities m_SV_CreatePacketEntities;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect();
|
||||||
@ -251,6 +256,7 @@ public:
|
|||||||
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet();
|
virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet();
|
||||||
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase();
|
virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase();
|
||||||
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f();
|
virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f();
|
||||||
|
virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CRehldsHookchains g_RehldsHookchains;
|
extern CRehldsHookchains g_RehldsHookchains;
|
||||||
|
@ -199,6 +199,11 @@ const char* EXT_FUNC CRehldsServerData::GetName() {
|
|||||||
return g_psv.name;
|
return g_psv.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EXT_FUNC CRehldsServerData::SetName(const char* name) {
|
||||||
|
Q_strncpy(g_psv.name, name, ARRAYSIZE(g_psv.name) - 1);
|
||||||
|
g_psv.name[ARRAYSIZE(g_psv.name) - 1] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
uint32 EXT_FUNC CRehldsServerData::GetWorldmapCrc() {
|
uint32 EXT_FUNC CRehldsServerData::GetWorldmapCrc() {
|
||||||
return g_psv.worldmapCRC;
|
return g_psv.worldmapCRC;
|
||||||
}
|
}
|
||||||
@ -285,3 +290,11 @@ IGameClient* GetRehldsApiClient(client_t* cl)
|
|||||||
|
|
||||||
return g_GameClients[idx];
|
return g_GameClients[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ISteamGameServer* EXT_FUNC CRehldsServerData::GetSteamGameServer() {
|
||||||
|
return ::SteamGameServer();
|
||||||
|
}
|
||||||
|
|
||||||
|
netadr_t* EXT_FUNC CRehldsServerData::GetNetFrom() {
|
||||||
|
return &net_from;
|
||||||
|
}
|
||||||
|
@ -131,6 +131,9 @@ public:
|
|||||||
virtual double GetTime();
|
virtual double GetTime();
|
||||||
virtual void SetResourcesNum(int num);
|
virtual void SetResourcesNum(int num);
|
||||||
virtual struct resource_s *GetResource(int index);
|
virtual struct resource_s *GetResource(int index);
|
||||||
|
virtual void SetName(const char* name);
|
||||||
|
virtual ISteamGameServer *GetSteamGameServer();
|
||||||
|
virtual netadr_t *GetNetFrom();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern CGameClient** g_GameClients;
|
extern CGameClient** g_GameClients;
|
||||||
|
Loading…
Reference in New Issue
Block a user