Throttle the issuing of orders by the AI.

To prevent the AI generating lag spikes by issuing too many orders in a single tick, it is now limited in how many orders can be issued per tick. Extra orders are queued. This allows the performance hit of issuing multiple orders to be spread out over several ticks.
This commit is contained in:
RoosterDragon
2015-07-22 23:06:12 +01:00
parent 6b9dd9670a
commit 942ce6b5a6
6 changed files with 39 additions and 25 deletions

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.AI
return false;
HackyAI.BotDebug("AI: {0} is starting production of {1}".F(player, item.Name));
world.IssueOrder(Order.StartProduction(queue.Actor, item.Name, 1));
ai.QueueOrder(Order.StartProduction(queue.Actor, item.Name, 1));
}
else if (currentBuilding.Done)
{
@@ -87,11 +87,11 @@ namespace OpenRA.Mods.Common.AI
if (location == null)
{
HackyAI.BotDebug("AI: {0} has nowhere to place {1}".F(player, currentBuilding.Item));
world.IssueOrder(Order.CancelProduction(queue.Actor, currentBuilding.Item, 1));
ai.QueueOrder(Order.CancelProduction(queue.Actor, currentBuilding.Item, 1));
}
else
{
world.IssueOrder(new Order("PlaceBuilding", player.PlayerActor, false)
ai.QueueOrder(new Order("PlaceBuilding", player.PlayerActor, false)
{
TargetLocation = location.Value,
TargetString = currentBuilding.Item,