MapReaderH3M.h 2.6 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 readArtifact8();
  29. ArtifactID readArtifact32();
  30. CreatureID readCreature();
  31. HeroTypeID readHero();
  32. HeroTypeID readHeroPortrait();
  33. TerrainId readTerrain();
  34. RoadId readRoad();
  35. RiverId readRiver();
  36. PrimarySkill readPrimary();
  37. SecondarySkill readSkill();
  38. SpellID readSpell();
  39. SpellID readSpell32();
  40. GameResID readGameResID();
  41. PlayerColor readPlayer();
  42. PlayerColor readPlayer32();
  43. void readBitmaskBuildings(std::set<BuildingID> & dest, std::optional<FactionID> faction);
  44. void readBitmaskFactions(std::set<FactionID> & dest, bool invert);
  45. void readBitmaskPlayers(std::set<PlayerColor> & dest, bool invert);
  46. void readBitmaskResources(std::set<GameResID> & dest, bool invert);
  47. void readBitmaskHeroClassesSized(std::set<HeroClassID> & dest, bool invert);
  48. void readBitmaskHeroes(std::set<HeroTypeID> & dest, bool invert);
  49. void readBitmaskHeroesSized(std::set<HeroTypeID> & dest, bool invert);
  50. void readBitmaskArtifacts(std::set<ArtifactID> & dest, bool invert);
  51. void readBitmaskArtifactsSized(std::set<ArtifactID> & dest, bool invert);
  52. void readBitmaskSpells(std::set<SpellID> & dest, bool invert);
  53. void readBitmaskSkills(std::set<SecondarySkill> & dest, bool invert);
  54. int3 readInt3();
  55. std::shared_ptr<ObjectTemplate> readObjectTemplate();
  56. void skipUnused(size_t amount);
  57. void skipZero(size_t amount);
  58. void readResources(TResources & resources);
  59. bool readBool();
  60. uint8_t readUInt8();
  61. int8_t readInt8();
  62. int8_t readInt8Checked(int8_t lowerLimit, int8_t upperLimit);
  63. uint16_t readUInt16();
  64. uint32_t readUInt32();
  65. int32_t readInt32();
  66. std::string readBaseString();
  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