From a00f9e200e610920bd59e5fa9537902149143424 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Sun, 10 Apr 2011 07:43:04 +0200 Subject: [PATCH] Clean up bmap commands' flags argument 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 | 9 ++++++--- info/lbmap.t | 9 ++++++--- info/nbmap.t | 9 ++++++--- info/pbmap.t | 9 ++++++--- info/sbmap.t | 9 ++++++--- info/sharebmap.t | 2 +- src/lib/subs/maps.c | 35 +++++++++++++++++++++++++++++++++-- 7 files changed, 64 insertions(+), 18 deletions(-) diff --git a/info/bmap.t b/info/bmap.t index 5b0be26e..ba2d2908 100644 --- a/info/bmap.t +++ b/info/bmap.t @@ -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 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 diff --git a/info/lbmap.t b/info/lbmap.t index 79fd4411..4db089ca 100644 --- a/info/lbmap.t +++ b/info/lbmap.t @@ -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 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 diff --git a/info/nbmap.t b/info/nbmap.t index 1e35a2e5..1d80de64 100644 --- a/info/nbmap.t +++ b/info/nbmap.t @@ -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 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 diff --git a/info/pbmap.t b/info/pbmap.t index 0c2cf79b..01f12a2e 100644 --- a/info/pbmap.t +++ b/info/pbmap.t @@ -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 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 diff --git a/info/sbmap.t b/info/sbmap.t index 7213579e..c7f9eb98 100644 --- a/info/sbmap.t +++ b/info/sbmap.t @@ -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 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 diff --git a/info/sharebmap.t b/info/sharebmap.t index 527b0d09..173fb218 100644 --- a/info/sharebmap.t +++ b/info/sharebmap.t @@ -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 revert" See 'info bmap' for more details. .s1 .SA "bdes, bmap, Communication, Maps" diff --git a/src/lib/subs/maps.c b/src/lib/subs/maps.c index 7b2a7334..f10d251d 100644 --- a/src/lib/subs/maps.c +++ b/src/lib/subs/maps.c @@ -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; }