2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2011, Dave Pare, Jeff Bailey, Thomas Ruschak,
4 * Ken Stevens, Steve McClure, Markus Armbruster
6 * Empire 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 3 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, see <http://www.gnu.org/licenses/>.
21 * See files README, COPYING and CREDITS in the root of the source
22 * tree for related information and legal notices. It is expected
23 * that future projects/authors will amend these files as needed.
27 * rada.c: Do radar from a ship/unit/sector
29 * Known contributors to this file:
30 * Ron Koenderink, 2006
42 return radar(EF_SHIP);
48 return radar(EF_LAND);
60 union empobj_storage item;
64 if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
67 sprintf(prompt, "Radar from (%s # or sector(s)) : ", ef_nameof(type));
68 cp = getstarg(player->argp[1], prompt, buf);
72 switch (sarg_type(cp)) {
74 if (!snxtsct(&ns, cp))
76 tlev = getnatp(player->cnum)->nat_level[NAT_TLEV];
77 while (nxtsct(&ns, &item.sect)) {
78 if (item.sect.sct_type != SCT_RADAR)
82 radmap(item.sect.sct_x, item.sect.sct_y, item.sect.sct_effic,
88 /* assumes a NS_LIST return is a unit no */
89 if (!snxtitem(&ni, type, cp, NULL))
91 while (nxtitem(&ni, &item)) {
95 if (type == EF_SHIP) {
96 if (mchr[(int)item.ship.shp_type].m_flags & M_SONAR)
97 tf = techfact(item.ship.shp_tech, 1.0);
98 spy = mchr[item.ship.shp_type].m_vrnge;
100 if (!(lchr[(int)item.land.lnd_type].l_flags & L_RADAR)) {
101 pr("%s can't use radar!\n", prland(&item.land));
104 if (item.land.lnd_ship >= 0) {
105 pr("Units on ships can't use radar!\n");
108 spy = lchr[item.land.lnd_type].l_spy;
111 pr("%s at ", unit_nameof(&item.gen));
112 radmap(item.gen.x, item.gen.y, item.gen.effic,
113 item.gen.tech, spy, tf);
117 pr("Must use a %s or sector specifier\n", ef_nameof(type));