Move the rest of the translation to CServer

This commit is contained in:
Learath 2020-04-13 16:47:56 +03:00
parent b0e5a37fa9
commit f7e9df7abf
2 changed files with 37 additions and 39 deletions

View file

@ -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();

View file

@ -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;