]> git.pond.sub.org Git - empserver/commitdiff
Clean up bmap commands' flags argument
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 10 Apr 2011 05:43:04 +0000 (07:43 +0200)
committerMarkus Armbruster <armbru@pond.sub.org>
Thu, 14 Apr 2011 18:21:22 +0000 (20:21 +0200)
parse_map_flags() silently truncates map flags after the first 't' or
'r'.  This makes it accept arguments "true" and "revert".  However, it
also breaks the perfectly sensible argument "ts", which should show
ships just like "st", but doesn't.

info bmap & friends document arguments "true" and "revert", and also
suggest flags 't' and 'r'.  What a mess.

Make argument "revert" a special case.  Deprecate flag 'r', and clean
up truncation there.

Don't truncate after flag 't'.  If any bad flags follow, ignore
everything after 't', but deprecate that usage.

info/bmap.t
info/lbmap.t
info/nbmap.t
info/pbmap.t
info/sbmap.t
info/sharebmap.t
src/lib/subs/maps.c

index 5b0be26e5742b5ce5c7157761cd22ba9845271bc..ba2d2908f8727ccd318cd181fe93d24415fd8b8d 100644 (file)
@@ -77,12 +77,15 @@ A '*' will put all on the map.
 When multiple unit types are selected they are displayed
 in the following priority order: nukes, land units, ships, planes.
 To highlight sectors you own, specify the 'h' flag.
+With the 't' flag, the command shows your true bmap rather than your
+working bmap.
+.s1
+.L "Working and true bmap"
 .s1
 You actually have two bmaps.  One which is created by the server; this
 one is called your 'true' bmap.  You can view your true bmap at any
-time using the
-.SY "bmap <SECTS|SHIP> true"
-command.  However, usually when you view your bmap, you are looking at
+time using the 't' bmap flag.
+However, usually when you view your bmap, you are looking at
 your 'working' bmap.  The only difference between your working bmap
 and your true bmap is that your working bmap also contains
 designations put on there by you using the 'bdes' command, and by your
index 79fd44115839ef6f2c993565328fbd5726539c36..4db089ca3f31372bf77a0fe6b89b27f7b3cbf166 100644 (file)
@@ -79,12 +79,15 @@ A '*' will put all on the map.
 When multiple unit types are selected they are displayed
 in the following priority order: nukes, land units, ships, planes.
 To highlight sectors you own, specify the 'h' flag.
+With the 't' flag, the command shows your true bmap rather than your
+working bmap.
+.s1
+.L "Working and true bmap"
 .s1
 You actually have two bmaps.  One which is created by the server; this
 one is called your 'true' bmap.  You can view your true bmap at any
-time using the
-.SY "lbmap <SECTS|LAND UNIT> true"
-command.  However, usually when you view your bmap, you are looking at
+time using the 't' bmap flag.
+However, usually when you view your bmap, you are looking at
 your 'working' bmap.  The only difference between your working bmap
 and your true bmap is that your working bmap also contains
 designations put on there by you using the 'bdes' command, and by your
index 1e35a2e542e95d1a6d9dd69ce85fdd12140cf976..1d80de6460886a6bcca96679196708846fdfc73c 100644 (file)
@@ -77,12 +77,15 @@ A '*' will put all on the map.
 When multiple unit types are selected they are displayed
 in the following priority order: nukes, land units, ships, planes.
 To highlight sectors you own, specify the 'h' flag.
+With the 't' flag, the command shows your true bmap rather than your
+working bmap.
+.s1
+.L "Working and true bmap"
 .s1
 You actually have two bmaps.  One which is created by the server; this
 one is called your 'true' bmap.  You can view your true bmap at any
-time using the
-.SY "nbmap <SECTS|NUKE> true"
-command.  However, usually when you view your bmap, you are looking at
+time using the 't' bmap flag.
+However, usually when you view your bmap, you are looking at
 your 'working' bmap.  The only difference between your working bmap
 and your true bmap is that your working bmap also contains
 designations put on there by you using the 'bdes' command, and by your
index 0c2cf79bbadaf0ec6d23391a8a531b044b82fb22..01f12a2e775a74e8c9bd3257a0ac6597c4297540 100644 (file)
@@ -77,12 +77,15 @@ A '*' will put all on the map.
 When multiple unit types are selected they are displayed
 in the following priority order: nukes, land units, ships, planes.
 To highlight sectors you own, specify the 'h' flag.
