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