1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-04-11 11:31:52 +02:00

Fix buildings loading

This commit is contained in:
Ivan Savenko 2023-05-26 00:38:00 +03:00
parent 3519fd8302
commit fce5f9f907
3 changed files with 13 additions and 17 deletions

View File

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

View File

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

View File

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