Oops when stuck cargo snaps to new ship, plane or land unit

When units somehow get stuck on a dead carrier, a new build reusing
the dead carrier's UID picks up its cargo.  The cargo gets teleported
to its new carrier when the carrier moves.

Oops when a ship, plane or land unit is created with cargo.  To
recover, destroy the cargo.
This commit is contained in:
Markus Armbruster 2011-07-05 21:06:40 +02:00
parent 3de1e8be28
commit 6fb5caf633
5 changed files with 22 additions and 9 deletions

View file

@ -28,7 +28,7 @@
*
* Known contributors to this file:
* Steve McClure, 1996
* Markus Armbruster, 2004-2008
* Markus Armbruster, 2004-2011
*/
#include <config.h>
@ -79,9 +79,12 @@ lnd_prewrite(int n, void *old, void *new)
lnd_carrier_change(lp, EF_LAND, oldlp->lnd_land, lp->lnd_land);
/* We've avoided assigning to lp->lnd_own, in case oldlp == lp */
if (oldlp->lnd_own != own)
if (oldlp->lnd_own != own) {
lost_and_found(EF_LAND, oldlp->lnd_own, own,
lp->lnd_uid, lp->lnd_x, lp->lnd_y);
CANT_HAPPEN(!oldlp->lnd_own
&& unit_update_cargo((struct empobj *)oldlp));
}
lp->lnd_own = own;
if (!own || lp->lnd_x != oldlp->lnd_x || lp->lnd_y != oldlp->lnd_y)