Update lost file from prewrite callbacks
Losses of sectors, ships, planes, land units and nukes are tracked in the lost file. To keep it current, makelost() and makenotlost() were called whenever one of these changed owners. Cumbersome and error-prone. In fact, the lost file was never perfectly accurate. Detect the ownership change in the prewrite callback and call makelost() / makenotlost() from there. Remove lost file updates from where they're no longer needed: right before a put. takeover() is a bit more involved: it doesn't put the sectors, but all callers do, except for guerrilla(). So remove the lost file update from takeover(), but add it to guerrilla(). This takes care of lost file update for all ownership changes that go through ef_write(). It can't take care of any missing updates for changes that don't go through it.
This commit is contained in:
parent
c5482e4bfb
commit
0d139ee1d1
19 changed files with 85 additions and 133 deletions
|
@ -138,10 +138,6 @@ anti(void)
|
||||||
sect.sct_item[I_MILIT] = ache;
|
sect.sct_item[I_MILIT] = ache;
|
||||||
if (sect.sct_own == sect.sct_oldown)
|
if (sect.sct_own == sect.sct_oldown)
|
||||||
sect.sct_oldown = 0;
|
sect.sct_oldown = 0;
|
||||||
makelost(EF_SECTOR, sect.sct_own, 0,
|
|
||||||
sect.sct_x, sect.sct_y);
|
|
||||||
makenotlost(EF_SECTOR, sect.sct_oldown, 0,
|
|
||||||
sect.sct_x, sect.sct_y);
|
|
||||||
sect.sct_own = sect.sct_oldown;
|
sect.sct_own = sect.sct_oldown;
|
||||||
sect.sct_off = 1; /* Turn the sector off */
|
sect.sct_off = 1; /* Turn the sector off */
|
||||||
putsect(§);
|
putsect(§);
|
||||||
|
|
|
@ -383,8 +383,6 @@ build_ship(struct sctstr *sp, struct mchrstr *mp, short *vec, int tlev)
|
||||||
|
|
||||||
if (sp->sct_pstage == PLG_INFECT)
|
if (sp->sct_pstage == PLG_INFECT)
|
||||||
ship.shp_pstage = PLG_EXPOSED;
|
ship.shp_pstage = PLG_EXPOSED;
|
||||||
makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid,
|
|
||||||
ship.shp_x, ship.shp_y);
|
|
||||||
putship(ship.shp_uid, &ship);
|
putship(ship.shp_uid, &ship);
|
||||||
pr("%s", prship(&ship));
|
pr("%s", prship(&ship));
|
||||||
pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
|
pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||||
|
@ -507,8 +505,6 @@ build_land(struct sctstr *sp, struct lchrstr *lp, short *vec, int tlev)
|
||||||
if (sp->sct_pstage == PLG_INFECT)
|
if (sp->sct_pstage == PLG_INFECT)
|
||||||
land.lnd_pstage = PLG_EXPOSED;
|
land.lnd_pstage = PLG_EXPOSED;
|
||||||
putland(nstr.cur, &land);
|
putland(nstr.cur, &land);
|
||||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
pr("%s", prland(&land));
|
pr("%s", prland(&land));
|
||||||
pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
|
pr(" built in sector %s\n", xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -693,8 +689,6 @@ build_nuke(struct sctstr *sp, struct nchrstr *np, short *vec, int tlev)
|
||||||
vec[I_OIL] -= np->n_oil;
|
vec[I_OIL] -= np->n_oil;
|
||||||
vec[I_RAD] -= np->n_rad;
|
vec[I_RAD] -= np->n_rad;
|
||||||
|
|
||||||
makenotlost(EF_NUKE, nuke.nuk_own, nuke.nuk_uid,
|
|
||||||
nuke.nuk_x, nuke.nuk_y);
|
|
||||||
putnuke(nuke.nuk_uid, &nuke);
|
putnuke(nuke.nuk_uid, &nuke);
|
||||||
pr("%s created in %s\n", prnuke(&nuke),
|
pr("%s created in %s\n", prnuke(&nuke),
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||||
|
@ -793,8 +787,6 @@ build_plane(struct sctstr *sp, struct plchrstr *pp, short *vec, int tlev)
|
||||||
vec[I_HCM] -= hcm;
|
vec[I_HCM] -= hcm;
|
||||||
vec[I_MILIT] -= mil;
|
vec[I_MILIT] -= mil;
|
||||||
|
|
||||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
|
||||||
plane.pln_x, plane.pln_y);
|
|
||||||
putplane(plane.pln_uid, &plane);
|
putplane(plane.pln_uid, &plane);
|
||||||
pr("%s built in sector %s\n", prplane(&plane),
|
pr("%s built in sector %s\n", prplane(&plane),
|
||||||
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
xyas(sp->sct_x, sp->sct_y, player->cnum));
|
||||||
|
|
|
@ -229,10 +229,7 @@ grab_sect(struct sctstr *sp, natid to)
|
||||||
|
|
||||||
wu(0, to, "\t%s ceded to you by %s\n",
|
wu(0, to, "\t%s ceded to you by %s\n",
|
||||||
prplane(pp), cname(player->cnum));
|
prplane(pp), cname(player->cnum));
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_own = to;
|
pp->pln_own = to;
|
||||||
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
|
||||||
pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_mobil = 0;
|
pp->pln_mobil = 0;
|
||||||
pp->pln_mission = 0;
|
pp->pln_mission = 0;
|
||||||
putplane(pp->pln_uid, pp);
|
putplane(pp->pln_uid, pp);
|
||||||
|
@ -246,10 +243,7 @@ grab_sect(struct sctstr *sp, natid to)
|
||||||
|
|
||||||
wu(0, to, "\t%s ceded to you by %s\n",
|
wu(0, to, "\t%s ceded to you by %s\n",
|
||||||
prnuke(np), cname(player->cnum));
|
prnuke(np), cname(player->cnum));
|
||||||
makelost(EF_NUKE, np->nuk_own, np->nuk_uid, np->nuk_x, np->nuk_y);
|
|
||||||
np->nuk_own = to;
|
np->nuk_own = to;
|
||||||
makenotlost(EF_NUKE, np->nuk_own, np->nuk_uid,
|
|
||||||
np->nuk_x, np->nuk_y);
|
|
||||||
putnuke(ni.cur, np);
|
putnuke(ni.cur, np);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,8 +259,6 @@ grab_sect(struct sctstr *sp, natid to)
|
||||||
|
|
||||||
wu(0, to, "\t%s ceded to you by %s\n",
|
wu(0, to, "\t%s ceded to you by %s\n",
|
||||||
prland(lp), cname(player->cnum));
|
prland(lp), cname(player->cnum));
|
||||||
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
|
|
||||||
makenotlost(EF_LAND, to, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
|
|
||||||
lp->lnd_own = to;
|
lp->lnd_own = to;
|
||||||
lp->lnd_mobil = 0;
|
lp->lnd_mobil = 0;
|
||||||
lp->lnd_mission = 0;
|
lp->lnd_mission = 0;
|
||||||
|
@ -288,8 +280,6 @@ grab_sect(struct sctstr *sp, natid to)
|
||||||
|
|
||||||
sp->sct_dist_x = sp->sct_x;
|
sp->sct_dist_x = sp->sct_x;
|
||||||
sp->sct_dist_y = sp->sct_y;
|
sp->sct_dist_y = sp->sct_y;
|
||||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
|
||||||
makenotlost(EF_SECTOR, to, 0, sp->sct_x, sp->sct_y);
|
|
||||||
if (sp->sct_oldown == sp->sct_own)
|
if (sp->sct_oldown == sp->sct_own)
|
||||||
sp->sct_oldown = to;
|
sp->sct_oldown = to;
|
||||||
sp->sct_own = to;
|
sp->sct_own = to;
|
||||||
|
@ -358,10 +348,7 @@ grab_ship(struct shpstr *sp, natid to)
|
||||||
|
|
||||||
wu(0, to, "\t%s ceded to you by %s\n",
|
wu(0, to, "\t%s ceded to you by %s\n",
|
||||||
prplane(pp), cname(player->cnum));
|
prplane(pp), cname(player->cnum));
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_own = to;
|
pp->pln_own = to;
|
||||||
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
|
||||||
pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_mobil = 0;
|
pp->pln_mobil = 0;
|
||||||
pp->pln_mission = 0;
|
pp->pln_mission = 0;
|
||||||
putplane(pp->pln_uid, pp);
|
putplane(pp->pln_uid, pp);
|
||||||
|
@ -379,15 +366,11 @@ grab_ship(struct shpstr *sp, natid to)
|
||||||
|
|
||||||
wu(0, to, "\t%s ceded to you by %s\n",
|
wu(0, to, "\t%s ceded to you by %s\n",
|
||||||
prland(lp), cname(player->cnum));
|
prland(lp), cname(player->cnum));
|
||||||
makelost(EF_LAND, lp->lnd_own, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
|
|
||||||
makenotlost(EF_LAND, to, lp->lnd_uid, lp->lnd_x, lp->lnd_y);
|
|
||||||
lp->lnd_own = to;
|
lp->lnd_own = to;
|
||||||
lp->lnd_mobil = 0;
|
lp->lnd_mobil = 0;
|
||||||
lp->lnd_mission = 0;
|
lp->lnd_mission = 0;
|
||||||
putland(ni.cur, lp);
|
putland(ni.cur, lp);
|
||||||
}
|
}
|
||||||
|
|
||||||
makelost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
|
|
||||||
sp->shp_own = to;
|
sp->shp_own = to;
|
||||||
makenotlost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,8 +112,6 @@ coll(void)
|
||||||
* Used to call takeover() here a long time ago, but that does
|
* Used to call takeover() here a long time ago, but that does
|
||||||
* unwanted things, like generate che.
|
* unwanted things, like generate che.
|
||||||
*/
|
*/
|
||||||
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
|
|
||||||
makenotlost(EF_SECTOR, player->cnum, 0, sect.sct_x, sect.sct_y);
|
|
||||||
sect.sct_own = player->cnum;
|
sect.sct_own = player->cnum;
|
||||||
|
|
||||||
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
memset(sect.sct_dist, 0, sizeof(sect.sct_dist));
|
||||||
|
|
|
@ -462,8 +462,6 @@ doland(char op, int arg, char *p, struct sctstr *sect)
|
||||||
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
xyas(sect->sct_x, sect->sct_y, player->cnum),
|
||||||
cname(sect->sct_own), sect->sct_own, cname(newown), newown);
|
cname(sect->sct_own), sect->sct_own, cname(newown), newown);
|
||||||
if (sect->sct_own) {
|
if (sect->sct_own) {
|
||||||
makelost(EF_SECTOR, sect->sct_own, 0,
|
|
||||||
sect->sct_x, sect->sct_y);
|
|
||||||
wu(player->cnum, sect->sct_own,
|
wu(player->cnum, sect->sct_own,
|
||||||
"Sector %s lost to deity intervention\n",
|
"Sector %s lost to deity intervention\n",
|
||||||
xyas(sect->sct_x, sect->sct_y, sect->sct_own));
|
xyas(sect->sct_x, sect->sct_y, sect->sct_own));
|
||||||
|
@ -471,7 +469,6 @@ doland(char op, int arg, char *p, struct sctstr *sect)
|
||||||
benefit(sect->sct_own, 0);
|
benefit(sect->sct_own, 0);
|
||||||
sect->sct_own = newown;
|
sect->sct_own = newown;
|
||||||
if (newown) {
|
if (newown) {
|
||||||
makenotlost(EF_SECTOR, newown, 0, sect->sct_x, sect->sct_y);
|
|
||||||
wu(player->cnum, newown,
|
wu(player->cnum, newown,
|
||||||
"Sector %s gained from deity intervention\n",
|
"Sector %s gained from deity intervention\n",
|
||||||
xyas(sect->sct_x, sect->sct_y, sect->sct_own));
|
xyas(sect->sct_x, sect->sct_y, sect->sct_own));
|
||||||
|
@ -777,11 +774,7 @@ doship(char op, int arg, char *p, struct shpstr *ship)
|
||||||
if (arg && arg < MAXNOC) {
|
if (arg && arg < MAXNOC) {
|
||||||
wu(player->cnum, (natid)arg,
|
wu(player->cnum, (natid)arg,
|
||||||
"%s given to you by deity intervention!\n", prship(ship));
|
"%s given to you by deity intervention!\n", prship(ship));
|
||||||
makelost(EF_SHIP, ship->shp_own, ship->shp_uid,
|
|
||||||
ship->shp_x, ship->shp_y);
|
|
||||||
ship->shp_own = (natid)arg;
|
ship->shp_own = (natid)arg;
|
||||||
makenotlost(EF_SHIP, ship->shp_own, ship->shp_uid,
|
|
||||||
ship->shp_x, ship->shp_y);
|
|
||||||
} else if (!arg)
|
} else if (!arg)
|
||||||
ship->shp_effic = 0;
|
ship->shp_effic = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -882,11 +875,7 @@ dounit(char op, int arg, char *p, struct lndstr *land)
|
||||||
if (arg && arg < MAXNOC) {
|
if (arg && arg < MAXNOC) {
|
||||||
wu(player->cnum, (natid)arg,
|
wu(player->cnum, (natid)arg,
|
||||||
"%s given to you by deity intervention!\n", prland(land));
|
"%s given to you by deity intervention!\n", prland(land));
|
||||||
makelost(EF_LAND, land->lnd_own, land->lnd_uid,
|
|
||||||
land->lnd_x, land->lnd_y);
|
|
||||||
land->lnd_own = (natid)arg;
|
land->lnd_own = (natid)arg;
|
||||||
makenotlost(EF_LAND, land->lnd_own, land->lnd_uid,
|
|
||||||
land->lnd_x, land->lnd_y);
|
|
||||||
} else if (!arg)
|
} else if (!arg)
|
||||||
land->lnd_effic = 0;
|
land->lnd_effic = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -1009,11 +998,7 @@ doplane(char op, int arg, char *p, struct plnstr *plane)
|
||||||
"%s taken from you by deity intervention!\n",
|
"%s taken from you by deity intervention!\n",
|
||||||
prplane(plane));
|
prplane(plane));
|
||||||
if (arg && arg < MAXNOC) {
|
if (arg && arg < MAXNOC) {
|
||||||
makelost(EF_PLANE, plane->pln_own, plane->pln_uid,
|
|
||||||
plane->pln_x, plane->pln_y);
|
|
||||||
plane->pln_own = (natid)arg;
|
plane->pln_own = (natid)arg;
|
||||||
makenotlost(EF_PLANE, plane->pln_own, plane->pln_uid,
|
|
||||||
plane->pln_x, plane->pln_y);
|
|
||||||
wu(player->cnum, plane->pln_own,
|
wu(player->cnum, plane->pln_own,
|
||||||
"%s given to you by deity intervention!\n", prplane(plane));
|
"%s given to you by deity intervention!\n", prplane(plane));
|
||||||
} else if (!arg)
|
} else if (!arg)
|
||||||
|
|
|
@ -316,10 +316,7 @@ gift(natid givee, natid giver, void *ptr, char *mesg)
|
||||||
|
|
||||||
if (giver != givee)
|
if (giver != givee)
|
||||||
wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(gen), mesg);
|
wu(0, givee, "%s %s %s\n", cname(giver), obj_nameof(gen), mesg);
|
||||||
|
|
||||||
makelost(gen->ef_type, gen->own, gen->uid, gen->x, gen->y);
|
|
||||||
gen->own = givee;
|
gen->own = givee;
|
||||||
makenotlost(gen->ef_type, gen->own, gen->uid, gen->x, gen->y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
|
@ -196,11 +196,7 @@ scra(void)
|
||||||
"%s given to you by %s\n", prplane(&plane),
|
"%s given to you by %s\n", prplane(&plane),
|
||||||
cname(player->cnum));
|
cname(player->cnum));
|
||||||
}
|
}
|
||||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
|
||||||
plane.pln_x, plane.pln_y);
|
|
||||||
plane.pln_own = sect2.sct_own;
|
plane.pln_own = sect2.sct_own;
|
||||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
|
||||||
plane.pln_x, plane.pln_y);
|
|
||||||
putplane(plane.pln_uid, &plane);
|
putplane(plane.pln_uid, &plane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -222,11 +218,7 @@ scra(void)
|
||||||
"%s given to you by %s\n", prland(&land),
|
"%s given to you by %s\n", prland(&land),
|
||||||
cname(player->cnum));
|
cname(player->cnum));
|
||||||
}
|
}
|
||||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
land.lnd_own = sect2.sct_own;
|
land.lnd_own = sect2.sct_own;
|
||||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,11 +253,7 @@ scra(void)
|
||||||
"%s given to you by %s\n", prland(&land),
|
"%s given to you by %s\n", prland(&land),
|
||||||
cname(player->cnum));
|
cname(player->cnum));
|
||||||
}
|
}
|
||||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
land.lnd_own = sect2.sct_own;
|
land.lnd_own = sect2.sct_own;
|
||||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
putland(land.lnd_uid, &land);
|
putland(land.lnd_uid, &land);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -288,11 +276,7 @@ scra(void)
|
||||||
"%s given to you by %s\n", prplane(&plane),
|
"%s given to you by %s\n", prplane(&plane),
|
||||||
cname(player->cnum));
|
cname(player->cnum));
|
||||||
}
|
}
|
||||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
|
||||||
plane.pln_x, plane.pln_y);
|
|
||||||
plane.pln_own = sect2.sct_own;
|
plane.pln_own = sect2.sct_own;
|
||||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
|
||||||
plane.pln_x, plane.pln_y);
|
|
||||||
putplane(plane.pln_uid, &plane);
|
putplane(plane.pln_uid, &plane);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -149,9 +149,6 @@ setsector(void)
|
||||||
wu(player->cnum, amt,
|
wu(player->cnum, amt,
|
||||||
"Sector %s gained from deity intervention\n",
|
"Sector %s gained from deity intervention\n",
|
||||||
xyas(sect.sct_x, sect.sct_y, amt));
|
xyas(sect.sct_x, sect.sct_y, amt));
|
||||||
makelost(EF_SECTOR, sect.sct_own, 0,
|
|
||||||
sect.sct_x, sect.sct_y);
|
|
||||||
makenotlost(EF_SECTOR, amt, 0, sect.sct_x, sect.sct_y);
|
|
||||||
sect.sct_own = (natid)amt;
|
sect.sct_own = (natid)amt;
|
||||||
putsect(§);
|
putsect(§);
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,22 +352,14 @@ check_trade(void)
|
||||||
case EF_NUKE:
|
case EF_NUKE:
|
||||||
tg.nuke.nuk_x = trade.trd_x;
|
tg.nuke.nuk_x = trade.trd_x;
|
||||||
tg.nuke.nuk_y = trade.trd_y;
|
tg.nuke.nuk_y = trade.trd_y;
|
||||||
makelost(EF_NUKE, tg.nuke.nuk_own, tg.nuke.nuk_uid,
|
|
||||||
tg.nuke.nuk_x, tg.nuke.nuk_y);
|
|
||||||
tg.nuke.nuk_own = trade.trd_maxbidder;
|
tg.nuke.nuk_own = trade.trd_maxbidder;
|
||||||
makenotlost(EF_NUKE, tg.nuke.nuk_own, tg.nuke.nuk_uid,
|
|
||||||
tg.nuke.nuk_x, tg.nuke.nuk_y);
|
|
||||||
break;
|
break;
|
||||||
case EF_PLANE:
|
case EF_PLANE:
|
||||||
if (!pln_is_in_orbit(&tg.plane)) {
|
if (!pln_is_in_orbit(&tg.plane)) {
|
||||||
tg.plane.pln_x = trade.trd_x;
|
tg.plane.pln_x = trade.trd_x;
|
||||||
tg.plane.pln_y = trade.trd_y;
|
tg.plane.pln_y = trade.trd_y;
|
||||||
}
|
}
|
||||||
makelost(EF_PLANE, tg.plane.pln_own, tg.plane.pln_uid,
|
|
||||||
tg.plane.pln_x, tg.plane.pln_y);
|
|
||||||
tg.plane.pln_own = trade.trd_maxbidder;
|
tg.plane.pln_own = trade.trd_maxbidder;
|
||||||
makenotlost(EF_PLANE, tg.plane.pln_own, tg.plane.pln_uid,
|
|
||||||
tg.plane.pln_x, tg.plane.pln_y);
|
|
||||||
tg.plane.pln_wing = 0;
|
tg.plane.pln_wing = 0;
|
||||||
/* no cheap version of fly */
|
/* no cheap version of fly */
|
||||||
if (opt_MOB_ACCESS) {
|
if (opt_MOB_ACCESS) {
|
||||||
|
@ -393,11 +385,7 @@ check_trade(void)
|
||||||
ship.shp_nland--;
|
ship.shp_nland--;
|
||||||
putship(ship.shp_uid, &ship);
|
putship(ship.shp_uid, &ship);
|
||||||
}
|
}
|
||||||
makelost(EF_LAND, tg.land.lnd_own, tg.land.lnd_uid,
|
|
||||||
tg.land.lnd_x, tg.land.lnd_y);
|
|
||||||
tg.land.lnd_own = trade.trd_maxbidder;
|
tg.land.lnd_own = trade.trd_maxbidder;
|
||||||
makenotlost(EF_LAND, tg.land.lnd_own, tg.land.lnd_uid,
|
|
||||||
tg.land.lnd_x, tg.land.lnd_y);
|
|
||||||
tg.land.lnd_army = 0;
|
tg.land.lnd_army = 0;
|
||||||
/* no cheap version of fly */
|
/* no cheap version of fly */
|
||||||
if (opt_MOB_ACCESS) {
|
if (opt_MOB_ACCESS) {
|
||||||
|
|
|
@ -361,8 +361,6 @@ put_combat(struct combat *com)
|
||||||
sect.sct_mobil = (short)(com->mob - com->mobcost);
|
sect.sct_mobil = (short)(com->mob - com->mobcost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
|
|
||||||
makenotlost(EF_SECTOR, com->own, 0, sect.sct_x, sect.sct_y);
|
|
||||||
sect.sct_own = com->own;
|
sect.sct_own = com->own;
|
||||||
if (com->plague) {
|
if (com->plague) {
|
||||||
if (sect.sct_pstage == PLG_HEALTHY)
|
if (sect.sct_pstage == PLG_HEALTHY)
|
||||||
|
@ -381,11 +379,7 @@ put_combat(struct combat *com)
|
||||||
else
|
else
|
||||||
land.lnd_mobil = (signed char)(com->mob - com->mobcost);
|
land.lnd_mobil = (signed char)(com->mob - com->mobcost);
|
||||||
}
|
}
|
||||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
land.lnd_own = com->own;
|
land.lnd_own = com->own;
|
||||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
|
||||||
land.lnd_x, land.lnd_y);
|
|
||||||
if (com->plague) {
|
if (com->plague) {
|
||||||
if (land.lnd_pstage == PLG_HEALTHY)
|
if (land.lnd_pstage == PLG_HEALTHY)
|
||||||
land.lnd_pstage = PLG_EXPOSED;
|
land.lnd_pstage = PLG_EXPOSED;
|
||||||
|
@ -409,11 +403,7 @@ put_combat(struct combat *com)
|
||||||
else
|
else
|
||||||
ship.shp_mobil = (signed char)(com->mob - com->mobcost);
|
ship.shp_mobil = (signed char)(com->mob - com->mobcost);
|
||||||
}
|
}
|
||||||
makelost(EF_SHIP, ship.shp_own, ship.shp_uid,
|
|
||||||
ship.shp_x, ship.shp_y);
|
|
||||||
ship.shp_own = com->own;
|
ship.shp_own = com->own;
|
||||||
makenotlost(EF_SHIP, ship.shp_own, ship.shp_uid,
|
|
||||||
ship.shp_x, ship.shp_y);
|
|
||||||
if (com->plague) {
|
if (com->plague) {
|
||||||
if (ship.shp_pstage == PLG_HEALTHY)
|
if (ship.shp_pstage == PLG_HEALTHY)
|
||||||
ship.shp_pstage = PLG_EXPOSED;
|
ship.shp_pstage = PLG_EXPOSED;
|
||||||
|
|
|
@ -134,7 +134,6 @@ knockdown(struct sctstr *sp)
|
||||||
xyas(sp->sct_x, sp->sct_y, sp->sct_own));
|
xyas(sp->sct_x, sp->sct_y, sp->sct_own));
|
||||||
sp->sct_type = SCT_WATER;
|
sp->sct_type = SCT_WATER;
|
||||||
sp->sct_newtype = SCT_WATER;
|
sp->sct_newtype = SCT_WATER;
|
||||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
|
||||||
sp->sct_own = 0;
|
sp->sct_own = 0;
|
||||||
sp->sct_oldown = 0;
|
sp->sct_oldown = 0;
|
||||||
sp->sct_mobil = 0;
|
sp->sct_mobil = 0;
|
||||||
|
|
|
@ -116,7 +116,6 @@ detonate(struct nukstr *np, coord x, coord y, int airburst)
|
||||||
sect.sct_fallout = MIN(fallout, FALLOUT_MAX);
|
sect.sct_fallout = MIN(fallout, FALLOUT_MAX);
|
||||||
}
|
}
|
||||||
if (damage > 100) {
|
if (damage > 100) {
|
||||||
makelost(EF_SECTOR, sect.sct_own, 0, sect.sct_x, sect.sct_y);
|
|
||||||
sect.sct_oldown = 0;
|
sect.sct_oldown = 0;
|
||||||
sect.sct_own = 0;
|
sect.sct_own = 0;
|
||||||
if (type == SCT_WATER || type == SCT_BSPAN ||
|
if (type == SCT_WATER || type == SCT_BSPAN ||
|
||||||
|
|
|
@ -111,15 +111,15 @@ lnd_postread(int n, void *ptr)
|
||||||
void
|
void
|
||||||
lnd_prewrite(int n, void *old, void *new)
|
lnd_prewrite(int n, void *old, void *new)
|
||||||
{
|
{
|
||||||
|
struct lndstr *oldlp = old;
|
||||||
struct lndstr *llp = new;
|
struct lndstr *llp = new;
|
||||||
|
natid own = llp->lnd_own;
|
||||||
struct lndstr *lp;
|
struct lndstr *lp;
|
||||||
struct plnstr *pp;
|
struct plnstr *pp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (llp->lnd_own && llp->lnd_effic < LAND_MINEFF) {
|
if (llp->lnd_own && llp->lnd_effic < LAND_MINEFF) {
|
||||||
makelost(EF_LAND, llp->lnd_own, llp->lnd_uid,
|
own = 0;
|
||||||
llp->lnd_x, llp->lnd_y);
|
|
||||||
llp->lnd_own = 0;
|
|
||||||
|
|
||||||
for (i = 0; NULL != (lp = getlandp(i)); i++) {
|
for (i = 0; NULL != (lp = getlandp(i)); i++) {
|
||||||
if (lp->lnd_own && lp->lnd_land == n) {
|
if (lp->lnd_own && lp->lnd_land == n) {
|
||||||
|
@ -149,6 +149,17 @@ lnd_prewrite(int n, void *old, void *new)
|
||||||
item_prewrite(llp->lnd_item);
|
item_prewrite(llp->lnd_item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We've avoided assigning to llp->lnd_own, in case oldsp == sp */
|
||||||
|
if (oldlp->lnd_own != own) {
|
||||||
|
if (oldlp->lnd_own)
|
||||||
|
makelost(EF_LAND, oldlp->lnd_own,
|
||||||
|
llp->lnd_uid, llp->lnd_x, llp->lnd_y);
|
||||||
|
if (own)
|
||||||
|
makenotlost(EF_LAND, own,
|
||||||
|
llp->lnd_uid, llp->lnd_x, llp->lnd_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
llp->lnd_own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
|
@ -76,15 +76,24 @@ nuk_postread(int n, void *ptr)
|
||||||
void
|
void
|
||||||
nuk_prewrite(int n, void *old, void *new)
|
nuk_prewrite(int n, void *old, void *new)
|
||||||
{
|
{
|
||||||
|
struct nukstr *oldnp = old;
|
||||||
struct nukstr *np = new;
|
struct nukstr *np = new;
|
||||||
|
natid own = np->nuk_own;
|
||||||
|
|
||||||
if (np->nuk_effic == 0) {
|
if (np->nuk_effic == 0)
|
||||||
if (np->nuk_own)
|
own = 0;
|
||||||
makelost(EF_NUKE, np->nuk_own, np->nuk_uid,
|
|
||||||
np->nuk_x, np->nuk_y);
|
/* We've avoided assigning to np->nuk_own, in case oldsp == sp */
|
||||||
np->nuk_own = 0;
|
if (oldnp->nuk_own != own) {
|
||||||
np->nuk_effic = 0;
|
if (oldnp->nuk_own)
|
||||||
|
makelost(EF_NUKE, oldnp->nuk_own,
|
||||||
|
np->nuk_uid, np->nuk_x, np->nuk_y);
|
||||||
|
if (own)
|
||||||
|
makenotlost(EF_NUKE, own,
|
||||||
|
np->nuk_uid, np->nuk_x, np->nuk_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
np->nuk_own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
|
@ -110,15 +110,14 @@ pln_postread(int n, void *ptr)
|
||||||
void
|
void
|
||||||
pln_prewrite(int n, void *old, void *new)
|
pln_prewrite(int n, void *old, void *new)
|
||||||
{
|
{
|
||||||
|
struct plnstr *oldpp = old;
|
||||||
struct plnstr *pp = new;
|
struct plnstr *pp = new;
|
||||||
|
natid own = pp->pln_own;
|
||||||
struct nukstr *np;
|
struct nukstr *np;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (pp->pln_effic < PLANE_MINEFF) {
|
if (pp->pln_effic < PLANE_MINEFF) {
|
||||||
if (pp->pln_own)
|
own = 0;
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
|
||||||
pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_own = 0;
|
|
||||||
pp->pln_effic = 0;
|
pp->pln_effic = 0;
|
||||||
for (i = 0; NULL != (np = getnukep(i)); i++) {
|
for (i = 0; NULL != (np = getnukep(i)); i++) {
|
||||||
if (np->nuk_own && np->nuk_plane == n) {
|
if (np->nuk_own && np->nuk_plane == n) {
|
||||||
|
@ -129,6 +128,18 @@ pln_prewrite(int n, void *old, void *new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We've avoided assigning to pp->pln_own, in case oldsp == sp */
|
||||||
|
if (oldpp->pln_own != own) {
|
||||||
|
if (oldpp->pln_own)
|
||||||
|
makelost(EF_PLANE, oldpp->pln_own,
|
||||||
|
pp->pln_uid, pp->pln_x, pp->pln_y);
|
||||||
|
if (own)
|
||||||
|
makenotlost(EF_PLANE, own,
|
||||||
|
pp->pln_uid, pp->pln_x, pp->pln_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
pp->pln_own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
|
@ -61,6 +61,7 @@ sct_postread(int id, void *ptr)
|
||||||
void
|
void
|
||||||
sct_prewrite(int id, void *old, void *new)
|
sct_prewrite(int id, void *old, void *new)
|
||||||
{
|
{
|
||||||
|
struct sctstr *oldsp = old;
|
||||||
struct sctstr *sp = new;
|
struct sctstr *sp = new;
|
||||||
int mil, civs;
|
int mil, civs;
|
||||||
natid own;
|
natid own;
|
||||||
|
@ -70,23 +71,33 @@ sct_prewrite(int id, void *old, void *new)
|
||||||
|
|
||||||
mil = sp->sct_item[I_MILIT];
|
mil = sp->sct_item[I_MILIT];
|
||||||
civs = sp->sct_item[I_CIVIL];
|
civs = sp->sct_item[I_CIVIL];
|
||||||
|
own = sp->sct_own;
|
||||||
|
|
||||||
if (sp->sct_own != 0 && !civs) {
|
if (own && !civs) {
|
||||||
sp->sct_work = 100;
|
sp->sct_work = 100;
|
||||||
sp->sct_oldown = sp->sct_own;
|
sp->sct_oldown = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sp->sct_own && !civs && !mil
|
if (own && !civs && !mil && !has_units(sp->sct_x, sp->sct_y, own, NULL)
|
||||||
&& !has_units(sp->sct_x, sp->sct_y, sp->sct_own, NULL)
|
|
||||||
&& !(sp->sct_flags & MOVE_IN_PROGRESS)) {
|
&& !(sp->sct_flags & MOVE_IN_PROGRESS)) {
|
||||||
/* more cruft! */
|
/* more cruft! */
|
||||||
own = sp->sct_own;
|
own = 0;
|
||||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
|
||||||
sp->sct_own = 0;
|
|
||||||
sp->sct_mobil = 0;
|
sp->sct_mobil = 0;
|
||||||
if (sp->sct_type == SCT_CAPIT || sp->sct_type == SCT_MOUNT)
|
if (sp->sct_type == SCT_CAPIT || sp->sct_type == SCT_MOUNT)
|
||||||
caploss(sp, own, "");
|
caploss(sp, own, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We've avoided assigning to sp->sct_own, in case oldsp == sp */
|
||||||
|
if (oldsp->sct_own != own) {
|
||||||
|
if (oldsp->sct_own)
|
||||||
|
makelost(EF_SECTOR, oldsp->sct_own,
|
||||||
|
0, sp->sct_x, sp->sct_y);
|
||||||
|
if (own)
|
||||||
|
makenotlost(EF_SECTOR, own,
|
||||||
|
0, sp->sct_x, sp->sct_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
sp->sct_own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -64,15 +64,16 @@ shp_postread(int n, void *ptr)
|
||||||
void
|
void
|
||||||
shp_prewrite(int n, void *old, void *new)
|
shp_prewrite(int n, void *old, void *new)
|
||||||
{
|
{
|
||||||
|
struct shpstr *oldsp = old;
|
||||||
struct shpstr *sp = new;
|
struct shpstr *sp = new;
|
||||||
|
natid own = sp->shp_own;
|
||||||
struct lndstr *lp;
|
struct lndstr *lp;
|
||||||
struct plnstr *pp;
|
struct plnstr *pp;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (sp->shp_own != 0 && sp->shp_effic < SHIP_MINEFF) {
|
if (own && sp->shp_effic < SHIP_MINEFF) {
|
||||||
mpr(sp->shp_own, "\t%s sunk!\n", prship(sp));
|
mpr(own, "\t%s sunk!\n", prship(sp));
|
||||||
makelost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
|
own = 0;
|
||||||
sp->shp_own = 0;
|
|
||||||
|
|
||||||
for (i = 0; NULL != (lp = getlandp(i)); i++) {
|
for (i = 0; NULL != (lp = getlandp(i)); i++) {
|
||||||
if (lp->lnd_own && lp->lnd_ship == n) {
|
if (lp->lnd_own && lp->lnd_ship == n) {
|
||||||
|
@ -95,6 +96,18 @@ shp_prewrite(int n, void *old, void *new)
|
||||||
} else {
|
} 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) {
|
||||||
|
if (oldsp->shp_own)
|
||||||
|
makelost(EF_SHIP, oldsp->shp_own,
|
||||||
|
sp->shp_uid, sp->shp_x, sp->shp_y);
|
||||||
|
if (own)
|
||||||
|
makenotlost(EF_SHIP, own,
|
||||||
|
sp->shp_uid, sp->shp_x, sp->shp_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
sp->shp_own = own;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
|
|
@ -158,8 +158,6 @@ takeover(struct sctstr *sp, natid newown)
|
||||||
*/
|
*/
|
||||||
sp->sct_loyal = 50;
|
sp->sct_loyal = 50;
|
||||||
}
|
}
|
||||||
makelost(EF_SECTOR, sp->sct_own, 0, sp->sct_x, sp->sct_y);
|
|
||||||
makenotlost(EF_SECTOR, newown, 0, sp->sct_x, sp->sct_y);
|
|
||||||
sp->sct_own = newown;
|
sp->sct_own = newown;
|
||||||
if (opt_MOB_ACCESS) {
|
if (opt_MOB_ACCESS) {
|
||||||
game_tick_to_now(&sp->sct_access);
|
game_tick_to_now(&sp->sct_access);
|
||||||
|
@ -206,9 +204,7 @@ takeover_plane(struct plnstr *pp, natid newown)
|
||||||
trdswitchown(EF_PLANE, pp, newown);
|
trdswitchown(EF_PLANE, pp, newown);
|
||||||
if (pp->pln_mobil > 0)
|
if (pp->pln_mobil > 0)
|
||||||
pp->pln_mobil = 0;
|
pp->pln_mobil = 0;
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_own = newown;
|
pp->pln_own = newown;
|
||||||
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_mission = 0;
|
pp->pln_mission = 0;
|
||||||
pp->pln_wing = 0;
|
pp->pln_wing = 0;
|
||||||
putplane(pp->pln_uid, pp);
|
putplane(pp->pln_uid, pp);
|
||||||
|
@ -225,9 +221,7 @@ takeover_ship(struct shpstr *sp, natid newown, int hostile)
|
||||||
|
|
||||||
if (opt_MARKET)
|
if (opt_MARKET)
|
||||||
trdswitchown(EF_SHIP, sp, newown);
|
trdswitchown(EF_SHIP, sp, newown);
|
||||||
makelost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
|
|
||||||
sp->shp_own = newown;
|
sp->shp_own = newown;
|
||||||
makenotlost(EF_SHIP, sp->shp_own, sp->shp_uid, sp->shp_x, sp->shp_y);
|
|
||||||
sp->shp_mission = 0;
|
sp->shp_mission = 0;
|
||||||
sp->shp_fleet = 0;
|
sp->shp_fleet = 0;
|
||||||
sp->shp_rflags = 0;
|
sp->shp_rflags = 0;
|
||||||
|
@ -251,10 +245,7 @@ takeover_ship(struct shpstr *sp, natid newown, int hostile)
|
||||||
if (opt_MARKET)
|
if (opt_MARKET)
|
||||||
trdswitchown(EF_PLANE, pp, newown);
|
trdswitchown(EF_PLANE, pp, newown);
|
||||||
pp->pln_mission = 0;
|
pp->pln_mission = 0;
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_own = newown;
|
pp->pln_own = newown;
|
||||||
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
|
||||||
pp->pln_x, pp->pln_y);
|
|
||||||
putplane(pp->pln_uid, pp);
|
putplane(pp->pln_uid, pp);
|
||||||
}
|
}
|
||||||
/* Take over land units */
|
/* Take over land units */
|
||||||
|
@ -290,11 +281,7 @@ takeover_land(struct lndstr *landp, natid newown, int hostile)
|
||||||
if (opt_MARKET)
|
if (opt_MARKET)
|
||||||
trdswitchown(EF_LAND, landp, newown);
|
trdswitchown(EF_LAND, landp, newown);
|
||||||
landp->lnd_mission = 0;
|
landp->lnd_mission = 0;
|
||||||
makelost(EF_LAND, landp->lnd_own, landp->lnd_uid,
|
|
||||||
landp->lnd_x, landp->lnd_y);
|
|
||||||
landp->lnd_own = newown;
|
landp->lnd_own = newown;
|
||||||
makenotlost(EF_LAND, landp->lnd_own, landp->lnd_uid,
|
|
||||||
landp->lnd_x, landp->lnd_y);
|
|
||||||
pp = &p;
|
pp = &p;
|
||||||
lp = &llp;
|
lp = &llp;
|
||||||
/* Take over planes */
|
/* Take over planes */
|
||||||
|
@ -314,10 +301,7 @@ takeover_land(struct lndstr *landp, natid newown, int hostile)
|
||||||
if (opt_MARKET)
|
if (opt_MARKET)
|
||||||
trdswitchown(EF_PLANE, pp, newown);
|
trdswitchown(EF_PLANE, pp, newown);
|
||||||
pp->pln_mission = 0;
|
pp->pln_mission = 0;
|
||||||
makelost(EF_PLANE, pp->pln_own, pp->pln_uid, pp->pln_x, pp->pln_y);
|
|
||||||
pp->pln_own = newown;
|
pp->pln_own = newown;
|
||||||
makenotlost(EF_PLANE, pp->pln_own, pp->pln_uid,
|
|
||||||
pp->pln_x, pp->pln_y);
|
|
||||||
putplane(pp->pln_uid, pp);
|
putplane(pp->pln_uid, pp);
|
||||||
}
|
}
|
||||||
/* Take over land units */
|
/* Take over land units */
|
||||||
|
|
|
@ -312,8 +312,13 @@ guerrilla(struct sctstr *sp)
|
||||||
/* che won, and sector converts. */
|
/* che won, and sector converts. */
|
||||||
if (sp->sct_own == sp->sct_oldown)
|
if (sp->sct_own == sp->sct_oldown)
|
||||||
sp->sct_oldown = 0;
|
sp->sct_oldown = 0;
|
||||||
else
|
else {
|
||||||
|
makelost(EF_SECTOR, sp->sct_own,
|
||||||
|
0, sp->sct_x, sp->sct_y);
|
||||||
|
makenotlost(EF_SECTOR, sp->sct_oldown,
|
||||||
|
0, sp->sct_x, sp->sct_y);
|
||||||
takeover(sp, sp->sct_oldown);
|
takeover(sp, sp->sct_oldown);
|
||||||
|
}
|
||||||
sp->sct_mobil = oldmob;
|
sp->sct_mobil = oldmob;
|
||||||
civ += uw;
|
civ += uw;
|
||||||
uw = 0;
|
uw = 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue