Fix update to take dead units off carriers
upd_plane() upd_land() and left planes and land units lost to lack of maintenance on their carriers. Cargo lists were fine anyway, because unit_cargo_init() ignored dead units. But when the dead unit got reused for building a new one, pln_prewrite() / lnd_prewrite() got confused and attempted to take it off its carrier, which made clink_rem() oops, because the unit wasn't on the cargo list. No real harm done, as oops recovery was fine. Fix upd_plane() and upd_land() to clear the carrier. Make unit_cargo_init() oops when it finds dead units on carriers.
This commit is contained in:
parent
627eb9bc1a
commit
c2c0d1ff77
3 changed files with 14 additions and 3 deletions
|
@ -241,24 +241,33 @@ unit_cargo_init(void)
|
||||||
unit_onresize(i);
|
unit_onresize(i);
|
||||||
|
|
||||||
for (i = 0; (pp = getplanep(i)); i++) {
|
for (i = 0; (pp = getplanep(i)); i++) {
|
||||||
if (!pp->pln_own)
|
if (!pp->pln_own) {
|
||||||
|
if (CANT_HAPPEN(pp->pln_ship >= 0 || pp->pln_land >= 0))
|
||||||
|
pp->pln_ship = pp->pln_land = -1;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (CANT_HAPPEN(pp->pln_ship >= 0 && pp->pln_land >= 0))
|
if (CANT_HAPPEN(pp->pln_ship >= 0 && pp->pln_land >= 0))
|
||||||
pp->pln_land = -1;
|
pp->pln_land = -1;
|
||||||
pln_carrier_change(pp, EF_SHIP, -1, pp->pln_ship);
|
pln_carrier_change(pp, EF_SHIP, -1, pp->pln_ship);
|
||||||
pln_carrier_change(pp, EF_LAND, -1, pp->pln_land);
|
pln_carrier_change(pp, EF_LAND, -1, pp->pln_land);
|
||||||
}
|
}
|
||||||
for (i = 0; (lp = getlandp(i)); i++) {
|
for (i = 0; (lp = getlandp(i)); i++) {
|
||||||
if (!lp->lnd_own)
|
if (!lp->lnd_own) {
|
||||||
|
if (CANT_HAPPEN(lp->lnd_ship >= 0 || lp->lnd_land >= 0))
|
||||||
|
lp->lnd_ship = lp->lnd_land = -1;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
if (CANT_HAPPEN(lp->lnd_ship >= 0 && lp->lnd_land >= 0))
|
if (CANT_HAPPEN(lp->lnd_ship >= 0 && lp->lnd_land >= 0))
|
||||||
lp->lnd_land = -1;
|
lp->lnd_land = -1;
|
||||||
lnd_carrier_change(lp, EF_SHIP, -1, lp->lnd_ship);
|
lnd_carrier_change(lp, EF_SHIP, -1, lp->lnd_ship);
|
||||||
lnd_carrier_change(lp, EF_LAND, -1, lp->lnd_land);
|
lnd_carrier_change(lp, EF_LAND, -1, lp->lnd_land);
|
||||||
}
|
}
|
||||||
for (i = 0; (np = getnukep(i)); i++) {
|
for (i = 0; (np = getnukep(i)); i++) {
|
||||||
if (!np->nuk_own)
|
if (!np->nuk_own) {
|
||||||
|
if (CANT_HAPPEN(np->nuk_plane >= 0))
|
||||||
|
np->nuk_plane = -1;
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
nuk_carrier_change(np, EF_PLANE, -1, np->nuk_plane);
|
nuk_carrier_change(np, EF_PLANE, -1, np->nuk_plane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,7 @@ upd_land(struct lndstr *lp, int etus,
|
||||||
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
|
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid,
|
||||||
lp->lnd_x, lp->lnd_y);
|
lp->lnd_x, lp->lnd_y);
|
||||||
lp->lnd_own = 0;
|
lp->lnd_own = 0;
|
||||||
|
lp->lnd_ship = lp->lnd_land = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wu(0, lp->lnd_own,
|
wu(0, lp->lnd_own,
|
||||||
|
|
|
@ -110,6 +110,7 @@ upd_plane(struct plnstr *pp, int etus,
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
makelost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
||||||
pp->pln_x, pp->pln_y);
|
pp->pln_x, pp->pln_y);
|
||||||
pp->pln_own = 0;
|
pp->pln_own = 0;
|
||||||
|
pp->pln_ship = pp->pln_land = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
wu(0, pp->pln_own,
|
wu(0, pp->pln_own,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue