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.
This commit is contained in:
parent
457f797972
commit
a00f9e200e
7 changed files with 64 additions and 18 deletions
|
@ -77,12 +77,15 @@ A '*' will put all on the map.
|
||||||
When multiple unit types are selected they are displayed
|
When multiple unit types are selected they are displayed
|
||||||
in the following priority order: nukes, land units, ships, planes.
|
in the following priority order: nukes, land units, ships, planes.
|
||||||
To highlight sectors you own, specify the 'h' flag.
|
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
|
.s1
|
||||||
You actually have two bmaps. One which is created by the server; this
|
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
|
one is called your 'true' bmap. You can view your true bmap at any
|
||||||
time using the
|
time using the 't' bmap flag.
|
||||||
.SY "bmap <SECTS|SHIP> true"
|
However, usually when you view your bmap, you are looking at
|
||||||
command. However, usually when you view your bmap, you are looking at
|
|
||||||
your 'working' bmap. The only difference between your working bmap
|
your 'working' bmap. The only difference between your working bmap
|
||||||
and your true bmap is that your working bmap also contains
|
and your true bmap is that your working bmap also contains
|
||||||
designations put on there by you using the 'bdes' command, and by your
|
designations put on there by you using the 'bdes' command, and by your
|
||||||
|
|
|
@ -79,12 +79,15 @@ A '*' will put all on the map.
|
||||||
When multiple unit types are selected they are displayed
|
When multiple unit types are selected they are displayed
|
||||||
in the following priority order: nukes, land units, ships, planes.
|
in the following priority order: nukes, land units, ships, planes.
|
||||||
To highlight sectors you own, specify the 'h' flag.
|
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
|
.s1
|
||||||
You actually have two bmaps. One which is created by the server; this
|
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
|
one is called your 'true' bmap. You can view your true bmap at any
|
||||||
time using the
|
time using the 't' bmap flag.
|
||||||
.SY "lbmap <SECTS|LAND UNIT> true"
|
However, usually when you view your bmap, you are looking at
|
||||||
command. However, usually when you view your bmap, you are looking at
|
|
||||||
your 'working' bmap. The only difference between your working bmap
|
your 'working' bmap. The only difference between your working bmap
|
||||||
and your true bmap is that your working bmap also contains
|
and your true bmap is that your working bmap also contains
|
||||||
designations put on there by you using the 'bdes' command, and by your
|
designations put on there by you using the 'bdes' command, and by your
|
||||||
|
|
|
@ -77,12 +77,15 @@ A '*' will put all on the map.
|
||||||
When multiple unit types are selected they are displayed
|
When multiple unit types are selected they are displayed
|
||||||
in the following priority order: nukes, land units, ships, planes.
|
in the following priority order: nukes, land units, ships, planes.
|
||||||
To highlight sectors you own, specify the 'h' flag.
|
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
|
.s1
|
||||||
You actually have two bmaps. One which is created by the server; this
|
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
|
one is called your 'true' bmap. You can view your true bmap at any
|
||||||
time using the
|
time using the 't' bmap flag.
|
||||||
.SY "nbmap <SECTS|NUKE> true"
|
However, usually when you view your bmap, you are looking at
|
||||||
command. However, usually when you view your bmap, you are looking at
|
|
||||||
your 'working' bmap. The only difference between your working bmap
|
your 'working' bmap. The only difference between your working bmap
|
||||||
and your true bmap is that your working bmap also contains
|
and your true bmap is that your working bmap also contains
|
||||||
designations put on there by you using the 'bdes' command, and by your
|
designations put on there by you using the 'bdes' command, and by your
|
||||||
|
|
|
@ -77,12 +77,15 @@ A '*' will put all on the map.
|
||||||
When multiple unit types are selected they are displayed
|
When multiple unit types are selected they are displayed
|
||||||
in the following priority order: nukes, land units, ships, planes.
|
in the following priority order: nukes, land units, ships, planes.
|
||||||
To highlight sectors you own, specify the 'h' flag.
|
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
|
.s1
|
||||||
You actually have two bmaps. One which is created by the server; this
|
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
|
one is called your 'true' bmap. You can view your true bmap at any
|
||||||
time using the
|
time using the 't' bmap flag.
|
||||||
.SY "pbmap <SECTS|PLANE> true"
|
However, usually when you view your bmap, you are looking at
|
||||||
command. However, usually when you view your bmap, you are looking at
|
|
||||||
your 'working' bmap. The only difference between your working bmap
|
your 'working' bmap. The only difference between your working bmap
|
||||||
and your true bmap is that your working bmap also contains
|
and your true bmap is that your working bmap also contains
|
||||||
designations put on there by you using the 'bdes' command, and by your
|
designations put on there by you using the 'bdes' command, and by your
|
||||||
|
|
|
@ -79,12 +79,15 @@ A '*' will put all on the map.
|
||||||
When multiple unit types are selected they are displayed
|
When multiple unit types are selected they are displayed
|
||||||
in the following priority order: nukes, land units, ships, planes.
|
in the following priority order: nukes, land units, ships, planes.
|
||||||
To highlight sectors you own, specify the 'h' flag.
|
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
|
.s1
|
||||||
You actually have two bmaps. One which is created by the server; this
|
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
|
one is called your 'true' bmap. You can view your true bmap at any
|
||||||
time using the
|
time using the 't' bmap flag.
|
||||||
.SY "sbmap <SECTS|SHIP> true"
|
However, usually when you view your bmap, you are looking at
|
||||||
command. However, usually when you view your bmap, you are looking at
|
|
||||||
your 'working' bmap. The only difference between your working bmap
|
your 'working' bmap. The only difference between your working bmap
|
||||||
and your true bmap is that your working bmap also contains
|
and your true bmap is that your working bmap also contains
|
||||||
designations put on there by you using the 'bdes' command, and by your
|
designations put on there by you using the 'bdes' command, and by your
|
||||||
|
|
|
@ -29,7 +29,7 @@ not lose any information in this exchange.
|
||||||
.s1
|
.s1
|
||||||
Note that the sharebmap command only changes your 'working' bmap and
|
Note that the sharebmap command only changes your 'working' bmap and
|
||||||
so you can delete sharebmap information from your bmap by typing:
|
so you can delete sharebmap information from your bmap by typing:
|
||||||
.EX "bmap revert"
|
.EX "bmap <SECTS> revert"
|
||||||
See 'info bmap' for more details.
|
See 'info bmap' for more details.
|
||||||
.s1
|
.s1
|
||||||
.SA "bdes, bmap, Communication, Maps"
|
.SA "bdes, bmap, Communication, Maps"
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "file.h"
|
#include "file.h"
|
||||||
#include "land.h"
|
#include "land.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
#include "match.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "nat.h"
|
#include "nat.h"
|
||||||
#include "nsc.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);
|
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
|
static int
|
||||||
parse_map_flags(int bmap, char *str)
|
parse_map_flags(int bmap, char *str)
|
||||||
{
|
{
|
||||||
int map_flags;
|
int map_flags;
|
||||||
char *p;
|
char *p;
|
||||||
|
int tflags = 0;
|
||||||
|
char *tp = NULL;
|
||||||
|
|
||||||
switch (bmap) {
|
switch (bmap) {
|
||||||
default: CANT_REACH();
|
default: CANT_REACH();
|
||||||
|
@ -121,6 +132,10 @@ parse_map_flags(int bmap, char *str)
|
||||||
if (!str)
|
if (!str)
|
||||||
return map_flags;
|
return map_flags;
|
||||||
|
|
||||||
|
/* special case "revert" */
|
||||||
|
if (bmap == 'b' && mineq(str, "revert") != ME_MISMATCH)
|
||||||
|
return MAP_BMAP_REVERT;
|
||||||
|
|
||||||
for (p = str; *p; p++) {
|
for (p = str; *p; p++) {
|
||||||
switch (*p) {
|
switch (*p) {
|
||||||
case 's':
|
case 's':
|
||||||
|
@ -149,13 +164,29 @@ parse_map_flags(int bmap, char *str)
|
||||||
case 't':
|
case 't':
|
||||||
if (bmap != 'b')
|
if (bmap != 'b')
|
||||||
goto bad_flag;
|
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':
|
case 'r':
|
||||||
if (bmap != 'b')
|
if (bmap != 'b' || tflags)
|
||||||
goto bad_flag;
|
goto bad_flag;
|
||||||
|
warn_deprecated_arg("Map flag", "r", "argument 'revert'");
|
||||||
return MAP_BMAP_REVERT;
|
return MAP_BMAP_REVERT;
|
||||||
default:
|
default:
|
||||||
bad_flag:
|
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);
|
pr("Bad flag %c!\n", *p);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue