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"
|
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
|
|
|
|
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-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;
|
2013-04-16 16:16:58 +03:00
|
|
|
TeamID team; /// The default value is 255 representing that the player belongs to 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 {
|
|
|
|
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
|
|
|
|
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
|
|
|
|
CONST_VALUE // condition that always evaluates to "value" (0 = false, 1 = true)
|
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
|
|
|
|
|
|
|
const CGObjectInstance * object; // object that was at specified position on start
|
|
|
|
si32 value;
|
|
|
|
si32 objectType;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
h & object & value & objectType & position & condition;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2013-12-29 14:27:38 +03:00
|
|
|
h & identifier & trigger & description & 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
|
|
|
};
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
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.
|
2015-03-08 14:05:24 +02:00
|
|
|
Obj topVisitableId(bool excludeTop = false) const;
|
|
|
|
CGObjectInstance * topVisitableObj(bool excludeTop = false) const;
|
2012-11-11 15:23:31 +03:00
|
|
|
bool isWater() const;
|
|
|
|
bool isCoastal() const;
|
2015-11-29 11:32:06 +02:00
|
|
|
EDiggingStatus getDiggingStatus(const bool excludeTop = true) const;
|
2012-11-11 15:23:31 +03:00
|
|
|
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
|
2013-12-29 14:27:38 +03:00
|
|
|
// HOTA = 0x1e ... 0x20 // 28 ... 30
|
2013-05-04 22:20:32 +03:00
|
|
|
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
|
|
|
{
|
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;
|
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
|
|
|
|
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;
|
|
|
|
bool isInTheMap(const int3 & pos) const;
|
|
|
|
bool isWaterTile(const int3 & pos) const;
|
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);
|
2013-01-06 22:30:12 +03:00
|
|
|
void addQuest(CGObjectInstance * quest);
|
|
|
|
|
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;
|
|
|
|
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
|
2013-12-23 18:59:37 +03:00
|
|
|
std::vector< ConstTransitivePtr<CGHeroInstance> > heroesOnMap;
|
2015-03-08 15:11:23 +02:00
|
|
|
std::map<TeleportChannelID, 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;
|
|
|
|
|
|
|
|
unique_ptr<CMapEditManager> editManager;
|
|
|
|
|
2014-04-01 14:53:28 +03:00
|
|
|
int3 ***guardingCreaturePositions;
|
|
|
|
|
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;
|
2012-11-11 15:23:31 +03:00
|
|
|
}
|
2008-12-27 03:01:59 +02:00
|
|
|
};
|