Merge pull request #8268 from obrakmann/fix8262_d2k_double_remove_from_world
Fix potentially removing actors twice from world in Actor::ChangeOwner
This commit is contained in:
@@ -242,12 +242,17 @@ namespace OpenRA
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var oldOwner = Owner;
|
var oldOwner = Owner;
|
||||||
|
var wasInWorld = IsInWorld;
|
||||||
|
|
||||||
// momentarily remove from world so the ownership queries don't get confused
|
// momentarily remove from world so the ownership queries don't get confused
|
||||||
w.Remove(this);
|
if (wasInWorld)
|
||||||
|
w.Remove(this);
|
||||||
|
|
||||||
Owner = newOwner;
|
Owner = newOwner;
|
||||||
Generation++;
|
Generation++;
|
||||||
w.Add(this);
|
|
||||||
|
if (wasInWorld)
|
||||||
|
w.Add(this);
|
||||||
|
|
||||||
foreach (var t in this.TraitsImplementing<INotifyOwnerChanged>())
|
foreach (var t in this.TraitsImplementing<INotifyOwnerChanged>())
|
||||||
t.OnOwnerChanged(this, oldOwner, newOwner);
|
t.OnOwnerChanged(this, oldOwner, newOwner);
|
||||||
|
|||||||
Reference in New Issue
Block a user