From a0458eeb24082447903ecce587df6c7d7c6bbeab Mon Sep 17 00:00:00 2001 From: Squiggles211 Date: Thu, 15 May 2014 20:27:17 -0500 Subject: [PATCH] Fix crashes related to transports Fixes two specific causes of transport related crashes, one prevents infantry from continuing to take damage by Tiberium if loaded into the transport over Tiberium, and one fixes the edge case where an infantry dies in the same tick cycle as it was loaded into the transport. --- OpenRA.Mods.Cnc/PoisonedByTiberium.cs | 3 +++ OpenRA.Mods.RA/Activities/EnterTransport.cs | 10 ++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs index da238179fe..9d803af37d 100644 --- a/OpenRA.Mods.Cnc/PoisonedByTiberium.cs +++ b/OpenRA.Mods.Cnc/PoisonedByTiberium.cs @@ -32,6 +32,9 @@ namespace OpenRA.Mods.Cnc { if (--poisonTicks > 0) return; + // Prevents harming infantry in cargo. + if (!self.IsInWorld) return; + var rl = self.World.WorldActor.Trait(); var r = rl.GetResource(self.Location); if (r == null) return; diff --git a/OpenRA.Mods.RA/Activities/EnterTransport.cs b/OpenRA.Mods.RA/Activities/EnterTransport.cs index 84df9db0f1..549692e97a 100644 --- a/OpenRA.Mods.RA/Activities/EnterTransport.cs +++ b/OpenRA.Mods.RA/Activities/EnterTransport.cs @@ -41,8 +41,14 @@ namespace OpenRA.Mods.RA.Activities if (!cells.Contains(self.Location)) return NextActivity; - cargo.Load(transport, self); - self.World.AddFrameEndTask(w => w.Remove(self)); + self.World.AddFrameEndTask(w => + { + if(self.IsDead() || transport.IsDead() || !cargo.CanLoad(transport, self)) + return; + + cargo.Load(transport, self); + w.Remove(self); + }); return this; }