retreat lretreat: Change query syntax to match mission
Optional arguments can save typing. Mandatory arguments are more easily discoverable: just run the command and answer its prompts. Empire traditionally uses optional arguments only for expert features. Consider mission: [0:640] Command : mission Ship, plane or land unit (p,sh,la)? s ship(s)? 0 Mission (int, sup, osup, dsup, esc, res, air, query, clear)? int operations point? . frg frigate Early Bird(#0) on an interdiction mission, centered on 21,-3, radius 0 1 ship Compare retreat: [0:638] Command : retreat ship(s)? 0 shp# ship type x,y fl path as flt? flags 0 frg frigate 21,-3 1 ship Arguments are not discoverable this way. Change retreat to work like mission: make the second argument mandatory, and if it's 'q', show retreat orders, else treat it as path and ask for conditions: [0:637] Command : retreat ship(s)? 0 Retreat path, or q to query? jj Retreat conditions ('?' to list available ones)? i shp# ship type x,y fl path as flt? flags 0 frg frigate 21,-3 jj i 1 ship To reduce smart client and script breakage, keep retreat with one argument working as before, but print a deprecation warning. Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
parent
4de4da259a
commit
482d54c953
7 changed files with 55 additions and 24 deletions
|
@ -84,10 +84,27 @@ retreat(int type)
|
|||
if (!snxtitem(&ni, type, player->argp[1], NULL))
|
||||
return RET_SYN;
|
||||
nunits = 0;
|
||||
if (player->argp[2] != NULL) {
|
||||
pq = getstarg(player->argp[2], "Retreat path? ", buf1);
|
||||
if (!pq)
|
||||
|
||||
if (player->argp[1] && !player->argp[2]) {
|
||||
pr("Omitting the second argument is deprecated and will cease to work in a\n"
|
||||
"future release. Please use '%s q' to query retreat orders.\n\n",
|
||||
player->combuf);
|
||||
pq = "q";
|
||||
} else {
|
||||
/*
|
||||
* TODO getpath() or similar would be nice once the deprecated
|
||||
* syntax is gone.
|
||||
*/
|
||||
pq = getstarg(player->argp[2], "Retreat path, or q to query? ",
|
||||
buf1);
|
||||
if (!pq || !*pq)
|
||||
return RET_SYN;
|
||||
}
|
||||
|
||||
rflags = 0;
|
||||
if (*pq == 'q') {
|
||||
pq = NULL;
|
||||
} else {
|
||||
for (i = 0; i < RET_LEN - 1 && pq[i]; i++) {
|
||||
if (chkdir(pq[i], DIR_STOP, DIR_LAST) < 0) {
|
||||
pr("'%c' is not a valid direction...\n", pq[i]);
|
||||
|
@ -97,11 +114,7 @@ retreat(int type)
|
|||
}
|
||||
for (i--; i >= 0 && pq[i] == dirch[DIR_STOP]; i--)
|
||||
pq[i] = 0;
|
||||
} else
|
||||
pq = NULL;
|
||||
|
||||
rflags = 0;
|
||||
if (pq != NULL) {
|
||||
again:
|
||||
fl = getstarg(player->argp[3],
|
||||
"Retreat conditions ('?' to list available ones)? ",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue