MapReaderH3M.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * MapReaderH3M.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. #include "../ResourceSet.h"
  13. #include "MapFeaturesH3M.h"
  14. #include "MapIdentifiersH3M.h"
  15. VCMI_LIB_NAMESPACE_BEGIN
  16. class CBinaryReader;
  17. class CInputStream;
  18. struct MapFormatFeaturesH3M;
  19. class int3;
  20. enum class EMapFormat : uint8_t;
  21. class MapReaderH3M
  22. {
  23. public:
  24. explicit MapReaderH3M(CInputStream * stream);
  25. void setFormatLevel(const MapFormatFeaturesH3M & features);
  26. void setIdentifierRemapper(const MapIdentifiersH3M & remapper);
  27. ArtifactID readArtifact();
  28. ArtifactID readArtifact8();
  29. ArtifactID readArtifact32();
  30. CreatureID readCreature();
  31. HeroTypeID readHero();
  32. HeroTypeID readHeroPortrait();
  33. TerrainId readTerrain();
  34. RoadId readRoad();
  35. RiverId readRiver();
  36. SecondarySkill readSkill();
  37. SpellID readSpell();
  38. SpellID readSpell32();
  39. GameResID readGameResID();
  40. PlayerColor readPlayer();
  41. PlayerColor readPlayer32();
  42. void readBitmaskBuildings(std::set<BuildingID> & dest, std::optional<FactionID> faction);
  43. void readBitmaskFactions(std::set<FactionID> & dest, bool invert);
  44. void readBitmaskPlayers(std::set<PlayerColor> & dest, bool invert);
  45. void readBitmaskResources(std::set<GameResID> & dest, bool invert);
  46. void readBitmaskHeroClassesSized(std::set<HeroClassID> & dest, bool invert);
  47. void readBitmaskHeroes(std::set<HeroTypeID> & dest, bool invert);
  48. void readBitmaskHeroesSized(std::set<HeroTypeID> & dest, bool invert);
  49. void readBitmaskArtifacts(std::set<ArtifactID> & dest, bool invert);
  50. void readBitmaskArtifactsSized(std::set<ArtifactID> & dest, bool invert);
  51. void readBitmaskSpells(std::set<SpellID> & dest, bool invert);
  52. void readBitmaskSkills(std::set<SecondarySkill> & dest, bool invert);
  53. int3 readInt3();
  54. std::shared_ptr<ObjectTemplate> readObjectTemplate();
  55. void skipUnused(size_t amount);
  56. void skipZero(size_t amount);
  57. void readResourses(TResources & resources);
  58. bool readBool();
  59. ui8 readUInt8();
  60. si8 readInt8();
  61. ui16 readUInt16();
  62. si16 readInt16();
  63. ui32 readUInt32();
  64. si32 readInt32();
  65. std::string readBaseString();
  66. CBinaryReader & getInternalReader();
  67. private:
  68. template<class Identifier>
  69. Identifier remapIdentifier(const Identifier & identifier);
  70. template<class Identifier>
  71. void readBitmask(std::set<Identifier> & dest, int bytesToRead, int objectsToRead, bool invert);
  72. MapFormatFeaturesH3M features;
  73. MapIdentifiersH3M remapper;
  74. std::unique_ptr<CBinaryReader> reader;
  75. };
  76. VCMI_LIB_NAMESPACE_END