diff --git a/client/CServerHandler.cpp b/client/CServerHandler.cpp index 225c09c9e..18e9ee444 100644 --- a/client/CServerHandler.cpp +++ b/client/CServerHandler.cpp @@ -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, {}); } diff --git a/client/CServerHandler.h b/client/CServerHandler.h index 199aa04a8..4b3e61c65 100644 --- a/client/CServerHandler.h +++ b/client/CServerHandler.h @@ -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(); diff --git a/lib/StartInfo.cpp b/lib/StartInfo.cpp index c722c80d5..6338a1541 100644 --- a/lib/StartInfo.cpp +++ b/lib/StartInfo.cpp @@ -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!"); } }