| 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() |
nothing calls this directly
no test coverage detected