Merge pull request #12270 from AdmiralCurtiss/clang-enum-out-of-range-2

Netplay: Fix building on clang 17.
This commit is contained in:
Admiral H. Curtiss 2023-11-03 16:34:50 +01:00 committed by GitHub
commit c7243c368f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 6 deletions

View File

@ -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 = SKIPPABLE_EVENT;
event->type = static_cast<ENetEventType>(SKIPPABLE_EVENT);
return 1;
}
return 0;

View File

@ -23,5 +23,5 @@ 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);
constexpr int SKIPPABLE_EVENT = 42;
} // namespace Common::ENet

View File

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

View File

@ -257,7 +257,7 @@ bool NetPlayClient::Connect()
ENetEvent netEvent;
int net;
while ((net = enet_host_service(m_client, &netEvent, 5000)) > 0 &&
netEvent.type == Common::ENet::SKIPPABLE_EVENT)
static_cast<int>(netEvent.type) == Common::ENet::SKIPPABLE_EVENT)
{
// ignore packets from traversal server
}
@ -1645,7 +1645,7 @@ void NetPlayClient::ThreadFunc()
break;
default:
// not a valid switch case due to not technically being part of the enum
if (netEvent.type == Common::ENet::SKIPPABLE_EVENT)
if (static_cast<int>(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));

View File

@ -387,7 +387,7 @@ void NetPlayServer::ThreadFunc()
break;
default:
// not a valid switch case due to not technically being part of the enum
if (netEvent.type == Common::ENet::SKIPPABLE_EVENT)
if (static_cast<int>(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));