subs: Add unitsatxy() parameter only_count
Like shipsatxy(). To be used shortly. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
c9fc05ae5b
commit
9b33a4c598
3 changed files with 13 additions and 11 deletions
|
@ -448,7 +448,7 @@ extern int roundrange(double);
|
||||||
/* list.c */
|
/* list.c */
|
||||||
extern int shipsatxy(coord, coord, int, int, int);
|
extern int shipsatxy(coord, coord, int, int, int);
|
||||||
extern int carriersatxy(coord, coord, natid);
|
extern int carriersatxy(coord, coord, natid);
|
||||||
extern int unitsatxy(coord, coord, int, int);
|
extern int unitsatxy(coord, coord, int, int, int);
|
||||||
extern int planesatxy(coord, coord, int, int);
|
extern int planesatxy(coord, coord, int, int);
|
||||||
extern int asw_shipsatxy(coord, coord, int, int, struct plnstr *,
|
extern int asw_shipsatxy(coord, coord, int, int, struct plnstr *,
|
||||||
struct shiplist **);
|
struct shiplist **);
|
||||||
|
|
|
@ -196,7 +196,7 @@ pin_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
pr("Some subs are present in the sector.\n");
|
pr("Some subs are present in the sector.\n");
|
||||||
}
|
}
|
||||||
nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
|
nplanes = planesatxy(target->sct_x, target->sct_y, 0, 0);
|
||||||
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
|
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
|
||||||
retry:
|
retry:
|
||||||
p = getstring("Bomb what? (ship, plane, land unit, efficiency, commodities) ",
|
p = getstring("Bomb what? (ship, plane, land unit, efficiency, commodities) ",
|
||||||
buf);
|
buf);
|
||||||
|
@ -612,7 +612,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
plp = (struct plist *)qp;
|
plp = (struct plist *)qp;
|
||||||
if (changed_plane_aborts(plp))
|
if (changed_plane_aborts(plp))
|
||||||
continue;
|
continue;
|
||||||
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0);
|
nunits = unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
|
||||||
if (nunits == 0) {
|
if (nunits == 0) {
|
||||||
pr("%s could not find any units!\n", prplane(&plp->plane));
|
pr("%s could not find any units!\n", prplane(&plp->plane));
|
||||||
continue;
|
continue;
|
||||||
|
@ -628,7 +628,7 @@ land_bomb(struct emp_qelem *list, struct sctstr *target)
|
||||||
if (*q == '~')
|
if (*q == '~')
|
||||||
break;
|
break;
|
||||||
if (*q == '?') {
|
if (*q == '?') {
|
||||||
unitsatxy(target->sct_x, target->sct_y, 0, 0);
|
unitsatxy(target->sct_x, target->sct_y, 0, 0, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
n = atoi(q);
|
n = atoi(q);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
*
|
*
|
||||||
* Known contributors to this file:
|
* Known contributors to this file:
|
||||||
* Dave Pare, 1986
|
* Dave Pare, 1986
|
||||||
* Markus Armbruster, 2003-2012
|
* Markus Armbruster, 2003-2014
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
@ -119,7 +119,7 @@ carriersatxy(coord x, coord y, natid own)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
unitsatxy(coord x, coord y, int wantflags, int nowantflags)
|
unitsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
|
||||||
{
|
{
|
||||||
int first;
|
int first;
|
||||||
int units;
|
int units;
|
||||||
|
@ -152,12 +152,14 @@ unitsatxy(coord x, coord y, int wantflags, int nowantflags)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!only_count) {
|
||||||
if (first) {
|
if (first) {
|
||||||
pr(" # owner eff type\n");
|
pr(" # owner eff type\n");
|
||||||
first = 0;
|
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));
|
||||||
|
}
|
||||||
units++;
|
units++;
|
||||||
}
|
}
|
||||||
return units;
|
return units;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue