mirror of
https://github.com/vcmi/vcmi.git
synced 2025-03-27 21:49:10 +02:00
Fixed possible uncaught exception on starting map
This commit is contained in:
parent
9e4a42b25d
commit
c524caee5c
@ -572,7 +572,16 @@ void CServerHandler::sendRestartGame() const
|
||||
|
||||
void CServerHandler::sendStartGame(bool allowOnlyAI) const
|
||||
{
|
||||
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
|
||||
try
|
||||
{
|
||||
verifyStateBeforeStart(allowOnlyAI ? true : settings["session"]["onlyai"].Bool());
|
||||
}
|
||||
catch (const std::exception & e)
|
||||
{
|
||||
showServerError( std::string("Unable to start map! Reason: ") + e.what());
|
||||
return;
|
||||
}
|
||||
|
||||
LobbyStartGame lsg;
|
||||
if(client)
|
||||
{
|
||||
@ -696,7 +705,7 @@ void CServerHandler::startCampaignScenario(std::shared_ptr<CampaignState> cs)
|
||||
});
|
||||
}
|
||||
|
||||
void CServerHandler::showServerError(std::string txt)
|
||||
void CServerHandler::showServerError(std::string txt) const
|
||||
{
|
||||
CInfoWindow::showInfoDialog(txt, {});
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public:
|
||||
void startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameState = nullptr);
|
||||
void endGameplay(bool closeConnection = true, bool restart = false);
|
||||
void startCampaignScenario(std::shared_ptr<CampaignState> cs = {});
|
||||
void showServerError(std::string txt);
|
||||
void showServerError(std::string txt) const;
|
||||
|
||||
// TODO: LobbyState must be updated within game so we should always know how many player interfaces our client handle
|
||||
int howManyPlayerInterfaces();
|
||||
|
@ -71,7 +71,7 @@ std::string StartInfo::getCampaignName() const
|
||||
void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
|
||||
{
|
||||
if(!mi || !mi->mapHeader)
|
||||
throw std::domain_error("ExceptionMapMissing");
|
||||
throw std::domain_error("There is no map to start!");
|
||||
|
||||
auto missingMods = CMapService::verifyMapHeaderMods(*mi->mapHeader);
|
||||
CModHandler::Incompatibility::ModList modList;
|
||||
@ -88,12 +88,12 @@ void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
|
||||
break;
|
||||
|
||||
if(i == si->playerInfos.cend() && !ignoreNoHuman)
|
||||
throw std::domain_error("ExceptionNoHuman");
|
||||
throw std::domain_error("There is no human player on map");
|
||||
|
||||
if(si->mapGenOptions && si->mode == StartInfo::NEW_GAME)
|
||||
{
|
||||
if(!si->mapGenOptions->checkOptions())
|
||||
throw std::domain_error("ExceptionNoTemplate");
|
||||
throw std::domain_error("No random map template found!");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user