2023-10-19 16:19:09 +02:00
|
|
|
/*
|
|
|
|
* MapReaderH3M.h, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../GameConstants.h"
|
|
|
|
#include "../ResourceSet.h"
|
|
|
|
#include "MapFeaturesH3M.h"
|
|
|
|
#include "MapIdentifiersH3M.h"
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class CBinaryReader;
|
|
|
|
class CInputStream;
|
|
|
|
struct MapFormatFeaturesH3M;
|
|
|
|
class int3;
|
|
|
|
enum class EMapFormat : uint8_t;
|
|
|
|
|
|
|
|
class MapReaderH3M
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit MapReaderH3M(CInputStream * stream);
|
|
|
|
|
|
|
|
void setFormatLevel(const MapFormatFeaturesH3M & features);
|
|
|
|
void setIdentifierRemapper(const MapIdentifiersH3M & remapper);
|
|
|
|
|
|
|
|
ArtifactID readArtifact();
|
2023-11-08 17:35:17 +02:00
|
|
|
ArtifactID readArtifact8();
|
2023-10-19 16:19:09 +02:00
|
|
|
ArtifactID readArtifact32();
|
|
|
|
CreatureID readCreature();
|
|
|
|
HeroTypeID readHero();
|
|
|
|
HeroTypeID readHeroPortrait();
|
|
|
|
TerrainId readTerrain();
|
|
|
|
RoadId readRoad();
|
|
|
|
RiverId readRiver();
|
2024-02-05 21:27:55 +02:00
|
|
|
PrimarySkill readPrimary();
|
2023-10-19 16:19:09 +02:00
|
|
|
SecondarySkill readSkill();
|
|
|
|
SpellID readSpell();
|
|
|
|
SpellID readSpell32();
|
2023-11-08 17:35:17 +02:00
|
|
|
GameResID readGameResID();
|
2023-10-19 16:19:09 +02:00
|
|
|
PlayerColor readPlayer();
|
|
|
|
PlayerColor readPlayer32();
|
|
|
|
|
|
|
|
void readBitmaskBuildings(std::set<BuildingID> & dest, std::optional<FactionID> faction);
|
|
|
|
void readBitmaskFactions(std::set<FactionID> & dest, bool invert);
|
|
|
|
void readBitmaskPlayers(std::set<PlayerColor> & dest, bool invert);
|
|
|
|
void readBitmaskResources(std::set<GameResID> & dest, bool invert);
|
|
|
|
void readBitmaskHeroClassesSized(std::set<HeroClassID> & dest, bool invert);
|
2023-11-05 15:24:26 +02:00
|
|
|
void readBitmaskHeroes(std::set<HeroTypeID> & dest, bool invert);
|
|
|
|
void readBitmaskHeroesSized(std::set<HeroTypeID> & dest, bool invert);
|
|
|
|
void readBitmaskArtifacts(std::set<ArtifactID> & dest, bool invert);
|
|
|
|
void readBitmaskArtifactsSized(std::set<ArtifactID> & dest, bool invert);
|
2023-10-19 16:19:09 +02:00
|
|
|
void readBitmaskSpells(std::set<SpellID> & dest, bool invert);
|
|
|
|
void readBitmaskSkills(std::set<SecondarySkill> & dest, bool invert);
|
|
|
|
|
|
|
|
int3 readInt3();
|
|
|
|
|
|
|
|
std::shared_ptr<ObjectTemplate> readObjectTemplate();
|
|
|
|
|
|
|
|
void skipUnused(size_t amount);
|
|
|
|
void skipZero(size_t amount);
|
|
|
|
|
|
|
|
void readResourses(TResources & resources);
|
|
|
|
|
|
|
|
bool readBool();
|
|
|
|
|
2024-02-05 21:27:55 +02:00
|
|
|
uint8_t readUInt8();
|
|
|
|
int8_t readInt8();
|
|
|
|
int8_t readInt8Checked(int8_t lowerLimit, int8_t upperLimit);
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-02-05 21:27:55 +02:00
|
|
|
uint16_t readUInt16();
|
|
|
|
|
|
|
|
uint32_t readUInt32();
|
|
|
|
int32_t readInt32();
|
2023-10-19 16:19:09 +02:00
|
|
|
|
2024-02-05 21:27:55 +02:00
|
|
|
std::string readBaseString();
|
2023-10-19 16:19:09 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
template<class Identifier>
|
|
|
|
Identifier remapIdentifier(const Identifier & identifier);
|
|
|
|
|
|
|
|
template<class Identifier>
|
|
|
|
void readBitmask(std::set<Identifier> & dest, int bytesToRead, int objectsToRead, bool invert);
|
|
|
|
|
|
|
|
MapFormatFeaturesH3M features;
|
|
|
|
MapIdentifiersH3M remapper;
|
|
|
|
|
|
|
|
std::unique_ptr<CBinaryReader> reader;
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|