1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Do not crash on attempt to load campaign with unsupported maps

This commit is contained in:
Ivan Savenko 2024-01-24 13:44:22 +02:00
parent 702fc8077d
commit 2f5bf64340
2 changed files with 15 additions and 2 deletions

View File

@ -72,6 +72,7 @@
"vcmi.lobby.noUnderground" : "no underground",
"vcmi.lobby.sortDate" : "Sorts maps by change date",
"vcmi.client.errors.invalidMap" : "{Invalid map or campaign}\n\nFailed to start game! Selected map or campaign might be invalid or corrupted. Reason:\n%s",
"vcmi.client.errors.missingCampaigns" : "{Missing data files}\n\nCampaigns data files were not found! You may be using incomplete or corrupted Heroes 3 data files. Please reinstall game data.",
"vcmi.server.errors.existingProcess" : "Another VCMI server process is running. Please terminate it before starting a new game.",
"vcmi.server.errors.modsToEnable" : "{Following mods are required}",

View File

@ -127,11 +127,23 @@ void CLobbyScreen::toggleTab(std::shared_ptr<CIntObject> tab)
void CLobbyScreen::startCampaign()
{
if(CSH->mi)
{
if(!CSH->mi)
return;
try {
auto ourCampaign = CampaignHandler::getCampaign(CSH->mi->fileURI);
CSH->setCampaignState(ourCampaign);
}
catch (const std::runtime_error &e)
{
// handle possible exception on map loading. For example campaign that contains map in unsupported format
// for example, wog campaigns or hota campaigns without hota map support mod
MetaString message;
message.appendTextID("vcmi.client.errors.invalidMap");
message.replaceRawString(e.what());
CInfoWindow::showInfoDialog(message.toString(), {});
}
}
void CLobbyScreen::startScenario(bool allowOnlyAI)