diff --git a/Source/Core/Common/TraversalClient.cpp b/Source/Core/Common/TraversalClient.cpp index a2cd9b2647..cc1e4a148d 100644 --- a/Source/Core/Common/TraversalClient.cpp +++ b/Source/Core/Common/TraversalClient.cpp @@ -16,8 +16,8 @@ static void GetRandomishBytes(u8* buf, size_t size) } TraversalClient::TraversalClient(ENetHost* netHost, const std::string& server, const u16 port) - : m_NetHost(netHost), m_Client(nullptr), m_FailureReason(0), m_ConnectRequestId(0), - m_PendingConnect(false), m_Server(server), m_port(port), m_PingTime(0) + : m_NetHost(netHost), m_Client(nullptr), m_ConnectRequestId(0), m_PendingConnect(false), + m_Server(server), m_port(port), m_PingTime(0) { netHost->intercept = TraversalClient::InterceptCallback; @@ -34,7 +34,7 @@ void TraversalClient::ReconnectToServer() { if (enet_address_set_host(&m_ServerAddress, m_Server.c_str())) { - OnFailure(BadHost); + OnFailure(FailureReason::BadHost); return; } m_ServerAddress.port = m_port; @@ -123,7 +123,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet) case TraversalPacketAck: if (!packet->ack.ok) { - OnFailure(ServerForgotAboutUs); + OnFailure(FailureReason::ServerForgotAboutUs); break; } for (auto it = m_OutgoingTraversalPackets.begin(); it != m_OutgoingTraversalPackets.end(); ++it) @@ -140,7 +140,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet) break; if (!packet->helloFromServer.ok) { - OnFailure(VersionTooOld); + OnFailure(FailureReason::VersionTooOld); break; } m_HostId = packet->helloFromServer.yourHostId; @@ -199,7 +199,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet) buf.data = &ack; buf.dataLength = sizeof(ack); if (enet_socket_send(m_NetHost->socket, &m_ServerAddress, &buf, 1) == -1) - OnFailure(SocketSendError); + OnFailure(FailureReason::SocketSendError); } } @@ -220,7 +220,7 @@ void TraversalClient::ResendPacket(OutgoingTraversalPacketInfo* info) buf.data = &info->packet; buf.dataLength = sizeof(info->packet); if (enet_socket_send(m_NetHost->socket, &m_ServerAddress, &buf, 1) == -1) - OnFailure(SocketSendError); + OnFailure(FailureReason::SocketSendError); } void TraversalClient::HandleResends() @@ -232,7 +232,7 @@ void TraversalClient::HandleResends() { if (tpi.tries >= 5) { - OnFailure(ResendTimeout); + OnFailure(FailureReason::ResendTimeout); m_OutgoingTraversalPackets.clear(); break; } diff --git a/Source/Core/Common/TraversalClient.h b/Source/Core/Common/TraversalClient.h index 82a7d71c8e..befd530174 100644 --- a/Source/Core/Common/TraversalClient.h +++ b/Source/Core/Common/TraversalClient.h @@ -28,7 +28,7 @@ public: Connected, Failure }; - enum FailureReason + enum class FailureReason { BadHost = 0x300, VersionTooOld, @@ -50,7 +50,7 @@ public: TraversalClientClient* m_Client; TraversalHostId m_HostId; State m_State; - int m_FailureReason; + FailureReason m_FailureReason; private: struct OutgoingTraversalPacketInfo diff --git a/Source/Core/Core/NetPlayClient.h b/Source/Core/Core/NetPlayClient.h index 79545a6d35..00decb8093 100644 --- a/Source/Core/Core/NetPlayClient.h +++ b/Source/Core/Core/NetPlayClient.h @@ -34,7 +34,7 @@ public: virtual void OnPadBufferChanged(u32 buffer) = 0; virtual void OnDesync(u32 frame, const std::string& player) = 0; virtual void OnConnectionLost() = 0; - virtual void OnTraversalError(int error) = 0; + virtual void OnTraversalError(TraversalClient::FailureReason error) = 0; virtual bool IsRecording() = 0; virtual std::string FindGame(const std::string& game) = 0; virtual void ShowMD5Dialog(const std::string& file_identifier) = 0; diff --git a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp index 870851dee1..dad161cba7 100644 --- a/Source/Core/DolphinWX/NetPlay/NetWindow.cpp +++ b/Source/Core/DolphinWX/NetPlay/NetWindow.cpp @@ -457,19 +457,19 @@ void NetPlayDialog::OnConnectionLost() GetEventHandler()->AddPendingEvent(evt); } -void NetPlayDialog::OnTraversalError(int error) +void NetPlayDialog::OnTraversalError(TraversalClient::FailureReason error) { switch (error) { - case TraversalClient::BadHost: + case TraversalClient::FailureReason::BadHost: PanicAlertT("Couldn't look up central server"); break; - case TraversalClient::VersionTooOld: + case TraversalClient::FailureReason::VersionTooOld: PanicAlertT("Dolphin is too old for traversal server"); break; - case TraversalClient::ServerForgotAboutUs: - case TraversalClient::SocketSendError: - case TraversalClient::ResendTimeout: + case TraversalClient::FailureReason::ServerForgotAboutUs: + case TraversalClient::FailureReason::SocketSendError: + case TraversalClient::FailureReason::ResendTimeout: wxThreadEvent evt(wxEVT_THREAD, NP_GUI_EVT_TRAVERSAL_CONNECTION_ERROR); GetEventHandler()->AddPendingEvent(evt); break; diff --git a/Source/Core/DolphinWX/NetPlay/NetWindow.h b/Source/Core/DolphinWX/NetPlay/NetWindow.h index ce77a6dfd7..e3ccbf952f 100644 --- a/Source/Core/DolphinWX/NetPlay/NetWindow.h +++ b/Source/Core/DolphinWX/NetPlay/NetWindow.h @@ -102,7 +102,7 @@ public: void OnPadBufferChanged(u32 buffer) override; void OnDesync(u32 frame, const std::string& player) override; void OnConnectionLost() override; - void OnTraversalError(int error) override; + void OnTraversalError(TraversalClient::FailureReason error) override; static NetPlayDialog*& GetInstance() { return npd; } static NetPlayClient*& GetNetPlayClient() { return netplay_client; }