the3dfxdude/7kaa — pull request #27 by sraboy (2014-04-09 08:10:37+00:00)
Title: Resolves bug with units pathfinding to a now dead ship

Re: http://www.7kfans.com/forums/viewtopic.php?f=13&t=529.

Now that the funny DEBUG loading thing is resolved with Pull 22 can we take care of this one?

If a game is saved after a ship's hit points are set to 0, but before the sprites are destroyed or set to ACTION_DIE or SPRITE_DIE, they're loaded with the game and are not resolved. The only check done by UnitArray::assign_to_ship() is to ensure the values aren't -1 before using them for assignment. The crash happens on line 1057. The result is that the units simply move to the coast near where the ship was.
We have two options for how to handle this:

- Call stop2() which causes the units to stop in their tracks just like if you intentionally deleted a ship.
- Simply set the finalDest vars to -1 so the units will move to an area near where they should have boarded.

Personally, I'm for option 2. Realistically, 1000 years ago, these troops wouldn't know about a ship not being there until they got there. As far as the game goes, I don't want troops, who occasionally get strung out when traversing uneven ground and going around water, to just stop in their tracks and be scattered across the map.