|
|
@@ -11,17 +11,12 @@
|
|
|
#pragma once
|
|
|
|
|
|
#include "CMapService.h"
|
|
|
-#include "../GameConstants.h"
|
|
|
-#include "../ResourceSet.h"
|
|
|
-#include "../mapObjects/ObjectTemplate.h"
|
|
|
-
|
|
|
-#include "../int3.h"
|
|
|
-
|
|
|
+#include "MapFeaturesH3M.h"
|
|
|
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
|
|
|
|
|
class CGHeroInstance;
|
|
|
-class CBinaryReader;
|
|
|
+class MapReaderH3M;
|
|
|
class CArtifactInstance;
|
|
|
class CGObjectInstance;
|
|
|
class CGSeerHut;
|
|
|
@@ -30,7 +25,14 @@ class CGTownInstance;
|
|
|
class CCreatureSet;
|
|
|
class CInputStream;
|
|
|
class TextIdentifier;
|
|
|
+class CGPandoraBox;
|
|
|
|
|
|
+class ObjectInstanceID;
|
|
|
+class BuildingID;
|
|
|
+class ObjectTemplate;
|
|
|
+class SpellID;
|
|
|
+class PlayerColor;
|
|
|
+class int3;
|
|
|
|
|
|
class DLL_LINKAGE CMapLoaderH3M : public IMapLoader
|
|
|
{
|
|
|
@@ -61,9 +63,6 @@ public:
|
|
|
*/
|
|
|
std::unique_ptr<CMapHeader> loadMapHeader() override;
|
|
|
|
|
|
- /** true if you want to enable the map loader profiler to see how long a specific part took; default=false */
|
|
|
- static const bool IS_PROFILING_ENABLED;
|
|
|
-
|
|
|
private:
|
|
|
/**
|
|
|
* Initializes the map object from parsing the input buffer.
|
|
|
@@ -90,6 +89,11 @@ private:
|
|
|
*/
|
|
|
void readTeamInfo();
|
|
|
|
|
|
+ /**
|
|
|
+ * Reads the list of map flags.
|
|
|
+ */
|
|
|
+ void readMapOptions();
|
|
|
+
|
|
|
/**
|
|
|
* Reads the list of allowed heroes.
|
|
|
*/
|
|
|
@@ -151,6 +155,36 @@ private:
|
|
|
*/
|
|
|
void readObjects();
|
|
|
|
|
|
+ /// Reads single object from input stream based on template
|
|
|
+ CGObjectInstance * readObject(std::shared_ptr<const ObjectTemplate> objectTemplate, const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
|
|
+
|
|
|
+ CGObjectInstance * readEvent(const int3 & objectPosition);
|
|
|
+ CGObjectInstance * readMonster(const int3 & objectPosition, const ObjectInstanceID & idToBeGiven);
|
|
|
+ CGObjectInstance * readHero(const int3 & initialPos, const ObjectInstanceID & idToBeGiven);
|
|
|
+ CGObjectInstance * readSeerHut(const int3 & initialPos);
|
|
|
+ CGObjectInstance * readTown(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readSign(const int3 & position);
|
|
|
+ CGObjectInstance * readWitchHut();
|
|
|
+ CGObjectInstance * readScholar();
|
|
|
+ CGObjectInstance * readGarrison(const int3 & mapPosition);
|
|
|
+ CGObjectInstance * readArtifact(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readResource(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readMine(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readPandora(const int3 & position);
|
|
|
+ CGObjectInstance * readDwelling(const int3 & position);
|
|
|
+ CGObjectInstance * readDwellingRandom(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readShrine();
|
|
|
+ CGObjectInstance * readHeroPlaceholder(const int3 & position);
|
|
|
+ CGObjectInstance * readGrail(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
|
|
+ CGObjectInstance * readPyramid(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readBorderGuard();
|
|
|
+ CGObjectInstance * readBorderGate(const int3 & position, std::shared_ptr<const ObjectTemplate> objTempl);
|
|
|
+ CGObjectInstance * readQuestGuard(const int3 & position);
|
|
|
+ CGObjectInstance * readShipyard(const int3 & mapPosition);
|
|
|
+ CGObjectInstance * readLighthouse(const int3 & mapPosition);
|
|
|
+ CGObjectInstance * readGeneric(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
|
|
+ CGObjectInstance * readBank(const int3 & position, std::shared_ptr<const ObjectTemplate> objectTemplate);
|
|
|
+
|
|
|
/**
|
|
|
* Reads a creature set.
|
|
|
*
|
|
|
@@ -160,19 +194,11 @@ private:
|
|
|
void readCreatureSet(CCreatureSet * out, int number);
|
|
|
|
|
|
/**
|
|
|
- * Reads a hero.
|
|
|
- *
|
|
|
- * @param idToBeGiven the object id which should be set for the hero
|
|
|
- * @return a object instance
|
|
|
- */
|
|
|
- CGObjectInstance * readHero(const ObjectInstanceID & idToBeGiven, const int3 & initialPos);
|
|
|
-
|
|
|
- /**
|
|
|
- * Reads a seer hut.
|
|
|
+ * Reads a quest for the given quest guard.
|
|
|
*
|
|
|
- * @return the initialized seer hut object
|
|
|
+ * @param guard the quest guard where that quest should be applied to
|
|
|
*/
|
|
|
- CGSeerHut * readSeerHut(const int3 & position);
|
|
|
+ void readBoxContent(CGPandoraBox * object, const int3 & position);
|
|
|
|
|
|
/**
|
|
|
* Reads a quest for the given quest guard.
|
|
|
@@ -181,13 +207,7 @@ private:
|
|
|
*/
|
|
|
void readQuest(IQuestObject * guard, const int3 & position);
|
|
|
|
|
|
- /**
|
|
|
- * Reads a town.
|
|
|
- *
|
|
|
- * @param castleID the id of the castle type
|
|
|
- * @return the loaded town object
|
|
|
- */
|
|
|
- CGTownInstance * readTown(int castleID, const int3 & position);
|
|
|
+ void readSeerHutQuest(CGSeerHut * hut, const int3 & position);
|
|
|
|
|
|
/**
|
|
|
* Converts buildings to the specified castle id.
|
|
|
@@ -209,42 +229,19 @@ private:
|
|
|
*/
|
|
|
void readMessageAndGuards(std::string & message, CCreatureSet * guards, const int3 & position);
|
|
|
|
|
|
- void readSpells(std::set<SpellID> & dest);
|
|
|
-
|
|
|
- void readResourses(TResources& resources);
|
|
|
-
|
|
|
- template <class Indenifier>
|
|
|
- void readBitmask(std::set<Indenifier> &dest, const int byteCount, const int limit, bool negate = true);
|
|
|
-
|
|
|
- /** Reads bitmask to boolean vector
|
|
|
- * @param dest destination vector, shall be filed with "true" values
|
|
|
- * @param byteCount size in bytes of bimask
|
|
|
- * @param limit max count of vector elements to alter
|
|
|
- * @param negate if true then set bit in mask means clear flag in vertor
|
|
|
- */
|
|
|
- void readBitmask(std::vector<bool> & dest, const int byteCount, const int limit, bool negate = true);
|
|
|
-
|
|
|
- /**
|
|
|
- * Reverses the input argument.
|
|
|
- *
|
|
|
- * @param arg the input argument
|
|
|
- * @return the reversed 8-bit integer
|
|
|
- */
|
|
|
- ui8 reverse(ui8 arg) const;
|
|
|
-
|
|
|
- /**
|
|
|
- * Helper to read map position
|
|
|
- */
|
|
|
- int3 readInt3();
|
|
|
-
|
|
|
/// reads string from input stream and converts it to unicode
|
|
|
std::string readBasicString();
|
|
|
|
|
|
/// reads string from input stream, converts it to unicode and attempts to translate it
|
|
|
std::string readLocalizedString(const TextIdentifier & identifier);
|
|
|
|
|
|
+ void setOwnerAndValidate(const int3 & mapPosition, CGObjectInstance * object, const PlayerColor & owner);
|
|
|
+ void readSpells(std::set<SpellID> & dest);
|
|
|
+
|
|
|
void afterRead();
|
|
|
|
|
|
+ MapFormatFeaturesH3M features;
|
|
|
+
|
|
|
/** List of templates loaded from the map, used on later stage to create
|
|
|
* objects but not needed for fully functional CMap */
|
|
|
std::vector<std::shared_ptr<const ObjectTemplate>> templates;
|
|
|
@@ -257,7 +254,7 @@ private:
|
|
|
* (when loading a map then the mapHeader ptr points to the same object)
|
|
|
*/
|
|
|
std::unique_ptr<CMapHeader> mapHeader;
|
|
|
- std::unique_ptr<CBinaryReader> reader;
|
|
|
+ std::unique_ptr<MapReaderH3M> reader;
|
|
|
CInputStream * inputStream;
|
|
|
|
|
|
std::string mapName;
|