]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/rada.c
commands: Rename the command functions
[empserver] / src / lib / commands / rada.c
index 56b2fedd405f25b3298858ae0b214c37a945aad8..9d08255e696d5d16ac0e5a9e1508f2a761a7faf9 100644 (file)
@@ -1,11 +1,11 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
- *                           Ken Stevens, Steve McClure
+ *  Copyright (C) 1986-2021, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *                Ken Stevens, Steve McClure, Markus Armbruster
  *
- *  This program is free software; you can redistribute it and/or modify
+ *  Empire is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation, either version 3 of the License, or
  *  (at your option) any later version.
  *
  *  This program is distributed in the hope that it will be useful,
@@ -14,8 +14,7 @@
  *  GNU General Public License for more details.
  *
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  *
  *  ---
  *
 #include <config.h>
 
 #include "commands.h"
-#include "optlist.h"
-#include "empobj.h"
+#include "unit.h"
 
 int
-rada(void)
+c_radar(void)
 {
     return radar(EF_SHIP);
 }
 
 int
-lrad(void)
+c_lradar(void)
 {
     return radar(EF_LAND);
 }
@@ -54,7 +52,8 @@ radar(int type)
 {
     char *cp;
     double tf;
-    double tech;
+    double tlev;
+    int spy;
     struct nstr_item ni;
     struct nstr_sect ns;
     union empobj_storage item;
@@ -73,23 +72,21 @@ radar(int type)
     case NS_AREA:
        if (!snxtsct(&ns, cp))
            return RET_SYN;
-       tech = tfact(player->cnum, 8.0);
+       tlev = getnatp(player->cnum)->nat_level[NAT_TLEV];
        while (nxtsct(&ns, &item.sect)) {
            if (item.sect.sct_type != SCT_RADAR)
                continue;
            if (!player->owner)
                continue;
            radmap(item.sect.sct_x, item.sect.sct_y, item.sect.sct_effic,
-                  (int)(tech * 2.0), 0.0);
+                  tlev, 16, 0.0);
        }
        break;
     case NS_LIST:
     case NS_GROUP:
        /* assumes a NS_LIST return is a unit no */
-       if (!snxtitem(&ni, type, cp, NULL)) {
-           pr("Specify at least one %s\n", ef_nameof(type));
+       if (!snxtitem(&ni, type, cp, NULL))
            return RET_SYN;
-       }
        while (nxtitem(&ni, &item)) {
            if (!player->owner)
                continue;
@@ -97,23 +94,28 @@ radar(int type)
            if (type == EF_SHIP) {
                if (mchr[(int)item.ship.shp_type].m_flags & M_SONAR)
                    tf = techfact(item.ship.shp_tech, 1.0);
-               tech = techfact(item.ship.shp_tech,
-                               mchr[(int)item.ship.shp_type].m_vrnge);
+               spy = mchr[item.ship.shp_type].m_vrnge;
            } else {
                if (!(lchr[(int)item.land.lnd_type].l_flags & L_RADAR)) {
                    pr("%s can't use radar!\n", prland(&item.land));
                    continue;
                }
                if (item.land.lnd_ship >= 0) {
-                   pr("Units on ships can't use radar!\n");
+                   pr("%s is stowed on ship #%d, and can't use radar!\n",
+                      prland(&item.land), item.land.lnd_ship);
+                   continue;
+               }
+               if (item.land.lnd_land >= 0) {
+                   pr("%s is stowed on land #%d, and can't use radar!\n",
+                      prland(&item.land), item.land.lnd_land);
                    continue;
                }
-               tech = techfact(item.land.lnd_tech,
-                               lchr[item.land.lnd_type].l_spy);
+               spy = lchr[item.land.lnd_type].l_spy;
            }
 
-           pr("%s at ", obj_nameof(&item.gen));
-           radmap(item.gen.x, item.gen.y, item.gen.effic, (int)tech, tf);
+           pr("%s at ", unit_nameof(&item.gen));
+           radmap(item.gen.x, item.gen.y, item.gen.effic,
+                  item.gen.tech, spy, tf);
        }
        break;
     default: