]> git.pond.sub.org Git - empserver/commitdiff
Simplify map(): use getstarg() instead of getstring()
authorMarkus Armbruster <armbru@pond.sub.org>
Mon, 11 Apr 2011 17:49:10 +0000 (19:49 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 14 Apr 2011 18:21:23 +0000 (20:21 +0200)
src/lib/commands/map.c

index cbce5548ee3646ab62d13bb8e3693e32f85d0f9e..cc8a46e4346a30b0323b87f34a661f89dcd98980 100644 (file)
@@ -29,6 +29,8 @@
  *  Known contributors to this file:
  *     Dave Pare, 1986
  *     Ken Stevens, 1995
+ *     Marc Olzheim, 2004
+ *     Markus Armbruster, 2005-2011
  */
 
 #include <config.h>
@@ -44,9 +46,9 @@ map(void)
 {
     int unit_type = EF_BAD;
     int bmap = 0;
-    char *str;
+    char *str, *prompt;
     char buf[1024];
-    char prompt[128];
+    char prompt_buf[128];
 
     if (**player->argp != 'm') {
        if (**player->argp == 'b')
@@ -73,18 +75,15 @@ map(void)
        }
     }
 
-    if (!player->argp[1] || !*player->argp[1]) {
-       if (unit_type == EF_BAD) {
-           str = getstring("(sects)? ", buf);
-       } else {
-           sprintf(prompt, "(sects, %s)? ", ef_nameof(unit_type));
-           str = getstring(prompt, buf);
-       }
-
-       if (!str || !*str)
-           return RET_SYN;
-    } else
-       str = player->argp[1];
+    if (unit_type == EF_BAD)
+       prompt = "(sects)? ";
+    else {
+       sprintf(prompt_buf, "(sects, %s)? ", ef_nameof(unit_type));
+       prompt = prompt_buf;
+    }
+    str = getstarg(player->argp[1], prompt, buf);
+    if (!str || !*str)
+       return RET_SYN;
 
     if (unit_type == EF_BAD)
        unit_type = EF_SHIP;