2013-02-11 22:27:37 +03:00
|
|
|
/*
|
|
|
|
* GameConstants.cpp, 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
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2013-02-14 02:55:42 +03:00
|
|
|
#define INSTANTIATE_BASE_FOR_ID_HERE
|
|
|
|
|
2013-02-11 02:24:57 +03:00
|
|
|
#include "StdInc.h"
|
|
|
|
|
2016-10-27 15:27:10 +02:00
|
|
|
#ifndef VCMI_NO_EXTRA_VERSION
|
|
|
|
#include "../Version.h"
|
|
|
|
#endif
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
#include <vcmi/Artifact.h>
|
|
|
|
#include <vcmi/ArtifactService.h>
|
|
|
|
#include <vcmi/Faction.h>
|
|
|
|
#include <vcmi/FactionService.h>
|
|
|
|
#include <vcmi/HeroType.h>
|
|
|
|
#include <vcmi/HeroTypeService.h>
|
|
|
|
|
|
|
|
#include <vcmi/spells/Spell.h>
|
|
|
|
#include <vcmi/spells/Service.h>
|
2016-10-27 15:27:10 +02:00
|
|
|
|
2013-02-11 02:24:57 +03:00
|
|
|
#include "VCMI_Lib.h"
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
#include "mapObjects/CObjectClassesHandler.h"//todo: remove
|
|
|
|
#include "CArtHandler.h"//todo: remove
|
|
|
|
#include "CCreatureHandler.h"//todo: remove
|
|
|
|
#include "spells/CSpellHandler.h" //todo: remove
|
|
|
|
#include "CSkillHandler.h"//todo: remove
|
2016-09-15 17:22:54 +02:00
|
|
|
#include "StringConstants.h"
|
|
|
|
#include "CGeneralTextHandler.h"
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
#include "CModHandler.h"//todo: remove
|
2013-02-11 02:24:57 +03:00
|
|
|
|
2013-02-16 17:03:47 +03:00
|
|
|
const SlotID SlotID::COMMANDER_SLOT_PLACEHOLDER = SlotID(-2);
|
2016-01-29 23:53:53 +02:00
|
|
|
const SlotID SlotID::SUMMONED_SLOT_PLACEHOLDER = SlotID(-3);
|
|
|
|
const SlotID SlotID::WAR_MACHINES_SLOT = SlotID(-4);
|
|
|
|
const SlotID SlotID::ARROW_TOWERS_SLOT = SlotID(-5);
|
|
|
|
|
2017-06-03 07:25:10 +02:00
|
|
|
const PlayerColor PlayerColor::SPECTATOR = PlayerColor(252);
|
2013-03-03 20:06:03 +03:00
|
|
|
const PlayerColor PlayerColor::CANNOT_DETERMINE = PlayerColor(253);
|
|
|
|
const PlayerColor PlayerColor::UNFLAGGABLE = PlayerColor(254);
|
|
|
|
const PlayerColor PlayerColor::NEUTRAL = PlayerColor(255);
|
|
|
|
const PlayerColor PlayerColor::PLAYER_LIMIT = PlayerColor(PLAYER_LIMIT_I);
|
|
|
|
const TeamID TeamID::NO_TEAM = TeamID(255);
|
2013-02-16 17:03:47 +03:00
|
|
|
|
2016-10-27 15:27:10 +02:00
|
|
|
namespace GameConstants
|
|
|
|
{
|
|
|
|
#ifdef VCMI_NO_EXTRA_VERSION
|
2016-11-01 19:25:09 +02:00
|
|
|
const std::string VCMI_VERSION = std::string("VCMI 0.99");
|
2016-10-27 15:27:10 +02:00
|
|
|
#else
|
2016-11-01 19:25:09 +02:00
|
|
|
const std::string VCMI_VERSION = std::string("VCMI 0.99 ") + GIT_SHA1;
|
2016-10-27 15:27:10 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
si32 HeroTypeID::decode(const std::string & identifier)
|
|
|
|
{
|
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier("core", "hero", identifier);
|
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string HeroTypeID::encode(const si32 index)
|
|
|
|
{
|
|
|
|
return VLC->heroTypes()->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
2016-10-02 14:22:55 +02:00
|
|
|
const CArtifact * ArtifactID::toArtifact() const
|
2013-02-11 02:24:57 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->arth->objects.at(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Artifact * ArtifactID::toArtifact(const ArtifactService * service) const
|
|
|
|
{
|
|
|
|
return service->getById(*this);
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
si32 ArtifactID::decode(const std::string & identifier)
|
|
|
|
{
|
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier("core", "artifact", identifier);
|
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ArtifactID::encode(const si32 index)
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->artifacts()->getByIndex(index)->getJsonKey();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2016-10-02 14:22:55 +02:00
|
|
|
const CCreature * CreatureID::toCreature() const
|
2013-02-11 02:24:57 +03:00
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->creh->objects.at(*this);
|
|
|
|
}
|
|
|
|
|
|
|
|
const Creature * CreatureID::toCreature(const CreatureService * creatures) const
|
|
|
|
{
|
|
|
|
return creatures->getById(*this);
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
si32 CreatureID::decode(const std::string & identifier)
|
|
|
|
{
|
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier("core", "creature", identifier);
|
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string CreatureID::encode(const si32 index)
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->creatures()->getById(CreatureID(index))->getJsonKey();
|
2017-07-20 06:08:49 +02:00
|
|
|
}
|
|
|
|
|
2016-10-02 14:22:55 +02:00
|
|
|
const CSpell * SpellID::toSpell() const
|
2013-02-11 02:24:57 +03:00
|
|
|
{
|
2014-11-27 23:36:14 +02:00
|
|
|
if(num < 0 || num >= VLC->spellh->objects.size())
|
2015-03-22 21:32:22 +02:00
|
|
|
{
|
2017-08-11 19:03:05 +02:00
|
|
|
logGlobal->error("Unable to get spell of invalid ID %d", int(num));
|
2014-11-27 23:36:14 +02:00
|
|
|
return nullptr;
|
2015-03-22 21:32:22 +02:00
|
|
|
}
|
2014-03-07 16:21:09 +03:00
|
|
|
return VLC->spellh->objects[*this];
|
2013-02-11 02:24:57 +03:00
|
|
|
}
|
2013-02-14 02:55:42 +03:00
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
const spells::Spell * SpellID::toSpell(const spells::Service * service) const
|
|
|
|
{
|
|
|
|
return service->getById(*this);
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
si32 SpellID::decode(const std::string & identifier)
|
|
|
|
{
|
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier("core", "spell", identifier);
|
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string SpellID::encode(const si32 index)
|
|
|
|
{
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
return VLC->spells()->getByIndex(index)->getJsonKey();
|
2017-08-20 09:18:07 +02:00
|
|
|
}
|
|
|
|
|
2013-04-20 14:34:01 +03:00
|
|
|
bool PlayerColor::isValidPlayer() const
|
|
|
|
{
|
|
|
|
return num < PLAYER_LIMIT_I;
|
|
|
|
}
|
2013-11-09 19:25:20 +03:00
|
|
|
|
2017-06-03 07:25:10 +02:00
|
|
|
bool PlayerColor::isSpectator() const
|
|
|
|
{
|
|
|
|
return num == 252;
|
|
|
|
}
|
|
|
|
|
2016-09-15 17:22:54 +02:00
|
|
|
std::string PlayerColor::getStr(bool L10n) const
|
|
|
|
{
|
|
|
|
std::string ret = "unnamed";
|
|
|
|
if(isValidPlayer())
|
|
|
|
{
|
|
|
|
if(L10n)
|
|
|
|
ret = VLC->generaltexth->colors[num];
|
|
|
|
else
|
|
|
|
ret = GameConstants::PLAYER_COLOR_NAMES[num];
|
|
|
|
}
|
|
|
|
else if(L10n)
|
|
|
|
{
|
|
|
|
ret = VLC->generaltexth->allTexts[508];
|
|
|
|
ret[0] = std::tolower(ret[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string PlayerColor::getStrCap(bool L10n) const
|
|
|
|
{
|
|
|
|
std::string ret = getStr(L10n);
|
|
|
|
ret[0] = std::toupper(ret[0]);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
Entities redesign and a few ERM features
* Made most Handlers derived from CHandlerBase and moved service API there.
* Declared existing Entity APIs.
* Added basic script context caching
* Started Lua script module
* Started Lua spell effect API
* Started script state persistence
* Started battle info callback binding
* CommitPackage removed
* Extracted spells::Caster to own header; Expanded Spell API.
* implemented !!MC:S, !!FU:E, !!FU:P, !!MA, !!VR:H, !!VR:C
* !!BU:C, !!BU:E, !!BU:G, !!BU:M implemented
* Allow use of "MC:S@varName@" to declare normal variable (technically v-variable with string key)
* Re-enabled VERM macros.
* !?GM0 added
* !?TM implemented
* Added !!MF:N
* Started !?OB, !!BM, !!HE, !!OW, !!UN
* Added basic support of w-variables
* Added support for ERM indirect variables
* Made !?FU regular trigger
* !!re (ERA loop receiver) implemented
* Fixed ERM receivers with zero args.
2018-03-17 16:58:30 +02:00
|
|
|
const FactionID FactionID::ANY = FactionID(-1);
|
|
|
|
const FactionID FactionID::CASTLE = FactionID(0);
|
|
|
|
const FactionID FactionID::RAMPART = FactionID(1);
|
|
|
|
const FactionID FactionID::TOWER = FactionID(2);
|
|
|
|
const FactionID FactionID::INFERNO = FactionID(3);
|
|
|
|
const FactionID FactionID::NECROPOLIS = FactionID(4);
|
|
|
|
const FactionID FactionID::DUNGEON = FactionID(5);
|
|
|
|
const FactionID FactionID::STRONGHOLD = FactionID(6);
|
|
|
|
const FactionID FactionID::FORTRESS = FactionID(7);
|
|
|
|
const FactionID FactionID::CONFLUX = FactionID(8);
|
|
|
|
const FactionID FactionID::NEUTRAL = FactionID(9);
|
|
|
|
|
|
|
|
si32 FactionID::decode(const std::string & identifier)
|
|
|
|
{
|
|
|
|
auto rawId = VLC->modh->identifiers.getIdentifier("core", "faction", identifier);
|
|
|
|
if(rawId)
|
|
|
|
return rawId.get();
|
|
|
|
else
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string FactionID::encode(const si32 index)
|
|
|
|
{
|
|
|
|
return VLC->factions()->getByIndex(index)->getJsonKey();
|
|
|
|
}
|
|
|
|
|
2017-07-20 06:08:49 +02:00
|
|
|
std::ostream & operator<<(std::ostream & os, const EActionType actionType)
|
2013-11-09 19:25:20 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
static const std::map<EActionType, std::string> actionTypeToString =
|
2014-10-02 18:43:46 +03:00
|
|
|
{
|
2017-07-20 06:08:49 +02:00
|
|
|
{EActionType::END_TACTIC_PHASE, "End tactic phase"},
|
|
|
|
{EActionType::INVALID, "Invalid"},
|
|
|
|
{EActionType::NO_ACTION, "No action"},
|
|
|
|
{EActionType::HERO_SPELL, "Hero spell"},
|
|
|
|
{EActionType::WALK, "Walk"},
|
|
|
|
{EActionType::DEFEND, "Defend"},
|
|
|
|
{EActionType::RETREAT, "Retreat"},
|
|
|
|
{EActionType::SURRENDER, "Surrender"},
|
|
|
|
{EActionType::WALK_AND_ATTACK, "Walk and attack"},
|
|
|
|
{EActionType::SHOOT, "Shoot"},
|
|
|
|
{EActionType::WAIT, "Wait"},
|
|
|
|
{EActionType::CATAPULT, "Catapult"},
|
|
|
|
{EActionType::MONSTER_SPELL, "Monster spell"},
|
|
|
|
{EActionType::BAD_MORALE, "Bad morale"},
|
|
|
|
{EActionType::STACK_HEAL, "Stack heal"},
|
|
|
|
{EActionType::DAEMON_SUMMONING, "Daemon summoning"}
|
2014-10-02 18:43:46 +03:00
|
|
|
};
|
2013-11-09 19:25:20 +03:00
|
|
|
|
|
|
|
auto it = actionTypeToString.find(actionType);
|
|
|
|
if (it == actionTypeToString.end()) return os << "<Unknown type>";
|
|
|
|
else return os << it->second;
|
|
|
|
}
|
2015-03-22 21:32:22 +02:00
|
|
|
|
2015-11-05 11:46:44 +02:00
|
|
|
std::ostream & operator<<(std::ostream & os, const ETerrainType terrainType)
|
2015-03-22 21:32:22 +02:00
|
|
|
{
|
|
|
|
static const std::map<ETerrainType::EETerrainType, std::string> terrainTypeToString =
|
|
|
|
{
|
|
|
|
#define DEFINE_ELEMENT(element) {ETerrainType::element, #element}
|
|
|
|
DEFINE_ELEMENT(WRONG),
|
|
|
|
DEFINE_ELEMENT(BORDER),
|
|
|
|
DEFINE_ELEMENT(DIRT),
|
|
|
|
DEFINE_ELEMENT(SAND),
|
|
|
|
DEFINE_ELEMENT(GRASS),
|
|
|
|
DEFINE_ELEMENT(SNOW),
|
|
|
|
DEFINE_ELEMENT(SWAMP),
|
|
|
|
DEFINE_ELEMENT(ROUGH),
|
|
|
|
DEFINE_ELEMENT(SUBTERRANEAN),
|
|
|
|
DEFINE_ELEMENT(LAVA),
|
|
|
|
DEFINE_ELEMENT(WATER),
|
|
|
|
DEFINE_ELEMENT(ROCK)
|
2015-11-05 11:46:44 +02:00
|
|
|
#undef DEFINE_ELEMENT
|
2015-03-22 21:32:22 +02:00
|
|
|
};
|
|
|
|
|
2015-11-05 11:46:44 +02:00
|
|
|
auto it = terrainTypeToString.find(terrainType.num);
|
2015-03-22 21:32:22 +02:00
|
|
|
if (it == terrainTypeToString.end()) return os << "<Unknown type>";
|
|
|
|
else return os << it->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string ETerrainType::toString() const
|
|
|
|
{
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << *this;
|
|
|
|
return ss.str();
|
|
|
|
}
|
2015-11-02 12:25:01 +02:00
|
|
|
|
2015-11-05 11:46:44 +02:00
|
|
|
std::ostream & operator<<(std::ostream & os, const EPathfindingLayer pathfindingLayer)
|
2015-11-02 12:25:01 +02:00
|
|
|
{
|
2015-11-05 11:46:44 +02:00
|
|
|
static const std::map<EPathfindingLayer::EEPathfindingLayer, std::string> pathfinderLayerToString
|
2015-11-02 12:25:01 +02:00
|
|
|
{
|
|
|
|
#define DEFINE_ELEMENT(element) {EPathfindingLayer::element, #element}
|
|
|
|
DEFINE_ELEMENT(WRONG),
|
|
|
|
DEFINE_ELEMENT(AUTO),
|
|
|
|
DEFINE_ELEMENT(LAND),
|
|
|
|
DEFINE_ELEMENT(SAIL),
|
|
|
|
DEFINE_ELEMENT(WATER),
|
|
|
|
DEFINE_ELEMENT(AIR),
|
|
|
|
DEFINE_ELEMENT(NUM_LAYERS)
|
2015-11-05 11:46:44 +02:00
|
|
|
#undef DEFINE_ELEMENT
|
2015-11-02 12:25:01 +02:00
|
|
|
};
|
|
|
|
|
2015-11-05 11:46:44 +02:00
|
|
|
auto it = pathfinderLayerToString.find(pathfindingLayer.num);
|
2015-11-02 12:25:01 +02:00
|
|
|
if (it == pathfinderLayerToString.end()) return os << "<Unknown type>";
|
|
|
|
else return os << it->second;
|
|
|
|
}
|