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