fix a potential bug when requesting supplies for queued AI things caused by re-arranging the queue
This commit is contained in:
parent
6034ff515d
commit
558ad55bb0
1 changed files with 6 additions and 1 deletions
|
@ -862,6 +862,7 @@ static void AiCheckingWork()
|
|||
for (int i = 0; i < sz; ++i) {
|
||||
AiBuildQueue &queue = AiPlayer->UnitTypeBuilt[AiPlayer->UnitTypeBuilt.size() - sz + i];
|
||||
CUnitType &type = *queue.Type;
|
||||
bool new_supply = false;
|
||||
|
||||
// FIXME: must check if requirements are fulfilled.
|
||||
// Buildings can be destroyed.
|
||||
|
@ -869,7 +870,7 @@ static void AiCheckingWork()
|
|||
// Check if we have enough food.
|
||||
if (type.Stats[AiPlayer->Player->Index].Variables[DEMAND_INDEX].Value && !AiCheckSupply(*AiPlayer, type)) {
|
||||
AiPlayer->NeedSupply = true;
|
||||
AiRequestSupply();
|
||||
new_supply = true;
|
||||
}
|
||||
// Check limits, AI should be broken if reached.
|
||||
if (queue.Want > queue.Made && AiPlayer->Player->CheckLimits(type) < 0) {
|
||||
|
@ -897,6 +898,10 @@ static void AiCheckingWork()
|
|||
}
|
||||
}
|
||||
}
|
||||
if (new_supply) {
|
||||
// trigger this last, because it may re-arrange the queue and invalidate our queue item
|
||||
AiRequestSupply();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue