1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-07-03 00:46:55 +02:00

Fix the SACRIFICE fix regression

(crach if stack die on counter attack)
This commit is contained in:
AlexVinS
2015-10-06 02:04:25 +03:00
parent 4e60b4cf53
commit d042b08682

View File

@ -5441,8 +5441,9 @@ void CGameHandler::runBattle()
else else
{ {
logGlobal->traceStream() << "Activating " << next->nodeName(); logGlobal->traceStream() << "Activating " << next->nodeName();
auto nextId = next->ID;
BattleSetActiveStack sas; BattleSetActiveStack sas;
sas.stack = next->ID; sas.stack = nextId;
sendAndApply(&sas); sendAndApply(&sas);
auto actionWasMade = [&]() -> bool auto actionWasMade = [&]() -> bool
@ -5459,7 +5460,8 @@ void CGameHandler::runBattle()
while(!actionWasMade()) while(!actionWasMade())
{ {
battleMadeAction.cond.wait(lock); battleMadeAction.cond.wait(lock);
next = gs->curB->battleActiveStack(); //it may change while we wait if(battleGetStackByID(nextId, false) != next)
next = nullptr; //it may be removed, while we wait
} }
} }
} }
@ -5469,10 +5471,11 @@ void CGameHandler::runBattle()
breakOuter = true; breakOuter = true;
break; break;
} }
//we're after action, all results applied //we're after action, all results applied
checkForBattleEnd(); //check if this action ended the battle checkForBattleEnd(); //check if this action ended the battle
if(next != nullptr)
{
//check for good morale //check for good morale
nextStackMorale = next->MoraleVal(); nextStackMorale = next->MoraleVal();
if(!vstd::contains(next->state,EBattleStackState::HAD_MORALE) //only one extra move per turn possible if(!vstd::contains(next->state,EBattleStackState::HAD_MORALE) //only one extra move per turn possible
@ -5498,7 +5501,7 @@ void CGameHandler::runBattle()
++numberOfAsks; //move this stack once more ++numberOfAsks; //move this stack once more
} }
} }
}
--numberOfAsks; --numberOfAsks;
} while (numberOfAsks > 0); } while (numberOfAsks > 0);