1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-16 02:47:36 +02:00

* when active stack is killed by spell, game behaves properly

This commit is contained in:
mateuszb 2009-09-28 15:05:35 +00:00
parent 7382314dfd
commit 540e15d4ea
2 changed files with 21 additions and 14 deletions

View File

@ -1870,7 +1870,7 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
console->whoSetAlter = 0;
}
}
else if( sactive->hasFeatureOfType(StackFeature::CATAPULT) && isCatapultAttackable(myNumber) ) //catapulting
else if( sactive && sactive->hasFeatureOfType(StackFeature::CATAPULT) && isCatapultAttackable(myNumber) ) //catapulting
{
CGI->curh->changeGraphic(1,16);
console->alterTxt = "";
@ -1887,20 +1887,23 @@ void CBattleInterface::mouseMoved(const SDL_MouseMotionEvent &sEvent)
{
//setting console text and cursor
const CStack *sactive = LOCPLINT->cb->battleGetStackByID(activeStack);
char buf[500];
if(LOCPLINT->cb->battleGetStackByID(activeStack)->hasFeatureOfType(StackFeature::FLYING))
if(sactive) //there can be a moment when stack is dead ut next is not yet activated
{
CGI->curh->changeGraphic(1,2);
sprintf(buf, CGI->generaltexth->allTexts[295].c_str(), sactive->amount == 1 ? sactive->creature->nameSing.c_str() : sactive->creature->namePl.c_str());
}
else
{
CGI->curh->changeGraphic(1,1);
sprintf(buf, CGI->generaltexth->allTexts[294].c_str(), sactive->amount == 1 ? sactive->creature->nameSing.c_str() : sactive->creature->namePl.c_str());
}
char buf[500];
if(sactive->hasFeatureOfType(StackFeature::FLYING))
{
CGI->curh->changeGraphic(1,2);
sprintf(buf, CGI->generaltexth->allTexts[295].c_str(), sactive->amount == 1 ? sactive->creature->nameSing.c_str() : sactive->creature->namePl.c_str());
}
else
{
CGI->curh->changeGraphic(1,1);
sprintf(buf, CGI->generaltexth->allTexts[294].c_str(), sactive->amount == 1 ? sactive->creature->nameSing.c_str() : sactive->creature->namePl.c_str());
}
console->alterTxt = buf;
console->whoSetAlter = 0;
console->alterTxt = buf;
console->whoSetAlter = 0;
}
}
}
}

View File

@ -443,7 +443,7 @@ askInterfaceForMove:
sas.stack = next->ID;
sendAndApply(&sas);
boost::unique_lock<boost::mutex> lock(battleMadeAction.mx);
while(!battleMadeAction.data && !battleResult.get()) //active stack hasn't made its action and battle is still going
while(next->alive() && (!battleMadeAction.data && !battleResult.get())) //active stack hasn't made its action and battle is still going
battleMadeAction.cond.wait(lock);
battleMadeAction.data = false;
}
@ -3163,6 +3163,10 @@ bool CGameHandler::makeCustomAction( BattleAction &ba )
}
}
sendAndApply(&EndAction());
if( !gs->curB->getStack(gs->curB->activeStack, false)->alive() )
{
battleMadeAction.setn(true);
}
checkForBattleEnd(gs->curB->stacks);
if(battleResult.get())
{