瀏覽代碼

Fix buildings loading

Ivan Savenko 2 年之前
父節點
當前提交
fce5f9f907
共有 3 個文件被更改,包括 13 次插入17 次删除
  1. 3 3
      lib/mapping/MapFeaturesH3M.cpp
  2. 9 13
      lib/mapping/MapIdentifiersH3M.cpp
  3. 1 1
      lib/mapping/MapIdentifiersH3M.h

+ 3 - 3
lib/mapping/MapFeaturesH3M.cpp

@@ -135,14 +135,14 @@ MapFormatFeaturesH3M MapFormatFeaturesH3M::getFeaturesHOTA(uint32_t hotaVersion)
 	if(hotaVersion < 3)
 	{
 		result.artifactsCount = 163; // + HotA artifacts
-		result.heroesCount = 178; // + Cove
+		result.heroesCount = 176; // + Cove
 		result.heroesPortraitsCount = 187; // + Cove
 	}
 	if(hotaVersion == 3)
 	{
 		result.artifactsCount = 165; // + HotA artifacts
-		result.heroesCount = 179; // + Cove
-		result.heroesPortraitsCount = 187; // + Cove
+		result.heroesCount = 177; // + Cove + Giselle
+		result.heroesPortraitsCount = 188; // + Cove + Giselle
 	}
 
 	assert((result.heroesCount + 7) / 8 == result.heroesBytes);

+ 9 - 13
lib/mapping/MapIdentifiersH3M.cpp

@@ -21,10 +21,8 @@
 VCMI_LIB_NAMESPACE_BEGIN
 
 template<typename IdentifierID>
-std::map<IdentifierID, IdentifierID> MapIdentifiersH3M::loadMapping(const JsonNode & mapping, const std::string & identifierName)
+void MapIdentifiersH3M::loadMapping(std::map<IdentifierID, IdentifierID> & result, const JsonNode & mapping, const std::string & identifierName)
 {
-	std::map<IdentifierID, IdentifierID> result;
-
 	for (auto entry : mapping.Struct())
 	{
 		IdentifierID sourceID (entry.second.Integer());
@@ -32,8 +30,6 @@ std::map<IdentifierID, IdentifierID> MapIdentifiersH3M::loadMapping(const JsonNo
 
 		result[sourceID] = targetID;
 	}
-
-	return result;
 }
 
 void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
@@ -88,14 +84,14 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
 		}
 	}
 
-	mappingBuilding = loadMapping<BuildingID>(mapping["buildingsCommon"], "building.core:random");
-	mappingFaction = loadMapping<FactionID>(mapping["factions"], "faction");
-	mappingCreature = loadMapping<CreatureID>(mapping["creatures"], "creature");
-	mappingHeroType = loadMapping<HeroTypeID>(mapping["heroes"], "hero");
-	mappingHeroClass = loadMapping<HeroClassID>(mapping["heroClasses"], "heroClass");
-	mappingTerrain = loadMapping<TerrainId>(mapping["terrains"], "terrain");
-	mappingArtifact = loadMapping<ArtifactID>(mapping["artifacts"], "artifact");
-	mappingSecondarySkill = loadMapping<SecondarySkill>(mapping["skills"], "skill");
+	loadMapping(mappingBuilding, mapping["buildingsCommon"], "building.core:random");
+	loadMapping(mappingFaction, mapping["factions"], "faction");
+	loadMapping(mappingCreature, mapping["creatures"], "creature");
+	loadMapping(mappingHeroType, mapping["heroes"], "hero");
+	loadMapping(mappingHeroClass, mapping["heroClasses"], "heroClass");
+	loadMapping(mappingTerrain, mapping["terrains"], "terrain");
+	loadMapping(mappingArtifact, mapping["artifacts"], "artifact");
+	loadMapping(mappingSecondarySkill, mapping["skills"], "skill");
 }
 
 void MapIdentifiersH3M::remapTemplate(ObjectTemplate & objectTemplate)

+ 1 - 1
lib/mapping/MapIdentifiersH3M.h

@@ -46,7 +46,7 @@ class MapIdentifiersH3M
 	std::map<ObjectTypeIdentifier, ObjectTypeIdentifier> mappingObjectIndex;
 
 	template<typename IdentifierID>
-	std::map<IdentifierID, IdentifierID> loadMapping(const JsonNode & mapping, const std::string & identifierName);
+	void loadMapping(std::map<IdentifierID, IdentifierID> & result, const JsonNode & mapping, const std::string & identifierName);
 public:
 	void loadMapping(const JsonNode & mapping);