From 6ed6d658d1a40c7f68eca75896a9ff4e69eee647 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sat, 23 Jul 2016 10:19:20 +0200 Subject: [PATCH] subs: Simplify checks whether a ship just read exists Ships with efficiency below the minimum have their owner set to zero on write to the ship file. Therefore, a ship just read from the ship file exists unless its owner is zero. Additionally checking efficiency is redundant. Same for planes and land units. Drop obviously redundant efficiency checks. Signed-off-by: Markus Armbruster --- src/lib/subs/list.c | 12 ++++++------ src/lib/subs/plnsub.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/subs/list.c b/src/lib/subs/list.c index 35d4309e..1e808ebb 100644 --- a/src/lib/subs/list.c +++ b/src/lib/subs/list.c @@ -28,7 +28,7 @@ * * Known contributors to this file: * Dave Pare, 1986 - * Markus Armbruster, 2003-2015 + * Markus Armbruster, 2003-2016 */ #include @@ -69,7 +69,7 @@ shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count) while (nxtitem(&ni, &ship)) { if (player->owner) continue; - if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) + if (!ship.shp_own) continue; mp = &mchr[(int)ship.shp_type]; if (wantflags) { @@ -99,7 +99,7 @@ carriersatxy(coord x, coord y, natid own) ships = 0; snxtitem_xy(&ni, EF_SHIP, x, y); while (nxtitem(&ni, &ship)) { - if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) + if (!ship.shp_own) continue; if (relations_with(ship.shp_own, own) != ALLIED) continue; @@ -122,7 +122,7 @@ unitsatxy(coord x, coord y, int wantflags, int nowantflags) units = 0; snxtitem_xy(&ni, EF_LAND, x, y); while (nxtitem(&ni, &land)) { - if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0) + if (!land.lnd_own) continue; if (land.lnd_ship >= 0 || land.lnd_land >= 0) continue; @@ -157,7 +157,7 @@ planesatxy(coord x, coord y, int wantflags, int nowantflags) planes = 0; snxtitem_xy(&ni, EF_PLANE, x, y); while (nxtitem(&ni, &plane)) { - if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0) + if (!plane.pln_own) continue; if (plane.pln_ship >= 0 || plane.pln_land >= 0) continue; @@ -195,7 +195,7 @@ asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags, while (nxtitem(&ni, &ship)) { if (player->owner) continue; - if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) + if (!ship.shp_own) continue; mp = &mchr[(int)ship.shp_type]; if (wantflags) { diff --git a/src/lib/subs/plnsub.c b/src/lib/subs/plnsub.c index 324f4ea0..9bbeaad9 100644 --- a/src/lib/subs/plnsub.c +++ b/src/lib/subs/plnsub.c @@ -109,7 +109,7 @@ get_assembly_point(char *input, struct sctstr *ap_sect, char *buf) /* over own or allied ship is fine */ snxtitem_xy(&ni, EF_SHIP, x, y); while (nxtitem(&ni, &ship)) { - if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) + if (!ship.shp_own) continue; if (relations_with(ship.shp_own, player->cnum) == ALLIED) return ap_sect;