(pln_airbase_ok): New parameter noisy to allow suppressing messages.

Check player->cnum only when noisy.  Update existing caller to pass 1.
No functional change.

(mission_pln_airbase_ok): Remove, use pln_airbase_ok() instead.  No
functional change.
This commit is contained in:
Markus Armbruster 2007-11-03 09:29:45 +00:00
parent 6110e08772
commit 4ced91fe3f
3 changed files with 26 additions and 83 deletions

View file

@ -557,6 +557,7 @@ extern void pln_dropoff(struct emp_qelem *, struct ichrstr *,
coord, coord, void *, int); coord, coord, void *, int);
extern void pln_mine(struct emp_qelem *list, struct sctstr *sectp); extern void pln_mine(struct emp_qelem *list, struct sctstr *sectp);
extern int pln_capable(struct plnstr *, int, int); extern int pln_capable(struct plnstr *, int, int);
extern int pln_airbase_ok(struct plnstr *, int, int);
extern void pln_sel(struct nstr_item *, struct emp_qelem *, extern void pln_sel(struct nstr_item *, struct emp_qelem *,
struct sctstr *, int, int, int, int); struct sctstr *, int, int, int, int);
extern int pln_arm(struct emp_qelem *, int, char, struct ichrstr *, extern int pln_arm(struct emp_qelem *, int, char, struct ichrstr *,

View file

@ -902,70 +902,6 @@ oprange(struct empobj *gp, int *radius)
return range; return range;
} }
static int
mission_pln_airbase_ok(struct plnstr *pp)
{
struct shpstr ship;
struct lndstr land;
struct sctstr sect;
struct plchrstr *pcp = plchr + pp->pln_type;
if (pp->pln_ship >= 0) {
if (!getship(pp->pln_ship, &ship)) {
CANT_REACH();
return 0;
}
if (CANT_HAPPEN(ship.shp_effic < SHIP_MINEFF
|| !could_be_on_ship(pp, &ship)))
return 0;
if (ship.shp_own != pp->pln_own
&& getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) {
return 0;
}
if (ship.shp_effic < SHP_AIROPS_EFF)
return 0;
} else if (pp->pln_land >= 0) {
if (!getland(pp->pln_land, &land)) {
CANT_REACH();
return 0;
}
if (CANT_HAPPEN(land.lnd_effic < LAND_MINEFF
|| !(pcp->pl_flags & P_E)))
return 0;
if (land.lnd_own != pp->pln_own
&& getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED)
return 0;
if (land.lnd_effic < LND_AIROPS_EFF)
return 0;
if (land.lnd_ship >= 0 || land.lnd_land >= 0) {
return 0;
}
} else {
if (!getsect(pp->pln_x, pp->pln_y, &sect)) {
CANT_REACH();
return 0;
}
/* First, check allied status */
/* Can't fly from non-owned sectors or non-allied sectors */
if ((sect.sct_own != pp->pln_own) &&
(getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED)) {
return 0;
}
/* non-vtol plane */
if ((pcp->pl_flags & P_V) == 0) {
if ((sect.sct_type != SCT_AIRPT) || (sect.sct_effic < 40)) {
return 0;
}
}
}
return 1;
}
/* /*
* Remove all planes who cannot go on * Remove all planes who cannot go on
* the mission from the plane list. * the mission from the plane list.
@ -1013,7 +949,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
continue; continue;
} }
if (!mission_pln_airbase_ok(pp)) { if (!pln_airbase_ok(pp, 0, 0)) {
emp_remque(qp); emp_remque(qp);
free(qp); free(qp);
continue; continue;

View file

@ -385,16 +385,16 @@ pln_capable(struct plnstr *pp, int wantflags, int nowantflags)
return 1; return 1;
} }
static int int
pln_airbase_ok(struct plnstr *pp, int oneway) pln_airbase_ok(struct plnstr *pp, int oneway, int noisy)
{ {
struct shpstr ship; struct shpstr ship;
struct lndstr land; struct lndstr land;
struct sctstr sect; struct sctstr sect;
struct plchrstr *pcp = plchr + pp->pln_type; struct plchrstr *pcp = plchr + pp->pln_type;
if (CANT_HAPPEN(pp->pln_own != player->cnum)) if (CANT_HAPPEN(noisy && pp->pln_own != player->cnum))
return 0; noisy = 0;
if (pp->pln_ship >= 0) { if (pp->pln_ship >= 0) {
/* ship: needs to be own or allied, efficient */ /* ship: needs to be own or allied, efficient */
@ -408,6 +408,7 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
if (ship.shp_own != pp->pln_own if (ship.shp_own != pp->pln_own
&& getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) { && getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the ship %s is on\n", pr("(note) An ally does not own the ship %s is on\n",
prplane(pp)); prplane(pp));
return 0; return 0;
@ -427,6 +428,7 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
if (land.lnd_own != pp->pln_own if (land.lnd_own != pp->pln_own
&& getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED) { && getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the unit %s is on\n", pr("(note) An ally does not own the unit %s is on\n",
prplane(pp)); prplane(pp));
return 0; return 0;
@ -445,6 +447,7 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
if (sect.sct_own != pp->pln_own if (sect.sct_own != pp->pln_own
&& getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED) { && getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED) {
if (noisy)
pr("(note) An ally does not own the sector %s is in\n", pr("(note) An ally does not own the sector %s is in\n",
prplane(pp)); prplane(pp));
return 0; return 0;
@ -452,16 +455,19 @@ pln_airbase_ok(struct plnstr *pp, int oneway)
/* need airfield unless VTOL */ /* need airfield unless VTOL */
if ((pcp->pl_flags & P_V) == 0) { if ((pcp->pl_flags & P_V) == 0) {
if (sect.sct_type != SCT_AIRPT) { if (sect.sct_type != SCT_AIRPT) {
if (noisy)
pr("%s not at airport\n", prplane(pp)); pr("%s not at airport\n", prplane(pp));
return 0; return 0;
} }
if (sect.sct_effic < 40) { if (sect.sct_effic < 40) {
if (noisy)
pr("%s is not 40%% efficient, %s can't take off from there.\n", pr("%s is not 40%% efficient, %s can't take off from there.\n",
xyas(sect.sct_x, sect.sct_y, pp->pln_own), xyas(sect.sct_x, sect.sct_y, pp->pln_own),
prplane(pp)); prplane(pp));
return 0; return 0;
} }
if (!oneway && sect.sct_effic < 60) { if (!oneway && sect.sct_effic < 60) {
if (noisy)
pr("%s is not 60%% efficient, %s can't land there.\n", pr("%s is not 60%% efficient, %s can't land there.\n",
xyas(sect.sct_x, sect.sct_y, pp->pln_own), xyas(sect.sct_x, sect.sct_y, pp->pln_own),
prplane(pp)); prplane(pp));
@ -519,7 +525,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
prplane(&plane), plane.pln_range, range); prplane(&plane), plane.pln_range, range);
continue; continue;
} }
if (!pln_airbase_ok(&plane, rangemult != 2)) if (!pln_airbase_ok(&plane, rangemult != 2, 1))
continue; continue;
pr("%s standing by\n", prplane(&plane)); pr("%s standing by\n", prplane(&plane));
plane.pln_mission = 0; plane.pln_mission = 0;