Drop could_be_on_ship()'s load count parameters
Just one caller wants them. Inline that call, and simplify the others.
This commit is contained in:
parent
665d0d723d
commit
72f1e22b95
3 changed files with 12 additions and 14 deletions
|
@ -508,8 +508,7 @@ extern int pln_onewaymission(struct sctstr *, int *, int *);
|
||||||
extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
|
extern int pln_oneway_to_carrier_ok(struct emp_qelem *,
|
||||||
struct emp_qelem *, int);
|
struct emp_qelem *, int);
|
||||||
extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
|
extern void pln_newlanding(struct emp_qelem *, coord, coord, int);
|
||||||
extern int could_be_on_ship(struct plnstr *, struct shpstr *,
|
extern int could_be_on_ship(struct plnstr *, struct shpstr *);
|
||||||
int, int, int, int);
|
|
||||||
extern int put_plane_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 *,
|
extern void pln_dropoff(struct emp_qelem *, struct ichrstr *,
|
||||||
coord, coord, int);
|
coord, coord, int);
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
* David Sharnoff, 1987
|
* David Sharnoff, 1987
|
||||||
* Ken Stevens, 1995 (rewritten)
|
* Ken Stevens, 1995 (rewritten)
|
||||||
* Steve McClure, 1998-2000
|
* Steve McClure, 1998-2000
|
||||||
* Markus Armbruster, 2004-2011
|
* Markus Armbruster, 2004-2012
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -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)
|
} else if (sp->shp_x != pln.pln_x || sp->shp_y != pln.pln_y)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!could_be_on_ship(&pln, sp, 0, 0, 0, 0)) {
|
if (!could_be_on_ship(&pln, sp)) {
|
||||||
if (noisy) {
|
if (noisy) {
|
||||||
if (plchr[(int)pln.pln_type].pl_flags & P_K)
|
if (plchr[(int)pln.pln_type].pl_flags & P_K)
|
||||||
p = "choppers";
|
p = "choppers";
|
||||||
|
|
|
@ -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) {
|
for (qp = list->q_forw; qp != list; qp = qp->q_forw) {
|
||||||
plp = (struct plist *)qp;
|
plp = (struct plist *)qp;
|
||||||
if (cno >= 0) {
|
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",
|
pr("\t%s cannot land on ship #%d! %s aborts!\n",
|
||||||
prplane(&plp->plane), cno, prplane(&plp->plane));
|
prplane(&plp->plane), cno, prplane(&plp->plane));
|
||||||
else if (!put_plane_on_ship(&plp->plane, &ship))
|
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?
|
* 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
|
int
|
||||||
could_be_on_ship(struct plnstr *pp, struct shpstr *sp,
|
could_be_on_ship(struct plnstr *pp, struct shpstr *sp)
|
||||||
int n, int nch, int nxl, int nmsl)
|
|
||||||
{
|
{
|
||||||
|
int nch = 0, nxl = 0, nmsl = 0;
|
||||||
|
|
||||||
if (!inc_shp_nplane(pp, &nch, &nxl, &nmsl))
|
if (!inc_shp_nplane(pp, &nch, &nxl, &nmsl))
|
||||||
return 0;
|
return 0;
|
||||||
|
return ship_can_carry(sp, 1, nch, nxl, nmsl);
|
||||||
return ship_can_carry(sp, n + 1, nch, nxl, nmsl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -888,8 +885,10 @@ put_plane_on_ship(struct plnstr *plane, struct shpstr *ship)
|
||||||
return 1; /* Already on ship */
|
return 1; /* Already on ship */
|
||||||
|
|
||||||
n = shp_nplane(ship, &nch, &nxl, &nmsl);
|
n = shp_nplane(ship, &nch, &nxl, &nmsl);
|
||||||
if (!could_be_on_ship(plane, ship, n, nch, nxl, nmsl))
|
if (!inc_shp_nplane(plane, &nch, &nxl, &nmsl))
|
||||||
return 0;
|
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_x = ship->shp_x;
|
||||||
plane->pln_y = ship->shp_y;
|
plane->pln_y = ship->shp_y;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue