OpenRA/OpenRA — pull request #7 by hoxworth (2011-11-28 19:36:38+00:00)
Title: Fix for weird aircraft bug

This small commit fixes an odd aircraft issue I ran into during a recent game. One of the players was attacking a small ground force with a Yak. The Yak kills a V2 right before it is shot down by a rocket soldier. However, the plane gets stuck in the game world, is unplayable, and is auto-targeted by any hostile forces that go near it.

After running through the replays, the exact cause is as follows:

(1) In the first tick, the Yak destroys the V2
(2) In the very next tick, the Yak itself is killed. The `FallToEarth` kill observer queues up the `FallToEarth` activity on the `FlyAttack` activity.
(3) The `Tick` method for `FlyAttack` is called. The target is no longer valid (and in our instance, the Yak was out of ammo), so the `Cancel` method is called on the `FlyAttack` activity. This sets `NextActivity` to null, effectively canceling the crash animation for the plane.

By simply checking to see if the activity has already been canceled, this can be avoided.