(edit): Rewrite of undocumented and broken feature: if there are extra
arguments, they are interpreted as key-value pairs, and edit does not prompt for more. From Ron Koenderink. (player_coms): Document extended syntax.
This commit is contained in:
parent
e07fb30663
commit
be168eba05
3 changed files with 48 additions and 28 deletions
|
@ -1,7 +1,17 @@
|
||||||
.TH Command EDIT
|
.TH Command EDIT
|
||||||
.NA edit "Change stats of country, ship, land unit, or plane"
|
.NA edit "Change stats of country, ship, land unit, or plane"
|
||||||
.LV Expert
|
.LV Expert
|
||||||
.SY "edit <country|unit|ship|plane|nuke>"
|
.SY "edit <country|land|unit|ship|plane|nuke> [<KEY> <VALUE>]..."
|
||||||
Once you specify what you want to edit, the server will tell you what
|
The \*Qedit\*U command allows deities to edit properties of a country,
|
||||||
to do. Hit return to get out of the prompter.
|
sector (confusingly called <land> here), land unit, ship, plane or
|
||||||
|
nuke.
|
||||||
|
.s1
|
||||||
|
If you don't specify any <KEY> <VALUE> pair, \*Qedit\*U enters
|
||||||
|
interactive mode. Editable properties are shown together with their
|
||||||
|
keys and values. Enter a key character and a value to change a
|
||||||
|
property. Hit return to finish the command.
|
||||||
|
.s1
|
||||||
|
You can also specify one or more <KEY> <VALUE> pairs as command
|
||||||
|
arguments. In this case, \*Qedit\*U just sets the properties, and
|
||||||
|
does not enter interactive mode.
|
||||||
.SA "setsector, setresource, give, Deity"
|
.SA "setsector, setresource, give, Deity"
|
||||||
|
|
|
@ -87,6 +87,7 @@ edit(void)
|
||||||
int num;
|
int num;
|
||||||
int arg;
|
int arg;
|
||||||
int err;
|
int err;
|
||||||
|
int arg_index = 3;
|
||||||
coord x, y;
|
coord x, y;
|
||||||
float farg;
|
float farg;
|
||||||
natid nat;
|
natid nat;
|
||||||
|
@ -158,11 +159,19 @@ edit(void)
|
||||||
pr_land(&land);
|
pr_land(&land);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (player->argp[4] != 0)
|
}
|
||||||
(void)strcat(player->argp[3], player->argp[4]);
|
|
||||||
ptr = &buf[0];
|
ptr = &buf[0];
|
||||||
*ptr = 0;
|
*ptr = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
if (player->argp[arg_index] != 0) {
|
||||||
|
if (player->argp[arg_index+1] != 0) {
|
||||||
|
thing = player->argp[arg_index++];
|
||||||
|
ptr = player->argp[arg_index++];
|
||||||
|
arg = atoi(ptr);
|
||||||
|
} else
|
||||||
|
return RET_SYN;
|
||||||
|
}
|
||||||
|
else if (arg_index == 3) {
|
||||||
if ((err = getin(&thing, &ptr, &arg, buf)) != RET_OK) {
|
if ((err = getin(&thing, &ptr, &arg, buf)) != RET_OK) {
|
||||||
if (err == END) {
|
if (err == END) {
|
||||||
switch (ewhat) {
|
switch (ewhat) {
|
||||||
|
@ -186,6 +195,8 @@ edit(void)
|
||||||
} else
|
} else
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
break;
|
||||||
switch (ewhat) {
|
switch (ewhat) {
|
||||||
case 'c':
|
case 'c':
|
||||||
farg = atof(ptr);
|
farg = atof(ptr);
|
||||||
|
@ -206,7 +217,6 @@ edit(void)
|
||||||
return RET_FAIL;
|
return RET_FAIL;
|
||||||
break;
|
break;
|
||||||
case 'u':
|
case 'u':
|
||||||
farg = atof(ptr);
|
|
||||||
if ((err = dounit(thing[0], arg, ptr, &land))
|
if ((err = dounit(thing[0], arg, ptr, &land))
|
||||||
!= RET_OK)
|
!= RET_OK)
|
||||||
return err;
|
return err;
|
||||||
|
|
|
@ -287,7 +287,7 @@ struct cmndstr player_coms[] = {
|
||||||
{"drop <cargo-PLANES> <fighter-PLANES> <ap-SECT> <PATH|DESTINATION> <COMM>", 1, drop, C_MOD, NORM + MONEY + CAP},
|
{"drop <cargo-PLANES> <fighter-PLANES> <ap-SECT> <PATH|DESTINATION> <COMM>", 1, drop, C_MOD, NORM + MONEY + CAP},
|
||||||
{"dump <SECTS> [<fields>]", 0, dump, 0, NORM},
|
{"dump <SECTS> [<fields>]", 0, dump, 0, NORM},
|
||||||
{"echo [<string>]", 0, echo, 0, NORM},
|
{"echo [<string>]", 0, echo, 0, NORM},
|
||||||
{"edit <country|land|unit|ship|plane|nuke>", 0, edit, C_MOD, GOD},
|
{"edit <country|land|unit|ship|plane|nuke> [<KEY> <VALUE>]...", 0, edit, C_MOD, GOD},
|
||||||
{"enable", 0, enab, C_MOD, GOD},
|
{"enable", 0, enab, C_MOD, GOD},
|
||||||
{"enlist <SECTS> <NUM>", 2, enli, C_MOD, NORM + MONEY + CAP},
|
{"enlist <SECTS> <NUM>", 2, enli, C_MOD, NORM + MONEY + CAP},
|
||||||
{"execute <INPUT FILE>", 0, execute, 0, VIS},
|
{"execute <INPUT FILE>", 0, execute, 0, VIS},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue