Fix potentially removing actors twice from world in Actor::ChangeOwner

This commit is contained in:
Oliver Brakmann
2015-05-26 17:16:56 +02:00
parent 2cc125a3fa
commit 7b3b2f85f8

View File

@@ -242,12 +242,17 @@ namespace OpenRA
return;
var oldOwner = Owner;
var wasInWorld = IsInWorld;
// momentarily remove from world so the ownership queries don't get confused
w.Remove(this);
if (wasInWorld)
w.Remove(this);
Owner = newOwner;
Generation++;
w.Add(this);
if (wasInWorld)
w.Add(this);
foreach (var t in this.TraitsImplementing<INotifyOwnerChanged>())
t.OnOwnerChanged(this, oldOwner, newOwner);