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:
43 #include "prototypes.h"
46 shipsatxy(coord x, coord y, int wantflags, int nowantflags)
56 snxtitem_xy(&ni, EF_SHIP, x, y);
57 while (nxtitem(&ni, (s_char *)&ship)) {
60 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
62 mp = &mchr[(int)ship.shp_type];
64 if ((mp->m_flags & wantflags) == 0)
68 if (mp->m_flags & nowantflags)
72 pr(" # owner eff type\n");
75 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
76 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
82 /* This one only shows owned or allied ships */
85 carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
95 snxtitem_xy(&ni, EF_SHIP, x, y);
96 while (nxtitem(&ni, (s_char *)&ship)) {
97 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
99 if (ship.shp_own != own
100 && getrel(getnatp(ship.shp_own), own) != ALLIED)
102 if (ship.shp_effic < SHP_AIROPS_EFF)
104 mp = &mchr[(int)ship.shp_type];
106 if ((mp->m_flags & wantflags) == 0)
110 if (mp->m_flags & nowantflags)
114 pr(" # owner eff type\n");
117 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
118 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
125 unitsatxy(coord x, coord y, int wantflags, int nowantflags)
135 snxtitem_xy(&ni, EF_LAND, x, y);
136 while (nxtitem(&ni, (s_char *)&land)) {
137 if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0)
139 /* Can't bomb units on ships or other units */
140 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
142 lp = &lchr[(int)land.lnd_type];
145 if ((lp->l_flags & wantflags) == 0)
149 if (lp->l_flags & nowantflags)
153 if (lp->l_flags & L_SPY) {
154 if (!(chance(LND_SPY_DETECT_CHANCE(land.lnd_effic))))
159 pr(" # owner eff type\n");
162 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
163 cname(land.lnd_own), effadv(land.lnd_effic), prland(&land));
170 planesatxy(coord x, coord y, int wantflags, int nowantflags,
171 struct emp_qelem *list)
177 struct plchrstr *plp;
181 snxtitem_xy(&ni, EF_PLANE, x, y);
182 while (nxtitem(&ni, (s_char *)&plane)) {
183 if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0)
185 if (plane.pln_flags & PLN_LAUNCHED)
187 /* Is this plane one of the ones flying somewhere? */
188 if (ac_isflying(&plane, list))
190 plp = &plchr[(int)plane.pln_type];
192 pr(" # owner eff type\n");
196 if ((plp->pl_flags & wantflags) == 0)
200 if (plp->pl_flags & nowantflags)
203 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
204 cname(plane.pln_own), effadv(plane.pln_effic), prplane(&plane));
211 asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
212 struct plnstr *pp, struct shiplook *head)
222 snxtitem_xy(&ni, EF_SHIP, x, y);
223 while (nxtitem(&ni, (s_char *)&ship)) {
226 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
228 mp = &mchr[(int)ship.shp_type];
230 if ((mp->m_flags & wantflags) == 0)
234 if (mp->m_flags & nowantflags)
237 if (mp->m_flags & M_SUB) {
238 if (roll(100) > pln_hitchance(pp,
239 shp_hardtarget(&ship), EF_SHIP))
242 set_have_found(ship.shp_uid, head);
244 pr(" # owner eff type\n");
247 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
248 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
255 num_shipsatxy(coord x, coord y, int wantflags, int nowantflags)
263 snxtitem_xy(&ni, EF_SHIP, x, y);
264 while (nxtitem(&ni, (s_char *)&ship)) {
265 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
267 mp = &mchr[(int)ship.shp_type];
269 if ((mp->m_flags & wantflags) == 0)
273 if (mp->m_flags & nowantflags)
282 * is p a list of ships/planes/units?
294 if (!isdigit(*(p + x)) && (*(p + x) != '/'))