Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #12258 from skyfloogle/traversal-logging
Netplay: Don't log skippable events as errors
  • Loading branch information
AdmiralCurtiss committed Nov 1, 2023
2 parents 166d8a1 + bee6d5b commit ff009dd
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Common/ENet.cpp
Expand Up @@ -31,7 +31,7 @@ int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event)
// wakeup packet received
if (host->receivedDataLength == 1 && host->receivedData[0] == 0)
{
event->type = (ENetEventType)42;
event->type = SKIPPABLE_EVENT;
return 1;
}
return 0;
Expand Down
3 changes: 3 additions & 0 deletions Source/Core/Common/ENet.h
Expand Up @@ -21,4 +21,7 @@ using ENetHostPtr = std::unique_ptr<ENetHost, ENetHostDeleter>;
void WakeupThread(ENetHost* host);
int ENET_CALLBACK InterceptCallback(ENetHost* host, ENetEvent* event);
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
2 changes: 1 addition & 1 deletion Source/Core/Common/TraversalClient.cpp
Expand Up @@ -299,7 +299,7 @@ int ENET_CALLBACK TraversalClient::InterceptCallback(ENetHost* host, ENetEvent*
&host->receivedAddress) ||
(host->receivedDataLength == 1 && host->receivedData[0] == 0))
{
event->type = (ENetEventType)42;
event->type = Common::ENet::SKIPPABLE_EVENT;
return 1;
}
return 0;
Expand Down
8 changes: 6 additions & 2 deletions Source/Core/Core/NetPlayClient.cpp
Expand Up @@ -257,7 +257,7 @@ bool NetPlayClient::Connect()
ENetEvent netEvent;
int net;
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
}
Expand Down Expand Up @@ -1644,7 +1644,11 @@ void NetPlayClient::ThreadFunc()

break;
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;
}
}
Expand Down
6 changes: 5 additions & 1 deletion Source/Core/Core/NetPlayServer.cpp
Expand Up @@ -386,7 +386,11 @@ void NetPlayServer::ThreadFunc()
}
break;
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;
}
}
Expand Down

0 comments on commit ff009dd

Please sign in to comment.