mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-23 22:37:55 +02:00
found a bug in code where AI can change client gamestate directly causing sorting crash
This commit is contained in:
@@ -578,6 +578,7 @@ void CBattleAI::attemptCastingSpell()
|
||||
size_t minTurnSpan = ourUnits/3; //todo: tweak this
|
||||
|
||||
std::vector<battle::Units> newTurnOrder;
|
||||
|
||||
state.battleGetTurnOrder(newTurnOrder, amount, 2);
|
||||
|
||||
const bool turnSpanOK = evaluateQueue(newValueOfStack, newTurnOrder, &state, minTurnSpan, nullptr);
|
||||
|
||||
@@ -14,11 +14,16 @@
|
||||
|
||||
void actualizeEffect(TBonusListPtr target, const Bonus & ef)
|
||||
{
|
||||
for(auto bonus : *target) //TODO: optimize
|
||||
for(auto & bonus : *target) //TODO: optimize
|
||||
{
|
||||
if(bonus->source == Bonus::SPELL_EFFECT && bonus->type == ef.type && bonus->subtype == ef.subtype)
|
||||
{
|
||||
bonus->turnsRemain = std::max(bonus->turnsRemain, ef.turnsRemain);
|
||||
if(bonus->turnsRemain < ef.turnsRemain)
|
||||
{
|
||||
bonus.reset(new Bonus(*bonus));
|
||||
|
||||
bonus->turnsRemain = ef.turnsRemain;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user