<URL: http://bugs.freeciv.org/Ticket/Display.html?id=40062 >
Originally reported in PR#40061 for the debug command, investigation showed
that many of the commands had duplicate command usage synopses. Moreover,
the server/commands.c version was often out-of-date.
Merge all usage synopses into server/commands.c, and add missing TRANS
comments. Use proper access functions to check validity.
Index: server/commands.c
===================================================================
--- server/commands.c (revision 14344)
+++ server/commands.c (working copy)
@@ -21,9 +21,18 @@
#include "commands.h"
+struct command {
+ const char *name; /* name - will be matched by unique prefix */
+ enum cmdlevel_id level; /* access level required to use the command */
+ const char *synopsis; /* one or few-line summary of usage */
+ const char *short_help; /* one line (about 70 chars) description */
+ const char *extra_help; /* extra help information; will be line-wrapped */
+};
+
/* Commands must match the values in enum command_id. */
-const struct command commands[] = {
+static struct command commands[] = {
{"start", ALLOW_INFO,
+ /* no translatable parameters */
"start",
N_("Start the game, or restart after loading a savegame."),
N_("This command starts the game. When starting a new game, "
@@ -55,6 +64,7 @@
},
{"list", ALLOW_INFO,
+ /* no translatable parameters */
"list\n"
"list players\n"
"list teams\n"
@@ -66,6 +76,7 @@
" and defaults to 'players' if absent.")
},
{"quit", ALLOW_HACK,
+ /* no translatable parameters */
"quit",
N_("Quit the game and shutdown the server."), NULL
},
@@ -99,12 +110,14 @@
"or options with that prefix.")
},
{"wall", ALLOW_HACK,
+ /* TRANS: translate text between <> only */
N_("wall <message>"),
N_("Send message to all connections."),
N_("For each connected client, pops up a window showing the message "
"entered.")
},
{"vote", ALLOW_INFO,
+ /* TRANS: translate text between [] only */
N_("vote yes|no [vote number]"),
N_("Cast a vote."),
/* xgettext:no-c-format */
@@ -119,17 +132,21 @@
"case if nobody votes against it.")
},
{"debug", ALLOW_CTRL,
- N_("debug [ player <player> | city <x> <y> | units <x> <y> | unit <id> "
- "| tech <player> | timing | info]"),
+ /* no translatable parameters */
+ "debug [ diplomacy | ferries | player <player> | tech <player>"
+ " | city <x> <y> | units <x> <y> | unit <id> "
+ " | timing | info ]",
N_("Turn on or off AI debugging of given entity."),
N_("Print AI debug information about given entity and turn continous "
"debugging output for this entity on or off."),
},
{"set", ALLOW_CTRL,
+ /* TRANS: translate text between <> only */
N_("set <option-name> <value>"),
N_("Set server option."), NULL
},
{"team", ALLOW_CTRL,
+ /* TRANS: translate text between <> only */
N_("team <player> [team]"),
N_("Change, add or remove a player's team affiliation."),
N_("Sets a player as member of a team. If no team specified, the "
@@ -139,6 +156,7 @@
"with averaged individual scores.")
},
{"rulesetdir", ALLOW_CTRL,
+ /* TRANS: translate text between <> only */
N_("rulesetdir <directory>"),
N_("Choose new ruleset directory or modpack."),
N_("Choose new ruleset directory or modpack. Calling this\n "
@@ -160,6 +178,7 @@
N_("Set metaserver patches line."), NULL
},
{"metaconnection", ALLOW_HACK,
+ /* no translatable parameters */
"metaconnection u|up\n"
"metaconnection d|down\n"
"metaconnection ?",
@@ -213,8 +232,8 @@
"been started.")
},
{"away", ALLOW_INFO,
- N_("away\n"
- "away"),
+ /* no translatable parameters */
+ "away",
N_("Set yourself in away mode. The AI will watch your back."),
N_("The AI will govern your nation but do minimal changes."),
},
@@ -302,7 +321,9 @@
"Note that this command now takes connection names, not player names."
)
},
- {"first", ALLOW_INFO, "first",
+ {"first", ALLOW_INFO,
+ /* no translatable parameters */
+ "first",
N_("If there is none, become the game organizer with increased
permissions."),
NULL,
},
@@ -315,13 +336,13 @@
"concert with the option \"timeout\". Defaults are 0 0 0 1")
},
{"endgame", ALLOW_HACK,
- /* TRANS: translate text between <> only */
- N_("endgame"),
+ /* no translatable parameters */
+ "endgame",
N_("End the game immediately in a draw."), NULL,
},
{"surrender", ALLOW_INFO,
- /* TRANS: translate text between <> only */
- N_("surrender"),
+ /* no translatable parameters */
+ "surrender",
N_("Concede the game."),
N_("This tells everyone else that you concede the game, and if all "
"but one player (or one team) have conceded the game in this way "
@@ -365,12 +386,71 @@
N_("Write current settings as server commands to file."), NULL
},
{"rfcstyle", ALLOW_HACK,
+ /* no translatable parameters */
"rfcstyle",
N_("Switch server output between 'RFC-style' and normal style."), NULL
},
{"serverid", ALLOW_INFO,
+ /* no translatable parameters */
"serverid",
N_("Simply returns the id of the server."),
}
};
+
+/**************************************************************************
+ ...
+**************************************************************************/
+const struct command *command_by_number(int i)
+{
+ assert(i > 0 && i < CMD_NUM);
+ return &commands[i];
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+const char *command_name(const struct command *pcommand)
+{
+ return pcommand->name;
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+const char *command_name_by_number(int i)
+{
+ return command_by_number(i)->name;
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+const char *command_synopsis(const struct command *pcommand)
+{
+ return pcommand->synopsis;
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+const char *command_short_help(const struct command *pcommand)
+{
+ return pcommand->short_help;
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+const char *command_extra_help(const struct command *pcommand)
+{
+ return pcommand->extra_help;
+}
+
+/**************************************************************************
+ ...
+**************************************************************************/
+enum cmdlevel_id command_level(const struct command *pcommand)
+{
+ return pcommand->level;
+}
Index: server/commands.h
===================================================================
--- server/commands.h (revision 14344)
+++ server/commands.h (working copy)
@@ -19,14 +19,6 @@
/**************************************************************************
Commands - can be recognised by unique prefix
**************************************************************************/
-struct command {
- const char *name; /* name - will be matched by unique prefix */
- enum cmdlevel_id level; /* access level required to use the command */
- const char *synopsis; /* one or few-line summary of usage */
- const char *short_help; /* one line (about 70 chars) description */
- const char *extra_help; /* extra help information; will be line-wrapped */
-};
-
/* Order here is important: for ambiguous abbreviations the first
match is used. Arrange order to:
- allow old commands 's', 'h', 'l', 'q', 'c' to work.
@@ -91,6 +83,14 @@
CMD_AMBIGUOUS /* used as a possible iteration result */
};
-extern const struct command commands[];
+const struct command *command_by_number(int i);
+const char *command_name_by_number(int i);
+const char *command_name(const struct command *pcommand);
+const char *command_synopsis(const struct command *pcommand);
+const char *command_short_help(const struct command *pcommand);
+const char *command_extra_help(const struct command *pcommand);
+
+enum cmdlevel_id command_level(const struct command *pcommand);
+
#endif /* FC__COMMANDS_H */
Index: server/stdinhand.c
===================================================================
--- server/stdinhand.c (revision 14344)
+++ server/stdinhand.c (working copy)
@@ -160,9 +160,6 @@
return PNameOk;
}
-static const char *cmdname_accessor(int i) {
- return commands[i].name;
-}
/**************************************************************************
Convert a named command into an id.
If accept_ambiguity is true, return the first command in the
@@ -175,7 +172,7 @@
enum m_pre_result result;
int ind;
- result = match_prefix(cmdname_accessor, CMD_NUM, 0,
+ result = match_prefix(command_name_by_number, CMD_NUM, 0,
mystrncasecmp, token, &ind);
if (result < M_PRE_AMBIGUOUS) {
@@ -292,7 +289,7 @@
if (!caller) {
return TRUE; /* on the console, everything is allowed */
}
- return (caller->access_level >= commands[cmd].level);
+ return (caller->access_level >= command_level(command_by_number(cmd)));
}
/**************************************************************************
@@ -361,7 +358,7 @@
const char *line)
{
const char *cmdname = cmd < CMD_NUM
- ? commands[cmd].name
+ ? command_name_by_number(cmd)
: cmd == CMD_AMBIGUOUS
/* TRANS: ambiguous command */
? _("(ambiguous)")
@@ -1449,9 +1446,8 @@
}
if (ntokens == 0) {
- cmd_reply(CMD_TIMEOUT, caller, C_SYNTAX, _("Usage: timeoutincrease "
- "<turn> <turnadd> "
- "<value> <valuemult>."));
+ cmd_reply(CMD_TIMEOUT, caller, C_SYNTAX, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_TIMEOUT))));
return FALSE;
} else if (check) {
return TRUE;
@@ -1846,7 +1842,8 @@
cmd_reply(CMD_AWAY, caller, C_FAIL, _("This command is client only."));
return FALSE;
} else if (name && strlen(name) > 0) {
- notify_conn(caller->self, NULL, E_SETTING, _("Usage: away"));
+ notify_conn(caller->self, NULL, E_SETTING, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_AWAY))));
return FALSE;
} else if (!caller->player || caller->observer) {
/* This happens for detached or observer connections. */
@@ -2087,7 +2084,8 @@
}
if (ntokens != 2) {
cmd_reply(CMD_TEAM, caller, C_SYNTAX,
- _("Undefined argument. Usage: team <player> <team>."));
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_TEAM))));
goto cleanup;
}
@@ -2142,8 +2140,6 @@
char buf[MAX_LEN_CONSOLE_LINE];
char *arg[3];
int ntokens = 0, i;
- const char *usage = _("Undefined arguments. Usage: vote yes|no "
- "[vote number].");
bool res = FALSE;
if (caller == NULL || caller->player == NULL) {
@@ -2223,7 +2219,9 @@
}
check_vote(vote);
} else {
- cmd_reply(CMD_VOTE, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_VOTE, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_VOTE))));
goto cleanup;
}
@@ -2244,10 +2242,6 @@
char buf[MAX_LEN_CONSOLE_LINE];
char *arg[3];
int ntokens = 0, i;
- const char *usage = _("Undefined arguments. Usage: debug < diplomacy "
- "<player> | city <x> <y> | units <x> <y> | "
- "unit <id> | tech <player> | timing | info | "
- "ferries >.");
if (game.info.is_new_game) {
cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
@@ -2270,7 +2264,9 @@
enum m_pre_result match_result;
if (ntokens != 2) {
- cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DEBUG))));
goto cleanup;
}
pplayer = find_player_by_name_prefix(arg[1], &match_result);
@@ -2293,7 +2289,9 @@
enum m_pre_result match_result;
if (ntokens != 2) {
- cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DEBUG))));
goto cleanup;
}
pplayer = find_player_by_name_prefix(arg[1], &match_result);
@@ -2334,7 +2332,9 @@
struct city *pcity;
if (ntokens != 3) {
- cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DEBUG))));
goto cleanup;
}
if (sscanf(arg[1], "%d", &x) != 1 || sscanf(arg[2], "%d", &y) != 1) {
@@ -2364,7 +2364,9 @@
struct tile *ptile;
if (ntokens != 3) {
- cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DEBUG))));
goto cleanup;
}
if (sscanf(arg[1], "%d", &x) != 1 || sscanf(arg[2], "%d", &y) != 1) {
@@ -2404,7 +2406,9 @@
struct unit *punit;
if (ntokens != 2) {
- cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DEBUG))));
goto cleanup;
}
if (sscanf(arg[1], "%d", &id) != 1) {
@@ -2427,7 +2431,9 @@
unit_name_translation(punit));
}
} else {
- cmd_reply(CMD_DEBUG, caller, C_SYNTAX, usage);
+ cmd_reply(CMD_DEBUG, caller, C_SYNTAX,
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DEBUG))));
}
cleanup:
for (i = 0; i < ntokens; i++) {
@@ -2470,7 +2476,8 @@
cmd = lookup_option(command);
if (cmd==-1) {
cmd_reply(CMD_SET, caller, C_SYNTAX,
- _("Undefined argument. Usage: set <option> <value>."));
+ _("Undefined argument. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_SET))));
return FALSE;
}
else if (cmd==-2) {
@@ -2577,7 +2584,8 @@
case SSET_STRING:
if (strlen(arg) >= op->string_value_size) {
cmd_reply(CMD_SET, caller, C_SYNTAX,
- _("String value too long. Usage: set <option> <value>."));
+ _("String value too long. Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_SET))));
return FALSE;
} else {
const char *reject_message = NULL;
@@ -2730,14 +2738,14 @@
/* check syntax, only certain syntax if allowed depending on the caller */
if (!caller && ntokens < 1) {
- cmd_reply(CMD_OBSERVE, caller, C_SYNTAX,
- _("Usage: observe [connection-name [player-name]]"));
+ cmd_reply(CMD_OBSERVE, caller, C_SYNTAX, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_OBSERVE))));
goto end;
}
if (ntokens == 2 && (caller && caller->access_level != ALLOW_HACK)) {
cmd_reply(CMD_OBSERVE, caller, C_SYNTAX,
- _("Usage: observe [player-name]"));
+ _("Only the player name form is allowed."));
goto end;
}
@@ -2906,19 +2914,20 @@
/* check syntax */
if (!caller && ntokens != 2) {
- cmd_reply(CMD_TAKE, caller, C_SYNTAX,
- _("Usage: take <connection-name> <player-name>"));
+ cmd_reply(CMD_TAKE, caller, C_SYNTAX, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_TAKE))));
goto end;
}
if (caller && caller->access_level != ALLOW_HACK && ntokens != 1) {
- cmd_reply(CMD_TAKE, caller, C_SYNTAX, _("Usage: take <player-name>"));
+ cmd_reply(CMD_TAKE, caller, C_SYNTAX,
+ _("Only the player name form is allowed."));
goto end;
}
if (ntokens == 0) {
- cmd_reply(CMD_TAKE, caller, C_SYNTAX,
- _("Usage: take [connection-name] <player-name>"));
+ cmd_reply(CMD_TAKE, caller, C_SYNTAX, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_TAKE))));
goto end;
}
@@ -3082,8 +3091,8 @@
ntokens = get_tokens(buf, arg, 1, TOKEN_DELIMITERS);
if (!caller && ntokens == 0) {
- cmd_reply(CMD_DETACH, caller, C_SYNTAX,
- _("Usage: detach <connection-name>"));
+ cmd_reply(CMD_DETACH, caller, C_SYNTAX, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_DETACH))));
goto end;
}
@@ -3245,7 +3254,8 @@
char arg[MAX_LEN_PATH];
if (!filename || filename[0] == '\0') {
- cmd_reply(CMD_LOAD, caller, C_FAIL, _("Usage: load <game name>"));
+ cmd_reply(CMD_LOAD, caller, C_FAIL, _("Usage:\n%s"),
+ _(command_synopsis(command_by_number(CMD_LOAD))));
return FALSE;
}
if (S_S_INITIAL != server_state()) {
@@ -3505,7 +3515,7 @@
cmd_reply(cmd, caller, C_SYNTAX,
_("Warning: '%s' interpreted as '%s', but it is ambiguous."
" Try '%shelp'."),
- command, commands[cmd].name, caller?"/":"");
+ command, command_name_by_number(cmd), caller?"/":"");
} else if (cmd == CMD_UNRECOGNIZED) {
cmd_reply(cmd, caller, C_SYNTAX,
_("Unknown command. Try '%shelp'."), caller?"/":"");
@@ -3518,7 +3528,7 @@
&& !caller->observer /* don't allow observers to ask votes */
&& !check
&& caller->access_level == ALLOW_INFO
- && commands[cmd].level == ALLOW_CTRL) {
+ && ALLOW_CTRL == command_level(command_by_number(cmd))) {
int idx = player_index(caller->player);
/* If we already have a vote going, cancel it in favour of the new
@@ -3552,8 +3562,8 @@
}
if (caller
&& !(check && caller->access_level >= ALLOW_INFO
- && commands[cmd].level == ALLOW_CTRL)
- && caller->access_level < commands[cmd].level) {
+ && ALLOW_CTRL == command_level(command_by_number(cmd)))
+ && caller->access_level < command_level(command_by_number(cmd))) {
cmd_reply(cmd, caller, C_FAIL,
_("You are not allowed to use this command."));
return FALSE;
@@ -3572,7 +3582,7 @@
while(i>0 && my_isspace(arg[i]))
arg[i--]='\0';
- if (!check && commands[cmd].level > ALLOW_INFO) {
+ if (!check && ALLOW_INFO < command_level(command_by_number(cmd))) {
/*
* this command will affect the game - inform all players
*
@@ -3622,7 +3632,7 @@
case CMD_HARD:
case CMD_CHEATING:
case CMD_EXPERIMENTAL:
- return set_ai_level_named(caller, arg, commands[cmd].name, check);
+ return set_ai_level_named(caller, arg, command_name_by_number(cmd), check);
case CMD_QUIT:
return quit_game(caller, check);
case CMD_CUT:
@@ -3859,21 +3869,21 @@
enum command_id help_cmd,
enum command_id id)
{
- const struct command *cmd = &commands[id];
+ const struct command *cmd = command_by_number(id);
- if (cmd->short_help) {
+ if (command_short_help(cmd)) {
cmd_reply(help_cmd, caller, C_COMMENT,
/* TRANS: <untranslated name> - translated short help */
_("Command: %s - %s"),
- cmd->name,
- _(cmd->short_help));
+ command_name(cmd),
+ _(command_short_help(cmd)));
} else {
cmd_reply(help_cmd, caller, C_COMMENT,
/* TRANS: <untranslated name> */
_("Command: %s"),
- cmd->name);
+ command_name(cmd));
}
- if (cmd->synopsis) {
+ if (command_synopsis(cmd)) {
/* line up the synopsis lines: */
const char *syn = _("Synopsis: ");
size_t synlen = strlen(syn);
@@ -3881,12 +3891,12 @@
my_snprintf(prefix, sizeof(prefix), "%*s", (int) synlen, " ");
cmd_reply_prefix(help_cmd, caller, C_COMMENT, prefix,
- "%s%s", syn, _(cmd->synopsis));
+ "%s%s", syn, _(command_synopsis(cmd)));
}
cmd_reply(help_cmd, caller, C_COMMENT,
- _("Level: %s"), cmdlevel_name(cmd->level));
- if (cmd->extra_help) {
- const char *help = _(cmd->extra_help);
+ _("Level: %s"), cmdlevel_name(command_level(cmd)));
+ if (command_extra_help(cmd)) {
+ const char *help = _(command_extra_help(cmd));
cmd_reply(help_cmd, caller, C_COMMENT, _("Description:"));
cmd_reply_prefix(help_cmd, caller, C_COMMENT, " ",
@@ -3909,7 +3919,7 @@
cmd_reply(help_cmd, caller, C_COMMENT, horiz_line);
if(!caller && con_get_style()) {
for (i=0; i<CMD_NUM; i++) {
- cmd_reply(help_cmd, caller, C_COMMENT, "%s", commands[i].name);
+ cmd_reply(help_cmd, caller, C_COMMENT, "%s", command_name_by_number(i));
}
} else {
char buf[MAX_LEN_CONSOLE_LINE];
@@ -3918,7 +3928,7 @@
buf[0] = '\0';
for (i=0, j=0; i<CMD_NUM; i++) {
if (may_use(caller, i)) {
- cat_snprintf(buf, sizeof(buf), "%-19s", commands[i].name);
+ cat_snprintf(buf, sizeof(buf), "%-19s", command_name_by_number(i));
if((++j % 4) == 0) {
cmd_reply(help_cmd, caller, C_COMMENT, buf);
buf[0] = '\0';
@@ -3953,7 +3963,7 @@
**************************************************************************/
static const char *helparg_accessor(int i) {
if (i<CMD_NUM)
- return cmdname_accessor(i);
+ return command_name_by_number(i);
i -= CMD_NUM;
if (i<HELP_GENERAL_NUM)
return help_general_args[i];
@@ -4346,7 +4356,7 @@
**************************************************************************/
static char *command_generator(const char *text, int state)
{
- return generic_generator(text, state, CMD_NUM, cmdname_accessor);
+ return generic_generator(text, state, CMD_NUM, command_name_by_number);
}
/**************************************************************************
@@ -4473,7 +4483,7 @@
{
char *str_itr;
- if (contains_str_before_start(start, commands[CMD_HELP].name, FALSE))
+ if (contains_str_before_start(start, command_name_by_number(CMD_HELP),
FALSE))
return TRUE;
/* if there is only it is also OK */
@@ -4534,7 +4544,7 @@
int i = 0;
while (player_cmd[i] != -1) {
- if (contains_str_before_start(start, commands[player_cmd[i]].name, FALSE))
{
+ if (contains_str_before_start(start,
command_name_by_number(player_cmd[i]), FALSE)) {
return TRUE;
}
i++;
@@ -4548,7 +4558,7 @@
**************************************************************************/
static bool is_connection(int start)
{
- return contains_str_before_start(start, commands[CMD_CUT].name, FALSE);
+ return contains_str_before_start(start, command_name_by_number(CMD_CUT),
FALSE);
}
/**************************************************************************
@@ -4556,7 +4566,7 @@
**************************************************************************/
static bool is_cmdlevel_arg2(int start)
{
- return (contains_str_before_start(start, commands[CMD_CMDLEVEL].name, TRUE)
+ return (contains_str_before_start(start,
command_name_by_number(CMD_CMDLEVEL), TRUE)
&& num_tokens(start) == 2);
}
@@ -4565,7 +4575,7 @@
**************************************************************************/
static bool is_cmdlevel_arg1(int start)
{
- return contains_str_before_start(start, commands[CMD_CMDLEVEL].name, FALSE);
+ return contains_str_before_start(start,
command_name_by_number(CMD_CMDLEVEL), FALSE);
}
/**************************************************************************
@@ -4589,7 +4599,7 @@
int i = 0;
while (server_option_cmd[i] != -1) {
- if (contains_str_before_start(start, commands[server_option_cmd[i]].name,
+ if (contains_str_before_start(start,
command_name_by_number(server_option_cmd[i]),
FALSE)) {
return TRUE;
}
@@ -4616,7 +4626,7 @@
int i = 0;
while (option_level_cmd[i] != -1) {
- if (contains_str_before_start(start, commands[option_level_cmd[i]].name,
+ if (contains_str_before_start(start,
command_name_by_number(option_level_cmd[i]),
FALSE)) {
return TRUE;
}
@@ -4645,8 +4655,7 @@
int i = 0;
while (filename_cmd[i] != -1) {
- if (contains_str_before_start
- (start, commands[filename_cmd[i]].name, FALSE)) {
+ if (contains_str_before_start(start,
command_name_by_number(filename_cmd[i]), FALSE)) {
return TRUE;
}
i++;
@@ -4660,7 +4669,7 @@
**************************************************************************/
static bool is_help(int start)
{
- return contains_str_before_start(start, commands[CMD_HELP].name, FALSE);
+ return contains_str_before_start(start, command_name_by_number(CMD_HELP),
FALSE);
}
/**************************************************************************
@@ -4668,7 +4677,7 @@
**************************************************************************/
static bool is_list(int start)
{
- return contains_str_before_start(start, commands[CMD_LIST].name, FALSE);
+ return contains_str_before_start(start, command_name_by_number(CMD_LIST),
FALSE);
}
/**************************************************************************
Index: manual/civmanual.c
===================================================================
--- manual/civmanual.c (revision 14344)
+++ manual/civmanual.c (working copy)
@@ -184,20 +184,20 @@
fprintf(doc, _("<h1>Freeciv %s server commands</h1>\n\n"),
VERSION_STRING);
for (i = 0; i < CMD_NUM; i++) {
- const struct command *cmd = &commands[i];
+ const struct command *cmd = command_by_number(i);
fprintf(doc, SEPARATOR);
- fprintf(doc, "%s%s - %s%s\n\n", SECTION_BEGIN, cmd->name,
- _(cmd->short_help), SECTION_END);
- if (cmd->synopsis) {
+ fprintf(doc, "%s%s - %s%s\n\n", SECTION_BEGIN, command_name(cmd),
+ _(command_short_help(cmd)), SECTION_END);
+ if (command_synopsis(cmd)) {
fprintf(doc, _("<table>\n<tr>\n<td valign=\"top\">"
"<pre>Synopsis:</pre></td>\n<td>"));
- fprintf(doc, "<pre>%s</pre></td></tr></table>", _(cmd->synopsis));
+ fprintf(doc, "<pre>%s</pre></td></tr></table>",
_(command_synopsis(cmd)));
}
fprintf(doc, _("<p class=\"level\">Level: %s</p>\n\n"),
- cmdlevel_name(cmd->level));
- if (cmd->extra_help) {
- const char *help = _(cmd->extra_help);
+ cmdlevel_name(command_level(cmd)));
+ if (command_extra_help(cmd)) {
+ const char *help = _(command_extra_help(cmd));
fprintf(doc, _("<p>Description:</p>\n\n"));
fprintf(doc, "<pre>%s</pre>\n\n", help);
_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev