From 3711ef8eb540fbe9560ee9513824440c89000b92 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 29 Sep 2015 22:33:01 +0200 Subject: [PATCH] Fix AI queueing build orders twice at higher game speeds due to lag Fixes #9403. --- OpenRA.Mods.Common/AI/BaseBuilder.cs | 4 +++- OpenRA.Mods.Common/AI/HackyAI.cs | 10 +++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/AI/BaseBuilder.cs b/OpenRA.Mods.Common/AI/BaseBuilder.cs index 0dcffe45ea..30e350ab38 100644 --- a/OpenRA.Mods.Common/AI/BaseBuilder.cs +++ b/OpenRA.Mods.Common/AI/BaseBuilder.cs @@ -117,7 +117,9 @@ namespace OpenRA.Mods.Common.AI // Add a random factor so not every AI produces at the same tick early in the game. // Minimum should not be negative as delays in HackyAI could be zero. var randomFactor = ai.Random.Next(0, ai.Info.StructureProductionRandomBonusDelay); - waitTicks = active ? ai.Info.StructureProductionActiveDelay + randomFactor + + // Needs to be at least 4 * OrderLatency because otherwise the AI frequently duplicates build orders (i.e. makes the same build decision twice) + waitTicks = active ? 4 * world.LobbyInfo.GlobalSettings.OrderLatency + ai.Info.StructureProductionActiveDelay + randomFactor : ai.Info.StructureProductionInactiveDelay + randomFactor; } diff --git a/OpenRA.Mods.Common/AI/HackyAI.cs b/OpenRA.Mods.Common/AI/HackyAI.cs index 7d06ecf5b2..c7a58789c2 100644 --- a/OpenRA.Mods.Common/AI/HackyAI.cs +++ b/OpenRA.Mods.Common/AI/HackyAI.cs @@ -56,13 +56,13 @@ namespace OpenRA.Mods.Common.AI [Desc("Minimum excess power the AI should try to maintain.")] public readonly int MinimumExcessPower = 0; - [Desc("Delay (in ticks) between structure production checks when there is no active production.", - "A StructureProductionRandomBonusDelay is added to this.")] + [Desc("Additional delay (in ticks) between structure production checks when there is no active production.", + "StructureProductionRandomBonusDelay is added to this.")] public readonly int StructureProductionInactiveDelay = 125; - [Desc("Delay (in ticks) between structure production checks when actively building things.", - "A StructureProductionRandomBonusDelay is added to this.")] - public readonly int StructureProductionActiveDelay = 10; + [Desc("Additional delay (in ticks) added between structure production checks when actively building things.", + "Note: The total delay is gamespeed OrderLatency x 4 + this + StructureProductionRandomBonusDelay.")] + public readonly int StructureProductionActiveDelay = 0; [Desc("A random delay (in ticks) of up to this is added to active/inactive production delays.")] public readonly int StructureProductionRandomBonusDelay = 10;