Fix unhandled exceptions during packet processing

This commit is contained in:
ZehMatt committed 2021-07-29 20:06:36 +03:00
1 parent dac7d76e7a
commit 6877b8214a
1 file changed
+13 -5
+13 -5
View File
@@ -1698,15 +1698,23 @@ bool NetworkBase::ProcessConnection(NetworkConnection& connection)
void NetworkBase::ProcessPacket(NetworkConnection& connection, NetworkPacket& packet)
{
const auto& handlerList = GetMode() == NETWORK_MODE_SERVER ? server_command_handlers : client_command_handlers;
auto it = handlerList.find(packet.GetCommand());
if (it != handlerList.end())
try
{
auto commandHandler = it->second;
if (connection.AuthStatus == NetworkAuth::Ok || !packet.CommandRequiresAuth())
auto it = handlerList.find(packet.GetCommand());
if (it != handlerList.end())
{
(this->*commandHandler)(connection, packet);
auto commandHandler = it->second;
if (connection.AuthStatus == NetworkAuth::Ok || !packet.CommandRequiresAuth())
{
(this->*commandHandler)(connection, packet);
}
}
}
catch (const std::exception& ex)
{
log_verbose("Exception during packet processing: %s", ex.what());
}
packet.Clear();
}