소스 검색

c++03 -> c++11 switch:
- use std versions of function, bind and ref
- OVERRIDE -> override
- NULL -> nullptr
- use std versions of random distributions

NOTE: this may be last revision that supports gcc-4.5

Ivan Savenko 12 년 전
부모
커밋
2b45e13c5c
100개의 변경된 파일1398개의 추가작업 그리고 1438개의 파일을 삭제
  1. 3 3
      AI/BattleAI/BattleAI.cpp
  2. 22 22
      AI/BattleAI/BattleAI.h
  3. 2 2
      AI/StupidAI/StupidAI.cpp
  4. 23 23
      AI/StupidAI/StupidAI.h
  5. 0 11
      AI/VCAI/StdInc.h
  6. 22 19
      AI/VCAI/VCAI.cpp
  7. 72 72
      AI/VCAI/VCAI.h
  8. 1 1
      CCallback.cpp
  9. 7 7
      CCallback.h
  10. 34 46
      Global.h
  11. 6 6
      client/AdventureMapClasses.cpp
  12. 43 39
      client/CAdvmapInterface.cpp
  13. 2 2
      client/CAdvmapInterface.h
  14. 18 18
      client/CAnimation.cpp
  15. 5 5
      client/CAnimation.h
  16. 2 2
      client/CBitmapHandler.cpp
  17. 30 30
      client/CCastleInterface.cpp
  18. 1 1
      client/CCastleInterface.h
  19. 38 38
      client/CCreatureWindow.cpp
  20. 9 9
      client/CCreatureWindow.h
  21. 2 2
      client/CDefHandler.cpp
  22. 1 1
      client/CGameInfo.cpp
  23. 13 13
      client/CHeroWindow.cpp
  24. 1 1
      client/CHeroWindow.h
  25. 25 25
      client/CKingdomInterface.cpp
  26. 14 15
      client/CMT.cpp
  27. 5 5
      client/CMessage.cpp
  28. 9 9
      client/CMusicHandler.cpp
  29. 3 3
      client/CMusicHandler.h
  30. 17 17
      client/CPlayerInterface.cpp
  31. 72 72
      client/CPlayerInterface.h
  32. 66 66
      client/CPreGame.cpp
  33. 6 6
      client/CPreGame.h
  34. 7 7
      client/CQuestLog.cpp
  35. 2 2
      client/CQuestLog.h
  36. 16 16
      client/CSpellWindow.cpp
  37. 5 5
      client/CSpellWindow.h
  38. 44 47
      client/CVideoHandler.cpp
  39. 14 14
      client/Client.cpp
  40. 51 54
      client/Client.h
  41. 161 156
      client/GUIClasses.cpp
  42. 27 27
      client/GUIClasses.h
  43. 10 10
      client/Graphics.cpp
  44. 1 1
      client/Graphics.h
  45. 3 3
      client/NetPacksClient.cpp
  46. 7 7
      client/battle/CBattleAnimations.cpp
  47. 62 62
      client/battle/CBattleInterface.cpp
  48. 4 4
      client/battle/CBattleInterface.h
  49. 14 14
      client/battle/CBattleInterfaceClasses.cpp
  50. 1 1
      client/battle/CCreatureAnimation.cpp
  51. 3 3
      client/battle/CCreatureAnimation.h
  52. 1 1
      client/gui/CCursorHandler.cpp
  53. 1 1
      client/gui/CCursorHandler.h
  54. 6 6
      client/gui/CGuiHandler.cpp
  55. 1 1
      client/gui/CGuiHandler.h
  56. 1 1
      client/gui/CIntObject.cpp
  57. 28 28
      client/gui/CIntObjectClasses.cpp
  58. 12 12
      client/gui/CIntObjectClasses.h
  59. 3 3
      client/gui/Fonts.cpp
  60. 8 8
      client/gui/SDL_Extensions.cpp
  61. 8 8
      client/mapHandler.cpp
  62. 12 13
      lib/BattleState.cpp
  63. 9 9
      lib/BattleState.h
  64. 8 9
      lib/CArtHandler.cpp
  65. 4 4
      lib/CArtHandler.h
  66. 13 13
      lib/CBattleCallback.cpp
  67. 7 7
      lib/CBattleCallback.h
  68. 2 2
      lib/CConfigHandler.cpp
  69. 2 2
      lib/CConfigHandler.h
  70. 7 7
      lib/CConsoleHandler.cpp
  71. 1 1
      lib/CConsoleHandler.h
  72. 1 1
      lib/CCreatureHandler.cpp
  73. 1 1
      lib/CCreatureHandler.h
  74. 11 11
      lib/CCreatureSet.cpp
  75. 8 8
      lib/CCreatureSet.h
  76. 1 1
      lib/CGameInterface.h
  77. 29 30
      lib/CGameState.cpp
  78. 5 5
      lib/CGameState.h
  79. 4 4
      lib/CModHandler.cpp
  80. 5 5
      lib/CModHandler.h
  81. 35 33
      lib/CObjectHandler.cpp
  82. 35 35
      lib/CObjectHandler.h
  83. 4 4
      lib/CObstacleInstance.h
  84. 7 26
      lib/CRandomGenerator.h
  85. 1 1
      lib/CSpellHandler.h
  86. 2 2
      lib/CThreadHelper.cpp
  87. 7 7
      lib/CThreadHelper.h
  88. 3 3
      lib/Connection.cpp
  89. 13 13
      lib/Connection.h
  90. 2 2
      lib/ConstTransitivePtr.h
  91. 16 16
      lib/HeroBonus.cpp
  92. 16 16
      lib/HeroBonus.h
  93. 25 27
      lib/IGameCallback.cpp
  94. 3 3
      lib/IGameCallback.h
  95. 1 1
      lib/IGameEventsReceiver.h
  96. 1 1
      lib/JsonNode.cpp
  97. 1 1
      lib/JsonNode.h
  98. 3 3
      lib/NetPacks.h
  99. 17 17
      lib/NetPacksLib.cpp
  100. 1 1
      lib/StartInfo.h

+ 3 - 3
AI/BattleAI/BattleAI.cpp

@@ -31,7 +31,7 @@ struct Priorities
 } priorities;
 
 
-int distToNearestNeighbour(BattleHex hex, const ReachabilityInfo::TDistances& dists, BattleHex *chosenHex = NULL)
+int distToNearestNeighbour(BattleHex hex, const ReachabilityInfo::TDistances& dists, BattleHex *chosenHex = nullptr)
 {
 	int ret = 1000000;
 	BOOST_FOREACH(BattleHex n, hex.neighbouringTiles())
@@ -145,7 +145,7 @@ BattleAction CBattleAI::activeStack( const CStack * stack )
 			{
 				ThreatMap threatsToUs(stack);
 				auto dists = cbc->battleGetDistances(stack);
-				const EnemyInfo &ei= *range::min_element(targets.unreachableEnemies, boost::bind(isCloser, _1, _2, boost::ref(dists)));
+				const EnemyInfo &ei= *range::min_element(targets.unreachableEnemies, std::bind(isCloser, _1, _2, std::ref(dists)));
 				if(distToNearestNeighbour(ei.s->position, dists) < GameConstants::BFIELD_SIZE)
 				{
 					return goTowards(stack, ei.s->position);
@@ -592,7 +592,7 @@ ThreatMap::ThreatMap(const CStack *Endangered) : endangered(Endangered)
 	}
 }
 
-const TBonusListPtr StackWithBonuses::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= NULL*/, const std::string &cachingStr /*= ""*/) const 
+const TBonusListPtr StackWithBonuses::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const 
 {
 	TBonusListPtr ret = make_shared<BonusList>();
 	const TBonusListPtr originalList = stack->getAllBonuses(selector, limit, root, cachingStr);

+ 22 - 22
AI/BattleAI/BattleAI.h

@@ -13,7 +13,7 @@ public:
 	const CStack *stack;
 	mutable std::vector<Bonus> bonusesToAdd;
 
-	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const OVERRIDE;
+	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr, const std::string &cachingStr = "") const override;
 };
 
 struct EnemyInfo
@@ -120,27 +120,27 @@ public:
 	CBattleAI(void);
 	~CBattleAI(void);
 
-	void init(shared_ptr<CBattleCallback> CB) OVERRIDE;
-	void actionFinished(const BattleAction &action) OVERRIDE;//occurs AFTER every action taken by any stack or by the hero
-	void actionStarted(const BattleAction &action) OVERRIDE;//occurs BEFORE every action taken by any stack or by the hero
-	BattleAction activeStack(const CStack * stack) OVERRIDE; //called when it's turn of that stack
-
-	void battleAttack(const BattleAttack *ba) OVERRIDE; //called when stack is performing attack
-	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) OVERRIDE; //called when stack receives damage (after battleAttack())
-	void battleEnd(const BattleResult *br) OVERRIDE;
-	//void battleResultsApplied() OVERRIDE; //called when all effects of last battle are applied
-	void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied;
-	void battleNewRound(int round) OVERRIDE; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
-	void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) OVERRIDE;
-	void battleSpellCast(const BattleSpellCast *sc) OVERRIDE;
-	void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE;//called when a specific effect is set to stacks
-	//void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE;
-	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE; //called by engine when battle starts; side=0 - left, side=1 - right
-	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
-	void battleNewStackAppeared(const CStack * stack) OVERRIDE; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
-	void battleObstaclesRemoved(const std::set<si32> & removedObstacles) OVERRIDE; //called when a certain set  of obstacles is removed from batlefield; IDs of them are given
-	void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack
-	void battleStacksRemoved(const BattleStacksRemoved & bsr) OVERRIDE; //called when certain stack is completely removed from battlefield
+	void init(shared_ptr<CBattleCallback> CB) override;
+	void actionFinished(const BattleAction &action) override;//occurs AFTER every action taken by any stack or by the hero
+	void actionStarted(const BattleAction &action) override;//occurs BEFORE every action taken by any stack or by the hero
+	BattleAction activeStack(const CStack * stack) override; //called when it's turn of that stack
+
+	void battleAttack(const BattleAttack *ba) override; //called when stack is performing attack
+	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) override; //called when stack receives damage (after battleAttack())
+	void battleEnd(const BattleResult *br) override;
+	//void battleResultsApplied() override; //called when all effects of last battle are applied
+	void battleNewRoundFirst(int round) override; //called at the beginning of each turn before changes are applied;
+	void battleNewRound(int round) override; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
+	void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) override;
+	void battleSpellCast(const BattleSpellCast *sc) override;
+	void battleStacksEffectsSet(const SetStackEffect & sse) override;//called when a specific effect is set to stacks
+	//void battleTriggerEffect(const BattleTriggerEffect & bte) override;
+	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) override; //called by engine when battle starts; side=0 - left, side=1 - right
+	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
+	void battleNewStackAppeared(const CStack * stack) override; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
+	void battleObstaclesRemoved(const std::set<si32> & removedObstacles) override; //called when a certain set  of obstacles is removed from batlefield; IDs of them are given
+	void battleCatapultAttacked(const CatapultAttack & ca) override; //called when catapult makes an attack
+	void battleStacksRemoved(const BattleStacksRemoved & bsr) override; //called when certain stack is completely removed from battlefield
 
 	BattleAction goTowards(const CStack * stack, BattleHex hex );
 	BattleAction useCatapult(const CStack * stack);

+ 2 - 2
AI/StupidAI/StupidAI.cpp

@@ -60,7 +60,7 @@ bool isMoreProfitable(const EnemyInfo &ei1, const EnemyInfo& ei2)
 	return (ei1.adi-ei1.adr) < (ei2.adi - ei2.adr);
 }
 
-int distToNearestNeighbour(BattleHex hex, const ReachabilityInfo::TDistances& dists, BattleHex *chosenHex = NULL)
+int distToNearestNeighbour(BattleHex hex, const ReachabilityInfo::TDistances& dists, BattleHex *chosenHex = nullptr)
 {
 	int ret = 1000000;
 	BOOST_FOREACH(BattleHex n, hex.neighbouringTiles())
@@ -157,7 +157,7 @@ BattleAction CStupidAI::activeStack( const CStack * stack )
 	else if(enemiesUnreachable.size()) //due to #955 - a buggy battle may occur when there are no enemies
 	{
 		assert(enemiesUnreachable.size());
-		const EnemyInfo &ei= *std::min_element(enemiesUnreachable.begin(), enemiesUnreachable.end(), boost::bind(isCloser, _1, _2, boost::ref(dists)));
+		const EnemyInfo &ei= *std::min_element(enemiesUnreachable.begin(), enemiesUnreachable.end(), std::bind(isCloser, _1, _2, std::ref(dists)));
 		assert(ei.s);
 		if(distToNearestNeighbour(ei.s->position, dists) < GameConstants::BFIELD_SIZE)
 		{

+ 23 - 23
AI/StupidAI/StupidAI.h

@@ -12,32 +12,32 @@ public:
 	CStupidAI(void);
 	~CStupidAI(void);
 
-	void init(shared_ptr<CBattleCallback> CB) OVERRIDE;
-	void actionFinished(const BattleAction &action) OVERRIDE;//occurs AFTER every action taken by any stack or by the hero
-	void actionStarted(const BattleAction &action) OVERRIDE;//occurs BEFORE every action taken by any stack or by the hero
-	BattleAction activeStack(const CStack * stack) OVERRIDE; //called when it's turn of that stack
-
-	void battleAttack(const BattleAttack *ba) OVERRIDE; //called when stack is performing attack
-	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) OVERRIDE; //called when stack receives damage (after battleAttack())
-	void battleEnd(const BattleResult *br) OVERRIDE;
-	//void battleResultsApplied() OVERRIDE; //called when all effects of last battle are applied
-	void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied;
-	void battleNewRound(int round) OVERRIDE; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
-	void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) OVERRIDE;
-	void battleSpellCast(const BattleSpellCast *sc) OVERRIDE;
-	void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE;//called when a specific effect is set to stacks
-	//void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE;
-	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE; //called by engine when battle starts; side=0 - left, side=1 - right
-	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
-	void battleNewStackAppeared(const CStack * stack) OVERRIDE; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
-	void battleObstaclesRemoved(const std::set<si32> & removedObstacles) OVERRIDE; //called when a certain set  of obstacles is removed from batlefield; IDs of them are given
-	void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack
-	void battleStacksRemoved(const BattleStacksRemoved & bsr) OVERRIDE; //called when certain stack is completely removed from battlefield
+	void init(shared_ptr<CBattleCallback> CB) override;
+	void actionFinished(const BattleAction &action) override;//occurs AFTER every action taken by any stack or by the hero
+	void actionStarted(const BattleAction &action) override;//occurs BEFORE every action taken by any stack or by the hero
+	BattleAction activeStack(const CStack * stack) override; //called when it's turn of that stack
+
+	void battleAttack(const BattleAttack *ba) override; //called when stack is performing attack
+	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) override; //called when stack receives damage (after battleAttack())
+	void battleEnd(const BattleResult *br) override;
+	//void battleResultsApplied() override; //called when all effects of last battle are applied
+	void battleNewRoundFirst(int round) override; //called at the beginning of each turn before changes are applied;
+	void battleNewRound(int round) override; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
+	void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) override;
+	void battleSpellCast(const BattleSpellCast *sc) override;
+	void battleStacksEffectsSet(const SetStackEffect & sse) override;//called when a specific effect is set to stacks
+	//void battleTriggerEffect(const BattleTriggerEffect & bte) override;
+	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) override; //called by engine when battle starts; side=0 - left, side=1 - right
+	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp
+	void battleNewStackAppeared(const CStack * stack) override; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
+	void battleObstaclesRemoved(const std::set<si32> & removedObstacles) override; //called when a certain set  of obstacles is removed from batlefield; IDs of them are given
+	void battleCatapultAttacked(const CatapultAttack & ca) override; //called when catapult makes an attack
+	void battleStacksRemoved(const BattleStacksRemoved & bsr) override; //called when certain stack is completely removed from battlefield
 
 	BattleAction goTowards(const CStack * stack, BattleHex hex );
 
-	virtual void saveGame(COSer<CSaveFile> &h, const int version) OVERRIDE;
-	virtual void loadGame(CISer<CLoadFile> &h, const int version) OVERRIDE;
+	virtual void saveGame(COSer<CSaveFile> &h, const int version) override;
+	virtual void loadGame(CISer<CLoadFile> &h, const int version) override;
 
 };
 

+ 0 - 11
AI/VCAI/StdInc.h

@@ -1,15 +1,4 @@
 #pragma  once
 #include "../../Global.h"
-#include <cassert>
-#include <boost/lexical_cast.hpp>
-#include <boost/format.hpp>
-#include <boost/range/algorithm.hpp>
-#include <boost/type_traits.hpp>
-
-#include <boost/foreach.hpp>
-#include <boost/thread/tss.hpp>
 
 #include "Fuzzy.h"
-
-#include <fstream>
-#include <queue>

+ 22 - 19
AI/VCAI/VCAI.cpp

@@ -140,8 +140,8 @@ void removeDuplicates(std::vector<T> &vec)
 
 struct AtScopeExit
 {
-	boost::function<void()> foo;
-	AtScopeExit(const boost::function<void()> &FOO) : foo(FOO)
+	std::function<void()> foo;
+	AtScopeExit(const std::function<void()> &FOO) : foo(FOO)
 	{}
 	~AtScopeExit()
 	{
@@ -149,7 +149,7 @@ struct AtScopeExit
 	}
 };
 
-void foreach_tile_pos(boost::function<void(const int3& pos)> foo)
+void foreach_tile_pos(std::function<void(const int3& pos)> foo)
 {
 	for(int i = 0; i < cb->getMapSize().x; i++)
 		for(int j = 0; j < cb->getMapSize().y; j++)
@@ -157,7 +157,7 @@ void foreach_tile_pos(boost::function<void(const int3& pos)> foo)
 				foo(int3(i,j,k));
 }
 
-void foreach_neighbour(const int3 &pos, boost::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)
 	{
@@ -177,7 +177,7 @@ const unsigned char &retreiveTileN(const std::vector< std::vector< std::vector<u
 	return vectors[pos.x][pos.y][pos.z];
 }
 
-void foreach_tile(std::vector< std::vector< std::vector<unsigned char> > > &vectors, boost::function<void(unsigned char &in)> foo)
+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++)
@@ -323,7 +323,10 @@ ui64 evaluateDanger(crint3 tile, const CGHeroInstance *visitor)
 	auto visitableObjects = cb->getVisitableObjs(tile);
 	// in some scenarios hero happens to be "under" the object (eg town). Then we consider ONLY the hero.
 	if(vstd::contains_if(visitableObjects, objWithID<Obj::HERO>))
-		erase_if(visitableObjects, ! boost::bind(objWithID<Obj::HERO>, _1));
+		erase_if(visitableObjects, [](const CGObjectInstance * obj)
+		{
+			return !objWithID<Obj::HERO>(obj);
+		});
 
 	if(const CGObjectInstance * dangerousObject = backOrNull(visitableObjects))
 	{
@@ -532,7 +535,7 @@ void VCAI::gameOver(PlayerColor player, bool victory)
 // 		{
 // 			//play dirty: crash the whole engine to avoid lose
 // 			//that way AI is unbeatable!
-// 			*(int*)NULL = 666;
+// 			*(int*)nullptr = 666;
 // 		}
 
 // 		TODO - at least write some insults on stdout
@@ -579,7 +582,7 @@ void VCAI::heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visi
 	}
 }
 
-void VCAI::availableArtifactsChanged(const CGBlackMarket *bm /*= NULL*/)
+void VCAI::availableArtifactsChanged(const CGBlackMarket *bm /*= nullptr*/)
 {
 	LOG_TRACE(logAi);
 	NET_EVENT_HANDLER;
@@ -1560,7 +1563,7 @@ void VCAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int
 	NET_EVENT_HANDLER;
 	assert(playerID > PlayerColor::PLAYER_LIMIT || status.getBattle() == UPCOMING_BATTLE);
 	status.setBattle(ONGOING_BATTLE);
-	const CGObjectInstance *presumedEnemy = backOrNull(cb->getVisitableObjs(tile)); //may be NULL in some very are cases -> eg. visited monolith and fighting with an enemy at the FoW covered exit
+	const CGObjectInstance *presumedEnemy = backOrNull(cb->getVisitableObjs(tile)); //may be nullptr in some very are cases -> eg. visited monolith and fighting with an enemy at the FoW covered exit
 	battlename = boost::str(boost::format("Starting battle of %s attacking %s at %s") % (hero1 ? hero1->name : "a army") % (presumedEnemy ? presumedEnemy->hoverName : "unknown enemy") % tile);
 	CAdventureAI::battleStart(army1, army2, tile, hero1, hero2, side);
 }
@@ -1649,7 +1652,7 @@ const CGObjectInstance * VCAI::lookForArt(int aid) const
 			return obj;
 	}
 
-	return NULL;
+	return nullptr;
 
 	//TODO what if more than one artifact is available? return them all or some slection criteria
 }
@@ -1673,17 +1676,17 @@ HeroPtr VCAI::getHeroWithGrail() const
 		if(h->hasArt(2)) //grail
 			return h;
 
-	return NULL;
+	return nullptr;
 }
 
-const CGObjectInstance * VCAI::getUnvisitedObj(const boost::function<bool(const CGObjectInstance *)> &predicate)
+const CGObjectInstance * VCAI::getUnvisitedObj(const std::function<bool(const CGObjectInstance *)> &predicate)
 {
 	//TODO smarter definition of unvisited
 	BOOST_FOREACH(const CGObjectInstance *obj, visitableObjs)
 		if(predicate(obj) && !vstd::contains(alreadyVisited, obj))
 			return obj;
 
-	return NULL;
+	return nullptr;
 }
 
 bool VCAI::isAccessibleForHero(const int3 & pos, HeroPtr h, bool includeAllies /*= false*/) const
@@ -1986,7 +1989,7 @@ const CGTownInstance * VCAI::findTownWithTavern() const
 		if(t->hasBuilt(BuildingID::TAVERN) && !t->visitingHero)
 			return t;
 
-	return NULL;
+	return nullptr;
 }
 
 std::vector<HeroPtr> VCAI::getUnblockedHeroes() const
@@ -2009,7 +2012,7 @@ HeroPtr VCAI::primaryHero() const
 	boost::sort(hs, compareHeroStrength);
 
 	if(hs.empty())
-		return NULL;
+		return nullptr;
 
 	return hs.back();
 }
@@ -2498,7 +2501,7 @@ void VCAI::finish()
 		makingTurn->interrupt();
 }
 
-void VCAI::requestActionASAP(boost::function<void()> whatToDo)
+void VCAI::requestActionASAP(std::function<void()> whatToDo)
 {
 // 	static boost::mutex m;
 // 	boost::unique_lock<boost::mutex> mylock(m);
@@ -2834,7 +2837,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 		break;
 	case FIND_OBJ:
 		{
-			const CGObjectInstance * o = NULL;
+			const CGObjectInstance * o = nullptr;
 			if (resID > -1) //specified
 			{
 				BOOST_FOREACH(const CGObjectInstance *obj, ai->visitableObjs)
@@ -3071,7 +3074,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 				return CGoal(EXPLORE);
 
 			if(hero && !ai->isAccessibleForHero(tile, hero))
-				hero = NULL;
+				hero = nullptr;
 
 			if(!hero)
 			{
@@ -3384,7 +3387,7 @@ TSubgoal CGoal::whatToDoToAchieve()
 				else
 				{
 					boost::sort(objs, isCloser);
-					HeroPtr h = NULL;
+					HeroPtr h = nullptr;
 					BOOST_FOREACH(const CGObjectInstance *obj, objs)
 					{ //find safe dwelling
 						auto pos = obj->visitablePos();

+ 72 - 72
AI/VCAI/VCAI.h

@@ -154,12 +154,12 @@ struct CGoal
 		aid = -1;
 		resID = -1;
 		tile = int3(-1, -1, -1);
-		town = NULL;
+		town = nullptr;
 	}
 
 	bool invalid() const;
 
-	static TSubgoal goVisitOrLookFor(const CGObjectInstance *obj); //if obj is NULL, then we'll explore
+	static TSubgoal goVisitOrLookFor(const CGObjectInstance *obj); //if obj is nullptr, then we'll explore
 	static TSubgoal lookForArtSmart(int aid); //checks non-standard ways of obtaining art (merchants, quests, etc.)
 	static TSubgoal tryRecruitHero();
 
@@ -229,9 +229,9 @@ struct SectorMap
 
 struct CIssueCommand : CGoal
 {
-	boost::function<bool()> command;
+	std::function<bool()> command;
 
-	CIssueCommand(boost::function<bool()> _command): CGoal(ISSUE_COMMAND), command(_command) {}
+	CIssueCommand(std::function<bool()> _command): CGoal(ISSUE_COMMAND), command(_command) {}
 };
 
 
@@ -304,69 +304,69 @@ public:
 	int3 explorationNewPoint(int radius, HeroPtr h, std::vector<std::vector<int3> > &tiles);
 	void recruitHero();
 
-	virtual std::string getBattleAIName() const OVERRIDE;
-
-	virtual void init(shared_ptr<CCallback> CB) OVERRIDE;
-	virtual void yourTurn() OVERRIDE;
-
-	virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) OVERRIDE; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
-	virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) OVERRIDE; //TODO
-	virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) OVERRIDE; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
-	virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) OVERRIDE; //all stacks operations between these objects become allowed, interface has to call onEnd when done
-	virtual void saveGame(COSer<CSaveFile> &h, const int version) OVERRIDE; //saving
-	virtual void loadGame(CISer<CLoadFile> &h, const int version) OVERRIDE; //loading
-	virtual void finish() OVERRIDE;
-
-	virtual void availableCreaturesChanged(const CGDwelling *town) OVERRIDE;
-	virtual void heroMoved(const TryMoveHero & details) OVERRIDE;
-	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 artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) OVERRIDE;
-	virtual void artifactAssembled(const ArtifactLocation &al) OVERRIDE;
-	virtual void showTavernWindow(const CGObjectInstance *townOrTavern) OVERRIDE;
-	virtual void showThievesGuildWindow (const CGObjectInstance * obj) OVERRIDE;
-	virtual void playerBlocked(int reason) OVERRIDE;
-	virtual void showPuzzleMap() OVERRIDE;
-	virtual void showShipyardDialog(const IShipyard *obj) OVERRIDE;
-	virtual void gameOver(PlayerColor player, bool victory) OVERRIDE;
-	virtual void artifactPut(const ArtifactLocation &al) OVERRIDE;
-	virtual void artifactRemoved(const ArtifactLocation &al) OVERRIDE;
-	virtual void stacksErased(const StackLocation &location) OVERRIDE;
-	virtual void artifactDisassembled(const ArtifactLocation &al) OVERRIDE;
-	virtual void heroVisit(const CGHeroInstance *visitor, const CGObjectInstance *visitedObj, bool start) OVERRIDE;
-	virtual void availableArtifactsChanged(const CGBlackMarket *bm = NULL) OVERRIDE;
-	virtual void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town) OVERRIDE;
-	virtual void tileRevealed(const boost::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;
-	virtual void heroMovePointsChanged(const CGHeroInstance * hero) OVERRIDE;
-	virtual void stackChangedType(const StackLocation &location, const CCreature &newType) OVERRIDE;
-	virtual void stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count) OVERRIDE;
-	virtual void newObject(const CGObjectInstance * obj) OVERRIDE;
-	virtual void showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor) OVERRIDE;
-	virtual void playerBonusChanged(const Bonus &bonus, bool gain) OVERRIDE;
-	virtual void newStackInserted(const StackLocation &location, const CStackInstance &stack) OVERRIDE;
-	virtual void heroCreated(const CGHeroInstance*) OVERRIDE;
-	virtual void advmapSpellCast(const CGHeroInstance * caster, int spellID) OVERRIDE;
-	virtual void showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID) OVERRIDE;
-	virtual void requestRealized(PackageApplied *pa) OVERRIDE;
-	virtual void receivedResource(int type, int val) OVERRIDE;
-	virtual void stacksSwapped(const StackLocation &loc1, const StackLocation &loc2) OVERRIDE;
-	virtual void objectRemoved(const CGObjectInstance *obj) OVERRIDE;
-	virtual void showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor) OVERRIDE;
-	virtual void heroManaPointsChanged(const CGHeroInstance * hero) OVERRIDE;
-	virtual void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) OVERRIDE;
-	virtual void battleResultsApplied() OVERRIDE;
-	virtual void objectPropertyChanged(const SetObjectProperty * sop) OVERRIDE;
-	virtual void buildChanged(const CGTownInstance *town, BuildingID buildingID, int what) OVERRIDE;
-	virtual void heroBonusChanged(const CGHeroInstance *hero, const Bonus &bonus, bool gain) OVERRIDE;
-	virtual void showMarketWindow(const IMarket *market, const CGHeroInstance *visitor) OVERRIDE;
-
-	virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE;
-	virtual void battleEnd(const BattleResult *br) OVERRIDE;
+	virtual std::string getBattleAIName() const override;
+
+	virtual void init(shared_ptr<CCallback> CB) override;
+	virtual void yourTurn() override;
+
+	virtual void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override; //pskill is gained primary skill, interface has to choose one of given skills and call callback with selection id
+	virtual void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override; //TODO
+	virtual void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, const int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
+	virtual void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override; //all stacks operations between these objects become allowed, interface has to call onEnd when done
+	virtual void saveGame(COSer<CSaveFile> &h, const int version) override; //saving
+	virtual void loadGame(CISer<CLoadFile> &h, const int version) override; //loading
+	virtual void finish() override;
+
+	virtual void availableCreaturesChanged(const CGDwelling *town) override;
+	virtual void heroMoved(const TryMoveHero & details) override;
+	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 artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst) override;
+	virtual void artifactAssembled(const ArtifactLocation &al) override;
+	virtual void showTavernWindow(const CGObjectInstance *townOrTavern) override;
+	virtual void showThievesGuildWindow (const CGObjectInstance * obj) override;
+	virtual void playerBlocked(int reason) override;
+	virtual void showPuzzleMap() override;
+	virtual void showShipyardDialog(const IShipyard *obj) override;
+	virtual void gameOver(PlayerColor player, bool victory) override;
+	virtual void artifactPut(const ArtifactLocation &al) override;
+	virtual void artifactRemoved(const ArtifactLocation &al) override;
+	virtual void stacksErased(const StackLocation &location) override;
+	virtual void artifactDisassembled(const ArtifactLocation &al) override;
+	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 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;
+	virtual void heroMovePointsChanged(const CGHeroInstance * hero) override;
+	virtual void stackChangedType(const StackLocation &location, const CCreature &newType) override;
+	virtual void stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count) override;
+	virtual void newObject(const CGObjectInstance * obj) override;
+	virtual void showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor) override;
+	virtual void playerBonusChanged(const Bonus &bonus, bool gain) override;
+	virtual void newStackInserted(const StackLocation &location, const CStackInstance &stack) override;
+	virtual void heroCreated(const CGHeroInstance*) override;
+	virtual void advmapSpellCast(const CGHeroInstance * caster, int spellID) override;
+	virtual void showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID) override;
+	virtual void requestRealized(PackageApplied *pa) override;
+	virtual void receivedResource(int type, int val) override;
+	virtual void stacksSwapped(const StackLocation &loc1, const StackLocation &loc2) override;
+	virtual void objectRemoved(const CGObjectInstance *obj) override;
+	virtual void showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor) override;
+	virtual void heroManaPointsChanged(const CGHeroInstance * hero) override;
+	virtual void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) override;
+	virtual void battleResultsApplied() override;
+	virtual void objectPropertyChanged(const SetObjectProperty * sop) override;
+	virtual void buildChanged(const CGTownInstance *town, BuildingID buildingID, int what) override;
+	virtual void heroBonusChanged(const CGHeroInstance *hero, const Bonus &bonus, bool gain) override;
+	virtual void showMarketWindow(const IMarket *market, const CGHeroInstance *visitor) override;
+
+	virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) override;
+	virtual void battleEnd(const BattleResult *br) override;
 	void makeTurn();
 
 	void makeTurnInternal();
@@ -413,7 +413,7 @@ public:
 	bool isAccessible(const int3 &pos);
 	HeroPtr getHeroWithGrail() const;
 
-	const CGObjectInstance *getUnvisitedObj(const boost::function<bool(const CGObjectInstance *)> &predicate);
+	const CGObjectInstance *getUnvisitedObj(const std::function<bool(const CGObjectInstance *)> &predicate);
 	bool isAccessibleForHero(const int3 & pos, HeroPtr h, bool includeAllies = false) const;
 
 	const CGTownInstance *findTownWithTavern() const;
@@ -424,10 +424,10 @@ public:
 	bool containsSavedRes(const TResources &cost) const;
 	void checkHeroArmy (HeroPtr h);
 
-	void requestSent(const CPackForServer *pack, int requestID) OVERRIDE;
+	void requestSent(const CPackForServer *pack, int requestID) override;
 	void answerQuery(QueryID queryID, int selection);
 	//special function that can be called ONLY from game events handling thread and will send request ASAP
-	void requestActionASAP(boost::function<void()> whatToDo); 
+	void requestActionASAP(std::function<void()> whatToDo); 
 
 
 	template <typename Handler> void serializeInternal(Handler &h, const int version)
@@ -453,7 +453,7 @@ public:
 	{
 	};
 
-	const char *what() const throw () OVERRIDE
+	const char *what() const throw () override
 	{
 		return msg.c_str();
 	}
@@ -471,7 +471,7 @@ public:
 	{
 	};
 
-	const char *what() const throw () OVERRIDE
+	const char *what() const throw () override
 	{
 		return goal.name().c_str();
 	}

+ 1 - 1
CCallback.cpp

@@ -216,7 +216,7 @@ void CCallback::buyArtifact(const CGHeroInstance *hero, ArtifactID aid)
 	sendRequest(&pack);
 }
 
-void CCallback::trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero/* = NULL*/)
+void CCallback::trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero/* = nullptr*/)
 {
 	TradeOnMarketplace pack;
 	pack.market = market;

+ 7 - 7
CCallback.h

@@ -56,7 +56,7 @@ public:
 	virtual bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE)=0; //if newID==-1 then best possible upgrade will be made
 	virtual void swapGarrisonHero(const CGTownInstance *town)=0;
 
-	virtual void trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
+	virtual void trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero = nullptr)=0; //mode==0: sell val1 units of id1 resource for id2 resiurce
 
 	virtual int selectionMade(int selection, QueryID queryID) =0;
 	virtual int swapCreatures(const CArmedInstance *s1, const CArmedInstance *s2, SlotID p1, SlotID p2)=0;//swaps creatures between two possibly different garrisons // TODO: AI-unsafe code - fix it!
@@ -89,8 +89,8 @@ protected:
 
 public:
 	CBattleCallback(CGameState *GS, boost::optional<PlayerColor> Player, CClient *C);
-	int battleMakeAction(BattleAction* action) OVERRIDE;//for casting spells by hero - DO NOT use it for moving active stack
-	bool battleMakeTacticAction(BattleAction * action) OVERRIDE; // performs tactic phase actions
+	int battleMakeAction(BattleAction* action) override;//for casting spells by hero - DO NOT use it for moving active stack
+	bool battleMakeTacticAction(BattleAction * action) override; // performs tactic phase actions
 
 	friend class CCallback;
 	friend class CClient;
@@ -135,14 +135,14 @@ public:
 	//bool moveArtifact(const CGHeroInstance * hero, ui16 src, const CStackInstance * stack, ui16 dest); // TODO: unify classes
 	//bool moveArtifact(const CStackInstance * stack, ui16 src , const CGHeroInstance * hero, ui16 dest); // TODO: unify classes
 	bool assembleArtifacts(const CGHeroInstance * hero, ArtifactPosition artifactSlot, bool assemble, ArtifactID assembleTo);
-	bool buildBuilding(const CGTownInstance *town, BuildingID buildingID) OVERRIDE;
+	bool buildBuilding(const CGTownInstance *town, BuildingID buildingID) override;
 	void recruitCreatures(const CGObjectInstance *obj, CreatureID ID, ui32 amount, si32 level=-1);
 	bool dismissCreature(const CArmedInstance *obj, SlotID stackPos);
-	bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE) OVERRIDE;
+	bool upgradeCreature(const CArmedInstance *obj, SlotID stackPos, CreatureID newID=CreatureID::NONE) override;
 	void endTurn();
 	void swapGarrisonHero(const CGTownInstance *town);
-	void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) OVERRIDE;
-	void trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero = NULL);
+	void buyArtifact(const CGHeroInstance *hero, ArtifactID aid) override;
+	void trade(const CGObjectInstance *market, EMarketMode::EMarketMode mode, int id1, int id2, int val1, const CGHeroInstance *hero = nullptr);
 	void setFormation(const CGHeroInstance * hero, bool tight);
 	void setSelection(const CArmedInstance * obj);
 	void recruitHero(const CGObjectInstance *townOrTavern, const CGHeroInstance *hero);

+ 34 - 46
Global.h

@@ -35,23 +35,20 @@ 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
-#if defined(__clang__) || (defined(__GNUC__) && (GCC_VERSION >= 440))
+#if defined(__clang__) || defined(__GNUC__)
 #define CPP11_USE_INITIALIZERS_LIST
 #endif
 
-//nullptr -  only msvc and gcc-4.6 or later, othervice define it  as NULL
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && (GCC_VERSION >= 460)) && !(defined(__clang__))
+//nullptr -  only msvc and gcc-4.6 or later, othervice define it  as nullptr
+#if (defined(__GNUC__)) && (GCC_VERSION < 460)
 #define nullptr NULL
 #endif
 
 //override keyword - only msvc and gcc-4.7 or later.
-#if !defined(_MSC_VER) && !(defined(__GNUC__) && (GCC_VERSION >= 470)) && !(defined(__clang__))
+#if !defined(_MSC_VER) && !defined(__clang__) && !(defined(__GNUC__) && (GCC_VERSION >= 470))
 #define override
 #endif
 
-//workaround to support existing code
-#define OVERRIDE override
-
 /* ---------------------------------------------------------------------------- */
 /* Suppress some compiler warnings */
 /* ---------------------------------------------------------------------------- */
@@ -72,6 +69,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <climits>
 #include <cmath>
 #include <cstdlib>
+#include <functional>
 #include <fstream>
 #include <iomanip>
 #include <iostream>
@@ -79,6 +77,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <memory>
 #include <numeric>
 #include <queue>
+#include <random>
 #include <set>
 #include <sstream>
 #include <string>
@@ -93,12 +92,11 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #define BOOST_THREAD_VERSION 3
 #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/assert.hpp>
 #include <boost/assign.hpp>
-#include <boost/bind.hpp>
 #include <boost/cstdint.hpp>
 #include <boost/current_function.hpp>
 #include <boost/date_time/posix_time/posix_time.hpp>
@@ -106,17 +104,15 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 #include <boost/filesystem.hpp>
 #include <boost/foreach.hpp>
 #include <boost/format.hpp>
-#include <boost/function.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/logic/tribool.hpp>
-#include <boost/program_options.hpp>
 #include <boost/optional.hpp>
-#include <boost/range/algorithm.hpp>
+#include <boost/program_options.hpp>
 #include <boost/range/adaptor/filtered.hpp>
+#include <boost/range/algorithm.hpp>
 #include <boost/thread.hpp>
 #include <boost/unordered_map.hpp>
 #include <boost/unordered_set.hpp>
-#include <boost/unordered_map.hpp>
 #include <boost/variant.hpp>
 
 #ifdef ANDROID
@@ -129,6 +125,7 @@ static_assert(sizeof(bool) == 1, "Bool needs to be 1 byte in size.");
 using std::shared_ptr;
 using std::unique_ptr;
 using std::make_shared;
+using namespace std::placeholders;
 namespace range = boost::range;
 
 /* ---------------------------------------------------------------------------- */
@@ -153,37 +150,33 @@ typedef boost::lock_guard<boost::recursive_mutex> TLockGuardRec;
 /* ---------------------------------------------------------------------------- */
 // Import + Export macro declarations
 #ifdef _WIN32
-#ifdef __GNUC__
-#define DLL_EXPORT __attribute__((dllexport))
-#else
-#define DLL_EXPORT __declspec(dllexport)
-#endif
+#  ifdef __GNUC__
+#    define DLL_EXPORT __attribute__((dllexport))
+#  else
+#    define DLL_EXPORT __declspec(dllexport)
+#  endif
 #else
-#if defined(__GNUC__) && GCC_VERSION >= 400
-#define DLL_EXPORT	__attribute__ ((visibility("default")))
-#else
-#define DLL_EXPORT
-#endif
+#  ifdef __GNUC__
+#    define DLL_EXPORT	__attribute__ ((visibility("default")))
+#  endif
 #endif
 
 #ifdef _WIN32
-#ifdef __GNUC__
-#define DLL_IMPORT __attribute__((dllimport))
+#  ifdef __GNUC__
+#    define DLL_IMPORT __attribute__((dllimport))
+#  else
+#    define DLL_IMPORT __declspec(dllimport)
+#  endif
 #else
-#define DLL_IMPORT __declspec(dllimport)
-#endif
-#else
-#if defined(__GNUC__) && GCC_VERSION >= 400
-#define DLL_IMPORT	__attribute__ ((visibility("default")))
-#else
-#define DLL_IMPORT
-#endif
+#  ifdef __GNUC__
+#    define DLL_IMPORT	__attribute__ ((visibility("default")))
+#  endif
 #endif
 
 #ifdef VCMI_DLL
-#define DLL_LINKAGE DLL_EXPORT
+#  define DLL_LINKAGE DLL_EXPORT
 #else
-#define DLL_LINKAGE DLL_IMPORT
+#  define DLL_LINKAGE DLL_IMPORT
 #endif
 
 #define THROW_FORMAT(message, formatting_elems)  throw std::runtime_error(boost::str(boost::format(message) % formatting_elems))
@@ -246,11 +239,6 @@ public:
 
 	bmap()
 	{}
-#if 0 // What is _Myt? gcc\clang does not have that
-	bmap(const typename std::map<KeyT, ValT>::_Myt& _Right)
-		: std::map<KeyT, ValT>(_Right)
-	{}
-#endif
 	explicit bmap(const typename std::map<KeyT, ValT>::key_compare& _Pred)
 		: std::map<KeyT, ValT>(_Pred)
 	{}
@@ -439,12 +427,12 @@ namespace vstd
 		return assigner<t1,t2>(a1,a2);
 	}
 
-	//deleted pointer and sets it to NULL
+	//deleted pointer and sets it to nullptr
 	template <typename T>
 	void clear_pointer(T* &ptr)
 	{
 		delete ptr;
-		ptr = NULL;
+		ptr = nullptr;
 	}
 
 	template<typename T>
@@ -550,7 +538,7 @@ namespace vstd
 		});
 	}
 
-	static inline int retreiveRandNum(const boost::function<int()> &randGen)
+	static inline int retreiveRandNum(const std::function<int()> &randGen)
 	{
 		if (randGen)
 			return randGen();
@@ -558,7 +546,7 @@ namespace vstd
 			return rand();
 	}
 
-	template <typename T> const T & pickRandomElementOf(const std::vector<T> &v, const boost::function<int()> &randGen)
+	template <typename T> const T & pickRandomElementOf(const std::vector<T> &v, const std::function<int()> &randGen)
 	{
 		return v.at(retreiveRandNum(randGen) % v.size());
 	}
@@ -570,7 +558,7 @@ namespace vstd
 	}
 
 	template <typename Container>
-	typename Container::value_type backOrNull(const Container &c) //returns last element of container or NULL if it is empty (to be used with containers of pointers)
+	typename Container::value_type backOrNull(const Container &c) //returns last element of container or nullptr if it is empty (to be used with containers of pointers)
 	{
 		if(c.size())
 			return c.back();
@@ -579,7 +567,7 @@ namespace vstd
 	}
 
 	template <typename Container>
-	typename Container::value_type frontOrNull(const Container &c) //returns first element of container or NULL if it is empty (to be used with containers of pointers)
+	typename Container::value_type frontOrNull(const Container &c) //returns first element of container or nullptr if it is empty (to be used with containers of pointers)
 	{
 		if(c.size())
 			return c.front();

+ 6 - 6
client/AdventureMapClasses.cpp

@@ -97,11 +97,11 @@ CList::CList(int Size, Point position, std::string btnUp, std::string btnDown, s
 	list = new CListBox(create, destroy, Point(1,scrollUp->pos.h), Point(0, 32), size, listAmount);
 
 	//assign callback only after list was created
-	scrollUp->callback = boost::bind(&CListBox::moveToPrev, list);
-	scrollDown = new CAdventureMapButton(CGI->generaltexth->zelp[helpDown], boost::bind(&CListBox::moveToNext, list), 0, scrollUp->pos.h + 32*size, btnDown);
+	scrollUp->callback = std::bind(&CListBox::moveToPrev, list);
+	scrollDown = new CAdventureMapButton(CGI->generaltexth->zelp[helpDown], std::bind(&CListBox::moveToNext, list), 0, scrollUp->pos.h + 32*size, btnDown);
 
-	scrollDown->callback += boost::bind(&CList::update, this);
-	scrollUp->callback += boost::bind(&CList::update, this);
+	scrollDown->callback += std::bind(&CList::update, this);
+	scrollUp->callback += std::bind(&CList::update, this);
 
 	update();
 }
@@ -236,7 +236,7 @@ CIntObject * CHeroList::createHeroItem(size_t index)
 }
 
 CHeroList::CHeroList(int size, Point position, std::string btnUp, std::string btnDown):
-    CList(size, position, btnUp, btnDown, LOCPLINT->wanderingHeroes.size(), 303, 304, boost::bind(&CHeroList::createHeroItem, this, _1))
+    CList(size, position, btnUp, btnDown, LOCPLINT->wanderingHeroes.size(), 303, 304, std::bind(&CHeroList::createHeroItem, this, _1))
 {
 }
 
@@ -321,7 +321,7 @@ std::string CTownList::CTownItem::getHoverText()
 }
 
 CTownList::CTownList(int size, Point position, std::string btnUp, std::string btnDown):
-    CList(size, position, btnUp, btnDown, LOCPLINT->towns.size(),  306, 307, boost::bind(&CTownList::createTownItem, this, _1))
+    CList(size, position, btnUp, btnDown, LOCPLINT->towns.size(),  306, 307, std::bind(&CTownList::createTownItem, this, _1))
 {
 }
 

+ 43 - 39
client/CAdvmapInterface.cpp

@@ -55,7 +55,7 @@ CAdvMapInt *adventureInt;
 
 
 CTerrainRect::CTerrainRect()
-	:curHoveredTile(-1,-1,-1), currentPath(NULL)
+	:curHoveredTile(-1,-1,-1), currentPath(nullptr)
 {
 	tilesw=(ADVOPT.advmapW+31)/32;
 	tilesh=(ADVOPT.advmapH+31)/32;
@@ -199,7 +199,7 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
 				if (hvx<0 && hvy<0)
 				{
 					Rect dstRect = genRect(32, 32, x + moveX, y + moveY);
-					CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &dstRect);
+					CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, nullptr, to, &dstRect);
 				}
 				else if(hvx<0)
 				{
@@ -225,7 +225,7 @@ void CTerrainRect::showPath(const SDL_Rect * extRect, SDL_Surface * to)
 				if (hvx<0 && hvy<0)
 				{
 					Rect dstRect = genRect(32, 32, x, y);
-					CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, NULL, to, &dstRect);
+					CSDL_Ext::blit8bppAlphaTo24bpp(arrows->ourImages[pn].bitmap, nullptr, to, &dstRect);
 				}
 				else if(hvx<0)
 				{
@@ -364,34 +364,34 @@ CAdvMapInt::CAdvMapInt():
     minimap(Rect(ADVOPT.minimapX, ADVOPT.minimapY, ADVOPT.minimapW, ADVOPT.minimapH)),
 statusbar(ADVOPT.statusbarX,ADVOPT.statusbarY,ADVOPT.statusbarG),
 kingOverview(CGI->generaltexth->zelp[293].first,CGI->generaltexth->zelp[293].second,
-			 boost::bind(&CAdvMapInt::fshowOverview,this),&ADVOPT.kingOverview, SDLK_k),
+			 std::bind(&CAdvMapInt::fshowOverview,this),&ADVOPT.kingOverview, SDLK_k),
 
 underground(CGI->generaltexth->zelp[294].first,CGI->generaltexth->zelp[294].second,
-			boost::bind(&CAdvMapInt::fswitchLevel,this),&ADVOPT.underground, SDLK_u),
+			std::bind(&CAdvMapInt::fswitchLevel,this),&ADVOPT.underground, SDLK_u),
 
 questlog(CGI->generaltexth->zelp[295].first,CGI->generaltexth->zelp[295].second,
-		 boost::bind(&CAdvMapInt::fshowQuestlog,this),&ADVOPT.questlog, SDLK_q),
+		 std::bind(&CAdvMapInt::fshowQuestlog,this),&ADVOPT.questlog, SDLK_q),
 
 sleepWake(CGI->generaltexth->zelp[296].first,CGI->generaltexth->zelp[296].second,
-		  boost::bind(&CAdvMapInt::fsleepWake,this), &ADVOPT.sleepWake, SDLK_w),
+		  std::bind(&CAdvMapInt::fsleepWake,this), &ADVOPT.sleepWake, SDLK_w),
 
 moveHero(CGI->generaltexth->zelp[297].first,CGI->generaltexth->zelp[297].second,
-		  boost::bind(&CAdvMapInt::fmoveHero,this), &ADVOPT.moveHero, SDLK_m),
+		  std::bind(&CAdvMapInt::fmoveHero,this), &ADVOPT.moveHero, SDLK_m),
 
 spellbook(CGI->generaltexth->zelp[298].first,CGI->generaltexth->zelp[298].second,
-		  boost::bind(&CAdvMapInt::fshowSpellbok,this), &ADVOPT.spellbook, SDLK_c),
+		  std::bind(&CAdvMapInt::fshowSpellbok,this), &ADVOPT.spellbook, SDLK_c),
 
 advOptions(CGI->generaltexth->zelp[299].first,CGI->generaltexth->zelp[299].second,
-		  boost::bind(&CAdvMapInt::fadventureOPtions,this), &ADVOPT.advOptions, SDLK_a),
+		  std::bind(&CAdvMapInt::fadventureOPtions,this), &ADVOPT.advOptions, SDLK_a),
 
 sysOptions(CGI->generaltexth->zelp[300].first,CGI->generaltexth->zelp[300].second,
-		  boost::bind(&CAdvMapInt::fsystemOptions,this), &ADVOPT.sysOptions, SDLK_o),
+		  std::bind(&CAdvMapInt::fsystemOptions,this), &ADVOPT.sysOptions, SDLK_o),
 
 nextHero(CGI->generaltexth->zelp[301].first,CGI->generaltexth->zelp[301].second,
-		  boost::bind(&CAdvMapInt::fnextHero,this), &ADVOPT.nextHero, SDLK_h),
+		  std::bind(&CAdvMapInt::fnextHero,this), &ADVOPT.nextHero, SDLK_h),
 
 endTurn(CGI->generaltexth->zelp[302].first,CGI->generaltexth->zelp[302].second,
-		  boost::bind(&CAdvMapInt::fendTurn,this), &ADVOPT.endTurn, SDLK_e),
+		  std::bind(&CAdvMapInt::fendTurn,this), &ADVOPT.endTurn, SDLK_e),
 
 heroList(ADVOPT.hlistSize, Point(ADVOPT.hlistX, ADVOPT.hlistY), ADVOPT.hlistAU, ADVOPT.hlistAD),
 townList(ADVOPT.tlistSize, Point(ADVOPT.tlistX, ADVOPT.tlistY), ADVOPT.tlistAU, ADVOPT.tlistAD),
@@ -399,12 +399,12 @@ infoBar(Rect(ADVOPT.infoboxX, ADVOPT.infoboxY, 192, 192) )
 {
 	duringAITurn = false;
 	state = NA;
-	spellBeingCasted = NULL;
+	spellBeingCasted = nullptr;
 	pos.x = pos.y = 0;
 	pos.w = screen->w;
 	pos.h = screen->h;
-	selection = NULL;
-	townList.onSelect = boost::bind(&CAdvMapInt::selectionChanged,this);
+	selection = nullptr;
+	townList.onSelect = std::bind(&CAdvMapInt::selectionChanged,this);
 	adventureInt=this;
 	bg = BitmapHandler::loadBitmap(ADVOPT.mainGraphic);
 	scrollingDir = 0;
@@ -527,7 +527,7 @@ void CAdvMapInt::fendTurn()
 		for (int i = 0; i < LOCPLINT->wanderingHeroes.size(); i++)
 			if (!isHeroSleeping(LOCPLINT->wanderingHeroes[i]) && (LOCPLINT->wanderingHeroes[i]->movement > 0))
 			{
-				LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], boost::bind(&CAdvMapInt::endingTurn, this), 0, false);
+				LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[55], std::bind(&CAdvMapInt::endingTurn, this), 0, false);
 				return;
 			}
 	}
@@ -698,7 +698,7 @@ void CAdvMapInt::setHeroSleeping(const CGHeroInstance *hero, bool sleep)
 		LOCPLINT->sleepingHeroes += hero;
 	else
 		LOCPLINT->sleepingHeroes -= hero;
-	updateNextHero(NULL);
+	updateNextHero(nullptr);
 }
 
 void CAdvMapInt::show(SDL_Surface * to)
@@ -721,8 +721,8 @@ void CAdvMapInt::show(SDL_Surface * to)
 	if((animValHitCount % (4/scrollSpeed)) == 0
 		&&  (
 			(GH.topInt() == this)
-			|| SDL_GetKeyState(NULL)[SDLK_LCTRL]
-			|| SDL_GetKeyState(NULL)[SDLK_RCTRL]
+			|| SDL_GetKeyState(nullptr)[SDLK_LCTRL]
+			|| SDL_GetKeyState(nullptr)[SDLK_RCTRL]
 )
 	)
 	{
@@ -799,7 +799,11 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
 
 		{
 			//find first town with tavern
-			auto itr = range::find_if(LOCPLINT->towns, boost::bind(&CGTownInstance::hasBuilt, _1, BuildingID::TAVERN));
+			auto itr = range::find_if(LOCPLINT->towns, [](const CGTownInstance * town)
+			{
+				return town->hasBuilt(BuildingID::TAVERN);
+			});
+
 			if(itr != LOCPLINT->towns.end())
 				LOCPLINT->showThievesGuildWindow(*itr);
 			else
@@ -878,7 +882,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
 			if(LOCPLINT->ctrlPressed()) //CTRL + T => open marketplace
 			{
 				//check if we have any marketplace
-				const CGTownInstance *townWithMarket = NULL;
+				const CGTownInstance *townWithMarket = nullptr;
 				BOOST_FOREACH(const CGTownInstance *t, LOCPLINT->cb->getTownsInfo())
 				{
 					if(t->hasBuilt(BuildingID::MARKETPLACE))
@@ -937,7 +941,7 @@ void CAdvMapInt::keyPressed(const SDL_KeyboardEvent & key)
 			terrain.currentPath = &path;
 			if(!LOCPLINT->cb->getPath2(h->getPosition(false) + dir, path))
 			{
-				terrain.currentPath = NULL;
+				terrain.currentPath = nullptr;
 				return;
 			}
 
@@ -986,7 +990,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
 	assert(sel);
 	LOCPLINT->cb->setSelection(sel);
 	selection = sel;
-	if (LOCPLINT->battleInt == NULL && LOCPLINT->makingTurn)
+	if (LOCPLINT->battleInt == nullptr && LOCPLINT->makingTurn)
 	{
 		auto pos = sel->visitablePos();
 		auto tile = LOCPLINT->cb->getTile(pos);
@@ -996,7 +1000,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
 	if(centerView)
 		centerOn(sel);
 
-	terrain.currentPath = NULL;
+	terrain.currentPath = nullptr;
 	if(sel->ID==Obj::TOWN)
 	{
 		auto town = dynamic_cast<const CGTownInstance*>(sel);
@@ -1005,8 +1009,8 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
 		townList.select(town);
 		heroList.select(nullptr);
 
-		updateSleepWake(NULL);
-		updateMoveHero(NULL);
+		updateSleepWake(nullptr);
+		updateMoveHero(nullptr);
 	}
 	else //hero selected
 	{
@@ -1028,7 +1032,7 @@ void CAdvMapInt::select(const CArmedInstance *sel, bool centerView /*= true*/)
 void CAdvMapInt::mouseMoved( const SDL_MouseMotionEvent & sEvent )
 {
 	//adventure map scrolling with mouse
-	if(!SDL_GetKeyState(NULL)[SDLK_LCTRL]  &&  isActive())
+	if(!SDL_GetKeyState(nullptr)[SDLK_LCTRL]  &&  isActive())
 	{
 		if(sEvent.x<15)
 		{
@@ -1452,7 +1456,7 @@ void CAdvMapInt::leaveCastingMode(bool cast /*= false*/, int3 dest /*= int3(-1,
 {
 	assert(spellBeingCasted);
 	SpellID id = spellBeingCasted->id;
-	spellBeingCasted = NULL;
+	spellBeingCasted = nullptr;
 	terrain.deactivate();
 	activate();
 
@@ -1467,7 +1471,7 @@ const CGHeroInstance * CAdvMapInt::curHero() const
 	if(selection && selection->ID == Obj::HERO)
 		return static_cast<const CGHeroInstance *>(selection);
 	else
-		return NULL;
+		return nullptr;
 }
 
 const CGTownInstance * CAdvMapInt::curTown() const
@@ -1475,7 +1479,7 @@ const CGTownInstance * CAdvMapInt::curTown() const
 	if(selection && selection->ID == Obj::TOWN)
 		return static_cast<const CGTownInstance *>(selection);
 	else
-		return NULL;
+		return nullptr;
 }
 
 const IShipyard * CAdvMapInt::ourInaccessibleShipyard(const CGObjectInstance *obj) const
@@ -1483,7 +1487,7 @@ const IShipyard * CAdvMapInt::ourInaccessibleShipyard(const CGObjectInstance *ob
 	const IShipyard *ret = IShipyard::castFrom(obj);
 
 	if(!ret || obj->tempOwner != player || CCS->curh->type || (CCS->curh->frame != 6 && CCS->curh->frame != 0))
-		return NULL;
+		return nullptr;
 
 	return ret;
 }
@@ -1513,19 +1517,19 @@ CAdventureOptions::CAdventureOptions():
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
-	exit = new CAdventureMapButton("","",boost::bind(&CAdventureOptions::close, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
+	exit = new CAdventureMapButton("","",std::bind(&CAdventureOptions::close, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
 	exit->assignedKeys.insert(SDLK_ESCAPE);
 
-	scenInfo = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 198, "ADVINFO.DEF",SDLK_i);
+	scenInfo = new CAdventureMapButton("","", std::bind(&CAdventureOptions::close, this), 24, 198, "ADVINFO.DEF",SDLK_i);
 	scenInfo->callback += CAdventureOptions::showScenarioInfo;
-	//viewWorld = new CAdventureMapButton("","",boost::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
+	//viewWorld = new CAdventureMapButton("","",std::bind(&CGuiHandler::popIntTotally, &GH, this), 204, 313, "IOK6432.DEF",SDLK_RETURN);
 
-	puzzle = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 81, "ADVPUZ.DEF");
-	puzzle->callback += boost::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT);
+	puzzle = new CAdventureMapButton("","", std::bind(&CAdventureOptions::close, this), 24, 81, "ADVPUZ.DEF");
+	puzzle->callback += std::bind(&CPlayerInterface::showPuzzleMap, LOCPLINT);
 
-	dig = new CAdventureMapButton("","", boost::bind(&CAdventureOptions::close, this), 24, 139, "ADVDIG.DEF");
+	dig = new CAdventureMapButton("","", std::bind(&CAdventureOptions::close, this), 24, 139, "ADVDIG.DEF");
 	if(const CGHeroInstance *h = adventureInt->curHero())
-		dig->callback += boost::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h);
+		dig->callback += std::bind(&CPlayerInterface::tryDiggging, LOCPLINT, h);
 	else
 		dig->block(true);
 }

+ 2 - 2
client/CAdvmapInterface.h

@@ -128,7 +128,7 @@ public:
 	CTownList townList;
 	CInfoBar infoBar;
 
-	const CSpell *spellBeingCasted; //NULL if none
+	const CSpell *spellBeingCasted; //nullptr if none
 
 	const CArmedInstance *selection; //currently selected town/hero
 
@@ -178,7 +178,7 @@ public:
 	void leaveCastingMode(bool cast = false, int3 dest = int3(-1, -1, -1));
 	const CGHeroInstance * curHero() const;
 	const CGTownInstance * curTown() const;
-	const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or NULL else
+	const IShipyard * ourInaccessibleShipyard(const CGObjectInstance *obj) const; //checks if obj is our ashipyard and cursor is 0,0 -> returns shipyard or nullptr else
 	//button updates
 	void updateSleepWake(const CGHeroInstance *h); 
 	void updateMoveHero(const CGHeroInstance *h, tribool hasPath = boost::logic::indeterminate);

+ 18 - 18
client/CAnimation.cpp

@@ -123,8 +123,8 @@ static CFileCache animationCache;
  *************************************************************************/
 
 CDefFile::CDefFile(std::string Name):
-	data(NULL),
-	palette(NULL)
+	data(nullptr),
+	palette(nullptr)
 {
 	//First 8 colors in def palette used for transparency
 	static SDL_Color H3Palette[8] =
@@ -340,8 +340,8 @@ const std::map<size_t, size_t > CDefFile::getEntries() const
 
 SDLImageLoader::SDLImageLoader(SDLImage * Img):
 	image(Img),
-	lineStart(NULL),
-	position(NULL)
+	lineStart(nullptr),
+	position(nullptr)
 {
 }
 
@@ -394,8 +394,8 @@ SDLImageLoader::~SDLImageLoader()
  
 CompImageLoader::CompImageLoader(CompImage * Img):
 	image(Img),
-	position(NULL),
-	entry(NULL),
+	position(nullptr),
+	entry(nullptr),
 	currentLine(0)
 {
 	
@@ -550,7 +550,7 @@ void CompImageLoader::EndLine()
 {
 	currentLine++;
 	image->line[currentLine] = position - image->surf;
-	entry = NULL;
+	entry = nullptr;
 
 }
 
@@ -586,7 +586,7 @@ void IImage::increaseRef()
 }
 
 SDLImage::SDLImage(CDefFile *data, size_t frame, size_t group, bool compressed):
-	surf(NULL)
+	surf(nullptr)
 {
 	SDLImageLoader loader(this);
 	data->loadFrame(frame, group, loader);
@@ -607,7 +607,7 @@ SDLImage::SDLImage(std::string filename, bool compressed):
 {
 	surf = BitmapHandler::loadBitmap(filename);
 
-	if (surf == NULL)
+	if (surf == nullptr)
 	{
         logGlobal->errorStream() << "Error: failed to load image "<<filename;
 	}
@@ -672,9 +672,9 @@ SDLImage::~SDLImage()
 }
 
 CompImage::CompImage(const CDefFile *data, size_t frame, size_t group):
-	surf(NULL),
-	line(NULL),
-	palette(NULL)
+	surf(nullptr),
+	line(nullptr),
+	palette(nullptr)
 	
 {
 	CompImageLoader loader(this);
@@ -854,7 +854,7 @@ void CompImage::BlitBlock(ui8 type, ui8 size, ui8 *&data, ui8 *&dest, ui8 alpha)
 
 void CompImage::playerColored(PlayerColor player)
 {
-	SDL_Color *pal = NULL;
+	SDL_Color *pal = nullptr;
 	if(player < PlayerColor::PLAYER_LIMIT)
 	{
 		pal = graphics->playerColorPalette + 32*player.getNum();
@@ -900,7 +900,7 @@ IImage * CAnimation::getFromExtraDef(std::string filename)
 {
 	size_t pos = filename.find(':');
 	if (pos == -1)
-		return NULL;
+		return nullptr;
 	CAnimation anim(filename.substr(0, pos));
 	pos++;
 	size_t frame = atoi(filename.c_str()+pos);
@@ -1052,7 +1052,7 @@ CDefFile * CAnimation::getFile() const
 
 	if (CResourceHandler::get()->existsResource(identifier))
 		return new CDefFile(name);
-	return NULL;
+	return nullptr;
 }
 
 void CAnimation::printError(size_t frame, size_t group, std::string type) const
@@ -1079,7 +1079,7 @@ CAnimation::CAnimation():
 	name(""),
 	compressed(false)
 {
-	init(NULL);
+	init(nullptr);
 	loadedAnims.insert(this);
 }
 
@@ -1114,7 +1114,7 @@ IImage * CAnimation::getImage(size_t frame, size_t group, bool verbose) const
 	}
 	if (verbose)
 		printError(frame, group, "GetImage");
-	return NULL;
+	return nullptr;
 }
 
 void CAnimation::load()
@@ -1494,7 +1494,7 @@ void CCreatureAnim::reset()
 
 void CCreatureAnim::startPreview(bool warMachine)
 {
-	callback = boost::bind(&CCreatureAnim::loopPreview, this, warMachine);
+	callback = std::bind(&CCreatureAnim::loopPreview, this, warMachine);
 }
 
 void CCreatureAnim::clearAndSet(EAnimType type)

+ 5 - 5
client/CAnimation.h

@@ -61,7 +61,7 @@ class IImage
 public:
 
 	//draws image on surface "where" at position
-	virtual void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const=0;
+	virtual void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=nullptr, ui8 alpha=255) const=0;
 
 	//decrease ref count, returns true if image can be deleted (refCount <= 0)
 	bool decreaseRef();
@@ -97,7 +97,7 @@ public:
 	SDLImage(SDL_Surface * from, bool extraRef);
 	~SDLImage();
 
-	void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL,  ui8 alpha=255) const;
+	void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=nullptr,  ui8 alpha=255) const;
 	void playerColored(PlayerColor player);
 	int width() const;
 	int height() const;
@@ -143,7 +143,7 @@ public:
 	CompImage(SDL_Surface * surf);
 	~CompImage();
 
-	void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=NULL, ui8 alpha=255) const;
+	void draw(SDL_Surface *where, int posX=0, int posY=0, Rect *src=nullptr, ui8 alpha=255) const;
 	void playerColored(PlayerColor player);
 	int width() const;
 	int height() const;
@@ -201,7 +201,7 @@ public:
 	//add custom surface to the selected position.
 	void setCustom(std::string filename, size_t frame, size_t group=0);
 
-	//get pointer to image from specific group, NULL if not found
+	//get pointer to image from specific group, nullptr if not found
 	IImage * getImage(size_t frame, size_t group=0, bool verbose=true) const;
 
 	//all available frames
@@ -287,7 +287,7 @@ protected:
 
 public:
 	//called when next animation sequence is required
-	boost::function<void()> callback;
+	std::function<void()> callback;
 
 	//Set per-surface alpha, 0 = transparent, 255 = opaque
 	void setAlpha(ui32 alphaValue);

+ 2 - 2
client/CBitmapHandler.cpp

@@ -103,14 +103,14 @@ SDL_Surface * BitmapHandler::loadBitmapFromDir(std::string path, std::string fna
 	if(!fname.size())
 	{
         logGlobal->warnStream() << "Call to loadBitmap with void fname!";
-		return NULL;
+		return nullptr;
 	}
 	if (!CResourceHandler::get()->existsResource(ResourceID(path + fname, EResType::IMAGE)))
 	{
 		return nullptr;
 	}
 
-	SDL_Surface * ret=NULL;
+	SDL_Surface * ret=nullptr;
 
 	auto readFile = CResourceHandler::get()->loadData(
 	                              ResourceID(path + fname, EResType::IMAGE));

+ 30 - 30
client/CCastleInterface.cpp

@@ -63,12 +63,12 @@ CBuildingRect::CBuildingRect(CCastleBuildings * Par, const CGTownInstance *Town,
 	if (!str->borderName.empty())
 		border = BitmapHandler::loadBitmap(str->borderName, true);
 	else
-		border = NULL;
+		border = nullptr;
 
 	if (!str->areaName.empty())
 		area = BitmapHandler::loadBitmap(str->areaName);
 	else
-		area = NULL;
+		area = nullptr;
 }
 
 CBuildingRect::~CBuildingRect()
@@ -97,7 +97,7 @@ void CBuildingRect::hover(bool on)
 
 		if(parent->selectedBuilding == this)
 		{
-			parent->selectedBuilding = NULL;
+			parent->selectedBuilding = nullptr;
 			GH.statusbar->clear();
 		}
 	}
@@ -237,7 +237,7 @@ void CBuildingRect::mouseMoved (const SDL_MouseMotionEvent & sEvent)
 		{
 			if(parent->selectedBuilding == this)
 			{
-				parent->selectedBuilding = NULL;
+				parent->selectedBuilding = nullptr;
 				GH.statusbar->clear();
 			}
 		}
@@ -436,7 +436,7 @@ void CHeroGSlot::set(const CGHeroInstance *newHero)
 	else if(!upg && owner->showEmpty) //up garrison
 		image = new CAnimImage("CREST58", LOCPLINT->castleInt->town->getOwner().getNum(), 0, 0, 0);
 	else 
-		image = NULL;
+		image = nullptr;
 }
 
 template <class ptr>
@@ -456,7 +456,7 @@ SORTHELP<CStructure> structSorter;
 
 CCastleBuildings::CCastleBuildings(const CGTownInstance* Town):
 	town(Town),
-	selectedBuilding(NULL)
+	selectedBuilding(nullptr)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
@@ -575,7 +575,7 @@ const CGHeroInstance* CCastleBuildings::getHero()
 		return town->visitingHero;
 	if (town->garrisonHero)
 		return town->garrisonHero;
-	return NULL;
+	return nullptr;
 }
 
 void CCastleBuildings::buildingClicked(BuildingID building)
@@ -753,7 +753,7 @@ void CCastleBuildings::enterCastleGate()
 	for(size_t i=0;i<Towns.size();i++)
 	{
 		const CGTownInstance *t = Towns[i];
-		if (t->id != this->town->id && t->visitingHero == NULL && //another town, empty and this is
+		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
@@ -761,7 +761,7 @@ void CCastleBuildings::enterCastleGate()
 	}
 	CPicture *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], boost::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1)));
+	    CGI->generaltexth->jktexts[41], std::bind (&CCastleInterface::castleTeleport, LOCPLINT->castleInt, _1)));
 }
 
 void CCastleBuildings::enterDwelling(int level)
@@ -833,7 +833,7 @@ void CCastleBuildings::enterTownHall()
 		else
 		{
 			LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[673]);
-			(dynamic_cast<CInfoWindow*>(GH.topInt()))->buttons[0]->callback += boost::bind(&CCastleBuildings::openTownHall, this);
+			(dynamic_cast<CInfoWindow*>(GH.topInt()))->buttons[0]->callback += std::bind(&CCastleBuildings::openTownHall, this);
 		}
 	}
 	else
@@ -854,8 +854,8 @@ void CCastleBuildings::openTownHall()
 
 CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInstance * from):
     CWindowObject(PLAYER_COLORED | BORDERED),
-	hall(NULL),
-	fort(NULL),
+	hall(nullptr),
+	fort(nullptr),
 	town(Town)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
@@ -876,12 +876,12 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
 	income = new CLabel(195, 443, FONT_SMALL, CENTER);
 	icon = new CAnimImage("ITPT", 0, 0, 15, 387);
 
-	exit = new CAdventureMapButton(CGI->generaltexth->tcommands[8], "", boost::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
+	exit = new CAdventureMapButton(CGI->generaltexth->tcommands[8], "", std::bind(&CCastleInterface::close,this), 744, 544, "TSBTNS", SDLK_RETURN);
 	exit->assignedKeys.insert(SDLK_ESCAPE);
 	exit->setOffset(4);
 
-	split = new CAdventureMapButton(CGI->generaltexth->tcommands[3], "", boost::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
-	split->callback += boost::bind(&HeroSlots::splitClicked, heroes);
+	split = new CAdventureMapButton(CGI->generaltexth->tcommands[3], "", std::bind(&CGarrisonInt::splitClick,garr), 744, 382, "TSBTNS.DEF");
+	split->callback += std::bind(&HeroSlots::splitClicked, heroes);
 	garr->addSplitBtn(split);
 
 	Rect barRect(9, 182, 732, 18);
@@ -893,7 +893,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
 		townlist->select(from);
 
 	townlist->select(town); //this will scroll list to select current town
-	townlist->onSelect = boost::bind(&CCastleInterface::townChange, this);
+	townlist->onSelect = std::bind(&CCastleInterface::townChange, this);
 
 	recreateIcons();
 	CCS->musich->playMusic(town->town->clientInfo.musicTheme, true);
@@ -903,7 +903,7 @@ CCastleInterface::CCastleInterface(const CGTownInstance * Town, const CGTownInst
 
 CCastleInterface::~CCastleInterface()
 {
-	LOCPLINT->castleInt = NULL;
+	LOCPLINT->castleInt = nullptr;
 	delete bicons;
 }
 
@@ -987,8 +987,8 @@ CCreaInfo::CCreaInfo(Point position, const CGTownInstance *Town, int Level, bool
 	if ( town->creatures.size() <= level || town->creatures[level].second.empty())
 	{
 		level = -1;
-		label = NULL;
-		picture = NULL;
+		label = nullptr;
+		picture = nullptr;
 		return;//No creature
 	}
 	addUsedEvents(LCLICK | RCLICK | HOVER);
@@ -1092,7 +1092,7 @@ void CCreaInfo::clickRight(tribool down, bool previousState)
 
 CTownInfo::CTownInfo(int posX, int posY, const CGTownInstance* Town, bool townHall):
 	town(Town),
-	building(NULL)
+	building(nullptr)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	addUsedEvents(RCLICK | HOVER);
@@ -1298,7 +1298,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
 
 	title = new CLabel(399, 12, FONT_MEDIUM, CENTER, Colors::WHITE, town->town->buildings[BuildingID(town->hallLevel()+BuildingID::VILLAGE_HALL)]->Name());
 	exit = new CAdventureMapButton(CGI->generaltexth->hcommands[8], "", 
-	           boost::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
+	           std::bind(&CHallInterface::close,this), 748, 556, "TPMAGE1.DEF", SDLK_RETURN);
 	exit->assignedKeys.insert(SDLK_ESCAPE);
 
 	auto & boxList = town->town->clientInfo.hallSlots;
@@ -1307,7 +1307,7 @@ CHallInterface::CHallInterface(const CGTownInstance *Town):
 	{
 		for(size_t col=0; col<boxList[row].size(); col++) //for each box
 		{
-			const CBuilding *building = NULL;
+			const CBuilding *building = nullptr;
 			for(size_t item=0; item<boxList[row][col].size(); item++)//we are looking for the first not build structure
 			{
 				auto buildingID = boxList[row][col][item];
@@ -1391,12 +1391,12 @@ CBuildWindow::CBuildWindow(const CGTownInstance *Town, const CBuilding * Buildin
 	if(!rightClick)
 	{	//normal window
 		buy = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[595]) % building->Name()),
-		          "", boost::bind(&CBuildWindow::buyFunc,this), 45, 446,"IBUY30", SDLK_RETURN);
+		          "", std::bind(&CBuildWindow::buyFunc,this), 45, 446,"IBUY30", SDLK_RETURN);
 		buy->borderColor = Colors::METALLIC_GOLD;
 		buy->borderEnabled = true;
 		
 		cancel = new CAdventureMapButton(boost::str(boost::format(CGI->generaltexth->allTexts[596]) % building->Name()),
-		             "", boost::bind(&CBuildWindow::close,this), 290, 445, "ICANCEL", SDLK_ESCAPE);
+		             "", std::bind(&CBuildWindow::close,this), 290, 445, "ICANCEL", SDLK_ESCAPE);
 		cancel->borderColor = Colors::METALLIC_GOLD;
 		cancel->borderEnabled = true;
 		buy->block(state!=7 || LOCPLINT->playerID != town->tempOwner);
@@ -1428,7 +1428,7 @@ CFortScreen::CFortScreen(const CGTownInstance * town):
 	title = new CLabel(400, 12, FONT_BIG, CENTER, Colors::WHITE, fortBuilding->Name());
 	
 	std::string text = boost::str(boost::format(CGI->generaltexth->fcommands[6]) % fortBuilding->Name());
-	exit = new CAdventureMapButton(text, "", boost::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN);
+	exit = new CAdventureMapButton(text, "", std::bind(&CFortScreen::close,this) ,748, 556, "TPMAGE1", SDLK_RETURN);
 	exit->assignedKeys.insert(SDLK_ESCAPE);
 
 	std::vector<Point> positions;
@@ -1518,7 +1518,7 @@ void LabeledValue::hover(bool on)
 CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *Town, BuildingID buildingID, int Level):
 	town(Town),
 	level(Level),
-	availableCount(NULL)
+	availableCount(nullptr)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	pos.x +=posX;
@@ -1532,7 +1532,7 @@ CFortScreen::RecruitArea::RecruitArea(int posX, int posY, const CGTownInstance *
 	icons = new CPicture("TPCAINFO", 261, 3);
 	buildingPic = new CAnimImage(town->town->clientInfo.buildingsIcons, buildingID, 0, 4, 21);
 
-	const CCreature* creature = NULL;
+	const CCreature* creature = nullptr;
 
 	if (!town->creatures[level].second.empty())
 		creature = CGI->creh->creatures[town->creatures[level].second.back()];
@@ -1608,7 +1608,7 @@ CMageGuildScreen::CMageGuildScreen(CCastleInterface * owner):
 	Rect barRect(7, 556, 737, 18);
 	statusBar = new CGStatusBar(new CPicture(*background, barRect, 7, 556, false));
 	
-	exit = new CAdventureMapButton(CGI->generaltexth->allTexts[593],"",boost::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN);
+	exit = new CAdventureMapButton(CGI->generaltexth->allTexts[593],"",std::bind(&CMageGuildScreen::close,this), 748, 556,"TPMAGE1.DEF",SDLK_RETURN);
 	exit->assignedKeys.insert(SDLK_ESCAPE);
 	
 	std::vector<std::vector<Point> > positions;
@@ -1685,10 +1685,10 @@ CBlacksmithDialog::CBlacksmithDialog(bool possible, CreatureID creMachineID, Art
 	                boost::lexical_cast<std::string>(CGI->arth->artifacts[aid]->price));
 
 	std::string text = boost::str(boost::format(CGI->generaltexth->allTexts[595]) % creature->nameSing);
-	buy = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
+	buy = new CAdventureMapButton(text,"",std::bind(&CBlacksmithDialog::close, this), 42, 312,"IBUY30.DEF",SDLK_RETURN);
 	
 	text = boost::str(boost::format(CGI->generaltexth->allTexts[596]) % creature->nameSing);
-	cancel = new CAdventureMapButton(text,"",boost::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
+	cancel = new CAdventureMapButton(text,"",std::bind(&CBlacksmithDialog::close, this), 224, 312,"ICANCEL.DEF",SDLK_ESCAPE);
 
 	if(possible)
 		buy->callback += [=]{ LOCPLINT->cb->buyArtifact(LOCPLINT->cb->getHero(hid),aid); };

+ 1 - 1
client/CCastleInterface.h

@@ -84,7 +84,7 @@ public:
 	int upg; //0 - up garrison, 1 - down garrison
 
 	CAnimImage *image;
-	CAnimImage *selection; //selection border. NULL if not selected
+	CAnimImage *selection; //selection border. nullptr if not selected
 	
 	void setHighlight(bool on);
 	void set(const CGHeroInstance *newHero);

+ 38 - 38
client/CCreatureWindow.cpp

@@ -52,7 +52,7 @@ CCreatureWindow::CCreatureWindow (const CStack &stack, CreWinType Type):
 	else
 	{
 		CStackInstance * s = new CStackInstance(stack.type, 1); //TODO: war machines and summons should be regular stacks
-		init(s, &stack, NULL);
+		init(s, &stack, nullptr);
 		delete s;
 	}
 }
@@ -73,11 +73,11 @@ CCreatureWindow::CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCo
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 
 	CStackInstance * stack = new CStackInstance(Cid, creatureCount); //TODO: simplify?
-	init(stack, CGI->creh->creatures[Cid], NULL);
+	init(stack, CGI->creh->creatures[Cid], nullptr);
 	delete stack;
 }
 
-CCreatureWindow::CCreatureWindow(const CStackInstance &st, CreWinType Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui):
+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),
@@ -104,14 +104,14 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, CreWinType Type, boos
 			{
 				CFunctionList<void()> fs;
 				fs += Upg;
-				fs += boost::bind(&CCreatureWindow::close,this);
+				fs += std::bind(&CCreatureWindow::close,this);
 				CFunctionList<void()> cfl;
-				cfl = boost::bind(&CPlayerInterface::showYesNoDialog, LOCPLINT, CGI->generaltexth->allTexts[207], fs, 0, false, boost::ref(upgResCost));
+				cfl = std::bind(&CPlayerInterface::showYesNoDialog, LOCPLINT, CGI->generaltexth->allTexts[207], fs, 0, false, std::ref(upgResCost));
 				upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,cfl,385, 148,"IVIEWCR.DEF",SDLK_u);
 			}
 			else
 			{
-				upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,boost::function<void()>(),385, 148,"IVIEWCR.DEF");
+				upgrade = new CAdventureMapButton("",CGI->generaltexth->zelp[446].second,std::function<void()>(),385, 148,"IVIEWCR.DEF");
 				upgrade->callback.funcs.clear();
 				upgrade->setOffset(2);
 			}
@@ -122,9 +122,9 @@ CCreatureWindow::CCreatureWindow(const CStackInstance &st, CreWinType Type, boos
 			CFunctionList<void()> fs[2];
 			//on dismiss confirmed
 			fs[0] += Dsm; //dismiss
-			fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
+			fs[0] += std::bind(&CCreatureWindow::close,this);//close this window
 			CFunctionList<void()> cfl;
-			cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
+			cfl = std::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
 			dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second,cfl,333, 148,"IVIEWCR2.DEF",SDLK_d);
 		}
 	}
@@ -146,18 +146,18 @@ CCreatureWindow::CCreatureWindow (const CCommanderInstance * Commander, const CS
 		init(commander, commander, dynamic_cast<const CGHeroInstance*>(commander->armyObj));
 	}
 
-	boost::function<void()> Dsm;
+	std::function<void()> Dsm;
 	CFunctionList<void()> fs[2];
 	//on dismiss confirmed
 	fs[0] += Dsm; //dismiss
-	fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
+	fs[0] += std::bind(&CCreatureWindow::close,this);//close this window
 	CFunctionList<void()> cfl;
-	cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
+	cfl = std::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
 	if (type < COMMANDER_LEVEL_UP) //can dismiss only in regular window
 		dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, cfl, 333, 148,"IVIEWCR2.DEF", SDLK_d);
 }
 
-CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderInstance * Commander, boost::function<void(ui32)> callback):
+CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderInstance * Commander, std::function<void(ui32)> callback):
     CWindowObject(PLAYER_COLORED),
     type(COMMANDER_LEVEL_UP),
 	commander (Commander),
@@ -169,21 +169,21 @@ CCreatureWindow::CCreatureWindow (std::vector<ui32> &skills, const CCommanderIns
 
 	init(commander, commander, dynamic_cast<const CGHeroInstance*>(commander->armyObj));
 
-	boost::function<void()> Dsm;
+	std::function<void()> Dsm;
 	CFunctionList<void()> fs[2];
 	//on dismiss confirmed
 	fs[0] += Dsm; //dismiss
-	fs[0] += boost::bind(&CCreatureWindow::close,this);//close this window
+	fs[0] += std::bind(&CCreatureWindow::close,this);//close this window
 	CFunctionList<void()> cfl;
-	cfl = boost::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
+	cfl = std::bind(&CPlayerInterface::showYesNoDialog,LOCPLINT,CGI->generaltexth->allTexts[12],fs[0],fs[1],false,std::vector<CComponent*>());
 	if (type < COMMANDER_LEVEL_UP) //can dismiss only in regular window
 		dismiss = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, cfl, 333, 148,"IVIEWCR2.DEF", SDLK_d);
 }
 
 void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *StackNode, const CGHeroInstance *HeroOwner)
 {
-	creatureArtifact = NULL; //may be set later
-	artifactImage = NULL;
+	creatureArtifact = nullptr; //may be set later
+	artifactImage = nullptr;
 	stack = Stack;
 	c = stack->type;
 	if(!StackNode)
@@ -199,7 +199,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 		count = boost::lexical_cast<std::string>(Stack->count);
 
 	if (type < COMMANDER)
-		commander = NULL;
+		commander = nullptr;
 
 	bool creArt = false;
 	displayedArtifact = ArtifactPosition::CREATURE_SLOT; // 0
@@ -229,7 +229,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 			{
 				ui32 index = selectableSkills.size();
 				CSelectableSkill * selectableSkill = new CSelectableSkill();
-				selectableSkill->callback = boost::bind(&CCreatureWindow::selectSkill, this, index);
+				selectableSkill->callback = std::bind(&CCreatureWindow::selectSkill, this, index);
 
 				if (option < 100)
 				{
@@ -324,13 +324,13 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 		setBackground("CreWin" + boost::lexical_cast<std::string>(bonusRows) + ".pcx"); //1 to 4 rows for now
 
 	//Buttons
-	ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CCreatureWindow::close,this), 489, 148, "hsbtns.def", SDLK_RETURN);
+	ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, std::bind(&CCreatureWindow::close,this), 489, 148, "hsbtns.def", SDLK_RETURN);
 	ok->assignedKeys.insert(SDLK_ESCAPE);
 
 	if (type <= BATTLE) //in battle or info window
 	{
-		upgrade = NULL;
-		dismiss = NULL;
+		upgrade = nullptr;
+		dismiss = nullptr;
 	}
 	anim = new CCreaturePic(22, 48, c);
 
@@ -403,10 +403,10 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 		if (type > BATTLE && type < COMMANDER_BATTLE) //artifact buttons inactive in battle
 		{
 			//TODO: disable buttons if no artifact is equipped
-			leftArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
-			rightArtRoll = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
+			leftArtRoll = new CAdventureMapButton(std::string(), std::string(), std::bind (&CCreatureWindow::scrollArt, this, -1), 437, 98, "hsbtns3.def", SDLK_LEFT);
+			rightArtRoll = new CAdventureMapButton(std::string(), std::string(), std::bind (&CCreatureWindow::scrollArt, this, +1), 516, 98, "hsbtns5.def", SDLK_RIGHT);
 			if (heroOwner)
-				passArtToHero = new CAdventureMapButton(std::string(), std::string(), boost::bind (&CCreatureWindow::passArtifactToHero, this), 437, 148, "OVBUTN1.DEF", SDLK_HOME);
+				passArtToHero = new CAdventureMapButton(std::string(), std::string(), std::bind (&CCreatureWindow::passArtifactToHero, this), 437, 148, "OVBUTN1.DEF", SDLK_HOME);
 		}
 	}
 
@@ -437,7 +437,7 @@ void CCreatureWindow::init(const CStackInstance *Stack, const CBonusSystemNode *
 
 	if (bonusItems.size() > (bonusRows << 1)) //only after graphics are created
 	{
-		slider = new CSlider(528, 231 + commanderOffset, bonusRows*60, boost::bind (&CCreatureWindow::sliderMoved, this, _1),
+		slider = new CSlider(528, 231 + commanderOffset, bonusRows*60, std::bind (&CCreatureWindow::sliderMoved, this, _1),
 		bonusRows, (bonusItems.size() + 1) >> 1, 0, false, 0);
 	}
 	else //slider automatically places bonus Items
@@ -624,13 +624,13 @@ void CCreatureWindow::setArt(const CArtifactInstance *art)
 	creatureArtifact = art;
 	if (creatureArtifact)
 	{
-		if (artifactImage == NULL)
+		if (artifactImage == nullptr)
 			artifactImage = new CAnimImage("ARTIFACT", creatureArtifact->artType->iconIndex, 0, 466, 100);
 		else
 			artifactImage->setFrame(creatureArtifact->artType->iconIndex);
 	}
 	else
-		artifactImage = NULL;
+		artifactImage = nullptr;
 	
 	redraw();
 }
@@ -704,7 +704,7 @@ CBonusItem::CBonusItem(const Rect &Pos, const std::string &Name, const std::stri
 	if (graphicsName.size())
 		bonusGraphics = new CPicture(graphicsName, 26, 232);
 	else
-		bonusGraphics = NULL;
+		bonusGraphics = nullptr;
 
 	removeUsedEvents(ALL); //no actions atm
 }
@@ -737,7 +737,7 @@ void CCreInfoWindow::show(SDL_Surface * to)
 	creatureCount->showAll(to);
 }
 
-CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost::function<void()> upgradeFunc, boost::function<void()> dismissFunc, UpgradeInfo *upgradeInfo):
+CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, std::function<void()> upgradeFunc, std::function<void()> dismissFunc, UpgradeInfo *upgradeInfo):
     CWindowObject(PLAYER_COLORED | (LClicked ? 0 : RCLICK_POPUP), "CRSTKPU")
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
@@ -746,7 +746,7 @@ CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost
 	//additional buttons if opened with left click
 	if(LClicked)
 	{
-		boost::function<void()> closeFunc = boost::bind(&CCreInfoWindow::close,this);
+		std::function<void()> closeFunc = std::bind(&CCreInfoWindow::close,this);
 
 		if(upgradeFunc && upgradeInfo)
 		{
@@ -761,11 +761,11 @@ CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost
 			onUpgrade += upgradeFunc;
 			onUpgrade += closeFunc;
 
-			boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
+			std::function<void()> dialog = std::bind(&CPlayerInterface::showYesNoDialog,
 				LOCPLINT,
 				CGI->generaltexth->allTexts[207],
 				onUpgrade, 0, false,
-				boost::ref(upgResCost));
+				std::ref(upgResCost));
 
 			upgrade = new CAdventureMapButton("", CGI->generaltexth->zelp[446].second, dialog, 76, 237, "IVIEWCR", SDLK_u);
 			upgrade->block(!LOCPLINT->cb->getResourceAmount().canAfford(upgradeCost));
@@ -777,7 +777,7 @@ CCreInfoWindow::CCreInfoWindow(const CStackInstance &stack, bool LClicked, boost
 			onDismiss += dismissFunc;
 			onDismiss += closeFunc;
 
-			boost::function<void()> dialog = boost::bind(&CPlayerInterface::showYesNoDialog,
+			std::function<void()> dialog = std::bind(&CPlayerInterface::showYesNoDialog,
 				LOCPLINT,
 				CGI->generaltexth->allTexts[12],
 				onDismiss, 0, true, std::vector<CComponent*>());
@@ -792,7 +792,7 @@ CCreInfoWindow::CCreInfoWindow(int creatureID, bool LClicked, int creatureCount)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	const CCreature *creature = CGI->creh->creatures[creatureID];
-	init(creature, NULL, NULL, creatureCount, LClicked);
+	init(creature, nullptr, nullptr, creatureCount, LClicked);
 }
 
 CCreInfoWindow::CCreInfoWindow(const CStack &stack, bool LClicked):
@@ -869,9 +869,9 @@ void CCreInfoWindow::init(const CCreature *creature, const CBonusSystemNode *sta
 	}
 	else
 	{
-		abilityText = NULL;
+		abilityText = nullptr;
 		ok = new CAdventureMapButton("", CGI->generaltexth->zelp[445].second,
-			boost::bind(&CCreInfoWindow::close,this), 216, 237, "IOKAY.DEF", SDLK_RETURN);
+			std::bind(&CCreInfoWindow::close,this), 216, 237, "IOKAY.DEF", SDLK_RETURN);
 		ok->assignedKeys.insert(SDLK_ESCAPE);
 	}
 
@@ -913,7 +913,7 @@ CIntObject * createCreWindow(CreatureID Cid, CCreatureWindow::CreWinType Type, i
 		return new CCreatureWindow(Cid, Type, creatureCount);
 }
 
-CIntObject * createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui)
+CIntObject * createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, std::function<void()> Upg, std::function<void()> Dsm, UpgradeInfo *ui)
 {
 	if(settings["general"]["classicCreatureWindow"].Bool())
 		return new CCreInfoWindow(*s, type==CCreatureWindow::HERO, Upg, Dsm, ui);

+ 9 - 9
client/CCreatureWindow.h

@@ -82,15 +82,15 @@ public:
 	void artifactDisassembled (const ArtifactLocation &artLoc) {return;};
 	void artifactAssembled (const ArtifactLocation &artLoc) {return;};
 
-	boost::function<void()> dsm; //dismiss button callback
-	boost::function<void()> Upg; //upgrade button callback
-	boost::function<void(ui32)> levelUp; //choose commander skill to level up
+	std::function<void()> dsm; //dismiss button callback
+	std::function<void()> Upg; //upgrade button callback
+	std::function<void(ui32)> levelUp; //choose commander skill to level up
 
 	CCreatureWindow(const CStack & stack, CreWinType type); //battle c-tor
 	CCreatureWindow (const CStackInstance &stack, CreWinType Type); //pop-up c-tor
-	CCreatureWindow(const CStackInstance &st, CreWinType Type, boost::function<void()> Upg, boost::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
-	CCreatureWindow(const CCommanderInstance * commander, const CStack * stack = NULL); //commander window
-	CCreatureWindow(std::vector<ui32> &skills, const CCommanderInstance * commander, boost::function<void(ui32)> callback); 
+	CCreatureWindow(const CStackInstance &st, CreWinType Type, std::function<void()> Upg, std::function<void()> Dsm, UpgradeInfo *ui); //full garrison window
+	CCreatureWindow(const CCommanderInstance * commander, const CStack * stack = nullptr); //commander window
+	CCreatureWindow(std::vector<ui32> &skills, const CCommanderInstance * commander, std::function<void(ui32)> callback); 
 	CCreatureWindow(CreatureID Cid, CreWinType Type, int creatureCount); //c-tor
 
 	void init(const CStackInstance *stack, const CBonusSystemNode *stackNode, const CGHeroInstance *heroOwner);
@@ -123,7 +123,7 @@ public:
 class CSelectableSkill : public LRClickableAreaWText
 {
 public:
-	boost::function<void()> callback; //TODO: create more generic clickable class than AdvMapButton?
+	std::function<void()> callback; //TODO: create more generic clickable class than AdvMapButton?
 
 	virtual void clickLeft(tribool down, bool previousState);
 	virtual void clickRight(tribool down, bool previousState){};
@@ -146,7 +146,7 @@ public:
 
 	CAdventureMapButton * dismiss, * upgrade, * ok;
 
-	CCreInfoWindow(const CStackInstance & st, bool LClicked, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo * ui = NULL);
+	CCreInfoWindow(const CStackInstance & st, bool LClicked, std::function<void()> Upg = 0, std::function<void()> Dsm = 0, UpgradeInfo * ui = nullptr);
 	CCreInfoWindow(const CStack & st, bool LClicked = 0);
 	CCreInfoWindow(int Cid, bool LClicked, int creatureCount);
 	~CCreInfoWindow();
@@ -159,4 +159,4 @@ public:
 
 CIntObject *createCreWindow(const CStack *s, bool lclick = false);
 CIntObject *createCreWindow(CreatureID Cid, CCreatureWindow::CreWinType Type, int creatureCount);
-CIntObject *createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, boost::function<void()> Upg = 0, boost::function<void()> Dsm = 0, UpgradeInfo *ui = NULL);
+CIntObject *createCreWindow(const CStackInstance *s, CCreatureWindow::CreWinType type, std::function<void()> Upg = 0, std::function<void()> Dsm = 0, UpgradeInfo *ui = nullptr);

+ 2 - 2
client/CDefHandler.cpp

@@ -40,7 +40,7 @@ CDefHandler::~CDefHandler()
 		if (ourImages[i].bitmap)
 		{
 			SDL_FreeSurface(ourImages[i].bitmap);
-			ourImages[i].bitmap=NULL;
+			ourImages[i].bitmap=nullptr;
 		}
 	}
 }
@@ -130,7 +130,7 @@ void CDefHandler::expand(ui8 N,ui8 & BL, ui8 & BR)
 
 SDL_Surface * CDefHandler::getSprite (int SIndex, const ui8 * FDef, const BMPPalette * palette) const
 {
-	SDL_Surface * ret=NULL;
+	SDL_Surface * ret=nullptr;
 
 	ui32 BaseOffset,
 		SpriteWidth, SpriteHeight, //format of sprite

+ 1 - 1
client/CGameInfo.cpp

@@ -18,7 +18,7 @@ CClientState * CCS;
 
 CGameInfo::CGameInfo()
 {
-	mh = NULL;
+	mh = nullptr;
 }
 
 void CGameInfo::setFromLib()

+ 13 - 13
client/CHeroWindow.cpp

@@ -41,13 +41,13 @@
 
 using namespace boost::assign;
 
-const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= NULL*/, const std::string &cachingStr /*= ""*/) const
+const TBonusListPtr CHeroWithMaybePickedArtifact::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const
 {
 	TBonusListPtr out(new BonusList);
 	TBonusListPtr heroBonuses = hero->getAllBonuses(selector, limit, hero);
 	TBonusListPtr bonusesFromPickedUpArtifact;
 
-	CArtifactsOfHero::SCommonPart *cp = cww->artSets.size() ? cww->artSets.front()->commonInfo : NULL;
+	CArtifactsOfHero::SCommonPart *cp = cww->artSets.size() ? cww->artSets.front()->commonInfo : nullptr;
 	if(cp && cp->src.art && cp->src.valid() && cp->src.AOH && cp->src.AOH->getHero() == hero)
 	{
 		bonusesFromPickedUpArtifact = cp->src.art->getAllBonuses(selector, limit, hero);
@@ -103,20 +103,20 @@ CHeroWindow::CHeroWindow(const CGHeroInstance *hero):
 	//artifs = new CArtifactsOfHero(pos.topLeft(), true);
 	ourBar = new CGStatusBar(7, 559, "ADROLLVR.bmp", 660); // new CStatusBar(pos.x+72, pos.y+567, "ADROLLVR.bmp", 660);
 
-	quitButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),boost::bind(&CHeroWindow::close,this), 609, 516, "hsbtns.def", SDLK_RETURN);
+	quitButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[17], std::string(),std::bind(&CHeroWindow::close,this), 609, 516, "hsbtns.def", SDLK_RETURN);
 	quitButton->assignedKeys.insert(SDLK_ESCAPE);
-	dismissButton = new CAdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], boost::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
-	questlogButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), boost::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
+	dismissButton = new CAdventureMapButton(std::string(), CGI->generaltexth->heroscrn[28], std::bind(&CHeroWindow::dismissCurrent,this), 454, 429, "hsbtns2.def", SDLK_d);
+	questlogButton = new CAdventureMapButton(CGI->generaltexth->heroscrn[0], std::string(), std::bind(&CHeroWindow::questlog,this), 314, 429, "hsbtns4.def", SDLK_q);
 
 	formations = new CHighlightableButtonsGroup(0);
 	formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[23]),CGI->generaltexth->heroscrn[29], "hsbtns6.def", 481, 483, 0, 0, SDLK_t);
 	formations->addButton(map_list_of(0,CGI->generaltexth->heroscrn[24]),CGI->generaltexth->heroscrn[30], "hsbtns7.def", 481, 519, 1, 0, SDLK_l);
 
-	tacticsButton = new CHighlightableButton(0, 0, map_list_of(0,CGI->generaltexth->heroscrn[26])(3,CGI->generaltexth->heroscrn[25]), CGI->generaltexth->heroscrn[31], false, "hsbtns8.def", NULL, 539, 483, SDLK_b);
+	tacticsButton = new CHighlightableButton(0, 0, map_list_of(0,CGI->generaltexth->heroscrn[26])(3,CGI->generaltexth->heroscrn[25]), CGI->generaltexth->heroscrn[31], false, "hsbtns8.def", nullptr, 539, 483, SDLK_b);
 
 	if (hero->commander)
 	{
-		commanderButton = new CAdventureMapButton ("Commander", "Commander info", boost::bind(&CHeroWindow::commanderWindow, this), 317, 18, "chftke.def", SDLK_c, NULL, false);
+		commanderButton = new CAdventureMapButton ("Commander", "Commander info", std::bind(&CHeroWindow::commanderWindow, this), 317, 18, "chftke.def", SDLK_c, nullptr, false);
 	}
 
 
@@ -183,7 +183,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
 {	
 	if(!hero) //something strange... no hero? it shouldn't happen
 	{
-        logGlobal->errorStream() << "Set NULL hero? no way...";
+        logGlobal->errorStream() << "Set nullptr hero? no way...";
 		return;
 	}
 
@@ -201,13 +201,13 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
 	portraitImage->setFrame(curHero->portrait);
 
 	{
-		CAdventureMapButton * split = NULL;
+		CAdventureMapButton * split = nullptr;
 		OBJ_CONSTRUCTION_CAPTURING_ALL;
 		if(!garr)
 		{
 			garr = new CGarrisonInt(15, 485, 8, Point(), background->bg, Point(15,485), curHero);
 			split = new CAdventureMapButton(CGI->generaltexth->allTexts[256], CGI->generaltexth->heroscrn[32],
-					boost::bind(&CGarrisonInt::splitClick,garr), 539, 519, "hsbtns9.def", false, NULL, false); //deleted by garrison destructor
+					std::bind(&CGarrisonInt::splitClick,garr), 539, 519, "hsbtns9.def", false, nullptr, false); //deleted by garrison destructor
 			boost::algorithm::replace_first(split->hoverTexts[0],"%s",CGI->generaltexth->allTexts[43]);
 
 			garr->addSplitBtn(split);
@@ -282,7 +282,7 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
 	//setting formations
 	formations->onChange = 0;
 	formations->select(curHero->formation,true);
-	formations->onChange = boost::bind(&CCallback::setFormation, LOCPLINT->cb.get(), curHero, _1);
+	formations->onChange = std::bind(&CCallback::setFormation, LOCPLINT->cb.get(), curHero, _1);
 
 	morale->set(&heroWArt);
 	luck->set(&heroWArt);
@@ -293,8 +293,8 @@ void CHeroWindow::update(const CGHeroInstance * hero, bool redrawNeeded /*= fals
 
 void CHeroWindow::dismissCurrent()
 {
-	CFunctionList<void()> ony = boost::bind(&CHeroWindow::close,this);
-	ony += boost::bind(&CCallback::dismissHero, LOCPLINT->cb.get(), curHero);
+	CFunctionList<void()> ony = std::bind(&CHeroWindow::close,this);
+	ony += std::bind(&CCallback::dismissHero, LOCPLINT->cb.get(), curHero);
 	LOCPLINT->showYesNoDialog(CGI->generaltexth->allTexts[22], ony, 0, false);
 }
 

+ 1 - 1
client/CHeroWindow.h

@@ -46,7 +46,7 @@ public:
 	CWindowWithArtifacts *cww;
 
 	CHeroWithMaybePickedArtifact(CWindowWithArtifacts *Cww, const CGHeroInstance *Hero);
-	const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const OVERRIDE;
+	const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr, const std::string &cachingStr = "") const override;
 };
 
 class CHeroWindow: public CWindowObject, public CWindowWithGarrison, public CWindowWithArtifacts

+ 25 - 25
client/CKingdomInterface.cpp

@@ -32,8 +32,8 @@ InfoBox::InfoBox(Point position, InfoPos Pos, InfoSize Size, IInfoBoxData *Data)
 	size(Size),
 	infoPos(Pos),
 	data(Data),
-	value(NULL),
-	name(NULL)
+	value(nullptr),
+	name(nullptr)
 {
 	assert(data);
 	addUsedEvents(LCLICK | RCLICK);
@@ -253,7 +253,7 @@ bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, CComponent **com
 	{
 	case HERO_SPECIAL:
 		text = CGI->heroh->heroes[getSubID()]->specDescr;
-		*comp = NULL;
+		*comp = nullptr;
 		return true;
 	case HERO_PRIMARY_SKILL:
 		text = CGI->generaltexth->arraytxt[2+getSubID()];
@@ -261,11 +261,11 @@ bool InfoBoxAbstractHeroData::prepareMessage(std::string &text, CComponent **com
 		return true;
 	case HERO_MANA:
 		text = CGI->generaltexth->allTexts[149];
-		*comp = NULL;
+		*comp = nullptr;
 		return true;
 	case HERO_EXPERIENCE:
 		text = CGI->generaltexth->allTexts[241];
-		*comp = NULL;
+		*comp = nullptr;
 		return true;
 	case HERO_SECONDARY_SKILL:
 		{
@@ -383,7 +383,7 @@ bool InfoBoxHeroData::prepareMessage(std::string &text, CComponent**comp)
 		boost::replace_first(text, "%s", boost::lexical_cast<std::string>(hero->name));
 		boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->mana));
 		boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->manaLimit()));
-		*comp = NULL;
+		*comp = nullptr;
 		return true;
 
 	case HERO_EXPERIENCE:
@@ -391,7 +391,7 @@ bool InfoBoxHeroData::prepareMessage(std::string &text, CComponent**comp)
 		boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->level));
 		boost::replace_first(text, "%d", boost::lexical_cast<std::string>(CGI->heroh->reqExp(hero->level+1)));
 		boost::replace_first(text, "%d", boost::lexical_cast<std::string>(hero->exp));
-		*comp = NULL;
+		*comp = nullptr;
 		return true;
 
 	default:
@@ -462,7 +462,7 @@ CKingdomInterface::CKingdomInterface():
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	ui32 footerPos = conf.go()->ac.overviewSize * 116;
 
-	tabArea = new CTabbedInt(boost::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), Point(4,4));
+	tabArea = new CTabbedInt(std::bind(&CKingdomInterface::createMainTab, this, _1), CTabbedInt::DestroyFunc(), Point(4,4));
 
 	std::vector<const CGObjectInstance * > ownedObjects = LOCPLINT->cb->getMyObjects();
 	generateObjectsList(ownedObjects);
@@ -522,7 +522,7 @@ void CKingdomInterface::generateObjectsList(const std::vector<const CGObjectInst
 	{
 		objects.push_back(element.second);
 	}
-	dwellingsList = new CListBox(boost::bind(&CKingdomInterface::createOwnedObject, this, _1), CListBox::DestroyFunc(),
+	dwellingsList = new CListBox(std::bind(&CKingdomInterface::createOwnedObject, this, _1), CListBox::DestroyFunc(),
 	                             Point(740,44), Point(0,57), dwellSize, visibleObjects.size());
 }
 
@@ -535,7 +535,7 @@ CIntObject* CKingdomInterface::createOwnedObject(size_t index)
 		return new InfoBox(Point(), InfoBox::POS_CORNER, InfoBox::SIZE_SMALL,
 			   new InfoBoxCustom(value,"", "FLAGPORT", obj.imageID, obj.hoverText));
 	}
-	return NULL;
+	return nullptr;
 }
 
 CIntObject * CKingdomInterface::createMainTab(size_t index)
@@ -545,7 +545,7 @@ CIntObject * CKingdomInterface::createMainTab(size_t index)
 	{
 	case 0: return new CKingdHeroList(size);
 	case 1: return new CKingdTownList(size);
-	default:return NULL;
+	default:return nullptr;
 	}
 }
 
@@ -603,30 +603,30 @@ void CKingdomInterface::generateButtons()
 
 	//Main control buttons
 	btnHeroes = new CAdventureMapButton (CGI->generaltexth->overview[11], CGI->generaltexth->overview[6],
-	                                    boost::bind(&CKingdomInterface::activateTab, this, 0),748,28+footerPos,"OVBUTN1.DEF", SDLK_h);
+	                                    std::bind(&CKingdomInterface::activateTab, this, 0),748,28+footerPos,"OVBUTN1.DEF", SDLK_h);
 	btnHeroes->block(true);
 
 	btnTowns = new CAdventureMapButton (CGI->generaltexth->overview[12], CGI->generaltexth->overview[7],
-	                                   boost::bind(&CKingdomInterface::activateTab, this, 1),748,64+footerPos,"OVBUTN6.DEF", SDLK_t);
+	                                   std::bind(&CKingdomInterface::activateTab, this, 1),748,64+footerPos,"OVBUTN6.DEF", SDLK_t);
 
 	btnExit = new CAdventureMapButton (CGI->generaltexth->allTexts[600],"",
-	                                  boost::bind(&CKingdomInterface::close, this),748,99+footerPos,"OVBUTN1.DEF", SDLK_RETURN);
+	                                  std::bind(&CKingdomInterface::close, this),748,99+footerPos,"OVBUTN1.DEF", SDLK_RETURN);
 	btnExit->assignedKeys.insert(SDLK_ESCAPE);
 	btnExit->setOffset(3);
 
 	//Object list control buttons
-	dwellTop = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, 0),
+	dwellTop = new CAdventureMapButton ("", "", std::bind(&CListBox::moveToPos, dwellingsList, 0),
 	                                   733, 4, "OVBUTN4.DEF");
 
-	dwellBottom = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPos, dwellingsList, -1),
+	dwellBottom = new CAdventureMapButton ("", "", std::bind(&CListBox::moveToPos, dwellingsList, -1),
 	                                      733, footerPos+2, "OVBUTN4.DEF");
 	dwellBottom->setOffset(2);
 
-	dwellUp = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToPrev, dwellingsList),
+	dwellUp = new CAdventureMapButton ("", "", std::bind(&CListBox::moveToPrev, dwellingsList),
 	                                  733, 24, "OVBUTN4.DEF");
 	dwellUp->setOffset(4);
 
-	dwellDown = new CAdventureMapButton ("", "", boost::bind(&CListBox::moveToNext, dwellingsList),
+	dwellDown = new CAdventureMapButton ("", "", std::bind(&CListBox::moveToNext, dwellingsList),
 	                                    733, footerPos-18, "OVBUTN4.DEF");
 	dwellDown->setOffset(6);
 }
@@ -684,7 +684,7 @@ CKingdHeroList::CKingdHeroList(size_t maxSize)
 
 	ui32 townCount = LOCPLINT->cb->howManyHeroes(false);
 	ui32 size = conf.go()->ac.overviewSize*116 + 19;
-	heroes = new CListBox(boost::bind(&CKingdHeroList::createHeroItem, this, _1), boost::bind(&CKingdHeroList::destroyHeroItem, this, _1),
+	heroes = new CListBox(std::bind(&CKingdHeroList::createHeroItem, this, _1), std::bind(&CKingdHeroList::destroyHeroItem, this, _1),
 	                      Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) );
 }
 
@@ -737,7 +737,7 @@ CKingdTownList::CKingdTownList(size_t maxSize)
 
 	ui32 townCount = LOCPLINT->cb->howManyTowns();
 	ui32 size = conf.go()->ac.overviewSize*116 + 19;
-	towns = new CListBox(boost::bind(&CKingdTownList::createTownItem, this, _1), CListBox::DestroyFunc(),
+	towns = new CListBox(std::bind(&CKingdTownList::createTownItem, this, _1), CListBox::DestroyFunc(),
 	                     Point(19,21), Point(0,116), maxSize, townCount, 0, 1, Rect(-19, -21, size, size) );
 }
 
@@ -784,7 +784,7 @@ CTownItem::CTownItem(const CGTownInstance* Town):
 	hall = new CTownInfo( 69, 31, town, true);
 	fort = new CTownInfo(111, 31, town, false);
 
-	garr = new CGarrisonInt(313, 3, 4, Point(232,0),  NULL, Point(313,2), town->getUpperArmy(), town->visitingHero, true, true, true);
+	garr = new CGarrisonInt(313, 3, 4, Point(232,0),  nullptr, Point(313,2), town->getUpperArmy(), town->visitingHero, true, true, true);
 	heroes = new HeroSlots(town, Point(244,6), Point(475,6), garr, false);
 
 	size_t iconIndex = town->town->clientInfo.icons[town->hasFort()][town->builded >= CGI->modh->settings.MAX_BUILDING_PER_TURN];
@@ -886,7 +886,7 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
 	heroArts->commonInfo = artsCommonPart;
 	heroArts->setHero(hero);
 
-	artsTabs = new CTabbedInt(boost::bind(&CHeroItem::onTabSelected, this, _1), boost::bind(&CHeroItem::onTabDeselected, this, _1));
+	artsTabs = new CTabbedInt(std::bind(&CHeroItem::onTabSelected, this, _1), std::bind(&CHeroItem::onTabDeselected, this, _1));
 
 	artButtons = new CHighlightableButtonsGroup(0);
 	for (size_t it = 0; it<3; it++)
@@ -900,11 +900,11 @@ CHeroItem::CHeroItem(const CGHeroInstance* Hero, CArtifactsOfHero::SCommonPart *
 		artButtons->addButton(tooltip, overlay, "OVBUTN3",364+it*112, 46, it);
 		artButtons->buttons[it]->addTextOverlay(CGI->generaltexth->allTexts[stringID[it]], FONT_SMALL, Colors::YELLOW);
 	}
-	artButtons->onChange += boost::bind(&CTabbedInt::setActive, artsTabs, _1);
-	artButtons->onChange += boost::bind(&CHeroItem::onArtChange, this, _1);
+	artButtons->onChange += std::bind(&CTabbedInt::setActive, artsTabs, _1);
+	artButtons->onChange += std::bind(&CHeroItem::onArtChange, this, _1);
 	artButtons->select(0,0);
 
-	garr = new CGarrisonInt(6, 78, 4, Point(), NULL, Point(), hero, NULL, true, true);
+	garr = new CGarrisonInt(6, 78, 4, Point(), nullptr, Point(), hero, nullptr, true, true);
 
 	portrait = new CAnimImage("PortraitsLarge", hero->portrait, 0, 5, 6);
 	heroArea = new CHeroArea(5, 6, hero);

+ 14 - 15
client/CMT.cpp

@@ -1,7 +1,6 @@
 // CMT.cpp : Defines the entry point for the console application.
 //
 #include "StdInc.h"
-#include <boost/filesystem/operations.hpp>
 #include <SDL_mixer.h>
 #include "gui/SDL_Extensions.h"
 #include "CGameInfo.h"
@@ -68,9 +67,9 @@ namespace po = boost::program_options;
 std::string NAME_AFFIX = "client";
 std::string NAME = GameConstants::VCMI_VERSION + std::string(" (") + NAME_AFFIX + ')'; //application name
 CGuiHandler GH;
-static CClient *client=NULL;
-SDL_Surface *screen = NULL, //main screen surface
-	*screen2 = NULL,//and hlp surface (used to store not-active interfaces layer)
+static CClient *client=nullptr;
+SDL_Surface *screen = nullptr, //main screen surface
+	*screen2 = nullptr,//and hlp surface (used to store not-active interfaces layer)
 	*screenBuf = screen; //points to screen (if only advmapint is present) or screen2 (else) - should be used when updating controls which are not regularly redrawed
 static boost::thread *mainGUIThread;
 
@@ -89,7 +88,7 @@ void dispose();
 void playIntro();
 static void listenForEvents();
 //void requestChangingResolution();
-void startGame(StartInfo * options, CConnection *serv = NULL);
+void startGame(StartInfo * options, CConnection *serv = nullptr);
 
 #ifndef _WIN32
 #ifndef _GNU_SOURCE
@@ -212,7 +211,7 @@ int main(int argc, char** argv)
 
     // Check that game data is prepared. Otherwise run vcmibuilder helper application
     FILE* check = fopen((VCMIDirs::get().localPath() + "/game_data_prepared").c_str(), "r");
-    if (check == NULL) {
+    if (check == nullptr) {
         system("open ./vcmibuilder.app");
         return 0;
     }
@@ -276,7 +275,7 @@ int main(int argc, char** argv)
 	CStopWatch total, pomtime;
 	std::cout.flags(std::ios::unitbuf);
 	console = new CConsoleHandler;
-	*console->cb = boost::bind(&processCommand, _1);
+	*console->cb = std::bind(&processCommand, _1);
 	console->start();
 	atexit(dispose);
 
@@ -314,7 +313,7 @@ int main(int argc, char** argv)
     logGlobal->infoStream() <<"Loading settings: "<<pomtime.getDiff();
     logGlobal->infoStream() << NAME;
 
-	srand ( time(NULL) );
+	srand ( time(nullptr) );
 	
 
 	const JsonNode& video = settings["video"];
@@ -367,7 +366,7 @@ int main(int argc, char** argv)
 	{
 		if(!vm.count("battle") && !vm.count("nointro"))
 			playIntro();
-		SDL_FillRect(screen,NULL,0);
+		SDL_FillRect(screen,nullptr,0);
 	}
 
 	CSDL_Ext::update(screen);
@@ -408,7 +407,7 @@ int main(int argc, char** argv)
 
 	if(!gNoGUI)
 	{
-		mainGUIThread = new boost::thread(&CGuiHandler::run, boost::ref(GH));
+		mainGUIThread = new boost::thread(&CGuiHandler::run, &GH);
 		listenForEvents();
 	}
 	else
@@ -560,7 +559,7 @@ void processCommand(const std::string &message)
 	}
 	else if(cn=="crash")
 	{
-		int *ptr = NULL;
+		int *ptr = nullptr;
 		*ptr = 666;
 		//disaster!
 	}
@@ -769,7 +768,7 @@ static void setScreenRes(int w, int h, int bpp, bool fullscreen, bool resetVideo
 		SDL_InitSubSystem(SDL_INIT_VIDEO);
 	}
 	
-	if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == NULL)
+	if((screen = SDL_SetVideoMode(w, h, suggestedBpp, SDL_SWSURFACE|(fullscreen?SDL_FULLSCREEN:0))) == nullptr)
 	{
         logGlobal->errorStream() << "Requested screen resolution is not available (" << w << "x" << h << "x" << suggestedBpp << "bpp)";
 		throw std::runtime_error("Requested screen resolution is not available\n");
@@ -914,7 +913,7 @@ static void listenForEvents()
 	}
 }
 
-void startGame(StartInfo * options, CConnection *serv/* = NULL*/)
+void startGame(StartInfo * options, CConnection *serv/* = nullptr*/)
 {
 	if(vm.count("onlyAI"))
 	{
@@ -959,10 +958,10 @@ void handleQuit()
 		GH.terminate = true;
 		mainGUIThread->join();
 		delete mainGUIThread;
-		mainGUIThread = NULL;
+		mainGUIThread = nullptr;
 	}
 	delete console;
-	console = NULL;
+	console = nullptr;
 	boost::this_thread::sleep(boost::posix_time::milliseconds(750));
 	if(!gNoGUI)
 		SDL_Quit();

+ 5 - 5
client/CMessage.cpp

@@ -65,7 +65,7 @@ namespace
 {
 	CDefHandler * ok, *cancel;
 	std::vector<std::vector<SDL_Surface*> > piecesOfBox; //in colors of all players
-	SDL_Surface * background = NULL;
+	SDL_Surface * background = nullptr;
 }
 
 void CMessage::init()
@@ -352,16 +352,16 @@ void CMessage::drawBorder(PlayerColor playerColor, SDL_Surface * ret, int w, int
 
 	//corners
 	Rect dstR(x, y, box[0]->w, box[0]->h);
-	CSDL_Ext::blitSurface(box[0], NULL, ret, &dstR);
+	CSDL_Ext::blitSurface(box[0], nullptr, ret, &dstR);
 
 	dstR=Rect(x+w-box[1]->w, y,   box[1]->w, box[1]->h);
-	CSDL_Ext::blitSurface(box[1], NULL, ret, &dstR);
+	CSDL_Ext::blitSurface(box[1], nullptr, ret, &dstR);
 
 	dstR=Rect(x, y+h-box[2]->h+1, box[2]->w, box[2]->h);
-	CSDL_Ext::blitSurface(box[2], NULL, ret, &dstR);
+	CSDL_Ext::blitSurface(box[2], nullptr, ret, &dstR);
 
 	dstR=Rect(x+w-box[3]->w, y+h-box[3]->h+1, box[3]->w, box[3]->h);
-	CSDL_Ext::blitSurface(box[3], NULL, ret, &dstR);
+	CSDL_Ext::blitSurface(box[3], nullptr, ret, &dstR);
 }
 
 ComponentResolved::ComponentResolved( CComponent *Comp ):

+ 9 - 9
client/CMusicHandler.cpp

@@ -83,7 +83,7 @@ void CSoundHandler::onVolumeChange(const JsonNode &volumeNode)
 CSoundHandler::CSoundHandler():
 	listener(settings.listen["general"]["sound"])
 {
-	listener(boost::bind(&CSoundHandler::onVolumeChange, this, _1));
+	listener(std::bind(&CSoundHandler::onVolumeChange, this, _1));
 
 	// Vectors for helper(s)
 	pickupSounds += soundBase::pickup01, soundBase::pickup02, soundBase::pickup03,
@@ -269,9 +269,9 @@ void CSoundHandler::setVolume(ui32 percent)
 		Mix_Volume(-1, (MIX_MAX_VOLUME * volume)/100);
 }
 
-void CSoundHandler::setCallback(int channel, boost::function<void()> function)
+void CSoundHandler::setCallback(int channel, std::function<void()> function)
 {
-	std::map<int, boost::function<void()> >::iterator iter;
+	std::map<int, std::function<void()> >::iterator iter;
 	iter = callbacks.find(channel);
 
 	//channel not found. It may have finished so fire callback now
@@ -283,7 +283,7 @@ void CSoundHandler::setCallback(int channel, boost::function<void()> function)
 
 void CSoundHandler::soundFinishedCallback(int channel)
 {
-	std::map<int, boost::function<void()> >::iterator iter;
+	std::map<int, std::function<void()> >::iterator iter;
 	iter = callbacks.find(channel);
 
 	assert(iter != callbacks.end());
@@ -302,7 +302,7 @@ void CMusicHandler::onVolumeChange(const JsonNode &volumeNode)
 CMusicHandler::CMusicHandler():
 	listener(settings.listen["general"]["music"])
 {
-	listener(boost::bind(&CMusicHandler::onVolumeChange, this, _1));
+	listener(std::bind(&CMusicHandler::onVolumeChange, this, _1));
 	// Map music IDs
 	// Vectors for helper
 	const std::string setEnemy[] = {"AITheme0", "AITheme1", "AITheme2"};
@@ -338,7 +338,7 @@ void CMusicHandler::release()
 	{
 		boost::mutex::scoped_lock guard(musicMutex);
 
-		Mix_HookMusicFinished(NULL);
+		Mix_HookMusicFinished(nullptr);
 
 		current.reset();
 		next.reset();
@@ -416,7 +416,7 @@ void CMusicHandler::stopMusic(int fade_ms)
 
 	boost::mutex::scoped_lock guard(musicMutex);
 
-	if (current.get() != NULL)
+	if (current.get() != nullptr)
 		current->stop(fade_ms);
 	next.reset();
 }
@@ -433,7 +433,7 @@ void CMusicHandler::musicFinishedCallback(void)
 {
 	boost::mutex::scoped_lock guard(musicMutex);
 
-	if (current.get() != NULL)
+	if (current.get() != nullptr)
 	{
 		//return if current music still not finished
 		if (current->play())
@@ -442,7 +442,7 @@ void CMusicHandler::musicFinishedCallback(void)
 			current.reset();
 	}
 
-	if (current.get() == NULL && next.get() != NULL)
+	if (current.get() == nullptr && next.get() != nullptr)
 	{
 		current.reset(next.release());
 		current->play();

+ 3 - 3
client/CMusicHandler.h

@@ -47,8 +47,8 @@ private:
 	Mix_Chunk *GetSoundChunk(std::string &sound);
 
 	//have entry for every currently active channel
-	//boost::function will be NULL if callback was not set
-	std::map<int, boost::function<void()> > callbacks;
+	//std::function will be nullptr if callback was not set
+	std::map<int, std::function<void()> > callbacks;
 
 public:
 	CSoundHandler();
@@ -65,7 +65,7 @@ public:
 	int playSoundFromSet(std::vector<soundBase::soundID> &sound_vec);
 	void stopSound(int handler);
 
-	void setCallback(int channel, boost::function<void()> function);
+	void setCallback(int channel, std::function<void()> function);
 	void soundFinishedCallback(int channel);
 
 	std::map<const CSpell*, std::string> spellSounds;

+ 17 - 17
client/CPlayerInterface.cpp

@@ -112,11 +112,11 @@ CPlayerInterface::CPlayerInterface(PlayerColor Player)
 	howManyPeople++;
 	GH.defActionsDef = 0;
 	LOCPLINT = this;
-	curAction = NULL;
+	curAction = nullptr;
 	playerID=Player;
 	human=true;
-	castleInt = NULL;
-	battleInt = NULL;
+	castleInt = nullptr;
+	battleInt = nullptr;
 	//pim = new boost::recursive_mutex;
 	makingTurn = false;
 	showingDialog = new CondSh<bool>(false);
@@ -138,12 +138,12 @@ CPlayerInterface::~CPlayerInterface()
 		if(adventureInt->active & CIntObject::KEYBOARD)
 			adventureInt->deactivateKeyboard();
 		delete adventureInt;
-		adventureInt = NULL;
+		adventureInt = nullptr;
 	}
 
 	delete cingconsole;
 
-	LOCPLINT = NULL;
+	LOCPLINT = nullptr;
 }
 void CPlayerInterface::init(shared_ptr<CCallback> CB)
 {
@@ -165,7 +165,7 @@ void CPlayerInterface::yourTurn()
 
 		LOCPLINT = this;
 		GH.curInt = this;
-		adventureInt->selection = NULL;
+		adventureInt->selection = nullptr;
 
 		if(firstCall)
 		{
@@ -520,7 +520,7 @@ void CPlayerInterface::heroInGarrisonChange(const CGTownInstance *town)
 			wanderingHeroes.push_back(town->visitingHero);
 	}
 	adventureInt->heroList.update();
-	adventureInt->updateNextHero(NULL);
+	adventureInt->updateNextHero(nullptr);
 
 	if(CCastleInterface *c = castleInt)
 	{
@@ -749,7 +749,7 @@ void CPlayerInterface::actionFinished(const BattleAction &action)
 
 	battleInt->endAction(curAction);
 	delete curAction;
-	curAction = NULL;
+	curAction = nullptr;
 }
 
 BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when it's turn of that stack
@@ -792,7 +792,7 @@ BattleAction CPlayerInterface::activeStack(const CStack * stack) //called when i
 	//tidy up
 	BattleAction ret = *(b->givenCommand->data);
 	delete b->givenCommand->data;
-	b->givenCommand->data = NULL;
+	b->givenCommand->data = nullptr;
 
 	//return command
     logGlobal->traceStream() << "Giving command for " << stack->nodeName();
@@ -1325,12 +1325,12 @@ bool CPlayerInterface::moveHero( const CGHeroInstance *h, CGPath path )
 
 bool CPlayerInterface::shiftPressed() const
 {
-	return SDL_GetKeyState(NULL)[SDLK_LSHIFT]  ||  SDL_GetKeyState(NULL)[SDLK_RSHIFT];
+	return SDL_GetKeyState(nullptr)[SDLK_LSHIFT]  ||  SDL_GetKeyState(nullptr)[SDLK_RSHIFT];
 }
 
 bool CPlayerInterface::altPressed() const
 {
-	return SDL_GetKeyState(NULL)[SDLK_LALT]  ||  SDL_GetKeyState(NULL)[SDLK_RALT];
+	return SDL_GetKeyState(nullptr)[SDLK_LALT]  ||  SDL_GetKeyState(nullptr)[SDLK_RALT];
 }
 
 void CPlayerInterface::showGarrisonDialog( const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID)
@@ -1468,7 +1468,7 @@ void CPlayerInterface::initializeHeroTownList()
 		towns.push_back(allTowns[i]);
 
 	if (adventureInt)
-		adventureInt->updateNextHero(NULL);
+		adventureInt->updateNextHero(nullptr);
 }
 
 void CPlayerInterface::showRecruitmentDialog(const CGDwelling *dwelling, const CArmedInstance *dst, int level)
@@ -1547,7 +1547,7 @@ void CPlayerInterface::objectRemoved( const CGObjectInstance *obj )
 
 bool CPlayerInterface::ctrlPressed() const
 {
-	return SDL_GetKeyState(NULL)[SDLK_LCTRL]  ||  SDL_GetKeyState(NULL)[SDLK_RCTRL];
+	return SDL_GetKeyState(nullptr)[SDLK_LCTRL]  ||  SDL_GetKeyState(nullptr)[SDLK_RCTRL];
 }
 
 void CPlayerInterface::update()
@@ -2133,7 +2133,7 @@ void CPlayerInterface::eraseCurrentPathOf( const CGHeroInstance * ho, bool check
 	assert(ho == adventureInt->selection);
 
 	paths.erase(ho);
-	adventureInt->terrain.currentPath = NULL;
+	adventureInt->terrain.currentPath = nullptr;
 	adventureInt->updateMoveHero(ho, false);
 }
 
@@ -2165,7 +2165,7 @@ CGPath * CPlayerInterface::getAndVerifyPath(const CGHeroInstance * h)
 		}
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 void CPlayerInterface::acceptTurn()
@@ -2193,7 +2193,7 @@ void CPlayerInterface::acceptTurn()
 	//show new day animation and sound on infobar
 	adventureInt->infoBar.showDate();
 
-	adventureInt->updateNextHero(NULL);
+	adventureInt->updateNextHero(nullptr);
 	adventureInt->showAll(screen);
 
 	if(settings["session"]["autoSkip"].Bool() && !LOCPLINT->shiftPressed())
@@ -2286,7 +2286,7 @@ void CPlayerInterface::showHillFortWindow(const CGObjectInstance *object, const
 	GH.pushInt(chfw);
 }
 
-void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket *bm /*= NULL*/)
+void CPlayerInterface::availableArtifactsChanged(const CGBlackMarket *bm /*= nullptr*/)
 {
 	EVENT_HANDLER_CALLED_BY_CLIENT;
 	if(CMarketplaceWindow *cmw = dynamic_cast<CMarketplaceWindow*>(GH.topInt()))

+ 72 - 72
client/CPlayerInterface.h

@@ -97,12 +97,12 @@ public:
 	static const int SAVES_COUNT = 5;
 	static int howManyPeople;
 
-	CCastleInterface * castleInt; //NULL if castle window isn't opened
-	static CBattleInterface * battleInt; //NULL if no battle
+	CCastleInterface * castleInt; //nullptr if castle window isn't opened
+	static CBattleInterface * battleInt; //nullptr if no battle
 	CInGameConsole * cingconsole;
 
 	shared_ptr<CCallback> cb; //to communicate with engine
-	const BattleAction *curAction; //during the battle - action currently performed by active stack (or NULL)
+	const BattleAction *curAction; //during the battle - action currently performed by active stack (or nullptr)
 
 	std::list<CInfoWindow *> dialogs; //queue of dialogs awaiting to be shown (not currently shown!)
 
@@ -133,13 +133,13 @@ public:
 	int getLastIndex(std::string namePrefix);
 
 	//overridden funcs from CGameInterface
-	void buildChanged(const CGTownInstance *town, BuildingID buildingID, int what) OVERRIDE; //what: 1 - built, 2 - demolished
-	void stackChagedCount(const StackLocation &location, const TQuantity &change, bool isAbsolute) OVERRIDE; //if absolute, change is the new count; otherwise count was modified by adding change
-	void stackChangedType(const StackLocation &location, const CCreature &newType) OVERRIDE; //used eg. when upgrading creatures
-	void stacksErased(const StackLocation &location) OVERRIDE; //stack removed from previously filled slot
-	void stacksSwapped(const StackLocation &loc1, const StackLocation &loc2) OVERRIDE;
-	void newStackInserted(const StackLocation &location, const CStackInstance &stack) OVERRIDE; //new stack inserted at given (previously empty position)
-	void stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count) OVERRIDE; //moves creatures from src stack to dst slot, may be used for merging/splittint/moving stacks
+	void buildChanged(const CGTownInstance *town, BuildingID buildingID, int what) override; //what: 1 - built, 2 - demolished
+	void stackChagedCount(const StackLocation &location, const TQuantity &change, bool isAbsolute) override; //if absolute, change is the new count; otherwise count was modified by adding change
+	void stackChangedType(const StackLocation &location, const CCreature &newType) override; //used eg. when upgrading creatures
+	void stacksErased(const StackLocation &location) override; //stack removed from previously filled slot
+	void stacksSwapped(const StackLocation &loc1, const StackLocation &loc2) override;
+	void newStackInserted(const StackLocation &location, const CStackInstance &stack) override; //new stack inserted at given (previously empty position)
+	void stacksRebalanced(const StackLocation &src, const StackLocation &dst, TQuantity count) override; //moves creatures from src stack to dst slot, may be used for merging/splittint/moving stacks
 
 	void artifactPut(const ArtifactLocation &al);
 	void artifactRemoved(const ArtifactLocation &al);
@@ -147,70 +147,70 @@ public:
 	void artifactAssembled(const ArtifactLocation &al);
 	void artifactDisassembled(const ArtifactLocation &al);
 
-	void heroCreated(const CGHeroInstance* hero) OVERRIDE;
-	void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) OVERRIDE;
-	void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) OVERRIDE;
-	void heroInGarrisonChange(const CGTownInstance *town) OVERRIDE;
-	void heroMoved(const TryMoveHero & details) OVERRIDE;
-	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) OVERRIDE;
-	void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) OVERRIDE;
-	void heroManaPointsChanged(const CGHeroInstance * hero) OVERRIDE;
-	void heroMovePointsChanged(const CGHeroInstance * hero) OVERRIDE;
-	void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town) OVERRIDE;
-	void receivedResource(int type, int val) OVERRIDE;
-	void showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID) OVERRIDE;
-	void showRecruitmentDialog(const CGDwelling *dwelling, const CArmedInstance *dst, int level) OVERRIDE;
-	void showShipyardDialog(const IShipyard *obj) OVERRIDE; //obj may be town or shipyard;
-	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, int soundID, bool selection, bool cancel) OVERRIDE; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
-	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) OVERRIDE;
-	void showPuzzleMap() OVERRIDE;
-	void showMarketWindow(const IMarket *market, const CGHeroInstance *visitor) OVERRIDE;
-	void showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor) OVERRIDE;
-	void showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor) OVERRIDE;
-	void showTavernWindow(const CGObjectInstance *townOrTavern) OVERRIDE;
-	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 newObject(const CGObjectInstance * obj) OVERRIDE;
-	void availableArtifactsChanged(const CGBlackMarket *bm = NULL) OVERRIDE; //bm may be NULL, then artifacts are changed in the global pool (used by merchants in towns)
-	void yourTurn() OVERRIDE;
-	void availableCreaturesChanged(const CGDwelling *town) OVERRIDE;
-	void heroBonusChanged(const CGHeroInstance *hero, const Bonus &bonus, bool gain) OVERRIDE;//if gain hero received bonus, else he lost it
-	void playerBonusChanged(const Bonus &bonus, bool gain) OVERRIDE;
-	void requestRealized(PackageApplied *pa) OVERRIDE;
-	void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) OVERRIDE;
-	void centerView (int3 pos, int focusTime) OVERRIDE;
-	void objectPropertyChanged(const SetObjectProperty * sop) OVERRIDE;
-	void objectRemoved(const CGObjectInstance *obj) OVERRIDE;
-	void gameOver(PlayerColor player, bool victory) OVERRIDE;
-	void playerStartsTurn(PlayerColor player) OVERRIDE; //called before yourTurn on active itnerface
-	void showComp(const Component &comp, std::string message) OVERRIDE; //display component in the advmapint infobox
-	void saveGame(COSer<CSaveFile> &h, const int version) OVERRIDE; //saving
-	void loadGame(CISer<CLoadFile> &h, const int version) OVERRIDE; //loading
+	void heroCreated(const CGHeroInstance* hero) override;
+	void heroGotLevel(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, QueryID queryID) override;
+	void commanderGotLevel (const CCommanderInstance * commander, std::vector<ui32> skills, QueryID queryID) override;
+	void heroInGarrisonChange(const CGTownInstance *town) override;
+	void heroMoved(const TryMoveHero & details) override;
+	void heroPrimarySkillChanged(const CGHeroInstance * hero, int which, si64 val) override;
+	void heroSecondarySkillChanged(const CGHeroInstance * hero, int which, int val) override;
+	void heroManaPointsChanged(const CGHeroInstance * hero) override;
+	void heroMovePointsChanged(const CGHeroInstance * hero) override;
+	void heroVisitsTown(const CGHeroInstance* hero, const CGTownInstance * town) override;
+	void receivedResource(int type, int val) override;
+	void showInfoDialog(const std::string &text, const std::vector<Component*> &components, int soundID) override;
+	void showRecruitmentDialog(const CGDwelling *dwelling, const CArmedInstance *dst, int level) override;
+	void showShipyardDialog(const IShipyard *obj) override; //obj may be town or shipyard;
+	void showBlockingDialog(const std::string &text, const std::vector<Component> &components, QueryID askID, int soundID, bool selection, bool cancel) override; //Show a dialog, player must take decision. If selection then he has to choose between one of given components, if cancel he is allowed to not choose. After making choice, CCallback::selectionMade should be called with number of selected component (1 - n) or 0 for cancel (if allowed) and askID.
+	void showGarrisonDialog(const CArmedInstance *up, const CGHeroInstance *down, bool removableUnits, QueryID queryID) override;
+	void showPuzzleMap() override;
+	void showMarketWindow(const IMarket *market, const CGHeroInstance *visitor) override;
+	void showUniversityWindow(const IMarket *market, const CGHeroInstance *visitor) override;
+	void showHillFortWindow(const CGObjectInstance *object, const CGHeroInstance *visitor) override;
+	void showTavernWindow(const CGObjectInstance *townOrTavern) override;
+	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 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;
+	void availableCreaturesChanged(const CGDwelling *town) override;
+	void heroBonusChanged(const CGHeroInstance *hero, const Bonus &bonus, bool gain) override;//if gain hero received bonus, else he lost it
+	void playerBonusChanged(const Bonus &bonus, bool gain) override;
+	void requestRealized(PackageApplied *pa) override;
+	void heroExchangeStarted(ObjectInstanceID hero1, ObjectInstanceID hero2, QueryID query) override;
+	void centerView (int3 pos, int focusTime) override;
+	void objectPropertyChanged(const SetObjectProperty * sop) override;
+	void objectRemoved(const CGObjectInstance *obj) override;
+	void gameOver(PlayerColor player, bool victory) override;
+	void playerStartsTurn(PlayerColor player) override; //called before yourTurn on active itnerface
+	void showComp(const Component &comp, std::string message) override; //display component in the advmapint infobox
+	void saveGame(COSer<CSaveFile> &h, const int version) override; //saving
+	void loadGame(CISer<CLoadFile> &h, const int version) override; //loading
 
 	//for battles
-	void actionFinished(const BattleAction& action) OVERRIDE;//occurs AFTER action taken by active stack or by the hero
-	void actionStarted(const BattleAction& action) OVERRIDE;//occurs BEFORE action taken by active stack or by the hero
-	BattleAction activeStack(const CStack * stack) OVERRIDE; //called when it's turn of that stack
-	void battleAttack(const BattleAttack *ba) OVERRIDE; //stack performs attack
-	void battleEnd(const BattleResult *br) OVERRIDE; //end of battle
-	void battleNewRoundFirst(int round) OVERRIDE; //called at the beginning of each turn before changes are applied; used for HP regen handling
-	void battleNewRound(int round) OVERRIDE; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
-	void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) OVERRIDE;
-	void battleSpellCast(const BattleSpellCast *sc) OVERRIDE;
-	void battleStacksEffectsSet(const SetStackEffect & sse) OVERRIDE; //called when a specific effect is set to stacks
-	void battleTriggerEffect(const BattleTriggerEffect & bte) OVERRIDE; //various one-shot effect
-	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) OVERRIDE;
-	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) OVERRIDE; //called by engine when battle starts; side=0 - left, side=1 - right
-	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) OVERRIDE; //called when stacks are healed / resurrected
-	void battleNewStackAppeared(const CStack * stack) OVERRIDE; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
-	void battleObstaclesRemoved(const std::set<si32> & removedObstacles) OVERRIDE; //called when a certain set  of obstacles is removed from batlefield; IDs of them are given
-	void battleCatapultAttacked(const CatapultAttack & ca) OVERRIDE; //called when catapult makes an attack
-	void battleStacksRemoved(const BattleStacksRemoved & bsr) OVERRIDE; //called when certain stack is completely removed from battlefield
-	void battleObstaclePlaced(const CObstacleInstance &obstacle) OVERRIDE;
-	void yourTacticPhase(int distance) OVERRIDE;
+	void actionFinished(const BattleAction& action) override;//occurs AFTER action taken by active stack or by the hero
+	void actionStarted(const BattleAction& action) override;//occurs BEFORE action taken by active stack or by the hero
+	BattleAction activeStack(const CStack * stack) override; //called when it's turn of that stack
+	void battleAttack(const BattleAttack *ba) override; //stack performs attack
+	void battleEnd(const BattleResult *br) override; //end of battle
+	void battleNewRoundFirst(int round) override; //called at the beginning of each turn before changes are applied; used for HP regen handling
+	void battleNewRound(int round) override; //called at the beginning of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
+	void battleStackMoved(const CStack * stack, std::vector<BattleHex> dest, int distance) override;
+	void battleSpellCast(const BattleSpellCast *sc) override;
+	void battleStacksEffectsSet(const SetStackEffect & sse) override; //called when a specific effect is set to stacks
+	void battleTriggerEffect(const BattleTriggerEffect & bte) override; //various one-shot effect
+	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa) override;
+	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side) override; //called by engine when battle starts; side=0 - left, side=1 - right
+	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, bool tentHeal, si32 lifeDrainFrom) override; //called when stacks are healed / resurrected
+	void battleNewStackAppeared(const CStack * stack) override; //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned
+	void battleObstaclesRemoved(const std::set<si32> & removedObstacles) override; //called when a certain set  of obstacles is removed from batlefield; IDs of them are given
+	void battleCatapultAttacked(const CatapultAttack & ca) override; //called when catapult makes an attack
+	void battleStacksRemoved(const BattleStacksRemoved & bsr) override; //called when certain stack is completely removed from battlefield
+	void battleObstaclePlaced(const CObstacleInstance &obstacle) override;
+	void yourTacticPhase(int distance) override;
 
 	//-------------//
 	void showArtifactAssemblyDialog(ui32 artifactID, ui32 assembleTo, bool assemble, CFunctionList<void()> onYes, CFunctionList<void()> onNo);

+ 66 - 66
client/CPreGame.cpp

@@ -53,15 +53,15 @@
  *
  */
 namespace fs = boost::filesystem;
-using boost::bind;
-using boost::ref;
+using std::bind;
+using std::ref;
 
 #if _MSC_VER >= 1600
-	//#define bind boost::bind
-	//#define ref boost::ref
+	//#define bind std::bind
+	//#define ref std::ref
 #endif
 
-void startGame(StartInfo * options, CConnection *serv = NULL);
+void startGame(StartInfo * options, CConnection *serv = nullptr);
 
 CGPreGame * CGP = nullptr;
 ISelectionScreenInfo *SEL;
@@ -92,8 +92,8 @@ struct EvilHlpStruct
 		}
 		else
 		{
-			serv = NULL;
-			sInfo = NULL;
+			serv = nullptr;
+			sInfo = nullptr;
 		}
 	}
 
@@ -206,7 +206,7 @@ class CBaseForPGApply
 public:
 	virtual void applyOnPG(CSelectionScreen *selScr, void *pack) const =0;
 	virtual ~CBaseForPGApply(){};
-	template<typename U> static CBaseForPGApply *getApplier(const U * t=NULL)
+	template<typename U> static CBaseForPGApply *getApplier(const U * t=nullptr)
 	{
 		return new CApplyOnPG<U>;
 	}
@@ -222,7 +222,7 @@ public:
 	}
 };
 
-static CApplier<CBaseForPGApply> *applier = NULL;
+static CApplier<CBaseForPGApply> *applier = nullptr;
 
 static CPicture* createPicture(const JsonNode& config)
 {
@@ -253,7 +253,7 @@ CMenuScreen::CMenuScreen(const JsonNode& configNode):
 	//Hardcoded entry
 	menuNameToEntry.push_back("credits");
 
-	tabs = new CTabbedInt(boost::bind(&CMenuScreen::createTab, this, _1), CTabbedInt::DestroyFunc());
+	tabs = new CTabbedInt(std::bind(&CMenuScreen::createTab, this, _1), CTabbedInt::DestroyFunc());
 	tabs->type |= REDRAW_PARENT;
 }
 
@@ -302,8 +302,8 @@ void CMenuScreen::switchToTab(size_t index)
 	tabs->setActive(index);
 }
 
-//funciton for std::string -> boost::function conversion for main menu
-static boost::function<void()> genCommand(CMenuScreen* menu, std::vector<std::string> menuType, const std::string &string)
+//funciton for std::string -> std::function conversion for main menu
+static std::function<void()> genCommand(CMenuScreen* menu, std::vector<std::string> menuType, const std::string &string)
 {
 	static const std::vector<std::string> commandType  = boost::assign::list_of
 		("to")("campaigns")("start")("load")("exit")("highscores");
@@ -326,11 +326,11 @@ static boost::function<void()> genCommand(CMenuScreen* menu, std::vector<std::st
 				{
 					size_t index2 = std::find(menuType.begin(), menuType.end(), commands.front()) - menuType.begin();
 					if ( index2 != menuType.size())
-						return boost::bind(&CMenuScreen::switchToTab, menu, index2);
+						return std::bind(&CMenuScreen::switchToTab, menu, index2);
 				}
 				break; case 1://open campaign selection window
 				{
-					return boost::bind(&CGPreGame::openCampaignScreen, CGP, commands.front());
+					return std::bind(&CGPreGame::openCampaignScreen, CGP, commands.front());
 				}
 				break; case 2://start
 				{
@@ -338,38 +338,38 @@ static boost::function<void()> genCommand(CMenuScreen* menu, std::vector<std::st
 					{
 						case 0: return bind(&CGPreGame::openSel, CGP, CMenuScreen::newGame, CMenuScreen::SINGLE_PLAYER);
 						case 1: return &pushIntT<CMultiMode>;
-						case 2: return boost::bind(&CGPreGame::openSel, CGP, CMenuScreen::campaignList, CMenuScreen::SINGLE_PLAYER);
-						case 3: return boost::function<void()>();//TODO: start tutorial
+						case 2: return std::bind(&CGPreGame::openSel, CGP, CMenuScreen::campaignList, CMenuScreen::SINGLE_PLAYER);
+						case 3: return std::function<void()>();//TODO: start tutorial
 					}
 				}
 				break; case 3://load
 				{
 					switch (std::find(gameType.begin(), gameType.end(), commands.front()) - gameType.begin())
 					{
-						case 0: return boost::bind(&CGPreGame::openSel, CGP, CMenuScreen::loadGame, CMenuScreen::SINGLE_PLAYER);
-						case 1: return boost::bind(&CGPreGame::openSel, CGP, CMenuScreen::loadGame, CMenuScreen::MULTI_HOT_SEAT);
-						case 2: return boost::function<void()>();//TODO: load campaign
-						case 3: return boost::function<void()>();//TODO: load tutorial
+						case 0: return std::bind(&CGPreGame::openSel, CGP, CMenuScreen::loadGame, CMenuScreen::SINGLE_PLAYER);
+						case 1: return std::bind(&CGPreGame::openSel, CGP, CMenuScreen::loadGame, CMenuScreen::MULTI_HOT_SEAT);
+						case 2: return std::function<void()>();//TODO: load campaign
+						case 3: return std::function<void()>();//TODO: load tutorial
 					}
 				}
 				break; case 4://exit
 				{
-					return boost::bind(CInfoWindow::showYesNoDialog, boost::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*>*)0, do_quit, 0, false, PlayerColor(1));
 				}
 				break; case 5://highscores
 				{
-					return boost::function<void()>(); //TODO: high scores &pushIntT<CHighScores>;
+					return std::function<void()>(); //TODO: high scores &pushIntT<CHighScores>;
 				}
 			}
 		}
 	}
     logGlobal->errorStream()<<"Failed to parse command: "<<string;
-	return boost::function<void()>();
+	return std::function<void()>();
 }
 
 CAdventureMapButton* CMenuEntry::createButton(CMenuScreen* parent, const JsonNode& button)
 {
-	boost::function<void()> command = genCommand(parent, parent->menuNameToEntry, button["command"].String());
+	std::function<void()> command = genCommand(parent, parent->menuNameToEntry, button["command"].String());
 
 	std::pair<std::string, std::string> help;
 	if (!button["help"].isNull() && button["help"].Float() > 0)
@@ -437,8 +437,8 @@ void CreditsScreen::show(SDL_Surface * to)
 	SDL_SetClipRect(screen, &creditsArea);
 	redraw();
 	CIntObject::showAll(to);
-	SDL_SetClipRect(screen, NULL);
-	SDL_SetClipRect(screenBuf, NULL);
+	SDL_SetClipRect(screen, nullptr);
+	SDL_SetClipRect(screenBuf, nullptr);
 
 	//end of credits, close this screen
 	if (credits->pos.y + credits->pos.h < 0)
@@ -520,7 +520,7 @@ void CGPreGame::update()
 	GH.updateTime();
 	GH.handleEvents();
 
-	//if (GH.curInt == NULL) // no redraw, when a new game was created
+	//if (GH.curInt == nullptr) // no redraw, when a new game was created
 		//return;
 
 	GH.topInt()->show(screen);
@@ -562,9 +562,9 @@ void CGPreGame::removeFromGui()
 	GH.popInt(GH.topInt()); //remove background
 }
 
-CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/, const std::map<ui8, std::string> * Names /*= NULL*/, const std::string & Address /*=""*/, const std::string & Port /*= ""*/)
-	: ISelectionScreenInfo(Names), serverHandlingThread(NULL), mx(new boost::recursive_mutex),
-	  serv(NULL), ongoingClosing(false), myNameID(255)
+CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/, const std::map<ui8, std::string> * Names /*= nullptr*/, const std::string & Address /*=""*/, const std::string & Port /*= ""*/)
+	: ISelectionScreenInfo(Names), serverHandlingThread(nullptr), mx(new boost::recursive_mutex),
+	  serv(nullptr), ongoingClosing(false), myNameID(255)
 {
 	CGPreGame::create(); //we depend on its graphics
 	screenType = Type;
@@ -574,7 +574,7 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 
 	bool network = (MultiPlayer == CMenuScreen::MULTI_NETWORK_GUEST || MultiPlayer == CMenuScreen::MULTI_NETWORK_HOST);
 
-	CServerHandler *sh = NULL;
+	CServerHandler *sh = nullptr;
 	if(multiPlayer == CMenuScreen::MULTI_NETWORK_HOST)
 	{
 		sh = new CServerHandler;
@@ -605,16 +605,16 @@ CSelectionScreen::CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMulti
 	}
 
 	sInfo.difficulty = 1;
-	current = NULL;
+	current = nullptr;
 
 	sInfo.mode = (Type == CMenuScreen::newGame ? StartInfo::NEW_GAME : StartInfo::LOAD_GAME);
 	sInfo.turnTime = 0;
-	curTab = NULL;
+	curTab = nullptr;
 
 	card = new InfoCard(network); //right info card
 	if (screenType == CMenuScreen::campaignList)
 	{
-		opt = NULL;
+		opt = nullptr;
 	}
 	else
 	{
@@ -794,7 +794,7 @@ void CSelectionScreen::toggleTab(CIntObject *tab)
 	}
 	else
 	{
-		curTab = NULL;
+		curTab = nullptr;
 	};
 	GH.totalRedraw();
 }
@@ -814,7 +814,7 @@ void CSelectionScreen::changeSelection(const CMapInfo * to)
 	   SEL->sInfo.difficulty = to->scenarioOpts->difficulty;
 	if(screenType != CMenuScreen::campaignList)
 	{
-		updateStartInfo(to ? to->fileURI : "", sInfo, to ? to->mapHeader.get() : NULL);
+		updateStartInfo(to ? to->fileURI : "", sInfo, to ? to->mapHeader.get() : nullptr);
 		if(screenType == CMenuScreen::newGame)
 		{
 			if(to && to->isRandomMap)
@@ -910,7 +910,7 @@ void CSelectionScreen::startScenario()
 
 		StartInfo * si = new StartInfo(sInfo);
 		CGP->removeFromGui();
-		CGP->showLoadingScreen(boost::bind(&startGame, si, (CConnection *)nullptr));
+		CGP->showLoadingScreen(std::bind(&startGame, si, (CConnection *)nullptr));
 	}
 	else
 	{
@@ -920,7 +920,7 @@ void CSelectionScreen::startScenario()
 		saveGameName = "Saves/" + sel->txt->text;
 
 		CFunctionList<void()> overWrite;
-		overWrite += boost::bind(&CCallback::save, LOCPLINT->cb.get(), saveGameName);
+		overWrite += std::bind(&CCallback::save, LOCPLINT->cb.get(), saveGameName);
 		overWrite += bind(&CGuiHandler::popIntTotally, &GH, this);
 
 		if(CResourceHandler::get()->existsResource(ResourceID(saveGameName, EResType::CLIENT_SAVEGAME)))
@@ -950,7 +950,7 @@ void CSelectionScreen::handleConnection()
 		assert(serv);
 		while(serv)
 		{
-			CPackForSelectionScreen *pack = NULL;
+			CPackForSelectionScreen *pack = nullptr;
 			*serv >> pack;
             logNetwork->traceStream() << "Received a pack of type " << typeid(*pack).name();
 			assert(pack);
@@ -1093,7 +1093,7 @@ void SelectionTab::filter( int size, bool selectFirst )
 	else
 	{
 		slider->block(true);
-		onSelect(NULL);
+		onSelect(nullptr);
 	}
 }
 
@@ -1189,14 +1189,14 @@ void SelectionTab::parseCampaigns(const std::vector<ResourceID> & files )
 	}
 }
 
-SelectionTab::SelectionTab(CMenuScreen::EState Type, const boost::function<void(CMapInfo *)> &OnSelect, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/)
-	:bg(NULL), onSelect(OnSelect)
+SelectionTab::SelectionTab(CMenuScreen::EState Type, const std::function<void(CMapInfo *)> &OnSelect, CMenuScreen::EMultiMode MultiPlayer /*= CMenuScreen::SINGLE_PLAYER*/)
+	:bg(nullptr), onSelect(OnSelect)
 {
 	OBJ_CONSTRUCTION;
 	selectionPos = 0;
 	addUsedEvents(LCLICK | WHEEL | KEYBOARD | DOUBLECLICK);
-	slider = NULL;
-	txt = NULL;
+	slider = nullptr;
+	txt = nullptr;
 	tabType = Type;
 
 	if (Type != CMenuScreen::campaignList)
@@ -1936,14 +1936,14 @@ void CChatBox::addNewMessage(const std::string &text)
 }
 
 InfoCard::InfoCard( bool Network )
-  : bg(NULL), network(Network), chatOn(false), chat(NULL), playerListBg(NULL),
-	difficulty(NULL), sizes(NULL), sFlags(NULL)
+  : bg(nullptr), network(Network), chatOn(false), chat(nullptr), playerListBg(nullptr),
+	difficulty(nullptr), sizes(nullptr), sFlags(nullptr)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	pos.x += 393;
 	pos.y += 6;
 	addUsedEvents(RCLICK);
-	mapDescription = NULL;
+	mapDescription = nullptr;
 
 	Rect descriptionRect(26, 149, 320, 115);
 	mapDescription = new CTextBox("", descriptionRect, 1);
@@ -2244,7 +2244,7 @@ void InfoCard::setChat(bool activateChat)
 }
 
 OptionsTab::OptionsTab():
-	turnDuration(NULL)
+	turnDuration(nullptr)
 {
 	OBJ_CONSTRUCTION;
 	bg = new CPicture("ADVOPTBK", 0, 6);
@@ -2453,7 +2453,7 @@ void OptionsTab::setTurnLength( int npos )
 void OptionsTab::flagPressed( PlayerColor color )
 {
 	PlayerSettings &clicked =  SEL->sInfo.playerInfos[color];
-	PlayerSettings *old = NULL;
+	PlayerSettings *old = nullptr;
 
 	if(SEL->playerNames.size() == 1) //single player -> just swap
 	{
@@ -2564,7 +2564,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
 	}
 	else
 		for(int i = 0; i < 6; i++)
-			btns[i] = NULL;
+			btns[i] = nullptr;
 
 	selectButtons();
 
@@ -2586,7 +2586,7 @@ OptionsTab::PlayerOptionsEntry::PlayerOptionsEntry( OptionsTab *owner, PlayerSet
 		flag->hoverable = true;
 	}
 	else
-		flag = NULL;
+		flag = nullptr;
 
 	town = new SelectedBox(Point(119, 2), s, TOWN);
 	hero = new SelectedBox(Point(195, 2), s, HERO);
@@ -3103,7 +3103,7 @@ CHotSeatPlayers::CHotSeatPlayers(const std::string &firstPlayer)
 	for(int i = 0; i < ARRAY_COUNT(txt); i++)
 	{
 		txt[i] = new CTextInput(Rect(60, 85 + i*30, 280, 16), *bg);
-		txt[i]->cb += boost::bind(&CHotSeatPlayers::onChange, this, _1);
+		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);
@@ -3195,7 +3195,7 @@ void CBonusSelection::init()
 		{
 			regions.push_back(new CRegion(this, true, true, g));
 			regions[regions.size()-1]->rclickText = ourCampaign->camp->scenarios[g].regionText;
-			if (highlightedRegion == NULL)
+			if (highlightedRegion == nullptr)
 			{
 				highlightedRegion = regions.back();
 				selectMap(g, true);
@@ -3609,7 +3609,7 @@ void CBonusSelection::startMap()
 
 	auto exitCb = [si]()
 	{
-		CGP->showLoadingScreen(boost::bind(&startGame, si, (CConnection *)nullptr));
+		CGP->showLoadingScreen(std::bind(&startGame, si, (CConnection *)nullptr));
 	};
 
 	if (scenario.prolog.hasPrologEpilog)
@@ -3771,12 +3771,12 @@ CSavingScreen::~CSavingScreen()
 
 }
 
-ISelectionScreenInfo::ISelectionScreenInfo(const std::map<ui8, std::string> *Names /*= NULL*/)
+ISelectionScreenInfo::ISelectionScreenInfo(const std::map<ui8, std::string> *Names /*= nullptr*/)
 {
 	multiPlayer = CMenuScreen::SINGLE_PLAYER;
 	assert(!SEL);
 	SEL = this;
-	current = NULL;
+	current = nullptr;
 
 	if(Names && Names->size()) //if have custom set of player names - use it
 		playerNames = *Names;
@@ -3787,7 +3787,7 @@ ISelectionScreenInfo::ISelectionScreenInfo(const std::map<ui8, std::string> *Nam
 ISelectionScreenInfo::~ISelectionScreenInfo()
 {
 	assert(SEL == this);
-	SEL = NULL;
+	SEL = nullptr;
 }
 
 void ISelectionScreenInfo::updateStartInfo(std::string filename, StartInfo & sInfo, const CMapHeader * mapHeader)
@@ -3953,11 +3953,11 @@ void StartWithCurrentSettings::apply(CSelectionScreen *selScreen)
 		*selScreen->serv << this; //resend to confirm
 	}
 
-	selScreen->serv = NULL; //hide it so it won't be deleted
+	selScreen->serv = nullptr; //hide it so it won't be deleted
 	vstd::clear_pointer(selScreen->serverHandlingThread); //detach us
 	saveGameName.clear();
 
-	CGP->showLoadingScreen(boost::bind(&startGame, startingInfo.sInfo, startingInfo.serv));
+	CGP->showLoadingScreen(std::bind(&startGame, startingInfo.sInfo, startingInfo.serv));
 	throw 666; //EVIL, EVIL, EVIL workaround to kill thread (does "goto catch" outside listening loop)
 }
 
@@ -4037,7 +4037,7 @@ CAdventureMapButton* CCampaignScreen::createExitButton(const JsonNode& button)
 	if (!button["help"].isNull() && button["help"].Float() > 0)
 		help = CGI->generaltexth->zelp[button["help"].Float()];
 
-	boost::function<void()> close = boost::bind(&CGuiHandler::popIntTotally, &GH, this);
+	std::function<void()> close = std::bind(&CGuiHandler::popIntTotally, &GH, this);
 	return new CAdventureMapButton(help, close, button["x"].Float(), button["y"].Float(), button["name"].String(), button["hotkey"].Float());
 }
 
@@ -4074,7 +4074,7 @@ void CCampaignScreen::showAll(SDL_Surface *to)
 		CMessage::drawBorder(PlayerColor(1), to, pos.w+28, pos.h+30, pos.x-14, pos.y-15);
 }
 
-void CGPreGame::showLoadingScreen(boost::function<void()> loader)
+void CGPreGame::showLoadingScreen(std::function<void()> loader)
 {
 	if (GH.listInt.size() && GH.listInt.front() == CGP) //pregame active
 		CGP->removeFromGui();
@@ -4090,7 +4090,7 @@ std::string CLoadingScreen::getBackground()
 	return conf[ rand() % conf.size() ].String();
 }
 
-CLoadingScreen::CLoadingScreen(boost::function<void ()> loader):
+CLoadingScreen::CLoadingScreen(std::function<void ()> loader):
     CWindowObject(BORDERED, getBackground()),
     loadingThread(loader)
 {
@@ -4163,11 +4163,11 @@ CSimpleJoinScreen::CSimpleJoinScreen()
 	title = new CTextBox("Enter address:", boxRect, 0, FONT_BIG, CENTER, Colors::WHITE);
 
 	address = new CTextInput(Rect(25, 68, 175, 16), *bg);
-	address->cb += boost::bind(&CSimpleJoinScreen::onChange, this, _1);
+	address->cb += std::bind(&CSimpleJoinScreen::onChange, this, _1);
 
 	port = new CTextInput(Rect(25, 115, 175, 16), *bg);
-	port->cb += boost::bind(&CSimpleJoinScreen::onChange, this, _1);
-	port->filters.add(boost::bind(&CTextInput::numberFilter, _1, _2, 0, 65535));
+	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);
@@ -4184,7 +4184,7 @@ void CSimpleJoinScreen::enterSelectionScreen()
 	std::string textPort = port->text;
 
 	GH.popIntTotally(this);
-	GH.pushInt(new CSelectionScreen(CMenuScreen::newGame, CMenuScreen::MULTI_NETWORK_GUEST, NULL, textAddress, textPort));
+	GH.pushInt(new CSelectionScreen(CMenuScreen::newGame, CMenuScreen::MULTI_NETWORK_GUEST, nullptr, textAddress, textPort));
 }
 
 void CSimpleJoinScreen::onChange(const std::string & newText)

+ 6 - 6
client/CPreGame.h

@@ -157,7 +157,7 @@ public:
 	std::vector<CMapInfo> allItems;
 	std::vector<CMapInfo*> curItems;
 	size_t selectionPos;
-	boost::function<void(CMapInfo *)> onSelect;
+	std::function<void(CMapInfo *)> onSelect;
 
 	ESortBy sortingBy;
 	bool ascending;
@@ -181,7 +181,7 @@ public:
 	void clickLeft(tribool down, bool previousState);
 	void keyPressed(const SDL_KeyboardEvent & key);
 	void onDoubleClick();
-	SelectionTab(CMenuScreen::EState Type, const boost::function<void(CMapInfo *)> &OnSelect, CMenuScreen::EMultiMode MultiPlayer = CMenuScreen::SINGLE_PLAYER);
+	SelectionTab(CMenuScreen::EState Type, const std::function<void(CMapInfo *)> &OnSelect, CMenuScreen::EMultiMode MultiPlayer = CMenuScreen::SINGLE_PLAYER);
     ~SelectionTab();
 };
 
@@ -321,7 +321,7 @@ public:
 	StartInfo sInfo;
 	std::map<ui8, std::string> playerNames; // id of player <-> player name; 0 is reserved as ID of AI "players"
 
-	ISelectionScreenInfo(const std::map<ui8, std::string> *Names = NULL);
+	ISelectionScreenInfo(const std::map<ui8, std::string> *Names = nullptr);
 	virtual ~ISelectionScreenInfo();
 	virtual void update(){};
 	virtual void propagateOptions() {};
@@ -359,7 +359,7 @@ public:
 	bool ongoingClosing;
 	ui8 myNameID; //used when networking - otherwise all player are "mine"
 
-	CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer = CMenuScreen::SINGLE_PLAYER, const std::map<ui8, std::string> * Names = NULL, const std::string & Address = "", const std::string & Port = "");
+	CSelectionScreen(CMenuScreen::EState Type, CMenuScreen::EMultiMode MultiPlayer = CMenuScreen::SINGLE_PLAYER, const std::map<ui8, std::string> * Names = nullptr, const std::string & Address = "", const std::string & Port = "");
 	~CSelectionScreen();
 	void toggleTab(CIntObject *tab);
 	void changeSelection(const CMapInfo *to);
@@ -591,7 +591,7 @@ public:
 
 	static CGPreGame * create();
 	void removeFromGui();
-	static void showLoadingScreen(boost::function<void()> loader);
+	static void showLoadingScreen(std::function<void()> loader);
 };
 
 class CLoadingScreen : public CWindowObject
@@ -600,7 +600,7 @@ class CLoadingScreen : public CWindowObject
 
 	std::string getBackground();
 public:
-	CLoadingScreen(boost::function<void()> loader);
+	CLoadingScreen(std::function<void()> loader);
 	~CLoadingScreen();
 
 	void showAll(SDL_Surface *to);

+ 7 - 7
client/CQuestLog.cpp

@@ -66,7 +66,7 @@ void CQuestIcon::showAll(SDL_Surface * to)
 
 CQuestMinimap::CQuestMinimap (const Rect & position) :
 CMinimap (position),
-	currentQuest (NULL)
+	currentQuest (nullptr)
 {
 }
 
@@ -90,7 +90,7 @@ void CQuestMinimap::addQuestMarks (const QuestInfo * q)
 	CQuestIcon * pic = new CQuestIcon ("VwSymbol.def", 3, x, y);
 
 	pic->moveBy (Point ( -pic->pos.w/2, -pic->pos.h/2));
-	pic->callback = boost::bind (&CQuestMinimap::iconClicked, this);
+	pic->callback = std::bind (&CQuestMinimap::iconClicked, this);
 
 	icons.push_back(pic);
 }
@@ -119,9 +119,9 @@ void CQuestMinimap::showAll(SDL_Surface * to)
 CQuestLog::CQuestLog (const std::vector<QuestInfo> & Quests) :
 	CWindowObject(PLAYER_COLORED, "QuestLog.pcx"),
 	questIndex(0),
-	currentQuest(NULL),
+	currentQuest(nullptr),
 	quests (Quests),
-	slider(NULL)
+	slider(nullptr)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	init();
@@ -131,10 +131,10 @@ void CQuestLog::init()
 {
 	minimap = new CQuestMinimap (Rect (47, 33, 144, 144));
 	description = new CTextBox ("", Rect(245, 33, 350, 355), 1, FONT_MEDIUM, TOPLEFT, Colors::WHITE);
-	ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, boost::bind(&CQuestLog::close,this), 547, 401, "IOKAY.DEF", SDLK_RETURN);
+	ok = new CAdventureMapButton("",CGI->generaltexth->zelp[445].second, std::bind(&CQuestLog::close,this), 547, 401, "IOKAY.DEF", SDLK_RETURN);
 
 	if (quests.size() > QUEST_COUNT)
-		slider = new CSlider(203, 199, 230, boost::bind (&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, quests.size(), false, 0);
+		slider = new CSlider(203, 199, 230, std::bind (&CQuestLog::sliderMoved, this, _1), QUEST_COUNT, quests.size(), false, 0);
 
 	for (int i = 0; i < quests.size(); ++i)
 	{
@@ -143,7 +143,7 @@ void CQuestLog::init()
 		if (quests[i].obj)
 			text.addReplacement (quests[i].obj->getHoverText()); //get name of the object
 		CQuestLabel * label = new CQuestLabel (28, 199 + i * 24, FONT_SMALL, TOPLEFT, Colors::WHITE, text.toString());
-		label->callback = boost::bind(&CQuestLog::selectQuest, this, i);
+		label->callback = std::bind(&CQuestLog::selectQuest, this, i);
 		label->setBounds (172, 30);
 		labels.push_back(label);
 	}

+ 2 - 2
client/CQuestLog.h

@@ -36,7 +36,7 @@ const int QUEST_COUNT = 9;
 class CQuestLabel : public LRClickableAreaWText, public CBoundedLabel
 {
 public:
-	boost::function<void()> callback;
+	std::function<void()> callback;
 
 	CQuestLabel (int x=0, int y=0, EFonts Font = FONT_SMALL, EAlignment Align = TOPLEFT, const SDL_Color &Color = Colors::WHITE, const std::string &Text =  "")
 		: CBoundedLabel (x, y, FONT_SMALL, TOPLEFT, Colors::WHITE, Text){};
@@ -47,7 +47,7 @@ public:
 class CQuestIcon : public CAnimImage
 {
 public:
-	boost::function<void()> callback; //TODO: merge with other similiar classes?
+	std::function<void()> callback; //TODO: merge with other similiar classes?
 
 	CQuestIcon (const std::string &defname, int index, int x=0, int y=0);
 

+ 16 - 16
client/CSpellWindow.cpp

@@ -31,8 +31,8 @@
  *
  */
 
-SpellbookInteractiveArea::SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL,
-	const std::string & textR, boost::function<void()> funcHon, boost::function<void()> funcHoff, CPlayerInterface * _myInt)
+SpellbookInteractiveArea::SpellbookInteractiveArea(const SDL_Rect & myRect, std::function<void()> funcL,
+	const std::string & textR, std::function<void()> funcHon, std::function<void()> funcHoff, CPlayerInterface * _myInt)
 {
 	addUsedEvents(LCLICK | RCLICK | HOVER);
 	pos = myRect;
@@ -159,29 +159,29 @@ CSpellWindow::CSpellWindow(const SDL_Rect &, const CGHeroInstance * _myHero, CPl
 
 	statusBar = new CGStatusBar(7 + pos.x, 569 + pos.y, "Spelroll.bmp");
 	SDL_Rect temp_rect = genRect(45, 35, 479 + pos.x, 405 + pos.y);
-	exitBtn = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fexitb, this), CGI->generaltexth->zelp[460].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[460].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	exitBtn = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::fexitb, this), CGI->generaltexth->zelp[460].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[460].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(45, 35, 221 + pos.x, 405 + pos.y);
-	battleSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fbattleSpellsb, this), CGI->generaltexth->zelp[453].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[453].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	battleSpells = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::fbattleSpellsb, this), CGI->generaltexth->zelp[453].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[453].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(45, 35, 355 + pos.x, 405 + pos.y);
-	adventureSpells = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fadvSpellsb, this), CGI->generaltexth->zelp[452].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[452].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	adventureSpells = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::fadvSpellsb, this), CGI->generaltexth->zelp[452].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[452].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(45, 35, 418 + pos.x, 405 + pos.y);
-	manaPoints = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fmanaPtsb, this), CGI->generaltexth->zelp[459].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[459].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	manaPoints = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::fmanaPtsb, this), CGI->generaltexth->zelp[459].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[459].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 
 	temp_rect = genRect(36, 56, 549 + pos.x, 94 + pos.y);
-	selectSpellsA = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 0), CGI->generaltexth->zelp[454].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[454].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	selectSpellsA = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 0), CGI->generaltexth->zelp[454].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[454].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(36, 56, 549 + pos.x, 151 + pos.y);
-	selectSpellsE = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 3), CGI->generaltexth->zelp[457].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[457].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	selectSpellsE = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 3), CGI->generaltexth->zelp[457].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[457].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(36, 56, 549 + pos.x, 210 + pos.y);
-	selectSpellsF = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 1), CGI->generaltexth->zelp[455].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[455].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	selectSpellsF = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 1), CGI->generaltexth->zelp[455].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[455].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(36, 56, 549 + pos.x, 270 + pos.y);
-	selectSpellsW = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 2), CGI->generaltexth->zelp[456].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[456].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	selectSpellsW = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 2), CGI->generaltexth->zelp[456].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[456].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(36, 56, 549 + pos.x, 330 + pos.y);
-	selectSpellsAll = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::selectSchool, this, 4), CGI->generaltexth->zelp[458].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[458].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	selectSpellsAll = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::selectSchool, this, 4), CGI->generaltexth->zelp[458].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[458].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 
 	temp_rect = genRect(leftCorner->h, leftCorner->w, 97 + pos.x, 77 + pos.y);
-	lCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fLcornerb, this), CGI->generaltexth->zelp[450].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[450].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	lCorner = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::fLcornerb, this), CGI->generaltexth->zelp[450].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[450].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 	temp_rect = genRect(rightCorner->h, rightCorner->w, 487 + pos.x, 72 + pos.y);
-	rCorner = new SpellbookInteractiveArea(temp_rect, boost::bind(&CSpellWindow::fRcornerb, this), CGI->generaltexth->zelp[451].second, boost::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[451].first)), boost::bind(&CGStatusBar::clear, statusBar), myInt);
+	rCorner = new SpellbookInteractiveArea(temp_rect, std::bind(&CSpellWindow::fRcornerb, this), CGI->generaltexth->zelp[451].second, std::bind(&CGStatusBar::print, statusBar, (CGI->generaltexth->zelp[451].first)), std::bind(&CGStatusBar::clear, statusBar), myInt);
 
 	//areas for spells
 	int xpos = 117 + pos.x, ypos = 90 + pos.y;
@@ -758,7 +758,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 						for(size_t i=0;i<Towns.size();i++)
 						{
 							const CGTownInstance *t = Towns[i];
-							if (t->visitingHero == NULL) //empty town and this is
+							if (t->visitingHero == nullptr) //empty town and this is
 							{
 								availableTowns.push_back(t->id.getNum());//add to the list
 							}
@@ -769,7 +769,7 @@ void CSpellWindow::SpellArea::clickLeft(tribool down, bool previousState)
 							GH.pushInt (new CObjectListWindow(availableTowns,
 								new CPicture(graphics->spellscr->ourImages[spell].bitmap, 0, 0, false),
 								CGI->generaltexth->jktexts[40], CGI->generaltexth->jktexts[41],
-								boost::bind (&CSpellWindow::teleportTo, owner, _1, h)));
+								std::bind (&CSpellWindow::teleportTo, owner, _1, h)));
 					}
 					return;
 				}
@@ -790,7 +790,7 @@ void CSpellWindow::SpellArea::clickRight(tribool down, bool previousState)
 	{
 		std::string dmgInfo;
 		const CGHeroInstance * hero = owner->myHero;
-		int causedDmg = owner->myInt->cb->estimateSpellDamage( CGI->spellh->spells[mySpell], (hero ? hero : NULL));
+		int causedDmg = owner->myInt->cb->estimateSpellDamage( CGI->spellh->spells[mySpell], (hero ? hero : nullptr));
 		if(causedDmg == 0 || mySpell == 57) //Titan's Lightning Bolt already has damage info included
 			dmgInfo = "";
 		else

+ 5 - 5
client/CSpellWindow.h

@@ -24,18 +24,18 @@ class CPlayerInterface;
 class SpellbookInteractiveArea : public CIntObject
 {
 private:
-	boost::function<void()> onLeft;
+	std::function<void()> onLeft;
 	std::string textOnRclick;
-	boost::function<void()> onHoverOn;
-	boost::function<void()> onHoverOff;
+	std::function<void()> onHoverOn;
+	std::function<void()> onHoverOff;
 	CPlayerInterface * myInt;
 public:
 	void clickLeft(tribool down, bool previousState);
 	void clickRight(tribool down, bool previousState);
 	void hover(bool on);
 
-	SpellbookInteractiveArea(const SDL_Rect & myRect, boost::function<void()> funcL, const std::string & textR,
-		boost::function<void()> funcHon, boost::function<void()> funcHoff, CPlayerInterface * _myInt);//c-tor
+	SpellbookInteractiveArea(const SDL_Rect & myRect, std::function<void()> funcL, const std::string & textR,
+		std::function<void()> funcHon, std::function<void()> funcHoff, CPlayerInterface * _myInt);//c-tor
 };
 
 /// The spell window

+ 44 - 47
client/CVideoHandler.cpp

@@ -23,9 +23,6 @@ static bool keyDown()
 
 #ifdef _WIN32
 
-#include <boost/algorithm/string/predicate.hpp>
-
-
 void checkForError(bool throwing = true)
 {
 	int error = GetLastError();
@@ -34,13 +31,13 @@ void checkForError(bool throwing = true)
 
     logGlobal->errorStream() << "Error " << error << " encountered!";
 	std::string msg;
-	char* pTemp = NULL;
+	char* pTemp = nullptr;
 	FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
-		NULL, error,  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, NULL );
+		nullptr, error,  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, nullptr );
     logGlobal->errorStream() << "Error: " << pTemp;
 	msg = pTemp;
 	LocalFree( pTemp );
-	pTemp = NULL;
+	pTemp = nullptr;
 	if(throwing)
 		throw std::runtime_error(msg);
 }
@@ -75,7 +72,7 @@ void *DLLHandler::FindAddress(const char *symbol)
 	if(!dll)
 	{
         logGlobal->errorStream() << "Cannot look for " << symbol << " because DLL hasn't been appropriately loaded!";
-		return NULL;
+		return nullptr;
 	}
 	ret = (void*) GetProcAddress(dll,symbol);
 	if(!ret)
@@ -100,7 +97,7 @@ DLLHandler::~DLLHandler()
 
 DLLHandler::DLLHandler()
 {
-	dll = NULL;
+	dll = nullptr;
 }
 
 CBIKHandler::CBIKHandler()
@@ -117,10 +114,10 @@ CBIKHandler::CBIKHandler()
 	binkClose =  (BinkClose)FindAddress("_BinkClose@4");
 
 
-	hBinkFile = NULL;
-	hBink = NULL;
+	hBinkFile = nullptr;
+	hBink = nullptr;
 
-	buffer = NULL;
+	buffer = nullptr;
 	bufferSize = 0;
 }
 
@@ -131,7 +128,7 @@ bool CBIKHandler::open(std::string name)
 		name.c_str(),				// file name
 		GENERIC_READ,						// access mode
 		FILE_SHARE_READ,	// share mode
-		NULL,								// Security Descriptor
+		nullptr,								// Security Descriptor
 		OPEN_EXISTING,						// how to create
 		FILE_ATTRIBUTE_NORMAL,//FILE_FLAG_SEQUENTIAL_SCAN,			// file attributes
 		0								// handle to template file
@@ -146,7 +143,7 @@ bool CBIKHandler::open(std::string name)
     {
 		void *waveout = GetProcAddress(dll,"_BinkOpenWaveOut@4");
 		if(waveout)
-			binkSetSoundSystem(waveout,NULL);
+			binkSetSoundSystem(waveout,nullptr);
 
     }
 
@@ -162,7 +159,7 @@ bool CBIKHandler::open(std::string name)
 
 checkErrorAndClean:
 	CloseHandle(hBinkFile);
-	hBinkFile = NULL;
+	hBinkFile = nullptr;
 	checkForError();
 	throw std::runtime_error("BIK failed opening video!");
 }
@@ -213,12 +210,12 @@ bool CBIKHandler::nextFrame()
 void CBIKHandler::close()
 {
 	binkClose(hBink);
-	hBink = NULL;
+	hBink = nullptr;
 	CloseHandle(hBinkFile);
-	hBinkFile = NULL;
+	hBinkFile = nullptr;
 	delete [] buffer;
 
-	buffer = NULL;
+	buffer = nullptr;
 	bufferSize = 0;
 }
 
@@ -256,7 +253,7 @@ void CBIKHandler::allocBuffer(int Bpp)
 void CBIKHandler::freeBuffer()
 {
 	delete [] buffer;
-	buffer = NULL;
+	buffer = nullptr;
 	bufferSize = 0;
 }
 
@@ -271,7 +268,7 @@ bool CSmackPlayer::wait()
 	return ptrSmackWait(data);
 }
 
-CSmackPlayer::CSmackPlayer() : data(NULL)
+CSmackPlayer::CSmackPlayer() : data(nullptr)
 {
 	Instantiate("smackw32.dll");
 	ptrSmackNextFrame = (SmackNextFrame)FindAddress("_SmackNextFrame@4");
@@ -293,7 +290,7 @@ CSmackPlayer::~CSmackPlayer()
 void CSmackPlayer::close()
 {
 	ptrSmackClose(data);
-	data = NULL;
+	data = nullptr;
 }
 
 bool CSmackPlayer::open( std::string name )
@@ -397,7 +394,7 @@ void CSmackPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
 
 CVideoPlayer::CVideoPlayer()
 {
-	current = NULL;
+	current = nullptr;
 }
 
 CVideoPlayer::~CVideoPlayer()
@@ -452,7 +449,7 @@ void CVideoPlayer::close()
 	}
 
 	current->close();
-	current = NULL;
+	current = nullptr;
 	if(!DeleteFileA(fname.c_str()))
 	{
         logGlobal->errorStream() << "Cannot remove temporarily extracted video file: " << fname;
@@ -594,12 +591,12 @@ static si64 lodSeek(void * opaque, si64 pos, int whence)
 
 CVideoPlayer::CVideoPlayer()
 {
-	format = NULL;
-	frame = NULL;
-	codec = NULL;
-	sws = NULL;
-	overlay = NULL;
-	dest = NULL;
+	format = nullptr;
+	frame = nullptr;
+	codec = nullptr;
+	sws = nullptr;
+	overlay = nullptr;
+	dest = nullptr;
 	context = nullptr;
 
 	// Register codecs. TODO: May be overkill. Should call a
@@ -637,7 +634,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	static const int BUFFER_SIZE = 4096;
 
 	unsigned char * buffer  = (unsigned char *)av_malloc(BUFFER_SIZE);// will be freed by ffmpeg
-	context = avio_alloc_context( buffer, BUFFER_SIZE, 0, (void *)this, lodRead, NULL, lodSeek);
+	context = avio_alloc_context( buffer, BUFFER_SIZE, 0, (void *)this, lodRead, nullptr, lodSeek);
 
 	format = avformat_alloc_context();
 	format->pb = context;
@@ -652,7 +649,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
 	if (av_find_stream_info(format) < 0)
 #else
-	if (avformat_find_stream_info(format, NULL) < 0)
+	if (avformat_find_stream_info(format, nullptr) < 0)
 #endif
 		return false;
 
@@ -677,7 +674,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	// Find the decoder for the video stream
 	codec = avcodec_find_decoder(codecContext->codec_id);
 
-	if (codec == NULL)
+	if (codec == nullptr)
 	{
 		// Unsupported codec
 		return false;
@@ -687,11 +684,11 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 6, 0)
 	if ( avcodec_open(codecContext, codec) < 0 )
 #else
-	if ( avcodec_open2(codecContext, codec, NULL) < 0 )
+	if ( avcodec_open2(codecContext, codec, nullptr) < 0 )
 #endif
 	{
 		// Could not open codec
-		codec = NULL;
+		codec = nullptr;
 		return false;
 	}
 
@@ -712,7 +709,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 		destRect.h = codecContext->height;
 	}
 
-	if (overlay == NULL && dest == NULL)
+	if (overlay == nullptr && dest == nullptr)
 		return false;
 
 	// Convert the image into YUV format that SDL uses
@@ -720,7 +717,7 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 	{
 		sws = sws_getContext(codecContext->width, codecContext->height,
 							 codecContext->pix_fmt, codecContext->width, codecContext->height,
-							 PIX_FMT_YUV420P, SWS_BICUBIC, NULL, NULL, NULL);
+							 PIX_FMT_YUV420P, SWS_BICUBIC, nullptr, nullptr, nullptr);
 	}
 	else
 	{
@@ -751,10 +748,10 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
 
 		sws = sws_getContext(codecContext->width, codecContext->height,
 							 codecContext->pix_fmt, codecContext->width, codecContext->height,
-							 screenFormat, SWS_BICUBIC, NULL, NULL, NULL);
+							 screenFormat, SWS_BICUBIC, nullptr, nullptr, nullptr);
 	}
 
-	if (sws == NULL)
+	if (sws == nullptr)
 		return false;
 
 	pos.w = codecContext->width;
@@ -770,7 +767,7 @@ bool CVideoPlayer::nextFrame()
 	int frameFinished = 0;
 	bool gotError = false;
 
-	if (sws == NULL)
+	if (sws == nullptr)
 		return false;
 
 	while(!frameFinished)
@@ -841,7 +838,7 @@ bool CVideoPlayer::nextFrame()
 
 void CVideoPlayer::show( int x, int y, SDL_Surface *dst, bool update )
 {
-	if (sws == NULL)
+	if (sws == nullptr)
 		return;
 
 	pos.x = x;
@@ -859,7 +856,7 @@ void CVideoPlayer::redraw( int x, int y, SDL_Surface *dst, bool update )
 
 void CVideoPlayer::update( int x, int y, SDL_Surface *dst, bool forceRedraw, bool update )
 {
-	if (sws == NULL)
+	if (sws == nullptr)
 		return;
 
 	if (refreshCount <= 0)
@@ -892,39 +889,39 @@ void CVideoPlayer::close()
 	if (sws)
 	{
 		sws_freeContext(sws);
-		sws = NULL;
+		sws = nullptr;
 	}
 
 	if (overlay)
 	{
 		SDL_FreeYUVOverlay(overlay);
-		overlay = NULL;
+		overlay = nullptr;
 	}
 
 	if (dest)
 	{
 		SDL_FreeSurface(dest);
-		dest = NULL;
+		dest = nullptr;
 	}
 
 	if (frame)
 	{
 		av_free(frame);
-		frame = NULL;
+		frame = nullptr;
 	}
 
 	if (codec)
 	{
 		avcodec_close(codecContext);
-		codec = NULL;
-		codecContext = NULL;
+		codec = nullptr;
+		codecContext = nullptr;
 	}
 
 	if (format)
 	{
 #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53, 17, 0)
 		av_close_input_file(format);
-		format = NULL;
+		format = nullptr;
 #else
 		avformat_close_input(&format);
 #endif

+ 14 - 14
client/Client.cpp

@@ -58,7 +58,7 @@ public:
 	virtual void applyOnClBefore(CClient *cl, void *pack) const =0; 
 	virtual ~CBaseForCLApply(){}
 
-	template<typename U> static CBaseForCLApply *getApplier(const U * t=NULL)
+	template<typename U> static CBaseForCLApply *getApplier(const U * t=nullptr)
 	{
 		return new CApplyOnCL<U>;
 	}
@@ -136,7 +136,7 @@ void CClient::run()
 	setThreadName("CClient::run");
 	try
 	{
-		CPack *pack = NULL;
+		CPack *pack = nullptr;
 		while(!terminate)
 		{
 			pack = serv->retreivePack(); //get the package from the server
@@ -144,12 +144,12 @@ void CClient::run()
 			if (terminate) 
 			{
 				delete pack;
-				pack = NULL;
+				pack = nullptr;
 				break;
 			}
 
 			handlePack(pack);
-			pack = NULL;
+			pack = nullptr;
 		}
 	} 
 	//catch only asio exceptions
@@ -189,7 +189,7 @@ void CClient::endGame( bool closeConnection /*= true*/ )
 		stopConnection();
     logNetwork->infoStream() << "Closed connection.";
 
-	GH.curInt = NULL;
+	GH.curInt = nullptr;
 	LOCPLINT->terminate_cond.setn(true);
 	{
 		boost::unique_lock<boost::recursive_mutex> un(*LOCPLINT->pim);
@@ -198,14 +198,14 @@ void CClient::endGame( bool closeConnection /*= true*/ )
 			GH.topInt()->deactivate();
 		GH.listInt.clear();
 		GH.objsToBlit.clear();
-		GH.statusbar = NULL;
+		GH.statusbar = nullptr;
         logNetwork->infoStream() << "Removed GUI.";
 
 		vstd::clear_pointer(const_cast<CGameInfo*>(CGI)->mh);
 		vstd::clear_pointer(gs);
 
         logNetwork->infoStream() << "Deleted mapHandler and gameState.";
-		LOCPLINT = NULL;
+		LOCPLINT = nullptr;
 	}
 
 	playerint.clear();
@@ -297,7 +297,7 @@ void CClient::newGame( CConnection *con, StartInfo *si )
 {
 	enum {SINGLE, HOST, GUEST} networkMode = SINGLE;
 
-	if (con == NULL) 
+	if (con == nullptr) 
 	{
 		CServerHandler sh;
 		serv = sh.connectToServer();
@@ -556,14 +556,14 @@ void CClient::stopConnection()
         logNetwork->infoStream() << "Connection handler thread joined";
 
 		delete connectionHandler;
-		connectionHandler = NULL;
+		connectionHandler = nullptr;
 	}
 
 	if (serv) //and delete connection
 	{
 		serv->close();
 		delete serv;
-		serv = NULL;
+		serv = nullptr;
         logNetwork->warnStream() << "Our socket has been closed.";
 	}
 }
@@ -660,7 +660,7 @@ void CClient::commenceTacticPhaseForInt(shared_ptr<CBattleGameInterface> battleI
 	} HANDLE_EXCEPTION
 }
 
-void CClient::invalidatePaths(const CGHeroInstance *h /*= NULL*/)
+void CClient::invalidatePaths(const CGHeroInstance *h /*= nullptr*/)
 {
 	if(!h || pathInfo->hero == h)
 		pathInfo->isValid = false;
@@ -807,8 +807,8 @@ CConnection * CServerHandler::connectToServer()
 
 CServerHandler::CServerHandler(bool runServer /*= false*/)
 {
-	serverThread = NULL;
-	shared = NULL;
+	serverThread = nullptr;
+	shared = nullptr;
 	port = boost::lexical_cast<std::string>(settings["server"]["port"].Float());
 	verbose = true;
 
@@ -843,7 +843,7 @@ void CServerHandler::callServer()
 
 CConnection * CServerHandler::justConnectToServer(const std::string &host, const std::string &port)
 {
-	CConnection *ret = NULL;
+	CConnection *ret = nullptr;
 	while(!ret)
 	{
 		try

+ 51 - 54
client/Client.h

@@ -30,8 +30,6 @@ class CScriptingModule;
 struct CPathsInfo;
 namespace boost { class thread; }
 
-void processCommand(const std::string &message, CClient *&client);
-
 /// structure to handle running server and connecting to it
 class CServerHandler
 {
@@ -156,7 +154,7 @@ public:
 	void campaignMapFinished( shared_ptr<CCampaignState> camp );
 	void finishCampaign( shared_ptr<CCampaignState> camp );
 	void proposeNextMission(shared_ptr<CCampaignState> camp);
-	void invalidatePaths(const CGHeroInstance *h = NULL); //invalidates paths for hero h or for any hero if h is NULL => they'll got recalculated when the next query comes
+	void invalidatePaths(const CGHeroInstance *h = nullptr); //invalidates paths for hero h or for any hero if h is nullptr => they'll got recalculated when the next query comes
 	void calculatePaths(const CGHeroInstance *h);
 	void updatePaths(); //calls calculatePaths for same hero for which we previously calculated paths
 
@@ -164,74 +162,73 @@ public:
 	boost::thread *connectionHandler; //thread running run() method
 
 	//////////////////////////////////////////////////////////////////////////
-	virtual PlayerColor getLocalPlayer() const OVERRIDE;
+	virtual PlayerColor getLocalPlayer() const override;
 
 	//////////////////////////////////////////////////////////////////////////
 	//not working yet, will be implement somewhen later with support for local-sim-based gameplay
-	void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) OVERRIDE {};
-	bool removeObject(const CGObjectInstance * obj) OVERRIDE {return false;};
-	void setBlockVis(ObjectInstanceID objid, bool bv) OVERRIDE {};
-	void setOwner(const CGObjectInstance * obj, PlayerColor owner) OVERRIDE {};
-	void setHoverName(const CGObjectInstance * obj, MetaString * name) OVERRIDE {};
-	void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) OVERRIDE {};
-	void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) OVERRIDE {}; 
-
-	void showBlockingDialog(BlockingDialog *iw) OVERRIDE {}; 
-	void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) OVERRIDE {};
-	void showThievesGuildWindow(PlayerColor player, ObjectInstanceID requestingObjId) OVERRIDE {};
-	void giveResource(PlayerColor player, Res::ERes which, int val) OVERRIDE {};
-	virtual void giveResources(PlayerColor player, TResources resources) OVERRIDE {};
-
-	void giveCreatures(const CArmedInstance * objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) OVERRIDE {};
-	void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) OVERRIDE {};
-	bool changeStackType(const StackLocation &sl, CCreature *c) OVERRIDE {return false;};
-	bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) OVERRIDE {return false;};
-	bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count) OVERRIDE {return false;};
+	void changeSpells(const CGHeroInstance * hero, bool give, const std::set<SpellID> &spells) override {};
+	bool removeObject(const CGObjectInstance * obj) override {return false;};
+	void setBlockVis(ObjectInstanceID objid, bool bv) override {};
+	void setOwner(const CGObjectInstance * obj, PlayerColor owner) override {};
+	void setHoverName(const CGObjectInstance * obj, MetaString * name) override {};
+	void changePrimSkill(const CGHeroInstance * hero, PrimarySkill::PrimarySkill which, si64 val, bool abs=false) override {};
+	void changeSecSkill(const CGHeroInstance * hero, SecondarySkill which, int val, bool abs=false) override {}; 
+
+	void showBlockingDialog(BlockingDialog *iw) override {}; 
+	void showGarrisonDialog(ObjectInstanceID upobj, ObjectInstanceID hid, bool removableUnits) override {};
+	void showThievesGuildWindow(PlayerColor player, ObjectInstanceID requestingObjId) override {};
+	void giveResource(PlayerColor player, Res::ERes which, int val) override {};
+	virtual void giveResources(PlayerColor player, TResources resources) override {};
+
+	void giveCreatures(const CArmedInstance * objid, const CGHeroInstance * h, const CCreatureSet &creatures, bool remove) override {};
+	void takeCreatures(ObjectInstanceID objid, const std::vector<CStackBasicDescriptor> &creatures) override {};
+	bool changeStackType(const StackLocation &sl, CCreature *c) override {return false;};
+	bool changeStackCount(const StackLocation &sl, TQuantity count, bool absoluteValue = false) override {return false;};
+	bool insertNewStack(const StackLocation &sl, const CCreature *c, TQuantity count) override {return false;};
 	bool eraseStack(const StackLocation &sl, bool forceRemoval = false){return false;};
-	bool swapStacks(const StackLocation &sl1, const StackLocation &sl2) OVERRIDE {return false;}
-	bool addToSlot(const StackLocation &sl, const CCreature *c, TQuantity count) OVERRIDE {return false;}
-	void tryJoiningArmy(const CArmedInstance *src, const CArmedInstance *dst, bool removeObjWhenFinished, bool allowMerging) OVERRIDE {}
-	bool moveStack(const StackLocation &src, const StackLocation &dst, TQuantity count = -1) OVERRIDE {return false;}
+	bool swapStacks(const StackLocation &sl1, const StackLocation &sl2) override {return false;}
+	bool addToSlot(const StackLocation &sl, const CCreature *c, TQuantity count) override {return false;}
+	void tryJoiningArmy(const CArmedInstance *src, const CArmedInstance *dst, bool removeObjWhenFinished, bool allowMerging) override {}
+	bool moveStack(const StackLocation &src, const StackLocation &dst, TQuantity count = -1) override {return false;}
 	
-	void removeAfterVisit(const CGObjectInstance *object) OVERRIDE {};
-
-	void giveHeroNewArtifact(const CGHeroInstance *h, const CArtifact *artType, ArtifactPosition pos) OVERRIDE {};
-	void giveHeroArtifact(const CGHeroInstance *h, const CArtifactInstance *a, ArtifactPosition pos) OVERRIDE {};
-	void putArtifact(const ArtifactLocation &al, const CArtifactInstance *a) OVERRIDE {}; 
-	void removeArtifact(const ArtifactLocation &al) OVERRIDE {};
-	bool moveArtifact(const ArtifactLocation &al1, const ArtifactLocation &al2) OVERRIDE {return false;};
-	void synchronizeArtifactHandlerLists() OVERRIDE {};
-
-	void showCompInfo(ShowInInfobox * comp) OVERRIDE {};
-	void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) OVERRIDE {};
-	void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) OVERRIDE {};
+	void removeAfterVisit(const CGObjectInstance *object) override {};
+
+	void giveHeroNewArtifact(const CGHeroInstance *h, const CArtifact *artType, ArtifactPosition pos) override {};
+	void giveHeroArtifact(const CGHeroInstance *h, const CArtifactInstance *a, ArtifactPosition pos) override {};
+	void putArtifact(const ArtifactLocation &al, const CArtifactInstance *a) override {}; 
+	void removeArtifact(const ArtifactLocation &al) override {};
+	bool moveArtifact(const ArtifactLocation &al1, const ArtifactLocation &al2) override {return false;};
+	void synchronizeArtifactHandlerLists() override {};
+
+	void showCompInfo(ShowInInfobox * comp) override {};
+	void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {};
+	void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero) override {};
 	//void giveHeroArtifact(int artid, int hid, int position){}; 
 	//void giveNewArtifact(int hid, int position){};
-	void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = NULL) OVERRIDE {}; //use hero=NULL for no hero
-	void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false) OVERRIDE {}; //if any of armies is hero, hero will be used
-	void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false) OVERRIDE {}; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
-	void setAmount(ObjectInstanceID objid, ui32 val) OVERRIDE {};
-	bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) OVERRIDE {return false;};
-	void giveHeroBonus(GiveBonus * bonus) OVERRIDE {};
-	void setMovePoints(SetMovePoints * smp) OVERRIDE {};
-	void setManaPoints(ObjectInstanceID hid, int val) OVERRIDE {};
-	void giveHero(ObjectInstanceID id, PlayerColor player) OVERRIDE {};
-	void changeObjPos(ObjectInstanceID objid, int3 newPos, ui8 flags) OVERRIDE {};
-	void sendAndApply(CPackForClient * info) OVERRIDE {};
-	void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) OVERRIDE {};
+	void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr) override {}; //use hero=nullptr for no hero
+	void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used
+	void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false) override {}; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
+	void setAmount(ObjectInstanceID objid, ui32 val) override {};
+	bool moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, PlayerColor asker = PlayerColor::NEUTRAL) override {return false;};
+	void giveHeroBonus(GiveBonus * bonus) override {};
+	void setMovePoints(SetMovePoints * smp) override {};
+	void setManaPoints(ObjectInstanceID hid, int val) override {};
+	void giveHero(ObjectInstanceID id, PlayerColor player) override {};
+	void changeObjPos(ObjectInstanceID objid, int3 newPos, ui8 flags) override {};
+	void sendAndApply(CPackForClient * info) override {};
+	void heroExchange(ObjectInstanceID hero1, ObjectInstanceID hero2) override {};
 
 	//////////////////////////////////////////////////////////////////////////
 	friend class CCallback; //handling players actions
 	friend class CBattleCallback; //handling players actions
-	friend void processCommand(const std::string &message, CClient *&client); //handling console
-	
+
 	int sendRequest(const CPack *request, PlayerColor player); //returns ID given to that request
 
 	void handlePack( CPack * pack ); //applies the given pack and deletes it
 	void battleStarted(const BattleInfo * info);
 	void commenceTacticPhaseForInt(shared_ptr<CBattleGameInterface> battleInt); //will be called as separate thread
 
-	void commitPackage(CPackForClient *pack) OVERRIDE;
+	void commitPackage(CPackForClient *pack) override;
 
 	//////////////////////////////////////////////////////////////////////////
 

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 161 - 156
client/GUIClasses.cpp


+ 27 - 27
client/GUIClasses.h

@@ -105,7 +105,7 @@ public:
 	~CInfoWindow(); //d-tor
 
 	static void showYesNoDialog( const std::string & text, const std::vector<CComponent*> *components, const CFunctionList<void( ) > &onYes, const CFunctionList<void()> &onNo, bool DelComps = true, PlayerColor player = PlayerColor(1)); //use only before the game starts! (showYesNoDialog in LOCPLINT must be used then)
-	static CInfoWindow *create(const std::string &text, PlayerColor playerID = PlayerColor(1), const std::vector<CComponent*> *components = NULL, bool DelComps = false);
+	static CInfoWindow *create(const std::string &text, PlayerColor playerID = PlayerColor(1), const std::vector<CComponent*> *components = nullptr, bool DelComps = false);
 
 	/// create text from title and description: {title}\n\n description
 	static std::string genText(std::string title, std::string description);
@@ -160,7 +160,7 @@ public:
 	void show(SDL_Surface * to);
 	CInfoPopup(SDL_Surface * Bitmap, int x, int y, bool Free=false); //c-tor
 	CInfoPopup(SDL_Surface * Bitmap, const Point &p, EAlignment alignment, bool Free=false); //c-tor
-	CInfoPopup(SDL_Surface * Bitmap = NULL, bool Free = false); //default c-tor
+	CInfoPopup(SDL_Surface * Bitmap = nullptr, bool Free = false); //default c-tor
 
 	void init(int x, int y);
 	~CInfoPopup(); //d-tor
@@ -227,14 +227,14 @@ class CSelectableComponent : public CComponent, public CKeyShortcut
 	void init();
 public:
 	bool selected; //if true, this component is selected
-	boost::function<void()> onSelect; //function called on selection change
+	std::function<void()> onSelect; //function called on selection change
 
 	void showAll(SDL_Surface * to);
 	void select(bool on);
 
 	void clickLeft(tribool down, bool previousState); //call-in
-	CSelectableComponent(Etype Type, int Sub, int Val, ESize imageSize=large, boost::function<void()> OnSelect = 0); //c-tor
-	CSelectableComponent(const Component &c, boost::function<void()> OnSelect = 0); //c-tor
+	CSelectableComponent(Etype Type, int Sub, int Val, ESize imageSize=large, std::function<void()> OnSelect = 0); //c-tor
+	CSelectableComponent(const Component &c, std::function<void()> OnSelect = 0); //c-tor
 };
 
 /// box with multiple components (up to 8?)
@@ -244,7 +244,7 @@ class CComponentBox : public CIntObject
 	std::vector<CComponent *> components;
 
 	CSelectableComponent * selected;
-	boost::function<void(int newID)> onSelect;
+	std::function<void(int newID)> onSelect;
 
 	void selectionChanged(CSelectableComponent * newSelection);
 
@@ -269,7 +269,7 @@ public:
 	/// constructor for selectable components
 	/// will also create "or" labels between components
 	/// onSelect - optional function that will be called every time on selection change
-	CComponentBox(std::vector<CSelectableComponent *> components, Rect position, boost::function<void(int newID)> onSelect = 0);
+	CComponentBox(std::vector<CSelectableComponent *> components, Rect position, std::function<void(int newID)> onSelect = 0);
 };
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -314,7 +314,7 @@ class CGarrisonSlot : public CIntObject
 {
 	SlotID ID; //for identification
 	CGarrisonInt *owner;
-	const CStackInstance *myStack; //NULL if slot is empty
+	const CStackInstance *myStack; //nullptr if slot is empty
 	const CCreature *creature;
 	int upg; //0 - up garrison, 1 - down garrison
 
@@ -330,7 +330,7 @@ public:
 	void clickRight(tribool down, bool previousState);
 	void clickLeft(tribool down, bool previousState);
 	void update();
-	CGarrisonSlot(CGarrisonInt *Owner, int x, int y, SlotID IID, int Upg=0, const CStackInstance * Creature=NULL);
+	CGarrisonSlot(CGarrisonInt *Owner, int x, int y, SlotID IID, int Upg=0, const CStackInstance * Creature=nullptr);
 
 	friend class CGarrisonInt;
 };
@@ -383,7 +383,7 @@ public:
 	//removableUnits - you can take units from top;
 	//smallImgs - units images size 64x58 or 32x32;
 	//twoRows - display slots in 2 row (1st row = 4 slots, 2nd = 3 slots)
-	CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *pomsur, const Point &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=NULL, bool _removableUnits = true, bool smallImgs = false, bool _twoRows=false); //c-tor
+	CGarrisonInt(int x, int y, int inx, const Point &garsOffset, SDL_Surface *pomsur, const Point &SurOffset, const CArmedInstance *s1, const CArmedInstance *s2=nullptr, bool _removableUnits = true, bool smallImgs = false, bool _twoRows=false); //c-tor
 };
 
 /// draws picture with creature on background, use Animated=true to get animation
@@ -430,7 +430,7 @@ class CRecruitmentWindow : public CWindowObject
 		void createItems(TResources res);
 	};
 
-	boost::function<void(CreatureID,int)> onRecruit; //void (int ID, int amount) <-- call to recruit creatures
+	std::function<void(CreatureID,int)> onRecruit; //void (int ID, int amount) <-- call to recruit creatures
 
 	int level;
 	const CArmedInstance *dst;
@@ -454,14 +454,14 @@ class CRecruitmentWindow : public CWindowObject
 	void showAll(SDL_Surface *to);
 public:
 	const CGDwelling * const dwelling;
-	CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const boost::function<void(CreatureID,int)> & Recruit, int y_offset = 0); //creatures - pairs<creature_ID,amount> //c-tor
+	CRecruitmentWindow(const CGDwelling *Dwelling, int Level, const CArmedInstance *Dst, const std::function<void(CreatureID,int)> & Recruit, int y_offset = 0); //creatures - pairs<creature_ID,amount> //c-tor
 	void availableCreaturesChanged();
 };
 
 /// Split window where creatures can be split up into two single unit stacks
 class CSplitWindow : public CWindowObject
 {
-	boost::function<void(int, int)> callback;
+	std::function<void(int, int)> callback;
 	int leftAmount;
 	int rightAmount;
 
@@ -485,7 +485,7 @@ public:
 	 * leftMin, rightMin - minimal amount of creatures in each stack
 	 * leftAmount, rightAmount - amount of creatures in each stack
 	 */
-	CSplitWindow(const CCreature * creature, boost::function<void(int, int)> callback,
+	CSplitWindow(const CCreature * creature, std::function<void(int, int)> callback,
 	             int leftMin, int rightMin, int leftAmount, int rightAmount);
 };
 
@@ -493,12 +493,12 @@ public:
 class CLevelWindow : public CWindowObject
 {
 	CComponentBox * box; //skills to select
-	boost::function<void(ui32)> cb;
+	std::function<void(ui32)> cb;
 
 	void selectionChanged(unsigned to);
 public:
 
-	CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, boost::function<void(ui32)> callback); //c-tor
+	CLevelWindow(const CGHeroInstance *hero, PrimarySkill::PrimarySkill pskill, std::vector<SecondarySkill> &skills, std::function<void(ui32)> callback); //c-tor
 	~CLevelWindow(); //d-tor
 
 };
@@ -530,7 +530,7 @@ class CObjectListWindow : public CWindowObject
 		void clickLeft(tribool down, bool previousState);
 	};
 
-	boost::function<void(int)> onSelect;//called when OK button is pressed, returns id of selected item.
+	std::function<void(int)> onSelect;//called when OK button is pressed, returns id of selected item.
 	CLabel * title;
 	CLabel * descr;
 
@@ -544,12 +544,12 @@ class CObjectListWindow : public CWindowObject
 public:
 	size_t selected;//index of currently selected item
 	/// Callback will be called when OK button is pressed, returns id of selected item. initState = initially selected item
-	/// Image can be NULL
+	/// Image can be nullptr
 	///item names will be taken from map objects
 	CObjectListWindow(const std::vector<int> &_items, CPicture * titlePic, std::string _title, std::string _descr,
-                      boost::function<void(int)> Callback);
+                      std::function<void(int)> Callback);
 	CObjectListWindow(const std::vector<std::string> &_items, CPicture * titlePic, std::string _title, std::string _descr,
-                      boost::function<void(int)> Callback);
+                      std::function<void(int)> Callback);
 
 	CIntObject *genItem(size_t index);
 	void elementSelected();//call callback and close this window
@@ -625,7 +625,7 @@ public:
 	CArtifactsOfHero *arts;
 	//all indexes: 1 = left, 0 = right
 	std::vector<CTradeableItem*> items[2];
-	CTradeableItem *hLeft, *hRight; //highlighted items (NULL if no highlight)
+	CTradeableItem *hLeft, *hRight; //highlighted items (nullptr if no highlight)
 	EType itemsType[2];
 
 	EMarketMode::EMarketMode mode;//0 - res<->res; 1 - res<->plauer; 2 - buy artifact; 3 - sell artifact
@@ -640,7 +640,7 @@ public:
 	void initSubs(bool Left);
 	void initTypes();
 	void initItems(bool Left);
-	std::vector<int> *getItemsIds(bool Left); //NULL if default
+	std::vector<int> *getItemsIds(bool Left); //nullptr if default
 	void getPositionsFor(std::vector<Rect> &poss, bool Left, EType type) const;
 	void removeItems(const std::set<CTradeableItem *> &toRemove);
 	void removeItem(CTradeableItem * t);
@@ -671,7 +671,7 @@ public:
 	void sliderMoved(int to);
 	void makeDeal();
 	void selectionChanged(bool side); //true == left
-	CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = NULL, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); //c-tor
+	CMarketplaceWindow(const IMarket *Market, const CGHeroInstance *Hero = nullptr, EMarketMode::EMarketMode Mode = EMarketMode::RESOURCE_RESOURCE); //c-tor
 	~CMarketplaceWindow(); //d-tor
 
 	Point selectionOffset(bool Left) const;
@@ -908,7 +908,7 @@ public:
 	CArtifactsOfHero * ourOwner;
 	const CArtifactInstance * ourArt; // should be changed only with setArtifact()
 
-	CArtPlace(Point position, const CArtifactInstance * Art = NULL); //c-tor
+	CArtPlace(Point position, const CArtifactInstance * Art = nullptr); //c-tor
 	void clickLeft(tribool down, bool previousState);
 	void clickRight(tribool down, bool previousState);
 	void select ();
@@ -955,7 +955,7 @@ public:
 	CAdventureMapButton * leftArtRoll, * rightArtRoll;
 	bool allowedAssembling;
 	std::multiset<const CArtifactInstance*> artifactsOnAltar; //artifacts id that are technically present in backpack but in GUI are moved to the altar - they'll be omitted in backpack slots
-	boost::function<void(CArtPlace*)> highlightModeCallback; //if set, clicking on art place doesn't pick artifact but highlights the slot and calls this function
+	std::function<void(CArtPlace*)> highlightModeCallback; //if set, clicking on art place doesn't pick artifact but highlights the slot and calls this function
 
 	void realizeCurrentTransaction(); //calls callback with parameters stored in commonInfo
 	void artifactMoved(const ArtifactLocation &src, const ArtifactLocation &dst);
@@ -1057,7 +1057,7 @@ public:
 
 	CGStatusBar * statusBar;
 
-	CShipyardWindow(const std::vector<si32> &cost, int state, int boatType, const boost::function<void()> &onBuy);
+	CShipyardWindow(const std::vector<si32> &cost, int state, int boatType, const std::function<void()> &onBuy);
 };
 
 /// Puzzle screen which gets uncovered when you visit obilisks
@@ -1099,7 +1099,7 @@ public:
 
 	const CArmedInstance *army;//object with army for transforming (hero or town)
 	const CGHeroInstance *hero;//only if we have hero in town
-	const CGTownInstance *town;//market, town garrison is used if hero == NULL
+	const CGTownInstance *town;//market, town garrison is used if hero == nullptr
 	std::vector<CItem*> items;
 
 	CAdventureMapButton *all, *convert, *cancel;

+ 10 - 10
client/Graphics.cpp

@@ -42,7 +42,7 @@ using namespace CSDL_Ext;
  *
  */
 
-Graphics * graphics = NULL;
+Graphics * graphics = nullptr;
 
 void Graphics::loadPaletteAndColors()
 {
@@ -121,12 +121,12 @@ void Graphics::initializeBattleGraphics()
 Graphics::Graphics()
 {
 	std::vector<Task> tasks; //preparing list of graphics to load
-	tasks += boost::bind(&Graphics::loadFonts,this);
-	tasks += boost::bind(&Graphics::loadPaletteAndColors,this);
-	tasks += boost::bind(&Graphics::loadHeroFlags,this);
-	tasks += boost::bind(&Graphics::initializeBattleGraphics,this);
-	tasks += boost::bind(&Graphics::loadErmuToPicture,this);
-	tasks += boost::bind(&Graphics::initializeImageLists,this);
+	tasks += std::bind(&Graphics::loadFonts,this);
+	tasks += std::bind(&Graphics::loadPaletteAndColors,this);
+	tasks += std::bind(&Graphics::loadHeroFlags,this);
+	tasks += std::bind(&Graphics::initializeBattleGraphics,this);
+	tasks += std::bind(&Graphics::loadErmuToPicture,this);
+	tasks += std::bind(&Graphics::initializeImageLists,this);
 	tasks += GET_DEF_ESS(resources32,"RESOURCE.DEF");
 	tasks += GET_DEF_ESS(spellscr,"SPELLSCR.DEF");
 	tasks += GET_DEF_ESS(heroMoveArrows,"ADAG.DEF");
@@ -199,7 +199,7 @@ CDefEssential * Graphics::loadHeroAnim( const std::string &name, const std::vect
 	return anim;
 }
 
-void Graphics::loadHeroFlags(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr, bool mode)
+void Graphics::loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr, bool mode)
 {
 	for(int i=0;i<8;i++)
 		(this->*pr.first).push_back(CDefHandler::giveDefEss(pr.second[i]));
@@ -273,7 +273,7 @@ void Graphics::loadHeroFlags()
 	boost::thread_group grupa;
 	for(int g=3; g>=0; --g)
 	{
-		grupa.create_thread(boost::bind(&Graphics::loadHeroFlags,this,boost::ref(pr[g]),true));
+		grupa.create_thread(std::bind(&Graphics::loadHeroFlagsDetail, this, std::ref(pr[g]), true));
 	}
 	grupa.join_all();
     logGlobal->infoStream() << "Loading and transforming heroes' flags: "<<th.getDiff();
@@ -285,7 +285,7 @@ void Graphics::blueToPlayersAdv(SDL_Surface * sur, PlayerColor player)
 // 		return;
 	if(sur->format->BitsPerPixel == 8)
 	{
-		SDL_Color *palette = NULL;
+		SDL_Color *palette = nullptr;
 		if(player < PlayerColor::PLAYER_LIMIT)
 		{
 			palette = playerColorPalette + 32*player.getNum();

+ 1 - 1
client/Graphics.h

@@ -74,7 +74,7 @@ public:
 	void initializeBattleGraphics();
 	void loadPaletteAndColors();
 	void loadHeroFlags();
-	void loadHeroFlags(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr, bool mode);
+	void loadHeroFlagsDetail(std::pair<std::vector<CDefEssential *> Graphics::*, std::vector<const char *> > &pr, bool mode);
 	void loadHeroAnims();
 	CDefEssential *  loadHeroAnim(const std::string &name, const std::vector<std::pair<int,int> > &rotations);
 	void loadErmuToPicture();

+ 3 - 3
client/NetPacksClient.cpp

@@ -476,7 +476,7 @@ void SetHeroesInTown::applyCl( CClient *cl )
 // void SetHeroArtifacts::applyCl( CClient *cl )
 // {
 // // 	CGHeroInstance *h = GS(cl)->getHero(hid);
-// // 	CGameInterface *player = (vstd::contains(cl->playerint,h->tempOwner) ? cl->playerint[h->tempOwner] : NULL);
+// // 	CGameInterface *player = (vstd::contains(cl->playerint,h->tempOwner) ? cl->playerint[h->tempOwner] : nullptr);
 // // 	if(!player)
 // // 		return;
 //
@@ -632,7 +632,7 @@ void BattleSetActiveStack::applyCl( CClient *cl )
 		playerToCall = activated->owner;
 	}
 	if( vstd::contains(cl->battleints, playerToCall) )
-		boost::thread( boost::bind(&CClient::waitForMoveAndSend, cl, playerToCall) );
+		boost::thread( std::bind(&CClient::waitForMoveAndSend, cl, playerToCall) );
 }
 
 void BattleTriggerEffect::applyCl(CClient * cl)
@@ -924,7 +924,7 @@ 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(NULL);
+			i->second->availableArtifactsChanged(nullptr);
 	}
 	else
 	{

+ 7 - 7
client/battle/CBattleAnimations.cpp

@@ -26,7 +26,7 @@ void CBattleAnimation::endAnim()
 	{
 		if(it->first == this)
 		{
-			it->first = NULL;
+			it->first = nullptr;
 		}
 	}
 
@@ -97,7 +97,7 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
 : CBattleStackAnimation(_owner, attacker), dest(_dest), attackedStack(defender), attackingStack(attacker)
 {
 
-	assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n");
+	assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
 	bool isCatapultAttack = attackingStack->hasBonusOfType(Bonus::CATAPULT) 
 							&& owner->curInt->cb->battleHexToWallPart(_dest) >= 0;
 
@@ -120,7 +120,7 @@ bool CDefenceAnimation::init()
 	//	return false;
 	//}
 
-	if(attacker == NULL && owner->battleEffects.size() > 0)
+	if(attacker == nullptr && owner->battleEffects.size() > 0)
 		return false;
 
 	ui32 lowestMoveID = owner->animIDhelper + 5;
@@ -134,7 +134,7 @@ bool CDefenceAnimation::init()
 		if(attAnim && attAnim->stack->ID != stack->ID)
 			continue;
 
-		if(attacker != NULL)
+		if(attacker != nullptr)
 		{
 			int attackerAnimType = owner->creAnims[attacker->ID]->getType();
 			if( ( attackerAnimType == CCreatureAnim::ATTACK_UP ||
@@ -222,7 +222,7 @@ void CDefenceAnimation::endAnim()
 
 	//printing info to console
 
-	//if(attacker!=NULL)
+	//if(attacker!=nullptr)
 	//	owner->printConsoleAttacked(stack, dmg, amountKilled, attacker);
 
 	//const CStack * attacker = owner->curInt->cb->battleGetStackByID(IDby, false);
@@ -604,7 +604,7 @@ CReverseAnimation::CReverseAnimation(CBattleInterface * _owner, const CStack * s
 
 bool CReverseAnimation::init()
 {
-	if(myAnim() == NULL || myAnim()->getType() == CCreatureAnim::DEATH)
+	if(myAnim() == nullptr || myAnim()->getType() == CCreatureAnim::DEATH)
 	{
 		endAnim();
 
@@ -978,7 +978,7 @@ bool CSpellEffectAnimation::init()
 			}
 
 			// Correction for 2-hex creatures.
-			if (destStack != NULL && destStack->doubleWide())
+			if (destStack != nullptr && destStack->doubleWide())
 				be.x += (destStack->attackerOwned ? -1 : 1)*tilePos.w/2;
 
 			owner->battleEffects.push_back(be);

+ 62 - 62
client/battle/CBattleInterface.cpp

@@ -92,11 +92,11 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 								   CGHeroInstance *hero1, CGHeroInstance *hero2, 
 								   const SDL_Rect & myRect, 
 								   shared_ptr<CPlayerInterface> att, shared_ptr<CPlayerInterface> defen)
-	: background(nullptr), queue(NULL), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
-	  activeStack(NULL), stackToActivate(NULL), selectedStack(NULL), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
-	  currentlyHoveredHex(-1), attackingHex(-1), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(NULL), sp(NULL),
-	  siegeH(NULL), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0),
-	  givenCommand(NULL), myTurn(false), resWindow(NULL), moveStarted(false), moveSh(-1), bresult(NULL)
+	: background(nullptr), queue(nullptr), attackingHeroInstance(hero1), defendingHeroInstance(hero2), animCount(0),
+	  activeStack(nullptr), stackToActivate(nullptr), selectedStack(nullptr), mouseHoveredStack(-1), lastMouseHoveredStackAnimationTime(-1), previouslyHoveredHex(-1),
+	  currentlyHoveredHex(-1), attackingHex(-1), stackCanCastSpell(false), creatureCasting(false), spellDestSelectMode(false), spellSelMode(NO_LOCATION), spellToCast(nullptr), sp(nullptr),
+	  siegeH(nullptr), attackerInt(att), defenderInt(defen), curInt(att), animIDhelper(0),
+	  givenCommand(nullptr), myTurn(false), resWindow(nullptr), moveStarted(false), moveSh(-1), bresult(nullptr)
 {
 	OBJ_CONSTRUCTION;
 
@@ -109,7 +109,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	animsAreDisplayed.setn(false);
 	pos = myRect;
 	strongInterest = true;
-	givenCommand = new CondSh<BattleAction *>(NULL);
+	givenCommand = new CondSh<BattleAction *>(nullptr);
 
 	if(attackerInt && attackerInt->cb->battleGetTacticDist()) //hot-seat -> check tactics for both players (defender may be local human)
 		tacticianInterface = attackerInt;
@@ -215,19 +215,19 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 // 	blitAt(menu, pos.x, 556 + pos.y);
 
 	//preparing buttons and console
-	bOptions = new CAdventureMapButton (CGI->generaltexth->zelp[381].first, CGI->generaltexth->zelp[381].second, boost::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", SDLK_o);
-	bSurrender = new CAdventureMapButton (CGI->generaltexth->zelp[379].first, CGI->generaltexth->zelp[379].second, boost::bind(&CBattleInterface::bSurrenderf,this), 54, 561, "icm001.def", SDLK_s);
-	bFlee = new CAdventureMapButton (CGI->generaltexth->zelp[380].first, CGI->generaltexth->zelp[380].second, boost::bind(&CBattleInterface::bFleef,this), 105, 561, "icm002.def", SDLK_r);
+	bOptions = new CAdventureMapButton (CGI->generaltexth->zelp[381].first, CGI->generaltexth->zelp[381].second, std::bind(&CBattleInterface::bOptionsf,this), 3, 561, "icm003.def", SDLK_o);
+	bSurrender = new CAdventureMapButton (CGI->generaltexth->zelp[379].first, CGI->generaltexth->zelp[379].second, std::bind(&CBattleInterface::bSurrenderf,this), 54, 561, "icm001.def", SDLK_s);
+	bFlee = new CAdventureMapButton (CGI->generaltexth->zelp[380].first, CGI->generaltexth->zelp[380].second, std::bind(&CBattleInterface::bFleef,this), 105, 561, "icm002.def", SDLK_r);
 	bFlee->block(!curInt->cb->getMyColor() || !curInt->cb->battleCanFlee());
 	bSurrender->block(!curInt->cb->getMyColor() || curInt->cb->battleGetSurrenderCost() < 0);
-	bAutofight  = new CAdventureMapButton (CGI->generaltexth->zelp[382].first, CGI->generaltexth->zelp[382].second, boost::bind(&CBattleInterface::bAutofightf,this), 157, 561, "icm004.def", SDLK_a);
-	bSpell = new CAdventureMapButton (CGI->generaltexth->zelp[385].first, CGI->generaltexth->zelp[385].second, boost::bind(&CBattleInterface::bSpellf,this), 645, 561, "icm005.def", SDLK_c);
+	bAutofight  = new CAdventureMapButton (CGI->generaltexth->zelp[382].first, CGI->generaltexth->zelp[382].second, std::bind(&CBattleInterface::bAutofightf,this), 157, 561, "icm004.def", SDLK_a);
+	bSpell = new CAdventureMapButton (CGI->generaltexth->zelp[385].first, CGI->generaltexth->zelp[385].second, std::bind(&CBattleInterface::bSpellf,this), 645, 561, "icm005.def", SDLK_c);
 	bSpell->block(true);
-	bWait = new CAdventureMapButton (CGI->generaltexth->zelp[386].first, CGI->generaltexth->zelp[386].second, boost::bind(&CBattleInterface::bWaitf,this), 696, 561, "icm006.def", SDLK_w);
-	bDefence = new CAdventureMapButton (CGI->generaltexth->zelp[387].first, CGI->generaltexth->zelp[387].second, boost::bind(&CBattleInterface::bDefencef,this), 747, 561, "icm007.def", SDLK_d);
+	bWait = new CAdventureMapButton (CGI->generaltexth->zelp[386].first, CGI->generaltexth->zelp[386].second, std::bind(&CBattleInterface::bWaitf,this), 696, 561, "icm006.def", SDLK_w);
+	bDefence = new CAdventureMapButton (CGI->generaltexth->zelp[387].first, CGI->generaltexth->zelp[387].second, std::bind(&CBattleInterface::bDefencef,this), 747, 561, "icm007.def", SDLK_d);
 	bDefence->assignedKeys.insert(SDLK_SPACE);
-	bConsoleUp = new CAdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleUpf,this), 624, 561, "ComSlide.def", SDLK_UP);
-	bConsoleDown = new CAdventureMapButton (std::string(), std::string(), boost::bind(&CBattleInterface::bConsoleDownf,this), 624, 580, "ComSlide.def", SDLK_DOWN);
+	bConsoleUp = new CAdventureMapButton (std::string(), std::string(), std::bind(&CBattleInterface::bConsoleUpf,this), 624, 561, "ComSlide.def", SDLK_UP);
+	bConsoleDown = new CAdventureMapButton (std::string(), std::string(), std::bind(&CBattleInterface::bConsoleDownf,this), 624, 580, "ComSlide.def", SDLK_DOWN);
 	bConsoleDown->setOffset(2);
 	console = new CBattleConsole();
 	console->pos.x += 211;
@@ -236,8 +236,8 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	console->pos.h = 38;
 	if(tacticsMode)
 	{
-		btactNext = new CAdventureMapButton(std::string(), std::string(), boost::bind(&CBattleInterface::bTacticNextStack,this, (CStack*)NULL), 213, 560, "icm011.def", SDLK_SPACE);
-		btactEnd = new CAdventureMapButton(std::string(), std::string(), boost::bind(&CBattleInterface::bEndTacticPhase,this), 419, 560, "icm012.def", SDLK_RETURN);
+		btactNext = new CAdventureMapButton(std::string(), std::string(), std::bind(&CBattleInterface::bTacticNextStack,this, (CStack*)nullptr), 213, 560, "icm011.def", SDLK_SPACE);
+		btactEnd = new CAdventureMapButton(std::string(), std::string(), std::bind(&CBattleInterface::bEndTacticPhase,this), 419, 560, "icm012.def", SDLK_RETURN);
 		bDefence->block(true);
 		bWait->block(true);
 		menu = BitmapHandler::loadBitmap("COPLACBR.BMP");
@@ -245,7 +245,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 	else
 	{
 		menu = BitmapHandler::loadBitmap("CBAR.BMP");
-		btactEnd = btactNext = NULL;
+		btactEnd = btactNext = nullptr;
 	}
 	graphics->blueToPlayersAdv(menu, curInt->playerID);
 
@@ -258,12 +258,12 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 		else
 			battleImage = hero1->type->heroClass->imageBattleMale;
 
-		attackingHero = new CBattleHero(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : NULL, this);
+		attackingHero = new CBattleHero(battleImage, false, hero1->tempOwner, hero1->tempOwner == curInt->playerID ? hero1 : nullptr, this);
 		attackingHero->pos = genRect(attackingHero->dh->ourImages[0].bitmap->h, attackingHero->dh->ourImages[0].bitmap->w, pos.x - 43, pos.y - 19);
 	}
 	else
 	{
-		attackingHero = NULL;
+		attackingHero = nullptr;
 	}
 	if(hero2) // defending hero
 	{
@@ -273,12 +273,12 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 		else
 			battleImage = hero2->type->heroClass->imageBattleMale;
 
-		defendingHero = new CBattleHero(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : NULL, this);
+		defendingHero = new CBattleHero(battleImage, true, hero2->tempOwner, hero2->tempOwner == curInt->playerID ? hero2 : nullptr, this);
 		defendingHero->pos = genRect(defendingHero->dh->ourImages[0].bitmap->h, defendingHero->dh->ourImages[0].bitmap->w, pos.x + 693, pos.y - 19);
 	}
 	else
 	{
-		defendingHero = NULL;
+		defendingHero = nullptr;
 	}
 
 	//preparing cells and hexes
@@ -402,7 +402,7 @@ CBattleInterface::CBattleInterface(const CCreatureSet * army1, const CCreatureSe
 
 CBattleInterface::~CBattleInterface()
 {
-	curInt->battleInt = NULL;
+	curInt->battleInt = nullptr;
 	givenCommand->cond.notify_all(); //that two lines should make any activeStack waiting thread to finish
 
 
@@ -589,7 +589,7 @@ void CBattleInterface::show(SDL_Surface * to)
 	SDL_SetClipRect(to, &pos);
 
 	//printing background and hexes
-	if(activeStack != NULL && creAnims[activeStack->ID]->getType() != CCreatureAnim::MOVING) //show everything with range
+	if(activeStack != nullptr && creAnims[activeStack->ID]->getType() != CCreatureAnim::MOVING) //show everything with range
 	{
 		blitAt(backgroundWithHexes, pos.x, pos.y, to);
 	}
@@ -599,7 +599,7 @@ void CBattleInterface::show(SDL_Surface * to)
 		blitAt(background, pos.x, pos.y, to);
 		if(settings["battle"]["cellBorders"].Bool())
 		{
-			CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, to, &pos);
+			CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, nullptr, to, &pos);
 		}
 		//Blit absolute obstacles
 		BOOST_FOREACH(auto &oi, curInt->cb->battleGetAllObstacles())
@@ -644,7 +644,7 @@ void CBattleInterface::show(SDL_Surface * to)
 						int x = 14 + ((shadedHex/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(shadedHex%GameConstants::BFIELD_WIDTH) + pos.x;
 						int y = 86 + 42 * (shadedHex/GameConstants::BFIELD_WIDTH) + pos.y;
 						SDL_Rect temp_rect = genRect(cellShade->h, cellShade->w, x, y);
-						CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &temp_rect);
+						CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, nullptr, to, &temp_rect);
 					}
 				}
 			}
@@ -658,12 +658,12 @@ void CBattleInterface::show(SDL_Surface * to)
 						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;
 						SDL_Rect temp_rect = genRect(cellShade->h, cellShade->w, x, y);
-						CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &temp_rect);
+						CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, nullptr, to, &temp_rect);
 					}
 				}
 
 				//patch by ench0: show enemy stack movement shadow
-				// activeStack == NULL means it is opponent's turn...
+				// activeStack == nullptr means it is opponent's turn...
 				if(activeStack && settings["battle"]["stackRange"].Bool())
 				{
 					// display the movement shadow of the stack at b (i.e. stack under mouse)
@@ -676,7 +676,7 @@ void CBattleInterface::show(SDL_Surface * to)
 							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;
 							SDL_Rect temp_rect = genRect (cellShade->h, cellShade->w, x, y);
-							CSDL_Ext::blit8bppAlphaTo24bpp (cellShade, NULL, to, &temp_rect);
+							CSDL_Ext::blit8bppAlphaTo24bpp (cellShade, nullptr, to, &temp_rect);
 						}
 					}
 				}
@@ -685,7 +685,7 @@ void CBattleInterface::show(SDL_Surface * to)
 				int x = 14 + ((b/GameConstants::BFIELD_WIDTH)%2==0 ? 22 : 0) + 44*(b%GameConstants::BFIELD_WIDTH) + pos.x;
 				int y = 86 + 42 * (b/GameConstants::BFIELD_WIDTH) + pos.y;
 				SDL_Rect temp_rect = genRect(cellShade->h, cellShade->w, x, y);
-				CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, to, &temp_rect);
+				CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, nullptr, to, &temp_rect);
 			}
 		}
 	}
@@ -750,7 +750,7 @@ void CBattleInterface::show(SDL_Surface * to)
 	int preSize = pendingAnims.size();
 	for(std::list<std::pair<CBattleAnimation *, bool> >::iterator it = pendingAnims.begin(); it != pendingAnims.end(); ++it)
 	{
-		if(it->first == NULL)
+		if(it->first == nullptr)
 		{
 			pendingAnims.erase(it);
 			it = pendingAnims.begin();
@@ -767,7 +767,7 @@ void CBattleInterface::show(SDL_Surface * to)
 		bool changedStack = false;
 
 		//activation of next stack
-		if(pendingAnims.size() == 0 && stackToActivate != NULL)
+		if(pendingAnims.size() == 0 && stackToActivate != nullptr)
 		{
 			activateStack();
 			changedStack = true;
@@ -892,7 +892,7 @@ void CBattleInterface::show(SDL_Surface * to)
 		{
 			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_BlitSurface(bitmapToBlit, NULL, to, &temp_rect);
+			SDL_BlitSurface(bitmapToBlit, nullptr, to, &temp_rect);
 		}
 	}
 
@@ -1228,7 +1228,7 @@ void CBattleInterface::bFleef()
 
 	if( curInt->cb->battleCanFlee() )
 	{
-		CFunctionList<void()> ony = boost::bind(&CBattleInterface::reallyFlee,this);
+		CFunctionList<void()> ony = std::bind(&CBattleInterface::reallyFlee,this);
 		curInt->showYesNoDialog(CGI->generaltexth->allTexts[28], ony, 0, false); //Are you sure you want to retreat?
 	}
 	else
@@ -1341,7 +1341,7 @@ void CBattleInterface::bWaitf()
 	if(spellDestSelectMode) //we are casting a spell
 		return;
 
-	if(activeStack != NULL)
+	if(activeStack != nullptr)
 		giveCommand(Battle::WAIT,0,activeStack->ID);
 }
 
@@ -1350,7 +1350,7 @@ void CBattleInterface::bDefencef()
 	if(spellDestSelectMode) //we are casting a spell
 		return;
 
-	if(activeStack != NULL)
+	if(activeStack != nullptr)
 		giveCommand(Battle::DEFEND,0,activeStack->ID);
 }
 
@@ -1422,7 +1422,7 @@ void CBattleInterface::stackRemoved(int stackID)
 
 void CBattleInterface::stackActivated(const CStack * stack) //TODO: check it all before game state is changed due to abilities
 {
-	//givenCommand = NULL;
+	//givenCommand = nullptr;
 	stackToActivate = stack;
 	waitForAnims();
 	//if(pendingAnims.size() == 0)
@@ -1541,14 +1541,14 @@ void CBattleInterface::giveCommand(Battle::ActionType action, BattleHex tile, ui
 	{
         logGlobal->traceStream() << "Setting command for " << (stack ? stack->nodeName() : "hero");
 		myTurn = false;
-		activeStack = NULL;
+		activeStack = nullptr;
 		givenCommand->setn(ba);
 	}
 	else
 	{
 		curInt->cb->battleMakeTacticAction(ba);
 		vstd::clear_pointer(ba);
-		activeStack = NULL;
+		activeStack = nullptr;
 		//next stack will be activated when action ends
 	}
 }
@@ -1580,7 +1580,7 @@ const CGHeroInstance * CBattleInterface::getActiveHero()
 	const CStack * attacker = activeStack;
 	if (!attacker)
 	{
-		return NULL;
+		return nullptr;
 	}
 
 	if (attacker->attackerOwned)
@@ -1601,7 +1601,7 @@ 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)
 	{
 		const CStack * stack = curInt->cb->battleGetStackByID(ca.attacker);
-		addNewAnim(new CShootingAnimation(this, stack, it->first.second, NULL, true, it->second));
+		addNewAnim(new CShootingAnimation(this, stack, it->first.second, nullptr, true, it->second));
 
 		SDL_FreeSurface(siegeH->walls[it->first.first + 2]);
 		siegeH->walls[it->first.first + 2] = BitmapHandler::loadBitmap(
@@ -1618,7 +1618,7 @@ void CBattleInterface::battleFinished(const BattleResult& br)
 		animsAreDisplayed.waitUntil(false);
 	}
 	displayBattleFinished();
-	activeStack = NULL;
+	activeStack = nullptr;
 }
 
 void CBattleInterface::displayBattleFinished()
@@ -1635,7 +1635,7 @@ void CBattleInterface::spellCast( const BattleSpellCast * sc )
 	const CSpell &spell = *CGI->spellh->spells[sc->id];
 
 	//spell opening battle is cast when no stack is active
-	if(sc->castedByHero && ( activeStack == NULL || sc->side == !activeStack->attackerOwned) )
+	if(sc->castedByHero && ( activeStack == nullptr || sc->side == !activeStack->attackerOwned) )
 		bSpell->block(true);
 
 	std::vector< std::string > anims; //for magic arrow and ice bolt
@@ -1931,7 +1931,7 @@ void CBattleInterface::battleStacksEffectsSet(const SetStackEffect & sse)
 	}
 
 
-	if (activeStack != NULL) //it can be -1 when a creature casts effect
+	if (activeStack != nullptr) //it can be -1 when a creature casts effect
 	{
 		redrawBackgroundWithHexes(activeStack);
 	}
@@ -2052,7 +2052,7 @@ int CBattleInterface::getAnimSpeed() const
 void CBattleInterface::activateStack()
 {
 	activeStack = stackToActivate;
-	stackToActivate = NULL;
+	stackToActivate = nullptr;
 	const CStack *s = activeStack;
 
 	myTurn = true;
@@ -2067,7 +2067,7 @@ void CBattleInterface::activateStack()
 	ESpellCastProblem::ESpellCastProblem spellcastingProblem;
 	bool canCastSpells = curInt->cb->battleCanCastSpell(&spellcastingProblem);
 	bSpell->block(!canCastSpells && spellcastingProblem != ESpellCastProblem::MAGIC_IS_BLOCKED); //if magic is blocked, we leave button active, so the message can be displayed (cf bug #97)
-	bSurrender->block((curInt == attackerInt ? defendingHeroInstance : attackingHeroInstance) == NULL);
+	bSurrender->block((curInt == attackerInt ? defendingHeroInstance : attackingHeroInstance) == nullptr);
 	bFlee->block(!curInt->cb->battleCanFlee());
 	bSurrender->block(curInt->cb->battleGetSurrenderCost() < 0);
 
@@ -2118,8 +2118,8 @@ void CBattleInterface::endCastingSpell()
 	assert(spellDestSelectMode);
 
 	delete spellToCast;
-	spellToCast = NULL;
-	sp = NULL;
+	spellToCast = nullptr;
+	sp = nullptr;
 	spellDestSelectMode = false;
 	CCS->curh->changeGraphic(ECursor::COMBAT, ECursor::COMBAT_POINTER);
 
@@ -2281,7 +2281,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
                    (moveInside ? amountNormal->w + 10 : 0) * (stack->attackerOwned ? -1 : +1);
         int yAdd = 260 + ((stack->attackerOwned || moveInside) ? 0 : -15);
 		//blitting amount background box
-		SDL_Surface *amountBG = NULL;
+		SDL_Surface *amountBG = nullptr;
 		TBonusListPtr spellEffects = stack->getSpellBonuses();
 		if(!spellEffects->size())
 		{
@@ -2309,7 +2309,7 @@ void CBattleInterface::showAliveStack(const CStack *stack, SDL_Surface * to)
 			}
 		}
 		SDL_Rect temp_rect = genRect(amountNormal->h, amountNormal->w, creAnims[ID]->pos.x + xAdd, creAnims[ID]->pos.y + yAdd);
-		SDL_BlitSurface(amountBG, NULL, to, &temp_rect);
+		SDL_BlitSurface(amountBG, nullptr, to, &temp_rect);
 		//blitting amount
 
 		Point textPos(creAnims[ID]->pos.x + xAdd + 15, creAnims[ID]->pos.y + yAdd + 5);
@@ -2363,7 +2363,7 @@ void CBattleInterface::showPieceOfWall(SDL_Surface * to, int hex, const std::vec
 
 			if(posToSeek != -1)
 			{
-				const CStack *turret = NULL;
+				const CStack *turret = nullptr;
 
 				BOOST_FOREACH(const CStack *s, stacks)
 				{
@@ -2422,7 +2422,7 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
 	}
 
 	if(settings["battle"]["cellBorders"].Bool())
-		CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, NULL, backgroundWithHexes, NULL);
+		CSDL_Ext::blit8bppAlphaTo24bpp(cellBorders, nullptr, backgroundWithHexes, nullptr);
 
 	if(settings["battle"]["stackRange"].Bool())
 	{
@@ -2435,7 +2435,7 @@ void CBattleInterface::redrawBackgroundWithHexes(const CStack * activeStack)
 			int x = 58 + (i%2==0 ? 22 : 0) + 44*j;
 			int y = 86 + 42 * i;
 			SDL_Rect temp_rect = genRect(cellShade->h, cellShade->w, x, y);
-			CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, NULL, backgroundWithHexes, &temp_rect);
+			CSDL_Ext::blit8bppAlphaTo24bpp(cellShade, nullptr, backgroundWithHexes, &temp_rect);
 		}
 	}
 }
@@ -2468,7 +2468,7 @@ void CBattleInterface::printConsoleAttacked( const CStack * defender, int dmg, i
 
 void CBattleInterface::projectileShowHelper(SDL_Surface * to)
 {
-	if(to == NULL)
+	if(to == nullptr)
 		to = screen;
 	std::list< std::list<ProjectileInfo>::iterator > toBeDeleted;
 	for(std::list<ProjectileInfo>::iterator it=projectiles.begin(); it!=projectiles.end(); ++it)
@@ -2493,12 +2493,12 @@ void CBattleInterface::projectileShowHelper(SDL_Surface * to)
 		if(it->reverse)
 		{
 			SDL_Surface * rev = CSDL_Ext::rotate01(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap);
-			CSDL_Ext::blit8bppAlphaTo24bpp(rev, NULL, to, &dst);
+			CSDL_Ext::blit8bppAlphaTo24bpp(rev, nullptr, to, &dst);
 			SDL_FreeSurface(rev);
 		}
 		else
 		{
-			CSDL_Ext::blit8bppAlphaTo24bpp(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap, NULL, to, &dst);
+			CSDL_Ext::blit8bppAlphaTo24bpp(idToProjectile[it->creID]->ourImages[it->frameNum].bitmap, nullptr, to, &dst);
 		}
 
 		// Update projectile
@@ -2719,7 +2719,7 @@ void CBattleInterface::waitForAnims()
 
 void CBattleInterface::bEndTacticPhase()
 {
-	activeStack = NULL;
+	activeStack = nullptr;
 	btactEnd->block(true);
 	tacticsMode = false;
 }
@@ -2729,7 +2729,7 @@ static bool immobile(const CStack *s)
 	return !s->Speed(0, true); //should bound stacks be immobile?
 }
 
-void CBattleInterface::bTacticNextStack(const CStack *current /*= NULL*/)
+void CBattleInterface::bTacticNextStack(const CStack *current /*= nullptr*/)
 {
 	if(!current)
 		current = activeStack;
@@ -3103,7 +3103,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 				isCastingPossible = true;
 				break;
 			case RANDOM_GENIE_SPELL: //we assume that teleport / sacrifice will never be avaliable as random spell
-				sp = NULL;
+				sp = nullptr;
 				consoleMsg = boost::str(boost::format(CGI->generaltexth->allTexts[301]) % shere->getName()); //Cast a spell on %
 				creatureCasting = true;
 				isCastingPossible = true;
@@ -3147,7 +3147,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 				realizeAction = [=]{ GH.pushInt(createCreWindow(shere, true)); };
 	
 				//setting console text
-				const time_t curTime = time(NULL);
+				const time_t curTime = time(nullptr);
 				CCreatureAnimation *hoveredStackAnim = creAnims[shere->ID];
 
 				if (shere->ID != mouseHoveredStack
@@ -3245,7 +3245,7 @@ void CBattleInterface::handleHex(BattleHex myNumber, int eventType)
 					curInt->cb->battleMakeAction(spellToCast);
 					endCastingSpell();
 				}
-				selectedStack = NULL;
+				selectedStack = nullptr;
 			}
 		};
 	}
@@ -3271,7 +3271,7 @@ bool CBattleInterface::isCastingPossibleHere (const CStack * sactive, const CSta
 	else //hero casting
 		spellID  = spellToCast->additionalInfo;
 
-	sp = NULL;
+	sp = nullptr;
 	if (spellID >= 0) 
 		sp = CGI->spellh->spells[spellID];
 

+ 4 - 4
client/battle/CBattleInterface.h

@@ -124,8 +124,8 @@ private:
 
 	std::map< int, bool > creDir; // <creatureID, if false reverse creature's animation> //TODO: move it to battle callback
 	ui8 animCount;
-	const CStack * activeStack; //number of active stack; NULL - no one
-	const CStack * stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; NULL of none
+	const CStack * activeStack; //number of active stack; nullptr - no one
+	const CStack * stackToActivate; //when animation is playing, we should wait till the end to make the next stack active; nullptr of none
 	const CStack * selectedStack; //for Teleport / Sacrifice
 	void activateStack(); //sets activeStack to stackToActivate etc.
 	int mouseHoveredStack; //stack hovered by mouse; if -1 -> none
@@ -220,7 +220,7 @@ public:
 	std::vector<CClickableHex*> bfield; //11 lines, 17 hexes on each
 	//std::vector< CBattleObstacle * > obstacles; //vector of obstacles on the battlefield
 	SDL_Surface * cellBorder, * cellShade;
-	CondSh<BattleAction *> *givenCommand; //data != NULL if we have i.e. moved current unit
+	CondSh<BattleAction *> *givenCommand; //data != nullptr if we have i.e. moved current unit
 	bool myTurn; //if true, interface is active (commands can be ordered)
 	CBattleResultWindow * resWindow; //window of end of battle
 
@@ -241,7 +241,7 @@ public:
 	void bDefencef();
 	void bConsoleUpf();
 	void bConsoleDownf();
-	void bTacticNextStack(const CStack *current = NULL);
+	void bTacticNextStack(const CStack *current = nullptr);
 	void bEndTacticPhase();
 	//end of button handle funcs
 	//napisz tu klase odpowiadajaca za wyswietlanie bitwy i obsluge uzytkownika, polecenia ma przekazywac callbackiem

+ 14 - 14
client/battle/CBattleInterfaceClasses.cpp

@@ -134,13 +134,13 @@ void CBattleHero::show(SDL_Surface * to)
 	}
 	CSDL_Ext::blit8bppAlphaTo24bpp(
 		flag->ourImages[flagAnim].bitmap,
-		NULL,
+		nullptr,
 		screen,
 		&temp_rect);
 
 	//animation of hero
 	SDL_Rect rect = pos;
-	CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[currentFrame].bitmap, NULL, to, &rect);
+	CSDL_Ext::blit8bppAlphaTo24bpp(dh->ourImages[currentFrame].bitmap, nullptr, to, &rect);
 
 	if ( ++animCount == 4 )
 	{
@@ -165,7 +165,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
 	if(myOwner->spellDestSelectMode) //we are casting a spell
 		return;
 
-	if(!down && myHero != NULL && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
+	if(!down && myHero != nullptr && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
 	{
 		for(int it=0; it<GameConstants::BFIELD_SIZE; ++it) //do nothing when any hex is hovered - hero's animation overlaps battlefield
 		{
@@ -248,11 +248,11 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt
 	background = new CPicture("comopbck.bmp");
 	background->colorize(owner->curInt->playerID);
 
-	viewGrid = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintCellBorders, owner, true), boost::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", NULL, 25, 56, false);
+	viewGrid = new CHighlightableButton(std::bind(&CBattleInterface::setPrintCellBorders, owner, true), std::bind(&CBattleInterface::setPrintCellBorders, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[427].first)(3,CGI->generaltexth->zelp[427].first), CGI->generaltexth->zelp[427].second, false, "sysopchk.def", nullptr, 25, 56, false);
 	viewGrid->select(settings["battle"]["cellBorders"].Bool());
-	movementShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintStackRange, owner, true), boost::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[428].first)(3,CGI->generaltexth->zelp[428].first), CGI->generaltexth->zelp[428].second, false, "sysopchk.def", NULL, 25, 89, false);
+	movementShadow = new CHighlightableButton(std::bind(&CBattleInterface::setPrintStackRange, owner, true), std::bind(&CBattleInterface::setPrintStackRange, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[428].first)(3,CGI->generaltexth->zelp[428].first), CGI->generaltexth->zelp[428].second, false, "sysopchk.def", nullptr, 25, 89, false);
 	movementShadow->select(settings["battle"]["stackRange"].Bool());
-	mouseShadow = new CHighlightableButton(boost::bind(&CBattleInterface::setPrintMouseShadow, owner, true), boost::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[429].first)(3,CGI->generaltexth->zelp[429].first), CGI->generaltexth->zelp[429].second, false, "sysopchk.def", NULL, 25, 122, false);
+	mouseShadow = new CHighlightableButton(std::bind(&CBattleInterface::setPrintMouseShadow, owner, true), std::bind(&CBattleInterface::setPrintMouseShadow, owner, false), boost::assign::map_list_of(0,CGI->generaltexth->zelp[429].first)(3,CGI->generaltexth->zelp[429].first), CGI->generaltexth->zelp[429].second, false, "sysopchk.def", nullptr, 25, 122, false);
 	mouseShadow->select(settings["battle"]["mouseShadow"].Bool());
 
 	animSpeeds = new CHighlightableButtonsGroup(0);
@@ -260,12 +260,12 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt
 	animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[423].first),CGI->generaltexth->zelp[423].second, "sysob10.def", 92, 225, 2);
 	animSpeeds->addButton(boost::assign::map_list_of(0,CGI->generaltexth->zelp[424].first),CGI->generaltexth->zelp[424].second, "sysob11.def",156, 225, 4);
 	animSpeeds->select(owner->getAnimSpeed(), 1);
-	animSpeeds->onChange = boost::bind(&CBattleInterface::setAnimSpeed, owner, _1);
+	animSpeeds->onChange = std::bind(&CBattleInterface::setAnimSpeed, owner, _1);
 
-	setToDefault = new CAdventureMapButton (CGI->generaltexth->zelp[393], boost::bind(&CBattleOptionsWindow::bDefaultf,this), 246, 359, "codefaul.def");
+	setToDefault = new CAdventureMapButton (CGI->generaltexth->zelp[393], std::bind(&CBattleOptionsWindow::bDefaultf,this), 246, 359, "codefaul.def");
 	setToDefault->swappedImages = true;
 	setToDefault->update();
-	exit = new CAdventureMapButton (CGI->generaltexth->zelp[392], boost::bind(&CBattleOptionsWindow::bExitf,this), 357, 359, "soretrn.def",SDLK_RETURN);
+	exit = new CAdventureMapButton (CGI->generaltexth->zelp[392], std::bind(&CBattleOptionsWindow::bExitf,this), 357, 359, "soretrn.def",SDLK_RETURN);
 	exit->swappedImages = true;
 	exit->update();
 
@@ -312,7 +312,7 @@ CBattleResultWindow::CBattleResultWindow(const BattleResult &br, const SDL_Rect
 	CPicture * bg = new CPicture("CPRESULT");
 	bg->colorize(owner.playerID);
 
-	exit = new CAdventureMapButton ("", "", boost::bind(&CBattleResultWindow::bExitf,this), 384, 505, "iok6432.def", SDLK_RETURN);
+	exit = new CAdventureMapButton ("", "", std::bind(&CBattleResultWindow::bExitf,this), 384, 505, "iok6432.def", SDLK_RETURN);
 	exit->borderColor = Colors::METALLIC_GOLD;
 	exit->borderEnabled = true;
 
@@ -531,7 +531,7 @@ void CClickableHex::hover(bool on)
 	}
 }
 
-CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(NULL)
+CClickableHex::CClickableHex() : setAlterText(false), myNumber(-1), accessible(true), hovered(false), strictHovered(false), myInterface(nullptr)
 {
 	addUsedEvents(LCLICK | RCLICK | HOVER | MOVE);
 }
@@ -553,7 +553,7 @@ void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
 	if(hovered && strictHovered) //print attacked creature to console
 	{
 		const CStack * attackedStack = myInterface->curInt->cb->battleGetStackByPos(myNumber);
-		if(myInterface->console->alterTxt.size() == 0 &&attackedStack != NULL &&
+		if(myInterface->console->alterTxt.size() == 0 &&attackedStack != nullptr &&
 			attackedStack->owner != myInterface->curInt->playerID &&
 			attackedStack->alive())
 		{
@@ -582,7 +582,7 @@ void CClickableHex::clickLeft(tribool down, bool previousState)
 void CClickableHex::clickRight(tribool down, bool previousState)
 {
 	const CStack * myst = myInterface->curInt->cb->battleGetStackByPos(myNumber); //stack info
-	if(hovered && strictHovered && myst!=NULL)
+	if(hovered && strictHovered && myst!=nullptr)
 	{
 
 		if(!myst->alive()) return;
@@ -616,7 +616,7 @@ CStackQueue::CStackQueue(bool Embedded, CBattleInterface * _owner)
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	if(embedded)
 	{
-		bg = NULL;
+		bg = nullptr;
 		pos.w = QUEUE_SIZE * 37;
 		pos.h = 46;
 		pos.x = screen->w/2 - pos.w/2;

+ 1 - 1
client/battle/CCreatureAnimation.cpp

@@ -163,7 +163,7 @@ void CCreatureAnimation::playOnce( CCreatureAnim::EAnimType type )
 
 
 template<int bpp>
-int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= NULL*/)
+int CCreatureAnimation::nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame /*= true*/, bool yellowBorder /*= false*/, bool blueBorder /*= false*/, SDL_Rect * destRect /*= nullptr*/)
 {
 	//increasing frame number
 	int SIndex = curFrame;

+ 3 - 3
client/battle/CCreatureAnimation.h

@@ -52,8 +52,8 @@ private:
 	CCreatureAnim::EAnimType type; //type of animation being displayed (-1 - whole animation, >0 - specified part [default: -1])
 	
 	template<int bpp>
-	int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next 
-	int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next 
+	int nextFrameT(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = nullptr); //0 - success, any other - error //print next 
+	int nextFrameMiddle(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool IncrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = nullptr); //0 - success, any other - error //print next 
 	
 	std::map<int, std::vector<int> > frameGroups; //groups of frames; [groupID] -> vector of frame IDs in group
 	bool once;
@@ -66,7 +66,7 @@ public:
 	void setType(CCreatureAnim::EAnimType type); //sets type of animation and cleares framecount
 	CCreatureAnim::EAnimType getType() const; //returns type of animation
 
-	int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = NULL); //0 - success, any other - error //print next 
+	int nextFrame(SDL_Surface * dest, int x, int y, bool attacker, ui8 animCount, bool incrementFrame = true, bool yellowBorder = false, bool blueBorder = false, SDL_Rect * destRect = nullptr); //0 - success, any other - error //print next 
 	void incrementFrame();
 	int getFrame() const; // Gets the current frame ID relative to DEF file.
 	int getAnimationFrame() const; // Gets the current frame ID relative to frame group.

+ 1 - 1
client/gui/CCursorHandler.cpp

@@ -97,7 +97,7 @@ void CCursorHandler::drawRestored()
 	shiftPos(x, y);
 
 	SDL_Rect temp_rect = genRect(40, 40, x, y);
-	SDL_BlitSurface(help, NULL, screen, &temp_rect);
+	SDL_BlitSurface(help, nullptr, screen, &temp_rect);
 	//blitAt(help,x,y);
 }
 

+ 1 - 1
client/gui/CCursorHandler.h

@@ -49,7 +49,7 @@ public:
 	/**
 	 * Replaces the cursor with a custom image.
 	 *
-	 * @param image Image to replace cursor with or NULL to use the normal
+	 * @param image Image to replace cursor with or nullptr to use the normal
 	 * cursor. CursorHandler takes ownership of object
 	 */
 	void dragAndDropCursor (CAnimImage * image);

+ 6 - 6
client/gui/CGuiHandler.cpp

@@ -136,7 +136,7 @@ void CGuiHandler::popInts( int howMany )
 IShowActivatable * CGuiHandler::topInt()
 {
 	if(!listInt.size())
-		return NULL;
+		return nullptr;
 	else 
 		return listInt.front();
 }
@@ -303,7 +303,7 @@ void CGuiHandler::handleEvent(SDL_Event *sEvent)
 				(*i)->clickRight(boost::logic::indeterminate, prev);
 		}
 	}
-	current = NULL;
+	current = nullptr;
 
 } //event end
 
@@ -397,10 +397,10 @@ void CGuiHandler::run()
 CGuiHandler::CGuiHandler()
 :lastClick(-500, -500)
 {
-	curInt = NULL;
-	current = NULL;
+	curInt = nullptr;
+	current = nullptr;
 	terminate = false;
-	statusbar = NULL;
+	statusbar = nullptr;
 
 	// Creates the FPS manager and sets the framerate to 48 which is doubled the value of the original Heroes 3 FPS rate
 	mainFPSmng = new CFramerateManager(48);
@@ -414,7 +414,7 @@ CGuiHandler::~CGuiHandler()
 
 void CGuiHandler::breakEventHandling()
 {
-	current = NULL;
+	current = nullptr;
 }
 
 void CGuiHandler::drawFPSCounter()

+ 1 - 1
client/gui/CGuiHandler.h

@@ -67,7 +67,7 @@ public:
 	//objs to blit
 	std::vector<IShowable*> objsToBlit;
 
-	SDL_Event * current; //current event - can be set to NULL to stop handling event
+	SDL_Event * current; //current event - can be set to nullptr to stop handling event
 	IUpdateable *curInt;
 
 	Point lastClick;

+ 1 - 1
client/gui/CIntObject.cpp

@@ -257,7 +257,7 @@ void CIntObject::removeChild(CIntObject *child, bool adjustPosition /*= false*/)
 	assert(vstd::contains(children, child));
 	assert(child->parent_m == this);
 	children -= child;
-	child->parent_m = NULL;
+	child->parent_m = nullptr;
 	if(adjustPosition)
 		child->pos -= pos;
 }

+ 28 - 28
client/gui/CIntObjectClasses.cpp

@@ -97,7 +97,7 @@ CPicture::~CPicture()
 void CPicture::init()
 {
 	needRefresh = false;
-	srcRect = NULL;
+	srcRect = nullptr;
 }
 
 void CPicture::show(SDL_Surface * to)
@@ -158,7 +158,7 @@ void CPicture::createSimpleRect(const Rect &r, bool screenFormat, ui32 color)
 	else
 		bg = SDL_CreateRGBSurface(SDL_SWSURFACE, r.w, r.h, 8, 0, 0, 0, 0);
 
-	SDL_FillRect(bg, NULL, color);
+	SDL_FillRect(bg, nullptr, color);
 	freeSurf = true;
 }
 
@@ -200,8 +200,8 @@ CButtonBase::CButtonBase()
 	swappedImages = keepFrame = false;
 	bitmapOffset = 0;
 	state=NORMAL;
-	image = NULL;
-	text = NULL;
+	image = nullptr;
+	text = nullptr;
 }
 
 CButtonBase::~CButtonBase()
@@ -304,7 +304,7 @@ CAdventureMapButton::CAdventureMapButton( const std::string &Name, const std::st
 	init(Callback, pom, HelpBox, info->playerColoured, info->defName, &info->additionalDefs, info->x, info->y, key);
 }
 
-CAdventureMapButton::CAdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
+CAdventureMapButton::CAdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key/*=0*/, std::vector<std::string> * add /*= nullptr*/, bool playerColoredButton /*= false */ )
 {
 	std::map<int,std::string> pom;
 	pom[0] = help.first;
@@ -357,7 +357,7 @@ void CAdventureMapButton::hover (bool on)
 
 	std::string *name = (vstd::contains(hoverTexts,getState()))
 		? (&hoverTexts[getState()])
-		: (vstd::contains(hoverTexts,0) ? (&hoverTexts[0]) : NULL);
+		: (vstd::contains(hoverTexts,0) ? (&hoverTexts[0]) : nullptr);
 	if(name && name->size() && !isBlocked()) //if there is no name, there is nohing to display also
 	{
 		if (LOCPLINT && LOCPLINT->battleInt) //for battle buttons
@@ -491,7 +491,7 @@ CHighlightableButton::CHighlightableButton( const CFunctionList<void()> &onSelec
 	init(onSelect,Name,HelpBox,playerColoredButton,defName,add,x,y,key);
 }
 
-CHighlightableButton::CHighlightableButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
+CHighlightableButton::CHighlightableButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= nullptr*/, bool playerColoredButton /*= false */ )
 : onlyOn(false), selected(false) // TODO: callback2(???)
 {
 	ID = myid;
@@ -500,7 +500,7 @@ CHighlightableButton::CHighlightableButton( const std::pair<std::string, std::st
 	init(onSelect, pom, help.second, playerColoredButton, defName, add, x, y, key);
 }
 
-CHighlightableButton::CHighlightableButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= NULL*/, bool playerColoredButton /*= false */ )
+CHighlightableButton::CHighlightableButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key/*=0*/, std::vector<std::string> * add /*= nullptr*/, bool playerColoredButton /*= false */ )
 : onlyOn(false), selected(false) // TODO: callback2(???)
 {
 	ID = myid;
@@ -516,7 +516,7 @@ void CHighlightableButtonsGroup::addButton(CHighlightableButton* bt)
 	addChild(bt);
 	bt->recActions = defActions;//FIXME: not needed?
 
-	bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
+	bt->callback += std::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
 	bt->onlyOn = true;
 	buttons.push_back(bt);
 }
@@ -530,7 +530,7 @@ void CHighlightableButtonsGroup::addButton(const std::map<int,std::string> &tool
 		bt->setOffset(buttons.size()-3);
 	}
 	bt->ID = uid;
-	bt->callback += boost::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
+	bt->callback += std::bind(&CHighlightableButtonsGroup::selectionChanged,this,bt->ID);
 	bt->onlyOn = true;
 	buttons.push_back(bt);
 }
@@ -546,7 +546,7 @@ CHighlightableButtonsGroup::~CHighlightableButtonsGroup()
 
 void CHighlightableButtonsGroup::select(int id, bool mode)
 {
-	CHighlightableButton *bt = NULL;
+	CHighlightableButton *bt = nullptr;
 	if(mode)
 	{
 		for(size_t i=0;i<buttons.size() && !bt; ++i)
@@ -723,7 +723,7 @@ CSlider::~CSlider()
 
 }
 
-CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
+CSlider::CSlider(int x, int y, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, int Value, bool Horizontal, int style)
 :capacity(Capacity),amount(Amount),horizontal(Horizontal), moved(Moved)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
@@ -753,9 +753,9 @@ CSlider::CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int
 		right->pos.y = pos.y + totalw - 16;
 	}
 
-	left->callback = boost::bind(&CSlider::moveLeft,this);
-	right->callback = boost::bind(&CSlider::moveRight,this);
-	slider->callback = boost::bind(&CSlider::sliderClicked,this);
+	left->callback = std::bind(&CSlider::moveLeft,this);
+	right->callback = std::bind(&CSlider::moveRight,this);
+	slider->callback = std::bind(&CSlider::sliderClicked,this);
 	left->pos.w = left->pos.h = right->pos.w = right->pos.h = slider->pos.w = slider->pos.h = 16;
 	if(horizontal)
 	{
@@ -892,7 +892,7 @@ CIntObject* CObjectList::createItem(size_t index)
 {
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	CIntObject * item = createObject(index);
-	if (item == NULL)
+	if (item == nullptr)
 		item = new CIntObject();
 
 	item->recActions = defActions;
@@ -903,7 +903,7 @@ CIntObject* CObjectList::createItem(size_t index)
 
 CTabbedInt::CTabbedInt(CreateFunc create, DestroyFunc destroy, Point position, size_t ActiveID):
 CObjectList(create, destroy),
-activeTab(NULL),
+activeTab(nullptr),
 activeID(ActiveID)
 {
 	pos += position;
@@ -948,7 +948,7 @@ CListBox::CListBox(CreateFunc create, DestroyFunc destroy, Point Pos, Point Item
 	if (Slider & 1)
 	{
 		OBJ_CONSTRUCTION_CAPTURING_ALL;
-		slider = new CSlider(SliderPos.x, SliderPos.y, SliderPos.w, boost::bind(&CListBox::moveToPos, this, _1),
+		slider = new CSlider(SliderPos.x, SliderPos.y, SliderPos.w, std::bind(&CListBox::moveToPos, this, _1),
 			VisibleSize, TotalSize, InitialPos, Slider & 2, Slider & 4);
 	}
 	reset();
@@ -1095,7 +1095,7 @@ CSimpleWindow::~CSimpleWindow()
 	if (bitmap)
 	{
 		SDL_FreeSurface(bitmap);
-		bitmap=NULL;
+		bitmap=nullptr;
 	}
 }
 
@@ -1170,7 +1170,7 @@ CLabel::CLabel(int x, int y, EFonts Font /*= FONT_SMALL*/, EAlignment Align, con
 	pos.x += x;
 	pos.y += y;
 	pos.w = pos.h = 0;
-	bg = NULL;
+	bg = nullptr;
 	ignoreLeadingWhitespace = false;
 
 	if (alignment == TOPLEFT) // causes issues for MIDDLE
@@ -1315,7 +1315,7 @@ void CLabelGroup::add(int x, int y, const std::string &text)
 }
 
 CTextBox::CTextBox(std::string Text, const Rect &rect, int SliderStyle, EFonts Font /*= FONT_SMALL*/, EAlignment Align /*= TOPLEFT*/, const SDL_Color &Color /*= Colors::WHITE*/)
-:CBoundedLabel(rect.x, rect.y, Font, Align, Color, Text), sliderStyle(SliderStyle), slider(NULL)
+:CBoundedLabel(rect.x, rect.y, Font, Align, Color, Text), sliderStyle(SliderStyle), slider(nullptr)
 {
 	type |= REDRAW_PARENT;
 	autoRedraw = false;
@@ -1341,7 +1341,7 @@ void CTextBox::recalculateLines(const std::string &Txt)
 	{
 		lines = CMessage::breakText(Txt, pos.w - 32 - 10, font);
 		OBJ_CONSTRUCTION_CAPTURING_ALL;
-		slider = new CSlider(pos.w - 32, 0, pos.h, boost::bind(&CTextBox::sliderMoved, this, _1), lineCapacity, lines.size(), 0, false, sliderStyle);
+		slider = new CSlider(pos.w - 32, 0, pos.h, std::bind(&CTextBox::sliderMoved, this, _1), lineCapacity, lines.size(), 0, false, sliderStyle);
 		if(active)
 			slider->activate();
 	}
@@ -1512,9 +1512,9 @@ CTextInput::CTextInput(const Rect &Pos, SDL_Surface *srf)
 	bg = new CPicture(Pos, 0, true);
 	Rect hlp = Pos;
 	if(srf)
-		CSDL_Ext::blitSurface(srf, &hlp, *bg, NULL);
+		CSDL_Ext::blitSurface(srf, &hlp, *bg, nullptr);
 	else
-		SDL_FillRect(*bg, NULL, 0);
+		SDL_FillRect(*bg, nullptr, 0);
 	pos.w = bg->pos.w;
 	pos.h = bg->pos.h;
 	bg->pos = pos;
@@ -1639,7 +1639,7 @@ CFocusable::CFocusable()
 CFocusable::~CFocusable()
 {
 	if(inputWithFocus == this)
-		inputWithFocus = NULL;
+		inputWithFocus = nullptr;
 
 	focusables -= this;
 }
@@ -1814,9 +1814,9 @@ void CWindowObject::setShadow(bool on)
 			Uint32 shadowColor = SDL_MapRGBA(shadowCornerTempl->format, 0, 0, 0, 192);
 
 			//fill with shadow body color
-			SDL_FillRect(shadowCornerTempl, NULL, shadowColor);
-			SDL_FillRect(shadowBottomTempl, NULL, shadowColor);
-			SDL_FillRect(shadowRightTempl,  NULL, shadowColor);
+			SDL_FillRect(shadowCornerTempl, nullptr, shadowColor);
+			SDL_FillRect(shadowBottomTempl, nullptr, shadowColor);
+			SDL_FillRect(shadowRightTempl,  nullptr, shadowColor);
 
 			//fill last row and column with more transparent color
 			blitAlphaCol(shadowRightTempl , size-1);

+ 12 - 12
client/gui/CIntObjectClasses.h

@@ -27,7 +27,7 @@ class CSimpleWindow : public CIntObject
 public:
 	SDL_Surface * bitmap; //background
 	virtual void show(SDL_Surface * to);
-	CSimpleWindow():bitmap(NULL){}; //c-tor
+	CSimpleWindow():bitmap(nullptr){}; //c-tor
 	virtual ~CSimpleWindow(); //d-tor
 };
 
@@ -37,7 +37,7 @@ class CPicture : public CIntObject
 	void setSurface(SDL_Surface *to);
 public: 
 	SDL_Surface * bg;
-	Rect * srcRect; //if NULL then whole surface will be used
+	Rect * srcRect; //if nullptr then whole surface will be used
 	bool freeSurf; //whether surface will be freed upon CPicture destruction
 	bool needRefresh;//Surface needs to be displayed each frame
 
@@ -139,8 +139,8 @@ public:
 	void hover (bool on);
 
 	CAdventureMapButton(); //c-tor
-	CAdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
-	CAdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
+	CAdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = nullptr, bool playerColoredButton = false );//c-tor
+	CAdventureMapButton( const std::pair<std::string, std::string> &help, const CFunctionList<void()> &Callback, int x, int y, const std::string &defName, int key=0, std::vector<std::string> * add = nullptr, bool playerColoredButton = false );//c-tor
 	CAdventureMapButton( const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &Callback, config::ButtonInfo *info, int key=0);//c-tor
 
 	void init(const CFunctionList<void()> &Callback, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key );
@@ -157,8 +157,8 @@ class CHighlightableButton
 {
 public:
 	CHighlightableButton(const CFunctionList<void()> &onSelect, const CFunctionList<void()> &onDeselect, const std::map<int,std::string> &Name, const std::string &HelpBox, bool playerColoredButton, const std::string &defName, std::vector<std::string> * add, int x, int y, int key=0);
-	CHighlightableButton(const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
-	CHighlightableButton(const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = NULL, bool playerColoredButton = false );//c-tor
+	CHighlightableButton(const std::pair<std::string, std::string> &help, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = nullptr, bool playerColoredButton = false );//c-tor
+	CHighlightableButton(const std::string &Name, const std::string &HelpBox, const CFunctionList<void()> &onSelect, int x, int y, const std::string &defName, int myid, int key=0, std::vector<std::string> * add = nullptr, bool playerColoredButton = false );//c-tor
 	bool onlyOn;//button can not be de-selected
 	bool selected;//state of highlightable button
 	int ID; //for identification
@@ -200,7 +200,7 @@ public:
 	bool wheelScrolling;
 	bool keyScrolling;
 
-	boost::function<void(int)> moved;
+	std::function<void(int)> moved;
 
 	void redrawSlider(); 
 	void sliderClicked();
@@ -216,7 +216,7 @@ public:
 	void mouseMoved (const SDL_MouseMotionEvent & sEvent);
 	void showAll(SDL_Surface * to);
 
-	CSlider(int x, int y, int totalw, boost::function<void(int)> Moved, int Capacity, int Amount, 
+	CSlider(int x, int y, int totalw, std::function<void(int)> Moved, int Capacity, int Amount, 
 		int Value=0, bool Horizontal=true, int style = 0); //style 0 - brown, 1 - blue
 	~CSlider();
 	void moveToMax();
@@ -226,8 +226,8 @@ public:
 class CObjectList : public CIntObject
 {
 public:
-	typedef boost::function<CIntObject* (size_t)> CreateFunc;
-	typedef boost::function<void(CIntObject *)> DestroyFunc;
+	typedef std::function<CIntObject* (size_t)> CreateFunc;
+	typedef std::function<void(CIntObject *)> DestroyFunc;
 
 private:
 	CreateFunc createObject;
@@ -445,7 +445,7 @@ public:
 
 	CTextInput(const Rect &Pos, EFonts font, const CFunctionList<void(const std::string &)> &CB);
 	CTextInput(const Rect &Pos, const Point &bgOffset, const std::string &bgName, const CFunctionList<void(const std::string &)> &CB);
-	CTextInput(const Rect &Pos, SDL_Surface *srf = NULL);
+	CTextInput(const Rect &Pos, SDL_Surface *srf = nullptr);
 
 	void clickLeft(tribool down, bool previousState) override;
 	void keyPressed(const SDL_KeyboardEvent & key) override;
@@ -454,7 +454,7 @@ public:
 	//Filter that will block all characters not allowed in filenames
 	static void filenameFilter(std::string &text, const std::string & oldText);
 	//Filter that will allow only input of numbers in range min-max (min-max are allowed)
-	//min-max should be set via something like boost::bind
+	//min-max should be set via something like std::bind
 	static void numberFilter(std::string &text, const std::string & oldText, int minValue, int maxValue);
 };
 

+ 3 - 3
client/gui/Fonts.cpp

@@ -243,14 +243,14 @@ size_t CTrueTypeFont::getLineHeight() const
 size_t CTrueTypeFont::getSymbolWidth(char data) const
 {
 	int advance;
-	TTF_GlyphMetrics(font.get(), data, NULL, NULL, NULL, NULL, &advance);
+	TTF_GlyphMetrics(font.get(), data, nullptr, nullptr, nullptr, nullptr, &advance);
 	return advance;
 }
 
 size_t CTrueTypeFont::getStringWidth(const std::string & data) const
 {
 	int width;
-	TTF_SizeText(font.get(), data.c_str(), &width, NULL);
+	TTF_SizeText(font.get(), data.c_str(), &width, nullptr);
 	return width;
 }
 
@@ -273,7 +273,7 @@ void CTrueTypeFont::renderText(SDL_Surface * surface, const std::string & data,
 		assert(rendered);
 
 		Rect rect(pos.x, pos.y, rendered->w, rendered->h);
-		SDL_BlitSurface(rendered, NULL, surface, &rect);
+		SDL_BlitSurface(rendered, nullptr, surface, &rect);
 		SDL_FreeSurface(rendered);
 	}
 }

+ 8 - 8
client/gui/SDL_Extensions.cpp

@@ -53,7 +53,7 @@ void blitAt(SDL_Surface * src, int x, int y, SDL_Surface * dst)
 {
 	if(!dst) dst = screen;
 	SDL_Rect pom = genRect(src->h,src->w,x,y);
-	CSDL_Ext::blitSurface(src,NULL,dst,&pom);
+	CSDL_Ext::blitSurface(src,nullptr,dst,&pom);
 }
 
 void blitAt(SDL_Surface * src, const SDL_Rect & pos, SDL_Surface * dst)
@@ -395,7 +395,7 @@ int CSDL_Ext::blit8bppAlphaTo24bppT(const SDL_Surface * src, const SDL_Rect * sr
 		/* Make sure the surfaces aren't locked */
 		if ( ! src || ! dst )
 		{
-			SDL_SetError("SDL_UpperBlit: passed a NULL surface");
+			SDL_SetError("SDL_UpperBlit: passed a nullptr surface");
 			return -1;
 		}
 		if ( src->locked || dst->locked )
@@ -404,8 +404,8 @@ int CSDL_Ext::blit8bppAlphaTo24bppT(const SDL_Surface * src, const SDL_Rect * sr
 			return -1;
 		}
 
-		/* If the destination rectangle is NULL, use the entire dest surface */
-		if ( dstRect == NULL )
+		/* If the destination rectangle is nullptr, use the entire dest surface */
+		if ( dstRect == nullptr )
 		{
 			fulldst.x = fulldst.y = 0;
 			dstRect = &fulldst;
@@ -614,7 +614,7 @@ case BytesPerPixel:									\
 		CASE_BPP(4)
 	default:
         logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
-		return NULL;
+		return nullptr;
 	}
 
 }
@@ -628,7 +628,7 @@ TColorPutterAlpha CSDL_Ext::getPutterAlphaFor(SDL_Surface * const &dest, int inc
 		CASE_BPP(4)
 	default:
         logGlobal->errorStream() << (int)dest->format->BitsPerPixel << "bpp is not supported!";
-		return NULL;
+		return nullptr;
 	}
 #undef CASE_BPP
 }
@@ -716,7 +716,7 @@ BlitterWithRotationVal CSDL_Ext::getBlitterWithRotation(SDL_Surface *dest)
 	}
 
 	assert(0);
-	return NULL;
+	return nullptr;
 }
 
 BlitterWithRotationVal CSDL_Ext::getBlitterWithRotationAndAlpha(SDL_Surface *dest)
@@ -732,7 +732,7 @@ BlitterWithRotationVal CSDL_Ext::getBlitterWithRotationAndAlpha(SDL_Surface *des
 	}
 
 	assert(0);
-	return NULL;
+	return nullptr;
 }
 
 template<int bpp>

+ 8 - 8
client/mapHandler.cpp

@@ -245,7 +245,7 @@ static void processDef (const CGDefInfo* def)
 {
 	if(def->id == Obj::EVENT)
 	{
-		graphics->advmapobjGraphics[def->name] = NULL;
+		graphics->advmapobjGraphics[def->name] = nullptr;
 		return;
 	}
 	CDefEssential * ourDef = graphics->getDef(def);
@@ -543,7 +543,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 				pp.w = sr.w;
 
 				const CGHeroInstance * themp = (obj->ID != Obj::HERO
-					? NULL  
+					? nullptr  
 					: static_cast<const CGHeroInstance*>(obj));
 
 				//print hero / boat and flag
@@ -551,8 +551,8 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 				{
 					const int IMGVAL = 8; //frames per group of movement animation
 					ui8 dir;
-					std::vector<Cimage> * iv = NULL;
-					std::vector<CDefEssential *> Graphics::*flg = NULL;
+					std::vector<Cimage> * iv = nullptr;
+					std::vector<CDefEssential *> Graphics::*flg = nullptr;
 					SDL_Surface * tb = nullptr; //surface to blitted
 
 					if(themp) //hero
@@ -639,7 +639,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 							bufr.h = 64;
 							bufr.w = 96;
 							if(bufr.x-extRect->x>-64)
-								CSDL_Ext::blitSurface((graphics->*flg)[color.getNum()]->ourImages[getHeroFrameNum(dir, false) *8+(heroAnim/4)%IMGVAL].bitmap, NULL, extSurf, &bufr);
+								CSDL_Ext::blitSurface((graphics->*flg)[color.getNum()]->ourImages[getHeroFrameNum(dir, false) *8+(heroAnim/4)%IMGVAL].bitmap, nullptr, extSurf, &bufr);
 						}
 					}
 				}
@@ -665,7 +665,7 @@ void CMapHandler::terrainRect( int3 top_tile, ui8 anim, const std::vector< std::
 			{
 				if(bx == grailPosRel.x && by == grailPosRel.y)
 				{
-					CSDL_Ext::blit8bppAlphaTo24bpp(graphics->heroMoveArrows->ourImages[0].bitmap, NULL, extSurf, &sr);
+					CSDL_Ext::blit8bppAlphaTo24bpp(graphics->heroMoveArrows->ourImages[0].bitmap, nullptr, extSurf, &sr);
 				}
 			}
 		}
@@ -1077,8 +1077,8 @@ CMapHandler::~CMapHandler()
 CMapHandler::CMapHandler()
 {
 	frameW = frameH = 0;
-	graphics->FoWfullHide = NULL;
-	graphics->FoWpartialHide = NULL;
+	graphics->FoWfullHide = nullptr;
+	graphics->FoWpartialHide = nullptr;
 }
 
 void CMapHandler::getTerrainDescr( const int3 &pos, std::string & out, bool terName )

+ 12 - 13
lib/BattleState.cpp

@@ -2,7 +2,6 @@
 #include "BattleState.h"
 
 #include <numeric>
-#include <boost/random/linear_congruential.hpp>
 #include "VCMI_Lib.h"
 #include "CObjectHandler.h"
 #include "CHeroHandler.h"
@@ -23,7 +22,7 @@
  * Full text of license available in license.txt file, in main folder
  *
  */
-extern boost::rand48 ran;
+extern std::minstd_rand ran;
 
 const CStack * BattleInfo::getNextStack() const
 {
@@ -33,7 +32,7 @@ const CStack * BattleInfo::getNextStack() const
 	if(hlp.size())
 		return hlp[0];
 	else
-		return NULL;
+		return nullptr;
 }
 
 int BattleInfo::getAvaliableHex(CreatureID creID, bool attackerOwned, int initialPos) const
@@ -193,7 +192,7 @@ bool BattleInfo::resurrects(SpellID spellid) const
 
 const CStack * BattleInfo::battleGetStack(BattleHex pos, bool onlyAlive)
 {
-	CStack * stack = NULL;
+	CStack * stack = nullptr;
 	for(ui32 g=0; g<stacks.size(); ++g)
 	{
 		if(stacks[g]->position == pos
@@ -299,7 +298,7 @@ struct RangeGenerator
 	{
 	};
 
-	RangeGenerator(int _min, int _max, boost::function<int()> _myRand)
+	RangeGenerator(int _min, int _max, std::function<int()> _myRand)
 	{
 		myRand = _myRand;
 		min = _min;
@@ -317,7 +316,7 @@ struct RangeGenerator
 	}
 
 	//get number fulfilling predicate. Never gives the same number twice.
-	int getSuchNumber(boost::function<bool(int)> goodNumberPred = 0)
+	int getSuchNumber(std::function<bool(int)> goodNumberPred = 0)
 	{
 		int ret = -1;
 		do
@@ -343,7 +342,7 @@ struct RangeGenerator
 
 	int min, remainingCount;
 	std::vector<bool> remaining;
-	boost::function<int()> myRand;
+	std::function<int()> myRand;
 };
 
 BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldType battlefieldType, const CArmedInstance *armies[2], const CGHeroInstance * heroes[2], bool creatureBank, const CGTownInstance *town )
@@ -376,7 +375,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 	}
 	else
 	{
-		curB->town = NULL;
+		curB->town = nullptr;
 		curB->siege = CGTownInstance::NONE;
 		curB->terrainType = terrain;
 	}
@@ -391,7 +390,7 @@ BattleInfo * BattleInfo::setupBattle( int3 tile, ETerrainType terrain, BFieldTyp
 	}
 
 	//randomize obstacles
- 	if (town == NULL && !creatureBank) //do it only when it's not siege and not creature bank
+ 	if (town == nullptr && !creatureBank) //do it only when it's not siege and not creature bank
  	{
 		const int ABSOLUTE_OBSTACLES_COUNT = 34, USUAL_OBSTACLES_COUNT = 91; //shouldn't be changes if we want H3-like obstacle placement
 
@@ -857,7 +856,7 @@ CStack::CStack()
 	setNodeType(STACK_BATTLE);
 }
 CStack::CStack(const CStackBasicDescriptor *stack, PlayerColor O, int I, bool AO, SlotID S)
-	: base(NULL), ID(I), owner(O), slot(S), attackerOwned(AO), counterAttacks(1)
+	: base(nullptr), ID(I), owner(O), slot(S), attackerOwned(AO), counterAttacks(1)
 {
 	type = stack->type;
 	count = baseAmount = stack->count;
@@ -866,8 +865,8 @@ CStack::CStack(const CStackBasicDescriptor *stack, PlayerColor O, int I, bool AO
 
 void CStack::init()
 {
-	base = NULL;
-	type = NULL;
+	base = nullptr;
+	type = nullptr;
 	ID = -1;
 	count = baseAmount = -1;
 	firstHPleft = -1;
@@ -1111,7 +1110,7 @@ const CGHeroInstance * CStack::getMyHero() const
 			if(n->getNodeType() == HERO)
 				return dynamic_cast<const CGHeroInstance *>(n);
 
-	return NULL;
+	return nullptr;
 }
 
 std::string CStack::nodeName() const

+ 9 - 9
lib/BattleState.h

@@ -86,12 +86,12 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	const CStack * getNextStack() const; //which stack will have turn after current one
 	//void getStackQueue(std::vector<const CStack *> &out, int howMany, int turn = 0, int lastMoved = -1) const; //returns stack in order of their movement action
 
-	//void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set<BattleHex> & occupyable, bool flying, const CStack* stackToOmmit = NULL) const; //send pointer to at least 187 allocated bytes
+	//void getAccessibilityMap(bool *accessibility, bool twoHex, bool attackerOwned, bool addOccupiable, std::set<BattleHex> & occupyable, bool flying, const CStack* stackToOmmit = nullptr) const; //send pointer to at least 187 allocated bytes
 	//static bool isAccessible(BattleHex hex, bool * accessibility, bool twoHex, bool attackerOwned, bool flying, bool lastPos); //helper for makeBFS
 	int getAvaliableHex(CreatureID creID, bool attackerOwned, int initialPos = -1) const; //find place for summon / clone effects
 	//void makeBFS(BattleHex start, bool*accessibility, BattleHex *predecessor, int *dists, bool twoHex, bool attackerOwned, bool flying, bool fillPredecessors) const; //*accessibility must be prepared bool[187] array; last two pointers must point to the at least 187-elements int arrays - there is written result
 	std::pair< std::vector<BattleHex>, int > getPath(BattleHex start, BattleHex dest, const CStack *stack); //returned value: pair<path, length>; length may be different than number of elements in path since flying vreatures jump between distant hexes
-	//std::vector<BattleHex> getAccessibility(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = NULL, bool forPassingBy = false) const; //returns vector of accessible tiles (taking into account the creature range)
+	//std::vector<BattleHex> getAccessibility(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = nullptr, bool forPassingBy = false) const; //returns vector of accessible tiles (taking into account the creature range)
 
 	//bool isObstacleVisibleForSide(const CObstacleInstance &obstacle, ui8 side) const;
 	shared_ptr<CObstacleInstance> getObstacleOnTile(BattleHex tile) const;
@@ -108,7 +108,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	CStack * generateNewStack(const CStackBasicDescriptor &base, bool attackerOwned, SlotID slot, BattleHex position) const; //helper for CGameHandler::setupBattle and spells addign new stacks to the battlefield
 	int getIdForNewStack() const; //suggest a currently unused ID that'd suitable for generating a new stack
 	//std::pair<const CStack *, BattleHex> getNearestStack(const CStack * closest, boost::logic::tribool attackerOwned) const; //if attackerOwned is indetermnate, returened stack is of any owner; hex is the number of hex we should be looking from; returns (nerarest creature, predecessorHex)
-	ui32 calculateHealedHP(const CGHeroInstance * caster, const CSpell * spell, const CStack * stack, const CStack * sacrificedStack = NULL) const; //Sacrifice
+	ui32 calculateHealedHP(const CGHeroInstance * caster, const CSpell * spell, const CStack * stack, const CStack * sacrificedStack = nullptr) const; //Sacrifice
 	ui32 calculateHealedHP(int healedHealth, const CSpell * spell, const CStack * stack) const; //for Archangel
 	ui32 calculateHealedHP(const CSpell * spell, int usedSpellPower, int spellSchoolLevel, const CStack * stack) const; //healing spells casted by stacks
 	bool resurrects(SpellID spellid) const; //TODO: move it to spellHandler?
@@ -119,7 +119,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 	std::vector<ui32> 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;
 
 	const CStack * battleGetStack(BattleHex pos, bool onlyAlive); //returns stack at given tile
-	const CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; NULL if none
+	const CGHeroInstance * battleGetOwner(const CStack * stack) const; //returns hero that owns given stack; nullptr if none
 	void localInit();
 
 	void localInitStack(CStack * s);
@@ -136,7 +136,7 @@ struct DLL_LINKAGE BattleInfo : public CBonusSystemNode, public CBattleInfoCallb
 class DLL_LINKAGE CStack : public CBonusSystemNode, public CStackBasicDescriptor
 {
 public:
-	const CStackInstance *base; //garrison slot from which stack originates (NULL for war machines, summoned cres, etc)
+	const CStackInstance *base; //garrison slot from which stack originates (nullptr for war machines, summoned cres, etc)
 
 	ui32 ID; //unique ID of stack
 	ui32 baseAmount;
@@ -157,7 +157,7 @@ public:
 	CStack(const CStackBasicDescriptor *stack, PlayerColor O, int I, bool AO, SlotID S = SlotID(255)); //c-tor
 	CStack(); //c-tor
 	~CStack();
-	std::string nodeName() const OVERRIDE;
+	std::string nodeName() const override;
 
 	void init(); //set initial (invalid) values
 	void postInit(); //used to finish initialization when inheriting creature parameters is working
@@ -173,7 +173,7 @@ public:
 	si32 magicResistance() const; //include aura of resistance
 	static void stackEffectToFeature(std::vector<Bonus> & sf, const Bonus & sse);
 	std::vector<si32> activeSpells() const; //returns vector of active spell IDs sorted by time of cast
-	const CGHeroInstance *getMyHero() const; //if stack belongs to hero (directly or was by him summoned) returns hero, NULL otherwise
+	const CGHeroInstance *getMyHero() const; //if stack belongs to hero (directly or was by him summoned) returns hero, nullptr otherwise
 
 	static inline Bonus featureGenerator(Bonus::BonusType type, si16 subtype, si32 value, ui16 turnsRemain, si32 additionalInfo = 0, Bonus::LimitEffect limit = Bonus::NO_LIMIT)
 	{
@@ -204,7 +204,7 @@ public:
 		h & ID & baseAmount & firstHPleft & owner & slot & attackerOwned & position & state & counterAttacks
 			& shots & casts & count;
 
-		const CArmedInstance *army = (base ? base->armyObj : NULL);
+		const CArmedInstance *army = (base ? base->armyObj : nullptr);
 		SlotID slot = (base ? base->armyObj->findStack(base) : SlotID());
 
 		if(h.saving)
@@ -222,7 +222,7 @@ public:
 			}
 			else if(!army || slot == SlotID() || !army->hasStackAtSlot(slot))
 			{
-				base = NULL;
+				base = nullptr;
                 logGlobal->warnStream() << type->nameSing << " doesn't have a base stack!";
 			}
 			else

+ 8 - 9
lib/CArtHandler.cpp

@@ -3,7 +3,6 @@
 
 #include "filesystem/CResourceLoader.h"
 #include "CGeneralTextHandler.h"
-#include <boost/random/linear_congruential.hpp>
 #include "VCMI_Lib.h"
 #include "CModHandler.h"
 #include "CSpellHandler.h"
@@ -23,7 +22,7 @@ using namespace boost::assign;
  *
  */
 
-extern boost::rand48 ran;
+extern std::minstd_rand ran;
 // Note: list must match entries in ArtTraits.txt
 #define ART_POS_LIST    \
 	ART_POS(SPELLBOOK)  \
@@ -494,7 +493,7 @@ void CArtHandler::giveArtBonus( ArtifactID aid, Bonus::BonusType type, int val,
 	giveArtBonus(aid, createBonus(type, val, subtype, valType, limiter, additionalInfo));
 }
 
-void CArtHandler::giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator /*= NULL*/, int additionalInfo)
+void CArtHandler::giveArtBonus(ArtifactID aid, Bonus::BonusType type, int val, int subtype, shared_ptr<IPropagator> propagator /*= nullptr*/, int additionalInfo)
 {
 	giveArtBonus(aid, createBonus(type, val, subtype, propagator, additionalInfo));
 }
@@ -967,7 +966,7 @@ void CCombinedArtifactInstance::removeFrom(ArtifactLocation al)
 
 CArtifactInstance * CCombinedArtifactInstance::figureMainConstituent(const ArtifactLocation al)
 {
-	CArtifactInstance *mainConstituent = NULL; //it'll be replaced with combined artifact, not a lock
+	CArtifactInstance *mainConstituent = nullptr; //it'll be replaced with combined artifact, not a lock
 	BOOST_FOREACH(ConstituentInfo &ci, constituentsInfo)
 		if(ci.slot == al.slot)
 			mainConstituent = ci.art;
@@ -1006,7 +1005,7 @@ bool CCombinedArtifactInstance::isPart(const CArtifactInstance *supposedPart) co
 	return false;
 }
 
-CCombinedArtifactInstance::ConstituentInfo::ConstituentInfo(CArtifactInstance *Art /*= NULL*/, ArtifactPosition Slot /*= -1*/)
+CCombinedArtifactInstance::ConstituentInfo::ConstituentInfo(CArtifactInstance *Art /*= nullptr*/, ArtifactPosition Slot /*= -1*/)
 {
 	art = Art;
 	slot = Slot;
@@ -1025,7 +1024,7 @@ const CArtifactInstance* CArtifactSet::getArt(ArtifactPosition pos, bool exclude
 			return si->artifact;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 CArtifactInstance* CArtifactSet::getArt(ArtifactPosition pos, bool excludeLocked /*= true*/)
@@ -1072,7 +1071,7 @@ const CArtifactInstance * CArtifactSet::getArtByInstanceId( ArtifactInstanceID a
 		if(i.artifact->id == artInstId)
 			return i.artifact;
 
-	return NULL;
+	return nullptr;
 }
 
 bool CArtifactSet::hasArt(ui32 aid, bool onlyWorn /*= false*/) const
@@ -1088,12 +1087,12 @@ const ArtSlotInfo * CArtifactSet::getSlot(ArtifactPosition pos) const
 	{
 		int backpackPos = (int)pos - GameConstants::BACKPACK_START;
 		if(backpackPos < 0 || backpackPos >= artifactsInBackpack.size())
-			return NULL;
+			return nullptr;
 		else
 			return &artifactsInBackpack[backpackPos];
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 bool CArtifactSet::isPositionFree(ArtifactPosition pos, bool onlyLockCheck /*= false*/) const

+ 4 - 4
lib/CArtHandler.h

@@ -67,7 +67,7 @@ public:
 
 	ui32 price;
 	bmap<ArtBearer::ArtBearer, std::vector<ArtifactPosition> > possibleSlots; //Bearer Type => ids of slots where artifact can be placed
-	std::unique_ptr<std::vector<CArtifact *> > constituents; // Artifacts IDs a combined artifact consists of, or NULL.
+	std::unique_ptr<std::vector<CArtifact *> > constituents; // Artifacts IDs a combined artifact consists of, or nullptr.
 	std::vector<CArtifact *> constituentOf; // Reverse map of constituents - combined arts that include this art
 	EartClass aClass;
 	ArtifactID id;
@@ -157,7 +157,7 @@ public:
 		}
 
 		bool operator==(const ConstituentInfo &rhs) const;
-		ConstituentInfo(CArtifactInstance *art = NULL, ArtifactPosition slot = ArtifactPosition::PRE_FIRST);
+		ConstituentInfo(CArtifactInstance *art = nullptr, ArtifactPosition slot = ArtifactPosition::PRE_FIRST);
 	};
 
 	std::vector<ConstituentInfo> constituentsInfo;
@@ -272,8 +272,8 @@ public:
 	void eraseArtSlot(ArtifactPosition slot);
 
 	const ArtSlotInfo *getSlot(ArtifactPosition pos) const;
-	const CArtifactInstance* getArt(ArtifactPosition pos, bool excludeLocked = true) const; //NULL - no artifact
-	CArtifactInstance* getArt(ArtifactPosition pos, bool excludeLocked = true); //NULL - no artifact
+	const CArtifactInstance* getArt(ArtifactPosition pos, bool excludeLocked = true) const; //nullptr - no artifact
+	CArtifactInstance* getArt(ArtifactPosition pos, bool excludeLocked = true); //nullptr - no artifact
 	ArtifactPosition getArtPos(int aid, bool onlyWorn = true) const; //looks for equipped artifact with given ID and returns its slot ID or -1 if none(if more than one such artifact lower ID is returned)
 	ArtifactPosition getArtPos(const CArtifactInstance *art) const;
 	const CArtifactInstance *getArtByInstanceId(ArtifactInstanceID artInstId) const;

+ 13 - 13
lib/CBattleCallback.cpp

@@ -210,8 +210,8 @@ const CGTownInstance * CBattleInfoEssentials::battleGetDefendedTown() const
 	RETURN_IF_NOT_BATTLE(nullptr);
 
 
-	if(!getBattle() || getBattle()->town == NULL)
-		return NULL;
+	if(!getBattle() || getBattle()->town == nullptr)
+		return nullptr;
 
 	return getBattle()->town;
 }
@@ -503,7 +503,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 	//let's define a huge lambda
 	auto takeStack = [&](std::vector<const CStack *> &st) -> const CStack*
 	{
-		const CStack *ret = NULL;
+		const CStack *ret = nullptr;
 		unsigned i, //fastest stack
 			j=0; //fastest stack of the other side
 		for(i = 0; i < st.size(); i++)
@@ -514,7 +514,7 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 		if(i == st.size())
 			return nullptr;
 
-		const CStack *fastest = st[i], *other = NULL;
+		const CStack *fastest = st[i], *other = nullptr;
 		int bestSpeed = fastest->Speed(turn);
 
 		if(fastest->attackerOwned != lastMoved)
@@ -546,9 +546,9 @@ void CBattleInfoCallback::battleGetStackQueue(std::vector<const CStack *> &out,
 
 		assert(ret);
 		if(ret == fastest)
-			st[i] = NULL;
+			st[i] = nullptr;
 		else
-			st[j] = NULL;
+			st[j] = nullptr;
 
 		lastMoved = ret->attackerOwned;
 		return ret;
@@ -998,7 +998,7 @@ TDmgRange CBattleInfoCallback::battleEstimateDamage(const CStack * attacker, con
 	return battleEstimateDamage(bai, retaliationDmg);
 }
 
-std::pair<ui32, ui32> CBattleInfoCallback::battleEstimateDamage(const BattleAttackInfo &bai, std::pair<ui32, ui32> * retaliationDmg /*= NULL*/) const
+std::pair<ui32, ui32> CBattleInfoCallback::battleEstimateDamage(const BattleAttackInfo &bai, std::pair<ui32, ui32> * retaliationDmg /*= nullptr*/) const
 {
 	RETURN_IF_NOT_BATTLE(std::make_pair(0, 0));
 
@@ -1225,7 +1225,7 @@ std::pair<const CStack *, BattleHex> CBattleInfoCallback::getNearestStack(const
 		return std::make_pair(minimal->stack, reachability.predecessors[minimal->stack->position]);
 	}
 	else
-		return std::make_pair<const CStack * , BattleHex>(NULL, BattleHex::INVALID);
+		return std::make_pair<const CStack * , BattleHex>(nullptr, BattleHex::INVALID);
 }
 
 si8 CBattleInfoCallback::battleGetTacticDist() const
@@ -1424,7 +1424,7 @@ bool CBattleInfoCallback::isToReverse (BattleHex hexFrom, BattleHex hexTo, bool
 	}
 }
 
-ReachabilityInfo::TDistances CBattleInfoCallback::battleGetDistances(const CStack * stack, BattleHex hex /*= BattleHex::INVALID*/, BattleHex * predecessors /*= NULL*/) const
+ReachabilityInfo::TDistances CBattleInfoCallback::battleGetDistances(const CStack * stack, BattleHex hex /*= BattleHex::INVALID*/, BattleHex * predecessors /*= nullptr*/) const
 {
 	ReachabilityInfo::TDistances ret;
 	ret.fill(-1);
@@ -1811,7 +1811,7 @@ ESpellCastProblem::ESpellCastProblem CBattleInfoCallback::battleCanCastThisSpell
 	if (mode == ECastingMode::HERO_CASTING)
 		return battleIsImmune(battleGetFightingHero(playerToSide(player)), spell, mode, dest);
 	else
-		return battleIsImmune(NULL, spell, mode, dest);
+		return battleIsImmune(nullptr, spell, mode, dest);
 }
 
 ui32 CBattleInfoCallback::calculateSpellBonus(ui32 baseDamage, const CSpell * sp, const CGHeroInstance * caster, const CStack * affectedCreature) const
@@ -1999,13 +1999,13 @@ std::set<const CStack*> CBattleInfoCallback::getAffectedCreatures(const CSpell *
 	return attackedCres;
 }
 
-const CStack * CBattleInfoCallback::getStackIf(boost::function<bool(const CStack*)> pred) const
+const CStack * CBattleInfoCallback::getStackIf(std::function<bool(const CStack*)> pred) const
 {
 	RETURN_IF_NOT_BATTLE(nullptr);
 	auto stacks = battleGetAllStacks();
 	auto stackItr = range::find_if(stacks, pred);
 	return stackItr == stacks.end()
-		? NULL
+		? nullptr
 		: *stackItr;
 }
 
@@ -2172,7 +2172,7 @@ int CBattleInfoCallback::battleGetSurrenderCost(PlayerColor Player) const
 
 si8 CBattleInfoCallback::battleMaxSpellLevel() const
 {
-	const CBonusSystemNode *node = NULL;
+	const CBonusSystemNode *node = nullptr;
 	if(const CGHeroInstance *h =  battleGetFightingHero(battleGetMySide()))
 		node = h;
 	//TODO else use battle node

+ 7 - 7
lib/CBattleCallback.h

@@ -36,7 +36,7 @@ class CBattleInfoEssentials;
 //Basic class for various callbacks (interfaces called by players to get info about game and so forth)
 class DLL_LINKAGE CCallbackBase
 {
-	const BattleInfo *battle; //battle to which the player is engaged, NULL if none or not applicable
+	const BattleInfo *battle; //battle to which the player is engaged, nullptr if none or not applicable
 
 	const BattleInfo * getBattle() const
 	{
@@ -171,7 +171,7 @@ public:
 	bool battleHasNativeStack(ui8 side) const;
 	ui8 battleGetWallState(int partOfWall) const; //for determining state of a part of the wall; format: parameter [0] - keep, [1] - bottom tower, [2] - bottom wall, [3] - below gate, [4] - over gate, [5] - upper wall, [6] - uppert tower, [7] - gate; returned value: 1 - intact, 2 - damaged, 3 - destroyed; 0 - no battle
 	int battleGetMoatDmg() const; //what dmg unit will suffer if ending turn in the moat
-	const CGTownInstance * battleGetDefendedTown() const; //returns defended town if current battle is a siege, NULL instead
+	const CGTownInstance * battleGetDefendedTown() const; //returns defended town if current battle is a siege, nullptr instead
 	const CStack *battleActiveStack() const;
 	si8 battleTacticDist() const; //returns tactic distance in current tactics phase; 0 if not in tactics phase
 	si8 battleGetTacticsSide() const; //returns which side is in tactics phase, undefined if none (?)
@@ -226,10 +226,10 @@ public:
 	void battleGetStackCountOutsideHexes(bool *ac) const; // returns hexes which when in front of a stack cause us to move the amount box back
 
 
-	std::vector<BattleHex> battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = NULL) const; //returns hexes reachable by creature with id ID (valid movement destinations), DOES contain stack current position
+	std::vector<BattleHex> battleGetAvailableHexes(const CStack * stack, bool addOccupiable, std::vector<BattleHex> * attackable = nullptr) const; //returns hexes reachable by creature with id ID (valid movement destinations), DOES contain stack current position
 
 	int battleGetSurrenderCost(PlayerColor Player) const; //returns cost of surrendering battle, -1 if surrendering is not possible
-	ReachabilityInfo::TDistances battleGetDistances(const CStack * stack, BattleHex hex = BattleHex::INVALID, BattleHex * predecessors = NULL) const; //returns vector of distances to [dest hex number]
+	ReachabilityInfo::TDistances battleGetDistances(const CStack * stack, BattleHex hex = BattleHex::INVALID, BattleHex * predecessors = nullptr) const; //returns vector of distances to [dest hex number]
 	std::set<BattleHex> battleGetAttackedHexes(const CStack* attacker, BattleHex destinationTile, BattleHex attackerPos = BattleHex::INVALID) const;
 	bool battleCanShoot(const CStack * stack, BattleHex dest) const; //determines if stack with given ID shoot at the selected destination
 	bool battleIsStackBlocked(const CStack * stack) const; //returns true if there is neighboring enemy stack
@@ -240,8 +240,8 @@ public:
 	TDmgRange calculateDmgRange(const CStack* attacker, const CStack* defender, bool shooting, ui8 charge, bool lucky, bool unlucky, bool deathBlow, bool ballistaDoubleDmg) const; //charge - number of hexes travelled before attack (for champion's jousting); returns pair <min dmg, max dmg>
 
 	//hextowallpart  //int battleGetWallUnderHex(BattleHex hex) const; //returns part of destructible wall / gate / keep under given hex or -1 if not found
-	std::pair<ui32, ui32> battleEstimateDamage(const BattleAttackInfo &bai, std::pair<ui32, ui32> * retaliationDmg = NULL) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
-	std::pair<ui32, ui32> battleEstimateDamage(const CStack * attacker, const CStack * defender, std::pair<ui32, ui32> * retaliationDmg = NULL) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
+	std::pair<ui32, ui32> battleEstimateDamage(const BattleAttackInfo &bai, std::pair<ui32, ui32> * retaliationDmg = nullptr) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
+	std::pair<ui32, ui32> battleEstimateDamage(const CStack * attacker, const CStack * defender, std::pair<ui32, ui32> * retaliationDmg = nullptr) const; //estimates damage dealt by attacker to defender; it may be not precise especially when stack has randomly working bonuses; returns pair <min dmg, max dmg>
 	si8 battleHasDistancePenalty( const CStack * stack, BattleHex destHex ) const;
 	si8 battleHasDistancePenalty(const IBonusBearer *bonusBearer, BattleHex shooterPosition, BattleHex destHex ) const;
 	si8 battleHasWallPenalty(const CStack * stack, BattleHex destHex) const; //checks if given stack has wall penalty
@@ -268,7 +268,7 @@ public:
 	ESpellCastProblem::ESpellCastProblem battleIsImmune(const CGHeroInstance * caster, const CSpell * spell, ECastingMode::ECastingMode mode, BattleHex dest) const; 
 
 
-	const CStack * getStackIf(boost::function<bool(const CStack*)> pred) const;
+	const CStack * getStackIf(std::function<bool(const CStack*)> pred) const;
 
 	si8 battleHasShootingPenalty(const CStack * stack, BattleHex destHex)
 	{

+ 2 - 2
lib/CConfigHandler.cpp

@@ -135,7 +135,7 @@ void SettingsListener::nodeInvalidated(const std::vector<std::string> &changedPa
 		callback(parent.getNode(path));
 }
 
-void SettingsListener::operator() (boost::function<void(const JsonNode&)> _callback)
+void SettingsListener::operator() (std::function<void(const JsonNode&)> _callback)
 {
 	callback = _callback;
 }
@@ -200,7 +200,7 @@ static void setGem(AdventureMapConfig &ac, const int gem, const JsonNode &g)
 	ac.gemG.push_back(g["graphic"].String());
 }
 
-CConfigHandler::CConfigHandler(void): current(NULL)
+CConfigHandler::CConfigHandler(void): current(nullptr)
 {
 }
 

+ 2 - 2
lib/CConfigHandler.h

@@ -63,7 +63,7 @@ class DLL_LINKAGE SettingsListener
 	// Path to this node
 	std::vector<std::string> path;
 	// Callback
-	boost::function<void(const JsonNode&)> callback;
+	std::function<void(const JsonNode&)> callback;
 
 	SettingsListener(SettingsStorage &_parent, const std::vector<std::string> &_path);
 
@@ -75,7 +75,7 @@ public:
 	~SettingsListener();
 
 	// assign callback function
-	void operator()(boost::function<void(const JsonNode&)> _callback);
+	void operator()(std::function<void(const JsonNode&)> _callback);
 
 	friend class SettingsStorage;
 };

+ 7 - 7
lib/CConsoleHandler.cpp

@@ -61,9 +61,9 @@ void printWinError()
     logGlobal->errorStream() << "Error " << error << " encountered:";
 
 	//Get error description
-	char* pTemp = NULL;
+	char* pTemp = nullptr;
 	FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM,
-		NULL, error,  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, NULL);
+		nullptr, error,  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPSTR)&pTemp, 1, nullptr);
     logGlobal->errorStream() << pTemp;
 	LocalFree( pTemp );
 }
@@ -124,9 +124,9 @@ LONG WINAPI onUnhandledException(EXCEPTION_POINTERS* exception)
 	MINIDUMP_EXCEPTION_INFORMATION meinfo = {threadId, exception, TRUE};
 
 	//create file where dump will be placed
-	char *mname = NULL;
+	char *mname = nullptr;
 	char buffer[MAX_PATH + 1];
-	HMODULE hModule = NULL;
+	HMODULE hModule = nullptr;
 	GetModuleFileNameA(hModule, buffer, MAX_PATH);
 	mname = strrchr(buffer, '\\');
 	if (mname != 0)
@@ -228,7 +228,7 @@ CConsoleHandler::CConsoleHandler() : thread(nullptr)
 #else
 	defColor = "\x1b[0m";
 #endif
-    cb = new boost::function<void(const std::string &)>;
+    cb = new std::function<void(const std::string &)>;
 }
 CConsoleHandler::~CConsoleHandler()
 {
@@ -248,11 +248,11 @@ void CConsoleHandler::end()
 #endif
 		thread->join();
 		delete thread;
-		thread = NULL;
+		thread = nullptr;
 	}
 }
 
 void CConsoleHandler::start()
 {
-	thread = new boost::thread(boost::bind(&CConsoleHandler::run,console));
+	thread = new boost::thread(std::bind(&CConsoleHandler::run,console));
 }

+ 1 - 1
lib/CConsoleHandler.h

@@ -75,7 +75,7 @@ public:
 #endif
 	}
 
-    boost::function<void(const std::string &)> *cb; //function to be called when message is received
+    std::function<void(const std::string &)> *cb; //function to be called when message is received
 
 private:
     int run();

+ 1 - 1
lib/CCreatureHandler.cpp

@@ -1046,7 +1046,7 @@ CCreatureHandler::~CCreatureHandler()
 		creature.dellNull();
 }
 
-CreatureID CCreatureHandler::pickRandomMonster(const boost::function<int()> &randGen, int tier) const
+CreatureID CCreatureHandler::pickRandomMonster(const std::function<int()> &randGen, int tier) const
 {
 	int r = 0;
 	if(tier == -1) //pick any allowed creature

+ 1 - 1
lib/CCreatureHandler.h

@@ -184,7 +184,7 @@ public:
 	std::vector <std::pair <Bonus*, std::pair <ui8, ui8> > > skillRequirements; // first - Bonus, second - which two skills are needed to use it
 
 	void deserializationFix();
-	CreatureID pickRandomMonster(const boost::function<int()> &randGen = 0, int tier = -1) const; //tier <1 - CREATURES_PER_TOWN> or -1 for any
+	CreatureID pickRandomMonster(const std::function<int()> &randGen = 0, int tier = -1) const; //tier <1 - CREATURES_PER_TOWN> or -1 for any
 	void addBonusForTier(int tier, Bonus *b); //tier must be <1-7>
 	void addBonusForAllCreatures(Bonus *b);
 

+ 11 - 11
lib/CCreatureSet.cpp

@@ -37,7 +37,7 @@ const CCreature* CCreatureSet::getCreature(SlotID slot) const
 	if (i != stacks.end())
 		return i->second->type;
 	else
-		return NULL;
+		return nullptr;
 }
 
 bool CCreatureSet::setCreature(SlotID slot, CreatureID type, TQuantity quantity) /*slots 0 to 6 */
@@ -281,7 +281,7 @@ const CStackInstance* CCreatureSet::getStackPtr(SlotID slot) const
 {
 	if(hasStackAtSlot(slot))
 		return stacks.find(slot)->second;
-	else return NULL;
+	else return nullptr;
 }
 
 void CCreatureSet::eraseStack(SlotID slot)
@@ -386,7 +386,7 @@ CStackInstance * CCreatureSet::detachStack(SlotID slot)
 
 	//if(CArmedInstance *armedObj = castToArmyObj())
 	{
-		ret->setArmyObj(NULL); //detaches from current armyobj
+		ret->setArmyObj(nullptr); //detaches from current armyobj
 	}
 
 	assert(!ret->armyObj); //we failed detaching?
@@ -477,9 +477,9 @@ void CStackInstance::init()
 {
 	experience = 0;
 	count = 0;
-	type = NULL;
+	type = nullptr;
 	idRand = -1;
-	_armyObj = NULL;
+	_armyObj = nullptr;
 	setNodeType(STACK_INSTANCE);
 }
 
@@ -549,7 +549,7 @@ void CStackInstance::setType(CreatureID creID)
 	if(creID >= 0 && creID < VLC->creh->creatures.size())
 		setType(VLC->creh->creatures[creID]);
 	else
-		setType((const CCreature*)NULL);
+		setType((const CCreature*)nullptr);
 }
 
 void CStackInstance::setType(const CCreature *c)
@@ -638,10 +638,10 @@ std::string CStackInstance::nodeName() const
 void CStackInstance::deserializationFix()
 {
 	const CCreature *backup = type;
-	type = NULL;
+	type = nullptr;
 		setType(backup);
 	const CArmedInstance *armyBackup = _armyObj;
-	_armyObj = NULL;
+	_armyObj = nullptr;
 	setArmyObj(armyBackup);
 	artDeserializationFix(this);
 }
@@ -689,9 +689,9 @@ void CCommanderInstance::init()
 	experience = 0;
 	level = 1;
 	count = 1;
-	type = NULL;
+	type = nullptr;
 	idRand = -1;
-	_armyObj = NULL;
+	_armyObj = nullptr;
 	setNodeType (CBonusSystemNode::COMMANDER);
 	secondarySkills.resize (ECommander::SPELL_POWER + 1);
 }
@@ -748,7 +748,7 @@ bool CCommanderInstance::gainsLevel() const
 
 CStackBasicDescriptor::CStackBasicDescriptor()
 {
-	type = NULL;
+	type = nullptr;
 	count = -1;
 }
 

+ 8 - 8
lib/CCreatureSet.h

@@ -78,8 +78,8 @@ public:
 	void setArmyObj(const CArmedInstance *ArmyObj);
 	virtual void giveStackExp(TExpType exp);
 	bool valid(bool allowUnrandomized) const;
-	ArtBearer::ArtBearer bearerType() const OVERRIDE; //from CArtifactSet
-	virtual std::string nodeName() const OVERRIDE; //from CBonusSystemnode
+	ArtBearer::ArtBearer bearerType() const override; //from CArtifactSet
+	virtual std::string nodeName() const override; //from CBonusSystemnode
 	void deserializationFix();
 };
 
@@ -95,7 +95,7 @@ public:
 	std::vector <ui8> secondarySkills; //ID -> level
 	std::set <ui8> specialSKills;
 	//std::vector <CArtifactInstance *> arts;
-	void init() OVERRIDE;
+	void init() override;
 	CCommanderInstance();
 	CCommanderInstance (CreatureID id);
 	~CCommanderInstance();
@@ -106,8 +106,8 @@ public:
 	bool gainsLevel() const; //true if commander has lower level than should upon his experience
 	ui64 getPower() const {return 0;};
 	int getExpRank() const;
-	int getLevel() const OVERRIDE; 
-	ArtBearer::ArtBearer bearerType() const OVERRIDE; //from CArtifactSet
+	int getLevel() const override; 
+	ArtBearer::ArtBearer bearerType() const override; //from CArtifactSet
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -133,8 +133,8 @@ class DLL_LINKAGE CSimpleArmy : public IArmyDescriptor
 {
 public:
 	TSimpleSlots army;
-	void clear() OVERRIDE;
-	bool setCreature(SlotID slot, CreatureID cre, TQuantity count) OVERRIDE;
+	void clear() override;
+	bool setCreature(SlotID slot, CreatureID cre, TQuantity count) override;
 	operator bool() const;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -181,7 +181,7 @@ public:
 	void setToArmy(CSimpleArmy &src); //erases all our army and moves stacks from src to us; src MUST NOT be an armed object! WARNING: use it wisely. Or better do not use at all.
 
 	const CStackInstance& getStack(SlotID slot) const; //stack must exist
-	const CStackInstance* getStackPtr(SlotID slot) const; //if stack doesn't exist, returns NULL
+	const CStackInstance* getStackPtr(SlotID slot) const; //if stack doesn't exist, returns nullptr
 	const CCreature* getCreature(SlotID slot) const; //workaround of map issue;
 	int getStackCount (SlotID slot) const;
 	TExpType getStackExperience(SlotID slot) const;

+ 1 - 1
lib/CGameInterface.h

@@ -105,7 +105,7 @@ class DLL_LINKAGE CGlobalAI : public CGameInterface // AI class (to derivate)
 {
 public:
 	CGlobalAI();
-	virtual BattleAction activeStack(const CStack * stack) OVERRIDE;
+	virtual BattleAction activeStack(const CStack * stack) override;
 };
 
 //class to  be inherited by adventure-only AIs, it cedes battle actions to given battle-AI

+ 29 - 30
lib/CGameState.cpp

@@ -1,7 +1,6 @@
 #include "StdInc.h"
 #include "CGameState.h"
 
-#include <boost/random/linear_congruential.hpp>
 #include "mapping/CCampaignHandler.h"
 #include "CDefObjInfoHandler.h"
 #include "CArtHandler.h"
@@ -28,7 +27,7 @@
 #include "rmg/CMapGenerator.h"
 #include "CStopWatch.h"
 
-DLL_LINKAGE boost::rand48 ran;
+DLL_LINKAGE std::minstd_rand ran;
 class CGObjectInstance;
 
 #ifdef min
@@ -55,7 +54,7 @@ class CBaseForGSApply
 public:
 	virtual void applyOnGS(CGameState *gs, void *pack) const =0;
 	virtual ~CBaseForGSApply(){};
-	template<typename U> static CBaseForGSApply *getApplier(const U * t=NULL)
+	template<typename U> static CBaseForGSApply *getApplier(const U * t=nullptr)
 	{
 		return new CApplyOnGS<U>;
 	}
@@ -73,7 +72,7 @@ public:
 	}
 };
 
-static CApplier<CBaseForGSApply> *applierGs = NULL;
+static CApplier<CBaseForGSApply> *applierGs = nullptr;
 
 class IObjectCaller
 {
@@ -102,7 +101,7 @@ class CObjectCallersHandler
 public:
 	std::vector<IObjectCaller*> apps;
 
-	template<typename T> void registerType(const T * t=NULL)
+	template<typename T> void registerType(const T * t=nullptr)
 	{
 		apps.push_back(new CObjectCaller<T>);
 	}
@@ -129,7 +128,7 @@ public:
 	//for (size_t i = 0; i < apps.size(); i++)
 	//apps[i]->postInit();
 	}
-} *objCaller = NULL;
+} *objCaller = nullptr;
 
 void MetaString::getLocalString(const std::pair<ui8,ui32> &txt, std::string &dst) const
 {
@@ -364,7 +363,7 @@ static CGObjectInstance * createObject(Obj id, int subid, int3 pos, PlayerColor
 	if(!nobj->defInfo)
         logGlobal->warnStream() <<"No def declaration for " <<id <<" "<<subid;
 	nobj->pos = pos;
-	//nobj->state = NULL;//new CLuaObjectScript();
+	//nobj->state = nullptr;//new CLuaObjectScript();
 	nobj->tempOwner = owner;
 	nobj->defInfo->id = id;
 	nobj->defInfo->subid = subid;
@@ -376,14 +375,14 @@ static CGObjectInstance * createObject(Obj id, int subid, int3 pos, PlayerColor
 	return nobj;
 }
 
-CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor player, const CTown *town, bmap<ui32, ConstTransitivePtr<CGHeroInstance> > &available, const CHeroClass *bannedClass /*= NULL*/) const
+CGHeroInstance * CGameState::HeroesPool::pickHeroFor(bool native, PlayerColor player, const CTown *town, bmap<ui32, ConstTransitivePtr<CGHeroInstance> > &available, const CHeroClass *bannedClass /*= nullptr*/) const
 {
-	CGHeroInstance *ret = NULL;
+	CGHeroInstance *ret = nullptr;
 
 	if(player>=PlayerColor::PLAYER_LIMIT)
 	{
         logGlobal->errorStream() << "Cannot pick hero for " << town->faction->index << ". Wrong owner!";
-		return NULL;
+		return nullptr;
 	}
 
 	std::vector<CGHeroInstance *> pool;
@@ -522,15 +521,15 @@ std::pair<Obj,int> CGameState::pickObject (CGObjectInstance *obj)
 	case Obj::RANDOM_HERO:
 		return std::make_pair(Obj::HERO, pickHero(obj->tempOwner));
 	case Obj::RANDOM_MONSTER:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran)));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran)));
 	case Obj::RANDOM_MONSTER_L1:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 1));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 1));
 	case Obj::RANDOM_MONSTER_L2:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 2));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 2));
 	case Obj::RANDOM_MONSTER_L3:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 3));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 3));
 	case Obj::RANDOM_MONSTER_L4:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 4));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 4));
 	case Obj::RANDOM_RESOURCE:
 		return std::make_pair(Obj::RESOURCE,ran()%7); //now it's OH3 style, use %8 for mithril
 	case Obj::RANDOM_TOWN:
@@ -559,11 +558,11 @@ std::pair<Obj,int> CGameState::pickObject (CGObjectInstance *obj)
 			return std::make_pair(Obj::TOWN,f);
 		}
 	case Obj::RANDOM_MONSTER_L5:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 5));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 5));
 	case Obj::RANDOM_MONSTER_L6:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 6));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 6));
 	case Obj::RANDOM_MONSTER_L7:
-		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(boost::ref(ran), 7));
+		return std::make_pair(Obj::MONSTER, VLC->creh->pickRandomMonster(std::ref(ran), 7));
 	case Obj::RANDOM_DWELLING:
 	case Obj::RANDOM_DWELLING_LVL:
 	case Obj::RANDOM_DWELLING_FACTION:
@@ -856,7 +855,7 @@ void CGameState::init(StartInfo * si)
 	ran.seed((boost::int32_t)si->seedToBeUsed);
 	scenarioOps = new StartInfo(*si);
 	initialOpts = new StartInfo(*si);
-	si = NULL;
+	si = nullptr;
 
 	switch(scenarioOps->mode)
 	{
@@ -1522,11 +1521,11 @@ void CGameState::initDuel()
 
 	const CArmedInstance *armies[2] = {0};
 	const CGHeroInstance *heroes[2] = {0};
-	CGTownInstance *town = NULL;
+	CGTownInstance *town = nullptr;
 
 	for(int i = 0; i < 2; i++)
 	{
-		CArmedInstance *obj = NULL;
+		CArmedInstance *obj = nullptr;
 		if(dp.sides[i].heroId >= 0)
 		{
 			const DuelParameters::SideSettings &ss = dp.sides[i];
@@ -1678,8 +1677,8 @@ UpgradeInfo CGameState::getUpgradeInfo(const CStackInstance &stack)
 	UpgradeInfo ret;
 	const CCreature *base = stack.type;
 
-	const CGHeroInstance *h = stack.armyObj->ID == Obj::HERO ? static_cast<const CGHeroInstance*>(stack.armyObj) : NULL;
-	const CGTownInstance *t = NULL;
+	const CGHeroInstance *h = stack.armyObj->ID == Obj::HERO ? static_cast<const CGHeroInstance*>(stack.armyObj) : nullptr;
+	const CGTownInstance *t = nullptr;
 
 	if(stack.armyObj->ID == Obj::TOWN)
 		t = static_cast<const CGTownInstance *>(stack.armyObj);
@@ -2077,7 +2076,7 @@ int CGameState::victoryCheck( PlayerColor player ) const
 				int total = 0; //creature counter
 				for(size_t i = 0; i < map->objects.size(); i++)
 				{
-					const CArmedInstance *ai = NULL;
+					const CArmedInstance *ai = nullptr;
 					if(map->objects[i]
 						&& map->objects[i]->tempOwner == player //object controlled by player
 						&&  (ai = dynamic_cast<const CArmedInstance*>(map->objects[i].get()))) //contains army
@@ -2251,7 +2250,7 @@ struct statsHLP
 	{
 		std::vector<ConstTransitivePtr<CGHeroInstance> > &h = gs->players[color].heroes;
 		if(!h.size())
-			return NULL;
+			return nullptr;
 		//best hero will be that with highest exp
 		int best = 0;
 		for(int b=1; b<h.size(); ++b)
@@ -2608,7 +2607,7 @@ std::vector<std::pair<CGHeroInstance*, ObjectInstanceID> > CGameState::campaignH
 					logGlobal->warnStream() << "Warning, no hero to replace!";
 					map->removeBlockVisTiles(hp, true);
 					delete hp;
-					map->objects[g] = NULL;
+					map->objects[g] = nullptr;
 				}
 				//we don't have to remove hero from Xheroes because it would destroy the order and duplicates shouldn't happen
 			}
@@ -2673,7 +2672,7 @@ CGPathNode::CGPathNode()
 	land = 0;
 	moveRemains = 0;
 	turns = 255;
-	theNodeBefore = NULL;
+	theNodeBefore = nullptr;
 }
 
 bool CGPathNode::reachable() const
@@ -2703,7 +2702,7 @@ bool CPathsInfo::getPath( const int3 &dst, CGPath &out )
 CPathsInfo::CPathsInfo( const int3 &Sizes )
 :sizes(Sizes)
 {
-	hero = NULL;
+	hero = nullptr;
 	nodes = new CGPathNode**[sizes.x];
 	for(int i = 0; i < sizes.x; i++)
 	{
@@ -2781,7 +2780,7 @@ void InfoAboutHero::assign(const InfoAboutHero & iah)
 {
 	InfoAboutArmy::operator = (iah);
 
-	details = (iah.details ? new Details(*iah.details) : NULL);
+	details = (iah.details ? new Details(*iah.details) : nullptr);
 	hclass = iah.hclass;
 	portrait = iah.portrait;
 }
@@ -3054,7 +3053,7 @@ void CPathfinder::initializeGraph()
 				node.coord.y = j;
 				node.coord.z = k;
                 node.land = tinfo->terType != ETerrainType::WATER;
-				node.theNodeBefore = NULL;
+				node.theNodeBefore = nullptr;
 			}
 		}
 	}

+ 5 - 5
lib/CGameState.h

@@ -179,7 +179,7 @@ public:
 	ui8 daysWithoutCastle;
 
 	PlayerState();
-	std::string nodeName() const OVERRIDE;
+	std::string nodeName() const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -350,7 +350,7 @@ private:
 
 public:
 	CPathfinder(CPathsInfo &_out, CGameState *_gs, const CGHeroInstance *_hero);
-	void calculatePaths(int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or NULL if path does not exists
+	void calculatePaths(int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists
 };
 
 
@@ -370,10 +370,10 @@ public:
 
 	struct DLL_LINKAGE HeroesPool
 	{
-		bmap<ui32, ConstTransitivePtr<CGHeroInstance> > heroesPool; //[subID] - heroes available to buy; NULL if not available
+		bmap<ui32, ConstTransitivePtr<CGHeroInstance> > heroesPool; //[subID] - heroes available to buy; nullptr if not available
 		bmap<ui32,ui8> pavailable; // [subid] -> which players can recruit hero (binary flags)
 
-		CGHeroInstance * pickHeroFor(bool native, PlayerColor player, const CTown *town, bmap<ui32, ConstTransitivePtr<CGHeroInstance> > &available, const CHeroClass *bannedClass = NULL) const;
+		CGHeroInstance * pickHeroFor(bool native, PlayerColor player, const CTown *town, bmap<ui32, ConstTransitivePtr<CGHeroInstance> > &available, const CHeroClass *bannedClass = nullptr) const;
 
 		template <typename Handler> void serialize(Handler &h, const int version)
 		{
@@ -401,7 +401,7 @@ public:
 	PlayerRelations::PlayerRelations getPlayerRelations(PlayerColor color1, PlayerColor color2);
 	bool checkForVisitableDir(const int3 & src, const int3 & dst) const; //check if src tile is visitable from dst tile
 	bool checkForVisitableDir(const int3 & src, const TerrainTile *pom, const int3 & dst) const; //check if src tile is visitable from dst tile
-	void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or NULL if path does not exists
+	void calculatePaths(const CGHeroInstance *hero, CPathsInfo &out, int3 src = int3(-1,-1,-1), int movement = -1); //calculates possible paths for hero, by default uses current hero position and movement left; returns pointer to newly allocated CPath or nullptr if path does not exists
 	int3 guardingCreaturePosition (int3 pos) const;
 	std::vector<CGObjectInstance*> guardingCreatures (int3 pos) const;
 	int victoryCheck(PlayerColor player) const; //checks if given player is winner; -1 if std victory, 1 if special victory, 0 else

+ 4 - 4
lib/CModHandler.cpp

@@ -45,7 +45,7 @@ void CIdentifierStorage::checkIdentifier(std::string & ID)
 }
 
 CIdentifierStorage::ObjectCallback::ObjectCallback(std::string localScope, std::string remoteScope, std::string type,
-                                                   std::string name, const boost::function<void(si32)> & callback):
+                                                   std::string name, const std::function<void(si32)> & callback):
     localScope(localScope),
     remoteScope(remoteScope),
     type(type),
@@ -81,21 +81,21 @@ void CIdentifierStorage::requestIdentifier(ObjectCallback callback)
 	scheduledRequests.push_back(callback);
 }
 
-void CIdentifierStorage::requestIdentifier(std::string scope, std::string type, std::string name, const boost::function<void(si32)> & callback)
+void CIdentifierStorage::requestIdentifier(std::string scope, std::string type, std::string name, const std::function<void(si32)> & callback)
 {
 	auto pair = splitString(name, ':'); // remoteScope:name
 
 	requestIdentifier(ObjectCallback(scope, pair.first, type, pair.second, callback));
 }
 
-void CIdentifierStorage::requestIdentifier(std::string type, const JsonNode & name, const boost::function<void(si32)> & callback)
+void CIdentifierStorage::requestIdentifier(std::string type, const JsonNode & name, const std::function<void(si32)> & callback)
 {
 	auto pair = splitString(name.String(), ':'); // remoteScope:name
 
 	requestIdentifier(ObjectCallback(name.meta, pair.first, type, pair.second, callback));
 }
 
-void CIdentifierStorage::requestIdentifier(const JsonNode & name, const boost::function<void(si32)> & callback)
+void CIdentifierStorage::requestIdentifier(const JsonNode & name, const std::function<void(si32)> & callback)
 {
 	auto pair  = splitString(name.String(), ':'); // remoteScope:<type.name>
 	auto pair2 = splitString(pair.second,   '.'); // type.name

+ 5 - 5
lib/CModHandler.h

@@ -31,9 +31,9 @@ class CIdentifierStorage
 		std::string remoteScope; /// scope in which this object must be found
 		std::string type;        /// type, e.g. creature, faction, hero, etc
 		std::string name;        /// string ID
-		boost::function<void(si32)> callback;
+		std::function<void(si32)> callback;
 
-		ObjectCallback(std::string localScope, std::string remoteScope, std::string type, std::string name, const boost::function<void(si32)> & callback);
+		ObjectCallback(std::string localScope, std::string remoteScope, std::string type, std::string name, const std::function<void(si32)> & callback);
 	};
 
 	struct ObjectData // entry created on ID registration
@@ -53,9 +53,9 @@ class CIdentifierStorage
 public:
 	/// request identifier for specific object name. If ID is not yet resolved callback will be queued
 	/// and will be called later
-	void requestIdentifier(std::string scope, std::string type, std::string name, const boost::function<void(si32)> & callback);
-	void requestIdentifier(std::string type, const JsonNode & name, const boost::function<void(si32)> & callback);
-	void requestIdentifier(const JsonNode & name, const boost::function<void(si32)> & callback);
+	void requestIdentifier(std::string scope, std::string type, std::string name, const std::function<void(si32)> & callback);
+	void requestIdentifier(std::string type, const JsonNode & name, const std::function<void(si32)> & callback);
+	void requestIdentifier(const JsonNode & name, const std::function<void(si32)> & callback);
 
 	/// registers new object, calls all associated callbacks
 	void registerObject(std::string scope, std::string type, std::string name, si32 identifier);

+ 35 - 33
lib/CObjectHandler.cpp

@@ -18,7 +18,6 @@
 #include "CSpellHandler.h"
 #include "CModHandler.h"
 #include "../client/CSoundBase.h"
-#include <boost/random/linear_congruential.hpp>
 #include "CTownHandler.h"
 #include "CCreatureHandler.h"
 #include "VCMI_Lib.h"
@@ -41,8 +40,8 @@ using namespace boost::assign;
 
 std::map<Obj, std::map<int, std::vector<ObjectInstanceID> > > CGTeleport::objs;
 std::vector<std::pair<ObjectInstanceID, ObjectInstanceID> > CGTeleport::gates;
-IGameCallback * IObjectInterface::cb = NULL;
-extern boost::rand48 ran;
+IGameCallback * IObjectInterface::cb = nullptr;
+extern std::minstd_rand ran;
 std::map <PlayerColor, std::set <ui8> > CGKeys::playerKeyMap;
 std::map <si32, std::vector<ObjectInstanceID> > CGMagi::eyelist;
 ui8 CGObelisk::obeliskCount; //how many obelisks are on map
@@ -304,7 +303,7 @@ CGObjectInstance::CGObjectInstance()
 	//state = new CLuaObjectScript();
 	ID = Obj::NO_OBJ;
 	subID = -1;
-	defInfo = NULL;
+	defInfo = nullptr;
 	tempOwner = PlayerColor::UNFLAGGABLE;
 	blockVisit = false;
 }
@@ -312,7 +311,7 @@ CGObjectInstance::~CGObjectInstance()
 {
 	//if (state)
 	//	delete state;
-	//state=NULL;
+	//state=nullptr;
 }
 
 const std::string & CGObjectInstance::getHoverText() const
@@ -336,9 +335,9 @@ int CGObjectInstance::getHeight() const //returns height of object graphic in ti
 }
 bool CGObjectInstance::visitableAt(int x, int y) const //returns true if object is visitable at location (x, y) form left top tile of image (x, y in tiles)
 {
-	if(defInfo==NULL)
+	if(defInfo==nullptr)
 	{
-        logGlobal->warnStream() << "Warning: VisitableAt for obj "<< id.getNum() <<": NULL defInfo!";
+        logGlobal->warnStream() << "Warning: VisitableAt for obj "<< id.getNum() <<": nullptr defInfo!";
 		return false;
 	}
 
@@ -351,7 +350,7 @@ bool CGObjectInstance::visitableAt(int x, int y) const //returns true if object
 }
 bool CGObjectInstance::blockingAt(int x, int y) const
 {
-	if(x<0 || y<0 || x>=getWidth() || y>=getHeight() || defInfo==NULL)
+	if(x<0 || y<0 || x>=getWidth() || y>=getHeight() || defInfo==nullptr)
 		return false;
 	if((defInfo->blockMap[y+6-getHeight()] >> (7-(8-getWidth()+x) )) & 1)
 		return false;
@@ -754,10 +753,10 @@ CGHeroInstance::CGHeroInstance()
 	isStanding = true;
 	moveDir = 4;
 	exp = 0xffffffff;
-	visitedTown = NULL;
-	type = NULL;
-	boat = NULL;
-	commander = NULL;
+	visitedTown = nullptr;
+	type = nullptr;
+	boat = nullptr;
+	commander = nullptr;
 	sex = 0xff;
 	secSkills.push_back(std::make_pair(SecondarySkill::DEFAULT, -1));
 }
@@ -842,7 +841,7 @@ void CGHeroInstance::initHero()
 		mana = manaLimit();
 }
 
-void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= NULL*/)
+void CGHeroInstance::initArmy(IArmyDescriptor *dst /*= nullptr*/)
 {
 	if(!dst)
 		dst = this;
@@ -1206,7 +1205,7 @@ void CGHeroInstance::Updatespecialty() //TODO: calculate special value of bonuse
 						break; //use only hero skills as bonuses to avoid feedback loop
 					case Bonus::PRIMARY_SKILL: //for creatures, that is
 					{
-						const CCreature * cre = NULL;
+						const CCreature * cre = nullptr;
 						int creLevel = 0;
 						if (auto creatureLimiter = std::dynamic_pointer_cast<CCreatureTypeLimiter>(b->limiter)) //TODO: more general eveluation of bonuses?
 						{
@@ -2167,7 +2166,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
 	{
 		if(armedGarrison() || visitingHero)
 		{
-			const CGHeroInstance *defendingHero = NULL;
+			const CGHeroInstance *defendingHero = nullptr;
 			const CArmedInstance *defendingArmy = this;
 
 			if(visitingHero)
@@ -2183,7 +2182,7 @@ void CGTownInstance::onHeroVisit(const CGHeroInstance * h) const
 			//TODO
 			//"borrowing" army from garrison to visiting hero
 
-			cb->startBattlePrimary(h, defendingArmy, getSightCenter(), h, defendingHero, false, (outsideTown ? NULL : this));
+			cb->startBattlePrimary(h, defendingArmy, getSightCenter(), h, defendingHero, false, (outsideTown ? nullptr : this));
 		}
 		else
 		{
@@ -2581,10 +2580,10 @@ void CGTownInstance::setVisitingHero(CGHeroInstance *h)
 	else
 	{
 		PlayerState *p = cb->gameState()->getPlayer(visitingHero->tempOwner);
-		visitingHero->visitedTown = NULL;
+		visitingHero->visitedTown = nullptr;
 		visitingHero->detachFrom(&townAndVis);
 		visitingHero->attachTo(p);
-		visitingHero = NULL;
+		visitingHero = nullptr;
 	}
 }
 
@@ -2604,11 +2603,11 @@ void CGTownInstance::setGarrisonedHero(CGHeroInstance *h)
 	else
 	{
 		PlayerState *p = cb->gameState()->getPlayer(garrisonHero->tempOwner);
-		garrisonHero->visitedTown = NULL;
+		garrisonHero->visitedTown = nullptr;
 		garrisonHero->inTownGarrison = false;
 		garrisonHero->detachFrom(this);
 		garrisonHero->attachTo(p);
-		garrisonHero = NULL;
+		garrisonHero = nullptr;
 	}
 	updateMoraleBonusFromArmy(); //avoid giving morale bonus for same army twice
 }
@@ -3954,7 +3953,10 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
 	}
 
 	//sort by position
-	std::sort(gatesSplit[0].begin(), gatesSplit[0].end(), boost::bind(&CGObjectInstance::pos, _1) < boost::bind(&CGObjectInstance::pos, _2));
+	std::sort(gatesSplit[0].begin(), gatesSplit[0].end(), [](const CGObjectInstance * a, const CGObjectInstance * b)
+	{
+		return a->pos < b->pos;
+	});
 
 	for(size_t i = 0; i < gatesSplit[0].size(); i++)
 	{
@@ -3978,7 +3980,7 @@ void CGTeleport::postInit() //matches subterranean gates into pairs
 		if(best.first >= 0) //found pair
 		{
 			gates.push_back(std::make_pair(cur->id, gatesSplit[1][best.first]->id));
-			gatesSplit[1][best.first] = NULL;
+			gatesSplit[1][best.first] = nullptr;
 		}
 		else
 		{
@@ -4956,7 +4958,7 @@ const CGHeroInstance * CGSeerHut::getHeroToKill(bool allowNull) const
 {
 	const CGObjectInstance *o = cb->getObjByQuestIdentifier(quest->m13489val);
 	if(allowNull && !o)
-		return NULL;
+		return nullptr;
 	assert(o && o->ID == Obj::HERO);
 	return static_cast<const CGHeroInstance*>(o);
 }
@@ -4965,7 +4967,7 @@ const CGCreature * CGSeerHut::getCreatureToKill(bool allowNull) const
 {
 	const CGObjectInstance *o = cb->getObjByQuestIdentifier(quest->m13489val);
 	if(allowNull && !o)
-		return NULL;
+		return nullptr;
 	assert(o && o->ID == Obj::MONSTER);
 	return static_cast<const CGCreature*>(o);
 }
@@ -6080,7 +6082,7 @@ void CGOnceVisitable::blockingDialogAnswered(const CGHeroInstance *hero, ui32 an
 void CBank::initObj()
 {
 	index = VLC->objh->bankObjToIndex(this);
-	bc = NULL;
+	bc = nullptr;
 	daycounter = 0;
 	multiplier = 1;
 }
@@ -6150,7 +6152,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
 			reset (val%100);
 			break;
 		case ObjProperty::BANK_CLEAR_CONFIG:
-			bc = NULL;
+			bc = nullptr;
 			break;
 		case ObjProperty::BANK_CLEAR_ARTIFACTS: //remove rewards from Derelict Ship
 			artifacts.clear();
@@ -6210,7 +6212,7 @@ void CBank::setPropertyDer (ui8 what, ui32 val)
 
 void CBank::newTurn() const
 {
-	if (bc == NULL)
+	if (bc == nullptr)
 	{
 		if (cb->getDate() == 1)
 			initialize(); //initialize on first day
@@ -6415,7 +6417,7 @@ void CBank::battleFinished(const CGHeroInstance *hero, const BattleResult &resul
 			cb->showInfoDialog(&iw);
 			cb->giveCreatures(this, hero, ourArmy, false);
 		}
-		cb->setObjProperty (id, ObjProperty::BANK_CLEAR_CONFIG, 0); //bc = NULL
+		cb->setObjProperty (id, ObjProperty::BANK_CLEAR_CONFIG, 0); //bc = nullptr
 	}
 }
 
@@ -6659,7 +6661,7 @@ void CGMagi::onHeroVisit(const CGHeroInstance * h) const
 }
 void CGBoat::initObj()
 {
-	hero = NULL;
+	hero = nullptr;
 }
 
 void CGSirens::initObj()
@@ -6804,7 +6806,7 @@ IShipyard::IShipyard(const CGObjectInstance *O)
 IShipyard * IShipyard::castFrom( CGObjectInstance *obj )
 {
 	if(!obj)
-		return NULL;
+		return nullptr;
 
 	if(obj->ID == Obj::TOWN)
 	{
@@ -6816,7 +6818,7 @@ IShipyard * IShipyard::castFrom( CGObjectInstance *obj )
 	}
 	else
 	{
-		return NULL;
+		return nullptr;
 	}
 }
 
@@ -7047,7 +7049,7 @@ void CArmedInstance::randomizeArmy(int type)
 
 CArmedInstance::CArmedInstance()
 {
-	battle = NULL;
+	battle = nullptr;
 }
 
 //int CArmedInstance::valOfGlobalBonuses(CSelector selector) const
@@ -7294,7 +7296,7 @@ const IMarket * IMarket::castFrom(const CGObjectInstance *obj, bool verbose /*=
 	default:
 		if(verbose)
             logGlobal->errorStream() << "Cannot cast to IMarket object with ID " << obj->ID;
-		return NULL;
+		return nullptr;
 	}
 }
 

+ 35 - 35
lib/CObjectHandler.h

@@ -81,8 +81,8 @@ public:
 	CQuest(){missionType = MISSION_NONE;}; //default constructor
 
 	virtual bool checkQuest (const CGHeroInstance * h) const; //determines whether the quest is complete or not
-	virtual void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = NULL) const;
-	virtual void getCompletionText (MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h = NULL) const;
+	virtual void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = nullptr) const;
+	virtual void getCompletionText (MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h = nullptr) const;
 	virtual void getRolloverText (MetaString &text, bool onHover) const; //hover or quest log entry
 	virtual void completeQuest (const CGHeroInstance * h) const {};
 	virtual void addReplacements(MetaString &out, const std::string &base) const;
@@ -141,7 +141,7 @@ public:
 
 	enum EGeneratorState {GOOD, BOAT_ALREADY_BUILT, TILE_BLOCKED, NO_WATER};
 	EGeneratorState state() const; //0 - can buid, 1 - there is already a boat at dest tile, 2 - dest tile is blocked, 3 - no water
-	void getProblemText(MetaString &out, const CGHeroInstance *visitor = NULL) const;
+	void getProblemText(MetaString &out, const CGHeroInstance *visitor = nullptr) const;
 };
 
 class DLL_LINKAGE IShipyard : public IBoatGenerator
@@ -395,7 +395,7 @@ public:
 	double getHeroStrength() const;
 	ui64 getTotalStrength() const;
 	TExpType calculateXp(TExpType exp) const; //apply learning skill
-	ui8 getSpellSchoolLevel(const CSpell * spell, int *outSelectedSchool = NULL) const; //returns level on which given spell would be cast by this hero (0 - none, 1 - basic etc); optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
+	ui8 getSpellSchoolLevel(const CSpell * spell, int *outSelectedSchool = nullptr) const; //returns level on which given spell would be cast by this hero (0 - none, 1 - basic etc); optionally returns number of selected school by arg - 0 - air magic, 1 - fire magic, 2 - water magic, 3 - earth magic,
 	bool canCastThisSpell(const CSpell * spell) const; //determines if this hero can cast given spell; takes into account existing spell in spellbook, existing spellbook and artifact bonuses
 	CStackBasicDescriptor calculateNecromancy (const BattleResult &battleResult) const;
 	void showNecromancyDialog(const CStackBasicDescriptor &raisedStack) const;
@@ -411,7 +411,7 @@ public:
 	void putArtifact(ArtifactPosition pos, CArtifactInstance *art);
 	void putInBackpack(CArtifactInstance *art);
 	void initExp();
-	void initArmy(IArmyDescriptor *dst = NULL);
+	void initArmy(IArmyDescriptor *dst = nullptr);
 	//void giveArtifact (ui32 aid);
 	void initHeroDefInfo();
 	void pushPrimSkill(PrimarySkill::PrimarySkill which, int val);
@@ -477,8 +477,8 @@ public:
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	void newTurn() const override;
 	void setProperty(ui8 what, ui32 val) override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 private:
 	void heroAcceptsCreatures(const CGHeroInstance *h) const;
@@ -495,7 +495,7 @@ public:
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	void initObj() override;
 	bool wasVisited (const CGHeroInstance * h) const override;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -533,7 +533,7 @@ public:
 	void onHeroVisit (const CGHeroInstance * h) const override;
 
 	COPWBonus (BuildingID index, CGTownInstance *TOWN);
-	COPWBonus (){ID = BuildingID::NONE; town = NULL;};
+	COPWBonus (){ID = BuildingID::NONE; town = nullptr;};
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & static_cast<CGTownBuilding&>(*this);
@@ -551,7 +551,7 @@ public:
 	void onHeroVisit (const CGHeroInstance * h) const override;
 
 	CTownBonus (BuildingID index, CGTownInstance *TOWN);
-	CTownBonus (){ID = BuildingID::NONE; town = NULL;};
+	CTownBonus (){ID = BuildingID::NONE; town = nullptr;};
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & static_cast<CGTownBuilding&>(*this);
@@ -672,7 +672,7 @@ public:
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	void onHeroLeave(const CGHeroInstance * h) const override;
 	void initObj() override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
 protected:
 	void setPropertyDer(ui8 what, ui32 val) override;
 };
@@ -697,9 +697,9 @@ public:
 
 	void initObj() override;
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
-	void heroLevelUpDone(const CGHeroInstance *hero) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
+	void heroLevelUpDone(const CGHeroInstance *hero) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -756,8 +756,8 @@ public:
 	const std::string & getHoverText() const override;
 	void initObj() override;
 	void newTurn() const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 
 	struct DLL_LINKAGE RestoredCreature // info about merging stacks after battle back into one
@@ -810,7 +810,7 @@ public:
 	CQuest * quest;
 
 	IQuestObject(){quest = new CQuest;};
-	virtual void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = NULL) const;
+	virtual void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = nullptr) const;
 	virtual bool checkQuest (const CGHeroInstance * h) const;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -833,14 +833,14 @@ public:
 	const std::string & getHoverText() const override;
 	void newTurn() const override;
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	int checkDirection() const; //calculates the region of map where monster is placed
 	void setObjToKill(); //remember creatures / heroes to kill after they are initialized
 	const CGHeroInstance *getHeroToKill(bool allowNull = false) const;
 	const CGCreature *getCreatureToKill(bool allowNull = false) const;
 	void getRolloverText (MetaString &text, bool onHover) const;
-	void getCompletionText(MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h = NULL) const;
+	void getCompletionText(MetaString &text, std::vector<Component> &components, bool isCustom, const CGHeroInstance * h = nullptr) const;
 	void finishQuest (const CGHeroInstance * h, ui32 accept) const; //common for both objects
 	void completeQuest (const CGHeroInstance * h) const;
 
@@ -907,7 +907,7 @@ public:
 
 	ui8 getPassableness() const;
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -923,8 +923,8 @@ public:
 	std::string message;
 
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	void pick( const CGHeroInstance * h ) const;
 	void initObj() override;
@@ -944,8 +944,8 @@ public:
 
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	void initObj() override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	void collectRes(PlayerColor player) const;
 
@@ -963,7 +963,7 @@ public:
 
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	void initObj() override;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -994,8 +994,8 @@ public:
 	ui32 producedQuantity;
 	
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	void flagMine(PlayerColor player) const;
 	void newTurn() const override;
@@ -1143,9 +1143,9 @@ public:
 	CGBorderGuard() : IQuestObject(){};
 	void initObj() override;
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
-	void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = NULL) const;
+	void getVisitText (MetaString &text, std::vector<Component> &components, bool isCustom, bool FirstVisit, const CGHeroInstance * h = nullptr) const;
 	void getRolloverText (MetaString &text, bool onHover) const;
 	bool checkQuest (const CGHeroInstance * h) const;
 
@@ -1181,7 +1181,7 @@ public:
 
 	CGBoat()
 	{
-		hero = NULL;
+		hero = nullptr;
 		direction = 4;
 	}
 	template <typename Handler> void serialize(Handler &h, const int version)
@@ -1201,7 +1201,7 @@ public:
 	void onHeroVisit(const CGHeroInstance * h) const override;
 	const std::string & getHoverText() const override;
 	void initObj() override;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -1226,8 +1226,8 @@ class DLL_LINKAGE CBank : public CArmedInstance
 	void newTurn() const override;
 	bool wasVisited (PlayerColor player) const override;
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -1246,7 +1246,7 @@ public:
 	const std::string & getHoverText() const override;
 	void newTurn() const override {}; //empty, no reset
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const OVERRIDE;
+	void battleFinished(const CGHeroInstance *hero, const BattleResult &result) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -1284,7 +1284,7 @@ class DLL_LINKAGE CCartographer : public CPlayersVisited
 ///behaviour varies depending on surface and  floor
 public:
 	void onHeroVisit(const CGHeroInstance * h) const override;
-	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const OVERRIDE;
+	void blockingDialogAnswered(const CGHeroInstance *hero, ui32 answer) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{

+ 4 - 4
lib/CObstacleInstance.h

@@ -56,7 +56,7 @@ struct DLL_LINKAGE CObstacleInstance
 
 struct DLL_LINKAGE MoatObstacle : CObstacleInstance
 {
-	virtual std::vector<BattleHex> getAffectedTiles() const OVERRIDE; //for special effects (not blocking)
+	virtual std::vector<BattleHex> getAffectedTiles() const override; //for special effects (not blocking)
 };
 
 struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance
@@ -69,10 +69,10 @@ struct DLL_LINKAGE SpellCreatedObstacle : CObstacleInstance
 
 	SpellCreatedObstacle();
 
-	virtual std::vector<BattleHex> getAffectedTiles() const OVERRIDE; //for special effects (not blocking)
-	virtual bool visibleForSide(ui8 side, bool hasNativeStack) const OVERRIDE; //0 attacker
+	virtual std::vector<BattleHex> getAffectedTiles() const override; //for special effects (not blocking)
+	virtual bool visibleForSide(ui8 side, bool hasNativeStack) const override; //0 attacker
 
-	virtual void battleTurnPassed() OVERRIDE;
+	virtual void battleTurnPassed() override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{

+ 7 - 26
lib/CRandomGenerator.h

@@ -11,28 +11,11 @@
 
 #pragma once
 
-#include <boost/version.hpp>
-#include <boost/random/mersenne_twister.hpp>
-
-#if BOOST_VERSION >= 104700
-#include <boost/random/uniform_int_distribution.hpp>
-#include <boost/random/uniform_real_distribution.hpp>
-#else
-#include <boost/random/uniform_int.hpp>
-#include <boost/random/uniform_real.hpp>
-#endif
-#include <boost/random/variate_generator.hpp>
-
-typedef boost::mt19937 TGenerator;
-#if BOOST_VERSION >= 104700
-typedef boost::random::uniform_int_distribution<int> TIntDist;
-typedef boost::random::uniform_real_distribution<double> TRealDist;
-#else
-typedef boost::uniform_int<int> TIntDist;
-typedef boost::uniform_real<double> TRealDist;
-#endif
-typedef boost::variate_generator<TGenerator &, TIntDist> TRandI;
-typedef boost::variate_generator<TGenerator &, TRealDist> TRand;
+typedef std::mt19937 TGenerator;
+typedef std::uniform_int_distribution<int> TIntDist;
+typedef std::uniform_real_distribution<double> TRealDist;
+typedef std::function<int()> TRandI;
+typedef std::function<double()> TRand;
 
 /// The random generator randomly generates integers and real numbers("doubles") between
 /// a given range. This is a header only class and mainly a wrapper for
@@ -55,8 +38,7 @@ public:
 	/// e.g.: auto a = gen.getRangeI(0,10); a(); a(); a();
 	TRandI getRangeI(int lower, int upper)
 	{
-		TIntDist range(lower, upper);
-		return TRandI(gen, range);
+		return std::bind(TIntDist(lower, upper), gen);
 	}
 	
 	int getInteger(int lower, int upper)
@@ -68,8 +50,7 @@ public:
 	/// e.g.: auto a = gen.getRangeI(0,10); a(); a(); a();
 	TRand getRange(double lower, double upper)
 	{
-		TRealDist range(lower, upper);
-		return TRand(gen, range);
+		return std::bind(TRealDist(lower, upper), gen);
 	}
 	
 	double getDouble(double lower, double upper)

+ 1 - 1
lib/CSpellHandler.h

@@ -48,7 +48,7 @@ public:
 	CSpell();
 	~CSpell();
 
-	std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = NULL ) const; //convert range to specific hexes; last optional out parameter is set to true, if spell would cover unavailable hexes (that are not included in ret)
+	std::vector<BattleHex> rangeInHexes(BattleHex centralHex, ui8 schoolLvl, ui8 side, bool *outDroppedHexes = nullptr ) const; //convert range to specific hexes; last optional out parameter is set to true, if spell would cover unavailable hexes (that are not included in ret)
 	si16 mainEffectAnim; //main spell effect animation, in AC format (or -1 when none)
 	ETargetType getTargetType() const;
 

+ 2 - 2
lib/CThreadHelper.cpp

@@ -16,7 +16,7 @@
  *
  */
 
-CThreadHelper::CThreadHelper(std::vector<boost::function<void()> > *Tasks, int Threads)
+CThreadHelper::CThreadHelper(std::vector<std::function<void()> > *Tasks, int Threads)
 {
 	currentTask = 0; amount = Tasks->size();
 	tasks = Tasks;
@@ -26,7 +26,7 @@ void CThreadHelper::run()
 {
 	boost::thread_group grupa;
 	for(int i=0;i<threads;i++)
-		grupa.create_thread(boost::bind(&CThreadHelper::processTasks,this));
+		grupa.create_thread(std::bind(&CThreadHelper::processTasks,this));
 	grupa.join_all();
 }
 void CThreadHelper::processTasks()

+ 7 - 7
lib/CThreadHelper.h

@@ -13,7 +13,7 @@
  *
  */
 
-typedef boost::function<void()> Task;
+typedef std::function<void()> Task;
 
 /// Can assign CPU work to other threads/cores
 class DLL_LINKAGE CThreadHelper
@@ -25,11 +25,11 @@ class DLL_LINKAGE CThreadHelper
 
 	void processTasks();
 public:
-	CThreadHelper(std::vector<boost::function<void()> > *Tasks, int Threads);
+	CThreadHelper(std::vector<std::function<void()> > *Tasks, int Threads);
 	void run();
 };
 
-template <typename T> inline void setData(T * data, boost::function<T()> func)
+template <typename T> inline void setData(T * data, std::function<T()> func)
 {
 	*data = func();
 }
@@ -37,16 +37,16 @@ template <typename T> inline void setData(T * data, boost::function<T()> func)
 void DLL_LINKAGE setThreadName(const std::string &name);
 
 #define GET_DATA(TYPE,DESTINATION,FUNCTION_TO_GET) \
-	(boost::bind(&setData<TYPE>,&DESTINATION,FUNCTION_TO_GET))
+	(std::bind(&setData<TYPE>,&DESTINATION,FUNCTION_TO_GET))
 #define GET_SURFACE(SUR_DESTINATION, SUR_NAME) \
 	(GET_DATA \
 		(SDL_Surface*,SUR_DESTINATION,\
-		boost::function<SDL_Surface*()>(boost::bind(&BitmapHandler::loadBitmap,SUR_NAME,true))))
+		std::function<SDL_Surface*()>(std::bind(&BitmapHandler::loadBitmap,SUR_NAME,true))))
 #define GET_DEF(DESTINATION, DEF_NAME) \
 	(GET_DATA \
 		(CDefHandler*,DESTINATION,\
-		boost::function<CDefHandler*()>(boost::bind(CDefHandler::giveDef,DEF_NAME))))
+		std::function<CDefHandler*()>(std::bind(CDefHandler::giveDef,DEF_NAME))))
 #define GET_DEF_ESS(DESTINATION, DEF_NAME) \
 	(GET_DATA \
 		(CDefEssential*,DESTINATION,\
-		boost::function<CDefEssential*()>(boost::bind(CDefHandler::giveDefEss,DEF_NAME))))
+		std::function<CDefEssential*()>(std::bind(CDefHandler::giveDefEss,DEF_NAME))))

+ 3 - 3
lib/Connection.cpp

@@ -60,7 +60,7 @@ void CConnection::init()
 	wmx = new boost::mutex;
 	rmx = new boost::mutex;
 
-	handler = NULL;
+	handler = nullptr;
 	receivedStop = sendStop = false;
 	static int cid = 1;
 	connectionID = cid++;
@@ -199,7 +199,7 @@ void CConnection::close()
 	{
 		socket->close();
 		delete socket;
-		socket = NULL;
+		socket = nullptr;
 	}
 }
 
@@ -220,7 +220,7 @@ void CConnection::reportState(CLogger * out)
 
 CPack * CConnection::retreivePack()
 {
-	CPack *ret = NULL;
+	CPack *ret = nullptr;
 	boost::unique_lock<boost::mutex> lock(*rmx);
     logNetwork->traceStream() << "Listening... ";
 	*this >> ret;

+ 13 - 13
lib/Connection.h

@@ -91,19 +91,19 @@ class DLL_LINKAGE CTypeList
 public:
 	CTypeList();
 	ui16 registerType(const std::type_info *type);
-	template <typename T> ui16 registerType(const T * t = NULL)
+	template <typename T> ui16 registerType(const T * t = nullptr)
 	{
 		return registerType(getTypeInfo(t));
 	}
 
 	ui16 getTypeID(const std::type_info *type);
-	template <typename T> ui16 getTypeID(const T * t = NULL)
+	template <typename T> ui16 getTypeID(const T * t = nullptr)
 	{
 		return getTypeID(getTypeInfo(t));
 	}
 
 
-	template <typename T> const std::type_info * getTypeInfo(const T * t = NULL)
+	template <typename T> const std::type_info * getTypeInfo(const T * t = nullptr)
 	{
 		if(t)
 			return &typeid(*t);
@@ -351,7 +351,7 @@ public:
 	template <typename T, typename U>
 	const VectorisedObjectInfo<T, U> *getVectorisedTypeInfo()
 	{
-		const std::type_info *myType = NULL;
+		const std::type_info *myType = nullptr;
 //
 // 		if(boost::is_base_of<CGObjectInstance, T>::value) //ugly workaround to support also types derived from CGObjectInstance -> if we encounter one, treat it aas CGObj..
 // 			myType = &typeid(CGObjectInstance);
@@ -360,7 +360,7 @@ public:
 
 		TTypeVecMap::iterator i = vectors.find(myType);
 		if(i == vectors.end())
-			return NULL;
+			return nullptr;
 		else
 		{
 			assert(!i->second.empty());
@@ -374,7 +374,7 @@ public:
 	T* getVectorItemFromId(const VectorisedObjectInfo<T, U> &oInfo, U id) const
 	{
 	/*	if(id < 0)
-			return NULL;*/
+			return nullptr;*/
 		si32 idAsNumber = idToNumber(id);
 
 		assert(oInfo.vector);
@@ -557,7 +557,7 @@ public:
 			delete iter->second;
 	}
 
-	template<typename T> void registerType(const T * t=NULL)
+	template<typename T> void registerType(const T * t=nullptr)
 	{
 		ui16 ID = typeList.registerType(t);
 		savers[ID] = new CPointerSaver<COSer<Serializer>,T>;
@@ -593,11 +593,11 @@ public:
 	template <typename T>
 	void savePointer(const T &data)
 	{
-		//write if pointer is not NULL
-		ui8 hlp = (data!=NULL);
+		//write if pointer is not nullptr
+		ui8 hlp = (data!=nullptr);
 		*this << hlp;
 
-		//if pointer is NULL then we don't need anything more...
+		//if pointer is nullptr then we don't need anything more...
 		if(!hlp)
 			return;
 
@@ -873,7 +873,7 @@ public:
 			delete iter->second;
 	}
 
-	template<typename T> void registerType(const T * t=NULL)
+	template<typename T> void registerType(const T * t=nullptr)
 	{
 		ui16 ID = typeList.registerType(t);
 		loaders[ID] = new CPointerLoader<CISer<Serializer>,T>;
@@ -980,7 +980,7 @@ public:
 		*this >> hlp;
 		if(!hlp)
 		{
-			data = NULL;
+			data = nullptr;
 			return;
 		}
 
@@ -1374,7 +1374,7 @@ public:
 		for(iter = apps.begin(); iter != apps.end(); iter++)
 			delete iter->second;
 	}
-	template<typename U> void registerType(const U * t=NULL)
+	template<typename U> void registerType(const U * t=nullptr)
 	{
 		ui16 ID = typeList.registerType(t);
 		apps[ID] = T::getApplier(t);

+ 2 - 2
lib/ConstTransitivePtr.h

@@ -20,7 +20,7 @@ class ConstTransitivePtr
 		: ptr(const_cast<T*>(Ptr)) 
 	{}
 public:
-	ConstTransitivePtr(T *Ptr = NULL)
+	ConstTransitivePtr(T *Ptr = nullptr)
 		: ptr(Ptr) 
 	{}
 
@@ -64,7 +64,7 @@ public:
 	void dellNull()
 	{
 		delete ptr;
-		ptr = NULL;
+		ptr = nullptr;
 	}
 
 	template <typename Handler> void serialize(Handler &h, const int version)

+ 16 - 16
lib/HeroBonus.cpp

@@ -187,7 +187,7 @@ const Bonus * BonusList::getFirst(const CSelector &selector) const
 		if(selector(b))
 			return &*b;
 	}
-	return NULL;
+	return nullptr;
 }
 
 Bonus * BonusList::getFirst(const CSelector &select)
@@ -198,7 +198,7 @@ Bonus * BonusList::getFirst(const CSelector &select)
 		if(select(b))
 			return &*b;
 	}
-	return NULL;
+	return nullptr;
 }
 
 void BonusList::getModifiersWDescr(TModDescr &out) const
@@ -248,7 +248,7 @@ int BonusList::valOfBonuses(const CSelector &select) const
 
 // void BonusList::limit(const CBonusSystemNode &node)
 // {
-// 	remove_if(boost::bind(&CBonusSystemNode::isLimitedOnUs, boost::ref(node), _1));
+// 	remove_if(std::bind(&CBonusSystemNode::isLimitedOnUs, std::ref(node), _1));
 // }
 
 
@@ -329,7 +329,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;
-	TBonusListPtr hlp = getAllBonuses(selector, limit, NULL, cachingStr);
+	TBonusListPtr hlp = getAllBonuses(selector, limit, nullptr, cachingStr);
 	return hlp->totalValue();
 }
 bool IBonusBearer::hasBonus(const CSelector &selector, const std::string &cachingStr /*= ""*/) const
@@ -374,12 +374,12 @@ 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, NULL, cachingStr);
+	return getAllBonuses(selector, 0, nullptr, cachingStr);
 }
 
 const TBonusListPtr IBonusBearer::getBonuses(const CSelector &selector, const CSelector &limit, const std::string &cachingStr /*= ""*/) const
 {
-	return getAllBonuses(selector, limit, NULL, cachingStr);
+	return getAllBonuses(selector, limit, nullptr, cachingStr);
 }
 
 bool IBonusBearer::hasBonusFrom(Bonus::BonusSource source, ui32 sourceID) const
@@ -512,7 +512,7 @@ const Bonus * IBonusBearer::getEffect(ui16 id, int turn /*= 0*/) const
 				return &(*it);
 		}
 	}
-	return NULL;
+	return nullptr;
 }
 
 ui8 IBonusBearer::howManyEffectsSet(ui16 id) const
@@ -558,7 +558,7 @@ Bonus * CBonusSystemNode::getBonusLocalFirst(const CSelector &selector)
 			return ret;
 	}
 
-	return NULL;
+	return nullptr;
 }
 
 const Bonus * CBonusSystemNode::getBonusLocalFirst( const CSelector &selector ) const
@@ -604,7 +604,7 @@ void CBonusSystemNode::getAllBonusesRec(BonusList &out) const
 	bonuses.getAllBonuses(out);
 }
 
-const TBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= NULL*/, const std::string &cachingStr /*= ""*/) const
+const TBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/, const std::string &cachingStr /*= ""*/) const
 {
 	bool limitOnUs = (!root || root == this); //caching won't work when we want to limit bonuses against an external node
 	if (CBonusSystemNode::cachingEnabled && limitOnUs)
@@ -657,7 +657,7 @@ const TBonusListPtr CBonusSystemNode::getAllBonuses(const CSelector &selector, c
 	}
 }
 
-const TBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= NULL*/) const
+const TBonusListPtr CBonusSystemNode::getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root /*= nullptr*/) const
 {
 	auto ret = make_shared<BonusList>();
 
@@ -1099,7 +1099,7 @@ const CSpell * Bonus::sourceSpell() const
 {
 	if(source == SPELL_EFFECT)
 		return SpellID(sid).toSpell();
-	return NULL;
+	return nullptr;
 }
 
 std::string Bonus::Description() const
@@ -1250,7 +1250,7 @@ const CStack * retreiveStackBattle(const CBonusSystemNode *node)
 	case CBonusSystemNode::STACK_BATTLE:
 		return static_cast<const CStack*>(node);
 	default:
-		return NULL;
+		return nullptr;
 	}
 }
 
@@ -1263,7 +1263,7 @@ const CStackInstance * retreiveStackInstance(const CBonusSystemNode *node)
 	case CBonusSystemNode::STACK_BATTLE:
 		return (static_cast<const CStack*>(node))->base;
 	default:
-		return NULL;
+		return nullptr;
 	}
 }
 
@@ -1277,7 +1277,7 @@ const CCreature * retrieveCreature(const CBonusSystemNode *node)
 		const CStackInstance *csi = retreiveStackInstance(node);
 		if(csi)
 			return csi->type;
-		return NULL;
+		return nullptr;
 	}
 }
 
@@ -1360,7 +1360,7 @@ CCreatureTypeLimiter::CCreatureTypeLimiter(const CCreature &Creature, bool Inclu
 
 CCreatureTypeLimiter::CCreatureTypeLimiter()
 {
-	creature = NULL;
+	creature = nullptr;
 	includeUpgrades = false;
 }
 
@@ -1410,7 +1410,7 @@ bool IPropagator::shouldBeAttached(CBonusSystemNode *dest)
 
 // CBonusSystemNode * CPropagatorNodeType::getDestNode(CBonusSystemNode *source, CBonusSystemNode *redParent, CBonusSystemNode *redChild)
 // {
-// 	return NULL;
+// 	return nullptr;
 // }
 
 CPropagatorNodeType::CPropagatorNodeType()

+ 16 - 16
lib/HeroBonus.h

@@ -27,7 +27,7 @@ typedef std::vector<std::pair<int,std::string> > TModDescr; //modifiers values a
 typedef std::set<CBonusSystemNode*> TNodes;
 typedef std::set<const CBonusSystemNode*> TCNodes;
 typedef std::vector<CBonusSystemNode *> TNodesVector;
-typedef boost::function<bool(const Bonus*)> CSelector;
+typedef std::function<bool(const Bonus*)> CSelector;
 
 
 
@@ -373,7 +373,7 @@ public:
 	void push_back(Bonus* const &x);
 	std::vector<Bonus*>::iterator erase (const int position);
 	void clear();
-	void resize(std::vector<Bonus*>::size_type sz, Bonus* c = NULL );
+	void resize(std::vector<Bonus*>::size_type sz, Bonus* c = nullptr );
 	void insert(std::vector<Bonus*>::iterator position, std::vector<Bonus*>::size_type n, Bonus* const &x);
 	Bonus *const &operator[] (std::vector<Bonus*>::size_type n) { return bonuses[n]; }
 	Bonus *const &operator[] (std::vector<Bonus*>::size_type n) const { return bonuses[n]; }
@@ -474,7 +474,7 @@ public:
 	CPropagatorNodeType();
 	CPropagatorNodeType(int NodeType);
 	bool shouldBeAttached(CBonusSystemNode *dest);
-	//CBonusSystemNode *getDestNode(CBonusSystemNode *source, CBonusSystemNode *redParent, CBonusSystemNode *redChild) OVERRIDE;
+	//CBonusSystemNode *getDestNode(CBonusSystemNode *source, CBonusSystemNode *redParent, CBonusSystemNode *redChild) override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -508,9 +508,9 @@ class DLL_LINKAGE IBonusBearer
 public:
 	//new bonusing node interface
 	// * selector is predicate that tests if HeroBonus matches our criteria
-	// * root is node on which call was made (NULL will be replaced with this)
+	// * root is node on which call was made (nullptr will be replaced with this)
 	//interface
-	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const = 0;
+	virtual const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr, const std::string &cachingStr = "") const = 0;
 	void getModifiersWDescr(TModDescr &out, const CSelector &selector, const std::string &cachingStr = "") const;  //out: pairs<modifier value, modifier description>
 	int getBonusesCount(const CSelector &selector, const std::string &cachingStr = "") const;
 	int valOfBonuses(const CSelector &selector, const std::string &cachingStr = "") const;
@@ -577,7 +577,7 @@ private:
 
 	void getBonusesRec(BonusList &out, const CSelector &selector, const CSelector &limit) const;
 	void getAllBonusesRec(BonusList &out) const;
-	const TBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL) const;
+	const TBonusListPtr getAllBonusesWithoutCaching(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr) const;
 
 public:
 
@@ -586,7 +586,7 @@ public:
 
 	void limitBonuses(const BonusList &allBonuses, BonusList &out) const; //out will bo populed with bonuses that are not limited here
 	TBonusListPtr limitBonuses(const BonusList &allBonuses) const; //same as above, returns out by val for convienence
-	const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = NULL, const std::string &cachingStr = "") const;
+	const TBonusListPtr getAllBonuses(const CSelector &selector, const CSelector &limit, const CBonusSystemNode *root = nullptr, const std::string &cachingStr = "") const;
 	void getParents(TCNodes &out) const;  //retrieves list of parent nodes (nodes to inherit bonuses from),
 	const Bonus *getBonusLocalFirst(const CSelector &selector) const;
 
@@ -651,7 +651,7 @@ public:
 
 namespace NBonus
 {
-	//set of methods that may be safely called with NULL objs
+	//set of methods that may be safely called with nullptr objs
 	DLL_LINKAGE int valOf(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1); //subtype -> subtype of bonus, if -1 then any
 	DLL_LINKAGE bool hasOfType(const CBonusSystemNode *obj, Bonus::BonusType type, int subtype = -1);//determines if hero has a bonus of given type (and optionally subtype)
 	//DLL_LINKAGE const HeroBonus * get(const CBonusSystemNode *obj, int from, int id );
@@ -796,7 +796,7 @@ class DLL_LINKAGE LimiterList : public ILimiter
 	std::vector<TLimiterPtr> limiters;
 
 public:
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 	void add(TLimiterPtr limiter);
 };
 
@@ -810,7 +810,7 @@ public:
 	CCreatureTypeLimiter(const CCreature &Creature, bool IncludeUpgrades = true);
 	void setCreature (CreatureID id);
 
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -829,7 +829,7 @@ public:
 	HasAnotherBonusLimiter(Bonus::BonusType bonus = Bonus::NONE);
 	HasAnotherBonusLimiter(Bonus::BonusType bonus, TBonusSubtype _subtype);
 
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -845,7 +845,7 @@ public:
 	CreatureNativeTerrainLimiter();
 	CreatureNativeTerrainLimiter(int TerrainType);
 
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -861,7 +861,7 @@ public:
 	CreatureFactionLimiter();
 	CreatureFactionLimiter(int TerrainType);
 
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -877,7 +877,7 @@ public:
 	CreatureAlignmentLimiter();
 	CreatureAlignmentLimiter(si8 Alignment);
 
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -893,7 +893,7 @@ public:
 	StackOwnerLimiter();
 	StackOwnerLimiter(PlayerColor Owner);
 
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
@@ -909,7 +909,7 @@ public:
 
 	RankRangeLimiter();
 	RankRangeLimiter(ui8 Min, ui8 Max = 255);
-	int limit(const BonusLimitationContext &context) const OVERRIDE;
+	int limit(const BonusLimitationContext &context) const override;
 
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{

+ 25 - 27
lib/IGameCallback.cpp

@@ -1,8 +1,6 @@
 #include "StdInc.h"
 #include "IGameCallback.h"
 
-#include <boost/random/linear_congruential.hpp>
-
 #include "CGameState.h"
 #include "mapping/CMap.h"
 #include "CObjectHandler.h"
@@ -38,7 +36,7 @@
 #define ERROR_RET_IF(cond, txt) do {if(cond){logGlobal->errorStream() << BOOST_CURRENT_FUNCTION << ": " << txt; return;}} while(0)
 #define ERROR_RET_VAL_IF(cond, txt, retVal) do {if(cond){logGlobal->errorStream() << BOOST_CURRENT_FUNCTION << ": " << txt; return retVal;}} while(0)
 
-extern boost::rand48 ran;
+extern std::minstd_rand ran;
 
 CGameState * CPrivilagedInfoCallback::gameState ()
 {
@@ -63,7 +61,7 @@ int CGameInfoCallback::getResource(PlayerColor Player, Res::ERes which) const
 const CGHeroInstance* CGameInfoCallback::getSelectedHero( PlayerColor Player ) const
 {
 	const PlayerState *p = getPlayer(Player);
-	ERROR_RET_VAL_IF(!p, "No player info!", NULL);
+	ERROR_RET_VAL_IF(!p, "No player info!", nullptr);
 	return getHero(p->currentSelection);
 }
 
@@ -88,7 +86,7 @@ void CPrivilagedInfoCallback::getTilesInRange( boost::unordered_set<int3, ShashI
 		getAllTiles (tiles, player, -1, 0);
 	else
 	{
-		const TeamState * team = !player ? NULL : gs->getPlayerTeam(*player);
+		const TeamState * team = !player ? nullptr : gs->getPlayerTeam(*player);
 		for (int xd = std::max<int>(pos.x - radious , 0); xd <= std::min<int>(pos.x + radious, gs->map->width - 1); xd++)
 		{
 			for (int yd = std::max<int>(pos.y - radious, 0); yd <= std::min<int>(pos.y + radious, gs->map->height - 1); yd++)
@@ -259,27 +257,27 @@ template DLL_LINKAGE void CPrivilagedInfoCallback::saveCommonState<CSaveFile>(CS
 TerrainTile * CNonConstInfoCallback::getTile( int3 pos )
 {
 	if(!gs->map->isInTheMap(pos))
-		return NULL;
+		return nullptr;
 	return &gs->map->getTile(pos);
 }
 
 const PlayerState * CGameInfoCallback::getPlayer(PlayerColor color, bool verbose) const
 {
-	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!hasAccess(color), verbose, "Cannot access player " << color << "info!", NULL);
-	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!vstd::contains(gs->players,color), verbose, "Cannot find player " << color << "info!", NULL);
+	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!hasAccess(color), verbose, "Cannot access player " << color << "info!", nullptr);
+	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!vstd::contains(gs->players,color), verbose, "Cannot find player " << color << "info!", nullptr);
 	return &gs->players[color];
 }
 
 const CTown * CGameInfoCallback::getNativeTown(PlayerColor color) const
 {
 	const PlayerSettings *ps = getPlayerSettings(color);
-	ERROR_RET_VAL_IF(!ps, "There is no such player!", NULL);
+	ERROR_RET_VAL_IF(!ps, "There is no such player!", nullptr);
 	return VLC->townh->factions[ps->castle]->town;
 }
 
 const CGObjectInstance * CGameInfoCallback::getObjByQuestIdentifier(int identifier) const
 {
-	ERROR_RET_VAL_IF(!vstd::contains(gs->map->questIdentifierToId, identifier), "There is no object with such quest identifier!", NULL);
+	ERROR_RET_VAL_IF(!vstd::contains(gs->map->questIdentifierToId, identifier), "There is no object with such quest identifier!", nullptr);
 	return getObj(gs->map->questIdentifierToId[identifier]);
 }
 
@@ -294,7 +292,7 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v
 	{
 		if(verbose)
             logGlobal->errorStream() << "Cannot get object with id " << oid;
-		return NULL;
+		return nullptr;
 	}
 
 	const CGObjectInstance *ret = gs->map->objects[oid];
@@ -302,14 +300,14 @@ const CGObjectInstance* CGameInfoCallback::getObj(ObjectInstanceID objid, bool v
 	{
 		if(verbose)
             logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object was removed.";
-		return NULL;
+		return nullptr;
 	}
 
 	if(!isVisible(ret, player))
 	{
 		if(verbose)
             logGlobal->errorStream() << "Cannot get object with id " << oid << ". Object is not visible.";
-		return NULL;
+		return nullptr;
 	}
 
 	return ret;
@@ -321,7 +319,7 @@ const CGHeroInstance* CGameInfoCallback::getHero(ObjectInstanceID objid) const
 	if(obj)
 		return dynamic_cast<const CGHeroInstance*>(obj);
 	else
-		return NULL;
+		return nullptr;
 }
 const CGTownInstance* CGameInfoCallback::getTown(ObjectInstanceID objid) const
 {
@@ -329,7 +327,7 @@ const CGTownInstance* CGameInfoCallback::getTown(ObjectInstanceID objid) const
 	if(obj)
 		return dynamic_cast<const CGTownInstance*>(obj);
 	else
-		return NULL;
+		return nullptr;
 }
 
 void CGameInfoCallback::getUpgradeInfo(const CArmedInstance *obj, SlotID stackPos, UpgradeInfo &out) const
@@ -371,7 +369,7 @@ int CGameInfoCallback::estimateSpellDamage(const CSpell * sp, const CGHeroInstan
 	{
 		if (hero) //but we see hero's spellbook
 			return gs->curB->calculateSpellDmg(
-				sp, hero, NULL, hero->getSpellSchoolLevel(sp), hero->getPrimSkillLevel(PrimarySkill::SPELL_POWER));
+				sp, hero, nullptr, hero->getSpellSchoolLevel(sp), hero->getPrimSkillLevel(PrimarySkill::SPELL_POWER));
 		else
 			return 0; //mage guild
 	}
@@ -379,7 +377,7 @@ int CGameInfoCallback::estimateSpellDamage(const CSpell * sp, const CGHeroInstan
 	//const CGHeroInstance * ourHero = gs->curB->heroes[0]->tempOwner == player ? gs->curB->heroes[0] : gs->curB->heroes[1];
 	const CGHeroInstance * ourHero = hero;
 	return gs->curB->calculateSpellDmg(
-		sp, ourHero, NULL, ourHero->getSpellSchoolLevel(sp), ourHero->getPrimSkillLevel(PrimarySkill::SPELL_POWER));
+		sp, ourHero, nullptr, ourHero->getSpellSchoolLevel(sp), ourHero->getPrimSkillLevel(PrimarySkill::SPELL_POWER));
 }
 
 void CGameInfoCallback::getThievesGuildInfo(SThievesGuildInfo & thi, const CGObjectInstance * obj)
@@ -493,7 +491,7 @@ bool CGameInfoCallback::isVisible(const CGObjectInstance *obj) const
 // 	if()
 // 	const CArmedInstance *armi = dynamic_cast<const CArmedInstance*>(obj);
 // 	if(!armi)
-// 		return NULL;
+// 		return nullptr;
 // 	else
 // 		return armi;
 // }
@@ -559,7 +557,7 @@ std::vector<const CGHeroInstance *> CGameInfoCallback::getAvailableHeroes(const
 
 const TerrainTile * CGameInfoCallback::getTile( int3 tile, bool verbose) const
 {
-	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!isVisible(tile), verbose, tile << " is not visible!", NULL);
+	ERROR_VERBOSE_OR_NOT_RET_VAL_IF(!isVisible(tile), verbose, tile << " is not visible!", nullptr);
 
 	//boost::shared_lock<boost::shared_mutex> lock(*gs->mx);
 	return &gs->map->getTile(tile);
@@ -858,7 +856,7 @@ const CGHeroInstance* CPlayerSpecificInfoCallback::getHeroBySerial(int serialId,
 {
 	ASSERT_IF_CALLED_WITH_PLAYER
 	const PlayerState *p = getPlayer(*player);
-	ERROR_RET_VAL_IF(!p, "No player info", NULL);
+	ERROR_RET_VAL_IF(!p, "No player info", nullptr);
 
 	if (!includeGarrisoned)
 	{
@@ -866,7 +864,7 @@ const CGHeroInstance* CPlayerSpecificInfoCallback::getHeroBySerial(int serialId,
 			if(p->heroes[i]->inTownGarrison)
 				serialId++;
 	}
-	ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->heroes.size(), "No player info", NULL);
+	ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->heroes.size(), "No player info", nullptr);
 	return p->heroes[serialId];
 }
 
@@ -874,8 +872,8 @@ const CGTownInstance* CPlayerSpecificInfoCallback::getTownBySerial(int serialId)
 {
 	ASSERT_IF_CALLED_WITH_PLAYER
 	const PlayerState *p = getPlayer(*player);
-	ERROR_RET_VAL_IF(!p, "No player info", NULL);
-	ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->towns.size(), "No player info", NULL);
+	ERROR_RET_VAL_IF(!p, "No player info", nullptr);
+	ERROR_RET_VAL_IF(serialId < 0 || serialId >= p->towns.size(), "No player info", nullptr);
 	return p->towns[serialId];
 }
 
@@ -930,9 +928,9 @@ CGObjectInstance * CNonConstInfoCallback::getObjInstance( ObjectInstanceID oid )
 
 const TeamState * CGameInfoCallback::getTeam( TeamID teamID ) const
 {
-	ERROR_RET_VAL_IF(!vstd::contains(gs->teams, teamID), "Cannot find info for team " << teamID, NULL);
+	ERROR_RET_VAL_IF(!vstd::contains(gs->teams, teamID), "Cannot find info for team " << teamID, nullptr);
 	const TeamState *ret = &gs->teams[teamID];
-	ERROR_RET_VAL_IF(!!player && !vstd::contains(ret->players, *player), "Illegal attempt to access team data!", NULL);
+	ERROR_RET_VAL_IF(!!player && !vstd::contains(ret->players, *player), "Illegal attempt to access team data!", nullptr);
 	return ret;
 }
 
@@ -941,7 +939,7 @@ const TeamState * CGameInfoCallback::getPlayerTeam( PlayerColor color ) const
 	const PlayerState * ps = getPlayer(color);
 	if (ps)
 		return getTeam(ps->team);
-	return NULL;
+	return nullptr;
 }
 
 const CGHeroInstance* CGameInfoCallback::getHeroWithSubid( int subid ) const
@@ -950,7 +948,7 @@ const CGHeroInstance* CGameInfoCallback::getHeroWithSubid( int subid ) const
 		if(h->subID == subid)
 			return h;
 
-	return NULL;
+	return nullptr;
 }
 
 PlayerColor CGameInfoCallback::getLocalPlayer() const

+ 3 - 3
lib/IGameCallback.h

@@ -102,7 +102,7 @@ public:
 	bool getHeroInfo(const CGObjectInstance *hero, InfoAboutHero &dest) const;
 	int getSpellCost(const CSpell * sp, const CGHeroInstance * caster) const; //when called during battle, takes into account creatures' spell cost reduction
 	int estimateSpellDamage(const CSpell * sp, const CGHeroInstance * hero) const; //estimates damage of given spell; returns 0 if spell causes no dmg
-	const CGHeroInstance* getSelectedHero(PlayerColor player) const; //NULL if no hero is selected
+	const CGHeroInstance* getSelectedHero(PlayerColor player) const; //nullptr if no hero is selected
 	const CGHeroInstance* getSelectedHero() const; //of current (active) player
 	const CArtifactInstance * getArtInstance(ArtifactInstanceID aid) const;
 	const CGObjectInstance * getObjInstance(ObjectInstanceID oid) const;
@@ -114,7 +114,7 @@ public:
 	std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
 	std::vector <std::string > getObjDescriptions(int3 pos)const; //returns descriptions of objects at pos in order from the lowest to the highest
 	PlayerColor getOwner(ObjectInstanceID heroID) const;
-	const CGObjectInstance *getObjByQuestIdentifier(int identifier) const; //NULL if object has been removed (eg. killed)
+	const CGObjectInstance *getObjByQuestIdentifier(int identifier) const; //nullptr if object has been removed (eg. killed)
 
 	//map
 	int3 guardingCreaturePosition (int3 pos) const;
@@ -249,7 +249,7 @@ public:
 	virtual void showCompInfo(ShowInInfobox * comp)=0;
 	virtual void heroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0;
 	virtual void stopHeroVisitCastle(const CGTownInstance * obj, const CGHeroInstance * hero)=0;
-	virtual void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = NULL)=0; //use hero=NULL for no hero
+	virtual void startBattlePrimary(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool creatureBank = false, const CGTownInstance *town = nullptr)=0; //use hero=nullptr for no hero
 	virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, int3 tile, bool creatureBank = false)=0; //if any of armies is hero, hero will be used
 	virtual void startBattleI(const CArmedInstance *army1, const CArmedInstance *army2, bool creatureBank = false)=0; //if any of armies is hero, hero will be used, visitable tile of second obj is place of battle
 	virtual void setAmount(ObjectInstanceID objid, ui32 val)=0;

+ 1 - 1
lib/IGameEventsReceiver.h

@@ -117,7 +117,7 @@ public:
 	virtual void tileHidden(const boost::unordered_set<int3, ShashInt3> &pos){};
 	virtual void tileRevealed(const boost::unordered_set<int3, ShashInt3> &pos){};
 	virtual void newObject(const CGObjectInstance * obj){}; //eg. ship built in shipyard
-	virtual void availableArtifactsChanged(const CGBlackMarket *bm = NULL){}; //bm may be NULL, then artifacts are changed in the global pool (used by merchants in towns)
+	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){};
 	virtual void availableCreaturesChanged(const CGDwelling *town){};
 	virtual void heroBonusChanged(const CGHeroInstance *hero, const Bonus &bonus, bool gain){};//if gain hero received bonus, else he lost it

+ 1 - 1
lib/JsonNode.cpp

@@ -140,7 +140,7 @@ void JsonNode::setType(JsonType Type)
 	if (type == Type)
 		return;
 
-	//Reset node to NULL
+	//Reset node to nullptr
 	if (Type != DATA_NULL)
 		setType(DATA_NULL);
 

+ 1 - 1
lib/JsonNode.h

@@ -68,7 +68,7 @@ public:
 
 	void setMeta(std::string metadata, bool recursive = true);
 
-	/// Convert node to another type. Converting to NULL will clear all data
+	/// Convert node to another type. Converting to nullptr will clear all data
 	void setType(JsonType Type);
 	JsonType getType() const;
 

+ 3 - 3
lib/NetPacks.h

@@ -71,7 +71,7 @@ struct CPackForServer : public CPack
 	CPackForServer()
 	{
 		type = 2;
-		c = NULL;
+		c = nullptr;
 		player = PlayerColor::NEUTRAL;
 	};
 
@@ -2269,7 +2269,7 @@ struct SelectMap : public CPregamePackToPropagate
 	}
 	SelectMap()
 	{
-		mapInfo = NULL;
+		mapInfo = nullptr;
 		free = true;
 	}
 	~SelectMap()
@@ -2301,7 +2301,7 @@ struct UpdateStartOptions : public CPregamePackToPropagate
 	}
 	UpdateStartOptions()
 	{
-		options = NULL;
+		options = nullptr;
 		free = true;
 	}
 	~UpdateStartOptions()

+ 17 - 17
lib/NetPacksLib.cpp

@@ -144,7 +144,7 @@ DLL_LINKAGE void HeroVisitCastle::applyGs( CGameState *gs )
 	if(start())
 		t->setVisitingHero(h);
 	else
-		t->setVisitingHero(NULL);
+		t->setVisitingHero(nullptr);
 }
 
 DLL_LINKAGE void ChangeSpells::applyGs( CGameState *gs )
@@ -217,7 +217,7 @@ DLL_LINKAGE void SetAvailableHeroes::applyGs( CGameState *gs )
 
 DLL_LINKAGE void GiveBonus::applyGs( CGameState *gs )
 {
-	CBonusSystemNode *cbsn = NULL;
+	CBonusSystemNode *cbsn = nullptr;
 	switch(who)
 	{
 	case HERO:
@@ -316,10 +316,10 @@ DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs )
 		if(h->visitedTown)
 		{
 			if(h->inTownGarrison)
-				h->visitedTown->garrisonHero = NULL;
+				h->visitedTown->garrisonHero = nullptr;
 			else
-				h->visitedTown->visitingHero = NULL;
-			h->visitedTown = NULL;
+				h->visitedTown->visitingHero = nullptr;
+			h->visitedTown = nullptr;
 		}
 
 		//return hero to the pool, so he may reappear in tavern
@@ -327,7 +327,7 @@ DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs )
 		if(!vstd::contains(gs->hpool.pavailable, h->subID))
 			gs->hpool.pavailable[h->subID] = 0xff;
 
-		gs->map->objects[id.getNum()] = NULL;
+		gs->map->objects[id.getNum()] = nullptr;
 
 
 		return;
@@ -336,14 +336,14 @@ DLL_LINKAGE void RemoveObject::applyGs( CGameState *gs )
 	auto quest = dynamic_cast<const CQuest *>(obj);
 	if (quest)
 	{
-		gs->map->quests[quest->qid] = NULL;
+		gs->map->quests[quest->qid] = nullptr;
 		BOOST_FOREACH (auto &player, gs->players)
 		{
 			BOOST_FOREACH (auto &q, player.second.quests)
 			{
 				if (q.obj == obj)
 				{
-					q.obj = NULL;
+					q.obj = nullptr;
 				}
 			}
 		}
@@ -415,9 +415,9 @@ void TryMoveHero::applyGs( CGameState *gs )
 		CGBoat *b = const_cast<CGBoat *>(h->boat);
 		b->direction = h->moveDir;
 		b->pos = start;
-		b->hero = NULL;
+		b->hero = nullptr;
 		gs->map->addBlockVisTiles(b);
-		h->boat = NULL;
+		h->boat = nullptr;
 	}
 
 	if(start!=end && (result == SUCCESS || result == TELEPORTATION || result == EMBARK || result == DISEMBARK))
@@ -472,9 +472,9 @@ DLL_LINKAGE void SetHeroesInTown::applyGs( CGameState *gs )
 	bool newGarrisonComesFromVisiting = g && g == t->visitingHero;
 
 	if(newVisitorComesFromGarrison)
-		t->setGarrisonedHero(NULL);
+		t->setGarrisonedHero(nullptr);
 	if(newGarrisonComesFromVisiting)
-		t->setVisitingHero(NULL);
+		t->setVisitingHero(nullptr);
 	if(!newGarrisonComesFromVisiting || v)
 		t->setVisitingHero(v);
 	if(!newVisitorComesFromGarrison || g)
@@ -543,7 +543,7 @@ DLL_LINKAGE void GiveHero::applyGs( CGameState *gs )
 DLL_LINKAGE void NewObject::applyGs( CGameState *gs )
 {
 
-	CGObjectInstance *o = NULL;
+	CGObjectInstance *o = nullptr;
 	switch(ID)
 	{
 	case Obj::BOAT:
@@ -607,7 +607,7 @@ DLL_LINKAGE const CStackInstance * StackLocation::getStack()
 	if(!army->hasStackAtSlot(slot))
 	{
         logNetwork->warnStream() << "Warning: " << army->nodeName() << " dont have a stack at slot " << slot;
-		return NULL;
+		return nullptr;
 	}
 	return &army->getStack(slot);
 }
@@ -664,10 +664,10 @@ DLL_LINKAGE const CArtifactInstance *ArtifactLocation::getArt() const
 		else
 		{
             logNetwork->warnStream() << "ArtifactLocation::getArt: That location is locked!";
-			return NULL;
+			return nullptr;
 		}
 	}
-	return NULL;
+	return nullptr;
 }
 
 DLL_LINKAGE const CArtifactSet * ArtifactLocation::getHolderArtSet() const
@@ -1130,7 +1130,7 @@ void BattleResult::applyGs( CGameState *gs )
 		CBonusSystemNode::treeHasChanged();
 	}
 
-	gs->curB->belligerents[0]->battle = gs->curB->belligerents[1]->battle = NULL;
+	gs->curB->belligerents[0]->battle = gs->curB->belligerents[1]->battle = nullptr;
 	gs->curB.dellNull();
 }
 

+ 1 - 1
lib/StartInfo.h

@@ -104,7 +104,7 @@ struct StartInfo
 			if(it->second.playerID == nameID)
 				return &it->second;
 
-		return NULL;
+		return nullptr;
 	}
 
 	template <typename Handler>

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.