+With the 't' flag, the command shows your true bmap rather than your
+working bmap.
+.s1
+.L "Working and true bmap"
 .s1
 You actually have two bmaps.  One which is created by the server; this
 one is called your 'true' bmap.  You can view your true bmap at any
-time using the
-.SY "pbmap <SECTS|PLANE> true"
-command.  However, usually when you view your bmap, you are looking at
+time using the 't' bmap flag.
+However, usually when you view your bmap, you are looking at
 your 'working' bmap.  The only difference between your working bmap
 and your true bmap is that your working bmap also contains
 designations put on there by you using the 'bdes' command, and by your
index 7213579eb669c7f19035abd80e418b947b4280f7..c7f9eb983e3b5c00397fa64b559415b108c440a5 100644 (file)
@@ -79,12 +79,15 @@ A '*' will put all on the map.
 When multiple unit types are selected they are displayed
 in the following priority order: nukes, land units, ships, planes.
 To highlight sectors you own, specify the 'h' flag.
+With the 't' flag, the command shows your true bmap rather than your
+working bmap.
+.s1
+.L "Working and true bmap"
 .s1
 You actually have two bmaps.  One which is created by the server; this
 one is called your 'true' bmap.  You can view your true bmap at any
-time using the
-.SY "sbmap <SECTS|SHIP> true"
-command.  However, usually when you view your bmap, you are looking at
+time using the 't' bmap flag.
+However, usually when you view your bmap, you are looking at
 your 'working' bmap.  The only difference between your working bmap
 and your true bmap is that your working bmap also contains
 designations put on there by you using the 'bdes' command, and by your
index 527b0d09dcb11a53b8c649f45cbc85c3674af5db..173fb21808b0454aa5d64bd88332be77ee39af72 100644 (file)
@@ -29,7 +29,7 @@ not lose any information in this exchange.
 .s1
 Note that the sharebmap command only changes your 'working' bmap and
 so you can delete sharebmap information from your bmap by typing:
-.EX "bmap revert"
+.EX "bmap <SECTS> revert"
 See 'info bmap' for more details.
 .s1
 .SA "bdes, bmap, Communication, Maps"
index 7b2a7334a8ca809ec597ea2a2da9499d0d53c610..f10d251d35149b2eb103dd69a19ff4173c2e33e4 100644 (file)
@@ -41,6 +41,7 @@
 #include "file.h"
 #include "land.h"
 #include "map.h"
+#include "match.h"
 #include "misc.h"
 #include "nat.h"
 #include "nsc.h"
@@ -104,11 +105,21 @@ do_map(int bmap, int unit_type, char *arg, char *map_flags_arg)
     return draw_map(origin, map_flags, &ns);
 }
 
+static void
+warn_deprecated_arg(char *what, char *arg, char *use)
+{
+    pr("%s '%s' is deprecated and will go away in a future release.\n"
+       "Use %s instead.\n",
+       what, arg, use);
+}
+
 static int
 parse_map_flags(int bmap, char *str)
 {
     int map_flags;
     char *p;
+    int tflags = 0;
+    char *tp = NULL;
 
     switch (bmap) {
     default: CANT_REACH();
@@ -121,6 +132,10 @@ parse_map_flags(int bmap, char *str)
     if (!str)
        return map_flags;
 
+    /* special case "revert" */
+    if (bmap == 'b' && mineq(str, "revert") != ME_MISMATCH)
+       return MAP_BMAP_REVERT;
+
     for (p = str; *p; p++) {
        switch (*p) {
        case 's':
@@ -149,13 +164,29 @@ parse_map_flags(int bmap, char *str)
        case 't':
            if (bmap != 'b')
                goto bad_flag;
-           return map_flags | MAP_ALT;
+           map_flags |= MAP_ALT;
+           /*
+            * Flags following 't' used to be ignored.  That breaks
+            * perfectly sensible "ts".  Try to continue, but save
+            * state for when a bad flag is found.
+            */
+           if (!tflags) {
+               tflags = map_flags;
+               tp = p;
+           }
+           break;
        case 'r':
-           if (bmap != 'b')
+           if (bmap != 'b' || tflags)
                goto bad_flag;
+           warn_deprecated_arg("Map flag", "r", "argument 'revert'");
            return MAP_BMAP_REVERT;
        default:
        bad_flag:
+           if (tflags) {
+               /* ignore bad flags following 't' */
+               warn_deprecated_arg("Argument", tp, "map flag 't'");
+               return tflags;
+           }
            pr("Bad flag %c!\n", *p);
            return -1;
        }