From 6f56b5bb3050587c4a142874d243d65f22fd78b4 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Sat, 4 Dec 2010 19:44:23 +0000 Subject: [PATCH] * a few more consts --- AI/GeniusAI/CGeniusAI.cpp | 10 +++++----- AI/GeniusAI/CGeniusAI.h | 8 ++++---- CGameInterface.h | 10 +++++----- client/CBattleInterface.cpp | 2 +- client/CBattleInterface.h | 2 +- client/CPlayerInterface.cpp | 14 +++++++------- client/CPlayerInterface.h | 10 +++++----- lib/NetPacks.h | 8 ++++---- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/AI/GeniusAI/CGeniusAI.cpp b/AI/GeniusAI/CGeniusAI.cpp index ad2e6a172..173e7f9c5 100644 --- a/AI/GeniusAI/CGeniusAI.cpp +++ b/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& bsa) +void CGeniusAI::battleStacksAttacked(const std::set& 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::iterator i = br->casualties[0].begin(); i != br->casualties[0].end(); i++) + for (std::map::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"); } diff --git a/AI/GeniusAI/CGeniusAI.h b/AI/GeniusAI/CGeniusAI.h index b620e744d..8fbad0afc 100644 --- a/AI/GeniusAI/CGeniusAI.h +++ b/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 & 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 & 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 obstacles); //called when battlefield is prepared, prior the battle beginning // diff --git a/CGameInterface.h b/CGameInterface.h index 918c52517..71c8ad08a 100644 --- a/CGameInterface.h +++ b/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 & 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 & 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 obstacles){}; //called when battlefield is prepared, prior the battle beginning virtual void battleStacksHealedRes(const std::vector > & healedStacks, bool lifeDrain, si32 lifeDrainFrom){}; //called when stacks are healed / resurrected first element of pair - stack id, second - healed hp diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index 595e8b147..a5e9dbf91 100644 --- a/client/CBattleInterface.cpp +++ b/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]; diff --git a/client/CBattleInterface.h b/client/CBattleInterface.h index 3b0f25850..d800418cb 100644 --- a/client/CBattleInterface.h +++ b/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 diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 2d5e65b0e..21abb37d6 100644 --- a/client/CPlayerInterface.cpp +++ b/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 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 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 un(*pim); battleInt->battleStacksEffectsSet(sse); } -void CPlayerInterface::battleStacksAttacked(std::vector & bsa) +void CPlayerInterface::battleStacksAttacked(const std::vector & bsa) { if(LOCPLINT != this) { //another local interface should do this @@ -769,7 +769,7 @@ void CPlayerInterface::battleStacksAttacked(std::vector & b std::vector arg; - for(std::vector::iterator i = bsa.begin(); i != bsa.end(); i++) + for(std::vector::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 & 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::iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++) + for(std::vector::const_iterator i = ba->bsa.begin(); i != ba->bsa.end(); i++) battleInt->stackIsShooting(ba->stackAttacking,cb->battleGetPos(i->stackAttacked), i->stackAttacked); } else diff --git a/client/CPlayerInterface.h b/client/CPlayerInterface.h index f3e035040..4c0e9d2c0 100644 --- a/client/CPlayerInterface.h +++ b/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 & 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 & 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 > & 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 diff --git a/lib/NetPacks.h b/lib/NetPacks.h index bcc37e405..0502069a0 100644 --- a/lib/NetPacks.h +++ b/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;