]> git.pond.sub.org Git - empserver/blobdiff - src/lib/commands/rada.c
Fix trailing whitespace
[empserver] / src / lib / commands / rada.c
index 73d4dbb6e998a9aa42072f0196ae081eeaca7fb0..af91ceaa0faf289503c3def40aef4e671504575a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Empire - A multi-player, client/server Internet based war game.
- *  Copyright (C) 1986-2006, Dave Pare, Jeff Bailey, Thomas Ruschak,
+ *  Copyright (C) 1986-2008, Dave Pare, Jeff Bailey, Thomas Ruschak,
  *                           Ken Stevens, Steve McClure
  *
  *  This program is free software; you can redistribute it and/or modify
  *  ---
  *
  *  rada.c: Do radar from a ship/unit/sector
- * 
+ *
  *  Known contributors to this file:
- *     
+ *     Ron Koenderink, 2006
  */
 
 #include <config.h>
 
-#include <ctype.h>
 #include "commands.h"
 #include "optlist.h"
 #include "empobj.h"
 
 int
 rada(void)
+{
+    return radar(EF_SHIP);
+}
+
+int
+lrad(void)
+{
+    return radar(EF_LAND);
+}
+
+int
+radar(short type)
 {
     char *cp;
     double tf;
@@ -48,14 +59,14 @@ rada(void)
     struct nstr_sect ns;
     union empobj_storage item;
     char buf[1024];
-    short type;
     char prompt[80];
 
-    type = player->argp[0][0] == 'l' ? EF_LAND : EF_SHIP;
+    if (CANT_HAPPEN(type != EF_LAND && type != EF_SHIP))
+       type = EF_SHIP;
 
     sprintf(prompt, "Radar from (%s # or sector(s)) : ", ef_nameof(type));
     cp = getstarg(player->argp[1], prompt, buf);
-                     
+
     if (cp == 0)
        return RET_SYN;
     switch (sarg_type(cp)) {
@@ -79,7 +90,7 @@ rada(void)
     case NS_LIST:
     case NS_GROUP:
        /* assumes a NS_LIST return is a unit no */
-       if (!snxtitem(&ni, type, cp)) {
+       if (!snxtitem(&ni, type, cp, NULL)) {
            pr("Specify at least one %s\n", ef_nameof(type));
            return RET_SYN;
        }
@@ -101,7 +112,8 @@ rada(void)
                    pr("Units on ships can't use radar!\n");
                    continue;
                }
-               tech = techfact(item.land.lnd_tech, item.land.lnd_spy);
+               tech = techfact(item.land.lnd_tech,
+                               lchr[item.land.lnd_type].l_spy);
            }
 
            pr("%s at ", obj_nameof(&item.gen));