mirror of
https://github.com/vcmi/vcmi.git
synced 2025-12-01 23:12:49 +02:00
Improvements to type safety of Identifier class
- Constructor of Identifier from integer is now explicit - Lobby hero/town selection now uses Identifiers instead of int's - Removed serialization workaround for hero portraits - Added dummy objects for custom heroes portraits for ID resolver to use - HeroInstance now stores portrait ID only in case of custom portrait - Fixed loading of campaign heroes portraits on RoE maps
This commit is contained in:
@@ -87,15 +87,7 @@ void MapIdentifiersH3M::loadMapping(const JsonNode & mapping)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto entry : mapping["portraits"].Struct())
|
||||
{
|
||||
int32_t sourceID = entry.second.Integer();
|
||||
int32_t targetID = *VLC->identifiers()->getIdentifier(entry.second.meta, "hero", entry.first);
|
||||
int32_t iconID = VLC->heroTypes()->getByIndex(targetID)->getIconIndex();
|
||||
|
||||
mappingHeroPortrait[sourceID] = iconID;
|
||||
}
|
||||
|
||||
loadMapping(mappingHeroPortrait, mapping["portraits"], "hero");
|
||||
loadMapping(mappingBuilding, mapping["buildingsCommon"], "building.core:random");
|
||||
loadMapping(mappingFaction, mapping["factions"], "faction");
|
||||
loadMapping(mappingCreature, mapping["creatures"], "creature");
|
||||
@@ -168,7 +160,7 @@ HeroTypeID MapIdentifiersH3M::remap(HeroTypeID input) const
|
||||
return input;
|
||||
}
|
||||
|
||||
int32_t MapIdentifiersH3M::remapPortrrait(int32_t input) const
|
||||
HeroTypeID MapIdentifiersH3M::remapPortrait(HeroTypeID input) const
|
||||
{
|
||||
if (mappingHeroPortrait.count(input))
|
||||
return mappingHeroPortrait.at(input);
|
||||
|
||||
Reference in New Issue
Block a user