Browse Source

* a few more consts

mateuszb 15 years ago
parent
commit
6f56b5bb30

+ 5 - 5
AI/GeniusAI/CGeniusAI.cpp

@@ -1235,7 +1235,7 @@ void CGeniusAI::actionStarted(const BattleAction *action)
 /**
  * called when stack is performing attack
  */
-void CGeniusAI::battleAttack(BattleAttack* ba)
+void CGeniusAI::battleAttack(const BattleAttack* ba)
 {
 	DbgBox("\t\t\tCGeniusAI::battleAttack");
 }
@@ -1244,7 +1244,7 @@ void CGeniusAI::battleAttack(BattleAttack* ba)
 /**
  * called when stack receives damage (after battleAttack())
  */
-void CGeniusAI::battleStacksAttacked(std::set<BattleStackAttacked>& bsa)
+void CGeniusAI::battleStacksAttacked(const std::set<BattleStackAttacked>& bsa)
 {
 	DbgBox("\t\t\tCGeniusAI::battleStacksAttacked");
 }
@@ -1271,7 +1271,7 @@ void CGeniusAI::battleStart(const CCreatureSet *army1, const CCreatureSet *army2
 /**
  *
  */
-void CGeniusAI::battleEnd(BattleResult* br)
+void CGeniusAI::battleEnd(const BattleResult* br)
 {
 	switch (br->winner)
 	{
@@ -1280,7 +1280,7 @@ void CGeniusAI::battleEnd(BattleResult* br)
 		case 2:	tlog6 << "It's a draw." << std::endl; break;
 	};
 	tlog6 << "lost ";
-	for (std::map<ui32,si32>::iterator i = br->casualties[0].begin(); i != br->casualties[0].end(); i++)
+	for (std::map<ui32,si32>::const_iterator i = br->casualties[0].begin(); i != br->casualties[0].end(); i++)
 		tlog6 << i->second << " " << VLC->creh->creatures[i->first]->namePl << endl;
 				
 	delete m_battleLogic;
@@ -1322,7 +1322,7 @@ void CGeniusAI::battleStackMoved(int ID, int dest, int distance, bool end)
 /**
  *
  */
-void CGeniusAI::battleSpellCast(BattleSpellCast *sc)
+void CGeniusAI::battleSpellCast(const BattleSpellCast *sc)
 {
 	DbgBox("\t\t\tCGeniusAI::battleSpellCast");
 }

+ 4 - 4
AI/GeniusAI/CGeniusAI.h

@@ -201,12 +201,12 @@ public:
 	// battle
 	virtual void actionFinished(const BattleAction *action);//occurs AFTER every action taken by any stack or by the hero
 	virtual void actionStarted(const BattleAction *action);//occurs BEFORE every action taken by any stack or by the hero
-	virtual void battleAttack(BattleAttack *ba); //called when stack is performing attack
-	virtual void battleStacksAttacked(std::set<BattleStackAttacked> & bsa); //called when stack receives damage (after battleAttack())
-	virtual void battleEnd(BattleResult *br);
+	virtual void battleAttack(const BattleAttack *ba); //called when stack is performing attack
+	virtual void battleStacksAttacked(const std::set<BattleStackAttacked> & bsa); //called when stack receives damage (after battleAttack())
+	virtual void battleEnd(const BattleResult *br);
 	virtual void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
 	virtual void battleStackMoved(int ID, int dest, int distance, bool end);
-	virtual void battleSpellCast(BattleSpellCast *sc);
+	virtual void battleSpellCast(const BattleSpellCast *sc);
 	virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
 	//virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles); //called when battlefield is prepared, prior the battle beginning
 	//

+ 5 - 5
CGameInterface.h

@@ -111,15 +111,15 @@ public:
 	virtual void actionFinished(const BattleAction *action){};//occurs AFTER every action taken by any stack or by the hero
 	virtual void actionStarted(const BattleAction *action){};//occurs BEFORE every action taken by any stack or by the hero
 	virtual BattleAction activeStack(int stackID)=0; //called when it's turn of that stack
-	virtual void battleAttack(BattleAttack *ba){}; //called when stack is performing attack
-	virtual void battleStacksAttacked(std::vector<BattleStackAttacked> & bsa){}; //called when stack receives damage (after battleAttack())
-	virtual void battleEnd(BattleResult *br){};
+	virtual void battleAttack(const BattleAttack *ba){}; //called when stack is performing attack
+	virtual void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa){}; //called when stack receives damage (after battleAttack())
+	virtual void battleEnd(const BattleResult *br){};
 	virtual void battleResultsApplied(){}; //called when all effects of last battle are applied
 	virtual void battleNewRoundFirst(int round){}; //called at the beginning of each turn before changes are applied;
 	virtual void battleNewRound(int round){}; //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
 	virtual void battleStackMoved(int ID, int dest, int distance, bool end){};
-	virtual void battleSpellCast(BattleSpellCast *sc){};
-	virtual void battleStacksEffectsSet(SetStackEffect & sse){};//called when a specific effect is set to stacks
+	virtual void battleSpellCast(const BattleSpellCast *sc){};
+	virtual void battleStacksEffectsSet(const SetStackEffect & sse){};//called when a specific effect is set to stacks
 	virtual void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side){}; //called by engine when battle starts; side=0 - left, side=1 - right
 	//virtual void battlefieldPrepared(int battlefieldType, std::vector<CObstacle*> obstacles){}; //called when battlefield is prepared, prior the battle beginning
 	virtual void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp

+ 1 - 1
client/CBattleInterface.cpp

@@ -2670,7 +2670,7 @@ void CBattleInterface::displayBattleFinished()
 	GH.pushInt(resWindow);
 }
 
-void CBattleInterface::spellCast(BattleSpellCast * sc)
+void CBattleInterface::spellCast( const BattleSpellCast * sc )
 {
 	const CSpell &spell = CGI->spellh->spells[sc->id];
 

+ 1 - 1
client/CBattleInterface.h

@@ -506,7 +506,7 @@ public:
 	void battleFinished(const BattleResult& br); //called when battle is finished - battleresult window should be printed
 	const BattleResult * bresult; //result of a battle; if non-zero then display when all animations end
 	void displayBattleFinished(); //displays battle result
-	void spellCast(BattleSpellCast * sc); //called when a hero casts a spell
+	void spellCast(const BattleSpellCast * sc); //called when a hero casts a spell
 	void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
 	void castThisSpell(int spellID); //called when player has chosen a spell from spellbook
 	void displayEffect(ui32 effect, int destTile); //displays effect of a spell on the battlefield; affected: true - attacker. false - defender

+ 7 - 7
client/CPlayerInterface.cpp

@@ -715,7 +715,7 @@ BattleAction CPlayerInterface::activeStack(int stackID) //called when it's turn
 	return ret;
 }
 
