2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2004, 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)
100 snxtitem_xy(&ni, EF_SHIP, x, y);
101 while (nxtitem(&ni, (s_char *)&ship)) {
102 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
104 if (ship.shp_own != own
105 && getrel(getnatp(ship.shp_own), own) != ALLIED)
107 if (ship.shp_effic < SHP_AIROPS_EFF)
109 mp = &mchr[(int)ship.shp_type];
111 if ((mp->m_flags & wantflags) == 0)
115 if (mp->m_flags & nowantflags)
119 pr(" # owner eff type\n");
122 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
123 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
130 unitsatxy(coord x, coord y, int wantflags, int nowantflags)
140 snxtitem_xy(&ni, EF_LAND, x, y);
141 while (nxtitem(&ni, (s_char *)&land)) {
142 if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0)
144 /* Can't bomb units on ships or other units */
145 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
147 lp = &lchr[(int)land.lnd_type];
150 if ((lp->l_flags & wantflags) == 0)
154 if (lp->l_flags & nowantflags)
158 if (lp->l_flags & L_SPY) {
159 if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
164 pr(" # owner eff type\n");
167 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
168 cname(land.lnd_own), effadv(land.lnd_effic), prland(&land));
175 planesatxy(coord x, coord y, int wantflags, int nowantflags,
176 struct emp_qelem *list)
182 struct plchrstr *plp;
186 snxtitem_xy(&ni, EF_PLANE, x, y);
187 while (nxtitem(&ni, (s_char *)&plane)) {
188 if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0)
190 if (plane.pln_flags & PLN_LAUNCHED)
192 /* Is this plane one of the ones flying somewhere? */
193 if (ac_isflying(&plane, list))
195 plp = &plchr[(int)plane.pln_type];
197 pr(" # owner eff type\n");
201 if ((plp->pl_flags & wantflags) == 0)
205 if (plp->pl_flags & nowantflags)
208 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
209 cname(plane.pln_own), effadv(plane.pln_effic), prplane(&plane));
216 asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
217 struct plnstr *pp, struct shiplook *head)
227 snxtitem_xy(&ni, EF_SHIP, x, y);
228 while (nxtitem(&ni, (s_char *)&ship)) {
231 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
233 mp = &mchr[(int)ship.shp_type];
235 if ((mp->m_flags & wantflags) == 0)
239 if (mp->m_flags & nowantflags)
242 if (mp->m_flags & M_SUB) {
243 if (roll(100) > pln_hitchance(pp,
244 shp_hardtarget(&ship), EF_SHIP))
247 set_have_found(ship.shp_uid, head);
249 pr(" # owner eff type\n");
252 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
253 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
260 num_shipsatxy(coord x, coord y, int wantflags, int nowantflags)
268 snxtitem_xy(&ni, EF_SHIP, x, y);
269 while (nxtitem(&ni, (s_char *)&ship)) {
270 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
272 mp = &mchr[(int)ship.shp_type];
274 if ((mp->m_flags & wantflags) == 0)
278 if (mp->m_flags & nowantflags)
287 * is p a list of ships/planes/units?
299 if (!isdigit(*(p + x)) && (*(p + x) != '/'))