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 <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2016-07-23 10:19:20 +02:00
parent 0c6d1e422e
commit 6ed6d658d1
2 changed files with 7 additions and 7 deletions

View file

@ -28,7 +28,7 @@
* *
* Known contributors to this file: * Known contributors to this file:
* Dave Pare, 1986 * Dave Pare, 1986
* Markus Armbruster, 2003-2015 * Markus Armbruster, 2003-2016
*/ */
#include <config.h> #include <config.h>
@ -69,7 +69,7 @@ shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
while (nxtitem(&ni, &ship)) { while (nxtitem(&ni, &ship)) {
if (player->owner) if (player->owner)
continue; continue;
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) if (!ship.shp_own)
continue; continue;
mp = &mchr[(int)ship.shp_type]; mp = &mchr[(int)ship.shp_type];
if (wantflags) { if (wantflags) {
@ -99,7 +99,7 @@ carriersatxy(coord x, coord y, natid own)
ships = 0; ships = 0;
snxtitem_xy(&ni, EF_SHIP, x, y); snxtitem_xy(&ni, EF_SHIP, x, y);
while (nxtitem(&ni, &ship)) { while (nxtitem(&ni, &ship)) {
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) if (!ship.shp_own)
continue; continue;
if (relations_with(ship.shp_own, own) != ALLIED) if (relations_with(ship.shp_own, own) != ALLIED)
continue; continue;
@ -122,7 +122,7 @@ unitsatxy(coord x, coord y, int wantflags, int nowantflags)
units = 0; units = 0;
snxtitem_xy(&ni, EF_LAND, x, y); snxtitem_xy(&ni, EF_LAND, x, y);
while (nxtitem(&ni, &land)) { while (nxtitem(&ni, &land)) {
if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0) if (!land.lnd_own)
continue; continue;
if (land.lnd_ship >= 0 || land.lnd_land >= 0) if (land.lnd_ship >= 0 || land.lnd_land >= 0)
continue; continue;
@ -157,7 +157,7 @@ planesatxy(coord x, coord y, int wantflags, int nowantflags)
planes = 0; planes = 0;
snxtitem_xy(&ni, EF_PLANE, x, y); snxtitem_xy(&ni, EF_PLANE, x, y);
while (nxtitem(&ni, &plane)) { while (nxtitem(&ni, &plane)) {
if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0) if (!plane.pln_own)
continue; continue;
if (plane.pln_ship >= 0 || plane.pln_land >= 0) if (plane.pln_ship >= 0 || plane.pln_land >= 0)
continue; continue;
@ -195,7 +195,7 @@ asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
while (nxtitem(&ni, &ship)) { while (nxtitem(&ni, &ship)) {
if (player->owner) if (player->owner)
continue; continue;
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) if (!ship.shp_own)
continue; continue;
mp = &mchr[(int)ship.shp_type]; mp = &mchr[(int)ship.shp_type];
if (wantflags) { if (wantflags) {

View file

@ -109,7 +109,7 @@ get_assembly_point(char *input, struct sctstr *ap_sect, char *buf)
/* over own or allied ship is fine */ /* over own or allied ship is fine */
snxtitem_xy(&ni, EF_SHIP, x, y); snxtitem_xy(&ni, EF_SHIP, x, y);
while (nxtitem(&ni, &ship)) { while (nxtitem(&ni, &ship)) {
if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0) if (!ship.shp_own)
continue; continue;
if (relations_with(ship.shp_own, player->cnum) == ALLIED) if (relations_with(ship.shp_own, player->cnum) == ALLIED)
return ap_sect; return ap_sect;