From ca49b33f808ee7594c0a8bccdc017393906d0554 Mon Sep 17 00:00:00 2001 From: Garey Akhmetshin Date: Sat, 13 Mar 2021 05:23:01 +0500 Subject: [PATCH] Clone signon data between worlds --- rehlds/HLTV/Core/src/World.cpp | 9 ++++++++- rehlds/HLTV/Core/src/World.h | 16 +++++++++++----- rehlds/HLTV/Proxy/src/Proxy.cpp | 9 +++++++-- rehlds/public/HLTV/IWorld.h | 1 + 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/rehlds/HLTV/Core/src/World.cpp b/rehlds/HLTV/Core/src/World.cpp index 8fb764f..3b90a3f 100644 --- a/rehlds/HLTV/Core/src/World.cpp +++ b/rehlds/HLTV/Core/src/World.cpp @@ -1449,6 +1449,14 @@ bool World::AddSignonData(unsigned char type, unsigned char *data, int size) return m_SignonData.IsOverflowed(); } + +bool World::AddSignonData(unsigned char* data, int size) +{ + m_SignonData.WriteBuf(data, size); + + return m_SignonData.IsOverflowed(); +} + int World::FindUserMsgByName(char *name) { for (UserMsg *pList = m_ClientUserMsgs; pList; pList = pList->next) @@ -2376,6 +2384,5 @@ delta_t *World::GetEntityDelta() const { delta_t *World::GetWeaponDelta() const { return Delta::m_WeaponDelta; } - EXPOSE_INTERFACE_FN(CreateWorld, World, WORLD_INTERFACE_VERSION); #endif // HOOK_HLTV diff --git a/rehlds/HLTV/Core/src/World.h b/rehlds/HLTV/Core/src/World.h index 09e98dd..ed6d1d7 100644 --- a/rehlds/HLTV/Core/src/World.h +++ b/rehlds/HLTV/Core/src/World.h @@ -120,12 +120,15 @@ public: EXT_FUNC bool AddResource(resource_t *resource); EXT_FUNC void AddLightStyle(int index, char *style); EXT_FUNC bool AddSignonData(unsigned char type, unsigned char *data, int size); + bool AddSignonData(unsigned char* data, int size); EXT_FUNC bool AddUserMessage(int msgNumber, int size, char *name); EXT_FUNC void AddBaselineEntity(int index, entity_state_t *ent); EXT_FUNC void AddInstancedBaselineEntity(int index, entity_state_t *ent); EXT_FUNC void UpdatePlayer(int playerNum, int userId, char *infostring, char *hashedcdkey); - EXT_FUNC void WriteFrame(frame_t *frame, unsigned int lastFrameSeqnr, BitBuffer *reliableStream, BitBuffer *unreliableStream, unsigned int deltaSeqNr, unsigned int clientDelta, bool addVoice); + EXT_FUNC void WriteFrame(frame_t *frame, unsigned int lastFrameSeqnr, BitBuffer *reliableStream, + BitBuffer *unreliableStream, unsigned int deltaSeqNr, unsigned int clientDelta, + bool addVoice); EXT_FUNC void WriteNewData(BitBuffer *stream); EXT_FUNC void WriteClientUpdate(BitBuffer *stream, int playerIndex); EXT_FUNC void WriteMovevars(BitBuffer *stream); @@ -139,7 +142,8 @@ public: private: int CompressFrame(frame_t *from, BitBuffer *stream); - int ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &numbase, bool &newbl, int &newblindex, bool full, int &offset); + int ParseDeltaHeader(BitBuffer *stream, bool &remove, bool &custom, int &numbase, bool &newbl, int &newblindex, + bool full, int &offset); void SetDirector(IDirector *director); void SetTimeScale(float scale); void SetGameGroupAddress(NetAddress *addr); @@ -158,7 +162,8 @@ private: void WritePacketEntities(BitBuffer *stream, frame_t *frame, frame_t *deltaframe); bool WriteDeltaEntities(BitBuffer *stream, frame_t *fullFrame, unsigned int deltaSeqNr, unsigned int clientDelta); - enum WorldState { + enum WorldState + { WORLD_UNDEFINED, WORLD_INITIALIZING, WORLD_DISCONNECTED, @@ -188,9 +193,9 @@ private: delta_t *GetEventDelta() const; delta_t *GetClientDelta() const; delta_t *GetEntityDelta() const; - delta_t *GetWeaponDelta() const; delta_t *GetDeltaEncoder(int index, bool custom); bool IsDeltaEncoder() const; + delta_t* GetWeaponDelta() const; protected: bool m_IsPaused; @@ -209,7 +214,8 @@ protected: int m_ViewEntity; serverinfo_t m_DetailedServerInfo; - enum { + enum + { MAX_ENTITIES = 1380, MAX_INSTANCED_BASELINES = 64, MAX_FRAME_CACHE = 32, diff --git a/rehlds/HLTV/Proxy/src/Proxy.cpp b/rehlds/HLTV/Proxy/src/Proxy.cpp index e36e87b..1a45d5f 100644 --- a/rehlds/HLTV/Proxy/src/Proxy.cpp +++ b/rehlds/HLTV/Proxy/src/Proxy.cpp @@ -89,6 +89,8 @@ EXPOSE_SINGLE_INTERFACE(Proxy, IProxy, PROXY_INTERFACE_VERSION); #ifdef HLTV_FIXES void Proxy::AddNextWorld() { + BitBuffer temp_buff; + temp_buff.Resize(0x8000); static int num_alloc = 0; static char instance[64]; snprintf(instance, sizeof(instance), "AddNextWorld_%d", num_alloc++); @@ -99,8 +101,11 @@ void Proxy::AddNextWorld() return; } + m_World->WriteSigonData(&temp_buff); + nextWorld->AddSignonData(temp_buff.GetData(), temp_buff.CurrentSize()); + nextWorld->RegisterListener(this); - + m_Worlds.AddTail(nextWorld); if (m_DemoClient.IsActive()) @@ -1473,7 +1478,7 @@ void Proxy::ReceiveSignal(ISystemModule *module, unsigned int signal, void *data case 6: { #ifdef HLTV_FIXES - if (!m_IsFinishingBroadcast && m_ClientDelay > 0.0) + if (!m_IsFinishingBroadcast && m_ClientDelay > 0.f) { //If we finished broadcast we need to get frames from next "World" (Next server map) AddNextWorld(); diff --git a/rehlds/public/HLTV/IWorld.h b/rehlds/public/HLTV/IWorld.h index 8e24c26..d232492 100644 --- a/rehlds/public/HLTV/IWorld.h +++ b/rehlds/public/HLTV/IWorld.h @@ -144,6 +144,7 @@ public: virtual bool AddResource(resource_t *resource) = 0; virtual void AddLightStyle(int index, char *style) = 0; virtual bool AddSignonData(unsigned char type, unsigned char *data, int size) = 0; + virtual bool AddSignonData(unsigned char* data, int size) = 0; virtual bool AddUserMessage(int msgNumber, int size, char *name) = 0; virtual void AddBaselineEntity(int index, entity_state_t *ent) = 0; virtual void AddInstancedBaselineEntity(int index, entity_state_t *ent) = 0;