Freeciv-3.3: /fast/freeciv/nightly/main/server/commands.c Source File

Freeciv-3.3

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