From 9d531b0d848b894d13f554d0259c380ef9d655e8 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Fri, 7 Aug 2009 09:45:21 +0000 Subject: [PATCH] * fixed: - 0.72d #27 - 0.73 #13 --- client/CBattleInterface.cpp | 24 ++++++++++++------------ client/CBattleInterface.h | 4 ++-- client/CPlayerInterface.cpp | 8 +------- client/GUIClasses.cpp | 3 +++ lib/CGameState.cpp | 3 +++ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/client/CBattleInterface.cpp b/client/CBattleInterface.cpp index d93d5df1b..a1e73bee8 100644 --- a/client/CBattleInterface.cpp +++ b/client/CBattleInterface.cpp @@ -86,11 +86,7 @@ CBattleInterface::CBattleInterface(CCreatureSet * army1, CCreatureSet * army2, C std::map stacks = LOCPLINT->cb->battleGetStacks(); for(std::map::iterator b=stacks.begin(); b!=stacks.end(); ++b) { - std::pair coords = CBattleHex::getXYUnitAnim(b->second.position, b->second.owner == attackingHeroInstance->tempOwner, &b->second); - creAnims[b->second.ID] = (new CCreatureAnimation(b->second.creature->animDefName)); - creAnims[b->second.ID]->setType(2); - creAnims[b->second.ID]->pos = genRect(creAnims[b->second.ID]->fullHeight, creAnims[b->second.ID]->fullWidth, coords.first, coords.second); - creDir[b->second.ID] = b->second.owner==attackingHeroInstance->tempOwner; + newStack(b->second.ID); } //preparing menu background and terrain std::vector< std::string > & backref = graphics->battleBacks[ LOCPLINT->cb->battleGetBattlefieldType() ]; @@ -998,17 +994,21 @@ void CBattleInterface::bConsoleDownf() console->scrollDown(); } -void CBattleInterface::newStack(CStack stack) +void CBattleInterface::newStack(int stackID) { - creAnims[stack.ID] = new CCreatureAnimation(stack.creature->animDefName); - creAnims[stack.ID]->setType(2); - creDir[stack.ID] = stack.owner==attackingHeroInstance->tempOwner; + const CStack * newStack = LOCPLINT->cb->battleGetStackByID(stackID); + + std::pair coords = CBattleHex::getXYUnitAnim(newStack->position, newStack->owner == attackingHeroInstance->tempOwner, newStack); + creAnims[stackID] = (new CCreatureAnimation(newStack->creature->animDefName)); + creAnims[stackID]->setType(2); + creAnims[stackID]->pos = genRect(creAnims[newStack->ID]->fullHeight, creAnims[newStack->ID]->fullWidth, coords.first, coords.second); + creDir[stackID] = newStack->owner == attackingHeroInstance->tempOwner; } -void CBattleInterface::stackRemoved(CStack stack) +void CBattleInterface::stackRemoved(int stackID) { - delete creAnims[stack.ID]; - creAnims.erase(stack.ID); + delete creAnims[stackID]; + creAnims.erase(stackID); } void CBattleInterface::stackActivated(int number) diff --git a/client/CBattleInterface.h b/client/CBattleInterface.h index f764a438e..2ae7207e0 100644 --- a/client/CBattleInterface.h +++ b/client/CBattleInterface.h @@ -281,8 +281,8 @@ public: }; //call-ins - void newStack(CStack stack); //new stack appeared on battlefield - void stackRemoved(CStack stack); //stack disappeared from batlefiled + void newStack(int stackID); //new stack appeared on battlefield + void stackRemoved(int stackID); //stack disappeared from batlefiled //void stackKilled(int ID, int dmg, int killed, int IDby, bool byShooting); //stack has been killed (but corpses remain) void stackActivated(int number); //active stack has been changed void stackMoved(int number, int destHex, bool endMoving, int distance); //stack with id number moved to destHex diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 10bba5903..fd9538ddc 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -976,14 +976,8 @@ void CPlayerInterface::battleStacksHealedRes(const std::vectorbattleGetStackByID(stackID); - //changing necessary things in battle interface - std::pair coords = CBattleHex::getXYUnitAnim(newStack->position, newStack->owner == battleInt->attackingHeroInstance->tempOwner, newStack); - battleInt->creAnims[newStack->ID] = (new CCreatureAnimation(newStack->creature->animDefName)); - battleInt->creAnims[newStack->ID]->setType(2); - battleInt->creAnims[newStack->ID]->pos = genRect(battleInt->creAnims[newStack->ID]->fullHeight, battleInt->creAnims[newStack->ID]->fullWidth, coords.first, coords.second); - battleInt->creDir[newStack->ID] = newStack->owner == battleInt->attackingHeroInstance->tempOwner; + battleInt->newStack(stackID); } void CPlayerInterface::battleNewRound(int round) //called at the beggining of each turn, round=-1 is the tactic phase, round=0 is the first "normal" turn diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 4e6551ee7..2cf3b6660 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -3125,6 +3125,9 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key) } case SDLK_UP: //up arrow { + if(previouslyEntered.size() == 0) + break; + if(prevEntDisp == -1) { prevEntDisp = previouslyEntered.size() - 1; diff --git a/lib/CGameState.cpp b/lib/CGameState.cpp index a6cae2848..7d2d060d0 100644 --- a/lib/CGameState.cpp +++ b/lib/CGameState.cpp @@ -411,6 +411,9 @@ std::vector BattleInfo::getAccessibility(int stackID, bool addOccupiable) bool BattleInfo::isStackBlocked(int ID) { CStack *our = getStack(ID); + if(our->hasFeatureOfType(StackFeature::SIEGE_WEAPON)) //siege weapons cannot be blocked + return true; + for(unsigned int i=0; ialive()