Freeciv21
Develop your civilization from humble roots to a global empire
commands.h
Go to the documentation of this file.
1 /**************************************************************************
2 \^~~~~\ ) ( /~~~~^/ * _ Copyright (c) 1996-2020 Freeciv21 and
3  ) *** \ {**} / *** ( * _ {o} _ Freeciv contributors. This file is
4  ) *** \_ ^^ _/ *** ( * {o}{o}{o} part of Freeciv21. Freeciv21 is free
5  ) **** vv **** ( * ~\ | /~software: you can redistribute it and/or
6  )_**** ****_( * OoO modify it under the terms of the GNU
7  )*** m m ***( * /|\ General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version. You should have received a copy of
10  the GNU General Public License along with Freeciv21.
11  If not, see https://www.gnu.org/licenses/.
12 **************************************************************************/
13 
14 #pragma once
15 
16 #include "connection.h" // enum cmdlevel
17 
18 enum cmd_echo {
20  CMD_ECHO_ADMINS, // i.e. all with 'admin' access and above.
22 };
23 
24 /**************************************************************************
25  Commands - can be recognised by unique prefix
26 **************************************************************************/
27 /* Order here is important: for ambiguous abbreviations the first
28  match is used. Arrange order to:
29  - allow old commands 's', 'h', 'l', 'q', 'c' to work.
30  - reduce harm for ambiguous cases, where "harm" includes inconvenience,
31  eg accidently removing a player in a running game.
32 */
33 enum command_id {
34  // old one-letter commands:
40 
41  // completely non-harmful:
47 
48  // mostly non-harmful:
69 #ifdef FREECIV_DEBUG
70  CMD_EXPERIMENTAL,
71 #endif
74  CMD_TIMEOUT_SHOW, // not really harmful, info level
83 
84  // potentially harmful:
86  CMD_SURRENDER, // not really harmful, info level
101 
102  // undocumented
105 
106  // pseudo-commands:
107  CMD_NUM, // the number of commands - for iterations
108  CMD_UNRECOGNIZED, // used as a possible iteration result
109  CMD_AMBIGUOUS // used as a possible iteration result
110 };
111 
112 const struct command *command_by_number(int i);
113 const char *command_name_by_number(int i);
114 
115 const char *command_name(const struct command *pcommand);
116 const char *command_synopsis(const struct command *pcommand);
117 const char *command_short_help(const struct command *pcommand);
118 char *command_extra_help(const struct command *pcommand);
119 
120 enum cmdlevel command_level(const struct command *pcommand);
121 enum cmd_echo command_echo(const struct command *pcommand);
122 int command_vote_flags(const struct command *pcommand);
123 int command_vote_percent(const struct command *pcommand);
command_id
Definition: commands.h:33
@ CMD_NUM
Definition: commands.h:107
@ CMD_IGNORE
Definition: commands.h:79
@ CMD_TIMEOUT_SHOW
Definition: commands.h:74
@ CMD_METASERVER
Definition: commands.h:56
@ CMD_END_GAME
Definition: commands.h:85
@ CMD_DEFAULT
Definition: commands.h:94
@ CMD_METAPATCHES
Definition: commands.h:54
@ CMD_TEAM
Definition: commands.h:51
@ CMD_DELEGATE
Definition: commands.h:97
@ CMD_CHEATING
Definition: commands.h:68
@ CMD_PLAYERCOLOR
Definition: commands.h:81
@ CMD_LIST
Definition: commands.h:37
@ CMD_AITOGGLE
Definition: commands.h:57
@ CMD_CUT
Definition: commands.h:39
@ CMD_EXPLAIN
Definition: commands.h:42
@ CMD_SHOW
Definition: commands.h:43
@ CMD_METAMESSAGE
Definition: commands.h:53
@ CMD_RULESETDIR
Definition: commands.h:52
@ CMD_HARD
Definition: commands.h:67
@ CMD_RFCSTYLE
Definition: commands.h:103
@ CMD_DETACH
Definition: commands.h:60
@ CMD_NORMAL
Definition: commands.h:66
@ CMD_HANDICAPPED
Definition: commands.h:63
@ CMD_VOTE
Definition: commands.h:46
@ CMD_NOVICE
Definition: commands.h:64
@ CMD_UNRECOGNIZED
Definition: commands.h:108
@ CMD_CREATE
Definition: commands.h:61
@ CMD_LOAD
Definition: commands.h:90
@ CMD_AICMD
Definition: commands.h:98
@ CMD_AMBIGUOUS
Definition: commands.h:109
@ CMD_LUA
Definition: commands.h:95
@ CMD_FCDB
Definition: commands.h:99
@ CMD_CANCELVOTE
Definition: commands.h:78
@ CMD_TIMEOUT_INCREASE
Definition: commands.h:77
@ CMD_SAVE
Definition: commands.h:88
@ CMD_TIMEOUT_SET
Definition: commands.h:75
@ CMD_SRVID
Definition: commands.h:104
@ CMD_SCENSAVE
Definition: commands.h:89
@ CMD_START_GAME
Definition: commands.h:35
@ CMD_UNIGNORE
Definition: commands.h:80
@ CMD_FIRSTLEVEL
Definition: commands.h:73
@ CMD_WALL
Definition: commands.h:44
@ CMD_TIMEOUT_ADD
Definition: commands.h:76
@ CMD_EASY
Definition: commands.h:65
@ CMD_KICK
Definition: commands.h:96
@ CMD_WRITE_SCRIPT
Definition: commands.h:92
@ CMD_CONNECTMSG
Definition: commands.h:45
@ CMD_TAKE
Definition: commands.h:58
@ CMD_HELP
Definition: commands.h:36
@ CMD_REMOVE
Definition: commands.h:87
@ CMD_OBSERVE
Definition: commands.h:59
@ CMD_RESET
Definition: commands.h:93
@ CMD_SURRENDER
Definition: commands.h:86
@ CMD_METACONN
Definition: commands.h:55
@ CMD_READ_SCRIPT
Definition: commands.h:91
@ CMD_CMDLEVEL
Definition: commands.h:72
@ CMD_SET
Definition: commands.h:50
@ CMD_AWAY
Definition: commands.h:62
@ CMD_QUIT
Definition: commands.h:38
@ CMD_DEBUG
Definition: commands.h:49
@ CMD_PLAYERNATION
Definition: commands.h:82
@ CMD_MAPIMG
Definition: commands.h:100
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
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
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
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