From 2963c30755969260ba7a69b98bb7acd0eb0f38e8 Mon Sep 17 00:00:00 2001 From: def Date: Mon, 20 Dec 2021 23:17:09 +0100 Subject: [PATCH] Fix run_on_join being run on normal player again (fixes #4494) --- src/engine/client.h | 4 +-- src/engine/client/client.cpp | 47 +++++++++++++++++----------------- src/engine/client/client.h | 6 ++--- src/game/client/gameclient.cpp | 2 +- 4 files changed, 29 insertions(+), 30 deletions(-) diff --git a/src/engine/client.h b/src/engine/client.h index 2a4227fc5..d2aed7f6a 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -134,7 +134,7 @@ public: virtual void Notify(const char *pTitle, const char *pMessage) = 0; // networking - virtual void EnterGame() = 0; + virtual void EnterGame(bool Dummy) = 0; // virtual const char *MapDownloadName() const = 0; @@ -243,7 +243,7 @@ public: virtual void OnUpdate() = 0; virtual void OnStateChange(int NewState, int OldState) = 0; virtual void OnConnected() = 0; - virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, bool IsDummy = 0) = 0; + virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, bool Dummy = 0) = 0; virtual void OnPredict() = 0; virtual void OnActivateEditor() = 0; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index b5ddb5c7a..c5f237259 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -452,10 +452,10 @@ void CClient::SendInfo() SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH); } -void CClient::SendEnterGame() +void CClient::SendEnterGame(bool Dummy) { CMsgPacker Msg(NETMSG_ENTERGAME, true); - SendMsg(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH); + SendMsgY(&Msg, MSGFLAG_VITAL | MSGFLAG_FLUSH, Dummy); } void CClient::SendReady() @@ -634,49 +634,48 @@ void CClient::SetState(int s) } // called when the map is loaded and we should init for a new round -void CClient::OnEnterGame() +void CClient::OnEnterGame(bool Dummy) { // reset input int i; for(i = 0; i < 200; i++) { - m_aInputs[0][i].m_Tick = -1; - m_aInputs[1][i].m_Tick = -1; + m_aInputs[Dummy][i].m_Tick = -1; } - m_CurrentInput[0] = 0; - m_CurrentInput[1] = 0; + m_CurrentInput[Dummy] = 0; // reset snapshots - m_aSnapshots[g_Config.m_ClDummy][SNAP_CURRENT] = 0; - m_aSnapshots[g_Config.m_ClDummy][SNAP_PREV] = 0; - m_SnapshotStorage[g_Config.m_ClDummy].PurgeAll(); - m_ReceivedSnapshots[g_Config.m_ClDummy] = 0; - m_SnapshotParts[g_Config.m_ClDummy] = 0; - m_PredTick[g_Config.m_ClDummy] = 0; - m_CurrentRecvTick[g_Config.m_ClDummy] = 0; - m_CurGameTick[g_Config.m_ClDummy] = 0; - m_PrevGameTick[g_Config.m_ClDummy] = 0; + m_aSnapshots[Dummy][SNAP_CURRENT] = 0; + m_aSnapshots[Dummy][SNAP_PREV] = 0; + m_SnapshotStorage[Dummy].PurgeAll(); + m_ReceivedSnapshots[Dummy] = 0; + m_SnapshotParts[Dummy] = 0; + m_PredTick[Dummy] = 0; + m_CurrentRecvTick[Dummy] = 0; + m_CurGameTick[Dummy] = 0; + m_PrevGameTick[Dummy] = 0; - if(g_Config.m_ClDummy == 0) + if(Dummy == 0) + { m_LastDummyConnectTime = 0; - - GameClient()->OnEnterGame(); + GameClient()->OnEnterGame(); + } } -void CClient::EnterGame() +void CClient::EnterGame(bool Dummy) { if(State() == IClient::STATE_DEMOPLAYBACK) return; + m_CodeRunAfterJoin[Dummy] = false; + // now we will wait for two snapshots // to finish the connection - SendEnterGame(); - OnEnterGame(); + SendEnterGame(Dummy); + OnEnterGame(Dummy); ServerInfoRequest(); // fresh one for timeout protection m_CurrentServerNextPingTime = time_get() + time_freq() / 2; - m_CodeRunAfterJoin[0] = false; - m_CodeRunAfterJoin[1] = false; } void GenerateTimeoutCode(char *pBuffer, unsigned Size, char *pSeed, const NETADDR &Addr, bool Dummy) diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 5a1eecb55..295419584 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -301,7 +301,7 @@ public: virtual int SendMsgY(CMsgPacker *pMsg, int Flags, int NetClient = 1); void SendInfo(); - void SendEnterGame(); + void SendEnterGame(bool Dummy); void SendReady(); void SendMapRequest(); @@ -329,8 +329,8 @@ public: void SetState(int s); // called when the map is loaded and we should init for a new round - void OnEnterGame(); - virtual void EnterGame(); + void OnEnterGame(bool Dummy); + virtual void EnterGame(bool Dummy); virtual void Connect(const char *pAddress, const char *pPassword = NULL); void DisconnectWithReason(const char *pReason); diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 6cea6399c..1b639375a 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -735,7 +735,7 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) if(MsgId == NETMSGTYPE_SV_READYTOENTER) { - Client()->EnterGame(); + Client()->EnterGame(IsDummy ? !g_Config.m_ClDummy : g_Config.m_ClDummy); } else if(MsgId == NETMSGTYPE_SV_EMOTICON) {