Prechádzať zdrojové kódy

second part of c++11 update. gcc 4.5 and VS 2010 are no longer supported
- BOOST_FOREACH -> for
- replaced several boost classes with std (e.g. unordered)
- removed gcc-4.5 workarounds
- ran clang c++11 migration tool to detect some cases:
- - pointer initialized with "0" to nullptr
- - replace for with iterators with range-based for
- - use auto in some situations (type name specified twice, avoid long iterators type names)

Ivan Savenko 12 rokov pred
rodič
commit
f82122d9be
88 zmenil súbory, kde vykonal 2059 pridanie a 2056 odobranie
  1. 16 16
      AI/BattleAI/BattleAI.cpp
  2. 4 4
      AI/StupidAI/StupidAI.cpp
  3. 4 4
      AI/VCAI/Fuzzy.cpp
  4. 86 86
      AI/VCAI/VCAI.cpp
  5. 3 3
      AI/VCAI/VCAI.h
  6. 2 2
      CMakeLists.txt
  7. 36 30
      Global.h
  8. 12 12
      client/AdventureMapClasses.cpp
  9. 2 2
      client/CAdvmapInterface.cpp
  10. 28 28
      client/CAnimation.cpp
  11. 21 21
      client/CCastleInterface.cpp
  12. 15 15
      client/CCreatureWindow.cpp
  13. 10 10
      client/CDefHandler.cpp
  14. 5 5
      client/CHeroWindow.cpp
  15. 16 17
      client/CKingdomInterface.cpp
  16. 8 8
      client/CMT.cpp
  17. 32 32
      client/CMessage.cpp
  18. 1 1
      client/CMusicHandler.cpp
  19. 62 62
      client/CPlayerInterface.cpp
  20. 2 2
      client/CPlayerInterface.h
  21. 106 114
      client/CPreGame.cpp
  22. 2 2
      client/CQuestLog.cpp
  23. 18 18
      client/CSpellWindow.cpp
  24. 16 18
      client/Client.cpp
  25. 123 123
      client/GUIClasses.cpp
  26. 21 21
      client/Graphics.cpp
  27. 19 19
      client/NetPacksClient.cpp
  28. 33 33
      client/battle/CBattleAnimations.cpp
  29. 101 101
      client/battle/CBattleInterface.cpp
  30. 12 12
      client/battle/CBattleInterfaceClasses.cpp
  31. 5 5
      client/battle/CCreatureAnimation.cpp
  32. 27 27
      client/gui/CGuiHandler.cpp
  33. 14 14
      client/gui/CIntObject.cpp
  34. 26 26
      client/gui/CIntObjectClasses.cpp
  35. 13 13
      client/gui/Fonts.cpp
  36. 51 51
      client/mapHandler.cpp
  37. 43 43
      lib/BattleState.cpp
  38. 43 43
      lib/CArtHandler.cpp
  39. 52 52
      lib/CBattleCallback.cpp
  40. 2 2
      lib/CBonusTypeHandler.cpp
  41. 4 4
      lib/CConfigHandler.cpp
  42. 25 25
      lib/CCreatureHandler.cpp
  43. 35 35
      lib/CCreatureSet.cpp
  44. 7 7
      lib/CDefObjInfoHandler.cpp
  45. 168 170
      lib/CGameState.cpp
  46. 33 33
      lib/CHeroHandler.cpp
  47. 24 24
      lib/CModHandler.cpp
  48. 140 140
      lib/CObjectHandler.cpp
  49. 1 1
      lib/CObjectHandler.h
  50. 23 23
      lib/CSpellHandler.cpp
  51. 23 23
      lib/CTownHandler.cpp
  52. 1 1
      lib/Connection.cpp
  53. 4 4
      lib/Connection.h
  54. 40 40
      lib/HeroBonus.cpp
  55. 24 10
      lib/HeroBonus.h
  56. 30 30
      lib/IGameCallback.cpp
  57. 2 2
      lib/IGameCallback.h
  58. 3 3
      lib/IGameEventsReceiver.h
  59. 20 20
      lib/JsonNode.cpp
  60. 3 3
      lib/JsonNode.h
  61. 2 2
      lib/NetPacks.h
  62. 50 50
      lib/NetPacksLib.cpp
  63. 5 5
      lib/ResourceSet.cpp
  64. 6 6
      lib/filesystem/CFilesystemLoader.cpp
  65. 3 3
      lib/filesystem/CFilesystemLoader.h
  66. 6 6
      lib/filesystem/CLodArchiveLoader.cpp
  67. 2 2
      lib/filesystem/CLodArchiveLoader.h
  68. 4 4
      lib/filesystem/CMappedFileLoader.cpp
  69. 2 2
      lib/filesystem/CMappedFileLoader.h
  70. 8 8
      lib/filesystem/CResourceLoader.cpp
  71. 11 11
      lib/filesystem/CResourceLoader.h
  72. 1 1
      lib/filesystem/ISimpleResourceLoader.h
  73. 3 3
      lib/int3.h
  74. 2 2
      lib/logging/CBasicLogConfigurator.cpp
  75. 2 2
      lib/logging/CLogger.cpp
  76. 1 1
      lib/logging/CLogger.h
  77. 6 6
      lib/mapping/CCampaignHandler.cpp
  78. 3 3
      lib/mapping/CMap.cpp
  79. 19 19
      lib/mapping/CMapEditManager.cpp
  80. 1 2
      lib/mapping/CMapEditManager.h
  81. 2 4
      lib/mapping/CMapInfo.h
  82. 43 43
      lib/mapping/MapFormatH3M.cpp
  83. 14 14
      lib/rmg/CMapGenerator.cpp
  84. 6 6
      scripting/erm/ERMInterpreter.cpp
  85. 1 1
      scripting/erm/ERMParser.cpp
  86. 132 133
      server/CGameHandler.cpp
  87. 12 12
      server/CQuery.cpp
  88. 10 10
      server/CVCMIServer.cpp

+ 16 - 16
AI/BattleAI/BattleAI.cpp

@@ -34,7 +34,7 @@ struct Priorities
 int distToNearestNeighbour(BattleHex hex, const ReachabilityInfo::TDistances& dists, BattleHex *chosenHex = nullptr)
 {
 	int ret = 1000000;
-	BOOST_FOREACH(BattleHex n, hex.neighbouringTiles())
+	for(BattleHex n : hex.neighbouringTiles())
 	{
 		if(dists[n] >= 0 && dists[n] < ret)
 		{
@@ -53,10 +53,10 @@ bool isCloser(const EnemyInfo & ei1, const EnemyInfo & ei2, const ReachabilityIn
 }
 
 template <typename Container, typename Pred>
-auto sum(const Container & c, Pred p) -> decltype(p(*boost::begin(c)))
+auto sum(const Container & c, Pred p) -> decltype(p(*std::begin(c)))
 {
 	double ret = 0;
-	BOOST_FOREACH(const auto &element, c)
+	for(const auto &element : c)
 	{
 		ret += p(element);
 	}
@@ -347,7 +347,7 @@ struct CurrentOffensivePotential
 
 	CurrentOffensivePotential(ui8 side)
 	{
-		BOOST_FOREACH(auto stack, cbc->battleGetStacks())
+		for(auto stack : cbc->battleGetStacks())
 		{
 			if(stack->attackerOwned == !side)
 				ourAttacks[stack] = PotentialTargets(stack);
@@ -359,10 +359,10 @@ struct CurrentOffensivePotential
 	int potentialValue()
 	{
 		int ourPotential = 0, enemyPotential = 0;
-		BOOST_FOREACH(auto &p, ourAttacks)
+		for(auto &p : ourAttacks)
 			ourPotential += p.second.bestAction().attackValue();
 
-		BOOST_FOREACH(auto &p, enemyAttacks)
+		for(auto &p : enemyAttacks)
 			enemyPotential += p.second.bestAction().attackValue();
 
 		return ourPotential - enemyPotential;
@@ -408,9 +408,9 @@ void CBattleAI::attemptCastingSpell()
 
 	//Get possible spell-target pairs
 	std::vector<PossibleSpellcast> possibleCasts;
-	BOOST_FOREACH(auto spell, possibleSpells)
+	for(auto spell : possibleSpells)
 	{
-		BOOST_FOREACH(auto hex, getTargetsToConsider(spell))
+		for(auto hex : getTargetsToConsider(spell))
 		{
 			PossibleSpellcast ps = {spell, hex};
 			possibleCasts.push_back(ps);
@@ -421,7 +421,7 @@ void CBattleAI::attemptCastingSpell()
 		return;
 
 	std::map<const CStack*, int> valueOfStack;
-	BOOST_FOREACH(auto stack, cb->battleGetStacks())
+	for(auto stack : cb->battleGetStacks())
 	{
 		PotentialTargets pt(stack);
 		valueOfStack[stack] = pt.bestActionValue();
@@ -447,7 +447,7 @@ void CBattleAI::attemptCastingSpell()
 				if(stacksSuffering.empty())
 					return -1;
 
-				BOOST_FOREACH(auto stack, stacksSuffering)
+				for(auto stack : stacksSuffering)
 				{
 					const int dmg = cb->calculateSpellDmg(ps.spell, hero, stack, skillLevel, spellPower);
 					if(stack->owner == playerID)
@@ -548,7 +548,7 @@ ThreatMap::ThreatMap(const CStack *Endangered) : endangered(Endangered)
 {
 	sufferedDamage.fill(0);
 
-	BOOST_FOREACH(const CStack *enemy, cbc->battleGetStacks())
+	for(const CStack *enemy : cbc->battleGetStacks())
 	{
 		//Consider only stacks of different owner
 		if(enemy->attackerOwned == endangered->attackerOwned)
@@ -563,7 +563,7 @@ ThreatMap::ThreatMap(const CStack *Endangered) : endangered(Endangered)
 			if(enemyReachability.isReachable(i))
 			{
 				meleeAttackable[i] = true;
-				BOOST_FOREACH(auto n, BattleHex(i).neighbouringTiles())
+				for(auto n : BattleHex(i).neighbouringTiles())
 					meleeAttackable[n] = true;
 			}
 		}
@@ -596,8 +596,8 @@ const TBonusListPtr StackWithBonuses::getAllBonuses(const CSelector &selector, c
 {
 	TBonusListPtr ret = make_shared<BonusList>();
 	const TBonusListPtr originalList = stack->getAllBonuses(selector, limit, root, cachingStr);
-	boost::copy(*originalList, std::back_inserter(*ret));
-	BOOST_FOREACH(auto &bonus, bonusesToAdd)
+	range::copy(*originalList, std::back_inserter(*ret));
+	for(auto &bonus : bonusesToAdd)
 	{
 		if(selector(&bonus)  &&  (!limit || !limit(&bonus)))
 			ret->push_back(&bonus);
@@ -664,7 +664,7 @@ PotentialTargets::PotentialTargets(const CStack *attacker, const HypotheticChang
 	auto dists = cbc->battleGetDistances(attacker);
 	auto avHexes = cbc->battleGetAvailableHexes(attacker, false);
 
-	BOOST_FOREACH(const CStack *enemy, cbc->battleGetStacks())
+	for(const CStack *enemy : cbc->battleGetStacks())
 	{
 		//Consider only stacks of different owner
 		if(enemy->attackerOwned == attacker->attackerOwned)
@@ -691,7 +691,7 @@ PotentialTargets::PotentialTargets(const CStack *attacker, const HypotheticChang
 		}
 		else
 		{
-			BOOST_FOREACH(BattleHex hex, avHexes)
+			for(BattleHex hex : avHexes)
 				if(CStack::isMeleeAttackPossible(attacker, enemy, hex))
 					possibleAttacks.push_back(GenerateAttackInfo(false, hex));
 

+ 4 - 4
AI/StupidAI/StupidAI.cpp

@@ -63,7 +63,7 @@ bool isMoreProfitable(const EnemyInfo &ei1, const EnemyInfo& ei2)
 int distToNearestNeighbour(BattleHex hex, const ReachabilityInfo::TDistances& dists, BattleHex *chosenHex = nullptr)
 {
 	int ret = 1000000;
-	BOOST_FOREACH(BattleHex n, hex.neighbouringTiles())
+	for(auto & n: hex.neighbouringTiles())
 	{
 		if(dists[n] >= 0 && dists[n] < ret)
 		{
@@ -86,7 +86,7 @@ static bool willSecondHexBlockMoreEnemyShooters(const BattleHex &h1, const Battl
 	int shooters[2] = {0}; //count of shooters on hexes
 
 	for(int i = 0; i < 2; i++)
-		BOOST_FOREACH(BattleHex neighbour, (i ? h2 : h1).neighbouringTiles())
+		for (auto & neighbour : (i ? h2 : h1).neighbouringTiles())
 			if(const CStack *s = cbc->battleGetStackByPos(neighbour))
 				if(s->getCreature()->isShooting())
 						shooters[i]++;
@@ -114,7 +114,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
 		return attack;
 	}
 
-	BOOST_FOREACH(const CStack *s, cb->battleGetStacks(CBattleCallback::ONLY_ENEMY))
+	for (const CStack *s : cb->battleGetStacks(CBattleCallback::ONLY_ENEMY))
 	{
 		if(cb->battleCanShoot(stack, s->position))
 		{
@@ -124,7 +124,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
 		{
 			std::vector<BattleHex> avHexes = cb->battleGetAvailableHexes(stack, false);
 
-			BOOST_FOREACH(BattleHex hex, avHexes)
+			for (BattleHex hex : avHexes)
 			{
 				if(CStack::isMeleeAttackPossible(stack, s, hex))
 				{

+ 4 - 4
AI/VCAI/Fuzzy.cpp

@@ -37,7 +37,7 @@ struct armyStructure
 ui64 evaluateBankConfig (BankConfig * bc)
 {
 	ui64 danger = 0;
-	BOOST_FOREACH (auto opt, bc->guards)
+	for (auto opt : bc->guards)
 	{
 		danger += VLC->creh->creatures[opt.first]->fightValue * opt.second;
 	}
@@ -52,7 +52,7 @@ armyStructure evaluateArmyStructure (const CArmedInstance * army)
 	double shootersStrenght = 0;
 	ui32 maxSpeed = 0;
 
-	BOOST_FOREACH(auto s, army->Slots())
+	for(auto s : army->Slots())
 	{
 		bool walker = true;
 		if (s.second->type->hasBonusOfType(Bonus::SHOOTER))
@@ -123,7 +123,7 @@ void FuzzyHelper::initTacticalAdvantage()
 
 		helper += ourShooters, ourWalkers, ourFlyers, enemyShooters, enemyWalkers, enemyFlyers;
 
-		BOOST_FOREACH (auto val, helper)
+		for (auto val : helper)
 		{
 			val->addTerm (new fl::ShoulderTerm("FEW", 0, 0.75, true));
 			val->addTerm (new fl::ShoulderTerm("MANY", 0.25, 1, false));
@@ -136,7 +136,7 @@ void FuzzyHelper::initTacticalAdvantage()
 
 		helper += ourSpeed, enemySpeed;
 
-		BOOST_FOREACH (auto val, helper)
+		for (auto val : helper)
 		{
 			val->addTerm (new fl::ShoulderTerm("LOW", 3, 8.1, true));
 			val->addTerm (new fl::TriangularTerm("MEDIUM", 6.9, 13.1));

+ 86 - 86
AI/VCAI/VCAI.cpp

@@ -159,7 +159,7 @@ void foreach_tile_pos(std::function<void(const int3& pos)> foo)
 
 void foreach_neighbour(const int3 &pos, std::function<void(const int3& pos)> foo)
 {
-	BOOST_FOREACH(const int3 &dir, dirs)
+	for(const int3 &dir : dirs)
 	{
 		const int3 n = pos + dir;
 		if(cb->isInTheMap(n))
@@ -179,10 +179,10 @@ const unsigned char &retreiveTileN(const std::vector< std::vector< std::vector<u
 
 void foreach_tile(std::vector< std::vector< std::vector<unsigned char> > > &vectors, std::function<void(unsigned char &in)> foo)
 {
-	for(auto i = vectors.begin(); i != vectors.end(); i++)
-		for(auto j = i->begin(); j != i->end(); j++)
-			for(auto z = j->begin(); z != j->end(); z++)
-				foo(*z);
+	for(auto & vector : vectors)
+		for(auto j = vector.begin(); j != vector.end(); j++)
+			for(auto & elem : *j)
+				foo(elem);
 }
 
 struct ObjInfo
@@ -241,7 +241,7 @@ ui64 howManyReinforcementsCanGet(HeroPtr h, const CGTownInstance *t)
 	ui64 ret = 0;
 	int freeHeroSlots = GameConstants::ARMY_SIZE - h->stacksCount();
 	std::vector<const CStackInstance *> toMove;
-	BOOST_FOREACH(auto const slot, t->Slots())
+	for(auto const slot : t->Slots())
 	{
 		//can be merged woth another stack?
 		SlotID dst = h->getSlotFor(slot.second->getCreatureID());
@@ -254,7 +254,7 @@ ui64 howManyReinforcementsCanGet(HeroPtr h, const CGTownInstance *t)
 	{
 		return lhs->getPower() < rhs->getPower();
 	});
-	BOOST_REVERSE_FOREACH(const CStackInstance *stack, toMove)
+	for (auto & stack : boost::adaptors::reverse(toMove))
 	{
 		if(freeHeroSlots)
 		{
@@ -341,7 +341,7 @@ ui64 evaluateDanger(crint3 tile, const CGHeroInstance *visitor)
 	}
 
 	auto guards = cb->getGuardingCreatures(tile);
-	BOOST_FOREACH (auto cre, guards)
+	for (auto cre : guards)
 	{
 		amax (guardDanger, evaluateDanger(cre) * fh->getTacticalAdvantage(visitor, dynamic_cast<const CArmedInstance*>(cre))); //we are interested in strongest monster around
 	}
@@ -596,7 +596,7 @@ void VCAI::heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * tow
 	//moveCreaturesToHero(town);
 }
 
-void VCAI::tileHidden(const boost::unordered_set<int3, ShashInt3> &pos)
+void VCAI::tileHidden(const std::unordered_set<int3, ShashInt3> &pos)
 {
 	LOG_TRACE(logAi);
 	NET_EVENT_HANDLER;
@@ -604,12 +604,12 @@ void VCAI::tileHidden(const boost::unordered_set<int3, ShashInt3> &pos)
 	validateVisitableObjs();
 }
 
-void VCAI::tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos)
+void VCAI::tileRevealed(const std::unordered_set<int3, ShashInt3> &pos)
 {
 	LOG_TRACE(logAi);
 	NET_EVENT_HANDLER;
-	BOOST_FOREACH(int3 tile, pos)
-		BOOST_FOREACH(const CGObjectInstance *obj, myCb->getVisitableObjs(tile))
+	for(int3 tile : pos)
+		for(const CGObjectInstance *obj : myCb->getVisitableObjs(tile))
 			addVisitableObj(obj);
 }
 
@@ -686,7 +686,7 @@ void VCAI::objectRemoved(const CGObjectInstance *obj)
 	erase_if_present(reservedObjs, obj);
 
 
-	BOOST_FOREACH(auto &p, reservedHeroesMap)
+	for(auto &p : reservedHeroesMap)
 		erase_if_present(p.second, obj);
 
 	//TODO
@@ -953,7 +953,7 @@ void VCAI::makeTurn()
 			townVisitsThisWeek.clear();
 			std::vector<const CGObjectInstance *> objs;
 			retreiveVisitableObjs(objs, true);
-			BOOST_FOREACH(const CGObjectInstance *obj, objs)
+			for(const CGObjectInstance *obj : objs)
 			{
 				if (isWeeklyRevisitable(obj))
 				{
@@ -974,7 +974,7 @@ void VCAI::makeTurn()
 				int dangerousObjects = 0;
 				std::vector<const CGObjectInstance *> objs;
 				retreiveVisitableObjs(objs, false);
-				BOOST_FOREACH (auto obj, objs)
+				for (auto obj : objs)
 				{
 					if (evaluateDanger(obj)) //potentilaly dnagerous
 					{
@@ -1005,18 +1005,18 @@ void VCAI::makeTurnInternal()
 	saving = 0;
 
 	//it looks messy here, but it's better to have armed heroes before attempting realizing goals
-	BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+	for(const CGTownInstance *t : cb->getTownsInfo())
 		moveCreaturesToHero(t);
 
 	try
 	{
 		//Pick objects reserved in previous turn - we expect only nerby objects there
 		auto reservedHeroesCopy = reservedHeroesMap; //work on copy => the map may be changed while iterating (eg because hero died when attempting a goal)
-		BOOST_FOREACH (auto hero, reservedHeroesCopy)
+		for (auto hero : reservedHeroesCopy)
 		{
 			cb->setSelection(hero.first.get());
 			boost::sort (hero.second, isCloser);
-			BOOST_FOREACH (auto obj, hero.second)
+			for (auto obj : hero.second)
 			{
 				striveToGoal (CGoal(VISIT_TILE).sethero(hero.first).settile(obj->visitablePos()));
 			}
@@ -1051,7 +1051,7 @@ void VCAI::makeTurnInternal()
 		}
 
 		auto quests = myCb->getMyQuests();
-		BOOST_FOREACH (auto quest, quests)
+		for (auto quest : quests)
 		{
 			striveToQuest (quest);
 		}
@@ -1114,8 +1114,8 @@ bool VCAI::canGetArmy (const CGHeroInstance * army, const CGHeroInstance * sourc
 	int armySize = 0; 
 	//we calculate total strength for each creature type available in armies
 	std::map<const CCreature*, int> creToPower;
-	BOOST_FOREACH(auto armyPtr, armies)
-		BOOST_FOREACH(auto &i, armyPtr->Slots())
+	for(auto armyPtr : armies)
+		for(auto &i : armyPtr->Slots())
 		{
 			++armySize;//TODO: allow splitting stacks?
 			creToPower[i.second->type] += i.second->getPower();
@@ -1140,7 +1140,7 @@ bool VCAI::canGetArmy (const CGHeroInstance * army, const CGHeroInstance * sourc
 	//foreach best type -> iterate over slots in both armies and if it's the appropriate type, send it to the slot where it belongs
 	for (int i = 0; i < bestArmy.size(); i++) //i-th strongest creature type will go to i-th slot
 	{
-		BOOST_FOREACH(auto armyPtr, armies)
+		for(auto armyPtr : armies)
 			for (int j = 0; j < GameConstants::ARMY_SIZE; j++)
 			{
 				if(armyPtr->getCreature(SlotID(j)) == bestArmy[i]  &&  (i != j || armyPtr != army)) //it's a searched creature not in dst slot
@@ -1158,8 +1158,8 @@ void VCAI::pickBestCreatures(const CArmedInstance * army, const CArmedInstance *
 	int armySize = 0; 
 	//we calculate total strength for each creature type available in armies
 	std::map<const CCreature*, int> creToPower;
-	BOOST_FOREACH(auto armyPtr, armies)
-		BOOST_FOREACH(auto &i, armyPtr->Slots())
+	for(auto armyPtr : armies)
+		for(auto &i : armyPtr->Slots())
 		{
 			++armySize;//TODO: allow splitting stacks?
 			creToPower[i.second->type] += i.second->getPower();
@@ -1184,7 +1184,7 @@ void VCAI::pickBestCreatures(const CArmedInstance * army, const CArmedInstance *
 	//foreach best type -> iterate over slots in both armies and if it's the appropriate type, send it to the slot where it belongs
 	for (int i = 0; i < bestArmy.size(); i++) //i-th strongest creature type will go to i-th slot
 	{
-		BOOST_FOREACH(auto armyPtr, armies)
+		for(auto armyPtr : armies)
 			for (int j = 0; j < GameConstants::ARMY_SIZE; j++)
 			{
 				if(armyPtr->getCreature(SlotID(j)) == bestArmy[i]  &&  (i != j || armyPtr != army)) //it's a searched creature not in dst slot
@@ -1244,7 +1244,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
 
 	toBuild.insert(building);
 
-	BOOST_FOREACH(BuildingID buildID, toBuild)
+	for(BuildingID buildID : toBuild)
 	{
 		EBuildingState::EBuildingState canBuild = cb->canBuildStructure(t, buildID);
 		if (canBuild == EBuildingState::HAVE_CAPITAL
@@ -1260,7 +1260,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
 	TResources income = estimateIncome();
 	//TODO: calculate if we have enough resources to build it in maxDays
 
-	BOOST_FOREACH(const auto & buildID, toBuild)
+	for(const auto & buildID : toBuild)
 	{
 		const CBuilding *b = t->town->buildings[buildID];
 
@@ -1292,7 +1292,7 @@ bool VCAI::tryBuildStructure(const CGTownInstance * t, BuildingID building, unsi
 
 bool VCAI::tryBuildAnyStructure(const CGTownInstance * t, std::vector<BuildingID> buildList, unsigned int maxDays)
 {
-	BOOST_FOREACH(const auto & building, buildList)
+	for(const auto & building : buildList)
 	{
 		if(t->hasBuilt(building))
 			continue;
@@ -1304,7 +1304,7 @@ bool VCAI::tryBuildAnyStructure(const CGTownInstance * t, std::vector<BuildingID
 
 bool VCAI::tryBuildNextStructure(const CGTownInstance * t, std::vector<BuildingID> buildList, unsigned int maxDays)
 {
-	BOOST_FOREACH(const auto & building, buildList)
+	for(const auto & building : buildList)
 	{
 		if(t->hasBuilt(building))
 			continue;
@@ -1398,7 +1398,7 @@ std::vector<const CGObjectInstance *> VCAI::getPossibleDestinations(HeroPtr h)
 {
 	validateVisitableObjs();
 	std::vector<const CGObjectInstance *> possibleDestinations;
-	BOOST_FOREACH(const CGObjectInstance *obj, visitableObjs)
+	for(const CGObjectInstance *obj : visitableObjs)
 	{
 		if(cb->getPathInfo(obj->visitablePos())->reachable() && !obj->wasVisited(playerID) &&
 			(obj->tempOwner != playerID || isWeeklyRevisitable(obj))) //flag or get weekly resources / creatures
@@ -1452,7 +1452,7 @@ void VCAI::wander(HeroPtr h)
 
 	        std::vector<const CGTownInstance *> townsReachable;
 	        std::vector<const CGTownInstance *> townsNotReachable;
-	        BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+	        for(const CGTownInstance *t : cb->getTownsInfo())
 	        {
 	            if(!t->visitingHero && howManyReinforcementsCanGet(h,t) && !vstd::contains(townVisitsThisWeek[h], t))
 	            {
@@ -1487,7 +1487,7 @@ void VCAI::wander(HeroPtr h)
 				std::vector<const CGTownInstance *> towns = cb->getTownsInfo();
 				erase_if(towns, [](const CGTownInstance *t) -> bool
 				{
-					BOOST_FOREACH(const CGHeroInstance *h, cb->getHeroesInfo())
+					for(const CGHeroInstance *h : cb->getHeroesInfo())
 					if(!t->getArmyStrength() || howManyReinforcementsCanGet(h, t))
 						return true;
 					return false;
@@ -1619,7 +1619,7 @@ void VCAI::retreiveVisitableObjs(std::vector<const CGObjectInstance *> &out, boo
 {
 	foreach_tile_pos([&](const int3 &pos)
 	{
-		BOOST_FOREACH(const CGObjectInstance *obj, myCb->getVisitableObjs(pos, false))
+		for(const CGObjectInstance *obj : myCb->getVisitableObjs(pos, false))
 		{
 			if(includeOwned || obj->tempOwner != playerID)
 				out.push_back(obj);
@@ -1646,7 +1646,7 @@ void VCAI::addVisitableObj(const CGObjectInstance *obj)
 
 const CGObjectInstance * VCAI::lookForArt(int aid) const
 {
-	BOOST_FOREACH(const CGObjectInstance *obj, ai->visitableObjs)
+	for(const CGObjectInstance *obj : ai->visitableObjs)
 	{
 		if(obj->ID == 5 && obj->subID == aid)
 			return obj;
@@ -1661,7 +1661,7 @@ bool VCAI::isAccessible(const int3 &pos)
 {
 	//TODO precalculate for speed
 
-	BOOST_FOREACH(const CGHeroInstance *h, cb->getHeroesInfo())
+	for(const CGHeroInstance *h : cb->getHeroesInfo())
 	{
 		if(isAccessibleForHero(pos, h))
 			return true;
@@ -1672,7 +1672,7 @@ bool VCAI::isAccessible(const int3 &pos)
 
 HeroPtr VCAI::getHeroWithGrail() const
 {
-	BOOST_FOREACH(const CGHeroInstance *h, cb->getHeroesInfo())
+	for(const CGHeroInstance *h : cb->getHeroesInfo())
 		if(h->hasArt(2)) //grail
 			return h;
 
@@ -1682,7 +1682,7 @@ HeroPtr VCAI::getHeroWithGrail() const
 const CGObjectInstance * VCAI::getUnvisitedObj(const std::function<bool(const CGObjectInstance *)> &predicate)
 {
 	//TODO smarter definition of unvisited
-	BOOST_FOREACH(const CGObjectInstance *obj, visitableObjs)
+	for(const CGObjectInstance *obj : visitableObjs)
 		if(predicate(obj) && !vstd::contains(alreadyVisited, obj))
 			return obj;
 
@@ -1694,7 +1694,7 @@ bool VCAI::isAccessibleForHero(const int3 & pos, HeroPtr h, bool includeAllies /
 	cb->setSelection(*h);
 	if (!includeAllies)
 	{ //don't visit tile occupied by allied hero
-		BOOST_FOREACH (auto obj, cb->getVisitableObjs(pos))
+		for (auto obj : cb->getVisitableObjs(pos))
 		{
 			if (obj->ID == Obj::HERO && obj->tempOwner == h->tempOwner && obj != h)
 				return false;
@@ -1830,7 +1830,7 @@ int howManyTilesWillBeDiscovered(int radious, int3 pos, crint3 dir)
 
 void getVisibleNeighbours(const std::vector<int3> &tiles, std::vector<int3> &out)
 {
-	BOOST_FOREACH(const int3 &tile, tiles)
+	for(const int3 &tile : tiles)
 	{
 		foreach_neighbour(tile, [&](int3 neighbour)
 		{
@@ -1896,7 +1896,7 @@ void VCAI::tryRealize(CGoal g)
 
 			if(!t)
 			{
-				BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+				for(const CGTownInstance *t : cb->getTownsInfo())
 				{
 					switch(cb->canBuildStructure(t, BuildingID(g.bid)))
 					{
@@ -1985,7 +1985,7 @@ void VCAI::tryRealize(CGoal g)
 
 const CGTownInstance * VCAI::findTownWithTavern() const
 {
-	BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+	for(const CGTownInstance *t : cb->getTownsInfo())
 		if(t->hasBuilt(BuildingID::TAVERN) && !t->visitingHero)
 			return t;
 
@@ -1997,7 +1997,7 @@ std::vector<HeroPtr> VCAI::getUnblockedHeroes() const
 	std::vector<HeroPtr> ret;
 	boost::copy(cb->getHeroesInfo(), std::back_inserter(ret));
 
-	BOOST_FOREACH(auto h, lockedHeroes)
+	for(auto h : lockedHeroes)
 	{
 		//if (!h.second.invalid()) //we can use heroes without valid goal
 		if (h.second.goalType == DIG_AT_TILE || !h.first->movement) //experiment: use all heroes that have movement left, TODO: unlock heroes that couldn't realize their goals 
@@ -2200,7 +2200,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 		{
 			case CQuest::MISSION_ART:
 			{
-				BOOST_FOREACH (auto hero, heroes) //TODO: remove duplicated code?
+				for (auto hero : heroes) //TODO: remove duplicated code?
 				{
 					if (q.quest->checkQuest(hero))
 					{
@@ -2208,7 +2208,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 						return;
 					}
 				}
-				BOOST_FOREACH (auto art, q.quest->m5arts)
+				for (auto art : q.quest->m5arts)
 				{
 					striveToGoal (CGoal(GET_ART_TYPE).setaid(art)); //TODO: transport?
 				}
@@ -2217,7 +2217,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 			case CQuest::MISSION_HERO:
 			{
 				//striveToGoal (CGoal(RECRUIT_HERO));
-				BOOST_FOREACH (auto hero, heroes)
+				for (auto hero : heroes)
 				{
 					if (q.quest->checkQuest(hero))
 					{
@@ -2231,7 +2231,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 			}
 			case CQuest::MISSION_ARMY:
 			{
-				BOOST_FOREACH (auto hero, heroes)
+				for (auto hero : heroes)
 				{
 					if (q.quest->checkQuest(hero)) //veyr bad info - stacks can be split between multiple heroes :(
 					{
@@ -2239,7 +2239,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 						return;
 					}
 				}
-				BOOST_FOREACH (auto creature, q.quest->m6creatures)
+				for (auto creature : q.quest->m6creatures)
 				{
 					striveToGoal (CGoal(GATHER_TROOPS).setobjid(creature.type->idNumber).setvalue(creature.count));
 				}
@@ -2281,7 +2281,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 			case CQuest::MISSION_PRIMARY_STAT:
 			{
 				auto heroes = cb->getHeroesInfo();
-				BOOST_FOREACH (auto hero, heroes)
+				for (auto hero : heroes)
 				{
 					if (q.quest->checkQuest(hero))
 					{
@@ -2298,7 +2298,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 			case CQuest::MISSION_LEVEL:
 			{
 				auto heroes = cb->getHeroesInfo();
-				BOOST_FOREACH (auto hero, heroes)
+				for (auto hero : heroes)
 				{
 					if (q.quest->checkQuest(hero))
 					{
@@ -2326,7 +2326,7 @@ void VCAI::striveToQuest (const QuestInfo &q)
 
 void VCAI::performTypicalActions()
 {
-	BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+	for(const CGTownInstance *t : cb->getTownsInfo())
 	{
         logAi->debugStream() << boost::format("Looking into %s") % t->name;
 		buildStructure(t);
@@ -2340,7 +2340,7 @@ void VCAI::performTypicalActions()
 		}
 	}
 
-	BOOST_FOREACH(auto h, getUnblockedHeroes())
+	for(auto h : getUnblockedHeroes())
 	{
         logAi->debugStream() << boost::format("Looking into %s, MP=%d") % h->name.c_str() % h->movement;
 		makePossibleUpgrades(*h);
@@ -2369,7 +2369,7 @@ int3 VCAI::explorationBestNeighbour(int3 hpos, int radius, HeroPtr h)
 {
 	TimeCheck tc("looking for best exploration neighbour");
 	std::map<int3, int> dstToRevealedTiles;
-	BOOST_FOREACH(crint3 dir, dirs)
+	for(crint3 dir : dirs)
 		if(cb->isInTheMap(hpos+dir))
 			dstToRevealedTiles[hpos + dir] = howManyTilesWillBeDiscovered(radius, hpos, dir) * isSafeToVisit(h, hpos + dir);
 
@@ -2407,7 +2407,7 @@ int3 VCAI::explorationNewPoint(int radius, HeroPtr h, std::vector<std::vector<in
 		getVisibleNeighbours(tiles[i-1], tiles[i]);
 		removeDuplicates(tiles[i]);
 
-		BOOST_FOREACH(const int3 &tile, tiles[i])
+		for(const int3 &tile : tiles[i])
 		{
 			if(cb->getPathInfo(tile)->reachable() && isSafeToVisit(h, tile) && howManyTilesWillBeDiscovered(tile, radius) && !isBlockedBorderGate(tile))
 			{
@@ -2421,7 +2421,7 @@ int3 VCAI::explorationNewPoint(int radius, HeroPtr h, std::vector<std::vector<in
 TResources VCAI::estimateIncome() const
 {
 	TResources ret;
-	BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+	for(const CGTownInstance *t : cb->getTownsInfo())
 	{
 		ret[Res::GOLD] += t->dailyIncome();
 
@@ -2440,7 +2440,7 @@ TResources VCAI::estimateIncome() const
 		}
 	}
 
-	BOOST_FOREACH(const CGObjectInstance *obj, getFlaggedObjects())
+	for(const CGObjectInstance *obj : getFlaggedObjects())
 	{
 		if(obj->ID == Obj::MINE)
 		{
@@ -2523,7 +2523,7 @@ void VCAI::lostHero(HeroPtr h)
     logAi->debugStream() << boost::format("I lost my hero %s. It's best to forget and move on.") % h.name;
 
 	erase_if_present(lockedHeroes, h);
-	BOOST_FOREACH(auto obj, reservedHeroesMap[h])
+	for(auto obj : reservedHeroesMap[h])
 	{
 		erase_if_present(reservedObjs, obj); //unreserve all objects for that hero
 	}
@@ -2573,7 +2573,7 @@ void VCAI::validateObject(ObjectIdRef obj)
 	{
 		erase_if(visitableObjs, matchesId);
 
-		BOOST_FOREACH(auto &p, reservedHeroesMap)
+		for(auto &p : reservedHeroesMap)
 			erase_if(p.second, matchesId);
 	}
 }
@@ -2701,7 +2701,7 @@ int3 whereToExplore(HeroPtr h)
 	//look for nearby objs -> visit them if they're close enouh
 	const int DIST_LIMIT = 3;
 	std::vector<const CGObjectInstance *> nearbyVisitableObjs;
-	BOOST_FOREACH(const CGObjectInstance *obj, ai->getPossibleDestinations(h))
+	for(const CGObjectInstance *obj : ai->getPossibleDestinations(h))
 	{
 		int3 op = obj->visitablePos();
 		CGPath p;
@@ -2730,8 +2730,8 @@ int3 whereToExplore(HeroPtr h)
 			{
 				TimeCheck tc("Evaluating exploration possibilities");
 				tiles[0].clear(); //we can't reach FoW anyway
-				BOOST_FOREACH(auto &vt, tiles)
-					BOOST_FOREACH(auto &tile, vt)
+				for(auto &vt : tiles)
+					for(auto &tile : vt)
 						profits[howManyTilesWillBeDiscovered(tile, radius)].push_back(tile);
 			}
 
@@ -2840,7 +2840,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 			const CGObjectInstance * o = nullptr;
 			if (resID > -1) //specified
 			{
-				BOOST_FOREACH(const CGObjectInstance *obj, ai->visitableObjs)
+				for(const CGObjectInstance *obj : ai->visitableObjs)
 				{
 					if(obj->ID == objid && obj->subID == resID)
 					{
@@ -2851,7 +2851,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 			}
 			else
 			{
-				BOOST_FOREACH(const CGObjectInstance *obj, ai->visitableObjs)
+				for(const CGObjectInstance *obj : ai->visitableObjs)
 				{
 					if(obj->ID == objid)
 					{
@@ -2969,7 +2969,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 			{
 				if (hero.get(true))
 				{
-					BOOST_FOREACH (auto obj, objs)
+					for (auto obj : objs)
 					{
 						auto pos = obj->visitablePos();
 						//FIXME: this confition fails if everything but guarded subterranen gate was explored. in this case we should gather army for hero
@@ -2979,7 +2979,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 				}
 				else
 				{
-					BOOST_FOREACH (auto obj, objs)
+					for (auto obj : objs)
 					{
 						auto pos = obj->visitablePos();
 						if (ai->isAccessible (pos)) //TODO: check safety?
@@ -3083,7 +3083,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 					return CGoal(RECRUIT_HERO);
 				}
 
-				BOOST_FOREACH(const CGHeroInstance *h, cb->getHeroesInfo())
+				for(const CGHeroInstance *h : cb->getHeroesInfo())
 				{
 					if(ai->isAccessibleForHero(tile, h))
 					{
@@ -3134,7 +3134,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 
 			std::vector<const CGObjectInstance*> visObjs;
 			ai->retreiveVisitableObjs(visObjs, true);
-			BOOST_FOREACH(const CGObjectInstance *obj, visObjs)
+			for(const CGObjectInstance *obj : visObjs)
 			{
 				if(const IMarket *m = IMarket::castFrom(obj, false))
 				{
@@ -3158,7 +3158,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 
 			if(!markets.size())
 			{
-				BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+				for(const CGTownInstance *t : cb->getTownsInfo())
 				{
 					if(cb->canBuildStructure(t, BuildingID::MARKETPLACE) == EBuildingState::ALLOWED)
 						return CGoal(BUILD_STRUCTURE).settown(t).setbid(BuildingID::MARKETPLACE);
@@ -3192,7 +3192,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 	case GATHER_TROOPS:
 		{
 			std::vector<const CGDwelling *> dwellings;
-			BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+			for(const CGTownInstance *t : cb->getTownsInfo())
 			{
 				auto creature = VLC->creh->creatures[objid];
 				if (t->subID == creature->faction) //TODO: how to force AI to build unupgraded creatures? :O
@@ -3211,17 +3211,17 @@ TSubgoal CGoal::whatToDoToAchieve()
 					}
 				}
 			}
-			BOOST_FOREACH (auto obj, ai->visitableObjs)
+			for (auto obj : ai->visitableObjs)
 			{
 				if (obj->ID != Obj::CREATURE_GENERATOR1) //TODO: what with other creature generators?
 					continue;
 
 				auto d = dynamic_cast<const CGDwelling *>(obj);
-				BOOST_FOREACH (auto creature, d->creatures)
+				for (auto creature : d->creatures)
 				{
 					if (creature.first) //there are more than 0 creatures avaliabe
 					{
-						BOOST_FOREACH (auto type, creature.second)
+						for (auto type : creature.second)
 						{
 							if (type == objid)
 								dwellings.push_back(d);
@@ -3302,7 +3302,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 				I_AM_ELEMENTAR;
 
 			boost::sort(objs, isCloser);
-			BOOST_FOREACH(const CGObjectInstance *obj, objs)
+			for(const CGObjectInstance *obj : objs)
 			{
 				if (ai->isAccessibleForHero(obj->visitablePos(), h))
 				{
@@ -3334,7 +3334,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 			};
 
 			std::vector<const CGTownInstance *> townsReachable;
-			BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+			for(const CGTownInstance *t : cb->getTownsInfo())
 			{
 				if(!t->visitingHero && howManyReinforcementsCanGet(hero,t))
 				{
@@ -3388,14 +3388,14 @@ TSubgoal CGoal::whatToDoToAchieve()
 				{
 					boost::sort(objs, isCloser);
 					HeroPtr h = nullptr;
-					BOOST_FOREACH(const CGObjectInstance *obj, objs)
+					for(const CGObjectInstance *obj : objs)
 					{ //find safe dwelling
 						auto pos = obj->visitablePos();
 						if (shouldVisit (hero, obj)) //creatures fit in army
 							h = hero;
 						else
 						{
-							BOOST_FOREACH(auto ourHero, cb->getHeroesInfo()) //make use of multiple heroes
+							for(auto ourHero : cb->getHeroesInfo()) //make use of multiple heroes
 							{
 								if (shouldVisit(ourHero, obj))
 									h = ourHero;
@@ -3445,11 +3445,11 @@ SectorMap::SectorMap()
 {
 // 	int3 sizes = cb->getMapSize();
 // 	sector.resize(sizes.x);
-// 	BOOST_FOREACH(auto &i, sector)
+// 	for(auto &i : sector)
 // 		i.resize(sizes.y);
 //
-// 	BOOST_FOREACH(auto &i, sector)
-// 		BOOST_FOREACH(auto &j, i)
+// 	for(auto &i : sector)
+// 		for(auto &j : i)
 // 			j.resize(sizes.z, 0);
 	update();
 }
@@ -3588,7 +3588,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
 		case Obj::BORDERGUARD:
 		case Obj::BORDER_GATE:
 		{
-			BOOST_FOREACH (auto q, ai->myCb->getMyQuests())
+			for (auto q : ai->myCb->getMyQuests())
 			{
 				if (q.obj == obj)
 				{
@@ -3601,7 +3601,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
 		case Obj::SEER_HUT:
 		case Obj::QUEST_GUARD:
 		{
-			BOOST_FOREACH (auto q, ai->myCb->getMyQuests())
+			for (auto q : ai->myCb->getMyQuests())
 			{
 				if (q.obj == obj)
 				{
@@ -3620,9 +3620,9 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
 				return true; //flag just in case
 			bool canRecruitCreatures = false;
 			const CGDwelling * d = dynamic_cast<const CGDwelling *>(obj);
-			BOOST_FOREACH(auto level, d->creatures)
+			for(auto level : d->creatures)
 			{
-				BOOST_FOREACH(auto c, level.second)
+				for(auto c : level.second)
 				{
 					if (h->getSlotFor(CreatureID(c)) != SlotID())
 						canRecruitCreatures = true;
@@ -3633,7 +3633,7 @@ bool shouldVisit(HeroPtr h, const CGObjectInstance * obj)
 		}
 		case Obj::HILL_FORT:
 		{	
-			BOOST_FOREACH (auto slot, h->Slots())
+			for (auto slot : h->Slots())
 			{
 				if (slot.second->type->upgrades.size())
 					return true; //TODO: check price?
@@ -3703,7 +3703,7 @@ int3 SectorMap::firstTileToGet(HeroPtr h, crint3 dst)
 			const Sector *s = sq.front();
 			sq.pop();
 
-			BOOST_FOREACH(int3 ep, s->embarkmentPoints)
+			for(int3 ep : s->embarkmentPoints)
 			{
 				Sector *neigh = &infoOnSectors[retreiveTile(ep)];
 				//preds[s].push_back(neigh);
@@ -3754,7 +3754,7 @@ int3 SectorMap::firstTileToGet(HeroPtr h, crint3 dst)
 					//we need to find a shipyard with an access to the desired sector's EP
 					//TODO what about Summon Boat spell?
 					std::vector<const IShipyard *> shipyards;
-					BOOST_FOREACH(const CGTownInstance *t, cb->getTownsInfo())
+					for(const CGTownInstance *t : cb->getTownsInfo())
 					{
 						if(t->hasBuilt(BuildingID::SHIPYARD))
 							shipyards.push_back(t);
@@ -3762,7 +3762,7 @@ int3 SectorMap::firstTileToGet(HeroPtr h, crint3 dst)
 
 					std::vector<const CGObjectInstance*> visObjs;
 					ai->retreiveVisitableObjs(visObjs, true);
-					BOOST_FOREACH(const CGObjectInstance *obj, visObjs)
+					for(const CGObjectInstance *obj : visObjs)
 					{
 						if(obj->ID != Obj::TOWN) //towns were handled in the previous loop
 							if(const IShipyard *shipyard = IShipyard::castFrom(obj))

+ 3 - 3
AI/VCAI/VCAI.h

@@ -322,7 +322,7 @@ public:
 	virtual void stackChagedCount(const StackLocation &location, const TQuantity &change, bool isAbsolute) override;
 	virtual void heroInGarrisonChange(const CGTownInstance *town) override;
 	virtual void centerView(int3 pos, int focusTime) override;
-	virtual void tileHidden(const boost::unordered_set<int3, ShashInt3> &pos) override;
+	virtual void tileHidden(const std::unordered_set<int3, ShashInt3> &pos) override;
 	virtual void artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) override;
 	virtual void artifactAssembled(const ArtifactLocation &al) override;
 	virtual void showTavernWindow(const CGObjectInstance *townOrTavern) override;
@@ -338,7 +338,7 @@ public:
 	virtual void heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start) override;
 	virtual void availableArtifactsChanged(const CGBlackMarket *bm = nullptr) override;
 	virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town) override;
-	virtual void tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos) override;
+	virtual void tileRevealed(const std::unordered_set<int3, ShashInt3> &pos) override;
 	virtual void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override;
 	virtual void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override;
 	virtual void showRecruitmentDialog(const CGDwelling *dwelling, const CArmedInstance *dst, int level) override;
@@ -488,4 +488,4 @@ bool isWeeklyRevisitable (const CGObjectInstance * obj);
 bool shouldVisit (HeroPtr h, const CGObjectInstance * obj);
 
 void makePossibleUpgrades(const CArmedInstance *obj);
-bool boundaryBetweenTwoPoints (int3 pos1, int3 pos2);
+bool boundaryBetweenTwoPoints (int3 pos1, int3 pos2);

+ 2 - 2
CMakeLists.txt

@@ -14,7 +14,7 @@ set(VCMI_VERSION_MAJOR 0)
 set(VCMI_VERSION_MINOR 93)
 set(VCMI_VERSION_PATCH 0)
 
-option(DISABLE_ERM "Disable compilation of ERM scripting module" ON)
+option(ENABLE_ERM "Enable compilation of ERM scripting module" OFF)
 option(ENABLE_EDITOR "Enable compilation of map editor" OFF)
 option(ENABLE_TEST "Enable compilation of unit tests" OFF)
 
@@ -124,7 +124,7 @@ add_subdirectory(lib)
 add_subdirectory(client)
 add_subdirectory(server)
 add_subdirectory(AI)
-if (NOT DISABLE_ERM)
+if (ENABLE_ERM)
 	add_subdirectory(scripting/erm)
 endif()
 if (ENABLE_EDITOR)

+ 36 - 30
Global.h

@@ -1,3 +1,4 @@
+#pragma once
 
 /*
  * Global.h, part of VCMI engine
@@ -9,8 +10,6 @@
  *
  */
 
-#pragma once
-
 /* ---------------------------------------------------------------------------- */
 /* Compiler detection */
 /* ---------------------------------------------------------------------------- */
@@ -18,15 +17,19 @@
 static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 
 #if defined _M_X64 && defined _WIN32 //Win64 -> cannot load 32-bit DLLs for video handling
-    #define DISABLE_VIDEO
+#  define DISABLE_VIDEO
 #endif
 
 #ifdef __GNUC__
-#define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__)
+#  define GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__ * 10 + __GNUC_PATCHLEVEL__)
+#endif
+
+#if !defined(__clang__) && defined(__GNUC__) && (GCC_VERSION < 460)
+#  error VCMI requires at least gcc-4.6 for successfull compilation or clang-3.1. Please update your compiler
 #endif
 
 #if defined(__GNUC__) && (GCC_VERSION == 470 || GCC_VERSION == 471)
-#error This GCC version has buggy std::array::at version and should not be used. Please update to 4.7.2 or use 4.6.x.
+#  error This GCC version has buggy std::array::at version and should not be used. Please update to 4.7.2 or use 4.6.x.
 #endif
 
 /* ---------------------------------------------------------------------------- */
@@ -34,26 +37,21 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 /* ---------------------------------------------------------------------------- */
 //defining available c++11 features
 
-//initialization lists - only gcc-4.4 or later
+//initialization lists - gcc or clang
 #if defined(__clang__) || defined(__GNUC__)
-#define CPP11_USE_INITIALIZERS_LIST
+#  define CPP11_USE_INITIALIZERS_LIST
 #endif
 
-//nullptr -  only msvc and gcc-4.6 or later, othervice define it  as nullptr
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && (GCC_VERSION >= 460)) && !(defined(__clang__))
-#define nullptr NULL
-#endif
-
-//override keyword - only msvc and gcc-4.7 or later.
+//override keyword - not present in gcc-4.6
 #if !defined(_MSC_VER) && !defined(__clang__) && !(defined(__GNUC__) && (GCC_VERSION >= 470))
-#define override
+#  define override
 #endif
 
 /* ---------------------------------------------------------------------------- */
 /* Suppress some compiler warnings */
 /* ---------------------------------------------------------------------------- */
 #ifdef _MSC_VER
-#pragma warning (disable : 4800 ) /* disable conversion to bool warning -- I think it's intended in all places */
+#  pragma warning (disable : 4800 ) /* disable conversion to bool warning -- I think it's intended in all places */
 #endif
 
 /* ---------------------------------------------------------------------------- */
@@ -81,6 +79,8 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <set>
 #include <sstream>
 #include <string>
+#include <unordered_set>
+#include <unordered_map>
 #include <utility>
 #include <vector>
 
@@ -93,7 +93,6 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #endif
 #define BOOST_THREAD_DONT_PROVIDE_THREAD_DESTRUCTOR_CALLS_TERMINATE_IF_JOINABLE 1
 #define BOOST_BIND_NO_PLACEHOLDERS
-//#define BOOST_SYSTEM_NO_DEPRECATED 1
 
 #include <boost/algorithm/string.hpp>
 #include <boost/assign.hpp>
@@ -102,17 +101,15 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <boost/date_time/posix_time/posix_time.hpp>
 #include <boost/date_time/posix_time/posix_time_io.hpp>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 #include <boost/format.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/logic/tribool.hpp>
 #include <boost/optional.hpp>
 #include <boost/program_options.hpp>
 #include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/adaptor/reversed.hpp>
 #include <boost/range/algorithm.hpp>
 #include <boost/thread.hpp>
-#include <boost/unordered_map.hpp>
-#include <boost/unordered_set.hpp>
 #include <boost/variant.hpp>
 
 #ifdef ANDROID
@@ -268,18 +265,27 @@ public:
 
 namespace vstd
 {
+	
+	// combine hashes. Present in boost but not in std
+	template <class T>
+	inline void hash_combine(std::size_t& seed, const T& v)
+	{
+		std::hash<T> hasher;
+		seed ^= hasher(v) + 0x9e3779b9 + (seed<<6) + (seed>>2);
+	}
+	
 	//returns true if container c contains item i
 	template <typename Container, typename Item>
 	bool contains(const Container & c, const Item &i)
 	{
-		return std::find(boost::begin(c), boost::end(c),i) != boost::end(c);
+		return std::find(std::begin(c), std::end(c),i) != std::end(c);
 	}
 
 	//returns true if container c contains item i
 	template <typename Container, typename Pred>
 	bool contains_if(const Container & c, Pred p)
 	{
-		return std::find_if(boost::begin(c), boost::end(c), p) != boost::end(c);
+		return std::find_if(std::begin(c), std::end(c), p) != std::end(c);
 	}
 
 	//returns true if map c contains item i
@@ -298,13 +304,13 @@ namespace vstd
 
 	//returns true if unordered set c contains item i
 	template <typename Item>
-	bool contains(const boost::unordered_set<Item> & c, const Item &i)
+	bool contains(const std::unordered_set<Item> & c, const Item &i)
 	{
 		return c.find(i)!=c.end();
 	}
 
 	template <typename V, typename Item, typename Item2>
-	bool contains(const boost::unordered_map<Item,V> & c, const Item2 &i)
+	bool contains(const std::unordered_map<Item,V> & c, const Item2 &i)
 	{
 		return c.find(i)!=c.end();
 	}
@@ -314,7 +320,7 @@ namespace vstd
 	int find_pos(const Container & c, const T2 &s)
 	{
 		size_t i=0;
-		for (auto iter = boost::begin(c); iter != boost::end(c); iter++, i++)
+		for (auto iter = std::begin(c); iter != std::end(c); iter++, i++)
 			if(*iter == s)
 				return i;
 		return -1;
@@ -466,7 +472,7 @@ namespace vstd
 	{
 		assert(r.size());
 		index %= r.size();
-		auto itr = boost::begin(r);
+		auto itr = std::begin(r);
 		std::advance(itr, index);
 		return *itr;
 	}
@@ -507,7 +513,7 @@ namespace vstd
 	template<typename InputRange, typename OutputIterator, typename Predicate>
 	OutputIterator copy_if(const InputRange &input, OutputIterator result, Predicate pred)
 	{
-		return std::copy_if(boost::const_begin(input), boost::end(input), result, pred);
+		return std::copy_if(boost::const_begin(input), std::end(input), result, pred);
 	}
 
 	template <typename Container>
@@ -518,9 +524,9 @@ namespace vstd
 
 	//Returns iterator to the element for which the value of ValueFunction is minimal
 	template<class ForwardRange, class ValueFunction>
-	auto minElementByFun(const ForwardRange& rng, ValueFunction vf) -> decltype(boost::begin(rng))
+	auto minElementByFun(const ForwardRange& rng, ValueFunction vf) -> decltype(std::begin(rng))
 	{
-		typedef decltype(*boost::begin(rng)) ElemType;
+		typedef decltype(*std::begin(rng)) ElemType;
 		return boost::min_element(rng, [&] (ElemType lhs, ElemType rhs) -> bool
 		{
 			return vf(lhs) < vf(rhs);
@@ -529,9 +535,9 @@ namespace vstd
 		
 	//Returns iterator to the element for which the value of ValueFunction is maximal
 	template<class ForwardRange, class ValueFunction>
-	auto maxElementByFun(const ForwardRange& rng, ValueFunction vf) -> decltype(boost::begin(rng))
+	auto maxElementByFun(const ForwardRange& rng, ValueFunction vf) -> decltype(std::begin(rng))
 	{
-		typedef decltype(*boost::begin(rng)) ElemType;
+		typedef decltype(*std::begin(rng)) ElemType;
 		return boost::max_element(rng, [&] (ElemType lhs, ElemType rhs) -> bool
 		{
 			return vf(lhs) < vf(rhs);

+ 12 - 12
client/AdventureMapClasses.cpp

@@ -248,9 +248,9 @@ void CHeroList::select(const CGHeroInstance * hero)
 void CHeroList::update(const CGHeroInstance * hero)
 {
 	//this hero is already present, update its status
-	for (auto iter = list->getItems().begin(); iter != list->getItems().end(); iter++)
+	for (auto & elem : list->getItems())
 	{
-		auto item = dynamic_cast<CHeroItem*>(*iter);
+		auto item = dynamic_cast<CHeroItem*>(elem);
 		if (item && item->hero == hero && vstd::contains(LOCPLINT->wanderingHeroes, hero))
 		{
 			item->update();
@@ -355,7 +355,7 @@ const SDL_Color & CMinimapInstance::getTileColor(const int3 & pos)
 		return fogOfWar;
 
 	// if object at tile is owned - it will be colored as its owner
-	BOOST_FOREACH(const CGObjectInstance *obj, tile->blockingObjects)
+	for(const CGObjectInstance *obj : tile->blockingObjects)
 	{
 		//heroes will be blitted later
 		if (obj->ID == Obj::HERO)
@@ -463,7 +463,7 @@ void CMinimapInstance::showAll(SDL_Surface *to)
 
 	//draw heroes
 	std::vector <const CGHeroInstance *> heroes = LOCPLINT->cb->getHeroesInfo(false);
-	BOOST_FOREACH(auto & hero, heroes)
+	for(auto & hero : heroes)
 	{
 		int3 position = hero->getPosition(false);
 		if (position.z == level)
@@ -480,15 +480,15 @@ std::map<int, std::pair<SDL_Color, SDL_Color> > CMinimap::loadColors(std::string
 
 	const JsonNode config(ResourceID(from, EResType::TEXT));
 
-	BOOST_FOREACH(auto &m, config.Struct())
+	for(auto &m : config.Struct())
 	{
 		auto index = boost::find(GameConstants::TERRAIN_NAMES, m.first);
-		if (index == boost::end(GameConstants::TERRAIN_NAMES))
+		if (index == std::end(GameConstants::TERRAIN_NAMES))
 		{
             logGlobal->errorStream() << "Error: unknown terrain in terrains.json: " << m.first;
 			continue;
 		}
-		int terrainID = index - boost::begin(GameConstants::TERRAIN_NAMES);
+		int terrainID = index - std::begin(GameConstants::TERRAIN_NAMES);
 
 		const JsonVector &unblockedVec = m.second["minimapUnblocked"].Vector();
 		SDL_Color normal =
@@ -651,7 +651,7 @@ CInfoBar::CVisibleInfo::CVisibleInfo(Point position):
 void CInfoBar::CVisibleInfo::show(SDL_Surface *to)
 {
 	CIntObject::show(to);
-	BOOST_FOREACH(auto object, forceRefresh)
+	for(auto object : forceRefresh)
 		object->showAll(to);
 }
 
@@ -750,7 +750,7 @@ void CInfoBar::CVisibleInfo::loadGameStatus()
 
 	//get amount of halls of each level
 	std::vector<int> halls(4, 0);
-	BOOST_FOREACH(auto town, LOCPLINT->towns)
+	for(auto town : LOCPLINT->towns)
 		halls[town->hallLevel()]++;
 
 	std::vector<PlayerColor> allies, enemies;
@@ -774,14 +774,14 @@ void CInfoBar::CVisibleInfo::loadGameStatus()
 	auto enemyLabel = new CLabel(10, 136, FONT_SMALL, TOPLEFT, Colors::WHITE, CGI->generaltexth->allTexts[391] + ":");
 
 	int posx = allyLabel->pos.w + allyLabel->pos.x - pos.x + 4;
-	BOOST_FOREACH(PlayerColor & player, allies)
+	for(PlayerColor & player : allies)
 	{
 		auto image = new CAnimImage("ITGFLAGS", player.getNum(), 0, posx, 102);
 		posx += image->pos.w;
 	}
 
 	posx = enemyLabel->pos.w + enemyLabel->pos.x - pos.x + 4;
-	BOOST_FOREACH(PlayerColor & player, enemies)
+	for(PlayerColor & player : enemies)
 	{
 		auto image = new CAnimImage("ITGFLAGS", player.getNum(), 0, posx, 132);
 		posx += image->pos.w;
@@ -803,7 +803,7 @@ void CInfoBar::CVisibleInfo::loadComponent(const Component & compToDisplay, std:
 
 	new CPicture("ADSTATOT", 1);
 
-	auto comp = new CComponent(compToDisplay);
+	auto   comp = new CComponent(compToDisplay);
 	comp->moveTo(Point(pos.x+47, pos.y+50));
 
 	new CTextBox(message, Rect(10, 4, 160, 50), 0, FONT_SMALL, CENTER, Colors::WHITE);

+ 2 - 2
client/CAdvmapInterface.cpp

@@ -494,7 +494,7 @@ void CAdvMapInt::fshowSpellbok()
 
 	centerOn(selection);
 
-	CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), curHero(), LOCPLINT, false);
+	auto   spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), curHero(), LOCPLINT, false);
 	GH.pushInt(spellWindow);
 }
 
@@ -883,7 +883,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
 			{
 				//check if we have any marketplace
 				const CGTownInstance *townWithMarket = nullptr;
-				BOOST_FOREACH(const CGTownInstance *t, LOCPLINT->cb->getTownsInfo())
+				for(const CGTownInstance *t : LOCPLINT->cb->getTownsInfo())
 				{
 					if(t->hasBuilt(BuildingID::MARKETPLACE))
 					{

+ 28 - 28
client/CAnimation.cpp

@@ -79,7 +79,7 @@ class CFileCache
 
 		ui8 * getCopy()
 		{
-			ui8 * ret = new ui8[size];
+			auto   ret = new ui8[size];
 			std::copy(data, data + size, ret);
 			return ret;
 		}
@@ -97,7 +97,7 @@ class CFileCache
 public:
 	ui8 * getCachedFile(ResourceID && rid)
 	{
-		BOOST_FOREACH(auto & file, cache)
+		for(auto & file : cache)
 		{
 			if (file.name == rid)
 				return file.getCopy();
@@ -329,8 +329,8 @@ const std::map<size_t, size_t > CDefFile::getEntries() const
 {
 	std::map<size_t, size_t > ret;
 
-	for (auto mapIt = offset.begin(); mapIt!=offset.end(); ++mapIt)
-		ret[mapIt->first] =  mapIt->second.size();
+	for (auto & elem : offset)
+		ret[elem.first] =  elem.second.size();
 	return ret;
 }
 
@@ -523,7 +523,7 @@ inline void CompImageLoader::Load(size_t size, ui8 color)
 		return;
 	if (color==0xff)
 	{
-		ui8* tmpbuf = new ui8[size];
+		auto   tmpbuf = new ui8[size];
 		memset((void*)tmpbuf, color, size);
 		Load(size, tmpbuf);
 		delete [] tmpbuf;
@@ -990,12 +990,12 @@ void CAnimation::initFromJson(const JsonNode & config)
 	std::string basepath;
 	basepath = config["basepath"].String();
 
-	BOOST_FOREACH(const JsonNode &group, config["sequences"].Vector())
+	for(const JsonNode &group : config["sequences"].Vector())
 	{
 		size_t groupID = group["group"].Float();//TODO: string-to-value conversion("moving" -> MOVING)
 		source[groupID].clear();
 
-		BOOST_FOREACH(const JsonNode &frame, group["frames"].Vector())
+		for(const JsonNode &frame : group["frames"].Vector())
 		{
 			source[groupID].push_back(JsonNode());
 			std::string filename =  frame.String();
@@ -1003,7 +1003,7 @@ void CAnimation::initFromJson(const JsonNode & config)
 		}
 	}
 
-	BOOST_FOREACH(const JsonNode &node, config["images"].Vector())
+	for(const JsonNode &node : config["images"].Vector())
 	{
 		size_t group = node["group"].Float();
 		size_t frame = node["frame"].Float();
@@ -1023,8 +1023,8 @@ void CAnimation::init(CDefFile * file)
 	{
 		const std::map<size_t, size_t> defEntries = file->getEntries();
 
-		for (std::map<size_t, size_t>::const_iterator mapIt = defEntries.begin(); mapIt!=defEntries.end(); ++mapIt)
-			source[mapIt->first].resize(mapIt->second);
+		for (auto & defEntrie : defEntries)
+			source[defEntrie.first].resize(defEntrie.second);
 	}
 
 	ResourceID resID(std::string("SPRITES/") + name, EResType::TEXT);
@@ -1034,7 +1034,7 @@ void CAnimation::init(CDefFile * file)
 
 	auto & configList = CResourceHandler::get()->getResourcesWithName(resID);
 
-	BOOST_FOREACH(auto & entry, configList)
+	for(auto & entry : configList)
 	{
 		auto stream = entry.getLoader()->load(entry.getResourceName());
 		std::unique_ptr<ui8[]> textData(new ui8[stream->getSize()]);
@@ -1088,9 +1088,9 @@ CAnimation::~CAnimation()
 	if (!images.empty())
 	{
         logGlobal->warnStream()<<"Warning: not all frames were unloaded from "<<name;
-		for (group_map::iterator group = images.begin(); group != images.end(); ++group )
-			for (image_map::iterator image = group->second.begin(); image != group->second.end(); ++image )
-				delete image->second;
+		for (auto & elem : images)
+			for (auto & _image : elem.second)
+				delete _image.second;
 	}
 	loadedAnims.erase(this);
 }
@@ -1105,10 +1105,10 @@ void CAnimation::setCustom(std::string filename, size_t frame, size_t group)
 
 IImage * CAnimation::getImage(size_t frame, size_t group, bool verbose) const
 {
-	group_map::const_iterator groupIter = images.find(group);
+	auto groupIter = images.find(group);
 	if (groupIter != images.end())
 	{
-		image_map::const_iterator imageIter = groupIter->second.find(frame);
+		auto imageIter = groupIter->second.find(frame);
 		if (imageIter != groupIter->second.end())
 			return imageIter->second;
 	}
@@ -1121,18 +1121,18 @@ void CAnimation::load()
 {
 	CDefFile * file = getFile();
 
-	for (source_map::iterator group = source.begin(); group != source.end(); ++group )
-		for (size_t image=0; image < group->second.size(); image++)
-			loadFrame(file, image, group->first);
+	for (auto & elem : source)
+		for (size_t image=0; image < elem.second.size(); image++)
+			loadFrame(file, image, elem.first);
 
 	delete file;
 }
 
 void CAnimation::unload()
 {
-	for (source_map::iterator group = source.begin(); group != source.end(); ++group )
-		for (size_t image=0; image < group->second.size(); image++)
-			unloadFrame(image, group->first);
+	for (auto & elem : source)
+		for (size_t image=0; image < elem.second.size(); image++)
+			unloadFrame(image, elem.first);
 
 }
 
@@ -1168,7 +1168,7 @@ void CAnimation::unload(size_t frame, size_t group)
 
 size_t CAnimation::size(size_t group) const
 {
-	source_map::const_iterator iter = source.find(group);
+	auto iter = source.find(group);
 	if (iter != source.end())
 		return iter->second.size();
 	return 0;
@@ -1179,9 +1179,9 @@ std::set<CAnimation*> CAnimation::loadedAnims;
 void CAnimation::getAnimInfo()
 {
     logGlobal->errorStream()<<"Animation stats: Loaded "<<loadedAnims.size()<<" total";
-	for (std::set<CAnimation*>::iterator it = loadedAnims.begin(); it != loadedAnims.end(); it++)
+	for (auto anim : loadedAnims)
 	{
-		CAnimation * anim = *it;
+		
         logGlobal->errorStream()<<"Name: "<<anim->name<<" Groups: "<<anim->images.size();
 		if (!anim->images.empty())
             logGlobal->errorStream()<<", "<<anim->images.begin()->second.size()<<" image loaded in group "<< anim->images.begin()->first;
@@ -1427,9 +1427,9 @@ void CCreatureAnim::loopPreview(bool warMachine)
 	static const EAnimType machPreviewList[] = {HOLDING, MOVING, SHOOT_UP, SHOOT_FRONT, SHOOT_DOWN};
 	auto & previewList = warMachine ? machPreviewList : creaPreviewList;
 	
-	for (size_t i=0; i<ARRAY_COUNT(previewList); i++)
-		if (anim.size(previewList[i]))
-			available.push_back(previewList[i]);
+	for (auto & elem : previewList)
+		if (anim.size(elem))
+			available.push_back(elem);
 
 	size_t rnd = rand()%(available.size()*2);
 

+ 21 - 21
client/CCastleInterface.cpp

@@ -420,8 +420,8 @@ void CHeroGSlot::setHighlight( bool on )
 
 	if(owner->garrisonedHero->hero && owner->visitingHero->hero) //two heroes in town
 	{
-		for(size_t i = 0; i<owner->garr->splitButtons.size(); i++) //splitting enabled when slot higlighted
-			owner->garr->splitButtons[i]->block(!on);
+		for(auto & elem : owner->garr->splitButtons) //splitting enabled when slot higlighted
+			elem->block(!on);
 	}
 }
 
@@ -472,7 +472,7 @@ void CCastleBuildings::recreate()
 	selectedBuilding = nullptr;
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	//clear existing buildings
-	BOOST_FOREACH(auto build, buildings)
+	for(auto build : buildings)
 		delete build;
 	buildings.clear();
 	groups.clear();
@@ -491,7 +491,7 @@ void CCastleBuildings::recreate()
 		}
 	}
 
-	BOOST_FOREACH(const CStructure * structure, town->town->clientInfo.structures)
+	for(const CStructure * structure : town->town->clientInfo.structures)
 	{
 		if (!structure->building)
 		{
@@ -504,7 +504,7 @@ void CCastleBuildings::recreate()
 		}
 	}
 
-	BOOST_FOREACH(auto & entry, groups)
+	for(auto & entry : groups)
 	{
 		const CBuilding * build = town->town->buildings[entry.first];
 
@@ -535,7 +535,7 @@ void CCastleBuildings::addBuilding(BuildingID building)
 
 	auto & structures = groups[base];
 
-	BOOST_FOREACH(CBuildingRect * rect, buildings)
+	for(CBuildingRect * rect : buildings)
 	{
 		if (vstd::contains(structures, rect->str))
 		{
@@ -558,14 +558,14 @@ void CCastleBuildings::removeBuilding(BuildingID building)
 void CCastleBuildings::show(SDL_Surface * to)
 {
 	CIntObject::show(to);
-	BOOST_FOREACH(CBuildingRect * str, buildings)
+	for(CBuildingRect * str : buildings)
 		str->show(to);
 }
 
 void CCastleBuildings::showAll(SDL_Surface * to)
 {
 	CIntObject::showAll(to);
-	BOOST_FOREACH(CBuildingRect * str, buildings)
+	for(CBuildingRect * str : buildings)
 		str->showAll(to);
 }
 
@@ -750,16 +750,16 @@ void CCastleBuildings::enterCastleGate()
 	}
 	std::vector <int> availableTowns;
 	std::vector <const CGTownInstance*> Towns = LOCPLINT->cb->getTownsInfo(false);
-	for(size_t i=0;i<Towns.size();i++)
+	for(auto & Town : Towns)
 	{
-		const CGTownInstance *t = Towns[i];
+		const CGTownInstance *t = Town;
 		if (t->id != this->town->id && t->visitingHero == nullptr && //another town, empty and this is
 			t->hasBuilt(BuildingID::CASTLE_GATE, ETownType::INFERNO))
 		{
 			availableTowns.push_back(t->id.getNum());//add to the list
 		}
 	}
-	CPicture *titlePic = new CPicture (LOCPLINT->castleInt->bicons->ourImages[BuildingID::CASTLE_GATE].bitmap, 0,0, false);//will be deleted by selection window
+	auto  titlePic = new CPicture (LOCPLINT->castleInt->bicons->ourImages[BuildingID::CASTLE_GATE].bitmap, 0,0, false);//will be deleted by selection window
 	GH.pushInt (new CObjectListWindow(availableTowns, titlePic, CGI->generaltexth->jktexts[40],
 	    CGI->generaltexth->jktexts[41], std::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1)));
 }
@@ -965,8 +965,8 @@ void CCastleInterface::recreateIcons()
 	hall = new CTownInfo( 80, 413, town, true);
 	fort = new CTownInfo(122, 413, town, false);
 
-	for (size_t i=0; i<creainfo.size(); i++)
-		delete creainfo[i];
+	for (auto & elem : creainfo)
+		delete elem;
 	creainfo.clear();
 
 	for (size_t i=0; i<4; i++)
@@ -1071,7 +1071,7 @@ std::string CCreaInfo::genGrowthText()
 	GrowthInfo gi = town->getGrowthInfo(level);
 	std::string descr = boost::str(boost::format(CGI->generaltexth->allTexts[589]) % creature->nameSing % gi.totalGrowth());
 
-	BOOST_FOREACH(const GrowthInfo::Entry &entry, gi.entries)
+	for(const GrowthInfo::Entry &entry : gi.entries)
 	{
 		descr +="\n" + entry.description;
 	}
@@ -1151,7 +1151,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
 			delete builds;
 			builds = new CCastleBuildings(town);
 
-			BOOST_FOREACH(const CStructure * str, town->town->clientInfo.structures)
+			for(const CStructure * str : town->town->clientInfo.structures)
 			{
 				if (str->building)
                     logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
@@ -1167,7 +1167,7 @@ void CCastleInterface::keyPressed( const SDL_KeyboardEvent & key )
 			delete builds;
 			builds = new CCastleBuildings(town);
 
-			BOOST_FOREACH(const CStructure * str, town->town->clientInfo.structures)
+			for(const CStructure * str : town->town->clientInfo.structures)
 			{
 				if (str->building)
                     logGlobal->errorStream() << int(str->building->bid) << " -> " << int(str->pos.z);
@@ -1308,9 +1308,9 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
 		for(size_t col=0; col<boxList[row].size(); col++) //for each box
 		{
 			const CBuilding *building = nullptr;
-			for(size_t item=0; item<boxList[row][col].size(); item++)//we are looking for the first not build structure
+			for(auto & elem : boxList[row][col])//we are looking for the first not build structure
 			{
-				auto buildingID = boxList[row][col][item];
+				auto buildingID = elem;
 				building = town->town->buildings[buildingID];
 
 				if(!vstd::contains(town->builtBuildings,buildingID))
@@ -1348,7 +1348,7 @@ std::string CBuildWindow::getTextForState(int state)
 			ret = CGI->generaltexth->allTexts[52];
 			std::set<BuildingID> reqs= LOCPLINT->cb->getBuildingRequiments(town, building->bid);
 
-			BOOST_FOREACH(const auto & i, reqs)
+			for(const auto & i : reqs)
 			{
 				if (vstd::contains(town->builtBuildings, i))
 					continue;//skipping constructed buildings
@@ -1466,8 +1466,8 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
 
 void CFortScreen::creaturesChanged()
 {
-	for (size_t i=0; i<recAreas.size(); i++)
-		recAreas[i]->creaturesChanged();
+	for (auto & elem : recAreas)
+		elem->creaturesChanged();
 }
 
 LabeledValue::LabeledValue(Rect size, std::string name, std::string descr, int min, int max)

+ 15 - 15
client/CCreatureWindow.cpp

@@ -51,7 +51,7 @@ CCreatureWindow::CCreatureWindow (const CStack &stack, CreWinType Type):
 		init(stack.base, &stack, dynamic_cast<const CGHeroInstance*>(stack.base->armyObj));
 	else
 	{
-		CStackInstance * s = new CStackInstance(stack.type, 1); //TODO: war machines and summons should be regular stacks
+		auto   s = new CStackInstance(stack.type, 1); //TODO: war machines and summons should be regular stacks
 		init(s, &stack, nullptr);
 		delete s;
 	}
@@ -72,7 +72,7 @@ CCreatureWindow::CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCo
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
-	CStackInstance * stack = new CStackInstance(Cid, creatureCount); //TODO: simplify?
+	auto   stack = new CStackInstance(Cid, creatureCount); //TODO: simplify?
 	init(stack, CGI->creh->creatures[Cid], nullptr);
 	delete stack;
 }
@@ -80,9 +80,9 @@ CCreatureWindow::CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCo
 CCreatureWindow::CCreatureWindow(const CStackInstance &st, CreWinType Type, std::function<void()> Upg, std::function<void()> Dsm, UpgradeInfo *ui):
     CWindowObject(PLAYER_COLORED | (Type == OTHER ? RCLICK_POPUP : 0 ) ),
     type(Type),
-    dismiss(0),
-    upgrade(0),
-    ok(0),
+    dismiss(nullptr),
+    upgrade(nullptr),
+    ok(nullptr),
     dsm(Dsm)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
@@ -225,10 +225,10 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 
 		if (type == COMMANDER_LEVEL_UP)
 		{
-			BOOST_FOREACH (auto option, upgradeOptions)
+			for (auto option : upgradeOptions)
 			{
 				ui32 index = selectableSkills.size();
-				CSelectableSkill * selectableSkill = new CSelectableSkill();
+				auto   selectableSkill = new CSelectableSkill();
 				selectableSkill->callback = std::bind(&CCreatureWindow::selectSkill, this, index);
 
 				if (option < 100)
@@ -260,7 +260,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 	}
 
 	std::string text;
-	BOOST_FOREACH(Bonus* b, bl)
+	for(Bonus* b : bl)
 	{
 		text = stack->bonusToString(b, false);
 		if (text.size()) //if it's possible to give any description for this kind of bonus
@@ -415,7 +415,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 		//spell effects
 		int printed=0; //how many effect pics have been printed
 		std::vector<si32> spells = battleStack->activeSpells();
-		BOOST_FOREACH(si32 effect, spells)
+		for(si32 effect : spells)
 		{
 			std::string spellText;
 			if (effect < graphics->spellEffectsPics->ourImages.size()) //not all effects have graphics (for eg. Acid Breath)
@@ -541,10 +541,10 @@ void CCreatureWindow::showAll(SDL_Surface * to)
 	printLine(4, CGI->generaltexth->allTexts[388], c->valOfBonuses(Bonus::STACK_HEALTH), stackNode->valOfBonuses(Bonus::STACK_HEALTH));
 	printLine(6, CGI->generaltexth->zelp[441].first, c->valOfBonuses(Bonus::STACKS_SPEED), stackNode->valOfBonuses(Bonus::STACKS_SPEED));
 
-	BOOST_FOREACH(CBonusItem* b, bonusItems)
+	for(CBonusItem* b : bonusItems)
 		b->showAll (to);
 
-	BOOST_FOREACH(auto s, selectableSkills)
+	for(auto s : selectableSkills)
 		s->showAll (to);
 
 	for (int i = 0; i < skillPictures.size(); i++)
@@ -660,7 +660,7 @@ void CCreatureWindow::passArtifactToHero()
 void CCreatureWindow::artifactRemoved (const ArtifactLocation &artLoc)
 {
 	//align artifacts to remove holes
-	BOOST_FOREACH (auto al, stack->artifactsWorn)
+	for (auto al : stack->artifactsWorn)
 	{
 		ArtifactPosition freeSlot = al.second.artifact->firstAvailableSlot(stack); 
 		if (freeSlot < al.first)
@@ -684,8 +684,8 @@ void CCreatureWindow::selectSkill (ui32 which)
 
 CCreatureWindow::~CCreatureWindow()
 {
- 	for (int i=0; i<upgResCost.size(); ++i)
- 		delete upgResCost[i];
+ 	for (auto & elem : upgResCost)
+ 		delete elem;
 	bonusItems.clear();
 }
 
@@ -804,7 +804,7 @@ CCreInfoWindow::CCreInfoWindow(const CStack &stack, bool LClicked):
 
 CCreInfoWindow::~CCreInfoWindow()
 {
-	BOOST_FOREACH(CComponent* object, upgResCost)
+	for(CComponent* object : upgResCost)
 		delete object;
 }
 

+ 10 - 10
client/CDefHandler.cpp

@@ -35,19 +35,19 @@ CDefHandler::~CDefHandler()
 {
 	if (notFreeImgs)
 		return;
-	for (size_t i=0; i<ourImages.size(); ++i)
+	for (auto & elem : ourImages)
 	{
-		if (ourImages[i].bitmap)
+		if (elem.bitmap)
 		{
-			SDL_FreeSurface(ourImages[i].bitmap);
-			ourImages[i].bitmap=nullptr;
+			SDL_FreeSurface(elem.bitmap);
+			elem.bitmap=nullptr;
 		}
 	}
 }
 CDefEssential::~CDefEssential()
 {
-	for(size_t i=0; i < ourImages.size(); ++i)
-		SDL_FreeSurface(ourImages[i].bitmap);
+	for(auto & elem : ourImages)
+		SDL_FreeSurface(elem.bitmap);
 }
 
 void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
@@ -107,9 +107,9 @@ void CDefHandler::openFromMemory(ui8 *table, const std::string & name)
 		}
 	}
 
-	for(ui32 j=0; j<SEntries.size(); ++j)
+	for(auto & elem : SEntries)
 	{
-		SEntries[j].name = SEntries[j].name.substr(0, SEntries[j].name.find('.')+4);
+		elem.name = elem.name.substr(0, elem.name.find('.')+4);
 	}
 	//RWEntries = new ui32[height];
 	for(ui32 i=0; i < SEntries.size(); ++i)
@@ -354,7 +354,7 @@ SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPal
 
 CDefEssential * CDefHandler::essentialize()
 {
-	CDefEssential * ret = new CDefEssential;
+	auto   ret = new CDefEssential;
 	ret->ourImages = ourImages;
 	notFreeImgs = true;
 	return ret;
@@ -366,7 +366,7 @@ CDefHandler * CDefHandler::giveDef(const std::string & defName)
 	                 ResourceID(std::string("SPRITES/") + defName, EResType::ANIMATION)).first.release();
 	if(!data)
 		throw std::runtime_error("bad def name!");
-	CDefHandler * nh = new CDefHandler();
+	auto   nh = new CDefHandler();
 	nh->openFromMemory(data, defName);
 	delete [] data;
 	return nh;

+ 5 - 5
client/CHeroWindow.cpp

@@ -55,9 +55,9 @@ const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector
 	else
 		bonusesFromPickedUpArtifact = TBonusListPtr(new BonusList);
 
-	BOOST_FOREACH(Bonus *b, *bonusesFromPickedUpArtifact)
+	for(Bonus *b : *bonusesFromPickedUpArtifact)
 		*heroBonuses -= b;
-	BOOST_FOREACH(Bonus *b, *heroBonuses)
+	for(Bonus *b : *heroBonuses)
 		out->push_back(b);
 	return out;
 }
@@ -130,7 +130,7 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero):
 
 	for(int v=0; v<GameConstants::PRIMARY_SKILLS; ++v)
 	{
-		LRClickableAreaWTextComp *area = new LRClickableAreaWTextComp(Rect(30 + 70*v, 109, 42, 64), CComponent::primskill);
+		auto  area = new LRClickableAreaWTextComp(Rect(30 + 70*v, 109, 42, 64), CComponent::primskill);
 		area->text = CGI->generaltexth->arraytxt[2+v];
 		area->type = v;
 		area->hoverText = boost::str(boost::format(CGI->generaltexth->heroscrn[1]) % CGI->generaltexth->primarySkillNames[v]);
@@ -214,7 +214,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
 		}
 		if(!artSets.size())
 		{
-			CArtifactsOfHero *arts = new CArtifactsOfHero(Point(-65, -8), true);
+			auto  arts = new CArtifactsOfHero(Point(-65, -8), true);
 			arts->setHero(curHero);
 			artSets.push_back(arts);
 		}
@@ -258,7 +258,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
 
 	//if we have exchange window with this curHero open
 	bool noDismiss=false;
-	BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+	for(IShowActivatable *isa : GH.listInt)
 	{
 		if(CExchangeWindow * cew = dynamic_cast<CExchangeWindow*>(isa))
 			for(int g=0; g < ARRAY_COUNT(cew->heroInst); ++g)

+ 16 - 17
client/CKingdomInterface.cpp

@@ -491,7 +491,7 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
 	idToImage[std::make_pair( 87, 0)] = 87;//Harbor
 
 	std::map<int, OwnedObjectInfo> visibleObjects;
-	BOOST_FOREACH(const CGObjectInstance * object, ownedObjects)
+	for(const CGObjectInstance * object : ownedObjects)
 	{
 		//Dwellings
 		if ( object->ID == Obj::CREATURE_GENERATOR1 )
@@ -504,7 +504,7 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
 			}
 		}
 		//Special objects from idToImage map that should be displayed in objects list
-		std::map<std::pair<int,int>,int>::iterator iter = idToImage.find(std::make_pair(object->ID, object->subID));
+		auto iter = idToImage.find(std::make_pair(object->ID, object->subID));
 		if (iter != idToImage.end())
 		{
 			OwnedObjectInfo &info = visibleObjects[iter->second];
@@ -517,8 +517,7 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
 	}
 	objects.reserve(visibleObjects.size());
 
-	std::pair<int, OwnedObjectInfo> element;
-	BOOST_FOREACH(element, visibleObjects)
+	for(auto & element : visibleObjects)
 	{
 		objects.push_back(element.second);
 	}
@@ -555,7 +554,7 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
 	std::vector<int> minesCount(GameConstants::RESOURCE_QUANTITY, 0);
 	int totalIncome=0;
 
-	BOOST_FOREACH(const CGObjectInstance * object, ownedObjects)
+	for(const CGObjectInstance * object : ownedObjects)
 	{
 		//Mines
 		if ( object->ID == Obj::MINE )
@@ -571,17 +570,17 @@ void CKingdomInterface::generateMinesList(const std::vector<const CGObjectInstan
 
 	//Heroes can produce gold as well - skill, specialty or arts
 	std::vector<const CGHeroInstance*> heroes = LOCPLINT->cb->getHeroesInfo(true);
-	for(size_t i=0; i<heroes.size(); i++)
+	for(auto & heroe : heroes)
 	{
-		totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ESTATES));
-		totalIncome += heroes[i]->valOfBonuses(Selector::typeSubtype(Bonus::GENERATE_RESOURCE, Res::GOLD));
+		totalIncome += heroe->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ESTATES));
+		totalIncome += heroe->valOfBonuses(Selector::typeSubtype(Bonus::GENERATE_RESOURCE, Res::GOLD));
 	}
 
 	//Add town income of all towns
 	std::vector<const CGTownInstance*> towns = LOCPLINT->cb->getTownsInfo(true);
-	for(size_t i=0; i<towns.size(); i++)
+	for(auto & town : towns)
 	{
-		totalIncome += towns[i]->dailyIncome();
+		totalIncome += town->dailyIncome();
 	}
 	for (int i=0; i<7; i++)
 	{
@@ -691,7 +690,7 @@ CKingdHeroList::CKingdHeroList(size_t maxSize)
 void CKingdHeroList::updateGarrisons()
 {
 	std::list<CIntObject*> list = heroes->getItems();
-	BOOST_FOREACH(CIntObject* object, list)
+	for(CIntObject* object : list)
 	{
 		if (CGarrisonHolder * garrison = dynamic_cast<CGarrisonHolder*>(object) )
 			garrison->updateGarrisons();
@@ -705,7 +704,7 @@ CIntObject* CKingdHeroList::createHeroItem(size_t index)
 
 	if (index < heroesCount)
 	{
-		CHeroItem * hero = new CHeroItem(LOCPLINT->cb->getHeroBySerial(index, false), &artsCommonPart);
+		auto   hero = new CHeroItem(LOCPLINT->cb->getHeroBySerial(index, false), &artsCommonPart);
 		artsCommonPart.participants.insert(hero->heroArts);
 		artSets.push_back(hero->heroArts);
 		return hero;
@@ -744,7 +743,7 @@ CKingdTownList::CKingdTownList(size_t maxSize)
 void CKingdTownList::townChanged(const CGTownInstance *town)
 {
 	std::list<CIntObject*> list = towns->getItems();
-	BOOST_FOREACH(CIntObject* object, list)
+	for(CIntObject* object : list)
 	{
 		CTownItem * townItem = dynamic_cast<CTownItem*>(object);
 		if ( townItem && townItem->town == town)
@@ -755,7 +754,7 @@ void CKingdTownList::townChanged(const CGTownInstance *town)
 void CKingdTownList::updateGarrisons()
 {
 	std::list<CIntObject*> list = towns->getItems();
-	BOOST_FOREACH(CIntObject* object, list)
+	for(CIntObject* object : list)
 	{
 		if (CGarrisonHolder * garrison = dynamic_cast<CGarrisonHolder*>(object) )
 			garrison->updateGarrisons();
@@ -866,9 +865,9 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
 	artTabs.resize(3);
-	ArtSlotsTab* arts1 = new ArtSlotsTab;
-	ArtSlotsTab* arts2 = new ArtSlotsTab;
-	BackpackTab* backpack = new BackpackTab;
+	auto   arts1 = new ArtSlotsTab;
+	auto   arts2 = new ArtSlotsTab;
+	auto   backpack = new BackpackTab;
 	artTabs[0] = arts1;
 	artTabs[1] = arts2;
 	artTabs[2] = backpack;

+ 8 - 8
client/CMT.cpp

@@ -397,7 +397,7 @@ int main(int argc, char** argv)
 	}
 	else
 	{
-		StartInfo *si = new StartInfo();
+		auto  si = new StartInfo();
 		si->mode = StartInfo::DUEL;
 		si->mapname = vm["battle"].as<std::string>();
 		si->playerInfos[PlayerColor(0)].color = PlayerColor(0);
@@ -445,7 +445,7 @@ void printInfoAboutIntObject(const CIntObject *obj, int level)
     sbuffer << " (" << obj->pos.w <<"x"<< obj->pos.h << ")";
     logGlobal->debugStream() << sbuffer.str();
 
-	BOOST_FOREACH(const CIntObject *child, obj->children)
+	for(const CIntObject *child : obj->children)
 		printInfoAboutIntObject(child, level+1);
 }
 
@@ -585,7 +585,7 @@ void processCommand(const std::string &message)
         std::cout << "\nInherited bonuses:\n";
 		TCNodes parents;
 		adventureInt->selection->getParents(parents);
-		BOOST_FOREACH(const CBonusSystemNode *parent, parents)
+		for(const CBonusSystemNode *parent : parents)
 		{
             std::cout << "\nBonuses from " << typeid(*parent).name() << std::endl << parent->getBonusList() << std::endl;
 		}
@@ -596,7 +596,7 @@ void processCommand(const std::string &message)
 	}
 	else if(cn == "gui")
 	{
-		BOOST_FOREACH(const IShowActivatable *child, GH.listInt)
+		for(const IShowActivatable *child : GH.listInt)
 		{
 			if(const CIntObject *obj = dynamic_cast<const CIntObject *>(child))
 				printInfoAboutIntObject(obj, 0);
@@ -611,7 +611,7 @@ void processCommand(const std::string &message)
 		readed >> what >> id1 >> id2;
 		if(what == "hs")
 		{
-			BOOST_FOREACH(const CGHeroInstance *h, LOCPLINT->cb->getHeroesInfo())
+			for(const CGHeroInstance *h : LOCPLINT->cb->getHeroesInfo())
 				if(h->type->ID.getNum() == id1)
 					if(const CArtifactInstance *a = h->getArt(ArtifactPosition(id2)))
                         std::cout << a->nodeName();
@@ -922,11 +922,11 @@ void startGame(StartInfo * options, CConnection *serv/* = nullptr*/)
 		int i = 0;
 
 
-		for(auto it = options->playerInfos.begin(); it != options->playerInfos.end(); ++it)
+		for(auto & elem : options->playerInfos)
 		{
-			it->second.playerID = PlayerSettings::PLAYER_AI;
+			elem.second.playerID = PlayerSettings::PLAYER_AI;
 			if(i < ais.size())
-				it->second.name = ais[i++];
+				elem.second.name = ais[i++];
 		}
 	}
 

+ 32 - 32
client/CMessage.cpp

@@ -77,17 +77,17 @@ void CMessage::init()
 			CDefHandler * bluePieces = CDefHandler::giveDef("DIALGBOX.DEF");
 			if (i==1)
 			{
-				for (size_t j=0;j<bluePieces->ourImages.size();++j)
+				for (auto & elem : bluePieces->ourImages)
 				{
-					piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap);
-					bluePieces->ourImages[j].bitmap->refcount++;
+					piecesOfBox[i].push_back(elem.bitmap);
+					elem.bitmap->refcount++;
 				}
 			}
-			for (size_t j=0;j<bluePieces->ourImages.size();++j)
+			for (auto & elem : bluePieces->ourImages)
 			{
-				graphics->blueToPlayersAdv(bluePieces->ourImages[j].bitmap, PlayerColor(i));
-				piecesOfBox[i].push_back(bluePieces->ourImages[j].bitmap);
-				bluePieces->ourImages[j].bitmap->refcount++;
+				graphics->blueToPlayersAdv(elem.bitmap, PlayerColor(i));
+				piecesOfBox[i].push_back(elem.bitmap);
+				elem.bitmap->refcount++;
 			}
 			delete bluePieces;
 		}
@@ -102,9 +102,9 @@ void CMessage::dispose()
 {
 	for (int i=0; i<PlayerColor::PLAYER_LIMIT_I; i++)
 	{
-		for (size_t j=0; j<piecesOfBox[i].size(); ++j)
+		for (auto & elem : piecesOfBox[i])
 		{
-			SDL_FreeSurface(piecesOfBox[i][j]);
+			SDL_FreeSurface(elem);
 		}
 	}
 	SDL_FreeSurface(background);
@@ -211,8 +211,8 @@ std::vector<std::string> CMessage::breakText( std::string text, size_t maxLineSi
 
 	/* Trim whitespaces of every line. */
 	//if(!allowLeadingWhitespace)
-		for (size_t i=0; i<ret.size(); i++)
-			boost::algorithm::trim(ret[i]);
+		for (auto & elem : ret)
+			boost::algorithm::trim(elem);
 
 	return ret;
 }
@@ -249,8 +249,8 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, PlayerColor play
 	{
 		// Compute total width of buttons
 		bw = 20*(ret->buttons.size()-1); // space between all buttons
-		for(size_t i=0; i<ret->buttons.size(); i++) //and add buttons width
-			bw+=ret->buttons[i]->pos.w;
+		for(auto & elem : ret->buttons) //and add buttons width
+			bw+=elem->pos.w;
 		winSize.second += 20 + //before button
 		ok->ourImages[0].bitmap->h; //button	
 	}
@@ -292,10 +292,10 @@ void CMessage::drawIWindow(CInfoWindow * ret, std::string text, PlayerColor play
 		bw = (ret->bitmap->w/2) - (bw/2);
 		curh = ret->bitmap->h - SIDE_MARGIN - ret->buttons[0]->pos.h;
 
-		for(size_t i=0; i<ret->buttons.size(); i++)
+		for(auto & elem : ret->buttons)
 		{
-			ret->buttons[i]->moveBy(Point(bw, curh));
-			bw += ret->buttons[i]->pos.w + 20;
+			elem->moveBy(Point(bw, curh));
+			bw += elem->pos.w + 20;
 		}
 	}
 	for(size_t i=0; i<ret->components.size(); i++)
@@ -401,9 +401,9 @@ void ComponentResolved::showAll(SDL_Surface *to)
 
 ComponentsToBlit::~ComponentsToBlit()
 {
-	for(size_t i=0; i<comps.size(); i++)
-		for(size_t j = 0; j < comps[i].size(); j++)
-			delete comps[i][j];
+	for(auto & elem : comps)
+		for(size_t j = 0; j < elem.size(); j++)
+			delete elem[j];
 
 }
 
@@ -419,9 +419,9 @@ ComponentsToBlit::ComponentsToBlit(std::vector<CComponent*> & SComps, int maxw,
 	int curw = 0;
 	int curr = 0; //current row
 
-	for(size_t i=0;i<SComps.size();i++)
+	for(auto & SComp : SComps)
 	{
-		ComponentResolved *cur = new ComponentResolved(SComps[i]);
+		auto  cur = new ComponentResolved(SComp);
 
 		int toadd = (cur->pos.w + BETWEEN_COMPS + (blitOr ? orWidth : 0));
 		if (curw + toadd > maxw)
@@ -440,11 +440,11 @@ ComponentsToBlit::ComponentsToBlit(std::vector<CComponent*> & SComps, int maxw,
 		comps[curr].push_back(cur);
 	}
 
-	for(size_t i=0;i<comps.size();i++)
+	for(auto & elem : comps)
 	{
 		int maxHeight = 0;
-		for(size_t j=0;j<comps[i].size();j++)
-			vstd::amax(maxHeight, comps[i][j]->pos.h);
+		for(size_t j=0;j<elem.size();j++)
+			vstd::amax(maxHeight, elem[j]->pos.h);
 
 		h += maxHeight + BETWEEN_COMPS_ROWS;
 	}
@@ -454,28 +454,28 @@ void ComponentsToBlit::blitCompsOnSur( bool blitOr, int inter, int &curh, SDL_Su
 {
 	int orWidth = graphics->fonts[FONT_MEDIUM]->getStringWidth(CGI->generaltexth->allTexts[4]);
 
-	for (size_t i=0;i<comps.size();i++)//for each row
+	for (auto & elem : comps)//for each row
 	{
 		int totalw=0, maxHeight=0;
-		for(size_t j=0;j<(comps)[i].size();j++)//find max height & total width in this row
+		for(size_t j=0;j<elem.size();j++)//find max height & total width in this row
 		{
-			ComponentResolved *cur = (comps)[i][j];
+			ComponentResolved *cur = elem[j];
 			totalw += cur->pos.w;
 			vstd::amax(maxHeight, cur->pos.h);
 		}
 
 		//add space between comps in this row
 		if(blitOr)
-			totalw += (inter*2+orWidth) * ((comps)[i].size() - 1);
+			totalw += (inter*2+orWidth) * (elem.size() - 1);
 		else
-			totalw += (inter) * ((comps)[i].size() - 1);
+			totalw += (inter) * (elem.size() - 1);
 
 		int middleh = curh + maxHeight/2;//axis for image aligment
 		int curw = ret->w/2 - totalw/2;
 
-		for(size_t j=0;j<(comps)[i].size();j++)
+		for(size_t j=0;j<elem.size();j++)
 		{
-			ComponentResolved *cur = (comps)[i][j];
+			ComponentResolved *cur = elem[j];
 			cur->moveTo(Point(curw, curh));
 
 			//blit component
@@ -483,7 +483,7 @@ void ComponentsToBlit::blitCompsOnSur( bool blitOr, int inter, int &curh, SDL_Su
 			curw += cur->pos.w;
 
 			//if there is subsequent component blit "or"
-			if(j<((comps)[i].size()-1))
+			if(j<(elem.size()-1))
 			{
 				if(blitOr)
 				{

+ 1 - 1
client/CMusicHandler.cpp

@@ -182,7 +182,7 @@ void CSoundHandler::initSpellsSounds(const std::vector< ConstTransitivePtr<CSpel
 
 	if (!config["spell_sounds"].isNull())
 	{
-		BOOST_FOREACH(const JsonNode &node, config["spell_sounds"].Vector())
+		for(const JsonNode &node : config["spell_sounds"].Vector())
 		{
 			int spellid = node["id"].Float();
 			const CSpell *s = CGI->spellh->spells[spellid];

+ 62 - 62
client/CPlayerInterface.cpp

@@ -215,10 +215,10 @@ void CPlayerInterface::yourTurn()
 STRONG_INLINE void subRect(const int & x, const int & y, const int & z, const SDL_Rect & r, const ObjectInstanceID & hid)
 {
 	TerrainTile2 & hlp = CGI->mh->ttiles[x][y][z];
-	for(int h=0; h<hlp.objects.size(); ++h)
-		if(hlp.objects[h].first->id == hid)
+	for(auto & elem : hlp.objects)
+		if(elem.first->id == hid)
 		{
-			hlp.objects[h].second = r;
+			elem.second = r;
 			return;
 		}
 }
@@ -249,9 +249,9 @@ void CPlayerInterface::heroMoved(const TryMoveHero & details)
 		//TODO very evil workaround -> retreive pointer to hero so we could animate it
 		// TODO -> we should not need full CGHeroInstance structure to display animation or it should not be handled by playerint (but by the client itself)
 		const TerrainTile2 &tile = CGI->mh->ttiles[hp.x-1][hp.y][hp.z];
-		for(int i = 0; i < tile.objects.size(); i++)
-			if(tile.objects[i].first->id == details.id)
-				hero = dynamic_cast<const CGHeroInstance *>(tile.objects[i].first);
+		for(auto & elem : tile.objects)
+			if(elem.first->id == details.id)
+				hero = dynamic_cast<const CGHeroInstance *>(elem.first);
 
 		if(!hero) //still nothing...
 			return;
@@ -530,7 +530,7 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
 		c->garr->recreateSlots();
 		c->heroes->update();
 	}
-	BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+	for(IShowActivatable *isa : GH.listInt)
 	{
 		CKingdomInterface *ki = dynamic_cast<CKingdomInterface*>(isa);
 		if (ki)
@@ -553,16 +553,16 @@ void CPlayerInterface::heroVisitsTown(const CGHeroInstance* hero, const CGTownIn
 void CPlayerInterface::garrisonsChanged(std::vector<const CGObjectInstance *> objs)
 {
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
-	BOOST_FOREACH(auto object, objs)
+	for(auto object : objs)
 		updateInfo(object);
 
-	for(std::list<IShowActivatable*>::iterator i = GH.listInt.begin(); i != GH.listInt.end(); i++)
+	for(auto & elem : GH.listInt)
 	{
-		CGarrisonHolder *cgh = dynamic_cast<CGarrisonHolder*>(*i);
+		CGarrisonHolder *cgh = dynamic_cast<CGarrisonHolder*>(elem);
 		if (cgh)
 			cgh->updateGarrisons();
 
-		if(CTradeWindow *cmw = dynamic_cast<CTradeWindow*>(*i))
+		if(CTradeWindow *cmw = dynamic_cast<CTradeWindow*>(elem))
 		{
 			if(vstd::contains(objs, cmw->hero))
 				cmw->garrisonChanged();
@@ -635,9 +635,9 @@ void CPlayerInterface::battleStacksHealedRes(const std::vector<std::pair<ui32, u
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	BATTLE_EVENT_POSSIBLE_RETURN;
 
-	for(int b=0; b<healedStacks.size(); ++b)
+	for(auto & healedStack : healedStacks)
 	{
-		const CStack * healed = cb->battleGetStackByID(healedStacks[b].first);
+		const CStack * healed = cb->battleGetStackByID(healedStack.first);
 		if(battleInt->creAnims[healed->ID]->getType() == CCreatureAnim::DEATH)
 		{
 			//stack has been resurrected
@@ -718,9 +718,9 @@ void CPlayerInterface::battleStacksRemoved(const BattleStacksRemoved & bsr)
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	BATTLE_EVENT_POSSIBLE_RETURN;
 
-	for(std::set<ui32>::const_iterator it = bsr.stackIDs.begin(); it != bsr.stackIDs.end(); ++it) //for each removed stack
+	for(auto & elem : bsr.stackIDs) //for each removed stack
 	{
-		battleInt->stackRemoved(*it);
+		battleInt->stackRemoved(elem);
 		//battleInt->stackRemoved(LOCPLINT->cb->battleGetStackByID(*it));
 	}
 }
@@ -811,7 +811,7 @@ void CPlayerInterface::battleEnd(const BattleResult *br)
 		if(!battleInt)
 		{
 			SDL_Rect temp_rect = genRect(561, 470, (screen->w - 800)/2 + 165, (screen->h - 600)/2 + 19);
-			auto resWindow = new CBattleResultWindow(*br, temp_rect, *this);
+			auto   resWindow = new CBattleResultWindow(*br, temp_rect, *this);
 			GH.pushInt(resWindow);
 			return;
 		}
@@ -857,17 +857,17 @@ void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacke
 	BATTLE_EVENT_POSSIBLE_RETURN;
 	
 	std::vector<StackAttackedInfo> arg;
-	for(std::vector<BattleStackAttacked>::const_iterator i = bsa.begin(); i != bsa.end(); i++)
+	for(auto & elem : bsa)
 	{
-		const CStack *defender = cb->battleGetStackByID(i->stackAttacked, false);
-		const CStack *attacker = cb->battleGetStackByID(i->attackerID, false);
-		if(i->isEffect() && i->effect != 12) //and not armageddon
+		const CStack *defender = cb->battleGetStackByID(elem.stackAttacked, false);
+		const CStack *attacker = cb->battleGetStackByID(elem.attackerID, false);
+		if(elem.isEffect() && elem.effect != 12) //and not armageddon
 		{
-			if (defender && !i->isSecondary())
-				battleInt->displayEffect(i->effect, defender->position);
+			if (defender && !elem.isSecondary())
+				battleInt->displayEffect(elem.effect, defender->position);
 		}
 		bool shooting = (LOCPLINT->curAction ? LOCPLINT->curAction->actionType == Battle::SHOOT : false); //FIXME: why action is deleted during enchanter cast?
-		StackAttackedInfo to_put = {defender, i->damageAmount, i->killedAmount, attacker, shooting, i->killed(), i->willRebirth(), i->cloneKilled()};
+		StackAttackedInfo to_put = {defender, elem.damageAmount, elem.killedAmount, attacker, shooting, elem.killed(), elem.willRebirth(), elem.cloneKilled()};
 		arg.push_back(to_put);
 	}
 
@@ -908,9 +908,9 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba)
 		std::string hlp = CGI->generaltexth->allTexts[(stack->count != 1) ? 366 : 365];
 		boost::algorithm::replace_first(hlp,"%s", (stack->count != 1) ? stack->getCreature()->namePl.c_str() : stack->getCreature()->nameSing.c_str());
 		battleInt->console->addText(hlp);
-		for (std::vector<BattleStackAttacked>::const_iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
+		for (auto & elem : ba->bsa)
 		{
-			const CStack * attacked = cb->battleGetStackByID(i->stackAttacked);
+			const CStack * attacked = cb->battleGetStackByID(elem.stackAttacked);
 			battleInt->displayEffect(73, attacked->position);
 		}
 		CCS->soundh->playSound(soundBase::deathBlow);
@@ -921,11 +921,11 @@ void CPlayerInterface::battleAttack(const BattleAttack *ba)
 
 	if(ba->shot())
 	{
-		for(std::vector<BattleStackAttacked>::const_iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
+		for(auto & elem : ba->bsa)
 		{
-			if (!i->isSecondary()) //display projectile only for primary target
+			if (!elem.isSecondary()) //display projectile only for primary target
 			{
-				const CStack * attacked = cb->battleGetStackByID(i->stackAttacked);
+				const CStack * attacked = cb->battleGetStackByID(elem.stackAttacked);
 				battleInt->stackAttacking(attacker, attacked->position, attacked, true);
 			}
 		}
@@ -979,8 +979,8 @@ void CPlayerInterface::showInfoDialog(const std::string &text, const std::vector
 		return;
 	}
 	std::vector<CComponent*> intComps;
-	for(int i=0;i<components.size();i++)
-		intComps.push_back(new CComponent(*components[i]));
+	for(auto & component : components)
+		intComps.push_back(new CComponent(*component));
 	showInfoDialog(text,intComps,soundID);
 
 }
@@ -1036,16 +1036,16 @@ void CPlayerInterface::showBlockingDialog( const std::string &text, const std::v
 	if(!selection && cancel) //simple yes/no dialog
 	{
 		std::vector<CComponent*> intComps;
-		for(int i=0;i<components.size();i++)
-			intComps.push_back(new CComponent(components[i])); //will be deleted by close in window
+		for(auto & component : components)
+			intComps.push_back(new CComponent(component)); //will be deleted by close in window
 
 		showYesNoDialog(text, [=]{ cb->selectionMade(1, askID); }, [=]{ cb->selectionMade(0, askID); }, true, intComps);
 	}
 	else if(selection)
 	{
 		std::vector<CSelectableComponent*> intComps;
-		for(int i=0;i<components.size();i++)
-			intComps.push_back(new CSelectableComponent(components[i])); //will be deleted by CSelWindow::close
+		for(auto & component : components)
+			intComps.push_back(new CSelectableComponent(component)); //will be deleted by CSelWindow::close
 
 		std::vector<std::pair<std::string,CFunctionList<void()> > > pom;
 		pom.push_back(std::pair<std::string,CFunctionList<void()> >("IOKAY.DEF",0));
@@ -1057,27 +1057,27 @@ void CPlayerInterface::showBlockingDialog( const std::string &text, const std::v
 		int charperline = 35;
 		if (pom.size() > 1)
 			charperline = 50;
-		CSelWindow * temp = new CSelWindow(text, playerID, charperline, intComps, pom, askID);
+		auto   temp = new CSelWindow(text, playerID, charperline, intComps, pom, askID);
 		GH.pushInt(temp);
 		intComps[0]->clickLeft(true, false);
 	}
 
 }
 
-void CPlayerInterface::tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos)
+void CPlayerInterface::tileRevealed(const std::unordered_set<int3, ShashInt3> &pos)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	for(boost::unordered_set<int3, ShashInt3>::const_iterator i=pos.begin(); i!=pos.end();i++)
-		adventureInt->minimap.showTile(*i);
+	for(auto & po : pos)
+		adventureInt->minimap.showTile(po);
 	if(pos.size())
 		GH.totalRedraw();
 }
 
-void CPlayerInterface::tileHidden(const boost::unordered_set<int3, ShashInt3> &pos)
+void CPlayerInterface::tileHidden(const std::unordered_set<int3, ShashInt3> &pos)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	for(boost::unordered_set<int3, ShashInt3>::const_iterator i=pos.begin(); i!=pos.end();i++)
-		adventureInt->minimap.hideTile(*i);
+	for(auto & po : pos)
+		adventureInt->minimap.hideTile(po);
 	if(pos.size())
 		GH.totalRedraw();
 }
@@ -1137,7 +1137,7 @@ void CPlayerInterface::availableCreaturesChanged( const CGDwelling *town )
 		if(fs)
 			fs->creaturesChanged();
 
-		BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+		for(IShowActivatable *isa : GH.listInt)
 		{
 			CKingdomInterface *ki = dynamic_cast<CKingdomInterface*>(isa);
 			if (ki && townObj)
@@ -1177,7 +1177,7 @@ template <typename Handler> void CPlayerInterface::serializeTempl( Handler &h, c
 	std::map<const CGHeroInstance *, int3> pathsMap; //hero -> dest
 	if(h.saving)
 	{
-		BOOST_FOREACH(auto &p, paths)
+		for(auto &p : paths)
 			pathsMap[p.first] = p.second.endPos();
 		h & pathsMap;
 	}
@@ -1186,7 +1186,7 @@ template <typename Handler> void CPlayerInterface::serializeTempl( Handler &h, c
 		h & pathsMap;
 
 		CPathsInfo pathsInfo(cb->getMapSize());
-		BOOST_FOREACH(auto &p, pathsMap)
+		for(auto &p : pathsMap)
 		{
 			cb->calculatePaths(p.first, pathsInfo);
 			CGPath path;
@@ -1346,7 +1346,7 @@ void CPlayerInterface::showGarrisonDialog( const CArmedInstance *up, const CGHer
 
 	waitForAllDialogs();
 
-	CGarrisonWindow *cgw = new CGarrisonWindow(up,down,removableUnits);
+	auto  cgw = new CGarrisonWindow(up,down,removableUnits);
 	cgw->quit->callback += onEnd;
 	GH.pushInt(cgw);
 }
@@ -1374,7 +1374,7 @@ void CPlayerInterface::showArtifactAssemblyDialog (ui32 artifactID, ui32 assembl
 		text += boost::str(boost::format(CGI->generaltexth->allTexts[732]) % assembledArtifact.Name());
 
 		// Picture of assembled artifact at bottom.
-		CComponent* sc = new CComponent(CComponent::artifact, assembledArtifact.id, 0);
+		auto   sc = new CComponent(CComponent::artifact, assembledArtifact.id, 0);
 		//sc->description = assembledArtifact.Description();
 		//sc->subtitle = assembledArtifact.Name();
 		scs.push_back(sc);
@@ -1407,10 +1407,10 @@ void CPlayerInterface::objectPropertyChanged(const SetObjectProperty * sop)
 	{
 		const CGObjectInstance * obj = cb->getObj(sop->id);
 		std::set<int3> pos = obj->getBlockedPos();
-		for(std::set<int3>::const_iterator it = pos.begin(); it != pos.end(); ++it)
+		for(auto & po : pos)
 		{
-			if(cb->isVisible(*it))
-				adventureInt->minimap.showTile(*it);
+			if(cb->isVisible(po))
+				adventureInt->minimap.showTile(po);
 		}
 
 		if(obj->ID == Obj::TOWN)
@@ -1447,9 +1447,9 @@ void CPlayerInterface::initializeHeroTownList()
 	wanderingHeroes = newWanderingHeroes;
 	newWanderingHeroes.clear();*/
 
-	for (int i = 0; i < allHeroes.size(); i++)
-		if (!allHeroes[i]->inTownGarrison)
-			wanderingHeroes += allHeroes[i];
+	for (auto & allHeroe : allHeroes)
+		if (!allHeroe->inTownGarrison)
+			wanderingHeroes += allHeroe;
 
 	std::vector<const CGTownInstance*> allTowns = cb->getTownsInfo();
 	/*
@@ -1464,8 +1464,8 @@ void CPlayerInterface::initializeHeroTownList()
 	towns.clear();
 	towns = newTowns;
 	newTowns.clear();*/
-	for(int i = 0; i < allTowns.size(); i++)
-		towns.push_back(allTowns[i]);
+	for(auto & allTown : allTowns)
+		towns.push_back(allTown);
 
 	if (adventureInt)
 		adventureInt->updateNextHero(nullptr);
@@ -2275,14 +2275,14 @@ void CPlayerInterface::showMarketWindow(const IMarket *market, const CGHeroInsta
 void CPlayerInterface::showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	CUniversityWindow *cuw = new CUniversityWindow(visitor, market);
+	auto  cuw = new CUniversityWindow(visitor, market);
 	GH.pushInt(cuw);
 }
 
 void CPlayerInterface::showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	CHillFortWindow *chfw = new CHillFortWindow(visitor, object);
+	auto  chfw = new CHillFortWindow(visitor, object);
 	GH.pushInt(chfw);
 }
 
@@ -2296,14 +2296,14 @@ void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket *bm /*= nul
 void CPlayerInterface::showTavernWindow(const CGObjectInstance *townOrTavern)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	CTavernWindow *tv = new CTavernWindow(townOrTavern);
+	auto  tv = new CTavernWindow(townOrTavern);
 	GH.pushInt(tv);
 }
 
 void CPlayerInterface::showThievesGuildWindow (const CGObjectInstance * obj)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	CThievesGuildWindow *tgw = new CThievesGuildWindow(obj);
+	auto  tgw = new CThievesGuildWindow(obj);
 	GH.pushInt(tgw);
 }
 
@@ -2397,7 +2397,7 @@ void CPlayerInterface::artifactPut(const ArtifactLocation &al)
 void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+	for(IShowActivatable *isa : GH.listInt)
 	{
 		auto artWin = dynamic_cast<CArtifactHolder*>(isa);
 		if(artWin)
@@ -2408,7 +2408,7 @@ void CPlayerInterface::artifactRemoved(const ArtifactLocation &al)
 void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+	for(IShowActivatable *isa : GH.listInt)
 	{
 		auto artWin = dynamic_cast<CArtifactHolder*>(isa);
 		if(artWin)
@@ -2419,7 +2419,7 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
 void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+	for(IShowActivatable *isa : GH.listInt)
 	{
 		auto artWin = dynamic_cast<CArtifactHolder*>(isa);
 		if(artWin)
@@ -2430,7 +2430,7 @@ void CPlayerInterface::artifactAssembled(const ArtifactLocation &al)
 void CPlayerInterface::artifactDisassembled(const ArtifactLocation &al)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
-	BOOST_FOREACH(IShowActivatable *isa, GH.listInt)
+	for(IShowActivatable *isa : GH.listInt)
 	{
 		auto artWin = dynamic_cast<CArtifactHolder*>(isa);
 		if(artWin)

+ 2 - 2
client/CPlayerInterface.h

@@ -171,8 +171,8 @@ public:
 	void showThievesGuildWindow (const CGObjectInstance * obj) override;
 	void showQuestLog() override;
 	void advmapSpellCast(const CGHeroInstance * caster, int spellID) override; //called when a hero casts a spell
-	void tileHidden(const boost::unordered_set<int3, ShashInt3> &pos) override; //called when given tiles become hidden under fog of war
-	void tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos) override; //called when fog of war disappears from given tiles
+	void tileHidden(const std::unordered_set<int3, ShashInt3> &pos) override; //called when given tiles become hidden under fog of war
+	void tileRevealed(const std::unordered_set<int3, ShashInt3> &pos) override; //called when fog of war disappears from given tiles
 	void newObject(const CGObjectInstance * obj) override;
 	void availableArtifactsChanged(const CGBlackMarket *bm = nullptr) override; //bm may be nullptr, then artifacts are changed in the global pool (used by merchants in towns)
 	void yourTurn() override;

+ 106 - 114
client/CPreGame.cpp

@@ -53,13 +53,6 @@
  *
  */
 namespace fs = boost::filesystem;
-using std::bind;
-using std::ref;
-
-#if _MSC_VER >= 1600
-	//#define bind std::bind
-	//#define ref std::ref
-#endif
 
 void startGame(StartInfo * options, CConnection *serv = nullptr);
 
@@ -108,7 +101,7 @@ static void do_quit()
 
 static CMapInfo *mapInfoFromGame()
 {
-	CMapInfo * ret = new CMapInfo();
+	auto   ret = new CMapInfo();
 	ret->mapHeader = std::unique_ptr<CMapHeader>(new CMapHeader(*LOCPLINT->cb->getMapHeader()));
 	return ret;
 }
@@ -244,10 +237,10 @@ CMenuScreen::CMenuScreen(const JsonNode& configNode):
 
 	pos = background->center();
 
-	BOOST_FOREACH(const JsonNode& node, config["items"].Vector())
+	for(const JsonNode& node : config["items"].Vector())
 		menuNameToEntry.push_back(node["name"].String());
 
-	BOOST_FOREACH(const JsonNode& node, config["images"].Vector())
+	for(const JsonNode& node : config["images"].Vector())
 		images.push_back(createPicture(node));
 
 	//Hardcoded entry
@@ -336,7 +329,7 @@ static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::stri
 				{
 					switch (std::find(gameType.begin(), gameType.end(), commands.front()) - gameType.begin())
 					{
-						case 0: return bind(&CGPreGame::openSel, CGP, CMenuScreen::newGame, CMenuScreen::SINGLE_PLAYER);
+						case 0: return std::bind(&CGPreGame::openSel, CGP, CMenuScreen::newGame, CMenuScreen::SINGLE_PLAYER);
 						case 1: return &pushIntT<CMultiMode>;
 						case 2: return std::bind(&CGPreGame::openSel, CGP, CMenuScreen::campaignList, CMenuScreen::SINGLE_PLAYER);
 						case 3: return std::function<void()>();//TODO: start tutorial
@@ -354,7 +347,7 @@ static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::stri
 				}
 				break; case 4://exit
 				{
-					return std::bind(CInfoWindow::showYesNoDialog, std::ref(CGI->generaltexth->allTexts[69]), (const std::vector<CComponent*>*)0, do_quit, 0, false, PlayerColor(1));
+					return std::bind(CInfoWindow::showYesNoDialog, std::ref(CGI->generaltexth->allTexts[69]), (const std::vector<CComponent*>*)nullptr, do_quit, 0, false, PlayerColor(1));
 				}
 				break; case 5://highscores
 				{
@@ -392,10 +385,10 @@ CMenuEntry::CMenuEntry(CMenuScreen* parent, const JsonNode &config)
 	type |= REDRAW_PARENT;
 	pos = parent->pos;
 
-	BOOST_FOREACH(const JsonNode& node, config["images"].Vector())
+	for(const JsonNode& node : config["images"].Vector())
 		images.push_back(createPicture(node));
 
-	BOOST_FOREACH(const JsonNode& node, config["buttons"].Vector())
+	for(const JsonNode& node : config["buttons"].Vector())
 	{
 		buttons.push_back(createButton(parent, node));
 		buttons.back()->hoverable = true;
@@ -536,7 +529,7 @@ void CGPreGame::update()
 
 void CGPreGame::openCampaignScreen(std::string name)
 {
-	BOOST_FOREACH(const JsonNode& node, (*pregameConfig)["campaignsset"].Vector())
+	for(const JsonNode& node : (*pregameConfig)["campaignsset"].Vector())
 	{
 		if (node["name"].String() == name)
 		{
@@ -622,17 +615,17 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 		opt->recActions = DISPOSE;
 
 		randMapTab = new CRandomMapTab();
-		randMapTab->getMapInfoChanged() += bind(&CSelectionScreen::changeSelection, this, _1);
+		randMapTab->getMapInfoChanged() += std::bind(&CSelectionScreen::changeSelection, this, _1);
 		randMapTab->recActions = DISPOSE;
 	}
-	sel = new SelectionTab(screenType, bind(&CSelectionScreen::changeSelection, this, _1), multiPlayer); //scenario selection tab
+	sel = new SelectionTab(screenType, std::bind(&CSelectionScreen::changeSelection, this, _1), multiPlayer); //scenario selection tab
 	sel->recActions = DISPOSE;
 
 	switch(screenType)
 	{
 	case CMenuScreen::newGame:
 		{
-			card->difficulty->onChange = bind(&CSelectionScreen::difficultyChange, this, _1);
+			card->difficulty->onChange = std::bind(&CSelectionScreen::difficultyChange, this, _1);
 			card->difficulty->select(1, 0);
 			CAdventureMapButton * select = new CAdventureMapButton(CGI->generaltexth->zelp[45], 0, 411, 80, "GSPBUTT.DEF", SDLK_s);
 			select->callback = [&]()
@@ -642,7 +635,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 			};
 			select->addTextOverlay(CGI->generaltexth->allTexts[500], FONT_SMALL);
 
-			CAdventureMapButton *opts = new CAdventureMapButton(CGI->generaltexth->zelp[46], bind(&CSelectionScreen::toggleTab, this, opt), 411, 510, "GSPBUTT.DEF", SDLK_a);
+			CAdventureMapButton *opts = new CAdventureMapButton(CGI->generaltexth->zelp[46], std::bind(&CSelectionScreen::toggleTab, this, opt), 411, 510, "GSPBUTT.DEF", SDLK_a);
 			opts->addTextOverlay(CGI->generaltexth->allTexts[501], FONT_SMALL);
 
 			CAdventureMapButton * randomBtn = new CAdventureMapButton(CGI->generaltexth->zelp[47], 0, 411, 105, "GSPBUTT.DEF", SDLK_r);
@@ -653,11 +646,11 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 				changeSelection(randMapTab->getMapInfo());
 			};
 
-			start  = new CAdventureMapButton(CGI->generaltexth->zelp[103], bind(&CSelectionScreen::startScenario, this), 411, 535, "SCNRBEG.DEF", SDLK_b);
+			start  = new CAdventureMapButton(CGI->generaltexth->zelp[103], std::bind(&CSelectionScreen::startScenario, this), 411, 535, "SCNRBEG.DEF", SDLK_b);
 
 			if(network)
 			{
-				CAdventureMapButton *hideChat = new CAdventureMapButton(CGI->generaltexth->zelp[48], bind(&InfoCard::toggleChat, card), 619, 83, "GSPBUT2.DEF", SDLK_h);
+				CAdventureMapButton *hideChat = new CAdventureMapButton(CGI->generaltexth->zelp[48], std::bind(&InfoCard::toggleChat, card), 619, 83, "GSPBUT2.DEF", SDLK_h);
 				hideChat->addTextOverlay(CGI->generaltexth->allTexts[531], FONT_SMALL);
 
 				if(multiPlayer == CMenuScreen::MULTI_NETWORK_GUEST)
@@ -674,15 +667,15 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 		break;
 	case CMenuScreen::loadGame:
 		sel->recActions = 255;
-		start  = new CAdventureMapButton(CGI->generaltexth->zelp[103], bind(&CSelectionScreen::startScenario, this), 411, 535, "SCNRLOD.DEF", SDLK_l);
+		start  = new CAdventureMapButton(CGI->generaltexth->zelp[103], std::bind(&CSelectionScreen::startScenario, this), 411, 535, "SCNRLOD.DEF", SDLK_l);
 		break;
 	case CMenuScreen::saveGame:
 		sel->recActions = 255;
-		start  = new CAdventureMapButton("", CGI->generaltexth->zelp[103].second, bind(&CSelectionScreen::startScenario, this), 411, 535, "SCNRSAV.DEF");
+		start  = new CAdventureMapButton("", CGI->generaltexth->zelp[103].second, std::bind(&CSelectionScreen::startScenario, this), 411, 535, "SCNRSAV.DEF");
 		break;
 	case CMenuScreen::campaignList:
 		sel->recActions = 255;
-		start  = new CAdventureMapButton(std::pair<std::string, std::string>(), bind(&CSelectionScreen::startCampaign, this), 411, 535, "SCNRLOD.DEF", SDLK_b);
+		start  = new CAdventureMapButton(std::pair<std::string, std::string>(), std::bind(&CSelectionScreen::startCampaign, this), 411, 535, "SCNRLOD.DEF", SDLK_b);
 		break;
 	}
 
@@ -698,7 +691,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 		backName = "SCNRBACK.DEF";
 	}
 
-	back = new CAdventureMapButton("", CGI->generaltexth->zelp[105].second, bind(&CGuiHandler::popIntTotally, &GH, this), 581, 535, backName, SDLK_ESCAPE);
+	back = new CAdventureMapButton("", CGI->generaltexth->zelp[105].second, std::bind(&CGuiHandler::popIntTotally, &GH, this), 581, 535, backName, SDLK_ESCAPE);
 
 	if(network)
 	{
@@ -885,7 +878,7 @@ void CSelectionScreen::startScenario()
 		if(sInfo.mapGenOptions)
 		{
 			// Update player settings for RMG
-			BOOST_FOREACH(const auto & psetPair, sInfo.playerInfos)
+			for(const auto & psetPair : sInfo.playerInfos)
 			{
 				const auto & pset = psetPair.second;
 				sInfo.mapGenOptions->setStartingTownForPlayer(pset.color, pset.castle);
@@ -908,7 +901,7 @@ void CSelectionScreen::startScenario()
 			saveGameName = sInfo.mapname;
 		}
 
-		StartInfo * si = new StartInfo(sInfo);
+		auto   si = new StartInfo(sInfo);
 		CGP->removeFromGui();
 		CGP->showLoadingScreen(std::bind(&startGame, si, (CConnection *)nullptr));
 	}
@@ -921,7 +914,7 @@ void CSelectionScreen::startScenario()
 
 		CFunctionList<void()> overWrite;
 		overWrite += std::bind(&CCallback::save, LOCPLINT->cb.get(), saveGameName);
-		overWrite += bind(&CGuiHandler::popIntTotally, &GH, this);
+		overWrite += std::bind(&CGuiHandler::popIntTotally, &GH, this);
 
 		if(CResourceHandler::get()->existsResource(ResourceID(saveGameName, EResType::CLIENT_SAVEGAME)))
 		{
@@ -1068,14 +1061,14 @@ void SelectionTab::filter( int size, bool selectFirst )
 
 	if(tabType == CMenuScreen::campaignList)
 	{
-		for (size_t i=0; i<allItems.size(); i++)
-			curItems.push_back(&allItems[i]);
+		for (auto & elem : allItems)
+			curItems.push_back(&elem);
 	}
 	else
 	{
-		for (size_t i=0; i<allItems.size(); i++)
-			if( allItems[i].mapHeader && allItems[i].mapHeader->version  &&  (!size || allItems[i].mapHeader->width == size))
-				curItems.push_back(&allItems[i]);
+		for (auto & elem : allItems)
+			if( elem.mapHeader && elem.mapHeader->version  &&  (!size || elem.mapHeader->width == size))
+				curItems.push_back(&elem);
 	}
 
 	if(curItems.size())
@@ -1120,31 +1113,31 @@ std::vector<ResourceID> SelectionTab::getFiles(std::string dirURI, int resType)
 void SelectionTab::parseMaps(const std::vector<ResourceID> & files)
 {
 	allItems.clear();
-	for(int i = 0; i < files.size(); ++i)
+	for(auto & file : files)
 	{
 		try
 		{
 			CMapInfo mapInfo;
-			mapInfo.mapInit(files[i].getName());
+			mapInfo.mapInit(file.getName());
 
 			// ignore unsupported map versions (e.g. WoG maps without WoG
 			if (mapInfo.mapHeader->version <= CGI->modh->settings.data["textData"]["mapVersion"].Float())
-				allItems.push_back(mapInfo);
+				allItems.push_back(std::move(mapInfo));
 		}
 		catch(std::exception & e)
 		{
-            logGlobal->errorStream() << "Map " << files[i].getName() << " is invalid. Message: " << e.what();
+            logGlobal->errorStream() << "Map " << file.getName() << " is invalid. Message: " << e.what();
 		}
 	}
 }
 
 void SelectionTab::parseGames(const std::vector<ResourceID> &files, bool multi)
 {
-	for(int i=0; i<files.size(); i++)
+	for(auto & file : files)
 	{
 		try
 		{
-			CLoadFile lf(CResourceHandler::get()->getResourceName(files[i]));
+			CLoadFile lf(CResourceHandler::get()->getResourceName(file));
 			lf.checkMagicBytes(SAVEGAME_MAGIC);
 // 			ui8 sign[8];
 // 			lf >> sign;
@@ -1155,12 +1148,12 @@ void SelectionTab::parseGames(const std::vector<ResourceID> &files, bool multi)
 
 			// Create the map info object
 			CMapInfo mapInfo;
-			mapInfo.mapHeader = std::shared_ptr<CMapHeader>(new CMapHeader);
+			mapInfo.mapHeader = make_unique<CMapHeader>();
 			mapInfo.scenarioOpts = new StartInfo;
 			lf >> *(mapInfo.mapHeader.get()) >> mapInfo.scenarioOpts;
-			mapInfo.fileURI = files[i].getName();
+			mapInfo.fileURI = file.getName();
 			mapInfo.countPlayers();
-			std::time_t time = CFileInfo(CResourceHandler::get()->getResourceName(files[i])).getDate();
+			std::time_t time = CFileInfo(CResourceHandler::get()->getResourceName(file)).getDate();
 			mapInfo.date = std::asctime(std::localtime(&time));
 
 			// If multi mode then only multi games, otherwise single
@@ -1169,11 +1162,11 @@ void SelectionTab::parseGames(const std::vector<ResourceID> &files, bool multi)
 				mapInfo.mapHeader.reset();
 			}
 
-			allItems.push_back(mapInfo);
+			allItems.push_back(std::move(mapInfo));
 		}
 		catch(const std::exception & e)
 		{
-            logGlobal->errorStream() << "Error: Failed to process " << files[i].getName() <<": " << e.what();
+            logGlobal->errorStream() << "Error: Failed to process " << file.getName() <<": " << e.what();
 		}
 	}
 }
@@ -1264,7 +1257,7 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const std::function<void(CM
 			int sizes[] = {36, 72, 108, 144, 0};
 			const char * names[] = {"SCSMBUT.DEF", "SCMDBUT.DEF", "SCLGBUT.DEF", "SCXLBUT.DEF", "SCALBUT.DEF"};
 			for(int i = 0; i < 5; i++)
-				new CAdventureMapButton("", CGI->generaltexth->zelp[54+i].second, bind(&SelectionTab::filter, this, sizes[i], true), 158 + 47*i, 46, names[i]);
+				new CAdventureMapButton("", CGI->generaltexth->zelp[54+i].second, std::bind(&SelectionTab::filter, this, sizes[i], true), 158 + 47*i, 46, names[i]);
 		}
 
 		//sort buttons buttons
@@ -1272,17 +1265,17 @@ SelectionTab::SelectionTab(CMenuScreen::EState Type, const std::function<void(CM
 			int xpos[] = {23, 55, 88, 121, 306, 339};
 			const char * names[] = {"SCBUTT1.DEF", "SCBUTT2.DEF", "SCBUTCP.DEF", "SCBUTT3.DEF", "SCBUTT4.DEF", "SCBUTT5.DEF"};
 			for(int i = 0; i < 6; i++)
-				new CAdventureMapButton("", CGI->generaltexth->zelp[107+i].second, bind(&SelectionTab::sortBy, this, i), xpos[i], 86, names[i]);
+				new CAdventureMapButton("", CGI->generaltexth->zelp[107+i].second, std::bind(&SelectionTab::sortBy, this, i), xpos[i], 86, names[i]);
 		}
 	}
 	else
 	{
 		//sort by buttons
-		new CAdventureMapButton("", "", bind(&SelectionTab::sortBy, this, _numOfMaps), 23, 86, "CamCusM.DEF"); //by num of maps
-		new CAdventureMapButton("", "", bind(&SelectionTab::sortBy, this, _name), 55, 86, "CamCusL.DEF"); //by name
+		new CAdventureMapButton("", "", std::bind(&SelectionTab::sortBy, this, _numOfMaps), 23, 86, "CamCusM.DEF"); //by num of maps
+		new CAdventureMapButton("", "", std::bind(&SelectionTab::sortBy, this, _name), 55, 86, "CamCusL.DEF"); //by name
 	}
 
-	slider = new CSlider(372, 86, tabType != CMenuScreen::saveGame ? 480 : 430, bind(&SelectionTab::sliderMove, this, _1), positions, curItems.size(), 0, false, 1);
+	slider = new CSlider(372, 86, tabType != CMenuScreen::saveGame ? 480 : 430, std::bind(&SelectionTab::sliderMove, this, _1), positions, curItems.size(), 0, false, 1);
 	slider->addUsedEvents(WHEEL);
 	slider->slider->keepFrame = true;
 	format =  CDefHandler::giveDef("SCSELC.DEF");
@@ -1759,7 +1752,7 @@ void CRandomMapTab::addButtonsToGroup(CHighlightableButtonsGroup * group, const
 
 void CRandomMapTab::deactivateButtonsFrom(CHighlightableButtonsGroup * group, int startId)
 {
-	BOOST_FOREACH(CHighlightableButton * btn, group->buttons)
+	for(CHighlightableButton * btn : group->buttons)
 	{
 		if(startId == CMapGenOptions::RANDOM_SIZE || btn->ID < startId)
 		{
@@ -1848,12 +1841,11 @@ void CRandomMapTab::updateMapInfo()
 	// Generate header info
 	mapInfo = make_unique<CMapInfo>();
 	mapInfo->isRandomMap = true;
-	auto mapHeader = std::make_shared<CMapHeader>();
-	mapHeader->version = EMapFormat::SOD;
-	mapHeader->name = CGI->generaltexth->allTexts[740];
-	mapHeader->description = CGI->generaltexth->allTexts[741];
-	mapHeader->difficulty = 1; // Normal
-	mapInfo->mapHeader = mapHeader;
+	mapInfo->mapHeader = make_unique<CMapHeader>();
+	mapInfo->mapHeader->version = EMapFormat::SOD;
+	mapInfo->mapHeader->name = CGI->generaltexth->allTexts[740];
+	mapInfo->mapHeader->description = CGI->generaltexth->allTexts[741];
+	mapInfo->mapHeader->difficulty = 1; // Normal
 	mapInfo->mapHeader->height = mapGenOptions.getHeight();
 	mapInfo->mapHeader->width = mapGenOptions.getWidth();
 	mapInfo->mapHeader->twoLevel = mapGenOptions.getHasTwoLevels();
@@ -2204,9 +2196,9 @@ void InfoCard::showTeamsPopup()
 				flags.push_back(j);
 
 		int curx = 128 - 9*flags.size();
-		for(int j = 0; j < flags.size(); j++)
+		for(auto & flag : flags)
 		{
-			blitAt(sFlags->ourImages[flags[j]].bitmap, curx, 75 + 50*i, bmp);
+			blitAt(sFlags->ourImages[flag].bitmap, curx, 75 + 50*i, bmp);
 			curx += 18;
 		}
 	}
@@ -2251,7 +2243,7 @@ OptionsTab::OptionsTab():
 	pos = bg->pos;
 
 	if(SEL->screenType == CMenuScreen::newGame)
-		turnDuration = new CSlider(55, 551, 194, bind(&OptionsTab::setTurnLength, this, _1), 1, 11, 11, true, 1);
+		turnDuration = new CSlider(55, 551, 194, std::bind(&OptionsTab::setTurnLength, this, _1), 1, 11, 11, true, 1);
 }
 
 OptionsTab::~OptionsTab()
@@ -2423,9 +2415,9 @@ void OptionsTab::nextBonus( PlayerColor player, int dir )
 
 void OptionsTab::recreate()
 {
-	for(auto it = entries.begin(); it != entries.end(); ++it)
+	for(auto & elem : entries)
 	{
-		delete it->second;
+		delete elem.second;
 	}
 	entries.clear();
 	usedHeroes.clear();
@@ -2435,8 +2427,8 @@ void OptionsTab::recreate()
 	{
 		entries.insert(std::make_pair(it->first, new PlayerOptionsEntry(this, it->second)));
 		const std::vector<SHeroName> &heroes = SEL->current->mapHeader->players[it->first.getNum()].heroesNames;
-		for(size_t hi=0; hi<heroes.size(); hi++)
-			usedHeroes.insert(heroes[hi].heroId);
+		for(auto & heroe : heroes)
+			usedHeroes.insert(heroe.heroId);
 	}
 
 }
@@ -2555,16 +2547,16 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
 	bg = new CPicture(BitmapHandler::loadBitmap(bgs[s.color.getNum()]), 0, 0, true);
 	if(SEL->screenType == CMenuScreen::newGame)
 	{
-		btns[0] = new CAdventureMapButton(CGI->generaltexth->zelp[132], bind(&OptionsTab::nextCastle, owner, s.color, -1), 107, 5, "ADOPLFA.DEF");
-		btns[1] = new CAdventureMapButton(CGI->generaltexth->zelp[133], bind(&OptionsTab::nextCastle, owner, s.color, +1), 168, 5, "ADOPRTA.DEF");
-		btns[2] = new CAdventureMapButton(CGI->generaltexth->zelp[148], bind(&OptionsTab::nextHero, owner, s.color, -1), 183, 5, "ADOPLFA.DEF");
-		btns[3] = new CAdventureMapButton(CGI->generaltexth->zelp[149], bind(&OptionsTab::nextHero, owner, s.color, +1), 244, 5, "ADOPRTA.DEF");
-		btns[4] = new CAdventureMapButton(CGI->generaltexth->zelp[164], bind(&OptionsTab::nextBonus, owner, s.color, -1), 259, 5, "ADOPLFA.DEF");
-		btns[5] = new CAdventureMapButton(CGI->generaltexth->zelp[165], bind(&OptionsTab::nextBonus, owner, s.color, +1), 320, 5, "ADOPRTA.DEF");
+		btns[0] = new CAdventureMapButton(CGI->generaltexth->zelp[132], std::bind(&OptionsTab::nextCastle, owner, s.color, -1), 107, 5, "ADOPLFA.DEF");
+		btns[1] = new CAdventureMapButton(CGI->generaltexth->zelp[133], std::bind(&OptionsTab::nextCastle, owner, s.color, +1), 168, 5, "ADOPRTA.DEF");
+		btns[2] = new CAdventureMapButton(CGI->generaltexth->zelp[148], std::bind(&OptionsTab::nextHero, owner, s.color, -1), 183, 5, "ADOPLFA.DEF");
+		btns[3] = new CAdventureMapButton(CGI->generaltexth->zelp[149], std::bind(&OptionsTab::nextHero, owner, s.color, +1), 244, 5, "ADOPRTA.DEF");
+		btns[4] = new CAdventureMapButton(CGI->generaltexth->zelp[164], std::bind(&OptionsTab::nextBonus, owner, s.color, -1), 259, 5, "ADOPLFA.DEF");
+		btns[5] = new CAdventureMapButton(CGI->generaltexth->zelp[165], std::bind(&OptionsTab::nextBonus, owner, s.color, +1), 320, 5, "ADOPRTA.DEF");
 	}
 	else
-		for(int i = 0; i < 6; i++)
-			btns[i] = nullptr;
+		for(auto & elem : btns)
+			elem = nullptr;
 
 	selectButtons();
 
@@ -2582,7 +2574,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
 		&&  SEL->current->mapHeader->players[s.color.getNum()].canHumanPlay
 		&&  SEL->multiPlayer != CMenuScreen::MULTI_NETWORK_GUEST)
 	{
-		flag = new CAdventureMapButton(CGI->generaltexth->zelp[180], bind(&OptionsTab::flagPressed, owner, s.color), -43, 2, flags[s.color.getNum()]);
+		flag = new CAdventureMapButton(CGI->generaltexth->zelp[180], std::bind(&OptionsTab::flagPressed, owner, s.color), -43, 2, flags[s.color.getNum()]);
 		flag->hoverable = true;
 	}
 	else
@@ -2898,8 +2890,8 @@ void OptionsTab::CPregameTooltipBox::genTownWindow()
 	std::vector<CComponent *> components;
 	const CTown * town = CGI->townh->factions[settings.castle]->town;
 
-	for (size_t i=0; i< town->creatures.size(); i++)
-		components.push_back(new CComponent(CComponent::creature, town->creatures[i].front(), 0, CComponent::tiny));
+	for (auto & elem : town->creatures)
+		components.push_back(new CComponent(CComponent::creature, elem.front(), 0, CComponent::tiny));
 
 	new CComponentBox(components, Rect(10, 140, pos.w - 20, 140));
 }
@@ -2986,7 +2978,7 @@ CScenarioInfo::CScenarioInfo(const CMapHeader *mapHeader, const StartInfo *start
 	card->changeSelection(current);
 
 	card->difficulty->select(startInfo->difficulty, 0);
-	back = new CAdventureMapButton("", CGI->generaltexth->zelp[105].second, bind(&CGuiHandler::popIntTotally, &GH, this), 584, 535, "SCNRBACK.DEF", SDLK_ESCAPE);
+	back = new CAdventureMapButton("", CGI->generaltexth->zelp[105].second, std::bind(&CGuiHandler::popIntTotally, &GH, this), 584, 535, "SCNRBACK.DEF", SDLK_ESCAPE);
 }
 
 CScenarioInfo::~CScenarioInfo()
@@ -3063,10 +3055,10 @@ CMultiMode::CMultiMode()
 	txt = new CTextInput(Rect(19, 436, 334, 16), *bg);
 	txt->setTxt(settings["general"]["playerName"].String()); //Player
 
-	btns[0] = new CAdventureMapButton(CGI->generaltexth->zelp[266], bind(&CMultiMode::openHotseat, this), 373, 78, "MUBHOT.DEF");
-	btns[1] = new CAdventureMapButton("Host TCP/IP game", "", bind(&CMultiMode::hostTCP, this), 373, 78 + 57*1, "MUBHOST.DEF");
-	btns[2] = new CAdventureMapButton("Join TCP/IP game", "", bind(&CMultiMode::joinTCP, this), 373, 78 + 57*2, "MUBJOIN.DEF");
-	btns[6] = new CAdventureMapButton(CGI->generaltexth->zelp[288], bind(&CGuiHandler::popIntTotally, ref(GH), this), 373, 424, "MUBCANC.DEF", SDLK_ESCAPE);
+	btns[0] = new CAdventureMapButton(CGI->generaltexth->zelp[266], std::bind(&CMultiMode::openHotseat, this), 373, 78, "MUBHOT.DEF");
+	btns[1] = new CAdventureMapButton("Host TCP/IP game", "", std::bind(&CMultiMode::hostTCP, this), 373, 78 + 57*1, "MUBHOST.DEF");
+	btns[2] = new CAdventureMapButton("Join TCP/IP game", "", std::bind(&CMultiMode::joinTCP, this), 373, 78 + 57*2, "MUBJOIN.DEF");
+	btns[6] = new CAdventureMapButton(CGI->generaltexth->zelp[288], std::bind(&CGuiHandler::popIntTotally, std::ref(GH), this), 373, 424, "MUBCANC.DEF", SDLK_ESCAPE);
 }
 
 void CMultiMode::openHotseat()
@@ -3106,8 +3098,8 @@ CHotSeatPlayers::CHotSeatPlayers(const std::string &firstPlayer)
 		txt[i]->cb += std::bind(&CHotSeatPlayers::onChange, this, _1);
 	}
 
-	ok = new CAdventureMapButton(CGI->generaltexth->zelp[560], bind(&CHotSeatPlayers::enterSelectionScreen, this), 95, 338, "MUBCHCK.DEF", SDLK_RETURN);
-	cancel = new CAdventureMapButton(CGI->generaltexth->zelp[561], bind(&CGuiHandler::popIntTotally, ref(GH), this), 205, 338, "MUBCANC.DEF", SDLK_ESCAPE);
+	ok = new CAdventureMapButton(CGI->generaltexth->zelp[560], std::bind(&CHotSeatPlayers::enterSelectionScreen, this), 95, 338, "MUBCHCK.DEF", SDLK_RETURN);
+	cancel = new CAdventureMapButton(CGI->generaltexth->zelp[561], std::bind(&CGuiHandler::popIntTotally, std::ref(GH), this), 205, 338, "MUBCANC.DEF", SDLK_ESCAPE);
 	bar = new CGStatusBar(new CPicture(Rect(7, 381, 348, 18), 0));//226, 472
 
 	txt[0]->setTxt(firstPlayer, true);
@@ -3118,8 +3110,8 @@ void CHotSeatPlayers::onChange(std::string newText)
 {
 	size_t namesCount = 0;
 
-	for(int i = 0; i < ARRAY_COUNT(txt); i++)
-		if(!txt[i]->text.empty())
+	for(auto & elem : txt)
+		if(!elem->text.empty())
 			namesCount++;
 
 	ok->block(namesCount < 2);
@@ -3163,8 +3155,8 @@ void CBonusSelection::init()
 
 	blitAt(panel, 456, 6, background);
 
-	startB = new CAdventureMapButton("", "", bind(&CBonusSelection::startMap, this), 475, 536, "CBBEGIB.DEF", SDLK_RETURN);
-	backB = new CAdventureMapButton("", "", bind(&CBonusSelection::goBack, this), 624, 536, "CBCANCB.DEF", SDLK_ESCAPE);
+	startB = new CAdventureMapButton("", "", std::bind(&CBonusSelection::startMap, this), 475, 536, "CBBEGIB.DEF", SDLK_RETURN);
+	backB = new CAdventureMapButton("", "", std::bind(&CBonusSelection::goBack, this), 624, 536, "CBCANCB.DEF", SDLK_ESCAPE);
 
 	//campaign name
 	if (ourCampaign->camp->header.name.length())
@@ -3242,8 +3234,8 @@ void CBonusSelection::init()
 	//difficulty selection buttons
 	if (ourCampaign->camp->header.difficultyChoosenByPlayer)
 	{
-		diffLb = new CAdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, false), 694, 508, "SCNRBLF.DEF");
-		diffRb = new CAdventureMapButton("", "", bind(&CBonusSelection::changeDiff, this, true), 738, 508, "SCNRBRT.DEF");
+		diffLb = new CAdventureMapButton("", "", std::bind(&CBonusSelection::changeDiff, this, false), 694, 508, "SCNRBLF.DEF");
+		diffRb = new CAdventureMapButton("", "", std::bind(&CBonusSelection::changeDiff, this, true), 738, 508, "SCNRBRT.DEF");
 	}
 
 	//load miniflags
@@ -3271,9 +3263,9 @@ CBonusSelection::~CBonusSelection()
 	delete sizes;
 	delete ourHeader;
 	delete sFlags;
-	for (int b=0; b<ARRAY_COUNT(diffPics); ++b)
+	for (auto & elem : diffPics)
 	{
-		SDL_FreeSurface(diffPics[b]);
+		SDL_FreeSurface(elem);
 	}
 }
 
@@ -3297,14 +3289,14 @@ void CBonusSelection::loadPositionsOfGraphics()
 	const JsonNode config(ResourceID("config/campaign_regions.json"));
 	int idx = 0;
 
-	BOOST_FOREACH(const JsonNode &campaign, config["campaign_regions"].Vector())
+	for(const JsonNode &campaign : config["campaign_regions"].Vector())
 	{
 		SCampPositions sc;
 
 		sc.campPrefix = campaign["prefix"].String();
 		sc.colorSuffixLength = campaign["color_suffix_length"].Float();
 
-		BOOST_FOREACH(const JsonNode &desc,  campaign["desc"].Vector())
+		for(const JsonNode &desc :  campaign["desc"].Vector())
 		{
 			SCampPositions::SRegionDesc rd;
 
@@ -3426,11 +3418,11 @@ void CBonusSelection::updateBonusSelection()
 
 	updateStartButtonState(-1);
 
-	for (size_t i=0; i<bonuses->buttons.size(); i++)
+	for (auto & elem : bonuses->buttons)
 	{
-		if (bonuses->buttons[i]->active)
-			bonuses->buttons[i]->deactivate();
-		delete bonuses->buttons[i];
+		if (elem->active)
+			elem->deactivate();
+		delete elem;
 	}
 	bonuses->buttons.clear();
 
@@ -3458,11 +3450,11 @@ void CBonusSelection::updateBonusSelection()
 			case CScenarioTravel::STravelBonus::BUILDING:
 				{
 					int faction = -1;
-					for(auto it = sInfo.playerInfos.begin(); it != sInfo.playerInfos.end(); ++it)
+					for(auto & elem : sInfo.playerInfos)
 					{
-						if (it->second.playerID)
+						if (elem.second.playerID)
 						{
-							faction = it->second.castle;
+							faction = elem.second.castle;
 							break;
 						}
 
@@ -3590,7 +3582,7 @@ void CBonusSelection::updateBonusSelection()
 			if (picNumber != -1)
 				picName += ":" + boost::lexical_cast<std::string>(picNumber);
 
-			CAnimation * anim = new CAnimation();
+			auto   anim = new CAnimation();
 			anim->setCustom(picName, 0);
 			bonusButton->setImage(anim);
 			const SDL_Color brightYellow = { 242, 226, 110, 0 };
@@ -3601,7 +3593,7 @@ void CBonusSelection::updateBonusSelection()
 
 void CBonusSelection::startMap()
 {
-	StartInfo *si = new StartInfo(sInfo);
+	auto  si = new StartInfo(sInfo);
 
 	const CCampaignScenario & scenario = ourCampaign->camp->scenarios[ourCampaign->currentMap];
 
@@ -3645,12 +3637,12 @@ void CBonusSelection::selectBonus( int id )
 	{
 		std::map<ui8, std::string> names;
 		names[1] = settings["general"]["playerName"].String();
-		for(auto it = sInfo.playerInfos.begin(); it != sInfo.playerInfos.end(); ++it)
+		for(auto & elem : sInfo.playerInfos)
 		{
-			if(it->first == PlayerColor(bonDescs[id].info1))
-				::setPlayer(it->second, 1, names);
+			if(elem.first == PlayerColor(bonDescs[id].info1))
+				::setPlayer(elem.second, 1, names);
 			else
-				::setPlayer(it->second, 0, names);
+				::setPlayer(elem.second, 0, names);
 		}
 	}
 }
@@ -3707,9 +3699,9 @@ CBonusSelection::CRegion::CRegion( CBonusSelection * _owner, bool _accessible, b
 
 CBonusSelection::CRegion::~CRegion()
 {
-	for (int g=0; g<ARRAY_COUNT(graphics); ++g)
+	for (auto & elem : graphics)
 	{
-		SDL_FreeSurface(graphics[g]);
+		SDL_FreeSurface(elem);
 	}
 }
 
@@ -3842,12 +3834,12 @@ void PlayerJoined::apply(CSelectionScreen *selScreen)
 	SEL->playerNames[connectionID] = playerName;
 
 	//put new player in first slot with AI
-	for(auto i = SEL->sInfo.playerInfos.begin(); i != SEL->sInfo.playerInfos.end(); i++)
+	for(auto & elem : SEL->sInfo.playerInfos)
 	{
-		if(!i->second.playerID)
+		if(!elem.second.playerID)
 		{
-			selScreen->setPlayer(i->second, connectionID);
-			selScreen->opt->entries[i->second.color]->selectButtons();
+			selScreen->setPlayer(elem.second, connectionID);
+			selScreen->opt->entries[elem.second.color]->selectButtons();
 			break;
 		}
 	}
@@ -4046,7 +4038,7 @@ CCampaignScreen::CCampaignScreen(const JsonNode &config)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
-	BOOST_FOREACH(const JsonNode& node, config["images"].Vector())
+	for(const JsonNode& node : config["images"].Vector())
 		images.push_back(createPicture(node));
 
 	if (!images.empty())
@@ -4063,7 +4055,7 @@ CCampaignScreen::CCampaignScreen(const JsonNode &config)
 		back->hoverable = true;
 	}
 
-	BOOST_FOREACH(const JsonNode& node, config["items"].Vector())
+	for(const JsonNode& node : config["items"].Vector())
 		campButtons.push_back(new CCampaignButton(node));
 }
 
@@ -4169,8 +4161,8 @@ CSimpleJoinScreen::CSimpleJoinScreen()
 	port->cb += std::bind(&CSimpleJoinScreen::onChange, this, _1);
 	port->filters.add(std::bind(&CTextInput::numberFilter, _1, _2, 0, 65535));
 
-	ok = new CAdventureMapButton(CGI->generaltexth->zelp[560], bind(&CSimpleJoinScreen::enterSelectionScreen, this), 26, 142, "MUBCHCK.DEF", SDLK_RETURN);
-	cancel = new CAdventureMapButton(CGI->generaltexth->zelp[561], bind(&CGuiHandler::popIntTotally, ref(GH), this), 142, 142, "MUBCANC.DEF", SDLK_ESCAPE);
+	ok = new CAdventureMapButton(CGI->generaltexth->zelp[560], std::bind(&CSimpleJoinScreen::enterSelectionScreen, this), 26, 142, "MUBCHCK.DEF", SDLK_RETURN);
+	cancel = new CAdventureMapButton(CGI->generaltexth->zelp[561], std::bind(&CGuiHandler::popIntTotally, std::ref(GH), this), 142, 142, "MUBCANC.DEF", SDLK_ESCAPE);
 	bar = new CGStatusBar(new CPicture(Rect(7, 186, 218, 18), 0));
 
 	port->setTxt(boost::lexical_cast<std::string>(settings["server"]["port"].Float()), true);

+ 2 - 2
client/CQuestLog.cpp

@@ -112,7 +112,7 @@ void CQuestMinimap::iconClicked()
 void CQuestMinimap::showAll(SDL_Surface * to)
 {
 	CIntObject::showAll(to); // blitting IntObject directly to hide radar
-	BOOST_FOREACH (auto pic, icons)
+	for (auto pic : icons)
 		pic->showAll(to);
 }
 
@@ -154,7 +154,7 @@ void CQuestLog::init()
 void CQuestLog::showAll(SDL_Surface * to)
 {
 	CIntObject::showAll (to);
-	BOOST_FOREACH (auto label, labels)
+	for (auto label : labels)
 	{
 		label->show(to); //shows only if active
 	}

+ 18 - 18
client/CSpellWindow.cpp

@@ -85,12 +85,12 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
 	}
 
 	//initializing sizes of spellbook's parts
-	for(int b=0; b<5; ++b)
-		sitesPerTabAdv[b] = 0;
-	for(int b=0; b<5; ++b)
-		sitesPerTabBattle[b] = 0;
+	for(auto & elem : sitesPerTabAdv)
+		elem = 0;
+	for(auto & elem : sitesPerTabBattle)
+		elem = 0;
 
-	BOOST_FOREACH(auto g, mySpells)
+	for(auto g : mySpells)
 	{
 		const CSpell &s = *CGI->spellh->spells[g];
 		Uint8 *sitesPerOurTab = s.combatSpell ? sitesPerTabBattle : sitesPerTabAdv;
@@ -222,8 +222,8 @@ CSpellWindow::~CSpellWindow()
 	delete spells;
 	delete spellTab;
 	delete schools;
-	for(int b=0; b<4; ++b)
-		delete schoolBorders[b];
+	for(auto & elem : schoolBorders)
+		delete elem;
 
 	delete exitBtn;
 	delete battleSpells;
@@ -240,9 +240,9 @@ CSpellWindow::~CSpellWindow()
 	delete lCorner;
 	delete rCorner;
 
-	for(int g=0; g<12; ++g)
+	for(auto & elem : spellAreas)
 	{
-		delete spellAreas[g];
+		delete elem;
 	}
 }
 
@@ -341,9 +341,9 @@ void CSpellWindow::showAll(SDL_Surface * to)
 	}
 
 	//printing spell info
-	for(int b=0; b<12; ++b)
+	for(auto & elem : spellAreas)
 	{
-		spellAreas[b]->showAll(to);
+		elem->showAll(to);
 	}
 }
 
@@ -473,9 +473,9 @@ void CSpellWindow::activate()
 	selectSpellsW->activate();
 	selectSpellsAll->activate();
 
-	for(int g=0; g<12; ++g)
+	for(auto & elem : spellAreas)
 	{
-		spellAreas[g]->activate();
+		elem->activate();
 	}
 
 	lCorner->activate();
@@ -496,9 +496,9 @@ void CSpellWindow::deactivate()
 	selectSpellsW->deactivate();
 	selectSpellsAll->deactivate();
 
-	for(int g=0; g<12; ++g)
+	for(auto & elem : spellAreas)
 	{
-		spellAreas[g]->deactivate();
+		elem->deactivate();
 	}
 
 	lCorner->deactivate();
@@ -640,7 +640,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 				{
 					std::string text = CGI->generaltexth->allTexts[538], summoner, elemental, caster;
 					std::vector<const CStack *> stacks = owner->myInt->cb->battleGetStacks();
-					BOOST_FOREACH(const CStack * s, stacks)
+					for(const CStack * s : stacks)
 					{
 						if(vstd::contains(s->state, EBattleStackState::SUMMONED))
 						{
@@ -755,9 +755,9 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 					}
 					else
 					{ //let the player choose
-						for(size_t i=0;i<Towns.size();i++)
+						for(auto & Town : Towns)
 						{
-							const CGTownInstance *t = Towns[i];
+							const CGTownInstance *t = Town;
 							if (t->visitingHero == nullptr) //empty town and this is
 							{
 								availableTowns.push_back(t->id.getNum());//add to the list

+ 16 - 18
client/Client.cpp

@@ -180,7 +180,7 @@ void CClient::save(const std::string & fname)
 void CClient::endGame( bool closeConnection /*= true*/ )
 {
 	//suggest interfaces to finish their stuff (AI should interrupt any bg working threads)
-	BOOST_FOREACH(auto i, playerint)
+	for(auto i : playerint)
 		i.second->finish();
 
 	// Game is ending
@@ -280,10 +280,9 @@ void CClient::loadGame( const std::string & fname )
         logNetwork->infoStream() << "Server opened savegame properly.";
 
 	*serv << ui32(gs->scenarioOps->playerInfos.size()+1); //number of players + neutral
-	for(auto it = gs->scenarioOps->playerInfos.begin(); 
-		it != gs->scenarioOps->playerInfos.end(); ++it)
+	for(auto & elem : gs->scenarioOps->playerInfos)
 	{
-		*serv << ui8(it->first.getNum()); //players
+		*serv << ui8(elem.first.getNum()); //players
 	}
 	*serv << ui8(PlayerColor::NEUTRAL.getNum());
     logNetwork->infoStream() <<"Sent info to server: "<<tmh.getDiff();
@@ -342,13 +341,13 @@ void CClient::newGame( CConnection *con, StartInfo *si )
 	// Now after possible random map gen, we know exact player count.
 	// Inform server about how many players client handles
 	std::set<PlayerColor> myPlayers;
-	for(auto it = gs->scenarioOps->playerInfos.begin(); it != gs->scenarioOps->playerInfos.end(); ++it)
+	for(auto & elem : gs->scenarioOps->playerInfos)
 	{
 		if((networkMode == SINGLE)                                                      //single - one client has all player
-		   || (networkMode != SINGLE && serv->connectionID == it->second.playerID)      //multi - client has only "its players"
-		   || (networkMode == HOST && it->second.playerID == PlayerSettings::PLAYER_AI))//multi - host has all AI players
+		   || (networkMode != SINGLE && serv->connectionID == elem.second.playerID)      //multi - client has only "its players"
+		   || (networkMode == HOST && elem.second.playerID == PlayerSettings::PLAYER_AI))//multi - host has all AI players
 		{
-			myPlayers.insert(it->first); //add player
+			myPlayers.insert(elem.first); //add player
 		}
 	}
 	if(networkMode != GUEST)
@@ -367,10 +366,9 @@ void CClient::newGame( CConnection *con, StartInfo *si )
 	}
 
 	int humanPlayers = 0;
-	for(auto it = gs->scenarioOps->playerInfos.begin(); 
-		it != gs->scenarioOps->playerInfos.end(); ++it)//initializing interfaces for players
+	for(auto & elem : gs->scenarioOps->playerInfos)//initializing interfaces for players
 	{
-		PlayerColor color = it->first;
+		PlayerColor color = elem.first;
 		gs->currentPlayer = color;
 		if(!vstd::contains(myPlayers, color))
 			continue;
@@ -378,9 +376,9 @@ void CClient::newGame( CConnection *con, StartInfo *si )
         logNetwork->traceStream() << "Preparing interface for player " << color;
 		if(si->mode != StartInfo::DUEL)
 		{
-			if(it->second.playerID == PlayerSettings::PLAYER_AI)
+			if(elem.second.playerID == PlayerSettings::PLAYER_AI)
 			{
-				auto AiToGive = aiNameForPlayer(it->second, false);
+				auto AiToGive = aiNameForPlayer(elem.second, false);
 				logNetwork->infoStream() << boost::format("Player %s will be lead by %s") % color % AiToGive;
 				installNewPlayerInterface(CDynLibHandler::getNewAI(AiToGive), color);
 			}
@@ -392,7 +390,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
 		}
 		else
 		{
-			std::string AItoGive = aiNameForPlayer(it->second, true);
+			std::string AItoGive = aiNameForPlayer(elem.second, true);
 			installNewBattleInterface(CDynLibHandler::getNewBattleAI(AItoGive), color);
 		}
 	}
@@ -419,7 +417,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
 
 // 	std::vector<FileInfo> scriptModules;
 // 	CFileUtility::getFilesWithExt(scriptModules, LIB_DIR "/scripting", "." LIB_EXT);
-// 	BOOST_FOREACH(FileInfo &m, scriptModules)
+// 	for(FileInfo &m : scriptModules)
 // 	{
 // 		CScriptingModule * nm = CDynLibHandler::getNewScriptingModule(m.name);
 // 		privilagedGameEventReceivers.push_back(nm);
@@ -570,12 +568,12 @@ void CClient::stopConnection()
 
 void CClient::battleStarted(const BattleInfo * info)
 {
-	BOOST_FOREACH(auto &battleCb, battleCallbacks)
+	for(auto &battleCb : battleCallbacks)
 	{
 		if(vstd::contains(info->sides, battleCb.first)  ||  battleCb.first >= PlayerColor::PLAYER_LIMIT)
 			battleCb.second->setBattle(info);
 	}
-// 	BOOST_FOREACH(ui8 side, info->sides)
+// 	for(ui8 side : info->sides)
 // 		if(battleCallbacks.count(side))
 // 			battleCallbacks[side]->setBattle(info);
 
@@ -614,7 +612,7 @@ void CClient::battleStarted(const BattleInfo * info)
 
 void CClient::battleFinished()
 {
-	BOOST_FOREACH(PlayerColor side, gs->curB->sides)
+	for(PlayerColor side : gs->curB->sides)
 		if(battleCallbacks.count(side))
 			battleCallbacks[side]->setBattle(nullptr);
 }

+ 123 - 123
client/GUIClasses.cpp

@@ -80,7 +80,7 @@ void CArmyTooltip::init(const InfoAboutArmy &army)
 	slotsPos.push_back(Point(90,122));
 	slotsPos.push_back(Point(126,122));
 
-	BOOST_FOREACH(auto & slot, army.army)
+	for(auto & slot : army.army)
 	{
 		if(slot.first.getNum() >= GameConstants::ARMY_SIZE)
 		{
@@ -327,8 +327,8 @@ void CGarrisonSlot::clickLeft(tribool down, bool previousState)
 				owner->selectSlot(nullptr);
 				owner->setSplittingMode(false);
 
-				for(size_t i = 0; i<owner->splitButtons.size(); i++)
-					owner->splitButtons[i]->block(true);
+				for(auto & elem : owner->splitButtons)
+					elem->block(true);
 
 				redraw();
 				refr = true;
@@ -430,8 +430,8 @@ void CGarrisonSlot::clickLeft(tribool down, bool previousState)
 				owner->selectSlot(this);
 				if(creature)
 				{
-					for(size_t i = 0; i<owner->splitButtons.size(); i++)
-						owner->splitButtons[i]->block(false);
+					for(auto & elem : owner->splitButtons)
+						elem->block(false);
 				}
 			}
 			redraw();
@@ -525,9 +525,9 @@ void CGarrisonInt::createSet(std::vector<CGarrisonSlot*> &ret, const CCreatureSe
 
 	if (set)
 	{
-		for(TSlots::const_iterator i=set->Slots().begin(); i!=set->Slots().end(); i++)
+		for(auto & elem : set->Slots())
 		{
-			ret[i->first.getNum()] = new CGarrisonSlot(this, posX + (i->first.getNum()*distance), posY, i->first, Upg, i->second);
+			ret[elem.first.getNum()] = new CGarrisonSlot(this, posX + (elem.first.getNum()*distance), posY, elem.first, Upg, elem.second);
 		}
 	}
 
@@ -558,14 +558,14 @@ void CGarrisonInt::recreateSlots()
 	selectSlot(nullptr);
 	setSplittingMode(false);
 
-	for(size_t i = 0; i<splitButtons.size(); i++)
-		splitButtons[i]->block(true);
+	for(auto & elem : splitButtons)
+		elem->block(true);
 
 
-	BOOST_FOREACH(CGarrisonSlot * slot, slotsUp)
+	for(CGarrisonSlot * slot : slotsUp)
 		slot->update();
 
-	BOOST_FOREACH(CGarrisonSlot * slot, slotsDown)
+	for(CGarrisonSlot * slot : slotsDown)
 		slot->update();
 }
 
@@ -613,7 +613,7 @@ void CGarrisonInt::selectSlot(CGarrisonSlot *slot)
 			highlighted->setHighlight(false);
 
 		highlighted = slot;
-		BOOST_FOREACH (auto button, splitButtons)
+		for (auto button : splitButtons)
 			button->block(highlighted == nullptr);
 
 		if (highlighted)
@@ -627,10 +627,10 @@ void CGarrisonInt::setSplittingMode(bool on)
 
 	if (inSplittingMode || on)
 	{
-		BOOST_FOREACH(CGarrisonSlot * slot, slotsUp)
+		for(CGarrisonSlot * slot : slotsUp)
 			slot->setHighlight( ( on && (slot->creature == nullptr || slot->creature == getSelection()->creature)));
 
-		BOOST_FOREACH(CGarrisonSlot * slot, slotsDown)
+		for(CGarrisonSlot * slot : slotsDown)
 			slot->setHighlight( ( on && (slot->creature == nullptr || slot->creature == getSelection()->creature)));
 		inSplittingMode = on;
 	}
@@ -653,12 +653,12 @@ CInfoWindow::CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo
 
 	type |= BLOCK_ADV_HOTKEYS;
 	ID = QueryID(-1);
-	for(int i=0;i<Buttons.size();i++)
+	for(auto & Button : Buttons)
 	{
-		CAdventureMapButton *button = new CAdventureMapButton("","",std::bind(&CInfoWindow::close,this),0,0,Buttons[i].first);
+		CAdventureMapButton *button = new CAdventureMapButton("","",std::bind(&CInfoWindow::close,this),0,0,Button.first);
 		button->borderColor = Colors::METALLIC_GOLD;
 		button->borderEnabled = true;
-		button->callback.add(Buttons[i].second); //each button will close the window apart from call-defined actions
+		button->callback.add(Button.second); //each button will close the window apart from call-defined actions
 		buttons.push_back(button);
 	}
 
@@ -675,12 +675,12 @@ CInfoWindow::CInfoWindow(std::string Text, PlayerColor player, const TCompsInfo
 		buttons.back()->assignedKeys.insert(SDLK_ESCAPE); //last button - reacts on escape
 	}
 
-	for(int i=0;i<comps.size();i++)
+	for(auto & comp : comps)
 	{
-		comps[i]->recActions = 0xff;
-		addChild(comps[i]);
-		comps[i]->recActions &= ~(SHOWALL | UPDATE);
-		components.push_back(comps[i]);
+		comp->recActions = 0xff;
+		addChild(comp);
+		comp->recActions &= ~(SHOWALL | UPDATE);
+		components.push_back(comp);
 	}
 	setDelComps(delComps);
 	CMessage::drawIWindow(this,Text,player);
@@ -709,8 +709,8 @@ CInfoWindow::~CInfoWindow()
 {
 	if(!delComps)
 	{
-		for (int i=0;i<components.size();i++)
-			removeChild(components[i]);
+		for (auto & elem : components)
+			removeChild(elem);
 	}
 }
 
@@ -727,10 +727,10 @@ void CInfoWindow::showYesNoDialog(const std::string & text, const std::vector<CC
 	pom.push_back(std::pair<std::string,CFunctionList<void()> >("IOKAY.DEF",0));
 	pom.push_back(std::pair<std::string,CFunctionList<void()> >("ICANCEL.DEF",0));
 	CInfoWindow * temp = new CInfoWindow(text, player, components ? *components : std::vector<CComponent*>(), pom, DelComps);
-	for(int i=0;i<onYes.funcs.size();i++)
-		temp->buttons[0]->callback += onYes.funcs[i];
-	for(int i=0;i<onNo.funcs.size();i++)
-		temp->buttons[1]->callback += onNo.funcs[i];
+	for(auto & elem : onYes.funcs)
+		temp->buttons[0]->callback += elem;
+	for(auto & elem : onNo.funcs)
+		temp->buttons[1]->callback += elem;
 
 	GH.pushInt(temp);
 }
@@ -751,7 +751,7 @@ std::string CInfoWindow::genText(std::string title, std::string description)
 void CInfoWindow::setDelComps(bool DelComps)
 {
 	delComps = DelComps;
-	BOOST_FOREACH(CComponent *comp, components)
+	for(CComponent *comp : components)
 	{
 		if(delComps)
 			comp->recActions |= DISPOSE;
@@ -877,10 +877,10 @@ void CComponent::init(Etype Type, int Subtype, int Val, ESize imageSize)
 	pos.h += 4; //distance between text and image
 
 	std::vector<std::string> textLines = CMessage::breakText(getSubtitle(), std::max<int>(80, pos.w), font);
-	BOOST_FOREACH(auto & line, textLines)
+	for(auto & line : textLines)
 	{
 		int height = graphics->fonts[font]->getLineHeight();
-		CLabel * label = new CLabel(pos.w/2, pos.h + height/2, font, CENTER, Colors::WHITE, line);
+		auto   label = new CLabel(pos.w/2, pos.h + height/2, font, CENTER, Colors::WHITE, line);
 
 		pos.h += height;
 		if (label->pos.w > pos.w)
@@ -1117,7 +1117,7 @@ void CComponentBox::placeComponents(bool selectable)
 		return;
 
 	//prepare components
-	BOOST_FOREACH(auto & comp, components)
+	for(auto & comp : components)
 	{
 		addChild(comp);
 		comp->moveTo(Point(pos.x, pos.y));
@@ -1137,7 +1137,7 @@ void CComponentBox::placeComponents(bool selectable)
 	//split components in rows
 	CComponent * prevComp = nullptr;
 
-	BOOST_FOREACH(CComponent * comp, components)
+	for(CComponent * comp : components)
 	{
 		//make sure that components are smaller than our width
 		//assert(pos.w == 0 || pos.w < comp->pos.w);
@@ -1164,12 +1164,12 @@ void CComponentBox::placeComponents(bool selectable)
 
 	if (pos.w == 0)
 	{
-		BOOST_FOREACH(auto & row, rows)
+		for(auto & row : rows)
 			vstd::amax(pos.w, row.width);
 	}
 
 	int height = (rows.size() - 1) * betweenRows;
-	BOOST_FOREACH(auto & row, rows)
+	for(auto & row : rows)
 		height += row.height;
 
 	//assert(pos.h == 0 || pos.h < height);
@@ -1180,14 +1180,14 @@ void CComponentBox::placeComponents(bool selectable)
 	int currentY = (pos.h - height) / 2;
 
 	//move components to their positions
-	for (size_t row = 0; row < rows.size(); row++)
+	for (auto & rows_row : rows)
 	{
 		// amount of free space we may add on each side of every component
-		int freeSpace = (pos.w - rows[row].width) / (rows[row].comps * 2);
+		int freeSpace = (pos.w - rows_row.width) / (rows_row.comps * 2);
 		prevComp = nullptr;
 
 		int currentX = 0;
-		for (size_t col = 0; col < rows[row].comps; col++)
+		for (size_t col = 0; col < rows_row.comps; col++)
 		{
 			currentX += freeSpace;
 			if (prevComp)
@@ -1207,7 +1207,7 @@ void CComponentBox::placeComponents(bool selectable)
 
 			prevComp = *(iter++);
 		}
-		currentY += rows[row].height + betweenRows;
+		currentY += rows_row.height + betweenRows;
 	}
 }
 
@@ -1241,7 +1241,7 @@ CComponentBox::CComponentBox(std::vector<CSelectableComponent *> _components, Re
 	assert(!components.empty());
 
 	int key = SDLK_1;
-	BOOST_FOREACH(auto & comp, _components)
+	for(auto & comp : _components)
 	{
 		comp->onSelect = std::bind(&CComponentBox::selectionChanged, this, comp);
 		comp->assignedKeys.insert(key++);
@@ -1383,7 +1383,7 @@ CRecruitmentWindow::CCostBox::CCostBox(Rect position, std::string title)
 void CRecruitmentWindow::CCostBox::set(TResources res)
 {
 	//just update values
-	BOOST_FOREACH(auto & item, resources)
+	for(auto & item : resources)
 	{
 		item.second.first->setTxt(boost::lexical_cast<std::string>(res[item.first]));
 	}
@@ -1393,7 +1393,7 @@ void CRecruitmentWindow::CCostBox::createItems(TResources res)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
-	BOOST_FOREACH(auto & curr, resources)
+	for(auto & curr : resources)
 	{
 		delete curr.second.first;
 		delete curr.second.second;
@@ -1414,7 +1414,7 @@ void CRecruitmentWindow::CCostBox::createItems(TResources res)
 	{
 		int curx = pos.w / 2 - (16 * resources.size()) - (8 * (resources.size() - 1));
 		//reverse to display gold as first resource
-		BOOST_REVERSE_FOREACH(auto & res, resources)
+		for (auto & res : boost::adaptors::reverse(resources))
 		{
 			res.second.first->moveBy(Point(curx, 22));
 			res.second.second->moveBy(Point(curx, 22));
@@ -1522,7 +1522,7 @@ CRecruitmentWindow::CRecruitmentWindow(const CGDwelling *Dwelling, int Level, co
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	new CGStatusBar(new CPicture(*background, Rect(8, pos.h - 26, pos.w - 16, 19), 8, pos.h - 26));
 
-	slider = new CSlider(176,279,135,0,0,0,0,true);
+	slider = new CSlider(176,279,135,nullptr,0,0,0,true);
 	slider->moved = std::bind(&CRecruitmentWindow::sliderMoved,this, _1);
 
 	maxButton = new CAdventureMapButton(CGI->generaltexth->zelp[553],std::bind(&CSlider::moveToMax,slider),134,313,"IRCBTNS.DEF",SDLK_m);
@@ -1555,7 +1555,7 @@ void CRecruitmentWindow::availableCreaturesChanged()
 	select(nullptr);
 
 	//delete old cards
-	BOOST_FOREACH(auto & card, cards)
+	for(auto & card : cards)
 		delete card;
 	cards.clear();
 
@@ -1568,7 +1568,7 @@ void CRecruitmentWindow::availableCreaturesChanged()
 		int amount = dwelling->creatures[i].first;
 
 		//create new cards
-		BOOST_REVERSE_FOREACH(auto & creature, dwelling->creatures[i].second)
+		for(auto & creature : boost::adaptors::reverse(dwelling->creatures[i].second))
 			cards.push_back(new CCreatureCard(this, CGI->creh->creatures[creature], amount));
 	}
 
@@ -1593,7 +1593,7 @@ void CRecruitmentWindow::availableCreaturesChanged()
 
 	//now we know total amount of cards and can move them to correct position
 	int curx = pos.w / 2 - (creatureWidth*cards.size()/2) - (spaceBetween*(cards.size()-1)/2);
-	BOOST_FOREACH(auto & card, cards)
+	for(auto & card : cards)
 	{
 		card->moveBy(Point(curx, 64));
 		curx += totalCreatureWidth;
@@ -1722,12 +1722,12 @@ CLevelWindow::CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkil
 	{
 		std::vector<CSelectableComponent *> comps;
 
-		for(size_t i=0;i<skills.size();i++)
+		for(auto & skill : skills)
 		{
 			comps.push_back(new CSelectableComponent(
 								CComponent::secskill,
-								skills[i],
-								hero->getSecSkillLevel( SecondarySkill(skills[i]) )+1,
+								skill,
+								hero->getSecSkillLevel( SecondarySkill(skill) )+1,
 								CComponent::medium));
 		}
 		box = new CComponentBox(comps, Rect(75, 300, pos.w - 150, 100));
@@ -1820,7 +1820,7 @@ CObjectListWindow::CObjectListWindow(const std::vector<int> &_items, CPicture *
 	onSelect(Callback)
 {
 	items.reserve(_items.size());
-	BOOST_FOREACH(int id, _items)
+	for(int id : _items)
 	{
 		items.push_back(std::make_pair(id, CGI->mh->map->objects[id]->hoverName));
 	}
@@ -1887,7 +1887,7 @@ void CObjectListWindow::changeSelection(size_t which)
 		return;
 
 	std::list< CIntObject * > elements = list->getItems();
-	BOOST_FOREACH(CIntObject * element, elements)
+	for(CIntObject * element : elements)
 	{
 		CItem *item;
 		if ( (item = dynamic_cast<CItem*>(element)) )
@@ -2277,7 +2277,7 @@ void CTradeWindow::initItems(bool Left)
 			xOffset = -361;
 			yOffset = +46;
 
-			CTradeableItem *hlp = new CTradeableItem(Point(137, 469), itemsType[Left], -1, 1, 0);
+			auto  hlp = new CTradeableItem(Point(137, 469), itemsType[Left], -1, 1, 0);
 			hlp->recActions &= ~(UPDATE | SHOWALL);
 			items[Left].push_back(hlp);
 		}
@@ -2322,7 +2322,7 @@ void CTradeWindow::initItems(bool Left)
 		if(id < 0 && mode != EMarketMode::ARTIFACT_EXP)  //when sacrificing artifacts we need to prepare empty slots
 			continue;
 
-		CTradeableItem *hlp = new CTradeableItem(pos[j].topLeft(), itemsType[Left], id, Left, j);
+		auto  hlp = new CTradeableItem(pos[j].topLeft(), itemsType[Left], id, Left, j);
 		hlp->pos = pos[j] + this->pos.topLeft();
 		items[Left].push_back(hlp);
 	}
@@ -2407,7 +2407,7 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType typ
 
 		if(!Left)
 		{
-			BOOST_FOREACH(Rect &r, poss)
+			for(Rect &r : poss)
 				r.x += leftToRightOffset;
 		}
 	}
@@ -2415,7 +2415,7 @@ void CTradeWindow::getPositionsFor(std::vector<Rect> &poss, bool Left, EType typ
 
 void CTradeWindow::initSubs(bool Left)
 {
-	BOOST_FOREACH(CTradeableItem *t, items[Left])
+	for(CTradeableItem *t : items[Left])
 	{
 		if(Left)
 		{
@@ -2474,7 +2474,7 @@ void CTradeWindow::showAll(SDL_Surface * to)
 
 void CTradeWindow::removeItems(const std::set<CTradeableItem *> &toRemove)
 {
-	BOOST_FOREACH(CTradeableItem *t, toRemove)
+	for(CTradeableItem *t : toRemove)
 		removeItem(t);
 }
 
@@ -2492,7 +2492,7 @@ void CTradeWindow::removeItem(CTradeableItem * t)
 
 void CTradeWindow::getEmptySlots(std::set<CTradeableItem *> &toRemove)
 {
-	BOOST_FOREACH(CTradeableItem *t, items[1])
+	for(CTradeableItem *t : items[1])
 		if(!hero->getStackCount(SlotID(t->serial)))
 			toRemove.insert(t);
 }
@@ -2604,7 +2604,7 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan
 
 	if(sliderNeeded)
 	{
-		slider = new CSlider(231,490,137,0,0,0);
+		slider = new CSlider(231,490,137,nullptr,0,0);
 		slider->moved = std::bind(&CMarketplaceWindow::sliderMoved,this,_1);
 		max = new CAdventureMapButton(CGI->generaltexth->zelp[596],std::bind(&CMarketplaceWindow::setMax,this),229,520,"IRCBTNS.DEF");
 		max->block(true);
@@ -2675,10 +2675,10 @@ CMarketplaceWindow::CMarketplaceWindow(const IMarket *Market, const CGHeroInstan
 CMarketplaceWindow::~CMarketplaceWindow()
 {
 	hLeft = hRight = nullptr;
-	for(int i=0;i<items[1].size();i++)
-		delete items[1][i];
-	for(int i=0;i<items[0].size();i++)
-		delete items[0][i];
+	for(auto & elem : items[1])
+		delete elem;
+	for(auto & elem : items[0])
+		delete elem;
 
 	items[1].clear();
 	items[0].clear();
@@ -2817,7 +2817,7 @@ void CMarketplaceWindow::artifactsChanged(bool Left)
 
 	std::vector<int> available = market->availableItemsIds(mode);
 	std::set<CTradeableItem *> toRemove;
-	BOOST_FOREACH(CTradeableItem *t, items[0])
+	for(CTradeableItem *t : items[0])
 		if(!vstd::contains(available, t->id))
 			toRemove.insert(t);
 
@@ -3011,7 +3011,7 @@ CAltarWindow::CAltarWindow(const IMarket *Market, const CGHeroInstance *Hero /*=
 		 //To sacrifice creatures, move them from your army on to the Altar and click Sacrifice
 		new CTextBox(CGI->generaltexth->allTexts[480], Rect(320, 56, 256, 40), 0, FONT_SMALL, CENTER, Colors::YELLOW);
 
-		slider = new CSlider(231,481,137,0,0,0);
+		slider = new CSlider(231,481,137,nullptr,0,0);
 		slider->moved = std::bind(&CAltarWindow::sliderMoved,this,_1);
 		max = new CAdventureMapButton(CGI->generaltexth->zelp[578],std::bind(&CSlider::moveToMax, slider),147,520,"IRCBTNS.DEF");
 
@@ -3111,10 +3111,10 @@ void CAltarWindow::makeDeal()
 				LOCPLINT->cb->trade(market->o, mode, i, 0, toSacrifice[i], hero);
 		}
 
-		BOOST_FOREACH(int& val, sacrificedUnits)
+		for(int& val : sacrificedUnits)
 			val = 0;
 
-		BOOST_FOREACH(CTradeableItem *t, items[0])
+		for(CTradeableItem *t : items[0])
 		{
 			t->setType(CREATURE_PLACEHOLDER);
 			t->subtitle = "";
@@ -3122,13 +3122,13 @@ void CAltarWindow::makeDeal()
 	}
 	else
 	{
-		BOOST_FOREACH(const CArtifactInstance *art, arts->artifactsOnAltar) //sacrifice each artifact on the list
+		for(const CArtifactInstance *art : arts->artifactsOnAltar) //sacrifice each artifact on the list
 		{
 			LOCPLINT->cb->trade(market->o, mode, hero->getArtPos(art), -1, 1, hero);
 		}
 		arts->artifactsOnAltar.clear();
 
-		BOOST_FOREACH(CTradeableItem *t, items[0])
+		for(CTradeableItem *t : items[0])
 		{
 			t->setID(-1);
 			t->subtitle = "";
@@ -3147,12 +3147,12 @@ void CAltarWindow::SacrificeAll()
 	if(mode == EMarketMode::CREATURE_EXP)
 	{
 		bool movedAnything = false;
-		BOOST_FOREACH(CTradeableItem *t, items[1])
+		for(CTradeableItem *t : items[1])
 			sacrificedUnits[t->serial] = hero->getStackCount(SlotID(t->serial));
 
 		sacrificedUnits[items[1].front()->serial]--;
 
-		BOOST_FOREACH(CTradeableItem *t, items[0])
+		for(CTradeableItem *t : items[0])
 		{
 			updateRight(t);
 			if(t->type == CREATURE)
@@ -3206,9 +3206,9 @@ void CAltarWindow::mimicCres()
 	std::vector<Rect> positions;
 	getPositionsFor(positions, false, CREATURE);
 
-	BOOST_FOREACH(CTradeableItem *t, items[1])
+	for(CTradeableItem *t : items[1])
 	{
-		CTradeableItem *hlp = new CTradeableItem(positions[t->serial].topLeft(), CREATURE_PLACEHOLDER, t->id, false, t->serial);
+		auto  hlp = new CTradeableItem(positions[t->serial].topLeft(), CREATURE_PLACEHOLDER, t->id, false, t->serial);
 		hlp->pos = positions[t->serial] + this->pos.topLeft();
 		items[0].push_back(hlp);
 	}
@@ -3245,7 +3245,7 @@ void CAltarWindow::garrisonChanged()
 	std::set<CTradeableItem *> empty;
 	getEmptySlots(empty);
 
-	BOOST_FOREACH(CTradeableItem *t, empty)
+	for(CTradeableItem *t : empty)
 	{
 		removeItem(*std::find_if(items[0].begin(), items[0].end(), [&](const CTradeableItem * item)
 		{
@@ -3260,7 +3260,7 @@ void CAltarWindow::garrisonChanged()
 void CAltarWindow::getExpValues()
 {
 	int dump;
-	BOOST_FOREACH(CTradeableItem *t, items[1])
+	for(CTradeableItem *t : items[1])
 		if(t->id >= 0)
 			market->getOffer(t->id, 0, dump, expPerUnit[t->serial], EMarketMode::CREATURE_EXP);
 }
@@ -3277,7 +3277,7 @@ void CAltarWindow::calcTotalExp()
 	}
 	else
 	{
-		BOOST_FOREACH(const CArtifactInstance *art, arts->artifactsOnAltar)
+		for(const CArtifactInstance *art : arts->artifactsOnAltar)
 		{
 			int dmp, valOfArt;
 			market->getOffer(art->artType->id, 0, dmp, valOfArt, mode);
@@ -3323,16 +3323,16 @@ void CAltarWindow::SacrificeBackpack()
 {
 	std::multiset<const CArtifactInstance *> toOmmit = arts->artifactsOnAltar;
 
-	for (int i = 0; i < hero->artifactsInBackpack.size(); i++)
+	for (auto & elem : hero->artifactsInBackpack)
 	{
 
-		if(vstd::contains(toOmmit, hero->artifactsInBackpack[i].artifact))
+		if(vstd::contains(toOmmit, elem.artifact))
 		{
-			toOmmit -= hero->artifactsInBackpack[i].artifact;
+			toOmmit -= elem.artifact;
 			continue;
 		}
 
-		putOnAltar(nullptr, hero->artifactsInBackpack[i].artifact);
+		putOnAltar(nullptr, elem.artifact);
 	}
 
 	arts->scrollBackpack(0);
@@ -3570,7 +3570,7 @@ void CSystemOptionsWindow::selectGameRes()
 
 	std::vector<std::string> items;
 
-	BOOST_FOREACH( config::CConfigHandler::GuiOptionsMap::value_type& value, conf.guiOptions)
+	for( config::CConfigHandler::GuiOptionsMap::value_type& value : conf.guiOptions)
 	{
 		std::string resX = boost::lexical_cast<std::string>(value.first.first);
 		std::string resY = boost::lexical_cast<std::string>(value.first.second);
@@ -3814,7 +3814,7 @@ void CInGameConsole::show(SDL_Surface * to)
 	std::vector<std::list< std::pair< std::string, int > >::iterator> toDel;
 
 	boost::unique_lock<boost::mutex> lock(texts_mx);
-	for(std::list< std::pair< std::string, int > >::iterator it = texts.begin(); it != texts.end(); ++it, ++number)
+	for(auto it = texts.begin(); it != texts.end(); ++it, ++number)
 	{
 		Point leftBottomCorner(0, screen->h);
 		if(LOCPLINT->battleInt)
@@ -3830,9 +3830,9 @@ void CInGameConsole::show(SDL_Surface * to)
 		}
 	}
 
-	for(int it=0; it<toDel.size(); ++it)
+	for(auto & elem : toDel)
 	{
-		texts.erase(toDel[it]);
+		texts.erase(elem);
 	}
 }
 
@@ -4157,7 +4157,7 @@ void CArtPlace::clickLeft(tribool down, bool previousState)
 	{
 		if(ourArt->artType->id == 0)
 		{
-			CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), ourOwner->curHero, LOCPLINT, LOCPLINT->battleInt);
+			auto   spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), ourOwner->curHero, LOCPLINT, LOCPLINT->battleInt);
 			GH.pushInt(spellWindow);
 		}
 	}
@@ -4258,7 +4258,7 @@ void CArtPlace::clickRight(tribool down, bool previousState)
 				std::vector<const CArtifact *> assemblyPossibilities = ourArt->assemblyPossibilities(ourOwner->curHero);
 
 				// If the artifact can be assembled, display dialog.
-				BOOST_FOREACH(const CArtifact *combination, assemblyPossibilities)
+				for(const CArtifact *combination : assemblyPossibilities)
 				{
 					LOCPLINT->showArtifactAssemblyDialog(
 						ourArt->artType->id,
@@ -4668,11 +4668,11 @@ void CArtifactsOfHero::scrollBackpack(int dir)
 	//in artifact merchant selling artifacts we may have highlight on one of backpack artifacts -> market needs update, cause artifact under highlight changed
 	if(highlightModeCallback)
 	{
-		for(int i = 0; i < backpack.size(); i++)
+		for(auto & elem : backpack)
 		{
-			if(backpack[i]->marked)
+			if(elem->marked)
 			{
-				highlightModeCallback(backpack[i]);
+				highlightModeCallback(elem);
 				break;
 			}
 		}
@@ -4694,8 +4694,8 @@ void CArtifactsOfHero::scrollBackpack(int dir)
  */
 void CArtifactsOfHero::markPossibleSlots(const CArtifactInstance* art)
 {
-	BOOST_FOREACH(CArtifactsOfHero *aoh, commonInfo->participants)
-		BOOST_FOREACH(CArtPlace *place, aoh->artWorn)
+	for(CArtifactsOfHero *aoh : commonInfo->participants)
+		for(CArtPlace *place : aoh->artWorn)
 			place->selectSlot(art->canBePutAt(ArtifactLocation(aoh->curHero, place->slotID), true));
 
 	safeRedraw();
@@ -4707,7 +4707,7 @@ void CArtifactsOfHero::markPossibleSlots(const CArtifactInstance* art)
 void CArtifactsOfHero::unmarkSlots(bool withRedraw /*= true*/)
 {
 	if(commonInfo)
-		BOOST_FOREACH(CArtifactsOfHero *aoh, commonInfo->participants)
+		for(CArtifactsOfHero *aoh : commonInfo->participants)
 			aoh->unmarkLocalSlots(false);
 	else
 		unmarkLocalSlots(false);\
@@ -4718,9 +4718,9 @@ void CArtifactsOfHero::unmarkSlots(bool withRedraw /*= true*/)
 
 void CArtifactsOfHero::unmarkLocalSlots(bool withRedraw /*= true*/)
 {
-	BOOST_FOREACH(CArtPlace *place, artWorn)
+	for(CArtPlace *place : artWorn)
 		place->selectSlot(false);
-	BOOST_FOREACH(CArtPlace *place, backpack)
+	for(CArtPlace *place : backpack)
 		place->selectSlot(false);
 
 	if(withRedraw)
@@ -4766,7 +4766,7 @@ CArtifactsOfHero::CArtifactsOfHero(std::vector<CArtPlace *> ArtWorn, std::vector
 	artWorn(ArtWorn), backpack(Backpack),
 	backpackPos(0), commonInfo(nullptr), updateState(false),
 	leftArtRoll(leftScroll), rightArtRoll(rightScroll),
-	allowedAssembling(true), highlightModeCallback(0)
+	allowedAssembling(true), highlightModeCallback(nullptr)
 {
 	if(createCommonPart)
 	{
@@ -4793,7 +4793,7 @@ 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(0)
+ : curHero(nullptr), backpackPos(0), commonInfo(nullptr), updateState(false), allowedAssembling(true), highlightModeCallback(nullptr)
 {
 	if(createCommonPart)
 	{
@@ -4825,7 +4825,7 @@ CArtifactsOfHero::CArtifactsOfHero(const Point& position, bool createCommonPart
 	// Create slots for the backpack.
 	for(size_t s=0; s<5; ++s)
 	{
-		CArtPlace * add = new CArtPlace(Point(403 + 46 * s, 365));
+		auto   add = new CArtPlace(Point(403 + 46 * s, 365));
 
 		add->ourOwner = this;
 		eraseSlotData(add, ArtifactPosition(GameConstants::BACKPACK_START + s));
@@ -4926,7 +4926,7 @@ void CArtifactsOfHero::artifactMoved(const ArtifactLocation &src, const Artifact
 		commonInfo->reset();
 
 		CArtPlace *ap = nullptr;
-		BOOST_FOREACH(CArtifactsOfHero *aoh, commonInfo->participants)
+		for(CArtifactsOfHero *aoh : commonInfo->participants)
 		{
 			if(dst.isHolder(aoh->curHero))
 			{
@@ -4998,7 +4998,7 @@ CArtPlace * CArtifactsOfHero::getArtPlace(int slot)
 	}
 	else
 	{
-		BOOST_FOREACH(CArtPlace *ap, backpack)
+		for(CArtPlace *ap : backpack)
 			if(ap->slotID == slot)
 				return ap;
 	}
@@ -5265,11 +5265,11 @@ CPuzzleWindow::CPuzzleWindow(const int3 &GrailPos, double discoveredRatio):
 
 	auto & puzzleMap = CGI->townh->factions[faction]->puzzleMap;
 
-	for(int g=0; g<puzzleMap.size(); ++g)
+	for(auto & elem : puzzleMap)
 	{
-		const SPuzzleInfo & info = puzzleMap[g];
+		const SPuzzleInfo & info = elem;
 
-		auto piece = new CPicture(info.filename, info.x, info.y);
+		auto   piece = new CPicture(info.filename, info.x, info.y);
 
 		//piece that will slowly disappear
 		if(info.whenUncovered <= GameConstants::PUZZLE_MAP_PIECES * discoveredRatio)
@@ -5301,14 +5301,14 @@ void CPuzzleWindow::show(SDL_Surface * to)
 	if (currentAlpha < animSpeed)
 	{
 		//animation done
-		BOOST_FOREACH(auto & piece, piecesToRemove)
+		for(auto & piece : piecesToRemove)
 			delete piece;
 		piecesToRemove.clear();
 	}
 	else
 	{
 		//update disappearing puzzles
-		BOOST_FOREACH(auto & piece, piecesToRemove)
+		for(auto & piece : piecesToRemove)
 			piece->setAlpha(currentAlpha);
 		currentAlpha -= animSpeed;
 	}
@@ -5355,22 +5355,22 @@ CTransformerWindow::CItem::CItem(CTransformerWindow * parent, int size, int id):
 
 void CTransformerWindow::makeDeal()
 {
-	for (int i=0; i<items.size(); i++)
-		if (!items[i]->left)
-			LOCPLINT->cb->trade(town, EMarketMode::CREATURE_UNDEAD, items[i]->id, 0, 0, hero);
+	for (auto & elem : items)
+		if (!elem->left)
+			LOCPLINT->cb->trade(town, EMarketMode::CREATURE_UNDEAD, elem->id, 0, 0, hero);
 }
 
 void CTransformerWindow::addAll()
 {
-	for (int i=0; i<items.size(); i++)
-		if (items[i]->left)
-			items[i]->move();
+	for (auto & elem : items)
+		if (elem->left)
+			elem->move();
 	showAll(screen2);
 }
 
 void CTransformerWindow::updateGarrisons()
 {
-	BOOST_FOREACH(auto & item, items)
+	for(auto & item : items)
 	{
 		item->update();
 	}
@@ -5409,7 +5409,7 @@ void CUniversityWindow::CItem::clickLeft(tribool down, bool previousState)
 	{
 		if ( state() != 2 )
 			return;
-		CUnivConfirmWindow *win = new CUnivConfirmWindow(parent, ID, LOCPLINT->cb->getResourceAmount(Res::GOLD) >= 2000);
+		auto  win = new CUnivConfirmWindow(parent, ID, LOCPLINT->cb->getResourceAmount(Res::GOLD) >= 2000);
 		GH.pushInt(win);
 	}
 }
@@ -5823,7 +5823,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
 
 	//printing best hero
 	int counter = 0;
-	BOOST_FOREACH(auto & iter, tgi.colorToBestHero)
+	for(auto & iter : tgi.colorToBestHero)
 	{
 		if(iter.second.portrait >= 0)
 		{
@@ -5848,7 +5848,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
 
 	//printing best creature
 	counter = 0;
-	BOOST_FOREACH(auto & it, tgi.bestCreature)
+	for(auto & it : tgi.bestCreature)
 	{
 		if(it.second >= 0)
 			new CAnimImage("TWCRPORT", it.second+2, 0, 255 + 66 * counter, 479);
@@ -5857,7 +5857,7 @@ CThievesGuildWindow::CThievesGuildWindow(const CGObjectInstance * _owner):
 
 	//printing personality
 	counter = 0;
-	BOOST_FOREACH(auto & it, tgi.personality)
+	for(auto & it : tgi.personality)
 	{
 		std::string text;
         if(it.second == EAiTactic::NONE)
@@ -5912,10 +5912,10 @@ void MoraleLuckBox::set(const IBonusBearer *node)
 		}
 		else
 		{
-			for(int it=0; it < mrl.size(); it++)
+			for(auto & elem : mrl)
 			{
-				if (mrl[it].first) //no bonuses with value 0
-					text += "\n" + mrl[it].second;
+				if (elem.first) //no bonuses with value 0
+					text += "\n" + elem.second;
 			}
 		}
 	}
@@ -5946,14 +5946,14 @@ CArtifactHolder::CArtifactHolder()
 
 void CWindowWithArtifacts::artifactRemoved(const ArtifactLocation &artLoc)
 {
-	BOOST_FOREACH(CArtifactsOfHero *aoh, artSets)
+	for(CArtifactsOfHero *aoh : artSets)
 		aoh->artifactRemoved(artLoc);
 }
 
 void CWindowWithArtifacts::artifactMoved(const ArtifactLocation &artLoc, const ArtifactLocation &destLoc)
 {
 	CArtifactsOfHero *destaoh = nullptr;
-	BOOST_FOREACH(CArtifactsOfHero *aoh, artSets)
+	for(CArtifactsOfHero *aoh : artSets)
 	{
 		aoh->artifactMoved(artLoc, destLoc);
 		aoh->redraw();
@@ -5970,13 +5970,13 @@ void CWindowWithArtifacts::artifactMoved(const ArtifactLocation &artLoc, const A
 
 void CWindowWithArtifacts::artifactDisassembled(const ArtifactLocation &artLoc)
 {
-	BOOST_FOREACH(CArtifactsOfHero *aoh, artSets)
+	for(CArtifactsOfHero *aoh : artSets)
 		aoh->artifactDisassembled(artLoc);
 }
 
 void CWindowWithArtifacts::artifactAssembled(const ArtifactLocation &artLoc)
 {
-	BOOST_FOREACH(CArtifactsOfHero *aoh, artSets)
+	for(CArtifactsOfHero *aoh : artSets)
 		aoh->artifactAssembled(artLoc);
 }
 
@@ -6038,7 +6038,7 @@ void CRClickPopup::createAndPush(const std::string &txt, const CInfoWindow::TCom
 	CSimpleWindow * temp = new CInfoWindow(txt, player, comps);
 	temp->center(Point(GH.current->motion)); //center on mouse
 	temp->fitToScreen(10);
-	CRClickPopupInt *rcpi = new CRClickPopupInt(temp,true);
+	auto  rcpi = new CRClickPopupInt(temp,true);
 	GH.pushInt(rcpi);
 }
 

+ 21 - 21
client/Graphics.cpp

@@ -99,17 +99,17 @@ void Graphics::initializeBattleGraphics()
 	battleBacks.resize(idx+1);	// 1 to idx, 0 is unused
 
 	idx = 1;
-	BOOST_FOREACH(const JsonNode &t, config["backgrounds"].Vector()) {
+	for(const JsonNode &t : config["backgrounds"].Vector()) {
 		battleBacks[idx].push_back(t.String());
 		idx++;
 	}
 
 	//initialization of AC->def name mapping
-	BOOST_FOREACH(const JsonNode &ac, config["ac_mapping"].Vector()) {
+	for(const JsonNode &ac : config["ac_mapping"].Vector()) {
 		int ACid = ac["id"].Float();
 		std::vector< std::string > toAdd;
 
-		BOOST_FOREACH(const JsonNode &defname, ac["defnames"].Vector()) {
+		for(const JsonNode &defname : ac["defnames"].Vector()) {
 			toAdd.push_back(defname.String());
 		}
 
@@ -134,9 +134,9 @@ Graphics::Graphics()
 	CThreadHelper th(&tasks,std::max((ui32)1,boost::thread::hardware_concurrency()));
 	th.run();
 
-	for(size_t y=0; y < heroMoveArrows->ourImages.size(); ++y)
+	for(auto & elem : heroMoveArrows->ourImages)
 	{
-		CSDL_Ext::alphaTransform(heroMoveArrows->ourImages[y].bitmap);
+		CSDL_Ext::alphaTransform(elem.bitmap);
 	}
 }
 
@@ -146,9 +146,9 @@ void Graphics::loadHeroAnims()
 	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);
 
-	for(size_t i=0; i<CGI->heroh->classes.heroClasses.size(); ++i)
+	for(auto & elem : CGI->heroh->classes.heroClasses)
 	{
-		const CHeroClass * hc = CGI->heroh->classes.heroClasses[i];
+		const CHeroClass * hc = elem;
 
 		if (!vstd::contains(heroAnims, hc->imageMapFemale))
 			heroAnims[hc->imageMapFemale] = loadHeroAnim(hc->imageMapFemale, rotations);
@@ -192,9 +192,9 @@ CDefEssential * Graphics::loadHeroAnim( const std::string &name, const std::vect
 			}
 		}
 	}
-	for(size_t ff=0; ff<anim->ourImages.size(); ++ff)
+	for(auto & elem : anim->ourImages)
 	{
-		CSDL_Ext::alphaTransform(anim->ourImages[ff].bitmap);
+		CSDL_Ext::alphaTransform(elem.bitmap);
 	}
 	return anim;
 }
@@ -210,15 +210,15 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
 		std::vector<Cimage> &curImgs = (this->*pr.first)[q]->ourImages;
 		for(size_t o=0; o<curImgs.size(); ++o)
 		{
-			for(size_t p=0; p<rotations.size(); p++)
+			for(auto & rotation : rotations)
 			{
-				if(curImgs[o].groupNumber==rotations[p].first)
+				if(curImgs[o].groupNumber==rotation.first)
 				{
 					for(int e=0; e<8; ++e)
 					{
 						Cimage nci;
 						nci.bitmap = CSDL_Ext::rotate01(curImgs[o+e].bitmap);
-						nci.groupNumber = rotations[p].second;
+						nci.groupNumber = rotation.second;
 						nci.imName = std::string();
 						curImgs.push_back(nci);
 					}
@@ -244,10 +244,10 @@ void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphi
 				}
 			}
 		}
-		for(size_t ff=0; ff<curImgs.size(); ++ff)
+		for(auto & curImg : curImgs)
 		{
-			SDL_SetColorKey(curImgs[ff].bitmap, SDL_SRCCOLORKEY,
-				SDL_MapRGB(curImgs[ff].bitmap->format, 0, 255, 255)
+			SDL_SetColorKey(curImg.bitmap, SDL_SRCCOLORKEY,
+				SDL_MapRGB(curImg.bitmap->format, 0, 255, 255)
 				);
 		}
 	}
@@ -406,9 +406,9 @@ void Graphics::loadErmuToPicture()
 	//loading ERMU to picture
 	const JsonNode config(ResourceID("config/ERMU_to_picture.json"));
 	int etp_idx = 0;
-	BOOST_FOREACH(const JsonNode &etp, config["ERMU_to_picture"].Vector()) {
+	for(const JsonNode &etp : config["ERMU_to_picture"].Vector()) {
 		int idx = 0;
-		BOOST_FOREACH(const JsonNode &n, etp.Vector()) {
+		for(const JsonNode &n : etp.Vector()) {
 			ERMUtoPicture[idx][etp_idx] = n.String();
 			idx ++;
 		}
@@ -436,13 +436,13 @@ void Graphics::addImageListEntry(size_t index, std::string listName, std::string
 
 void Graphics::initializeImageLists()
 {
-	BOOST_FOREACH(const CCreature * creature, CGI->creh->creatures)
+	for(const CCreature * creature : CGI->creh->creatures)
 	{
 		addImageListEntry(creature->iconIndex, "CPRSMALL", creature->smallIconName);
 		addImageListEntry(creature->iconIndex, "TWCRPORT", creature->largeIconName);
 	}
 
-	BOOST_FOREACH(const CHero * hero, CGI->heroh->heroes)
+	for(const CHero * hero : CGI->heroh->heroes)
 	{
 		addImageListEntry(hero->imageIndex, "UN32", hero->iconSpecSmall);
 		addImageListEntry(hero->imageIndex, "UN44", hero->iconSpecLarge);
@@ -450,13 +450,13 @@ void Graphics::initializeImageLists()
 		addImageListEntry(hero->imageIndex, "PORTRAITSSMALL", hero->portraitSmall);
 	}
 
-	BOOST_FOREACH(const CArtifact * art, CGI->arth->artifacts)
+	for(const CArtifact * art : CGI->arth->artifacts)
 	{
 		addImageListEntry(art->iconIndex, "ARTIFACT", art->image);
 		addImageListEntry(art->iconIndex, "ARTIFACTLARGE", art->large);
 	}
 
-	BOOST_FOREACH(const CFaction * faction, CGI->townh->factions)
+	for(const CFaction * faction : CGI->townh->factions)
 	{
 		if (faction->town)
 		{

+ 19 - 19
client/NetPacksClient.cpp

@@ -34,7 +34,7 @@
 #define CALL_IN_PRIVILAGED_INTS(function, ...)										\
 	do																				\
 	{																				\
-		BOOST_FOREACH(auto &ger, cl->privilagedGameEventReceivers)	\
+		for(auto &ger : cl->privilagedGameEventReceivers)	\
 			ger->function(__VA_ARGS__);												\
 	} while(0)
 
@@ -60,7 +60,7 @@
 																\
 		if(cl->additionalBattleInts.count(player))				\
 		{														\
-			BOOST_FOREACH(auto bInt, cl->additionalBattleInts[player])\
+			for(auto bInt : cl->additionalBattleInts[player])\
 				bInt->function(__VA_ARGS__);					\
 		}														\
 	} while (0);
@@ -68,7 +68,7 @@
 #define BATTLE_INTERFACE_CALL_RECEIVERS(function,...) 	\
 	do															\
 	{															\
-		BOOST_FOREACH(auto & ber, cl->privilagedBattleEventReceivers)\
+		for(auto & ber : cl->privilagedBattleEventReceivers)\
 			ber->function(__VA_ARGS__);							\
 	} while(0)
 
@@ -166,7 +166,7 @@ void SetMovePoints::applyCl( CClient *cl )
 void FoWChange::applyCl( CClient *cl )
 {
 
-	BOOST_FOREACH(auto &i, cl->playerint)
+	for(auto &i : cl->playerint)
 		if(cl->getPlayerRelations(i.first, player) != PlayerRelations::ENEMIES)
 		{
 			if(mode)
@@ -385,7 +385,7 @@ void TryMoveHero::applyCl( CClient *cl )
 
 	PlayerColor player = h->tempOwner;
 
-	BOOST_FOREACH(auto &i, cl->playerint)
+	for(auto &i : cl->playerint)
 		if(cl->getPlayerRelations(i.first, player) != PlayerRelations::ENEMIES)
 			i.second->tileRevealed(fowRevealed);
 
@@ -409,7 +409,7 @@ void TryMoveHero::applyCl( CClient *cl )
 void NewStructures::applyCl( CClient *cl )
 {
 	CGTownInstance *town = GS(cl)->getTown(tid);
-	BOOST_FOREACH(const auto & id, bid)
+	for(const auto & id : bid)
 	{
 		if(id == BuildingID::CAPITOL) //fort or capitol
 		{
@@ -426,7 +426,7 @@ void NewStructures::applyCl( CClient *cl )
 void RazeStructures::applyCl (CClient *cl)
 {
 	CGTownInstance *town = GS(cl)->getTown(tid);
-	BOOST_FOREACH(const auto & id, bid)
+	for(const auto & id : bid)
 	{
 		if (id == BuildingID::CAPITOL) //fort or capitol
 		{
@@ -469,7 +469,7 @@ void SetHeroesInTown::applyCl( CClient *cl )
 	if (hVisit && vstd::contains(cl->playerint, hVisit->tempOwner))
 		playersToNotify.insert(hVisit->tempOwner);
 
-	BOOST_FOREACH(auto playerID, playersToNotify)
+	for(auto playerID : playersToNotify)
 		cl->playerint[playerID]->heroInGarrisonChange(t);
 }
 
@@ -483,11 +483,11 @@ void SetHeroesInTown::applyCl( CClient *cl )
 // 	//h->recreateArtBonuses();
 // 	//player->heroArtifactSetChanged(h);
 //
-// // 	BOOST_FOREACH(Bonus bonus, gained)
+// // 	for(Bonus bonus : gained)
 // // 	{
 // // 		player->heroBonusChanged(h,bonus,true);
 // // 	}
-// // 	BOOST_FOREACH(Bonus bonus, lost)
+// // 	for(Bonus bonus : lost)
 // // 	{
 // // 		player->heroBonusChanged(h,bonus,false);
 // // 	}
@@ -528,9 +528,9 @@ void GiveHero::applyFirstCl( CClient *cl )
 void InfoWindow::applyCl( CClient *cl )
 {
 	std::vector<Component*> comps;
-	for(size_t i=0;i<components.size();i++)
+	for(auto & elem : components)
 	{
-		comps.push_back(&components[i]);
+		comps.push_back(&elem);
 	}
 	std::string str;
 	text.toString(str);
@@ -669,11 +669,11 @@ void BattleStackAttacked::applyFirstCl( CClient *cl )
 void BattleAttack::applyFirstCl( CClient *cl )
 {
 	BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleAttack,this);
-	for (int g=0; g<bsa.size(); ++g)
+	for (auto & elem : bsa)
 	{
-		for (int z=0; z<bsa[g].healedStacks.size(); ++z)
+		for (int z=0; z<elem.healedStacks.size(); ++z)
 		{
-			bsa[g].healedStacks[z].applyCl(cl);
+			elem.healedStacks[z].applyCl(cl);
 		}
 	}
 }
@@ -719,9 +719,9 @@ void BattleResultsApplied::applyCl( CClient *cl )
 void StacksHealedOrResurrected::applyCl( CClient *cl )
 {
 	std::vector<std::pair<ui32, ui32> > shiftedHealed;
-	for(int v=0; v<healedStacks.size(); ++v)
+	for(auto & elem : healedStacks)
 	{
-		shiftedHealed.push_back(std::make_pair(healedStacks[v].stackID, healedStacks[v].healedHP));
+		shiftedHealed.push_back(std::make_pair(elem.stackID, elem.healedHP));
 	}
 	BATTLE_INTERFACE_CALL_IF_PRESENT_FOR_BOTH_SIDES(battleStacksHealedRes, shiftedHealed, lifeDrain, tentHealing, drainedFrom);
 }
@@ -923,8 +923,8 @@ void SetAvailableArtifacts::applyCl(CClient *cl)
 {
 	if(id < 0) //artifact merchants globally
 	{
-		for(auto i=cl->playerint.begin(); i!=cl->playerint.end(); i++)
-			i->second->availableArtifactsChanged(nullptr);
+		for(auto & elem : cl->playerint)
+			elem.second->availableArtifactsChanged(nullptr);
 	}
 	else
 	{

+ 33 - 33
client/battle/CBattleAnimations.cpp

@@ -22,11 +22,11 @@ CBattleAnimation::CBattleAnimation(CBattleInterface * _owner)
 
 void CBattleAnimation::endAnim()
 {
-	for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
+	for(auto & elem : owner->pendingAnims)
 	{
-		if(it->first == this)
+		if(elem.first == this)
 		{
-			it->first = nullptr;
+			elem.first = nullptr;
 		}
 	}
 
@@ -38,10 +38,10 @@ bool CBattleAnimation::isEarliest(bool perStackConcurrency)
 	CBattleStackAnimation * thAnim = dynamic_cast<CBattleStackAnimation *>(this);
 	CSpellEffectAnimation * thSen = dynamic_cast<CSpellEffectAnimation *>(this);
 
-	for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
+	for(auto & elem : owner->pendingAnims)
 	{
-		CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(it->first);
-		CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(it->first);
+		CBattleStackAnimation * stAnim = dynamic_cast<CBattleStackAnimation *>(elem.first);
+		CSpellEffectAnimation * sen = dynamic_cast<CSpellEffectAnimation *>(elem.first);
 		if(perStackConcurrency && stAnim && thAnim && stAnim->stack->ID != thAnim->stack->ID)
 			continue;
 
@@ -53,8 +53,8 @@ bool CBattleAnimation::isEarliest(bool perStackConcurrency)
 		if(revAnim && thAnim && stAnim && stAnim->stack->ID == thAnim->stack->ID && revAnim->priority)
 			return false;
 
-		if(it->first)
-			vstd::amin(lowestMoveID, it->first->ID);
+		if(elem.first)
+			vstd::amin(lowestMoveID, elem.first->ID);
 	}
 	return (ID == lowestMoveID) || (lowestMoveID == (owner->animIDhelper + 5));
 }
@@ -124,13 +124,13 @@ bool CDefenceAnimation::init()
 		return false;
 
 	ui32 lowestMoveID = owner->animIDhelper + 5;
-	for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
+	for(auto & elem : owner->pendingAnims)
 	{
-		CDefenceAnimation * defAnim = dynamic_cast<CDefenceAnimation *>(it->first);
+		CDefenceAnimation * defAnim = dynamic_cast<CDefenceAnimation *>(elem.first);
 		if(defAnim && defAnim->stack->ID != stack->ID)
 			continue;
 
-		CAttackAnimation * attAnim = dynamic_cast<CAttackAnimation *>(it->first);
+		CAttackAnimation * attAnim = dynamic_cast<CAttackAnimation *>(elem.first);
 		if(attAnim && attAnim->stack->ID != stack->ID)
 			continue;
 
@@ -143,13 +143,13 @@ bool CDefenceAnimation::init()
 				return false;
 		}
 
-		CReverseAnimation * animAsRev = dynamic_cast<CReverseAnimation *>(it->first);
+		CReverseAnimation * animAsRev = dynamic_cast<CReverseAnimation *>(elem.first);
 
 		if(animAsRev && animAsRev->priority)
 			return false;
 
-		if(it->first)
-			vstd::amin(lowestMoveID, it->first->ID);
+		if(elem.first)
+			vstd::amin(lowestMoveID, elem.first->ID);
 	}
 	if(ID > lowestMoveID)
 		return false;
@@ -474,11 +474,11 @@ void CMovementAnimation::nextFrame()
 				myAnim()->pos.x += 44;
 
 			// re-init animation
-			for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = owner->pendingAnims.begin(); it != owner->pendingAnims.end(); ++it)
+			for(auto & elem : owner->pendingAnims)
 			{
-				if (it->first == this)
+				if (elem.first == this)
 				{
-					it->second = false;
+					elem.second = false;
 					break;
 				}
 			}
@@ -896,9 +896,9 @@ bool CSpellEffectAnimation::init()
 
 			if (Vflip)
 			{
-				for (size_t v = 0; v < anim->ourImages.size(); ++v)
+				for (auto & elem : anim->ourImages)
 				{
-					CSDL_Ext::VflipSurf(anim->ourImages[v].bitmap);
+					CSDL_Ext::VflipSurf(elem.bitmap);
 				}
 			}
 
@@ -911,9 +911,9 @@ bool CSpellEffectAnimation::init()
 					be.anim = CDefHandler::giveDef(graphics->battleACToDef[effect][0]);
 					if (Vflip)
 					{
-						for (size_t v = 0; v < be.anim->ourImages.size(); ++v)
+						for (auto & elem : be.anim->ourImages)
 						{
-							CSDL_Ext::VflipSurf(be.anim->ourImages[v].bitmap);
+							CSDL_Ext::VflipSurf(elem.bitmap);
 						}
 					}
 					be.frame = 0;
@@ -946,9 +946,9 @@ bool CSpellEffectAnimation::init()
 
 			if (Vflip)
 			{
-				for (size_t v = 0; v < be.anim->ourImages.size(); ++v)
+				for (auto & elem : be.anim->ourImages)
 				{
-					CSDL_Ext::VflipSurf(be.anim->ourImages[v].bitmap);
+					CSDL_Ext::VflipSurf(elem.bitmap);
 				}
 			}
 
@@ -996,21 +996,21 @@ bool CSpellEffectAnimation::init()
 void CSpellEffectAnimation::nextFrame()
 {
 	//notice: there may be more than one effect in owner->battleEffects correcponding to this animation (ie. armageddon)
-	for(std::list<BattleEffect>::iterator it = owner->battleEffects.begin(); it != owner->battleEffects.end(); ++it)
+	for(auto & elem : owner->battleEffects)
 	{
-		if(it->effectID == ID)
+		if(elem.effectID == ID)
 		{
-			++(it->frame);
+			++(elem.frame);
 
-			if(it->frame == it->maxFrame)
+			if(elem.frame == elem.maxFrame)
 			{
 				endAnim();
 				break;
 			}
 			else
 			{
-				it->x += dx;
-				it->y += dy;
+				elem.x += dx;
+				elem.y += dy;
 			}
 		}
 	}
@@ -1022,7 +1022,7 @@ void CSpellEffectAnimation::endAnim()
 
 	std::vector<std::list<BattleEffect>::iterator> toDel;
 
-	for(std::list<BattleEffect>::iterator it = owner->battleEffects.begin(); it != owner->battleEffects.end(); ++it)
+	for(auto it = owner->battleEffects.begin(); it != owner->battleEffects.end(); ++it)
 	{
 		if(it->effectID == ID)
 		{
@@ -1030,10 +1030,10 @@ void CSpellEffectAnimation::endAnim()
 		}
 	}
 
-	for(size_t b = 0; b < toDel.size(); ++b)
+	for(auto & elem : toDel)
 	{
-		delete toDel[b]->anim;
-		owner->battleEffects.erase(toDel[b]);
+		delete elem->anim;
+		owner->battleEffects.erase(elem);
 	}
 
 	delete this;

+ 101 - 101
client/battle/CBattleInterface.cpp

@@ -147,7 +147,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	this->army1 = army1;
 	this->army2 = army2;
 	std::vector<const CStack*> stacks = curInt->cb->battleGetAllStacks();
-	BOOST_FOREACH(const CStack *s, stacks)
+	for(const CStack *s : stacks)
 	{
 		newStack(s);
 	}
@@ -288,7 +288,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	CSDL_Ext::alphaTransform(cellShade);
 	for(int h = 0; h < GameConstants::BFIELD_SIZE; ++h)
 	{
-		CClickableHex *hex = new CClickableHex();
+		auto hex = new CClickableHex();
 		hex->myNumber = h;
 		hex->pos = hexPosition(h);
 		hex->accessible = true;
@@ -296,12 +296,12 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 		bfield.push_back(hex);
 	}
 	//locking occupied positions on batlefield
-	BOOST_FOREACH(const CStack *s, stacks)  //stacks gained at top of this function
+	for(const CStack *s : stacks)  //stacks gained at top of this function
 		if(s->position >= 0) //turrets have position < 0
 			bfield[s->position]->accessible = false;
 
 	//loading projectiles for units
-	BOOST_FOREACH(const CStack *s, stacks)
+	for(const CStack *s : stacks)
 	{
 		if(s->getCreature()->isShooting())
 		{
@@ -315,9 +315,9 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 
 			projectile = CDefHandler::giveDef(creature->animation.projectileImageName);
 
-			for(size_t s = 0; s < projectile->ourImages.size(); ++s) //alpha transforming
+			for(auto & elem : projectile->ourImages) //alpha transforming
 			{
-				CSDL_Ext::alphaTransform(projectile->ourImages[s].bitmap);
+				CSDL_Ext::alphaTransform(elem.bitmap);
 			}
 		}
 	}
@@ -352,20 +352,20 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 
 	//preparing obstacle defs
 	auto obst = curInt->cb->battleGetAllObstacles();
-	for(size_t t = 0; t < obst.size(); ++t)
+	for(auto & elem : obst)
 	{
-		const int ID = obst[t]->ID;
-		if(obst[t]->obstacleType == CObstacleInstance::USUAL)
+		const int ID = elem->ID;
+		if(elem->obstacleType == CObstacleInstance::USUAL)
 		{
-			idToObstacle[ID] = CDefHandler::giveDef(obst[t]->getInfo().defName);
-			for(size_t n = 0; n < idToObstacle[ID]->ourImages.size(); ++n)
+			idToObstacle[ID] = CDefHandler::giveDef(elem->getInfo().defName);
+			for(auto & _n : idToObstacle[ID]->ourImages)
 			{
-				SDL_SetColorKey(idToObstacle[ID]->ourImages[n].bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(idToObstacle[ID]->ourImages[n].bitmap->format,0,255,255));
+				SDL_SetColorKey(_n.bitmap, SDL_SRCCOLORKEY, SDL_MapRGB(_n.bitmap->format,0,255,255));
 			}
 		}
-		else if(obst[t]->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
+		else if(elem->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
 		{
-			idToAbsoluteObstacle[ID] = BitmapHandler::loadBitmap(obst[t]->getInfo().defName);
+			idToAbsoluteObstacle[ID] = BitmapHandler::loadBitmap(elem->getInfo().defName);
 		}
 	}
 
@@ -377,7 +377,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	smallForceField[0] = CDefHandler::giveDef("C15SPE1.DEF");
 	smallForceField[1] = CDefHandler::giveDef("C15SPE4.DEF");
 
-	BOOST_FOREACH(auto hex, bfield)
+	for(auto hex : bfield)
 		addChild(hex);
 
 	if(tacticsMode)
@@ -426,7 +426,7 @@ CBattleInterface::~CBattleInterface()
 	delete bWait;
 	delete bDefence;
 
-	BOOST_FOREACH(auto hex, bfield)
+	for(auto hex : bfield)
 		delete hex;
 
 	delete bConsoleUp;
@@ -441,14 +441,14 @@ CBattleInterface::~CBattleInterface()
 	SDL_FreeSurface(cellBorder);
 	SDL_FreeSurface(cellShade);
 
-	for(std::map< int, CCreatureAnimation * >::iterator g=creAnims.begin(); g!=creAnims.end(); ++g)
-		delete g->second;
+	for(auto & elem : creAnims)
+		delete elem.second;
 
-	for(std::map< int, CDefHandler * >::iterator g=idToProjectile.begin(); g!=idToProjectile.end(); ++g)
-		delete g->second;
+	for(auto & elem : idToProjectile)
+		delete elem.second;
 
-	for(std::map< int, CDefHandler * >::iterator g=idToObstacle.begin(); g!=idToObstacle.end(); ++g)
-		delete g->second;
+	for(auto & elem : idToObstacle)
+		delete elem.second;
 
 	delete quicksand;
 	delete landMine;
@@ -512,7 +512,7 @@ void CBattleInterface::activate()
 	bWait->activate();
 	bDefence->activate();
 
-	BOOST_FOREACH(auto hex, bfield)
+	for(auto hex : bfield)
 		hex->activate();
 
 	if(attackingHero)
@@ -548,7 +548,7 @@ void CBattleInterface::deactivate()
 	bWait->deactivate();
 	bDefence->deactivate();
 
-	BOOST_FOREACH(auto hex, bfield)
+	for(auto hex : bfield)
 		hex->deactivate();
 
 	if(attackingHero)
@@ -602,7 +602,7 @@ void CBattleInterface::show(SDL_Surface * to)
 			CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, nullptr, to, &pos);
 		}
 		//Blit absolute obstacles
-		BOOST_FOREACH(auto &oi, curInt->cb->battleGetAllObstacles())
+		for(auto &oi : curInt->cb->battleGetAllObstacles())
 			if(oi->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE)
 				blitAt(imageOfObstacle(*oi), pos.x + oi->getInfo().width, pos.y + oi->getInfo().height, to);
 	}
@@ -637,7 +637,7 @@ void CBattleInterface::show(SDL_Surface * to)
 
 				//obtaining range and printing it
 				auto shaded = spToCast.rangeInHexes(b, schoolLevel, curInt->cb->battleGetMySide());
-				BOOST_FOREACH(auto shadedHex, shaded) //for spells with range greater then one hex
+				for(auto shadedHex : shaded) //for spells with range greater then one hex
 				{
 					if(settings["battle"]["mouseShadow"].Bool() && (shadedHex % GameConstants::BFIELD_WIDTH != 0) && (shadedHex % GameConstants::BFIELD_WIDTH != 16))
 					{
@@ -653,7 +653,7 @@ void CBattleInterface::show(SDL_Surface * to)
 				if (activeStack) //highlight all attackable hexes
 				{
 					std::set<BattleHex> set = curInt->cb->battleGetAttackedHexes(activeStack, currentlyHoveredHex, attackingHex);
-					BOOST_FOREACH(BattleHex hex, set)
+					for(BattleHex hex : set)
 					{
 						int x = 14 + ((hex/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(hex%GameConstants::BFIELD_WIDTH) + pos.x;
 						int y = 86 + 42 * (hex/GameConstants::BFIELD_WIDTH) + pos.y;
@@ -671,7 +671,7 @@ void CBattleInterface::show(SDL_Surface * to)
 					if (shere && shere != activeStack && shere->alive())
 					{
 						std::vector<BattleHex> v = curInt->cb->battleGetAvailableHexes(shere, true );
-						BOOST_FOREACH (BattleHex hex, v)
+						for (BattleHex hex : v)
 						{
 							int x = 14 + ((hex / GameConstants::BFIELD_WIDTH ) % 2 == 0 ? 22 : 0) + 44 * (hex % GameConstants::BFIELD_WIDTH) + pos.x;
 							int y = 86 + 42 * (hex / GameConstants::BFIELD_WIDTH) + pos.y;
@@ -714,18 +714,18 @@ void CBattleInterface::show(SDL_Surface * to)
 	////showing units //a lot of work...
 	std::vector<const CStack *> stackAliveByHex[GameConstants::BFIELD_SIZE];
 	//double loop because dead stacks should be printed first
-	for (size_t i = 0; i < stacks.size(); i++)
+	for (auto & stack : stacks)
 	{
-		const CStack *s = stacks[i];
+		const CStack *s = stack;
 		if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
 			continue;
 		if(creAnims[s->ID]->getType() != CCreatureAnim::DEATH && s->position >= 0) //don't show turrets here
 			stackAliveByHex[s->position].push_back(s);
 	}
 	std::vector<const CStack *> stackDeadByHex[GameConstants::BFIELD_SIZE];
-	for (size_t i = 0; i < stacks.size(); i++)
+	for (auto & stack : stacks)
 	{
-		const CStack *s = stacks[i];
+		const CStack *s = stack;
 		if(creAnims.find(s->ID) == creAnims.end()) //e.g. for summoned but not yet handled stacks
 			continue;
 		if(creAnims[s->ID]->getType() == CCreatureAnim::DEATH)
@@ -733,22 +733,22 @@ void CBattleInterface::show(SDL_Surface * to)
 	}
 
 	//handle animations
-	for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = pendingAnims.begin(); it != pendingAnims.end(); ++it)
+	for(auto & elem : pendingAnims)
 	{
-		if(!it->first) //this animation should be deleted
+		if(!elem.first) //this animation should be deleted
 			continue;
 
-		if(!it->second)
+		if(!elem.second)
 		{
-			it->second = it->first->init();
+			elem.second = elem.first->init();
 		}
-		if(it->second && it->first)
-			it->first->nextFrame();
+		if(elem.second && elem.first)
+			elem.first->nextFrame();
 	}
 
 	//delete anims
 	int preSize = pendingAnims.size();
-	for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = pendingAnims.begin(); it != pendingAnims.end(); ++it)
+	for(auto it = pendingAnims.begin(); it != pendingAnims.end(); ++it)
 	{
 		if(it->first == nullptr)
 		{
@@ -786,11 +786,11 @@ void CBattleInterface::show(SDL_Surface * to)
 		}
 	}
 
-	for(int b=0; b<GameConstants::BFIELD_SIZE; ++b) //showing dead stacks
+	for(auto & elem : stackDeadByHex) //showing dead stacks
 	{
-		for(size_t v=0; v<stackDeadByHex[b].size(); ++v)
+		for(size_t v=0; v<elem.size(); ++v)
 		{
-			creAnims[stackDeadByHex[b][v]->ID]->nextFrame(to, creAnims[stackDeadByHex[b][v]->ID]->pos.x, creAnims[stackDeadByHex[b][v]->ID]->pos.y, creDir[stackDeadByHex[b][v]->ID], animCount, false); //increment always when moving, never if stack died
+			creAnims[elem[v]->ID]->nextFrame(to, creAnims[elem[v]->ID]->pos.x, creAnims[elem[v]->ID]->pos.y, creDir[elem[v]->ID], animCount, false); //increment always when moving, never if stack died
 		}
 	}
 	std::vector<const CStack *> flyingStacks; //flying stacks should be displayed later, over other stacks and obstacles
@@ -877,8 +877,8 @@ void CBattleInterface::show(SDL_Surface * to)
 		}
 	}
 
-	for(size_t b = 0; b < flyingStacks.size(); ++b) //showing flying stacks
-		showAliveStack(flyingStacks[b], to);
+	for(auto & flyingStack : flyingStacks) //showing flying stacks
+		showAliveStack(flyingStack, to);
 
 	//units shown
 
@@ -888,10 +888,10 @@ void CBattleInterface::show(SDL_Surface * to)
 	//showing spell effects
 	if(battleEffects.size())
 	{
-		for(std::list<BattleEffect>::iterator it = battleEffects.begin(); it!=battleEffects.end(); ++it)
+		for(auto & elem : battleEffects)
 		{
-			SDL_Surface * bitmapToBlit = it->anim->ourImages[(it->frame)%it->anim->ourImages.size()].bitmap;
-			SDL_Rect temp_rect = genRect(bitmapToBlit->h, bitmapToBlit->w, it->x, it->y);
+			SDL_Surface * bitmapToBlit = elem.anim->ourImages[(elem.frame)%elem.anim->ourImages.size()].bitmap;
+			SDL_Rect temp_rect = genRect(bitmapToBlit->h, bitmapToBlit->w, elem.x, elem.y);
 			SDL_BlitSurface(bitmapToBlit, nullptr, to, &temp_rect);
 		}
 	}
@@ -960,9 +960,9 @@ void CBattleInterface::showAliveStacks(std::vector<const CStack *> *aliveStacks,
 		if(defendingHero)
 			defendingHero->show(to);
 
-	for(size_t v = 0; v < aliveStacks[hex].size(); ++v)
+	for(auto & elem : aliveStacks[hex])
 	{
-		const CStack *s = aliveStacks[hex][v];
+		const CStack *s = elem;
 
 		if(!s->hasBonusOfType(Bonus::FLYING) || creAnims[s->ID]->getType() != CCreatureAnim::DEATH)
 			showAliveStack(s, to);
@@ -976,7 +976,7 @@ void CBattleInterface::showObstacles(std::multimap<BattleHex, int> *hexToObstacl
 	std::pair<std::multimap<BattleHex, int>::const_iterator, std::multimap<BattleHex, int>::const_iterator> obstRange =
 		hexToObstacle->equal_range(hex);
 
-	for(std::multimap<BattleHex, int>::const_iterator it = obstRange.first; it != obstRange.second; ++it)
+	for(auto it = obstRange.first; it != obstRange.second; ++it)
 	{
 		const CObstacleInstance & curOb = *obstacles[it->second];
 		SDL_Surface *toBlit = imageOfObstacle(curOb);
@@ -1200,7 +1200,7 @@ void CBattleInterface::bOptionsf()
 
 	Rect tempRect = genRect(431, 481, 160, 84);
 	tempRect += pos.topLeft();
-	CBattleOptionsWindow * optionsWin = new CBattleOptionsWindow(tempRect, this);
+	auto  optionsWin = new CBattleOptionsWindow(tempRect, this);
 	GH.pushInt(optionsWin);
 }
 
@@ -1312,7 +1312,7 @@ void CBattleInterface::bSpellf()
 	ESpellCastProblem::ESpellCastProblem spellCastProblem;
 	if (curInt->cb->battleCanCastSpell(&spellCastProblem))
 	{
-		CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, curInt.get());
+		auto  spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, curInt.get());
 		GH.pushInt(spellWindow);
 	}
 	else if(spellCastProblem == ESpellCastProblem::MAGIC_IS_BLOCKED)
@@ -1438,23 +1438,23 @@ void CBattleInterface::stackMoved(const CStack * stack, std::vector<BattleHex> d
 
 void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attackedInfos)
 {
-	for (size_t h = 0; h < attackedInfos.size(); ++h)
+	for (auto & attackedInfo : attackedInfos)
 	{
-		if (!attackedInfos[h].cloneKilled) //FIXME: play dead animation for cloned creature before it vanishes
-			addNewAnim(new CDefenceAnimation(attackedInfos[h], this));
-		if (attackedInfos[h].rebirth)
+		if (!attackedInfo.cloneKilled) //FIXME: play dead animation for cloned creature before it vanishes
+			addNewAnim(new CDefenceAnimation(attackedInfo, this));
+		if (attackedInfo.rebirth)
 		{
-			displayEffect(50, attackedInfos[h].defender->position); //TODO: play reverse death animation
+			displayEffect(50, attackedInfo.defender->position); //TODO: play reverse death animation
 			CCS->soundh->playSound(soundBase::RESURECT);
 		}
 	}
 	waitForAnims();
 	int targets = 0, killed = 0, damage = 0;
-	for(size_t h = 0; h < attackedInfos.size(); ++h)
+	for(auto & attackedInfo : attackedInfos)
 	{
 		++targets;
-		killed += attackedInfos[h].amountKilled;
-		damage += attackedInfos[h].dmg;
+		killed += attackedInfo.amountKilled;
+		damage += attackedInfo.dmg;
 	}
 	if (attackedInfos.front().cloneKilled) //FIXME: cloned stack is already removed
 		return;
@@ -1463,12 +1463,12 @@ void CBattleInterface::stacksAreAttacked(std::vector<StackAttackedInfo> attacked
 	else
 		printConsoleAttacked(attackedInfos.front().defender, damage, killed, attackedInfos.front().attacker, false);
 
-	for(size_t h = 0; h < attackedInfos.size(); ++h)
+	for(auto & attackedInfo : attackedInfos)
 	{
-		if (attackedInfos[h].rebirth)
-			creAnims[attackedInfos[h].defender->ID]->setType(CCreatureAnim::HOLDING);
-		if (attackedInfos[h].cloneKilled)
-			stackRemoved(attackedInfos[h].defender->ID);
+		if (attackedInfo.rebirth)
+			creAnims[attackedInfo.defender->ID]->setType(CCreatureAnim::HOLDING);
+		if (attackedInfo.cloneKilled)
+			stackRemoved(attackedInfo.defender->ID);
 	}
 }
 
@@ -1489,7 +1489,7 @@ void CBattleInterface::newRoundFirst( int round )
 {
 	//handle regeneration
 	std::vector<const CStack*> stacks = curInt->cb->battleGetStacks(); //gets only alive stacks
-//	BOOST_FOREACH(const CStack *s, stacks)
+//	for(const CStack *s : stacks)
 //	{
 //	}
 	waitForAnims();
@@ -1517,7 +1517,7 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
 	if(stack && stack != activeStack)
         logGlobal->warnStream() << "Warning: giving an order to a non-active stack?";
 
-	BattleAction * ba = new BattleAction(); //is deleted in CPlayerInterface::activeStack()
+	auto  ba = new BattleAction(); //is deleted in CPlayerInterface::activeStack()
 	ba->side = defendingHeroInstance ? (curInt->playerID == defendingHeroInstance->tempOwner) : false;
 	ba->actionType = action;
 	ba->destinationTile = tile;
@@ -1555,9 +1555,9 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
 
 bool CBattleInterface::isTileAttackable(const BattleHex & number) const
 {
-	for(size_t b=0; b<occupyableHexes.size(); ++b)
+	for(auto & elem : occupyableHexes)
 	{
-		if(BattleHex::mutualPosition(occupyableHexes[b], number) != -1 || occupyableHexes[b] == number)
+		if(BattleHex::mutualPosition(elem, number) != -1 || elem == number)
 			return true;
 	}
 	return false;
@@ -1598,7 +1598,7 @@ void CBattleInterface::hexLclicked(int whichOne)
 
 void CBattleInterface::stackIsCatapulting(const CatapultAttack & ca)
 {
-	for(std::set< std::pair< std::pair< ui8, si16 >, ui8> >::const_iterator it = ca.attackedParts.begin(); it != ca.attackedParts.end(); ++it)
+	for(auto it = ca.attackedParts.begin(); it != ca.attackedParts.end(); ++it)
 	{
 		const CStack * stack = curInt->cb->battleGetStackByID(ca.attacker);
 		addNewAnim(new CShootingAnimation(this, stack, it->first.second, nullptr, true, it->second));
@@ -1703,10 +1703,10 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
 	case SpellID::TITANS_LIGHTNING_BOLT:
 	case SpellID::THUNDERBOLT:
 	case SpellID::CHAIN_LIGHTNING: //TODO: zigzag effect
-		for (auto it = sc->affectedCres.begin(); it != sc->affectedCres.end(); ++it) //in case we have multiple targets
+		for (auto & elem : sc->affectedCres) //in case we have multiple targets
 		{
-			displayEffect(1, curInt->cb->battleGetStackByID(*it, false)->position);
-			displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(*it, false)->position);
+			displayEffect(1, curInt->cb->battleGetStackByID(elem, false)->position);
+			displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(elem, false)->position);
 		}
 		break;
 	case SpellID::DISPEL:
@@ -1715,9 +1715,9 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
 	case SpellID::ANIMATE_DEAD:
 	case SpellID::DISPEL_HELPFUL_SPELLS:
 	case SpellID::SACRIFICE: //TODO: animation upon killed stack
-		for(std::set<ui32>::const_iterator it = sc->affectedCres.begin(); it != sc->affectedCres.end(); ++it)
+		for(auto & elem : sc->affectedCres)
 		{
-			displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(*it, false)->position);
+			displayEffect(spell.mainEffectAnim, curInt->cb->battleGetStackByID(elem, false)->position);
 		}
 		break;
 	case SpellID::SUMMON_FIRE_ELEMENTAL:
@@ -1736,9 +1736,9 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
 	}
 
 	//support for resistance
-	for(size_t j = 0; j < sc->resisted.size(); ++j)
+	for(auto & elem : sc->resisted)
 	{
-		int tile = curInt->cb->battleGetStackByID(sc->resisted[j])->position;
+		int tile = curInt->cb->battleGetStackByID(elem)->position;
 		displayEffect(78, tile);
 	}
 
@@ -1903,9 +1903,9 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
 	int effID = sse.effect.back().sid;
 	if(effID != -1) //can be -1 for defensive stance effect
 	{
-		for(std::vector<ui32>::const_iterator ci = sse.stacks.begin(); ci!=sse.stacks.end(); ++ci)
+		for(auto & elem : sse.stacks)
 		{
-			displayEffect(CGI->spellh->spells[effID]->mainEffectAnim, curInt->cb->battleGetStackByID(*ci)->position);
+			displayEffect(CGI->spellh->spells[effID]->mainEffectAnim, curInt->cb->battleGetStackByID(elem)->position);
 		}
 	}
 	else if (sse.stacks.size() == 1 && sse.effect.size() == 2)
@@ -1939,7 +1939,7 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
 
 void CBattleInterface::castThisSpell(int spellID)
 {
-	BattleAction * ba = new BattleAction;
+	auto  ba = new BattleAction;
 	ba->actionType = Battle::HERO_SPELL;
 	ba->additionalInfo = spellID; //spell number
 	ba->destinationTile = -1;
@@ -2147,7 +2147,7 @@ void CBattleInterface::getPossibleActionsForStack(const CStack * stack)
 				 //TODO: poll possible spells
 				const CSpell * spell;
 				BonusList spellBonuses = *stack->getBonuses (Selector::type(Bonus::SPELLCASTER));
-				BOOST_FOREACH (Bonus * spellBonus, spellBonuses)
+				for (Bonus * spellBonus : spellBonuses)
 				{
 					spell = CGI->spellh->spells[spellBonus->subtype];
 					if (spell->isRisingSpell())
@@ -2249,12 +2249,12 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
 
 	// As long as the projectile of the shooter-stack is flying incrementFrame should be false
 	//bool shootingFinished = true;
-	for (std::list<ProjectileInfo>::iterator it = projectiles.begin(); it != projectiles.end(); ++it)
+	for (auto & elem : projectiles)
 	{
-		if (it->stackID == ID)
+		if (elem.stackID == ID)
 		{
 			//shootingFinished = false;
-			if (it->animStartDelay == 0)
+			if (elem.animStartDelay == 0)
 				incrementFrame = false;
 		}
 	}
@@ -2291,9 +2291,9 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
 		{
 			int pos=0; //determining total positiveness of effects
 			std::vector<si32> spellIds = stack->activeSpells();
-			for(std::vector<si32>::const_iterator it = spellIds.begin(); it != spellIds.end(); it++)
+			for(auto & spellId : spellIds)
 			{
-				pos += CGI->spellh->spells[ *it ]->positiveness;
+				pos += CGI->spellh->spells[ spellId ]->positiveness;
 			}
 			if(pos > 0)
 			{
@@ -2339,10 +2339,10 @@ void CBattleInterface::showPieceOfWall(SDL_Surface * to, int hex, const std::vec
 	hexToPart[186] = list_of<int>(3);
 #endif
 
-	std::map<int, std::list<int> >::const_iterator it = hexToPart.find(hex);
+	auto it = hexToPart.find(hex);
 	if(it != hexToPart.end())
 	{
-		BOOST_FOREACH(int wallNum, it->second)
+		for(int wallNum : it->second)
 		{
 			siegeH->printPartOfWall(to, wallNum);
 
@@ -2365,7 +2365,7 @@ void CBattleInterface::showPieceOfWall(SDL_Surface * to, int hex, const std::vec
 			{
 				const CStack *turret = nullptr;
 
-				BOOST_FOREACH(const CStack *s, stacks)
+				for(const CStack *s : stacks)
 				{
 					if(s->position == posToSeek)
 					{
@@ -2415,7 +2415,7 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
 	blitAt(background, 0, 0, backgroundWithHexes);
 
 	//draw absolute obstacles (cliffs and so on)
-	BOOST_FOREACH(auto &oi, curInt->cb->battleGetAllObstacles())
+	for(auto &oi : curInt->cb->battleGetAllObstacles())
 	{
 		if(oi->obstacleType == CObstacleInstance::ABSOLUTE_OBSTACLE/*  ||  oi.obstacleType == CObstacleInstance::MOAT*/)
 			blitAt(imageOfObstacle(*oi), oi->getInfo().width, oi->getInfo().height, backgroundWithHexes);
@@ -2428,7 +2428,7 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
 	{
 		std::vector<BattleHex> hexesToShade = occupyableHexes;
 		hexesToShade.insert(hexesToShade.end(), attackableHexes.begin(), attackableHexes.end());
-		BOOST_FOREACH(BattleHex hex, hexesToShade)
+		for(BattleHex hex : hexesToShade)
 		{
 			int i = hex.getY(); //row
 			int j = hex.getX()-1; //column
@@ -2471,7 +2471,7 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
 	if(to == nullptr)
 		to = screen;
 	std::list< std::list<ProjectileInfo>::iterator > toBeDeleted;
-	for(std::list<ProjectileInfo>::iterator it=projectiles.begin(); it!=projectiles.end(); ++it)
+	for(auto it=projectiles.begin(); it!=projectiles.end(); ++it)
 	{
 		// Creature have to be in a shooting anim and the anim start delay must be over.
 		// Otherwise abort to start moving the projectile.
@@ -2526,9 +2526,9 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
 			}
 		}
 	}
-	for(std::list< std::list<ProjectileInfo>::iterator >::iterator it = toBeDeleted.begin(); it!= toBeDeleted.end(); ++it)
+	for(auto & elem : toBeDeleted)
 	{
-		projectiles.erase(*it);
+		projectiles.erase(elem);
 	}
 }
 
@@ -2560,7 +2560,7 @@ void CBattleInterface::endAction(const BattleAction* action)
 // 	stacks.insert(LOCPLINT->cb->battleGetStackByPos(action->destinationTile));
 	TStacks stacks = curInt->cb->battleGetStacks(CBattleCallback::MINE_AND_ENEMY);
 
-	BOOST_FOREACH(const CStack *s, stacks)
+	for(const CStack *s : stacks)
 	{
 		if(s && creDir[s->ID] != bool(s->attackerOwned) && s->alive())
 		{
@@ -2739,7 +2739,7 @@ void CBattleInterface::bTacticNextStack(const CStack *current /*= nullptr*/)
 
 	TStacks stacksOfMine = tacticianInterface->cb->battleGetStacks(CBattleCallback::ONLY_MINE);
 	stacksOfMine.erase(std::remove_if(stacksOfMine.begin(), stacksOfMine.end(), &immobile), stacksOfMine.end());
-	TStacks::iterator it = vstd::find(stacksOfMine, current);
+	auto it = vstd::find(stacksOfMine, current);
 	if(it != stacksOfMine.end() && ++it != stacksOfMine.end())
 		stackActivated(*it);
 	else
@@ -2845,7 +2845,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 	localActions.clear();
 	illegalActions.clear();
 
-	BOOST_FOREACH (PossibleActions action, possibleActions)
+	for (PossibleActions action : possibleActions)
 	{
 		bool legalAction = false; //this action is legal and can't be performed
 		bool notLegal = false; //this action is not legal and should display message
@@ -2952,7 +2952,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 					legalAction = true;
 					bool hexesOutsideBattlefield = false;
 					auto tilesThatMustBeClear = sp->rangeInHexes(myNumber, hero->getSpellSchoolLevel(sp), side, &hexesOutsideBattlefield);
-					BOOST_FOREACH(BattleHex hex, tilesThatMustBeClear)
+					for(BattleHex hex : tilesThatMustBeClear)
 					{
 						if(curInt->cb->battleGetStackByPos(hex, false)  ||  !!curInt->cb->battleGetObstacleOnPos(hex, false) 
 						 || !hex.isAvailable())
@@ -3590,7 +3590,7 @@ void CBattleInterface::requestAutofightingAIToTakeAction()
 
 	boost::thread aiThread([&] 
 	{
-		auto ba = new BattleAction(curInt->autofightingAI->activeStack(activeStack));
+		auto  ba = new BattleAction(curInt->autofightingAI->activeStack(activeStack));
 
 		if(curInt->isAutoFightOn)
 		{
@@ -3618,9 +3618,9 @@ CBattleInterface::SiegeHelper::SiegeHelper(const CGTownInstance *siegeTown, cons
 
 CBattleInterface::SiegeHelper::~SiegeHelper()
 {
-	for(int g = 0; g < ARRAY_COUNT(walls); ++g)
+	for(auto & elem : walls)
 	{
-		SDL_FreeSurface(walls[g]);
+		SDL_FreeSurface(elem);
 	}
 }
 

+ 12 - 12
client/battle/CBattleInterfaceClasses.cpp

@@ -174,7 +174,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
 		}
 		CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
 
-		CSpellWindow * spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->curInt.get());
+		auto  spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->curInt.get());
 		GH.pushInt(spellWindow);
 	}
 }
@@ -208,15 +208,15 @@ CBattleHero::CBattleHero(const std::string & defName, bool flipG, PlayerColor pl
     animCount(0)
 {
 	dh = CDefHandler::giveDef( defName );
-	for(size_t i = 0; i < dh->ourImages.size(); ++i) //transforming images
+	for(auto & elem : dh->ourImages) //transforming images
 	{
 		if(flip)
 		{
-			SDL_Surface * hlp = CSDL_Ext::rotate01(dh->ourImages[i].bitmap);
-			SDL_FreeSurface(dh->ourImages[i].bitmap);
-			dh->ourImages[i].bitmap = hlp;
+			SDL_Surface * hlp = CSDL_Ext::rotate01(elem.bitmap);
+			SDL_FreeSurface(elem.bitmap);
+			elem.bitmap = hlp;
 		}
-		CSDL_Ext::alphaTransform(dh->ourImages[i].bitmap);
+		CSDL_Ext::alphaTransform(elem.bitmap);
 	}
 
 	if(flip)
@@ -225,10 +225,10 @@ CBattleHero::CBattleHero(const std::string & defName, bool flipG, PlayerColor pl
 		flag = CDefHandler::giveDef("CMFLAGL.DEF");
 
 	//coloring flag and adding transparency
-	for(size_t i = 0; i < flag->ourImages.size(); ++i)
+	for(auto & elem : flag->ourImages)
 	{
-		CSDL_Ext::alphaTransform(flag->ourImages[i].bitmap);
-		graphics->blueToPlayersAdv(flag->ourImages[i].bitmap, player);
+		CSDL_Ext::alphaTransform(elem.bitmap);
+		graphics->blueToPlayersAdv(elem.bitmap, player);
 	}
 	addUsedEvents(LCLICK);
 
@@ -373,11 +373,11 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
 		{
 			int xPos = 235 - (br.casualties[step].size()*32 + (br.casualties[step].size() - 1)*10)/2; //increment by 42 with each picture
 			int yPos = 344 + step*97;
-			for(std::map<ui32,si32>::const_iterator it=br.casualties[step].begin(); it!=br.casualties[step].end(); ++it)
+			for(auto & elem : br.casualties[step])
 			{
-				new CAnimImage("CPRSMALL", CGI->creh->creatures[it->first]->iconIndex, 0, xPos, yPos);
+				new CAnimImage("CPRSMALL", CGI->creh->creatures[elem.first]->iconIndex, 0, xPos, yPos);
 				std::ostringstream amount;
-				amount<<it->second;
+				amount<<elem.second;
 				new CLabel( xPos+16, yPos + 42, FONT_SMALL, CENTER, Colors::WHITE, amount.str());
 				xPos += 42;
 			}

+ 5 - 5
client/battle/CCreatureAnimation.cpp

@@ -58,12 +58,12 @@ CCreatureAnimation::CCreatureAnimation(std::string name) : internalFrame(0), onc
 	totalBlocks = read_le_u32(FDef + i); i+=4;
 
 	i=0x10;
-	for (int it=0;it<256;it++)
+	for (auto & elem : palette)
 	{
-		palette[it].R = FDef[i++];
-		palette[it].G = FDef[i++];
-		palette[it].B = FDef[i++];
-		palette[it].F = 0;
+		elem.R = FDef[i++];
+		elem.G = FDef[i++];
+		elem.B = FDef[i++];
+		elem.F = 0;
 	}
 	i=0x310;
 	totalEntries=0;

+ 27 - 27
client/gui/CGuiHandler.cpp

@@ -73,7 +73,7 @@ void CGuiHandler::handleElementActivate(CIntObject * elem, ui16 activityFlag)
 void CGuiHandler::handleElementDeActivate(CIntObject * elem, ui16 activityFlag)
 {
 	processLists(activityFlag,[&](std::list<CIntObject*> * lst){
-		std::list<CIntObject*>::iterator hlp = std::find(lst->begin(),lst->end(),elem);
+		auto hlp = std::find(lst->begin(),lst->end(),elem);
 		assert(hlp != lst->end());
 		lst->erase(hlp);		
 	});
@@ -143,8 +143,8 @@ IShowActivatable * CGuiHandler::topInt()
 
 void CGuiHandler::totalRedraw()
 {
-	for(int i=0;i<objsToBlit.size();i++)
-		objsToBlit[i]->showAll(screen2);
+	for(auto & elem : objsToBlit)
+		elem->showAll(screen2);
 	blitAt(screen2,0,0,screen);
 }
 
@@ -152,10 +152,10 @@ void CGuiHandler::updateTime()
 {
 	int ms = mainFPSmng->getElapsedMilliseconds();
 	std::list<CIntObject*> hlp = timeinterested;
-	for (std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end();i++)
+	for (auto & elem : hlp)
 	{
-		if(!vstd::contains(timeinterested,*i)) continue;
-		(*i)->onTimer(ms);
+		if(!vstd::contains(timeinterested,elem)) continue;
+		(elem)->onTimer(ms);
 	}
 }
 
@@ -194,7 +194,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 		}
 
 		bool keysCaptured = false;
-		for(std::list<CIntObject*>::iterator i=keyinterested.begin(); i != keyinterested.end() && current; i++)
+		for(auto i=keyinterested.begin(); i != keyinterested.end() && current; i++)
 		{
 			if((*i)->captureThisEvent(key))
 			{
@@ -204,7 +204,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 		}
 
 		std::list<CIntObject*> miCopy = keyinterested;
-		for(std::list<CIntObject*>::iterator i=miCopy.begin(); i != miCopy.end() && current; i++)
+		for(auto i=miCopy.begin(); i != miCopy.end() && current; i++)
 			if(vstd::contains(keyinterested,*i) && (!keysCaptured || (*i)->captureThisEvent(key)))
 				(**i).keyPressed(key);
 	}
@@ -221,7 +221,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 			if(lastClick == sEvent->motion  &&  (SDL_GetTicks() - lastClickTime) < 300)
 			{
 				std::list<CIntObject*> hlp = doubleClickInterested;
-				for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
+				for(auto i=hlp.begin(); i != hlp.end() && current; i++)
 				{
 					if(!vstd::contains(doubleClickInterested,*i)) continue;
 					if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y))
@@ -236,7 +236,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 			lastClickTime = SDL_GetTicks();
 
 			std::list<CIntObject*> hlp = lclickable;
-			for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
+			for(auto i=hlp.begin(); i != hlp.end() && current; i++)
 			{
 				if(!vstd::contains(lclickable,*i)) continue;
 				if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y))
@@ -250,7 +250,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 		else if (sEvent->button.button == SDL_BUTTON_RIGHT)
 		{
 			std::list<CIntObject*> hlp = rclickable;
-			for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
+			for(auto i=hlp.begin(); i != hlp.end() && current; i++)
 			{
 				if(!vstd::contains(rclickable,*i)) continue;
 				if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y))
@@ -264,7 +264,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 		else if(sEvent->button.button == SDL_BUTTON_WHEELDOWN || sEvent->button.button == SDL_BUTTON_WHEELUP)
 		{
 			std::list<CIntObject*> hlp = wheelInterested;
-			for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
+			for(auto i=hlp.begin(); i != hlp.end() && current; i++)
 			{
 				if(!vstd::contains(wheelInterested,*i)) continue;
 				(*i)->wheelScrolled(sEvent->button.button == SDL_BUTTON_WHEELDOWN, isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y));
@@ -274,7 +274,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 	else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_LEFT))
 	{
 		std::list<CIntObject*> hlp = lclickable;
-		for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
+		for(auto i=hlp.begin(); i != hlp.end() && current; i++)
 		{
 			if(!vstd::contains(lclickable,*i)) continue;
 			prev = (*i)->pressedL;
@@ -290,7 +290,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 	else if ((sEvent->type==SDL_MOUSEBUTTONUP) && (sEvent->button.button == SDL_BUTTON_RIGHT))
 	{
 		std::list<CIntObject*> hlp = rclickable;
-		for(std::list<CIntObject*>::iterator i=hlp.begin(); i != hlp.end() && current; i++)
+		for(auto i=hlp.begin(); i != hlp.end() && current; i++)
 		{
 			if(!vstd::contains(rclickable,*i)) continue;
 			prev = (*i)->pressedR;
@@ -311,23 +311,23 @@ void CGuiHandler::handleMouseMotion(SDL_Event *sEvent)
 {
 	//sending active, hovered hoverable objects hover() call
 	std::vector<CIntObject*> hlp;
-	for(std::list<CIntObject*>::iterator i=hoverable.begin(); i != hoverable.end();i++)
+	for(auto & elem : hoverable)
 	{
-		if (isItIn(&(*i)->pos,sEvent->motion.x,sEvent->motion.y))
+		if (isItIn(&(elem)->pos,sEvent->motion.x,sEvent->motion.y))
 		{
-			if (!(*i)->hovered)
-				hlp.push_back((*i));
+			if (!(elem)->hovered)
+				hlp.push_back((elem));
 		}
-		else if ((*i)->hovered)
+		else if ((elem)->hovered)
 		{
-			(*i)->hover(false);
-			(*i)->hovered = false;
+			(elem)->hover(false);
+			(elem)->hovered = false;
 		}
 	}
-	for(int i=0; i<hlp.size();i++)
+	for(auto & elem : hlp)
 	{
-		hlp[i]->hover(true);
-		hlp[i]->hovered = true;
+		elem->hover(true);
+		elem->hovered = true;
 	}
 
 	handleMoveInterested(sEvent->motion);
@@ -345,11 +345,11 @@ void CGuiHandler::handleMoveInterested( const SDL_MouseMotionEvent & motion )
 {	
 	//sending active, MotionInterested objects mouseMoved() call
 	std::list<CIntObject*> miCopy = motioninterested;
-	for(std::list<CIntObject*>::iterator i=miCopy.begin(); i != miCopy.end();i++)
+	for(auto & elem : miCopy)
 	{
-		if ((*i)->strongInterest || isItIn(&(*i)->pos, motion.x, motion.y))
+		if ((elem)->strongInterest || isItIn(&(elem)->pos, motion.x, motion.y))
 		{
-			(*i)->mouseMoved(motion);
+			(elem)->mouseMoved(motion);
 		}
 	}
 }

+ 14 - 14
client/gui/CIntObject.cpp

@@ -46,18 +46,18 @@ void CIntObject::onTimer(int timePassed)
 void CIntObject::show(SDL_Surface * to)
 {
 	if(defActions & UPDATE)
-		for(size_t i = 0; i < children.size(); i++)
-			if(children[i]->recActions & UPDATE)
-				children[i]->show(to);
+		for(auto & elem : children)
+			if(elem->recActions & UPDATE)
+				elem->show(to);
 }
 
 void CIntObject::showAll(SDL_Surface * to)
 {
 	if(defActions & SHOWALL)
 	{
-		for(size_t i = 0; i < children.size(); i++)
-			if(children[i]->recActions & SHOWALL)
-				children[i]->showAll(to);
+		for(auto & elem : children)
+			if(elem->recActions & SHOWALL)
+				elem->showAll(to);
 
 	}
 }
@@ -79,9 +79,9 @@ void CIntObject::activate()
 	activate(used);
 
 	if(defActions & ACTIVATE)
-		for(size_t i = 0; i < children.size(); i++)
-			if(children[i]->recActions & ACTIVATE)
-				children[i]->activate();
+		for(auto & elem : children)
+			if(elem->recActions & ACTIVATE)
+				elem->activate();
 }
 
 void CIntObject::activate(ui16 what)
@@ -100,9 +100,9 @@ void CIntObject::deactivate()
 	assert(!active_m);
 
 	if(defActions & DEACTIVATE)
-		for(size_t i = 0; i < children.size(); i++)
-			if(children[i]->recActions & DEACTIVATE)
-				children[i]->deactivate();
+		for(auto & elem : children)
+			if(elem->recActions & DEACTIVATE)
+				elem->deactivate();
 }
 
 void CIntObject::deactivate(ui16 what)
@@ -219,8 +219,8 @@ void CIntObject::moveBy( const Point &p, bool propagate /*= true*/ )
 	pos.x += p.x;
 	pos.y += p.y;
 	if(propagate)
-		for(size_t i = 0; i < children.size(); i++)
-			children[i]->moveBy(p, propagate);
+		for(auto & elem : children)
+			elem->moveBy(p, propagate);
 }
 
 void CIntObject::moveTo( const Point &p, bool propagate /*= true*/ )

+ 26 - 26
client/gui/CIntObjectClasses.cpp

@@ -402,8 +402,8 @@ void CAdventureMapButton::init(const CFunctionList<void()> &Callback, const std:
 	if (!defName.empty())
 		imageNames.push_back(defName);
 	if (add)
-		for (size_t i=0; i<add->size();i++ )
-			imageNames.push_back(add->at(i));
+		for (auto & elem : *add)
+			imageNames.push_back(elem);
 	setIndex(0, playerColoredButton);
 }
 
@@ -524,7 +524,7 @@ void CHighlightableButtonsGroup::addButton(CHighlightableButton* bt)
 void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tooltip, const std::string &HelpBox, const std::string &defName, int x, int y, int uid, const CFunctionList<void()> &OnSelect, int key)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
-	CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, 0, x, y, key);
+	CHighlightableButton *bt = new CHighlightableButton(OnSelect, 0, tooltip, HelpBox, false, defName, nullptr, x, y, key);
 	if(musicLike)
 	{
 		bt->setOffset(buttons.size()-3);
@@ -563,9 +563,9 @@ void CHighlightableButtonsGroup::select(int id, bool mode)
 
 void CHighlightableButtonsGroup::selectionChanged(int to)
 {
-	for(size_t i=0;i<buttons.size(); ++i)
-		if(buttons[i]->ID!=to && buttons[i]->isHighlighted())
-			buttons[i]->select(false);
+	for(auto & elem : buttons)
+		if(elem->ID!=to && elem->isHighlighted())
+			elem->select(false);
 	onChange(to);
 	if (parent)
 		parent->redraw();
@@ -575,9 +575,9 @@ void CHighlightableButtonsGroup::show(SDL_Surface * to)
 {
 	if (musicLike)
 	{
-		for(size_t i=0;i<buttons.size(); ++i)
-			if(buttons[i]->isHighlighted())
-				buttons[i]->show(to);
+		for(auto & elem : buttons)
+			if(elem->isHighlighted())
+				elem->show(to);
 	}
 	else
 		CIntObject::show(to);
@@ -587,9 +587,9 @@ void CHighlightableButtonsGroup::showAll(SDL_Surface * to)
 {
 	if (musicLike)
 	{
-		for(size_t i=0;i<buttons.size(); ++i)
-			if(buttons[i]->isHighlighted())
-				buttons[i]->showAll(to);
+		for(auto & elem : buttons)
+			if(elem->isHighlighted())
+				elem->showAll(to);
 	}
 	else
 		CIntObject::showAll(to);
@@ -597,9 +597,9 @@ void CHighlightableButtonsGroup::showAll(SDL_Surface * to)
 
 void CHighlightableButtonsGroup::block( ui8 on )
 {
-	for(size_t i=0;i<buttons.size(); ++i)
+	for(auto & elem : buttons)
 	{
-		buttons[i]->block(on);
+		elem->block(on);
 	}
 }
 
@@ -774,17 +774,17 @@ CSlider::CSlider(int x, int y, int totalw, std::function<void(int)> Moved, int C
 		//NOTE: this images do not have "blocked" frames. They should be implemented somehow (e.g. palette transform or something...)
 
 		//use source def to create custom animations. Format "name.def:123" will load this frame from def file
-		CAnimation *animLeft = new CAnimation();
+		auto animLeft = new CAnimation();
 		animLeft->setCustom(name + ":0", 0);
 		animLeft->setCustom(name + ":1", 1);
 		left->setImage(animLeft);
 
-		CAnimation *animRight = new CAnimation();
+		auto animRight = new CAnimation();
 		animRight->setCustom(name + ":2", 0);
 		animRight->setCustom(name + ":3", 1);
 		right->setImage(animRight);
 
-		CAnimation *animSlider = new CAnimation();
+		auto animSlider = new CAnimation();
 		animSlider->setCustom(name + ":4", 0);
 		slider->setImage(animSlider);
 	}
@@ -958,9 +958,9 @@ CListBox::CListBox(CreateFunc create, DestroyFunc destroy, Point Pos, Point Item
 void CListBox::updatePositions()
 {
 	Point itemPos = pos.topLeft();
-	for (std::list<CIntObject*>::iterator it = items.begin(); it!=items.end(); it++)
+	for (auto & elem : items)
 	{
-		(*it)->moveTo(itemPos);
+		(elem)->moveTo(itemPos);
 		itemPos += itemOffset;
 	}
 	if (active)
@@ -974,10 +974,10 @@ void CListBox::updatePositions()
 void CListBox::reset()
 {
 	size_t current = first;
-	for (std::list<CIntObject*>::iterator it = items.begin(); it!=items.end(); it++)
+	for (auto & elem : items)
 	{
-		deleteItem(*it);
-		*it = createItem(current++);
+		deleteItem(elem);
+		elem = createItem(current++);
 	}
 	updatePositions();
 }
@@ -1300,7 +1300,7 @@ void CBoundedLabel::recalculateLines(const std::string &Txt)
 
 	maxH = lineHeight * lines.size();
 	maxW = 0;
-	BOOST_FOREACH(const std::string &line, lines)
+	for(const std::string &line : lines)
 		vstd::amax(maxW, f->getStringWidth(line.c_str()));
 }
 
@@ -1348,7 +1348,7 @@ void CTextBox::recalculateLines(const std::string &Txt)
 
 	maxH = lineHeight * lines.size();
 	maxW = 0;
-	BOOST_FOREACH(const std::string &line, lines)
+	for(const std::string &line : lines)
 		vstd::amax(maxW, f->getStringWidth(line));
 }
 
@@ -1658,7 +1658,7 @@ void CFocusable::giveFocus()
 
 void CFocusable::moveFocus()
 {
-	std::list<CFocusable*>::iterator i = vstd::find(focusables, this),
+	auto i = vstd::find(focusables, this),
 		ourIt = i;
 	for(i++; i != ourIt; i++)
 	{
@@ -1725,7 +1725,7 @@ CPicture * CWindowObject::createBg(std::string imageName, bool playerColored)
 	if (imageName.empty())
 		return nullptr;
 
-	auto image = new CPicture(imageName);
+	auto  image = new CPicture(imageName);
 	if (playerColored)
 		image->colorize(LOCPLINT->playerID);
 	return image;

+ 13 - 13
client/gui/Fonts.cpp

@@ -40,7 +40,7 @@ void IFont::renderTextLinesLeft(SDL_Surface * surface, const std::vector<std::st
 {
 	Point currPos = pos;
 
-	BOOST_FOREACH(const std::string & line, data)
+	for(const std::string & line : data)
 	{
 		renderTextLeft(surface, line, color, currPos);
 		currPos.y += getLineHeight();
@@ -52,7 +52,7 @@ void IFont::renderTextLinesRight(SDL_Surface * surface, const std::vector<std::s
 	Point currPos = pos;
 	currPos.y -= data.size() * getLineHeight();
 
-	BOOST_FOREACH(const std::string & line, data)
+	for(const std::string & line : data)
 	{
 		renderTextRight(surface, line, color, currPos);
 		currPos.y += getLineHeight();
@@ -64,7 +64,7 @@ void IFont::renderTextLinesCenter(SDL_Surface * surface, const std::vector<std::
 	Point currPos = pos;
 	currPos.y -= data.size() * getLineHeight()/2;
 
-	BOOST_FOREACH(const std::string & line, data)
+	for(const std::string & line : data)
 	{
 		renderTextCenter(surface, line, color, currPos);
 		currPos.y += getLineHeight();
@@ -77,17 +77,17 @@ std::array<CBitmapFont::Char, CBitmapFont::totalChars> CBitmapFont::loadChars()
 
 	size_t offset = 32;
 
-	for (size_t i=0; i< ret.size(); i++)
+	for (auto & elem : ret)
 	{
-		ret[i].leftOffset =  read_le_u32(data.first.get() + offset); offset+=4;
-		ret[i].width =       read_le_u32(data.first.get() + offset); offset+=4;
-		ret[i].rightOffset = read_le_u32(data.first.get() + offset); offset+=4;
+		elem.leftOffset =  read_le_u32(data.first.get() + offset); offset+=4;
+		elem.width =       read_le_u32(data.first.get() + offset); offset+=4;
+		elem.rightOffset = read_le_u32(data.first.get() + offset); offset+=4;
 	}
 
-	for (size_t i=0; i< ret.size(); i++)
+	for (auto & elem : ret)
 	{
 		int pixelOffset =  read_le_u32(data.first.get() + offset); offset+=4;
-		ret[i].pixels = data.first.get() + 4128 + pixelOffset;
+		elem.pixels = data.first.get() + 4128 + pixelOffset;
 
 		assert(pixelOffset + 4128 < data.second);
 	}
@@ -115,7 +115,7 @@ size_t CBitmapFont::getStringWidth(const std::string & data) const
 {
 	size_t width = 0;
 
-	BOOST_FOREACH(auto & ch, data)
+	for(auto & ch : data)
 	{
 		width += getSymbolWidth(ch);
 	}
@@ -188,9 +188,9 @@ void CBitmapFont::renderText(SDL_Surface * surface, const std::string & data, co
 
 	SDL_LockSurface(surface);
 	// for each symbol
-	for(size_t index = 0; index < data.size(); index++)
+	for(auto & elem : data)
 	{
-		renderCharacter(surface, chars[ui8(data[index])], color, posX, posY);
+		renderCharacter(surface, chars[ui8(elem)], color, posX, posY);
 	}
 	SDL_UnlockSurface(surface);
 }
@@ -215,7 +215,7 @@ int CTrueTypeFont::getFontStyle(const JsonNode &config)
 {
 	const JsonVector & names = config["style"].Vector();
 	int ret = 0;
-	BOOST_FOREACH(const JsonNode & node, names)
+	for(const JsonNode & node : names)
 	{
 		if (node.String() == "bold")
 			ret |= TTF_STYLE_BOLD;

+ 51 - 51
client/mapHandler.cpp

@@ -101,34 +101,34 @@ void CMapHandler::prepareFOWDefs()
 	static const int missRot [] = {22, 15, 2, 13, 12, 16, 28, 17, 20, 19, 7, 24, 26, 25, 30, 32, 27};
 
 	Cimage nw;
-	for(int g=0; g<ARRAY_COUNT(missRot); ++g)
+	for(auto & elem : missRot)
 	{
-		nw = graphics->FoWpartialHide->ourImages[missRot[g]];
+		nw = graphics->FoWpartialHide->ourImages[elem];
 		nw.bitmap = CSDL_Ext::rotate01(nw.bitmap);
 		graphics->FoWpartialHide->ourImages.push_back(nw);
 	}
 	//necessaary rotations added
 
 	//alpha - transformation
-	for(size_t i = 0; i < graphics->FoWpartialHide->ourImages.size(); ++i)
+	for(auto & elem : graphics->FoWpartialHide->ourImages)
 	{
-		CSDL_Ext::alphaTransform(graphics->FoWpartialHide->ourImages[i].bitmap);
+		CSDL_Ext::alphaTransform(elem.bitmap);
 	}
 
 	//initialization of type of full-hide image
 	hideBitmap.resize(sizes.x);
-	for (size_t i = 0; i < hideBitmap.size();i++)
+	for (auto & elem : hideBitmap)
 	{
-		hideBitmap[i].resize(sizes.y);
+		elem.resize(sizes.y);
 	}
-	for (size_t i = 0; i < hideBitmap.size(); ++i)
+	for (auto & elem : hideBitmap)
 	{
 		for (int j = 0; j < sizes.y; ++j)
 		{
-			hideBitmap[i][j].resize(sizes.z);
+			elem[j].resize(sizes.z);
 			for(int k = 0; k < sizes.z; ++k)
 			{
-				hideBitmap[i][j][k] = rand()%graphics->FoWfullHide->ourImages.size();
+				elem[j][k] = rand()%graphics->FoWfullHide->ourImages.size();
 			}
 		}
 	}
@@ -145,18 +145,18 @@ void CMapHandler::roadsRiverTerrainInit()
 	staticRiverDefs.push_back(CDefHandler::giveDefEss("icyrvr.def"));
 	staticRiverDefs.push_back(CDefHandler::giveDefEss("mudrvr.def"));
 	staticRiverDefs.push_back(CDefHandler::giveDefEss("lavrvr.def"));
-	for(size_t g=0; g<staticRiverDefs.size(); ++g)
+	for(auto & elem : staticRiverDefs)
 	{
-		for(size_t h=0; h < staticRiverDefs[g]->ourImages.size(); ++h)
+		for(size_t h=0; h < elem->ourImages.size(); ++h)
 		{
-			CSDL_Ext::alphaTransform(staticRiverDefs[g]->ourImages[h].bitmap);
+			CSDL_Ext::alphaTransform(elem->ourImages[h].bitmap);
 		}
 	}
-	for(size_t g=0; g<roadDefs.size(); ++g)
+	for(auto & elem : roadDefs)
 	{
-		for(size_t h=0; h < roadDefs[g]->ourImages.size(); ++h)
+		for(size_t h=0; h < elem->ourImages.size(); ++h)
 		{
-			CSDL_Ext::alphaTransform(roadDefs[g]->ourImages[h].bitmap);
+			CSDL_Ext::alphaTransform(elem->ourImages[h].bitmap);
 		}
 	}
 
@@ -264,18 +264,18 @@ static void processDef (const CGDefInfo* def)
 
 	}
 	//alpha transformation
-	for(size_t yy=0; yy < ourDef->ourImages.size(); ++yy)
+	for(auto & elem : ourDef->ourImages)
 	{
-		CSDL_Ext::alphaTransform(ourDef->ourImages[yy].bitmap);
+		CSDL_Ext::alphaTransform(elem.bitmap);
 	}
 }
 
 void CMapHandler::initObjectRects()
 {
 	//initializing objects / rects
-	for(size_t f=0; f < map->objects.size(); ++f)
+	for(auto & elem : map->objects)
 	{
-		const CGObjectInstance *obj = map->objects[f];
+		const CGObjectInstance *obj = elem;
 		if(	!obj
 			|| (obj->ID==Obj::HERO && static_cast<const CGHeroInstance*>(obj)->inTownGarrison) //garrisoned hero
 			|| (obj->ID==Obj::BOAT && static_cast<const CGBoat*>(obj)->hero) //boat with hero (hero graphics is used)
@@ -371,11 +371,11 @@ void CMapHandler::init()
 	offsetX = (mapW - (2*frameW+1)*32)/2;
 	offsetY = (mapH - (2*frameH+1)*32)/2;
 
-	for(int i=0;i<map->heroesOnMap.size();i++)
+	for(auto & elem : map->heroesOnMap)
 	{
-		if( !graphics->getDef(map->heroesOnMap[i]) )
+		if( !graphics->getDef(elem) )
 		{
-			initHeroDef(map->heroesOnMap[i]);
+			initHeroDef(elem);
 		}
 	}
 
@@ -518,9 +518,9 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 
 			//blit objects
 			const std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > &objects = tile.objects;
-			for(int h=0; h < objects.size(); ++h)
+			for(auto & object : objects)
 			{
-				const CGObjectInstance *obj = objects[h].first;
+				const CGObjectInstance *obj = object.first;
 				if (!graphics->getDef(obj))
 					processDef(obj->defInfo);
 
@@ -538,7 +538,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 
  				SDL_Rect sr2(sr); 
 
-				SDL_Rect pp = objects[h].second;
+				SDL_Rect pp = object.second;
 				pp.h = sr.h;
 				pp.w = sr.w;
 
@@ -879,7 +879,7 @@ bool CMapHandler::printObject(const CGObjectInstance *obj)
 			{
 				TerrainTile2 & curt = ttiles[obj->pos.x + fx - tilesW+1][obj->pos.y + fy - tilesH+1][obj->pos.z];
 
-				std::vector< std::pair<const CGObjectInstance*,SDL_Rect> >::iterator i = curt.objects.begin();
+				auto i = curt.objects.begin();
 				for(; i != curt.objects.end(); i++)
 				{
 					OCM_HLP cmp;
@@ -1029,29 +1029,29 @@ void shiftColors(SDL_Surface *img, int from, int howMany) //shifts colors in pal
 
 void CMapHandler::updateWater() //shift colors in palettes of water tiles
 {
-	for(size_t j=0; j < terrainGraphics[7].size(); ++j)
+	for(auto & elem : terrainGraphics[7])
 	{
-		shiftColors(terrainGraphics[7][j],246, 9); 
+		shiftColors(elem,246, 9); 
 	}
-	for(size_t j=0; j < terrainGraphics[8].size(); ++j)
+	for(auto & elem : terrainGraphics[8])
 	{
-		shiftColors(terrainGraphics[8][j],229, 12); 
-		shiftColors(terrainGraphics[8][j],242, 14); 
+		shiftColors(elem,229, 12); 
+		shiftColors(elem,242, 14); 
 	}
-	for(size_t j=0; j < staticRiverDefs[0]->ourImages.size(); ++j)
+	for(auto & elem : staticRiverDefs[0]->ourImages)
 	{
-		shiftColors(staticRiverDefs[0]->ourImages[j].bitmap,183, 12); 
-		shiftColors(staticRiverDefs[0]->ourImages[j].bitmap,195, 6); 
+		shiftColors(elem.bitmap,183, 12); 
+		shiftColors(elem.bitmap,195, 6); 
 	}
-	for(size_t j=0; j < staticRiverDefs[2]->ourImages.size(); ++j)
+	for(auto & elem : staticRiverDefs[2]->ourImages)
 	{
-		shiftColors(staticRiverDefs[2]->ourImages[j].bitmap,228, 12); 
-		shiftColors(staticRiverDefs[2]->ourImages[j].bitmap,183, 6); 
-		shiftColors(staticRiverDefs[2]->ourImages[j].bitmap,240, 6); 
+		shiftColors(elem.bitmap,228, 12); 
+		shiftColors(elem.bitmap,183, 6); 
+		shiftColors(elem.bitmap,240, 6); 
 	}
-	for(size_t j=0; j < staticRiverDefs[3]->ourImages.size(); ++j)
+	for(auto & elem : staticRiverDefs[3]->ourImages)
 	{
-		shiftColors(staticRiverDefs[3]->ourImages[j].bitmap,240, 9); 
+		shiftColors(elem.bitmap,240, 9); 
 	}
 }
 
@@ -1060,16 +1060,16 @@ CMapHandler::~CMapHandler()
 	delete graphics->FoWfullHide;
 	delete graphics->FoWpartialHide;
 
-	for(int i=0; i < roadDefs.size(); i++)
-		delete roadDefs[i];
+	for(auto & elem : roadDefs)
+		delete elem;
 
-	for(int i=0; i < staticRiverDefs.size(); i++)
-		delete staticRiverDefs[i];
+	for(auto & elem : staticRiverDefs)
+		delete elem;
 
-	for(int i=0; i < terrainGraphics.size(); ++i)
+	for(auto & elem : terrainGraphics)
 	{
-		for(int j=0; j < terrainGraphics[i].size(); ++j)
-			SDL_FreeSurface(terrainGraphics[i][j]);
+		for(int j=0; j < elem.size(); ++j)
+			SDL_FreeSurface(elem[j]);
 	}
 	terrainGraphics.clear();
 }
@@ -1086,11 +1086,11 @@ void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terN
 	out.clear();
 	TerrainTile2 & tt = ttiles[pos.x][pos.y][pos.z];
 	const TerrainTile &t = map->getTile(pos);
-	for(std::vector < std::pair<const CGObjectInstance*,SDL_Rect> >::const_iterator i = tt.objects.begin(); i != tt.objects.end(); i++)
+	for(auto & elem : tt.objects)
 	{
-		if(i->first->ID == Obj::HOLE) //Hole
+		if(elem.first->ID == Obj::HOLE) //Hole
 		{
-			out = i->first->hoverName;
+			out = elem.first->hoverName;
 			return;
 		}
 	}
@@ -1115,5 +1115,5 @@ ui8 CMapHandler::getPhaseShift(const CGObjectInstance *object) const
 }
 
 TerrainTile2::TerrainTile2()
- :terbitmap(0)
+ :terbitmap(nullptr)
 {}

+ 43 - 43
lib/BattleState.cpp

@@ -109,9 +109,9 @@ ui32 BattleInfo::calculateDmg( const CStack* attacker, const CStack* defender, c
 
 void BattleInfo::calculateCasualties( std::map<ui32,si32> *casualties ) const
 {
-	for(ui32 i=0; i<stacks.size();i++)//setting casualties
+	for(auto & elem : stacks)//setting casualties
 	{
-		const CStack * const st = stacks[i];
+		const CStack * const st = elem;
 		si32 killed = (st->alive() ? st->baseAmount - st->count : st->baseAmount);
 		vstd::amax(killed, 0);
 		if(killed)
@@ -144,7 +144,7 @@ CStack * BattleInfo::generateNewStack(const CStackInstance &base, bool attackerO
 	assert((owner >= PlayerColor::PLAYER_LIMIT)  ||
 		   (base.armyObj && base.armyObj->tempOwner == owner));
 
-	CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot);
+	auto  ret = new CStack(&base, owner, stackID, attackerOwned, slot);
 	ret->position = getAvaliableHex (base.getCreatureID(), attackerOwned, position); //TODO: what if no free tile on battlefield was found?
 	ret->state.insert(EBattleStackState::ALIVE);  //alive state indication
 	return ret;
@@ -154,7 +154,7 @@ CStack * BattleInfo::generateNewStack(const CStackBasicDescriptor &base, bool at
 {
 	int stackID = getIdForNewStack();
 	PlayerColor owner = attackerOwned ? sides[0] : sides[1];
-	CStack * ret = new CStack(&base, owner, stackID, attackerOwned, slot);
+	auto  ret = new CStack(&base, owner, stackID, attackerOwned, slot);
 	ret->position = position;
 	ret->state.insert(EBattleStackState::ALIVE);  //alive state indication
 	return ret;
@@ -193,18 +193,18 @@ bool BattleInfo::resurrects(SpellID spellid) const
 const CStack * BattleInfo::battleGetStack(BattleHex pos, bool onlyAlive)
 {
 	CStack * stack = nullptr;
-	for(ui32 g=0; g<stacks.size(); ++g)
+	for(auto & elem : stacks)
 	{
-		if(stacks[g]->position == pos
-			|| (stacks[g]->doubleWide()
-			&&( (stacks[g]->attackerOwned && stacks[g]->position-1 == pos)
-			||	(!stacks[g]->attackerOwned && stacks[g]->position+1 == pos)	)
+		if(elem->position == pos
+			|| (elem->doubleWide()
+			&&( (elem->attackerOwned && elem->position-1 == pos)
+			||	(!elem->attackerOwned && elem->position+1 == pos)	)
 			) )
 		{
-			if (stacks[g]->alive())
-				return stacks[g]; //we prefer living stacks - there cna be only one stack on te tile, so return it imediately
+			if (elem->alive())
+				return elem; //we prefer living stacks - there cna be only one stack on te tile, so return it imediately
 			else if (!onlyAlive)
-				stack = stacks[g]; //dead stacks are only accessible when there's no alive stack on this tile
+				stack = elem; //dead stacks are only accessible when there's no alive stack on this tile
 		}
 	}
 	return stack;
@@ -219,10 +219,10 @@ void BattleInfo::localInit()
 {
 	belligerents[0]->battle = belligerents[1]->battle = this;
 
-	BOOST_FOREACH(CArmedInstance *b, belligerents)
+	for(CArmedInstance *b : belligerents)
 		b->attachTo(this);
 
-	BOOST_FOREACH(CStack *s, stacks)
+	for(CStack *s : stacks)
 		localInitStack(s);
 
 	exportBonuses();
@@ -251,10 +251,10 @@ namespace CGH
 
 	static void readBattlePositions(const JsonNode &node, vector< vector<int> > & dest)
 	{
-		BOOST_FOREACH(const JsonNode &level, node.Vector())
+		for(const JsonNode &level : node.Vector())
 		{
 			std::vector<int> pom;
-			BOOST_FOREACH(const JsonNode &value, level.Vector())
+			for(const JsonNode &value : level.Vector())
 			{
 				pom.push_back(value.Float());
 			}
@@ -316,7 +316,7 @@ struct RangeGenerator
 	}
 
 	//get number fulfilling predicate. Never gives the same number twice.
-	int getSuchNumber(std::function<bool(int)> goodNumberPred = 0)
+	int getSuchNumber(std::function<bool(int)> goodNumberPred = nullptr)
 	{
 		int ret = -1;
 		do
@@ -348,7 +348,7 @@ struct RangeGenerator
 BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldType battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town )
 {
 	CMP_stack cmpst;
-	BattleInfo *curB = new BattleInfo;
+	auto curB = new BattleInfo;
 	curB->castSpells[0] = curB->castSpells[1] = 0;
 	curB->sides[0] = armies[0]->tempOwner;
 	curB->sides[1] = armies[1]->tempOwner;
@@ -424,7 +424,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 				obstPtr->uniqueID = curB->obstacles.size();
 				curB->obstacles.push_back(obstPtr);
 
-				BOOST_FOREACH(BattleHex blocked, obstPtr->getBlockedTiles())
+				for(BattleHex blocked : obstPtr->getBlockedTiles())
 					blockedTiles.push_back(blocked);
 				tilesToBlock -= VLC->heroh->absoluteObstacles[obstPtr->ID].blockedTiles.size() / 2;
 			}
@@ -453,7 +453,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 					if(vstd::contains(blockedTiles, pos))
 						return false;
 
-					BOOST_FOREACH(BattleHex blocked, obi.getBlocked(pos))
+					for(BattleHex blocked : obi.getBlocked(pos))
 					{
 						if(vstd::contains(blockedTiles, blocked))
 							return false;
@@ -473,7 +473,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 				obstPtr->uniqueID = curB->obstacles.size();
 				curB->obstacles.push_back(obstPtr);
 
-				BOOST_FOREACH(BattleHex blocked, obstPtr->getBlockedTiles())
+				for(BattleHex blocked : obstPtr->getBlockedTiles())
 					blockedTiles.push_back(blocked);
 				tilesToBlock -= obi.blockedTiles.size();
 			}
@@ -497,11 +497,11 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 	CGH::readBattlePositions(positions[4]["levels"], creBankFormations[0]);
 	CGH::readBattlePositions(positions[5]["levels"], creBankFormations[1]);
 
-	BOOST_FOREACH (auto position, config["commanderPositions"]["field"].Vector())
+	for (auto position : config["commanderPositions"]["field"].Vector())
 	{
 		commanderField.push_back (position.Float());
 	}
-	BOOST_FOREACH (auto position, config["commanderPositions"]["creBank"].Vector())
+	for (auto position : config["commanderPositions"]["creBank"].Vector())
 	{
 		commanderBank.push_back (position.Float());
 	}
@@ -537,7 +537,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 		vstd::abetween(formationNo, 0, GameConstants::ARMY_SIZE - 1);
 
 		int k = 0; //stack serial
-		for(TSlots::const_iterator i = armies[side]->Slots().begin(); i != armies[side]->Slots().end(); i++, k++)
+		for(auto i = armies[side]->Slots().begin(); i != armies[side]->Slots().end(); i++, k++)
 		{
 			std::vector<int> *formationVector = nullptr;
 			if(creatureBank)
@@ -688,13 +688,13 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 	{
 		TNodes nodes;
 		curB->belligerents[i]->getRedAncestors(nodes);
-		BOOST_FOREACH(CBonusSystemNode *n, nodes)
+		for(CBonusSystemNode *n : nodes)
 		{
-			BOOST_FOREACH(Bonus *b, n->getExportedBonusList())
+			for(Bonus *b : n->getExportedBonusList())
 			{
 				if(b->effectRange == Bonus::ONLY_ENEMY_ARMY/* && b->propagator && b->propagator->shouldBeAttached(curB)*/)
 				{
-					Bonus *bCopy = new Bonus(*b);
+					auto bCopy = new Bonus(*b);
 					bCopy->effectRange = Bonus::NO_LIMIT;
 					bCopy->propagator.reset();
 					bCopy->limiter.reset(new StackOwnerLimiter(curB->sides[!i]));
@@ -719,11 +719,11 @@ const CGHeroInstance * BattleInfo::getHero( PlayerColor player ) const
 std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const CGHeroInstance * caster, const CGHeroInstance * hero2, const std::set<const CStack*> affectedCreatures, PlayerColor casterSideOwner, ECastingMode::ECastingMode mode, int usedSpellPower, int spellLevel) const
 {
 	std::vector<ui32> ret;
-	for(auto it = affectedCreatures.begin(); it != affectedCreatures.end(); ++it)
+	for(auto & affectedCreature : affectedCreatures)
 	{
-		if(battleIsImmune(caster, sp, mode, (*it)->position) != ESpellCastProblem::OK) //FIXME: immune stacks should not display resisted animation
+		if(battleIsImmune(caster, sp, mode, (affectedCreature)->position) != ESpellCastProblem::OK) //FIXME: immune stacks should not display resisted animation
 		{
-			ret.push_back((*it)->ID);
+			ret.push_back((affectedCreature)->ID);
 			continue;
 		}
 
@@ -738,26 +738,26 @@ std::vector<ui32> BattleInfo::calculateResistedStacks(const CSpell * sp, const C
 		else
 			bonusHero = hero2;*/
 
-		int prob = (*it)->magicResistance(); //probability of resistance in %
+		int prob = (affectedCreature)->magicResistance(); //probability of resistance in %
 
 		if(prob > 100) prob = 100;
 
 		if(rand()%100 < prob) //immunity from resistance
-			ret.push_back((*it)->ID);
+			ret.push_back((affectedCreature)->ID);
 
 	}
 
 	if(sp->id == SpellID::HYPNOTIZE) //hypnotize
 	{
-		for(auto it = affectedCreatures.begin(); it != affectedCreatures.end(); ++it)
+		for(auto & affectedCreature : affectedCreatures)
 		{
-			if( (*it)->hasBonusOfType(Bonus::SPELL_IMMUNITY, sp->id) //100% sure spell immunity
-				|| ( (*it)->count - 1 ) * (*it)->MaxHealth() + (*it)->firstHPleft
+			if( (affectedCreature)->hasBonusOfType(Bonus::SPELL_IMMUNITY, sp->id) //100% sure spell immunity
+				|| ( (affectedCreature)->count - 1 ) * (affectedCreature)->MaxHealth() + (affectedCreature)->firstHPleft
 		>
-		calculateSpellBonus (usedSpellPower * 25 + sp->powers[spellLevel], sp, caster, *it) //apply 'damage' bonus for hypnotize, including hero specialty
+		calculateSpellBonus (usedSpellPower * 25 + sp->powers[spellLevel], sp, caster, affectedCreature) //apply 'damage' bonus for hypnotize, including hero specialty
 			)
 			{
-				ret.push_back((*it)->ID);
+				ret.push_back((affectedCreature)->ID);
 			}
 		}
 	}
@@ -796,7 +796,7 @@ int BattleInfo::getIdForNewStack() const
 
 shared_ptr<CObstacleInstance> BattleInfo::getObstacleOnTile(BattleHex tile) const
 {
-	BOOST_FOREACH(auto &obs, obstacles)
+	for(auto &obs : obstacles)
 		if(vstd::contains(obs->getAffectedTiles(), tile))
 			return obs;
 
@@ -896,7 +896,7 @@ ui32 CStack::Speed( int turn /*= 0*/ , bool useBind /* = false*/) const
 	int speed = valOfBonuses(Selector::type(Bonus::STACKS_SPEED) && Selector::turns(turn));
 
 	int percentBonus = 0;
-	BOOST_FOREACH(const Bonus *b, getBonusList())
+	for(const Bonus *b : getBonusList())
 	{
 		if(b->type == Bonus::STACKS_SPEED)
 		{
@@ -930,7 +930,7 @@ si32 CStack::magicResistance() const
 	{
 		magicResistance = base->magicResistance();
 		int auraBonus = 0;
-		BOOST_FOREACH (const CStack * stack, base->armyObj->battle-> batteAdjacentCreatures(this))
+		for (const CStack * stack : base->armyObj->battle-> batteAdjacentCreatures(this))
 	{
 		if (stack->owner == owner)
 		{
@@ -952,7 +952,7 @@ void CStack::stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse)
 	std::vector<Bonus> tmp;
 	sp->getEffects(tmp, sse.val);
 
-	BOOST_FOREACH(Bonus& b, tmp)
+	for(Bonus& b : tmp)
 	{
 		b.turnsRemain =  sse.turnsRemain;
 		sf.push_back(b);
@@ -1087,7 +1087,7 @@ std::vector<si32> CStack::activeSpells() const
 	std::vector<si32> ret;
 
 	TBonusListPtr spellEffects = getSpellBonuses();
-	BOOST_FOREACH(const Bonus *it, *spellEffects)
+	for(const Bonus *it : *spellEffects)
 	{
 		if (!vstd::contains(ret, it->sid)) //do not duplicate spells with multiple effects
 			ret.push_back(it->sid);
@@ -1106,7 +1106,7 @@ const CGHeroInstance * CStack::getMyHero() const
 	if(base)
 		return dynamic_cast<const CGHeroInstance *>(base->armyObj);
 	else //we are attached directly?
-		BOOST_FOREACH(const CBonusSystemNode *n, getParentNodes())
+		for(const CBonusSystemNode *n : getParentNodes())
 			if(n->getNodeType() == HERO)
 				return dynamic_cast<const CGHeroInstance *>(n);
 

+ 43 - 43
lib/CArtHandler.cpp

@@ -118,14 +118,14 @@ void CGrowingArtifact::levelUpArtifact (CArtifactInstance * art)
 	b.duration = Bonus::COMMANDER_KILLED;
 	art->accumulateBonus (b);
 
-	BOOST_FOREACH (auto bonus, bonusesPerLevel)
+	for (auto bonus : bonusesPerLevel)
 	{
 		if (art->valOfBonuses(Bonus::LEVEL_COUNTER) % bonus.first == 0) //every n levels
 		{
 			art->accumulateBonus (bonus.second);
 		}
 	}
-	BOOST_FOREACH (auto bonus, thresholdBonuses)
+	for (auto bonus : thresholdBonuses)
 	{
 		if (art->valOfBonuses(Bonus::LEVEL_COUNTER) == bonus.first) //every n levels
 		{
@@ -145,7 +145,7 @@ CArtHandler::CArtHandler()
 
 CArtHandler::~CArtHandler()
 {
-	BOOST_FOREACH(CArtifact * art, artifacts)
+	for(CArtifact * art : artifacts)
 		delete art;
 }
 
@@ -176,12 +176,12 @@ std::vector<JsonNode> CArtHandler::loadLegacyData(size_t dataSize)
 		artData["text"]["event"].String() = events.readString();
 		artData["value"].Float() = parser.readNumber();
 
-		for(int j=0; j<artSlots.size(); j++)
+		for(auto & artSlot : artSlots)
 		{
 			if(parser.readString() == "x")
 			{
 				artData["slot"].Vector().push_back(JsonNode());
-				artData["slot"].Vector().back().String() = artSlots.at(j);
+				artData["slot"].Vector().back().String() = artSlot;
 			}
 		}
 		artData["class"].String() = classes[parser.readString()[0]];
@@ -231,7 +231,7 @@ CArtifact * CArtHandler::loadFromJson(const JsonNode & node)
 		art = new CArtifact();
 	else
 	{
-		CGrowingArtifact * growing = new CGrowingArtifact();
+		auto  growing = new CGrowingArtifact();
 		loadGrowingArt(growing, node);
 		art = growing;
 	}
@@ -258,7 +258,7 @@ CArtifact * CArtHandler::loadFromJson(const JsonNode & node)
 	loadType(art, node);
 	loadComponents(art, node);
 
-	BOOST_FOREACH (auto b, node["bonuses"].Vector())
+	for (auto b : node["bonuses"].Vector())
 	{
 		auto bonus = JsonUtils::parseBonus (b);
 		bonus->sid = art->id;
@@ -302,7 +302,7 @@ void CArtHandler::loadSlots(CArtifact * art, const JsonNode & node)
 			addSlot(art, node["slot"].String());
 		else
 		{
-			BOOST_FOREACH (const JsonNode & slot, node["slot"].Vector())
+			for (const JsonNode & slot : node["slot"].Vector())
 				addSlot(art, slot.String());
 		}
 	}
@@ -335,7 +335,7 @@ void CArtHandler::loadType(CArtifact * art, const JsonNode & node)
 	static const std::map<std::string, int> artifactBearerMap = boost::assign::map_list_of ART_BEARER_LIST;
 #undef ART_BEARER
 
-	BOOST_FOREACH (const JsonNode & b, node["type"].Vector())
+	for (const JsonNode & b : node["type"].Vector())
 	{
 		auto it = artifactBearerMap.find (b.String());
 		if (it != artifactBearerMap.end())
@@ -363,7 +363,7 @@ void CArtHandler::loadComponents(CArtifact * art, const JsonNode & node)
 	if (!node["components"].isNull())
 	{
 		art->constituents.reset(new std::vector<CArtifact *>());
-		BOOST_FOREACH (auto component, node["components"].Vector())
+		for (auto component : node["components"].Vector())
 		{
 			VLC->modh->identifiers.requestIdentifier("artifact", component, [=](si32 id)
 			{
@@ -378,11 +378,11 @@ void CArtHandler::loadComponents(CArtifact * art, const JsonNode & node)
 
 void CArtHandler::loadGrowingArt(CGrowingArtifact * art, const JsonNode & node)
 {
-	BOOST_FOREACH (auto b, node["growing"]["bonusesPerLevel"].Vector())
+	for (auto b : node["growing"]["bonusesPerLevel"].Vector())
 	{
 		art->bonusesPerLevel.push_back (std::pair <ui16, Bonus> (b["level"].Float(), *JsonUtils::parseBonus (b["bonus"])));
 	}
-	BOOST_FOREACH (auto b, node["growing"]["thresholdBonuses"].Vector())
+	for (auto b : node["growing"]["thresholdBonuses"].Vector())
 	{
 		art->thresholdBonuses.push_back (std::pair <ui16, Bonus> (b["level"].Float(), *JsonUtils::parseBonus (b["bonus"])));
 	}
@@ -431,9 +431,9 @@ ArtifactID CArtHandler::getArtSync (ui32 rand, int flags, bool erasePicked)
 		if (arts->empty()) //restock available arts
 			fillList(*arts, flag);
 
-		for (int i = 0; i < arts->size(); ++i)
+		for (auto & arts_i : *arts)
 		{
-			CArtifact *art = (*arts)[i];
+			CArtifact *art = arts_i;
 			out.push_back(art);
 		}
 	};
@@ -472,7 +472,7 @@ ArtifactID CArtHandler::getArtSync (ui32 rand, int flags, bool erasePicked)
 
 Bonus *createBonus(Bonus::BonusType type, int val, int subtype, Bonus::ValueType valType, shared_ptr<ILimiter> limiter = shared_ptr<ILimiter>(), int additionalInfo = 0)
 {
-	Bonus *added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,-1,subtype);
+	auto added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,-1,subtype);
 	added->additionalInfo = additionalInfo;
 	added->valType = valType;
 	added->limiter = limiter;
@@ -481,7 +481,7 @@ Bonus *createBonus(Bonus::BonusType type, int val, int subtype, Bonus::ValueType
 
 Bonus *createBonus(Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator = shared_ptr<IPropagator>(), int additionalInfo = 0)
 {
-	Bonus *added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,-1,subtype);
+	auto added = new Bonus(Bonus::PERMANENT,type,Bonus::ARTIFACT,val,-1,subtype);
 	added->additionalInfo = additionalInfo;
 	added->valType = Bonus::BASE_NUMBER;
 	added->propagator = propagator;
@@ -623,17 +623,17 @@ boost::optional<std::vector<CArtifact*>&> CArtHandler::listFromClass( CArtifact:
 	case CArtifact::ART_RELIC:
 		return relics;
 	default: //special artifacts should not be erased
-		return 0;
+		return nullptr;
 	}
 }
 
 void CArtHandler::fillList( std::vector<CArtifact*> &listToBeFilled, CArtifact::EartClass artifactClass )
 {
 	assert(listToBeFilled.empty());
-	for (int i = 0; i < allowedArtifacts.size(); ++i)
+	for (auto & elem : allowedArtifacts)
 	{
-		if (allowedArtifacts[i]->aClass == artifactClass)
-			listToBeFilled.push_back(allowedArtifacts[i]);
+		if (elem->aClass == artifactClass)
+			listToBeFilled.push_back(elem);
 	}
 }
 
@@ -661,8 +661,8 @@ std::string CArtifactInstance::nodeName() const
 
 CArtifactInstance * CArtifactInstance::createScroll( const CSpell *s)
 {
-	CArtifactInstance *ret = new CArtifactInstance(VLC->arth->artifacts[1]);
-	Bonus *b = new Bonus(Bonus::PERMANENT, Bonus::SPELL, Bonus::ARTIFACT_INSTANCE, -1, 1, s->id);
+	auto ret = new CArtifactInstance(VLC->arth->artifacts[1]);
+	auto b = new Bonus(Bonus::PERMANENT, Bonus::SPELL, Bonus::ARTIFACT_INSTANCE, -1, 1, s->id);
 	ret->addNewBonus(b);
 	return ret;
 }
@@ -676,7 +676,7 @@ void CArtifactInstance::init()
 
 ArtifactPosition CArtifactInstance::firstAvailableSlot(const CArtifactSet *h) const
 {
-	BOOST_FOREACH(auto slot, artType->possibleSlots[h->bearerType()])
+	for(auto slot : artType->possibleSlots[h->bearerType()])
 	{
 		if(canBePutAt(h, slot)) //if(artType->fitsAt(h->artifWorn, slot))
 		{
@@ -758,12 +758,12 @@ std::vector<const CArtifact *> CArtifactInstance::assemblyPossibilities(const CA
 	if(artType->constituents) //combined artifact already: no combining of combined artifacts... for now.
 		return ret;
 
-	BOOST_FOREACH(const CArtifact * artifact, artType->constituentOf)
+	for(const CArtifact * artifact : artType->constituentOf)
 	{
 		assert(artifact->constituents);
 		bool possible = true;
 
-		BOOST_FOREACH(const CArtifact * constituent, *artifact->constituents) //check if all constituents are available
+		for(const CArtifact * constituent : *artifact->constituents) //check if all constituents are available
 		{
 			if(!h->hasArt(constituent->id, true)) //constituent must be equipped
 			{
@@ -789,10 +789,10 @@ CArtifactInstance * CArtifactInstance::createNewArtifactInstance(CArtifact *Art)
 {
 	if(!Art->constituents)
 	{
-		auto ret = new CArtifactInstance(Art);
+		auto  ret = new CArtifactInstance(Art);
 		if (dynamic_cast<CGrowingArtifact *>(Art))
 		{
-			Bonus * bonus = new Bonus;
+			auto  bonus = new Bonus;
 			bonus->type = Bonus::LEVEL_COUNTER;
 			bonus->val = 0;
 			ret->addNewBonus (bonus);
@@ -801,7 +801,7 @@ CArtifactInstance * CArtifactInstance::createNewArtifactInstance(CArtifact *Art)
 	}
 	else
 	{
-		CCombinedArtifactInstance * ret = new CCombinedArtifactInstance(Art);
+		auto  ret = new CCombinedArtifactInstance(Art);
 		ret->createConstituents();
 		return ret;
 	}
@@ -847,7 +847,7 @@ bool CCombinedArtifactInstance::canBePutAt(const CArtifactSet *artSet, ArtifactP
 
 	//it may be that we picked a combined artifact in hero screen (though technically it's still there) to move it
 	//so we remove from the list all constituents that are already present on dst hero in the form of locks
-	BOOST_FOREACH(const ConstituentInfo &constituent, constituentsInfo)
+	for(const ConstituentInfo &constituent : constituentsInfo)
 	{
 		if(constituent.art == artSet->getArt(constituent.slot, false)) //no need to worry about locked constituent
 			constituentsToBePlaced -= constituent;
@@ -888,7 +888,7 @@ void CCombinedArtifactInstance::createConstituents()
 	assert(artType);
 	assert(artType->constituents);
 
-	BOOST_FOREACH(const CArtifact * art, *artType->constituents)
+	for(const CArtifact * art : *artType->constituents)
 	{
 		addAsConstituent(CArtifactInstance::createNewArtifactInstance(art->id), ArtifactPosition::PRE_FIRST);
 	}
@@ -907,7 +907,7 @@ void CCombinedArtifactInstance::putAt(ArtifactLocation al)
 	if(al.slot >= GameConstants::BACKPACK_START)
 	{
 		CArtifactInstance::putAt(al);
-		BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
+		for(ConstituentInfo &ci : constituentsInfo)
 			ci.slot = ArtifactPosition::PRE_FIRST;
 	}
 	else
@@ -915,7 +915,7 @@ void CCombinedArtifactInstance::putAt(ArtifactLocation al)
 		CArtifactInstance *mainConstituent = figureMainConstituent(al); //it'll be replaced with combined artifact, not a lock
 		CArtifactInstance::putAt(al); //puts combined art (this)
 
-		BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
+		for(ConstituentInfo &ci : constituentsInfo)
 		{
 			if(ci.art != mainConstituent)
 			{
@@ -948,7 +948,7 @@ void CCombinedArtifactInstance::removeFrom(ArtifactLocation al)
 	}
 	else
 	{
-		BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
+		for(ConstituentInfo &ci : constituentsInfo)
 		{
 			if(ci.slot >= 0)
 			{
@@ -967,13 +967,13 @@ void CCombinedArtifactInstance::removeFrom(ArtifactLocation al)
 CArtifactInstance * CCombinedArtifactInstance::figureMainConstituent(const ArtifactLocation al)
 {
 	CArtifactInstance *mainConstituent = nullptr; //it'll be replaced with combined artifact, not a lock
-	BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
+	for(ConstituentInfo &ci : constituentsInfo)
 		if(ci.slot == al.slot)
 			mainConstituent = ci.art;
 
 	if(!mainConstituent)
 	{
-		BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
+		for(ConstituentInfo &ci : constituentsInfo)
 		{
 			if(vstd::contains(ci.art->artType->possibleSlots[al.getHolderArtSet()->bearerType()], al.slot))
 			{
@@ -987,7 +987,7 @@ CArtifactInstance * CCombinedArtifactInstance::figureMainConstituent(const Artif
 
 void CCombinedArtifactInstance::deserializationFix()
 {
-	BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
+	for(ConstituentInfo &ci : constituentsInfo)
 		attachTo(ci.art);
 }
 
@@ -998,7 +998,7 @@ bool CCombinedArtifactInstance::isPart(const CArtifactInstance *supposedPart) co
 		return true;
 
 	//check for constituents
-	BOOST_FOREACH(const ConstituentInfo &constituent, constituentsInfo)
+	for(const ConstituentInfo &constituent : constituentsInfo)
 		if(constituent.art == supposedPart)
 			return true;
 
@@ -1050,7 +1050,7 @@ ArtifactPosition CArtifactSet::getArtPos(int aid, bool onlyWorn /*= true*/) cons
 
 ArtifactPosition CArtifactSet::getArtPos(const CArtifactInstance *art) const
 {
-	BOOST_FOREACH(auto i, artifactsWorn)
+	for(auto i : artifactsWorn)
 		if(i.second.artifact == art)
 			return i.first;
 
@@ -1063,11 +1063,11 @@ ArtifactPosition CArtifactSet::getArtPos(const CArtifactInstance *art) const
 
 const CArtifactInstance * CArtifactSet::getArtByInstanceId( ArtifactInstanceID artInstId ) const
 {
-	BOOST_FOREACH(auto i, artifactsWorn)
+	for(auto i : artifactsWorn)
 		if(i.second.artifact->id == artInstId)
 			return i.second.artifact;
 
-	BOOST_FOREACH(auto i, artifactsInBackpack)
+	for(auto i : artifactsInBackpack)
 		if(i.artifact->id == artInstId)
 			return i.artifact;
 
@@ -1151,7 +1151,7 @@ void CArtifactSet::eraseArtSlot(ArtifactPosition slot)
 
 void CArtifactSet::artDeserializationFix(CBonusSystemNode *node)
 {
-	for(auto i = artifactsWorn.begin(); i != artifactsWorn.end(); i++)
-		if(i->second.artifact && !i->second.locked)
-			node->attachTo(i->second.artifact);
+	for(auto & elem : artifactsWorn)
+		if(elem.second.artifact && !elem.second.locked)
+			node->attachTo(elem.second.artifact);
 }

+ 52 - 52
lib/CBattleCallback.cpp

@@ -80,10 +80,10 @@ namespace SiegeStuffThatShouldBeMovedToHandlers //  <=== TODO
 			std::make_pair(147, EWallParts::INDESTRUCTIBLE_PART)
 		};
 
-		for(int g = 0; g < ARRAY_COUNT(attackable); ++g)
+		for(auto & elem : attackable)
 		{
-			if(attackable[g].first == hex)
-				return attackable[g].second;
+			if(elem.first == hex)
+				return elem.second;
 		}
 
 		return EWallParts::INVALID; //not found!
@@ -144,7 +144,7 @@ std::vector<shared_ptr<const CObstacleInstance> > CBattleInfoEssentials::battleG
 		}
 	}
 
-	BOOST_FOREACH(auto oi, getBattle()->obstacles)
+	for(auto oi : getBattle()->obstacles)
 	{
 		if(getBattle()->battleIsObstacleVisibleForSide(*oi, *perspective))
 			ret.push_back(oi);
@@ -163,7 +163,7 @@ bool CBattleInfoEssentials::battleHasNativeStack(ui8 side) const
 {
 	RETURN_IF_NOT_BATTLE(false);
 
-	BOOST_FOREACH(const CStack *s, battleGetAllStacks())
+	for(const CStack *s : battleGetAllStacks())
 	{
 		if(s->attackerOwned == !side  &&  s->getCreature()->isItNativeTerrain(getBattle()->terrainType))
 			return true;
@@ -240,7 +240,7 @@ const CStack* CBattleInfoEssentials::battleGetStackByID(int ID, bool onlyAlive)
 {
 	RETURN_IF_NOT_BATTLE(nullptr);
 
-	BOOST_FOREACH(auto s, battleGetAllStacks())
+	for(auto s : battleGetAllStacks())
 		if(s->ID == ID  &&  (!onlyAlive || s->alive()))
 			return s;
 
@@ -452,7 +452,7 @@ std::set<BattleHex> CBattleInfoCallback::battleGetAttackedHexes(const CStack* at
 
 	AttackableTiles at = getPotentiallyAttackableHexes(attacker, destinationTile, attackerPos);
 
-	BOOST_FOREACH (BattleHex tile, at.hostileCreaturePositions)
+	for (BattleHex tile : at.hostileCreaturePositions)
 	{
 		const CStack * st = battleGetStackByPos(tile, true);
 		if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk?
@@ -460,7 +460,7 @@ std::set<BattleHex> CBattleInfoCallback::battleGetAttackedHexes(const CStack* at
 			attackedHexes.insert(tile);
 		}
 	}
-	BOOST_FOREACH (BattleHex tile, at.friendlyCreaturePositions)
+	for (BattleHex tile : at.friendlyCreaturePositions)
 	{
 		if(battleGetStackByPos(tile, true)) //friendly stacks can also be damaged by Dragon Breath
 		{
@@ -489,7 +489,7 @@ SpellID CBattleInfoCallback::battleGetRandomStackSpell(const CStack * stack, ERa
 const CStack* CBattleInfoCallback::battleGetStackByPos(BattleHex pos, bool onlyAlive) const
 {
 	RETURN_IF_NOT_BATTLE(nullptr);
-	BOOST_FOREACH(auto s, battleGetAllStacks())
+	for(auto s : battleGetAllStacks())
 		if(vstd::contains(s->getHexes(), pos)  &&  (!onlyAlive || s->alive()))
 			return s;
 
@@ -579,7 +579,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 		return;
 	}
 
-	BOOST_FOREACH(auto s, battleGetAllStacks())
+	for(auto s : battleGetAllStacks())
 	{
 		if((turn <= 0 && !s->willMove()) //we are considering current round and stack won't move
 			|| (turn > 0 && !s->canMove(turn)) //stack won't be able to move in later rounds
@@ -714,7 +714,7 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetAvailableHexes(const CStack
 			return availableNeighbor != ret.end();
 		};
 
-		BOOST_FOREACH(const CStack * otherSt, battleAliveStacks(stack->attackerOwned))
+		for(const CStack * otherSt : battleAliveStacks(stack->attackerOwned))
 		{
 			if(!otherSt->isValidTarget(false))
 				continue;
@@ -727,7 +727,7 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetAvailableHexes(const CStack
 				continue;
 			}
 
-			BOOST_FOREACH(BattleHex he, occupied)
+			for(BattleHex he : occupied)
 			{
 				if(meleeAttackable(he))
 					attackable->push_back(he);
@@ -824,7 +824,7 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 
 		for(int g = 0; g < VLC->creh->creatures.size(); ++g)
 		{
-			BOOST_FOREACH(const Bonus *b, VLC->creh->creatures[g]->getBonusList())
+			for(const Bonus *b : VLC->creh->creatures[g]->getBonusList())
 			{
 				if ( (b->type == Bonus::KING3 && spLevel >= 3) || //expert
 					(b->type == Bonus::KING2 && spLevel >= 2) || //adv +
@@ -836,9 +836,9 @@ TDmgRange CBattleInfoCallback::calculateDmgRange(const BattleAttackInfo &info) c
 			}
 		}
 
-		for(ui32 g=0; g<affectedIds.size(); ++g)
+		for(auto & affectedId : affectedIds)
 		{
-			if(defenderType->idNumber == affectedIds[g])
+			if(defenderType->idNumber == affectedId)
 			{
 				attackDefenceDifference += SpellID(SpellID::SLAYER).toSpell()->powers[spLevel];
 				break;
@@ -1036,7 +1036,7 @@ shared_ptr<const CObstacleInstance> CBattleInfoCallback::battleGetObstacleOnPos(
 {
 	RETURN_IF_NOT_BATTLE(shared_ptr<const CObstacleInstance>());
 
-	BOOST_FOREACH(auto &obs, battleGetAllObstacles())
+	for(auto &obs : battleGetAllObstacles())
 	{
 		if(vstd::contains(obs->getBlockedTiles(), tile)
 			|| (!onlyBlocking  &&  vstd::contains(obs->getAffectedTiles(), tile)))
@@ -1067,17 +1067,17 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 	}
 
 	//tiles occupied by standing stacks
-	BOOST_FOREACH(auto stack, battleAliveStacks())
+	for(auto stack : battleAliveStacks())
 	{
-		BOOST_FOREACH(auto hex, stack->getHexes())
+		for(auto hex : stack->getHexes())
 			if(hex.isAvailable()) //towers can have <0 pos; we don't also want to overwrite side columns
 				ret[hex] = EAccessibility::ALIVE_STACK;
 	}
 
 	//obstacles
-	BOOST_FOREACH(const auto &obst, battleGetAllObstacles())
+	for(const auto &obst : battleGetAllObstacles())
 	{
-		BOOST_FOREACH(auto hex, obst->getBlockedTiles())
+		for(auto hex : obst->getBlockedTiles())
 			ret[hex] = EAccessibility::OBSTACLE;
 	}
 
@@ -1085,7 +1085,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 	if(battleGetSiegeLevel() > 0)
 	{
 		static const int permanentlyLocked[] = {12, 45, 78, 112, 147, 165};
-		BOOST_FOREACH(auto hex, permanentlyLocked)
+		for(auto hex : permanentlyLocked)
 			ret[hex] = EAccessibility::UNAVAILABLE;
 
 		//TODO likely duplicated logic
@@ -1093,10 +1093,10 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility() const
 			{std::make_pair(2, BattleHex(182)), std::make_pair(3, BattleHex(130)),
 			std::make_pair(4, BattleHex(62)), std::make_pair(5, BattleHex(29))};
 
-		for(int b=0; b<ARRAY_COUNT(lockedIfNotDestroyed); ++b)
+		for(auto & elem : lockedIfNotDestroyed)
 		{
-			if(battleGetWallState(lockedIfNotDestroyed[b].first) < 3)
-				ret[lockedIfNotDestroyed[b].second] = EAccessibility::DESTRUCTIBLE_WALL;
+			if(battleGetWallState(elem.first) < 3)
+				ret[elem.second] = EAccessibility::DESTRUCTIBLE_WALL;
 		}
 	}
 
@@ -1111,7 +1111,7 @@ AccessibilityInfo CBattleInfoCallback::getAccesibility(const CStack *stack) cons
 AccessibilityInfo CBattleInfoCallback::getAccesibility(const std::vector<BattleHex> &accessibleHexes) const
 {
 	auto ret = getAccesibility();
-	BOOST_FOREACH(auto hex, accessibleHexes)
+	for(auto hex : accessibleHexes)
 		if(hex.isValid())
 			ret[hex] = EAccessibility::ACCESSIBLE;
 
@@ -1151,7 +1151,7 @@ ReachabilityInfo CBattleInfoCallback::makeBFS(const AccessibilityInfo &accessibi
 			continue;
 
 		const int costToNeighbour = ret.distances[curHex] + 1;
-		BOOST_FOREACH(BattleHex neighbour, curHex.neighbouringTiles())
+		for(BattleHex neighbour : curHex.neighbouringTiles())
 		{
 			const bool accessible = accessibility.accessible(neighbour, params.doubleWide, params.attackerOwned);
 			const int costFoundSoFar = ret.distances[neighbour];
@@ -1178,7 +1178,7 @@ std::set<BattleHex> CBattleInfoCallback::getStoppers(BattlePerspective::BattlePe
 	std::set<BattleHex> ret;
 	RETURN_IF_NOT_BATTLE(ret);
 
-	BOOST_FOREACH(auto &oi, battleGetAllObstacles(whichSidePerspective))
+	for(auto &oi : battleGetAllObstacles(whichSidePerspective))
 	{
 		if(battleIsObstacleVisibleForSide(*oi, whichSidePerspective))
 		{
@@ -1313,7 +1313,7 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
 	if (attacker->hasBonusOfType(Bonus::THREE_HEADED_ATTACK))
 	{
 		std::vector<BattleHex> hexes = attacker->getSurroundingHexes(attackerPos);
-		BOOST_FOREACH (BattleHex tile, hexes)
+		for (BattleHex tile : hexes)
 		{
 			if ((BattleHex::mutualPosition(tile, destinationTile) > -1 && BattleHex::mutualPosition (tile, hex) > -1)) //adjacent both to attacker's head and attacked tile
 			{
@@ -1346,7 +1346,7 @@ AttackableTiles CBattleInfoCallback::getPotentiallyAttackableHexes (const CStack
 			BattleHex::checkAndPush (destinationTile.hex + pseudoVector + ((hex/WN)%2 ? 1 : 0), hexes);
 			break;
 		}
-		BOOST_FOREACH (BattleHex tile, hexes)
+		for (BattleHex tile : hexes)
 		{
 			//friendly stacks can also be damaged by Dragon Breath
 			if (battleGetStackByPos (tile, true))
@@ -1363,7 +1363,7 @@ std::set<const CStack*> CBattleInfoCallback::getAttackedCreatures(const CStack*
 	RETURN_IF_NOT_BATTLE(attackedCres);
 
 	AttackableTiles at = getPotentiallyAttackableHexes(attacker, destinationTile, attackerPos);
-	BOOST_FOREACH (BattleHex tile, at.hostileCreaturePositions) //all around & three-headed attack
+	for (BattleHex tile : at.hostileCreaturePositions) //all around & three-headed attack
 	{
 		const CStack * st = battleGetStackByPos(tile, true);
 		if(st && st->owner != attacker->owner) //only hostile stacks - does it work well with Berserk?
@@ -1371,7 +1371,7 @@ std::set<const CStack*> CBattleInfoCallback::getAttackedCreatures(const CStack*
 			attackedCres.insert(st);
 		}
 	}
-	BOOST_FOREACH (BattleHex tile, at.friendlyCreaturePositions)
+	for (BattleHex tile : at.friendlyCreaturePositions)
 	{
 		const CStack * st = battleGetStackByPos(tile, true);
 		if(st) //friendly stacks can also be damaged by Dragon Breath
@@ -1458,7 +1458,7 @@ si8 CBattleInfoCallback::battleHasDistancePenalty(const IBonusBearer *bonusBeare
 	if(const CStack * dstStack = battleGetStackByPos(destHex, false))
 	{
 		//If any hex of target creature is within range, there is no penalty
-		BOOST_FOREACH(auto hex, dstStack->getHexes())
+		for(auto hex : dstStack->getHexes())
 			if(BattleHex::getDistance(shooterPosition, hex) <= GameConstants::BATTLE_PENALTY_DISTANCE)
 				return false;
 
@@ -1526,7 +1526,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleIsImmune(const C
 			{
 				TBonusListPtr spellBon = subject->getSpellBonuses();
 				bool hasPositiveSpell = false;
-				BOOST_FOREACH(const Bonus * b, *spellBon)
+				for(const Bonus * b : *spellBon)
 				{
 					if(SpellID(b->sid).toSpell()->isPositive())
 					{
@@ -1604,7 +1604,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 	if(spell->isNegative())
 	{
 		bool allEnemiesImmune = true;
-		BOOST_FOREACH(auto enemyStack, battleAliveStacks(!side))
+		for(auto enemyStack : battleAliveStacks(!side))
 		{
 			if(!enemyStack->hasBonusOfType(Bonus::SPELL_IMMUNITY, spell->id))
 			{
@@ -1631,7 +1631,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 	if(arpos < ARRAY_COUNT(spellIDs))
 	{
 		//check if there are summoned elementals of other type
-		BOOST_FOREACH( const CStack * st, battleAliveStacks())
+		for( const CStack * st : battleAliveStacks())
 			if(vstd::contains(st->state, EBattleStackState::SUMMONED) && st->getCreature()->idNumber == creIDs[arpos])
 				return ESpellCastProblem::ANOTHER_ELEMENTAL_SUMMONED;
 	}
@@ -1645,7 +1645,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 		{
 			const CGHeroInstance * caster = battleGetFightingHero(side);
 			bool targetExists = false;
-			BOOST_FOREACH(const CStack * stack, battleAliveStacks())
+			for(const CStack * stack : battleAliveStacks())
 			{
 				switch (spell->positiveness)
 				{
@@ -1705,7 +1705,7 @@ std::vector<BattleHex> CBattleInfoCallback::battleGetPossibleTargets(PlayerColor
 		{
 			const CGHeroInstance * caster = battleGetFightingHero(playerToSide(player)); //TODO
 
-			BOOST_FOREACH(const CStack * stack, battleAliveStacks())
+			for(const CStack * stack : battleAliveStacks())
 			{
 				switch (spell->positiveness)
 				{
@@ -1749,7 +1749,7 @@ ui32 CBattleInfoCallback::battleGetSpellCost(const CSpell * sp, const CGHeroInst
 	si32 manaIncrease = 0;
 
 
-	BOOST_FOREACH(auto stack, battleAliveStacks())
+	for(auto stack : battleAliveStacks())
 	{
 		if(stack->owner == caster->tempOwner  &&  stack->hasBonusOfType(Bonus::CHANGES_SPELL_COST_FOR_ALLY) )
 		{
@@ -1901,7 +1901,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 	//fixme: what about other rising spells (Sacrifice) ?
 	if(spell->id == SpellID::DEATH_RIPPLE || spell->id == SpellID::DESTROY_UNDEAD || spell->id == SpellID::ARMAGEDDON)
 	{
-		BOOST_FOREACH(const CStack *stack, battleGetAllStacks())
+		for(const CStack *stack : battleGetAllStacks())
 		{
 			if((spell->id == SpellID::DEATH_RIPPLE && !stack->getCreature()->isUndead()) //death ripple
 				|| (spell->id == SpellID::DESTROY_UNDEAD && stack->getCreature()->isUndead()) //destroy undead
@@ -1916,11 +1916,11 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 	else if (spell->id == SpellID::CHAIN_LIGHTNING)
 	{
 		std::set<BattleHex> possibleHexes;
-		BOOST_FOREACH (auto stack, battleGetAllStacks())
+		for (auto stack : battleGetAllStacks())
 		{
 			if (stack->isValidTarget())
 			{
-				BOOST_FOREACH (auto hex, stack->getHexes())
+				for (auto hex : stack->getHexes())
 				{
 					possibleHexes.insert (hex);
 				}
@@ -1933,7 +1933,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 			if (!stack)
 				break;
 			attackedCres.insert (stack);
-			BOOST_FOREACH (auto hex, stack->getHexes())
+			for (auto hex : stack->getHexes())
 			{
 				possibleHexes.erase (hex); //can't hit same place twice
 			}
@@ -1944,7 +1944,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 	}
 	else if (spell->range[skillLevel].size() > 1) //custom many-hex range
 	{
-		BOOST_FOREACH(BattleHex hex, attackedHexes)
+		for(BattleHex hex : attackedHexes)
 		{
 			if(const CStack * st = battleGetStackByPos(hex, onlyAlive))
 			{
@@ -1970,7 +1970,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 		}
 		else
 		{
-			BOOST_FOREACH (auto stack, battleGetAllStacks())
+			for (auto stack : battleGetAllStacks())
 			{
 				/*if it's non negative spell and our unit or non positive spell and hostile unit */
 				if((!spell->isNegative() && stack->owner == attackerOwner)
@@ -1990,7 +1990,7 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 	}
 	else //custom range from attackedHexes
 	{
-		BOOST_FOREACH(BattleHex hex, attackedHexes)
+		for(BattleHex hex : attackedHexes)
 		{
 			if(const CStack * st = battleGetStackByPos(hex, onlyAlive))
 				attackedCres.insert(st);
@@ -2016,7 +2016,7 @@ bool CBattleInfoCallback::battleIsStackBlocked(const CStack * stack) const
 	if(stack->hasBonusOfType(Bonus::SIEGE_WEAPON)) //siege weapons cannot be blocked
 		return false;
 
-	BOOST_FOREACH(const CStack * s,  batteAdjacentCreatures(stack))
+	for(const CStack * s :  batteAdjacentCreatures(stack))
 	{
 		if (s->owner != stack->owner) //blocked by enemy stack
 			return true;
@@ -2029,7 +2029,7 @@ std::set<const CStack*> CBattleInfoCallback:: batteAdjacentCreatures(const CStac
 	std::set<const CStack*> stacks;
 	RETURN_IF_NOT_BATTLE(stacks);
 
-	BOOST_FOREACH (BattleHex hex, stack->getSurroundingHexes())
+	for (BattleHex hex : stack->getSurroundingHexes())
 		if(const CStack *neighbour = battleGetStackByPos(hex, true))
 			stacks.insert(neighbour);
 
@@ -2041,7 +2041,7 @@ SpellID CBattleInfoCallback::getRandomBeneficialSpell(const CStack * subject) co
 	RETURN_IF_NOT_BATTLE(SpellID::NONE);
 	std::vector<SpellID> possibleSpells;
 
-	BOOST_FOREACH(const CSpell *spell, VLC->spellh->spells)
+	for(const CSpell *spell : VLC->spellh->spells)
 	{
 		if (spell->isPositive()) //only positive
 		{
@@ -2133,12 +2133,12 @@ SpellID CBattleInfoCallback::getRandomCastedSpell(const CStack * caster) const
 	if (!bl->size())
 		return SpellID::NONE;
 	int totalWeight = 0;
-	BOOST_FOREACH(Bonus * b, *bl)
+	for(Bonus * b : *bl)
 	{
 		totalWeight += std::max(b->additionalInfo, 1); //minimal chance to cast is 1
 	}
 	int randomPos = rand() % totalWeight;
-	BOOST_FOREACH(Bonus * b, *bl)
+	for(Bonus * b : *bl)
 	{
 		randomPos -= std::max(b->additionalInfo, 1);
 		if(randomPos < 0)
@@ -2158,7 +2158,7 @@ int CBattleInfoCallback::battleGetSurrenderCost(PlayerColor Player) const
 
 	int ret = 0;
 	double discount = 0;
-	BOOST_FOREACH(const CStack *s, battleAliveStacks(playerToSide(Player)))
+	for(const CStack *s : battleAliveStacks(playerToSide(Player)))
 		if(s->base) //we pay for our stack that comes from our army slots - condition eliminates summoned cres and war machines
 			ret += s->getCreature()->cost[Res::GOLD] * s->count;
 
@@ -2195,7 +2195,7 @@ bool AccessibilityInfo::accessible(BattleHex tile, const CStack *stack) const
 bool AccessibilityInfo::accessible(BattleHex tile, bool doubleWide, bool attackerOwned) const
 {
 	// All hexes that stack would cover if standing on tile have to be accessible.
-	BOOST_FOREACH(auto hex, CStack::getHexes(tile, doubleWide, attackerOwned))
+	for(auto hex : CStack::getHexes(tile, doubleWide, attackerOwned))
 	{
         // If the hex is out of range then the tile isn't accessible
         if(!hex.isValid())

+ 2 - 2
lib/CBonusTypeHandler.cpp

@@ -66,7 +66,7 @@ std::string MacroString::build(const GetValue& getValue) const
 {
 	std::string result;
 	
-	BOOST_FOREACH(const Item &i, items)
+	for(const Item &i : items)
 	{
 		switch (i.type)
 		{
@@ -269,7 +269,7 @@ void CBonusTypeHandler::load()
 
 void CBonusTypeHandler::load(const JsonNode& config)
 {
-	BOOST_FOREACH(auto & node, config.Struct())
+	for(auto & node : config.Struct())
 	{
 		auto it = bonusNameMap.find(node.first);
 		

+ 4 - 4
lib/CConfigHandler.cpp

@@ -71,7 +71,7 @@ void SettingsStorage::init()
 
 void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath)
 {
-	BOOST_FOREACH(SettingsListener * listener, listeners)
+	for(SettingsListener * listener : listeners)
 		listener->nodeInvalidated(changedPath);
 
 	JsonNode savedConf = config;
@@ -87,7 +87,7 @@ void SettingsStorage::invalidateNode(const std::vector<std::string> &changedPath
 JsonNode & SettingsStorage::getNode(std::vector<std::string> path)
 {
 	JsonNode *node = &config;
-	BOOST_FOREACH(std::string& value, path)
+	for(std::string& value : path)
 		node = &(*node)[value];
 
 	return *node;
@@ -187,7 +187,7 @@ static void setButton(ButtonInfo &button, const JsonNode &g)
 	if (!g["additionalDefs"].isNull()) {
 		const JsonVector &defs_vec = g["additionalDefs"].Vector();
 
-		BOOST_FOREACH(const JsonNode &def, defs_vec) {
+		for(const JsonNode &def : defs_vec) {
 			button.additionalDefs.push_back(def.String());
 		}
 	}
@@ -214,7 +214,7 @@ void config::CConfigHandler::init()
 	const JsonNode config(ResourceID("config/resolutions.json"));
 	const JsonVector &guisettings_vec = config["GUISettings"].Vector();
 
-	BOOST_FOREACH(const JsonNode &g, guisettings_vec) 
+	for(const JsonNode &g : guisettings_vec) 
 	{
 		std::pair<int,int> curRes(g["resolution"]["x"].Float(), g["resolution"]["y"].Float());
 		GUIOptions *current = &conf.guiOptions[curRes];

+ 25 - 25
lib/CCreatureHandler.cpp

@@ -107,7 +107,7 @@ CCreature::CCreature()
 }
 void CCreature::addBonus(int val, Bonus::BonusType type, int subtype /*= -1*/)
 {
-	Bonus *added = new Bonus(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, idNumber, subtype, Bonus::BASE_NUMBER);
+	auto added = new Bonus(Bonus::PERMANENT, type, Bonus::CREATURE_ABILITY, val, idNumber, subtype, Bonus::BASE_NUMBER);
 	addNewBonus(added);
 }
 
@@ -135,7 +135,7 @@ bool CCreature::isItNativeTerrain(int terrain) const
 void CCreature::setId(CreatureID ID)
 {
 	idNumber = ID;
-	BOOST_FOREACH(auto bonus, getExportedBonusList())
+	for(auto bonus : getExportedBonusList())
 	{
 		if(bonus->source == Bonus::CREATURE_ABILITY)
 			bonus->sid = ID;
@@ -144,7 +144,7 @@ void CCreature::setId(CreatureID ID)
 
 static void AddAbility(CCreature *cre, const JsonVector &ability_vec)
 {
-	Bonus *nsf = new Bonus();
+	auto nsf = new Bonus();
 	std::string type = ability_vec[0].String();
 
 	auto it = bonusNameMap.find(type);
@@ -194,23 +194,23 @@ void CCreatureHandler::loadCommanders()
 
 	const JsonNode & config = data; // switch to const data accessors
 
-	BOOST_FOREACH (auto bonus, config["bonusPerLevel"].Vector())
+	for (auto bonus : config["bonusPerLevel"].Vector())
 	{
 		commanderLevelPremy.push_back(JsonUtils::parseBonus (bonus.Vector()));
 	}
 
 	int i = 0;
-	BOOST_FOREACH (auto skill, config["skillLevels"].Vector())
+	for (auto skill : config["skillLevels"].Vector())
 	{
 		skillLevels.push_back (std::vector<ui8>());
-		BOOST_FOREACH (auto skillLevel, skill["levels"].Vector())
+		for (auto skillLevel : skill["levels"].Vector())
 		{
 			skillLevels[i].push_back (skillLevel.Float());
 		}
 		++i;
 	}
 
-	BOOST_FOREACH (auto ability, config["abilityRequirements"].Vector())
+	for (auto ability : config["abilityRequirements"].Vector())
 	{
 		std::pair <Bonus*, std::pair <ui8, ui8> > a;
 		a.first = JsonUtils::parseBonus (ability["ability"].Vector());
@@ -252,7 +252,7 @@ void CCreatureHandler::loadBonuses(JsonNode & creature, std::string bonuses)
 		return boost::algorithm::find_first(bonuses, name);
 	};
 
-	BOOST_FOREACH(auto a, abilityMap)
+	for(auto a : abilityMap)
 	{
 		if(hasAbility(a.first))
 			creature["abilities"][a.first] = a.second;
@@ -364,7 +364,7 @@ void CCreatureHandler::loadObject(std::string scope, std::string name, const Jso
 
 	VLC->modh->identifiers.registerObject(scope, "creature", name, object->idNumber);
 
-	BOOST_FOREACH(auto node, data["extraNames"].Vector())
+	for(auto node : data["extraNames"].Vector())
 	{
 		VLC->modh->identifiers.registerObject(scope, "creature", node.String(), object->idNumber);
 	}
@@ -385,7 +385,7 @@ void CCreatureHandler::loadObject(std::string scope, std::string name, const Jso
 	creatures[index] = object;
 
 	VLC->modh->identifiers.registerObject(scope, "creature", name, object->idNumber);
-	BOOST_FOREACH(auto node, data["extraNames"].Vector())
+	for(auto node : data["extraNames"].Vector())
 	{
 		VLC->modh->identifiers.registerObject(scope, "creature", node.String(), object->idNumber);
 	}
@@ -395,7 +395,7 @@ std::vector<bool> CCreatureHandler::getDefaultAllowed() const
 {
 	std::vector<bool> ret;
 
-	BOOST_FOREACH(const CCreature * crea, creatures)
+	for(const CCreature * crea : creatures)
 	{
 		ret.push_back(crea ? !crea->special : false);
 	}
@@ -421,7 +421,7 @@ void CCreatureHandler::loadCrExpBon()
 
 		parser.readString(); //ignore index
 		loadStackExp(b, bl, parser);
-		BOOST_FOREACH(Bonus * b, bl)
+		for(Bonus * b : bl)
 			addBonusForAllCreatures(b); //health bonus is common for all
 		parser.endLine();
 
@@ -432,7 +432,7 @@ void CCreatureHandler::loadCrExpBon()
 				parser.readString(); //ignore index
 				bl.clear();
 				loadStackExp(b, bl, parser);
-				BOOST_FOREACH(Bonus * b, bl)
+				for(Bonus * b : bl)
 					addBonusForTier(i, b);
 				parser.endLine();
 			}
@@ -442,7 +442,7 @@ void CCreatureHandler::loadCrExpBon()
 			parser.readString(); //ignore index
 			bl.clear();
 			loadStackExp(b, bl, parser);
-			BOOST_FOREACH(Bonus * b, bl)
+			for(Bonus * b : bl)
 			{
 				addBonusForTier(7, b);
 				creaturesOfLevel[0].addNewBonus(b); //bonuses from level 7 are given to high-level creatures
@@ -562,7 +562,7 @@ void CCreatureHandler::loadUnitAnimInfo(JsonNode & graphics, CLegacyConfigParser
 
 CCreature * CCreatureHandler::loadFromJson(const JsonNode & node)
 {
-	CCreature * cre = new CCreature();
+	auto  cre = new CCreature();
 
 	const JsonNode & name = node["name"];
 	cre->nameSing = name["singular"].String();
@@ -634,7 +634,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
 
 	if (config["abilities"].getType() == JsonNode::DATA_STRUCT)
 	{
-		BOOST_FOREACH(auto &ability, config["abilities"].Struct())
+		for(auto &ability : config["abilities"].Struct())
 		{
 			if (!ability.second.isNull())
 			{
@@ -647,7 +647,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
 	}
 	else
 	{
-		BOOST_FOREACH(const JsonNode &ability, config["abilities"].Vector())
+		for(const JsonNode &ability : config["abilities"].Vector())
 		{
 			if (ability.getType() == JsonNode::DATA_VECTOR)
 			{
@@ -669,7 +669,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
 		creature->faction = faction;
 	});
 
-	BOOST_FOREACH(const JsonNode &value, config["upgrades"].Vector())
+	for(const JsonNode &value : config["upgrades"].Vector())
 	{
 		VLC->modh->identifiers.requestIdentifier("creature", value, [=](si32 identifier)
 		{
@@ -697,7 +697,7 @@ void CCreatureHandler::loadCreatureJson(CCreature * creature, const JsonNode & c
 
 void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode & input)
 {
-	BOOST_FOREACH (const JsonNode &exp, input.Vector())
+	for (const JsonNode &exp : input.Vector())
 	{
 		auto bonus = JsonUtils::parseBonus (exp["bonus"]);
 		bonus->source = Bonus::STACK_EXPERIENCE;
@@ -706,7 +706,7 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
 		int lowerLimit = 1;//, upperLimit = 255;
 		if (values[0].getType() == JsonNode::JsonType::DATA_BOOL)
 		{
-			BOOST_FOREACH (const JsonNode &val, values)
+			for (const JsonNode &val : values)
 			{
 				if (val.Bool() == true)
 				{
@@ -720,7 +720,7 @@ void CCreatureHandler::loadStackExperience(CCreature * creature, const JsonNode
 		else
 		{
 			int lastVal = 0;
-			BOOST_FOREACH (const JsonNode &val, values)
+			for (const JsonNode &val : values)
 			{
 				if (val.Float() != lastVal)
 				{
@@ -1042,7 +1042,7 @@ int CCreatureHandler::stringToNumber(std::string & s)
 
 CCreatureHandler::~CCreatureHandler()
 {
-	BOOST_FOREACH(auto & creature, creatures)
+	for(auto & creature : creatures)
 		creature.dellNull();
 }
 
@@ -1060,7 +1060,7 @@ CreatureID CCreatureHandler::pickRandomMonster(const std::function<int()> &randG
 	{
 		assert(vstd::iswithin(tier, 1, 7));
 		std::vector<CreatureID> allowed;
-		BOOST_FOREACH(const CBonusSystemNode *b, creaturesOfLevel[tier].getChildrenNodes())
+		for(const CBonusSystemNode *b : creaturesOfLevel[tier].getChildrenNodes())
 		{
 			assert(b->getNodeType() == CBonusSystemNode::CREATURE);
 			const CCreature * crea = dynamic_cast<const CCreature*>(b);
@@ -1093,14 +1093,14 @@ void CCreatureHandler::addBonusForAllCreatures(Bonus *b)
 
 void CCreatureHandler::buildBonusTreeForTiers()
 {
-	BOOST_FOREACH(CCreature *c, creatures)
+	for(CCreature *c : creatures)
 	{
 		if(vstd::isbetween(c->level, 0, ARRAY_COUNT(creaturesOfLevel)))
 			c->attachTo(&creaturesOfLevel[c->level]);
 		else
 			c->attachTo(&creaturesOfLevel[0]);
 	}
-	BOOST_FOREACH(CBonusSystemNode &b, creaturesOfLevel)
+	for(CBonusSystemNode &b : creaturesOfLevel)
 		b.attachTo(&allCreatures);
 }
 

+ 35 - 35
lib/CCreatureSet.cpp

@@ -24,7 +24,7 @@
 
 const CStackInstance &CCreatureSet::operator[](SlotID slot) const
 {
-	TSlots::const_iterator i = stacks.find(slot);
+	auto i = stacks.find(slot);
 	if (i != stacks.end())
 		return *i->second;
 	else
@@ -33,7 +33,7 @@ const CStackInstance &CCreatureSet::operator[](SlotID slot) const
 
 const CCreature* CCreatureSet::getCreature(SlotID slot) const
 {
-	TSlots::const_iterator i = stacks.find(slot);
+	auto i = stacks.find(slot);
 	if (i != stacks.end())
 		return i->second->type;
 	else
@@ -69,12 +69,12 @@ SlotID CCreatureSet::getSlotFor(CreatureID creature, ui32 slotsAmount/*=7*/) con
 SlotID CCreatureSet::getSlotFor(const CCreature *c, ui32 slotsAmount/*=ARMY_SIZE*/) const
 {
 	assert(c->valid());
-	for(TSlots::const_iterator i=stacks.begin(); i!=stacks.end(); ++i)
+	for(auto & elem : stacks)
 	{
-		assert(i->second->type->valid());
-		if(i->second->type == c)
+		assert(elem.second->type->valid());
+		if(elem.second->type == c)
 		{
-			return i->first; //if there is already such creature we return its slot id
+			return elem.first; //if there is already such creature we return its slot id
 		}
 	}
 	return getFreeSlot(slotsAmount);
@@ -94,7 +94,7 @@ SlotID CCreatureSet::getFreeSlot(ui32 slotsAmount/*=ARMY_SIZE*/) const
 
 int CCreatureSet::getStackCount(SlotID slot) const
 {
-	TSlots::const_iterator i = stacks.find(slot);
+	auto i = stacks.find(slot);
 	if (i != stacks.end())
 		return i->second->count;
 	else
@@ -103,7 +103,7 @@ int CCreatureSet::getStackCount(SlotID slot) const
 
 TExpType CCreatureSet::getStackExperience(SlotID slot) const
 {
-	TSlots::const_iterator i = stacks.find(slot);
+	auto i = stacks.find(slot);
 	if (i != stacks.end())
 		return i->second->experience;
 	else
@@ -117,25 +117,25 @@ bool CCreatureSet::mergableStacks(std::pair<SlotID, SlotID> &out, SlotID prefera
 	if(preferable.validSlot() &&  vstd::contains(stacks, preferable))
 	{
 		const CCreature *cr = stacks.find(preferable)->second->type;
-		for(TSlots::const_iterator j=stacks.begin(); j!=stacks.end(); ++j)
+		for(auto & elem : stacks)
 		{
-			if(cr == j->second->type && j->first != preferable)
+			if(cr == elem.second->type && elem.first != preferable)
 			{
 				out.first = preferable;
-				out.second = j->first;
+				out.second = elem.first;
 				return true;
 			}
 		}
 	}
 
-	for(TSlots::const_iterator i=stacks.begin(); i!=stacks.end(); ++i)
+	for(auto i=stacks.begin(); i!=stacks.end(); ++i)
 	{
-		for(TSlots::const_iterator j=stacks.begin(); j!=stacks.end(); ++j)
+		for(auto & elem : stacks)
 		{
-			if(i->second->type == j->second->type  &&  i->first != j->first)
+			if(i->second->type == elem.second->type  &&  i->first != elem.first)
 			{
 				out.first = i->first;
-				out.second = j->first;
+				out.second = elem.first;
 				return true;
 			}
 		}
@@ -145,7 +145,7 @@ bool CCreatureSet::mergableStacks(std::pair<SlotID, SlotID> &out, SlotID prefera
 
 void CCreatureSet::sweep()
 {
-	for(TSlots::iterator i=stacks.begin(); i!=stacks.end(); ++i)
+	for(auto i=stacks.begin(); i!=stacks.end(); ++i)
 	{
 		if(!i->second->count)
 		{
@@ -194,9 +194,9 @@ void CCreatureSet::addToSlot(SlotID slot, CStackInstance *stack, bool allowMergi
 
 bool CCreatureSet::validTypes(bool allowUnrandomized /*= false*/) const
 {
-	for(TSlots::const_iterator i=stacks.begin(); i!=stacks.end(); ++i)
+	for(auto & elem : stacks)
 	{
-		if(!i->second->valid(allowUnrandomized))
+		if(!elem.second->valid(allowUnrandomized))
 			return false;
 	}
 	return true;
@@ -215,8 +215,8 @@ bool CCreatureSet::needsLastStack() const
 ui64 CCreatureSet::getArmyStrength() const
 {
 	ui64 ret = 0;
-	for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
-		ret += i->second->getPower();
+	for(auto & elem : stacks)
+		ret += elem.second->getPower();
 	return ret;
 }
 
@@ -296,8 +296,8 @@ bool CCreatureSet::contains(const CStackInstance *stack) const
 	if(!stack)
 		return false;
 
-	for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); ++i)
-		if(i->second == stack)
+	for(auto & elem : stacks)
+		if(elem.second == stack)
 			return true;
 
 	return false;
@@ -312,9 +312,9 @@ SlotID CCreatureSet::findStack(const CStackInstance *stack) const
 	if(!stack)
 		return SlotID();
 
-	for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); ++i)
-		if(i->second == stack)
-			return i->first;
+	for(auto & elem : stacks)
+		if(elem.second == stack)
+			return elem.first;
 
 	return SlotID();
 }
@@ -369,7 +369,7 @@ void CCreatureSet::setToArmy(CSimpleArmy &src)
 	clear();
 	while(src)
 	{
-		TSimpleSlots::iterator i = src.army.begin();
+		auto i = src.army.begin();
 
 		assert(i->second.type);
 		assert(i->second.count);
@@ -409,11 +409,11 @@ bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStac
 	{
 		int freeSlots = stacksCount() - GameConstants::ARMY_SIZE;
 		std::set<const CCreature*> cresToAdd;
-		for(TSlots::const_iterator i = cs.stacks.begin(); i != cs.stacks.end(); i++)
+		for(auto & elem : cs.stacks)
 		{
-			SlotID dest = getSlotFor(i->second->type);
+			SlotID dest = getSlotFor(elem.second->type);
 			if(!dest.validSlot() || hasStackAtSlot(dest))
-				cresToAdd.insert(i->second->type);
+				cresToAdd.insert(elem.second->type);
 		}
 		return cresToAdd.size() <= freeSlots;
 	}
@@ -422,13 +422,13 @@ bool CCreatureSet::canBeMergedWith(const CCreatureSet &cs, bool allowMergingStac
 		CCreatureSet cres;
 
 		//get types of creatures that need their own slot
-		for(TSlots::const_iterator i = cs.stacks.begin(); i != cs.stacks.end(); i++)
-			cres.addToSlot(i->first, i->second->type->idNumber, 1, true);
+		for(auto & elem : cs.stacks)
+			cres.addToSlot(elem.first, elem.second->type->idNumber, 1, true);
 		SlotID j;
-		for(TSlots::const_iterator i = stacks.begin(); i != stacks.end(); i++)
+		for(auto & elem : stacks)
 		{
-			if ((j = cres.getSlotFor(i->second->type)).validSlot())
-				cres.addToSlot(j, i->second->type->idNumber, 1, true);  //merge if possible
+			if ((j = cres.getSlotFor(elem.second->type)).validSlot())
+				cres.addToSlot(j, elem.second->type->idNumber, 1, true);  //merge if possible
 			else
 				return false; //no place found
 		}
@@ -730,7 +730,7 @@ int CCommanderInstance::getLevel() const
 void CCommanderInstance::levelUp ()
 {
 	level++;
-	BOOST_FOREACH (auto bonus, VLC->creh->commanderLevelPremy)
+	for (auto bonus : VLC->creh->commanderLevelPremy)
 	{ //grant all regular level-up bonuses
 		accumulateBonus (*bonus);
 	}

+ 7 - 7
lib/CDefObjInfoHandler.cpp

@@ -18,9 +18,9 @@
 
 bool CGDefInfo::isVisitable() const
 {
-	for (int i=0; i<6; i++)
+	for (auto & elem : visitMap)
 	{
-		if (visitMap[i])
+		if (elem)
 			return true;
 	}
 	return false;
@@ -58,7 +58,7 @@ CDefObjInfoHandler::CDefObjInfoHandler()
 	std::string mapStr;
 	for(int hh=0; hh<objNumber; ++hh)
 	{
-		CGDefInfo* nobj = new CGDefInfo();
+		auto  nobj = new CGDefInfo();
 		std::string dump;
 		inp>>nobj->name;
 
@@ -120,9 +120,9 @@ CDefObjInfoHandler::CDefObjInfoHandler()
 				Obj::QUEST_GUARD,
 				Obj::CORPSE};
 
-			for(int i=0; i < ARRAY_COUNT(visitableFromTop); i++)
+			for(auto & elem : visitableFromTop)
 			{
-				if(visitableFromTop[i] == nobj->id)
+				if(elem == nobj->id)
 				{
 					nobj->visitDir = 0xff;
 					break;
@@ -163,7 +163,7 @@ CDefObjInfoHandler::CDefObjInfoHandler()
 
 CDefObjInfoHandler::~CDefObjInfoHandler()
 {
-	for(bmap<int,bmap<int, ConstTransitivePtr<CGDefInfo> > >::iterator i=gobjs.begin(); i!=gobjs.end(); i++)
-		for(bmap<int, ConstTransitivePtr<CGDefInfo> >::iterator j=i->second.begin(); j!=i->second.end(); j++)
+	for(auto & elem : gobjs)
+		for(auto j=elem.second.begin(); j!=elem.second.end(); j++)
 			j->second.dellNull();
 }

+ 168 - 170
lib/CGameState.cpp

@@ -113,8 +113,8 @@ public:
 
 	~CObjectCallersHandler()
 	{
-		for (size_t i = 0; i < apps.size(); i++)
-			delete apps[i];
+		for (auto & elem : apps)
+			delete elem;
 	}
 
 	void preInit()
@@ -221,9 +221,9 @@ DLL_LINKAGE void MetaString::toString(std::string &dst) const
 	size_t exSt = 0, loSt = 0, nums = 0;
 	dst.clear();
 
-	for(size_t i=0;i<message.size();++i)
+	for(auto & elem : message)
 	{//TEXACT_STRING, TLOCAL_STRING, TNUMBER, TREPLACE_ESTRING, TREPLACE_LSTRING, TREPLACE_NUMBER
-		switch(message[i])
+		switch(elem)
 		{
 		case TEXACT_STRING:
 			dst += exactStrings[exSt++];
@@ -343,7 +343,7 @@ static CGObjectInstance * createObject(Obj id, int subid, int3 pos, PlayerColor
 	{
 	case Obj::HERO:
 		{
-			CGHeroInstance * nobj = new CGHeroInstance();
+			auto  nobj = new CGHeroInstance();
 			nobj->pos = pos;
 			nobj->tempOwner = owner;
 			nobj->subID = subid;
@@ -389,12 +389,12 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
 
 	if(native)
 	{
-		for(auto i=available.begin(); i!=available.end(); i++)
+		for(auto & elem : available)
 		{
-			if(pavailable.find(i->first)->second & 1<<player.getNum()
-				&& i->second->type->heroClass->faction == town->faction->index)
+			if(pavailable.find(elem.first)->second & 1<<player.getNum()
+				&& elem.second->type->heroClass->faction == town->faction->index)
 			{
-				pool.push_back(i->second); //get all available heroes
+				pool.push_back(elem.second); //get all available heroes
 			}
 		}
 		if(!pool.size())
@@ -411,13 +411,13 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
 	{
 		int sum=0, r;
 
-		for(auto i=available.begin(); i!=available.end(); i++)
+		for(auto & elem : available)
 		{
-			if (pavailable.find(i->first)->second & (1<<player.getNum()) &&    // hero is available
-			    ( !bannedClass || i->second->type->heroClass != bannedClass) ) // and his class is not same as other hero
+			if (pavailable.find(elem.first)->second & (1<<player.getNum()) &&    // hero is available
+			    ( !bannedClass || elem.second->type->heroClass != bannedClass) ) // and his class is not same as other hero
 			{
-				pool.push_back(i->second);
-				sum += i->second->type->heroClass->selectionProbability[town->faction->index]; //total weight
+				pool.push_back(elem.second);
+				sum += elem.second->type->heroClass->selectionProbability[town->faction->index]; //total weight
 			}
 		}
 		if(!pool.size() || sum == 0)
@@ -427,12 +427,12 @@ CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor pl
 		}
 
 		r = rand()%sum;
-		for (ui32 i=0; i<pool.size(); i++)
+		for (auto & elem : pool)
 		{
-			r -= pool[i]->type->heroClass->selectionProbability[town->faction->index];
+			r -= elem->type->heroClass->selectionProbability[town->faction->index];
 			if(r < 0)
 			{
-				ret = pool[i];
+				ret = elem;
 				break;
 			}
 		}
@@ -470,7 +470,7 @@ int CGameState::pickHero(PlayerColor owner)
 	const size_t lastHero  = std::min(firstHero + GameConstants::HEROES_PER_TYPE*2, VLC->heroh->heroes.size()) - 1;
 	const auto heroesToConsider = getUnusedAllowedHeroes();
 
-	BOOST_FOREACH(auto hid, heroesToConsider)
+	for(auto hid : heroesToConsider)
 	{
 		if(vstd::iswithin(hid.getNum(), firstHero, lastHero))
 			factionHeroes.push_back(hid);
@@ -576,22 +576,22 @@ std::pair<Obj,int> CGameState::pickObject (CGObjectInstance *obj)
 				faction = ran() % VLC->townh->factions.size();
 				if (info->asCastle)
 				{
-					for(ui32 i=0;i<map->objects.size();i++)
+					for(auto & elem : map->objects)
 					{
-						if(!map->objects[i])
+						if(!elem)
 							continue;
 
-						if(map->objects[i]->ID==Obj::RANDOM_TOWN
-							&& dynamic_cast<CGTownInstance*>(map->objects[i].get())->identifier == info->identifier)
+						if(elem->ID==Obj::RANDOM_TOWN
+							&& dynamic_cast<CGTownInstance*>(elem.get())->identifier == info->identifier)
 						{
-							randomizeObject(map->objects[i]); //we have to randomize the castle first
-							faction = map->objects[i]->subID;
+							randomizeObject(elem); //we have to randomize the castle first
+							faction = elem->subID;
 							break;
 						}
-						else if(map->objects[i]->ID==Obj::TOWN
-							&& dynamic_cast<CGTownInstance*>(map->objects[i].get())->identifier == info->identifier)
+						else if(elem->ID==Obj::TOWN
+							&& dynamic_cast<CGTownInstance*>(elem.get())->identifier == info->identifier)
 						{
-							faction = map->objects[i]->subID;
+							faction = elem->subID;
 							break;
 						}
 					}
@@ -632,7 +632,7 @@ std::pair<Obj,int> CGameState::pickObject (CGObjectInstance *obj)
 
 			//NOTE: this will pick last dwelling with this creature (Mantis #900)
 			//check for block map equality is better but more complex solution
-			BOOST_FOREACH(auto &iter, VLC->objh->cregens)
+			for(auto &iter : VLC->objh->cregens)
 				if (iter.second == cid)
 					result = std::make_pair(Obj::CREATURE_GENERATOR1, iter.first);
 
@@ -764,7 +764,7 @@ CGameState::~CGameState()
 	delete applierGs;
 	delete objCaller;
 
-	BOOST_FOREACH(auto ptr, hpool.heroesPool) // clean hero pool
+	for(auto ptr : hpool.heroesPool) // clean hero pool
 		ptr.second.dellNull();
 }
 
@@ -826,7 +826,7 @@ void CGameState::init(StartInfo * si)
 						{
 							continue;
 						}
-						Bonus *bb = new Bonus(Bonus::PERMANENT, Bonus::PRIMARY_SKILL, Bonus::CAMPAIGN_BONUS, val, scenarioOps->campState->currentMap, g);
+						auto bb = new Bonus(Bonus::PERMANENT, Bonus::PRIMARY_SKILL, Bonus::CAMPAIGN_BONUS, val, scenarioOps->campState->currentMap, g);
 						hero->addNewBonus(bb);
 					}
 				}
@@ -967,9 +967,9 @@ void CGameState::init(StartInfo * si)
  		}
 
 		//remove tiles with holes
-		for(ui32 no=0; no<map->objects.size(); ++no)
-			if(map->objects[no] && map->objects[no]->ID == Obj::HOLE)
-				allowedPos -= map->objects[no]->pos;
+		for(auto & elem : map->objects)
+			if(elem && elem->ID == Obj::HOLE)
+				allowedPos -= elem->pos;
 
 		if(allowedPos.size())
 			map->grailPos = allowedPos[ran() % allowedPos.size()];
@@ -979,22 +979,21 @@ void CGameState::init(StartInfo * si)
 
 	//picking random factions for players
     logGlobal->debugStream() << "\tPicking random factions for players";
-	for(auto it = scenarioOps->playerInfos.begin();
-		it != scenarioOps->playerInfos.end(); ++it)
+	for(auto & elem : scenarioOps->playerInfos)
 	{
-		if(it->second.castle==-1)
+		if(elem.second.castle==-1)
 		{
-			int randomID = ran() % map->players[it->first.getNum()].allowedFactions.size();
-			auto iter = map->players[it->first.getNum()].allowedFactions.begin();
+			int randomID = ran() % map->players[elem.first.getNum()].allowedFactions.size();
+			auto iter = map->players[elem.first.getNum()].allowedFactions.begin();
 			std::advance(iter, randomID);
 
-			it->second.castle = *iter;
+			elem.second.castle = *iter;
 		}
 	}
 
 	//randomizing objects
     logGlobal->debugStream() << "\tRandomizing objects";
-	BOOST_FOREACH(CGObjectInstance *obj, map->objects)
+	for(CGObjectInstance *obj : map->objects)
 	{
 		if(!obj)
 			continue;
@@ -1015,12 +1014,11 @@ void CGameState::init(StartInfo * si)
 
 	/*********creating players entries in gs****************************************/
     logGlobal->debugStream() << "\tCreating player entries in gs";
-	for(auto it = scenarioOps->playerInfos.begin();
-		it != scenarioOps->playerInfos.end(); ++it)
+	for(auto & elem : scenarioOps->playerInfos)
 	{
-		std::pair<PlayerColor, PlayerState> ins(it->first,PlayerState());
+		std::pair<PlayerColor, PlayerState> ins(elem.first,PlayerState());
 		ins.second.color=ins.first;
-		ins.second.human = it->second.playerID;
+		ins.second.human = elem.second.playerID;
 		ins.second.team = map->players[ins.first.getNum()].team;
 		teams[ins.second.team].id = ins.second.team;//init team
 		teams[ins.second.team].players.insert(ins.first);//add player to team
@@ -1084,9 +1082,9 @@ void CGameState::init(StartInfo * si)
 	TResources startresAI(level["ai"]);
 	TResources startresHuman(level["human"]);
 
-	for (auto i = players.begin(); i!=players.end(); i++)
+	for (auto & elem : players)
 	{
-		PlayerState &p = i->second;
+		PlayerState &p = elem.second;
 
 		if (p.human)
 			p.resources = startresHuman;
@@ -1101,7 +1099,7 @@ void CGameState::init(StartInfo * si)
 		if(chosenBonus && chosenBonus->type == CScenarioTravel::STravelBonus::RESOURCE)
 		{
 			std::vector<const PlayerSettings *> people = getHumanPlayerInfo(); //players we will give resource bonus
-			BOOST_FOREACH(const PlayerSettings *ps, people)
+			for(const PlayerSettings *ps : people)
 			{
 				std::vector<int> res; //resources we will give
 				switch (chosenBonus->info1)
@@ -1120,9 +1118,9 @@ void CGameState::init(StartInfo * si)
 					break;
 				}
 				//increasing resource quantity
-				for (int n=0; n<res.size(); ++n)
+				for (auto & re : res)
 				{
-					players[ps->color].resources[res[n]] += chosenBonus->info2;
+					players[ps->color].resources[re] += chosenBonus->info2;
 				}
 			}
 		}
@@ -1130,7 +1128,7 @@ void CGameState::init(StartInfo * si)
 
 
 	/*************************HEROES INIT / POOL************************************************/
-	BOOST_FOREACH(auto hero, map->heroesOnMap)  //heroes instances initialization
+	for(auto hero : map->heroesOnMap)  //heroes instances initialization
 	{
 		if (hero->getOwner() == PlayerColor::UNFLAGGABLE)
 		{
@@ -1143,14 +1141,14 @@ void CGameState::init(StartInfo * si)
 		map->allHeroes[hero->type->ID.getNum()] = hero;
 	}
 
-	BOOST_FOREACH(auto obj, map->objects) //prisons
+	for(auto obj : map->objects) //prisons
 	{
 		if(obj && obj->ID == Obj::PRISON)
 			map->allHeroes[obj->subID] = dynamic_cast<CGHeroInstance*>(obj.get());
 	}
 
 	std::set<HeroTypeID> heroesToCreate = getUnusedAllowedHeroes(); //ids of heroes to be created and put into the pool
-	BOOST_FOREACH(auto ph, map->predefinedHeroes)
+	for(auto ph : map->predefinedHeroes)
 	{
 		if(!vstd::contains(heroesToCreate, HeroTypeID(ph->subID)))
 			continue;
@@ -1162,9 +1160,9 @@ void CGameState::init(StartInfo * si)
 		map->allHeroes[ph->subID] = ph;
 	}
 
-	BOOST_FOREACH(HeroTypeID htype, heroesToCreate) //all not used allowed heroes go with default state into the pool
+	for(HeroTypeID htype : heroesToCreate) //all not used allowed heroes go with default state into the pool
 	{
-		CGHeroInstance * vhi = new CGHeroInstance();
+		auto  vhi = new CGHeroInstance();
 		vhi->initHero(htype);
 
 		int typeID = htype.getNum();
@@ -1173,9 +1171,9 @@ void CGameState::init(StartInfo * si)
 		hpool.pavailable[typeID] = 0xff;
 	}
 
-	for(ui32 i=0; i<map->disposedHeroes.size(); i++)
+	for(auto & elem : map->disposedHeroes)
 	{
-        hpool.pavailable[map->disposedHeroes[i].heroId] = map->disposedHeroes[i].players;
+        hpool.pavailable[elem.heroId] = elem.players;
 	}
 
 	if (scenarioOps->mode == StartInfo::CAMPAIGN) //give campaign bonuses for specific / best hero
@@ -1185,11 +1183,11 @@ void CGameState::init(StartInfo * si)
 		{
 			//find human player
 			PlayerColor humanPlayer=PlayerColor::NEUTRAL;
-			for (auto it=players.begin(); it != players.end(); ++it)
+			for (auto & elem : players)
 			{
-				if(it->second.human)
+				if(elem.second.human)
 				{
-					humanPlayer = it->first;
+					humanPlayer = elem.first;
 					break;
 				}
 			}
@@ -1214,11 +1212,11 @@ void CGameState::init(StartInfo * si)
 			}
 			else //specific hero
 			{
-				for (int b=0; b<heroes.size(); ++b)
+				for (auto & heroe : heroes)
 				{
-					if (heroes[b]->subID == chosenBonus->info1)
+					if (heroe->subID == chosenBonus->info1)
 					{
-						giveCampaignBonusToHero(heroes[b]);
+						giveCampaignBonusToHero(heroe);
 						break;
 					}
 				}
@@ -1228,62 +1226,62 @@ void CGameState::init(StartInfo * si)
 
 	/*************************FOG**OF**WAR******************************************/
     logGlobal->debugStream() << "\tFog of war"; //FIXME: should be initialized after all bonuses are set
-	for(auto k=teams.begin(); k!=teams.end(); ++k)
+	for(auto & elem : teams)
 	{
-		k->second.fogOfWarMap.resize(map->width);
+		elem.second.fogOfWarMap.resize(map->width);
 		for(int g=0; g<map->width; ++g)
-			k->second.fogOfWarMap[g].resize(map->height);
+			elem.second.fogOfWarMap[g].resize(map->height);
 
 		for(int g=-0; g<map->width; ++g)
 			for(int h=0; h<map->height; ++h)
-				k->second.fogOfWarMap[g][h].resize(map->twoLevel ? 2 : 1, 0);
+				elem.second.fogOfWarMap[g][h].resize(map->twoLevel ? 2 : 1, 0);
 
 		for(int g=0; g<map->width; ++g)
 			for(int h=0; h<map->height; ++h)
 				for(int v = 0; v < (map->twoLevel ? 2 : 1); ++v)
-					k->second.fogOfWarMap[g][h][v] = 0;
+					elem.second.fogOfWarMap[g][h][v] = 0;
 
-		BOOST_FOREACH(CGObjectInstance *obj, map->objects)
+		for(CGObjectInstance *obj : map->objects)
 		{
-			if(!obj || !vstd::contains(k->second.players, obj->tempOwner)) continue; //not a flagged object
+			if(!obj || !vstd::contains(elem.second.players, obj->tempOwner)) continue; //not a flagged object
 
-			boost::unordered_set<int3, ShashInt3> tiles;
+			std::unordered_set<int3, ShashInt3> tiles;
 			obj->getSightTiles(tiles);
-			BOOST_FOREACH(int3 tile, tiles)
+			for(int3 tile : tiles)
 			{
-				k->second.fogOfWarMap[tile.x][tile.y][tile.z] = 1;
+				elem.second.fogOfWarMap[tile.x][tile.y][tile.z] = 1;
 			}
 		}
 	}
 
     logGlobal->debugStream() << "\tStarting bonuses";
-	for(auto k=players.begin(); k!=players.end(); ++k)
+	for(auto & elem : players)
 	{
 		//starting bonus
-		if(scenarioOps->playerInfos[k->first].bonus==PlayerSettings::RANDOM)
-			scenarioOps->playerInfos[k->first].bonus = static_cast<PlayerSettings::Ebonus>(ran()%3);
-		switch(scenarioOps->playerInfos[k->first].bonus)
+		if(scenarioOps->playerInfos[elem.first].bonus==PlayerSettings::RANDOM)
+			scenarioOps->playerInfos[elem.first].bonus = static_cast<PlayerSettings::Ebonus>(ran()%3);
+		switch(scenarioOps->playerInfos[elem.first].bonus)
 		{
 		case PlayerSettings::GOLD:
-			k->second.resources[Res::GOLD] += 500 + (ran()%6)*100;
+			elem.second.resources[Res::GOLD] += 500 + (ran()%6)*100;
 			break;
 		case PlayerSettings::RESOURCE:
 			{
-				int res = VLC->townh->factions[scenarioOps->playerInfos[k->first].castle]->town->primaryRes;
+				int res = VLC->townh->factions[scenarioOps->playerInfos[elem.first].castle]->town->primaryRes;
 				if(res == Res::WOOD_AND_ORE)
 				{
-					k->second.resources[Res::WOOD] += 5 + ran()%6;
-					k->second.resources[Res::ORE] += 5 + ran()%6;
+					elem.second.resources[Res::WOOD] += 5 + ran()%6;
+					elem.second.resources[Res::ORE] += 5 + ran()%6;
 				}
 				else
 				{
-					k->second.resources[res] += 3 + ran()%4;
+					elem.second.resources[res] += 3 + ran()%4;
 				}
 				break;
 			}
 		case PlayerSettings::ARTIFACT:
 			{
- 				if(!k->second.heroes.size())
+ 				if(!elem.second.heroes.size())
 				{
                     logGlobal->debugStream() << "Cannot give starting artifact - no heroes!";
 					break;
@@ -1291,7 +1289,7 @@ void CGameState::init(StartInfo * si)
  				CArtifact *toGive;
  				toGive = VLC->arth->artifacts[VLC->arth->getRandomArt (CArtifact::ART_TREASURE)];
 
-				CGHeroInstance *hero = k->second.heroes[0];
+				CGHeroInstance *hero = elem.second.heroes[0];
  				giveHeroArtifact(hero, toGive->id);
 			}
 			break;
@@ -1330,9 +1328,9 @@ void CGameState::init(StartInfo * si)
 	for ( int i=0; i<4; i++)
 		CGTownInstance::universitySkills.push_back(14+i);//skills for university
 
-	for (ui32 i=0;i<map->towns.size();i++)
+	for (auto & elem : map->towns)
 	{
-		CGTownInstance * vti =(map->towns[i]);
+		CGTownInstance * vti =(elem);
 		if(!vti->town)
 			vti->town = VLC->townh->factions[vti->subID]->town;
 		if (vti->name.length()==0) // if town hasn't name we draw it
@@ -1372,7 +1370,7 @@ void CGameState::init(StartInfo * si)
 			}
 
 		//town events
-		BOOST_FOREACH(CCastleEvent &ev, vti->events)
+		for(CCastleEvent &ev : vti->events)
 		{
 			for (int i = 0; i<GameConstants::CREATURES_PER_TOWN; i++)
 				if (vstd::contains(ev.buildings,(-31-i))) //if we have horde for this level
@@ -1428,12 +1426,12 @@ void CGameState::init(StartInfo * si)
 
     logGlobal->debugStream() << "\tObject initialization";
 	objCaller->preInit();
-	BOOST_FOREACH(CGObjectInstance *obj, map->objects)
+	for(CGObjectInstance *obj : map->objects)
 	{
 		if(obj)
 			obj->initObj();
 	}
-	BOOST_FOREACH(CGObjectInstance *obj, map->objects)
+	for(CGObjectInstance *obj : map->objects)
 	{
 		if(!obj)
 			continue;
@@ -1459,9 +1457,9 @@ void CGameState::init(StartInfo * si)
 			continue;
 
 		//init visiting and garrisoned heroes
-		BOOST_FOREACH(CGHeroInstance *h, k->second.heroes)
+		for(CGHeroInstance *h : k->second.heroes)
 		{
-			BOOST_FOREACH(CGTownInstance *t, k->second.towns)
+			for(CGTownInstance *t : k->second.towns)
 			{
 				int3 vistile = t->pos; vistile.x--; //tile next to the entrance
 				if(vistile == h->pos || h->pos==t->pos)
@@ -1519,8 +1517,8 @@ void CGameState::initDuel()
 		throw;
 	}
 
-	const CArmedInstance *armies[2] = {0};
-	const CGHeroInstance *heroes[2] = {0};
+	const CArmedInstance *armies[2] = {nullptr};
+	const CGHeroInstance *heroes[2] = {nullptr};
 	CGTownInstance *town = nullptr;
 
 	for(int i = 0; i < 2; i++)
@@ -1529,7 +1527,7 @@ void CGameState::initDuel()
 		if(dp.sides[i].heroId >= 0)
 		{
 			const DuelParameters::SideSettings &ss = dp.sides[i];
-			CGHeroInstance *h = new CGHeroInstance();
+			auto h = new CGHeroInstance();
 			armies[i] = heroes[i] = h;
 			obj = h;
 			h->subID = ss.heroId;
@@ -1542,13 +1540,13 @@ void CGameState::initDuel()
 				boost::copy(ss.spells, std::inserter(h->spells, h->spells.begin()));
 			}
 
-			BOOST_FOREACH(auto &parka, ss.artifacts)
+			for(auto &parka : ss.artifacts)
 			{
 				h->putArtifact(ArtifactPosition(parka.first), parka.second);
 			}
 
 			typedef const std::pair<si32, si8> &TSecSKill;
-			BOOST_FOREACH(TSecSKill secSkill, ss.heroSecSkills)
+			for(TSecSKill secSkill : ss.heroSecSkills)
 				h->setSecSkillLevel(SecondarySkill(secSkill.first), secSkill.second, 1);
 
 			h->initHero(HeroTypeID(h->subID));
@@ -1556,7 +1554,7 @@ void CGameState::initDuel()
 		}
 		else
 		{
-			CGCreature *c = new CGCreature();
+			auto c = new CGCreature();
 			armies[i] = obj = c;
 			//c->subID = 34;
 		}
@@ -1571,7 +1569,7 @@ void CGameState::initDuel()
 				obj->setCreature(SlotID(j), cre, count);
 		}
 
-		BOOST_FOREACH(const DuelParameters::CusomCreature &cc, dp.creatures)
+		for(const DuelParameters::CusomCreature &cc : dp.creatures)
 		{
 			CCreature *c = VLC->creh->creatures[cc.id];
 			if(cc.attack >= 0)
@@ -1610,7 +1608,7 @@ BFieldType CGameState::battleGetBattlefieldType(int3 tile) const
 	if(dynamic_cast<const CGMine *>(t.visitableObjects.front()))
 		return BFieldType::SUBTERRANEAN;
 
-	BOOST_FOREACH(auto &obj, map->objects)
+	for(auto &obj : map->objects)
 	{
 		//look only for objects covering given tile
 		if( !obj || obj->pos.z != tile.z
@@ -1685,7 +1683,7 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
 	else if(h)
 	{	//hero specialty
 		TBonusListPtr lista = h->getBonuses(Selector::typeSubtype(Bonus::SPECIAL_UPGRADE, base->idNumber));
-		BOOST_FOREACH(const Bonus *it, *lista)
+		for(const Bonus *it : *lista)
 		{
 			auto nid = CreatureID(it->additionalInfo);
 			if (nid != base->idNumber) //in very specific case the upgrade is available by default (?)
@@ -1698,11 +1696,11 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
 	}
 	if(t)
 	{
-		BOOST_FOREACH(const CGTownInstance::TCreaturesSet::value_type & dwelling, t->creatures)
+		for(const CGTownInstance::TCreaturesSet::value_type & dwelling : t->creatures)
 		{
 			if (vstd::contains(dwelling.second, base->idNumber)) //Dwelling with our creature
 			{
-				BOOST_FOREACH(auto upgrID, dwelling.second)
+				for(auto upgrID : dwelling.second)
 				{
 					if(vstd::contains(base->upgrades, upgrID)) //possible upgrade
 					{
@@ -1720,7 +1718,7 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
 		static const int costModifiers[] = {0, 25, 50, 75, 100}; //we get cheaper upgrades depending on level
 		const int costModifier = costModifiers[std::min<int>(std::max((int)base->level - 1, 0), ARRAY_COUNT(costModifiers) - 1)];
 
-		BOOST_FOREACH(auto nid, base->upgrades)
+		for(auto nid : base->upgrades)
 		{
 			ret.newID.push_back(nid);
 			ret.cost.push_back((VLC->creh->creatures[nid]->cost - base->cost) * costModifier / 100);
@@ -1751,9 +1749,9 @@ void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<i
 	static const int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0),
 					int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) };
 
-	for (size_t i = 0; i < ARRAY_COUNT(dirs); i++)
+	for (auto & dir : dirs)
 	{
-		const int3 hlp = tile + dirs[i];
+		const int3 hlp = tile + dir;
 		if(!map->isInTheMap(hlp))
 			continue;
 
@@ -1765,12 +1763,12 @@ void CGameState::getNeighbours(const TerrainTile &srct, int3 tile, std::vector<i
 // 			continue;
 // 		}
 
-        if(srct.terType == ETerrainType::WATER && limitCoastSailing && hlpt.terType == ETerrainType::WATER && dirs[i].x && dirs[i].y) //diagonal move through water
+        if(srct.terType == ETerrainType::WATER && limitCoastSailing && hlpt.terType == ETerrainType::WATER && dir.x && dir.y) //diagonal move through water
 		{
 			int3 hlp1 = tile,
 				hlp2 = tile;
-			hlp1.x += dirs[i].x;
-			hlp2.y += dirs[i].y;
+			hlp1.x += dir.x;
+			hlp2.y += dir.y;
 
             if(map->getTile(hlp1).terType != ETerrainType::WATER || map->getTile(hlp2).terType != ETerrainType::WATER)
 				continue;
@@ -1829,9 +1827,9 @@ int CGameState::getMovementCost(const CGHeroInstance *h, const int3 &src, const
 	{
 		std::vector<int3> vec;
         getNeighbours(d, dest, vec, s.terType != ETerrainType::WATER, true);
-		for(size_t i=0; i < vec.size(); i++)
+		for(auto & elem : vec)
 		{
-			int fcost = getMovementCost(h,dest,vec[i],left,false);
+			int fcost = getMovementCost(h,dest,elem,left,false);
 			if(fcost <= left)
 			{
 				return ret;
@@ -1871,7 +1869,7 @@ std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
 	const TerrainTile &posTile = map->getTile(pos);
 	if (posTile.visitable)
 	{
-		BOOST_FOREACH (CGObjectInstance* obj, posTile.visitableObjects)
+		for (CGObjectInstance* obj : posTile.visitableObjects)
 		{
 			if(obj->blockVisit)
 			{
@@ -1890,7 +1888,7 @@ std::vector<CGObjectInstance*> CGameState::guardingCreatures (int3 pos) const
 				const auto & tile = map->getTile(pos);
                 if (tile.visitable && (tile.isWater() == posTile.isWater()))
 				{
-					BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
+					for (CGObjectInstance* obj : tile.visitableObjects)
 					{
 						if (obj->ID == Obj::MONSTER  &&  checkForVisitableDir(pos, &map->getTile(originalPos), originalPos)) // Monster being able to attack investigated tile
 						{
@@ -1918,7 +1916,7 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
 	const TerrainTile &posTile = map->getTile(pos);
 	if (posTile.visitable)
 	{
-		BOOST_FOREACH (CGObjectInstance* obj, posTile.visitableObjects)
+		for (CGObjectInstance* obj : posTile.visitableObjects)
 		{
 			if(obj->blockVisit)
 			{
@@ -1941,7 +1939,7 @@ int3 CGameState::guardingCreaturePosition (int3 pos) const
 				const auto & tile = map->getTile(pos);
                 if (tile.visitable && (tile.isWater() == posTile.isWater()))
 				{
-					BOOST_FOREACH (CGObjectInstance* obj, tile.visitableObjects)
+					for (CGObjectInstance* obj : tile.visitableObjects)
 					{
 						if (obj->ID == Obj::MONSTER  &&  checkForVisitableDir(pos, &map->getTile(originalPos), originalPos)) // Monster being able to attack investigated tile
 						{
@@ -2064,8 +2062,8 @@ int CGameState::victoryCheck( PlayerColor player ) const
 		{
 		case EVictoryConditionType::ARTIFACT:
 			//check if any hero has winning artifact
-			for(size_t i = 0; i < p->heroes.size(); i++)
-                if(p->heroes[i]->hasArt(map->victoryCondition.objectId))
+			for(auto & elem : p->heroes)
+                if(elem->hasArt(map->victoryCondition.objectId))
 					return 1;
 
 			break;
@@ -2081,9 +2079,9 @@ int CGameState::victoryCheck( PlayerColor player ) const
 						&& map->objects[i]->tempOwner == player //object controlled by player
 						&&  (ai = dynamic_cast<const CArmedInstance*>(map->objects[i].get()))) //contains army
 					{
-						for(TSlots::const_iterator i=ai->Slots().begin(); i!=ai->Slots().end(); ++i) //iterate through army
-                            if(i->second->type->idNumber == map->victoryCondition.objectId) //it's searched creature
-								total += i->second->count;
+						for(auto & elem : ai->Slots()) //iterate through army
+                            if(elem.second->type->idNumber == map->victoryCondition.objectId) //it's searched creature
+								total += elem.second->count;
 					}
 				}
 
@@ -2107,7 +2105,7 @@ int CGameState::victoryCheck( PlayerColor player ) const
 			break;
 
 		case EVictoryConditionType::BUILDGRAIL:
-			BOOST_FOREACH(const CGTownInstance *t, map->towns)
+			for(const CGTownInstance *t : map->towns)
 				if((t == map->victoryCondition.obj || !map->victoryCondition.obj)
 					&& t->tempOwner == player
 					&& t->hasBuilt(BuildingID::GRAIL))
@@ -2129,11 +2127,11 @@ int CGameState::victoryCheck( PlayerColor player ) const
 				return 1;
 			break;
 		case EVictoryConditionType::TAKEDWELLINGS:
-			for(size_t i = 0; i < map->objects.size(); i++)
+			for(auto & elem : map->objects)
 			{
-				if(map->objects[i] && map->objects[i]->tempOwner != player) //check not flagged objs
+				if(elem && elem->tempOwner != player) //check not flagged objs
 				{
-					switch(map->objects[i]->ID)
+					switch(elem->ID)
 					{
 					case Obj::CREATURE_GENERATOR1: case Obj::CREATURE_GENERATOR2:
 					case Obj::CREATURE_GENERATOR3: case Obj::CREATURE_GENERATOR4:
@@ -2145,11 +2143,11 @@ int CGameState::victoryCheck( PlayerColor player ) const
 			return 1;
 			break;
 		case EVictoryConditionType::TAKEMINES:
-			for(size_t i = 0; i < map->objects.size(); i++)
+			for(auto & elem : map->objects)
 			{
-				if(map->objects[i] && map->objects[i]->tempOwner != player) //check not flagged objs
+				if(elem && elem->tempOwner != player) //check not flagged objs
 				{
-					switch(map->objects[i]->ID)
+					switch(elem->ID)
 					{
 					case Obj::MINE: case Obj::ABANDONED_MINE:
 						return 0; //found not flagged mine - player not won
@@ -2180,17 +2178,17 @@ PlayerColor CGameState::checkForStandardWin() const
 	//all enemies lost
 	PlayerColor supposedWinner = PlayerColor::NEUTRAL;
 	TeamID winnerTeam = TeamID::NO_TEAM;
-	for(auto i = players.begin(); i != players.end(); i++)
+	for(auto & elem : players)
 	{
-		if(i->second.status == EPlayerStatus::INGAME && i->first < PlayerColor::PLAYER_LIMIT)
+		if(elem.second.status == EPlayerStatus::INGAME && elem.first < PlayerColor::PLAYER_LIMIT)
 		{
 			if(supposedWinner == PlayerColor::NEUTRAL)
 			{
 				//first player remaining ingame - candidate for victory
-				supposedWinner = i->second.color;
-				winnerTeam = i->second.team;
+				supposedWinner = elem.second.color;
+				winnerTeam = elem.second.team;
 			}
-			else if(winnerTeam != i->second.team)
+			else if(winnerTeam != elem.second.team)
 			{
 				//current candidate has enemy remaining in game -> no vicotry
 				return PlayerColor::NEUTRAL;
@@ -2267,7 +2265,7 @@ struct statsHLP
 	static int getNumberOfArts(const PlayerState * ps)
 	{
 		int ret = 0;
-		BOOST_FOREACH(auto h, ps->heroes)
+		for(auto h : ps->heroes)
 		{
 			ret += h->artifactsInBackpack.size() + h->artifactsWorn.size();
 		}
@@ -2279,7 +2277,7 @@ struct statsHLP
 	{
 		si64 str = 0;
 
-		BOOST_FOREACH(auto h, ps->heroes)
+		for(auto h : ps->heroes)
 		{
 			if(!h->inTownGarrison)		//original h3 behavior
 				str += h->getArmyStrength();
@@ -2305,10 +2303,10 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
 		tgi.FIELD = statsHLP::getRank(stats); \
 	}
 
-	for(auto g = players.begin(); g != players.end(); ++g)
+	for(auto & elem : players)
 	{
-		if(g->second.color != PlayerColor::NEUTRAL)
-			tgi.playerColors.push_back(g->second.color);
+		if(elem.second.color != PlayerColor::NEUTRAL)
+			tgi.playerColors.push_back(elem.second.color);
 	}
 
 	if(level >= 1) //num of towns & num of heroes
@@ -2386,9 +2384,9 @@ void CGameState::obtainPlayersStats(SThievesGuildInfo & tgi, int level)
 			if(g->second.color == PlayerColor::NEUTRAL) //do nothing for neutral player
 				continue;
 			int bestCre = -1; //best creature's ID
-			for(int b=0; b<g->second.heroes.size(); ++b)
+			for(auto & elem : g->second.heroes)
 			{
-				for(TSlots::const_iterator it = g->second.heroes[b]->Slots().begin(); it != g->second.heroes[b]->Slots().end(); ++it)
+				for(auto it = elem->Slots().begin(); it != elem->Slots().end(); ++it)
 				{
 					int toCmp = it->second->type->idNumber; //ID of creature we should compare with the best one
 					if(bestCre == -1 || VLC->creh->creatures[bestCre]->AIValue < VLC->creh->creatures[toCmp]->AIValue)
@@ -2458,7 +2456,7 @@ void CGameState::buildBonusSystemTree()
 	buildGlobalTeamPlayerTree();
 	attachArmedObjects();
 
-	BOOST_FOREACH(CGTownInstance *t, map->towns)
+	for(CGTownInstance *t : map->towns)
 	{
 		t->deserializationFix();
 	}
@@ -2479,7 +2477,7 @@ void CGameState::buildGlobalTeamPlayerTree()
 		TeamState *t = &k->second;
 		t->attachTo(&globalEffects);
 
-		BOOST_FOREACH(PlayerColor teamMember, k->second.players)
+		for(PlayerColor teamMember : k->second.players)
 		{
 			PlayerState *p = getPlayer(teamMember);
 			assert(p);
@@ -2490,7 +2488,7 @@ void CGameState::buildGlobalTeamPlayerTree()
 
 void CGameState::attachArmedObjects()
 {
-	BOOST_FOREACH(CGObjectInstance *obj, map->objects)
+	for(CGObjectInstance *obj : map->objects)
 	{
 		if(CArmedInstance *armed = dynamic_cast<CArmedInstance*>(obj))
 			armed->whatShouldBeAttached()->attachTo(armed->whereShouldBeAttached(this));
@@ -2512,7 +2510,7 @@ std::set<HeroTypeID> CGameState::getUnusedAllowedHeroes(bool alsoIncludeNotAllow
 		if(map->allowedHeroes[i] || alsoIncludeNotAllowed)
 			ret.insert(HeroTypeID(i));
 
-	BOOST_FOREACH(auto hero, map->heroesOnMap)  //heroes instances initialization
+	for(auto hero : map->heroesOnMap)  //heroes instances initialization
 	{
 		if(hero->type)
 			ret -= hero->type->ID;
@@ -2520,7 +2518,7 @@ std::set<HeroTypeID> CGameState::getUnusedAllowedHeroes(bool alsoIncludeNotAllow
 			ret -= HeroTypeID(hero->subID);
 	}
 
-	BOOST_FOREACH(auto obj, map->objects) //prisons
+	for(auto obj : map->objects) //prisons
 		if(obj && obj->ID == Obj::PRISON)
 			ret -= HeroTypeID(obj->subID);
 
@@ -2562,7 +2560,7 @@ std::vector<std::pair<CGHeroInstance*, ObjectInstanceID> > CGameState::campaignH
 			if(hp->subID != 0xFF) //select by type
 			{
 				bool found = false;
-				BOOST_FOREACH(auto ghi, Xheroes)
+				for(auto ghi : Xheroes)
 				{
 					if (ghi->subID == hp->subID)
 					{
@@ -2574,7 +2572,7 @@ std::vector<std::pair<CGHeroInstance*, ObjectInstanceID> > CGameState::campaignH
 				}
 				if (!found)
 				{
-					CGHeroInstance * nh = new CGHeroInstance();
+					auto  nh = new CGHeroInstance();
 					nh->initHero(HeroTypeID(hp->subID));
 					replaceHero(gid, nh);
 				}
@@ -2619,7 +2617,7 @@ std::vector<std::pair<CGHeroInstance*, ObjectInstanceID> > CGameState::campaignH
 
 void CGameState::placeCampaignHeroes(const std::vector<std::pair<CGHeroInstance*, ObjectInstanceID> > &campHeroReplacements)
 {
-	BOOST_FOREACH(auto obj, campHeroReplacements)
+	for(auto obj : campHeroReplacements)
 	{
 		CGHeroPlaceholder *placeholder = dynamic_cast<CGHeroPlaceholder*>(getObjInstance(obj.second));
 
@@ -2629,7 +2627,7 @@ void CGameState::placeCampaignHeroes(const std::vector<std::pair<CGHeroInstance*
 		heroToPlace->pos = placeholder->pos;
 		heroToPlace->type = VLC->heroh->heroes[heroToPlace->type->ID.getNum()]; //TODO is this reasonable? either old type can be still used or it can be deleted?
 
-		BOOST_FOREACH(auto &&i, heroToPlace->stacks)
+		for(auto &&i : heroToPlace->stacks)
 			i.second->type = VLC->creh->creatures[i.second->getCreatureID()];
 
 		auto fixArtifact = [&](CArtifactInstance * art)
@@ -2639,9 +2637,9 @@ void CGameState::placeCampaignHeroes(const std::vector<std::pair<CGHeroInstance*
 			art->id = ArtifactInstanceID(gs->map->artInstances.size() - 1);
 		};
 
-		BOOST_FOREACH(auto &&i, heroToPlace->artifactsWorn)
+		for(auto &&i : heroToPlace->artifactsWorn)
 			fixArtifact(i.second.artifact);
-		BOOST_FOREACH(auto &&i, heroToPlace->artifactsInBackpack)
+		for(auto &&i : heroToPlace->artifactsInBackpack)
 			fixArtifact(i.artifact);
 
 		map->heroesOnMap.push_back(heroToPlace);
@@ -2654,11 +2652,11 @@ void CGameState::placeCampaignHeroes(const std::vector<std::pair<CGHeroInstance*
 
 bool CGameState::isUsedHero(HeroTypeID hid) const
 {
-	BOOST_FOREACH(auto hero, map->heroesOnMap)  //heroes instances initialization
+	for(auto hero : map->heroesOnMap)  //heroes instances initialization
 		if(hero->subID == hid.getNum())
 			return true;
 
-	BOOST_FOREACH(auto obj, map->objects) //prisons
+	for(auto obj : map->objects) //prisons
 		if(obj && obj->ID == Obj::PRISON  && obj->subID == hid.getNum())
 			return true;
 
@@ -2741,9 +2739,9 @@ void CGPath::convert( ui8 mode )
 {
 	if(mode==0)
 	{
-		for(ui32 i=0;i<nodes.size();i++)
+		for(auto & elem : nodes)
 		{
-			nodes[i].coord = CGHeroInstance::convertPosition(nodes[i].coord,true);
+			elem.coord = CGHeroInstance::convertPosition(elem.coord,true);
 		}
 	}
 }
@@ -2885,12 +2883,12 @@ void InfoAboutTown::initFromTown(const CGTownInstance *t, bool detailed)
 ArmyDescriptor::ArmyDescriptor(const CArmedInstance *army, bool detailed)
     : isDetailed(detailed)
 {
-	for(TSlots::const_iterator i = army->Slots().begin(); i != army->Slots().end(); i++)
+	for(auto & elem : army->Slots())
 	{
 		if(detailed)
-			(*this)[i->first] = *i->second;
+			(*this)[elem.first] = *elem.second;
 		else
-			(*this)[i->first] = CStackBasicDescriptor(i->second->type, i->second->getQuantityID());
+			(*this)[elem.first] = CStackBasicDescriptor(elem.second->type, elem.second->getQuantityID());
 	}
 }
 
@@ -2905,13 +2903,13 @@ int ArmyDescriptor::getStrength() const
 	ui64 ret = 0;
 	if(isDetailed)
 	{
-		for(const_iterator i = begin(); i != end(); i++)
-			ret += i->second.type->AIValue * i->second.count;
+		for(auto & elem : *this)
+			ret += elem.second.type->AIValue * elem.second.count;
 	}
 	else
 	{
-		for(const_iterator i = begin(); i != end(); i++)
-			ret += i->second.type->AIValue * CCreature::estimateCreatureCount(i->second.count);
+		for(auto & elem : *this)
+			ret += elem.second.type->AIValue * CCreature::estimateCreatureCount(elem.second.count);
 	}
 	return ret;
 }
@@ -2944,11 +2942,11 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
 	const JsonNode duelData(ResourceID("DATA/" + fname, EResType::TEXT));
 	ret.terType = ETerrainType((int)duelData["terType"].Float());
 	ret.bfieldType = BFieldType((int)duelData["bfieldType"].Float());
-	BOOST_FOREACH(const JsonNode &n, duelData["sides"].Vector())
+	for(const JsonNode &n : duelData["sides"].Vector())
 	{
 		SideSettings &ss = ret.sides[(int)n["side"].Float()];
 		int i = 0;
-		BOOST_FOREACH(const JsonNode &stackNode, n["army"].Vector())
+		for(const JsonNode &stackNode : n["army"].Vector())
 		{
 			ss.stacks[i].type = CreatureID((si32)stackNode.Vector()[0].Float());
 			ss.stacks[i].count = stackNode.Vector()[1].Float();
@@ -2960,10 +2958,10 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
 		else
 			ss.heroId = -1;
 
-		BOOST_FOREACH(const JsonNode &n, n["heroPrimSkills"].Vector())
+		for(const JsonNode &n : n["heroPrimSkills"].Vector())
 			ss.heroPrimSkills.push_back(n.Float());
 
-		BOOST_FOREACH(const JsonNode &skillNode, n["heroSecSkills"].Vector())
+		for(const JsonNode &skillNode : n["heroSecSkills"].Vector())
 		{
 			std::pair<si32, si8> secSkill;
 			secSkill.first = skillNode.Vector()[0].Float();
@@ -2978,17 +2976,17 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
 			const JsonNode & spells = n["spells"];
 			if(spells.getType() == JsonNode::DATA_STRING  &&  spells.String() == "all")
 			{
-				BOOST_FOREACH(auto spell, VLC->spellh->spells)
+				for(auto spell : VLC->spellh->spells)
 					if(spell->id <= SpellID::SUMMON_AIR_ELEMENTAL)
 						ss.spells.insert(spell->id);
 			}
 			else
-				BOOST_FOREACH(const JsonNode &spell, n["spells"].Vector())
+				for(const JsonNode &spell : n["spells"].Vector())
 					ss.spells.insert(SpellID(spell.Float()));
 		}
 	}
 
-	BOOST_FOREACH(const JsonNode &n, duelData["obstacles"].Vector())
+	for(const JsonNode &n : duelData["obstacles"].Vector())
 	{
 		auto oi = make_shared<CObstacleInstance>();
 		if(n.getType() == JsonNode::DATA_VECTOR)
@@ -3006,7 +3004,7 @@ DuelParameters DuelParameters::fromJSON(const std::string &fname)
 		ret.obstacles.push_back(oi);
 	}
 
-	BOOST_FOREACH(const JsonNode &n, duelData["creatures"].Vector())
+	for(const JsonNode &n : duelData["creatures"].Vector())
 	{
 		CusomCreature cc;
 		cc.id = n["id"].Float();
@@ -3128,9 +3126,9 @@ void CPathfinder::calculatePaths(int3 src /*= int3(-1,-1,-1)*/, int movement /*=
 
 		gs->getNeighbours(*ct, cp->coord, neighbours, boost::logic::indeterminate, !cp->land);
 
-		for(ui32 i=0; i < neighbours.size(); i++)
+		for(auto & neighbour : neighbours)
 		{
-			const int3 &n = neighbours[i]; //current neighbor
+			const int3 &n = neighbour; //current neighbor
 			dp = getNode(n);
 			dt = &gs->map->getTile(n);
             destTopVisObjID = dt->topVisitableId();
@@ -3229,7 +3227,7 @@ CGPathNode::EAccessibility CPathfinder::evaluateAccessibility(const TerrainTile
 		}
 		else
 		{
-			BOOST_FOREACH(const CGObjectInstance *obj, tinfo->visitableObjects)
+			for(const CGObjectInstance *obj : tinfo->visitableObjects)
 			{
 				if(obj->passableFor(hero->tempOwner)) //special object instance specific passableness flag - overwrites other accessibility flags
 				{

+ 33 - 33
lib/CHeroHandler.cpp

@@ -26,16 +26,16 @@ SecondarySkill CHeroClass::chooseSecSkill(const std::set<SecondarySkill> & possi
 	if(possibles.size()==1)
 		return *possibles.begin();
 	int totalProb = 0;
-	for(auto i=possibles.begin(); i!=possibles.end(); i++)
+	for(auto & possible : possibles)
 	{
-		totalProb += secSkillProbability[*i];
+		totalProb += secSkillProbability[possible];
 	}
 	int ran = rand()%totalProb;
-	for(auto i=possibles.begin(); i!=possibles.end(); i++)
+	for(auto & possible : possibles)
 	{
-		ran -= secSkillProbability[*i];
+		ran -= secSkillProbability[possible];
 		if(ran<0)
-			return *i;
+			return possible;
 	}
 	throw std::runtime_error("Cannot pick secondary skill!");
 }
@@ -55,7 +55,7 @@ std::vector<BattleHex> CObstacleInfo::getBlocked(BattleHex hex) const
 		return ret;
 	}
 
-	BOOST_FOREACH(int offset, blockedTiles)
+	for(int offset : blockedTiles)
 	{
 		BattleHex toBlock = hex + offset;
 		if((hex.getY() & 1) && !(toBlock.getY() & 1))
@@ -80,7 +80,7 @@ bool CObstacleInfo::isAppropriate(ETerrainType terrainType, int specialBattlefie
 
 CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
 {
-	CHeroClass * heroClass = new CHeroClass();
+	auto  heroClass = new CHeroClass();
 
 	heroClass->imageBattleFemale = node["animation"]["battle"]["female"].String();
 	heroClass->imageBattleMale   = node["animation"]["battle"]["male"].String();
@@ -89,19 +89,19 @@ CHeroClass *CHeroClassHandler::loadFromJson(const JsonNode & node)
 
 	heroClass->name = node["name"].String();
 
-	BOOST_FOREACH(const std::string & pSkill, PrimarySkill::names)
+	for(const std::string & pSkill : PrimarySkill::names)
 	{
 		heroClass->primarySkillInitial.push_back(node["primarySkills"][pSkill].Float());
 		heroClass->primarySkillLowLevel.push_back(node["lowLevelChance"][pSkill].Float());
 		heroClass->primarySkillHighLevel.push_back(node["highLevelChance"][pSkill].Float());
 	}
 
-	BOOST_FOREACH(const std::string & secSkill, NSecondarySkill::names)
+	for(const std::string & secSkill : NSecondarySkill::names)
 	{
 		heroClass->secSkillProbability.push_back(node["secondarySkills"][secSkill].Float());
 	}
 
-	BOOST_FOREACH(auto & tavern, node["tavern"].Struct())
+	for(auto & tavern : node["tavern"].Struct())
 	{
 		int value = tavern.second.Float();
 
@@ -140,20 +140,20 @@ std::vector<JsonNode> CHeroClassHandler::loadLegacyData(size_t dataSize)
 
 		parser.readNumber(); // unused aggression
 
-		for (size_t i=0; i < GameConstants::PRIMARY_SKILLS; i++)
-			entry["primarySkills"][PrimarySkill::names[i]].Float() = parser.readNumber();
+		for (auto & name : PrimarySkill::names)
+			entry["primarySkills"][name].Float() = parser.readNumber();
 
-		for (size_t i=0; i < GameConstants::PRIMARY_SKILLS; i++)
-			entry["lowLevelChance"][PrimarySkill::names[i]].Float() = parser.readNumber();
+		for (auto & name : PrimarySkill::names)
+			entry["lowLevelChance"][name].Float() = parser.readNumber();
 
-		for (size_t i=0; i < GameConstants::PRIMARY_SKILLS; i++)
-			entry["highLevelChance"][PrimarySkill::names[i]].Float() = parser.readNumber();
+		for (auto & name : PrimarySkill::names)
+			entry["highLevelChance"][name].Float() = parser.readNumber();
 
-		for (size_t i=0; i < GameConstants::SKILL_QUANTITY; i++)
-			entry["secondarySkills"][NSecondarySkill::names[i]].Float() = parser.readNumber();
+		for (auto & name : NSecondarySkill::names)
+			entry["secondarySkills"][name].Float() = parser.readNumber();
 
-		for(size_t i = 0; i < GameConstants::F_NUMBER; i++)
-			entry["tavern"][ETownType::names[i]].Float() = parser.readNumber();
+		for(auto & name : ETownType::names)
+			entry["tavern"][name].Float() = parser.readNumber();
 
 		parser.endLine();
 		h3Data.push_back(entry);
@@ -189,7 +189,7 @@ std::vector<bool> CHeroClassHandler::getDefaultAllowed() const
 
 CHeroClassHandler::~CHeroClassHandler()
 {
-	BOOST_FOREACH(auto heroClass, heroClasses)
+	for(auto heroClass : heroClasses)
 	{
 		delete heroClass.get();
 	}
@@ -197,7 +197,7 @@ CHeroClassHandler::~CHeroClassHandler()
 
 CHeroHandler::~CHeroHandler()
 {
-	BOOST_FOREACH(auto hero, heroes)
+	for(auto hero : heroes)
 		delete hero.get();
 }
 
@@ -217,7 +217,7 @@ CHeroHandler::CHeroHandler()
 
 CHero * CHeroHandler::loadFromJson(const JsonNode & node)
 {
-	CHero * hero = new CHero;
+	auto  hero = new CHero;
 
 	hero->sex = node["female"].Bool();
 	hero->special = node["special"].Bool();
@@ -270,9 +270,9 @@ void CHeroHandler::loadHeroArmy(CHero * hero, const JsonNode & node)
 
 void CHeroHandler::loadHeroSkills(CHero * hero, const JsonNode & node)
 {
-	BOOST_FOREACH(const JsonNode &set, node["skills"].Vector())
+	for(const JsonNode &set : node["skills"].Vector())
 	{
-		int skillLevel = boost::range::find(NSecondarySkill::levels, set["level"].String()) - boost::begin(NSecondarySkill::levels);
+		int skillLevel = boost::range::find(NSecondarySkill::levels, set["level"].String()) - std::begin(NSecondarySkill::levels);
 		if (skillLevel < SecSkillLevel::LEVELS_SIZE)
 		{
 			size_t currentIndex = hero->secSkillsInit.size();
@@ -292,7 +292,7 @@ void CHeroHandler::loadHeroSkills(CHero * hero, const JsonNode & node)
 	// spellbook is considered present if hero have "spellbook" entry even when this is an empty set (0 spells)
 	hero->haveSpellBook = !node["spellbook"].isNull();
 
-	BOOST_FOREACH(const JsonNode & spell, node["spellbook"].Vector())
+	for(const JsonNode & spell : node["spellbook"].Vector())
 	{
 		if (spell.getType() == JsonNode::DATA_FLOAT) // for compatibility
 		{
@@ -312,7 +312,7 @@ void CHeroHandler::loadHeroSkills(CHero * hero, const JsonNode & node)
 void CHeroHandler::loadHeroSpecialty(CHero * hero, const JsonNode & node)
 {
 	//deprecated, used only for original spciealties
-	BOOST_FOREACH(const JsonNode &specialty, node["specialties"].Vector())
+	for(const JsonNode &specialty : node["specialties"].Vector())
 	{
 		SSpecialtyInfo spec;
 
@@ -324,11 +324,11 @@ void CHeroHandler::loadHeroSpecialty(CHero * hero, const JsonNode & node)
 		hero->spec.push_back(spec); //put a copy of dummy
 	}
 	//new format, using bonus system
-	BOOST_FOREACH(const JsonNode &specialty, node["specialty"].Vector())
+	for(const JsonNode &specialty : node["specialty"].Vector())
 	{
 		SSpecialtyBonus hs;
 		hs.growsWithLevel = specialty["growsWithLevel"].Bool();
-		BOOST_FOREACH (const JsonNode & bonus, specialty["bonuses"].Vector())
+		for (const JsonNode & bonus : specialty["bonuses"].Vector())
 		{
 			auto b = JsonUtils::parseBonus(bonus);
 			hs.bonuses.push_back (b);
@@ -366,7 +366,7 @@ void CHeroHandler::loadObstacles()
 {
 	auto loadObstacles = [](const JsonNode &node, bool absolute, std::map<int, CObstacleInfo> &out)
 	{
-		BOOST_FOREACH(const JsonNode &obs, node.Vector())
+		for(const JsonNode &obs : node.Vector())
 		{
 			int ID = obs["id"].Float();
 			CObstacleInfo & obi = out[ID];
@@ -491,7 +491,7 @@ void CHeroHandler::loadObject(std::string scope, std::string name, const JsonNod
 
 ui32 CHeroHandler::level (ui64 experience) const
 {
-	return boost::range::upper_bound(expPerLevel, experience) - boost::begin(expPerLevel);
+	return boost::range::upper_bound(expPerLevel, experience) - std::begin(expPerLevel);
 }
 
 ui64 CHeroHandler::reqExp (ui32 level) const
@@ -515,7 +515,7 @@ void CHeroHandler::loadTerrains()
 	const JsonNode config(ResourceID("config/terrains.json"));
 
 	terrCosts.reserve(GameConstants::TERRAIN_TYPES);
-	BOOST_FOREACH(const std::string & name, GameConstants::TERRAIN_NAMES)
+	for(const std::string & name : GameConstants::TERRAIN_NAMES)
 		terrCosts.push_back(config[name]["moveCost"].Float());
 }
 
@@ -525,7 +525,7 @@ std::vector<bool> CHeroHandler::getDefaultAllowed() const
 	std::vector<bool> allowedHeroes;
 	allowedHeroes.reserve(heroes.size());
 
-	BOOST_FOREACH(const CHero * hero, heroes)
+	for(const CHero * hero : heroes)
 	{
 		allowedHeroes.push_back(!hero->special);
 	}

+ 24 - 24
lib/CModHandler.cpp

@@ -170,14 +170,14 @@ void CIdentifierStorage::finalize()
 {
 	bool errorsFound = false;
 
-	BOOST_FOREACH(const ObjectCallback & request, scheduledRequests)
+	for(const ObjectCallback & request : scheduledRequests)
 	{
 		errorsFound |= !resolveIdentifier(request);
 	}
 
 	if (errorsFound)
 	{
-		BOOST_FOREACH(auto object, registeredObjects)
+		for(auto object : registeredObjects)
 		{
 			logGlobal->traceStream() << object.first << " -> " << object.second.id;
 		}
@@ -191,7 +191,7 @@ CContentHandler::ContentTypeHandler::ContentTypeHandler(IHandlerBase * handler,
     objectName(objectName),
     originalData(handler->loadLegacyData(VLC->modh->settings.data["textData"][objectName].Float()))
 {
-	BOOST_FOREACH(auto & node, originalData)
+	for(auto & node : originalData)
 	{
 		node.setMeta("core");
 	}
@@ -204,7 +204,7 @@ void CContentHandler::ContentTypeHandler::preloadModData(std::string modName, st
 
 	ModInfo & modInfo = modData[modName];
 
-	BOOST_FOREACH(auto entry, data.Struct())
+	for(auto entry : data.Struct())
 	{
 		size_t colon = entry.first.find(':');
 
@@ -237,7 +237,7 @@ void CContentHandler::ContentTypeHandler::loadMod(std::string modName)
 	if (!modInfo.patches.isNull())
 		JsonUtils::merge(modInfo.modData, modInfo.patches);
 
-	BOOST_FOREACH(auto entry, modInfo.modData.Struct())
+	for(auto entry : modInfo.modData.Struct())
 	{
 		const std::string & name = entry.first;
 		JsonNode & data = entry.second;
@@ -277,7 +277,7 @@ CContentHandler::CContentHandler()
 
 void CContentHandler::preloadModData(std::string modName, JsonNode modConfig)
 {
-	BOOST_FOREACH(auto & handler, handlers)
+	for(auto & handler : handlers)
 	{
 		handler.second.preloadModData(modName, modConfig[handler.first].convertTo<std::vector<std::string> >());
 	}
@@ -285,7 +285,7 @@ void CContentHandler::preloadModData(std::string modName, JsonNode modConfig)
 
 void CContentHandler::loadMod(std::string modName)
 {
-	BOOST_FOREACH(auto & handler, handlers)
+	for(auto & handler : handlers)
 	{
 		handler.second.loadMod(modName);
 	}
@@ -338,7 +338,7 @@ bool CModHandler::hasCircularDependency(TModID modID, std::set <TModID> currentL
 	currentList.insert(modID);
 
 	// recursively check every dependency of this mod
-	BOOST_FOREACH(const TModID & dependency, mod.dependencies)
+	for(const TModID & dependency : mod.dependencies)
 	{
 		if (hasCircularDependency(dependency, currentList))
 		{
@@ -351,11 +351,11 @@ bool CModHandler::hasCircularDependency(TModID modID, std::set <TModID> currentL
 
 bool CModHandler::checkDependencies(const std::vector <TModID> & input) const
 {
-	BOOST_FOREACH(const TModID & id, input)
+	for(const TModID & id : input)
 	{
 		const CModInfo & mod = allMods.at(id);
 
-		BOOST_FOREACH(const TModID & dep, mod.dependencies)
+		for(const TModID & dep : mod.dependencies)
 		{
 			if (!vstd::contains(input, dep))
 			{
@@ -364,7 +364,7 @@ bool CModHandler::checkDependencies(const std::vector <TModID> & input) const
 			}
 		}
 
-		BOOST_FOREACH(const TModID & conflicting, mod.conflicts)
+		for(const TModID & conflicting : mod.conflicts)
 		{
 			if (vstd::contains(input, conflicting))
 			{
@@ -396,7 +396,7 @@ std::vector <TModID> CModHandler::resolveDependencies(std::vector <TModID> input
 	// Check if all mod dependencies are resolved (moved to resolvedMods)
 	auto isResolved = [&](const CModInfo mod) -> bool
 	{
-		BOOST_FOREACH(const TModID & dependency, mod.dependencies)
+		for(const TModID & dependency : mod.dependencies)
 		{
 			if (!vstd::contains(resolvedMods, dependency))
 				return false;
@@ -441,7 +441,7 @@ void CModHandler::initialize(std::vector<std::string> availableMods)
 
 	std::vector <TModID> detectedMods;
 
-	BOOST_FOREACH(std::string name, availableMods)
+	for(std::string name : availableMods)
 	{
 		boost::to_lower(name);
 		std::string modFileName = "mods/" + name + "/mod.json";
@@ -505,7 +505,7 @@ void CModHandler::handleData(Handler handler, const JsonNode & source, std::stri
 {
 	JsonNode config = JsonUtils::assembleFromFiles(source[listName].convertTo<std::vector<std::string> >());
 
-	BOOST_FOREACH(auto & entry, config.Struct())
+	for(auto & entry : config.Struct())
 	{
 		if (!entry.second.isNull()) // may happens if mod removed object by setting json entry to null
 		{
@@ -532,7 +532,7 @@ void CModHandler::loadGameContent()
 	content.preloadModData("core", JsonNode(ResourceID("config/gameConfig.json")));
 	logGlobal->infoStream() << "\tParsing original game data: " << timer.getDiff() << " ms";
 
-	BOOST_FOREACH(const TModID & modName, activeMods)
+	for(const TModID & modName : activeMods)
 	{
 		logGlobal->infoStream() << "\t\t" << allMods[modName].name;
 
@@ -548,7 +548,7 @@ void CModHandler::loadGameContent()
 	content.loadMod("core");
 	logGlobal->infoStream() << "\tLoading original game data: " << timer.getDiff() << " ms";
 
-	BOOST_FOREACH(const TModID & modName, activeMods)
+	for(const TModID & modName : activeMods)
 	{
 		content.loadMod(modName);
 		logGlobal->infoStream() << "\t\t" << allMods[modName].name;
@@ -571,11 +571,11 @@ void CModHandler::reload()
 
 		const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::MONSTER].begin()->second;
 
-		BOOST_FOREACH(auto & crea, VLC->creh->creatures)
+		for(auto & crea : VLC->creh->creatures)
 		{
 			if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::MONSTER], crea->idNumber)) // no obj info for this type
 			{
-				CGDefInfo * info = new CGDefInfo(*baseInfo);
+				auto  info = new CGDefInfo(*baseInfo);
 				info->subid = crea->idNumber;
 				info->name = crea->advMapDef;
 
@@ -588,11 +588,11 @@ void CModHandler::reload()
 
 		const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::ARTIFACT].begin()->second;
 
-		BOOST_FOREACH(auto & art, VLC->arth->artifacts)
+		for(auto & art : VLC->arth->artifacts)
 		{
 			if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::ARTIFACT], art->id)) // no obj info for this type
 			{
-				CGDefInfo * info = new CGDefInfo(*baseInfo);
+				auto  info = new CGDefInfo(*baseInfo);
 				info->subid = art->id;
 				info->name = art->advMapDef;
 
@@ -607,7 +607,7 @@ void CModHandler::reload()
 		const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::TOWN].begin()->second;
 		auto & townInfos = VLC->dobjinfo->gobjs[Obj::TOWN];
 
-		BOOST_FOREACH(auto & faction, VLC->townh->factions)
+		for(auto & faction : VLC->townh->factions)
 		{
 			TFaction index = faction->index;
 			CTown * town = faction->town;
@@ -617,7 +617,7 @@ void CModHandler::reload()
 
 				if (!vstd::contains(VLC->dobjinfo->gobjs[Obj::TOWN], index)) // no obj info for this type
 				{
-					CGDefInfo * info = new CGDefInfo(*baseInfo);
+					auto  info = new CGDefInfo(*baseInfo);
 					info->subid = index;
 
 					townInfos[index] = info;
@@ -634,9 +634,9 @@ void CModHandler::reload()
 				{
 					const CGDefInfo * baseInfo = VLC->dobjinfo->gobjs[Obj::CREATURE_GENERATOR1][i]; //get same blockmap as first dwelling of tier i
 
-					BOOST_FOREACH (auto cre, town->creatures[i]) //both unupgraded and upgraded get same dwelling
+					for (auto cre : town->creatures[i]) //both unupgraded and upgraded get same dwelling
 					{
-						CGDefInfo * info = new CGDefInfo(*baseInfo);
+						auto  info = new CGDefInfo(*baseInfo);
 						info->subid = cre;
 						info->name = town->dwellings[i];
 						VLC->dobjinfo->gobjs[Obj::CREATURE_GENERATOR1][cre] = info;

+ 140 - 140
lib/CObjectHandler.cpp

@@ -157,7 +157,7 @@ bool CPlayersVisited::wasVisited( PlayerColor player ) const
 
 bool CPlayersVisited::wasVisited( TeamID team ) const
 {
-	BOOST_FOREACH(auto i, players)
+	for(auto i : players)
 	{
 		if(cb->getPlayer(i)->team == team)
 			return true;
@@ -183,7 +183,7 @@ static void readBankLevel(const JsonNode &level, BankConfig &bc)
 
 	bc.chance = level["chance"].Float();
 
-	BOOST_FOREACH(const JsonNode &creature, level["guards"].Vector())
+	for(const JsonNode &creature : level["guards"].Vector())
 	{
 		readCreatures(creature, bc.guards);
 	}
@@ -193,20 +193,20 @@ static void readBankLevel(const JsonNode &level, BankConfig &bc)
 
 	bc.resources.resize(GameConstants::RESOURCE_QUANTITY);
 	idx = 0;
-	BOOST_FOREACH(const JsonNode &resource, level["reward_resources"].Vector())
+	for(const JsonNode &resource : level["reward_resources"].Vector())
 	{
 		bc.resources[idx] = resource.Float();
 		idx ++;
 	}
 
-	BOOST_FOREACH(const JsonNode &creature, level["reward_creatures"].Vector())
+	for(const JsonNode &creature : level["reward_creatures"].Vector())
 	{
 		readCreatures(creature, bc.creatures);
 	}
 
 	bc.artifacts.resize(4);
 	idx = 0;
-	BOOST_FOREACH(const JsonNode &artifact, level["reward_artifacts"].Vector())
+	for(const JsonNode &artifact : level["reward_artifacts"].Vector())
 	{
 		bc.artifacts[idx] = artifact.Float();
 		idx ++;
@@ -222,7 +222,7 @@ CObjectHandler::CObjectHandler()
     logGlobal->traceStream() << "\t\tReading cregens ";
 
 	const JsonNode config(ResourceID("config/dwellings.json"));
-	BOOST_FOREACH(const JsonNode &dwelling, config["dwellings"].Vector())
+	for(const JsonNode &dwelling : config["dwellings"].Vector())
 	{
 		cregens[dwelling["dwelling"].Float()] = CreatureID((si32)dwelling["creature"].Float());
 	}
@@ -230,7 +230,7 @@ CObjectHandler::CObjectHandler()
 
     logGlobal->traceStream() << "\t\tReading resources prices ";
 	const JsonNode config2(ResourceID("config/resources.json"));
-	BOOST_FOREACH(const JsonNode &price, config2["resources_prices"].Vector())
+	for(const JsonNode &price : config2["resources_prices"].Vector())
 	{
 		resVals.push_back(price.Float());
 	}
@@ -239,12 +239,12 @@ CObjectHandler::CObjectHandler()
     logGlobal->traceStream() << "\t\tReading banks configs";
 	const JsonNode config3(ResourceID("config/bankconfig.json"));
 	int bank_num = 0;
-	BOOST_FOREACH(const JsonNode &bank, config3["banks"].Vector())
+	for(const JsonNode &bank : config3["banks"].Vector())
 	{
 		creBanksNames[bank_num] = bank["name"].String();
 
 		int level_num = 0;
-		BOOST_FOREACH(const JsonNode &level, bank["levels"].Vector())
+		for(const JsonNode &level : bank["levels"].Vector())
 		{
 			banksInfo[bank_num].push_back(new BankConfig);
 			BankConfig &bc = *banksInfo[bank_num].back();
@@ -261,9 +261,9 @@ CObjectHandler::CObjectHandler()
 
 CObjectHandler::~CObjectHandler()
 {
-	BOOST_FOREACH(auto & mapEntry, banksInfo)
+	for(auto & mapEntry : banksInfo)
 	{
-		BOOST_FOREACH(auto & vecEntry, mapEntry.second)
+		for(auto & vecEntry : mapEntry.second)
 		{
 			vecEntry.dellNull();
 		}
@@ -469,7 +469,7 @@ int CGObjectInstance::getSightRadious() const
 {
 	return 3;
 }
-void CGObjectInstance::getSightTiles(boost::unordered_set<int3, ShashInt3> &tiles) const //returns reference to the set
+void CGObjectInstance::getSightTiles(std::unordered_set<int3, ShashInt3> &tiles) const //returns reference to the set
 {
 	cb->getTilesInRange(tiles, getSightCenter(), getSightRadious(), tempOwner, 1);
 }
@@ -479,13 +479,13 @@ void CGObjectInstance::hideTiles(PlayerColor ourplayer, int radius) const
 	{
 		if ( !vstd::contains(i->second.players, ourplayer ))//another team
 		{
-			for (auto j = i->second.players.begin(); j != i->second.players.end(); j++)
-				if ( cb->getPlayer(*j)->status == EPlayerStatus::INGAME )//seek for living player (if any)
+			for (auto & elem : i->second.players)
+				if ( cb->getPlayer(elem)->status == EPlayerStatus::INGAME )//seek for living player (if any)
 				{
 					FoWChange fw;
 					fw.mode = 0;
-					fw.player = *j;
-					cb->getTilesInRange (fw.tiles, pos, radius, (*j), -1);
+					fw.player = elem;
+					cb->getTilesInRange (fw.tiles, pos, radius, (elem), -1);
 					cb->sendAndApply (&fw);
 					break;
 				}
@@ -582,7 +582,7 @@ static int lowestSpeed(const CGHeroInstance * chi)
         logGlobal->errorStream() << "Error! Hero " << chi->id.getNum() << " ("<<chi->name<<") has no army!";
 		return 20;
 	}
-	TSlots::const_iterator i = chi->Slots().begin();
+	auto i = chi->Slots().begin();
 	//TODO? should speed modifiers (eg from artifacts) affect hero movement?
 	int ret = (i++)->second->valOfBonuses(Bonus::STACKS_SPEED);
 	for (;i!=chi->Slots().end();i++)
@@ -627,7 +627,7 @@ ui32 CGHeroInstance::getTileCost(const TerrainTile &dest, const TerrainTile &fro
 		// will always have best penalty without any influence from player-defined stacks order
 
 		bool nativeArmy = true;
-		BOOST_FOREACH(auto stack, stacks)
+		for(auto stack : stacks)
 		{
 			int nativeTerrain = VLC->townh->factions[stack.second->type->faction]->nativeTerrain;
 
@@ -675,9 +675,9 @@ bool CGHeroInstance::canWalkOnSea() const
 
 ui8 CGHeroInstance::getSecSkillLevel(SecondarySkill skill) const
 {
-	for(size_t i=0; i < secSkills.size(); ++i)
-		if(secSkills[i].first == skill)
-			return secSkills[i].second;
+	for(auto & elem : secSkills)
+		if(elem.first == skill)
+			return elem.second;
 	return 0;
 }
 
@@ -690,21 +690,21 @@ void CGHeroInstance::setSecSkillLevel(SecondarySkill which, int val, bool abs)
 	}
 	else
 	{
-		for (unsigned i=0; i<secSkills.size(); i++)
+		for (auto & elem : secSkills)
 		{
-			if(secSkills[i].first == which)
+			if(elem.first == which)
 			{
 				if(abs)
-					secSkills[i].second = val;
+					elem.second = val;
 				else
-					secSkills[i].second += val;
+					elem.second += val;
 
-				if(secSkills[i].second > 3) //workaround to avoid crashes when same sec skill is given more than once
+				if(elem.second > 3) //workaround to avoid crashes when same sec skill is given more than once
 				{
                     logGlobal->warnStream() << "Warning: Skill " << which << " increased over limit! Decreasing to Expert.";
-					secSkills[i].second = 3;
+					elem.second = 3;
 				}
-				updateSkill(which, secSkills[i].second); //when we know final value
+				updateSkill(which, elem.second); //when we know final value
 			}
 		}
 	}
@@ -777,7 +777,7 @@ void CGHeroInstance::initHero()
 
 	if(!vstd::contains(spells, SpellID::PRESET)) //hero starts with a spell
 	{
-		BOOST_FOREACH(auto spellID, type->spells)
+		for(auto spellID : type->spells)
 			spells.insert(spellID);
 	}
 	else //remove placeholder
@@ -983,16 +983,16 @@ const std::string & CGHeroInstance::getBiography() const
 void CGHeroInstance::initObj() //TODO: use bonus system
 {
 	blockVisit = true;
-	HeroSpecial * hs = new HeroSpecial();
+	auto  hs = new HeroSpecial();
 	hs->setNodeType(CBonusSystemNode::specialty);
 	attachTo(hs); //do we ever need to detach it?
 
 	if(!type)
 		initHero(); //TODO: set up everything for prison before specialties are configured
 
-	BOOST_FOREACH(const auto &spec, type->spec) //TODO: unfity with bonus system
+	for(const auto &spec : type->spec) //TODO: unfity with bonus system
 	{
-		Bonus *bonus = new Bonus();
+		auto bonus = new Bonus();
 		bonus->val = spec.val;
 		bonus->sid = id.getNum(); //from the hero, specialty has no unique id
 		bonus->duration = Bonus::PERMANENT;
@@ -1123,7 +1123,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
 				hs->addNewBonus(bonus);
 				bonus = new Bonus(*bonus);
 
-				BOOST_FOREACH(auto cre_id, creatures[spec.subtype]->upgrades)
+				for(auto cre_id : creatures[spec.subtype]->upgrades)
 				{
 					bonus->subtype = cre_id; //propagate for regular upgrades of base creature
 					hs->addNewBonus(bonus);
@@ -1165,13 +1165,13 @@ void CGHeroInstance::initObj() //TODO: use bonus system
 	}
 	specialty.push_back(hs); //will it work?
 
-	BOOST_FOREACH (auto hs2, type->specialty) //copy active (probably growing) bonuses from hero prootype to hero object
+	for (auto hs2 : type->specialty) //copy active (probably growing) bonuses from hero prootype to hero object
 	{
-		HeroSpecial * hs = new HeroSpecial();
+		auto  hs = new HeroSpecial();
 		attachTo(hs); //do we ever need to detach it?
 
 		hs->setNodeType(CBonusSystemNode::specialty);
-		BOOST_FOREACH (auto bonus, hs2.bonuses)
+		for (auto bonus : hs2.bonuses)
 		{
 			hs->addNewBonus (bonus);
 		}
@@ -1181,7 +1181,7 @@ void CGHeroInstance::initObj() //TODO: use bonus system
 	}
 
 	//initialize bonuses
-	BOOST_FOREACH(auto skill_info, secSkills)
+	for(auto skill_info : secSkills)
 		updateSkill(SecondarySkill(skill_info.first), skill_info.second);
 	Updatespecialty();
 
@@ -1190,13 +1190,13 @@ void CGHeroInstance::initObj() //TODO: use bonus system
 }
 void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuses on-the-fly?
 {
-	BOOST_FOREACH (auto hs, specialty)
+	for (auto hs : specialty)
 	{
 		if (hs->growsWithLevel)
 		{
 			//const auto &creatures = VLC->creh->creatures;
 
-			BOOST_FOREACH(Bonus * b, hs->getBonusList())
+			for(Bonus * b : hs->getBonusList())
 			{
 				switch (b->type)
 				{
@@ -1319,7 +1319,7 @@ void CGHeroInstance::updateSkill(SecondarySkill which, int val)
 	}
 	else
 	{
-		Bonus *bonus = new Bonus(Bonus::PERMANENT, Bonus::SECONDARY_SKILL_PREMY, Bonus::SECONDARY_SKILL, skillVal, id.getNum(), which, skillValType);
+		auto bonus = new Bonus(Bonus::PERMANENT, Bonus::SECONDARY_SKILL_PREMY, Bonus::SECONDARY_SKILL, skillVal, id.getNum(), which, skillValType);
 		bonus->source = Bonus::SECONDARY_SKILL;
 		addNewBonus(bonus);
 	}
@@ -1424,14 +1424,14 @@ CStackBasicDescriptor CGHeroInstance::calculateNecromancy (const BattleResult &b
 		const ui32 raisedUnitHP = raisedUnitType->valOfBonuses(Bonus::STACK_HEALTH);
 
 		//calculate creatures raised from each defeated stack
-		for (std::map<ui32,si32>::const_iterator it = casualties.begin(); it != casualties.end(); it++)
+		for (auto & casualtie : casualties)
 		{
 			// Get lost enemy hit points convertible to units.
-			CCreature * c = VLC->creh->creatures[it->first];
+			CCreature * c = VLC->creh->creatures[casualtie.first];
 			if (c->isLiving())
 			{
-				const ui32 raisedHP = c->valOfBonuses(Bonus::STACK_HEALTH) * it->second * necromancySkill;
-				raisedUnits += std::min<ui32>(raisedHP / raisedUnitHP, it->second * necromancySkill); //limit to % of HP and % of original stack count
+				const ui32 raisedHP = c->valOfBonuses(Bonus::STACK_HEALTH) * casualtie.second * necromancySkill;
+				raisedUnits += std::min<ui32>(raisedHP / raisedUnitHP, casualtie.second * necromancySkill); //limit to % of HP and % of original stack count
 			}
 		}
 
@@ -1527,8 +1527,8 @@ int CGHeroInstance::getBoatType() const
 void CGHeroInstance::getOutOffsets(std::vector<int3> &offsets) const
 {
 	static int3 dirs[] = { int3(0,1,0),int3(0,-1,0),int3(-1,0,0),int3(+1,0,0), int3(1,1,0),int3(-1,1,0),int3(1,-1,0),int3(-1,-1,0) };
-	for (size_t i = 0; i < ARRAY_COUNT(dirs); i++)
-		offsets += dirs[i];
+	for (auto & dir : dirs)
+		offsets += dir;
 }
 
 int CGHeroInstance::getSpellCost(const CSpell *sp) const
@@ -1577,7 +1577,7 @@ void CGHeroInstance::deserializationFix()
 {
 	artDeserializationFix(this);
 
-	//BOOST_FOREACH (auto hs, specialty)
+	//for (auto hs : specialty)
 	//{
 	//	attachTo (hs);
 	//}
@@ -1636,13 +1636,13 @@ std::vector<SecondarySkill> CGHeroInstance::levelUpProposedSkills() const
 		if (cb->isAllowed(2,i))
 			none.insert(SecondarySkill(i));
 
-	for(unsigned i=0; i<secSkills.size(); i++)
+	for(auto & elem : secSkills)
 	{
-		if(secSkills[i].second < 3)
-			basicAndAdv.insert(secSkills[i].first);
+		if(elem.second < 3)
+			basicAndAdv.insert(elem.first);
 		else
-			expert.insert(secSkills[i].first);
-		none.erase(secSkills[i].first);
+			expert.insert(elem.first);
+		none.erase(elem.first);
 	}
 
 	//first offered skill
@@ -1811,15 +1811,15 @@ void CGDwelling::onHeroVisit( const CGHeroInstance * h ) const
 	{
 		bd.text.addTxt(MetaString::ADVOB_TXT, ID == Obj::CREATURE_GENERATOR1 ? 35 : 36); //{%s} Would you like to recruit %s? / {%s} Would you like to recruit %s, %s, %s, or %s?
 		bd.text.addReplacement(ID == Obj::CREATURE_GENERATOR1 ? MetaString::CREGENS : MetaString::CREGENS4, subID);
-		for(size_t i = 0; i < creatures.size(); i++)
-			bd.text.addReplacement(MetaString::CRE_PL_NAMES, creatures[i].second[0]);
+		for(auto & elem : creatures)
+			bd.text.addReplacement(MetaString::CRE_PL_NAMES, elem.second[0]);
 	}
 	else if(ID == Obj::REFUGEE_CAMP)
 	{
 		bd.text.addTxt(MetaString::ADVOB_TXT, 35); //{%s} Would you like to recruit %s?
 		bd.text.addReplacement(MetaString::OBJ_NAMES, ID);
-		for(size_t i = 0; i < creatures.size(); i++)
-			bd.text.addReplacement(MetaString::CRE_PL_NAMES, creatures[i].second[0]);
+		for(auto & elem : creatures)
+			bd.text.addReplacement(MetaString::CRE_PL_NAMES, elem.second[0]);
 	}
 	else if(ID == Obj::WAR_MACHINE_FACTORY)
 		bd.text.addTxt(MetaString::ADVOB_TXT, 157); //{War Machine Factory} Would you like to purchase War Machines?
@@ -2081,7 +2081,7 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
 	int dwellingBonus = 0;
 	if(const PlayerState *p = cb->getPlayer(tempOwner, false))
 	{
-		BOOST_FOREACH(const CGDwelling *dwelling, p->dwellings)
+		for(const CGDwelling *dwelling : p->dwellings)
 			if(vstd::contains(creatures[level].second, dwelling->creatures[0].second[0]))
 				dwellingBonus++;
 	}
@@ -2091,12 +2091,12 @@ GrowthInfo CGTownInstance::getGrowthInfo(int level) const
 
 	//other *-of-legion-like bonuses (%d to growth cumulative with grail)
 	TBonusListPtr bonuses = getBonuses(Selector::type(Bonus::CREATURE_GROWTH) && Selector::subtype(level));
-	BOOST_FOREACH(const Bonus *b, *bonuses)
+	for(const Bonus *b : *bonuses)
 		ret.entries.push_back(GrowthInfo::Entry(b->Description() + " %+d", b->val));
 
 	//statue-of-legion-like bonus: % to base+castle
 	TBonusListPtr bonuses2 = getBonuses(Selector::type(Bonus::CREATURE_GROWTH_PERCENT));
-	BOOST_FOREACH(const Bonus *b, *bonuses2)
+	for(const Bonus *b : *bonuses2)
 		ret.entries.push_back(GrowthInfo::Entry(b->Description() + " %+d", b->val * (base + castleBonus) / 100));
 
 	if(hasBuilt(BuildingID::GRAIL)) //grail - +50% to ALL (so far added) growth
@@ -2137,8 +2137,8 @@ CGTownInstance::CGTownInstance()
 
 CGTownInstance::~CGTownInstance()
 {
-	for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i != bonusingBuildings.end(); i++)
-		delete *i;
+	for (auto & elem : bonusingBuildings)
+		delete elem;
 }
 
 int CGTownInstance::spellsAtLevel(int level, bool checkGuild) const
@@ -2268,20 +2268,20 @@ void CGTownInstance::newTurn() const
 		}
 
 		if ( subID == ETownType::DUNGEON )
-			for (std::vector<CGTownBuilding*>::const_iterator i = bonusingBuildings.begin(); i!=bonusingBuildings.end(); i++)
+			for (auto & elem : bonusingBuildings)
 		{
-			if ((*i)->ID == BuildingID::MANA_VORTEX)
-				cb->setObjProperty (id, ObjProperty::STRUCTURE_CLEAR_VISITORS, (*i)->id); //reset visitors for Mana Vortex
+			if ((elem)->ID == BuildingID::MANA_VORTEX)
+				cb->setObjProperty (id, ObjProperty::STRUCTURE_CLEAR_VISITORS, (elem)->id); //reset visitors for Mana Vortex
 		}
 
 		if (tempOwner == PlayerColor::NEUTRAL) //garrison growth for neutral towns
 			{
 				std::vector<SlotID> nativeCrits; //slots
-				for (TSlots::const_iterator it = Slots().begin(); it != Slots().end(); it++)
+				for (auto & elem : Slots())
 				{
-					if (it->second->type->faction == subID) //native
+					if (elem.second->type->faction == subID) //native
 					{
-						nativeCrits.push_back(it->first); //collect matching slots
+						nativeCrits.push_back(elem.first); //collect matching slots
 					}
 				}
 				if (nativeCrits.size())
@@ -2339,7 +2339,7 @@ ui8 CGTownInstance::getPassableness() const
 
 	ui8 mask = 0;
 	TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner);
-	BOOST_FOREACH(PlayerColor it, ts->players)
+	for(PlayerColor it : ts->players)
 		mask |= 1<<it.getNum();//allies - add to possible visitors
 
 	return mask;
@@ -2391,7 +2391,7 @@ int CGTownInstance::getMarketEfficiency() const
 	assert(p);
 
 	int marketCount = 0;
-	BOOST_FOREACH(const CGTownInstance *t, p->towns)
+	for(const CGTownInstance *t : p->towns)
 		if(t->hasBuilt(BuildingID::MARKETPLACE))
 			marketCount++;
 
@@ -2431,7 +2431,7 @@ std::vector<int> CGTownInstance::availableItemsIds(EMarketMode::EMarketMode mode
 	if(mode == EMarketMode::RESOURCE_ARTIFACT)
 	{
 		std::vector<int> ret;
-		BOOST_FOREACH(const CArtifact *a, merchantArtifacts)
+		for(const CArtifact *a : merchantArtifacts)
 			if(a)
 				ret.push_back(a->id);
 			else
@@ -2484,7 +2484,7 @@ void CGTownInstance::recreateBuildingsBonuses()
 
 	BonusList bl;
 	getExportedBonusList().getBonuses(bl, Selector::sourceType(Bonus::TOWN_STRUCTURE));
-	BOOST_FOREACH(Bonus *b, bl)
+	for(Bonus *b : bl)
 		removeBonus(b);
 
 	//tricky! -> checks tavern only if no bratherhood of sword or not a castle
@@ -3313,7 +3313,7 @@ int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
 	myKindCres.insert(myCreature->idNumber); //we
 	myKindCres.insert(myCreature->upgrades.begin(), myCreature->upgrades.end()); //our upgrades
 
-	BOOST_FOREACH(ConstTransitivePtr<CCreature> &crea, VLC->creh->creatures)
+	for(ConstTransitivePtr<CCreature> &crea : VLC->creh->creatures)
 	{
 		if(vstd::contains(crea->upgrades, myCreature->idNumber)) //it's our base creatures
 			myKindCres.insert(crea->idNumber);
@@ -3322,11 +3322,11 @@ int CGCreature::takenAction(const CGHeroInstance *h, bool allowJoin) const
 	int count = 0, //how many creatures of similar kind has hero
 		totalCount = 0;
 
-	for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); i++)
+	for (auto & elem : h->Slots())
 	{
-		if(vstd::contains(myKindCres,i->second->type->idNumber))
-			count += i->second->count;
-		totalCount += i->second->count;
+		if(vstd::contains(myKindCres,elem.second->type->idNumber))
+			count += elem.second->count;
+		totalCount += elem.second->count;
 	}
 
 	int sympathy = 0; // 0 if hero have no similar creatures
@@ -3596,7 +3596,7 @@ void CGMine::initObj()
 	{
 		//set guardians
 		int howManyTroglodytes = 100 + ran()%100;
-		CStackInstance *troglodytes = new CStackInstance(CreatureID::TROGLODYTES, howManyTroglodytes);
+		auto troglodytes = new CStackInstance(CreatureID::TROGLODYTES, howManyTroglodytes);
 		putStack(SlotID(0), troglodytes);
 
 		//after map reading tempOwner placeholds bitmask for allowed resources
@@ -3874,7 +3874,7 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
 					if (h->Slots().size() > 1 || h->Slots().begin()->second->count > 1)
 					{ //we can't remove last unit
 						SlotID targetstack = h->Slots().begin()->first; //slot numbers may vary
-						for(TSlots::const_reverse_iterator i = h->Slots().rbegin(); i != h->Slots().rend(); i++)
+						for(auto i = h->Slots().rbegin(); i != h->Slots().rend(); i++)
 						{
 							if (h->getPower(targetstack) > h->getPower(i->first))
 							{
@@ -3917,7 +3917,7 @@ void CGTeleport::onHeroVisit( const CGHeroInstance * h ) const
 	if (ID == Obj::WHIRLPOOL)
 	{
 		std::set<int3> tiles = cb->getObj(destinationid)->getBlockedPos();
-		std::set<int3>::iterator it = tiles.begin();
+		auto it = tiles.begin();
 		std::advance (it, rand() % tiles.size()); //picking random element of set is tiring
 		cb->moveHero (h->id, *it + int3(1,0,0), true);
 	}
@@ -3946,9 +3946,9 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
 {
 	//split on underground and surface gates
 	std::vector<const CGObjectInstance *> gatesSplit[2]; //surface and underground gates
-	for(size_t i = 0; i < objs[Obj::SUBTERRANEAN_GATE][0].size(); i++)
+	for(auto & elem : objs[Obj::SUBTERRANEAN_GATE][0])
 	{
-		const CGObjectInstance *hlp = cb->getObj(objs[Obj::SUBTERRANEAN_GATE][0][i]);
+		const CGObjectInstance *hlp = cb->getObj(elem);
 		gatesSplit[hlp->pos.z].push_back(hlp);
 	}
 
@@ -3992,12 +3992,12 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
 
 ObjectInstanceID CGTeleport::getMatchingGate(ObjectInstanceID id)
 {
-	for(int i=0; i < gates.size(); i++)
+	for(auto & gate : gates)
 	{
-		if(gates[i].first == id)
-			return gates[i].second;
-		if(gates[i].second == id)
-			return gates[i].first;
+		if(gate.first == id)
+			return gate.second;
+		if(gate.second == id)
+			return gate.first;
 	}
 
 	return ObjectInstanceID();
@@ -4330,9 +4330,9 @@ bool CQuest::checkQuest (const CGHeroInstance * h) const
 				return true;
 			return false;
 		case MISSION_ART:
-			for (int i = 0; i < m5arts.size(); ++i)
+			for (auto & elem : m5arts)
 			{
-				if (h->hasArt(m5arts[i]))
+				if (h->hasArt(elem))
 					continue;
 				return false; //if the artifact was not found
 			}
@@ -4432,11 +4432,11 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
 		case MISSION_ART:
 		{
 			MetaString loot;
-			for (std::vector<ui16>::const_iterator it = m5arts.begin(); it != m5arts.end(); ++it)
+			for (auto & elem : m5arts)
 			{
-				components.push_back(Component (Component::ARTIFACT, *it, 0, 0));
+				components.push_back(Component (Component::ARTIFACT, elem, 0, 0));
 				loot << "%s";
-				loot.addReplacement(MetaString::ART_NAMES, *it);
+				loot.addReplacement(MetaString::ART_NAMES, elem);
 			}
 			if (!isCustom)
 				iwText.addReplacement(loot.buildList());
@@ -4445,11 +4445,11 @@ void CQuest::getVisitText (MetaString &iwText, std::vector<Component> &component
 		case MISSION_ARMY:
 		{
 			MetaString loot;
-			for (std::vector<CStackBasicDescriptor>::const_iterator it = m6creatures.begin(); it != m6creatures.end(); ++it)
+			for (auto & elem : m6creatures)
 			{
-				components.push_back(Component(*it));
+				components.push_back(Component(elem));
 				loot << "%s";
-				loot.addReplacement(*it);
+				loot.addReplacement(elem);
 			}
 			if (!isCustom)
 				iwText.addReplacement(loot.buildList());
@@ -4515,10 +4515,10 @@ void CQuest::getRolloverText (MetaString &ms, bool onHover) const
 		case MISSION_ART:
 			{
 				MetaString loot;
-				for (std::vector<ui16>::const_iterator it = m5arts.begin(); it != m5arts.end(); ++it)
+				for (auto & elem : m5arts)
 				{
 					loot << "%s";
-					loot.addReplacement(MetaString::ART_NAMES, *it);
+					loot.addReplacement(MetaString::ART_NAMES, elem);
 				}
 				ms.addReplacement(loot.buildList());
 			}
@@ -4526,10 +4526,10 @@ void CQuest::getRolloverText (MetaString &ms, bool onHover) const
 		case MISSION_ARMY:
 			{
 				MetaString loot;
-				for (std::vector<CStackBasicDescriptor>::const_iterator it = m6creatures.begin(); it != m6creatures.end(); ++it)
+				for (auto & elem : m6creatures)
 				{
 					loot << "%s";
-					loot.addReplacement(*it);
+					loot.addReplacement(elem);
 				}
 				ms.addReplacement(loot.buildList());
 			}
@@ -4589,10 +4589,10 @@ void CQuest::getCompletionText (MetaString &iwText, std::vector<Component> &comp
 		case CQuest::MISSION_ART:
 		{
 			MetaString loot;
-			for (std::vector<ui16>::const_iterator it = m5arts.begin(); it != m5arts.end(); ++it)
+			for (auto & elem : m5arts)
 			{
 				loot << "%s";
-				loot.addReplacement(MetaString::ART_NAMES, *it);
+				loot.addReplacement(MetaString::ART_NAMES, elem);
 			}
 			if (!isCustomComplete)
 				iwText.addReplacement(loot.buildList());
@@ -4601,10 +4601,10 @@ void CQuest::getCompletionText (MetaString &iwText, std::vector<Component> &comp
 		case CQuest::MISSION_ARMY:
 		{
 			MetaString loot;
-			for (std::vector<CStackBasicDescriptor>::const_iterator it = m6creatures.begin(); it != m6creatures.end(); ++it)
+			for (auto & elem : m6creatures)
 			{
 				loot << "%s";
-				loot.addReplacement(*it);
+				loot.addReplacement(elem);
 			}
 			if (!isCustomComplete)
 				iwText.addReplacement(loot.buildList());
@@ -4876,9 +4876,9 @@ void CGSeerHut::finishQuest(const CGHeroInstance * h, ui32 accept) const
 		switch (quest->missionType)
 		{
 			case CQuest::MISSION_ART:
-				for (std::vector<ui16>::const_iterator it = quest->m5arts.begin(); it != quest->m5arts.end(); ++it)
+				for (auto & elem : quest->m5arts)
 				{
-					cb->removeArtifact(ArtifactLocation(h, h->getArtPos(*it, false)));
+					cb->removeArtifact(ArtifactLocation(h, h->getArtPos(elem, false)));
 				}
 				break;
 			case CQuest::MISSION_ARMY:
@@ -5180,7 +5180,7 @@ void CGBonusingObject::onHeroVisit( const CGHeroInstance * h ) const
 		iw.soundID = soundBase::STORE;
 		bool someUpgradeDone = false;
 
-		for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); ++i)
+		for (auto i = h->Slots().begin(); i != h->Slots().end(); ++i)
 		{
 			if(i->second->type->idNumber == CreatureID::CAVALIER)
 			{
@@ -5334,9 +5334,9 @@ void CGPandoraBox::giveContentsUpToExp(const CGHeroInstance *h) const
 	iw.player = h->getOwner();
 
 	bool changesPrimSkill = false;
-	for (int i = 0; i < primskills.size(); i++)
+	for (auto & elem : primskills)
 	{
-		if(primskills[i])
+		if(elem)
 		{
 			changesPrimSkill = true;
 			break;
@@ -5486,9 +5486,9 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
 	// 	getText(iw,afterBattle,183,h);
 	iw.text.addTxt(MetaString::ADVOB_TXT, 183); //% has found treasure
 	iw.text.addReplacement(h->name);
-	for(int i=0; i<artifacts.size(); i++)
+	for(auto & elem : artifacts)
 	{
-		iw.components.push_back(Component(Component::ARTIFACT,artifacts[i],0,0));
+		iw.components.push_back(Component(Component::ARTIFACT,elem,0,0));
 		if(iw.components.size() >= 14)
 		{
 			cb->showInfoDialog(&iw);
@@ -5506,8 +5506,8 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
 		if(resources[i])
 			cb->giveResource(h->getOwner(),static_cast<Res::ERes>(i),resources[i]);
 
-	for(int i=0; i<artifacts.size(); i++)
-		cb->giveHeroNewArtifact(h, VLC->arth->artifacts[artifacts[i]],ArtifactPosition::FIRST_AVAILABLE);
+	for(auto & elem : artifacts)
+		cb->giveHeroNewArtifact(h, VLC->arth->artifacts[elem],ArtifactPosition::FIRST_AVAILABLE);
 
 	iw.components.clear();
 	iw.text.clear();
@@ -5515,11 +5515,11 @@ void CGPandoraBox::giveContentsAfterExp(const CGHeroInstance *h) const
 	if (creatures.Slots().size())
 	{ //this part is taken straight from creature bank
 		MetaString loot;
-		for(TSlots::const_iterator i = creatures.Slots().begin(); i != creatures.Slots().end(); i++)
+		for(auto & elem : creatures.Slots())
 		{ //build list of joined creatures
-			iw.components.push_back(Component(*i->second));
+			iw.components.push_back(Component(*elem.second));
 			loot << "%s";
-			loot.addReplacement(*i->second);
+			loot.addReplacement(*elem.second);
 		}
 
 		if (creatures.Slots().size() == 1 && creatures.Slots().begin()->second->count == 1)
@@ -5872,7 +5872,7 @@ ui8 CGGarrison::getPassableness() const
 
 	ui8 mask = 0;
 	TeamState * ts = cb->gameState()->getPlayerTeam(tempOwner);
-	BOOST_FOREACH(PlayerColor it, ts->players)
+	for(PlayerColor it : ts->players)
 		mask |= 1<<it.getNum(); //allies - add to possible visitors
 
 	return mask;
@@ -6095,11 +6095,11 @@ const std::string & CBank::getHoverText() const
 void CBank::reset(ui16 var1) //prevents desync
 {
 	ui8 chance = 0;
-	for (ui8 i = 0; i < VLC->objh->banksInfo[index].size(); i++)
+	for (auto & elem : VLC->objh->banksInfo[index])
 	{
-		if (var1 < (chance += VLC->objh->banksInfo[index][i]->chance))
+		if (var1 < (chance += elem->chance))
 		{
- 			bc = VLC->objh->banksInfo[index][i];
+ 			bc = elem;
 			break;
 		}
 	}
@@ -6173,9 +6173,9 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
 					{
 						if (bc->guards.back().second) //all stacks are present
 						{
-							for (auto it = bc->guards.begin(); it != bc->guards.end(); it++)
+							for (auto & elem : bc->guards)
 							{
-								setCreature (SlotID(stacksCount()), it->first, it->second);
+								setCreature (SlotID(stacksCount()), elem.first, elem.second);
 							}
 						}
 						else if (bc->guards[2].second)//Wraiths are present, split two stacks in Crypt
@@ -6369,12 +6369,12 @@ void CBank::battleFinished(const CGHeroInstance *hero, const BattleResult &resul
 			}
 		}
 		//grant artifacts
-		for (std::vector<ui32>::const_iterator it = artifacts.begin(); it != artifacts.end(); it++)
+		for (auto & elem : artifacts)
 		{
-			iw.components.push_back (Component (Component::ARTIFACT, *it, 0, 0));
+			iw.components.push_back (Component (Component::ARTIFACT, elem, 0, 0));
 			loot << "%s";
-			loot.addReplacement(MetaString::ART_NAMES, *it);
-			cb->giveHeroNewArtifact (hero, VLC->arth->artifacts[*it], ArtifactPosition::FIRST_AVAILABLE);
+			loot.addReplacement(MetaString::ART_NAMES, elem);
+			cb->giveHeroNewArtifact (hero, VLC->arth->artifacts[elem], ArtifactPosition::FIRST_AVAILABLE);
 		}
 		//display loot
 		if (!iw.components.empty())
@@ -6398,11 +6398,11 @@ void CBank::battleFinished(const CGHeroInstance *hero, const BattleResult &resul
 			SlotID slot = ourArmy.getSlotFor(it->first);
 			ourArmy.addToSlot(slot, it->first, it->second);
 		}
-		for (TSlots::const_iterator i = ourArmy.Slots().begin(); i != ourArmy.Slots().end(); i++)
+		for (auto & elem : ourArmy.Slots())
 		{
-			iw.components.push_back(Component(*i->second));
+			iw.components.push_back(Component(*elem.second));
 			loot << "%s";
-			loot.addReplacement(*i->second);
+			loot.addReplacement(*elem.second);
 		}
 
 		if (ourArmy.Slots().size())
@@ -6639,7 +6639,7 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const
 			fw.player = h->tempOwner;
 			fw.mode = 1;
 
-			BOOST_FOREACH(auto it, eyelist[subID])
+			for(auto it : eyelist[subID])
 			{
 				const CGObjectInstance *eye = cb->getObj(it);
 
@@ -6689,7 +6689,7 @@ void CGSirens::onHeroVisit( const CGHeroInstance * h ) const
 		giveDummyBonus(h->id, Bonus::ONE_BATTLE);
 		TExpType xp = 0;
 
-		for (TSlots::const_iterator i = h->Slots().begin(); i != h->Slots().end(); i++)
+		for (auto i = h->Slots().begin(); i != h->Slots().end(); i++)
 		{
 			TQuantity drown = i->second->count * 0.3;
 			if(drown)
@@ -6732,12 +6732,12 @@ int3 IBoatGenerator::bestLocation() const
 	std::vector<int3> offsets;
 	getOutOffsets(offsets);
 
-	for (int i = 0; i < offsets.size(); ++i)
+	for (auto & offset : offsets)
 	{
-		if (const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offsets[i], false)) //tile is in the map
+		if (const TerrainTile *tile = IObjectInterface::cb->getTile(o->pos + offset, false)) //tile is in the map
 		{
             if (tile->terType == ETerrainType::WATER  &&  (!tile->blocked || tile->blockingObjects.front()->ID == 8)) //and is water and is not blocked or is blocked by boat
-				return o->pos + offsets[i];
+				return o->pos + offset;
 		}
 	}
 	return int3 (-1,-1,-1);
@@ -7031,18 +7031,18 @@ void CGLighthouse::giveBonusTo( PlayerColor player ) const
 void CArmedInstance::randomizeArmy(int type)
 {
 	int max = VLC->creh->creatures.size();
-	for (TSlots::iterator j = stacks.begin(); j != stacks.end();j++)
+	for (auto & elem : stacks)
 	{
-		int randID = j->second->idRand;
+		int randID = elem.second->idRand;
 		if(randID > max)
 		{
 			int level = (randID-VLC->creh->creatures.size()) / 2 -1;
 			bool upgrade = !(randID % 2);
-			j->second->setType(VLC->townh->factions[type]->town->creatures[level][upgrade]);
+			elem.second->setType(VLC->townh->factions[type]->town->creatures[level][upgrade]);
 			randID = -1;
 		}
 
-		assert(j->second->armyObj == this);
+		assert(elem.second->armyObj == this);
 	}
 	return;
 }
@@ -7074,7 +7074,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
 	std::set<TFaction> factions;
 	bool hasUndead = false;
 
-	BOOST_FOREACH(auto slot, Slots())
+	for(auto slot : Slots())
 	{
 		const CStackInstance * inst = slot.second;
 		const CCreature * creature  = VLC->creh->creatures[inst->getCreatureID()];
@@ -7091,7 +7091,7 @@ void CArmedInstance::updateMoraleBonusFromArmy()
 	{
 		size_t mixableFactions = 0;
 
-		BOOST_FOREACH(TFaction f, factions)
+		for(TFaction f : factions)
 		{
 			if (VLC->townh->factions[f]->alignment != EAlignment::EVIL)
 				mixableFactions++;
@@ -7386,7 +7386,7 @@ std::vector<int> CGBlackMarket::availableItemsIds(EMarketMode::EMarketMode mode)
 	case EMarketMode::RESOURCE_ARTIFACT:
 		{
 			std::vector<int> ret;
-			BOOST_FOREACH(const CArtifact *a, artifacts)
+			for(const CArtifact *a : artifacts)
 				if(a)
 					ret.push_back(a->id);
 				else
@@ -7466,7 +7466,7 @@ CTownAndVisitingHero::CTownAndVisitingHero()
 int GrowthInfo::totalGrowth() const
 {
 	int ret = 0;
-	BOOST_FOREACH(const Entry &entry, entries)
+	for(const Entry &entry : entries)
 		ret += entry.count;
 
 	return ret;

+ 1 - 1
lib/CObjectHandler.h

@@ -188,7 +188,7 @@ public:
 	virtual int3 getSightCenter() const; //"center" tile from which the sight distance is calculated
 	virtual int getSightRadious() const; //sight distance (should be used if player-owned structure)
 	bool passableFor(PlayerColor color) const;
-	void getSightTiles(boost::unordered_set<int3, ShashInt3> &tiles) const; //returns reference to the set
+	void getSightTiles(std::unordered_set<int3, ShashInt3> &tiles) const; //returns reference to the set
 	PlayerColor getOwner() const;
 	void setOwner(PlayerColor ow);
 	int getWidth() const; //returns width of object graphic in tiles

+ 23 - 23
lib/CSpellHandler.cpp

@@ -91,8 +91,8 @@ namespace SRSLPraserHelpers
 		}
 
 		std::pair<int, int> mainPointForLayer[6]; //A, B, C, D, E, F points
-		for(int b=0; b<6; ++b)
-			mainPointForLayer[b] = hexToPair(center);
+		for(auto & elem : mainPointForLayer)
+			elem = hexToPair(center);
 
 		for(int it=1; it<=high; ++it) //it - distance to the center
 		{
@@ -133,10 +133,10 @@ CSpell::CSpell()
 
 CSpell::~CSpell()
 {
-	for (size_t i=0; i<effects.size(); i++)
+	for (auto & elem : effects)
 	{
-		for (size_t j=0; j<effects[i].size(); j++)
-			delete effects[i][j];
+		for (size_t j=0; j<elem.size(); j++)
+			delete elem[j];
 	}
 }
 
@@ -186,16 +186,16 @@ std::vector<BattleHex> CSpell::rangeInHexes(BattleHex centralHex, ui8 schoolLvl,
 		std::string number1, number2;
 		int beg, end;
 		bool readingFirst = true;
-		for(int it=0; it<rng.size(); ++it)
+		for(auto & elem : rng)
 		{
-			if( std::isdigit(rng[it]) ) //reading numer
+			if( std::isdigit(elem) ) //reading numer
 			{
 				if(readingFirst)
-					number1 += rng[it];
+					number1 += elem;
 				else
-					number2 += rng[it];
+					number2 += elem;
 			}
-			else if(rng[it] == ',') //comma
+			else if(elem == ',') //comma
 			{
 				//calculating variables
 				if(readingFirst)
@@ -220,13 +220,13 @@ std::vector<BattleHex> CSpell::rangeInHexes(BattleHex centralHex, ui8 schoolLvl,
 					readingFirst = true;
 				}
 				//adding abtained hexes
-				for(std::set<ui16>::iterator it = curLayer.begin(); it != curLayer.end(); ++it)
+				for(auto & curLayer_it : curLayer)
 				{
-					ret.push_back(*it);
+					ret.push_back(curLayer_it);
 				}
 
 			}
-			else if(rng[it] == '-') //dash
+			else if(elem == '-') //dash
 			{
 				beg = atoi(number1.c_str());
 				number1 = "";
@@ -265,7 +265,7 @@ void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const
 	}
 	lst.reserve(lst.size() + effects[level].size());
 
-	BOOST_FOREACH (Bonus *b, effects[level])
+	for (Bonus *b : effects[level])
 	{
 		//TODO: value, add value
 		lst.push_back(Bonus(*b));
@@ -275,13 +275,13 @@ void CSpell::getEffects(std::vector<Bonus>& lst, const int level) const
 bool CSpell::isImmuneBy(const IBonusBearer* obj) const
 {
 	//todo: use new bonus API
-	BOOST_FOREACH(auto b, limiters)
+	for(auto b : limiters)
 	{
 		if (!obj->hasBonusOfType(b))
 			return true;
 	}
 
-	BOOST_FOREACH(auto b, immunities)
+	for(auto b : immunities)
 	{
 		if (obj->hasBonusOfType(b))
 			return true;
@@ -365,7 +365,7 @@ bool DLL_LINKAGE isInScreenRange(const int3 &center, const int3 &pos)
 
 CSpell * CSpellHandler::loadSpell(CLegacyConfigParser & parser, const SpellID id)
 {
-	CSpell * spell = new CSpell; //new currently being read spell
+	auto  spell = new CSpell; //new currently being read spell
 
 	spell->id      = id;
 
@@ -448,7 +448,7 @@ CSpellHandler::CSpellHandler()
 	JsonNode config(ResourceID("config/spell_info.json"));
 	config.setMeta("core");
 
-	BOOST_FOREACH(auto &spell, config["spells"].Struct())
+	for(auto &spell : config["spells"].Struct())
 	{
 		//reading exact info
 		int spellID = spell.second["id"].Float();
@@ -459,7 +459,7 @@ CSpellHandler::CSpellHandler()
 
 		s->range.resize(4);
 		int idx = 0;
-		BOOST_FOREACH(const JsonNode &range, spell.second["ranges"].Vector())
+		for(const JsonNode &range : spell.second["ranges"].Vector())
 			s->range[idx++] = range.String();
 
 		s->counteredSpells = spell.second["counters"].convertTo<std::vector<SpellID> >();
@@ -472,7 +472,7 @@ CSpellHandler::CSpellHandler()
 		{
 			auto flags = flags_node.convertTo<std::vector<std::string> >();
 
-			BOOST_FOREACH (const auto & flag, flags)
+			for (const auto & flag : flags)
 			{
 				if (flag == "damage")
 				{
@@ -491,7 +491,7 @@ CSpellHandler::CSpellHandler()
 
 		const JsonNode & effects_node = spell.second["effects"];
 
-		BOOST_FOREACH (const JsonNode & bonus_node, effects_node.Vector())
+		for (const JsonNode & bonus_node : effects_node.Vector())
 		{
 			auto &v_node = bonus_node["values"];
 			auto &a_node = bonus_node["ainfos"];
@@ -542,7 +542,7 @@ CSpellHandler::CSpellHandler()
 			if (!node.isNull())
 			{
 				auto names = node.convertTo<std::vector<std::string> >();
-				BOOST_FOREACH(auto name, names)
+				for(auto name : names)
 				   find_in_map(name, vec);
 			}
 		};
@@ -560,7 +560,7 @@ CSpellHandler::CSpellHandler()
 
 CSpellHandler::~CSpellHandler()
 {
-	BOOST_FOREACH(auto & spell, spells)
+	for(auto & spell : spells)
 	{
 		spell.dellNull();
 	}

+ 23 - 23
lib/CTownHandler.cpp

@@ -73,10 +73,10 @@ CTown::CTown()
 
 CTown::~CTown()
 {
-	BOOST_FOREACH(auto & build, buildings)
+	for(auto & build : buildings)
 		build.second.dellNull();
 
-	BOOST_FOREACH(auto & str, clientInfo.structures)
+	for(auto & str : clientInfo.structures)
 		str.dellNull();
 }
 
@@ -87,7 +87,7 @@ CTownHandler::CTownHandler()
 
 CTownHandler::~CTownHandler()
 {
-	BOOST_FOREACH(auto faction, factions)
+	for(auto faction : factions)
 		faction.dellNull();
 }
 
@@ -97,7 +97,7 @@ JsonNode readBuilding(CLegacyConfigParser & parser)
 	JsonNode & cost = ret["cost"];
 
 	//note: this code will try to parse mithril as well but wil always return 0 for it
-	BOOST_FOREACH(const std::string & resID, GameConstants::RESOURCE_NAMES)
+	for(const std::string & resID : GameConstants::RESOURCE_NAMES)
 		cost[resID].Float() = parser.readNumber();
 
 	cost.Struct().erase("mithril"); // erase mithril to avoid confusing validator
@@ -262,7 +262,7 @@ std::vector<JsonNode> CTownHandler::loadLegacyData(size_t dataSize)
 
 void CTownHandler::loadBuilding(CTown &town, const JsonNode & source)
 {
-	CBuilding * ret = new CBuilding;
+	auto  ret = new CBuilding;
 
 	static const std::string modes [] = {"normal", "auto", "special", "grail"};
 
@@ -274,7 +274,7 @@ void CTownHandler::loadBuilding(CTown &town, const JsonNode & source)
 	ret->description = source["description"].String();
 	ret->resources = TResources(source["cost"]);
 
-	BOOST_FOREACH(const JsonNode &building, source["requires"].Vector())
+	for(const JsonNode &building : source["requires"].Vector())
 		ret->requirements.insert(BuildingID(building.Float()));
 
 	if (!source["upgrades"].isNull())
@@ -292,7 +292,7 @@ void CTownHandler::loadBuildings(CTown &town, const JsonNode & source)
 {
 	if (source.getType() == JsonNode::DATA_VECTOR)
 	{
-		BOOST_FOREACH(auto &node, source.Vector())
+		for(auto &node : source.Vector())
 		{
 			if (!node.isNull())
 				loadBuilding(town, node);
@@ -300,7 +300,7 @@ void CTownHandler::loadBuildings(CTown &town, const JsonNode & source)
 	}
 	else
 	{
-		BOOST_FOREACH(auto &node, source.Struct())
+		for(auto &node : source.Struct())
 		{
 			if (!node.second.isNull())
 				loadBuilding(town, node.second);
@@ -310,7 +310,7 @@ void CTownHandler::loadBuildings(CTown &town, const JsonNode & source)
 
 void CTownHandler::loadStructure(CTown &town, const JsonNode & source)
 {
-	CStructure * ret = new CStructure;
+	auto  ret = new CStructure;
 
 	if (source["id"].isNull())
 	{
@@ -343,7 +343,7 @@ void CTownHandler::loadStructures(CTown &town, const JsonNode & source)
 {
 	if (source.getType() == JsonNode::DATA_VECTOR)
 	{
-		BOOST_FOREACH(auto &node, source.Vector())
+		for(auto &node : source.Vector())
 		{
 			if (!node.isNull())
 				loadStructure(town, node);
@@ -351,7 +351,7 @@ void CTownHandler::loadStructures(CTown &town, const JsonNode & source)
 	}
 	else
 	{
-		BOOST_FOREACH(auto &node, source.Struct())
+		for(auto &node : source.Struct())
 		{
 			if (!node.second.isNull())
 				loadStructure(town, node.second);
@@ -361,15 +361,15 @@ void CTownHandler::loadStructures(CTown &town, const JsonNode & source)
 
 void CTownHandler::loadTownHall(CTown &town, const JsonNode & source)
 {
-	BOOST_FOREACH(const JsonNode &row, source.Vector())
+	for(const JsonNode &row : source.Vector())
 	{
 		std::vector< std::vector<BuildingID> > hallRow;
 
-		BOOST_FOREACH(const JsonNode &box, row.Vector())
+		for(const JsonNode &box : row.Vector())
 		{
 			std::vector<BuildingID> hallBox;
 
-			BOOST_FOREACH(const JsonNode &value, box.Vector())
+			for(const JsonNode &value : box.Vector())
 			{
 				hallBox.push_back(BuildingID(value.Float()));
 			}
@@ -464,10 +464,10 @@ void CTownHandler::loadClientData(CTown &town, const JsonNode & source)
 void CTownHandler::loadTown(CTown &town, const JsonNode & source)
 {
 	auto resIter = boost::find(GameConstants::RESOURCE_NAMES, source["primaryResource"].String());
-	if (resIter == boost::end(GameConstants::RESOURCE_NAMES))
+	if (resIter == std::end(GameConstants::RESOURCE_NAMES))
 		town.primaryRes = Res::WOOD_AND_ORE; //Wood + Ore
 	else
-		town.primaryRes = resIter - boost::begin(GameConstants::RESOURCE_NAMES);
+		town.primaryRes = resIter - std::begin(GameConstants::RESOURCE_NAMES);
 
 	VLC->modh->identifiers.requestIdentifier("creature", source["warMachine"],
 	[&town](si32 creature)
@@ -481,7 +481,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
 	town.names = source["names"].convertTo<std::vector<std::string> >();
 
 	//  Horde building creature level
-	BOOST_FOREACH(const JsonNode &node, source["horde"].Vector())
+	for(const JsonNode &node : source["horde"].Vector())
 	{
 		town.hordeLvl[town.hordeLvl.size()] = node.Float();
 	}
@@ -506,7 +506,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
 	}
 
 	/// set chance of specific hero class to appear in this town
-	BOOST_FOREACH(auto &node, source["tavern"].Struct())
+	for(auto &node : source["tavern"].Struct())
 	{
 		int chance = node.second.Float();
 
@@ -516,7 +516,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
 		});
 	}
 
-	BOOST_FOREACH(auto &node, source["guildSpells"].Struct())
+	for(auto &node : source["guildSpells"].Struct())
 	{
 		int chance = node.second.Float();
 
@@ -526,7 +526,7 @@ void CTownHandler::loadTown(CTown &town, const JsonNode & source)
 		});
 	}
 
-	BOOST_FOREACH (const JsonNode &d, source["adventureMap"]["dwellings"].Vector())
+	for (const JsonNode &d : source["adventureMap"]["dwellings"].Vector())
 	{
 		town.dwellings.push_back (d["graphics"].String());
 		town.dwellingNames.push_back (d["name"].String());
@@ -541,7 +541,7 @@ void CTownHandler::loadPuzzle(CFaction &faction, const JsonNode &source)
 	faction.puzzleMap.reserve(GameConstants::PUZZLE_MAP_PIECES);
 
 	std::string prefix = source["prefix"].String();
-	BOOST_FOREACH(const JsonNode &piece, source["pieces"].Vector())
+	for(const JsonNode &piece : source["pieces"].Vector())
 	{
 		size_t index = faction.puzzleMap.size();
 		SPuzzleInfo spi;
@@ -564,7 +564,7 @@ void CTownHandler::loadPuzzle(CFaction &faction, const JsonNode &source)
 
 CFaction * CTownHandler::loadFromJson(const JsonNode &source)
 {
-	CFaction * faction = new CFaction();
+	auto  faction = new CFaction();
 
 	faction->name = source["name"].String();
 
@@ -640,7 +640,7 @@ void CTownHandler::loadObject(std::string scope, std::string name, const JsonNod
 std::vector<bool> CTownHandler::getDefaultAllowed() const
 {
 	std::vector<bool> allowedFactions;
-	BOOST_FOREACH(auto town, factions)
+	for(auto town : factions)
 	{
 		allowedFactions.push_back(town->town != nullptr);
 	}

+ 1 - 1
lib/Connection.cpp

@@ -186,7 +186,7 @@ CConnection::~CConnection(void)
 
 template<class T>
 CConnection & CConnection::operator&(const T &t) {
-	throw std::exception();
+//	throw std::exception();
 //XXX this is temporaly ? solution to fix gcc (4.3.3, other?) compilation
 //    problem for more details contact [email protected] or [email protected]
 //    do not remove this exception it shoudnt be called

+ 4 - 4
lib/Connection.h

@@ -739,12 +739,12 @@ public:
 			*this << *i;
 	}
 	template <typename T, typename U>
-	void saveSerializable(const boost::unordered_set<T, U> &data)
+	void saveSerializable(const std::unordered_set<T, U> &data)
 	{
-		boost::unordered_set<T, U> &d = const_cast<boost::unordered_set<T, U> &>(data);
+		std::unordered_set<T, U> &d = const_cast<std::unordered_set<T, U> &>(data);
 		ui32 length = d.size();
 		*this << length;
-		for(typename boost::unordered_set<T, U>::iterator i=d.begin();i!=d.end();i++)
+		for(typename std::unordered_set<T, U>::iterator i=d.begin();i!=d.end();i++)
 			*this << *i;
 	}
 	template <typename T>
@@ -1132,7 +1132,7 @@ public:
 		}
 	}
 	template <typename T, typename U>
-	void loadSerializable(boost::unordered_set<T, U> &data)
+	void loadSerializable(std::unordered_set<T, U> &data)
 	{
 		READ_CHECK_U32(length);
         data.clear();

+ 40 - 40
lib/HeroBonus.cpp

@@ -21,10 +21,10 @@
 #include "CArtHandler.h"
 #include "GameConstants.h"
 
-#define FOREACH_PARENT(pname) 	TNodes lparents; getParents(lparents); BOOST_FOREACH(CBonusSystemNode *pname, lparents)
-#define FOREACH_CPARENT(pname) 	TCNodes lparents; getParents(lparents); BOOST_FOREACH(const CBonusSystemNode *pname, lparents)
-#define FOREACH_RED_CHILD(pname) 	TNodes lchildren; getRedChildren(lchildren); BOOST_FOREACH(CBonusSystemNode *pname, lchildren)
-#define FOREACH_RED_PARENT(pname) 	TNodes lparents; getRedParents(lparents); BOOST_FOREACH(CBonusSystemNode *pname, lparents)
+#define FOREACH_PARENT(pname) 	TNodes lparents; getParents(lparents); for(CBonusSystemNode *pname : lparents)
+#define FOREACH_CPARENT(pname) 	TCNodes lparents; getParents(lparents); for(const CBonusSystemNode *pname : lparents)
+#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;
@@ -106,9 +106,9 @@ int BonusList::totalValue() const
 	int indepMin = 0;
 	bool hasIndepMin = false;
 
-	for (size_t i = 0; i < bonuses.size(); i++)
+	for (auto & elem : bonuses)
 	{
-		Bonus *b = bonuses[i];
+		Bonus *b = elem;
 
 		switch(b->valType)
 		{
@@ -181,9 +181,9 @@ int BonusList::totalValue() const
 }
 const Bonus * BonusList::getFirst(const CSelector &selector) const
 {
-	for (ui32 i = 0; i < bonuses.size(); i++)
+	for (auto & elem : bonuses)
 	{
-		const Bonus *b = bonuses[i];
+		const Bonus *b = elem;
 		if(selector(b))
 			return &*b;
 	}
@@ -192,9 +192,9 @@ const Bonus * BonusList::getFirst(const CSelector &selector) const
 
 Bonus * BonusList::getFirst(const CSelector &select)
 {
-	for (ui32 i = 0; i < bonuses.size(); i++)
+	for (auto & elem : bonuses)
 	{
-		Bonus *b = bonuses[i];
+		Bonus *b = elem;
 		if(select(b))
 			return &*b;
 	}
@@ -203,27 +203,27 @@ Bonus * BonusList::getFirst(const CSelector &select)
 
 void BonusList::getModifiersWDescr(TModDescr &out) const
 {
-	for (size_t i = 0; i < bonuses.size(); i++)
+	for (auto & elem : bonuses)
 	{
-		Bonus *b = bonuses[i];
+		Bonus *b = elem;
 		out.push_back(std::make_pair(b->val, b->Description()));
 	}
 }
 
 void BonusList::getBonuses(BonusList & out, const CSelector &selector) const
 {
-// 	BOOST_FOREACH(Bonus *i, *this)
+// 	for(Bonus *i : *this)
 // 		if(selector(i) && i->effectRange == Bonus::NO_LIMIT)
 // 			out.push_back(i);
 
-	getBonuses(out, selector, 0);
+	getBonuses(out, selector, nullptr);
 }
 
 void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSelector &limit) const
 {
-	for (ui32 i = 0; i < bonuses.size(); i++)
+	for (auto & elem : bonuses)
 	{
-		Bonus *b = bonuses[i];
+		Bonus *b = elem;
 
 		//add matching bonuses that matches limit predicate or have NO_LIMIT if no given predicate
 		if(selector(b) && ((!limit && b->effectRange == Bonus::NO_LIMIT) || (limit && limit(b))))
@@ -233,14 +233,14 @@ void BonusList::getBonuses(BonusList & out, const CSelector &selector, const CSe
 
 void BonusList::getAllBonuses(BonusList &out) const
 {
-	BOOST_FOREACH(Bonus *b, bonuses)
+	for(Bonus *b : bonuses)
 		out.push_back(b);
 }
 
 int BonusList::valOfBonuses(const CSelector &select) const
 {
 	BonusList ret;
-	CSelector limit = 0;
+	CSelector limit = nullptr;
 	getBonuses(ret, select, limit);
 	ret.eliminateDuplicates();
 	return ret.totalValue();
@@ -283,7 +283,7 @@ void BonusList::clear()
 
 std::vector<BonusList*>::size_type BonusList::operator-=(Bonus* const &i)
 {
-	std::vector<Bonus*>::iterator itr = std::find(bonuses.begin(), bonuses.end(), i);
+	auto itr = std::find(bonuses.begin(), bonuses.end(), i);
 	if(itr == bonuses.end())
 		return false;
 	bonuses.erase(itr);
@@ -328,7 +328,7 @@ int IBonusBearer::valOfBonuses(Bonus::BonusType type, int subtype /*= -1*/) cons
 
 int IBonusBearer::valOfBonuses(const CSelector &selector, const std::string &cachingStr) const
 {
-	CSelector limit = 0;
+	CSelector limit = nullptr;
 	TBonusListPtr hlp = getAllBonuses(selector, limit, nullptr, cachingStr);
 	return hlp->totalValue();
 }
@@ -374,7 +374,7 @@ int IBonusBearer::getBonusesCount(const CSelector &selector, const std::string &
 
 const TBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const std::string &cachingStr /*= ""*/) const
 {
-	return getAllBonuses(selector, 0, nullptr, cachingStr);
+	return getAllBonuses(selector, nullptr, nullptr, cachingStr);
 }
 
 const TBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr /*= ""*/) const
@@ -504,7 +504,7 @@ const Bonus * IBonusBearer::getEffect(ui16 id, int turn /*= 0*/) const
 {
 	//TODO should check only local bonuses?
 	auto bonuses = getAllBonuses();
-	BOOST_FOREACH(const Bonus *it, *bonuses)
+	for(const Bonus *it : *bonuses)
 	{
 		if(it->source == Bonus::SPELL_EFFECT && it->sid == id)
 		{
@@ -521,7 +521,7 @@ ui8 IBonusBearer::howManyEffectsSet(ui16 id) const
 	ui8 ret = 0;
 
 	auto bonuses = getAllBonuses();
-	BOOST_FOREACH(const Bonus *it, *bonuses)
+	for(const Bonus *it : *bonuses)
 	{
 		if(it->source == Bonus::SPELL_EFFECT && it->sid == id) //effect found
 		{
@@ -568,18 +568,18 @@ const Bonus * CBonusSystemNode::getBonusLocalFirst( const CSelector &selector )
 
 void CBonusSystemNode::getParents(TCNodes &out) const /*retreives list of parent nodes (nodes to inherit bonuses from) */
 {
-	for (ui32 i = 0; i < parents.size(); i++)
+	for (auto & elem : parents)
 	{
-		const CBonusSystemNode *parent = parents[i];
+		const CBonusSystemNode *parent = elem;
 		out.insert(parent);
 	}
 }
 
 void CBonusSystemNode::getParents(TNodes &out)
 {
-	for (ui32 i = 0; i < parents.size(); i++)
+	for (auto & elem : parents)
 	{
-		const CBonusSystemNode *parent = parents[i];
+		const CBonusSystemNode *parent = elem;
 		out.insert(const_cast<CBonusSystemNode*>(parent));
 	}
 }
@@ -678,13 +678,13 @@ const TBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelecto
 		BonusList rootBonuses, limitedRootBonuses;
 		getAllBonusesRec(rootBonuses);
 
-		BOOST_FOREACH(Bonus *b, beforeLimiting)
+		for(Bonus *b : beforeLimiting)
 			rootBonuses.push_back(b);
 
 		rootBonuses.eliminateDuplicates();
 		root->limitBonuses(rootBonuses, limitedRootBonuses);
 
-		BOOST_FOREACH(Bonus *b, beforeLimiting)
+		for(Bonus *b : beforeLimiting)
 			if(vstd::contains(limitedRootBonuses, b))
 				afterLimiting.push_back(b);
 
@@ -711,7 +711,7 @@ CBonusSystemNode::~CBonusSystemNode()
 			children.front()->detachFrom(this);
 	}
 
-	BOOST_FOREACH(Bonus *b, exportedBonuses)
+	for(Bonus *b : exportedBonuses)
 		delete b;
 }
 
@@ -747,10 +747,10 @@ void CBonusSystemNode::popBonuses(const CSelector &s)
 {
 	BonusList bl;
 	exportedBonuses.getBonuses(bl, s);
-	BOOST_FOREACH(Bonus *b, bl)
+	for(Bonus *b : bl)
 		removeBonus(b);
 
-	BOOST_FOREACH(CBonusSystemNode *child, children)
+	for(CBonusSystemNode *child : children)
 		child->popBonuses(s);
 }
 
@@ -879,7 +879,7 @@ void CBonusSystemNode::getRedParents(TNodes &out)
 
 	if(!actsAsBonusSourceOnly())
 	{
-		BOOST_FOREACH(CBonusSystemNode *child, children)
+		for(CBonusSystemNode *child : children)
 		{
 			out.insert(child);
 		}
@@ -898,7 +898,7 @@ void CBonusSystemNode::getRedChildren(TNodes &out)
 
 	if(actsAsBonusSourceOnly())
 	{
-		BOOST_FOREACH(CBonusSystemNode *child, children)
+		for(CBonusSystemNode *child : children)
 		{
 			out.insert(child);
 		}
@@ -907,7 +907,7 @@ void CBonusSystemNode::getRedChildren(TNodes &out)
 
 void CBonusSystemNode::newRedDescendant(CBonusSystemNode *descendant)
 {
-	BOOST_FOREACH(Bonus *b, exportedBonuses)
+	for(Bonus *b : exportedBonuses)
 		if(b->propagator)
 			descendant->propagateBonus(b);
 
@@ -917,7 +917,7 @@ void CBonusSystemNode::newRedDescendant(CBonusSystemNode *descendant)
 
 void CBonusSystemNode::removedRedDescendant(CBonusSystemNode *descendant)
 {
-	BOOST_FOREACH(Bonus *b, exportedBonuses)
+	for(Bonus *b : exportedBonuses)
 		if(b->propagator)
 			descendant->unpropagateBonus(b);
 
@@ -942,9 +942,9 @@ void CBonusSystemNode::getRedDescendants(TNodes &out)
 void CBonusSystemNode::battleTurnPassed()
 {
 	BonusList bonusesCpy = exportedBonuses; //copy, because removing bonuses invalidates iters
-	for (ui32 i = 0; i < bonusesCpy.size(); i++)
+	for (auto & elem : bonusesCpy)
 	{
-		Bonus *b = bonusesCpy[i];
+		Bonus *b = elem;
 
 		if(b->duration & Bonus::N_TURNS)
 		{
@@ -967,7 +967,7 @@ void CBonusSystemNode::exportBonus(Bonus * b)
 
 void CBonusSystemNode::exportBonuses()
 {
-	BOOST_FOREACH(Bonus *b, exportedBonuses)
+	for(Bonus *b : exportedBonuses)
 		exportBonus(b);
 }
 
@@ -1544,7 +1544,7 @@ int LimiterList::limit( const BonusLimitationContext &context ) const
 {
 	bool wasntSure = false;
 
-	BOOST_FOREACH(auto limiter, limiters)
+	for(auto limiter : limiters)
 	{
 		auto result = limiter->limit(context);
 		if(result == ILimiter::DISCARD)

+ 24 - 10
lib/HeroBonus.h

@@ -364,6 +364,9 @@ public:
 	typedef TInternalContainer::const_reference const_reference;
 	typedef TInternalContainer::value_type value_type;
 
+	typedef TInternalContainer::const_iterator const_iterator;
+	typedef TInternalContainer::iterator iterator;
+
 	BonusList(bool BelongsToTree = false);
 	BonusList(const BonusList &bonusList);
 	BonusList& operator=(const BonusList &bonusList);
@@ -427,29 +430,40 @@ public:
 		h & static_cast<std::vector<Bonus*>&>(bonuses);
 	}
 
-	friend inline std::vector<Bonus*>::iterator range_begin(BonusList & x);
-	friend inline std::vector<Bonus*>::iterator range_end(BonusList & x);
+	// C++ for range support
+	auto begin () -> decltype (bonuses.begin())
+	{
+		return bonuses.begin();
+	}
+
+	auto end () -> decltype (bonuses.end())
+	{
+		return bonuses.end();
+	}
+
+	//friend inline std::vector<Bonus*>::iterator range_begin(BonusList & x);
+	//friend inline std::vector<Bonus*>::iterator range_end(BonusList & x);
 };
 
 
 // Extensions for BOOST_FOREACH to enable iterating of BonusList objects
 // Don't touch/call this functions
-inline std::vector<Bonus*>::iterator range_begin(BonusList & x)
+inline BonusList::iterator range_begin(BonusList & x)
 {
-	return x.bonuses.begin();
+	return x.begin();
 }
 
-inline std::vector<Bonus*>::iterator range_end(BonusList & x)
+inline BonusList::iterator range_end(BonusList & x)
 {
-	return x.bonuses.end();
+	return x.end();
 }
 
-inline std::vector<Bonus*>::const_iterator range_begin(BonusList const &x)
+inline BonusList::const_iterator range_begin(BonusList const &x)
 {
 	return x.begin();
 }
 
-inline std::vector<Bonus*>::const_iterator range_end(BonusList const &x)
+inline BonusList::const_iterator range_end(BonusList const &x)
 {
 	return x.end();
 }
@@ -963,7 +977,7 @@ void BonusList::insert(const int position, InputIterator first, InputIterator la
 }
 
 // Extensions for BOOST_FOREACH to enable iterating of BonusList objects
-namespace boost
+/*namespace boost
 {
 	template<>
 	struct range_mutable_iterator<BonusList>
@@ -976,4 +990,4 @@ namespace boost
 	{
 		typedef std::vector<Bonus*>::const_iterator type;
 	};
-}
+}*/

+ 30 - 30
lib/IGameCallback.cpp

@@ -75,7 +75,7 @@ const PlayerSettings * CGameInfoCallback::getPlayerSettings(PlayerColor color) c
 	return &gs->scenarioOps->getIthPlayersSettings(color);
 }
 
-void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, boost::optional<PlayerColor> player/*=uninit*/, int mode/*=0*/ ) const
+void CPrivilagedInfoCallback::getTilesInRange( std::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, boost::optional<PlayerColor> player/*=uninit*/, int mode/*=0*/ ) const
 {
 	if(!!player && *player >= PlayerColor::PLAYER_LIMIT)
 	{
@@ -105,7 +105,7 @@ void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set<int3, ShashI
 	}
 }
 
-void CPrivilagedInfoCallback::getAllTiles (boost::unordered_set<int3, ShashInt3> &tiles, boost::optional<PlayerColor> Player/*=uninit*/, int level, int surface ) const
+void CPrivilagedInfoCallback::getAllTiles (std::unordered_set<int3, ShashInt3> &tiles, boost::optional<PlayerColor> Player/*=uninit*/, int level, int surface ) const
 {
 	if(!!Player && *Player >= PlayerColor::PLAYER_LIMIT)
 	{
@@ -126,9 +126,9 @@ void CPrivilagedInfoCallback::getAllTiles (boost::unordered_set<int3, ShashInt3>
 	else
 		floors.push_back(level);
 
-	for (std::vector<int>::const_iterator i = floors.begin(); i!= floors.end(); i++)
+	for (auto zd : floors)
 	{
-		register int zd = *i;
+		
 		for (int xd = 0; xd < gs->map->width; xd++)
 		{
 			for (int yd = 0; yd < gs->map->height; yd++)
@@ -149,9 +149,9 @@ void CPrivilagedInfoCallback::getFreeTiles (std::vector<int3> &tiles) const
 		floors.push_back(b);
 	}
 	const TerrainTile *tinfo;
-	for (std::vector<int>::const_iterator i = floors.begin(); i!= floors.end(); i++)
+	for (auto zd : floors)
 	{
-		register int zd = *i;
+		
 		for (int xd = 0; xd < gs->map->width; xd++)
 		{
 			for (int yd = 0; yd < gs->map->height; yd++)
@@ -428,7 +428,7 @@ std::vector<const CGObjectInstance*> CGameInfoCallback::getGuardingCreatures (in
 {
 	ERROR_RET_VAL_IF(!isVisible(pos), "Tile is not visible!", std::vector<const CGObjectInstance*>());
 	std::vector<const CGObjectInstance*> ret;
-	BOOST_FOREACH(auto cr, gs->guardingCreatures(pos))
+	for(auto cr : gs->guardingCreatures(pos))
 	{
 		ret.push_back(cr);
 	}
@@ -460,7 +460,7 @@ std::vector < std::string > CGameInfoCallback::getObjDescriptions(int3 pos) cons
 	ERROR_RET_VAL_IF(!t, "Not a valid tile given!", ret);
 
 
-	BOOST_FOREACH(const CGObjectInstance * obj, t->blockingObjects)
+	for(const CGObjectInstance * obj : t->blockingObjects)
 		ret.push_back(obj->getHoverText());
 	return ret;
 }
@@ -502,7 +502,7 @@ std::vector < const CGObjectInstance * > CGameInfoCallback::getBlockingObjs( int
 	const TerrainTile *t = getTile(pos);
 	ERROR_RET_VAL_IF(!t, "Not a valid tile requested!", ret);
 
-	BOOST_FOREACH(const CGObjectInstance * obj, t->blockingObjects)
+	for(const CGObjectInstance * obj : t->blockingObjects)
 		ret.push_back(obj);
 	return ret;
 }
@@ -513,9 +513,9 @@ std::vector <const CGObjectInstance * > CGameInfoCallback::getVisitableObjs(int3
 	const TerrainTile *t = getTile(pos, verbose);
 	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!t, verbose, pos << " is not visible!", ret);
 
-	BOOST_FOREACH(const CGObjectInstance * obj, t->visitableObjects)
+	for(const CGObjectInstance * obj : t->visitableObjects)
 	{
-		if(player < 0 || obj->ID != Obj::EVENT) //hide events from players
+		if(player < nullptr || obj->ID != Obj::EVENT) //hide events from players
 			ret.push_back(obj);
 	}
 
@@ -527,7 +527,7 @@ std::vector < const CGObjectInstance * > CGameInfoCallback::getFlaggableObjects(
 	std::vector<const CGObjectInstance *> ret;
 	const TerrainTile *t = getTile(pos);
 	ERROR_RET_VAL_IF(!t, "Not a valid tile requested!", ret);
-	BOOST_FOREACH(const CGObjectInstance *obj, t->blockingObjects)
+	for(const CGObjectInstance *obj : t->blockingObjects)
 		if(obj->tempOwner != PlayerColor::UNFLAGGABLE)
 			ret.push_back(obj);
 // 	const std::vector < std::pair<const CGObjectInstance*,SDL_Rect> > & objs = CGI->mh->ttiles[pos.x][pos.y][pos.z].objects;
@@ -583,11 +583,11 @@ EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTow
 	std::set<BuildingID> reqs = getBuildingRequiments(t, ID);//getting all requirements
 
 	bool notAllBuilt = false;
-	for( std::set<BuildingID>::iterator ri  =  reqs.begin(); ri != reqs.end(); ri++ )
+	for(auto & req : reqs)
 	{
-		if(!t->hasBuilt(*ri)) //lack of requirements - cannot build
+		if(!t->hasBuilt(req)) //lack of requirements - cannot build
 		{
-			if(vstd::contains(t->forbiddenBuildings, *ri)) // not built requirement forbidden - same goes to this build
+			if(vstd::contains(t->forbiddenBuildings, req)) // not built requirement forbidden - same goes to this build
 				return EBuildingState::FORBIDDEN;
 			else
 				notAllBuilt = true; // no return here - we need to check if any required builds are forbidden
@@ -605,7 +605,7 @@ EBuildingState::EBuildingState CGameInfoCallback::canBuildStructure( const CGTow
 		const PlayerState *ps = getPlayer(t->tempOwner);
 		if(ps)
 		{
-			BOOST_FOREACH(const CGTownInstance *t, ps->towns)
+			for(const CGTownInstance *t : ps->towns)
 			{
 				if(t->hasBuilt(BuildingID::CAPITOL))
 				{
@@ -649,8 +649,8 @@ std::set<BuildingID> CGameInfoCallback::getBuildingRequiments( const CGTownInsta
 				auto & requires = t->town->buildings[*i]->requirements;
 
 				used.insert(*i);
-				for(auto j = requires.begin(); j!= requires.end(); j++)
-					reqs.insert(*j);//creating full list of requirements
+				for(auto & require : requires)
+					reqs.insert(require);//creating full list of requirements
 			}
 		}
 	}
@@ -701,8 +701,8 @@ int CGameInfoCallback::getHeroCount( PlayerColor player, bool includeGarrisoned
 	if(includeGarrisoned)
 		return p->heroes.size();
 	else
-		for(ui32 i = 0; i < p->heroes.size(); i++)
-			if(!p->heroes[i]->inTownGarrison)
+		for(auto & elem : p->heroes)
+			if(!elem->inTownGarrison)
 				ret++;
 	return ret;
 }
@@ -749,9 +749,9 @@ std::vector < const CGTownInstance *> CPlayerSpecificInfoCallback::getTownsInfo(
 {
 	//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
 	std::vector < const CGTownInstance *> ret = std::vector < const CGTownInstance *>();
-	BOOST_FOREACH(const auto & i, gs->players)
+	for(const auto & i : gs->players)
 	{
-		BOOST_FOREACH(const auto & town, i.second.towns)
+		for(const auto & town : i.second.towns)
 		{
 			if (i.first==player || (isVisible(town, player) && !onlyOur))
 			{
@@ -765,7 +765,7 @@ std::vector < const CGHeroInstance *> CPlayerSpecificInfoCallback::getHeroesInfo
 {
 	//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
 	std::vector < const CGHeroInstance *> ret;
-	BOOST_FOREACH(auto hero, gs->map->heroesOnMap)
+	for(auto hero : gs->map->heroesOnMap)
 	{
 		if( !player || (hero->tempOwner == *player) ||
 			(isVisible(hero->getPosition(false), player) && !onlyOur)	)
@@ -789,12 +789,12 @@ int CPlayerSpecificInfoCallback::getHeroSerial(const CGHeroInstance * hero, bool
 	size_t index = 0;
 	auto & heroes = gs->players[*player].heroes;
 
-	for (auto curHero = heroes.begin(); curHero!=heroes.end(); curHero++)
+	for (auto & heroe : heroes)
 	{
-		if (includeGarrisoned || !(*curHero)->inTownGarrison)
+		if (includeGarrisoned || !(heroe)->inTownGarrison)
 			index++;
 
-		if (*curHero == hero)
+		if (heroe == hero)
 			return index;
 	}
 	return -1;
@@ -816,7 +816,7 @@ int3 CPlayerSpecificInfoCallback::getGrailPos( double &outKnownRatio )
 std::vector < const CGObjectInstance * > CPlayerSpecificInfoCallback::getMyObjects() const
 {
 	std::vector < const CGObjectInstance * > ret;
-	BOOST_FOREACH(const CGObjectInstance * obj, gs->map->objects)
+	for(const CGObjectInstance * obj : gs->map->objects)
 	{
 		if(obj && obj->tempOwner == player)
 			ret.push_back(obj);
@@ -828,7 +828,7 @@ std::vector < const CGDwelling * > CPlayerSpecificInfoCallback::getMyDwellings()
 {
 	ASSERT_IF_CALLED_WITH_PLAYER
 	std::vector < const CGDwelling * > ret;
-	BOOST_FOREACH(CGDwelling * dw, gs->getPlayer(*player)->dwellings)
+	for(CGDwelling * dw : gs->getPlayer(*player)->dwellings)
 	{
 		ret.push_back(dw);
 	}
@@ -838,7 +838,7 @@ std::vector < const CGDwelling * > CPlayerSpecificInfoCallback::getMyDwellings()
 std::vector <QuestInfo> CPlayerSpecificInfoCallback::getMyQuests() const
 {
 	std::vector <QuestInfo> ret;
-	BOOST_FOREACH (auto quest, gs->getPlayer(*player)->quests)
+	for (auto quest : gs->getPlayer(*player)->quests)
 	{
 		ret.push_back (quest);
 	}
@@ -944,7 +944,7 @@ const TeamState * CGameInfoCallback::getPlayerTeam( PlayerColor color ) const
 
 const CGHeroInstance* CGameInfoCallback::getHeroWithSubid( int subid ) const
 {
-	BOOST_FOREACH(const CGHeroInstance *h, gs->map->heroesOnMap)
+	for(const CGHeroInstance *h : gs->map->heroesOnMap)
 		if(h->subID == subid)
 			return h;
 

+ 2 - 2
lib/IGameCallback.h

@@ -171,8 +171,8 @@ class DLL_LINKAGE CPrivilagedInfoCallback : public CGameInfoCallback
 public:
 	CGameState * gameState ();
 	void getFreeTiles (std::vector<int3> &tiles) const; //used for random spawns
-	void getTilesInRange(boost::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, boost::optional<PlayerColor> player = boost::optional<PlayerColor>(), int mode=0) const;  //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 -  only unrevealed
-	void getAllTiles (boost::unordered_set<int3, ShashInt3> &tiles, boost::optional<PlayerColor> player = boost::optional<PlayerColor>(), int level=-1, int surface=0) const; //returns all tiles on given level (-1 - both levels, otherwise number of level); surface: 0 - land and water, 1 - only land, 2 - only water
+	void getTilesInRange(std::unordered_set<int3, ShashInt3> &tiles, int3 pos, int radious, boost::optional<PlayerColor> player = boost::optional<PlayerColor>(), int mode=0) const;  //mode 1 - only unrevealed tiles; mode 0 - all, mode -1 -  only unrevealed
+	void getAllTiles (std::unordered_set<int3, ShashInt3> &tiles, boost::optional<PlayerColor> player = boost::optional<PlayerColor>(), int level=-1, int surface=0) const; //returns all tiles on given level (-1 - both levels, otherwise number of level); surface: 0 - land and water, 1 - only land, 2 - only water
 	ArtifactID getRandomArt (int flags);
 	ArtifactID getArtSync (ui32 rand, int flags, bool erasePicked); //synchronous
 	void pickAllowedArtsSet(std::vector<const CArtifact*> &out); //gives 3 treasures, 3 minors, 1 major -> used by Black Market and Artifact Merchant

+ 3 - 3
lib/IGameEventsReceiver.h

@@ -114,8 +114,8 @@ public:
 	virtual void showThievesGuildWindow (const CGObjectInstance * obj){};
 	virtual void showQuestLog(){};
 	virtual void advmapSpellCast(const CGHeroInstance * caster, int spellID){}; //called when a hero casts a spell
-	virtual void tileHidden(const boost::unordered_set<int3, ShashInt3> &pos){};
-	virtual void tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos){};
+	virtual void tileHidden(const std::unordered_set<int3, ShashInt3> &pos){};
+	virtual void tileRevealed(const std::unordered_set<int3, ShashInt3> &pos){};
 	virtual void newObject(const CGObjectInstance * obj){}; //eg. ship built in shipyard
 	virtual void availableArtifactsChanged(const CGBlackMarket *bm = nullptr){}; //bm may be nullptr, then artifacts are changed in the global pool (used by merchants in towns)
 	virtual void centerView (int3 pos, int focusTime){};
@@ -133,4 +133,4 @@ public:
 
 	//TODO shouldnt be moved down the tree?
 	virtual void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID queryID){};
-};
+};

+ 20 - 20
lib/JsonNode.cpp

@@ -119,14 +119,14 @@ void JsonNode::setMeta(std::string metadata, bool recursive)
 		{
 			break; case DATA_VECTOR:
 			{
-				BOOST_FOREACH(auto & node, Vector())
+				for(auto & node : Vector())
 				{
 					node.setMeta(metadata);
 				}
 			}
 			break; case DATA_STRUCT:
 			{
-				BOOST_FOREACH(auto & node, Struct())
+				for(auto & node : Struct())
 				{
 					node.second.setMeta(metadata);
 				}
@@ -257,7 +257,7 @@ JsonNode & JsonNode::operator[](std::string child)
 
 const JsonNode & JsonNode::operator[](std::string child) const
 {
-	JsonMap::const_iterator it = Struct().find(child);
+	auto it = Struct().find(child);
 	if (it != Struct().end())
 		return it->second;
 	return nullNode;
@@ -775,7 +775,7 @@ static const std::map<std::string, JsonNode::JsonType> stringToType =
 
 std::string JsonValidator::validateEnum(const JsonNode &node, const JsonVector &enumeration)
 {
-	BOOST_FOREACH(auto & enumEntry, enumeration)
+	for(auto & enumEntry : enumeration)
 	{
 		if (node == enumEntry)
 			return "";
@@ -790,7 +790,7 @@ std::string JsonValidator::validatesSchemaList(const JsonNode &node, const JsonN
 		std::string errors = "<tested schemas>\n";
 		size_t result = 0;
 
-		BOOST_FOREACH(auto & schema, schemas.Vector())
+		for(auto & schema : schemas.Vector())
 		{
 			std::string error = validateNode(node, schema);
 			if (error.empty())
@@ -993,11 +993,11 @@ std::string JsonValidator::validateStruct(const JsonNode &node, const JsonNode &
 		auto & properties = schema["properties"];
 		auto & additional = schema["additionalProperties"];
 
-		BOOST_FOREACH(auto & entry, map)
+		for(auto & entry : map)
 			errors += validateStructItem(entry.second, properties, additional, entry.first);
 	}
 
-	BOOST_FOREACH(auto & required, schema["required"].Vector())
+	for(auto & required : schema["required"].Vector())
 	{
 		if (node[required.String()].isNull())
 			errors += fail("Required entry " + required.String() + " is missing");
@@ -1028,14 +1028,14 @@ std::string JsonValidator::validateStruct(const JsonNode &node, const JsonNode &
 	// a) array of fields that must be present
 	// b) struct with schema against which data should be valid
 	// These checks are triggered only if key is present
-	BOOST_FOREACH(auto & deps, schema["dependencies"].Struct())
+	for(auto & deps : schema["dependencies"].Struct())
 	{
 		if (vstd::contains(map, deps.first))
 		{
 			if (deps.second.getType() == JsonNode::DATA_VECTOR)
 			{
 				JsonVector depList = deps.second.Vector();
-				BOOST_FOREACH(auto & depEntry, depList)
+				for(auto & depEntry : depList)
 				{
 					if (!vstd::contains(map, depEntry.String()))
 						errors += fail("Property " + depEntry.String() + " required for " + deps.first + " is missing");
@@ -1134,7 +1134,7 @@ std::string JsonValidator::fail(const std::string &message)
 	errors += "At ";
 	if (!currentPath.empty())
 	{
-		BOOST_FOREACH(const JsonNode &path, currentPath)
+		for(const JsonNode &path : currentPath)
 		{
 			errors += "/";
 			if (path.getType() == JsonNode::DATA_STRING)
@@ -1176,7 +1176,7 @@ void JsonUtils::parseTypedBonusShort(const JsonVector& source, Bonus *dest)
 
 Bonus * JsonUtils::parseBonus (const JsonVector &ability_vec) //TODO: merge with AddAbility, create universal parser for all bonus properties
 {
-	Bonus * b = new Bonus();
+	auto  b = new Bonus();
 	std::string type = ability_vec[0].String();
 	auto it = bonusNameMap.find(type);
 	if (it == bonusNameMap.end())
@@ -1254,7 +1254,7 @@ void JsonUtils::resolveIdentifier (const JsonNode &node, si32 &var)
 Bonus * JsonUtils::parseBonus (const JsonNode &ability)
 {
 
-	Bonus * b = new Bonus();
+	auto  b = new Bonus();
 	const JsonNode *value;
 
 	std::string type = ability["type"].String();
@@ -1297,7 +1297,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
 		case JsonNode::DATA_VECTOR:
 			{
 				ui16 dur = 0;
-				BOOST_FOREACH (const JsonNode & d, value->Vector())
+				for (const JsonNode & d : value->Vector())
 				{
 					dur |= parseByMap(bonusDurationMap, &d, "duration type ");
 				}
@@ -1316,7 +1316,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
 	value = &ability["limiters"];
 	if (!value->isNull())
 	{
-		BOOST_FOREACH (const JsonNode & limiter, value->Vector())
+		for (const JsonNode & limiter : value->Vector())
 		{
 			switch (limiter.getType())
 			{
@@ -1382,7 +1382,7 @@ Bonus * JsonUtils::parseBonus (const JsonNode &ability)
 template<class Key, class Val>
 Key reverseMapFirst(const Val & val, const std::map<Key, Val> map)
 {
-	BOOST_FOREACH(auto it, map)
+	for(auto it : map)
 	{
 		if(it.second == val)
 		{
@@ -1422,7 +1422,7 @@ void minimizeNode(JsonNode & node, const JsonNode & schema)
 	{
 		std::set<std::string> foundEntries;
 
-		BOOST_FOREACH(auto & entry, schema["required"].Vector())
+		for(auto & entry : schema["required"].Vector())
 		{
 			std::string name = entry.String();
 			foundEntries.insert(name);
@@ -1461,7 +1461,7 @@ void maximizeNode(JsonNode & node, const JsonNode & schema)
 		std::set<std::string> foundEntries;
 
 		// check all required entries that have default version
-		BOOST_FOREACH(auto & entry, schema["required"].Vector())
+		for(auto & entry : schema["required"].Vector())
 		{
 			std::string name = entry.String();
 			foundEntries.insert(name);
@@ -1583,7 +1583,7 @@ void JsonUtils::merge(JsonNode & dest, JsonNode & source)
 		case JsonNode::DATA_STRUCT:
 		{
 			//recursively merge all entries from struct
-			BOOST_FOREACH(auto & node, source.Struct())
+			for(auto & node : source.Struct())
 				merge(dest[node.first], node.second);
 		}
 	}
@@ -1599,7 +1599,7 @@ JsonNode JsonUtils::assembleFromFiles(std::vector<std::string> files)
 {
 	JsonNode result;
 
-	BOOST_FOREACH(std::string file, files)
+	for(std::string file : files)
 	{
 		JsonNode section(ResourceID(file, EResType::TEXT));
 		merge(result, section);
@@ -1613,7 +1613,7 @@ JsonNode JsonUtils::assembleFromFiles(std::string filename)
 
 	auto & configList = CResourceHandler::get()->getResourcesWithName(ResourceID(filename, EResType::TEXT));
 
-	BOOST_FOREACH(auto & entry, configList)
+	for(auto & entry : configList)
 	{
 		// FIXME: some way to make this code more readable
 		auto stream = entry.getLoader()->load(entry.getResourceName());

+ 3 - 3
lib/JsonNode.h

@@ -239,7 +239,7 @@ namespace JsonDetail
 		static std::map<std::string, Type> convert(const JsonNode & node)
 		{
 			std::map<std::string, Type> ret;
-			BOOST_FOREACH(auto entry, node.Struct())
+			for (const JsonMap::value_type & entry : node.Struct())
 			{
 				ret.insert(entry.first, entry.second.convertTo<Type>());
 			}
@@ -253,7 +253,7 @@ namespace JsonDetail
 		static std::set<Type> convert(const JsonNode & node)
 		{
 			std::set<Type> ret;
-			BOOST_FOREACH(auto entry, node.Vector())
+			for(const JsonVector::value_type & entry : node.Vector())
 			{
 				ret.insert(entry.convertTo<Type>());
 			}
@@ -267,7 +267,7 @@ namespace JsonDetail
 		static std::vector<Type> convert(const JsonNode & node)
 		{
 			std::vector<Type> ret;
-			BOOST_FOREACH(auto entry, node.Vector())
+			for (const JsonVector::value_type & entry: node.Vector())
 			{
 				ret.push_back(entry.convertTo<Type>());
 			}

+ 2 - 2
lib/NetPacks.h

@@ -392,7 +392,7 @@ struct FoWChange : public CPackForClient //112
 	void applyCl(CClient *cl);
 	DLL_LINKAGE void applyGs(CGameState *gs);
 
-	boost::unordered_set<int3, struct ShashInt3 > tiles;
+	std::unordered_set<int3, struct ShashInt3 > tiles;
 	PlayerColor player;
 	ui8 mode; //mode==0 - hide, mode==1 - reveal
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -646,7 +646,7 @@ struct TryMoveHero : public CPackForClient //501
 	ui32 movePoints;
 	EResult result; //uses EResult
 	int3 start, end; //h3m format
-	boost::unordered_set<int3, ShashInt3> fowRevealed; //revealed tiles
+	std::unordered_set<int3, ShashInt3> fowRevealed; //revealed tiles
 	boost::optional<int3> attackedFrom; // Set when stepping into endangered tile.
 
 	bool humanKnows; //used locally during applying to client

+ 50 - 50
lib/NetPacksLib.cpp

@@ -152,10 +152,10 @@ DLL_LINKAGE void ChangeSpells::applyGs( CGameState *gs )
 	CGHeroInstance *hero = gs->getHero(hid);
 
 	if(learn)
-		BOOST_FOREACH(auto sid, spells)
+		for(auto sid : spells)
 			hero->spells.insert(sid);
 	else
-		BOOST_FOREACH(auto sid, spells)
+		for(auto sid : spells)
 			hero->spells.erase(sid);
 }
 
@@ -175,14 +175,14 @@ DLL_LINKAGE void SetMovePoints::applyGs( CGameState *gs )
 DLL_LINKAGE void FoWChange::applyGs( CGameState *gs )
 {
 	TeamState * team = gs->getPlayerTeam(player);
-	BOOST_FOREACH(int3 t, tiles)
+	for(int3 t : tiles)
 		team->fogOfWarMap[t.x][t.y][t.z] = mode;
 	if (mode == 0) //do not hide too much
 	{
-		boost::unordered_set<int3, ShashInt3> tilesRevealed;
-		for (size_t i = 0; i < gs->map->objects.size(); i++)
+		std::unordered_set<int3, ShashInt3> tilesRevealed;
+		for (auto & elem : gs->map->objects)
 		{
-			const CGObjectInstance *o = gs->map->objects[i];
+			const CGObjectInstance *o = elem;
 			if (o)
 			{
 				switch(o->ID)
@@ -197,7 +197,7 @@ DLL_LINKAGE void FoWChange::applyGs( CGameState *gs )
 				}
 			}
 		}
-		BOOST_FOREACH(int3 t, tilesRevealed) //probably not the most optimal solution ever
+		for(int3 t : tilesRevealed) //probably not the most optimal solution ever
 			team->fogOfWarMap[t.x][t.y][t.z] = 1;
 	}
 }
@@ -233,7 +233,7 @@ DLL_LINKAGE void GiveBonus::applyGs( CGameState *gs )
 
 	assert(cbsn);
 
-	Bonus *b = new Bonus(bonus);
+	auto b = new Bonus(bonus);
 	cbsn->addNewBonus(b);
 
 	std::string &descr = b->description;
@@ -337,9 +337,9 @@ DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs )
 	if (quest)
 	{
 		gs->map->quests[quest->qid] = nullptr;
-		BOOST_FOREACH (auto &player, gs->players)
+		for (auto &player : gs->players)
 		{
-			BOOST_FOREACH (auto &q, player.second.quests)
+			for (auto &q : player.second.quests)
 			{
 				if (q.obj == obj)
 				{
@@ -429,14 +429,14 @@ void TryMoveHero::applyGs( CGameState *gs )
 		gs->map->addBlockVisTiles(h);
 	}
 
-	BOOST_FOREACH(int3 t, fowRevealed)
+	for(int3 t : fowRevealed)
 		gs->getPlayerTeam(h->getOwner())->fogOfWarMap[t.x][t.y][t.z] = 1;
 }
 
 DLL_LINKAGE void NewStructures::applyGs( CGameState *gs )
 {
 	CGTownInstance *t = gs->getTown(tid);
-	BOOST_FOREACH(const auto & id, bid)
+	for(const auto & id : bid)
 	{
 		t->builtBuildings.insert(id);
 	}
@@ -446,7 +446,7 @@ DLL_LINKAGE void NewStructures::applyGs( CGameState *gs )
 DLL_LINKAGE void RazeStructures::applyGs( CGameState *gs )
 {
 	CGTownInstance *t = gs->getTown(tid);
-	BOOST_FOREACH(const auto & id, bid)
+	for(const auto & id : bid)
 	{
 		t->builtBuildings.erase(id);
 	}
@@ -722,7 +722,7 @@ DLL_LINKAGE void SwapStacks::applyGs( CGameState *gs )
 
 DLL_LINKAGE void InsertNewStack::applyGs( CGameState *gs )
 {
-	CStackInstance *s = new CStackInstance(stack.type, stack.count);
+	auto s = new CStackInstance(stack.type, stack.count);
 	sl.army->putStack(sl.slot, s);
 }
 
@@ -854,10 +854,10 @@ DLL_LINKAGE void AssembledArtifact::applyGs( CGameState *gs )
 	assert(transformedArt);
 	assert(vstd::contains(transformedArt->assemblyPossibilities(artSet), builtArt));
 
-	CCombinedArtifactInstance *combinedArt = new CCombinedArtifactInstance(builtArt);
+	auto combinedArt = new CCombinedArtifactInstance(builtArt);
 	gs->map->addNewArtifactInstance(combinedArt);
 	//retrieve all constituents
-	BOOST_FOREACH(const CArtifact * constituent, *builtArt->constituents)
+	for(const CArtifact * constituent : *builtArt->constituents)
 	{
 		ArtifactPosition pos = artSet->getArtPos(constituent->id);
 		assert(pos >= 0);
@@ -881,7 +881,7 @@ DLL_LINKAGE void DisassembledArtifact::applyGs( CGameState *gs )
 
 	std::vector<CCombinedArtifactInstance::ConstituentInfo> constituents = disassembled->constituentsInfo;
 	disassembled->removeFrom(al);
-	BOOST_FOREACH(CCombinedArtifactInstance::ConstituentInfo &ci, constituents)
+	for(CCombinedArtifactInstance::ConstituentInfo &ci : constituents)
 	{
 		ArtifactLocation constituentLoc = al;
 		constituentLoc.slot = (ci.slot >= 0 ? ci.slot : al.slot); //-1 is slot of main constituent -> it'll replace combined artifact in its pos
@@ -918,7 +918,7 @@ DLL_LINKAGE void SetAvailableArtifacts::applyGs( CGameState *gs )
 DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
 {
 	gs->day = day;
-	BOOST_FOREACH(NewTurn::Hero h, heroes) //give mana/movement point
+	for(NewTurn::Hero h : heroes) //give mana/movement point
 	{
 		CGHeroInstance *hero = gs->getHero(h.id);
 		hero->movement = h.move;
@@ -931,7 +931,7 @@ DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
 		gs->getPlayer(i->first)->resources = i->second;
 	}
 
-	BOOST_FOREACH(auto creatureSet, cres) //set available creatures in towns
+	for(auto creatureSet : cres) //set available creatures in towns
 		creatureSet.second.applyGs(gs);
 
 	gs->globalEffects.popBonuses(Bonus::OneDay); //works for children -> all game objs
@@ -949,7 +949,7 @@ DLL_LINKAGE void NewTurn::applyGs( CGameState *gs )
 			i->second.daysWithoutCastle++;
 	}
 
-	BOOST_FOREACH(CGTownInstance* t, gs->map->towns)
+	for(CGTownInstance* t : gs->map->towns)
 		t->builded = 0;
 }
 
@@ -1021,7 +1021,7 @@ DLL_LINKAGE void BattleNextRound::applyGs( CGameState *gs )
 
 	gs->curB->round = round;
 
-	BOOST_FOREACH(CStack *s, gs->curB->stacks)
+	for(CStack *s : gs->curB->stacks)
 	{
 		s->state -= EBattleStackState::DEFENDING;
 		s->state -= EBattleStackState::WAITING;
@@ -1034,7 +1034,7 @@ DLL_LINKAGE void BattleNextRound::applyGs( CGameState *gs )
 		s->battleTurnPassed();
 	}
 
-	BOOST_FOREACH(auto &obst, gs->curB->obstacles)
+	for(auto &obst : gs->curB->obstacles)
 		obst->battleTurnPassed();
 }
 
@@ -1091,7 +1091,7 @@ DLL_LINKAGE void BattleObstaclePlaced::applyGs( CGameState *gs )
 
 void BattleResult::applyGs( CGameState *gs )
 {
-	BOOST_FOREACH (CStack *s, gs->curB->stacks)
+	for (CStack *s : gs->curB->stacks)
 	{
 		if (s->base && s->base->armyObj && vstd::contains(s->state, EBattleStackState::SUMMONED))
 		{
@@ -1100,8 +1100,8 @@ void BattleResult::applyGs( CGameState *gs )
 			const_cast<CArmedInstance*>(s->base->armyObj)->eraseStack(s->slot);
 		}
 	}
-	for (unsigned i = 0; i < gs->curB->stacks.size(); i++)
-		delete gs->curB->stacks[i];
+	for (auto & elem : gs->curB->stacks)
+		delete elem;
 
 	CGHeroInstance *h;
 	for (int i = 0; i < 2; ++i)
@@ -1112,7 +1112,7 @@ void BattleResult::applyGs( CGameState *gs )
 			h->getBonusList().remove_if(Bonus::OneBattle); 	//remove any "until next battle" bonuses
 			if (h->commander && h->commander->alive)
 			{
-				BOOST_FOREACH (auto art, h->commander->artifactsWorn) //increment bonuses for commander artifacts
+				for (auto art : h->commander->artifactsWorn) //increment bonuses for commander artifacts
 				{
 					art.second.artifact->artType->levelUpArtifact (art.second.artifact);
 				}
@@ -1140,7 +1140,7 @@ void BattleStackMoved::applyGs( CGameState *gs )
 	BattleHex dest = tilesToMove.back();
 
 	//if unit ended movement on quicksands that were created by enemy, that quicksand patch becomes visible for owner
-	BOOST_FOREACH(auto &oi, gs->curB->obstacles)
+	for(auto &oi : gs->curB->obstacles)
 	{
 		if(oi->obstacleType == CObstacleInstance::QUICKSAND
 		&& vstd::contains(oi->getAffectedTiles(), tilesToMove.back()))
@@ -1166,9 +1166,9 @@ DLL_LINKAGE void BattleStackAttacked::applyGs( CGameState *gs )
 		at->state -= EBattleStackState::ALIVE;
 	}
 	//life drain handling
-	for (int g=0; g<healedStacks.size(); ++g)
+	for (auto & elem : healedStacks)
 	{
-		healedStacks[g].applyGs(gs);
+		elem.applyGs(gs);
 	}
 	if (willRebirth())
 	{
@@ -1193,7 +1193,7 @@ DLL_LINKAGE void BattleAttack::applyGs( CGameState *gs )
 	{
 		//don't remove ammo if we have a working ammo cart
 		bool hasAmmoCart = false;
-		BOOST_FOREACH(const CStack * st, gs->curB->stacks)
+		for(const CStack * st : gs->curB->stacks)
 		{
 			if(st->owner == attacker->owner && st->getCreature()->idNumber == CreatureID::AMMO_CART && st->alive())
 			{
@@ -1207,14 +1207,14 @@ DLL_LINKAGE void BattleAttack::applyGs( CGameState *gs )
 			attacker->shots--;
 		}
 	}
-	BOOST_FOREACH(BattleStackAttacked stackAttacked, bsa)
+	for(BattleStackAttacked stackAttacked : bsa)
 		stackAttacked.applyGs(gs);
 
 	attacker->getBonusList().remove_if(Bonus::UntilAttack);
 
-	for(std::vector<BattleStackAttacked>::const_iterator it = bsa.begin(); it != bsa.end(); ++it)
+	for(auto & elem : bsa)
 	{
-		CStack * stack = gs->curB->getStack(it->stackAttacked, false);
+		CStack * stack = gs->curB->getStack(elem.stackAttacked, false);
 		if (stack) //cloned stack is already gone
 			stack->getBonusList().remove_if(Bonus::UntilBeingAttacked);
 	}
@@ -1288,7 +1288,7 @@ DLL_LINKAGE void BattleSpellCast::applyGs( CGameState *gs )
 	const bool removeAllSpells = id == SpellID::DISPEL;
 	const bool removeHelpful = id == SpellID::DISPEL_HELPFUL_SPELLS;
 
-	BOOST_FOREACH(auto stackID, affectedCres)
+	for(auto stackID : affectedCres)
 	{
 		if(vstd::contains(resisted, stackID))
 			continue;
@@ -1312,9 +1312,9 @@ void actualizeEffect(CStack * s, const std::vector<Bonus> & ef)
 {
 	//actualizing features vector
 
-	BOOST_FOREACH(const Bonus &fromEffect, ef)
+	for(const Bonus &fromEffect : ef)
 	{
-		BOOST_FOREACH(Bonus *stackBonus, s->getBonusList()) //TODO: optimize
+		for(Bonus *stackBonus : s->getBonusList()) //TODO: optimize
 		{
 			if(stackBonus->source == Bonus::SPELL_EFFECT && stackBonus->type == fromEffect.type && stackBonus->subtype == fromEffect.subtype)
 			{
@@ -1325,7 +1325,7 @@ void actualizeEffect(CStack * s, const std::vector<Bonus> & ef)
 }
 void actualizeEffect(CStack * s, const Bonus & ef)
 {
-	BOOST_FOREACH(Bonus *stackBonus, s->getBonusList()) //TODO: optimize
+	for(Bonus *stackBonus : s->getBonusList()) //TODO: optimize
 	{
 		if(stackBonus->source == Bonus::SPELL_EFFECT && stackBonus->type == ef.type && stackBonus->subtype == ef.subtype)
 		{
@@ -1338,14 +1338,14 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
 {
 	int spellid = effect.begin()->sid; //effects' source ID
 
-	BOOST_FOREACH(ui32 id, stacks)
+	for(ui32 id : stacks)
 	{
 		CStack *s = gs->curB->getStack(id);
 		if(s)
 		{
 			if(spellid == SpellID::DISRUPTING_RAY || spellid == SpellID::ACID_BREATH_DEFENSE || !s->hasBonus(Selector::source(Bonus::SPELL_EFFECT, spellid)))//disrupting ray or acid breath or not on the list - just add
 			{
-				BOOST_FOREACH(Bonus &fromEffect, effect)
+				for(Bonus &fromEffect : effect)
 				{
 					logBonus->traceStream() << s->nodeName() << " receives a new bonus: " << fromEffect.Description();
 					s->addNewBonus( new Bonus(fromEffect));
@@ -1360,7 +1360,7 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
             logNetwork->errorStream() << "Cannot find stack " << id;
 	}
 	typedef std::pair<ui32, Bonus> p;
-	BOOST_FOREACH(p para, uniqueBonuses)
+	for(p para : uniqueBonuses)
 	{
 		CStack *s = gs->curB->getStack(para.first);
 		if (s)
@@ -1377,15 +1377,15 @@ DLL_LINKAGE void SetStackEffect::applyGs( CGameState *gs )
 
 DLL_LINKAGE void StacksInjured::applyGs( CGameState *gs )
 {
-	BOOST_FOREACH(BattleStackAttacked stackAttacked, stacks)
+	for(BattleStackAttacked stackAttacked : stacks)
 		stackAttacked.applyGs(gs);
 }
 
 DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
 {
-	for(int g=0; g<healedStacks.size(); ++g)
+	for(auto & elem : healedStacks)
 	{
-		CStack * changedStack = gs->curB->getStack(healedStacks[g].stackID, false);
+		CStack * changedStack = gs->curB->getStack(elem.stackID, false);
 
 		//checking if we resurrect a stack that is under a living stack
 		auto accessibility = gs->curB->getAccesibility();
@@ -1401,13 +1401,13 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
 		if(resurrected)
 		{
 			changedStack->state.insert(EBattleStackState::ALIVE);
-			if(healedStacks[g].lowLevelResurrection)
+			if(elem.lowLevelResurrection)
 				changedStack->state.insert(EBattleStackState::SUMMONED); //TODO: different counter for rised units
 		}
 		//int missingHPfirst = changedStack->MaxHealth() - changedStack->firstHPleft;
-		int res = std::min( healedStacks[g].healedHP / changedStack->MaxHealth() , changedStack->baseAmount - changedStack->count );
+		int res = std::min( elem.healedHP / changedStack->MaxHealth() , changedStack->baseAmount - changedStack->count );
 		changedStack->count += res;
-		changedStack->firstHPleft += healedStacks[g].healedHP - res * changedStack->MaxHealth();
+		changedStack->firstHPleft += elem.healedHP - res * changedStack->MaxHealth();
 		if(changedStack->firstHPleft > changedStack->MaxHealth())
 		{
 			changedStack->firstHPleft -= changedStack->MaxHealth();
@@ -1433,7 +1433,7 @@ DLL_LINKAGE void StacksHealedOrResurrected::applyGs( CGameState *gs )
 			const BonusList tmpFeatures = changedStack->getBonusList();
 			//changedStack->bonuses.clear();
 
-			BOOST_FOREACH(Bonus *b, tmpFeatures)
+			for(Bonus *b : tmpFeatures)
 			{
 				const CSpell *s = b->sourceSpell();
 				if(s && s->isNegative())
@@ -1449,7 +1449,7 @@ DLL_LINKAGE void ObstaclesRemoved::applyGs( CGameState *gs )
 {
 	if(gs->curB) //if there is a battle
 	{
-		BOOST_FOREACH(const si32 rem_obst,obstacles)
+		for(const si32 rem_obst :obstacles)
 		{
 			for(int i=0; i<gs->curB->obstacles.size(); ++i)
 			{
@@ -1467,7 +1467,7 @@ DLL_LINKAGE void CatapultAttack::applyGs( CGameState *gs )
 {
 	if(gs->curB && gs->curB->siege != CGTownInstance::NONE) //if there is a battle and it's a siege
 	{
-		BOOST_FOREACH(const auto &it,attackedParts)
+		for(const auto &it :attackedParts)
 		{
 			gs->curB->si.wallState[it.first.first] =
 				std::min( gs->curB->si.wallState[it.first.first] + it.second, 3 );
@@ -1479,7 +1479,7 @@ DLL_LINKAGE void BattleStacksRemoved::applyGs( CGameState *gs )
 {
 	if(!gs->curB)
 		return;
-	BOOST_FOREACH(ui32 rem_stack, stackIDs)
+	for(ui32 rem_stack : stackIDs)
 	{
 		for(int b=0; b<gs->curB->stacks.size(); ++b) //find it in vector of stacks
 		{

+ 5 - 5
lib/ResourceSet.cpp

@@ -21,14 +21,14 @@ Res::ResourceSet::ResourceSet()
 Res::ResourceSet::ResourceSet(const JsonNode & node)
 {
 	reserve(GameConstants::RESOURCE_QUANTITY);
-	BOOST_FOREACH(std::string name, GameConstants::RESOURCE_NAMES)
+	for(std::string name : GameConstants::RESOURCE_NAMES)
 		push_back(node[name].Float());
 }
 
 bool Res::ResourceSet::nonZero() const
 {
-	for(int i = 0; i < size(); i++)
-		if(at(i))
+	for(auto & elem : *this)
+		if(elem)
 			return true;
 
 	return false;
@@ -36,8 +36,8 @@ bool Res::ResourceSet::nonZero() const
 
 void Res::ResourceSet::amax(const TResourceCap &val)
 {
-	for(int i = 0; i < size(); i++)
-		::vstd::amax(at(i), val);
+	for(auto & elem : *this)
+		::vstd::amax(elem, val);
 }
 
 bool Res::ResourceSet::canBeAfforded(const ResourceSet &res) const

+ 6 - 6
lib/filesystem/CFilesystemLoader.cpp

@@ -18,9 +18,9 @@ std::unique_ptr<CInputStream> CFilesystemLoader::load(const std::string & resour
 
 bool CFilesystemLoader::existsEntry(const std::string & resourceName) const
 {
-	for(auto it = fileList.begin(); it != fileList.end(); ++it)
+	for(auto & elem : fileList)
 	{
-		if(it->second == resourceName)
+		if(elem.second == resourceName)
 		{
 			return true;
 		}
@@ -29,7 +29,7 @@ bool CFilesystemLoader::existsEntry(const std::string & resourceName) const
 	return false;
 }
 
-boost::unordered_map<ResourceID, std::string> CFilesystemLoader::getEntries() const
+std::unordered_map<ResourceID, std::string> CFilesystemLoader::getEntries() const
 {
 	return fileList;
 }
@@ -52,7 +52,7 @@ bool CFilesystemLoader::createEntry(std::string filename, bool update)
 }
 
 
-boost::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(size_t depth, bool initial) const
+std::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(size_t depth, bool initial) const
 {
 	std::set<EResType::Type> initialTypes;
 	initialTypes.insert(EResType::DIRECTORY);
@@ -62,7 +62,7 @@ boost::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(size_
 	initialTypes.insert(EResType::ARCHIVE_SND);
 
 	assert(boost::filesystem::is_directory(baseDirectory));
-	boost::unordered_map<ResourceID, std::string> fileList;
+	std::unordered_map<ResourceID, std::string> fileList;
 
 	std::vector<std::string> path;//vector holding relative path to our file
 
@@ -97,4 +97,4 @@ boost::unordered_map<ResourceID, std::string> CFilesystemLoader::listFiles(size_
 	}
 
 	return fileList;
-}
+}

+ 3 - 3
lib/filesystem/CFilesystemLoader.h

@@ -37,7 +37,7 @@ public:
 	/// @see ISimpleResourceLoader
 	std::unique_ptr<CInputStream> load(const std::string & resourceName) const override;
 	bool existsEntry(const std::string & resourceName) const override;
-	boost::unordered_map<ResourceID, std::string> getEntries() const override;
+	std::unordered_map<ResourceID, std::string> getEntries() const override;
 	std::string getOrigin() const override;
 	bool createEntry(std::string filename, bool update) override;
 
@@ -49,7 +49,7 @@ private:
 	 * key = ResourceID for resource loader
 	 * value = name that can be used to access file
 	*/
-	boost::unordered_map<ResourceID, std::string> fileList;
+	std::unordered_map<ResourceID, std::string> fileList;
 
 	/**
 	 * Returns a list of pathnames denoting the files in the directory denoted by this pathname.
@@ -60,5 +60,5 @@ private:
 	 * @return a list of pathnames denoting the files and directories in the directory denoted by this pathname
 	 * The array will be empty if the directory is empty. Ptr is null if the directory doesn't exist or if it isn't a directory.
 	 */
-	boost::unordered_map<ResourceID, std::string> listFiles(size_t depth, bool initial) const;
+	std::unordered_map<ResourceID, std::string> listFiles(size_t depth, bool initial) const;
 };

+ 6 - 6
lib/filesystem/CLodArchiveLoader.cpp

@@ -93,7 +93,7 @@ void CLodArchiveLoader::initVIDArchive(CFileInputStream & fileStream)
 
 	// Get all entries from file
 	fileStream.seek(4);
-	struct VideoEntryBlock * vidEntries = new struct VideoEntryBlock[totalFiles];
+	auto  vidEntries = new struct VideoEntryBlock[totalFiles];
 	fileStream.read(reinterpret_cast<ui8 *>(vidEntries), sizeof(struct VideoEntryBlock) * totalFiles);
 
 	// Insert entries to list
@@ -141,7 +141,7 @@ void CLodArchiveLoader::initSNDArchive(CFileInputStream & fileStream)
 
 	// Get all entries from file
 	fileStream.seek(4);
-	struct SoundEntryBlock * sndEntries = new struct SoundEntryBlock[totalFiles];
+	auto  sndEntries = new struct SoundEntryBlock[totalFiles];
 	fileStream.read(reinterpret_cast<ui8 *>(sndEntries), sizeof(struct SoundEntryBlock) * totalFiles);
 
 	// Insert entries to list
@@ -184,13 +184,13 @@ std::unique_ptr<CInputStream> CLodArchiveLoader::load(const std::string & resour
 	}
 }
 
-boost::unordered_map<ResourceID, std::string> CLodArchiveLoader::getEntries() const
+std::unordered_map<ResourceID, std::string> CLodArchiveLoader::getEntries() const
 {
-	boost::unordered_map<ResourceID, std::string> retList;
+	std::unordered_map<ResourceID, std::string> retList;
 
-	for(auto it = entries.begin(); it != entries.end(); ++it)
+	for(auto & elem : entries)
 	{
-		const ArchiveEntry & entry = it->second;
+		const ArchiveEntry & entry = elem.second;
 		retList[ResourceID(entry.name)] = entry.name;
 	}
 

+ 2 - 2
lib/filesystem/CLodArchiveLoader.h

@@ -60,7 +60,7 @@ public:
 	/// Interface implementation
 	/// @see ISimpleResourceLoader
 	std::unique_ptr<CInputStream> load(const std::string & resourceName) const override;
-	boost::unordered_map<ResourceID, std::string> getEntries() const override;
+	std::unordered_map<ResourceID, std::string> getEntries() const override;
 	bool existsEntry(const std::string & resourceName) const override;
 	std::string getOrigin() const override;
 
@@ -92,5 +92,5 @@ private:
 	std::string archive;
 
 	/** Holds all entries of the archive file. An entry can be accessed via the entry name. **/
-	boost::unordered_map<std::string, ArchiveEntry> entries;
+	std::unordered_map<std::string, ArchiveEntry> entries;
 };

+ 4 - 4
lib/filesystem/CMappedFileLoader.cpp

@@ -5,7 +5,7 @@
 
 CMappedFileLoader::CMappedFileLoader(const JsonNode &config)
 {
-	BOOST_FOREACH(auto entry, config.Struct())
+	for(auto entry : config.Struct())
 	{
 		fileList[ResourceID(entry.first)] = entry.second.String();
 	}
@@ -18,9 +18,9 @@ std::unique_ptr<CInputStream> CMappedFileLoader::load(const std::string & resour
 
 bool CMappedFileLoader::existsEntry(const std::string & resourceName) const
 {
-	for(auto it = fileList.begin(); it != fileList.end(); ++it)
+	for(auto & elem : fileList)
 	{
-		if(it->second == resourceName)
+		if(elem.second == resourceName)
 		{
 			return true;
 		}
@@ -29,7 +29,7 @@ bool CMappedFileLoader::existsEntry(const std::string & resourceName) const
 	return false;
 }
 
-boost::unordered_map<ResourceID, std::string> CMappedFileLoader::getEntries() const
+std::unordered_map<ResourceID, std::string> CMappedFileLoader::getEntries() const
 {
 	return fileList;
 }

+ 2 - 2
lib/filesystem/CMappedFileLoader.h

@@ -40,7 +40,7 @@ public:
 	/// @see ISimpleResourceLoader
 	std::unique_ptr<CInputStream> load(const std::string & resourceName) const override;
 	bool existsEntry(const std::string & resourceName) const override;
-	boost::unordered_map<ResourceID, std::string> getEntries() const override;
+	std::unordered_map<ResourceID, std::string> getEntries() const override;
 	std::string getOrigin() const override;
 	std::string getFullName(const std::string & resourceName) const override;
 
@@ -49,5 +49,5 @@ private:
 	 * key = ResourceID for resource loader
 	 * value = ResourceID to which file this request will be redirected
 	*/
-	boost::unordered_map<ResourceID, std::string> fileList;
+	std::unordered_map<ResourceID, std::string> fileList;
 };

+ 8 - 8
lib/filesystem/CResourceLoader.cpp

@@ -141,7 +141,7 @@ bool CResourceLoader::createResource(std::string URI, bool update)
 {
 	std::string filename = URI;
 	boost::to_upper(URI);
-	BOOST_REVERSE_FOREACH (const LoaderEntry & entry, loaders)
+	for (auto & entry : boost::adaptors::reverse(loaders))
 	{
 		if (entry.writeable && boost::algorithm::starts_with(URI, entry.prefix))
 		{
@@ -172,11 +172,11 @@ void CResourceLoader::addLoader(std::string mountPoint, shared_ptr<ISimpleResour
 	loaders.push_back(loaderEntry);
 
 	// Get entries and add them to the resources list
-	const boost::unordered_map<ResourceID, std::string> & entries = loader->getEntries();
+	const std::unordered_map<ResourceID, std::string> & entries = loader->getEntries();
 
 	boost::to_upper(mountPoint);
 
-	BOOST_FOREACH (auto & entry, entries)
+	for (auto & entry : entries)
 	{
 		// Create identifier and locator and add them to the resources list
 		ResourceID ident(mountPoint, entry.first.getName(), entry.first.getType());
@@ -316,7 +316,7 @@ void CResourceHandler::initialize()
 	auto recurseInDir = [](std::string URI, int depth)
 	{
 		auto resources = initialLoader->getResourcesWithName(ResourceID(URI, EResType::DIRECTORY));
-		BOOST_FOREACH(const ResourceLocator & entry, resources)
+		for(const ResourceLocator & entry : resources)
 		{
 			std::string filename = entry.getLoader()->getOrigin() + '/' + entry.getResourceName();
 			if (!filename.empty())
@@ -363,7 +363,7 @@ void CResourceHandler::loadDirectory(const std::string &prefix, const std::strin
 
 	auto resources = initialLoader->getResourcesWithName(ResourceID(URI, EResType::DIRECTORY));
 
-	BOOST_FOREACH(const ResourceLocator & entry, resources)
+	for(const ResourceLocator & entry : resources)
 	{
 		std::string filename = entry.getLoader()->getOrigin() + '/' + entry.getResourceName();
 		resourceLoader->addLoader(mountPoint,
@@ -407,9 +407,9 @@ void CResourceHandler::loadFileSystem(const std::string & prefix, const std::str
 
 void CResourceHandler::loadFileSystem(const std::string & prefix, const JsonNode &fsConfig)
 {
-	BOOST_FOREACH(auto & mountPoint, fsConfig.Struct())
+	for(auto & mountPoint : fsConfig.Struct())
 	{
-		BOOST_FOREACH(auto & entry, mountPoint.second.Vector())
+		for(auto & entry : mountPoint.second.Vector())
 		{
 			CStopWatch timer;
             logGlobal->debugStream() << "\t\tLoading resource at " << prefix + entry["path"].String();
@@ -476,7 +476,7 @@ void CResourceHandler::setActiveMods(std::vector<std::string> enabledMods)
 	defaultFS[""].Vector()[0]["type"].String() = "dir";
 	defaultFS[""].Vector()[0]["path"].String() = "/Content";
 
-	BOOST_FOREACH(std::string & modName, enabledMods)
+	for(std::string & modName : enabledMods)
 	{
 		ResourceID modConfFile("all/mods/" + modName + "/mod", EResType::TEXT);
 		auto fsConfigData = initialLoader->loadData(modConfFile);

+ 11 - 11
lib/filesystem/CResourceLoader.h

@@ -157,17 +157,17 @@ private:
 	EResType::Type type;
 };
 
-/**
- 	* Generates a hash value for the resource identifier object.
- 	*
- 	* @param resourceIdent The object from which a hash value should be generated.
- 	* @return the generated hash value
- 	*/
-inline size_t hash_value(const ResourceID & resourceIdent)
+namespace std
 {
-	boost::hash<int> intHasher;
-	boost::hash<std::string> stringHasher;
-	return stringHasher(resourceIdent.getName()) ^ intHasher(static_cast<int>(resourceIdent.getType()));
+	template <> struct hash<ResourceID>
+	{
+		size_t operator()(const ResourceID & resourceIdent) const
+		{
+			std::hash<int> intHasher;
+			std::hash<std::string> stringHasher;
+			return stringHasher(resourceIdent.getName()) ^ intHasher(static_cast<int>(resourceIdent.getType()));
+		}
+	};
 }
 
 /**
@@ -176,7 +176,7 @@ inline size_t hash_value(const ResourceID & resourceIdent)
  */
 class DLL_LINKAGE CResourceLoader
 {
-	typedef boost::unordered_map<ResourceID, std::vector<ResourceLocator> > ResourcesMap;
+	typedef std::unordered_map<ResourceID, std::vector<ResourceLocator> > ResourcesMap;
 
 public:
 	/// class for iterating over all available files/Identifiers

+ 1 - 1
lib/filesystem/ISimpleResourceLoader.h

@@ -45,7 +45,7 @@ public:
 	 *
 	 * @return Returns a list of all entries in the archive or (file) system.
 	 */
-	virtual boost::unordered_map<ResourceID, std::string> getEntries() const =0;
+	virtual std::unordered_map<ResourceID, std::string> getEntries() const =0;
 
 	/**
 	 * Gets the origin of the loader.

+ 3 - 3
lib/int3.h

@@ -104,9 +104,9 @@ struct ShashInt3
 {
 	size_t operator()(int3 const& pos) const
 	{
-		size_t ret = ::boost::hash<int>()(pos.x);
-		boost::hash_combine(ret, pos.y);
-		boost::hash_combine(ret, pos.z);
+		size_t ret = std::hash<int>()(pos.x);
+		vstd::hash_combine(ret, pos.y);
+		vstd::hash_combine(ret, pos.z);
 		return ret;
 	}
 };

+ 2 - 2
lib/logging/CBasicLogConfigurator.cpp

@@ -27,7 +27,7 @@ void CBasicLogConfigurator::configure()
 		const JsonNode & loggers = loggingNode["loggers"];
 		if(!loggers.isNull())
 		{
-			BOOST_FOREACH(auto & loggerNode, loggers.Vector())
+			for(auto & loggerNode : loggers.Vector())
 			{
 				// Get logger
 				std::string name = loggerNode["domain"].String();
@@ -55,7 +55,7 @@ void CBasicLogConfigurator::configure()
 			const JsonNode & colorMappingNode = consoleNode["colorMapping"];
 			if(!colorMappingNode.isNull())
 			{
-				BOOST_FOREACH(const JsonNode & mappingNode, colorMappingNode.Vector())
+				for(const JsonNode & mappingNode : colorMappingNode.Vector())
 				{
 					std::string domain = mappingNode["domain"].String();
 					std::string level = mappingNode["level"].String();

+ 2 - 2
lib/logging/CLogger.cpp

@@ -197,7 +197,7 @@ void CLogger::callTargets(const LogRecord & record) const
 	TLockGuard _(mx);
 	for(const CLogger * logger = this; logger != nullptr; logger = logger->parent)
 	{
-		BOOST_FOREACH(auto & target, logger->targets)
+		for(auto & target : logger->targets)
 		{
 			target->write(record);
 		}
@@ -245,7 +245,7 @@ CLogManager::CLogManager()
 
 CLogManager::~CLogManager()
 {
-	BOOST_FOREACH(auto & i, loggers)
+	for(auto & i : loggers)
 	{
 		delete i.second;
 	}

+ 1 - 1
lib/logging/CLogger.h

@@ -116,7 +116,7 @@ private:
 	CLoggerDomain domain;
 	CLogger * parent;
 	ELogLevel::ELogLevel level;
-	std::list<unique_ptr<ILogTarget> > targets;
+	std::vector<unique_ptr<ILogTarget> > targets;
 	mutable boost::mutex mx;
 	static boost::recursive_mutex smx;
 };

+ 6 - 6
lib/mapping/CCampaignHandler.cpp

@@ -330,7 +330,7 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
 	if (!(travelOptions.whatHeroKeeps & 1))
 	{
 		//trimming experience
-		BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
+		for(CGHeroInstance * cgh : crossoverHeroes)
 		{
 			cgh->initExp();
 		}
@@ -338,7 +338,7 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
 	if (!(travelOptions.whatHeroKeeps & 2))
 	{
 		//trimming prim skills
-		BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
+		for(CGHeroInstance * cgh : crossoverHeroes)
 		{
 			for(int g=0; g<GameConstants::PRIMARY_SKILLS; ++g)
 			{
@@ -351,7 +351,7 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
 	if (!(travelOptions.whatHeroKeeps & 4))
 	{
 		//trimming sec skills
-		BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
+		for(CGHeroInstance * cgh : crossoverHeroes)
 		{
 			cgh->secSkills = cgh->type->secSkillsInit;
 		}
@@ -359,7 +359,7 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
 	if (!(travelOptions.whatHeroKeeps & 8))
 	{
 		//trimming spells
-		BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
+		for(CGHeroInstance * cgh : crossoverHeroes)
 		{
 			cgh->spells.clear();
 		}
@@ -367,7 +367,7 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
 	if (!(travelOptions.whatHeroKeeps & 16))
 	{
 		//trimming artifacts
-		BOOST_FOREACH(CGHeroInstance * hero, crossoverHeroes)
+		for(CGHeroInstance * hero : crossoverHeroes)
 		{
 			size_t totalArts = GameConstants::BACKPACK_START + hero->artifactsInBackpack.size();
 			for (size_t i=0; i<totalArts; i++ )
@@ -391,7 +391,7 @@ void CCampaignScenario::prepareCrossoverHeroes( std::vector<CGHeroInstance *> he
 	}
 
 	//trimming creatures
-	BOOST_FOREACH(CGHeroInstance * cgh, crossoverHeroes)
+	for(CGHeroInstance * cgh : crossoverHeroes)
 	{
 		vstd::erase_if(cgh->stacks, [&](const std::pair<SlotID, CStackInstance *> & j) -> bool
 		{

+ 3 - 3
lib/mapping/CMap.cpp

@@ -231,9 +231,9 @@ void CMap::addBlockVisTiles(CGObjectInstance * obj)
 
 CGHeroInstance * CMap::getHero(int heroID)
 {
-	for(ui32 i=0; i<heroesOnMap.size();i++)
-		if(heroesOnMap[i]->subID == heroID)
-			return heroesOnMap[i];
+	for(auto & elem : heroesOnMap)
+		if(elem->subID == heroID)
+			return elem;
 	return nullptr;
 }
 

+ 19 - 19
lib/mapping/CMapEditManager.cpp

@@ -251,7 +251,7 @@ CComposedOperation::CComposedOperation(CMap * map) : CMapOperation(map)
 
 void CComposedOperation::execute()
 {
-	BOOST_FOREACH(auto & operation, operations)
+	for(auto & operation : operations)
 	{
 		operation->execute();
 	}
@@ -259,7 +259,7 @@ void CComposedOperation::execute()
 
 void CComposedOperation::undo()
 {
-	BOOST_FOREACH(auto & operation, operations)
+	for(auto & operation : operations)
 	{
 		operation->undo();
 	}
@@ -267,7 +267,7 @@ void CComposedOperation::undo()
 
 void CComposedOperation::redo()
 {
-	BOOST_FOREACH(auto & operation, operations)
+	for(auto & operation : operations)
 	{
 		operation->redo();
 	}
@@ -320,7 +320,7 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig()
 	for(int i = 0; i < ARRAY_COUNT(patternTypes); ++i)
 	{
 		const auto & patternsVec = config[patternTypes[i]].Vector();
-		BOOST_FOREACH(const auto & ptrnNode, patternsVec)
+		for(const auto & ptrnNode : patternsVec)
 		{
 			TerrainViewPattern pattern;
 
@@ -333,7 +333,7 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig()
 				boost::algorithm::erase_all(cell, " ");
 				std::vector<std::string> rules;
 				boost::split(rules, cell, boost::is_any_of(","));
-				BOOST_FOREACH(std::string ruleStr, rules)
+				for(std::string ruleStr : rules)
 				{
 					std::vector<std::string> ruleParts;
 					boost::split(ruleParts, ruleStr, boost::is_any_of("-"));
@@ -359,7 +359,7 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig()
 			if(i == 0)
 			{
 				const auto & mappingStruct = ptrnNode["mapping"].Struct();
-				BOOST_FOREACH(const auto & mappingPair, mappingStruct)
+				for(const auto & mappingPair : mappingStruct)
 				{
 					TerrainViewPattern terGroupPattern = pattern;
 					auto mappingStr = mappingPair.second.String();
@@ -375,7 +375,7 @@ CTerrainViewPatternConfig::CTerrainViewPatternConfig()
 					mappingStr = mappingStr.substr(colonIndex + 1);
 					std::vector<std::string> mappings;
 					boost::split(mappings, mappingStr, boost::is_any_of(","));
-					BOOST_FOREACH(std::string mapping, mappings)
+					for(std::string mapping : mappings)
 					{
 						std::vector<std::string> range;
 						boost::split(range, mapping, boost::is_any_of("-"));
@@ -419,7 +419,7 @@ const std::vector<TerrainViewPattern> & CTerrainViewPatternConfig::getTerrainVie
 boost::optional<const TerrainViewPattern &> CTerrainViewPatternConfig::getTerrainViewPatternById(ETerrainGroup::ETerrainGroup terGroup, const std::string & id) const
 {
 	const std::vector<TerrainViewPattern> & groupPatterns = getTerrainViewPatternsForGroup(terGroup);
-	BOOST_FOREACH(const TerrainViewPattern & pattern, groupPatterns)
+	for(const TerrainViewPattern & pattern : groupPatterns)
 	{
 		if(id == pattern.id)
 		{
@@ -444,7 +444,7 @@ CDrawTerrainOperation::CDrawTerrainOperation(CMap * map, const CTerrainSelection
 
 void CDrawTerrainOperation::execute()
 {
-	BOOST_FOREACH(const auto & pos, terrainSel.getSelectedItems())
+	for(const auto & pos : terrainSel.getSelectedItems())
 	{
 		auto & tile = map->getTile(pos);
 		tile.terType = terType;
@@ -488,7 +488,7 @@ void CDrawTerrainOperation::updateTerrainTypes()
 		};
 
 		// Fill foreign invalid tiles
-		BOOST_FOREACH(const auto & tile, tiles.foreignTiles)
+		for(const auto & tile : tiles.foreignTiles)
 		{
 			updateTerrainType(tile, true);
 		}
@@ -542,9 +542,9 @@ void CDrawTerrainOperation::updateTerrainTypes()
 			{
 				static const int3 directions[] = { int3(0, -1, 0), int3(-1, 0, 0), int3(0, 1, 0), int3(1, 0, 0),
 											int3(-1, -1, 0), int3(-1, 1, 0), int3(1, 1, 0), int3(1, -1, 0)};
-				for(int i = 0; i < ARRAY_COUNT(directions); ++i)
+				for(auto & direction : directions)
 				{
-					auto it = suitableTiles.find(centerPos + directions[i]);
+					auto it = suitableTiles.find(centerPos + direction);
 					if(it != suitableTiles.end())
 					{
 						updateTerrainType(*it, tileRequiresValidation);
@@ -562,7 +562,7 @@ void CDrawTerrainOperation::updateTerrainTypes()
 
 void CDrawTerrainOperation::updateTerrainViews()
 {
-	BOOST_FOREACH(const auto & pos, invalidatedTerViews)
+	for(const auto & pos : invalidatedTerViews)
 	{
 		const auto & patterns =
 				CTerrainViewPatternConfig::get().getTerrainViewPatternsForGroup(getTerrainGroup(map->getTile(pos).terType));
@@ -687,9 +687,9 @@ CDrawTerrainOperation::ValidationResult CDrawTerrainOperation::validateTerrainVi
 
 		// Validate all rules per cell
 		int topPoints = -1;
-		for(int j = 0; j < pattern.data[i].size(); ++j)
+		for(auto & elem : pattern.data[i])
 		{
-			TerrainViewPattern::WeightedRule rule = pattern.data[i][j];
+			TerrainViewPattern::WeightedRule rule = elem;
 			if(!rule.isStandardRule())
 			{
 				if(recDepth == 0 && map->isInTheMap(currentPos))
@@ -849,9 +849,9 @@ CDrawTerrainOperation::InvalidTiles CDrawTerrainOperation::getInvalidTiles(const
 			if(valid && centerTerType != terType && (terType == ETerrainType::WATER || terType == ETerrainType::ROCK))
 			{
 				static const std::string patternIds[] = { "s1", "s2" };
-				for(int i = 0; i < ARRAY_COUNT(patternIds); ++i)
+				for(auto & patternId : patternIds)
 				{
-					valid = !validateTerrainView(pos, ptrConfig.getTerrainTypePatternById(patternIds[i])).result;
+					valid = !validateTerrainView(pos, ptrConfig.getTerrainTypePatternById(patternId)).result;
 					if(!valid) break;
 				}
 			}
@@ -859,9 +859,9 @@ CDrawTerrainOperation::InvalidTiles CDrawTerrainOperation::getInvalidTiles(const
 			else if(!valid && (terType != ETerrainType::WATER && terType != ETerrainType::ROCK))
 			{
 				static const std::string patternIds[] = { "n2", "n3" };
-				for(int i = 0; i < ARRAY_COUNT(patternIds); ++i)
+				for(auto & patternId : patternIds)
 				{
-					valid = validateTerrainView(pos, ptrConfig.getTerrainTypePatternById(patternIds[i])).result;
+					valid = validateTerrainView(pos, ptrConfig.getTerrainTypePatternById(patternId)).result;
 					if(valid) break;
 				}
 			}

+ 1 - 2
lib/mapping/CMapEditManager.h

@@ -137,8 +137,7 @@ public:
 	void addOperation(unique_ptr<CMapOperation> && operation); /// Client code does not need to call this method.
 
 private:
-	// FIXME: switch back to unique_ptr once gcc 4.5 is abandoned
-	typedef std::list<shared_ptr<CMapOperation> > TStack;
+	typedef std::list<unique_ptr<CMapOperation> > TStack;
 
 	void doOperation(TStack & fromStack, TStack & toStack, bool doUndo);
 	const CMapOperation * peek(const TStack & stack) const;

+ 2 - 4
lib/mapping/CMapInfo.h

@@ -20,10 +20,8 @@ struct StartInfo;
 class DLL_LINKAGE CMapInfo
 {
 public:
-	//FIXME: unique_ptr won't work here with gcc-4.5. (can't move into vector at CPregame.cpp, SelectionTab::parseMaps() method)
-	//Needs some workaround or wait till there is no need to support 4.5
-	shared_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
-	shared_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
+	unique_ptr<CMapHeader> mapHeader; //may be nullptr if campaign
+	unique_ptr<CCampaignHeader> campaignHeader; //may be nullptr if scenario
 	StartInfo * scenarioOpts; //options with which scenario has been started (used only with saved games)
 	std::string fileURI;
 	std::string date;

+ 43 - 43
lib/mapping/MapFormatH3M.cpp

@@ -63,7 +63,7 @@ void CMapLoaderH3M::init()
 	si64 temp_size = inputStream->getSize();
 	inputStream->seek(0);
 
-	ui8 * temp_buffer = new ui8[temp_size];
+	auto  temp_buffer = new ui8[temp_size];
 	inputStream->read(temp_buffer,temp_size);
 
 	// Compute checksum
@@ -122,17 +122,17 @@ void CMapLoaderH3M::init()
 	times.push_back(MapLoadingTime("events", sw.getDiff()));
 
 	// Calculate blocked / visitable positions
-	for(int f = 0; f < map->objects.size(); ++f)
+	for(auto & elem : map->objects)
 	{
-		if(!map->objects[f]->defInfo) continue;
-		map->addBlockVisTiles(map->objects[f]);
+		if(!elem->defInfo) continue;
+		map->addBlockVisTiles(elem);
 	}
 	times.push_back(MapLoadingTime("blocked/visitable tiles", sw.getDiff()));
 
 	// Print profiling times
 	if(IS_PROFILING_ENABLED)
 	{
-		BOOST_FOREACH(MapLoadingTime & mlt, times)
+		for(MapLoadingTime & mlt : times)
 		{
             logGlobal->debugStream() << "\tReading " << mlt.name << " took " << mlt.time << " ms.";
 		}
@@ -454,7 +454,7 @@ void CMapLoaderH3M::readAllowedArtifacts()
 	// ban combo artifacts
 	if (map->version == EMapFormat::ROE || map->version == EMapFormat::AB)
 	{
-		BOOST_FOREACH(CArtifact * artifact, VLC->arth->artifacts)
+		for(CArtifact * artifact : VLC->arth->artifacts)
 		{
 			// combo
 			if (artifact->constituents)
@@ -523,7 +523,7 @@ void CMapLoaderH3M::readPredefinedHeroes()
 				int custom =  reader.readUInt8();
 				if(!custom) continue;
 
-				CGHeroInstance * hero = new CGHeroInstance();
+				auto  hero = new CGHeroInstance();
 				hero->ID = Obj::HERO;
 				hero->subID = z;
 
@@ -688,7 +688,7 @@ CArtifactInstance * CMapLoaderH3M::createArtifact(int aid, int spellID /*= -1*/)
 	if(a->artType && (!!a->artType->constituents))
 	{
 		CCombinedArtifactInstance * comb = dynamic_cast<CCombinedArtifactInstance *>(a);
-		BOOST_FOREACH(CCombinedArtifactInstance::ConstituentInfo & ci, comb->constituentsInfo)
+		for(CCombinedArtifactInstance::ConstituentInfo & ci : comb->constituentsInfo)
 		{
 			map->addNewArtifactInstance(ci.art);
 		}
@@ -737,15 +737,15 @@ void CMapLoaderH3M::readDefInfo()
 	// Read custom defs
 	for(int idd = 0; idd < defAmount; ++idd)
 	{
-		CGDefInfo * defInfo = new CGDefInfo();
+		auto  defInfo = new CGDefInfo();
 
 		defInfo->name = reader.readString();
 		std::transform(defInfo->name.begin(),defInfo->name.end(),defInfo->name.begin(),(int(*)(int))toupper);
 
 		ui8 bytes[12];
-		for(int v = 0; v < 12; ++v)
+		for(auto & byte : bytes)
 		{
-			bytes[v] = reader.readUInt8();
+			byte = reader.readUInt8();
 		}
 
 		defInfo->terrainAllowed = reader.readUInt16();
@@ -813,7 +813,7 @@ void CMapLoaderH3M::readObjects()
 
 	for(int ww = 0; ww < howManyObjs; ++ww)
 	{
-		CGObjectInstance * nobj = 0;
+		CGObjectInstance * nobj = nullptr;
 
 		int3 objPos = readInt3();
 
@@ -827,7 +827,7 @@ void CMapLoaderH3M::readObjects()
 		{
 		case Obj::EVENT:
 			{
-				CGEvent * evnt = new CGEvent();
+				auto  evnt = new CGEvent();
 				nobj = evnt;
 
 				readMessageAndGuards(evnt->message, evnt);
@@ -950,7 +950,7 @@ void CMapLoaderH3M::readObjects()
 		case Obj::RANDOM_MONSTER_L6:
 		case Obj::RANDOM_MONSTER_L7:
 			{
-				CGCreature * cre = new CGCreature();
+				auto  cre = new CGCreature();
 				nobj = cre;
 
 				if(map->version > EMapFormat::ROE)
@@ -959,7 +959,7 @@ void CMapLoaderH3M::readObjects()
 					map->questIdentifierToId[cre->identifier] = idToBeGiven;
 				}
 
-				CStackInstance * hlp = new CStackInstance();
+				auto  hlp = new CStackInstance();
 				hlp->count = reader.readUInt16();
 
 				//type will be set during initialization
@@ -1014,7 +1014,7 @@ void CMapLoaderH3M::readObjects()
 		case Obj::OCEAN_BOTTLE:
 		case Obj::SIGN:
 			{
-				CGSignBottle * sb = new CGSignBottle();
+				auto  sb = new CGSignBottle();
 				nobj = sb;
 				sb->message = reader.readString();
 				reader.skip(4);
@@ -1028,7 +1028,7 @@ void CMapLoaderH3M::readObjects()
 			}
 		case Obj::WITCH_HUT:
 			{
-				CGWitchHut * wh = new CGWitchHut();
+				auto  wh = new CGWitchHut();
 				nobj = wh;
 
 				// in RoE we cannot specify it - all are allowed (I hope)
@@ -1061,7 +1061,7 @@ void CMapLoaderH3M::readObjects()
 			}
 		case Obj::SCHOLAR:
 			{
-				CGScholar * sch = new CGScholar();
+				auto  sch = new CGScholar();
 				nobj = sch;
 				sch->bonusType = static_cast<CGScholar::EBonusType>(reader.readUInt8());
 				sch->bonusID = reader.readUInt8();
@@ -1071,7 +1071,7 @@ void CMapLoaderH3M::readObjects()
 		case Obj::GARRISON:
 		case Obj::GARRISON2:
 			{
-				CGGarrison * gar = new CGGarrison();
+				auto  gar = new CGGarrison();
 				nobj = gar;
 				nobj->setOwner(PlayerColor(reader.readUInt8()));
 				reader.skip(3);
@@ -1097,7 +1097,7 @@ void CMapLoaderH3M::readObjects()
 			{
 				int artID = ArtifactID::NONE; //random, set later
 				int spellID = -1;
-				CGArtifact * art = new CGArtifact();
+				auto  art = new CGArtifact();
 				nobj = art;
 
 				readMessageAndGuards(art->message, art);
@@ -1119,7 +1119,7 @@ void CMapLoaderH3M::readObjects()
 		case Obj::RANDOM_RESOURCE:
 		case Obj::RESOURCE:
 			{
-				CGResource * res = new CGResource();
+				auto  res = new CGResource();
 				nobj = res;
 
 				readMessageAndGuards(res->message, res);
@@ -1167,7 +1167,7 @@ void CMapLoaderH3M::readObjects()
 		case Obj::SHRINE_OF_MAGIC_GESTURE:
 		case Obj::SHRINE_OF_MAGIC_THOUGHT:
 			{
-				CGShrine * shr = new CGShrine();
+				auto  shr = new CGShrine();
 				nobj = shr;
 				ui8 raw_id = reader.readUInt8();
 
@@ -1185,7 +1185,7 @@ void CMapLoaderH3M::readObjects()
 			}
 		case Obj::PANDORAS_BOX:
 			{
-				CGPandoraBox * box = new CGPandoraBox();
+				auto  box = new CGPandoraBox();
 				nobj = box;
 				readMessageAndGuards(box->message, box);
 
@@ -1279,7 +1279,7 @@ void CMapLoaderH3M::readObjects()
 			}
 		case Obj::QUEST_GUARD:
 			{
-				CGQuestGuard * guard = new CGQuestGuard();
+				auto  guard = new CGQuestGuard();
 				map->addQuest(guard);
 				readQuest(guard);
 				nobj = guard;
@@ -1339,7 +1339,7 @@ void CMapLoaderH3M::readObjects()
 			}
 		case Obj::HERO_PLACEHOLDER: //hero placeholder
 			{
-				CGHeroPlaceholder * hp = new CGHeroPlaceholder();
+				auto  hp = new CGHeroPlaceholder();
 				nobj = hp;
 
 				hp->setOwner(PlayerColor(reader.readUInt8()));
@@ -1504,7 +1504,7 @@ void CMapLoaderH3M::readCreatureSet(CCreatureSet * out, int number)
 		// Empty slot
 		if(creID == maxID) continue;
 
-		CStackInstance * hlp = new CStackInstance();
+		auto  hlp = new CStackInstance();
 		hlp->count = count;
 
 		if(creID > maxID - 0xf)
@@ -1526,7 +1526,7 @@ void CMapLoaderH3M::readCreatureSet(CCreatureSet * out, int number)
 
 CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven)
 {
-	CGHeroInstance * nhi = new CGHeroInstance();
+	auto  nhi = new CGHeroInstance();
 
 	int identifier = 0;
 	if(map->version > EMapFormat::ROE)
@@ -1540,13 +1540,13 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven)
 
 	//If hero of this type has been predefined, use that as a base.
 	//Instance data will overwrite the predefined values where appropriate.
-	for(int j = 0; j < map->predefinedHeroes.size(); ++j)
+	for(auto & elem : map->predefinedHeroes)
 	{
-		if(map->predefinedHeroes[j]->subID == nhi->subID)
+		if(elem->subID == nhi->subID)
 		{
             logGlobal->debugStream() << "Hero " << nhi->subID << " will be taken from the predefined heroes list.";
 			delete nhi;
-			nhi = map->predefinedHeroes[j];
+			nhi = elem;
 			break;
 		}
 	}
@@ -1554,12 +1554,12 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven)
 
 	nhi->portrait = nhi->subID;
 
-	for(int j = 0; j < map->disposedHeroes.size(); ++j)
+	for(auto & elem : map->disposedHeroes)
 	{
-		if(map->disposedHeroes[j].heroId == nhi->subID)
+		if(elem.heroId == nhi->subID)
 		{
-			nhi->name = map->disposedHeroes[j].name;
-			nhi->portrait = map->disposedHeroes[j].portrait;
+			nhi->name = elem.name;
+			nhi->portrait = elem.portrait;
 			break;
 		}
 	}
@@ -1690,7 +1690,7 @@ CGObjectInstance * CMapLoaderH3M::readHero(ObjectInstanceID idToBeGiven)
 
 CGSeerHut * CMapLoaderH3M::readSeerHut()
 {
-	CGSeerHut * hut = new CGSeerHut();
+	auto  hut = new CGSeerHut();
 
 	if(map->version > EMapFormat::ROE)
 	{
@@ -1884,7 +1884,7 @@ void CMapLoaderH3M::readQuest(IQuestObject * guard)
 
 CGTownInstance * CMapLoaderH3M::readTown(int castleID)
 {
-	CGTownInstance * nt = new CGTownInstance();
+	auto  nt = new CGTownInstance();
 	if(map->version > EMapFormat::ROE)
 	{
 		nt->identifier = reader.readUInt32();
@@ -2019,7 +2019,7 @@ std::set<BuildingID> CMapLoaderH3M::convertBuildings(const std::set<BuildingID>
 	// Note: this file is parsed many times.
 	const JsonNode config(ResourceID("config/buildings5.json"));
 
-	BOOST_FOREACH(const JsonNode & entry, config["table"].Vector())
+	for(const JsonNode & entry : config["table"].Vector())
 	{
 		int town = entry["town"].Float();
 
@@ -2029,23 +2029,23 @@ std::set<BuildingID> CMapLoaderH3M::convertBuildings(const std::set<BuildingID>
 		}
 	}
 
-	for(auto i = h3m.begin(); i != h3m.end(); ++i)
+	for(auto & elem : h3m)
 	{
-		if(mapa[*i] >= 0)
+		if(mapa[elem] >= 0)
 		{
-			ret.insert(mapa[*i]);
+			ret.insert(mapa[elem]);
 		}
 		// horde buildings
-		else if(mapa[*i] >= (-GameConstants::CREATURES_PER_TOWN))
+		else if(mapa[elem] >= (-GameConstants::CREATURES_PER_TOWN))
 		{
-			int level = (mapa[*i]);
+			int level = (mapa[elem]);
 
 			//(-30)..(-36) - horde buildings (for game loading only), don't see other way to handle hordes in random towns
 			ret.insert(BuildingID(level - 30));
 		}
 		else
 		{
-            logGlobal->warnStream() << "Conversion warning: unknown building " << *i << " in castle "
+            logGlobal->warnStream() << "Conversion warning: unknown building " << elem << " in castle "
                   << castleID;
 		}
 	}

+ 14 - 14
lib/rmg/CMapGenerator.cpp

@@ -310,7 +310,7 @@ const CRmgTemplate * CMapGenOptions::getPossibleTemplate(CRandomGenerator & gen)
 	// Find potential templates
 	const auto & tpls = getAvailableTemplates();
 	std::list<const CRmgTemplate *> potentialTpls;
-	BOOST_FOREACH(const auto & tplPair, tpls)
+	for(const auto & tplPair : tpls)
 	{
 		const auto & tpl = tplPair.second;
 		CRmgTemplate::CSize tplSize(width, height, hasTwoLevels);
@@ -439,7 +439,7 @@ std::string CMapGenerator::getMapDescription() const
 		static_cast<int>(mapGenOptions.getCompOnlyPlayerCount()) % waterContentStr[mapGenOptions.getWaterContent()] %
         monsterStrengthStr[mapGenOptions.getMonsterStrength()]);
 
-	BOOST_FOREACH(const auto & pair, mapGenOptions.getPlayersSettings())
+	for(const auto & pair : mapGenOptions.getPlayersSettings())
 	{
 		const auto & pSettings = pair.second;
 		if(pSettings.getPlayerType() == EPlayerType::HUMAN)
@@ -492,7 +492,7 @@ void CMapGenerator::addPlayerInfo()
 	}
 
 	// Team numbers are assigned randomly to every player
-	BOOST_FOREACH(const auto & pair, mapGenOptions.getPlayersSettings())
+	for(const auto & pair : mapGenOptions.getPlayersSettings())
 	{
 		const auto & pSettings = pair.second;
 		PlayerInfo player;
@@ -532,7 +532,7 @@ void CMapGenerator::genTowns()
 
 		PlayerColor owner(i);
 		int side = i % 2;
-		CGTownInstance * town = new CGTownInstance();
+		auto  town = new CGTownInstance();
 		town->ID = Obj::TOWN;
 		int townId = mapGenOptions.getPlayersSettings().find(PlayerColor(i))->second.getStartingTown();
 		if(townId == CMapGenOptions::CPlayerSettings::RANDOM_TOWN) townId = gen.getInteger(0, 8); // Default towns
@@ -740,7 +740,7 @@ std::set<ETerrainType> CRmgTemplateZone::getDefaultTerrainTypes() const
 	std::set<ETerrainType> terTypes;
 	static const ETerrainType::EETerrainType allowedTerTypes[] = { ETerrainType::DIRT, ETerrainType::SAND, ETerrainType::GRASS, ETerrainType::SNOW,
 												   ETerrainType::SWAMP, ETerrainType::ROUGH, ETerrainType::SUBTERRANEAN, ETerrainType::LAVA };
-	for(int i = 0; i < ARRAY_COUNT(allowedTerTypes); ++i) terTypes.insert(allowedTerTypes[i]);
+	for(auto & allowedTerType : allowedTerTypes) terTypes.insert(allowedTerType);
 	return terTypes;
 }
 
@@ -967,7 +967,7 @@ void CRmgTemplate::CPlayerCountRange::addNumber(int value)
 
 bool CRmgTemplate::CPlayerCountRange::isInRange(int count) const
 {
-	BOOST_FOREACH(const auto & pair, range)
+	for(const auto & pair : range)
 	{
 		if(count >= pair.first && count <= pair.second) return true;
 	}
@@ -977,7 +977,7 @@ bool CRmgTemplate::CPlayerCountRange::isInRange(int count) const
 std::set<int> CRmgTemplate::CPlayerCountRange::getNumbers() const
 {
 	std::set<int> numbers;
-	BOOST_FOREACH(const auto & pair, range)
+	for(const auto & pair : range)
 	{
 		for(int i = pair.first; i <= pair.second; ++i) numbers.insert(i);
 	}
@@ -992,7 +992,7 @@ const std::map<std::string, CRmgTemplate> & CRmgTemplateLoader::getTemplates() c
 void CJsonRmgTemplateLoader::loadTemplates()
 {
 	const JsonNode rootNode(ResourceID("config/rmg.json"));
-	BOOST_FOREACH(const auto & templatePair, rootNode.Struct())
+	for(const auto & templatePair : rootNode.Struct())
 	{
 		CRmgTemplate tpl;
 		try
@@ -1008,7 +1008,7 @@ void CJsonRmgTemplateLoader::loadTemplates()
 
 			// Parse zones
 			std::map<TRmgTemplateZoneId, CRmgTemplateZone> zones;
-			BOOST_FOREACH(const auto & zonePair, templateNode["zones"].Struct())
+			for(const auto & zonePair : templateNode["zones"].Struct())
 			{
 				CRmgTemplateZone zone;
 				auto zoneId = boost::lexical_cast<TRmgTemplateZoneId>(zonePair.first);
@@ -1031,7 +1031,7 @@ void CJsonRmgTemplateLoader::loadTemplates()
 
 			// Parse connections
 			std::list<CRmgTemplateZoneConnection> connections;
-			BOOST_FOREACH(const auto & connPair, templateNode["connections"].Vector())
+			for(const auto & connPair : templateNode["connections"].Vector())
 			{
 				CRmgTemplateZoneConnection conn;
 				conn.setZoneA(boost::lexical_cast<TRmgTemplateZoneId>(connPair["a"].String()));
@@ -1103,13 +1103,13 @@ CRmgTemplateZone::CTownInfo CJsonRmgTemplateLoader::parseTemplateZoneTowns(const
 std::set<TFaction> CJsonRmgTemplateLoader::parseTownTypes(const JsonVector & townTypesVector, const std::set<TFaction> & defaultTownTypes) const
 {
 	std::set<TFaction> townTypes;
-	BOOST_FOREACH(const auto & townTypeNode, townTypesVector)
+	for(const auto & townTypeNode : townTypesVector)
 	{
 		auto townTypeStr = townTypeNode.String();
 		if(townTypeStr == "all") return defaultTownTypes;
 
 		bool foundFaction = false;
-		BOOST_FOREACH(auto factionPtr, VLC->townh->factions)
+		for(auto factionPtr : VLC->townh->factions)
 		{
 			if(factionPtr->town != nullptr && townTypeStr == factionPtr->name)
 			{
@@ -1125,7 +1125,7 @@ std::set<TFaction> CJsonRmgTemplateLoader::parseTownTypes(const JsonVector & tow
 std::set<ETerrainType> CJsonRmgTemplateLoader::parseTerrainTypes(const JsonVector & terTypeStrings, const std::set<ETerrainType> & defaultTerrainTypes) const
 {
 	std::set<ETerrainType> terTypes;
-	BOOST_FOREACH(const auto & node, terTypeStrings)
+	for(const auto & node : terTypeStrings)
 	{
 		const auto & terTypeStr = node.String();
 		if(terTypeStr == "all") return defaultTerrainTypes;
@@ -1152,7 +1152,7 @@ CRmgTemplate::CPlayerCountRange CJsonRmgTemplateLoader::parsePlayers(const std::
 	}
 	std::vector<std::string> commaParts;
 	boost::split(commaParts, players, boost::is_any_of(","));
-	BOOST_FOREACH(const auto & commaPart, commaParts)
+	for(const auto & commaPart : commaParts)
 	{
 		std::vector<std::string> rangeParts;
 		boost::split(rangeParts, commaPart, boost::is_any_of("-"));

+ 6 - 6
scripting/erm/ERMInterpreter.cpp

@@ -89,7 +89,7 @@ namespace ERMPrinter
 		if(id.is_initialized())
 		{
 			logGlobal->debugStream() << "identifier: ";
-			BOOST_FOREACH(TIdentifierInternal x, id.get())
+			for (auto x : id.get())
 			{
 				logGlobal->debugStream() << "#";
 				boost::apply_visitor(IdentifierPrinterVisitor(), x);
@@ -215,7 +215,7 @@ namespace ERMPrinter
 		void operator()(TNormalBodyOption const& cmp) const
 		{
 			logGlobal->debugStream() << cmp.optionCode << "~";
-			BOOST_FOREACH(TBodyOptionItem optList, cmp.params)
+			for (auto optList : cmp.params)
 			{
 				boost::apply_visitor(BodyOptionItemPrinterVisitor(), optList);
 			}
@@ -225,7 +225,7 @@ namespace ERMPrinter
 	void bodyPrinter(const Tbody & body)
 	{
 		logGlobal->debugStream() << " body items: ";
-		BOOST_FOREACH(TBodyOption bi, body)
+		for (auto bi: body)
 		{
 			logGlobal->debugStream() << " (";
 			apply_visitor(BodyOptionVisitor(), bi);
@@ -299,7 +299,7 @@ namespace ERMPrinter
 		}
 		void operator()(TSymbol const& cmd) const
 		{
-			BOOST_FOREACH(TVModifier mod, cmd.symModifier)
+			for(auto mod : cmd.symModifier)
 			{
 				logGlobal->debugStream() << mod << " ";
 			}
@@ -329,12 +329,12 @@ namespace ERMPrinter
 
 	void printTVExp(const TVExp & exp)
 	{
-		BOOST_FOREACH(TVModifier mod, exp.modifier)
+		for (auto mod: exp.modifier)
 		{
 			logGlobal->debugStream() << mod << " ";
 		}
 		logGlobal->debugStream() << "[ ";
-		BOOST_FOREACH(TVOption opt, exp.children)
+		for (auto opt: exp.children)
 		{
 			boost::apply_visitor(VOptionPrinterVisitor(), opt);
 			logGlobal->debugStream() << " ";

+ 1 - 1
scripting/erm/ERMParser.cpp

@@ -521,7 +521,7 @@ int ERMParser::countHatsBeforeSemicolon( const std::string & line ) const
 	//CHECK: omit macros? or anything else? 
 	int numOfHats = 0; //num of '^' before ';'
 	//check for unmatched ^
-	BOOST_FOREACH(char c, line)
+	for (char c : line)
 	{
 		if(c == ';')
 			break;

+ 132 - 133
server/CGameHandler.cpp

@@ -99,7 +99,7 @@ static void giveExp(BattleResult &r)
 {
 	r.exp[0] = 0;
 	r.exp[1] = 0;
-	for(std::map<ui32,si32>::iterator i = r.casualties[!r.winner].begin(); i!=r.casualties[!r.winner].end(); i++)
+	for(auto i = r.casualties[!r.winner].begin(); i!=r.casualties[!r.winner].end(); i++)
 	{
 		r.exp[r.winner] += VLC->creh->creatures[i->first]->valOfBonuses(Bonus::STACK_HEALTH) * i->second;
 	}
@@ -324,7 +324,7 @@ void CGameHandler::levelUpCommander(const CCommanderInstance * c)
 			clu.skills.push_back(i);
 	}
 	int i = 100;
-	BOOST_FOREACH (auto specialSkill, VLC->creh->skillRequirements)
+	for (auto specialSkill : VLC->creh->skillRequirements)
 	{
 		if (c->secondarySkills[specialSkill.second.first] == ECommander::MAX_SKILL_LEVEL 
 			&&  c->secondarySkills[specialSkill.second.second] == ECommander::MAX_SKILL_LEVEL 
@@ -425,7 +425,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 
 	auto findBattleQuery = [this] () -> shared_ptr<CBattleQuery>
 	{
-		BOOST_FOREACH(auto &q, queries.allQueries())
+		for(auto &q : queries.allQueries())
 		{
 			if(auto bq = std::dynamic_pointer_cast<CBattleQuery>(q))
 				if(bq->bi == gs->curB)
@@ -471,7 +471,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 		{
 			int maxLevel = eagleEyeLevel + 1;
 			double eagleEyeChance = finishingBattle->winnerHero->valOfBonuses(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::EAGLE_EYE);
-			BOOST_FOREACH(const CSpell *sp, gs->curB->usedSpellsHistory[!battleResult.data->winner])
+			for(const CSpell *sp : gs->curB->usedSpellsHistory[!battleResult.data->winner])
 				if(sp->level <= maxLevel && !vstd::contains(finishingBattle->winnerHero->spells, sp->id) && rand() % 100 < eagleEyeChance)
 					cs.spells.insert(sp->id);
 		}
@@ -485,7 +485,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 		if (finishingBattle->loserHero)
 		{
 			auto artifactsWorn = finishingBattle->loserHero->artifactsWorn; //TODO: wrap it into a function, somehow (boost::variant -_-)
-			BOOST_FOREACH (auto artSlot, artifactsWorn)
+			for (auto artSlot : artifactsWorn)
 			{
 				MoveArtifact ma;
 				ma.src = ArtifactLocation (finishingBattle->loserHero, artSlot.first);
@@ -511,7 +511,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 			if (finishingBattle->loserHero->commander) //TODO: what if commanders belong to no hero?
 			{
 				artifactsWorn = finishingBattle->loserHero->commander->artifactsWorn;
-				BOOST_FOREACH (auto artSlot, artifactsWorn)
+				for (auto artSlot : artifactsWorn)
 				{
 					MoveArtifact ma;
 					ma.src = ArtifactLocation (finishingBattle->loserHero->commander.get(), artSlot.first);
@@ -525,10 +525,10 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 				}
 			}
 		}
-		BOOST_FOREACH (auto armySlot, gs->curB->belligerents[!battleResult.data->winner]->stacks)
+		for (auto armySlot : gs->curB->belligerents[!battleResult.data->winner]->stacks)
 		{
 			auto artifactsWorn = armySlot.second->artifactsWorn;
-			BOOST_FOREACH (auto artSlot, artifactsWorn)
+			for (auto artSlot : artifactsWorn)
 			{
 				MoveArtifact ma;
 				ma.src = ArtifactLocation (armySlot.second, artSlot.first);
@@ -552,7 +552,7 @@ void CGameHandler::endBattle(int3 tile, const CGHeroInstance *hero1, const CGHer
 
 		iw.text.addTxt (MetaString::GENERAL_TXT, 30); //You have captured enemy artifact
 
-		BOOST_FOREACH (auto id, arts) //TODO; separate function to display loot for various ojects?
+		for (auto id : arts) //TODO; separate function to display loot for various ojects?
 		{
 			iw.components.push_back (Component (Component::ARTIFACT, id, 0, 0));
 			if(iw.components.size() >= 14)
@@ -739,7 +739,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
 	{
 		std::set<const CStack*> attackedCreatures = gs->curB->getAttackedCreatures(att, targetHex); //creatures other than primary target
 
-		BOOST_FOREACH(const CStack * stack, attackedCreatures)
+		for(const CStack * stack : attackedCreatures)
 		{
 			if (stack != def) //do not hit same stack twice
 			{
@@ -757,7 +757,7 @@ void CGameHandler::prepareAttack(BattleAttack &bat, const CStack *att, const CSt
 		std::set<const CStack*> attackedCreatures = gs->curB->getAffectedCreatures(SpellID(bonus->subtype).toSpell(), bonus->val, att->owner, targetHex);
 		//TODO: get exact attacked hex for defender
 
-		BOOST_FOREACH(const CStack * stack, attackedCreatures)
+		for(const CStack * stack : attackedCreatures)
 		{
 			if (stack != def) //do not hit same stack twice
 			{
@@ -1038,8 +1038,8 @@ void CGameHandler::init(StartInfo *si)
 	gs->init(si);
     logGlobal->infoStream() << "Gamestate initialized!";
 
-	for(auto i = gs->players.begin(); i != gs->players.end(); i++)
-		states.addPlayer(i->first);
+	for(auto & elem : gs->players)
+		states.addPlayer(elem.first);
 }
 
 static bool evntCmp(const CMapEvent &a, const CMapEvent &b)
@@ -1100,7 +1100,7 @@ void CGameHandler::newTurn()
 
 	if (firstTurn)
 	{
-		BOOST_FOREACH (auto obj, gs->map->objects)
+		for (auto obj : gs->map->objects)
 		{
 			if (obj && obj->ID == Obj::PRISON) //give imprisoned hero 0 exp to level him up. easiest to do at this point
 			{
@@ -1113,7 +1113,7 @@ void CGameHandler::newTurn()
 	{
 		n.specialWeek = NewTurn::NORMAL;
 		bool deityOfFireBuilt = false;
-		BOOST_FOREACH(const CGTownInstance *t, gs->map->towns)
+		for(const CGTownInstance *t : gs->map->towns)
 		{
 			if(t->hasBuilt(BuildingID::GRAIL, ETownType::INFERNO))
 			{
@@ -1169,26 +1169,26 @@ void CGameHandler::newTurn()
 
 	bmap<ui32, ConstTransitivePtr<CGHeroInstance> > pool = gs->hpool.heroesPool;
 
-	for ( auto i=gs->players.begin() ; i!=gs->players.end();i++)
+	for (auto & elem : gs->players)
 	{
-		if(i->first == PlayerColor::NEUTRAL)
+		if(elem.first == PlayerColor::NEUTRAL)
 			continue;
-		else if(i->first >= PlayerColor::PLAYER_LIMIT)
+		else if(elem.first >= PlayerColor::PLAYER_LIMIT)
 			assert(0); //illegal player number!
 
-		std::pair<PlayerColor, si32> playerGold(i->first, i->second.resources[Res::GOLD]);
+		std::pair<PlayerColor, si32> playerGold(elem.first, elem.second.resources[Res::GOLD]);
 		hadGold.insert(playerGold);
 
 		if(newWeek) //new heroes in tavern
 		{
 			SetAvailableHeroes sah;
-			sah.player = i->first;
+			sah.player = elem.first;
 
 			//pick heroes and their armies
 			CHeroClass *banned = nullptr;
 			for (int j = 0; j < GameConstants::AVAILABLE_HEROES_PER_PLAYER; j++)
 			{
-				if(CGHeroInstance *h = gs->hpool.pickHeroFor(j == 0, i->first, getNativeTown(i->first), pool, banned)) //first hero - native if possible, second hero -> any other class
+				if(CGHeroInstance *h = gs->hpool.pickHeroFor(j == 0, elem.first, getNativeTown(elem.first), pool, banned)) //first hero - native if possible, second hero -> any other class
 				{
 					sah.hid[j] = h->subID;
 					h->initArmy(&sah.army[j]);
@@ -1201,9 +1201,9 @@ void CGameHandler::newTurn()
 			sendAndApply(&sah);
 		}
 
-		n.res[i->first] = i->second.resources;
+		n.res[elem.first] = elem.second.resources;
 
-		BOOST_FOREACH(CGHeroInstance *h, (*i).second.heroes)
+		for(CGHeroInstance *h : (elem).second.heroes)
 		{
 			if(h->visitedTown)
 				giveSpells(h->visitedTown, h);
@@ -1221,16 +1221,16 @@ void CGameHandler::newTurn()
 
 			if(!firstTurn) //not first day
 			{
-				n.res[i->first][Res::GOLD] += h->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ESTATES)); //estates
+				n.res[elem.first][Res::GOLD] += h->valOfBonuses(Selector::typeSubtype(Bonus::SECONDARY_SKILL_PREMY, SecondarySkill::ESTATES)); //estates
 
 				for (int k = 0; k < GameConstants::RESOURCE_QUANTITY; k++)
 				{
-					n.res[i->first][k] += h->valOfBonuses(Bonus::GENERATE_RESOURCE, k);
+					n.res[elem.first][k] += h->valOfBonuses(Bonus::GENERATE_RESOURCE, k);
 				}
 			}
 		}
 	}
-	BOOST_FOREACH(CGTownInstance *t, gs->map->towns)
+	for(CGTownInstance *t : gs->map->towns)
 	{
 		PlayerColor player = t->tempOwner;
 		handleTownEvents(t, n);
@@ -1381,9 +1381,9 @@ void CGameHandler::newTurn()
 						iw.text.addReplacement(MetaString::ARRAY_TXT, 43 + rand()%15);
 					}
 			}
-			for (auto i=gs->players.begin() ; i!=gs->players.end(); i++)
+			for (auto & elem : gs->players)
 			{
-				iw.player = i->first;
+				iw.player = elem.first;
 				sendAndApply(&iw);
 			}
 		}
@@ -1392,10 +1392,10 @@ void CGameHandler::newTurn()
     logGlobal->traceStream() << "Info about turn " << n.day << "has been sent!";
 	handleTimeEvents();
 	//call objects
-	for(size_t i = 0; i<gs->map->objects.size(); i++)
+	for(auto & elem : gs->map->objects)
 	{
-		if(gs->map->objects[i])
-			gs->map->objects[i]->newTurn();
+		if(elem)
+			elem->newTurn();
 	}
 
 	winLoseHandle(0xff);
@@ -1439,7 +1439,7 @@ void CGameHandler::run(bool resume)
 	LOG_TRACE_PARAMS(logGlobal, "resume=%d", resume);
 
 	using namespace boost::posix_time;
-	BOOST_FOREACH(CConnection *cc, conns)
+	for(CConnection *cc : conns)
 	{
 		if(!resume)
 		{
@@ -1451,7 +1451,7 @@ void CGameHandler::run(bool resume)
 
         std::stringstream sbuffer;
         sbuffer << "Connection " << cc->connectionID << " will handle " << players.size() << " player: ";
-		BOOST_FOREACH(PlayerColor color, players)
+		for(PlayerColor color : players)
 		{
             sbuffer << color << " ";
 			{
@@ -1466,14 +1466,14 @@ void CGameHandler::run(bool resume)
 		cc->disableSmartPointerSerialization();
 	}
 
-	for(std::set<CConnection*>::iterator i = conns.begin(); i!=conns.end();i++)
+	for(auto & elem : conns)
 	{
 		std::set<PlayerColor> pom;
 		for(auto j = connections.cbegin(); j!=connections.cend();j++)
-			if(j->second == *i)
+			if(j->second == elem)
 				pom.insert(j->first);
 
-		boost::thread(std::bind(&CGameHandler::handleConnection,this,pom,std::ref(**i)));
+		boost::thread(std::bind(&CGameHandler::handleConnection,this,pom,std::ref(*elem)));
 	}
 
 	if(gs->scenarioOps->mode == StartInfo::DUEL)
@@ -1547,11 +1547,11 @@ void CGameHandler::checkForBattleEnd()
 	//checking winning condition
 	bool hasStack[2]; //hasStack[0] - true if attacker has a living stack; defender similarly
 	hasStack[0] = hasStack[1] = false;
-	for(int b = 0; b<stacks.size(); ++b)
+	for(auto & stack : stacks)
 	{
-		if(stacks[b]->alive() && !stacks[b]->hasBonusOfType(Bonus::SIEGE_WEAPON))
+		if(stack->alive() && !stack->hasBonusOfType(Bonus::SIEGE_WEAPON))
 		{
-			hasStack[1-stacks[b]->attackerOwned] = true;
+			hasStack[1-stack->attackerOwned] = true;
 		}
 	}
 	if(!hasStack[0] || !hasStack[1]) //somebody has won
@@ -1573,8 +1573,8 @@ void CGameHandler::giveSpells( const CGTownInstance *t, const CGHeroInstance *h
 		{
 			std::vector<SpellID> spells;
 			getAllowedSpells(spells, i);
-			for (int j = 0; j < spells.size(); ++j)
-				cs.spells.insert(spells[j]);
+			for (auto & spell : spells)
+				cs.spells.insert(spell);
 		}
 		else
 		{
@@ -1681,7 +1681,7 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, Pl
 	// should be called if hero changes tile but before applying TryMoveHero package
 	auto leaveTile = [&]()
 	{
-		BOOST_FOREACH(CGObjectInstance *obj, gs->map->getTile(int3(h->pos.x-1, h->pos.y, h->pos.z)).visitableObjects)
+		for(CGObjectInstance *obj : gs->map->getTile(int3(h->pos.x-1, h->pos.y, h->pos.z)).visitableObjects)
 		{
 			obj->onHeroLeave(h);
 		}
@@ -1724,7 +1724,7 @@ bool CGameHandler::moveHero( ObjectInstanceID hid, int3 dst, ui8 teleporting, Pl
 	//interaction with blocking object (like resources)
 	auto blockingVisit = [&]() -> bool
 	{
-		BOOST_FOREACH(CGObjectInstance *obj, t.visitableObjects)
+		for(CGObjectInstance *obj : t.visitableObjects)
 		{
 			if(obj != h  &&  obj->blockVisit  &&  !obj->passableFor(h->tempOwner))
 			{
@@ -1830,7 +1830,7 @@ void CGameHandler::setOwner(const CGObjectInstance * obj, PlayerColor owner)
 
 	if((obj->ID == Obj::CREATURE_GENERATOR1 || obj->ID == Obj::CREATURE_GENERATOR4 ) && p && p->dwellings.size()==1)//first dwelling captured
 	{
-		BOOST_FOREACH(const CGTownInstance *t, gs->getPlayer(owner)->towns)
+		for(const CGTownInstance *t : gs->getPlayer(owner)->towns)
 		{
 			if (t->hasBuilt(BuildingID::PORTAL_OF_SUMMON, ETownType::DUNGEON))
 				setPortalDwelling(t);//set initial creatures for all portals of summoning
@@ -1875,9 +1875,9 @@ void CGameHandler::giveCreatures(const CArmedInstance *obj, const CGHeroInstance
 	COMPLAIN_RET_IF(creatures.stacksCount() > GameConstants::ARMY_SIZE, "Too many stacks to give!");
 
 	//first we move creatures to give to make them army of object-source
-	for (TSlots::const_iterator stack = creatures.Slots().begin(); stack != creatures.Slots().end(); stack++)
+	for (auto & elem : creatures.Slots())
 	{
-		addToSlot(StackLocation(obj, obj->getSlotFor(stack->second->type)), stack->second->type, stack->second->count);
+		addToSlot(StackLocation(obj, obj->getSlotFor(elem.second->type)), elem.second->type, elem.second->count);
 	}
 
 	tryJoiningArmy(obj, h, remove, true);
@@ -1890,7 +1890,7 @@ void CGameHandler::takeCreatures(ObjectInstanceID objid, const std::vector<CStac
 		return;
 	const CArmedInstance* obj = static_cast<const CArmedInstance*>(getObj(objid));
 
-	BOOST_FOREACH(CStackBasicDescriptor &sbd, cres)
+	for(CStackBasicDescriptor &sbd : cres)
 	{
 		TQuantity collected = 0;
 		while(collected < sbd.count)
@@ -2066,7 +2066,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 	ChangeSpells cs1;
 	cs1.learn = true;
 	cs1.hid = toHero;//giving spells to first hero
-	BOOST_FOREACH(auto it, h1->spells)
+	for(auto it : h1->spells)
 		if ( h2Lvl >= it.toSpell()->level && !vstd::contains(h2->spells, it))//hero can learn it and don't have it yet
 			cs1.spells.insert(it);//spell to learn
 
@@ -2074,7 +2074,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 	cs2.learn = true;
 	cs2.hid = fromHero;
 
-	BOOST_FOREACH(auto it, h2->spells)
+	for(auto it : h2->spells)
 		if ( h1Lvl >= it.toSpell()->level && !vstd::contains(h1->spells, it))
 			cs2.spells.insert(it);
 
@@ -2091,7 +2091,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 		{
 			iw.text.addTxt(MetaString::GENERAL_TXT, 140);//learns
 			int size = cs2.spells.size();
-			BOOST_FOREACH(auto it, cs2.spells)
+			for(auto it : cs2.spells)
 			{
 				iw.components.push_back(Component(Component::SPELL, it, 1, 0));
 				iw.text.addTxt(MetaString::SPELL_NAME, it.toEnum());
@@ -2116,7 +2116,7 @@ void CGameHandler::useScholarSkill(ObjectInstanceID fromHero, ObjectInstanceID t
 		{
 			iw.text.addTxt(MetaString::GENERAL_TXT, 147);//teaches
 			int size = cs1.spells.size();
-			BOOST_FOREACH(auto it, cs1.spells)
+			for(auto it : cs1.spells)
 			{
 				iw.components.push_back(Component(Component::SPELL, it, 1, 0));
 				iw.text.addTxt(MetaString::SPELL_NAME, it.toEnum());
@@ -2154,10 +2154,10 @@ void CGameHandler::heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2)
 void CGameHandler::sendToAllClients( CPackForClient * info )
 {
     logGlobal->traceStream() << "Sending to all clients a package of type " << typeid(*info).name();
-	for(std::set<CConnection*>::iterator i=conns.begin(); i!=conns.end();i++)
+	for(auto & elem : conns)
 	{
-		boost::unique_lock<boost::mutex> lock(*(*i)->wmx);
-		**i << info;
+		boost::unique_lock<boost::mutex> lock(*(elem)->wmx);
+		*elem << info;
 	}
 }
 
@@ -2247,7 +2247,7 @@ void CGameHandler::close()
 		exit(0);
 	}
 
-	//BOOST_FOREACH(CConnection *cc, conns)
+	//for(CConnection *cc : conns)
 	//	if(cc && cc->socket && cc->socket->is_open())
 	//		cc->socket->close();
 	//exit(0);
@@ -2457,7 +2457,7 @@ bool CGameHandler::buildStructure( ObjectInstanceID tid, BuildingID requestedID,
 	//Checks if all requirements will be met with expected building list "buildingsThatWillBe"
 	auto allRequirementsFullfilled = [&buildingsThatWillBe, t](const CBuilding *b)
 	{
-		BOOST_FOREACH(auto requirementID, b->requirements)
+		for(auto requirementID : b->requirements)
 			if(!vstd::contains(buildingsThatWillBe, t->town->buildings[requirementID]))
 				return false;
 
@@ -2467,7 +2467,7 @@ bool CGameHandler::buildStructure( ObjectInstanceID tid, BuildingID requestedID,
 
 
 	//Init the vectors
-	BOOST_FOREACH(auto & build, t->town->buildings)
+	for(auto & build : t->town->buildings)
 	{
 		if(t->hasBuilt(build.first))
 			buildingsThatWillBe.push_back(build.second);
@@ -2492,7 +2492,7 @@ bool CGameHandler::buildStructure( ObjectInstanceID tid, BuildingID requestedID,
 		buildingsThatWillBe.push_back(b);
 		remainingAutoBuildings -= b;
 
-		BOOST_FOREACH(auto autoBuilding, remainingAutoBuildings)
+		for(auto autoBuilding : remainingAutoBuildings)
 		{
 			if(allRequirementsFullfilled(autoBuilding))
 				buildingsToAdd.push(autoBuilding);
@@ -2507,7 +2507,7 @@ bool CGameHandler::buildStructure( ObjectInstanceID tid, BuildingID requestedID,
 	sendAndApply(&fw);
 
 	//Other post-built events
-	BOOST_FOREACH(auto builtID, ns.bid)
+	for(auto builtID : ns.bid)
 		processBuiltStructure(builtID);
 
 	//Take cost
@@ -2583,7 +2583,6 @@ bool CGameHandler::recruitCreatures( ObjectInstanceID objid, CreatureID crid, ui
 	bool found = false;
 	int level = 0;
 
-	typedef std::pair<const int,int> Parka;
 	for(; level < dw->creatures.size(); level++) //iterate through all levels
 	{
 		if ( (fromLvl != -1) && ( level !=fromLvl ) )
@@ -2702,7 +2701,7 @@ void CGameHandler::moveArmy(const CArmedInstance *src, const CArmedInstance *dst
 	assert(src->canBeMergedWith(*dst, allowMerging));
 	while(src->stacksCount())//while there are unmoved creatures
 	{
-		TSlots::const_iterator i = src->Slots().begin(); //iterator to stack to move
+		auto i = src->Slots().begin(); //iterator to stack to move
 		StackLocation sl(src, i->first); //location of stack to move
 
 		SlotID pos = dst->getSlotFor(i->second->type);
@@ -2952,7 +2951,7 @@ bool CGameHandler::buyArtifact(const IMarket *m, const CGHeroInstance *h, Res::E
 		COMPLAIN_RET("Wrong marktet...");
 
 	bool found = false;
-	BOOST_FOREACH(const CArtifact *&art, saa.arts)
+	for(const CArtifact *&art : saa.arts)
 	{
 		if(art && art->id == aid)
 		{
@@ -3584,11 +3583,11 @@ bool CGameHandler::makeBattleAction( BattleAction &ba )
 						}
 
 						BattleStacksRemoved bsr;
-						for(int g=0; g<gs->curB->stacks.size(); ++g)
+						for(auto & elem : gs->curB->stacks)
 						{
-							if(gs->curB->stacks[g]->position == posRemove)
+							if(elem->position == posRemove)
 							{
-								bsr.stackIDs.insert( gs->curB->stacks[g]->ID );
+								bsr.stackIDs.insert( elem->ID );
 								break;
 							}
 						}
@@ -3743,7 +3742,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
 
 		//give all spells
 		cs.learn = 1;
-		BOOST_FOREACH(auto spell, VLC->spellh->spells)
+		for(auto spell : VLC->spellh->spells)
 		{
 			if(!spell->creatureAbility)
 				cs.spells.insert(spell->id);
@@ -3763,7 +3762,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
 		CGTownInstance *town = gs->getTown(gs->getPlayer(player)->currentSelection);
 		if (town)
 		{
-			BOOST_FOREACH (auto & build, town->town->buildings)
+			for (auto & build : town->town->buildings)
 			{
 				if (!town->hasBuilt(build.first) && !build.second->Name().empty())
 				{
@@ -3828,7 +3827,7 @@ void CGameHandler::playerMessage( PlayerColor player, const std::string &message
 		FoWChange fc;
 		fc.mode = 1;
 		fc.player = player;
-		int3 * hlp_tab = new int3[gs->map->width * gs->map->height * (gs->map->twoLevel ? 2 : 1)];
+		auto  hlp_tab = new int3[gs->map->width * gs->map->height * (gs->map->twoLevel ? 2 : 1)];
 		int lastUnc = 0;
 		for(int i=0;i<gs->map->width;i++)
 			for(int j=0;j<gs->map->height;j++)
@@ -3941,7 +3940,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 		if (secHero && mode == ECastingMode::HERO_CASTING) //handle mana channel
 		{
 			int manaChannel = 0;
-			BOOST_FOREACH(CStack * stack, gs->curB->stacks) //TODO: shouldn't bonus system handle it somehow?
+			for(CStack * stack : gs->curB->stacks) //TODO: shouldn't bonus system handle it somehow?
 			{
 				if (stack->owner == secHero->tempOwner)
 				{
@@ -3960,7 +3959,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 	}
 	else //enchanter - hit all possible stacks
 	{
-		BOOST_FOREACH (const CStack * stack, gs->curB->stacks)
+		for (const CStack * stack : gs->curB->stacks)
 		{
 			/*if it's non negative spell and our unit or non positive spell and hostile unit */
 			if((!spell->isNegative() && stack->owner == casterColor)
@@ -3973,7 +3972,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 			}
 		}
 	}
-	BOOST_FOREACH (auto cre, attackedCres)
+	for (auto cre : attackedCres)
 	{
 		sc.affectedCres.insert (cre->ID);
 	}
@@ -4007,13 +4006,13 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 				}
 			}
 			int chainLightningModifier = 0;
-			for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it)
+			for(auto & attackedCre : attackedCres)
 			{
-				if(vstd::contains(sc.resisted, (*it)->ID)) //this creature resisted the spell
+				if(vstd::contains(sc.resisted, (attackedCre)->ID)) //this creature resisted the spell
 					continue;
 
 				BattleStackAttacked bsa;
-				if ((destination > -1 && (*it)->coversPos(destination)) || (spell->range[spellLvl] == "X" || mode == ECastingMode::ENCHANTER_CASTING))
+				if ((destination > -1 && (attackedCre)->coversPos(destination)) || (spell->range[spellLvl] == "X" || mode == ECastingMode::ENCHANTER_CASTING))
 					//display effect only upon primary target of area spell
 					//FIXME: if no stack is attacked, ther eis no animation and interface freezes
 				{
@@ -4023,16 +4022,16 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 				if (spellDamage)
 					bsa.damageAmount = spellDamage >> chainLightningModifier;
 				else
-					bsa.damageAmount = gs->curB->calculateSpellDmg(spell, caster, *it, spellLvl, usedSpellPower) >> chainLightningModifier;
+					bsa.damageAmount = gs->curB->calculateSpellDmg(spell, caster, attackedCre, spellLvl, usedSpellPower) >> chainLightningModifier;
 
 				sc.dmgToDisplay += bsa.damageAmount;
 
-				bsa.stackAttacked = (*it)->ID;
+				bsa.stackAttacked = (attackedCre)->ID;
 				if (mode == ECastingMode::ENCHANTER_CASTING) //multiple damage spells cast
 					bsa.attackerID = stack->ID;
 				else
 					bsa.attackerID = -1;
-				(*it)->prepareAttacked(bsa);
+				(attackedCre)->prepareAttacked(bsa);
 				si.stacks.push_back(bsa);
 
 				if (spellID == SpellID::CHAIN_LIGHTNING)
@@ -4066,7 +4065,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 			//TODO does hero specialty should affects his stack casting spells?
 
 			si32 power = 0;
-			BOOST_FOREACH(const CStack *affected, attackedCres)
+			for(const CStack *affected : attackedCres)
 			{
 				if(vstd::contains(sc.resisted, affected->ID)) //this creature resisted the spell
 					continue;
@@ -4135,25 +4134,25 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 			StacksHealedOrResurrected shr;
 			shr.lifeDrain = (ui8)false;
 			shr.tentHealing = (ui8)false;
-			for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it)
+			for(auto & attackedCre : attackedCres)
 			{
-				if(vstd::contains(sc.resisted, (*it)->ID) //this creature resisted the spell
-					|| (spellID == SpellID::ANIMATE_DEAD && !(*it)->hasBonusOfType(Bonus::UNDEAD)) //we try to cast animate dead on living stack, TODO: showuld be not affected earlier
+				if(vstd::contains(sc.resisted, (attackedCre)->ID) //this creature resisted the spell
+					|| (spellID == SpellID::ANIMATE_DEAD && !(attackedCre)->hasBonusOfType(Bonus::UNDEAD)) //we try to cast animate dead on living stack, TODO: showuld be not affected earlier
 					)
 					continue;
 				StacksHealedOrResurrected::HealInfo hi;
-				hi.stackID = (*it)->ID;
+				hi.stackID = (attackedCre)->ID;
 				if (stack) //casted by creature
 				{
 					if (hpGained)
 					{
-						hi.healedHP = gs->curB->calculateHealedHP(hpGained, spell, *it); //archangel
+						hi.healedHP = gs->curB->calculateHealedHP(hpGained, spell, attackedCre); //archangel
 					}
 					else
-						hi.healedHP = gs->curB->calculateHealedHP(spell, usedSpellPower, spellLvl, *it); //any typical spell (commander's cure or animate dead)
+						hi.healedHP = gs->curB->calculateHealedHP(spell, usedSpellPower, spellLvl, attackedCre); //any typical spell (commander's cure or animate dead)
 				}
 				else
-					hi.healedHP = gs->curB->calculateHealedHP(caster, spell, *it, gs->curB->battleGetStackByID(selectedStack)); //Casted by hero
+					hi.healedHP = gs->curB->calculateHealedHP(caster, spell, attackedCre, gs->curB->battleGetStackByID(selectedStack)); //Casted by hero
 				hi.lowLevelResurrection = spellLvl <= 1;
 				shr.healedStacks.push_back(hi);
 			}
@@ -4197,7 +4196,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 		{
 			//fire wall is build from multiple obstacles - one fire piece for each affected hex
 			auto affectedHexes = spell->rangeInHexes(destination, spellLvl, casterSide);
-			BOOST_FOREACH(BattleHex hex, affectedHexes)
+			for(BattleHex hex : affectedHexes)
 				placeObstacle(hex);
 		}
 		break;
@@ -4283,7 +4282,7 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 	case SpellID::REMOVE_OBSTACLE:
 		{
 			ObstaclesRemoved obr;
-			BOOST_FOREACH(auto &obstacle, battleGetAllObstacles())
+			for(auto &obstacle : battleGetAllObstacles())
 			{
 				if(vstd::contains(obstacle->getBlockedTiles(), destination))
 					obr.obstacles.insert(obstacle->uniqueID);
@@ -4298,9 +4297,9 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 		break;
 	case SpellID::DEATH_STARE: //handled in a bit different way
 		{
-			for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it)
+			for(auto & attackedCre : attackedCres)
 			{
-				if((*it)->hasBonusOfType(Bonus::UNDEAD) || (*it)->hasBonusOfType(Bonus::NON_LIVING)) //this creature is immune
+				if((attackedCre)->hasBonusOfType(Bonus::UNDEAD) || (attackedCre)->hasBonusOfType(Bonus::NON_LIVING)) //this creature is immune
 				{
 					sc.dmgToDisplay = 0; //TODO: handle Death Stare for multiple targets (?)
 					continue;
@@ -4309,25 +4308,25 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 				BattleStackAttacked bsa;
 				bsa.flags |= BattleStackAttacked::EFFECT;
 				bsa.effect = spell->mainEffectAnim; //from config\spell-Info.txt
-				bsa.damageAmount = usedSpellPower * (*it)->valOfBonuses(Bonus::STACK_HEALTH);
-				bsa.stackAttacked = (*it)->ID;
+				bsa.damageAmount = usedSpellPower * (attackedCre)->valOfBonuses(Bonus::STACK_HEALTH);
+				bsa.stackAttacked = (attackedCre)->ID;
 				bsa.attackerID = -1;
-				(*it)->prepareAttacked(bsa);
+				(attackedCre)->prepareAttacked(bsa);
 				si.stacks.push_back(bsa);
 			}
 		}
 		break;
 	case SpellID::ACID_BREATH_DAMAGE: //new effect, separate from acid breath defense reduction
 		{
-			for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it) //no immunities
+			for(auto & attackedCre : attackedCres) //no immunities
 			{
 				BattleStackAttacked bsa;
 				bsa.flags |= BattleStackAttacked::EFFECT;
 				bsa.effect = spell->mainEffectAnim;
 				bsa.damageAmount = usedSpellPower; //damage times the number of attackers
-				bsa.stackAttacked = (*it)->ID;
+				bsa.stackAttacked = (attackedCre)->ID;
 				bsa.attackerID = -1;
-				(*it)->prepareAttacked(bsa);
+				(attackedCre)->prepareAttacked(bsa);
 				si.stacks.push_back(bsa);
 			}
 		}
@@ -4351,25 +4350,25 @@ void CGameHandler::handleSpellCasting( SpellID spellID, int spellLvl, BattleHex
 	//Magic Mirror effect
 	if (spell->isNegative() && mode != ECastingMode::MAGIC_MIRROR && spell->level && spell->range[0] == "0") //it is actual spell and can be reflected to single target, no recurrence
 	{
-		for(auto it = attackedCres.begin(); it != attackedCres.end(); ++it)
+		for(auto & attackedCre : attackedCres)
 		{
-			int mirrorChance = (*it)->valOfBonuses(Bonus::MAGIC_MIRROR);
+			int mirrorChance = (attackedCre)->valOfBonuses(Bonus::MAGIC_MIRROR);
 			if(mirrorChance > rand()%100)
 			{
 				std::vector<CStack *> mirrorTargets;
 				std::vector<CStack *> & battleStacks = gs->curB->stacks;
-				for (size_t j = 0; j < battleStacks.size(); ++j)
+				for (auto & battleStack : battleStacks)
 				{
-					if(battleStacks[j]->owner == gs->curB->sides[casterSide]) //get enemy stacks which can be affected by this spell
+					if(battleStack->owner == gs->curB->sides[casterSide]) //get enemy stacks which can be affected by this spell
 					{
-						if (!gs->curB->battleIsImmune(nullptr, spell, ECastingMode::MAGIC_MIRROR, battleStacks[j]->position))
-							mirrorTargets.push_back(battleStacks[j]);
+						if (!gs->curB->battleIsImmune(nullptr, spell, ECastingMode::MAGIC_MIRROR, battleStack->position))
+							mirrorTargets.push_back(battleStack);
 					}
 				}
 				if (mirrorTargets.size())
 				{
 					int targetHex = mirrorTargets[rand() % mirrorTargets.size()]->position;
-					handleSpellCasting(spellID, 0, targetHex, 1 - casterSide, (*it)->owner, nullptr, (caster ? caster : nullptr), usedSpellPower, ECastingMode::MAGIC_MIRROR, (*it));
+					handleSpellCasting(spellID, 0, targetHex, 1 - casterSide, (attackedCre)->owner, nullptr, (caster ? caster : nullptr), usedSpellPower, ECastingMode::MAGIC_MIRROR, (attackedCre));
 				}
 			}
 		}
@@ -4460,7 +4459,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
 			BonusList bl = *(st->getBonuses(Selector::type(Bonus::BIND_EFFECT)));
 			std::set<const CStack*> stacks = gs->curB-> batteAdjacentCreatures(st);
 
-			BOOST_FOREACH(Bonus * b, bl)
+			for(Bonus * b : bl)
 			{
 				const CStack * stack = gs->curB->battleGetStackByID(b->additionalInfo); //binding stack must be alive and adjacent
 				if (stack)
@@ -4525,7 +4524,7 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
 		if (st->isLiving() && !st->hasBonusOfType(Bonus::FEARLESS))
 		{
 			bool fearsomeCreature = false;
-			BOOST_FOREACH(CStack * stack, gs->curB->stacks)
+			for(CStack * stack : gs->curB->stacks)
 			{
 				if (stack->owner != st->owner && stack->alive() && stack->hasBonusOfType(Bonus::FEAR))
 				{
@@ -4563,13 +4562,13 @@ void CGameHandler::stackTurnTrigger(const CStack * st)
 			}
 		}
 		bl = *(st->getBonuses(Selector::type(Bonus::ENCHANTED)));
-		BOOST_FOREACH (auto b, bl)
+		for (auto b : bl)
 		{
 			SetStackEffect sse;
 			int val = bl.valOfBonuses (Selector::typeSubtype(b->type, b->subtype));
 			if (val > 3)
 			{
-				BOOST_FOREACH (auto s, gs->curB->battleGetAllStacks())
+				for (auto s : gs->curB->battleGetAllStacks())
 				{
 					if (st->owner == s->owner && s->isValidTarget()) //all allied
 						sse.stacks.push_back (s->ID);
@@ -4746,7 +4745,7 @@ void CGameHandler::handleTownEvents(CGTownInstance * town, NewTurn &n)
 
 			}
 
-			BOOST_FOREACH(auto & i, ev.buildings)
+			for(auto & i : ev.buildings)
 			{
 				if ( town->hasBuilt(i))
 				{
@@ -5043,7 +5042,7 @@ void CGameHandler::checkLossVictory( PlayerColor player )
 		if(gs->scenarioOps->campState)
 		{
 			std::vector<CGHeroInstance *> hes;
-			BOOST_FOREACH(CGHeroInstance * ghi, gs->map->heroesOnMap)
+			for(CGHeroInstance * ghi : gs->map->heroesOnMap)
 			{
 				if (ghi->tempOwner == player)
 				{
@@ -5058,7 +5057,7 @@ void CGameHandler::checkLossVictory( PlayerColor player )
 			//Change connection mode
 			if(getPlayer(player)->human && getStartInfo()->campState)
 			{
-				BOOST_FOREACH(auto connection, conns)
+				for(auto connection : conns)
 					connection->prepareForSendingHeroes();
 			}
 
@@ -5237,18 +5236,18 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
 	{
 		std::set<SpellID> spellsToCast;
 		TBonusListPtr spells = attacker->getBonuses(Selector::type(attackMode));
-		BOOST_FOREACH(const Bonus *sf, *spells)
+		for(const Bonus *sf : *spells)
 		{
 			spellsToCast.insert (SpellID(sf->subtype));
 		}
-		BOOST_FOREACH(SpellID spellID, spellsToCast)
+		for(SpellID spellID : spellsToCast)
 		{
 			const CStack * oneOfAttacked = nullptr;
-			for (int g=0; g<bat.bsa.size(); ++g)
+			for (auto & elem : bat.bsa)
 			{
-				if (bat.bsa[g].newAmount > 0 && !bat.bsa[g].isSecondary()) //apply effects only to first target stack if it's alive
+				if (elem.newAmount > 0 && !elem.isSecondary()) //apply effects only to first target stack if it's alive
 				{
-					oneOfAttacked = gs->curB->battleGetStackByID(bat.bsa[g].stackAttacked);
+					oneOfAttacked = gs->curB->battleGetStackByID(elem.stackAttacked);
 					break;
 				}
 			}
@@ -5258,7 +5257,7 @@ void CGameHandler::attackCasting(const BattleAttack & bat, Bonus::BonusType atta
 				return;
 			int spellLevel = 0;
 			TBonusListPtr spellsByType = attacker->getBonuses(Selector::typeSubtype(attackMode, spellID));
-			BOOST_FOREACH(const Bonus *sf, *spellsByType)
+			for(const Bonus *sf : *spellsByType)
 			{
 				vstd::amax(spellLevel, sf->additionalInfo % 1000); //pick highest level
 				meleeRanged = sf->additionalInfo / 1000;
@@ -5331,7 +5330,7 @@ void CGameHandler::handleAfterAttackCasting( const BattleAttack & bat )
 
 	int acidDamage = 0;
 	TBonusListPtr acidBreath = attacker->getBonuses(Selector::type(Bonus::ACID_BREATH));
-	BOOST_FOREACH(const Bonus *b, *acidBreath)
+	for(const Bonus *b : *acidBreath)
 	{
 		if (b->additionalInfo > rand()%100)
 			acidDamage += b->val;
@@ -5384,7 +5383,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, SpellID spellID, const int
 			if(summonPos.x < 0)
 				COMPLAIN_RET("There is no water tile available!");
 
-			BOOST_FOREACH(const CGObjectInstance *obj, gs->map->objects)
+			for(const CGObjectInstance *obj : gs->map->objects)
 			{
 				if(obj && obj->ID == Obj::BOAT)
 				{
@@ -5532,7 +5531,7 @@ bool CGameHandler::castSpell(const CGHeroInstance *h, SpellID spellID, const int
 			{
 				double dist = town->pos.dist2d(h->pos);
 				ObjectInstanceID nearest = town->id; //nearest town's ID
-				BOOST_FOREACH(const CGTownInstance * currTown, gs->getPlayer(h->tempOwner)->towns)
+				for(const CGTownInstance * currTown : gs->getPlayer(h->tempOwner)->towns)
 				{
 					double curDist = currTown->pos.dist2d(h->pos);
 					if (nearest == ObjectInstanceID() || curDist < dist)
@@ -5711,7 +5710,7 @@ void CGameHandler::tryJoiningArmy(const CArmedInstance *src, const CArmedInstanc
 			bool cont = true;
 			while (cont)
 			{
-				for(TSlots::const_iterator i = src->stacks.begin(); i != src->stacks.end(); i++)//while there are unmoved creatures
+				for(auto i = src->stacks.begin(); i != src->stacks.end(); i++)//while there are unmoved creatures
 				{
 					SlotID pos = dst->getSlotFor(i->second->type);
 					if(pos.validSlot())
@@ -5799,7 +5798,7 @@ void CGameHandler::runBattle()
 		if(gs->curB->heroes[i] && gs->curB->heroes[i]->hasBonusOfType(Bonus::OPENING_BATTLE_SPELL))
 		{
 			TBonusListPtr bl = gs->curB->heroes[i]->getBonuses(Selector::type(Bonus::OPENING_BATTLE_SPELL));
-			BOOST_FOREACH (Bonus *b, *bl)
+			for (Bonus *b : *bl)
 			{
 				handleSpellCasting(SpellID(b->subtype), 3, -1, 0, gs->curB->heroes[i]->tempOwner, nullptr, gs->curB->heroes[1-i], b->val, ECastingMode::HERO_CASTING, nullptr);
 			}
@@ -5811,7 +5810,7 @@ void CGameHandler::runBattle()
 	{
 		NEW_ROUND;
 		auto obstacles = gs->curB->obstacles; //we copy container, because we're going to modify it
-		BOOST_FOREACH(auto &obstPtr, obstacles)
+		for(auto &obstPtr : obstacles)
 		{
 			if(const SpellCreatedObstacle *sco = dynamic_cast<const SpellCreatedObstacle *>(obstPtr.get()))
 				if(sco->turnsRemaining == 0)
@@ -5876,11 +5875,11 @@ void CGameHandler::runBattle()
 				attack.side = !next->attackerOwned;
 				attack.stackNumber = next->ID;
 
-				for(int g=0; g<gs->curB->stacks.size(); ++g)
+				for(auto & elem : gs->curB->stacks)
 				{
-					if(gs->curB->stacks[g]->owner != next->owner && gs->curB->stacks[g]->isValidTarget())
+					if(elem->owner != next->owner && elem->isValidTarget())
 					{
-						attack.destinationTile = gs->curB->stacks[g]->position;
+						attack.destinationTile = elem->position;
 						break;
 					}
 				}
@@ -5910,7 +5909,7 @@ void CGameHandler::runBattle()
 				std::vector< const CStack * > possibleStacks;
 
 				//is there any clean algorithm for that? (boost.range seems to lack copy_if) -> remove_copy_if?
-				BOOST_FOREACH(const CStack *s, battleGetAllStacks())
+				for(const CStack *s : battleGetAllStacks())
 					if(s->owner == next->owner  &&  s->canBeHealed())
 						possibleStacks.push_back(s);
 
@@ -6087,7 +6086,7 @@ void CGameHandler::setBattleResult(BattleResult::EResult resultType, int victori
 		complain("There is already set result?");
 		return;
 	}
-	BattleResult *br = new BattleResult;
+	auto br = new BattleResult;
 	br->result = resultType;
 	br->winner = victoriusSide; //surrendering side loses
 	gs->curB->calculateCasualties(br->casualties);
@@ -6157,7 +6156,7 @@ bool CGameHandler::isBlockedByQueries(const CPack *pack, PlayerColor player)
 void CGameHandler::removeAfterVisit(const CGObjectInstance *object)
 {
 	//If the object is being visited, there must be a matching query
-	BOOST_FOREACH(const auto &query, queries.allQueries())
+	for(const auto &query : queries.allQueries())
 	{
 		if(auto someVistQuery = std::dynamic_pointer_cast<CObjectVisitQuery>(query))
 		{
@@ -6191,11 +6190,11 @@ void CGameHandler::duelFinished()
 	logGlobal->debugStream() << boost::format("Winner side %d\nWinner casualties:") 
 		% (int)battleResult.data->winner;
 
-	for(auto i = battleResult.data->casualties[battleResult.data->winner].begin(); i != battleResult.data->casualties[battleResult.data->winner].end(); i++)
+	for(auto & elem : battleResult.data->casualties[battleResult.data->winner])
 	{
-		const CCreature *c = VLC->creh->creatures[i->first];
-		logGlobal->debugStream() << boost::format("\t* %d of %s") % i->second % c->namePl;
-		casualtiesPoints += c->AIValue * i->second;
+		const CCreature *c = VLC->creh->creatures[elem.first];
+		logGlobal->debugStream() << boost::format("\t* %d of %s") % elem.second % c->namePl;
+		casualtiesPoints += c->AIValue * elem.second;
 	}
 	logGlobal->debugStream() << boost::format("Total casualties points: %d") % casualtiesPoints;
 
@@ -6233,7 +6232,7 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance *army, BattleI
 	if(color == PlayerColor::UNFLAGGABLE)
 		color = PlayerColor::NEUTRAL;
 
-	BOOST_FOREACH(CStack *st, bat->stacks)
+	for(CStack *st : bat->stacks)
 	{
 		if(vstd::contains(st->state, EBattleStackState::SUMMONED)) //don't take into account summoned stacks
 			continue;
@@ -6261,7 +6260,7 @@ CasualtiesAfterBattle::CasualtiesAfterBattle(const CArmedInstance *army, BattleI
 
 void CasualtiesAfterBattle::takeFromArmy(CGameHandler *gh)
 {
-	BOOST_FOREACH(TStackAndItsNewCount &ncount, newStackCounts)
+	for(TStackAndItsNewCount &ncount : newStackCounts)
 	{
 		if(ncount.second > 0)
 			gh->changeStackCount(ncount.first, ncount.second, true);

+ 12 - 12
server/CQuery.cpp

@@ -9,11 +9,11 @@ template <typename Container>
 std::string formatContainer(const Container &c, std::string delimeter=", ", std::string opener="(", std::string closer=")")
 {
 	std::string ret = opener;
-	auto itr = boost::begin(c);
-	if(itr != boost::end(c))
+	auto itr = std::begin(c);
+	if(itr != std::end(c))
 	{
 		ret += boost::lexical_cast<std::string>(*itr);
-		while(++itr != boost::end(c))
+		while(++itr != std::end(c))
 		{
 			ret += delimeter;
 			ret += boost::lexical_cast<std::string>(*itr);
@@ -144,7 +144,7 @@ void Queries::popQuery(const CQuery &query)
 	LOG_TRACE_PARAMS(logGlobal, "query='%s'", query);
 
 	assert(query.players.size());
-	BOOST_FOREACH(auto player, query.players)
+	for(auto player : query.players)
 	{
 		auto top = topQuery(player);
 		if(top.get() == &query)
@@ -156,13 +156,13 @@ void Queries::popQuery(const CQuery &query)
 
 void Queries::popQuery(QueryPtr query)
 {
-	BOOST_FOREACH(auto player, query->players)
+	for(auto player : query->players)
 		popQuery(player, query);
 }
 
 void Queries::addQuery(QueryPtr query)
 {
-	BOOST_FOREACH(auto player, query->players)
+	for(auto player : query->players)
 		addQuery(player, query);
 }
 
@@ -188,7 +188,7 @@ void Queries::popIfTop(QueryPtr query)
 
 void Queries::popIfTop(const CQuery &query)
 {
-	BOOST_FOREACH(PlayerColor color, query.players)
+	for(PlayerColor color : query.players)
 		if(topQuery(color).get() == &query)
 			popQuery(color, topQuery(color));
 }
@@ -196,8 +196,8 @@ void Queries::popIfTop(const CQuery &query)
 std::vector<shared_ptr<const CQuery>> Queries::allQueries() const
 {
 	std::vector<shared_ptr<const CQuery>> ret;
-	BOOST_FOREACH(auto &playerQueries, queries)
-		BOOST_FOREACH(auto &query, playerQueries.second)
+	for(auto &playerQueries : queries)
+		for(auto &query : playerQueries.second)
 			ret.push_back(query);
 
 	return ret;
@@ -207,8 +207,8 @@ std::vector<shared_ptr<CQuery>> Queries::allQueries()
 {
 	//TODO code duplication with const function :(
 	std::vector<shared_ptr<CQuery>> ret;
-	BOOST_FOREACH(auto &playerQueries, queries)
-		BOOST_FOREACH(auto &query, playerQueries.second)
+	for(auto &playerQueries : queries)
+		for(auto &query : playerQueries.second)
 		ret.push_back(query);
 
 	return ret;
@@ -227,7 +227,7 @@ CBattleQuery::CBattleQuery(const BattleInfo *Bi)
 
 	bi = Bi;
 
-	BOOST_FOREACH(PlayerColor side, bi->sides)
+	for(PlayerColor side : bi->sides)
 		addPlayer(side);
 }
 

+ 10 - 10
server/CVCMIServer.cpp

@@ -114,7 +114,7 @@ void CPregameServer::handleConnection(CConnection *cpc)
 		connections -= cpc;
 
 		//notify other players about leaving
-		PlayerLeft *pl = new PlayerLeft();
+		auto pl = new PlayerLeft();
 		pl->playerID = cpc->connectionID;
 		announceTxt(cpc->name + " left the game");
 		toAnnounce.push_back(pl);
@@ -149,7 +149,7 @@ void CPregameServer::run()
 
 // 			//we end sending thread if we ordered all our connections to stop
 // 			ending = true;
-// 			BOOST_FOREACH(CPregameConnection *pc, connections)
+// 			for(CPregameConnection *pc : connections)
 // 				if(!pc->sendStop)
 // 					ending = false;
 
@@ -184,7 +184,7 @@ CPregameServer::~CPregameServer()
 	delete acceptor;
 	delete upcomingConnection;
 
-	BOOST_FOREACH(CPackForSelectionScreen *pack, toAnnounce)
+	for(CPackForSelectionScreen *pack : toAnnounce)
 		delete pack;
 
 	toAnnounce.clear();
@@ -210,7 +210,7 @@ void CPregameServer::connectionAccepted(const boost::system::error_code& ec)
 	startListeningThread(pc);
 
 	announceTxt(pc->name + " joins the game");
-	PlayerJoined *pj = new PlayerJoined();
+	auto pj = new PlayerJoined();
 	pj->playerName = pc->name;
 	pj->connectionID = pc->connectionID;
 	toAnnounce.push_back(pj);
@@ -240,7 +240,7 @@ void CPregameServer::announceTxt(const std::string &txt, const std::string &play
 
 void CPregameServer::announcePack(const CPackForSelectionScreen &pack)
 {
-	BOOST_FOREACH(CConnection *pc, connections)
+	for(CConnection *pc : connections)
 		sendPack(pc, pack);
 }
 
@@ -321,7 +321,7 @@ CVCMIServer::~CVCMIServer()
 
 CGameHandler * CVCMIServer::initGhFromHostingConnection(CConnection &c)
 {
-	CGameHandler *gh = new CGameHandler();
+	auto gh = new CGameHandler();
 	StartInfo si;
 	c >> si; //get start options
 
@@ -364,7 +364,7 @@ void CVCMIServer::newGame()
 
 void CVCMIServer::newPregame()
 {
-	CPregameServer *cps = new CPregameServer(firstConnection, acceptor);
+	auto cps = new CPregameServer(firstConnection, acceptor);
 	cps->run();
 	if(cps->state == CPregameServer::ENDING_WITHOUT_START)
 	{
@@ -378,7 +378,7 @@ void CVCMIServer::newPregame()
 		gh.conns = cps->connections;
 		gh.init(cps->curStartInfo);
 
-		BOOST_FOREACH(CConnection *c, gh.conns)
+		for(CConnection *c : gh.conns)
 			c->addStdVecItems(gh.gs);
 
 		gh.run(false);
@@ -406,7 +406,7 @@ void CVCMIServer::start()
 
 	boost::system::error_code error;
     logNetwork->infoStream()<<"Listening for connections at port " << acceptor->local_endpoint().port();
-	tcp::socket * s = new tcp::socket(acceptor->get_io_service());
+	auto  s = new tcp::socket(acceptor->get_io_service());
 	boost::thread acc(std::bind(vaccept,acceptor,s,&error));
 	sr->setToTrueAndNotify();
 	delete mr;
@@ -491,7 +491,7 @@ void CVCMIServer::loadGame()
 		}
 		else
 		{
-			tcp::socket * s = new tcp::socket(acceptor->get_io_service());
+			auto  s = new tcp::socket(acceptor->get_io_service());
 			acceptor->accept(*s,error);
 			if(error) //retry
 			{