MapIdentifiersH3M.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * MapIdentifiersH3M.h, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #pragma once
  11. #include "../GameConstants.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. class JsonNode;
  14. class ObjectTemplate;
  15. struct ObjectTypeIdentifier
  16. {
  17. Obj ID;
  18. int32_t subID;
  19. bool operator < (const ObjectTypeIdentifier & other) const
  20. {
  21. if (ID != other.ID)
  22. return ID < other.ID;
  23. return subID < other.subID;
  24. }
  25. };
  26. class MapIdentifiersH3M
  27. {
  28. std::map<BuildingID, BuildingID> mappingBuilding;
  29. std::map<FactionID, std::map<BuildingID, BuildingID>> mappingFactionBuilding;
  30. std::map<FactionID, FactionID> mappingFaction;
  31. std::map<CreatureID, CreatureID> mappingCreature;
  32. std::map<HeroTypeID, HeroTypeID> mappingHeroType;
  33. std::map<HeroClassID, HeroClassID> mappingHeroClass;
  34. std::map<TerrainId, TerrainId> mappingTerrain;
  35. std::map<ArtifactID, ArtifactID> mappingArtifact;
  36. std::map<SecondarySkill, SecondarySkill> mappingSecondarySkill;
  37. std::map<std::string, std::string> mappingObjectTemplate;
  38. std::map<ObjectTypeIdentifier, ObjectTypeIdentifier> mappingObjectIndex;
  39. template<typename IdentifierID>
  40. void loadMapping(std::map<IdentifierID, IdentifierID> & result, const JsonNode & mapping, const std::string & identifierName);
  41. public:
  42. void loadMapping(const JsonNode & mapping);
  43. void remapTemplate(ObjectTemplate & objectTemplate);
  44. BuildingID remapBuilding(std::optional<FactionID> owner, BuildingID input) const;
  45. FactionID remap(FactionID input) const;
  46. CreatureID remap(CreatureID input) const;
  47. HeroTypeID remap(HeroTypeID input) const;
  48. HeroClassID remap(HeroClassID input) const;
  49. TerrainId remap(TerrainId input) const;
  50. ArtifactID remap(ArtifactID input) const;
  51. SecondarySkill remap(SecondarySkill input) const;
  52. };
  53. VCMI_LIB_NAMESPACE_END