From: Markus Armbruster Date: Sat, 23 Jun 2012 15:10:48 +0000 (+0200) Subject: Drop could_be_on_ship()'s load count parameters X-Git-Tag: v4.3.31~151 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=72f1e22b95faa539b65a5080450d8f4864de585d Drop could_be_on_ship()'s load count parameters Just one caller wants them. Inline that call, and simplify the others. --- diff --git a/include/prototypes.h b/include/prototypes.h index 35d2e99ae..0971a4773 100644 --- a/include/prototypes.h +++ b/include/prototypes.h @@ -508,8 +508,7 @@ extern int pln_onewaymission(struct sctstr *, int *, int *); extern int pln_oneway_to_carrier_ok(struct emp_qelem *, struct emp_qelem *, int); extern void pln_newlanding(struct emp_qelem *, coord, coord, int); -extern int could_be_on_ship(struct plnstr *, struct shpstr *, - int, int, int, int); +extern int could_be_on_ship(struct plnstr *, struct shpstr *); extern int put_plane_on_ship(struct plnstr *, struct shpstr *); extern void pln_dropoff(struct emp_qelem *, struct ichrstr *, coord, coord, int); diff --git a/src/lib/commands/load.c b/src/lib/commands/load.c index ae70cbff0..fe4615570 100644 --- a/src/lib/commands/load.c +++ b/src/lib/commands/load.c @@ -30,7 +30,7 @@ * David Sharnoff, 1987 * Ken Stevens, 1995 (rewritten) * Steve McClure, 1998-2000 - * Markus Armbruster, 2004-2011 + * Markus Armbruster, 2004-2012 */ #include @@ -461,7 +461,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy, } else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y) continue; - if (!could_be_on_ship(&pln, sp, 0, 0, 0, 0)) { + if (!could_be_on_ship(&pln, sp)) { if (noisy) { if (plchr[(int)pln.pln_type].pl_flags & P_K) p = "choppers"; diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index ee111bc5d..8ee93a84a 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -227,7 +227,7 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno) for (qp = list->q_forw; qp != list; qp = qp->q_forw) { plp = (struct plist *)qp; if (cno >= 0) { - if (!could_be_on_ship(&plp->plane, &ship, 0, 0, 0, 0)) + if (!could_be_on_ship(&plp->plane, &ship)) pr("\t%s cannot land on ship #%d! %s aborts!\n", prplane(&plp->plane), cno, prplane(&plp->plane)); else if (!put_plane_on_ship(&plp->plane, &ship)) @@ -865,18 +865,15 @@ inc_shp_nplane(struct plnstr *pp, int *nch, int *nxl, int *nmsl) /* * Can PP be loaded on a ship of SP's type? - * Assume that it already carries N planes, of which NCH are choppers, - * NXL xlight, NMSL light missiles, and the rest are light fixed-wing - * planes. */ int -could_be_on_ship(struct plnstr *pp, struct shpstr *sp, - int n, int nch, int nxl, int nmsl) +could_be_on_ship(struct plnstr *pp, struct shpstr *sp) { + int nch = 0, nxl = 0, nmsl = 0; + if (!inc_shp_nplane(pp, &nch, &nxl, &nmsl)) return 0; - - return ship_can_carry(sp, n + 1, nch, nxl, nmsl); + return ship_can_carry(sp, 1, nch, nxl, nmsl); } int @@ -888,8 +885,10 @@ put_plane_on_ship(struct plnstr *plane, struct shpstr *ship) return 1; /* Already on ship */ n = shp_nplane(ship, &nch, &nxl, &nmsl); - if (!could_be_on_ship(plane, ship, n, nch, nxl, nmsl)) - return 0; + if (!inc_shp_nplane(plane, &nch, &nxl, &nmsl)) + return 0; /* not a carrier plane */ + if (!ship_can_carry(ship, n + 1, nch, nxl, nmsl)) + return 0; /* no space */ plane->pln_x = ship->shp_x; plane->pln_y = ship->shp_y;