Merge pull request #13079 from pchote/fix-carryall-crash

Fix crash when carryall cargo is killed on same tick as pickup.
This commit is contained in:
Oliver Brakmann
2017-04-08 22:49:14 +02:00
committed by GitHub

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits
public virtual object Create(ActorInitializer init) { return new Carryall(init.Self, this); }
}
public class Carryall : INotifyKilled, ISync, IRender, INotifyActorDisposing, IIssueOrder, IResolveOrder, IOrderVoice
public class Carryall : INotifyKilled, ISync, ITick, IRender, INotifyActorDisposing, IIssueOrder, IResolveOrder, IOrderVoice
{
public enum CarryallState
{
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
public Carryall(Actor self, CarryallInfo info)
{
this.Info = info;
Info = info;
Carryable = null;
State = CarryallState.Idle;
@@ -79,6 +79,13 @@ namespace OpenRA.Mods.Common.Traits
facing = self.Trait<IFacing>();
}
void ITick.Tick(Actor self)
{
// Cargo may be killed in the same tick as, but after they are attached
if (Carryable != null && Carryable.IsDead)
DetachCarryable(self);
}
void INotifyActorDisposing.Disposing(Actor self)
{
if (State == CarryallState.Carrying)
@@ -156,7 +163,7 @@ namespace OpenRA.Mods.Common.Traits
IEnumerable<IRenderable> IRender.Render(Actor self, WorldRenderer wr)
{
if (State == CarryallState.Carrying)
if (State == CarryallState.Carrying && !Carryable.IsDead)
{
if (carryablePreview == null)
{