Check if all players have the game before starting netplay

https://bugs.dolphin-emu.org/issues/8885
This commit is contained in:
Aestek 2016-07-10 10:13:34 +02:00
parent 7ee6d08213
commit cd9a58b704
7 changed files with 116 additions and 7 deletions

View file

@ -288,19 +288,33 @@ void NetPlayDialog::GetNetSettings(NetSettings& settings)
settings.m_EXIDevice[1] = instance.m_EXIDevice[1];
}
std::string NetPlayDialog::FindGame()
std::string NetPlayDialog::FindGame(const std::string& target_game)
{
// find path for selected game, sloppy..
for (u32 i = 0; auto game = m_game_list->GetISO(i); ++i)
if (m_selected_game == BuildGameName(*game))
if (target_game == BuildGameName(*game))
return game->GetFileName();
WxUtils::ShowErrorDialog(_("Game not found!"));
return "";
}
std::string NetPlayDialog::FindCurrentGame()
{
return FindGame(m_selected_game);
}
void NetPlayDialog::OnStart(wxCommandEvent&)
{
bool should_start = true;
if (!netplay_client->DoAllPlayersHaveGame())
{
should_start = wxMessageBox(_("Not all players have the game. Do you really want to start?"),
_("Warning"), wxYES_NO) == wxYES;
}
if (!should_start)
return;
NetSettings settings;
GetNetSettings(settings);
netplay_server->SetNetSettings(settings);
@ -442,7 +456,11 @@ void NetPlayDialog::OnThread(wxThreadEvent& event)
case NP_GUI_EVT_START_GAME:
// client start game :/
{
netplay_client->StartGame(FindGame());
std::string game = FindCurrentGame();
if (game.empty())
WxUtils::ShowErrorDialog(_("Game not found!"));
else
netplay_client->StartGame(game);
}
break;
case NP_GUI_EVT_STOP_GAME: