2 * Empire - A multi-player, client/server Internet based war game.
3 * Copyright (C) 1986-2006, 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 files README, COPYING and CREDITS in the root of the source
23 * tree for related information and legal notices. It is expected
24 * that future projects/authors will amend these files as needed.
28 * rada.c: Do radar from a ship/unit/sector
30 * Known contributors to this file:
63 from_unit = (**player->argp == 'l');
66 cp = getstarg(player->argp[1],
67 "Radar from (ship # or sector(s)) : ", buf);
69 cp = getstarg(player->argp[1],
70 "Radar from (unit # or sector(s)) : ", buf);
73 switch (sarg_type(cp)) {
75 if (!snxtsct(&ns, cp))
77 tech = tfact(player->cnum, 8.0);
78 if (tech > ((double)WORLD_Y / 4.0))
79 tech = ((double)WORLD_Y / 4.0);
80 if (tech > ((double)WORLD_X / 8.0))
81 tech = ((double)WORLD_X / 8.0);
82 while (nxtsct(&ns, §)) {
83 if (sect.sct_type != SCT_RADAR)
87 radmap(sect.sct_x, sect.sct_y, (int)sect.sct_effic,
88 (int)(tech * 2.0), 0.0);
94 /* assumes a NS_LIST return is a shipno */
95 if (!snxtitem(&ni, EF_SHIP, cp)) {
96 pr("Specify at least one ship\n");
99 while (nxtitem(&ni, &ship)) {
102 if (mchr[(int)ship.shp_type].m_flags & M_SONAR)
103 tf = techfact(ship.shp_tech, 1.0);
106 pr("%s at ", prship(&ship));
107 tech = techfact(ship.shp_tech,
108 (double)mchr[(int)ship.shp_type].m_vrnge);
109 if (tech > ((double)WORLD_Y / 2.0))
110 tech = ((double)WORLD_Y / 2.0);
111 if (tech > ((double)WORLD_X / 4.0))
112 tech = ((double)WORLD_X / 4.0);
113 radmap(ship.shp_x, ship.shp_y, ship.shp_effic,
117 /* from a land unit */
118 if (!snxtitem(&ni, EF_LAND, cp)) {
119 pr("Specify at least one unit\n");
122 while (nxtitem(&ni, &land)) {
125 if (!(lchr[(int)land.lnd_type].l_flags & L_RADAR)) {
126 pr("%s can't use radar!\n", prland(&land));
129 if (land.lnd_ship >= 0) {
130 pr("Units on ships can't use radar!\n");
134 pr("%s at ", prland(&land));
135 tech = techfact(land.lnd_tech, (double)land.lnd_spy);
136 if (tech > ((double)WORLD_Y / 2.0))
137 tech = ((double)WORLD_Y / 2.0);
138 if (tech > ((double)WORLD_X / 4.0))
139 tech = ((double)WORLD_X / 4.0);
140 radmap(land.lnd_x, land.lnd_y, land.lnd_effic,
147 pr("Must use a ship or sector specifier\n");
149 pr("Must use a unit or sector specifier\n");