Skip to content

Commit

Permalink
Fix invalid actors not spawning in-game.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mailaender authored and abcdefg30 committed Dec 23, 2022
1 parent d96ec21 commit daf10c3
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions OpenRA.Mods.Common/Traits/World/SpawnMapActors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@ public void WorldLoaded(World world, WorldRenderer wr)
{
var actorReference = new ActorReference(kv.Value.Value, kv.Value.ToDictionary());

// If there is no real player associated, don't spawn it.
var ownerName = actorReference.Get<OwnerInit>().InternalName;
if (!world.Players.Any(p => p.InternalName == ownerName))
continue;
// If an actor's doesn't have a valid owner transfer ownership to neutral
var ownerInit = actorReference.Get<OwnerInit>();
if (!world.Players.Any(p => p.InternalName == ownerInit.InstanceName))
{
actorReference.Remove(ownerInit);
actorReference.Add(new OwnerInit(world.WorldActor.Owner));
}

actorReference.Add(new SkipMakeAnimsInit());
actorReference.Add(new SpawnedByMapInit(kv.Key));
Expand Down

0 comments on commit daf10c3

Please sign in to comment.