MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / ProcessPacket

Method ProcessPacket

src/openrct2/network/NetworkBase.cpp:1853–1882  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1851 }
1852
1853 void NetworkBase::ProcessPacket(Connection& connection, Packet& packet)
1854 {
1855 const auto& handlerList = GetMode() == Mode::server ? server_command_handlers : client_command_handlers;
1856
1857 auto it = handlerList.find(packet.getCommand());
1858 if (it != handlerList.end())
1859 {
1860 auto commandHandler = it->second;
1861 if (connection.authStatus == Auth::ok || !packet.commandRequiresAuth())
1862 {
1863 try
1864 {
1865 (this->*commandHandler)(connection, packet);
1866 }
1867 catch (const std::exception& ex)
1868 {
1869 LOG_VERBOSE("Exception during packet processing: %s", ex.what());
1870 }
1871 }
1872 else if (GetMode() == Mode::server)
1873 {
1874 LOG_WARNING(
1875 "Connection %s sent command %u that requires authentication, disconnecting.",
1876 connection.socket->GetIpAddress().c_str(), static_cast<uint32_t>(packet.getCommand()));
1877 connection.disconnect();
1878 }
1879 }
1880
1881 packet.clear();
1882 }
1883
1884 // This is called at the end of each game tick, this where things should be processed that affects the game state.
1885 void NetworkBase::PostTick()

Callers

nothing calls this directly

Calls 9

GetModeFunction · 0.85
findMethod · 0.80
getCommandMethod · 0.80
commandRequiresAuthMethod · 0.80
disconnectMethod · 0.80
endMethod · 0.65
clearMethod · 0.65
whatMethod · 0.45
GetIpAddressMethod · 0.45

Tested by

no test coverage detected