MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / logPacket

Method logPacket

src/OpenLoco/src/Network/NetworkConnection.cpp:184–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184void NetworkConnection::logPacket([[maybe_unused]] const Packet& packet, [[maybe_unused]] bool sent, [[maybe_unused]] bool resend)
185{
186#if defined(DEBUG)
187#ifdef LOG_PACKETS
188 auto szDirection = sent ? "SENT" : "RECV";
189 auto seq = static_cast<int32_t>(packet.header.sequence);
190 auto bytes = static_cast<int32_t>(packet.header.dataSize);
191 if (packet.header.kind == PacketKind::ack || packet.header.kind == PacketKind::ping || resend)
192 {
193#ifdef LOG_ACK_PACKETS
194 Logging::info("[{}] #{:04} | ACK", szDirection, seq);
195#endif
196 }
197 else if (resend)
198 {
199 Logging::info("[{}] #{:04} | RESEND", szDirection, seq);
200 }
201 else if (packet.header.kind == PacketKind::gameCommand)
202 {
203 auto kind = getPacketKindString(packet.header.kind);
204 const auto& gc = packet.Cast<GameCommandPacket>();
205 Logging::info("[{}] #{:04} | {} (Index = {} Tick = {} Command = {})", szDirection, seq, kind, gc->index, gc->tick, gc->regs.esi);
206 }
207 else
208 {
209 auto kind = getPacketKindString(packet.header.kind);
210 Logging::info("[{}] #{:04} | {} ({} bytes)", szDirection, seq, kind, bytes);
211 }
212#endif
213#endif
214}

Callers

nothing calls this directly

Calls 2

infoFunction · 0.85
getPacketKindStringFunction · 0.85

Tested by

no test coverage detected