From 4ced91fe3fe8d68e9832dbd3a33b451e683ae51e Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 3 Nov 2007 09:29:45 +0000 Subject: [PATCH] (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. --- include/prototypes.h | 1 + src/lib/subs/mission.c | 66 +----------------------------------------- src/lib/subs/plnsub.c | 42 +++++++++++++++------------ 3 files changed, 26 insertions(+), 83 deletions(-) diff --git a/include/prototypes.h b/include/prototypes.h index ed91e7f5..ea800e7a 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -557,6 +557,7 @@ extern void pln_dropoff(struct emp_qelem *, struct ichrstr *, coord, coord, void *, int); extern void pln_mine(struct emp_qelem *list, struct sctstr *sectp); 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 *, struct sctstr *, int, int, int, int); extern int pln_arm(struct emp_qelem *, int, char, struct ichrstr *, diff --git a/src/lib/subs/mission.c b/src/lib/subs/mission.c index 148fb5ff..cc1644e6 100644 --- a/src/lib/subs/mission.c +++ b/src/lib/subs/mission.c @@ -902,70 +902,6 @@ oprange(struct empobj *gp, int *radius) 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, §)) { - 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 * the mission from the plane list. @@ -1013,7 +949,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags, continue; } - if (!mission_pln_airbase_ok(pp)) { + if (!pln_airbase_ok(pp, 0, 0)) { emp_remque(qp); free(qp); continue; diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index d81e34aa..c7a6a047 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -385,16 +385,16 @@ pln_capable(struct plnstr *pp, int wantflags, int nowantflags) return 1; } -static int -pln_airbase_ok(struct plnstr *pp, int oneway) +int +pln_airbase_ok(struct plnstr *pp, int oneway, int noisy) { struct shpstr ship; struct lndstr land; struct sctstr sect; struct plchrstr *pcp = plchr + pp->pln_type; - if (CANT_HAPPEN(pp->pln_own != player->cnum)) - return 0; + if (CANT_HAPPEN(noisy && pp->pln_own != player->cnum)) + noisy = 0; if (pp->pln_ship >= 0) { /* ship: needs to be own or allied, efficient */ @@ -408,8 +408,9 @@ pln_airbase_ok(struct plnstr *pp, int oneway) if (ship.shp_own != pp->pln_own && getrel(getnatp(ship.shp_own), pp->pln_own) != ALLIED) { - pr("(note) An ally does not own the ship %s is on\n", - prplane(pp)); + if (noisy) + pr("(note) An ally does not own the ship %s is on\n", + prplane(pp)); return 0; } if (ship.shp_effic < SHP_AIROPS_EFF) @@ -427,8 +428,9 @@ pln_airbase_ok(struct plnstr *pp, int oneway) if (land.lnd_own != pp->pln_own && getrel(getnatp(land.lnd_own), pp->pln_own) != ALLIED) { - pr("(note) An ally does not own the unit %s is on\n", - prplane(pp)); + if (noisy) + pr("(note) An ally does not own the unit %s is on\n", + prplane(pp)); return 0; } if (land.lnd_effic < LND_AIROPS_EFF) @@ -445,26 +447,30 @@ pln_airbase_ok(struct plnstr *pp, int oneway) if (sect.sct_own != pp->pln_own && getrel(getnatp(sect.sct_own), pp->pln_own) != ALLIED) { - pr("(note) An ally does not own the sector %s is in\n", - prplane(pp)); + if (noisy) + pr("(note) An ally does not own the sector %s is in\n", + prplane(pp)); return 0; } /* need airfield unless VTOL */ if ((pcp->pl_flags & P_V) == 0) { if (sect.sct_type != SCT_AIRPT) { - pr("%s not at airport\n", prplane(pp)); + if (noisy) + pr("%s not at airport\n", prplane(pp)); return 0; } if (sect.sct_effic < 40) { - pr("%s is not 40%% efficient, %s can't take off from there.\n", - xyas(sect.sct_x, sect.sct_y, pp->pln_own), - prplane(pp)); + if (noisy) + pr("%s is not 40%% efficient, %s can't take off from there.\n", + xyas(sect.sct_x, sect.sct_y, pp->pln_own), + prplane(pp)); return 0; } if (!oneway && sect.sct_effic < 60) { - pr("%s is not 60%% efficient, %s can't land there.\n", - xyas(sect.sct_x, sect.sct_y, pp->pln_own), - prplane(pp)); + if (noisy) + pr("%s is not 60%% efficient, %s can't land there.\n", + xyas(sect.sct_x, sect.sct_y, pp->pln_own), + prplane(pp)); return 0; } } @@ -519,7 +525,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap, prplane(&plane), plane.pln_range, range); continue; } - if (!pln_airbase_ok(&plane, rangemult != 2)) + if (!pln_airbase_ok(&plane, rangemult != 2, 1)) continue; pr("%s standing by\n", prplane(&plane)); plane.pln_mission = 0;