diff --git a/rehlds/engine/server.h b/rehlds/engine/server.h index a86c0e8..131d1fe 100644 --- a/rehlds/engine/server.h +++ b/rehlds/engine/server.h @@ -719,6 +719,7 @@ void SV_WriteDeltaHeader(int num, qboolean remove, qboolean custom, int *numbase void SV_InvokeCallback(void); 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_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); qboolean SV_ShouldUpdatePing(client_t *client); NOXREF qboolean SV_HasEventsInQueue(client_t *client); diff --git a/rehlds/engine/sv_main.cpp b/rehlds/engine/sv_main.cpp index bb0f6cb..aa07b94 100644 --- a/rehlds/engine/sv_main.cpp +++ b/rehlds/engine/sv_main.cpp @@ -2385,7 +2385,7 @@ void EXT_FUNC SV_ConnectClient_internal(void) Steam_NotifyClientDisconnect(client); if ((client->active || client->spawned) && client->edict) gEntityInterface.pfnClientDisconnect(client->edict); - + Con_Printf("%s:reconnect\n", NET_AdrToString(adr)); } else @@ -2468,7 +2468,7 @@ void EXT_FUNC SV_ConnectClient_internal(void) if (g_modfuncs.m_pfnConnectClient) 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_messagetime = realtime + 0.05; 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; } -/* ../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) +{ + return g_RehldsHookchains.m_SV_CreatePacketEntities.callChain(SV_CreatePacketEntities_api, type, GetRehldsApiClient(client), to, msg); +} + +/* ../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; int oldindex; diff --git a/rehlds/public/rehlds/rehlds_api.h b/rehlds/public/rehlds/rehlds_api.h index 728cfd1..8ecbde2 100644 --- a/rehlds/public/rehlds/rehlds_api.h +++ b/rehlds/public/rehlds/rehlds_api.h @@ -35,7 +35,7 @@ #include "model.h" #define REHLDS_API_VERSION_MAJOR 2 -#define REHLDS_API_VERSION_MINOR 11 +#define REHLDS_API_VERSION_MINOR 12 //Steam_NotifyClientConnect hook typedef IHookChain IRehldsHook_Steam_NotifyClientConnect; @@ -181,6 +181,10 @@ typedef IVoidHookChainRegistry IRehld typedef IVoidHookChain<> IRehldsHook_SV_Spawn_f; typedef IVoidHookChainRegistry<> IRehldsHookRegistry_SV_Spawn_f; +//SV_CreatePacketEntities hook +typedef IHookChain IRehldsHook_SV_CreatePacketEntities; +typedef IHookChainRegistry IRehldsHookRegistry_SV_CreatePacketEntities; + class IRehldsHookchains { public: virtual ~IRehldsHookchains() { } @@ -221,6 +225,7 @@ public: virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet() = 0; virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase() = 0; virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f() = 0; + virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities() = 0; }; struct RehldsFuncs_t { @@ -283,4 +288,4 @@ public: virtual IRehldsFlightRecorder* GetFlightRecorder() = 0; }; -#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001" \ No newline at end of file +#define VREHLDS_HLDS_API_VERSION "VREHLDS_HLDS_API_VERSION001" diff --git a/rehlds/public/rehlds/rehlds_interfaces.h b/rehlds/public/rehlds/rehlds_interfaces.h index 261460e..7d6a086 100644 --- a/rehlds/public/rehlds/rehlds_interfaces.h +++ b/rehlds/public/rehlds/rehlds_interfaces.h @@ -126,4 +126,7 @@ public: virtual double GetTime() = 0; virtual void SetResourcesNum(int num) = 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; }; diff --git a/rehlds/rehlds/rehlds_api_impl.cpp b/rehlds/rehlds/rehlds_api_impl.cpp index 0b05244..f1e74a8 100644 --- a/rehlds/rehlds/rehlds_api_impl.cpp +++ b/rehlds/rehlds/rehlds_api_impl.cpp @@ -372,6 +372,10 @@ IRehldsHookRegistry_SV_Spawn_f* CRehldsHookchains::SV_Spawn_f() { return &m_SV_Spawn_f; } +IRehldsHookRegistry_SV_CreatePacketEntities* CRehldsHookchains::SV_CreatePacketEntities() { + return &m_SV_CreatePacketEntities; +} + int EXT_FUNC CRehldsApi::GetMajorVersion() { return REHLDS_API_VERSION_MAJOR; diff --git a/rehlds/rehlds/rehlds_api_impl.h b/rehlds/rehlds/rehlds_api_impl.h index 1f00b65..246a4f0 100644 --- a/rehlds/rehlds/rehlds_api_impl.h +++ b/rehlds/rehlds/rehlds_api_impl.h @@ -175,6 +175,10 @@ typedef IVoidHookChainRegistryImpl CR typedef IVoidHookChainImpl<> CRehldsHook_SV_Spawn_f; typedef IVoidHookChainRegistryImpl<> CRehldsHookRegistry_SV_Spawn_f; +//SV_CreatePacketEntities hook +typedef IHookChainImpl CRehldsHook_SV_CreatePacketEntities; +typedef IHookChainRegistryImpl CRehldsHookRegistry_SV_CreatePacketEntities; + class CRehldsHookchains : public IRehldsHookchains { public: CRehldsHookRegistry_Steam_NotifyClientConnect m_Steam_NotifyClientConnect; @@ -213,6 +217,7 @@ public: CRehldsHookRegistry_Cvar_DirectSet m_Cvar_DirectSet; CRehldsHookRegistry_SV_EstablishTimeBase m_SV_EstablishTimeBase; CRehldsHookRegistry_SV_Spawn_f m_SV_Spawn_f; + CRehldsHookRegistry_SV_CreatePacketEntities m_SV_CreatePacketEntities; public: virtual IRehldsHookRegistry_Steam_NotifyClientConnect* Steam_NotifyClientConnect(); @@ -251,6 +256,7 @@ public: virtual IRehldsHookRegistry_Cvar_DirectSet* Cvar_DirectSet(); virtual IRehldsHookRegistry_SV_EstablishTimeBase* SV_EstablishTimeBase(); virtual IRehldsHookRegistry_SV_Spawn_f* SV_Spawn_f(); + virtual IRehldsHookRegistry_SV_CreatePacketEntities* SV_CreatePacketEntities(); }; extern CRehldsHookchains g_RehldsHookchains; diff --git a/rehlds/rehlds/rehlds_interfaces_impl.cpp b/rehlds/rehlds/rehlds_interfaces_impl.cpp index 6be8cf4..886421b 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.cpp +++ b/rehlds/rehlds/rehlds_interfaces_impl.cpp @@ -199,6 +199,11 @@ const char* EXT_FUNC CRehldsServerData::GetName() { 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() { return g_psv.worldmapCRC; } @@ -285,3 +290,11 @@ IGameClient* GetRehldsApiClient(client_t* cl) return g_GameClients[idx]; } + +ISteamGameServer* EXT_FUNC CRehldsServerData::GetSteamGameServer() { + return ::SteamGameServer(); +} + +netadr_t* EXT_FUNC CRehldsServerData::GetNetFrom() { + return &net_from; +} diff --git a/rehlds/rehlds/rehlds_interfaces_impl.h b/rehlds/rehlds/rehlds_interfaces_impl.h index 76325e7..caab23c 100644 --- a/rehlds/rehlds/rehlds_interfaces_impl.h +++ b/rehlds/rehlds/rehlds_interfaces_impl.h @@ -131,6 +131,9 @@ public: virtual double GetTime(); virtual void SetResourcesNum(int num); virtual struct resource_s *GetResource(int index); + virtual void SetName(const char* name); + virtual ISteamGameServer *GetSteamGameServer(); + virtual netadr_t *GetNetFrom(); }; extern CGameClient** g_GameClients;