Lower default cmdlevel to basic on game start.
[freeciv.git] / server / commands.c
blob9de92ceabcb16372f5841bab4c62c4c09c1230bb
1 /***********************************************************************
2 Freeciv - Copyright (C) 1996-2004 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
14 #ifdef HAVE_CONFIG_H
15 #include <fc_config.h>
16 #endif
18 /* utility */
19 #include "fcintl.h"
21 /* common */
22 #include "connection.h"
23 #include "mapimg.h"
25 /* server */
26 #include "commands.h"
27 #include "voting.h"
29 /* Set the synopsis text to don't be translated. */
30 #define SYN_ORIG_(String) "*" String
31 /* Test if the synopsis should be translated or not. */
32 #define SYN_TRANS_(String) ('*' == String[0] ? String + 1 : _(String))
34 struct command {
35 const char *name; /* name - will be matched by unique prefix */
36 enum cmdlevel level; /* access level required to use the command */
37 const char *synopsis; /* one or few-line summary of usage */
38 const char *short_help; /* one line (about 70 chars) description */
39 const char *extra_help; /* extra help information; will be line-wrapped */
40 char *(*extra_help_func)(void);
41 /* dynamically generated help; if non-NULL,
42 * extra_help is ignored. Must be pre-translated. */
43 enum cmd_echo echo; /* Who will be notified when used. */
44 int vote_flags; /* how to handle votes */
45 int vote_percent; /* percent required, meaning depends on flags */
48 /* Commands must match the values in enum command_id. */
49 static struct command commands[] = {
50 {"start", ALLOW_BASIC,
51 /* no translatable parameters */
52 SYN_ORIG_("start"),
53 N_("Start the game, or restart after loading a savegame."),
54 N_("This command starts the game. When starting a new game, "
55 "it should be used after all human players have connected, and "
56 "AI players have been created (if required), and any desired "
57 "changes to initial server options have been made. "
58 "After 'start', each human player will be able to "
59 "choose their nation, and then the game will begin. "
60 "This command is also required after loading a savegame "
61 "for the game to recommence. Once the game is running this command "
62 "is no longer available, since it would have no effect."), NULL,
63 CMD_ECHO_NONE, VCF_NONE, 0
66 {"help", ALLOW_INFO,
67 /* TRANS: translate text between <> only */
68 N_("help\n"
69 "help commands\n"
70 "help options\n"
71 "help <command-name>\n"
72 "help <option-name>"),
73 N_("Show help about server commands and server options."),
74 N_("With no arguments gives some introductory help. "
75 "With argument \"commands\" or \"options\" gives respectively "
76 "a list of all commands or all options. "
77 "Otherwise the argument is taken as a command name or option name, "
78 "and help is given for that command or option. For options, the help "
79 "information includes the current and default values for that option. "
80 "The argument may be abbreviated where unambiguous."), NULL,
81 CMD_ECHO_NONE, VCF_NONE, 0
84 {"list", ALLOW_INFO,
85 /* no translatable parameters */
86 SYN_ORIG_("list\n"
87 "list colors\n"
88 "list connections\n"
89 "list delegations\n"
90 "list ignored users\n"
91 "list map image definitions\n"
92 "list players\n"
93 "list scenarios\n"
94 "list nationsets\n"
95 "list teams\n"
96 "list votes\n"),
97 N_("Show a list of various things."),
98 N_("Show a list of:\n"
99 " - the player colors,\n"
100 " - connections to the server,\n"
101 " - all player delegations,\n"
102 " - your ignore list,\n"
103 " - the list of defined map images,\n"
104 " - the list of the players in the game,\n"
105 " - the available scenarios,\n"
106 " - the available nation sets in this ruleset,\n"
107 " - the teams of players or\n"
108 " - the running votes.\n"
109 "The argument may be abbreviated, and defaults to 'players' if "
110 "absent."), NULL,
111 CMD_ECHO_NONE, VCF_NONE, 0
113 {"quit", ALLOW_HACK,
114 /* no translatable parameters */
115 SYN_ORIG_("quit"),
116 N_("Quit the game and shutdown the server."), NULL, NULL,
117 CMD_ECHO_ALL, VCF_NONE, 0
119 {"cut", ALLOW_CTRL,
120 /* TRANS: translate text between <> only */
121 N_("cut <connection-name>"),
122 N_("Cut a client's connection to server."),
123 N_("Cut specified client's connection to the server, removing that client "
124 "from the game. If the game has not yet started that client's player "
125 "is removed from the game, otherwise there is no effect on the player. "
126 "Note that this command now takes connection names, not player names."),
127 NULL,
128 CMD_ECHO_ALL, VCF_NONE, 50
130 {"explain", ALLOW_INFO,
131 /* TRANS: translate text between <> only */
132 N_("explain\n"
133 "explain <option-name>"),
134 N_("Explain server options."),
135 N_("The 'explain' command gives a subset of the functionality of 'help', "
136 "and is included for backward compatibility. With no arguments it "
137 "gives a list of options (like 'help options'), and with an argument "
138 "it gives help for a particular option (like 'help <option-name>')."),
139 NULL,
140 CMD_ECHO_NONE, VCF_NONE, 0
142 {"show", ALLOW_INFO,
143 /* TRANS: translate text between <> only */
144 N_("show\n"
145 "show <option-name>\n"
146 "show <option-prefix>\n"
147 "show all\n"
148 "show vital\n"
149 "show situational\n"
150 "show rare\n"
151 "show changed\n"
152 "show locked\n"
153 "show rulesetdir"),
154 N_("Show server options."),
155 N_("With no arguments, shows vital server options (or available options, "
156 "when used by clients). With an option name argument, show only the "
157 "named option, or options with that prefix. With \"all\", it shows "
158 "all options. With \"vital\", \"situational\" or \"rare\", a set of "
159 "options with this level. With \"changed\", it shows only the options "
160 "which have been modified, while with \"locked\" all settings locked "
161 "by the ruleset will be listed. With \"ruleset\", it will show the "
162 "current ruleset directory name."), NULL,
163 CMD_ECHO_NONE, VCF_NONE, 0
165 {"wall", ALLOW_ADMIN,
166 /* TRANS: translate text between <> only */
167 N_("wall <message>"),
168 N_("Send message to all connections."),
169 N_("For each connected client, pops up a window showing the message "
170 "entered."), NULL,
171 CMD_ECHO_ADMINS, VCF_NONE, 0
173 {"connectmsg", ALLOW_ADMIN,
174 /* TRANS: translate text between <> only */
175 N_("connectmsg <message>"),
176 N_("Set message to show to connecting players."),
177 N_("Set message to send to clients when they connect.\n"
178 "Empty message means that no message is sent."), NULL,
179 CMD_ECHO_ADMINS, VCF_NONE, 0
181 {"vote", ALLOW_BASIC,
182 /* TRANS: translate text between [] only; "vote" is as a process */
183 N_("vote yes|no|abstain [vote number]"),
184 /* TRANS: "vote" as an instance of voting */
185 N_("Cast a vote."),
186 /* xgettext:no-c-format */
187 N_("A player with basic level access issuing a control level command "
188 "starts a new vote for the command. The /vote command followed by "
189 "\"yes\", \"no\", or \"abstain\", and optionally a vote number, "
190 "gives your vote. If you do not add a vote number, your vote applies "
191 "to the latest vote. You can only suggest one vote at a time. "
192 "The vote will pass immediately if more than half of the voters "
193 "who have not abstained vote for it, or fail immediately if at "
194 "least half of the voters who have not abstained vote against it."),
195 NULL,
196 CMD_ECHO_NONE, VCF_NONE, 0
198 {"debug", ALLOW_CTRL,
199 /* TRANS: translate text between <> only */
200 N_("debug diplomacy <player>\n"
201 "debug ferries\n"
202 "debug tech <player>\n"
203 "debug city <x> <y>\n"
204 "debug units <x> <y>\n"
205 "debug unit <id>\n"
206 "debug timing\n"
207 "debug info"),
208 N_("Turn on or off AI debugging of given entity."),
209 N_("Print AI debug information about given entity and turn continuous "
210 "debugging output for this entity on or off."), NULL,
211 CMD_ECHO_ADMINS, VCF_NONE, 0
213 {"set", ALLOW_CTRL,
214 /* TRANS: translate text between <> only */
215 N_("set <option-name> <value>"),
216 N_("Set server option."),
217 /* TRANS: don't translate text in '' */
218 N_("Set an option on the server. The syntax and legal values depend "
219 "on the option; see the help for each option. Some options are "
220 "\"bitwise\", in that they consist of a choice from a set of values; "
221 "separate these with |, for instance, '/set topology wrapx|iso'. For "
222 "these options, use syntax like '/set topology \"\"' to set no "
223 "values."), NULL,
224 CMD_ECHO_ALL, VCF_NONE, 50
226 {"team", ALLOW_CTRL,
227 /* TRANS: translate text between <> only */
228 N_("team <player> <team>"),
229 N_("Change a player's team affiliation."),
230 N_("A team is a group of players that start out allied, with shared "
231 "vision and embassies, and fight together to achieve team victory "
232 "with averaged individual scores. Each player is always a member "
233 "of a team (possibly the only member). This command changes which "
234 "team a player is a member of. Use \"\" if names contain whitespace."),
235 NULL,
236 CMD_ECHO_ALL, VCF_NONE, 50
238 {"rulesetdir", ALLOW_CTRL,
239 /* TRANS: translate text between <> only */
240 N_("rulesetdir <directory>"),
241 N_("Choose new ruleset directory or modpack."),
242 NULL, NULL,
243 CMD_ECHO_ALL, VCF_NONE, 50
245 {"metamessage", ALLOW_CTRL,
246 /* TRANS: translate text between <> only */
247 N_("metamessage <meta-line>"),
248 N_("Set metaserver info line."),
249 N_("Set user defined metaserver info line. If parameter is omitted, "
250 "previously set metamessage will be removed. For most of the time "
251 "user defined metamessage will be used instead of automatically "
252 "generated messages, if it is available."), NULL,
253 CMD_ECHO_ADMINS, VCF_NONE, 50
255 {"metapatches", ALLOW_HACK,
256 /* TRANS: translate text between <> only */
257 N_("metapatches <meta-line>"),
258 N_("Set metaserver patches line."), NULL, NULL,
259 CMD_ECHO_ADMINS, VCF_NONE, 0
261 {"metaconnection", ALLOW_ADMIN,
262 /* no translatable parameters */
263 SYN_ORIG_("metaconnection u|up\n"
264 "metaconnection d|down\n"
265 "metaconnection ?"),
266 N_("Control metaserver connection."),
267 N_("'metaconnection ?' reports on the status of the connection to metaserver. "
268 "'metaconnection down' or 'metac d' brings the metaserver connection down. "
269 "'metaconnection up' or 'metac u' brings the metaserver connection up. "
270 "'metaconnection persistent' or 'metac p' is like 'up', but keeps trying after failures. "),
271 NULL,
272 CMD_ECHO_ADMINS, VCF_NONE, 0
274 {"metaserver", ALLOW_ADMIN,
275 /* TRANS: translate text between <> only */
276 N_("metaserver <address>"),
277 N_("Set address (URL) for metaserver to report to."), NULL, NULL,
278 CMD_ECHO_ADMINS, VCF_NONE, 0
280 {"aitoggle", ALLOW_CTRL,
281 /* TRANS: translate text between <> only */
282 N_("aitoggle <player-name>"),
283 N_("Toggle AI status of player."), NULL, NULL,
284 CMD_ECHO_ADMINS, VCF_NONE, 50
286 {"take", ALLOW_INFO,
287 /* TRANS: translate text between [] and <> only */
288 N_("take [connection-name] <player-name>"),
289 N_("Take over a player's place in the game."),
290 /* TRANS: Don't translate text between '' */
291 N_("Only the console and connections with cmdlevel 'hack' can force "
292 "other connections to take over a player. If you're not one of these, "
293 "only the <player-name> argument is allowed. If '-' is given for the "
294 "player name and the connection does not already control a player, one "
295 "is created and assigned to the connection. The 'allowtake' option "
296 "controls which players may be taken and in what circumstances."),
297 NULL,
298 CMD_ECHO_ADMINS, VCF_NONE, 0
300 {"observe", ALLOW_INFO,
301 /* TRANS: translate text between [] only */
302 N_("observe [connection-name] [player-name]"),
303 N_("Observe a player or the whole game."),
304 /* TRANS: Don't translate text between '' */
305 N_("Only the console and connections with cmdlevel 'hack' can force "
306 "other connections to observe a player. If you're not one of these, "
307 "only the [player-name] argument is allowed. If the console gives no "
308 "player-name or the connection uses no arguments, then the connection "
309 "is attached to a global observer. The 'allowtake' option controls "
310 "which players may be observed and in what circumstances."), NULL,
311 CMD_ECHO_ADMINS, VCF_NONE, 0
313 {"detach", ALLOW_INFO,
314 /* TRANS: translate text between <> only */
315 N_("detach <connection-name>"),
316 N_("Detach from a player."),
317 N_("Only the console and connections with cmdlevel 'hack' can force "
318 "other connections to detach from a player."), NULL,
319 CMD_ECHO_ADMINS, VCF_NONE, 0
321 {"create", ALLOW_CTRL,
322 /* TRANS: translate text between <> and [] only */
323 N_("create <player name> [ai type]"),
324 N_("Create an AI player with a given name."),
325 /* TRANS: don't translate text between single quotes */
326 N_("With the 'create' command a new player with the given name is "
327 "created.\n"
328 "If 'player name' is empty, random name will be assigned when the game "
329 "begins. Until then player will be known by id derived from its type.\n"
330 "The 'ai type' parameter can be used to select which AI module will be "
331 "used for the created player. This requires that Freeciv has been "
332 "compiled with loadable AI module support and that the respective module "
333 "has been loaded.\n"
334 "If the game has already started, the new player will have no units or "
335 "cities; also, if no free player slots are available, the slot of a "
336 "dead player can be reused (removing all record of that player from the "
337 "running game)."), NULL,
338 CMD_ECHO_ALL, VCF_NONE, 50
340 {"away", ALLOW_BASIC,
341 /* no translatable parameters */
342 SYN_ORIG_("away"),
343 N_("Set yourself in away mode. The AI will watch your back."),
344 N_("The AI will govern your nation but do minimal changes."), NULL,
345 CMD_ECHO_NONE, VCF_NONE, 50
347 {"handicapped", ALLOW_CTRL,
348 /* TRANS: translate text between <> only */
349 N_("handicapped\n"
350 "handicapped <player-name>"),
351 N_("Set one or all AI players to 'handicapped'."),
352 N_("With no arguments, sets all AI players to skill level 'handicapped', "
353 "and sets the default level for any new AI players to 'handicapped'. "
354 "With an argument, sets the skill level for that player only."), NULL,
355 CMD_ECHO_ALL, VCF_NONE, 50
357 {"novice", ALLOW_CTRL,
358 /* TRANS: translate text between <> only */
359 N_("novice\n"
360 "novice <player-name>"),
361 N_("Set one or all AI players to 'novice'."),
362 N_("With no arguments, sets all AI players to skill level 'novice', and "
363 "sets the default level for any new AI players to 'novice'. With an "
364 "argument, sets the skill level for that player only."), NULL,
365 CMD_ECHO_ALL, VCF_NONE, 50
367 {"easy", ALLOW_CTRL,
368 /* TRANS: translate text between <> only */
369 N_("easy\n"
370 "easy <player-name>"),
371 N_("Set one or all AI players to 'easy'."),
372 N_("With no arguments, sets all AI players to skill level 'easy', and "
373 "sets the default level for any new AI players to 'easy'. With an "
374 "argument, sets the skill level for that player only."), NULL,
375 CMD_ECHO_ALL, VCF_NONE, 50
377 {"normal", ALLOW_CTRL,
378 /* TRANS: translate text between <> only */
379 N_("normal\n"
380 "normal <player-name>"),
381 N_("Set one or all AI players to 'normal'."),
382 N_("With no arguments, sets all AI players to skill level 'normal', and "
383 "sets the default level for any new AI players to 'normal'. With an "
384 "argument, sets the skill level for that player only."), NULL,
385 CMD_ECHO_ALL, VCF_NONE, 50
387 {"hard", ALLOW_CTRL,
388 /* TRANS: translate text between <> only */
389 N_("hard\n"
390 "hard <player-name>"),
391 N_("Set one or all AI players to 'hard'."),
392 N_("With no arguments, sets all AI players to skill level 'hard', and "
393 "sets the default level for any new AI players to 'hard'. With an "
394 "argument, sets the skill level for that player only."), NULL,
395 CMD_ECHO_ALL, VCF_NONE, 50
397 {"cheating", ALLOW_CTRL,
398 /* TRANS: translate text between <> only */
399 N_("cheating\n"
400 "cheating <player-name>"),
401 N_("Set one or all AI players to 'cheating'."),
402 N_("With no arguments, sets all AI players to skill level 'cheating', and "
403 "sets the default level for any new AI players to 'cheating'. With an "
404 "argument, sets the skill level for that player only."), NULL,
405 CMD_ECHO_ALL, VCF_NONE, 50
407 #ifdef DEBUG
408 {"experimental", ALLOW_CTRL,
409 /* TRANS: translate text between <> only */
410 N_("experimental\n"
411 "experimental <player-name>"),
412 N_("Set one or all AI players to 'experimental'."),
413 N_("With no arguments, sets all AI players to skill 'experimental', and "
414 "sets the default level for any new AI players to this. With an "
415 "argument, sets the skill level for that player only. THIS IS ONLY "
416 "FOR TESTING OF NEW AI FEATURES! For ordinary servers, this option "
417 "has no effect."), NULL,
418 CMD_ECHO_ALL, VCF_NONE, 50
420 #endif /* DEBUG */
421 {"cmdlevel", ALLOW_ADMIN,
422 /* TRANS: translate text between <> only */
423 N_("cmdlevel\n"
424 "cmdlevel <level>\n"
425 "cmdlevel <level> new\n"
426 "cmdlevel <level> first\n"
427 "cmdlevel <level> <connection-name>"),
428 N_("Query or set command access level access."),
429 N_("The command access level controls which server commands are available "
430 "to users via the client chatline. The available levels are:\n"
431 " none - no commands\n"
432 " info - informational or observer commands only\n"
433 " basic - commands available to players in the game\n"
434 " ctrl - commands that affect the game and users\n"
435 " admin - commands that affect server operation\n"
436 " hack - *all* commands - dangerous!\n"
437 "With no arguments, the current command access levels are reported. "
438 "With a single argument, the level is set for all existing "
439 "connections, and the default is set for future connections. "
440 "If 'new' is specified, the level is set for newly connecting clients. "
441 "If 'first come' is specified, the 'first come' level is set; it will be "
442 "granted to the first client to connect, or if there are connections "
443 "already, the first client to issue the 'first' command. "
444 "If a connection name is specified, the level is set for that "
445 "connection only.\n"
446 "Command access levels do not persist if a client disconnects, "
447 "because some untrusted person could reconnect with the same name. "
448 "Note that this command now takes connection names, not player names."
449 ), NULL,
450 CMD_ECHO_ADMINS, VCF_NONE, 50
452 {"first", ALLOW_BASIC,
453 /* no translatable parameters */
454 SYN_ORIG_("first"),
455 N_("If there is none, become the game organizer with increased permissions."),
456 NULL, NULL,
457 CMD_ECHO_ADMINS, VCF_NONE, 50
459 {"timeoutincrease", ALLOW_CTRL,
460 /* TRANS: translate text between <> only */
461 N_("timeoutincrease <turn> <turninc> <value> <valuemult>"),
462 N_("See \"/help timeoutincrease\"."),
463 N_("Every <turn> turns, add <value> to timeout timer, then add <turninc> "
464 "to <turn> and multiply <value> by <valuemult>. Use this command in "
465 "concert with the option \"timeout\". Defaults are 0 0 0 1"), NULL,
466 CMD_ECHO_ALL, VCF_NONE, 50
468 {"cancelvote", ALLOW_BASIC,
469 /* TRANS: translate text between <> only; "vote" is as a process */
470 N_("cancelvote\n"
471 "cancelvote <vote number>\n"
472 "cancelvote all\n"),
473 /* TRANS: "vote" as a process */
474 N_("Cancel a running vote."),
475 /* TRANS: "vote" as a process */
476 N_("With no arguments this command removes your own vote. If you have "
477 "an admin access level, you can cancel any vote by vote number, or "
478 "all votes with the \'all\' argument."), NULL,
479 CMD_ECHO_ADMINS, VCF_NONE, 0
481 {"ignore", ALLOW_INFO,
482 /* TRANS: translate text between <> and [] only */
483 N_("ignore [type=]<pattern>"),
484 N_("Block all messages from users matching the pattern."),
485 N_("The given pattern will be added to your ignore list; you will not "
486 "receive any messages from users matching this pattern. The type "
487 "may be either \"user\", \"host\", or \"ip\". The default type "
488 "(if omitted) is to match against the username. The pattern supports "
489 "unix glob style wildcards, i.e., * matches zero or more character, ? "
490 "exactly one character, [abc] exactly one of 'a' 'b' or 'c', etc. "
491 "To access your current ignore list, issue \"/list ignore\"."), NULL,
492 CMD_ECHO_NONE, VCF_NONE, 0
494 {"unignore", ALLOW_INFO,
495 /* TRANS: translate text between <> */
496 N_("unignore <range>"),
497 N_("Remove ignore list entries."),
498 N_("The ignore list entries in the given range will be removed; "
499 "you will be able to receive messages from the respective users. "
500 "The range argument may be a single number or a pair of numbers "
501 "separated by a dash '-'. If the first number is omitted, it is "
502 "assumed to be 1; if the last is omitted, it is assumed to be "
503 "the last valid ignore list index. To access your current ignore "
504 "list, issue \"/list ignore\"."), NULL,
505 CMD_ECHO_NONE, VCF_NONE, 0
507 {"playercolor", ALLOW_ADMIN,
508 /* TRANS: translate text between <> */
509 N_("playercolor <player-name> <color>\n"
510 "playercolor <player-name> reset"),
511 N_("Define the color of a player."),
512 N_("This command sets the color of a specific player, overriding any color "
513 "assigned according to the 'plrcolormode' setting.\n"
514 "The color is defined using hexadecimal notation (hex) for the "
515 "combination of Red, Green, and Blue color components (RGB), similarly "
516 "to HTML. For each component, the lowest (darkest) value is 0 (in "
517 "hex: 00), and the highest value is 255 (in hex: FF). The color "
518 "definition is simply the three hex values concatenated together "
519 "(RRGGBB). For example, the following command sets Caesar to pure red:\n"
520 " playercolor Caesar ff0000\n"
521 "Before the game starts, this command can only be used if the "
522 "'plrcolormode' setting is set to 'PLR_SET'; a player's color can be "
523 "unset again by specifying 'reset'.\n"
524 "Once the game has started and colors have been assigned, this command "
525 "changes the player color in any mode; 'reset' cannot be used.\n"
526 "To list the player colors, use 'list colors'."), NULL,
527 CMD_ECHO_NONE, VCF_NONE, 0
529 {"endgame", ALLOW_ADMIN,
530 /* no translatable parameters */
531 SYN_ORIG_("endgame"),
532 N_("End the game immediately in a draw."), NULL, NULL,
533 CMD_ECHO_ALL, VCF_NONE, 0
535 {"surrender", ALLOW_BASIC,
536 /* no translatable parameters */
537 SYN_ORIG_("surrender"),
538 N_("Concede the game."),
539 N_("This tells everyone else that you concede the game, and if all "
540 "but one player (or one team) have conceded the game in this way "
541 "then the game ends."), NULL,
542 CMD_ECHO_NONE, VCF_NONE, 0
544 {"remove", ALLOW_CTRL,
545 /* TRANS: translate text between <> only */
546 N_("remove <player-name>"),
547 N_("Fully remove player from game."),
548 N_("This *completely* removes a player from the game, including "
549 "all cities and units etc. Use with care!"), NULL,
550 CMD_ECHO_ALL, VCF_NONE, 50
552 {"save", ALLOW_ADMIN,
553 /* TRANS: translate text between <> only */
554 N_("save\n"
555 "save <file-name>"),
556 N_("Save game to file."),
557 N_("Save the current game to file <file-name>. If no file-name "
558 "argument is given saves to \"<auto-save name prefix><year>m.sav[.gz]\". "
559 "To reload a savegame created by 'save', start the server with "
560 "the command-line argument:\n"
561 " '--file <filename>' or '-f <filename>'\n"
562 "and use the 'start' command once players have reconnected."), NULL,
563 CMD_ECHO_ADMINS, VCF_NONE, 0
565 {"scensave", ALLOW_ADMIN,
566 /* TRANS: translate text between <> only */
567 N_("scensave\n"
568 "scensave <file-name>"),
569 N_("Save game to file as scenario."),
570 N_("Save the current game to file <file-name> as scenario. If no file-name "
571 "argument is given saves to \"<auto-save name prefix><year>m.sav[.gz]\". "
572 "To reload a savegame created by 'scensave', start the server with "
573 "the command-line argument:\n"
574 " '--file <filename>' or '-f <filename>'\n"
575 "and use the 'start' command once players have reconnected."), NULL,
576 CMD_ECHO_ADMINS, VCF_NONE, 0
578 {"load", ALLOW_CTRL,
579 /* TRANS: translate text between <> only */
580 N_("load\n"
581 "load <file-name>"),
582 N_("Load game from file."),
583 N_("Load a game from <file-name>. Any current data including players, "
584 "rulesets and server options are lost."), NULL,
585 CMD_ECHO_ADMINS, VCF_NONE, 50
587 {"read", ALLOW_CTRL,
588 /* TRANS: translate text between <> only */
589 N_("read <file-name>"),
590 N_("Process server commands from file."), NULL, NULL,
591 CMD_ECHO_ADMINS, VCF_NONE, 50
593 {"write", ALLOW_HACK,
594 /* TRANS: translate text between <> only */
595 N_("write <file-name>"),
596 N_("Write current settings as server commands to file."), NULL, NULL,
597 CMD_ECHO_ADMINS, VCF_NONE, 0
599 {"reset", ALLOW_CTRL,
600 /* no translatable parameters */
601 SYN_ORIG_("reset [game|ruleset|script|default]"),
602 N_("Reset all server settings."),
603 N_("Reset all settings if it is possible. The following levels are "
604 "supported:\n"
605 " game - using the values defined at the game start\n"
606 " ruleset - using the values defined in the ruleset\n"
607 " script - using default values and rereading the start script\n"
608 " default - using default values\n"), NULL,
609 CMD_ECHO_ALL, VCF_NONE, 50
611 {"default", ALLOW_CTRL,
612 /* no translatable parameters */
613 SYN_ORIG_("default <option name>"),
614 N_("Set option to its default value"),
615 N_("Set option to its default value, and track it as 'default' instead\n"
616 "of real value."), NULL,
617 CMD_ECHO_ALL, VCF_NONE, 50
619 {"lua", ALLOW_ADMIN,
620 /* TRANS: translate text between <> only */
621 N_("lua cmd <script line>\n"
622 "lua file <script file>\n"
623 "lua <script line> (deprecated)"),
624 N_("Evaluate a line of Freeciv script or a Freeciv script file in the "
625 "current game."), NULL, NULL,
626 CMD_ECHO_ADMINS, VCF_NONE, 0
628 {"kick", ALLOW_CTRL,
629 /* TRANS: translate text between <> */
630 N_("kick <user>"),
631 N_("Cut a connection and disallow reconnect."),
632 N_("The connection given by the 'user' argument will be cut from the "
633 "server and not allowed to reconnect. The time the user wouldn't be "
634 "able to reconnect is controlled by the 'kicktime' setting."), NULL,
635 CMD_ECHO_ADMINS, VCF_NOPASSALONE, 50
637 {"delegate", ALLOW_BASIC,
638 /* TRANS: translate only text between [] and <> */
639 N_("delegate to <username> [player-name]\n"
640 "delegate cancel [player-name]\n"
641 "delegate take <player-name>\n"
642 "delegate restore\n"
643 "delegate show <player-name>"),
644 N_("Delegate control to another user."),
645 N_("Delegation allows a user to nominate another user who can temporarily "
646 "take over control of their player while they are away.\n"
647 "'delegate to <username>': allow <username> to 'delegate take' your "
648 "player.\n"
649 "'delegate cancel': nominated user can no longer take your player.\n"
650 "'delegate take <player-name>': take control of a player who has been "
651 "delegated to you. (Behaves like 'take', except that the 'allowtake' "
652 "restrictions are not enforced.)\n"
653 "'delegate restore': relinquish control of a delegated player (opposite "
654 "of 'delegate take') and restore your previous view, if any. (This also "
655 "happens automatically if the player's owner reconnects.)\n"
656 "'delegate show': show who control of your player is currently "
657 "delegated to, if anyone.\n"
658 "The [player-name] argument can only be used by connections with "
659 "cmdlevel 'admin' or above to force the corresponding change of the "
660 "delegation status."), NULL,
661 CMD_ECHO_NONE, VCF_NONE, 0
663 {"fcdb", ALLOW_ADMIN,
664 /* TRANS: translate text between <> only */
665 N_("fcdb reload\n"
666 "fcdb lua <script>"),
667 N_("Manage the authentication database."),
668 N_("The argument 'reload' causes the database script file to be re-read "
669 "after a change, while the argument 'lua' evaluates a line of Lua "
670 "script in the context of the Lua instance for the database."), NULL,
671 CMD_ECHO_ADMINS, VCF_NONE, 0
673 {"mapimg", ALLOW_ADMIN,
674 /* TRANS: translate text between <> only */
675 N_("mapimg define <mapdef>\n"
676 "mapimg show <id>|all\n"
677 "mapimg create <id>|all\n"
678 "mapimg delete <id>|all\n"
679 "mapimg colortest"),
680 N_("Create image files of the world/player map."),
681 NULL, mapimg_help,
682 CMD_ECHO_ADMINS, VCF_NONE, 50
684 {"rfcstyle", ALLOW_HACK,
685 /* no translatable parameters */
686 SYN_ORIG_("rfcstyle"),
687 N_("Switch server output between 'RFC-style' and normal style."), NULL, NULL,
688 CMD_ECHO_ADMINS, VCF_NONE, 0
690 {"serverid", ALLOW_INFO,
691 /* no translatable parameters */
692 SYN_ORIG_("serverid"),
693 N_("Simply returns the id of the server."), NULL, NULL,
694 CMD_ECHO_NONE, VCF_NONE, 0
699 /**************************************************************************
700 Return command by its number.
701 **************************************************************************/
702 const struct command *command_by_number(int i)
704 fc_assert_ret_val(i >= 0 && i < CMD_NUM, NULL);
705 return &commands[i];
708 /**************************************************************************
709 Return name of the command
710 **************************************************************************/
711 const char *command_name(const struct command *pcommand)
713 return pcommand->name;
716 /**************************************************************************
717 Return name of the command by commands number.
718 **************************************************************************/
719 const char *command_name_by_number(int i)
721 return command_by_number(i)->name;
724 /**************************************************************************
725 Returns the synopsis text of the command (translated).
726 **************************************************************************/
727 const char *command_synopsis(const struct command *pcommand)
729 return SYN_TRANS_(pcommand->synopsis);
732 /**************************************************************************
733 Returns the short help text of the command (translated).
734 **************************************************************************/
735 const char *command_short_help(const struct command *pcommand)
737 return _(pcommand->short_help);
740 /**************************************************************************
741 Returns the extra help text of the command (translated).
742 The caller must free this string.
743 **************************************************************************/
744 char *command_extra_help(const struct command *pcommand)
746 if (pcommand->extra_help_func) {
747 fc_assert(pcommand->extra_help == NULL);
748 return pcommand->extra_help_func();
749 } else if (pcommand->extra_help) {
750 return fc_strdup(_(pcommand->extra_help));
751 } else {
752 return NULL;
756 /**************************************************************************
758 **************************************************************************/
759 enum cmdlevel command_level(const struct command *pcommand)
761 return pcommand->level;
764 /****************************************************************************
765 Retrurns the flag of the command to notify the users about its usage.
766 ****************************************************************************/
767 enum cmd_echo command_echo(const struct command *pcommand)
769 return pcommand->echo;
772 /**************************************************************************
773 Returns a bit-wise combination of all vote flags set for this command.
774 **************************************************************************/
775 int command_vote_flags(const struct command *pcommand)
777 return pcommand ? pcommand->vote_flags : 0;
780 /**************************************************************************
781 Returns the vote percent required for this command to pass in a vote.
782 **************************************************************************/
783 int command_vote_percent(const struct command *pcommand)
785 return pcommand ? pcommand->vote_percent : 0;