mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-13 19:54:17 +02:00
Fixed possible uncaught exception on starting map
This commit is contained in:
@@ -572,7 +572,16 @@ void CServerHandler::sendRestartGame() const
|
|||||||
|
|
||||||
void CServerHandler::sendStartGame(bool allowOnlyAI) 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;
|
LobbyStartGame lsg;
|
||||||
if(client)
|
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, {});
|
CInfoWindow::showInfoDialog(txt, {});
|
||||||
}
|
}
|
||||||
|
@@ -151,7 +151,7 @@ public:
|
|||||||
void startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameState = nullptr);
|
void startGameplay(VCMI_LIB_WRAP_NAMESPACE(CGameState) * gameState = nullptr);
|
||||||
void endGameplay(bool closeConnection = true, bool restart = false);
|
void endGameplay(bool closeConnection = true, bool restart = false);
|
||||||
void startCampaignScenario(std::shared_ptr<CampaignState> cs = {});
|
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
|
// TODO: LobbyState must be updated within game so we should always know how many player interfaces our client handle
|
||||||
int howManyPlayerInterfaces();
|
int howManyPlayerInterfaces();
|
||||||
|
@@ -71,7 +71,7 @@ std::string StartInfo::getCampaignName() const
|
|||||||
void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
|
void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
|
||||||
{
|
{
|
||||||
if(!mi || !mi->mapHeader)
|
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);
|
auto missingMods = CMapService::verifyMapHeaderMods(*mi->mapHeader);
|
||||||
CModHandler::Incompatibility::ModList modList;
|
CModHandler::Incompatibility::ModList modList;
|
||||||
@@ -88,12 +88,12 @@ void LobbyInfo::verifyStateBeforeStart(bool ignoreNoHuman) const
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
if(i == si->playerInfos.cend() && !ignoreNoHuman)
|
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 && si->mode == StartInfo::NEW_GAME)
|
||||||
{
|
{
|
||||||
if(!si->mapGenOptions->checkOptions())
|
if(!si->mapGenOptions->checkOptions())
|
||||||
throw std::domain_error("ExceptionNoTemplate");
|
throw std::domain_error("No random map template found!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user