From addfe47d4c5784307ebd32f0233105a7e02bf95f Mon Sep 17 00:00:00 2001 From: HMH Date: Sat, 3 May 2014 02:30:05 +0200 Subject: [PATCH] fix correct dummy-tunings now --- src/engine/client.h | 2 +- src/engine/client/client.cpp | 35 ++++++++++++++++++++++++++++++++-- src/engine/client/client.h | 1 + src/game/client/gameclient.cpp | 9 ++++++--- src/game/client/gameclient.h | 2 +- 5 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/engine/client.h b/src/engine/client.h index 7ecce621d..593914e10 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -169,7 +169,7 @@ public: virtual void OnRender() = 0; virtual void OnStateChange(int NewState, int OldState) = 0; virtual void OnConnected() = 0; - virtual void OnMessage(int MsgID, CUnpacker *pUnpacker) = 0; + virtual void OnMessage(int MsgID, CUnpacker *pUnpacker, bool IsDummy = 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 a70148e69..63705d009 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1735,6 +1735,37 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket) } } +void CClient::ProcessServerPacketDummy(CNetChunk *pPacket) +{ + CUnpacker Unpacker; + Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize); + + // unpack msgid and system flag + int Msg = Unpacker.GetInt(); + int Sys = Msg&1; + Msg >>= 1; + + if(Unpacker.Error()) + return; + + if(Sys) + { + // system message + if(Msg == NETMSG_MAP_CHANGE || Msg == NETMSG_MAP_DATA || Msg == NETMSG_PING || Msg == NETMSG_RCON_CMD_ADD || Msg == NETMSG_RCON_CMD_REM || Msg == NETMSG_RCON_AUTH_STATUS || Msg == NETMSG_RCON_LINE || Msg == NETMSG_PING_REPLY || Msg == NETMSG_INPUTTIMING || Msg == NETMSG_SNAP || Msg == NETMSG_SNAPSINGLE || Msg == NETMSG_SNAPEMPTY) + { + return; // no need of all that stuff for the dummy + } + else if(Msg == NETMSG_CON_READY) + { + GameClient()->OnConnected(); + } + } + else + { + GameClient()->OnMessage(Msg, &Unpacker, 1); + } +} + void CClient::PumpNetwork() { for(int i=0; i<2; i++) @@ -1779,12 +1810,12 @@ void CClient::PumpNetwork() if(g_Config.m_ClDummy) ProcessServerPacket(&Packet); //self else - ProcessConnlessPacket(&Packet); //multiclient + ProcessServerPacketDummy(&Packet); //multiclient } else { if(g_Config.m_ClDummy) - ProcessConnlessPacket(&Packet); //multiclient + ProcessServerPacketDummy(&Packet); //multiclient else ProcessServerPacket(&Packet); //self } diff --git a/src/engine/client/client.h b/src/engine/client/client.h index 19772a7e3..8ef475f72 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -280,6 +280,7 @@ public: void ProcessConnlessPacket(CNetChunk *pPacket); void ProcessServerPacket(CNetChunk *pPacket); + void ProcessServerPacketDummy(CNetChunk *pPacket); virtual int MapDownloadAmount() { return m_MapdownloadAmount; } virtual int MapDownloadTotalsize() { return m_MapdownloadTotalsize; } diff --git a/src/game/client/gameclient.cpp b/src/game/client/gameclient.cpp index 2950b58d3..7c6a414d6 100644 --- a/src/game/client/gameclient.cpp +++ b/src/game/client/gameclient.cpp @@ -593,10 +593,10 @@ void CGameClient::OnRelease() m_All.m_paComponents[i]->OnRelease(); } -void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) +void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy) { // special messages - if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE) + if(MsgId == NETMSGTYPE_SV_EXTRAPROJECTILE && !IsDummy) { int Num = pUnpacker->GetInt(); @@ -631,9 +631,12 @@ void CGameClient::OnMessage(int MsgId, CUnpacker *pUnpacker) m_ServerMode = SERVERMODE_PURE; // apply new tuning - m_Tuning[g_Config.m_ClDummy] = NewTuning; + m_Tuning[IsDummy ? !g_Config.m_ClDummy : g_Config.m_ClDummy] = NewTuning; return; } + + if(IsDummy) + return; // no need of all that stuff for the dummy void *pRawMsg = m_NetObjHandler.SecureUnpackMsg(MsgId, pUnpacker); if(!pRawMsg) diff --git a/src/game/client/gameclient.h b/src/game/client/gameclient.h index 0fcb11b50..7b3f3b743 100644 --- a/src/game/client/gameclient.h +++ b/src/game/client/gameclient.h @@ -219,7 +219,7 @@ public: virtual void OnInit(); virtual void OnConsoleInit(); virtual void OnStateChange(int NewState, int OldState); - virtual void OnMessage(int MsgId, CUnpacker *pUnpacker); + virtual void OnMessage(int MsgId, CUnpacker *pUnpacker, bool IsDummy = 0); virtual void OnNewSnapshot(); virtual void OnPredict(); virtual void OnActivateEditor();