]> git.pond.sub.org Git - empserver/commitdiff
Drop could_be_on_ship()'s load count parameters
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Jun 2012 15:10:48 +0000 (17:10 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 12 Jul 2012 17:52:33 +0000 (19:52 +0200)
Just one caller wants them.  Inline that call, and simplify the
others.

include/prototypes.h
src/lib/commands/load.c
src/lib/subs/plnsub.c

index 35d2e99aeb3dc2a7b270d8010e1fce08fa1fed2f..0971a477378bb9d347785401545cda6b28c00af5 100644 (file)
@@ -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 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);
 extern int put_plane_on_ship(struct plnstr *, struct shpstr *);
 extern void pln_dropoff(struct emp_qelem *, struct ichrstr *,
                        coord, coord, int);
index ae70cbff0ac7f0a3065a2bbef43252f83371e4b2..fe4615570eb01856aff1d092c24b99845e0a9272 100644 (file)
@@ -30,7 +30,7 @@
  *     David Sharnoff, 1987
  *     Ken Stevens, 1995 (rewritten)
  *     Steve McClure, 1998-2000
  *     David Sharnoff, 1987
  *     Ken Stevens, 1995 (rewritten)
  *     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)
            continue;
 
        } 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";
            if (noisy) {
                if (plchr[(int)pln.pln_type].pl_flags & P_K)
                    p = "choppers";
index ee111bc5de1fb1bd6e37e8320493ca50a1b5e65d..8ee93a84aa564fc16d908d621027cd53da4da939 100644 (file)
@@ -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) {
     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))
                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?
 
 /*
  * 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,
-                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;
     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
 }
 
 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);
        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;
 
     plane->pln_x = ship->shp_x;
     plane->pln_y = ship->shp_y;