2040: fixed faulty message id r=heinrich5991 a=ChillerDragon

(cherry picked from commit 9023796d27)

Co-authored-by: oy <Tom_Adams@web.de>
This commit is contained in:
bors[bot] 2020-01-25 12:40:14 +00:00 committed by GitHub
commit 749929431a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 93 additions and 133 deletions

View file

@ -160,12 +160,12 @@ public:
virtual void SnapSetStaticsize(int ItemType, int Size) = 0; virtual void SnapSetStaticsize(int ItemType, int Size) = 0;
virtual int SendMsg(CMsgPacker *pMsg, int Flags) = 0; virtual int SendMsg(CMsgPacker *pMsg, int Flags) = 0;
virtual int SendMsgExY(CMsgPacker *pMsg, int Flags, bool System=true, int NetClient=1) = 0; virtual int SendMsgY(CMsgPacker *pMsg, int Flags, int NetClient=1) = 0;
template<class T> template<class T>
int SendPackMsg(T *pMsg, int Flags) int SendPackMsg(T *pMsg, int Flags)
{ {
CMsgPacker Packer(pMsg->MsgID()); CMsgPacker Packer(pMsg->MsgID(), false);
if(pMsg->Pack(&Packer)) if(pMsg->Pack(&Packer))
return -1; return -1;
return SendMsg(&Packer, Flags); return SendMsg(&Packer, Flags);

View file

@ -362,11 +362,6 @@ CClient::CClient() : m_DemoPlayer(&m_SnapshotDelta)
// ----- send functions ----- // ----- send functions -----
int CClient::SendMsg(CMsgPacker *pMsg, int Flags) int CClient::SendMsg(CMsgPacker *pMsg, int Flags)
{
return SendMsgEx(pMsg, Flags, false);
}
int CClient::SendMsgEx(CMsgPacker *pMsg, int Flags, bool System)
{ {
CNetChunk Packet; CNetChunk Packet;
@ -374,21 +369,10 @@ int CClient::SendMsgEx(CMsgPacker *pMsg, int Flags, bool System)
return 0; return 0;
mem_zero(&Packet, sizeof(CNetChunk)); mem_zero(&Packet, sizeof(CNetChunk));
Packet.m_ClientID = 0; Packet.m_ClientID = 0;
Packet.m_pData = pMsg->Data(); Packet.m_pData = pMsg->Data();
Packet.m_DataSize = pMsg->Size(); Packet.m_DataSize = pMsg->Size();
// HACK: modify the message id in the packet and store the system flag
if(*((unsigned char*)Packet.m_pData) == 1 && System && Packet.m_DataSize == 1)
{
dbg_break();
}
*((unsigned char*)Packet.m_pData) <<= 1;
if(System)
*((unsigned char*)Packet.m_pData) |= 1;
if(Flags&MSGFLAG_VITAL) if(Flags&MSGFLAG_VITAL)
Packet.m_Flags |= NETSENDFLAG_VITAL; Packet.m_Flags |= NETSENDFLAG_VITAL;
if(Flags&MSGFLAG_FLUSH) if(Flags&MSGFLAG_FLUSH)
@ -411,23 +395,23 @@ int CClient::SendMsgEx(CMsgPacker *pMsg, int Flags, bool System)
void CClient::SendInfo() void CClient::SendInfo()
{ {
CMsgPacker Msg(NETMSG_INFO); CMsgPacker Msg(NETMSG_INFO, true);
Msg.AddString(GameClient()->NetVersion(), 128); Msg.AddString(GameClient()->NetVersion(), 128);
Msg.AddString(m_Password, 128); Msg.AddString(m_Password, 128);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
} }
void CClient::SendEnterGame() void CClient::SendEnterGame()
{ {
CMsgPacker Msg(NETMSG_ENTERGAME); CMsgPacker Msg(NETMSG_ENTERGAME, true);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
} }
void CClient::SendReady() void CClient::SendReady()
{ {
CMsgPacker Msg(NETMSG_READY); CMsgPacker Msg(NETMSG_READY, true);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
} }
void CClient::SendMapRequest() void CClient::SendMapRequest()
@ -435,9 +419,9 @@ void CClient::SendMapRequest()
if(m_MapdownloadFile) if(m_MapdownloadFile)
io_close(m_MapdownloadFile); io_close(m_MapdownloadFile);
m_MapdownloadFile = Storage()->OpenFile(m_aMapdownloadFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE); m_MapdownloadFile = Storage()->OpenFile(m_aMapdownloadFilename, IOFLAG_WRITE, IStorage::TYPE_SAVE);
CMsgPacker Msg(NETMSG_REQUEST_MAP_DATA); CMsgPacker Msg(NETMSG_REQUEST_MAP_DATA, true);
Msg.AddInt(m_MapdownloadChunk); Msg.AddInt(m_MapdownloadChunk);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
} }
void CClient::RconAuth(const char *pName, const char *pPassword) void CClient::RconAuth(const char *pName, const char *pPassword)
@ -448,18 +432,18 @@ void CClient::RconAuth(const char *pName, const char *pPassword)
if(pPassword != m_RconPassword) if(pPassword != m_RconPassword)
str_copy(m_RconPassword, pPassword, sizeof(m_RconPassword)); str_copy(m_RconPassword, pPassword, sizeof(m_RconPassword));
CMsgPacker Msg(NETMSG_RCON_AUTH); CMsgPacker Msg(NETMSG_RCON_AUTH, true);
Msg.AddString(pName, 32); Msg.AddString(pName, 32);
Msg.AddString(pPassword, 32); Msg.AddString(pPassword, 32);
Msg.AddInt(1); Msg.AddInt(1);
SendMsgEx(&Msg, MSGFLAG_VITAL); SendMsg(&Msg, MSGFLAG_VITAL);
} }
void CClient::Rcon(const char *pCmd) void CClient::Rcon(const char *pCmd)
{ {
CMsgPacker Msg(NETMSG_RCON_CMD); CMsgPacker Msg(NETMSG_RCON_CMD, true);
Msg.AddString(pCmd, 256); Msg.AddString(pCmd, 256);
SendMsgEx(&Msg, MSGFLAG_VITAL); SendMsg(&Msg, MSGFLAG_VITAL);
} }
bool CClient::ConnectionProblems() bool CClient::ConnectionProblems()
@ -469,16 +453,15 @@ bool CClient::ConnectionProblems()
void CClient::DirectInput(int *pInput, int Size) void CClient::DirectInput(int *pInput, int Size)
{ {
int i; CMsgPacker Msg(NETMSG_INPUT, true);
CMsgPacker Msg(NETMSG_INPUT);
Msg.AddInt(m_AckGameTick[g_Config.m_ClDummy]); Msg.AddInt(m_AckGameTick[g_Config.m_ClDummy]);
Msg.AddInt(m_PredTick[g_Config.m_ClDummy]); Msg.AddInt(m_PredTick[g_Config.m_ClDummy]);
Msg.AddInt(Size); Msg.AddInt(Size);
for(i = 0; i < Size/4; i++) for(int i = 0; i < Size/4; i++)
Msg.AddInt(pInput[i]); Msg.AddInt(pInput[i]);
SendMsgEx(&Msg, 0); SendMsg(&Msg, 0);
} }
void CClient::SendInput() void CClient::SendInput()
@ -508,7 +491,7 @@ void CClient::SendInput()
if(Size) if(Size)
{ {
// pack input // pack input
CMsgPacker Msg(NETMSG_INPUT); CMsgPacker Msg(NETMSG_INPUT, true);
Msg.AddInt(m_AckGameTick[i]); Msg.AddInt(m_AckGameTick[i]);
Msg.AddInt(m_PredTick[i]); Msg.AddInt(m_PredTick[i]);
Msg.AddInt(Size); Msg.AddInt(Size);
@ -524,7 +507,7 @@ void CClient::SendInput()
m_CurrentInput[i]++; m_CurrentInput[i]++;
m_CurrentInput[i] %= 200; m_CurrentInput[i] %= 200;
SendMsgExY(&Msg, MSGFLAG_FLUSH, true, i); SendMsgY(&Msg, MSGFLAG_FLUSH, i);
// ugly workaround for dummy. we need to send input with dummy to prevent // ugly workaround for dummy. we need to send input with dummy to prevent
// prediction time resets. but if we do it too often, then it's // prediction time resets. but if we do it too often, then it's
// impossible to use grenade with frozen dummy that gets hammered... // impossible to use grenade with frozen dummy that gets hammered...
@ -838,7 +821,7 @@ int CClient::GetCurrentRaceTime()
return (GameTick() - GameClient()->GetLastRaceTick()) / 50; return (GameTick() - GameClient()->GetLastRaceTick()) / 50;
} }
int CClient::SendMsgExY(CMsgPacker *pMsg, int Flags, bool System, int NetClient) int CClient::SendMsgY(CMsgPacker *pMsg, int Flags, int NetClient)
{ {
CNetChunk Packet; CNetChunk Packet;
@ -848,16 +831,6 @@ int CClient::SendMsgExY(CMsgPacker *pMsg, int Flags, bool System, int NetClient)
Packet.m_pData = pMsg->Data(); Packet.m_pData = pMsg->Data();
Packet.m_DataSize = pMsg->Size(); Packet.m_DataSize = pMsg->Size();
// HACK: modify the message id in the packet and store the system flag
if(*((unsigned char*)Packet.m_pData) == 1 && System && Packet.m_DataSize == 1)
{
dbg_break();
}
*((unsigned char*)Packet.m_pData) <<= 1;
if(System)
*((unsigned char*)Packet.m_pData) |= 1;
if(Flags&MSGFLAG_VITAL) if(Flags&MSGFLAG_VITAL)
Packet.m_Flags |= NETSENDFLAG_VITAL; Packet.m_Flags |= NETSENDFLAG_VITAL;
if(Flags&MSGFLAG_FLUSH) if(Flags&MSGFLAG_FLUSH)
@ -1541,7 +1514,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
{ {
CUnpacker Unpacker; CUnpacker Unpacker;
Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize); Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize);
CMsgPacker Packer(NETMSG_EX); CMsgPacker Packer(NETMSG_EX, true);
// unpack msgid and system flag // unpack msgid and system flag
int Msg; int Msg;
@ -1555,7 +1528,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
} }
else if(Result == UNPACKMESSAGE_ANSWER) else if(Result == UNPACKMESSAGE_ANSWER)
{ {
SendMsgEx(&Packer, MSGFLAG_VITAL, true); SendMsg(&Packer, MSGFLAG_VITAL);
} }
if(Sys) if(Sys)
@ -1709,9 +1682,9 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
// request new chunk // request new chunk
m_MapdownloadChunk++; m_MapdownloadChunk++;
CMsgPacker Msg(NETMSG_REQUEST_MAP_DATA); CMsgPacker Msg(NETMSG_REQUEST_MAP_DATA, true);
Msg.AddInt(m_MapdownloadChunk); Msg.AddInt(m_MapdownloadChunk);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH);
if(g_Config.m_Debug) if(g_Config.m_Debug)
{ {
@ -1727,8 +1700,8 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
} }
else if(Msg == NETMSG_PING) else if(Msg == NETMSG_PING)
{ {
CMsgPacker Msg(NETMSG_PING_REPLY); CMsgPacker Msg(NETMSG_PING_REPLY, true);
SendMsgEx(&Msg, 0); SendMsg(&Msg, 0);
} }
else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD) else if((pPacket->m_Flags&NET_CHUNKFLAG_VITAL) != 0 && Msg == NETMSG_RCON_CMD_ADD)
{ {
@ -1992,9 +1965,9 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket)
char aBuf[256]; char aBuf[256];
str_format(aBuf, sizeof(aBuf), "/timeout %s", m_aTimeoutCodes[g_Config.m_ClDummy]); str_format(aBuf, sizeof(aBuf), "/timeout %s", m_aTimeoutCodes[g_Config.m_ClDummy]);
Msg.m_pMessage = aBuf; Msg.m_pMessage = aBuf;
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID(), true);
Msg.Pack(&Packer); Msg.Pack(&Packer);
SendMsgExY(&Packer, MSGFLAG_VITAL, false, g_Config.m_ClDummy); SendMsgY(&Packer, MSGFLAG_VITAL, g_Config.m_ClDummy);
} }
} }
@ -2027,7 +2000,7 @@ void CClient::ProcessServerPacketDummy(CNetChunk *pPacket)
{ {
CUnpacker Unpacker; CUnpacker Unpacker;
Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize); Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize);
CMsgPacker Packer(NETMSG_EX); CMsgPacker Packer(NETMSG_EX, true);
// unpack msgid and system flag // unpack msgid and system flag
int Msg; int Msg;
@ -2041,7 +2014,7 @@ void CClient::ProcessServerPacketDummy(CNetChunk *pPacket)
} }
else if(Result == UNPACKMESSAGE_ANSWER) else if(Result == UNPACKMESSAGE_ANSWER)
{ {
SendMsgEx(&Packer, MSGFLAG_VITAL, true); SendMsg(&Packer, MSGFLAG_VITAL);
} }
if(Sys) if(Sys)
@ -2942,24 +2915,24 @@ void CClient::Run()
m_DummySendConnInfo = false; m_DummySendConnInfo = false;
// send client info // send client info
CMsgPacker MsgInfo(NETMSG_INFO); CMsgPacker MsgInfo(NETMSG_INFO, true);
MsgInfo.AddString(GameClient()->NetVersion(), 128); MsgInfo.AddString(GameClient()->NetVersion(), 128);
MsgInfo.AddString(m_Password, 128); MsgInfo.AddString(m_Password, 128);
SendMsgExY(&MsgInfo, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1); SendMsgY(&MsgInfo, MSGFLAG_VITAL|MSGFLAG_FLUSH, 1);
// update netclient // update netclient
m_NetClient[CLIENT_DUMMY].Update(); m_NetClient[CLIENT_DUMMY].Update();
// send ready // send ready
CMsgPacker MsgReady(NETMSG_READY); CMsgPacker MsgReady(NETMSG_READY, true);
SendMsgExY(&MsgReady, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1); SendMsgY(&MsgReady, MSGFLAG_VITAL|MSGFLAG_FLUSH, 1);
// startinfo // startinfo
GameClient()->SendDummyInfo(true); GameClient()->SendDummyInfo(true);
// send enter game an finish the connection // send enter game an finish the connection
CMsgPacker MsgEnter(NETMSG_ENTERGAME); CMsgPacker MsgEnter(NETMSG_ENTERGAME, true);
SendMsgExY(&MsgEnter, MSGFLAG_VITAL|MSGFLAG_FLUSH, true, 1); SendMsgY(&MsgEnter, MSGFLAG_VITAL|MSGFLAG_FLUSH, 1);
} }
// update input // update input
@ -3204,8 +3177,8 @@ void CClient::Con_Ping(IConsole::IResult *pResult, void *pUserData)
{ {
CClient *pSelf = (CClient *)pUserData; CClient *pSelf = (CClient *)pUserData;
CMsgPacker Msg(NETMSG_PING); CMsgPacker Msg(NETMSG_PING, true);
pSelf->SendMsgEx(&Msg, 0); pSelf->SendMsg(&Msg, 0);
pSelf->m_PingStartTime = time_get(); pSelf->m_PingStartTime = time_get();
} }

