fix crash with cloaking units and replays

This commit is contained in:
Chris Forbes
2011-03-06 11:34:19 +13:00
parent 020c2a8a4a
commit d7ed0233b0

View File

@@ -68,18 +68,19 @@ namespace OpenRA.Mods.RA
canCloak = (e.DamageState < DamageState.Critical);
if (Cloaked && !canCloak)
DoUncloak();
}
}
static readonly Renderable[] Nothing = { };
public IEnumerable<Renderable>
ModifyRender(Actor self, IEnumerable<Renderable> rs)
{
if (remainingTime > 0)
return rs;
if (Cloaked && IsVisible(self))
return rs.Select(a => a.WithPalette("shadow"));
else
return new Renderable[] { };
return rs;
if (Cloaked && IsVisible(self))
return rs.Select(a => a.WithPalette("shadow"));
else
return Nothing;
}
public void Tick(Actor self)
@@ -103,7 +104,7 @@ namespace OpenRA.Mods.RA
public bool IsVisible(Actor self)
{
if (!Cloaked || self.Owner == self.World.LocalPlayer || self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
if (!Cloaked || self.Owner == self.World.LocalPlayer || self.World.LocalPlayer == null || self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
return true;
return self.World.Queries.WithTrait<DetectCloaked>().Any(a => (self.Location - a.Actor.Location).Length < a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range);