1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

initializer lists part1

This commit is contained in:
AlexVinS 2014-10-02 19:43:46 +04:00
parent 463b9e46b3
commit 66b022f93e
20 changed files with 285 additions and 222 deletions

View File

@ -108,7 +108,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
if(stack->type->idNumber == CreatureID::CATAPULT)
{
BattleAction attack;
static const std::vector<int> wallHexes = boost::assign::list_of(50)(183)(182)(130)(62)(29)(12)(95);
static const std::vector<int> wallHexes = {50, 183, 182, 130, 62, 29, 12, 95};
attack.destinationTile = *RandomGeneratorUtil::nextItem(wallHexes, CRandomGenerator::getDefault());
attack.actionType = Battle::CATAPULT;

View File

@ -27,7 +27,6 @@ class FuzzyEngine;
class InputLVar;
class CGTownInstance;
using namespace boost::assign;
using namespace vstd;
//using namespace Goals;
@ -118,9 +117,6 @@ void FuzzyHelper::initTacticalAdvantage()
{
try
{
//Tactical advantage calculation
std::vector<fl::InputLVar*> helper;
ta.ourShooters = new fl::InputLVar("OurShooters");
ta.ourWalkers = new fl::InputLVar("OurWalkers");
ta.ourFlyers = new fl::InputLVar("OurFlyers");
@ -128,7 +124,11 @@ void FuzzyHelper::initTacticalAdvantage()
ta.enemyWalkers = new fl::InputLVar("EnemyWalkers");
ta.enemyFlyers = new fl::InputLVar("EnemyFlyers");
helper += ta.ourShooters, ta.ourWalkers, ta.ourFlyers, ta.enemyShooters, ta.enemyWalkers, ta.enemyFlyers;
//Tactical advantage calculation
std::vector<fl::InputLVar*> helper =
{
ta.ourShooters, ta.ourWalkers, ta.ourFlyers, ta.enemyShooters, ta.enemyWalkers, ta.enemyFlyers
};
for (auto val : helper)
{
@ -136,12 +136,11 @@ void FuzzyHelper::initTacticalAdvantage()
val->addTerm (new fl::ShoulderTerm("FEW", 0, 0.6, true));
val->addTerm (new fl::ShoulderTerm("MANY", 0.4, 1, false));
}
helper.clear();
ta.ourSpeed = new fl::InputLVar("OurSpeed");
ta.enemySpeed = new fl::InputLVar("EnemySpeed");
helper += ta.ourSpeed, ta.enemySpeed;
helper = {ta.ourSpeed, ta.enemySpeed};
for (auto val : helper)
{
@ -334,15 +333,13 @@ void FuzzyHelper::initVisitTile()
{
try
{
std::vector<fl::InputLVar*> helper;
vt.strengthRatio = new fl::InputLVar("strengthRatio"); //hero must be strong enough to defeat guards
vt.heroStrength = new fl::InputLVar("heroStrength"); //we want to use weakest possible hero
vt.turnDistance = new fl::InputLVar("turnDistance"); //we want to use hero who is near
vt.missionImportance = new fl::InputLVar("lockedMissionImportance"); //we may want to preempt hero with low-priority mission
vt.value = new fl::OutputLVar("Value");
helper += vt.strengthRatio, vt.heroStrength, vt.turnDistance, vt.missionImportance;
std::vector<fl::InputLVar*> helper = {vt.strengthRatio, vt.heroStrength, vt.turnDistance, vt.missionImportance};
for (auto val : helper)
{
engine.addInputLVar(val);

View File

@ -21,8 +21,6 @@
*
*/
using namespace boost::assign;
#define VCMI_SOUND_NAME(x)
#define VCMI_SOUND_FILE(y) #y,
@ -88,18 +86,26 @@ CSoundHandler::CSoundHandler():
listener(std::bind(&CSoundHandler::onVolumeChange, this, _1));
// Vectors for helper(s)
pickupSounds += soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
soundBase::pickup04, soundBase::pickup05, soundBase::pickup06, soundBase::pickup07;
pickupSounds =
{
soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
soundBase::pickup04, soundBase::pickup05, soundBase::pickup06, soundBase::pickup07
};
horseSounds += // must be the same order as terrains (see ETerrainType);
horseSounds = // must be the same order as terrains (see ETerrainType);
{
soundBase::horseDirt, soundBase::horseSand, soundBase::horseGrass,
soundBase::horseSnow, soundBase::horseSwamp, soundBase::horseRough,
soundBase::horseSubterranean, soundBase::horseLava,
soundBase::horseWater, soundBase::horseRock;
soundBase::horseWater, soundBase::horseRock
};
battleIntroSounds += soundBase::battle00, soundBase::battle01,
battleIntroSounds =
{
soundBase::battle00, soundBase::battle01,
soundBase::battle02, soundBase::battle03, soundBase::battle04,
soundBase::battle05, soundBase::battle06, soundBase::battle07;
soundBase::battle05, soundBase::battle06, soundBase::battle07
};
};
void CSoundHandler::init()

View File

@ -71,7 +71,6 @@
return; \
RETURN_IF_QUICK_COMBAT
using namespace boost::assign;
using namespace CSDL_Ext;
void processCommand(const std::string &message, CClient *&client);
@ -1438,7 +1437,7 @@ void CPlayerInterface::initializeHeroTownList()
for (auto & allHeroe : allHeroes)
if (!allHeroe->inTownGarrison)
wanderingHeroes += allHeroe;
wanderingHeroes.push_back(allHeroe);
std::vector<const CGTownInstance*> allTowns = cb->getTownsInfo();
/*

View File

@ -306,11 +306,11 @@ void CMenuScreen::switchToTab(size_t index)
//funciton for std::string -> std::function conversion for main menu
static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::string> menuType, const std::string &string)
{
static const std::vector<std::string> commandType = boost::assign::list_of
("to")("campaigns")("start")("load")("exit")("highscores");
static const std::vector<std::string> commandType =
{"to", "campaigns", "start", "load", "exit", "highscores"};
static const std::vector<std::string> gameType = boost::assign::list_of
("single")("multi")("campaign")("tutorial");
static const std::vector<std::string> gameType =
{"single", "multi", "campaign", "tutorial"};
std::list<std::string> commands;
boost::split(commands, string, boost::is_any_of("\t "));
@ -1624,13 +1624,12 @@ CRandomMapTab::CRandomMapTab()
mapSizeBtnGroup = new CToggleGroup(0);
mapSizeBtnGroup->pos.y += 81;
mapSizeBtnGroup->pos.x += 158;
const std::vector<std::string> mapSizeBtns = boost::assign::list_of("RANSIZS")("RANSIZM")("RANSIZL")("RANSIZX");
const std::vector<std::string> mapSizeBtns = {"RANSIZS", "RANSIZM","RANSIZL","RANSIZX"};
addButtonsToGroup(mapSizeBtnGroup, mapSizeBtns, 0, 3, 47, 198);
mapSizeBtnGroup->setSelected(1);
mapSizeBtnGroup->addCallback([&](int btnId)
{
const std::vector<int> mapSizeVal = boost::assign::list_of(CMapHeader::MAP_SIZE_SMALL)(CMapHeader::MAP_SIZE_MIDDLE)
(CMapHeader::MAP_SIZE_LARGE)(CMapHeader::MAP_SIZE_XLARGE);
const std::vector<int> mapSizeVal = {CMapHeader::MAP_SIZE_SMALL,CMapHeader::MAP_SIZE_MIDDLE,CMapHeader::MAP_SIZE_LARGE,CMapHeader::MAP_SIZE_XLARGE};
mapGenOptions.setWidth(mapSizeVal[btnId]);
mapGenOptions.setHeight(mapSizeVal[btnId]);
updateMapInfo();
@ -1706,7 +1705,7 @@ CRandomMapTab::CRandomMapTab()
waterContentGroup = new CToggleGroup(0);
waterContentGroup->pos.y += 419;
waterContentGroup->pos.x += BTNS_GROUP_LEFT_MARGIN;
const std::vector<std::string> waterContentBtns = boost::assign::list_of("RANNONE")("RANNORM")("RANISLD");
const std::vector<std::string> waterContentBtns = {"RANNONE","RANNORM","RANISLD"};
addButtonsWithRandToGroup(waterContentGroup, waterContentBtns, 0, 2, WIDE_BTN_WIDTH, 243, 246);
waterContentGroup->addCallback([&](int btnId)
{
@ -1717,7 +1716,7 @@ CRandomMapTab::CRandomMapTab()
monsterStrengthGroup = new CToggleGroup(0);
monsterStrengthGroup->pos.y += 485;
monsterStrengthGroup->pos.x += BTNS_GROUP_LEFT_MARGIN;
const std::vector<std::string> monsterStrengthBtns = boost::assign::list_of("RANWEAK")("RANNORM")("RANSTRG");
const std::vector<std::string> monsterStrengthBtns = {"RANWEAK","RANNORM","RANSTRG"};
addButtonsWithRandToGroup(monsterStrengthGroup, monsterStrengthBtns, 0, 2, WIDE_BTN_WIDTH, 248, 251);
monsterStrengthGroup->addCallback([&](int btnId)
{

View File

@ -23,7 +23,6 @@
#include "../lib/CStopWatch.h"
#include "../lib/mapObjects/CObjectClassesHandler.h"
using namespace boost::assign;
using namespace CSDL_Ext;
#ifdef min
#undef min
@ -157,9 +156,12 @@ Graphics::Graphics()
void Graphics::loadHeroAnims()
{
std::vector<std::pair<int,int> > rotations; //first - group number to be rotated1, second - group number after rotation1
rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12), std::make_pair(1,13),
std::make_pair(2,14), std::make_pair(3,15);
//first - group number to be rotated1, second - group number after rotation1
std::vector<std::pair<int,int> > rotations =
{
{6,10}, {7,11}, {8,12}, {1,13},
{2,14}, {3,15}
};
for(auto & elem : CGI->heroh->classes.heroClasses)
{
@ -216,8 +218,12 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
{
for(int i=0;i<8;i++)
(this->*pr.first).push_back(CDefHandler::giveDefEss(pr.second[i]));
std::vector<std::pair<int,int> > rotations; //first - group number to be rotated1, second - group number after rotation1
rotations += std::make_pair(6,10), std::make_pair(7,11), std::make_pair(8,12);
//first - group number to be rotated1, second - group number after rotation1
std::vector<std::pair<int,int> > rotations =
{
{6,10}, {7,11}, {8,12}
};
for(int q=0; q<8; ++q)
{
std::vector<Cimage> &curImgs = (this->*pr.first)[q]->ourImages;
@ -269,21 +275,32 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
void Graphics::loadHeroFlags()
{
using namespace boost::assign;
CStopWatch th;
std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4];
pr[0].first = &Graphics::flags1;
pr[0].second+=("ABF01L.DEF"),("ABF01G.DEF"),("ABF01R.DEF"),("ABF01D.DEF"),("ABF01B.DEF"),
("ABF01P.DEF"),("ABF01W.DEF"),("ABF01K.DEF");
pr[1].first = &Graphics::flags2;
pr[1].second+=("ABF02L.DEF"),("ABF02G.DEF"),("ABF02R.DEF"),("ABF02D.DEF"),("ABF02B.DEF"),
("ABF02P.DEF"),("ABF02W.DEF"),("ABF02K.DEF");
pr[2].first = &Graphics::flags3;
pr[2].second+=("ABF03L.DEF"),("ABF03G.DEF"),("ABF03R.DEF"),("ABF03D.DEF"),("ABF03B.DEF"),
("ABF03P.DEF"),("ABF03W.DEF"),("ABF03K.DEF");
pr[3].first = &Graphics::flags4;
pr[3].second+=("AF00.DEF"),("AF01.DEF"),("AF02.DEF"),("AF03.DEF"),("AF04.DEF"),
("AF05.DEF"),("AF06.DEF"),("AF07.DEF");
std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > pr[4] =
{
{
&Graphics::flags1,
{"ABF01L.DEF","ABF01G.DEF","ABF01R.DEF","ABF01D.DEF","ABF01B.DEF",
"ABF01P.DEF","ABF01W.DEF","ABF01K.DEF"}
},
{
&Graphics::flags2,
{"ABF02L.DEF","ABF02G.DEF","ABF02R.DEF","ABF02D.DEF","ABF02B.DEF",
"ABF02P.DEF","ABF02W.DEF","ABF02K.DEF"}
},
{
&Graphics::flags3,
{"ABF03L.DEF","ABF03G.DEF","ABF03R.DEF","ABF03D.DEF","ABF03B.DEF",
"ABF03P.DEF","ABF03W.DEF","ABF03K.DEF"}
},
{
&Graphics::flags4,
{"AF00.DEF","AF01.DEF","AF02.DEF","AF03.DEF","AF04.DEF",
"AF05.DEF","AF06.DEF","AF07.DEF"}
}
};
#if 0
boost::thread_group grupa;
for(int g=3; g>=0; --g)

View File

@ -35,7 +35,6 @@
#include "../../lib/NetPacks.h"
#include "../../lib/UnlockGuard.h"
using namespace boost::assign;
/*
* CBattleInterface.cpp, part of VCMI engine
@ -1737,7 +1736,8 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
possibleActions.clear();
if (tacticsMode)
{
possibleActions += MOVE_TACTICS, CHOOSE_TACTICS_STACK;
possibleActions.push_back(MOVE_TACTICS);
possibleActions.push_back(CHOOSE_TACTICS_STACK);
}
else
{

View File

@ -692,8 +692,6 @@ CArtifactsOfHero::CArtifactsOfHero(std::vector<CArtPlace *> ArtWorn, std::vector
CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart /*= false*/)
: curHero(nullptr), backpackPos(0), commonInfo(nullptr), updateState(false), allowedAssembling(true), highlightModeCallback(nullptr)
{
using namespace boost::assign;
if(createCommonPart)
{
commonInfo = new CArtifactsOfHero::SCommonPart;
@ -704,14 +702,16 @@ CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart
pos += position;
artWorn.resize(19);
std::vector<Point> slotPos;
slotPos += Point(509,30), Point(567,240), Point(509,80),
Point(383,68), Point(564,183), Point(509,130),
Point(431,68), Point(610,183), Point(515,295),
Point(383,143), Point(399,194), Point(415,245),
Point(431,296), Point(564,30), Point(610,30),
Point(610,76), Point(610,122), Point(610,310),
Point(381,296);
std::vector<Point> slotPos =
{
Point(509,30), Point(567,240), Point(509,80),
Point(383,68), Point(564,183), Point(509,130),
Point(431,68), Point(610,183), Point(515,295),
Point(383,143), Point(399,194), Point(415,245),
Point(431,296), Point(564,30), Point(610,30),
Point(610,76), Point(610,122), Point(610,310),
Point(381,296)
};
// Create slots for worn artifacts.
for (size_t g = 0; g < GameConstants::BACKPACK_START ; g++)

View File

@ -761,18 +761,20 @@ shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) cons
BattlefieldBI::BattlefieldBI BattleInfo::battlefieldTypeToBI(BFieldType bfieldType)
{
static const std::map<BFieldType, BattlefieldBI::BattlefieldBI> theMap = boost::assign::map_list_of
(BFieldType::CLOVER_FIELD, BattlefieldBI::CLOVER_FIELD)
(BFieldType::CURSED_GROUND, BattlefieldBI::CURSED_GROUND)
(BFieldType::EVIL_FOG, BattlefieldBI::EVIL_FOG)
(BFieldType::FAVOURABLE_WINDS, BattlefieldBI::NONE)
(BFieldType::FIERY_FIELDS, BattlefieldBI::FIERY_FIELDS)
(BFieldType::HOLY_GROUND, BattlefieldBI::HOLY_GROUND)
(BFieldType::LUCID_POOLS, BattlefieldBI::LUCID_POOLS)
(BFieldType::MAGIC_CLOUDS, BattlefieldBI::MAGIC_CLOUDS)
(BFieldType::MAGIC_PLAINS, BattlefieldBI::MAGIC_PLAINS)
(BFieldType::ROCKLANDS, BattlefieldBI::ROCKLANDS)
(BFieldType::SAND_SHORE, BattlefieldBI::COASTAL);
static const std::map<BFieldType, BattlefieldBI::BattlefieldBI> theMap =
{
{BFieldType::CLOVER_FIELD, BattlefieldBI::CLOVER_FIELD},
{BFieldType::CURSED_GROUND, BattlefieldBI::CURSED_GROUND},
{BFieldType::EVIL_FOG, BattlefieldBI::EVIL_FOG},
{BFieldType::FAVOURABLE_WINDS, BattlefieldBI::NONE},
{BFieldType::FIERY_FIELDS, BattlefieldBI::FIERY_FIELDS},
{BFieldType::HOLY_GROUND, BattlefieldBI::HOLY_GROUND},
{BFieldType::LUCID_POOLS, BattlefieldBI::LUCID_POOLS},
{BFieldType::MAGIC_CLOUDS, BattlefieldBI::MAGIC_CLOUDS},
{BFieldType::MAGIC_PLAINS, BattlefieldBI::MAGIC_PLAINS},
{BFieldType::ROCKLANDS, BattlefieldBI::ROCKLANDS},
{BFieldType::SAND_SHORE, BattlefieldBI::COASTAL}
};
auto itr = theMap.find(bfieldType);
if(itr != theMap.end())

View File

@ -45,7 +45,7 @@ using namespace boost::assign;
ART_POS(RIGHT_HAND) \
ART_POS(NECK) \
ART_POS(SHOULDERS) \
ART_POS(HEAD);
ART_POS(HEAD)
const std::string & CArtifact::Name() const
{
@ -157,12 +157,12 @@ std::vector<JsonNode> CArtHandler::loadLegacyData(size_t dataSize)
std::vector<JsonNode> h3Data;
h3Data.reserve(dataSize);
#define ART_POS(x) ( #x)
const std::vector<std::string> artSlots = boost::assign::list_of ART_POS_LIST;
#define ART_POS(x) #x ,
const std::vector<std::string> artSlots = { ART_POS_LIST };
#undef ART_POS
static std::map<char, std::string> classes =
map_list_of('S',"SPECIAL")('T',"TREASURE")('N',"MINOR")('J',"MAJOR")('R',"RELIC");
{{'S',"SPECIAL"}, {'T',"TREASURE"},{'N',"MINOR"},{'J',"MAJOR"},{'R',"RELIC"},};
CLegacyConfigParser parser("DATA/ARTRAITS.TXT");
CLegacyConfigParser events("DATA/ARTEVENT.TXT");
@ -264,8 +264,8 @@ CArtifact * CArtHandler::loadFromJson(const JsonNode & node)
ArtifactPosition CArtHandler::stringToSlot(std::string slotName)
{
#define ART_POS(x) ( #x, ArtifactPosition::x )
static const std::map<std::string, ArtifactPosition> artifactPositionMap = boost::assign::map_list_of ART_POS_LIST;
#define ART_POS(x) { #x, ArtifactPosition::x },
static const std::map<std::string, ArtifactPosition> artifactPositionMap = { ART_POS_LIST };
#undef ART_POS
auto it = artifactPositionMap.find (slotName);
if (it != artifactPositionMap.end())
@ -309,12 +309,14 @@ void CArtHandler::loadSlots(CArtifact * art, const JsonNode & node)
CArtifact::EartClass CArtHandler::stringToClass(std::string className)
{
static const std::map<std::string, CArtifact::EartClass> artifactClassMap = boost::assign::map_list_of
("TREASURE", CArtifact::ART_TREASURE)
("MINOR", CArtifact::ART_MINOR)
("MAJOR", CArtifact::ART_MAJOR)
("RELIC", CArtifact::ART_RELIC)
("SPECIAL", CArtifact::ART_SPECIAL);
static const std::map<std::string, CArtifact::EartClass> artifactClassMap =
{
{"TREASURE", CArtifact::ART_TREASURE},
{"MINOR", CArtifact::ART_MINOR},
{"MAJOR", CArtifact::ART_MAJOR},
{"RELIC", CArtifact::ART_RELIC},
{"SPECIAL", CArtifact::ART_SPECIAL}
};
auto it = artifactClassMap.find (className);
if (it != artifactClassMap.end())
@ -331,8 +333,8 @@ void CArtHandler::loadClass(CArtifact * art, const JsonNode & node)
void CArtHandler::loadType(CArtifact * art, const JsonNode & node)
{
#define ART_BEARER(x) ( #x, ArtBearer::x )
static const std::map<std::string, int> artifactBearerMap = boost::assign::map_list_of ART_BEARER_LIST;
#define ART_BEARER(x) { #x, ArtBearer::x },
static const std::map<std::string, int> artifactBearerMap = { ART_BEARER_LIST };
#undef ART_BEARER
for (const JsonNode & b : node["type"].Vector())

View File

@ -15,21 +15,26 @@
BuildingID CBuildingHandler::campToERMU( int camp, int townType, std::set<BuildingID> builtBuildings )
{
using namespace boost::assign;
static const std::vector<BuildingID> campToERMU = list_of(BuildingID::TOWN_HALL)(BuildingID::CITY_HALL)
(BuildingID::CAPITOL)(BuildingID::FORT)(BuildingID::CITADEL)(BuildingID::CASTLE)(BuildingID::TAVERN)
(BuildingID::BLACKSMITH)(BuildingID::MARKETPLACE)(BuildingID::RESOURCE_SILO)(BuildingID::NONE)
(BuildingID::MAGES_GUILD_1)(BuildingID::MAGES_GUILD_2)(BuildingID::MAGES_GUILD_3)(BuildingID::MAGES_GUILD_4)
(BuildingID::MAGES_GUILD_5)
(BuildingID::SHIPYARD)(BuildingID::GRAIL)
(BuildingID::SPECIAL_1)(BuildingID::SPECIAL_2)(BuildingID::SPECIAL_3)(BuildingID::SPECIAL_4)
; //creature generators with banks - handled separately
static const std::vector<BuildingID> campToERMU =
{
BuildingID::TOWN_HALL, BuildingID::CITY_HALL,
BuildingID::CAPITOL, BuildingID::FORT, BuildingID::CITADEL, BuildingID::CASTLE, BuildingID::TAVERN,
BuildingID::BLACKSMITH, BuildingID::MARKETPLACE, BuildingID::RESOURCE_SILO, BuildingID::NONE,
BuildingID::MAGES_GUILD_1, BuildingID::MAGES_GUILD_2, BuildingID::MAGES_GUILD_3, BuildingID::MAGES_GUILD_4,
BuildingID::MAGES_GUILD_5,
BuildingID::SHIPYARD, BuildingID::GRAIL,
BuildingID::SPECIAL_1, BuildingID::SPECIAL_2, BuildingID::SPECIAL_3, BuildingID::SPECIAL_4
}; //creature generators with banks - handled separately
if (camp < campToERMU.size())
{
return campToERMU[camp];
}
static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] = {list_of(2), list_of(1), list_of(1)(4), list_of(0)(2),
list_of(0), list_of(0), list_of(0), list_of(0), list_of(0)};
static const std::vector<int> hordeLvlsPerTType[GameConstants::F_NUMBER] =
{
{2}, {1}, {1,4}, {0,2}, {0}, {0}, {0}, {0}, {0}
};
int curPos = campToERMU.size();
for (int i=0; i<GameConstants::CREATURES_PER_TOWN; ++i)

View File

@ -232,22 +232,23 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
};
static const std::map<std::string, JsonNode> abilityMap =
boost::assign::map_list_of
("FLYING_ARMY", makeBonusNode("FLYING"))
("SHOOTING_ARMY", makeBonusNode("SHOOTER"))
("SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON"))
("const_free_attack", makeBonusNode("BLOCKS_RETALIATION"))
("IS_UNDEAD", makeBonusNode("UNDEAD"))
("const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY"))
("const_jousting", makeBonusNode("JOUSTING"))
("KING_1", makeBonusNode("KING1"))
("KING_2", makeBonusNode("KING2"))
("KING_3", makeBonusNode("KING3"))
("const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY"))
("CATAPULT", makeBonusNode("CATAPULT"))
("MULTI_HEADED", makeBonusNode("ATTACKS_ALL_ADJACENT"))
("IMMUNE_TO_MIND_SPELLS", makeBonusNode("MIND_IMMUNITY"))
("HAS_EXTENDED_ATTACK", makeBonusNode("TWO_HEX_ATTACK_BREATH"));
{
{"FLYING_ARMY", makeBonusNode("FLYING")},
{"SHOOTING_ARMY", makeBonusNode("SHOOTER")},
{"SIEGE_WEAPON", makeBonusNode("SIEGE_WEAPON")},
{"const_free_attack", makeBonusNode("BLOCKS_RETALIATION")},
{"IS_UNDEAD", makeBonusNode("UNDEAD")},
{"const_no_melee_penalty", makeBonusNode("NO_MELEE_PENALTY")},
{"const_jousting", makeBonusNode("JOUSTING")},
{"KING_1", makeBonusNode("KING1")},
{"KING_2", makeBonusNode("KING2")},
{"KING_3", makeBonusNode("KING3")},
{"const_no_wall_penalty", makeBonusNode("NO_WALL_PENALTY")},
{"CATAPULT", makeBonusNode("CATAPULT")},
{"MULTI_HEADED", makeBonusNode("ATTACKS_ALL_ADJACENT")},
{"IMMUNE_TO_MIND_SPELLS", makeBonusNode("MIND_IMMUNITY")},
{"HAS_EXTENDED_ATTACK", makeBonusNode("TWO_HEX_ATTACK_BREATH")}
};
auto hasAbility = [&](const std::string name) -> bool
{

View File

@ -100,23 +100,25 @@ bool PlayerColor::isValidPlayer() const
std::ostream & operator<<(std::ostream & os, const Battle::ActionType actionType)
{
static const std::map<Battle::ActionType, std::string> actionTypeToString = boost::assign::map_list_of
(Battle::END_TACTIC_PHASE, "End tactic phase")
(Battle::INVALID, "Invalid")
(Battle::NO_ACTION, "No action")
(Battle::HERO_SPELL, "Hero spell")
(Battle::WALK, "Walk")
(Battle::DEFEND, "Defend")
(Battle::RETREAT, "Retreat")
(Battle::SURRENDER, "Surrender")
(Battle::WALK_AND_ATTACK, "Walk and attack")
(Battle::SHOOT, "Shoot")
(Battle::WAIT, "Wait")
(Battle::CATAPULT, "Catapult")
(Battle::MONSTER_SPELL, "Monster spell")
(Battle::BAD_MORALE, "Bad morale")
(Battle::STACK_HEAL, "Stack heal")
(Battle::DAEMON_SUMMONING, "Daemon summoning");
static const std::map<Battle::ActionType, std::string> actionTypeToString =
{
{Battle::END_TACTIC_PHASE, "End tactic phase"},
{Battle::INVALID, "Invalid"},
{Battle::NO_ACTION, "No action"},
{Battle::HERO_SPELL, "Hero spell"},
{Battle::WALK, "Walk"},
{Battle::DEFEND, "Defend"},
{Battle::RETREAT, "Retreat"},
{Battle::SURRENDER, "Surrender"},
{Battle::WALK_AND_ATTACK, "Walk and attack"},
{Battle::SHOOT, "Shoot"},
{Battle::WAIT, "Wait"},
{Battle::CATAPULT, "Catapult"},
{Battle::MONSTER_SPELL, "Monster spell"},
{Battle::BAD_MORALE, "Bad morale"},
{Battle::STACK_HEAL, "Stack heal"},
{Battle::DAEMON_SUMMONING, "Daemon summoning"}
};
auto it = actionTypeToString.find(actionType);
if (it == actionTypeToString.end()) return os << "<Unknown type>";

View File

@ -26,21 +26,22 @@
#define FOREACH_RED_CHILD(pname) TNodes lchildren; getRedChildren(lchildren); for(CBonusSystemNode *pname : lchildren)
#define FOREACH_RED_PARENT(pname) TNodes lparents; getRedParents(lparents); for(CBonusSystemNode *pname : lparents)
#define BONUS_NAME(x) ( #x, Bonus::x )
const std::map<std::string, Bonus::BonusType> bonusNameMap = boost::assign::map_list_of BONUS_LIST;
#define BONUS_NAME(x) { #x, Bonus::x },
const std::map<std::string, Bonus::BonusType> bonusNameMap = { BONUS_LIST };
#undef BONUS_NAME
#define BONUS_VALUE(x) ( #x, Bonus::x )
const std::map<std::string, Bonus::ValueType> bonusValueMap = boost::assign::map_list_of BONUS_VALUE_LIST;
#define BONUS_VALUE(x) { #x, Bonus::x },
const std::map<std::string, Bonus::ValueType> bonusValueMap = { BONUS_VALUE_LIST };
#undef BONUS_VALUE
#define BONUS_SOURCE(x) ( #x, Bonus::x )
const std::map<std::string, Bonus::BonusSource> bonusSourceMap = boost::assign::map_list_of BONUS_SOURCE_LIST;
#define BONUS_SOURCE(x) { #x, Bonus::x },
const std::map<std::string, Bonus::BonusSource> bonusSourceMap = { BONUS_SOURCE_LIST };
#undef BONUS_SOURCE
#define BONUS_ITEM(x) ( #x, Bonus::x )
#define BONUS_ITEM(x) { #x, Bonus::x },
const std::map<std::string, ui16> bonusDurationMap = boost::assign::map_list_of
const std::map<std::string, ui16> bonusDurationMap =
{
BONUS_ITEM(PERMANENT)
BONUS_ITEM(ONE_BATTLE)
BONUS_ITEM(ONE_DAY)
@ -50,26 +51,33 @@ const std::map<std::string, ui16> bonusDurationMap = boost::assign::map_list_of
BONUS_ITEM(UNITL_BEING_ATTACKED)
BONUS_ITEM(UNTIL_ATTACK)
BONUS_ITEM(STACK_GETS_TURN)
BONUS_ITEM(COMMANDER_KILLED);
BONUS_ITEM(COMMANDER_KILLED)
};
const std::map<std::string, Bonus::LimitEffect> bonusLimitEffect = boost::assign::map_list_of
const std::map<std::string, Bonus::LimitEffect> bonusLimitEffect =
{
BONUS_ITEM(NO_LIMIT)
BONUS_ITEM(ONLY_DISTANCE_FIGHT)
BONUS_ITEM(ONLY_MELEE_FIGHT)
BONUS_ITEM(ONLY_ENEMY_ARMY);
BONUS_ITEM(ONLY_ENEMY_ARMY)
};
const std::map<std::string, TLimiterPtr> bonusLimiterMap = boost::assign::map_list_of
("SHOOTER_ONLY", make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER))
("DRAGON_NATURE", make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE))
("IS_UNDEAD", make_shared<HasAnotherBonusLimiter>(Bonus::UNDEAD));
const std::map<std::string, TLimiterPtr> bonusLimiterMap =
{
{"SHOOTER_ONLY", make_shared<HasAnotherBonusLimiter>(Bonus::SHOOTER)},
{"DRAGON_NATURE", make_shared<HasAnotherBonusLimiter>(Bonus::DRAGON_NATURE)},
{"IS_UNDEAD", make_shared<HasAnotherBonusLimiter>(Bonus::UNDEAD)}
};
const std::map<std::string, TPropagatorPtr> bonusPropagatorMap = boost::assign::map_list_of
("BATTLE_WIDE", make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE))
("VISITED_TOWN_AND_VISITOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR))
("PLAYER_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER))
("HERO", make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO))
("TEAM_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)) //untested
("GLOBAL_EFFECT", make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)); //untested
const std::map<std::string, TPropagatorPtr> bonusPropagatorMap =
{
{"BATTLE_WIDE", make_shared<CPropagatorNodeType>(CBonusSystemNode::BATTLE)},
{"VISITED_TOWN_AND_VISITOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TOWN_AND_VISITOR)},
{"PLAYER_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::PLAYER)},
{"HERO", make_shared<CPropagatorNodeType>(CBonusSystemNode::HERO)},
{"TEAM_PROPAGATOR", make_shared<CPropagatorNodeType>(CBonusSystemNode::TEAM)}, //untested
{"GLOBAL_EFFECT", make_shared<CPropagatorNodeType>(CBonusSystemNode::GLOBAL_EFFECTS)}
}; //untested
#define BONUS_LOG_LINE(x) logBonus->traceStream() << x

View File

@ -507,10 +507,14 @@ bool JsonParser::error(const std::string &message, bool warning)
///////////////////////////////////////////////////////////////////////////////
static const std::unordered_map<std::string, JsonNode::JsonType> stringToType =
boost::assign::map_list_of
("null", JsonNode::DATA_NULL) ("boolean", JsonNode::DATA_BOOL)
("number", JsonNode::DATA_FLOAT) ("string", JsonNode::DATA_STRING)
("array", JsonNode::DATA_VECTOR) ("object", JsonNode::DATA_STRUCT);
{
{"null", JsonNode::DATA_NULL},
{"boolean", JsonNode::DATA_BOOL},
{"number", JsonNode::DATA_FLOAT},
{"string", JsonNode::DATA_STRING},
{"array", JsonNode::DATA_VECTOR},
{"object", JsonNode::DATA_STRUCT}
};
namespace
{

View File

@ -86,42 +86,43 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
#endif
static const std::map<std::string, EResType::Type> stringToRes =
boost::assign::map_list_of
(".TXT", EResType::TEXT)
(".JSON", EResType::TEXT)
(".DEF", EResType::ANIMATION)
(".MSK", EResType::MASK)
(".MSG", EResType::MASK)
(".H3C", EResType::CAMPAIGN)
(".H3M", EResType::MAP)
(".FNT", EResType::BMP_FONT)
(".TTF", EResType::TTF_FONT)
(".BMP", EResType::IMAGE)
(".JPG", EResType::IMAGE)
(".PCX", EResType::IMAGE)
(".PNG", EResType::IMAGE)
(".TGA", EResType::IMAGE)
(".WAV", EResType::SOUND)
(".82M", EResType::SOUND)
(".SMK", EResType::VIDEO)
(".BIK", EResType::VIDEO)
(".MJPG", EResType::VIDEO)
(".MPG", EResType::VIDEO)
(".AVI", EResType::VIDEO)
(".MP3", EResType::MUSIC)
(".OGG", EResType::MUSIC)
(".FLAC", EResType::MUSIC)
(".ZIP", EResType::ARCHIVE_ZIP)
(".LOD", EResType::ARCHIVE_LOD)
(".PAC", EResType::ARCHIVE_LOD)
(".VID", EResType::ARCHIVE_VID)
(".SND", EResType::ARCHIVE_SND)
(".PAL", EResType::PALETTE)
(".VCGM1", EResType::CLIENT_SAVEGAME)
(".VSGM1", EResType::SERVER_SAVEGAME)
(".ERM", EResType::ERM)
(".ERT", EResType::ERT)
(".ERS", EResType::ERS);
{
{".TXT", EResType::TEXT},
{".JSON", EResType::TEXT},
{".DEF", EResType::ANIMATION},
{".MSK", EResType::MASK},
{".MSG", EResType::MASK},
{".H3C", EResType::CAMPAIGN},
{".H3M", EResType::MAP},
{".FNT", EResType::BMP_FONT},
{".TTF", EResType::TTF_FONT},
{".BMP", EResType::IMAGE},
{".JPG", EResType::IMAGE},
{".PCX", EResType::IMAGE},
{".PNG", EResType::IMAGE},
{".TGA", EResType::IMAGE},
{".WAV", EResType::SOUND},
{".82M", EResType::SOUND},
{".SMK", EResType::VIDEO},
{".BIK", EResType::VIDEO},
{".MJPG", EResType::VIDEO},
{".MPG", EResType::VIDEO},
{".AVI", EResType::VIDEO},
{".MP3", EResType::MUSIC},
{".OGG", EResType::MUSIC},
{".FLAC", EResType::MUSIC},
{".ZIP", EResType::ARCHIVE_ZIP},
{".LOD", EResType::ARCHIVE_LOD},
{".PAC", EResType::ARCHIVE_LOD},
{".VID", EResType::ARCHIVE_VID},
{".SND", EResType::ARCHIVE_SND},
{".PAL", EResType::PALETTE},
{".VCGM1", EResType::CLIENT_SAVEGAME},
{".VSGM1", EResType::SERVER_SAVEGAME},
{".ERM", EResType::ERM},
{".ERT", EResType::ERT},
{".ERS", EResType::ERS}
};
auto iter = stringToRes.find(extension);
if (iter == stringToRes.end())
@ -131,9 +132,10 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
std::string EResTypeHelper::getEResTypeAsString(EResType::Type type)
{
#define MAP_ENUM(value) (EResType::value, #value)
#define MAP_ENUM(value) {EResType::value, #value},
static const std::map<EResType::Type, std::string> stringToRes = boost::assign::map_list_of
static const std::map<EResType::Type, std::string> stringToRes =
{
MAP_ENUM(TEXT)
MAP_ENUM(ANIMATION)
MAP_ENUM(MASK)
@ -156,7 +158,8 @@ std::string EResTypeHelper::getEResTypeAsString(EResType::Type type)
MAP_ENUM(ERM)
MAP_ENUM(ERT)
MAP_ENUM(ERS)
MAP_ENUM(OTHER);
MAP_ENUM(OTHER)
};
#undef MAP_ENUM

View File

@ -87,12 +87,14 @@ void CBasicLogConfigurator::configure()
ELogLevel::ELogLevel CBasicLogConfigurator::getLogLevel(const std::string & level)
{
static const std::map<std::string, ELogLevel::ELogLevel> levelMap = boost::assign::map_list_of
("trace", ELogLevel::TRACE)
("debug", ELogLevel::DEBUG)
("info", ELogLevel::INFO)
("warn", ELogLevel::WARN)
("error", ELogLevel::ERROR);
static const std::map<std::string, ELogLevel::ELogLevel> levelMap =
{
{"trace", ELogLevel::TRACE},
{"debug", ELogLevel::DEBUG},
{"info", ELogLevel::INFO},
{"warn", ELogLevel::WARN},
{"error", ELogLevel::ERROR},
};
const auto & levelPair = levelMap.find(level);
if(levelPair != levelMap.end())
@ -103,15 +105,17 @@ ELogLevel::ELogLevel CBasicLogConfigurator::getLogLevel(const std::string & leve
EConsoleTextColor::EConsoleTextColor CBasicLogConfigurator::getConsoleColor(const std::string & colorName)
{
static const std::map<std::string, EConsoleTextColor::EConsoleTextColor> colorMap = boost::assign::map_list_of
("default", EConsoleTextColor::DEFAULT)
("green", EConsoleTextColor::GREEN)
("red", EConsoleTextColor::RED)
("magenta", EConsoleTextColor::MAGENTA)
("yellow", EConsoleTextColor::YELLOW)
("white", EConsoleTextColor::WHITE)
("gray", EConsoleTextColor::GRAY)
("teal", EConsoleTextColor::TEAL);
static const std::map<std::string, EConsoleTextColor::EConsoleTextColor> colorMap =
{
{"default", EConsoleTextColor::DEFAULT},
{"green", EConsoleTextColor::GREEN},
{"red", EConsoleTextColor::RED},
{"magenta", EConsoleTextColor::MAGENTA},
{"yellow", EConsoleTextColor::YELLOW},
{"white", EConsoleTextColor::WHITE},
{"gray", EConsoleTextColor::GRAY},
{"teal", EConsoleTextColor::TEAL},
};
const auto & colorPair = colorMap.find(colorName);
if(colorPair != colorMap.end())

View File

@ -402,9 +402,14 @@ CTerrainViewPatternConfig::~CTerrainViewPatternConfig()
ETerrainGroup::ETerrainGroup CTerrainViewPatternConfig::getTerrainGroup(const std::string & terGroup) const
{
static const std::map<std::string, ETerrainGroup::ETerrainGroup> terGroups
= boost::assign::map_list_of("normal", ETerrainGroup::NORMAL)("dirt", ETerrainGroup::DIRT)
("sand", ETerrainGroup::SAND)("water", ETerrainGroup::WATER)("rock", ETerrainGroup::ROCK);
static const std::map<std::string, ETerrainGroup::ETerrainGroup> terGroups =
{
{"normal", ETerrainGroup::NORMAL},
{"dirt", ETerrainGroup::DIRT},
{"sand", ETerrainGroup::SAND},
{"water", ETerrainGroup::WATER},
{"rock", ETerrainGroup::ROCK},
};
auto it = terGroups.find(terGroup);
if(it == terGroups.end()) throw std::runtime_error(boost::str(boost::format("Terrain group '%s' does not exist.") % terGroup));
return it->second;

View File

@ -199,8 +199,13 @@ CRmgTemplate::CSize CJsonRmgTemplateLoader::parseMapTemplateSize(const std::stri
std::vector<std::string> parts;
boost::split(parts, text, boost::is_any_of("+"));
static const std::map<std::string, int> mapSizeMapping = boost::assign::map_list_of("s", CMapHeader::MAP_SIZE_SMALL)
("m", CMapHeader::MAP_SIZE_MIDDLE)("l", CMapHeader::MAP_SIZE_LARGE)("xl", CMapHeader::MAP_SIZE_XLARGE);
static const std::map<std::string, int> mapSizeMapping =
{
{"s", CMapHeader::MAP_SIZE_SMALL},
{"m", CMapHeader::MAP_SIZE_MIDDLE},
{"l", CMapHeader::MAP_SIZE_LARGE},
{"xl", CMapHeader::MAP_SIZE_XLARGE},
};
auto it = mapSizeMapping.find(parts[0]);
if(it == mapSizeMapping.end())
{
@ -224,9 +229,13 @@ CRmgTemplate::CSize CJsonRmgTemplateLoader::parseMapTemplateSize(const std::stri
ETemplateZoneType::ETemplateZoneType CJsonRmgTemplateLoader::parseZoneType(const std::string & type) const
{
static const std::map<std::string, ETemplateZoneType::ETemplateZoneType> zoneTypeMapping = boost::assign::map_list_of
("playerStart", ETemplateZoneType::PLAYER_START)("cpuStart", ETemplateZoneType::CPU_START)
("treasure", ETemplateZoneType::TREASURE)("junction", ETemplateZoneType::JUNCTION);
static const std::map<std::string, ETemplateZoneType::ETemplateZoneType> zoneTypeMapping =
{
{"playerStart", ETemplateZoneType::PLAYER_START},
{"cpuStart", ETemplateZoneType::CPU_START},
{"treasure", ETemplateZoneType::TREASURE},
{"junction", ETemplateZoneType::JUNCTION},
};
auto it = zoneTypeMapping.find(type);
if(it == zoneTypeMapping.end()) throw std::runtime_error("Zone type unknown.");
return it->second;
@ -333,4 +342,4 @@ CRmgTemplateStorage::CRmgTemplateStorage()
CRmgTemplateStorage::~CRmgTemplateStorage()
{
for (auto & pair : templates) delete pair.second;
}
}

View File

@ -704,7 +704,7 @@ void CGameHandler::battleAfterLevelUp( const BattleResult &result )
visitObjectAfterVictory = false;
//handle victory/loss of engaged players
std::set<PlayerColor> playerColors = boost::assign::list_of(finishingBattle->loser)(finishingBattle->victor);
std::set<PlayerColor> playerColors = {finishingBattle->loser, finishingBattle->victor};
checkVictoryLossConditions(playerColors);
if(result.result == BattleResult::SURRENDER || result.result == BattleResult::ESCAPE) //loser has escaped or surrendered
@ -1819,7 +1819,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
SetObjectProperty sop(obj->id, 1, owner.getNum());
sendAndApply(&sop);
std::set<PlayerColor> playerColors = boost::assign::list_of(owner)(oldOwner);
std::set<PlayerColor> playerColors = {owner, oldOwner};
checkVictoryLossConditions(playerColors);
if(owner < PlayerColor::PLAYER_LIMIT && dynamic_cast<const CGTownInstance *>(obj)) //town captured