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"
|
2012-11-20 20:53:45 +03:00
|
|
|
#include "../CObjectHandler.h"
|
2012-11-03 16:30:47 +03:00
|
|
|
#include "../ResourceSet.h"
|
|
|
|
#include "../int3.h"
|
|
|
|
#include "../GameConstants.h"
|
|
|
|
|
2010-12-17 20:47:07 +02:00
|
|
|
class CArtifactInstance;
|
2008-12-27 03:01:59 +02:00
|
|
|
class CGDefInfo;
|
|
|
|
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
|
|
|
|
2012-11-06 19:39:29 +03:00
|
|
|
namespace EAiTactic
|
|
|
|
{
|
2013-04-14 22:24:31 +03:00
|
|
|
enum EAiTactic
|
|
|
|
{
|
|
|
|
NONE = -1,
|
|
|
|
RANDOM,
|
|
|
|
WARRIOR,
|
|
|
|
BUILDER,
|
|
|
|
EXPLORER
|
|
|
|
};
|
2012-11-06 19:39:29 +03: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-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.
|
2012-12-02 15:21:44 +03:00
|
|
|
std::set<TFaction> allowedFactions;
|
2012-11-11 15:23:31 +03:00
|
|
|
bool isFactionRandom;
|
2013-04-16 16:16:58 +03:00
|
|
|
si32 mainHeroPortrait; /// The default value is -1.
|
2012-11-11 15:23:31 +03:00
|
|
|
std::string mainHeroName;
|
2013-04-16 16:16:58 +03:00
|
|
|
std::vector<SHeroName> heroesNames; /// List of renamed heroes.
|
|
|
|
bool hasMainTown; /// The default value is false.
|
|
|
|
bool generateHeroAtMainTown; /// The default value is false.
|
2012-11-11 15:23:31 +03:00
|
|
|
int3 posOfMainTown;
|
2013-04-16 16:16:58 +03:00
|
|
|
TeamID team; /// The default value is 255 representing that the player belongs to no team.
|
|
|
|
|
|
|
|
bool generateHero; /// Unused.
|
|
|
|
si32 p7; /// Unknown and unused.
|
|
|
|
bool hasHero; /// Player has a (custom?) hero
|
|
|
|
si32 customHeroID; /// ID of custom hero, -1 if none
|
|
|
|
/// 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)
|
|
|
|
{
|
2012-12-10 17:28:27 +03:00
|
|
|
h & p7 & hasHero & customHeroID & canHumanPlay & canComputerPlay & aiTactic & allowedFactions & isFactionRandom &
|
2013-04-14 22:24:31 +03:00
|
|
|
mainHeroPortrait & mainHeroName & heroesNames & hasMainTown & generateHeroAtMainTown &
|
|
|
|
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)
|
2011-12-14 00:23:17 +03:00
|
|
|
struct DLL_LINKAGE LossCondition
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
LossCondition();
|
|
|
|
|
|
|
|
ELossConditionType::ELossConditionType typeOfLossCon;
|
2013-04-16 16:16:58 +03:00
|
|
|
int3 pos; /// the position of an object which mustn't be lost
|
|
|
|
si32 timeLimit; /// time limit in days, -1 if not used
|
2012-11-11 15:23:31 +03:00
|
|
|
const CGObjectInstance * obj;
|
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & typeOfLossCon & pos & timeLimit & obj;
|
|
|
|
}
|
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 victory condition describes the condition to win the game. (e.g. defeat all enemy heroes/castles,
|
|
|
|
/// receive a specific artifact, ...)
|
2012-10-26 20:51:05 +03:00
|
|
|
struct DLL_LINKAGE VictoryCondition
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
VictoryCondition();
|
2012-11-06 19:39:29 +03:00
|
|
|
|
2012-11-11 15:23:31 +03:00
|
|
|
EVictoryConditionType::EVictoryConditionType condition;
|
2013-04-16 16:16:58 +03:00
|
|
|
bool allowNormalVictory; /// true if a normal victory is allowed (defeat all enemy towns, heroes)
|
2012-11-11 15:23:31 +03:00
|
|
|
bool appliesToAI;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// pos of city to upgrade (3); pos of town to build grail, {-1,-1,-1} if not relevant (4); hero pos (5); town pos(6);
|
|
|
|
/// monster pos (7); destination pos(8)
|
2012-11-11 15:23:31 +03:00
|
|
|
int3 pos;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// artifact ID (0); monster ID (1); resource ID (2); needed fort level in upgraded town (3); artifact ID (8)
|
2012-11-11 15:23:31 +03:00
|
|
|
si32 objectId;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// needed count for creatures (1) / resource (2); upgraded town hall level (3);
|
2012-11-11 15:23:31 +03:00
|
|
|
si32 count;
|
2013-06-26 14:18:27 +03:00
|
|
|
/// object of specific monster / city / hero instance (nullptr if not used); set during map parsing
|
2012-11-11 15:23:31 +03:00
|
|
|
const CGObjectInstance * obj;
|
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)
|
|
|
|
{
|
|
|
|
h & condition & allowNormalVictory & appliesToAI & pos & objectId & count & obj;
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The map event is an event which e.g. gives or takes resources of a specific
|
|
|
|
/// amount to/from players and can appear regularly or once a time.
|
2011-12-14 00:23:17 +03:00
|
|
|
class DLL_LINKAGE CMapEvent
|
2008-12-27 03:01:59 +02:00
|
|
|
{
|
|
|
|
public:
|
2012-11-11 15:23:31 +03:00
|
|
|
CMapEvent();
|
|
|
|
|
|
|
|
bool earlierThan(const CMapEvent & other) const;
|
|
|
|
bool earlierThanOrEqual(const CMapEvent & other) const;
|
|
|
|
|
|
|
|
std::string name;
|
|
|
|
std::string message;
|
|
|
|
TResources resources;
|
2013-04-16 16:16:58 +03:00
|
|
|
ui8 players; // affected players, bit field?
|
2012-11-11 15:23:31 +03:00
|
|
|
ui8 humanAffected;
|
|
|
|
ui8 computerAffected;
|
|
|
|
ui32 firstOccurence;
|
2013-04-16 16:16:58 +03:00
|
|
|
ui32 nextOccurence; /// specifies after how many days the event will occur the next time; 0 if event occurs only one time
|
2012-11-11 15:23:31 +03:00
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & name & message & resources
|
2013-04-14 22:24:31 +03:00
|
|
|
& players & humanAffected & computerAffected & firstOccurence & nextOccurence;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|
2010-08-18 17:24:30 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The castle event builds/adds buildings/creatures for a specific town.
|
2011-12-14 00:23:17 +03:00
|
|
|
class DLL_LINKAGE CCastleEvent: public CMapEvent
|
2010-08-18 17:24:30 +03:00
|
|
|
{
|
|
|
|
public:
|
2012-11-11 15:23:31 +03:00
|
|
|
CCastleEvent();
|
|
|
|
|
2013-02-11 22:11:34 +03:00
|
|
|
std::set<BuildingID> buildings;
|
2012-11-11 15:23:31 +03:00
|
|
|
std::vector<si32> creatures;
|
|
|
|
CGTownInstance * town;
|
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
|
|
|
h & static_cast<CMapEvent &>(*this);
|
|
|
|
h & buildings & creatures;
|
|
|
|
}
|
2010-08-18 17:24:30 +03:00
|
|
|
};
|
|
|
|
|
2012-11-06 19:39:29 +03:00
|
|
|
namespace ERiverType
|
|
|
|
{
|
2013-04-14 22:24:31 +03:00
|
|
|
enum ERiverType
|
|
|
|
{
|
|
|
|
NO_RIVER, CLEAR_RIVER, ICY_RIVER, MUDDY_RIVER, LAVA_RIVER
|
|
|
|
};
|
2012-11-06 19:39:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace ERoadType
|
|
|
|
{
|
2013-04-14 22:24:31 +03:00
|
|
|
enum ERoadType
|
|
|
|
{
|
|
|
|
NO_ROAD, DIRT_ROAD, GRAVEL_ROAD, COBBLESTONE_ROAD
|
|
|
|
};
|
2012-11-06 19:39:29 +03:00
|
|
|
}
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// The terrain tile describes the terrain type and the visual representation of the terrain.
|
|
|
|
/// Furthermore the struct defines whether the tile is visitable or/and blocked and which objects reside in it.
|
2012-11-06 19:39:29 +03:00
|
|
|
struct DLL_LINKAGE TerrainTile
|
|
|
|
{
|
2012-11-11 15:23:31 +03:00
|
|
|
TerrainTile();
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Gets true if the terrain is not a rock. If from is water/land, same type is also required.
|
2013-06-26 14:18:27 +03:00
|
|
|
bool entrableTerrain(const TerrainTile * from = nullptr) const;
|
2012-11-11 15:23:31 +03:00
|
|
|
bool entrableTerrain(bool allowLand, bool allowSea) const;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Checks for blocking objects and terraint type (water / land).
|
2013-06-26 14:18:27 +03:00
|
|
|
bool isClear(const TerrainTile * from = nullptr) const;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Gets the ID of the top visitable object or -1 if there is none.
|
2012-11-11 15:23:31 +03:00
|
|
|
int topVisitableId() const;
|
|
|
|
bool isWater() const;
|
|
|
|
bool isCoastal() const;
|
|
|
|
bool hasFavourableWinds() const;
|
|
|
|
|
2013-02-13 01:24:48 +03:00
|
|
|
ETerrainType terType;
|
2012-11-11 15:23:31 +03:00
|
|
|
ui8 terView;
|
|
|
|
ERiverType::ERiverType riverType;
|
|
|
|
ui8 riverDir;
|
|
|
|
ERoadType::ERoadType roadType;
|
|
|
|
ui8 roadDir;
|
2013-04-16 16:16:58 +03:00
|
|
|
/// first two bits - how to rotate terrain graphic (next two - river graphic, next two - road);
|
|
|
|
/// 7th bit - whether tile is coastal (allows disembarking if land or block movement if water); 8th bit - Favourable Winds effect
|
2012-11-11 15:23:31 +03:00
|
|
|
ui8 extTileFlags;
|
|
|
|
bool visitable;
|
|
|
|
bool blocked;
|
|
|
|
|
|
|
|
std::vector<CGObjectInstance *> visitableObjects;
|
|
|
|
std::vector<CGObjectInstance *> blockingObjects;
|
|
|
|
|
|
|
|
template <typename Handler>
|
|
|
|
void serialize(Handler & h, const int version)
|
|
|
|
{
|
2013-04-20 21:44:55 +03:00
|
|
|
h & terType & terView & riverType & riverDir & roadType &roadDir & extTileFlags;
|
|
|
|
h & visitable & blocked;
|
|
|
|
h & visitableObjects & blockingObjects;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2012-11-06 19:39:29 +03:00
|
|
|
};
|
|
|
|
|
2012-10-26 20:51:05 +03:00
|
|
|
namespace EMapFormat
|
|
|
|
{
|
2013-04-14 22:24:31 +03:00
|
|
|
enum EMapFormat
|
|
|
|
{
|
2013-05-04 22:20:32 +03:00
|
|
|
INVALID = 0,
|
|
|
|
// HEX DEC
|
|
|
|
ROE = 0x0e, // 14
|
|
|
|
AB = 0x15, // 21
|
|
|
|
SOD = 0x1c, // 28
|
|
|
|
WOG = 0x33 // 51
|
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
|
|
|
{
|
|
|
|
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-04-16 16:16:58 +03:00
|
|
|
LossCondition lossCondition; /// The default value is lose all your towns and heroes.
|
|
|
|
VictoryCondition victoryCondition; /// The default value is defeat all enemies.
|
|
|
|
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;
|
2012-11-11 15:23:31 +03:00
|
|
|
std::vector<ui16> placeholdedHeroes;
|
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
|
|
|
|
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;
|
|
|
|
h & players & lossCondition & victoryCondition & howManyTeams & allowedHeroes;
|
|
|
|
}
|
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;
|
|
|
|
bool isInTheMap(const int3 & pos) const;
|
|
|
|
bool isWaterTile(const int3 & pos) const;
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
void addBlockVisTiles(CGObjectInstance * obj);
|
|
|
|
void removeBlockVisTiles(CGObjectInstance * obj, bool total = false);
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
void addNewArtifactInstance(CArtifactInstance * art);
|
|
|
|
void eraseArtifactInstance(CArtifactInstance * art);
|
2013-01-06 22:30:12 +03:00
|
|
|
void addQuest(CGObjectInstance * quest);
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// Gets the topmost object or the lowermost object depending on the flag lookForHero from the specified position.
|
|
|
|
const CGObjectInstance * getObjectiveObjectFrom(int3 pos, bool lookForHero);
|
|
|
|
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;
|
|
|
|
/// a 3-dimensional array of terrain tiles, access is as follows: x, y, level. where level=1 is underground
|
2012-11-11 15:23:31 +03:00
|
|
|
std::vector<Rumor> rumors;
|
|
|
|
std::vector<DisposedHero> disposedHeroes;
|
|
|
|
std::vector<ConstTransitivePtr<CGHeroInstance> > predefinedHeroes;
|
|
|
|
std::vector<ConstTransitivePtr<CGDefInfo> > customDefs;
|
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;
|
|
|
|
int grailRadious;
|
|
|
|
|
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
|
|
|
|
std::vector< ConstTransitivePtr<CGHeroInstance> > heroesOnMap;
|
|
|
|
|
2013-04-16 16:16:58 +03:00
|
|
|
/// associative list to identify which hero/creature id belongs to which object id(index for objects)
|
2013-02-14 02:55:42 +03:00
|
|
|
bmap<si32, ObjectInstanceID> questIdentifierToId;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
2013-04-19 14:43:11 +03:00
|
|
|
unique_ptr<CMapEditManager> editManager;
|
|
|
|
|
|
|
|
private:
|
|
|
|
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
|
|
|
|
if(h.saving)
|
|
|
|
{
|
|
|
|
// Save terrain
|
|
|
|
for(int i = 0; i < width ; ++i)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < height ; ++j)
|
|
|
|
{
|
2012-11-20 20:53:45 +03:00
|
|
|
for(int k = 0; k < (twoLevel ? 2 : 1); ++k)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
h & terrain[i][j][k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Load terrain
|
|
|
|
terrain = new TerrainTile**[width];
|
|
|
|
for(int ii = 0; ii < width; ++ii)
|
|
|
|
{
|
|
|
|
terrain[ii] = new TerrainTile*[height];
|
|
|
|
for(int jj = 0; jj < height; ++jj)
|
|
|
|
{
|
2012-11-20 20:53:45 +03:00
|
|
|
terrain[ii][jj] = new TerrainTile[twoLevel ? 2 : 1];
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for(int i = 0; i < width ; ++i)
|
|
|
|
{
|
|
|
|
for(int j = 0; j < height ; ++j)
|
|
|
|
{
|
2012-11-20 20:53:45 +03:00
|
|
|
for(int k = 0; k < (twoLevel ? 2 : 1); ++k)
|
2012-11-11 15:23:31 +03:00
|
|
|
{
|
|
|
|
h & terrain[i][j][k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h & customDefs & objects;
|
2013-05-19 01:30:48 +03:00
|
|
|
h & heroesOnMap & towns & artInstances;
|
2012-11-11 15:23:31 +03:00
|
|
|
|
|
|
|
// static members
|
|
|
|
h & CGTeleport::objs;
|
|
|
|
h & CGTeleport::gates;
|
|
|
|
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;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|