From 94bee3fd1b99b51c2568cf9cda06376e7b0d7a7d Mon Sep 17 00:00:00 2001
From: beegee1 <be.gentner@googlemail.com>
Date: Sun, 3 Nov 2013 16:44:47 +0000
Subject: [PATCH] - Changed visibility of curInt member of BattleInterface from
 public to private and provided a getter method

---
 client/battle/CBattleAnimations.cpp       | 10 +++++-----
 client/battle/CBattleInterface.cpp        |  5 +++++
 client/battle/CBattleInterface.h          |  3 ++-
 client/battle/CBattleInterfaceClasses.cpp | 14 +++++++-------
 4 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/client/battle/CBattleAnimations.cpp b/client/battle/CBattleAnimations.cpp
index d14d6c442..b4b113907 100644
--- a/client/battle/CBattleAnimations.cpp
+++ b/client/battle/CBattleAnimations.cpp
@@ -138,7 +138,7 @@ CAttackAnimation::CAttackAnimation(CBattleInterface *_owner, const CStack *attac
 
 	assert(attackingStack && "attackingStack is nullptr in CBattleAttack::CBattleAttack !\n");
 	bool isCatapultAttack = attackingStack->hasBonusOfType(Bonus::CATAPULT) 
-							&& owner->curInt->cb->battleHexToWallPart(_dest) >= 0;
+							&& owner->getCurrentPlayerInterface()->cb->battleHexToWallPart(_dest) >= 0;
 
 	assert(attackedStack || isCatapultAttack);
 	attackingStackPosBeforeReturn = attackingStack->position;
@@ -185,7 +185,7 @@ bool CDefenceAnimation::init()
 
 
 	//reverse unit if necessary
-	if (attacker && owner->curInt->cb->isToReverse(stack->position, attacker->position, owner->creDir[stack->ID], attacker->doubleWide(), owner->creDir[attacker->ID]))
+	if (attacker && owner->getCurrentPlayerInterface()->cb->isToReverse(stack->position, attacker->position, owner->creDir[stack->ID], attacker->doubleWide(), owner->creDir[attacker->ID]))
 	{
 		owner->addNewAnim(new CReverseAnimation(owner, stack, stack->position, true));
 		return false;
@@ -309,7 +309,7 @@ bool CMeleeAttackAnimation::init()
 		return false;
 	}
 
-	bool toReverse = owner->curInt->cb->isToReverse(attackingStackPosBeforeReturn, dest, owner->creDir[stack->ID], attackedStack->doubleWide(), owner->creDir[attackedStack->ID]);
+	bool toReverse = owner->getCurrentPlayerInterface()->cb->isToReverse(attackingStackPosBeforeReturn, dest, owner->creDir[stack->ID], attackedStack->doubleWide(), owner->creDir[attackedStack->ID]);
 
 	if (toReverse)
 	{
@@ -668,7 +668,7 @@ bool CShootingAnimation::init()
 	}
 
 	//reverse unit if necessary
-	if (attackingStack && attackedStack && owner->curInt->cb->isToReverse(attackingStack->position, attackedStack->position, owner->creDir[attackingStack->ID], attackingStack->doubleWide(), owner->creDir[attackedStack->ID]))
+	if (attackingStack && attackedStack && owner->getCurrentPlayerInterface()->cb->isToReverse(attackingStack->position, attackedStack->position, owner->creDir[attackingStack->ID], attackingStack->doubleWide(), owner->creDir[attackedStack->ID]))
 	{
 		owner->addNewAnim(new CReverseAnimation(owner, attackingStack, attackingStack->position, true));
 		return false;
@@ -902,7 +902,7 @@ bool CSpellEffectAnimation::init()
 	{
 		if(effect == -1 || graphics->battleACToDef[effect].size() != 0)
 		{
-			const CStack* destStack = owner->curInt->cb->battleGetStackByPos(destTile, false);
+			const CStack* destStack = owner->getCurrentPlayerInterface()->cb->battleGetStackByPos(destTile, false);
 			Rect &tilePos = owner->bfield[destTile]->pos;
 			BattleEffect be;
 			be.effectID = ID;
diff --git a/client/battle/CBattleInterface.cpp b/client/battle/CBattleInterface.cpp
index 63b7892f0..337b48e1d 100644
--- a/client/battle/CBattleInterface.cpp
+++ b/client/battle/CBattleInterface.cpp
@@ -1643,6 +1643,11 @@ int CBattleInterface::getAnimSpeed() const
 	return vstd::round(settings["battle"]["animationSpeed"].Float() * 100);
 }
 
+CPlayerInterface * CBattleInterface::getCurrentPlayerInterface() const
+{
+	return curInt.get();
+}
+
 void CBattleInterface::setActiveStack(const CStack * stack)
 {
 	if (activeStack) // update UI
diff --git a/client/battle/CBattleInterface.h b/client/battle/CBattleInterface.h
index 53f5085a4..1672180f0 100644
--- a/client/battle/CBattleInterface.h
+++ b/client/battle/CBattleInterface.h
@@ -213,6 +213,7 @@ private:
 	} * siegeH;
 
 	shared_ptr<CPlayerInterface> attackerInt, defenderInt; //because LOCPLINT is not enough in hotSeat
+	shared_ptr<CPlayerInterface> curInt; //current player interface
 	const CGHeroInstance * getActiveHero(); //returns hero that can currently cast a spell
 
 	/** Methods for displaying battle screen */
@@ -243,7 +244,6 @@ private:
 	/** End of battle screen blitting methods */
 
 public:
-	shared_ptr<CPlayerInterface> curInt; //current player interface
 	std::list<std::pair<CBattleAnimation *, bool> > pendingAnims; //currently displayed animations <anim, initialized>
 	void addNewAnim(CBattleAnimation * anim); //adds new anim to pendingAnims
 	ui32 animIDhelper; //for giving IDs for animations
@@ -258,6 +258,7 @@ public:
 	void setPrintMouseShadow(bool set); //if true, hex under mouse will be shaded
 	void setAnimSpeed(int set); //speed of animation; range 1..100
 	int getAnimSpeed() const; //speed of animation; range 1..100
+	CPlayerInterface * getCurrentPlayerInterface() const;
 
 	std::vector<CClickableHex*> bfield; //11 lines, 17 hexes on each
 	SDL_Surface * cellBorder, * cellShade;
diff --git a/client/battle/CBattleInterfaceClasses.cpp b/client/battle/CBattleInterfaceClasses.cpp
index f8a375bb3..b7986b48f 100644
--- a/client/battle/CBattleInterfaceClasses.cpp
+++ b/client/battle/CBattleInterfaceClasses.cpp
@@ -175,7 +175,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
 	if(myOwner->spellDestSelectMode) //we are casting a spell
 		return;
 
-	if(!down && myHero != nullptr && myOwner->myTurn && myOwner->curInt->cb->battleCanCastSpell()) //check conditions
+	if(!down && myHero != nullptr && myOwner->myTurn && myOwner->getCurrentPlayerInterface()->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
 		{
@@ -184,7 +184,7 @@ void CBattleHero::clickLeft(tribool down, bool previousState)
 		}
 		CCS->curh->changeGraphic(ECursor::ADVENTURE, 0);
 
-		auto  spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->curInt.get());
+		auto  spellWindow = new CSpellWindow(genRect(595, 620, (screen->w - 620)/2, (screen->h - 595)/2), myHero, myOwner->getCurrentPlayerInterface());
 		GH.pushInt(spellWindow);
 	}
 }
@@ -256,7 +256,7 @@ CBattleOptionsWindow::CBattleOptionsWindow(const SDL_Rect & position, CBattleInt
 	OBJ_CONSTRUCTION_CAPTURING_ALL;
 	pos = position;
 	background = new CPicture("comopbck.bmp");
-	background->colorize(owner->curInt->playerID);
+	background->colorize(owner->getCurrentPlayerInterface()->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", nullptr, 25, 56, false);
 	viewGrid->select(settings["battle"]["cellBorders"].Bool());
@@ -570,9 +570,9 @@ void CClickableHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
 
 	if(hovered && strictHovered) //print attacked creature to console
 	{
-		const CStack * attackedStack = myInterface->curInt->cb->battleGetStackByPos(myNumber);
+		const CStack * attackedStack = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber);
 		if(myInterface->console->alterTxt.size() == 0 &&attackedStack != nullptr &&
-			attackedStack->owner != myInterface->curInt->playerID &&
+			attackedStack->owner != myInterface->getCurrentPlayerInterface()->playerID &&
 			attackedStack->alive())
 		{
 			char tabh[160];
@@ -599,7 +599,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
+	const CStack * myst = myInterface->getCurrentPlayerInterface()->cb->battleGetStackByPos(myNumber); //stack info
 	if(hovered && strictHovered && myst!=nullptr)
 	{
 
@@ -614,7 +614,7 @@ void CClickableHex::clickRight(tribool down, bool previousState)
 void CStackQueue::update()
 {
 	stacksSorted.clear();
-	owner->curInt->cb->battleGetStackQueue(stacksSorted, stackBoxes.size());
+	owner->getCurrentPlayerInterface()->cb->battleGetStackQueue(stacksSorted, stackBoxes.size());
 	if(stacksSorted.size())
 	{
 		for (int i = 0; i < stackBoxes.size() ; i++)