-void CPlayerInterface::battleEnd(BattleResult *br)
+void CPlayerInterface::battleEnd(const BattleResult *br)
 {
 	if(LOCPLINT != this)
 	{ //another local interface should do this
@@ -736,7 +736,7 @@ void CPlayerInterface::battleStackMoved(int ID, int dest, int distance, bool end
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
 	battleInt->stackMoved(ID, dest, end, distance);
 }
-void CPlayerInterface::battleSpellCast(BattleSpellCast *sc)
+void CPlayerInterface::battleSpellCast( const BattleSpellCast *sc )
 {
 	if(LOCPLINT != this)
 	{ //another local interface should do this
@@ -746,7 +746,7 @@ void CPlayerInterface::battleSpellCast(BattleSpellCast *sc)
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
 	battleInt->spellCast(sc);
 }
-void CPlayerInterface::battleStacksEffectsSet(SetStackEffect & sse)
+void CPlayerInterface::battleStacksEffectsSet( const SetStackEffect & sse )
 {
 	if(LOCPLINT != this)
 	{ //another local interface should do this
@@ -756,7 +756,7 @@ void CPlayerInterface::battleStacksEffectsSet(SetStackEffect & sse)
 	boost::unique_lock<boost::recursive_mutex> un(*pim);
 	battleInt->battleStacksEffectsSet(sse);
 }
-void CPlayerInterface::battleStacksAttacked(std::vector<BattleStackAttacked> & bsa)
+void CPlayerInterface::battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa)
 {
 	if(LOCPLINT != this)
 	{ //another local interface should do this
@@ -769,7 +769,7 @@ void CPlayerInterface::battleStacksAttacked(std::vector<BattleStackAttacked> & b
 
 
 	std::vector<SStackAttackedInfo> arg;
-	for(std::vector<BattleStackAttacked>::iterator i = bsa.begin(); i != bsa.end(); i++)
+	for(std::vector<BattleStackAttacked>::const_iterator i = bsa.begin(); i != bsa.end(); i++)
 	{
 		if(i->isEffect() && i->effect != 12) //and not armageddon
 		{
@@ -789,7 +789,7 @@ void CPlayerInterface::battleStacksAttacked(std::vector<BattleStackAttacked> & b
 
 	battleInt->stacksAreAttacked(arg);
 }
-void CPlayerInterface::battleAttack(BattleAttack *ba)
+void CPlayerInterface::battleAttack(const BattleAttack *ba)
 {
 	if(LOCPLINT != this)
 	{ //another local interface should do this
@@ -812,7 +812,7 @@ void CPlayerInterface::battleAttack(BattleAttack *ba)
 
 	if(ba->shot())
 	{
-		for(std::vector<BattleStackAttacked>::iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
+		for(std::vector<BattleStackAttacked>::const_iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++)
 			battleInt->stackIsShooting(ba->stackAttacking,cb->battleGetPos(i->stackAttacked), i->stackAttacked);
 	}
 	else

+ 5 - 5
client/CPlayerInterface.h

@@ -203,15 +203,15 @@ public:
 	void actionFinished(const BattleAction* action);//occurs AFTER action taken by active stack or by the hero
 	void actionStarted(const BattleAction* action);//occurs BEFORE action taken by active stack or by the hero
 	BattleAction activeStack(int stackID); //called when it's turn of that stack
-	void battleAttack(BattleAttack *ba); //stack performs attack
-	void battleEnd(BattleResult *br); //end of battle
+	void battleAttack(const BattleAttack *ba); //stack performs attack
+	void battleEnd(const BattleResult *br); //end of battle
 	//void battleResultQuited();
 	void battleNewRoundFirst(int round); //called at the beginning of each turn before changes are applied; used for HP regen handling
 	void battleNewRound(int round); //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn
 	void battleStackMoved(int ID, int dest, int distance, bool end);
-	void battleSpellCast(BattleSpellCast *sc);
-	void battleStacksEffectsSet(SetStackEffect & sse); //called when a specific effect is set to stacks
-	void battleStacksAttacked(std::vector<BattleStackAttacked> & bsa);
+	void battleSpellCast(const BattleSpellCast *sc);
+	void battleStacksEffectsSet(const SetStackEffect & sse); //called when a specific effect is set to stacks
+	void battleStacksAttacked(const std::vector<BattleStackAttacked> & bsa);
 	void battleStart(const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side); //called by engine when battle starts; side=0 - left, side=1 - right
 	void battleStacksHealedRes(const std::vector<std::pair<ui32, ui32> > & healedStacks, bool lifeDrain, si32 lifeDrainFrom); //called when stacks are healed / resurrected
 	void battleNewStackAppeared(int stackID); //not called at the beginning of a battle or by resurrection; called eg. when elemental is summoned

+ 4 - 4
lib/NetPacks.h

@@ -1064,19 +1064,19 @@ struct BattleAttack : public CPackForClient//3006
 	ui32 stackAttacking;
 	ui8 flags;
 
-	bool shot()//distance attack - decrease number of shots
+	bool shot() const//distance attack - decrease number of shots
 	{
 		return flags & 1;
 	}
-	bool counter()//is it counterattack?
+	bool counter() const//is it counterattack?
 	{
 		return flags & 2;
 	}
-	bool lucky()
+	bool lucky() const
 	{
 		return flags & 4;
 	}
-	bool unlucky()
+	bool unlucky() const
 	{
 		//TODO: support?
 		return flags & 8;