2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2000, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * See the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23 * related information and legal notices. It is expected that any future
24 * projects/authors will amend these files as needed.
28 * list.c: List ships, planes, units at a given x,y
30 * Known contributors to this file:
48 #include "prototypes.h"
51 shipsatxy(coord x, coord y, int wantflags, int nowantflags)
61 snxtitem_xy(&ni, EF_SHIP, x, y);
62 while (nxtitem(&ni, (s_char *)&ship)) {
65 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
67 mp = &mchr[(int)ship.shp_type];
69 if ((mp->m_flags & wantflags) == 0)
73 if (mp->m_flags & nowantflags)
77 pr(" # owner eff type\n");
80 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
81 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
87 /* This one only shows owned or allied ships */
90 carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
101 snxtitem_xy(&ni, EF_SHIP, x, y);
102 while (nxtitem(&ni, (s_char *)&ship)) {
103 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
105 allied = (getrel(getnatp(ship.shp_own), own) == ALLIED);
106 if ((ship.shp_own != own) & !allied)
108 mp = &mchr[(int)ship.shp_type];
110 if ((mp->m_flags & wantflags) == 0)
114 if (mp->m_flags & nowantflags)
118 pr(" # owner eff type\n");
121 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
122 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
129 unitsatxy(coord x, coord y, int wantflags, int nowantflags)
139 snxtitem_xy(&ni, EF_LAND, x, y);
140 while (nxtitem(&ni, (s_char *)&land)) {
141 if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0)
143 /* Can't bomb units on ships or other units */
144 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
146 lp = &lchr[(int)land.lnd_type];
149 if ((lp->l_flags & wantflags) == 0)
153 if (lp->l_flags & nowantflags)
157 if (lp->l_flags & L_SPY) {
158 if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
163 pr(" # owner eff type\n");
166 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
167 cname(land.lnd_own), effadv(land.lnd_effic), prland(&land));
174 planesatxy(coord x, coord y, int wantflags, int nowantflags,
175 struct emp_qelem *list)
181 struct plchrstr *plp;
185 snxtitem_xy(&ni, EF_PLANE, x, y);
186 while (nxtitem(&ni, (s_char *)&plane)) {
187 if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0)
189 if (plane.pln_flags & PLN_LAUNCHED)
191 /* Is this plane one of the ones flying somewhere? */
192 if (ac_isflying(&plane, list))
194 plp = &plchr[(int)plane.pln_type];
196 pr(" # owner eff type\n");
200 if ((plp->pl_flags & wantflags) == 0)
204 if (plp->pl_flags & nowantflags)
207 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
208 cname(plane.pln_own), effadv(plane.pln_effic), prplane(&plane));
215 asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
216 struct plnstr *pp, struct shiplook *head)
226 snxtitem_xy(&ni, EF_SHIP, x, y);
227 while (nxtitem(&ni, (s_char *)&ship)) {
230 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
232 mp = &mchr[(int)ship.shp_type];
234 if ((mp->m_flags & wantflags) == 0)
238 if (mp->m_flags & nowantflags)
241 if (mp->m_flags & M_SUB) {
242 if (roll(100) > pln_hitchance(pp,
243 shp_hardtarget(&ship), EF_SHIP))
246 set_have_found(ship.shp_uid, head);
248 pr(" # owner eff type\n");
251 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
252 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
259 num_shipsatxy(coord x, coord y, int wantflags, int nowantflags)
267 snxtitem_xy(&ni, EF_SHIP, x, y);
268 while (nxtitem(&ni, (s_char *)&ship)) {
269 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
271 mp = &mchr[(int)ship.shp_type];
273 if ((mp->m_flags & wantflags) == 0)
277 if (mp->m_flags & nowantflags)
286 * is p a list of ships/planes/units?
298 if (!isdigit(*(p + x)) && (*(p + x) != '/'))