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.
This commit is contained in:
Lioncash 2021-09-22 15:29:04 -04:00
parent 80b4a4d7fd
commit 3840b55292
2 changed files with 13 additions and 37 deletions

View File

@ -784,10 +784,7 @@ void NetPlayClient::OnGameStatus(sf::Packet& packet)
{ {
std::lock_guard lkp(m_crit.players); std::lock_guard lkp(m_crit.players);
Player& player = m_players[pid]; packet >> m_players[pid].game_status;
u32 status;
packet >> status;
player.game_status = static_cast<SyncIdentifierComparison>(status);
} }
m_dialog->Update(); m_dialog->Update();
@ -797,19 +794,12 @@ void NetPlayClient::OnStartGame(sf::Packet& packet)
{ {
{ {
std::lock_guard lkg(m_crit.game); 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); INFO_LOG_FMT(NETPLAY, "Start of game {}", m_selected_game.game_id);
{ packet >> m_current_game;
std::underlying_type_t<PowerPC::CPUCore> core; packet >> m_net_settings.m_CPUthread;
if (packet >> core) packet >> m_net_settings.m_CPUcore;
m_net_settings.m_CPUcore = static_cast<PowerPC::CPUCore>(core);
else
m_net_settings.m_CPUcore = PowerPC::CPUCore::CachedInterpreter;
}
packet >> m_net_settings.m_EnableCheats; packet >> m_net_settings.m_EnableCheats;
packet >> m_net_settings.m_SelectedLanguage; packet >> m_net_settings.m_SelectedLanguage;
packet >> m_net_settings.m_OverrideRegionSettings; 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_RAMOverrideEnable;
packet >> m_net_settings.m_Mem1Size; packet >> m_net_settings.m_Mem1Size;
packet >> m_net_settings.m_Mem2Size; packet >> m_net_settings.m_Mem2Size;
packet >> m_net_settings.m_FallbackRegion;
{
std::underlying_type_t<DiscIO::Region> tmp;
packet >> tmp;
m_net_settings.m_FallbackRegion = static_cast<DiscIO::Region>(tmp);
}
packet >> m_net_settings.m_AllowSDWrites; packet >> m_net_settings.m_AllowSDWrites;
packet >> m_net_settings.m_CopyWiiSave; packet >> m_net_settings.m_CopyWiiSave;
packet >> m_net_settings.m_OCEnable; packet >> m_net_settings.m_OCEnable;
packet >> m_net_settings.m_OCFactor; packet >> m_net_settings.m_OCFactor;
for (auto& device : m_net_settings.m_EXIDevice) for (auto& device : m_net_settings.m_EXIDevice)
{ packet >> device;
int tmp;
packet >> tmp;
device = static_cast<ExpansionInterface::TEXIDevices>(tmp);
}
for (u32& value : m_net_settings.m_SYSCONFSettings) for (u32& value : m_net_settings.m_SYSCONFSettings)
packet >> value; packet >> value;
@ -1183,11 +1163,7 @@ void NetPlayClient::OnSyncSaveDataWii(sf::Packet& packet)
{ {
WiiSave::Storage::SaveFile file; WiiSave::Storage::SaveFile file;
packet >> file.mode >> file.attributes; packet >> file.mode >> file.attributes;
{ packet >> file.type;
u8 tmp;
packet >> tmp;
file.type = static_cast<WiiSave::Storage::SaveFile::Type>(tmp);
}
packet >> file.path; packet >> file.path;
if (file.type == WiiSave::Storage::SaveFile::Type::File) if (file.type == WiiSave::Storage::SaveFile::Type::File)

View File

@ -472,7 +472,7 @@ ConnectionError NetPlayServer::OnConnect(ENetPeer* socket, sf::Packet& rpac)
spac.clear(); spac.clear();
spac << MessageID::GameStatus; spac << MessageID::GameStatus;
spac << p.second.pid << static_cast<u32>(p.second.game_status); spac << p.second.pid << p.second.game_status;
Send(player.socket, spac); Send(player.socket, spac);
} }
@ -986,10 +986,10 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
case MessageID::GameStatus: case MessageID::GameStatus:
{ {
u32 status; SyncIdentifierComparison status;
packet >> status; packet >> status;
m_players[player.pid].game_status = static_cast<SyncIdentifierComparison>(status); m_players[player.pid].game_status = status;
// send msg to other clients // send msg to other clients
sf::Packet spac; sf::Packet spac;
@ -1473,7 +1473,7 @@ bool NetPlayServer::StartGame()
spac << MessageID::StartGame; spac << MessageID::StartGame;
spac << m_current_game; spac << m_current_game;
spac << m_settings.m_CPUthread; spac << m_settings.m_CPUthread;
spac << static_cast<std::underlying_type_t<PowerPC::CPUCore>>(m_settings.m_CPUcore); spac << m_settings.m_CPUcore;
spac << m_settings.m_EnableCheats; spac << m_settings.m_EnableCheats;
spac << m_settings.m_SelectedLanguage; spac << m_settings.m_SelectedLanguage;
spac << m_settings.m_OverrideRegionSettings; spac << m_settings.m_OverrideRegionSettings;
@ -1483,7 +1483,7 @@ bool NetPlayServer::StartGame()
spac << m_settings.m_RAMOverrideEnable; spac << m_settings.m_RAMOverrideEnable;
spac << m_settings.m_Mem1Size; spac << m_settings.m_Mem1Size;
spac << m_settings.m_Mem2Size; spac << m_settings.m_Mem2Size;
spac << static_cast<std::underlying_type_t<DiscIO::Region>>(m_settings.m_FallbackRegion); spac << m_settings.m_FallbackRegion;
spac << m_settings.m_AllowSDWrites; spac << m_settings.m_AllowSDWrites;
spac << m_settings.m_CopyWiiSave; spac << m_settings.m_CopyWiiSave;
spac << m_settings.m_OCEnable; spac << m_settings.m_OCEnable;
@ -1797,7 +1797,7 @@ bool NetPlayServer::SyncSaveData()
// Files // Files
for (const WiiSave::Storage::SaveFile& file : *files) for (const WiiSave::Storage::SaveFile& file : *files)
{ {
pac << file.mode << file.attributes << static_cast<u8>(file.type) << file.path; pac << file.mode << file.attributes << file.type << file.path;
if (file.type == WiiSave::Storage::SaveFile::Type::File) if (file.type == WiiSave::Storage::SaveFile::Type::File)
{ {