Browse Source

Merge pull request #6104 from MichalZr6/building_upgrades_fix

Log error instead of throw when upgrade is same building ID
Ivan Savenko 1 month ago
parent
commit
3898a33f20
1 changed files with 10 additions and 6 deletions
  1. 10 6
      lib/entities/faction/CTownHandler.cpp

+ 10 - 6
lib/entities/faction/CTownHandler.cpp

@@ -361,14 +361,18 @@ void CTownHandler::loadBuilding(CTown * town, const std::string & stringID, cons
 		// building id and upgrades can't be the same
 		// building id and upgrades can't be the same
 		if(stringID == source["upgrades"].String())
 		if(stringID == source["upgrades"].String())
 		{
 		{
-			throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.") %
-												stringID % ret->town->faction->getNameTranslated()));
+			auto townName = ret->town->faction->getNameTranslated();
+			logMod->error("Building with ID '%s' of town '%s' can't be an upgrade of the same building.", stringID, townName);
+			throw std::runtime_error(boost::str(boost::format("Building with ID '%s' of town '%s' can't be an upgrade of the same building.")
+												% stringID % townName));
 		}
 		}
-
-		LIBRARY->identifiers()->requestIdentifier(ret->town->getBuildingScope(), source["upgrades"], [=](si32 identifier)
+		else
 		{
 		{
-			ret->upgrade = BuildingID(identifier);
-		});
+			LIBRARY->identifiers()->requestIdentifier(ret->town->getBuildingScope(), source["upgrades"], [=](si32 identifier)
+			{
+				ret->upgrade = BuildingID(identifier);
+			});
+		}
 	}
 	}
 	else
 	else
 		ret->upgrade = BuildingID::NONE;
 		ret->upgrade = BuildingID::NONE;