2010-12-17 20:47:07 +02:00
|
|
|
|
2009-04-15 17:03:31 +03:00
|
|
|
/*
|
2012-11-03 16:30:47 +03:00
|
|
|
* CMap.h, part of VCMI engine
|
2009-04-15 17:03:31 +03:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-11-03 16:30:47 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../ConstTransitivePtr.h"
|
2014-06-05 19:52:14 +03:00
|
|
|
#include "../mapObjects/MiscObjects.h" // To serialize static props
|
|
|
|
#include "../mapObjects/CQuest.h" // To serialize static props
|
|
|
|
#include "../mapObjects/CGTownInstance.h" // To serialize static props
|
2012-11-03 16:30:47 +03:00
|
|
|
#include "../ResourceSet.h"
|
|
|
|
#include "../int3.h"
|
|
|
|
#include "../GameConstants.h"
|
2013-12-29 14:27:38 +03:00
|
|
|
#include "../LogicalExpression.h"
|
2015-12-02 21:05:10 +02:00
|
|
|
#include "CMapDefines.h"
|
2012-11-03 16:30:47 +03:00
|
|
|
|
2010-12-17 20:47:07 +02:00
|
|
|
class CArtifactInstance;
|
2008-12-27 03:01:59 +02:00
|
|
|
class CGObjectInstance;
|
|
|
|
class CGHeroInstance;
|
2012-04-22 20:38:36 +03:00
|
|
|
class CCommanderInstance;
|
2010-02-02 19:05:03 +02:00
|
|
|
class CGCreature;
|
2008-12-27 03:01:59 +02:00
|
|
|
class CQuest;
|
|
|
|
class CGTownInstance;
|
2010-11-10 02:06:25 +02:00
|
|
|
class IModableArt;
|
2012-09-16 16:34:01 +03:00
|
|
|
class IQuestObject;
|
2012-09-26 16:13:39 +03:00
|
|
|
class CInputStream;
|
2013-04-19 14:43:11 +03:00
|
|
|
class CMapEditManager;
|
2012-09-26 16:13:39 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The hero name struct consists of the hero id and the hero name.
|
2012-11-06 19:39:29 +03:00
|
|
|
struct DLL_LINKAGE SHeroName
|
2012-10-26 20:51:05 +03:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
SHeroName();
|
|
|
|
|
|
|
|
int heroId;
|
|
|
|
std::string heroName;
|
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & heroId & heroName;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
2011-02-22 13:52:36 +02:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The player info constains data about which factions are allowed, AI tactical settings,
|
|
|
|
/// the main hero name, where to generate the hero, whether the faction should be selected randomly,...
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE PlayerInfo
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
PlayerInfo();
|
2012-11-06 19:39:29 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Gets the default faction id or -1 for a random faction.
|
2012-11-11 15:23:31 +03:00
|
|
|
si8 defaultCastle() const;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Gets the default hero id or -1 for a random hero.
|
2012-11-11 15:23:31 +03:00
|
|
|
si8 defaultHero() const;
|
2013-04-14 22:24:31 +03:00
|
|
|
bool canAnyonePlay() const;
|
2013-12-23 18:59:37 +03:00
|
|
|
bool hasCustomMainHero() const;
|
2013-04-14 21:52:05 +03:00
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
bool canHumanPlay;
|
|
|
|
bool canComputerPlay;
|
2013-04-16 16:16:58 +03:00
|
|
|
EAiTactic::EAiTactic aiTactic; /// The default value is EAiTactic::RANDOM.
|
2013-12-23 18:59:37 +03:00
|
|
|
|
2012-12-02 15:21:44 +03:00
|
|
|
std::set<TFaction> allowedFactions;
|
2012-11-11 15:23:31 +03:00
|
|
|
bool isFactionRandom;
|
2013-12-23 18:59:37 +03:00
|
|
|
|
|
|
|
si32 mainCustomHeroPortrait; /// The default value is -1.
|
|
|
|
std::string mainCustomHeroName;
|
|
|
|
si32 mainCustomHeroId; /// ID of custom hero (only if portrait and hero name are set, otherwise unpredicted value), -1 if none (not always -1)
|
|
|
|
|
|
|
|
std::vector<SHeroName> heroesNames; /// list of placed heroes on the map
|
2013-04-16 16:16:58 +03:00
|
|
|
bool hasMainTown; /// The default value is false.
|
|
|
|
bool generateHeroAtMainTown; /// The default value is false.
|
2012-11-11 15:23:31 +03:00
|
|
|
int3 posOfMainTown;
|
2015-11-13 12:08:25 +02:00
|
|
|
TeamID team; /// The default value NO_TEAM
|
2013-12-23 18:59:37 +03:00
|
|
|
bool hasRandomHero; /// Player has a random hero
|
2013-04-16 16:16:58 +03:00
|
|
|
|
|
|
|
bool generateHero; /// Unused.
|
|
|
|
si32 p7; /// Unknown and unused.
|
|
|
|
/// Unused. Count of hero placeholders containing hero type.
|
|
|
|
/// WARNING: powerPlaceholders sometimes gives false 0 (eg. even if there is one placeholder), maybe different meaning ???
|
2012-11-20 20:53:45 +03:00
|
|
|
ui8 powerPlaceholders;
|
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
2013-12-23 18:59:37 +03:00
|
|
|
h & p7 & hasRandomHero & mainCustomHeroId & canHumanPlay & canComputerPlay & aiTactic & allowedFactions & isFactionRandom &
|
|
|
|
mainCustomHeroPortrait & mainCustomHeroName & heroesNames & hasMainTown & generateHeroAtMainTown &
|
2013-04-14 22:24:31 +03:00
|
|
|
posOfMainTown & team & generateHero;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
2011-02-22 13:52:36 +02:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The loss condition describes the condition to lose the game. (e.g. lose all own heroes/castles)
|
2013-12-29 14:27:38 +03:00
|
|
|
struct DLL_LINKAGE EventCondition
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2013-12-29 14:27:38 +03:00
|
|
|
enum EWinLoseType {
|
2016-02-22 22:43:57 +02:00
|
|
|
//internal use, deprecated
|
2013-12-29 14:27:38 +03:00
|
|
|
HAVE_ARTIFACT, // type - required artifact
|
|
|
|
HAVE_CREATURES, // type - creatures to collect, value - amount to collect
|
|
|
|
HAVE_RESOURCES, // type - resource ID, value - amount to collect
|
|
|
|
HAVE_BUILDING, // position - town, optional, type - building to build
|
|
|
|
CONTROL, // position - position of object, optional, type - type of object
|
|
|
|
DESTROY, // position - position of object, optional, type - type of object
|
|
|
|
TRANSPORT, // position - where artifact should be transported, type - type of artifact
|
2016-02-22 22:43:57 +02:00
|
|
|
|
|
|
|
//map format version pre 1.0
|
2013-12-29 14:27:38 +03:00
|
|
|
DAYS_PASSED, // value - number of days from start of the game
|
|
|
|
IS_HUMAN, // value - 0 = player is AI, 1 = player is human
|
|
|
|
DAYS_WITHOUT_TOWN, // value - how long player can live without town, 0=instakill
|
2014-02-09 15:10:02 +03:00
|
|
|
STANDARD_WIN, // normal defeat all enemies condition
|
2016-02-22 22:43:57 +02:00
|
|
|
CONST_VALUE, // condition that always evaluates to "value" (0 = false, 1 = true)
|
|
|
|
|
|
|
|
//map format version 1.0+
|
|
|
|
HAVE_0,
|
|
|
|
HAVE_BUILDING_0,
|
|
|
|
DESTROY_0
|
2013-12-29 14:27:38 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
EventCondition(EWinLoseType condition = STANDARD_WIN);
|
2014-02-09 22:47:23 +03:00
|
|
|
EventCondition(EWinLoseType condition, si32 value, si32 objectType, int3 position = int3(-1, -1, -1));
|
2013-12-29 14:27:38 +03:00
|
|
|
|
2016-02-22 22:43:57 +02:00
|
|
|
const CGObjectInstance * object; // object that was at specified position or with instance name on start
|
2013-12-29 14:27:38 +03:00
|
|
|
si32 value;
|
|
|
|
si32 objectType;
|
2016-02-22 22:43:57 +02:00
|
|
|
si32 objectSubtype;
|
|
|
|
std::string objectInstanceName;
|
2013-12-29 14:27:38 +03:00
|
|
|
int3 position;
|
|
|
|
EWinLoseType condition;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-12-29 14:27:38 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
2016-02-18 16:48:04 +02:00
|
|
|
h & object;
|
|
|
|
h & value;
|
|
|
|
h & objectType;
|
|
|
|
h & position;
|
|
|
|
h & condition;
|
2016-02-22 22:43:57 +02:00
|
|
|
if(version > 759)
|
|
|
|
{
|
|
|
|
h & objectSubtype;
|
|
|
|
h & objectInstanceName;
|
|
|
|
}
|
2013-12-29 14:27:38 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef LogicalExpression<EventCondition> EventExpression;
|
|
|
|
|
2013-12-29 17:35:38 +03:00
|
|
|
struct DLL_LINKAGE EventEffect
|
2013-12-29 14:27:38 +03:00
|
|
|
{
|
|
|
|
enum EType
|
|
|
|
{
|
|
|
|
VICTORY,
|
|
|
|
DEFEAT
|
|
|
|
};
|
|
|
|
|
|
|
|
/// effect type, using EType enum
|
|
|
|
si8 type;
|
|
|
|
|
|
|
|
/// message that will be sent to other players
|
|
|
|
std::string toOtherMessage;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
2013-12-29 14:27:38 +03:00
|
|
|
h & type & toOtherMessage;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
2011-02-22 13:52:36 +02:00
|
|
|
|
2013-12-29 17:35:38 +03:00
|
|
|
struct DLL_LINKAGE TriggeredEvent
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2013-12-29 14:27:38 +03:00
|
|
|
/// base condition that must be evaluated
|
|
|
|
EventExpression trigger;
|
|
|
|
|
|
|
|
/// string identifier read from config file (e.g. captureKreelah)
|
|
|
|
std::string identifier;
|
|
|
|
|
|
|
|
/// string-description, for use in UI (capture town to win)
|
|
|
|
std::string description;
|
|
|
|
|
|
|
|
/// Message that will be displayed when this event is triggered (You captured town. You won!)
|
|
|
|
std::string onFulfill;
|
|
|
|
|
|
|
|
/// Effect of this event. TODO: refactor into something more flexible
|
|
|
|
EventEffect effect;
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
2016-02-18 16:48:04 +02:00
|
|
|
h & identifier;
|
|
|
|
h & trigger;
|
|
|
|
h & description;
|
|
|
|
h & onFulfill & effect;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The rumor struct consists of a rumor name and text.
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE Rumor
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
std::string name;
|
|
|
|
std::string text;
|
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & name & text;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The disposed hero struct describes which hero can be hired from which player.
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE DisposedHero
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
DisposedHero();
|
|
|
|
|
|
|
|
ui32 heroId;
|
2013-04-16 16:16:58 +03:00
|
|
|
ui16 portrait; /// The portrait id of the hero, 0xFF is default.
|
2012-11-11 15:23:31 +03:00
|
|
|
std::string name;
|
2013-04-16 16:16:58 +03:00
|
|
|
ui8 players; /// Who can hire this hero (bitfield).
|
2012-11-11 15:23:31 +03:00
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & heroId & portrait & name & players;
|
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
|
|
|
|
2012-10-26 20:51:05 +03:00
|
|
|
namespace EMapFormat
|
|
|
|
{
|
2016-02-18 16:48:04 +02:00
|
|
|
enum EMapFormat: ui8
|
2013-04-14 22:24:31 +03:00
|
|
|
{
|
2013-05-04 22:20:32 +03:00
|
|
|
INVALID = 0,
|
|
|
|
// HEX DEC
|
|
|
|
ROE = 0x0e, // 14
|
|
|
|
AB = 0x15, // 21
|
|
|
|
SOD = 0x1c, // 28
|
2013-12-29 14:27:38 +03:00
|
|
|
// HOTA = 0x1e ... 0x20 // 28 ... 30
|
2016-02-09 19:20:03 +02:00
|
|
|
WOG = 0x33, // 51
|
|
|
|
VCMI = 0xF0
|
2013-04-14 22:24:31 +03:00
|
|
|
};
|
2012-10-26 20:51:05 +03:00
|
|
|
}
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The map header holds information about loss/victory condition,map format, version, players, height, width,...
|
2011-12-14 00:23:17 +03:00
|
|
|
class DLL_LINKAGE CMapHeader
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2013-12-29 14:27:38 +03:00
|
|
|
void setupEvents();
|
2008-12-27 03:01:59 +02:00
|
|
|
public:
|
2013-05-11 20:36:11 +03:00
|
|
|
static const int MAP_SIZE_SMALL;
|
|
|
|
static const int MAP_SIZE_MIDDLE;
|
|
|
|
static const int MAP_SIZE_LARGE;
|
|
|
|
static const int MAP_SIZE_XLARGE;
|
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
CMapHeader();
|
|
|
|
virtual ~CMapHeader();
|
2012-10-26 20:51:05 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
EMapFormat::EMapFormat version; /// The default value is EMapFormat::SOD.
|
|
|
|
si32 height; /// The default value is 72.
|
|
|
|
si32 width; /// The default value is 72.
|
|
|
|
bool twoLevel; /// The default value is true.
|
2012-11-11 15:23:31 +03:00
|
|
|
std::string name;
|
|
|
|
std::string description;
|
2013-04-16 16:16:58 +03:00
|
|
|
ui8 difficulty; /// The default value is 1 representing a normal map difficulty.
|
|
|
|
/// Specifies the maximum level to reach for a hero. A value of 0 states that there is no
|
|
|
|
/// maximum level for heroes. This is the default value.
|
2012-11-11 15:23:31 +03:00
|
|
|
ui8 levelLimit;
|
2013-12-29 14:27:38 +03:00
|
|
|
|
|
|
|
std::string victoryMessage;
|
|
|
|
std::string defeatMessage;
|
|
|
|
ui16 victoryIconIndex;
|
|
|
|
ui16 defeatIconIndex;
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
std::vector<PlayerInfo> players; /// The default size of the vector is PlayerColor::PLAYER_LIMIT.
|
2012-11-11 15:23:31 +03:00
|
|
|
ui8 howManyTeams;
|
2013-02-05 00:58:42 +03:00
|
|
|
std::vector<bool> allowedHeroes;
|
2016-02-21 21:12:58 +02:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
bool areAnyPlayers; /// Unused. True if there are any playable players on the map.
|
2012-10-26 20:51:05 +03:00
|
|
|
|
2013-12-29 14:27:38 +03:00
|
|
|
/// "main quests" of the map that describe victory and loss conditions
|
|
|
|
std::vector<TriggeredEvent> triggeredEvents;
|
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int Version)
|
|
|
|
{
|
|
|
|
h & version & name & description & width & height & twoLevel & difficulty & levelLimit & areAnyPlayers;
|
2013-12-29 14:27:38 +03:00
|
|
|
h & players & howManyTeams & allowedHeroes & triggeredEvents;
|
|
|
|
h & victoryMessage & victoryIconIndex & defeatMessage & defeatIconIndex;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
2009-01-06 20:42:20 +02:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The map contains the map header, the tiles of the terrain, objects, heroes, towns, rumors...
|
2012-10-26 20:51:05 +03:00
|
|
|
class DLL_LINKAGE CMap : public CMapHeader
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2012-10-26 20:51:05 +03:00
|
|
|
public:
|
2012-11-11 15:23:31 +03:00
|
|
|
CMap();
|
|
|
|
~CMap();
|
2013-04-16 16:16:58 +03:00
|
|
|
void initTerrain();
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-04-19 14:43:11 +03:00
|
|
|
CMapEditManager * getEditManager();
|
2012-11-11 15:23:31 +03:00
|
|
|
TerrainTile & getTile(const int3 & tile);
|
|
|
|
const TerrainTile & getTile(const int3 & tile) const;
|
2015-08-15 20:46:28 +02:00
|
|
|
bool isCoastalTile(const int3 & pos) const;
|
2012-11-11 15:23:31 +03:00
|
|
|
bool isInTheMap(const int3 & pos) const;
|
|
|
|
bool isWaterTile(const int3 & pos) const;
|
2015-08-15 20:46:28 +02:00
|
|
|
|
2014-04-01 14:53:28 +03:00
|
|
|
bool checkForVisitableDir( const int3 & src, const TerrainTile *pom, const int3 & dst ) const;
|
|
|
|
int3 guardingCreaturePosition (int3 pos) const;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
void addBlockVisTiles(CGObjectInstance * obj);
|
|
|
|
void removeBlockVisTiles(CGObjectInstance * obj, bool total = false);
|
2014-04-01 14:53:28 +03:00
|
|
|
void calculateGuardingGreaturePositions();
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
void addNewArtifactInstance(CArtifactInstance * art);
|
|
|
|
void eraseArtifactInstance(CArtifactInstance * art);
|
2016-09-08 13:24:28 +02:00
|
|
|
|
2016-02-22 18:26:42 +02:00
|
|
|
void addNewObject(CGObjectInstance * obj);
|
2013-01-06 22:30:12 +03:00
|
|
|
|
2013-12-29 14:27:38 +03:00
|
|
|
/// Gets object of specified type on requested position
|
|
|
|
const CGObjectInstance * getObjectiveObjectFrom(int3 pos, Obj::EObj type);
|
2013-04-16 16:16:58 +03:00
|
|
|
CGHeroInstance * getHero(int heroId);
|
2013-01-06 22:30:12 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Sets the victory/loss condition objectives ??
|
|
|
|
void checkForObjectives();
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
ui32 checksum;
|
2012-11-11 15:23:31 +03:00
|
|
|
std::vector<Rumor> rumors;
|
|
|
|
std::vector<DisposedHero> disposedHeroes;
|
|
|
|
std::vector<ConstTransitivePtr<CGHeroInstance> > predefinedHeroes;
|
2013-02-05 00:58:42 +03:00
|
|
|
std::vector<bool> allowedSpell;
|
|
|
|
std::vector<bool> allowedArtifact;
|
|
|
|
std::vector<bool> allowedAbilities;
|
2013-02-19 01:37:22 +03:00
|
|
|
std::list<CMapEvent> events;
|
2012-11-11 15:23:31 +03:00
|
|
|
int3 grailPos;
|
2016-01-31 17:01:58 +02:00
|
|
|
int grailRadius;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-05-19 01:30:48 +03:00
|
|
|
//Central lists of items in game. Position of item in the vectors below is their (instance) id.
|
2012-11-11 15:23:31 +03:00
|
|
|
std::vector< ConstTransitivePtr<CGObjectInstance> > objects;
|
|
|
|
std::vector< ConstTransitivePtr<CGTownInstance> > towns;
|
|
|
|
std::vector< ConstTransitivePtr<CArtifactInstance> > artInstances;
|
|
|
|
std::vector< ConstTransitivePtr<CQuest> > quests;
|
2013-05-19 01:30:48 +03:00
|
|
|
std::vector< ConstTransitivePtr<CGHeroInstance> > allHeroes; //indexed by [hero_type_id]; on map, disposed, prisons, etc.
|
|
|
|
|
|
|
|
//Helper lists
|
2013-12-23 18:59:37 +03:00
|
|
|
std::vector< ConstTransitivePtr<CGHeroInstance> > heroesOnMap;
|
2015-12-29 04:43:33 +02:00
|
|
|
std::map<TeleportChannelID, std::shared_ptr<TeleportChannel> > teleportChannels;
|
2013-12-23 18:59:37 +03:00
|
|
|
|
|
|
|
/// associative list to identify which hero/creature id belongs to which object id(index for objects)
|
|
|
|
std::map<si32, ObjectInstanceID> questIdentifierToId;
|
|
|
|
|
2015-12-29 04:43:33 +02:00
|
|
|
std::unique_ptr<CMapEditManager> editManager;
|
2013-12-23 18:59:37 +03:00
|
|
|
|
2014-04-01 14:53:28 +03:00
|
|
|
int3 ***guardingCreaturePositions;
|
|
|
|
|
2016-02-22 18:26:42 +02:00
|
|
|
std::map<std::string, ConstTransitivePtr<CGObjectInstance> > instanceNames;
|
|
|
|
|
2013-04-19 14:43:11 +03:00
|
|
|
private:
|
2013-12-21 20:34:59 +03:00
|
|
|
/// a 3-dimensional array of terrain tiles, access is as follows: x, y, level. where level=1 is underground
|
2013-04-19 14:43:11 +03:00
|
|
|
TerrainTile*** terrain;
|
|
|
|
|
|
|
|
public:
|
2012-11-11 15:23:31 +03:00
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler &h, const int formatVersion)
|
|
|
|
{
|
|
|
|
h & static_cast<CMapHeader&>(*this);
|
|
|
|
h & rumors & allowedSpell & allowedAbilities & allowedArtifact & events & grailPos;
|
2013-05-20 11:37:31 +03:00
|
|
|
h & artInstances & quests & allHeroes;
|
2012-11-11 15:23:31 +03:00
|
|
|
h & questIdentifierToId;
|
|
|
|
|
|
|
|
//TODO: viccondetails
|
2014-04-01 14:53:28 +03:00
|
|
|
int level = twoLevel ? 2 : 1;
|
2012-11-11 15:23:31 +03:00
|
|
|
if(h.saving)
|
|
|
|
{
|
|
|
|
// Save terrain
|
|
|
|
for(int i = 0; i < width ; ++i)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < height ; ++j)
|
|
|
|
{
|
2014-04-01 14:53:28 +03:00
|
|
|
for(int k = 0; k < level; ++k)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
h & terrain[i][j][k];
|
2014-04-01 14:53:28 +03:00
|
|
|
h & guardingCreaturePositions[i][j][k];
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Load terrain
|
|
|
|
terrain = new TerrainTile**[width];
|
2014-04-01 14:53:28 +03:00
|
|
|
guardingCreaturePositions = new int3**[width];
|
|
|
|
for(int i = 0; i < width; ++i)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2014-04-01 14:53:28 +03:00
|
|
|
terrain[i] = new TerrainTile*[height];
|
|
|
|
guardingCreaturePositions[i] = new int3*[height];
|
|
|
|
for(int j = 0; j < height; ++j)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
2014-04-01 14:53:28 +03:00
|
|
|
terrain[i][j] = new TerrainTile[level];
|
|
|
|
guardingCreaturePositions[i][j] = new int3[level];
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i = 0; i < width ; ++i)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < height ; ++j)
|
|
|
|
{
|
2014-04-01 14:53:28 +03:00
|
|
|
for(int k = 0; k < level; ++k)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
h & terrain[i][j][k];
|
2014-04-01 14:53:28 +03:00
|
|
|
h & guardingCreaturePositions[i][j][k];
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-01-03 02:48:38 +03:00
|
|
|
h & objects;
|
2015-03-08 15:11:23 +02:00
|
|
|
h & heroesOnMap & teleportChannels & towns & artInstances;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
|
|
|
// static members
|
|
|
|
h & CGKeys::playerKeyMap;
|
|
|
|
h & CGMagi::eyelist;
|
|
|
|
h & CGObelisk::obeliskCount & CGObelisk::visited;
|
|
|
|
h & CGTownInstance::merchantArtifacts;
|
2012-12-13 16:07:56 +03:00
|
|
|
h & CGTownInstance::universitySkills;
|
2016-02-22 18:26:42 +02:00
|
|
|
|
2016-02-24 01:59:34 +02:00
|
|
|
if(formatVersion >= 759)
|
2016-02-22 18:26:42 +02:00
|
|
|
{
|
|
|
|
h & instanceNames;
|
|
|
|
}
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|