From b7662c5ec670756be122505b32ed19be1f7c2663 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 24 Jan 2024 13:43:16 +0200 Subject: [PATCH 1/5] Android build ID bump --- android/vcmi-app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/vcmi-app/build.gradle b/android/vcmi-app/build.gradle index b8ab1c6ef..538fc9a4c 100644 --- a/android/vcmi-app/build.gradle +++ b/android/vcmi-app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "is.xyz.vcmi" minSdk 19 targetSdk 33 - versionCode 1450 + versionCode 1451 versionName "1.4.5" setProperty("archivesBaseName", "vcmi") } From 702fc8077dcf5320f0dd7042364e17a0d2f8d372 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 24 Jan 2024 13:43:35 +0200 Subject: [PATCH 2/5] Fix possible crash on invalid spell --- lib/CBonusTypeHandler.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/CBonusTypeHandler.cpp b/lib/CBonusTypeHandler.cpp index 7244c62d2..ba86a2d8e 100644 --- a/lib/CBonusTypeHandler.cpp +++ b/lib/CBonusTypeHandler.cpp @@ -76,10 +76,10 @@ std::string CBonusTypeHandler::bonusToString(const std::shared_ptr & bonu if (text.find("${val}") != std::string::npos) boost::algorithm::replace_all(text, "${val}", std::to_string(bearer->valOfBonuses(Selector::typeSubtype(bonus->type, bonus->subtype)))); - if (text.find("${subtype.creature}") != std::string::npos && bonus->subtype.as() != CreatureID::NONE) + if (text.find("${subtype.creature}") != std::string::npos && bonus->subtype.as().hasValue()) boost::algorithm::replace_all(text, "${subtype.creature}", bonus->subtype.as().toCreature()->getNamePluralTranslated()); - if (text.find("${subtype.spell}") != std::string::npos && bonus->subtype.as() != SpellID::NONE) + if (text.find("${subtype.spell}") != std::string::npos && bonus->subtype.as().hasValue()) boost::algorithm::replace_all(text, "${subtype.spell}", bonus->subtype.as().toSpell()->getNameTranslated()); return text; @@ -95,8 +95,11 @@ ImagePath CBonusTypeHandler::bonusToGraphics(const std::shared_ptr & bonu case BonusType::SPELL_IMMUNITY: { fullPath = true; - const CSpell * sp = bonus->subtype.as().toSpell(); - fileName = sp->getIconImmune(); + if (bonus->subtype.as().hasValue()) + { + const CSpell * sp = bonus->subtype.as().toSpell(); + fileName = sp->getIconImmune(); + } break; } case BonusType::SPELL_DAMAGE_REDUCTION: //Spell damage reduction for all schools From 2f5bf6434004ac44e24460660b868517583aae22 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 24 Jan 2024 13:44:22 +0200 Subject: [PATCH 3/5] Do not crash on attempt to load campaign with unsupported maps --- Mods/vcmi/config/vcmi/english.json | 1 + client/lobby/CLobbyScreen.cpp | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Mods/vcmi/config/vcmi/english.json b/Mods/vcmi/config/vcmi/english.json index 690e34700..010c2429d 100644 --- a/Mods/vcmi/config/vcmi/english.json +++ b/Mods/vcmi/config/vcmi/english.json @@ -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}", diff --git a/client/lobby/CLobbyScreen.cpp b/client/lobby/CLobbyScreen.cpp index 0c5a6670e..730f5e2ee 100644 --- a/client/lobby/CLobbyScreen.cpp +++ b/client/lobby/CLobbyScreen.cpp @@ -127,11 +127,23 @@ void CLobbyScreen::toggleTab(std::shared_ptr 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) From a2e0742ffb038a82d4bd04d29375f24b47494d8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Wed, 24 Jan 2024 06:20:46 +0100 Subject: [PATCH 4/5] Fix invalid logic which made AI not attack guards --- lib/pathfinder/PathfindingRules.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pathfinder/PathfindingRules.cpp b/lib/pathfinder/PathfindingRules.cpp index 49de31ff7..ca71db460 100644 --- a/lib/pathfinder/PathfindingRules.cpp +++ b/lib/pathfinder/PathfindingRules.cpp @@ -273,9 +273,9 @@ PathfinderBlockingRule::BlockingReason MovementAfterDestinationRule::getBlocking if(destination.guarded) { if (pathfinderHelper->options.ignoreGuards) - return BlockingReason::DESTINATION_GUARDED; - else return BlockingReason::NONE; + else + return BlockingReason::DESTINATION_GUARDED; } break; From d69e0b23e897c166329271389def64e57c4f4e0a Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Wed, 24 Jan 2024 14:09:40 +0200 Subject: [PATCH 5/5] Update changelog --- ChangeLog.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index cd7468304..78379b875 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,8 @@ * Fixed crash on creature spellcasting * Fixed crash on unit entering magical obstacles such as quicksands * Fixed freeze on map loading on some systems +* Fixed crash on attempt to start campaign with unsupported map +* Fixed crash on opening creature information window with invalid SPELL_IMMUNITY bonus ### Random Maps Generator * Fixed placement of guards sometimes resulting into open connection into third zone @@ -12,6 +14,10 @@ ### Map Editor * Fixed inspector using wrong editor for some values +### AI +* Fixed bug leading to AI not attacking wandering monsters in some cases +* Fixed crash on using StupidAI for autocombat or for enemy players + # 1.4.3 -> 1.4.4 ### General