MapReaderH3M.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 readArtifact32();
  29. CreatureID readCreature();
  30. HeroTypeID readHero();
  31. int32_t readHeroPortrait();
  32. TerrainId readTerrain();
  33. RoadId readRoad();
  34. RiverId readRiver();
  35. SecondarySkill readSkill();
  36. SpellID readSpell();
  37. SpellID readSpell32();
  38. PlayerColor readPlayer();
  39. PlayerColor readPlayer32();
  40. void readBitmaskBuildings(std::set<BuildingID> & dest, std::optional<FactionID> faction);
  41. void readBitmaskFactions(std::set<FactionID> & dest, bool invert);
  42. void readBitmaskPlayers(std::set<PlayerColor> & dest, bool invert);
  43. void readBitmaskResources(std::set<GameResID> & dest, bool invert);
  44. void readBitmaskHeroClassesSized(std::set<HeroClassID> & dest, bool invert);
  45. void readBitmaskHeroes(std::vector<bool> & dest, bool invert);
  46. void readBitmaskHeroesSized(std::vector<bool> & dest, bool invert);
  47. void readBitmaskArtifacts(std::vector<bool> & dest, bool invert);
  48. void readBitmaskArtifactsSized(std::vector<bool> & dest, bool invert);
  49. void readBitmaskSpells(std::vector<bool> & dest, bool invert);
  50. void readBitmaskSpells(std::set<SpellID> & dest, bool invert);
  51. void readBitmaskSkills(std::vector<bool> & 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. template<class Identifier>
  73. void readBitmask(std::vector<bool> & dest, int bytesToRead, int objectsToRead, bool invert);
  74. MapFormatFeaturesH3M features;
  75. MapIdentifiersH3M remapper;
  76. std::unique_ptr<CBinaryReader> reader;
  77. };
  78. VCMI_LIB_NAMESPACE_END