]> git.pond.sub.org Git - empserver/commitdiff
(can_be_on_ship, could_be_on_ship): Take pointer rather than UID
authorMarkus Armbruster <armbru@pond.sub.org>
Wed, 31 Oct 2007 06:39:37 +0000 (06:39 +0000)
committerMarkus Armbruster <armbru@pond.sub.org>
Wed, 31 Oct 2007 06:39:37 +0000 (06:39 +0000)
arguments.  Rename.  Callers changed.

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

index 91cbdd08d0576aa37b462568f1c499c114851e73..ddb6ce39acc2ac1535a0f3edf9b73c5f31d0cae8 100644 (file)
@@ -551,7 +551,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 can_be_on_ship(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, void *, int);
index 58b8e91730ada7b5b852164ec50b34f581d571a5..5dc22be1961a17b466a4f8a6d381348ce1ee3377 100644 (file)
@@ -414,7 +414,7 @@ load_plane_ship(struct sctstr *sectp, struct shpstr *sp, int noisy,
            continue;
 
        /* ship to (plane or missle) sanity */
-       if (!can_be_on_ship(pln.pln_uid, sp->shp_uid)) {
+       if (!could_be_on_ship(&pln, sp)) {
            if (plchr[(int)pln.pln_type].pl_flags & P_L) {
                strcpy(buf, "planes");
            } else if (plchr[(int)pln.pln_type].pl_flags & P_K) {
index 4def9a1b07607daa5e35d9423ebea287bb7f404e..da8a2c6f3c79ecf72fabb87b6b0f0da2454e7235 100644 (file)
@@ -1012,7 +1012,7 @@ mission_pln_sel(struct emp_qelem *list, int wantflags, int nowantflags,
                free(qp);
                continue;
            }
-           if (!can_be_on_ship(pp->pln_uid, ship.shp_uid)) {
+           if (!could_be_on_ship(pp, &ship)) {
                goto shipsunk;
            }
            if (ship.shp_effic < SHIP_MINEFF) {
index 89b9594b4ac66c35ccdef9ba73fca735143de467..1b74bd9d1be0a0d3a4ec5676fbbfa2f709fd1178 100644 (file)
@@ -217,7 +217,7 @@ pln_newlanding(struct emp_qelem *list, coord tx, coord ty, int cno)
        plp = (struct plist *)qp;
        if (cno >= 0) {
            count_planes(&ship);
-           if (!can_be_on_ship(plp->plane.pln_uid, ship.shp_uid))
+           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))
@@ -458,7 +458,7 @@ pln_sel(struct nstr_item *ni, struct emp_qelem *list, struct sctstr *ap,
                putplane(plane.pln_uid, &plane);
                continue;
            }
-           if (!can_be_on_ship(plane.pln_uid, ship.shp_uid))
+           if (!could_be_on_ship(&plane, &ship))
                goto shipsunk;
            if (ship.shp_effic < SHIP_MINEFF)
                goto shipsunk;
@@ -951,19 +951,14 @@ take_plane_off_land(struct plnstr *plane, struct lndstr *land)
     putplane(plane->pln_uid, plane);
 }
 
+/*
+ * Could a plane of PP's type be on on a ship of SP's type?
+ */
 int
-can_be_on_ship(int p, int s)
+could_be_on_ship(struct plnstr *pp, struct shpstr *sp)
 {
-    struct plnstr plane;
-    struct shpstr ship;
-    struct plchrstr *pcp;
-    struct mchrstr *mcp;
-
-    getplane(p, &plane);
-    getship(s, &ship);
-
-    pcp = &plchr[(int)plane.pln_type];
-    mcp = &mchr[(int)ship.shp_type];
+    struct plchrstr *pcp = plchr + pp->pln_type;
+    struct mchrstr *mcp = mchr + sp->shp_type;
 
     if (pcp->pl_flags & P_L)
        if (mcp->m_flags & M_FLY)