Make prewrite callbacks more robust
Treat zero owner just like efficiency below minimum. Before, cargo was taken off carriers only when efficiency fell below minimum, not when owner changed to zero. Run item_prewrite() unconditionally, for simplicity.
This commit is contained in:
parent
fc42f66b4a
commit
861a66625c
4 changed files with 18 additions and 20 deletions
|
@ -63,14 +63,13 @@ lnd_prewrite(int n, void *old, void *new)
|
|||
{
|
||||
struct lndstr *oldlp = old;
|
||||
struct lndstr *lp = new;
|
||||
natid own = lp->lnd_own;
|
||||
natid own = lp->lnd_effic < LAND_MINEFF ? 0 : lp->lnd_own;
|
||||
|
||||
if (lp->lnd_own && lp->lnd_effic < LAND_MINEFF) {
|
||||
own = 0;
|
||||
if (!own) {
|
||||
lp->lnd_effic = 0;
|
||||
lp->lnd_ship = lp->lnd_land = -1;
|
||||
} else {
|
||||
item_prewrite(lp->lnd_item);
|
||||
}
|
||||
item_prewrite(lp->lnd_item);
|
||||
|
||||
if (CANT_HAPPEN(lp->lnd_ship >= 0 && lp->lnd_land >= 0))
|
||||
lp->lnd_land = -1;
|
||||
|
@ -79,7 +78,7 @@ lnd_prewrite(int n, void *old, void *new)
|
|||
if (oldlp->lnd_land != lp->lnd_land)
|
||||
lnd_carrier_change(lp, EF_LAND, oldlp->lnd_land, lp->lnd_land);
|
||||
|
||||
/* We've avoided assigning to lp->lnd_own, in case oldsp == sp */
|
||||
/* We've avoided assigning to lp->lnd_own, in case oldlp == lp */
|
||||
if (oldlp->lnd_own != own)
|
||||
lost_and_found(EF_LAND, oldlp->lnd_own, own,
|
||||
lp->lnd_uid, lp->lnd_x, lp->lnd_y);
|
||||
|
|
|
@ -60,17 +60,17 @@ nuk_prewrite(int n, void *old, void *new)
|
|||
{
|
||||
struct nukstr *oldnp = old;
|
||||
struct nukstr *np = new;
|
||||
natid own = np->nuk_own;
|
||||
natid own = np->nuk_effic == 0 ? 0 : np->nuk_own;
|
||||
|
||||
if (np->nuk_effic == 0) {
|
||||
own = 0;
|
||||
if (!own) {
|
||||
np->nuk_effic = 0;
|
||||
np->nuk_plane = -1;
|
||||
}
|
||||
|
||||
if (oldnp->nuk_plane != np->nuk_plane)
|
||||
nuk_carrier_change(np, EF_PLANE, oldnp->nuk_plane, np->nuk_plane);
|
||||
|
||||
/* We've avoided assigning to np->nuk_own, in case oldsp == sp */
|
||||
/* We've avoided assigning to np->nuk_own, in case oldnp == np */
|
||||
if (oldnp->nuk_own != own)
|
||||
lost_and_found(EF_NUKE, oldnp->nuk_own, own,
|
||||
np->nuk_uid, np->nuk_x, np->nuk_y);
|
||||
|
|
|
@ -63,10 +63,9 @@ pln_prewrite(int n, void *old, void *new)
|
|||
{
|
||||
struct plnstr *oldpp = old;
|
||||
struct plnstr *pp = new;
|
||||
natid own = pp->pln_own;
|
||||
natid own = pp->pln_effic < PLANE_MINEFF ? 0 : pp->pln_own;
|
||||
|
||||
if (pp->pln_effic < PLANE_MINEFF) {
|
||||
own = 0;
|
||||
if (!own) {
|
||||
pp->pln_effic = 0;
|
||||
pp->pln_ship = pp->pln_land = -1;
|
||||
}
|
||||
|
@ -78,7 +77,7 @@ pln_prewrite(int n, void *old, void *new)
|
|||
if (oldpp->pln_land != pp->pln_land)
|
||||
pln_carrier_change(pp, EF_LAND, oldpp->pln_land, pp->pln_land);
|
||||
|
||||
/* We've avoided assigning to pp->pln_own, in case oldsp == sp */
|
||||
/* We've avoided assigning to pp->pln_own, in case oldpp == pp */
|
||||
if (oldpp->pln_own != own)
|
||||
lost_and_found(EF_PLANE, oldpp->pln_own, own,
|
||||
pp->pln_uid, pp->pln_x, pp->pln_y);
|
||||
|
|
|
@ -64,14 +64,14 @@ shp_prewrite(int n, void *old, void *new)
|
|||
{
|
||||
struct shpstr *oldsp = old;
|
||||
struct shpstr *sp = new;
|
||||
natid own = sp->shp_own;
|
||||
natid own = sp->shp_effic < SHIP_MINEFF ? 0 : sp->shp_own;
|
||||
|
||||
if (own && sp->shp_effic < SHIP_MINEFF) {
|
||||
if (!own) {
|
||||
sp->shp_effic = 0;
|
||||
if (sp->shp_own)
|
||||
mpr(own, "\t%s sunk!\n", prship(sp));
|
||||
own = 0;
|
||||
} else {
|
||||
item_prewrite(sp->shp_item);
|
||||
}
|
||||
item_prewrite(sp->shp_item);
|
||||
|
||||
/* We've avoided assigning to sp->shp_own, in case oldsp == sp */
|
||||
if (oldsp->shp_own != own)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue