Freeciv21
Develop your civilization from humble roots to a global empire
stdinhand.cpp File Reference
#include <fc_config.h>
#include <cstdarg>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <QCoreApplication>
#include <QRegularExpression>
#include <readline/readline.h>
#include "astring.h"
#include "bitvector.h"
#include "fciconv.h"
#include "fcintl.h"
#include "log.h"
#include "rand.h"
#include "registry.h"
#include "section_file.h"
#include "shared.h"
#include "support.h"
#include "timing.h"
#include "featured_text.h"
#include "game.h"
#include "map.h"
#include "mapimg.h"
#include "packets.h"
#include "player.h"
#include "research.h"
#include "rgbcolor.h"
#include "style.h"
#include "unitlist.h"
#include "version.h"
#include "aiiface.h"
#include "commands.h"
#include "connecthand.h"
#include "diplhand.h"
#include "gamehand.h"
#include "maphand.h"
#include "meta.h"
#include "notify.h"
#include "plrhand.h"
#include "ruleset.h"
#include "sanitycheck.h"
#include "settings.h"
#include "srv_log.h"
#include "srv_main.h"
#include "techtools.h"
#include "voting.h"
#include "savemain.h"
#include "script_fcdb.h"
#include "script_server.h"
#include "difficulty.h"
#include "stdinhand.h"
#include <set>
#include <string>
#include "specenum_gen.h"

Go to the source code of this file.

Macros

#define OPTION_NAME_SPACE   25
 
#define REG_EXP   "\\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)"
 
#define LOOKUP_OPTION_NO_RESULT   (-1)
 
#define LOOKUP_OPTION_AMBIGUOUS   (-2)
 
#define LOOKUP_OPTION_LEVEL_NAME   (-3)
 
#define LOOKUP_OPTION_RULESETDIR   (-4)
 
#define cmd_reply_show(string)    cmd_reply(called_as, caller, C_COMMENT, "%s", string)
 
#define SPECENUM_NAME   reset_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   RESET_GAME
 
#define SPECENUM_VALUE0NAME   "game"
 
#define SPECENUM_VALUE1   RESET_RULESET
 
#define SPECENUM_VALUE1NAME   "ruleset"
 
#define SPECENUM_VALUE2   RESET_SCRIPT
 
#define SPECENUM_VALUE2NAME   "script"
 
#define SPECENUM_VALUE3   RESET_DEFAULT
 
#define SPECENUM_VALUE3NAME   "default"
 
#define SPECENUM_NAME   lua_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   LUA_CMD
 
#define SPECENUM_VALUE0NAME   "cmd"
 
#define SPECENUM_VALUE1   LUA_FILE
 
#define SPECENUM_VALUE1NAME   "file"
 
#define SPECENUM_VALUE2   LUA_UNSAFE_CMD
 
#define SPECENUM_VALUE2NAME   "unsafe-cmd"
 
#define SPECENUM_VALUE3   LUA_UNSAFE_FILE
 
#define SPECENUM_VALUE3NAME   "unsafe-file"
 
#define SPECENUM_NAME   delegate_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   DELEGATE_CANCEL
 
#define SPECENUM_VALUE0NAME   "cancel"
 
#define SPECENUM_VALUE1   DELEGATE_RESTORE
 
#define SPECENUM_VALUE1NAME   "restore"
 
#define SPECENUM_VALUE2   DELEGATE_SHOW
 
#define SPECENUM_VALUE2NAME   "show"
 
#define SPECENUM_VALUE3   DELEGATE_TAKE
 
#define SPECENUM_VALUE3NAME   "take"
 
#define SPECENUM_VALUE4   DELEGATE_TO
 
#define SPECENUM_VALUE4NAME   "to"
 
#define SPECENUM_NAME   mapimg_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   MAPIMG_COLORTEST
 
#define SPECENUM_VALUE0NAME   "colortest"
 
#define SPECENUM_VALUE1   MAPIMG_CREATE
 
#define SPECENUM_VALUE1NAME   "create"
 
#define SPECENUM_VALUE2   MAPIMG_DEFINE
 
#define SPECENUM_VALUE2NAME   "define"
 
#define SPECENUM_VALUE3   MAPIMG_DELETE
 
#define SPECENUM_VALUE3NAME   "delete"
 
#define SPECENUM_VALUE4   MAPIMG_SHOW
 
#define SPECENUM_VALUE4NAME   "show"
 
#define SPECENUM_COUNT   MAPIMG_COUNT
 
#define SPECENUM_NAME   fcdb_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   FCDB_RELOAD
 
#define SPECENUM_VALUE0NAME   "reload"
 
#define SPECENUM_VALUE1   FCDB_LUA
 
#define SPECENUM_VALUE1NAME   "lua"
 
#define SPECENUM_COUNT   FCDB_COUNT
 
#define SPECENUM_NAME   help_general_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   HELP_GENERAL_COMMANDS
 
#define SPECENUM_VALUE0NAME   "commands"
 
#define SPECENUM_VALUE1   HELP_GENERAL_OPTIONS
 
#define SPECENUM_VALUE1NAME   "options"
 
#define SPECENUM_COUNT   HELP_GENERAL_COUNT
 
#define HELP_ARG_NUM   (CMD_NUM + HELP_GENERAL_COUNT + settings_number())
 
#define SPECENUM_NAME   list_args
 Additional 'help' arguments. More...
 
#define SPECENUM_VALUE0   LIST_COLORS
 
#define SPECENUM_VALUE0NAME   "colors"
 
#define SPECENUM_VALUE1   LIST_CONNECTIONS
 
#define SPECENUM_VALUE1NAME   "connections"
 
#define SPECENUM_VALUE2   LIST_DELEGATIONS
 
#define SPECENUM_VALUE2NAME   "delegations"
 
#define SPECENUM_VALUE3   LIST_IGNORE
 
#define SPECENUM_VALUE3NAME   "ignored users"
 
#define SPECENUM_VALUE4   LIST_MAPIMG
 
#define SPECENUM_VALUE4NAME   "map image definitions"
 
#define SPECENUM_VALUE5   LIST_PLAYERS
 
#define SPECENUM_VALUE5NAME   "players"
 
#define SPECENUM_VALUE6   LIST_RULESETS
 
#define SPECENUM_VALUE6NAME   "rulesets"
 
#define SPECENUM_VALUE7   LIST_SCENARIOS
 
#define SPECENUM_VALUE7NAME   "scenarios"
 
#define SPECENUM_VALUE8   LIST_NATIONSETS
 
#define SPECENUM_VALUE8NAME   "nationsets"
 
#define SPECENUM_VALUE9   LIST_TEAMS
 
#define SPECENUM_VALUE9NAME   "teams"
 
#define SPECENUM_VALUE10   LIST_VOTES
 
#define SPECENUM_VALUE10NAME   "votes"
 

Typedefs

typedef QHash< QString, time_t > kickhash
 

Functions

static bool cut_client_connection (struct connection *caller, char *name, bool check)
 Handle cut command. More...
 
static bool show_help (struct connection *caller, char *arg)
 Handle help command. More...
 
static bool show_list (struct connection *caller, char *arg)
 Show list of players or connections, or connection statistics. More...
 
static void show_colors (struct connection *caller)
 Show a list of all players with the assigned color. More...
 
static bool set_ai_level_named (struct connection *caller, const char *name, const char *level_name, bool check)
 Handle a user command to set an AI level. More...
 
static bool set_ai_level (struct connection *caller, const char *name, enum ai_level level, bool check)
 Set AI level. More...
 
static bool away_command (struct connection *caller, bool check)
 Set user to away mode. More...
 
static bool set_rulesetdir (struct connection *caller, char *str, bool check, int read_recursion)
 Load rulesets from a given ruleset directory. More...
 
static bool show_command (struct connection *caller, char *str, bool check)
 /show command: show settings and their values. More...
 
static bool show_settings (struct connection *caller, enum command_id called_as, char *str, bool check)
 Print a summary of the settings and their values. More...
 
static void show_settings_one (struct connection *caller, enum command_id cmd, struct setting *pset)
 Show one setting. More...
 
static void show_ruleset_info (struct connection *caller, enum command_id cmd, bool check, int read_recursion)
 Show changed settings and ruleset summary. More...
 
static void show_mapimg (struct connection *caller, enum command_id cmd)
 Show a list of all map image definitions on the command line. More...
 
static bool set_command (struct connection *caller, char *str, bool check)
 Handle set command. More...
 
static bool create_command (struct connection *caller, const char *str, bool check)
 Creates a named AI player. More...
 
static bool end_command (struct connection *caller, char *str, bool check)
 End the game immediately in a draw. More...
 
static bool surrender_command (struct connection *caller, char *str, bool check)
 Concede the game. More...
 
static bool handle_stdin_input_real (struct connection *caller, char *str, bool check, int read_recursion)
 Handle "command input", which could really come from stdin on console, or from client chat command, or read from file with -r, etc. More...
 
static bool read_init_script_real (struct connection *caller, const char *script_filename, bool from_cmdline, bool check, int read_recursion)
 Returns FALSE iff there was an error. More...
 
static bool reset_command (struct connection *caller, char *arg, bool check, int read_recursion)
 Reload the game settings from the ruleset and reload the init script if one was used. More...
 
static bool default_command (struct connection *caller, char *arg, bool check)
 Set a setting to its default value. More...
 
static bool lua_command (struct connection *caller, char *arg, bool check, int read_recursion)
 Evaluate a line of lua script or a lua script file. More...
 
static bool kick_command (struct connection *caller, char *name, bool check)
 Kick command handler. More...
 
static bool delegate_command (struct connection *caller, char *arg, bool check)
 Handle delegation of control. More...
 
static QString delegate_player_str (struct player *pplayer, bool observer)
 Return static string describing what a connection is connected to. More...
 
static bool aicmd_command (struct connection *caller, char *arg, bool check)
 Execute a command in the context of the AI of the player. More...
 
static bool fcdb_command (struct connection *caller, char *arg, bool check)
 Handle the freeciv database script module. More...
 
static const char * fcdb_accessor (int i)
 Returns possible parameters for the fcdb command. More...
 
static char setting_status (struct connection *caller, const struct setting *pset)
 Return the status of the setting (changeable, locked, fixed). More...
 
static bool player_name_check (const char *name, char *buf, size_t buflen)
 Check the player name. More...
 
static bool playercolor_command (struct connection *caller, char *str, bool check)
 /playercolor command handler. More...
 
static bool playernation_command (struct connection *caller, char *str, bool check)
 /playernation command handler. More...
 
static bool mapimg_command (struct connection *caller, char *arg, bool check)
 Handle mapimg command. More...
 
static const char * mapimg_accessor (int i)
 Returns possible parameters for the mapimg command. More...
 
static void show_delegations (struct connection *caller)
 List all delegations of the current game. More...
 
static void remove_quotes (QStringList &str)
 
static bool is_restricted (struct connection *caller)
 Are we operating under a restricted security regime? For now this does not do much. More...
 
static enum command_id command_named (const char *token, bool accept_ambiguity)
 Convert a named command into an id. More...
 
void stdinhand_init ()
 Initialize stuff related to this code module. More...
 
void stdinhand_turn ()
 Update stuff every turn that is related to this code module. More...
 
void stdinhand_free ()
 Deinitialize stuff related to this code module. More...
 
static bool may_use (struct connection *caller, enum command_id cmd)
 Whether the caller can use the specified command. More...
 
static bool may_use_nothing (struct connection *caller)
 Whether the caller cannot use any commands at all. More...
 
static void cmd_reply_line (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *line)
 feedback related to server commands caller == nullptr means console. More...
 
static void vcmd_reply_prefix (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *format, va_list ap)
 va_list version which allow embedded newlines, and each line is sent separately. More...
 
static void cmd_reply_prefix (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *format,...) fc__attribute((__format__(__printf__
 var-args version of above duplicate declaration required for attribute to work... More...
 
static void static void cmd_reply_prefix (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *format,...)
 
void cmd_reply (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *format,...)
 var-args version as above, no prefix More...
 
static void cmd_reply_no_such_player (enum command_id cmd, struct connection *caller, const char *name, enum m_pre_result match_result)
 Command specific argument parsing has detected that player argument is invalid. More...
 
static void cmd_reply_no_such_conn (enum command_id cmd, struct connection *caller, const char *name, enum m_pre_result match_result)
 Command specific argument parsing has detected that connection argument is invalid. More...
 
static void open_metaserver_connection (struct connection *caller, bool persistent)
 Start sending game info to metaserver. More...
 
static void close_metaserver_connection (struct connection *caller)
 Stop sending game info to metaserver. More...
 
static bool metaconnection_command (struct connection *caller, char *arg, bool check)
 Handle metaconnection command. More...
 
static bool metapatches_command (struct connection *caller, char *arg, bool check)
 Handle metapatches command. More...
 
static bool metamessage_command (struct connection *caller, char *arg, bool check)
 Handle metamessage command. More...
 
static bool metaserver_command (struct connection *caller, char *arg, bool check)
 Handle metaserver command. More...
 
static bool show_serverid (struct connection *caller, char *arg)
 Returns the serverid. More...
 
static bool save_command (struct connection *caller, char *arg, bool check)
 For command "save foo"; Save the game, with filename=arg, provided server state is ok. More...
 
static bool scensave_command (struct connection *caller, char *arg, bool check)
 For command "scensave foo"; Save the game, with filename=arg, provided server state is ok. More...
 
void toggle_ai_player_direct (struct connection *caller, struct player *pplayer)
 Handle ai player ai toggling. More...
 
static bool toggle_ai_command (struct connection *caller, char *arg, bool check)
 Handle aitoggle command. More...
 
enum rfc_status create_command_newcomer (const char *name, const char *ai, bool check, struct nation_type *pnation, struct player **newplayer, char *buf, size_t buflen)
 Try to add a player to a running game in the following order: More...
 
enum rfc_status create_command_pregame (const char *name, const char *ai, bool check, struct player **newplayer, char *buf, size_t buflen)
 Create player in pregame. More...
 
static bool remove_player_command (struct connection *caller, char *arg, bool check)
 Handle remove command. More...
 
static bool read_command (struct connection *caller, char *arg, bool check, int read_recursion)
 Main entry point for the read command. More...
 
bool read_init_script (struct connection *caller, const char *script_filename, bool from_cmdline, bool check)
 Main entry point for reading an init script. More...
 
QVector< QString > * get_init_script_choices ()
 Return a list of init scripts found on the data path. More...
 
static void write_init_script (char *script_filename)
 Write current settings to new init script. More...
 
static bool write_command (struct connection *caller, char *arg, bool check)
 Generate init script from settings currently in use. More...
 
static bool set_cmdlevel (struct connection *caller, struct connection *ptarget, enum cmdlevel level)
 Set ptarget's cmdlevel to level if caller is allowed to do so. More...
 
static bool a_connection_exists ()
 Returns true if there is at least one established connection. More...
 
static bool is_first_access_level_taken ()
 Return whether first access level is already taken. More...
 
enum cmdlevel access_level_for_next_connection ()
 Return access level for next connection. More...
 
void notify_if_first_access_level_is_available ()
 Check if first access level is available and if it is, notify connections about it. More...
 
static bool cmdlevel_command (struct connection *caller, char *str, bool check)
 Change command access level for individual player, or all, or new. More...
 
static bool firstlevel_command (struct connection *caller, bool check)
 This special command to set the command access level is not included into cmdlevel_command because of its lower access level: it can be used to promote one's own connection to 'first come' cmdlevel if that isn't already taken. More...
 
void set_running_game_access_level ()
 Adjust default command level on game start. More...
 
static const char * optname_accessor (int i)
 Returns possible parameters for the commands that take server options as parameters (CMD_EXPLAIN and CMD_SET). More...
 
static const char * olvlname_accessor (int i)
 Returns possible parameters for the /show command. More...
 
static bool timeout_show_command (struct connection *caller, char *str, bool check)
 Show the current timeout, time left before TC, etc. More...
 
static bool timeout_set_command (struct connection *caller, char *str, bool check, command_id self, bool add)
 Sets the timeout for the current turn. More...
 
static bool timeout_command (struct connection *caller, char *str, bool check)
 Set timeout options. More...
 
static enum sset_level lookup_option_level (const char *name)
 Find option level number by name. More...
 
static int lookup_option (const char *name)
 Find option index by name. More...
 
static void show_help_option (struct connection *caller, enum command_id help_cmd, int id)
 Show the caller detailed help for the single OPTION given by id. More...
 
static void show_help_option_list (struct connection *caller, enum command_id help_cmd)
 Show the caller list of OPTIONS. More...
 
static bool explain_option (struct connection *caller, char *str, bool check)
 Handle explain command. More...
 
static bool wall (char *str, bool check)
 Send a message to all players. More...
 
static bool connectmsg_command (struct connection *caller, char *str, bool check)
 Set message to send to all new connections. More...
 
static enum command_id cmd_of_level (enum ai_level level)
 Translate an AI level back to its CMD_* value. More...
 
void set_ai_level_direct (struct player *pplayer, enum ai_level level)
 Set an AI level from the server prompt. More...
 
static bool team_command (struct connection *caller, char *str, bool check)
 Handle team command. More...
 
static void show_votes (struct connection *caller)
 List all running votes. More...
 
static const char * vote_arg_accessor (int i)
 
static bool vote_command (struct connection *caller, char *str, bool check)
 Make or participate in a vote. More...
 
static bool cancelvote_command (struct connection *caller, char *arg, bool check)
 Cancel a vote... More...
 
static bool debug_command (struct connection *caller, char *str, bool check)
 Turn on selective debugging. More...
 
static struct settingvalidate_setting_arg (enum command_id cmd, struct connection *caller, char *arg)
 Helper to validate an argument referring to a server setting. More...
 
static bool is_allowed_to_take (struct connection *requester, struct connection *taker, struct player *pplayer, bool will_obs, char *msg, size_t msg_len)
 Check game.allow_take and fcdb if enabled for permission to take or observe a player. More...
 
static bool observe_command (struct connection *caller, char *str, bool check)
 Observe another player. More...
 
static bool take_command (struct connection *caller, char *str, bool check)
 Take over a player. More...
 
static bool detach_command (struct connection *caller, char *str, bool check)
 Detach from a player. More...
 
bool load_command (struct connection *caller, const char *filename, bool check, bool cmdline_load)
 Loads a file, complete with access checks and error messages sent back to the caller on failure. More...
 
static bool ignore_command (struct connection *caller, char *str, bool check)
 /ignore command handler. More...
 
static bool unignore_command (struct connection *caller, char *str, bool check)
 /unignore command handler. More...
 
static bool quit_game (struct connection *caller, bool check)
 Handle quit command. More...
 
bool should_quit ()
 Returns whether the server should exit after a command. More...
 
bool handle_stdin_input (struct connection *caller, char *str)
 Main entry point for "command input". More...
 
static const char * reset_accessor (int i)
 Returns possible parameters for the reset command. More...
 
static const char * lua_accessor (int i)
 Returns possible parameters for the reset command. More...
 
static const char * delegate_accessor (int i)
 Returns possible parameters for the 'delegate' command. More...
 
static void start_cmd_reply (struct connection *caller, bool notify, const char *msg)
 Send start command related message. More...
 
bool start_command (struct connection *caller, bool check, bool notify)
 Handle start command. More...
 
bool conn_is_kicked (struct connection *pconn, int *time_remaining)
 Returns FALSE if the connection isn't kicked and can connect the server normally. More...
 
static void show_help_intro (struct connection *caller, enum command_id help_cmd)
 Show caller introductory help about the server. More...
 
static void show_help_command (struct connection *caller, enum command_id help_cmd, enum command_id id)
 Show the caller detailed help for the single COMMAND given by id. More...
 
static void show_help_command_list (struct connection *caller, enum command_id help_cmd)
 Show the caller list of COMMANDS. More...
 
static void cmd_reply_matches (enum command_id cmd, struct connection *caller, m_pre_accessor_fn_t accessor_fn, int *matches, int num_matches)
 Send a reply to the caller listing the matched names from an ambiguous prefix. More...
 
static const char * helparg_accessor (int i)
 Convert unified helparg index to string; see above. More...
 
static void show_connections (struct connection *caller)
 List connections; initially mainly for debugging. More...
 
static bool show_ignore (struct connection *caller)
 Show the ignore list of the. More...
 
void show_players (struct connection *caller)
 Show the list of the players of the game. More...
 
static void show_rulesets (struct connection *caller)
 List rulesets (strictly, .serv init script files that conventionally accompany rulesets). More...
 
static void show_scenarios (struct connection *caller)
 List scenarios. More...
 
static void show_nationsets (struct connection *caller)
 List nation sets in the current ruleset. More...
 
static void show_teams (struct connection *caller)
 Show a list of teams on the command line. More...
 
static const char * list_accessor (int i)
 Returns possible parameters for the list command. More...
 
static char * generic_generator (const char *text, int state, int num, const char *(*index2str)(int))
 A generalised generator function: text and state are "standard" parameters to a readline generator function; num is number of possible completions, or -1 if this is not known and index2str should be iterated until it returns nullptr; index2str is a function which returns each possible completion string by index (it may return nullptr). More...
 
static char * command_generator (const char *text, int state)
 The valid commands at the root of the prompt. More...
 
static char * option_generator (const char *text, int state)
 The valid arguments to "set" and "explain". More...
 
static char * olevel_generator (const char *text, int state)
 The valid arguments to "show". More...
 
static const char * option_value_accessor (int idx)
 
static char * option_value_generator (const char *text, int state)
 The valid arguments to "set OPT", where OPT is the enumerated or bitwise option previously defined by completion_option. More...
 
static const char * playername_accessor (int idx)
 Access player name. More...
 
static char * player_generator (const char *text, int state)
 The valid playername arguments. More...
 
static const char * connection_name_accessor (int idx)
 Access connection user name, from game.all_connections. More...
 
static char * connection_generator (const char *text, int state)
 The valid connection user name arguments. More...
 
static const char * cmdlevel_arg1_accessor (int idx)
 Extra accessor function since cmdlevel_name() takes enum argument, not int. More...
 
static char * cmdlevel_arg1_generator (const char *text, int state)
 The valid first argument to "cmdlevel". More...
 
static const char * cmdlevel_arg2_accessor (int idx)
 Accessor for the second argument to "cmdlevel": "first" or "new" or a connection name. More...
 
static char * cmdlevel_arg2_generator (const char *text, int state)
 The valid arguments for the second argument to "cmdlevel". More...
 
static const char * aitype_accessor (int idx)
 Accessor for the second argument to "create": ai type name. More...
 
static char * aitype_generator (const char *text, int state)
 The valid arguments for the second argument to "create". More...
 
static char * reset_generator (const char *text, int state)
 The valid arguments for the argument to "reset". More...
 
static char * vote_generator (const char *text, int state)
 The valid arguments for the argument to "vote". More...
 
static char * delegate_generator (const char *text, int state)
 The valid arguments for the first argument to "delegate". More...
 
static char * mapimg_generator (const char *text, int state)
 The valid arguments for the first argument to "mapimg". More...
 
static char * fcdb_generator (const char *text, int state)
 The valid arguments for the argument to "fcdb". More...
 
static char * lua_generator (const char *text, int state)
 The valid arguments for the argument to "lua". More...
 
static char * help_generator (const char *text, int state)
 The valid first arguments to "help". More...
 
static char * list_generator (const char *text, int state)
 The valid first arguments to "list". More...
 
static bool contains_token_before_start (int start, int token, const char *arg, bool allow_fluff)
 Generalised version of contains_str_before_start, which searches the N'th token in rl_line_buffer (0=first). More...
 
static bool contains_str_before_start (int start, const char *cmd, bool allow_fluff)
 Returns whether the text between the start of rl_line_buffer and the start position is of the form [non-alpha]*cmd[non-alpha]* allow_fluff changes the regexp to [non-alpha]*cmd[non-alpha]. More...
 
static bool is_command (int start)
 Return whether we are completing command name. More...
 
static int num_tokens (int start)
 Number of tokens in rl_line_buffer before start. More...
 
static bool is_player (int start)
 Return whether we are completing player name argument. More...
 
static bool is_connection (int start)
 Return whether we are completing connection name argument. More...
 
static bool is_cmdlevel_arg2 (int start)
 Return whether we are completing cmdlevel command argument 2. More...
 
static bool is_cmdlevel_arg1 (int start)
 Return whether we are completing cmdlevel command argument. More...
 
static bool is_server_option (int start)
 Returns TRUE if the readline buffer string matches a server option at the given position. More...
 
static bool is_option_level (int start)
 Returns true if the readline buffer string matches an option level or an option at the given position. More...
 
static bool is_enum_option_value (int start, int *opt_p)
 Returns TRUE if the readline buffer string is such that we expect an enumerated value at the given position. More...
 
static bool is_filename (int start)
 Return whether we are completing filename. More...
 
static bool is_create_arg2 (int start)
 Return whether we are completing second argument for create command. More...
 
static bool is_reset (int start)
 Return whether we are completing argument for reset command. More...
 
static bool is_vote (int start)
 Return whether we are completing argument for vote command. More...
 
static bool is_delegate_arg1 (int start)
 Return whether we are completing first argument for delegate command. More...
 
static bool is_mapimg (int start)
 Return whether we are completing first argument for mapimg command. More...
 
static bool is_fcdb (int start)
 Return whether we are completing argument for fcdb command. More...
 
static bool is_lua (int start)
 Return whether we are completing argument for lua command. More...
 
static bool is_help (int start)
 Return whether we are completing help command argument. More...
 
static bool is_list (int start)
 Return whether we are completing list command argument. More...
 
char ** freeciv_completion (const char *text, int start, int end)
 Attempt to complete on the contents of TEXT. More...
 

Variables

static enum cmdlevel default_access_level = ALLOW_BASIC
 
static enum cmdlevel first_access_level = ALLOW_BASIC
 
static const char horiz_line []
 
static const char *const vote_args [] = {"yes", "no", "abstain", nullptr}
 Vote command argument definitions. More...
 
static int completion_option
 Accessor for values of the enum/bitwise option defined by 'completion_option'. More...
 
static const int player_cmd []
 Commands that may be followed by a player name. More...
 
static const int connection_cmd [] = {CMD_CUT, CMD_KICK, -1}
 Commands that may be followed by a connection name. More...
 
static const int server_option_cmd []
 Commands that may be followed by a server option name. More...
 
static const int option_level_cmd [] = {CMD_SHOW, -1}
 Commands that may be followed by an option level or server option. More...
 
static const int filename_cmd []
 Commands that may be followed by a filename. More...
 

Macro Definition Documentation

◆ cmd_reply_show

#define cmd_reply_show (   string)     cmd_reply(called_as, caller, C_COMMENT, "%s", string)

◆ HELP_ARG_NUM

#define HELP_ARG_NUM   (CMD_NUM + HELP_GENERAL_COUNT + settings_number())

Definition at line 6572 of file stdinhand.cpp.

◆ LOOKUP_OPTION_AMBIGUOUS

#define LOOKUP_OPTION_AMBIGUOUS   (-2)

Definition at line 1772 of file stdinhand.cpp.

◆ LOOKUP_OPTION_LEVEL_NAME

#define LOOKUP_OPTION_LEVEL_NAME   (-3)

Definition at line 1773 of file stdinhand.cpp.

◆ LOOKUP_OPTION_NO_RESULT

#define LOOKUP_OPTION_NO_RESULT   (-1)

Definition at line 1771 of file stdinhand.cpp.

◆ LOOKUP_OPTION_RULESETDIR

#define LOOKUP_OPTION_RULESETDIR   (-4)

Definition at line 1774 of file stdinhand.cpp.

◆ OPTION_NAME_SPACE

#define OPTION_NAME_SPACE   25

Definition at line 86 of file stdinhand.cpp.

◆ REG_EXP

#define REG_EXP   "\\s+(?=([^\"]*\"[^\"]*\")*[^\"]*$)"

Definition at line 87 of file stdinhand.cpp.

◆ SPECENUM_COUNT [1/3]

#define SPECENUM_COUNT   MAPIMG_COUNT

Definition at line 6563 of file stdinhand.cpp.

◆ SPECENUM_COUNT [2/3]

#define SPECENUM_COUNT   FCDB_COUNT

Definition at line 6563 of file stdinhand.cpp.

◆ SPECENUM_COUNT [3/3]

#define SPECENUM_COUNT   HELP_GENERAL_COUNT

Definition at line 6563 of file stdinhand.cpp.

◆ SPECENUM_NAME [1/7]

#define SPECENUM_NAME   reset_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_NAME [2/7]

#define SPECENUM_NAME   lua_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_NAME [3/7]

#define SPECENUM_NAME   delegate_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_NAME [4/7]

#define SPECENUM_NAME   mapimg_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_NAME [5/7]

#define SPECENUM_NAME   fcdb_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_NAME [6/7]

#define SPECENUM_NAME   help_general_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_NAME [7/7]

#define SPECENUM_NAME   list_args

Additional 'help' arguments.

'/list' arguments

Definition at line 7020 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [1/7]

#define SPECENUM_VALUE0   RESET_GAME

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [2/7]

#define SPECENUM_VALUE0   LUA_CMD

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [3/7]

#define SPECENUM_VALUE0   DELEGATE_CANCEL

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [4/7]

#define SPECENUM_VALUE0   MAPIMG_COLORTEST

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [5/7]

#define SPECENUM_VALUE0   FCDB_RELOAD

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [6/7]

#define SPECENUM_VALUE0   HELP_GENERAL_COMMANDS

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0 [7/7]

#define SPECENUM_VALUE0   LIST_COLORS

Definition at line 7021 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [1/7]

#define SPECENUM_VALUE0NAME   "game"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [2/7]

#define SPECENUM_VALUE0NAME   "cmd"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [3/7]

#define SPECENUM_VALUE0NAME   "cancel"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [4/7]

#define SPECENUM_VALUE0NAME   "colortest"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [5/7]

#define SPECENUM_VALUE0NAME   "reload"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [6/7]

#define SPECENUM_VALUE0NAME   "commands"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE0NAME [7/7]

#define SPECENUM_VALUE0NAME   "colors"

Definition at line 7022 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [1/7]

#define SPECENUM_VALUE1   RESET_RULESET

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [2/7]

#define SPECENUM_VALUE1   LUA_FILE

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [3/7]

#define SPECENUM_VALUE1   DELEGATE_RESTORE

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [4/7]

#define SPECENUM_VALUE1   MAPIMG_CREATE

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [5/7]

#define SPECENUM_VALUE1   FCDB_LUA

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [6/7]

#define SPECENUM_VALUE1   HELP_GENERAL_OPTIONS

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE1 [7/7]

#define SPECENUM_VALUE1   LIST_CONNECTIONS

Definition at line 7023 of file stdinhand.cpp.

◆ SPECENUM_VALUE10

#define SPECENUM_VALUE10   LIST_VOTES

Definition at line 7041 of file stdinhand.cpp.

◆ SPECENUM_VALUE10NAME

#define SPECENUM_VALUE10NAME   "votes"

Definition at line 7042 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [1/7]

#define SPECENUM_VALUE1NAME   "ruleset"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [2/7]

#define SPECENUM_VALUE1NAME   "file"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [3/7]

#define SPECENUM_VALUE1NAME   "restore"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [4/7]

#define SPECENUM_VALUE1NAME   "create"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [5/7]

#define SPECENUM_VALUE1NAME   "lua"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [6/7]

#define SPECENUM_VALUE1NAME   "options"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE1NAME [7/7]

#define SPECENUM_VALUE1NAME   "connections"

Definition at line 7024 of file stdinhand.cpp.

◆ SPECENUM_VALUE2 [1/5]

#define SPECENUM_VALUE2   RESET_SCRIPT

Definition at line 7025 of file stdinhand.cpp.

◆ SPECENUM_VALUE2 [2/5]

#define SPECENUM_VALUE2   LUA_UNSAFE_CMD

Definition at line 7025 of file stdinhand.cpp.

◆ SPECENUM_VALUE2 [3/5]

#define SPECENUM_VALUE2   DELEGATE_SHOW

Definition at line 7025 of file stdinhand.cpp.

◆ SPECENUM_VALUE2 [4/5]

#define SPECENUM_VALUE2   MAPIMG_DEFINE

Definition at line 7025 of file stdinhand.cpp.

◆ SPECENUM_VALUE2 [5/5]

#define SPECENUM_VALUE2   LIST_DELEGATIONS

Definition at line 7025 of file stdinhand.cpp.

◆ SPECENUM_VALUE2NAME [1/5]

#define SPECENUM_VALUE2NAME   "script"

Definition at line 7026 of file stdinhand.cpp.

◆ SPECENUM_VALUE2NAME [2/5]

#define SPECENUM_VALUE2NAME   "unsafe-cmd"

Definition at line 7026 of file stdinhand.cpp.

◆ SPECENUM_VALUE2NAME [3/5]

#define SPECENUM_VALUE2NAME   "show"

Definition at line 7026 of file stdinhand.cpp.

◆ SPECENUM_VALUE2NAME [4/5]

#define SPECENUM_VALUE2NAME   "define"

Definition at line 7026 of file stdinhand.cpp.

◆ SPECENUM_VALUE2NAME [5/5]

#define SPECENUM_VALUE2NAME   "delegations"

Definition at line 7026 of file stdinhand.cpp.

◆ SPECENUM_VALUE3 [1/5]

#define SPECENUM_VALUE3   RESET_DEFAULT

Definition at line 7027 of file stdinhand.cpp.

◆ SPECENUM_VALUE3 [2/5]

#define SPECENUM_VALUE3   LUA_UNSAFE_FILE

Definition at line 7027 of file stdinhand.cpp.

◆ SPECENUM_VALUE3 [3/5]

#define SPECENUM_VALUE3   DELEGATE_TAKE

Definition at line 7027 of file stdinhand.cpp.

◆ SPECENUM_VALUE3 [4/5]

#define SPECENUM_VALUE3   MAPIMG_DELETE

Definition at line 7027 of file stdinhand.cpp.

◆ SPECENUM_VALUE3 [5/5]

#define SPECENUM_VALUE3   LIST_IGNORE

Definition at line 7027 of file stdinhand.cpp.

◆ SPECENUM_VALUE3NAME [1/5]

#define SPECENUM_VALUE3NAME   "default"

Definition at line 7028 of file stdinhand.cpp.

◆ SPECENUM_VALUE3NAME [2/5]

#define SPECENUM_VALUE3NAME   "unsafe-file"

Definition at line 7028 of file stdinhand.cpp.

◆ SPECENUM_VALUE3NAME [3/5]

#define SPECENUM_VALUE3NAME   "take"

Definition at line 7028 of file stdinhand.cpp.

◆ SPECENUM_VALUE3NAME [4/5]

#define SPECENUM_VALUE3NAME   "delete"

Definition at line 7028 of file stdinhand.cpp.

◆ SPECENUM_VALUE3NAME [5/5]

#define SPECENUM_VALUE3NAME   "ignored users"

Definition at line 7028 of file stdinhand.cpp.

◆ SPECENUM_VALUE4 [1/3]

#define SPECENUM_VALUE4   DELEGATE_TO

Definition at line 7029 of file stdinhand.cpp.

◆ SPECENUM_VALUE4 [2/3]

#define SPECENUM_VALUE4   MAPIMG_SHOW

Definition at line 7029 of file stdinhand.cpp.

◆ SPECENUM_VALUE4 [3/3]

#define SPECENUM_VALUE4   LIST_MAPIMG

Definition at line 7029 of file stdinhand.cpp.

◆ SPECENUM_VALUE4NAME [1/3]

#define SPECENUM_VALUE4NAME   "to"

Definition at line 7030 of file stdinhand.cpp.

◆ SPECENUM_VALUE4NAME [2/3]

#define SPECENUM_VALUE4NAME   "show"

Definition at line 7030 of file stdinhand.cpp.

◆ SPECENUM_VALUE4NAME [3/3]

#define SPECENUM_VALUE4NAME   "map image definitions"

Definition at line 7030 of file stdinhand.cpp.

◆ SPECENUM_VALUE5

#define SPECENUM_VALUE5   LIST_PLAYERS

Definition at line 7031 of file stdinhand.cpp.

◆ SPECENUM_VALUE5NAME

#define SPECENUM_VALUE5NAME   "players"

Definition at line 7032 of file stdinhand.cpp.

◆ SPECENUM_VALUE6

#define SPECENUM_VALUE6   LIST_RULESETS

Definition at line 7033 of file stdinhand.cpp.

◆ SPECENUM_VALUE6NAME

#define SPECENUM_VALUE6NAME   "rulesets"

Definition at line 7034 of file stdinhand.cpp.

◆ SPECENUM_VALUE7

#define SPECENUM_VALUE7   LIST_SCENARIOS

Definition at line 7035 of file stdinhand.cpp.

◆ SPECENUM_VALUE7NAME

#define SPECENUM_VALUE7NAME   "scenarios"

Definition at line 7036 of file stdinhand.cpp.

◆ SPECENUM_VALUE8

#define SPECENUM_VALUE8   LIST_NATIONSETS

Definition at line 7037 of file stdinhand.cpp.

◆ SPECENUM_VALUE8NAME

#define SPECENUM_VALUE8NAME   "nationsets"

Definition at line 7038 of file stdinhand.cpp.

◆ SPECENUM_VALUE9

#define SPECENUM_VALUE9   LIST_TEAMS

Definition at line 7039 of file stdinhand.cpp.

◆ SPECENUM_VALUE9NAME

#define SPECENUM_VALUE9NAME   "teams"

Definition at line 7040 of file stdinhand.cpp.

Typedef Documentation

◆ kickhash

typedef QHash<QString, time_t> kickhash

Definition at line 91 of file stdinhand.cpp.

Function Documentation

◆ a_connection_exists()

static bool a_connection_exists ( )
static

Returns true if there is at least one established connection.

Definition at line 1345 of file stdinhand.cpp.

◆ access_level_for_next_connection()

enum cmdlevel access_level_for_next_connection ( )

Return access level for next connection.

Definition at line 1353 of file stdinhand.cpp.

Referenced by server_make_connection().

◆ aicmd_command()

static bool aicmd_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Execute a command in the context of the AI of the player.

Definition at line 5937 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ aitype_accessor()

static const char* aitype_accessor ( int  idx)
static

Accessor for the second argument to "create": ai type name.

Definition at line 7310 of file stdinhand.cpp.

Referenced by aitype_generator().

◆ aitype_generator()

static char* aitype_generator ( const char *  text,
int  state 
)
static

The valid arguments for the second argument to "create".

Definition at line 7318 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ away_command()

static bool away_command ( struct connection caller,
bool  check 
)
static

Set user to away mode.

Definition at line 2135 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ cancelvote_command()

static bool cancelvote_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Cancel a vote...

/cancelvote (vote number)|all.

Definition at line 2667 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ close_metaserver_connection()

static void close_metaserver_connection ( struct connection caller)
static

Stop sending game info to metaserver.

Definition at line 489 of file stdinhand.cpp.

Referenced by metaconnection_command(), and metaserver_command().

◆ cmd_of_level()

static enum command_id cmd_of_level ( enum ai_level  level)
static

Translate an AI level back to its CMD_* value.

If we just used /set ailevel <num> we wouldn't have to do this - rp

Definition at line 1984 of file stdinhand.cpp.

Referenced by set_ai_level(), and set_ai_level_direct().

◆ cmd_reply()

void cmd_reply ( enum command_id  cmd,
struct connection caller,
enum rfc_status rfc_status  ,
const char *  format,
  ... 
)

var-args version as above, no prefix

Definition at line 393 of file stdinhand.cpp.

Referenced by aicmd_command(), away_command(), cancelvote_command(), close_metaserver_connection(), cmd_of_level(), cmd_reply_matches(), cmd_reply_no_such_conn(), cmd_reply_no_such_player(), cmdlevel_command(), create_command(), cut_client_connection(), debug_command(), default_command(), delegate_command(), detach_command(), end_command(), explain_option(), fcdb_command(), firstlevel_command(), handle_stdin_input_real(), ignore_command(), kick_command(), load_command(), lookup_option_level(), lua_command(), mapimg_command(), metaconnection_command(), metamessage_command(), metapatches_command(), metaserver_command(), observe_command(), open_metaserver_connection(), playercolor_command(), playernation_command(), quit_game(), read_init_script_real(), remove_player_command(), reset_command(), save_command(), scensave_command(), script_fcdb_cmd_reply(), script_server_cmd_reply(), set_ai_level(), set_ai_level_direct(), set_cmdlevel(), set_command(), set_rulesetdir(), show_colors(), show_connections(), show_delegations(), show_help(), show_help_command(), show_help_command_list(), show_help_intro(), show_help_option(), show_help_option_list(), show_ignore(), show_list(), show_mapimg(), show_nationsets(), show_players(), show_ruleset_info(), show_rulesets(), show_scenarios(), show_serverid(), show_settings(), show_teams(), show_votes(), start_cmd_reply(), surrender_command(), take_command(), team_command(), timeout_set_command(), timeout_show_command(), toggle_ai_player_direct(), unignore_command(), validate_setting_arg(), vote_command(), and write_command().

◆ cmd_reply_line()

static void cmd_reply_line ( enum command_id  cmd,
struct connection caller,
enum rfc_status  rfc_status,
const char *  prefix,
const char *  line 
)
static

feedback related to server commands caller == nullptr means console.

No longer duplicate all output to console.

This lowlevel function takes a single line; prefix is prepended to line.

Definition at line 304 of file stdinhand.cpp.

Referenced by vcmd_reply_prefix().

◆ cmd_reply_matches()

static void cmd_reply_matches ( enum command_id  cmd,
struct connection caller,
m_pre_accessor_fn_t  accessor_fn,
int *  matches,
int  num_matches 
)
static

Send a reply to the caller listing the matched names from an ambiguous prefix.

Definition at line 6522 of file stdinhand.cpp.

Referenced by show_help().

◆ cmd_reply_no_such_conn()

static void cmd_reply_no_such_conn ( enum command_id  cmd,
struct connection caller,
const char *  name,
enum m_pre_result  match_result 
)
static

Command specific argument parsing has detected that connection argument is invalid.

This function is common handling for that situation.

Definition at line 441 of file stdinhand.cpp.

Referenced by cmdlevel_command(), cut_client_connection(), detach_command(), kick_command(), observe_command(), and take_command().

◆ cmd_reply_no_such_player()

static void cmd_reply_no_such_player ( enum command_id  cmd,
struct connection caller,
const char *  name,
enum m_pre_result  match_result 
)
static

Command specific argument parsing has detected that player argument is invalid.

This function is common handling for that situation.

Definition at line 406 of file stdinhand.cpp.

Referenced by aicmd_command(), debug_command(), delegate_command(), observe_command(), playercolor_command(), playernation_command(), remove_player_command(), set_ai_level(), take_command(), team_command(), and toggle_ai_command().

◆ cmd_reply_prefix() [1/2]

static void static void cmd_reply_prefix ( enum command_id  cmd,
struct connection caller,
enum rfc_status  rfc_status,
const char *  prefix,
const char *  format,
  ... 
)
static

Definition at line 380 of file stdinhand.cpp.

◆ cmd_reply_prefix() [2/2]

static void cmd_reply_prefix ( enum command_id  cmd,
struct connection caller,
enum rfc_status rfc_status  ,
const char *  prefix,
const char *  format,
  ... 
)
static

var-args version of above duplicate declaration required for attribute to work...

Referenced by show_help_command(), show_help_option(), show_nationsets(), and show_settings_one().

◆ cmdlevel_arg1_accessor()

static const char* cmdlevel_arg1_accessor ( int  idx)
static

Extra accessor function since cmdlevel_name() takes enum argument, not int.

Definition at line 7271 of file stdinhand.cpp.

Referenced by cmdlevel_arg1_generator().

◆ cmdlevel_arg1_generator()

static char* cmdlevel_arg1_generator ( const char *  text,
int  state 
)
static

The valid first argument to "cmdlevel".

Definition at line 7279 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ cmdlevel_arg2_accessor()

static const char* cmdlevel_arg2_accessor ( int  idx)
static

Accessor for the second argument to "cmdlevel": "first" or "new" or a connection name.

Definition at line 7289 of file stdinhand.cpp.

Referenced by cmdlevel_arg2_generator().

◆ cmdlevel_arg2_generator()

static char* cmdlevel_arg2_generator ( const char *  text,
int  state 
)
static

The valid arguments for the second argument to "cmdlevel".

Definition at line 7299 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ cmdlevel_command()

static bool cmdlevel_command ( struct connection caller,
char *  str,
bool  check 
)
static

Change command access level for individual player, or all, or new.

Definition at line 1396 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ command_generator()

static char* command_generator ( const char *  text,
int  state 
)
static

The valid commands at the root of the prompt.

Definition at line 7175 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ command_named()

static enum command_id command_named ( const char *  token,
bool  accept_ambiguity 
)
static

Convert a named command into an id.

If accept_ambiguity is true, return the first command in the enum list which matches, else return CMD_AMBIGUOUS on ambiguity. (This is a trick to allow ambiguity to be handled in a flexible way without importing notify_player() messages inside this routine - rp)

Definition at line 180 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ conn_is_kicked()

bool conn_is_kicked ( struct connection pconn,
int *  time_remaining 
)

Returns FALSE if the connection isn't kicked and can connect the server normally.

Definition at line 6280 of file stdinhand.cpp.

Referenced by handle_login_request().

◆ connection_generator()

static char* connection_generator ( const char *  text,
int  state 
)
static

The valid connection user name arguments.

Definition at line 7261 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ connection_name_accessor()

static const char* connection_name_accessor ( int  idx)
static

Access connection user name, from game.all_connections.

Definition at line 7253 of file stdinhand.cpp.

Referenced by cmdlevel_arg2_accessor(), and connection_generator().

◆ connectmsg_command()

static bool connectmsg_command ( struct connection caller,
char *  str,
bool  check 
)
static

Set message to send to all new connections.

Definition at line 1984 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ contains_str_before_start()

static bool contains_str_before_start ( int  start,
const char *  cmd,
bool  allow_fluff 
)
static

Returns whether the text between the start of rl_line_buffer and the start position is of the form [non-alpha]*cmd[non-alpha]* allow_fluff changes the regexp to [non-alpha]*cmd[non-alpha].

Definition at line 7445 of file stdinhand.cpp.

Referenced by is_cmdlevel_arg1(), is_cmdlevel_arg2(), is_command(), is_connection(), is_create_arg2(), is_delegate_arg1(), is_enum_option_value(), is_fcdb(), is_filename(), is_help(), is_list(), is_lua(), is_mapimg(), is_option_level(), is_player(), is_reset(), is_server_option(), and is_vote().

◆ contains_token_before_start()

static bool contains_token_before_start ( int  start,
int  token,
const char *  arg,
bool  allow_fluff 
)
static

Generalised version of contains_str_before_start, which searches the N'th token in rl_line_buffer (0=first).

Definition at line 7395 of file stdinhand.cpp.

Referenced by contains_str_before_start(), and is_enum_option_value().

◆ create_command()

static bool create_command ( struct connection caller,
const char *  str,
bool  check 
)
static

Creates a named AI player.

The function can be called before the start of the game (see creat_command_pregame()) and for a running game (see creat_command_newcomer(). In the later case, first free player slots are used before the slots of dead players are (re)used.

Definition at line 724 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ create_command_newcomer()

enum rfc_status create_command_newcomer ( const char *  name,
const char *  ai,
bool  check,
struct nation_type pnation,
struct player **  newplayer,
char *  buf,
size_t  buflen 
)

Try to add a player to a running game in the following order:

  1. Try to reuse the slot of a dead player with the username 'name'.
  2. Try to reuse the slot of a dead player.
  3. Try to use an empty player slot.

If 'pnation' is defined this nation is used for the new player.

Definition at line 724 of file stdinhand.cpp.

Referenced by api_edit_create_player(), and create_command().

◆ create_command_pregame()

enum rfc_status create_command_pregame ( const char *  name,
const char *  ai,
bool  check,
struct player **  newplayer,
char *  buf,
size_t  buflen 
)

Create player in pregame.

Definition at line 724 of file stdinhand.cpp.

Referenced by api_edit_create_player(), and create_command().

◆ cut_client_connection()

static bool cut_client_connection ( struct connection caller,
char *  name,
bool  check 
)
static

Handle cut command.

Definition at line 6248 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ debug_command()

static bool debug_command ( struct connection caller,
char *  str,
bool  check 
)
static

Turn on selective debugging.

Definition at line 2761 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ default_command()

static bool default_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Set a setting to its default value.

Definition at line 4963 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ delegate_accessor()

static const char* delegate_accessor ( int  i)
static

Returns possible parameters for the 'delegate' command.

Definition at line 5198 of file stdinhand.cpp.

Referenced by delegate_command(), and delegate_generator().

◆ delegate_command()

static bool delegate_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle delegation of control.

Definition at line 5207 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ delegate_generator()

static char* delegate_generator ( const char *  text,
int  state 
)
static

The valid arguments for the first argument to "delegate".

Definition at line 7344 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ delegate_player_str()

static QString delegate_player_str ( struct player pplayer,
bool  observer 
)
static

Return static string describing what a connection is connected to.

Definition at line 5662 of file stdinhand.cpp.

Referenced by delegate_command().

◆ detach_command()

static bool detach_command ( struct connection caller,
char *  str,
bool  check 
)
static

Detach from a player.

if that player wasn't /created and you were controlling the player, remove it (and then detach any observers as well).

If called for a global observer connection (where pconn->playing is nullptr) then it will correctly detach from observing mode.

Definition at line 3676 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ end_command()

static bool end_command ( struct connection caller,
char *  str,
bool  check 
)
static

End the game immediately in a draw.

Definition at line 4771 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ explain_option()

static bool explain_option ( struct connection caller,
char *  str,
bool  check 
)
static

Handle explain command.

Definition at line 1939 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ fcdb_accessor()

static const char * fcdb_accessor ( int  i)
static

Returns possible parameters for the fcdb command.

Definition at line 6011 of file stdinhand.cpp.

Referenced by fcdb_command(), and fcdb_generator().

◆ fcdb_command()

static bool fcdb_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle the freeciv database script module.

Definition at line 6020 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ fcdb_generator()

static char* fcdb_generator ( const char *  text,
int  state 
)
static

The valid arguments for the argument to "fcdb".

Definition at line 7362 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ firstlevel_command()

static bool firstlevel_command ( struct connection caller,
bool  check 
)
static

This special command to set the command access level is not included into cmdlevel_command because of its lower access level: it can be used to promote one's own connection to 'first come' cmdlevel if that isn't already taken.

Definition at line 1542 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ freeciv_completion()

char** freeciv_completion ( const char *  text,
int  start,
int  end 
)

Attempt to complete on the contents of TEXT.

START and END bound the region of rl_line_buffer that contains the word to complete. TEXT is the word to complete. We can use the entire contents of rl_line_buffer in case we want to do some simple parsing. Return the array of matches, or nullptr if there aren't any.

Definition at line 7767 of file stdinhand.cpp.

Referenced by freeciv::server::init_interactive().

◆ generic_generator()

static char* generic_generator ( const char *  text,
int  state,
int  num,
const char *(*)(int)  index2str 
)
static

A generalised generator function: text and state are "standard" parameters to a readline generator function; num is number of possible completions, or -1 if this is not known and index2str should be iterated until it returns nullptr; index2str is a function which returns each possible completion string by index (it may return nullptr).

Definition at line 7134 of file stdinhand.cpp.

Referenced by aitype_generator(), cmdlevel_arg1_generator(), cmdlevel_arg2_generator(), command_generator(), connection_generator(), delegate_generator(), fcdb_generator(), help_generator(), list_generator(), lua_generator(), mapimg_generator(), olevel_generator(), option_generator(), option_value_generator(), player_generator(), reset_generator(), and vote_generator().

◆ get_init_script_choices()

QVector<QString>* get_init_script_choices ( )

Return a list of init scripts found on the data path.

Caller should free. These are conventionally scripts that load rulesets (generally containing just a 'rulesetdir' command).

Definition at line 1218 of file stdinhand.cpp.

Referenced by send_ruleset_choices(), and show_rulesets().

◆ handle_stdin_input()

bool handle_stdin_input ( struct connection caller,
char *  str 
)

Main entry point for "command input".

Definition at line 4445 of file stdinhand.cpp.

Referenced by check_vote(), handle_chat_msg_req(), and freeciv::server::input_on_stdin().

◆ handle_stdin_input_real()

static bool handle_stdin_input_real ( struct connection caller,
char *  str,
bool  check,
int  read_recursion 
)
static

Handle "command input", which could really come from stdin on console, or from client chat command, or read from file with -r, etc.

caller == nullptr means console, str is the input, which may optionally start with SERVER_COMMAND_PREFIX character.

If check is TRUE, then do nothing, just check syntax.

Definition at line 4458 of file stdinhand.cpp.

Referenced by handle_stdin_input(), and read_init_script_real().

◆ help_generator()

static char* help_generator ( const char *  text,
int  state 
)
static

The valid first arguments to "help".

Definition at line 7378 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ helparg_accessor()

static const char* helparg_accessor ( int  i)
static

Convert unified helparg index to string; see above.

Definition at line 6577 of file stdinhand.cpp.

Referenced by help_generator(), and show_help().

◆ ignore_command()

static bool ignore_command ( struct connection caller,
char *  str,
bool  check 
)
static

/ignore command handler.

Definition at line 4079 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ is_allowed_to_take()

static bool is_allowed_to_take ( struct connection requester,
struct connection taker,
struct player pplayer,
bool  will_obs,
char *  msg,
size_t  msg_len 
)
static

Check game.allow_take and fcdb if enabled for permission to take or observe a player.

NB: If this function returns FALSE, then callers expect that 'msg' will be filled in with a nullptr-terminated string containing the reason.

Definition at line 3210 of file stdinhand.cpp.

Referenced by observe_command(), and take_command().

◆ is_cmdlevel_arg1()

static bool is_cmdlevel_arg1 ( int  start)
static

Return whether we are completing cmdlevel command argument.

Definition at line 7564 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_cmdlevel_arg2()

static bool is_cmdlevel_arg2 ( int  start)
static

Return whether we are completing cmdlevel command argument 2.

Definition at line 7554 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_command()

static bool is_command ( int  start)
static

Return whether we are completing command name.

This can be either command itself, or argument to 'help'.

Definition at line 7455 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_connection()

static bool is_connection ( int  start)
static

Return whether we are completing connection name argument.

Definition at line 7536 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_create_arg2()

static bool is_create_arg2 ( int  start)
static

Return whether we are completing second argument for create command.

Definition at line 7681 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_delegate_arg1()

static bool is_delegate_arg1 ( int  start)
static

Return whether we are completing first argument for delegate command.

Definition at line 7709 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_enum_option_value()

static bool is_enum_option_value ( int  start,
int *  opt_p 
)
static

Returns TRUE if the readline buffer string is such that we expect an enumerated value at the given position.

The option for which values should be completed is written to opt_p.

Definition at line 7627 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_fcdb()

static bool is_fcdb ( int  start)
static

Return whether we are completing argument for fcdb command.

Definition at line 7727 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_filename()

static bool is_filename ( int  start)
static

Return whether we are completing filename.

Definition at line 7663 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_first_access_level_taken()

static bool is_first_access_level_taken ( )
static

Return whether first access level is already taken.

Definition at line 1353 of file stdinhand.cpp.

Referenced by firstlevel_command(), and notify_if_first_access_level_is_available().

◆ is_help()

static bool is_help ( int  start)
static

Return whether we are completing help command argument.

Definition at line 7745 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_list()

static bool is_list ( int  start)
static

Return whether we are completing list command argument.

Definition at line 7754 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_lua()

static bool is_lua ( int  start)
static

Return whether we are completing argument for lua command.

Definition at line 7736 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_mapimg()

static bool is_mapimg ( int  start)
static

Return whether we are completing first argument for mapimg command.

Definition at line 7718 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_option_level()

static bool is_option_level ( int  start)
static

Returns true if the readline buffer string matches an option level or an option at the given position.

Definition at line 7607 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_player()

static bool is_player ( int  start)
static

Return whether we are completing player name argument.

Definition at line 7513 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_reset()

static bool is_reset ( int  start)
static

Return whether we are completing argument for reset command.

Definition at line 7691 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_restricted()

static bool is_restricted ( struct connection caller)
static

Are we operating under a restricted security regime? For now this does not do much.

Definition at line 171 of file stdinhand.cpp.

Referenced by cmd_of_level(), load_command(), lua_command(), read_init_script_real(), save_command(), scensave_command(), set_rulesetdir(), and write_command().

◆ is_server_option()

static bool is_server_option ( int  start)
static

Returns TRUE if the readline buffer string matches a server option at the given position.

Definition at line 7583 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ is_vote()

static bool is_vote ( int  start)
static

Return whether we are completing argument for vote command.

Definition at line 7700 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ kick_command()

static bool kick_command ( struct connection caller,
char *  name,
bool  check 
)
static

Kick command handler.

Definition at line 6329 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ list_accessor()

static const char* list_accessor ( int  i)
static

Returns possible parameters for the list command.

Definition at line 7048 of file stdinhand.cpp.

Referenced by list_generator(), and show_list().

◆ list_generator()

static char* list_generator ( const char *  text,
int  state 
)
static

The valid first arguments to "list".

Definition at line 7386 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ load_command()

bool load_command ( struct connection caller,
const char *  filename,
bool  check,
bool  cmdline_load 
)

Loads a file, complete with access checks and error messages sent back to the caller on failure.

caller is the connection requesting the load, or nullptr for a command-line load. Error messages are sent back to the caller and an access check is done to make sure they are allowed to load.

filename is simply the name of the file to be loaded. This may be approximate; the function will look for appropriate suffixes and will check in the various directories to see if the file is found.

if check is set then only a test run is done and no actual loading is attempted.

The return value is true if the load succeeds, or would succeed; false if there's an error in the file or file name. Some errors in loading however could be unrecoverable (if the save game is legitimate but has inconsistencies) and would lead to a broken server afterwards.

Definition at line 3780 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ lookup_option()

static int lookup_option ( const char *  name)
static

Find option index by name.

Return index (>=0) on success, else returned

  • LOOKUP_OPTION_NO_RESULT if no suitable options were found
  • LOOKUP_OPTION_AMBIGUOUS if several matches were found
  • LOOKUP_OPTION_LEVEL_NAME if it is an option level
  • LOOKUP_OPTION_RULESETDIR if the argument is rulesetdir (special case)

Definition at line 1783 of file stdinhand.cpp.

Referenced by explain_option(), show_settings(), and validate_setting_arg().

◆ lookup_option_level()

static enum sset_level lookup_option_level ( const char *  name)
static

Find option level number by name.

Definition at line 1713 of file stdinhand.cpp.

Referenced by lookup_option(), and show_settings().

◆ lua_accessor()

static const char* lua_accessor ( int  i)
static

Returns possible parameters for the reset command.

Definition at line 5007 of file stdinhand.cpp.

Referenced by lua_command(), and lua_generator().

◆ lua_command()

static bool lua_command ( struct connection caller,
char *  arg,
bool  check,
int  read_recursion 
)
static

Evaluate a line of lua script or a lua script file.

Definition at line 5016 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ lua_generator()

static char* lua_generator ( const char *  text,
int  state 
)
static

The valid arguments for the argument to "lua".

Definition at line 7370 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ mapimg_accessor()

static const char * mapimg_accessor ( int  i)
static

Returns possible parameters for the mapimg command.

Definition at line 5701 of file stdinhand.cpp.

Referenced by mapimg_command(), and mapimg_generator().

◆ mapimg_command()

static bool mapimg_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle mapimg command.

Definition at line 5710 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ mapimg_generator()

static char* mapimg_generator ( const char *  text,
int  state 
)
static

The valid arguments for the first argument to "mapimg".

Definition at line 7353 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ may_use()

static bool may_use ( struct connection caller,
enum command_id  cmd 
)
static

Whether the caller can use the specified command.

caller == nullptr means console.

Definition at line 254 of file stdinhand.cpp.

Referenced by show_help_command_list().

◆ may_use_nothing()

static bool may_use_nothing ( struct connection caller)
static

Whether the caller cannot use any commands at all.

caller == nullptr means console.

Definition at line 266 of file stdinhand.cpp.

Referenced by handle_stdin_input_real(), and show_help().

◆ metaconnection_command()

static bool metaconnection_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle metaconnection command.

Definition at line 502 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ metamessage_command()

static bool metamessage_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle metamessage command.

Definition at line 580 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ metapatches_command()

static bool metapatches_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle metapatches command.

Definition at line 554 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ metaserver_command()

static bool metaserver_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle metaserver command.

Definition at line 612 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ notify_if_first_access_level_is_available()

void notify_if_first_access_level_is_available ( )

Check if first access level is available and if it is, notify connections about it.

Definition at line 1382 of file stdinhand.cpp.

Referenced by lost_connection_to_client().

◆ num_tokens()

static int num_tokens ( int  start)
static

Number of tokens in rl_line_buffer before start.

Definition at line 7478 of file stdinhand.cpp.

Referenced by is_cmdlevel_arg2(), and is_create_arg2().

◆ observe_command()

static bool observe_command ( struct connection caller,
char *  str,
bool  check 
)
static

Observe another player.

If we were already attached, detach (see connection_detach()). The console and those with ALLOW_HACK can use the two-argument command and force others to observe.

Definition at line 3351 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ olevel_generator()

static char* olevel_generator ( const char *  text,
int  state 
)
static

The valid arguments to "show".

Definition at line 7191 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ olvlname_accessor()

static const char* olvlname_accessor ( int  i)
static

Returns possible parameters for the /show command.

Definition at line 1591 of file stdinhand.cpp.

Referenced by olevel_generator().

◆ open_metaserver_connection()

static void open_metaserver_connection ( struct connection caller,
bool  persistent 
)
static

Start sending game info to metaserver.

Definition at line 475 of file stdinhand.cpp.

Referenced by metaconnection_command().

◆ option_generator()

static char* option_generator ( const char *  text,
int  state 
)
static

The valid arguments to "set" and "explain".

Definition at line 7183 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ option_value_accessor()

static const char* option_value_accessor ( int  idx)
static

Definition at line 7202 of file stdinhand.cpp.

Referenced by option_value_generator().

◆ option_value_generator()

static char* option_value_generator ( const char *  text,
int  state 
)
static

The valid arguments to "set OPT", where OPT is the enumerated or bitwise option previously defined by completion_option.

Definition at line 7222 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ optname_accessor()

static const char* optname_accessor ( int  i)
static

Returns possible parameters for the commands that take server options as parameters (CMD_EXPLAIN and CMD_SET).

Definition at line 1583 of file stdinhand.cpp.

Referenced by helparg_accessor(), lookup_option(), olvlname_accessor(), and option_generator().

◆ player_generator()

static char* player_generator ( const char *  text,
int  state 
)
static

The valid playername arguments.

Definition at line 7244 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ player_name_check()

static bool player_name_check ( const char *  name,
char *  buf,
size_t  buflen 
)
static

Check the player name.

Returns TRUE if the player name is valid else an error message is saved in 'buf'.

Definition at line 180 of file stdinhand.cpp.

◆ playercolor_command()

static bool playercolor_command ( struct connection caller,
char *  str,
bool  check 
)
static

/playercolor command handler.

Definition at line 4204 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ playername_accessor()

static const char* playername_accessor ( int  idx)
static

Access player name.

Definition at line 7230 of file stdinhand.cpp.

Referenced by player_generator().

◆ playernation_command()

static bool playernation_command ( struct connection caller,
char *  str,
bool  check 
)
static

/playernation command handler.

Definition at line 4294 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ quit_game()

static bool quit_game ( struct connection caller,
bool  check 
)
static

Handle quit command.

Definition at line 4427 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ read_command()

static bool read_command ( struct connection caller,
char *  arg,
bool  check,
int  read_recursion 
)
static

Main entry point for the read command.

Definition at line 1105 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ read_init_script()

bool read_init_script ( struct connection caller,
const char *  script_filename,
bool  from_cmdline,
bool  check 
)

Main entry point for reading an init script.

Definition at line 1114 of file stdinhand.cpp.

Referenced by freeciv::server::prepare_game().

◆ read_init_script_real()

static bool read_init_script_real ( struct connection caller,
const char *  script_filename,
bool  from_cmdline,
bool  check,
int  read_recursion 
)
static

Returns FALSE iff there was an error.

Security: We will look for a file with mandatory extension '.serv', and on public servers we will not look outside the data directories. As long as the user cannot create files with arbitrary names in the root of the data directories, this should ensure that we will not be tricked into loading non-approved content. The script is read with the permissions of the caller, so it will in any case not lead to elevated permissions unless there are other bugs.

Definition at line 1132 of file stdinhand.cpp.

Referenced by read_command(), read_init_script(), and reset_command().

◆ remove_player_command()

static bool remove_player_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle remove command.

Definition at line 1067 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ remove_quotes()

◆ reset_accessor()

static const char* reset_accessor ( int  i)
static

Returns possible parameters for the reset command.

Definition at line 4845 of file stdinhand.cpp.

Referenced by reset_command(), and reset_generator().

◆ reset_command()

static bool reset_command ( struct connection caller,
char *  arg,
bool  check,
int  read_recursion 
)
static

Reload the game settings from the ruleset and reload the init script if one was used.

Definition at line 4855 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ reset_generator()

static char* reset_generator ( const char *  text,
int  state 
)
static

The valid arguments for the argument to "reset".

Definition at line 7327 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ save_command()

static bool save_command ( struct connection caller,
char *  arg,
bool  check 
)
static

For command "save foo"; Save the game, with filename=arg, provided server state is ok.

Definition at line 642 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ scensave_command()

static bool scensave_command ( struct connection caller,
char *  arg,
bool  check 
)
static

For command "scensave foo"; Save the game, with filename=arg, provided server state is ok.

Definition at line 659 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ set_ai_level()

static bool set_ai_level ( struct connection caller,
const char *  name,
enum ai_level  level,
bool  check 
)
static

Set AI level.

Definition at line 2079 of file stdinhand.cpp.

Referenced by set_ai_level_named().

◆ set_ai_level_direct()

void set_ai_level_direct ( struct player pplayer,
enum ai_level  level 
)

Set an AI level from the server prompt.

Definition at line 2056 of file stdinhand.cpp.

Referenced by split_player(), and srv_ready().

◆ set_ai_level_named()

static bool set_ai_level_named ( struct connection caller,
const char *  name,
const char *  level_name,
bool  check 
)
static

Handle a user command to set an AI level.

Definition at line 2068 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ set_cmdlevel()

static bool set_cmdlevel ( struct connection caller,
struct connection ptarget,
enum cmdlevel  level 
)
static

Set ptarget's cmdlevel to level if caller is allowed to do so.

Definition at line 1312 of file stdinhand.cpp.

Referenced by cmdlevel_command().

◆ set_command()

static bool set_command ( struct connection caller,
char *  str,
bool  check 
)
static

Handle set command.

Definition at line 3022 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ set_rulesetdir()

static bool set_rulesetdir ( struct connection caller,
char *  str,
bool  check,
int  read_recursion 
)
static

Load rulesets from a given ruleset directory.

Security: There are some rudimentary checks in load_rulesets() to see if this directory really is a viable ruleset directory. For public servers, we check against directory redirection (is_safe_filename) and other bad stuff in the directory name, and will only use directories inside the data directories.

Definition at line 3993 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ set_running_game_access_level()

void set_running_game_access_level ( )

Adjust default command level on game start.

Definition at line 1570 of file stdinhand.cpp.

Referenced by start_game().

◆ setting_status()

static char setting_status ( struct connection caller,
const struct setting pset 
)
static

Return the status of the setting (changeable, locked, fixed).

caller == nullptr means console.

Definition at line 278 of file stdinhand.cpp.

Referenced by show_settings_one().

◆ should_quit()

bool should_quit ( )

Returns whether the server should exit after a command.

Definition at line 4440 of file stdinhand.cpp.

◆ show_colors()

static void show_colors ( struct connection caller)
static

Show a list of all players with the assigned color.

Definition at line 6999 of file stdinhand.cpp.

Referenced by show_list().

◆ show_command()

static bool show_command ( struct connection caller,
char *  str,
bool  check 
)
static

/show command: show settings and their values.

Definition at line 2203 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ show_connections()

static void show_connections ( struct connection caller)
static

List connections; initially mainly for debugging.

Definition at line 6657 of file stdinhand.cpp.

Referenced by show_list().

◆ show_delegations()

static void show_delegations ( struct connection caller)
static

List all delegations of the current game.

Definition at line 6690 of file stdinhand.cpp.

Referenced by show_list().

◆ show_help()

static bool show_help ( struct connection caller,
char *  arg 
)
static

Handle help command.

Definition at line 6595 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ show_help_command()

static void show_help_command ( struct connection caller,
enum command_id  help_cmd,
enum command_id  id 
)
static

Show the caller detailed help for the single COMMAND given by id.

help_cmd is the command the player used.

Definition at line 6439 of file stdinhand.cpp.

Referenced by show_help().

◆ show_help_command_list()

static void show_help_command_list ( struct connection caller,
enum command_id  help_cmd 
)
static

Show the caller list of COMMANDS.

help_cmd is the command the player used.

Definition at line 6483 of file stdinhand.cpp.

Referenced by show_help().

◆ show_help_intro()

static void show_help_intro ( struct connection caller,
enum command_id  help_cmd 
)
static

Show caller introductory help about the server.

help_cmd is the command the player used.

Definition at line 6406 of file stdinhand.cpp.

Referenced by show_help().

◆ show_help_option()

static void show_help_option ( struct connection caller,
enum command_id  help_cmd,
int  id 
)
static

Show the caller detailed help for the single OPTION given by id.

help_cmd is the command the player used. Only show option values for options which the caller can SEE.

Definition at line 1812 of file stdinhand.cpp.

Referenced by explain_option(), and show_help().

◆ show_help_option_list()

static void show_help_option_list ( struct connection caller,
enum command_id  help_cmd 
)
static

Show the caller list of OPTIONS.

help_cmd is the command the player used. Only show options which the caller can SEE.

Definition at line 1898 of file stdinhand.cpp.

Referenced by explain_option(), and show_help().

◆ show_ignore()

static bool show_ignore ( struct connection caller)
static

Show the ignore list of the.

Definition at line 6726 of file stdinhand.cpp.

Referenced by show_list().

◆ show_list()

static bool show_list ( struct connection caller,
char *  arg 
)
static

Show list of players or connections, or connection statistics.

Definition at line 7057 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ show_mapimg()

static void show_mapimg ( struct connection caller,
enum command_id  cmd 
)
static

Show a list of all map image definitions on the command line.

Definition at line 6978 of file stdinhand.cpp.

Referenced by mapimg_command(), and show_list().

◆ show_nationsets()

static void show_nationsets ( struct connection caller)
static

List nation sets in the current ruleset.

Definition at line 6906 of file stdinhand.cpp.

Referenced by show_list().

◆ show_players()

void show_players ( struct connection caller)

Show the list of the players of the game.

Definition at line 6758 of file stdinhand.cpp.

Referenced by show_list().

◆ show_ruleset_info()

static void show_ruleset_info ( struct connection caller,
enum command_id  cmd,
bool  check,
int  read_recursion 
)
static

Show changed settings and ruleset summary.

Definition at line 2176 of file stdinhand.cpp.

Referenced by read_init_script_real(), reset_command(), and set_rulesetdir().

◆ show_rulesets()

static void show_rulesets ( struct connection caller)
static

List rulesets (strictly, .serv init script files that conventionally accompany rulesets).

Definition at line 6860 of file stdinhand.cpp.

Referenced by show_list().

◆ show_scenarios()

static void show_scenarios ( struct connection caller)
static

List scenarios.

We look both in the DATA_PATH and DATA_PATH/scenario

Definition at line 6882 of file stdinhand.cpp.

Referenced by show_list().

◆ show_serverid()

static bool show_serverid ( struct connection caller,
char *  arg 
)
static

Returns the serverid.

Definition at line 630 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ show_settings()

static bool show_settings ( struct connection caller,
enum command_id  called_as,
char *  str,
bool  check 
)
static

Print a summary of the settings and their values.

Note that most values are at most 4 digits, except seeds, which we let overflow their columns, plus a sign character. Only show options which the caller can SEE.

Definition at line 2213 of file stdinhand.cpp.

Referenced by show_command(), and show_ruleset_info().

◆ show_settings_one()

static void show_settings_one ( struct connection caller,
enum command_id  cmd,
struct setting pset 
)
static

Show one setting.

Each option value will be displayed as:

[OPTION_NAME_SPACE length for name] ## [value] ([min], [max])

where '##' is a combination of ' ', '!' or '+' followed by ' ', '*', or '=' with

  • '!': the option is locked by the ruleset
  • '+': you may change the option
  • '~': the option follows default value
  • '=': the value is same as default

Definition at line 2388 of file stdinhand.cpp.

Referenced by show_settings().

◆ show_teams()

static void show_teams ( struct connection caller)
static

Show a list of teams on the command line.

Definition at line 6945 of file stdinhand.cpp.

Referenced by show_list().

◆ show_votes()

static void show_votes ( struct connection caller)
static

List all running votes.

Moved from /vote command.

Definition at line 2522 of file stdinhand.cpp.

Referenced by show_list(), and vote_command().

◆ start_cmd_reply()

static void start_cmd_reply ( struct connection caller,
bool  notify,
const char *  msg 
)
static

Send start command related message.

Definition at line 6109 of file stdinhand.cpp.

Referenced by start_command().

◆ start_command()

bool start_command ( struct connection caller,
bool  check,
bool  notify 
)

Handle start command.

Notify all players about errors if notify set.

Definition at line 6121 of file stdinhand.cpp.

Referenced by handle_observer_ready(), handle_player_ready(), and handle_stdin_input_real().

◆ stdinhand_free()

void stdinhand_free ( )

Deinitialize stuff related to this code module.

Definition at line 244 of file stdinhand.cpp.

Referenced by server_quit().

◆ stdinhand_init()

void stdinhand_init ( )

Initialize stuff related to this code module.

Definition at line 231 of file stdinhand.cpp.

◆ stdinhand_turn()

void stdinhand_turn ( )

Update stuff every turn that is related to this code module.

Run this on turn end.

Definition at line 237 of file stdinhand.cpp.

Referenced by end_turn().

◆ surrender_command()

static bool surrender_command ( struct connection caller,
char *  str,
bool  check 
)
static

Concede the game.

You still continue playing until all but one player or team remains un-conceded.

Definition at line 4796 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ take_command()

static bool take_command ( struct connection caller,
char *  str,
bool  check 
)
static

Take over a player.

If a connection already has control of that player, disallow it.

If there are two arguments, treat the first as the connection name and the second as the player name (only hack and the console can do this). Otherwise, there should be one argument, that being the player that the caller wants to take.

Definition at line 3491 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ team_command()

static bool team_command ( struct connection caller,
char *  str,
bool  check 
)
static

Handle team command.

Definition at line 2449 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ timeout_command()

static bool timeout_command ( struct connection caller,
char *  str,
bool  check 
)
static

Set timeout options.

Definition at line 1713 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ timeout_set_command()

static bool timeout_set_command ( struct connection caller,
char *  str,
bool  check,
command_id  self,
bool  add 
)
static

Sets the timeout for the current turn.

If "add", add more time; else, replace the timeout.

Definition at line 1649 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ timeout_show_command()

static bool timeout_show_command ( struct connection caller,
char *  str,
bool  check 
)
static

Show the current timeout, time left before TC, etc.

Definition at line 1605 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ toggle_ai_command()

static bool toggle_ai_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Handle aitoggle command.

Definition at line 700 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ toggle_ai_player_direct()

void toggle_ai_player_direct ( struct connection caller,
struct player pplayer 
)

Handle ai player ai toggling.

Definition at line 676 of file stdinhand.cpp.

Referenced by autotoggle_action(), connection_attach_real(), connection_detach(), srv_ready(), and toggle_ai_command().

◆ unignore_command()

static bool unignore_command ( struct connection caller,
char *  str,
bool  check 
)
static

/unignore command handler.

Definition at line 4113 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ validate_setting_arg()

static struct setting* validate_setting_arg ( enum command_id  cmd,
struct connection caller,
char *  arg 
)
static

Helper to validate an argument referring to a server setting.

Sends error message and returns nullptr on failure.

Definition at line 2986 of file stdinhand.cpp.

Referenced by default_command(), and set_command().

◆ vcmd_reply_prefix()

static void vcmd_reply_prefix ( enum command_id  cmd,
struct connection caller,
enum rfc_status  rfc_status,
const char *  prefix,
const char *  format,
va_list  ap 
)
static

va_list version which allow embedded newlines, and each line is sent separately.

'prefix' is prepended to every line after the first line.

Definition at line 353 of file stdinhand.cpp.

Referenced by cmd_reply(), and cmd_reply_prefix().

◆ vote_arg_accessor()

static const char* vote_arg_accessor ( int  i)
static

Definition at line 2560 of file stdinhand.cpp.

Referenced by vote_command(), and vote_generator().

◆ vote_command()

static bool vote_command ( struct connection caller,
char *  str,
bool  check 
)
static

Make or participate in a vote.

Definition at line 2565 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ vote_generator()

static char* vote_generator ( const char *  text,
int  state 
)
static

The valid arguments for the argument to "vote".

Definition at line 7336 of file stdinhand.cpp.

Referenced by freeciv_completion().

◆ wall()

static bool wall ( char *  str,
bool  check 
)
static

Send a message to all players.

Definition at line 1972 of file stdinhand.cpp.

Referenced by handle_stdin_input_real(), and freeciv::layer_city::reset_ruleset().

◆ write_command()

static bool write_command ( struct connection caller,
char *  arg,
bool  check 
)
static

Generate init script from settings currently in use.

Definition at line 1296 of file stdinhand.cpp.

Referenced by handle_stdin_input_real().

◆ write_init_script()

static void write_init_script ( char *  script_filename)
static

Write current settings to new init script.

(Should this take a 'caller' argument for output? –dwp)

Definition at line 1228 of file stdinhand.cpp.

Referenced by write_command().

Variable Documentation

◆ completion_option

int completion_option
static

Accessor for values of the enum/bitwise option defined by 'completion_option'.

Definition at line 7201 of file stdinhand.cpp.

Referenced by freeciv_completion(), and option_value_accessor().

◆ connection_cmd

const int connection_cmd[] = {CMD_CUT, CMD_KICK, -1}
static

Commands that may be followed by a connection name.

Definition at line 7531 of file stdinhand.cpp.

Referenced by is_connection().

◆ default_access_level

enum cmdlevel default_access_level = ALLOW_BASIC
static

◆ filename_cmd

const int filename_cmd[]
static
Initial value:
@ CMD_LOAD
Definition: commands.h:90
@ CMD_SAVE
Definition: commands.h:88
@ CMD_WRITE_SCRIPT
Definition: commands.h:92
@ CMD_READ_SCRIPT
Definition: commands.h:91

Commands that may be followed by a filename.

Definition at line 7657 of file stdinhand.cpp.

Referenced by is_filename().

◆ first_access_level

enum cmdlevel first_access_level = ALLOW_BASIC
static

◆ horiz_line

const char horiz_line[]
static
Initial value:
= "------------------------------------------"
"------------------------------------"

Definition at line 153 of file stdinhand.cpp.

Referenced by cmdlevel_command(), show_colors(), show_connections(), show_delegations(), show_help_command_list(), show_help_option_list(), show_ignore(), show_mapimg(), show_nationsets(), show_players(), show_ruleset_info(), show_rulesets(), show_scenarios(), show_settings(), and show_teams().

◆ option_level_cmd

const int option_level_cmd[] = {CMD_SHOW, -1}
static

Commands that may be followed by an option level or server option.

Definition at line 7601 of file stdinhand.cpp.

Referenced by is_option_level().

◆ player_cmd

const int player_cmd[]
static
Initial value:
= {
@ CMD_TEAM
Definition: commands.h:51
@ CMD_CHEATING
Definition: commands.h:68
@ CMD_PLAYERCOLOR
Definition: commands.h:81
@ CMD_AITOGGLE
Definition: commands.h:57
@ CMD_HARD
Definition: commands.h:67
@ CMD_NORMAL
Definition: commands.h:66
@ CMD_HANDICAPPED
Definition: commands.h:63
@ CMD_NOVICE
Definition: commands.h:64
@ CMD_EASY
Definition: commands.h:65
@ CMD_REMOVE
Definition: commands.h:87

Commands that may be followed by a player name.

Definition at line 7502 of file stdinhand.cpp.

Referenced by is_player().

◆ server_option_cmd

const int server_option_cmd[]
static
Initial value:
-1}
@ CMD_DEFAULT
Definition: commands.h:94
@ CMD_EXPLAIN
Definition: commands.h:42
@ CMD_SET
Definition: commands.h:50

Commands that may be followed by a server option name.

CMD_SHOW is handled by option_level_cmd, which is for both option levels and server options

Definition at line 7576 of file stdinhand.cpp.

Referenced by is_server_option().

◆ vote_args

const char* const vote_args[] = {"yes", "no", "abstain", nullptr}
static

Vote command argument definitions.

Definition at line 2559 of file stdinhand.cpp.

Referenced by vote_arg_accessor().