subs: Drop a few superfluous variables

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2015-01-10 07:19:14 +01:00
parent 4ec6df865b
commit e4654866cf

View file

@ -51,13 +51,11 @@
int int
shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count) shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
{ {
int first;
int ships; int ships;
struct nstr_item ni; struct nstr_item ni;
struct mchrstr *mp; struct mchrstr *mp;
struct shpstr ship; struct shpstr ship;
first = 1;
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)) {
@ -75,10 +73,8 @@ shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
continue; continue;
} }
if (!only_count) { if (!only_count) {
if (first) { if (!ships)
pr(" # owner eff type\n"); pr(" # owner eff type\n");
first = 0;
}
pr("(#%3d) %10.10s %12.12s %s\n", ni.cur, pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship)); cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
} }
@ -92,12 +88,10 @@ shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
int int
carriersatxy(coord x, coord y, natid own) carriersatxy(coord x, coord y, natid own)
{ {
int first;
int ships; int ships;
struct nstr_item ni; struct nstr_item ni;
struct shpstr ship; struct shpstr ship;
first = 1;
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)) {
@ -107,10 +101,8 @@ carriersatxy(coord x, coord y, natid own)
continue; continue;
if ((carrier_planes(&ship, 0) & (P_L | P_K)) == 0) if ((carrier_planes(&ship, 0) & (P_L | P_K)) == 0)
continue; continue;
if (first) { if (!ships)
pr(" # owner eff type\n"); pr(" # owner eff type\n");
first = 0;
}
pr("(#%3d) %10.10s %12.12s %s\n", ni.cur, pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship)); cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
ships++; ships++;
@ -121,13 +113,11 @@ carriersatxy(coord x, coord y, natid own)
int int
unitsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count) unitsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
{ {
int first;
int units; int units;
struct nstr_item ni; struct nstr_item ni;
struct lchrstr *lp; struct lchrstr *lp;
struct lndstr land; struct lndstr land;
first = 1;
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)) {
@ -153,10 +143,8 @@ unitsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
} }
if (!only_count) { if (!only_count) {
if (first) { if (!units)
pr(" # owner eff type\n"); pr(" # owner eff type\n");
first = 0;
}
pr("(#%3d) %10.10s %12.12s %s\n", ni.cur, pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
cname(land.lnd_own), effadv(land.lnd_effic), prland(&land)); cname(land.lnd_own), effadv(land.lnd_effic), prland(&land));
} }
@ -168,14 +156,12 @@ unitsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
int int
planesatxy(coord x, coord y, int wantflags, int nowantflags) planesatxy(coord x, coord y, int wantflags, int nowantflags)
{ {
int first;
int planes; int planes;
struct plnstr plane; struct plnstr plane;
struct nstr_item ni; struct nstr_item ni;
struct plchrstr *plp; struct plchrstr *plp;
planes = 0; planes = 0;
first = 1;
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_effic < PLANE_MINEFF || plane.pln_own == 0)
@ -185,10 +171,8 @@ planesatxy(coord x, coord y, int wantflags, int nowantflags)
if (plane.pln_flags & PLN_LAUNCHED) if (plane.pln_flags & PLN_LAUNCHED)
continue; continue;
plp = &plchr[(int)plane.pln_type]; plp = &plchr[(int)plane.pln_type];
if (first) { if (!planes)
pr(" # owner eff type\n"); pr(" # owner eff type\n");
first = 0;
}
if (wantflags) { if (wantflags) {
if ((plp->pl_flags & wantflags) == 0) if ((plp->pl_flags & wantflags) == 0)
continue; continue;
@ -208,13 +192,11 @@ int
asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags, asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
struct plnstr *pp, struct shiplist **head) struct plnstr *pp, struct shiplist **head)
{ {
int first;
int ships; int ships;
struct nstr_item ni; struct nstr_item ni;
struct mchrstr *mp; struct mchrstr *mp;
struct shpstr ship; struct shpstr ship;
first = 1;
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)) {
@ -237,10 +219,8 @@ asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
continue; continue;
} }
add_shiplist(ship.shp_uid, head); add_shiplist(ship.shp_uid, head);
if (first) { if (!ships)
pr(" # owner eff type\n"); pr(" # owner eff type\n");
first = 0;
}
pr("(#%3d) %10.10s %12.12s %s\n", ni.cur, pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship)); cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
ships++; ships++;