fix crash on startup

This commit is contained in:
Chris Forbes
2011-02-28 20:35:09 +13:00
parent ced2247af8
commit c5684fcba5

View File

@@ -42,11 +42,14 @@ namespace OpenRA.Mods.RA.Air
{
/* not spawning in the air, so try to assoc. with our afld. this is a hack. */
var afld = self.World.FindUnits(self.CenterLocation, self.CenterLocation)
.FirstOrDefault( a => a.HasTrait<Reservable>() );
var res = afld.Trait<Reservable>();
if (res != null)
reservation = res.Reserve(afld, self);
.FirstOrDefault( a => a.HasTrait<Reservable>() );
if (afld != null)
{
var res = afld.Trait<Reservable>();
if (res != null)
reservation = res.Reserve(afld, self);
}
}
}
}