(gift): Remove the type argument, can be determined from the ptr
argument. Replace prship/prland/prplane/prnuke code with obj_nameof().
This commit is contained in:
parent
55107731cc
commit
f246f86542
4 changed files with 22 additions and 42 deletions
|
@ -57,7 +57,7 @@ extern void finish_server(void);
|
|||
*/
|
||||
extern int check_market(void);
|
||||
extern int sendmessage(struct natstr *, struct natstr *, char *, int);
|
||||
extern void gift(natid, natid, void *, int, char *);
|
||||
extern void gift(natid, natid, void *, char *);
|
||||
extern int display_mark(i_type, int);
|
||||
extern int want_to_abandon(struct sctstr *, i_type, int, struct lndstr *);
|
||||
extern int would_abandon(struct sctstr *, i_type, int, struct lndstr *);
|
||||
|
|
|
@ -106,7 +106,7 @@ arm(void)
|
|||
|
||||
snprintf(buf, sizeof(buf), "armed on your %s in %s",
|
||||
prplane(&pl), xyas(pl.pln_x, pl.pln_y, pl.pln_own));
|
||||
gift(pl.pln_own, player->cnum, &nuke, EF_NUKE, buf);
|
||||
gift(pl.pln_own, player->cnum, &nuke, buf);
|
||||
pl.pln_nuketype = nuke.nuk_type;
|
||||
nuke.nuk_plane = pl.pln_uid;
|
||||
putplane(pl.pln_uid, &pl);
|
||||
|
@ -157,7 +157,7 @@ disarm(void)
|
|||
snprintf(buf, sizeof(buf), "unloaded in your %s at %s",
|
||||
dchr[sect.sct_type].d_name,
|
||||
xyas(sect.sct_x, sect.sct_y, sect.sct_own));
|
||||
gift(sect.sct_own, player->cnum, &nuke, EF_NUKE, buf);
|
||||
gift(sect.sct_own, player->cnum, &nuke, buf);
|
||||
nuke.nuk_plane = -1;
|
||||
pl.pln_nuketype = -1;
|
||||
pl.pln_flags &= ~PLN_AIRBURST;
|
||||
|
|
|
@ -313,36 +313,16 @@ lload(void)
|
|||
}
|
||||
|
||||
void
|
||||
gift(natid givee, natid giver, void *ptr, int type, char *mesg)
|
||||
gift(natid givee, natid giver, void *ptr, char *mesg)
|
||||
{
|
||||
struct empobj *gen = ptr;
|
||||
char *p;
|
||||
|
||||
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;
|
||||
case EF_NUKE:
|
||||
p = prnuke(ptr);
|
||||
break;
|
||||
default:
|
||||
CANT_REACH();
|
||||
p = "a red herring";
|
||||
}
|
||||
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), p, mesg);
|
||||
}
|
||||
|
||||
makelost(type, gen->own, gen->uid, gen->x, gen->y);
|
||||
makelost(gen->ef_type, gen->own, gen->uid, gen->x, gen->y);
|
||||
gen->own = givee;
|
||||
makenotlost(type, gen->own, gen->uid, gen->x, gen->y);
|
||||
makenotlost(gen->ef_type, gen->own, gen->uid, gen->x, gen->y);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -460,7 +440,7 @@ 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);
|
||||
gift(sp->shp_own, player->cnum, &pln, buf);
|
||||
pln.pln_mission = 0;
|
||||
putplane(pln.pln_uid, &pln);
|
||||
} else {
|
||||
|
@ -473,7 +453,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
sprintf(buf, "unloaded in your %s at %s",
|
||||
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);
|
||||
gift(sectp->sct_own, player->cnum, &pln, buf);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
}
|
||||
pr("%s %s %s at %s.\n",
|
||||
|
@ -621,7 +601,7 @@ 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);
|
||||
gift(sp->shp_own, player->cnum, &land, buf);
|
||||
land.lnd_ship = sp->shp_uid;
|
||||
land.lnd_harden = 0;
|
||||
land.lnd_mission = 0;
|
||||
|
@ -638,7 +618,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
if (plane.pln_land != land.lnd_uid)
|
||||
continue;
|
||||
sprintf(buf, "loaded on %s", prship(sp));
|
||||
gift(sp->shp_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
gift(sp->shp_own, player->cnum, &plane, buf);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
@ -649,7 +629,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
|
|||
|
||||
/* Spies are unloaded quietly, others aren't */
|
||||
if (!(lchr[(int)land.lnd_type].l_flags & L_SPY))
|
||||
gift(sectp->sct_own, player->cnum, &land, EF_LAND, buf);
|
||||
gift(sectp->sct_own, player->cnum, &land, buf);
|
||||
land.lnd_ship = -1;
|
||||
sp->shp_nland--;
|
||||
putland(land.lnd_uid, &land);
|
||||
|
@ -668,7 +648,7 @@ load_land_ship(struct sctstr *sectp, struct shpstr *sp, 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);
|
||||
gift(sectp->sct_own, player->cnum, &plane, buf);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
@ -843,7 +823,7 @@ 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);
|
||||
gift(lp->lnd_own, player->cnum, &pln, buf);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
} else {
|
||||
if (!take_plane_off_land(&pln, lp)) {
|
||||
|
@ -854,7 +834,7 @@ 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);
|
||||
gift(sectp->sct_own, player->cnum, &pln, buf);
|
||||
putplane(pln.pln_uid, &pln);
|
||||
}
|
||||
pr("%s %s %s at %s.\n",
|
||||
|
@ -1048,7 +1028,7 @@ 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);
|
||||
gift(lp->lnd_own, player->cnum, &land, buf);
|
||||
land.lnd_land = lp->lnd_uid;
|
||||
land.lnd_harden = 0;
|
||||
land.lnd_mission = 0;
|
||||
|
@ -1065,7 +1045,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
if (plane.pln_land != land.lnd_uid)
|
||||
continue;
|
||||
sprintf(buf, "loaded on %s", prland(lp));
|
||||
gift(lp->lnd_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
gift(lp->lnd_own, player->cnum, &plane, buf);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
@ -1073,7 +1053,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
sprintf(buf, "unloaded in your %s at %s",
|
||||
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);
|
||||
gift(sectp->sct_own, player->cnum, &land, buf);
|
||||
land.lnd_land = -1;
|
||||
lp->lnd_nland--;
|
||||
putland(land.lnd_uid, &land);
|
||||
|
@ -1086,7 +1066,7 @@ load_land_land(struct sctstr *sectp, struct lndstr *lp, int noisy,
|
|||
continue;
|
||||
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);
|
||||
gift(sectp->sct_own, player->cnum, &plane, buf);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
|
|
@ -263,7 +263,7 @@ tend_land(struct shpstr *tenderp, char *units)
|
|||
sprintf(buf, "loaded on your %s at %s",
|
||||
prship(&target), xyas(target.shp_x, target.shp_y,
|
||||
target.shp_own));
|
||||
gift(target.shp_own, player->cnum, &land, EF_LAND, buf);
|
||||
gift(target.shp_own, player->cnum, &land, buf);
|
||||
land.lnd_ship = target.shp_uid;
|
||||
land.lnd_harden = 0;
|
||||
land.lnd_mission = 0;
|
||||
|
@ -280,7 +280,7 @@ tend_land(struct shpstr *tenderp, char *units)
|
|||
if (plane.pln_land != land.lnd_uid)
|
||||
continue;
|
||||
sprintf(buf, "loaded on %s", prship(&target));
|
||||
gift(target.shp_own, player->cnum, &plane, EF_PLANE, buf);
|
||||
gift(target.shp_own, player->cnum, &plane, buf);
|
||||
plane.pln_mission = 0;
|
||||
putplane(plane.pln_uid, &plane);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue