*
* Known contributors to this file:
* Ron Koenderink, 2006-2007
- * Markus Armbruster, 2006
+ * Markus Armbruster, 2006-2011
*/
#ifndef UNIT_H
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 *);
*
* Known contributors to this file:
* Steve McClure, 1996
- * Markus Armbruster, 2004-2008
+ * Markus Armbruster, 2004-2011
*/
#include <config.h>
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)
* Known contributors to this file:
* Dave Pare, 1989
* Steve McClure, 1996
- * Markus Armbruster, 2006-2008
+ * Markus Armbruster, 2006-2011
*/
#include <config.h>
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)
* Known contributors to this file:
* Dave Pare, 1989
* Steve McClure, 1996
- * Markus Armbruster, 2004-2008
+ * Markus Armbruster, 2004-2011
*/
#include <config.h>
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)
* 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);
obj.gen.y = carrier->y;
}
put_empobj(cargo_type, obj.gen.uid, &obj);
+ n++;
}
}
+ return n;
}
/*