MapReaderH3M.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. TerrainId readTerrain();
  32. RoadId readRoad();
  33. RiverId readRiver();
  34. SecondarySkill readSkill();
  35. SpellID readSpell();
  36. SpellID readSpell32();
  37. PlayerColor readPlayer();
  38. PlayerColor readPlayer32();
  39. void readBitmaskBuildings(std::set<BuildingID> & dest, std::optional<FactionID> faction);
  40. void readBitmaskFactions(std::set<FactionID> & dest, bool invert);
  41. void readBitmaskResources(std::set<GameResID> & dest, bool invert);
  42. void readBitmaskHeroClassesSized(std::set<HeroClassID> & dest, bool invert);
  43. void readBitmaskHeroes(std::vector<bool> & dest, bool invert);
  44. void readBitmaskHeroesSized(std::vector<bool> & dest, bool invert);
  45. void readBitmaskArtifacts(std::vector<bool> & dest, bool invert);
  46. void readBitmaskArtifactsSized(std::vector<bool> & dest, bool invert);
  47. void readBitmaskSpells(std::vector<bool> & dest, bool invert);
  48. void readBitmaskSpells(std::set<SpellID> & dest, bool invert);
  49. void readBitmaskSkills(std::vector<bool> & dest, bool invert);
  50. void readBitmaskSkills(std::set<SecondarySkill> & dest, bool invert);
  51. int3 readInt3();
  52. void skipUnused(size_t amount);
  53. void skipZero(size_t amount);
  54. void readResourses(TResources & resources);
  55. bool readBool();
  56. ui8 readUInt8();
  57. si8 readInt8();
  58. ui16 readUInt16();
  59. si16 readInt16();
  60. ui32 readUInt32();
  61. si32 readInt32();
  62. std::string readBaseString();
  63. CBinaryReader & getInternalReader();
  64. private:
  65. template<class Identifier>
  66. Identifier remapIdentifier(const Identifier & identifier);
  67. template<class Identifier>
  68. void readBitmask(std::set<Identifier> & dest, int bytesToRead, int objectsToRead, bool invert);
  69. template<class Identifier>
  70. void readBitmask(std::vector<bool> & dest, int bytesToRead, int objectsToRead, bool invert);
  71. MapFormatFeaturesH3M features;
  72. MapIdentifiersH3M remapper;
  73. std::unique_ptr<CBinaryReader> reader;
  74. };
  75. VCMI_LIB_NAMESPACE_END