View file

@ -250,9 +250,8 @@ public:
// ----- send functions ----- // ----- send functions -----
virtual int SendMsg(CMsgPacker *pMsg, int Flags); virtual int SendMsg(CMsgPacker *pMsg, int Flags);
virtual int SendMsgExY(CMsgPacker *pMsg, int Flags, bool System=true, int NetClient=1); virtual int SendMsgY(CMsgPacker *pMsg, int Flags, int NetClient=1);
int SendMsgEx(CMsgPacker *pMsg, int Flags, bool System=true);
void SendInfo(); void SendInfo();
void SendEnterGame(); void SendEnterGame();
void SendReady(); void SendReady();

View file

@ -9,16 +9,16 @@
class CMsgPacker : public CPacker class CMsgPacker : public CPacker
{ {
public: public:
CMsgPacker(int Type) CMsgPacker(int Type, bool System=false)
{ {
Reset(); Reset();
if(Type < OFFSET_UUID) if(Type < OFFSET_UUID)
{ {
AddInt(Type); AddInt((Type<<1)|(System?1:0));
} }
else else
{ {
AddInt(0); // NETMSG_EX, NETMSGTYPE_EX AddInt((0<<1)|(System?1:0)); // NETMSG_EX, NETMSGTYPE_EX
g_UuidManager.PackUuid(Type, this); g_UuidManager.PackUuid(Type, this);
} }
} }

View file

@ -100,7 +100,7 @@ public:
template<class T> template<class T>
int SendPackMsgOne(T *pMsg, int Flags, int ClientID) int SendPackMsgOne(T *pMsg, int Flags, int ClientID)
{ {
CMsgPacker Packer(pMsg->MsgID()); CMsgPacker Packer(pMsg->MsgID(), false);
if(pMsg->Pack(&Packer)) if(pMsg->Pack(&Packer))
return -1; return -1;
return SendMsg(&Packer, Flags, ClientID); return SendMsg(&Packer, Flags, ClientID);

View file

@ -621,27 +621,16 @@ int CServer::DistinctClientCount()
} }
int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientID) int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientID)
{
return SendMsgEx(pMsg, Flags, ClientID, false);
}
int CServer::SendMsgEx(CMsgPacker *pMsg, int Flags, int ClientID, bool System)
{ {
CNetChunk Packet; CNetChunk Packet;
if(!pMsg) if(!pMsg)
return -1; return -1;
mem_zero(&Packet, sizeof(CNetChunk)); mem_zero(&Packet, sizeof(CNetChunk));
Packet.m_ClientID = ClientID; Packet.m_ClientID = ClientID;
Packet.m_pData = pMsg->Data(); Packet.m_pData = pMsg->Data();
Packet.m_DataSize = pMsg->Size(); Packet.m_DataSize = pMsg->Size();
// HACK: modify the message id in the packet and store the system flag
*((unsigned char*)Packet.m_pData) <<= 1;
if(System)
*((unsigned char*)Packet.m_pData) |= 1;
if(Flags&MSGFLAG_VITAL) if(Flags&MSGFLAG_VITAL)
Packet.m_Flags |= NETSENDFLAG_VITAL; Packet.m_Flags |= NETSENDFLAG_VITAL;
if(Flags&MSGFLAG_FLUSH) if(Flags&MSGFLAG_FLUSH)
@ -786,17 +775,17 @@ void CServer::DoSnapshot()
if(NumPackets == 1) if(NumPackets == 1)
{ {
CMsgPacker Msg(NETMSG_SNAPSINGLE); CMsgPacker Msg(NETMSG_SNAPSINGLE, true);
Msg.AddInt(m_CurrentGameTick); Msg.AddInt(m_CurrentGameTick);
Msg.AddInt(m_CurrentGameTick-DeltaTick); Msg.AddInt(m_CurrentGameTick-DeltaTick);
Msg.AddInt(Crc); Msg.AddInt(Crc);
Msg.AddInt(Chunk); Msg.AddInt(Chunk);
Msg.AddRaw(&aCompData[n*MaxSize], Chunk); Msg.AddRaw(&aCompData[n*MaxSize], Chunk);
SendMsgEx(&Msg, MSGFLAG_FLUSH, i, true); SendMsg(&Msg, MSGFLAG_FLUSH, i);
} }
else else
{ {
CMsgPacker Msg(NETMSG_SNAP); CMsgPacker Msg(NETMSG_SNAP, true);
Msg.AddInt(m_CurrentGameTick); Msg.AddInt(m_CurrentGameTick);
Msg.AddInt(m_CurrentGameTick-DeltaTick); Msg.AddInt(m_CurrentGameTick-DeltaTick);
Msg.AddInt(NumPackets); Msg.AddInt(NumPackets);
@ -804,16 +793,16 @@ void CServer::DoSnapshot()
Msg.AddInt(Crc); Msg.AddInt(Crc);
Msg.AddInt(Chunk); Msg.AddInt(Chunk);
Msg.AddRaw(&aCompData[n*MaxSize], Chunk); Msg.AddRaw(&aCompData[n*MaxSize], Chunk);
SendMsgEx(&Msg, MSGFLAG_FLUSH, i, true); SendMsg(&Msg, MSGFLAG_FLUSH, i);
} }
} }
} }
else else
{ {
CMsgPacker Msg(NETMSG_SNAPEMPTY); CMsgPacker Msg(NETMSG_SNAPEMPTY, true);
Msg.AddInt(m_CurrentGameTick); Msg.AddInt(m_CurrentGameTick);
Msg.AddInt(m_CurrentGameTick-DeltaTick); Msg.AddInt(m_CurrentGameTick-DeltaTick);
SendMsgEx(&Msg, MSGFLAG_FLUSH, i, true); SendMsg(&Msg, MSGFLAG_FLUSH, i);
} }
} }
} }
@ -970,9 +959,9 @@ int CServer::DelClientCallback(int ClientID, const char *pReason, void *pUser)
void CServer::SendRconType(int ClientID, bool UsernameReq) void CServer::SendRconType(int ClientID, bool UsernameReq)
{ {
CMsgPacker Msg(NETMSG_RCONTYPE); CMsgPacker Msg(NETMSG_RCONTYPE, true);
Msg.AddInt(UsernameReq); Msg.AddInt(UsernameReq);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
void CServer::GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pMapSha256, int *pMapCrc) void CServer::GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_DIGEST *pMapSha256, int *pMapCrc)
@ -985,28 +974,28 @@ void CServer::GetMapInfo(char *pMapName, int MapNameSize, int *pMapSize, SHA256_
void CServer::SendCapabilities(int ClientID) void CServer::SendCapabilities(int ClientID)
{ {
CMsgPacker Msg(NETMSG_CAPABILITIES); CMsgPacker Msg(NETMSG_CAPABILITIES, true);
Msg.AddInt(SERVERCAP_CURVERSION); // version Msg.AddInt(SERVERCAP_CURVERSION); // version
Msg.AddInt(SERVERCAPFLAG_DDNET | SERVERCAPFLAG_CHATTIMEOUTCODE); // flags Msg.AddInt(SERVERCAPFLAG_DDNET | SERVERCAPFLAG_CHATTIMEOUTCODE); // flags
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
void CServer::SendMap(int ClientID) void CServer::SendMap(int ClientID)
{ {
{ {
CMsgPacker Msg(NETMSG_MAP_DETAILS); CMsgPacker Msg(NETMSG_MAP_DETAILS, true);
Msg.AddString(GetMapName(), 0); Msg.AddString(GetMapName(), 0);
Msg.AddRaw(&m_CurrentMapSha256.data, sizeof(m_CurrentMapSha256.data)); Msg.AddRaw(&m_CurrentMapSha256.data, sizeof(m_CurrentMapSha256.data));
Msg.AddInt(m_CurrentMapCrc); Msg.AddInt(m_CurrentMapCrc);
Msg.AddInt(m_CurrentMapSize); Msg.AddInt(m_CurrentMapSize);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
{ {
CMsgPacker Msg(NETMSG_MAP_CHANGE); CMsgPacker Msg(NETMSG_MAP_CHANGE, true);
Msg.AddString(GetMapName(), 0); Msg.AddString(GetMapName(), 0);
Msg.AddInt(m_CurrentMapCrc); Msg.AddInt(m_CurrentMapCrc);
Msg.AddInt(m_CurrentMapSize); Msg.AddInt(m_CurrentMapSize);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID);
} }
m_aClients[ClientID].m_NextMapChunk = 0; m_aClients[ClientID].m_NextMapChunk = 0;
@ -1028,13 +1017,13 @@ void CServer::SendMapData(int ClientID, int Chunk)
Last = 1; Last = 1;
} }
CMsgPacker Msg(NETMSG_MAP_DATA); CMsgPacker Msg(NETMSG_MAP_DATA, true);
Msg.AddInt(Last); Msg.AddInt(Last);
Msg.AddInt(m_CurrentMapCrc); Msg.AddInt(m_CurrentMapCrc);
Msg.AddInt(Chunk); Msg.AddInt(Chunk);
Msg.AddInt(ChunkSize); Msg.AddInt(ChunkSize);
Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize); Msg.AddRaw(&m_pCurrentMapData[Offset], ChunkSize);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID);
if(g_Config.m_Debug) if(g_Config.m_Debug)
{ {
@ -1046,15 +1035,15 @@ void CServer::SendMapData(int ClientID, int Chunk)
void CServer::SendConnectionReady(int ClientID) void CServer::SendConnectionReady(int ClientID)
{ {
CMsgPacker Msg(NETMSG_CON_READY); CMsgPacker Msg(NETMSG_CON_READY, true);
SendMsgEx(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL|MSGFLAG_FLUSH, ClientID);
} }
void CServer::SendRconLine(int ClientID, const char *pLine) void CServer::SendRconLine(int ClientID, const char *pLine)
{ {
CMsgPacker Msg(NETMSG_RCON_LINE); CMsgPacker Msg(NETMSG_RCON_LINE, true);
Msg.AddString(pLine, 512); Msg.AddString(pLine, 512);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
void CServer::SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighted) void CServer::SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighted)
@ -1103,18 +1092,18 @@ void CServer::SendRconLineAuthed(const char *pLine, void *pUser, bool Highlighte
void CServer::SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientID) void CServer::SendRconCmdAdd(const IConsole::CCommandInfo *pCommandInfo, int ClientID)
{ {
CMsgPacker Msg(NETMSG_RCON_CMD_ADD); CMsgPacker Msg(NETMSG_RCON_CMD_ADD, true);
Msg.AddString(pCommandInfo->m_pName, IConsole::TEMPCMD_NAME_LENGTH); Msg.AddString(pCommandInfo->m_pName, IConsole::TEMPCMD_NAME_LENGTH);
Msg.AddString(pCommandInfo->m_pHelp, IConsole::TEMPCMD_HELP_LENGTH); Msg.AddString(pCommandInfo->m_pHelp, IConsole::TEMPCMD_HELP_LENGTH);
Msg.AddString(pCommandInfo->m_pParams, IConsole::TEMPCMD_PARAMS_LENGTH); Msg.AddString(pCommandInfo->m_pParams, IConsole::TEMPCMD_PARAMS_LENGTH);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
void CServer::SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientID) void CServer::SendRconCmdRem(const IConsole::CCommandInfo *pCommandInfo, int ClientID)
{ {
CMsgPacker Msg(NETMSG_RCON_CMD_REM); CMsgPacker Msg(NETMSG_RCON_CMD_REM, true);
Msg.AddString(pCommandInfo->m_pName, 256); Msg.AddString(pCommandInfo->m_pName, 256);
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
} }
void CServer::UpdateClientRconCommands() void CServer::UpdateClientRconCommands()
@ -1137,7 +1126,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
int ClientID = pPacket->m_ClientID; int ClientID = pPacket->m_ClientID;
CUnpacker Unpacker; CUnpacker Unpacker;
Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize); Unpacker.Reset(pPacket->m_pData, pPacket->m_DataSize);
CMsgPacker Packer(NETMSG_EX); CMsgPacker Packer(NETMSG_EX, true);
// unpack msgid and system flag // unpack msgid and system flag
int Msg; int Msg;
@ -1171,7 +1160,7 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
if(Result == UNPACKMESSAGE_ANSWER) if(Result == UNPACKMESSAGE_ANSWER)
{ {
SendMsgEx(&Packer, MSGFLAG_VITAL, ClientID, true); SendMsg(&Packer, MSGFLAG_VITAL, ClientID);
} }
if(Sys) if(Sys)
@ -1297,10 +1286,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
{ {
int TimeLeft = ((TickStartTime(IntendedTick)-time_get())*1000) / time_freq(); int TimeLeft = ((TickStartTime(IntendedTick)-time_get())*1000) / time_freq();
CMsgPacker Msg(NETMSG_INPUTTIMING); CMsgPacker Msg(NETMSG_INPUTTIMING, true);
Msg.AddInt(IntendedTick); Msg.AddInt(IntendedTick);
Msg.AddInt(TimeLeft); Msg.AddInt(TimeLeft);
SendMsgEx(&Msg, 0, ClientID, true); SendMsg(&Msg, 0, ClientID);
} }
m_aClients[ClientID].m_LastInputTick = IntendedTick; m_aClients[ClientID].m_LastInputTick = IntendedTick;
@ -1388,10 +1377,10 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
{ {
if(m_aClients[ClientID].m_Authed != AuthLevel) if(m_aClients[ClientID].m_Authed != AuthLevel)
{ {
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS); CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS, true);
Msg.AddInt(1); //authed Msg.AddInt(1); //authed
Msg.AddInt(1); //cmdlist Msg.AddInt(1); //cmdlist
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
m_aClients[ClientID].m_Authed = AuthLevel; // Keeping m_Authed around is unwise... m_aClients[ClientID].m_Authed = AuthLevel; // Keeping m_Authed around is unwise...
m_aClients[ClientID].m_AuthKey = KeySlot; m_aClients[ClientID].m_AuthKey = KeySlot;
@ -1451,8 +1440,8 @@ void CServer::ProcessClientPacket(CNetChunk *pPacket)
} }
else if(Msg == NETMSG_PING) else if(Msg == NETMSG_PING)
{ {
CMsgPacker Msg(NETMSG_PING_REPLY); CMsgPacker Msg(NETMSG_PING_REPLY, true);
SendMsgEx(&Msg, 0, ClientID, true); SendMsg(&Msg, 0, ClientID);
} }
else else
{ {
@ -2855,10 +2844,10 @@ void CServer::ConchainConsoleOutputLevelUpdate(IConsole::IResult *pResult, void
void CServer::LogoutClient(int ClientID, const char *pReason) void CServer::LogoutClient(int ClientID, const char *pReason)
{ {
CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS); CMsgPacker Msg(NETMSG_RCON_AUTH_STATUS, true);
Msg.AddInt(0); //authed Msg.AddInt(0); //authed
Msg.AddInt(0); //cmdlist Msg.AddInt(0); //cmdlist
SendMsgEx(&Msg, MSGFLAG_VITAL, ClientID, true); SendMsg(&Msg, MSGFLAG_VITAL, ClientID);
m_aClients[ClientID].m_AuthTries = 0; m_aClients[ClientID].m_AuthTries = 0;
m_aClients[ClientID].m_pRconCmdToSend = 0; m_aClients[ClientID].m_pRconCmdToSend = 0;

View file

@ -269,7 +269,6 @@ public:
int DistinctClientCount(); int DistinctClientCount();
virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID); virtual int SendMsg(CMsgPacker *pMsg, int Flags, int ClientID);
int SendMsgEx(CMsgPacker *pMsg, int Flags, int ClientID, bool System);
void DoSnapshot(); void DoSnapshot();

View file

@ -188,9 +188,9 @@ void CEmoticon::Emote(int Emoticon)
if(g_Config.m_ClDummyCopyMoves) if(g_Config.m_ClDummyCopyMoves)
{ {
CMsgPacker Msg(NETMSGTYPE_CL_EMOTICON); CMsgPacker Msg(NETMSGTYPE_CL_EMOTICON, false);
Msg.AddInt(Emoticon); Msg.AddInt(Emoticon);
Client()->SendMsgExY(&Msg, MSGFLAG_VITAL, false, !g_Config.m_ClDummy); Client()->SendMsgY(&Msg, MSGFLAG_VITAL, !g_Config.m_ClDummy);
} }
} }

View file

@ -1471,17 +1471,17 @@ void CGameClient::OnNewSnapshot()
if(!m_DDRaceMsgSent[0] && m_Snap.m_pLocalInfo) if(!m_DDRaceMsgSent[0] && m_Snap.m_pLocalInfo)
{ {
CMsgPacker Msg(NETMSGTYPE_CL_ISDDNET); CMsgPacker Msg(NETMSGTYPE_CL_ISDDNET, false);
Msg.AddInt(CLIENT_VERSIONNR); Msg.AddInt(CLIENT_VERSIONNR);
Client()->SendMsgExY(&Msg, MSGFLAG_VITAL,false, 0); Client()->SendMsgY(&Msg, MSGFLAG_VITAL, 0);
m_DDRaceMsgSent[0] = true; m_DDRaceMsgSent[0] = true;
} }
if(!m_DDRaceMsgSent[1] && m_Snap.m_pLocalInfo && Client()->DummyConnected()) if(!m_DDRaceMsgSent[1] && m_Snap.m_pLocalInfo && Client()->DummyConnected())
{ {
CMsgPacker Msg(NETMSGTYPE_CL_ISDDNET); CMsgPacker Msg(NETMSGTYPE_CL_ISDDNET, false);
Msg.AddInt(CLIENT_VERSIONNR); Msg.AddInt(CLIENT_VERSIONNR);
Client()->SendMsgExY(&Msg, MSGFLAG_VITAL,false, 1); Client()->SendMsgY(&Msg, MSGFLAG_VITAL, 1);
m_DDRaceMsgSent[1] = true; m_DDRaceMsgSent[1] = true;
} }
@ -1841,9 +1841,9 @@ void CGameClient::SendInfo(bool Start)
Msg.m_UseCustomColor = g_Config.m_ClPlayerUseCustomColor; Msg.m_UseCustomColor = g_Config.m_ClPlayerUseCustomColor;
Msg.m_ColorBody = g_Config.m_ClPlayerColorBody; Msg.m_ColorBody = g_Config.m_ClPlayerColorBody;
Msg.m_ColorFeet = g_Config.m_ClPlayerColorFeet; Msg.m_ColorFeet = g_Config.m_ClPlayerColorFeet;
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID(), false);
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0); Client()->SendMsgY(&Packer, MSGFLAG_VITAL, 0);
m_CheckInfo[0] = -1; m_CheckInfo[0] = -1;
} }
else else
@ -1856,9 +1856,9 @@ void CGameClient::SendInfo(bool Start)
Msg.m_UseCustomColor = g_Config.m_ClPlayerUseCustomColor; Msg.m_UseCustomColor = g_Config.m_ClPlayerUseCustomColor;
Msg.m_ColorBody = g_Config.m_ClPlayerColorBody; Msg.m_ColorBody = g_Config.m_ClPlayerColorBody;
Msg.m_ColorFeet = g_Config.m_ClPlayerColorFeet; Msg.m_ColorFeet = g_Config.m_ClPlayerColorFeet;
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID(), false);
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 0); Client()->SendMsgY(&Packer, MSGFLAG_VITAL, 0);
m_CheckInfo[0] = Client()->GameTickSpeed(); m_CheckInfo[0] = Client()->GameTickSpeed();
} }
} }
@ -1875,9 +1875,9 @@ void CGameClient::SendDummyInfo(bool Start)
Msg.m_UseCustomColor = g_Config.m_ClDummyUseCustomColor; Msg.m_UseCustomColor = g_Config.m_ClDummyUseCustomColor;
Msg.m_ColorBody = g_Config.m_ClDummyColorBody; Msg.m_ColorBody = g_Config.m_ClDummyColorBody;
Msg.m_ColorFeet = g_Config.m_ClDummyColorFeet; Msg.m_ColorFeet = g_Config.m_ClDummyColorFeet;
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID(), false);
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL, false, 1); Client()->SendMsgY(&Packer, MSGFLAG_VITAL, 1);
m_CheckInfo[1] = -1; m_CheckInfo[1] = -1;
} }
else else
@ -1890,9 +1890,9 @@ void CGameClient::SendDummyInfo(bool Start)
Msg.m_UseCustomColor = g_Config.m_ClDummyUseCustomColor; Msg.m_UseCustomColor = g_Config.m_ClDummyUseCustomColor;
Msg.m_ColorBody = g_Config.m_ClDummyColorBody; Msg.m_ColorBody = g_Config.m_ClDummyColorBody;
Msg.m_ColorFeet = g_Config.m_ClDummyColorFeet; Msg.m_ColorFeet = g_Config.m_ClDummyColorFeet;
CMsgPacker Packer(Msg.MsgID()); CMsgPacker Packer(Msg.MsgID(), false);
Msg.Pack(&Packer); Msg.Pack(&Packer);
Client()->SendMsgExY(&Packer, MSGFLAG_VITAL,false, 1); Client()->SendMsgY(&Packer, MSGFLAG_VITAL, 1);
m_CheckInfo[1] = Client()->GameTickSpeed(); m_CheckInfo[1] = Client()->GameTickSpeed();
} }
} }
@ -1904,8 +1904,8 @@ void CGameClient::SendKill(int ClientID)
if(g_Config.m_ClDummyCopyMoves) if(g_Config.m_ClDummyCopyMoves)
{ {
CMsgPacker Msg(NETMSGTYPE_CL_KILL); CMsgPacker Msg(NETMSGTYPE_CL_KILL, false);
Client()->SendMsgExY(&Msg, MSGFLAG_VITAL, false, !g_Config.m_ClDummy); Client()->SendMsgY(&Msg, MSGFLAG_VITAL, !g_Config.m_ClDummy);
} }
} }