From 3840b552924f2c8d212c109a1ef3cb1661f2b643 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 22 Sep 2021 15:29:04 -0400 Subject: [PATCH] NetPlayClient/NetPlayServer: Remove now-unnecessary static_casts Now that we have the enum helpers in place, quite a few casts on their own can be removed. --- Source/Core/Core/NetPlayClient.cpp | 38 ++++++------------------------ Source/Core/Core/NetPlayServer.cpp | 12 +++++----- 2 files changed, 13 insertions(+), 37 deletions(-) diff --git a/Source/Core/Core/NetPlayClient.cpp b/Source/Core/Core/NetPlayClient.cpp index bcab00351f..8f730038ef 100644 --- a/Source/Core/Core/NetPlayClient.cpp +++ b/Source/Core/Core/NetPlayClient.cpp @@ -784,10 +784,7 @@ void NetPlayClient::OnGameStatus(sf::Packet& packet) { std::lock_guard lkp(m_crit.players); - Player& player = m_players[pid]; - u32 status; - packet >> status; - player.game_status = static_cast(status); + packet >> m_players[pid].game_status; } m_dialog->Update(); @@ -797,19 +794,12 @@ void NetPlayClient::OnStartGame(sf::Packet& packet) { { std::lock_guard lkg(m_crit.game); - packet >> m_current_game; - packet >> m_net_settings.m_CPUthread; INFO_LOG_FMT(NETPLAY, "Start of game {}", m_selected_game.game_id); - { - std::underlying_type_t core; - if (packet >> core) - m_net_settings.m_CPUcore = static_cast(core); - else - m_net_settings.m_CPUcore = PowerPC::CPUCore::CachedInterpreter; - } - + packet >> m_current_game; + packet >> m_net_settings.m_CPUthread; + packet >> m_net_settings.m_CPUcore; packet >> m_net_settings.m_EnableCheats; packet >> m_net_settings.m_SelectedLanguage; packet >> m_net_settings.m_OverrideRegionSettings; @@ -819,24 +809,14 @@ void NetPlayClient::OnStartGame(sf::Packet& packet) packet >> m_net_settings.m_RAMOverrideEnable; packet >> m_net_settings.m_Mem1Size; packet >> m_net_settings.m_Mem2Size; - - { - std::underlying_type_t tmp; - packet >> tmp; - m_net_settings.m_FallbackRegion = static_cast(tmp); - } - + packet >> m_net_settings.m_FallbackRegion; packet >> m_net_settings.m_AllowSDWrites; packet >> m_net_settings.m_CopyWiiSave; packet >> m_net_settings.m_OCEnable; packet >> m_net_settings.m_OCFactor; for (auto& device : m_net_settings.m_EXIDevice) - { - int tmp; - packet >> tmp; - device = static_cast(tmp); - } + packet >> device; for (u32& value : m_net_settings.m_SYSCONFSettings) packet >> value; @@ -1183,11 +1163,7 @@ void NetPlayClient::OnSyncSaveDataWii(sf::Packet& packet) { WiiSave::Storage::SaveFile file; packet >> file.mode >> file.attributes; - { - u8 tmp; - packet >> tmp; - file.type = static_cast(tmp); - } + packet >> file.type; packet >> file.path; if (file.type == WiiSave::Storage::SaveFile::Type::File) diff --git a/Source/Core/Core/NetPlayServer.cpp b/Source/Core/Core/NetPlayServer.cpp index c125cef358..806f4967ac 100644 --- a/Source/Core/Core/NetPlayServer.cpp +++ b/Source/Core/Core/NetPlayServer.cpp @@ -472,7 +472,7 @@ ConnectionError NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac) spac.clear(); spac << MessageID::GameStatus; - spac << p.second.pid << static_cast(p.second.game_status); + spac << p.second.pid << p.second.game_status; Send(player.socket, spac); } @@ -986,10 +986,10 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player) case MessageID::GameStatus: { - u32 status; + SyncIdentifierComparison status; packet >> status; - m_players[player.pid].game_status = static_cast(status); + m_players[player.pid].game_status = status; // send msg to other clients sf::Packet spac; @@ -1473,7 +1473,7 @@ bool NetPlayServer::StartGame() spac << MessageID::StartGame; spac << m_current_game; spac << m_settings.m_CPUthread; - spac << static_cast>(m_settings.m_CPUcore); + spac << m_settings.m_CPUcore; spac << m_settings.m_EnableCheats; spac << m_settings.m_SelectedLanguage; spac << m_settings.m_OverrideRegionSettings; @@ -1483,7 +1483,7 @@ bool NetPlayServer::StartGame() spac << m_settings.m_RAMOverrideEnable; spac << m_settings.m_Mem1Size; spac << m_settings.m_Mem2Size; - spac << static_cast>(m_settings.m_FallbackRegion); + spac << m_settings.m_FallbackRegion; spac << m_settings.m_AllowSDWrites; spac << m_settings.m_CopyWiiSave; spac << m_settings.m_OCEnable; @@ -1797,7 +1797,7 @@ bool NetPlayServer::SyncSaveData() // Files for (const WiiSave::Storage::SaveFile& file : *files) { - pac << file.mode << file.attributes << static_cast(file.type) << file.path; + pac << file.mode << file.attributes << file.type << file.path; if (file.type == WiiSave::Storage::SaveFile::Type::File) {