extern int planesatxy(coord, coord, int, int);
extern int asw_shipsatxy(coord, coord, int, int, struct plnstr *,
struct shiplist **);
+extern void print_shiplist(struct shiplist *);
extern int has_units(coord, coord, natid);
extern int adj_units(coord, coord, natid);
extern int islist(char *);
*
* Known contributors to this file:
* Dave Pare, 1986
- * Markus Armbruster, 2003-2014
+ * Markus Armbruster, 2003-2015
*/
#include <config.h>
#include "ship.h"
#include "xy.h"
+static void
+list_ship(struct shpstr *sp, int first)
+{
+ if (first)
+ pr(" # owner eff type\n");
+ pr("(#%3d) %10.10s %12.12s %s\n", sp->shp_uid,
+ cname(sp->shp_own), effadv(sp->shp_effic), prship(sp));
+}
+
int
shipsatxy(coord x, coord y, int wantflags, int nowantflags, int only_count)
{
if (mp->m_flags & nowantflags)
continue;
}
- if (!only_count) {
- if (!ships)
- pr(" # owner eff type\n");
- pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
- cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
- }
+ if (!only_count)
+ list_ship(&ship, !ships);
ships++;
}
return ships;
continue;
if ((carrier_planes(&ship, 0) & (P_L | P_K)) == 0)
continue;
- if (!ships)
- pr(" # owner eff type\n");
- pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
- cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
+ list_ship(&ship, !ships);
ships++;
}
return ships;
continue;
}
add_shiplist(ship.shp_uid, head);
- if (!ships)
- pr(" # owner eff type\n");
- pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
- cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
+ list_ship(&ship, !ships);
ships++;
}
return ships;
}
+void
+print_shiplist(struct shiplist *head)
+{
+ struct shiplist *s;
+ struct shpstr ship;
+
+ for (s = head; s; s = s->next) {
+ getship(s->uid, &ship);
+ list_ship(&ship, s == head);
+ }
+}
+
int
adj_units(coord x, coord y, natid own)
{