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"
50 extern s_char *effadv(int);
53 shipsatxy(coord x, coord y, int wantflags, int nowantflags)
63 snxtitem_xy(&ni, EF_SHIP, x, y);
64 while (nxtitem(&ni, (s_char *)&ship)) {
67 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
69 mp = &mchr[(int)ship.shp_type];
71 if ((mp->m_flags & wantflags) == 0)
75 if (mp->m_flags & nowantflags)
79 pr(" # owner eff type\n");
82 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
83 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
89 /* This one only shows owned or allied ships */
92 carriersatxy(coord x, coord y, int wantflags, int nowantflags, natid own)
103 snxtitem_xy(&ni, EF_SHIP, x, y);
104 while (nxtitem(&ni, (s_char *)&ship)) {
105 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
107 allied = (getrel(getnatp(ship.shp_own), own) == ALLIED);
108 if ((ship.shp_own != own) & !allied)
110 mp = &mchr[(int)ship.shp_type];
112 if ((mp->m_flags & wantflags) == 0)
116 if (mp->m_flags & nowantflags)
120 pr(" # owner eff type\n");
123 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
124 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
131 unitsatxy(coord x, coord y, int wantflags, int nowantflags)
142 snxtitem_xy(&ni, EF_LAND, x, y);
143 while (nxtitem(&ni, (s_char *)&land)) {
144 if (land.lnd_effic < LAND_MINEFF || land.lnd_own == 0)
146 /* Can't bomb units on ships or other units */
147 if (land.lnd_ship >= 0 || land.lnd_land >= 0)
149 lp = &lchr[(int)land.lnd_type];
152 if ((lp->l_flags & wantflags) == 0)
156 if (lp->l_flags & nowantflags)
160 if (lp->l_flags & L_SPY) {
161 odds = (double)(100 - land.lnd_effic) + 0.10;
167 pr(" # owner eff type\n");
170 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
171 cname(land.lnd_own), effadv(land.lnd_effic), prland(&land));
178 planesatxy(coord x, coord y, int wantflags, int nowantflags,
179 struct emp_qelem *list)
185 struct plchrstr *plp;
189 snxtitem_xy(&ni, EF_PLANE, x, y);
190 while (nxtitem(&ni, (s_char *)&plane)) {
191 if (plane.pln_effic < PLANE_MINEFF || plane.pln_own == 0)
193 if (plane.pln_flags & PLN_LAUNCHED)
195 /* Is this plane one of the ones flying somewhere? */
196 if (ac_isflying(&plane, list))
198 plp = &plchr[(int)plane.pln_type];
200 pr(" # owner eff type\n");
204 if ((plp->pl_flags & wantflags) == 0)
208 if (plp->pl_flags & nowantflags)
211 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
212 cname(plane.pln_own), effadv(plane.pln_effic), prplane(&plane));
219 asw_shipsatxy(coord x, coord y, int wantflags, int nowantflags,
220 struct plnstr *pp, struct shiplook *head)
230 snxtitem_xy(&ni, EF_SHIP, x, y);
231 while (nxtitem(&ni, (s_char *)&ship)) {
234 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
236 mp = &mchr[(int)ship.shp_type];
238 if ((mp->m_flags & wantflags) == 0)
242 if (mp->m_flags & nowantflags)
245 if (mp->m_flags & M_SUB) {
246 if (roll(100) > pln_hitchance(pp,
247 shp_hardtarget(&ship), EF_SHIP))
250 set_have_found(ship.shp_uid, head);
252 pr(" # owner eff type\n");
255 pr("(#%3d) %10.10s %12.12s %s\n", ni.cur,
256 cname(ship.shp_own), effadv(ship.shp_effic), prship(&ship));
263 num_shipsatxy(coord x, coord y, int wantflags, int nowantflags)
271 snxtitem_xy(&ni, EF_SHIP, x, y);
272 while (nxtitem(&ni, (s_char *)&ship)) {
273 if (ship.shp_effic < SHIP_MINEFF || ship.shp_own == 0)
275 mp = &mchr[(int)ship.shp_type];
277 if ((mp->m_flags & wantflags) == 0)
281 if (mp->m_flags & nowantflags)
290 * is p a list of ships/planes/units?
302 if (!isdigit(*(p + x)) && (*(p + x) != '/'))