2023-04-02 18:56:10 +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"
|
2023-04-03 14:02:15 +02:00
|
|
|
#include "../ResourceSet.h"
|
2023-04-02 18:56:10 +02:00
|
|
|
#include "MapFeaturesH3M.h"
|
2023-05-23 14:07:44 +02:00
|
|
|
#include "MapIdentifiersH3M.h"
|
2023-04-02 18:56:10 +02:00
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
class CBinaryReader;
|
|
|
|
class CInputStream;
|
|
|
|
struct MapFormatFeaturesH3M;
|
|
|
|
class int3;
|
|
|
|
enum class EMapFormat : uint8_t;
|
|
|
|
|
|
|
|
class MapReaderH3M
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
explicit MapReaderH3M(CInputStream * stream);
|
|
|
|
|
2023-05-23 14:07:44 +02:00
|
|
|
void setFormatLevel(const MapFormatFeaturesH3M & features);
|
|
|
|
void setIdentifierRemapper(const MapIdentifiersH3M & remapper);
|
2023-04-02 18:56:10 +02:00
|
|
|
|
|
|
|
ArtifactID readArtifact();
|
2023-04-05 12:40:13 +02:00
|
|
|
ArtifactID readArtifact32();
|
2023-04-02 18:56:10 +02:00
|
|
|
CreatureID readCreature();
|
|
|
|
HeroTypeID readHero();
|
2023-09-28 18:43:04 +02:00
|
|
|
HeroTypeID readHeroPortrait();
|
2023-04-02 18:56:10 +02:00
|
|
|
TerrainId readTerrain();
|
|
|
|
RoadId readRoad();
|
|
|
|
RiverId readRiver();
|
|
|
|
SecondarySkill readSkill();
|
|
|
|
SpellID readSpell();
|
|
|
|
SpellID readSpell32();
|
|
|
|
PlayerColor readPlayer();
|
|
|
|
PlayerColor readPlayer32();
|
|
|
|
|
2023-05-23 15:13:09 +02:00
|
|
|
void readBitmaskBuildings(std::set<BuildingID> & dest, std::optional<FactionID> faction);
|
2023-05-23 21:41:21 +02:00
|
|
|
void readBitmaskFactions(std::set<FactionID> & dest, bool invert);
|
2023-08-25 20:40:19 +02:00
|
|
|
void readBitmaskPlayers(std::set<PlayerColor> & dest, bool invert);
|
2023-05-23 21:41:21 +02:00
|
|
|
void readBitmaskResources(std::set<GameResID> & dest, bool invert);
|
|
|
|
void readBitmaskHeroClassesSized(std::set<HeroClassID> & dest, bool invert);
|
|
|
|
void readBitmaskHeroes(std::vector<bool> & dest, bool invert);
|
|
|
|
void readBitmaskHeroesSized(std::vector<bool> & dest, bool invert);
|
|
|
|
void readBitmaskArtifacts(std::vector<bool> & dest, bool invert);
|
|
|
|
void readBitmaskArtifactsSized(std::vector<bool> & dest, bool invert);
|
|
|
|
void readBitmaskSpells(std::vector<bool> & dest, bool invert);
|
|
|
|
void readBitmaskSpells(std::set<SpellID> & dest, bool invert);
|
|
|
|
void readBitmaskSkills(std::vector<bool> & dest, bool invert);
|
|
|
|
void readBitmaskSkills(std::set<SecondarySkill> & dest, bool invert);
|
2023-05-23 14:07:44 +02:00
|
|
|
|
2023-04-02 18:56:10 +02:00
|
|
|
int3 readInt3();
|
|
|
|
|
2023-05-25 18:35:21 +02:00
|
|
|
std::shared_ptr<ObjectTemplate> readObjectTemplate();
|
|
|
|
|
2023-04-02 18:56:10 +02:00
|
|
|
void skipUnused(size_t amount);
|
|
|
|
void skipZero(size_t amount);
|
|
|
|
|
2023-04-03 14:02:15 +02:00
|
|
|
void readResourses(TResources & resources);
|
2023-04-02 18:56:10 +02:00
|
|
|
|
|
|
|
bool readBool();
|
|
|
|
|
2023-04-03 14:02:15 +02:00
|
|
|
ui8 readUInt8();
|
|
|
|
si8 readInt8();
|
2023-04-02 18:56:10 +02:00
|
|
|
ui16 readUInt16();
|
|
|
|
si16 readInt16();
|
|
|
|
ui32 readUInt32();
|
|
|
|
si32 readInt32();
|
|
|
|
|
|
|
|
std::string readBaseString();
|
|
|
|
|
|
|
|
CBinaryReader & getInternalReader();
|
2023-04-03 14:02:15 +02:00
|
|
|
|
2023-04-02 18:56:10 +02:00
|
|
|
private:
|
2023-05-23 22:55:18 +02:00
|
|
|
template<class Identifier>
|
|
|
|
Identifier remapIdentifier(const Identifier & identifier);
|
|
|
|
|
2023-05-23 21:41:21 +02:00
|
|
|
template<class Identifier>
|
|
|
|
void readBitmask(std::set<Identifier> & dest, int bytesToRead, int objectsToRead, bool invert);
|
|
|
|
|
2023-05-23 22:55:18 +02:00
|
|
|
template<class Identifier>
|
2023-05-23 21:41:21 +02:00
|
|
|
void readBitmask(std::vector<bool> & dest, int bytesToRead, int objectsToRead, bool invert);
|
|
|
|
|
2023-04-02 18:56:10 +02:00
|
|
|
MapFormatFeaturesH3M features;
|
2023-05-23 14:07:44 +02:00
|
|
|
MapIdentifiersH3M remapper;
|
2023-04-02 18:56:10 +02:00
|
|
|
|
|
|
|
std::unique_ptr<CBinaryReader> reader;
|
|
|
|
};
|
|
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_END
|