From a847f3eafa121eae319c30a4fb4c6ad0ed613f74 Mon Sep 17 00:00:00 2001 From: abcdefg30 Date: Wed, 29 Jul 2020 00:31:13 +0200 Subject: [PATCH] Fix actors not yet in the world improperly updating power state --- OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs b/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs index bd4d7d22a1..54058bcf1a 100644 --- a/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs +++ b/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs @@ -73,7 +73,11 @@ namespace OpenRA.Mods.Common.Traits public void UpdateActor(Actor a) { - // old is 0 if a is not in powerDrain + // Do not add power from actors that are not in the world + if (!a.IsInWorld) + return; + + // Old is 0 if a is not in powerDrain int old; powerDrain.TryGetValue(a, out old); @@ -98,6 +102,10 @@ namespace OpenRA.Mods.Common.Traits public void RemoveActor(Actor a) { + // Do not remove power from actors that are still in the world + if (a.IsInWorld) + return; + int amount; if (!powerDrain.TryGetValue(a, out amount)) return;