(gift): All callers transfer ownership after calling gift(). Move
that code into gift(). Callers changed.
This commit is contained in:
parent
019ab0e7cf
commit
94bc512581
2 changed files with 21 additions and 89 deletions
|
@ -321,27 +321,31 @@ lload(void)
|
|||
void
|
||||
gift(natid givee, natid giver, void *ptr, int type, char *mesg)
|
||||
{
|
||||
struct genitem *gen = ptr;
|
||||
char *p;
|
||||
|
||||
if (giver == givee)
|
||||
return;
|
||||
if (giver != givee) {
|
||||
switch (type) {
|
||||
case EF_SHIP:
|
||||
p = prship(ptr);
|
||||
break;
|
||||
case EF_PLANE:
|
||||
p = prplane(ptr);
|
||||
break;
|
||||
case EF_LAND:
|
||||
p = prland(ptr);
|
||||
break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
p = "a red herring";
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case EF_SHIP:
|
||||
p = prship(ptr);
|
||||
break;
|
||||
case EF_PLANE:
|
||||
p = prplane(ptr);
|
||||
break;
|
||||
case EF_LAND:
|
||||
p = prland(ptr);
|
||||
break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
p = "a red herring";
|
||||
wu(0, givee, "%s %s %s\n", cname(giver), p, mesg);
|
||||
}
|
||||
|
||||
wu(0, givee, "%s %s %s\n", cname(giver), p, mesg);
|
||||
makelost(type, gen->own, gen->uid, gen->x, gen->y);
|
||||
gen->own = givee;
|
||||
makenotlost(type, gen->own, gen->uid, gen->x, gen->y);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -460,11 +464,6 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
sprintf(buf, "loaded on your %s at %s",
|
||||
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
||||
gift(sp->shp_own, player->cnum, &pln, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
pln.pln_own = sp->shp_own;
|
||||
makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
pln.pln_mission = 0;
|
||||
putplane(pln.pln_uid, &pln);
|
||||
} else {
|
||||
|
@ -478,11 +477,6 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
dchr[sectp->sct_type].d_name,
|
||||
xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
|
||||
gift(sectp->sct_own, player->cnum, &pln, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
pln.pln_own = sectp->sct_own;
|
||||
makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
}
|
||||
pr("%s %s %s at %s.\n",
|
||||
|
@ -631,11 +625,6 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
sprintf(buf, "loaded on your %s at %s",
|
||||
prship(sp), xyas(sp->shp_x, sp->shp_y, sp->shp_own));
|
||||
gift(sp->shp_own, player->cnum, &land, EF_LAND, buf);
|
||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_own = sp->shp_own;
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_ship = sp->shp_uid;
|
||||
land.lnd_harden = 0;
|
||||
land.lnd_mission = 0;
|
||||
|
@ -653,11 +642,6 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
continue;
|
||||
sprintf(buf, "loaded on %s", prship(sp));
|
||||
gift(sp->shp_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_own = sp->shp_own;
|
||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
@ -667,15 +651,8 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
|
||||
|
||||
/* Spies are unloaded quietly, others aren't */
|
||||
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY)) {
|
||||
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
|
||||
gift(sectp->sct_own, player->cnum, &land, EF_LAND, buf);
|
||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_own = sectp->sct_own;
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
}
|
||||
|
||||
land.lnd_ship = -1;
|
||||
sp->shp_nland--;
|
||||
putland(land.lnd_uid, &land);
|
||||
|
@ -695,11 +672,6 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
xyas(plane.pln_x, plane.pln_y,
|
||||
sectp->sct_own));
|
||||
gift(sectp->sct_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_own = sectp->sct_own;
|
||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
@ -875,11 +847,6 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
sprintf(buf, "loaded on %s at %s",
|
||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
|
||||
gift(lp->lnd_own, player->cnum, &pln, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
pln.pln_own = lp->lnd_own;
|
||||
makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
} else {
|
||||
if (!take_plane_off_land(&pln, lp)) {
|
||||
|
@ -891,11 +858,6 @@ load_plane_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
sprintf(buf, "unloaded at your sector at %s",
|
||||
xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
|
||||
gift(sectp->sct_own, player->cnum, &pln, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
pln.pln_own = sectp->sct_own;
|
||||
makenotlost(EF_PLANE, pln.pln_own, pln.pln_uid,
|
||||
pln.pln_x, pln.pln_y);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
}
|
||||
pr("%s %s %s at %s.\n",
|
||||
|
@ -1090,11 +1052,6 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
sprintf(buf, "loaded on your %s at %s",
|
||||
prland(lp), xyas(lp->lnd_x, lp->lnd_y, lp->lnd_own));
|
||||
gift(lp->lnd_own, player->cnum, &land, EF_LAND, buf);
|
||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_own = lp->lnd_own;
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_land = lp->lnd_uid;
|
||||
land.lnd_harden = 0;
|
||||
land.lnd_mission = 0;
|
||||
|
@ -1112,11 +1069,6 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
continue;
|
||||
sprintf(buf, "loaded on %s", prland(lp));
|
||||
gift(lp->lnd_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_own = lp->lnd_own;
|
||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
@ -1125,11 +1077,6 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
dchr[sectp->sct_type].d_name,
|
||||
xyas(sectp->sct_x, sectp->sct_y, sectp->sct_own));
|
||||
gift(sectp->sct_own, player->cnum, &land, EF_LAND, buf);
|
||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_own = sectp->sct_own;
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_land = -1;
|
||||
lp->lnd_nland--;
|
||||
putland(land.lnd_uid, &land);
|
||||
|
@ -1143,11 +1090,6 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
sprintf(buf, "unloaded at %s",
|
||||
xyas(plane.pln_x, plane.pln_y, sectp->sct_own));
|
||||
gift(sectp->sct_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_own = sectp->sct_own;
|
||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
|
|
@ -272,11 +272,6 @@ tend_land(struct shpstr *tenderp, char *units)
|
|||
prship(&target), xyas(target.shp_x, target.shp_y,
|
||||
target.shp_own));
|
||||
gift(target.shp_own, player->cnum, &land, EF_LAND, buf);
|
||||
makelost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_own = target.shp_own;
|
||||
makenotlost(EF_LAND, land.lnd_own, land.lnd_uid,
|
||||
land.lnd_x, land.lnd_y);
|
||||
land.lnd_ship = target.shp_uid;
|
||||
land.lnd_harden = 0;
|
||||
land.lnd_mission = 0;
|
||||
|
@ -294,11 +289,6 @@ tend_land(struct shpstr *tenderp, char *units)
|
|||
continue;
|
||||
sprintf(buf, "loaded on %s", prship(&target));
|
||||
gift(target.shp_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
makelost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_own = target.shp_own;
|
||||
makenotlost(EF_PLANE, plane.pln_own, plane.pln_uid,
|
||||
plane.pln_x, plane.pln_y);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue