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

Function RepackMsg

src/engine/client/client.cpp:113–166  ·  view source on GitHub ↗

----- send functions -----

Source from the content-addressed store, hash-verified

111
112// ----- send functions -----
113static inline bool RepackMsg(const CMsgPacker *pMsg, CPacker &Packer, bool Sixup)
114{
115 int MsgId = pMsg->m_MsgId;
116 Packer.Reset();
117
118 if(Sixup && !pMsg->m_NoTranslate)
119 {
120 if(pMsg->m_System)
121 {
122 if(MsgId >= OFFSET_UUID)
123 ;
124 else if(MsgId == NETMSG_INFO || MsgId == NETMSG_REQUEST_MAP_DATA)
125 ;
126 else if(MsgId == NETMSG_READY)
127 MsgId = protocol7::NETMSG_READY;
128 else if(MsgId == NETMSG_RCON_CMD)
129 MsgId = protocol7::NETMSG_RCON_CMD;
130 else if(MsgId == NETMSG_ENTERGAME)
131 MsgId = protocol7::NETMSG_ENTERGAME;
132 else if(MsgId == NETMSG_INPUT)
133 MsgId = protocol7::NETMSG_INPUT;
134 else if(MsgId == NETMSG_RCON_AUTH)
135 MsgId = protocol7::NETMSG_RCON_AUTH;
136 else if(MsgId == NETMSG_PING)
137 MsgId = protocol7::NETMSG_PING;
138 else
139 {
140 log_error("net", "0.7 DROP send sys %d", MsgId);
141 return false;
142 }
143 }
144 else
145 {
146 if(MsgId >= 0 && MsgId < OFFSET_UUID)
147 MsgId = Msg_SixToSeven(MsgId);
148
149 if(MsgId < 0)
150 return false;
151 }
152 }
153
154 if(pMsg->m_MsgId < OFFSET_UUID)
155 {
156 Packer.AddInt((MsgId << 1) | (pMsg->m_System ? 1 : 0));
157 }
158 else
159 {
160 Packer.AddInt(pMsg->m_System ? 1 : 0); // NETMSG_EX, NETMSGTYPE_EX
161 g_UuidManager.PackUuid(pMsg->m_MsgId, &Packer);
162 }
163 Packer.AddRaw(pMsg->Data(), pMsg->Size());
164
165 return true;
166}
167
168int CClient::SendMsg(int Conn, CMsgPacker *pMsg, int Flags)
169{

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