Merge pull request #12258 from skyfloogle/traversal-logging

Netplay: Don't log skippable events as errors
This commit is contained in:
Admiral H. Curtiss 2023-11-01 11:56:39 +01:00 committed by GitHub
commit ff009dd8b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 5 deletions

View File

@ -31,7 +31,7 @@ int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event)
// wakeup packet received // wakeup packet received
if (host->receivedDataLength == 1 && host->receivedData[0] == 0) if (host->receivedDataLength == 1 && host->receivedData[0] == 0)
{ {
event->type = (ENetEventType)42; event->type = SKIPPABLE_EVENT;
return 1; return 1;
} }
return 0; return 0;

View File

@ -21,4 +21,7 @@ using ENetHostPtr = std::unique_ptr<ENetHost, ENetHostDeleter>;
void WakeupThread(ENetHost* host); void WakeupThread(ENetHost* host);
int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event); int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event);
bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id); bool SendPacket(ENetPeer* socket, const sf::Packet& packet, u8 channel_id);
// used for traversal packets and wake-up packets
constexpr ENetEventType SKIPPABLE_EVENT = ENetEventType(42);
} // namespace Common::ENet } // namespace Common::ENet

View File

@ -299,7 +299,7 @@ int ENET_CALLBACK TraversalClient::InterceptCallback(ENetHost* host, ENetEvent*
&host->receivedAddress) || &host->receivedAddress) ||
(host->receivedDataLength == 1 && host->receivedData[0] == 0)) (host->receivedDataLength == 1 && host->receivedData[0] == 0))
{ {
event->type = (ENetEventType)42; event->type = Common::ENet::SKIPPABLE_EVENT;
return 1; return 1;
} }
return 0; return 0;

View File

@ -257,7 +257,7 @@ bool NetPlayClient::Connect()
ENetEvent netEvent; ENetEvent netEvent;
int net; int net;
while ((net = enet_host_service(m_client, &netEvent, 5000)) > 0 && while ((net = enet_host_service(m_client, &netEvent, 5000)) > 0 &&
netEvent.type == ENetEventType(42)) // See PR #11381 and ENetUtil::InterceptCallback netEvent.type == Common::ENet::SKIPPABLE_EVENT)
{ {
// ignore packets from traversal server // ignore packets from traversal server
} }
@ -1644,7 +1644,11 @@ void NetPlayClient::ThreadFunc()
break; break;
default: default:
ERROR_LOG_FMT(NETPLAY, "enet_host_service: unknown event type: {}", int(netEvent.type)); // not a valid switch case due to not technically being part of the enum
if (netEvent.type == Common::ENet::SKIPPABLE_EVENT)
INFO_LOG_FMT(NETPLAY, "enet_host_service: skippable packet event");
else
ERROR_LOG_FMT(NETPLAY, "enet_host_service: unknown event type: {}", int(netEvent.type));
break; break;
} }
} }

View File

@ -386,7 +386,11 @@ void NetPlayServer::ThreadFunc()
} }
break; break;
default: default:
ERROR_LOG_FMT(NETPLAY, "enet_host_service: unknown event type: {}", int(netEvent.type)); // not a valid switch case due to not technically being part of the enum
if (netEvent.type == Common::ENet::SKIPPABLE_EVENT)
INFO_LOG_FMT(NETPLAY, "enet_host_service: skippable packet event");
else
ERROR_LOG_FMT(NETPLAY, "enet_host_service: unknown event type: {}", int(netEvent.type));
break; break;
} }
} }