MCPcopy Create free account
hub / github.com/ddnet/ddnet / RepackMsg

Function RepackMsg

src/engine/server/server.cpp:851–900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

849}
850
851static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer, bool Sixup)
852{
853 int MsgId = pMsg->m_MsgId;
854 Packer.Reset();
855
856 if(Sixup && !pMsg->m_NoTranslate)
857 {
858 if(pMsg->m_System)
859 {
860 if(MsgId >= OFFSET_UUID)
861 ;
862 else if(MsgId >= NETMSG_MAP_CHANGE && MsgId <= NETMSG_MAP_DATA)
863 ;
864 else if(MsgId >= NETMSG_CON_READY && MsgId <= NETMSG_INPUTTIMING)
865 MsgId += 1;
866 else if(MsgId == NETMSG_RCON_LINE)
867 MsgId = protocol7::NETMSG_RCON_LINE;
868 else if(MsgId >= NETMSG_PING && MsgId <= NETMSG_PING_REPLY)
869 MsgId += 4;
870 else if(MsgId >= NETMSG_RCON_CMD_ADD && MsgId <= NETMSG_RCON_CMD_REM)
871 MsgId -= 11;
872 else
873 {
874 log_error("net", "DROP send sys %d", MsgId);
875 return false;
876 }
877 }
878 else
879 {
880 if(MsgId >= 0 && MsgId < OFFSET_UUID)
881 MsgId = Msg_SixToSeven(MsgId);
882
883 if(MsgId < 0)
884 return false;
885 }
886 }
887
888 if(MsgId < OFFSET_UUID)
889 {
890 Packer.AddInt((MsgId << 1) | (pMsg->m_System ? 1 : 0));
891 }
892 else
893 {
894 Packer.AddInt(pMsg->m_System ? 1 : 0); // NETMSG_EX, NETMSGTYPE_EX
895 g_UuidManager.PackUuid(MsgId, &Packer);
896 }
897 Packer.AddRaw(pMsg->Data(), pMsg->Size());
898
899 return true;
900}
901
902int CServer::SendMsg(CMsgPacker *pMsg, int Flags, int ClientId)
903{

Callers 1

SendMsgMethod · 0.70

Calls 6

AddIntMethod · 0.80
PackUuidMethod · 0.80
AddRawMethod · 0.80
ResetMethod · 0.45
DataMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected