mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Fix server crash releated to active stack remove.
This commit is contained in:
parent
6cf220b882
commit
d1ec538d72
@ -5444,11 +5444,23 @@ void CGameHandler::runBattle()
|
||||
BattleSetActiveStack sas;
|
||||
sas.stack = next->ID;
|
||||
sendAndApply(&sas);
|
||||
|
||||
auto actionWasMade = [&]() -> bool
|
||||
{
|
||||
if(battleMadeAction.data)//active stack has made its action
|
||||
return true;
|
||||
if(battleResult.get())// battle is finished
|
||||
return true;
|
||||
return !next->alive();//active stack is dead
|
||||
};
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(battleMadeAction.mx);
|
||||
battleMadeAction.data = false;
|
||||
while (next->alive() && //next is invalid after sacrificing current stack :?
|
||||
(!battleMadeAction.data && !battleResult.get())) //active stack hasn't made its action and battle is still going
|
||||
while(!actionWasMade())
|
||||
{
|
||||
battleMadeAction.cond.wait(lock);
|
||||
next = gs->curB->battleActiveStack(); //it may change while we wait
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user