Browse Source

Add better runtime error on invalid building ID

Ivan Savenko 1 year ago
parent
commit
0d3408ee68
1 changed files with 3 additions and 0 deletions
  1. 3 0
      client/windows/CCastleInterface.cpp

+ 3 - 0
client/windows/CCastleInterface.cpp

@@ -1540,6 +1540,9 @@ CHallInterface::CHallInterface(const CGTownInstance * Town):
 			const CBuilding * building = nullptr;
 			for(auto & buildingID : boxList[row][col])//we are looking for the first not built structure
 			{
+				if (town->town->buildings.count(buildingID) == 0)
+					throw std::runtime_error("Town " + Town->town->faction->getJsonKey() + " has no building with ID " + std::to_string(buildingID.getNum()));
+
 				const CBuilding * current = town->town->buildings.at(buildingID);
 				if(vstd::contains(town->builtBuildings, buildingID))
 				{