Fix actors not yet in the world improperly updating power state

This commit is contained in:
abcdefg30
2020-07-29 00:31:13 +02:00
committed by reaperrr
parent a751f074e7
commit a847f3eafa

View File

@@ -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;