1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-17 01:32:21 +02:00

Fix start game button for rmg without templates (#781)

This commit is contained in:
Nordsoft91
2022-08-30 09:30:21 +04:00
committed by GitHub
parent b664f9a128
commit 4f1f9e3c5d
3 changed files with 12 additions and 21 deletions

View File

@ -131,25 +131,19 @@ void CLobbyScreen::startScenario(bool allowOnlyAI)
CSH->sendStartGame(allowOnlyAI); CSH->sendStartGame(allowOnlyAI);
buttonStart->block(true); buttonStart->block(true);
} }
catch(ExceptionMapMissing & e) catch(std::exception & e)
{ {
(void)e; // unused logGlobal->error("Exception during startScenario: %s", e.what());
}
catch(ExceptionNoHuman & e) if(std::string(e.what()) == "ExceptionNoHuman")
{ CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), CInfoWindow::TCompsInfo(), PlayerColor(1));
(void)e; // unused
// You must position yourself prior to starting the game. if(std::string(e.what()) == "ExceptionNoTemplate")
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), CInfoWindow::TCompsInfo(), PlayerColor(1)); CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[751]), CInfoWindow::TCompsInfo(), PlayerColor(1));
}
catch(ExceptionNoTemplate & e)
{
(void)e; // unused
// Could not create a random map that fits current choices.
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[751]), CInfoWindow::TCompsInfo(), PlayerColor(1));
} }
catch(...) catch(...)
{ {
logGlobal->error("Unknown exception");
} }
} }

View File

@ -64,7 +64,7 @@ std::string StartInfo::getCampaignName() const
void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
{ {
if(!mi) if(!mi)
throw ExceptionMapMissing(); throw std::domain_error("ExceptionMapMissing");
//there must be at least one human player before game can be started //there must be at least one human player before game can be started
std::map<PlayerColor, PlayerSettings>::const_iterator i; std::map<PlayerColor, PlayerSettings>::const_iterator i;
@ -73,12 +73,12 @@ void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
break; break;
if(i == si->playerInfos.cend() && !ignoreNoHuman) if(i == si->playerInfos.cend() && !ignoreNoHuman)
throw ExceptionNoHuman(); throw std::domain_error("ExceptionNoHuman");
if(si->mapGenOptions && si->mode == StartInfo::NEW_GAME) if(si->mapGenOptions && si->mode == StartInfo::NEW_GAME)
{ {
if(!si->mapGenOptions->checkOptions()) if(!si->mapGenOptions->checkOptions())
throw ExceptionNoTemplate(); throw std::domain_error("ExceptionNoTemplate");
} }
} }

View File

@ -187,6 +187,3 @@ struct DLL_LINKAGE LobbyInfo : public LobbyState
TeamID getPlayerTeamId(PlayerColor color); TeamID getPlayerTeamId(PlayerColor color);
}; };
class ExceptionMapMissing : public std::exception {};
class ExceptionNoHuman : public std::exception {};
class ExceptionNoTemplate : public std::exception {};