MapReaderH3M.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. std::shared_ptr<ObjectTemplate> readObjectTemplate();
  53. void skipUnused(size_t amount);
  54. void skipZero(size_t amount);
  55. void readResourses(TResources & resources);
  56. bool readBool();
  57. ui8 readUInt8();
  58. si8 readInt8();
  59. ui16 readUInt16();
  60. si16 readInt16();
  61. ui32 readUInt32();
  62. si32 readInt32();
  63. std::string readBaseString();
  64. CBinaryReader & getInternalReader();
  65. private:
  66. template<class Identifier>
  67. Identifier remapIdentifier(const Identifier & identifier);
  68. template<class Identifier>
  69. void readBitmask(std::set<Identifier> & dest, int bytesToRead, int objectsToRead, bool invert);
  70. template<class Identifier>
  71. void readBitmask(std::vector<bool> & 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