浏览代码

Merge pull request #3558 from IvanSavenko/release_145

Release 1.4.5
Ivan Savenko 1 年之前
父节点
当前提交
3d2f69199a

+ 6 - 0
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

+ 1 - 0
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}",

+ 1 - 1
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")
 	}

+ 14 - 2
client/lobby/CLobbyScreen.cpp

@@ -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)

+ 7 - 4
lib/CBonusTypeHandler.cpp

@@ -76,10 +76,10 @@ std::string CBonusTypeHandler::bonusToString(const std::shared_ptr<Bonus> & 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>() != CreatureID::NONE)
+	if (text.find("${subtype.creature}") != std::string::npos && bonus->subtype.as<CreatureID>().hasValue())
 		boost::algorithm::replace_all(text, "${subtype.creature}", bonus->subtype.as<CreatureID>().toCreature()->getNamePluralTranslated());
 
-	if (text.find("${subtype.spell}") != std::string::npos && bonus->subtype.as<SpellID>() != SpellID::NONE)
+	if (text.find("${subtype.spell}") != std::string::npos && bonus->subtype.as<SpellID>().hasValue())
 		boost::algorithm::replace_all(text, "${subtype.spell}", bonus->subtype.as<SpellID>().toSpell()->getNameTranslated());
 
 	return text;
@@ -95,8 +95,11 @@ ImagePath CBonusTypeHandler::bonusToGraphics(const std::shared_ptr<Bonus> & bonu
 	case BonusType::SPELL_IMMUNITY:
 	{
 		fullPath = true;
-		const CSpell * sp = bonus->subtype.as<SpellID>().toSpell();
-		fileName = sp->getIconImmune();
+		if (bonus->subtype.as<SpellID>().hasValue())
+		{
+			const CSpell * sp = bonus->subtype.as<SpellID>().toSpell();
+			fileName = sp->getIconImmune();
+		}
 		break;
 	}
 	case BonusType::SPELL_DAMAGE_REDUCTION: //Spell damage reduction for all schools

+ 2 - 2
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;