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:
parent
3de1e8be28
commit
6fb5caf633
5 changed files with 22 additions and 9 deletions
|
@ -28,7 +28,7 @@
|
|||
*
|
||||
* Known contributors to this file:
|
||||
* Ron Koenderink, 2006-2007
|
||||
* Markus Armbruster, 2006
|
||||
* Markus Armbruster, 2006-2011
|
||||
*/
|
||||
|
||||
#ifndef UNIT_H
|
||||
|
@ -59,7 +59,7 @@ extern void unit_list(struct emp_qelem *);
|
|||
extern void unit_put(struct emp_qelem *list, natid actor);
|
||||
extern char *unit_path(int, struct empobj *, char *);
|
||||
extern void unit_view(struct emp_qelem *);
|
||||
extern void unit_update_cargo(struct empobj *);
|
||||
extern int unit_update_cargo(struct empobj *);
|
||||
extern void unit_drop_cargo(struct empobj *, natid);
|
||||
extern void unit_give_away(struct empobj *, natid, natid);
|
||||
extern void unit_wipe_orders(struct empobj *);
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Dave Pare, 1989
|
||||
* Steve McClure, 1996
|
||||
* Markus Armbruster, 2006-2008
|
||||
* Markus Armbruster, 2006-2011
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -78,9 +78,12 @@ pln_prewrite(int n, void *old, void *new)
|
|||
pln_carrier_change(pp, EF_LAND, oldpp->pln_land, pp->pln_land);
|
||||
|
||||
/* We've avoided assigning to pp->pln_own, in case oldpp == pp */
|
||||
if (oldpp->pln_own != own)
|
||||
if (oldpp->pln_own != own) {
|
||||
lost_and_found(EF_PLANE, oldpp->pln_own, own,
|
||||
pp->pln_uid, pp->pln_x, pp->pln_y);
|
||||
CANT_HAPPEN(!oldpp->pln_own
|
||||
&& unit_update_cargo((struct empobj *)oldpp));
|
||||
}
|
||||
|
||||
pp->pln_own = own;
|
||||
if (!own || pp->pln_x != oldpp->pln_x || pp->pln_y != oldpp->pln_y)
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
* Known contributors to this file:
|
||||
* Dave Pare, 1989
|
||||
* Steve McClure, 1996
|
||||
* Markus Armbruster, 2004-2008
|
||||
* Markus Armbruster, 2004-2011
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
@ -74,9 +74,12 @@ shp_prewrite(int n, void *old, void *new)
|
|||
item_prewrite(sp->shp_item);
|
||||
|
||||
/* We've avoided assigning to sp->shp_own, in case oldsp == sp */
|
||||
if (oldsp->shp_own != own)
|
||||
if (oldsp->shp_own != own) {
|
||||
lost_and_found(EF_SHIP, oldsp->shp_own, own,
|
||||
sp->shp_uid, sp->shp_x, sp->shp_y);
|
||||
CANT_HAPPEN(!oldsp->shp_own
|
||||
&& unit_update_cargo((struct empobj *)oldsp));
|
||||
}
|
||||
|
||||
sp->shp_own = own;
|
||||
if (!own || sp->shp_x != oldsp->shp_x || sp->shp_y != oldsp->shp_y)
|
||||
|
|
|
@ -243,13 +243,15 @@ unit_view(struct emp_qelem *list)
|
|||
* nukes).
|
||||
* Else update their location to the carrier's. Any op sectors equal
|
||||
* to location get updated, too.
|
||||
* Return number of units updated.
|
||||
*/
|
||||
void
|
||||
int
|
||||
unit_update_cargo(struct empobj *carrier)
|
||||
{
|
||||
int cargo_type;
|
||||
struct nstr_item ni;
|
||||
union empobj_storage obj;
|
||||
int n = 0;
|
||||
|
||||
for (cargo_type = EF_PLANE; cargo_type <= EF_NUKE; cargo_type++) {
|
||||
snxtitem_cargo(&ni, cargo_type, carrier->ef_type, carrier->uid);
|
||||
|
@ -267,8 +269,10 @@ unit_update_cargo(struct empobj *carrier)
|
|||
obj.gen.y = carrier->y;
|
||||
}
|
||||
put_empobj(cargo_type, obj.gen.uid, &obj);
|
||||
n++;
|
||||
}
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue