浏览代码

- Fixed castle.json (building structures)

beegee1 12 年之前
父节点
当前提交
30b3081ac4
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 1 1
      config/factions/castle.json
  2. 9 0
      lib/CTownHandler.cpp

+ 1 - 1
config/factions/castle.json

@@ -155,7 +155,7 @@
 				"shipyard":       { "id" : 6 },
 				"fort":           { "id" : 7 },
 				"citadel":        { "id" : 8,  "upgrades" : "fort" },
-				"castle":         { "id" : 9,  "upgrades" : "castle" },
+				"castle":         { "id" : 9,  "upgrades" : "citadel" },
 				"villageHall":    { "id" : 10, "mode" : "auto" },
 				"townHall":       { "id" : 11, "upgrades" : "villageHall", "requires" : [ "tavern" ] },
 				"cityHall":       { "id" : 12, "upgrades" : "townHall", "requires" : [ "allOf", [ "mageGuild1" ], [ "marketplace" ], [ "blacksmith" ] ] },

+ 9 - 0
lib/CTownHandler.cpp

@@ -37,7 +37,9 @@ BuildingID CBuilding::getBase() const
 {
 	const CBuilding * build = this;
 	while (build->upgrade >= 0)
+	{
 		build = build->town->buildings.at(build->upgrade);
+	}
 
 	return build->bid;
 }
@@ -313,6 +315,13 @@ void CTownHandler::loadBuilding(CTown &town, const std::string & stringID, const
 				ret->upgrade = BuildingID(identifier);
 			});
 		}
+
+		// building id and upgrades can't be the same
+		if(ret->upgrade == ret->bid)
+		{
+			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 % town.faction->name));
+		}
 	}
 	else
 		ret->upgrade = BuildingID::NONE;