From 4eb17e16428c42a239de938b40b8c3f8ea6b1b0b Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 24 Jun 2016 16:35:21 +0200 Subject: [PATCH 1/2] Fix all wandering actors wandering at first game tick NotifyBecomingIdle is only notified at the first idle tick, so `countdown` is not set when TickIdle checks it at first game tick. Therefore, we let TickIdle return early at first game tick to avoid that. --- OpenRA.Mods.Common/Traits/Wanders.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Wanders.cs b/OpenRA.Mods.Common/Traits/Wanders.cs index b39a1410cb..aa901add55 100644 --- a/OpenRA.Mods.Common/Traits/Wanders.cs +++ b/OpenRA.Mods.Common/Traits/Wanders.cs @@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Traits int countdown; int ticksIdle; int effectiveMoveRadius; + bool firstTick = true; public Wanders(Actor self, WandersInfo info) { @@ -54,6 +55,13 @@ namespace OpenRA.Mods.Common.Traits public void TickIdle(Actor self) { + // The countdown has not have been set at this point, so don't check yet + if (firstTick) + { + firstTick = false; + return; + } + if (--countdown > 0) return; From 38e1d409ffb08b2977c5b8967e7afe974adac3b6 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Fri, 24 Jun 2016 16:36:04 +0200 Subject: [PATCH 2/2] Make Wanders.TickIdle virtual So inheriting traits can override it. --- OpenRA.Mods.Common/Traits/Wanders.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Wanders.cs b/OpenRA.Mods.Common/Traits/Wanders.cs index aa901add55..b8ec03010c 100644 --- a/OpenRA.Mods.Common/Traits/Wanders.cs +++ b/OpenRA.Mods.Common/Traits/Wanders.cs @@ -53,7 +53,7 @@ namespace OpenRA.Mods.Common.Traits countdown = self.World.SharedRandom.Next(info.MinMoveDelay, info.MaxMoveDelay); } - public void TickIdle(Actor self) + public virtual void TickIdle(Actor self) { // The countdown has not have been set at this point, so don't check yet if (firstTick)