Freeciv-3.2
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 {"metamessage", ALLOW_CTRL,
254 /* TRANS: translate text between <> only */
255 N_("metamessage <meta-line>"),
256 N_("Set metaserver info line."),
257 N_("This command is deprecated. Set metamessage setting directly instead. "
258 "Command sets user defined metaserver info line. If parameter is omitted, "
259 "previously set metamessage will be removed. For most of the time "
260 "user defined metamessage will be used instead of automatically "
261 "generated messages, if it is available."), NULL,
263 },
264 {"metapatches", ALLOW_HACK,
265 /* TRANS: translate text between <> only */
266 N_("metapatches <meta-line>"),
267 N_("Set metaserver patches line."), NULL, NULL,
269 },
270 {"metaconnection", ALLOW_ADMIN,
271 /* No translatable parameters */
272 SYN_ORIG_("metaconnection u|up\n"
273 "metaconnection d|down\n"
274 "metaconnection p|persistent\n"
275 "metaconnection ?"),
276 N_("Control metaserver connection."),
277 N_("'metaconnection ?' reports on the status of the connection to metaserver. "
278 "'metaconnection down' or 'metac d' brings the metaserver connection down. "
279 "'metaconnection up' or 'metac u' brings the metaserver connection up. "
280 "'metaconnection persistent' or 'metac p' is like 'up', but keeps trying after failures. "),
281 NULL,
283 },
284 {"metaserver", ALLOW_ADMIN,
285 /* TRANS: translate text between <> only */
286 N_("metaserver <address>"),
287 N_("Set address (URL) for metaserver to report to."), NULL, NULL,
289 },
290 {"aitoggle", ALLOW_CTRL,
291 /* TRANS: translate text between <> only */
292 N_("aitoggle <player-name>"),
293 N_("Toggle AI status of player."), NULL, NULL,
295 },
296 {"take", ALLOW_INFO,
297 /* TRANS: translate text between [] and <> only */
298 N_("take [connection-name] <player-name>"),
299 N_("Take over a player's place in the game."),
300 /* TRANS: Don't translate text between '' */
301 N_("Only the console and connections with cmdlevel 'hack' can force "
302 "other connections to take over a player. If you're not one of these, "
303 "only the <player-name> argument is allowed. If '-' is given for the "
304 "player name and the connection does not already control a player, one "
305 "is created and assigned to the connection. The 'allowtake' option "
306 "controls which players may be taken and in what circumstances."),
307 NULL,
309 },
310 {"observe", ALLOW_INFO,
311 /* TRANS: translate text between [] only */
312 N_("observe [connection-name] [player-name]"),
313 N_("Observe a player or the whole game."),
314 /* TRANS: Don't translate text between '' */
315 N_("Only the console and connections with cmdlevel 'hack' can force "
316 "other connections to observe a player. If you're not one of these, "
317 "only the [player-name] argument is allowed. If the console gives no "
318 "player-name or the connection uses no arguments, then the connection "
319 "is attached to a global observer. The 'allowtake' option controls "
320 "which players may be observed and in what circumstances."), NULL,
322 },
323 {"detach", ALLOW_INFO,
324 /* TRANS: translate text between <> only */
325 N_("detach <connection-name>"),
326 N_("Detach from a player."),
327 N_("Only the console and connections with cmdlevel 'hack' can force "
328 "other connections to detach from a player."), NULL,
330 },
331 {"create", ALLOW_CTRL,
332 /* TRANS: translate text between <> and [] only */
333 N_("create <player-name> [ai type]"),
334 N_("Create an AI player with a given name."),
335 /* TRANS: don't translate text between single quotes */
336 N_("With the 'create' command a new player with the given name is "
337 "created.\n"
338 "If 'player-name' is empty, a random name will be assigned when the "
339 "game begins. Until then the player will be known by a name derived "
340 "from its type.\n"
341 "The 'ai type' parameter can be used to select which AI module will be "
342 "used for the created player. This requires that the respective module "
343 "has been loaded or built in to the server.\n"
344 "If the game has already started, the new player will have no units or "
345 "cities; also, if no free player slots are available, the slot of a "
346 "dead player can be reused (removing all record of that player from the "
347 "running game)."), NULL,
349 },
350 {"away", ALLOW_BASIC,
351 /* no translatable parameters */
352 SYN_ORIG_("away"),
353 N_("Set yourself in away mode. The AI will watch your back."),
356 },
357 {"restricted", ALLOW_CTRL,
358 /* TRANS: translate text between <> only */
359 N_("restricted\n"
360 "restricted <player-name>"),
361 /* TRANS: translate 'Restricted' as AI skill level */
362 N_("Set one or all AI players to 'Restricted'."), NULL, ai_level_help,
364 },
365 {"novice", ALLOW_CTRL,
366 /* TRANS: translate text between <> only */
367 N_("novice\n"
368 "novice <player-name>"),
369 /* TRANS: translate 'Novice' as AI skill level */
370 N_("Set one or all AI players to 'Novice'."), NULL, ai_level_help,
372 },
373 {"easy", ALLOW_CTRL,
374 /* TRANS: translate text between <> only */
375 N_("easy\n"
376 "easy <player-name>"),
377 /* TRANS: translate 'Easy' as AI skill level */
378 N_("Set one or all AI players to 'Easy'."), NULL, ai_level_help,
380 },
381 {"normal", ALLOW_CTRL,
382 /* TRANS: translate text between <> only */
383 N_("normal\n"
384 "normal <player-name>"),
385 /* TRANS: translate 'Normal' as AI skill level */
386 N_("Set one or all AI players to 'Normal'."), NULL, ai_level_help,
388 },
389 {"hard", ALLOW_CTRL,
390 /* TRANS: translate text between <> only */
391 N_("hard\n"
392 "hard <player-name>"),
393 /* TRANS: translate 'Hard' as AI skill level */
394 N_("Set one or all AI players to 'Hard'."), NULL, ai_level_help,
396 },
397 {"cheating", ALLOW_CTRL,
398 /* TRANS: translate text between <> only */
399 N_("cheating\n"
400 "cheating <player-name>"),
401 /* TRANS: translate 'Cheating' as AI skill level */
402 N_("Set one or all AI players to 'Cheating'."), NULL, ai_level_help,
404 },
405#ifdef FREECIV_DEBUG
406 {"experimental", ALLOW_CTRL,
407 /* TRANS: translate text between <> only */
408 N_("experimental\n"
409 "experimental <player-name>"),
410 /* TRANS: translate 'Experimental' as AI skill level */
411 N_("Set one or all AI players to 'Experimental'."), NULL, ai_level_help,
413 },
414#endif /* FREECIV_DEBUG */
415 {"cmdlevel", ALLOW_ADMIN,
416 /* TRANS: translate text between <> only */
417 N_("cmdlevel\n"
418 "cmdlevel <level>\n"
419 "cmdlevel <level> new\n"
420 "cmdlevel <level> first\n"
421 "cmdlevel <level> <connection-name>"),
422 N_("Query or set command access level access."),
423 N_("The command access level controls which server commands are available "
424 "to users via the client chatline. The available levels are:\n"
425 " none - no commands\n"
426 " info - informational or observer commands only\n"
427 " basic - commands available to players in the game\n"
428 " ctrl - commands that affect the game and users\n"
429 " admin - commands that affect server operation\n"
430 " hack - *all* commands - dangerous!\n"
431 "With no arguments, the current command access levels are reported. "
432 "With a single argument, the level is set for all existing "
433 "connections, and the default is set for future connections. "
434 "If 'new' is specified, the level is set for newly connecting clients. "
435 "If 'first come' is specified, the 'first come' level is set; it will be "
436 "granted to the first client to connect, or if there are connections "
437 "already, the first client to issue the 'first' command. "
438 "If a connection name is specified, the level is set for that "
439 "connection only.\n"
440 "Command access levels do not persist if a client disconnects, "
441 "because some untrusted person could reconnect with the same name. "
442 "Note that this command now takes connection names, not player names."
443 ), NULL,
445 },
446 {"first", ALLOW_BASIC,
447 /* no translatable parameters */
448 SYN_ORIG_("first"),
449 N_("If there is none, become the game organizer with increased permissions."),
450 NULL, NULL,
452 },
453 {"timeoutincrease", ALLOW_CTRL,
454 /* TRANS: translate text between <> only */
455 N_("timeoutincrease <turn> <turninc> <value> <valuemult>"),
456 N_("See \"/help timeoutincrease\"."),
457 N_("Every <turn> turns, add <value> to timeout timer, then add <turninc> "
458 "to <turn> and multiply <value> by <valuemult>. Use this command in "
459 "concert with the option \"timeout\". Defaults are 0 0 0 1"), NULL,
461 },
462 {"cancelvote", ALLOW_BASIC,
463 /* TRANS: translate text between <> only; "vote" is as a process */
464 N_("cancelvote\n"
465 "cancelvote <vote number>\n"
466 "cancelvote all\n"),
467 /* TRANS: "vote" as a process */
468 N_("Cancel a running vote."),
469 /* TRANS: "vote" as a process */
470 N_("With no arguments this command removes your own vote. If you have "
471 "an admin access level, you can cancel any vote by vote number, or "
472 "all votes with the \'all\' argument."), NULL,
474 },
475 {"ignore", ALLOW_INFO,
476 /* TRANS: translate text between <> and [] only */
477 N_("ignore [type=]<pattern>"),
478 N_("Block all messages from users matching the pattern."),
479 N_("The given pattern will be added to your ignore list; you will not "
480 "receive any messages from users matching this pattern. The type "
481 "may be either \"user\", \"host\", or \"ip\". The default type "
482 "(if omitted) is to match against the username. The pattern supports "
483 "unix glob style wildcards, i.e., * matches zero or more character, ? "
484 "exactly one character, [abc] exactly one of 'a' 'b' or 'c', etc. "
485 "To access your current ignore list, issue \"/list ignore\"."), NULL,
487 },
488 {"unignore", ALLOW_INFO,
489 /* TRANS: translate text between <> */
490 N_("unignore <range>"),
491 N_("Remove ignore list entries."),
492 N_("The ignore list entries in the given range will be removed; "
493 "you will be able to receive messages from the respective users. "
494 "The range argument may be a single number or a pair of numbers "
495 "separated by a dash '-'. If the first number is omitted, it is "
496 "assumed to be 1; if the last is omitted, it is assumed to be "
497 "the last valid ignore list index. To access your current ignore "
498 "list, issue \"/list ignore\"."), NULL,
500 },
501 {"playercolor", ALLOW_ADMIN,
502 /* TRANS: translate text between <> */
503 N_("playercolor <player-name> <color>\n"
504 "playercolor <player-name> reset"),
505 N_("Define the color of a player."),
506 N_("This command sets the color of a specific player, overriding any color "
507 "assigned according to the 'plrcolormode' setting.\n"
508 "The color is defined using hexadecimal notation (hex) for the "
509 "combination of Red, Green, and Blue color components (RGB), similarly "
510 "to HTML. For each component, the lowest (darkest) value is 0 (in "
511 "hex: 00), and the highest value is 255 (in hex: FF). The color "
512 "definition is simply the three hex values concatenated together "
513 "(RRGGBB). For example, the following command sets Caesar to pure red:\n"
514 " playercolor Caesar ff0000\n"
515 "Before the game starts, this command can only be used if the "
516 "'plrcolormode' setting is set to 'PLR_SET'; a player's color can be "
517 "unset again by specifying 'reset'.\n"
518 "Once the game has started and colors have been assigned, this command "
519 "changes the player color in any mode; 'reset' cannot be used.\n"
520 "To list the player colors, use 'list colors'."), NULL,
522 },
523 {"playernation", ALLOW_ADMIN,
524 /* TRANS: translate text between <> and [] only */
525 N_("playernation <player-name> [nation] [is-male] [leader] [style]"),
526 N_("Define the nation of a player."),
527 N_("This command sets the nation, leader name, style, and gender of a "
528 "specific player.\nThe gender parameter should be 1 if male, "
529 "otherwise 0. Omitting any of the player settings will reset the "
530 "player to defaults.\n"
531 "This command may not be used once the game has started."), NULL,
533 },
534 {"endgame", ALLOW_ADMIN,
535 /* no translatable parameters */
536 SYN_ORIG_("endgame"),
537 N_("End the game immediately in a draw."), NULL, NULL,
539 },
540 {"surrender", ALLOW_BASIC,
541 /* no translatable parameters */
542 SYN_ORIG_("surrender"),
543 N_("Concede the game."),
544 N_("This tells everyone else that you concede the game, and if all "
545 "but one player (or one team) have conceded the game in this way "
546 "then the game ends."), NULL,
548 },
549 {"remove", ALLOW_CTRL,
550 /* TRANS: translate text between <> only */
551 N_("remove <player-name>"),
552 N_("Fully remove player from game."),
553 N_("This *completely* removes a player from the game, including "
554 "all cities and units etc. Use with care!"), NULL,
556 },
557 {"save", ALLOW_ADMIN,
558 /* TRANS: translate text between <> only */
559 N_("save\n"
560 "save <file-name>"),
561 N_("Save game to file."),
562 N_("Save the current game to file <file-name>. If no file-name "
563 "argument is given saves to \"<auto-save name prefix><year>m.sav[.gz]\". "
564 "To reload a savegame created by 'save', start the server with "
565 "the command-line argument:\n"
566 " '--file <filename>' or '-f <filename>'\n"
567 "and use the 'start' command once players have reconnected."), NULL,
569 },
570 {"scensave", ALLOW_ADMIN,
571 /* TRANS: translate text between <> only */
572 N_("scensave\n"
573 "scensave <file-name>"),
574 N_("Save game to file as scenario."),
575 N_("Save the current game to file <file-name> as scenario. If no file-name "
576 "argument is given saves to \"<auto-save name prefix><year>m.sav[.gz]\". "
577 "To reload a savegame created by 'scensave', start the server with "
578 "the command-line argument:\n"
579 " '--file <filename>' or '-f <filename>'\n"
580 "and use the 'start' command once players have reconnected."), NULL,
582 },
583 {"load", ALLOW_CTRL,
584 /* TRANS: translate text between <> only */
585 N_("load\n"
586 "load <file-name>"),
587 N_("Load game from file."),
588 N_("Load a game from <file-name>. Any current data including players, "
589 "rulesets and server options are lost."), NULL,
591 },
592 {"read", ALLOW_CTRL,
593 /* TRANS: translate text between <> only */
594 N_("read <file-name>"),
595 N_("Process server commands from file."), NULL, NULL,
597 },
598 {"write", ALLOW_HACK,
599 /* TRANS: translate text between <> only */
600 N_("write <file-name>"),
601 N_("Write current settings as server commands to file."), NULL, NULL,
603 },
604 {"reset", ALLOW_CTRL,
605 /* no translatable parameters */
606 SYN_ORIG_("reset [game|ruleset|script|default]"),
607 N_("Reset all server settings."),
608 N_("Reset all settings if it is possible. The following levels are "
609 "supported:\n"
610 " game - using the values defined at the game start\n"
611 " ruleset - using the values defined in the ruleset\n"
612 " script - using default values and rereading the start script\n"
613 " default - using default values\n"), NULL,
615 },
616 {"default", ALLOW_CTRL,
617 /* TRANS: translate text between <> only */
618 N_("default <option name>"),
619 N_("Set option to its default value"),
620 N_("Reset the option to its default value. If the default ever changes "
621 "in a future version, the option's value will follow that change."),
622 NULL,
624 },
625 {"lua", ALLOW_ADMIN,
626 /* TRANS: translate text between <> only */
627 N_("lua cmd <script line>\n"
628 "lua unsafe-cmd <script line>\n"
629 "lua file <script file>\n"
630 "lua unsafe-file <script file>\n"
631 "lua <script line> (deprecated)"),
632 N_("Evaluate a line of Freeciv script or a Freeciv script file in the "
633 "current game."),
634 /* TRANS: Do not translate 'unsafe' or 'hack' */
635 N_("Subcommands with the 'unsafe' prefix run the script in an instance "
636 "separate from the ruleset. This instance doesn't restrict access "
637 "to Lua functions that can be used to hack the computer running "
638 "the Freeciv server. Access to it is therefore limited to the console "
639 "and connections with cmdlevel 'hack'"), NULL,
641 },
642 {"kick", ALLOW_CTRL,
643 /* TRANS: translate text between <> */
644 N_("kick <user>"),
645 N_("Cut a connection and disallow reconnect."),
646 N_("The connection given by the 'user' argument will be cut from the "
647 "server and not allowed to reconnect. The time the user wouldn't be "
648 "able to reconnect is controlled by the 'kicktime' setting."), NULL,
650 },
651 {"delegate", ALLOW_BASIC,
652 /* TRANS: translate only text between [] and <> */
653 N_("delegate to <username> [player-name]\n"
654 "delegate cancel [player-name]\n"
655 "delegate take <player-name>\n"
656 "delegate restore\n"
657 "delegate show <player-name>"),
658 N_("Delegate control to another user."),
659 N_("Delegation allows a user to nominate another user who can temporarily "
660 "take over control of their player while they are away.\n"
661 "'delegate to <username>': allow <username> to 'delegate take' your "
662 "player.\n"
663 "'delegate cancel': nominated user can no longer take your player.\n"
664 "'delegate take <player-name>': take control of a player who has been "
665 "delegated to you. (Behaves like 'take', except that the 'allowtake' "
666 "restrictions are not enforced.)\n"
667 "'delegate restore': relinquish control of a delegated player (opposite "
668 "of 'delegate take') and restore your previous view, if any. (This also "
669 "happens automatically if the player's owner reconnects.)\n"
670 "'delegate show': show who control of your player is currently "
671 "delegated to, if anyone.\n"
672 "The [player-name] argument can only be used by connections with "
673 "cmdlevel 'admin' or above to force the corresponding change of the "
674 "delegation status."), NULL,
676 },
677 {"aicmd", ALLOW_ADMIN,
678 /* TRANS: translate text between <> only */
679 N_("aicmd <player> <command>"),
680 N_("Execute AI command"),
681 N_("Execute a command in the context of the AI for the given player"),
682 NULL,
684 },
685 {"fcdb", ALLOW_ADMIN,
686 /* TRANS: translate text between <> only */
687 N_("fcdb reload\n"
688 "fcdb lua <script>"),
689 N_("Manage the authentication database."),
690 N_("The argument 'reload' causes the database script file to be re-read "
691 "after a change, while the argument 'lua' evaluates a line of Lua "
692 "script in the context of the Lua instance for the database."), NULL,
694 },
695 {"mapimg", ALLOW_ADMIN,
696 /* TRANS: translate text between <> only */
697 N_("mapimg define <mapdef>\n"
698 "mapimg show <id>|all\n"
699 "mapimg create <id>|all\n"
700 "mapimg delete <id>|all\n"
701 "mapimg colortest"),
702 N_("Create image files of the world/player map."),
705 },
706 {"lock", ALLOW_HACK,
707 /* TRANS: translate text between <> only */
708 N_("lock <setting>"),
709 N_("Lock setting so that non-admins can't change it."),
710 NULL, NULL,
712 },
713 {"unlock", ALLOW_HACK,
714 /* TRANS: translate text between <> only */
715 N_("unlock <setting>"),
716 N_("Unlock setting so that non-admins can change it."),
717 NULL, NULL,
719 },
720 {"rfcstyle", ALLOW_HACK,
721 /* no translatable parameters */
722 SYN_ORIG_("rfcstyle"),
723 N_("Switch server output between 'RFC-style' and normal style."), NULL, NULL,
725 },
726 {"serverid", ALLOW_INFO,
727 /* no translatable parameters */
728 SYN_ORIG_("serverid"),
729 N_("Simply returns the id of the server."), NULL, NULL,
731 }
732};
733
734/**********************************************************************/
737const struct command *command_by_number(int i)
738{
739 fc_assert_ret_val(i >= 0 && i < CMD_NUM, NULL);
740 return &commands[i];
741}
742
743/**********************************************************************/
746const char *command_name(const struct command *pcommand)
747{
748 return pcommand->name;
749}
750
751/**********************************************************************/
754const char *command_name_by_number(int i)
755{
756 return command_by_number(i)->name;
757}
758
759/**********************************************************************/
762const char *command_synopsis(const struct command *pcommand)
763{
764 return SYN_TRANS_(pcommand->synopsis);
765}
766
767/**********************************************************************/
770const char *command_short_help(const struct command *pcommand)
771{
772 return _(pcommand->short_help);
773}
774
775/**********************************************************************/
780{
781 if (pcommand->extra_help_func) {
782 fc_assert(pcommand->extra_help == NULL);
783 return pcommand->extra_help_func(pcommand->name);
784 } else if (pcommand->extra_help) {
785 return fc_strdup(_(pcommand->extra_help));
786 } else {
787 return NULL;
788 }
789}
790
791/**********************************************************************/
795{
796 return pcommand->level;
797}
798
799/**********************************************************************/
803{
804 return pcommand->echo;
805}
806
807/**********************************************************************/
811{
812 return pcommand ? pcommand->vote_flags : 0;
813}
814
815/**********************************************************************/
819{
820 return pcommand ? pcommand->vote_percent : 0;
821}
static struct command commands[]
Definition commands.c:52
enum cmd_echo command_echo(const struct command *pcommand)
Definition commands.c:802
#define SYN_TRANS_(String)
Definition commands.c:35
const char * command_name_by_number(int i)
Definition commands.c:754
const char * command_name(const struct command *pcommand)
Definition commands.c:746
int command_vote_percent(const struct command *pcommand)
Definition commands.c:818
#define SYN_ORIG_(String)
Definition commands.c:33
const struct command * command_by_number(int i)
Definition commands.c:737
int command_vote_flags(const struct command *pcommand)
Definition commands.c:810
const char * command_short_help(const struct command *pcommand)
Definition commands.c:770
char * command_extra_help(const struct command *pcommand)
Definition commands.c:779
enum cmdlevel command_level(const struct command *pcommand)
Definition commands.c:794
const char * command_synopsis(const struct command *pcommand)
Definition commands.c:762
@ CMD_NUM
Definition commands.h:109
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:75
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:176
#define fc_assert_ret_val(condition, val)
Definition log.h:194
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