From f7e9df7abfba591f68b4b11293a90ea95ba5d3c7 Mon Sep 17 00:00:00 2001 From: Learath Date: Mon, 13 Apr 2020 16:47:56 +0300 Subject: [PATCH] Move the rest of the translation to CServer --- src/engine/server/server.cpp | 37 ++++++++++++++++++++++++++ src/engine/shared/network_server.cpp | 39 ---------------------------- 2 files changed, 37 insertions(+), 39 deletions(-) diff --git a/src/engine/server/server.cpp b/src/engine/server/server.cpp index e76604567..5ddbb1229 100644 --- a/src/engine/server/server.cpp +++ b/src/engine/server/server.cpp @@ -1241,6 +1241,38 @@ void CServer::UpdateClientRconCommands() } } +static inline int MsgFromSixup(int Msg, bool System) +{ + if(System) + { + if(Msg == NETMSG_INFO) + ; + else if(Msg >= 18 && Msg <= 28) + Msg = NETMSG_READY + Msg - 18; + else + { + dbg_msg("net", "DROP recv sys %d", Msg); + return -1; + } + } + else + { + if(Msg >= 24 && Msg <= 27) + Msg = NETMSGTYPE_CL_SAY + Msg - 24; + else if(Msg == 28) + Msg = NETMSGTYPE_CL_KILL; + else if(Msg >= 30 && Msg <= 32) + Msg = NETMSGTYPE_CL_EMOTICON + Msg - 30; + else + { + dbg_msg("net", "DROP recv msg %d", Msg); + return -1; + } + } + + return Msg; +} + void CServer::ProcessClientPacket(CNetChunk *pPacket) { int ClientID = pPacket->m_ClientID; @@ -1266,6 +1298,11 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket) return; } + if(m_aClients[ClientID].m_Sixup && (Msg = MsgFromSixup(Msg, Sys)) < 0) + { + return; + } + if(g_Config.m_SvNetlimit && Msg != NETMSG_REQUEST_MAP_DATA) { int64 Now = time_get(); diff --git a/src/engine/shared/network_server.cpp b/src/engine/shared/network_server.cpp index 69c8807e4..40bb97c43 100644 --- a/src/engine/shared/network_server.cpp +++ b/src/engine/shared/network_server.cpp @@ -42,41 +42,6 @@ unsigned char g_aDummyMapData[] = { 0xc2, 0x00, 0x00, 0x38, 0x00, 0x05 }; -static unsigned char MsgTypeFromSixup(unsigned char Byte) -{ - unsigned char Six = Byte>>1; - unsigned char Msg; - if (Byte&1) - { - if(Six == 1) - Msg = NETMSG_INFO; - else if(Six >= 18 && Six <= 28) - Msg = NETMSG_READY + Six - 18; - else - { - dbg_msg("net", "DROP recv sys %d", Six); - return 0; - } - //dbg_msg("net", "recv sys %d <- %d", Msg, Six); - } - else - { - if(Six >= 24 && Six <= 27) - Msg = NETMSGTYPE_CL_SAY + Six - 24; - else if(Six == 28) - Msg = NETMSGTYPE_CL_KILL; - else if(Six >= 30 && Six <= 32) - Msg = NETMSGTYPE_CL_EMOTICON + Six - 30; - else - { - dbg_msg("net", "DROP recv msg %d", Six); - return 0; - } - //dbg_msg("net", "recv msg %d <- %d", Msg, Six); - } - return (Msg<<1) | (Byte&1); -} - static SECURITY_TOKEN ToSecurityToken(const unsigned char *pData) { return (int)pData[0] | (pData[1] << 8) | (pData[2] << 16) | (pData[3] << 24); @@ -657,11 +622,7 @@ int CNetServer::Recv(CNetChunk *pChunk) // check for a chunk if(m_RecvUnpacker.FetchChunk(pChunk)) - { - if(m_aSlots[pChunk->m_ClientID].m_Connection.m_Sixup) - *(unsigned char*)pChunk->m_pData = MsgTypeFromSixup(*(unsigned char*)pChunk->m_pData); return 1; - } // TODO: empty the recvinfo unsigned char *pData;