]> git.pond.sub.org Git - empserver/commitdiff
Inline fit_plane_on_ship() and fit_plane_on_land()
authorMarkus Armbruster <armbru@pond.sub.org>
Sat, 23 Jun 2012 14:46:11 +0000 (16:46 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 12 Jul 2012 17:52:33 +0000 (19:52 +0200)
Just one call site each.

src/lib/subs/plnsub.c

index c261ae1f39a57dfa7cd0bd3582b452f816a5bae8..ee111bc5de1fb1bd6e37e8320493ca50a1b5e65d 100644 (file)
@@ -879,27 +879,16 @@ could_be_on_ship(struct plnstr *pp, struct shpstr *sp,
     return ship_can_carry(sp, n + 1, nch, nxl, nmsl);
 }
 
-/*
- * Fit a plane of PP's type on ship SP.
- * Updating the plane accordingly is the caller's job.
- * Return whether it fits.
- */
-static int
-fit_plane_on_ship(struct plnstr *pp, struct shpstr *sp)
-{
-    int n, nch, nxl, nmsl;
-
-    n = shp_nplane(sp, &nch, &nxl, &nmsl);
-    return could_be_on_ship(pp, sp, n, nch, nxl, nmsl);
-}
-
 int
 put_plane_on_ship(struct plnstr *plane, struct shpstr *ship)
 {
+    int n, nch, nxl, nmsl;
+
     if (plane->pln_ship == ship->shp_uid)
        return 1;               /* Already on ship */
 
-    if (!fit_plane_on_ship(plane, ship))
+    n = shp_nplane(ship, &nch, &nxl, &nmsl);
+    if (!could_be_on_ship(plane, ship, n, nch, nxl, nmsl))
        return 0;
 
     plane->pln_x = ship->shp_x;
@@ -909,27 +898,14 @@ put_plane_on_ship(struct plnstr *plane, struct shpstr *ship)
     return 1;
 }
 
-/*
- * Fit a plane of PP's type on land unit LP.
- * Updating the plane accordingly is the caller's job.
- * Return whether it fits.
- */
-static int
-fit_plane_on_land(struct plnstr *pp, struct lndstr *lp)
-{
-    struct plchrstr *pcp = plchr + pp->pln_type;
-    struct lchrstr *lcp = lchr + lp->lnd_type;
-
-    return (pcp->pl_flags & P_E) && lnd_nxlight(lp) < lcp->l_nxlight;
-}
-
 int
 put_plane_on_land(struct plnstr *plane, struct lndstr *land)
 {
     if (plane->pln_land == land->lnd_uid)
        return 1;               /* Already on unit */
-
-    if (!fit_plane_on_land(plane, land))
+    if (!(plchr[plane->pln_type].pl_flags & P_E))
+       return 0;
+    if (lnd_nxlight(land) >= lchr[land->lnd_type].l_nxlight)
        return 0;
 
     plane->pln_x = land->lnd_x;