#597 fix crash when spawning mapactors if there is no player in the slot. said actors are not spawned now.

This commit is contained in:
Chris Forbes
2011-03-08 19:40:16 +13:00
parent e9a1c3f477
commit 6d36272134
3 changed files with 8 additions and 2 deletions

View File

@@ -8,7 +8,8 @@
*/
#endregion
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
@@ -22,7 +23,12 @@ namespace OpenRA.Mods.RA
public void WorldLoaded(World world)
{
foreach (var actorReference in world.Map.Actors.Value)
{
{
// if there is no real player associated, dont spawn it.
var ownerName = actorReference.Value.InitDict.Get<OwnerInit>().PlayerName;
if (!world.players.Values.Any(p => p.InternalName == ownerName))
continue;
var initDict = actorReference.Value.InitDict;
initDict.Add(new SkipMakeAnimsInit());
Actors[actorReference.Key] = world.CreateActor(actorReference.Value.Type, initDict);