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

This commit is contained in:
Nordsoft91 authored and GitHub committed 2022-08-30 08:30:21 +03:00
1 parent b664f9a128
commit 4f1f9e3c5d
3 files changed
+12 -21

No files matched your search

+9 -15
View File
@@ -131,25 +131,19 @@ void CLobbyScreen::startScenario(bool allowOnlyAI)
CSH->sendStartGame(allowOnlyAI);
buttonStart->block(true);
}
catch(ExceptionMapMissing & e)
catch(std::exception & e)
{
(void)e; // unused
}
catch(ExceptionNoHuman & e)
{
(void)e; // unused
// You must position yourself prior to starting the game.
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), 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));
logGlobal->error("Exception during startScenario: %s", e.what());
if(std::string(e.what()) == "ExceptionNoHuman")
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[530]), CInfoWindow::TCompsInfo(), PlayerColor(1));
if(std::string(e.what()) == "ExceptionNoTemplate")
CInfoWindow::showInfoDialog(std::ref(CGI->generaltexth->allTexts[751]), CInfoWindow::TCompsInfo(), PlayerColor(1));
}
catch(...)
{
logGlobal->error("Unknown exception");
}
}
+3 -3
View File
@@ -64,7 +64,7 @@ std::string StartInfo::getCampaignName() const
void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
{
if(!mi)
throw ExceptionMapMissing();
throw std::domain_error("ExceptionMapMissing");
//there must be at least one human player before game can be started
std::map<PlayerColor, PlayerSettings>::const_iterator i;
@@ -73,12 +73,12 @@ void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
break;
if(i == si->playerInfos.cend() && !ignoreNoHuman)
throw ExceptionNoHuman();
throw std::domain_error("ExceptionNoHuman");
if(si->mapGenOptions && si->mode == StartInfo::NEW_GAME)
{
if(!si->mapGenOptions->checkOptions())
throw ExceptionNoTemplate();
throw std::domain_error("ExceptionNoTemplate");
}
}
-3
View File
@@ -187,6 +187,3 @@ struct DLL_LINKAGE LobbyInfo : public LobbyState
TeamID getPlayerTeamId(PlayerColor color);
};
class ExceptionMapMissing : public std::exception {};
class ExceptionNoHuman : public std::exception {};
class ExceptionNoTemplate : public std::exception {};