Freeciv-3.3
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
stdinhand.c File Reference
#include "fc_prehdrs.h"
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "astring.h"
#include "bitvector.h"
#include "deprecations.h"
#include "fc_cmdline.h"
#include "fciconv.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "rand.h"
#include "registry.h"
#include "support.h"
#include "timing.h"
#include "section_file.h"
#include "capability.h"
#include "events.h"
#include "fc_types.h"
#include "featured_text.h"
#include "game.h"
#include "map.h"
#include "mapimg.h"
#include "modpack.h"
#include "packets.h"
#include "player.h"
#include "research.h"
#include "rgbcolor.h"
#include "srvdefs.h"
#include "unitlist.h"
#include "version.h"
#include "aiiface.h"
#include "citytools.h"
#include "connecthand.h"
#include "diplhand.h"
#include "gamehand.h"
#include "mapgen.h"
#include "maphand.h"
#include "meta.h"
#include "notify.h"
#include "plrhand.h"
#include "report.h"
#include "ruleload.h"
#include "sanitycheck.h"
#include "score.h"
#include "sernet.h"
#include "settings.h"
#include "srv_log.h"
#include "srv_main.h"
#include "techtools.h"
#include "voting.h"
#include "savemain.h"
#include "script_server.h"
#include "script_fcdb.h"
#include "difficulty.h"
#include "handicaps.h"
#include "stdinhand.h"
#include "spechash.h"
#include "specenum_gen.h"

Go to the source code of this file.

Data Structures

struct  mrc_listcmd_data
 

Macros

#define OPTION_NAME_SPACE   25
 
#define SPECHASH_TAG   kick
 
#define SPECHASH_ASTR_KEY_TYPE
 
#define SPECHASH_IDATA_TYPE   time_t *
 
#define SPECHASH_UDATA_TYPE   time_t
 
#define SPECHASH_IDATA_COPY   time_duplicate
 
#define SPECHASH_IDATA_FREE   (kick_hash_data_free_fn_t) free
 
#define SPECHASH_UDATA_TO_IDATA(t)   (&(t))
 
#define SPECHASH_IDATA_TO_UDATA(p)   (NULL != p ? *p : 0)
 
#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
 
#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
 
#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
 
#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
 
#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
 
#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
 
#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
 
#define SPECENUM_VALUE0   LIST_AIS
 
#define SPECENUM_VALUE0NAME   "ais"
 
#define SPECENUM_VALUE1   LIST_COLORS
 
#define SPECENUM_VALUE1NAME   "colors"
 
#define SPECENUM_VALUE2   LIST_CONNECTIONS
 
#define SPECENUM_VALUE2NAME   "connections"
 
#define SPECENUM_VALUE3   LIST_DELEGATIONS
 
#define SPECENUM_VALUE3NAME   "delegations"
 
#define SPECENUM_VALUE4   LIST_IGNORE
 
#define SPECENUM_VALUE4NAME   "ignored users"
 
#define SPECENUM_VALUE5   LIST_MAPIMG
 
#define SPECENUM_VALUE5NAME   "map image definitions"
 
#define SPECENUM_VALUE6   LIST_PLAYERS
 
#define SPECENUM_VALUE6NAME   "players"
 
#define SPECENUM_VALUE7   LIST_RULESETS
 
#define SPECENUM_VALUE7NAME   "rulesets"
 
#define SPECENUM_VALUE8   LIST_SCENARIOS
 
#define SPECENUM_VALUE8NAME   "scenarios"
 
#define SPECENUM_VALUE9   LIST_NATIONSETS
 
#define SPECENUM_VALUE9NAME   "nationsets"
 
#define SPECENUM_VALUE10   LIST_TEAMS
 
#define SPECENUM_VALUE10NAME   "teams"
 
#define SPECENUM_VALUE11   LIST_VOTES
 
#define SPECENUM_VALUE11NAME   "votes"
 

Functions

static time_ttime_duplicate (const time_t *t)
 
static bool cut_client_connection (struct connection *caller, char *name, bool check)
 
static bool show_help (struct connection *caller, char *arg)
 
static bool show_list (struct connection *caller, char *arg)
 
static void show_ais (struct connection *caller)
 
static void show_colors (struct connection *caller)
 
static bool set_ai_level_named (struct connection *caller, const char *name, const char *level_name, bool check)
 
static bool set_ai_level (struct connection *caller, const char *name, enum ai_level level, bool check)
 
static bool away_command (struct connection *caller, bool check)
 
static bool show_command (struct connection *caller, char *str, bool check)
 
static bool show_settings (struct connection *caller, enum command_id called_as, char *str, bool check)
 
static void show_settings_one (struct connection *caller, enum command_id cmd, struct setting *pset)
 
static void show_ruleset_info (struct connection *caller, enum command_id cmd, bool check, int read_recursion)
 
static void show_mapimg (struct connection *caller, enum command_id cmd)
 
static bool set_command (struct connection *caller, char *str, bool check)
 
static bool lock_command (struct connection *caller, char *str, bool check)
 
static bool unlock_command (struct connection *caller, char *str, bool check)
 
static bool create_command (struct connection *caller, const char *str, bool check)
 
static bool end_command (struct connection *caller, char *str, bool check)
 
static bool surrender_command (struct connection *caller, char *str, bool check)
 
static bool handle_stdin_input_real (struct connection *caller, char *str, bool check, int read_recursion)
 
static bool read_init_script_real (struct connection *caller, const char *script_filename, bool from_cmdline, bool check, int read_recursion)
 
static bool reset_command (struct connection *caller, char *arg, bool check, int read_recursion)
 
static bool default_command (struct connection *caller, char *arg, bool check)
 
static bool lua_command (struct connection *caller, char *arg, bool check, int read_recursion)
 
static bool kick_command (struct connection *caller, char *name, bool check)
 
static bool delegate_command (struct connection *caller, char *arg, bool check)
 
static const chardelegate_player_str (struct player *pplayer, bool observer)
 
static bool aicmd_command (struct connection *caller, char *arg, bool check)
 
static bool fcdb_command (struct connection *caller, char *arg, bool check)
 
static const charfcdb_accessor (int i)
 
static char setting_status (struct connection *caller, const struct setting *pset)
 
static bool player_name_check (const char *name, char *buf, size_t buflen)
 
static bool playercolor_command (struct connection *caller, char *str, bool check)
 
static bool playernation_command (struct connection *caller, char *str, bool check)
 
static bool mapimg_command (struct connection *caller, char *arg, bool check)
 
static const charmapimg_accessor (int i)
 
static void show_delegations (struct connection *caller)
 
static bool is_restricted (struct connection *caller)
 
static enum command_id command_named (const char *token, bool accept_ambiguity)
 
void stdinhand_init (void)
 
void stdinhand_turn (void)
 
void stdinhand_free (void)
 
static bool may_use (struct connection *caller, enum command_id cmd)
 
static bool may_use_nothing (struct connection *caller)
 
static void cmd_reply_line (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *prefix, const char *line)
 
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 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__
 
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,...)
 
static void cmd_reply_no_such_player (enum command_id cmd, struct connection *caller, const char *name, enum m_pre_result match_result)
 
static void cmd_reply_no_such_conn (enum command_id cmd, struct connection *caller, const char *name, enum m_pre_result match_result)
 
static void open_metaserver_connection (struct connection *caller, bool persistent)
 
static void close_metaserver_connection (struct connection *caller)
 
static bool metaconnection_command (struct connection *caller, char *arg, bool check)
 
static bool metapatches_command (struct connection *caller, char *arg, bool check)
 
static bool metamessage_command (struct connection *caller, char *arg, bool check)
 
static bool metaserver_command (struct connection *caller, char *arg, bool check)
 
static bool show_serverid (struct connection *caller, char *arg)
 
static bool save_command (struct connection *caller, char *arg, bool check)
 
static bool scensave_command (struct connection *caller, char *arg, bool check)
 
void toggle_ai_player_direct (struct connection *caller, struct player *pplayer)
 
static bool toggle_ai_command (struct connection *caller, char *arg, bool check)
 
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)
 
enum rfc_status create_command_pregame (const char *name, const char *ai, bool check, struct player **newplayer, char *buf, size_t buflen)
 
static bool remove_player_command (struct connection *caller, char *arg, bool check)
 
static bool read_command (struct connection *caller, char *arg, bool check, int read_recursion)
 
bool read_init_script (struct connection *caller, const char *script_filename, bool from_cmdline, bool check)
 
struct strvecget_init_script_choices (void)
 
static bool write_init_script (char *script_filename)
 
static bool write_command (struct connection *caller, char *arg, bool check)
 
static bool set_cmdlevel (struct connection *caller, struct connection *ptarget, enum cmdlevel level)
 
static bool a_connection_exists (void)
 
static bool is_first_access_level_taken (void)
 
enum cmdlevel access_level_for_next_connection (void)
 
void notify_if_first_access_level_is_available (void)
 
static bool cmdlevel_command (struct connection *caller, char *str, bool check)
 
static bool firstlevel_command (struct connection *caller, bool check)
 
void set_running_game_access_level (void)
 
static const charoptname_accessor (int i)
 
static bool timeout_command (struct connection *caller, char *str, bool check)
 
static enum sset_level lookup_option_level (const char *name)
 
static int lookup_option (const char *name)
 
static void show_help_option (struct connection *caller, enum command_id help_cmd, int id)
 
static void show_help_option_list (struct connection *caller, enum command_id help_cmd)
 
static bool explain_option (struct connection *caller, char *str, bool check)
 
static bool wall (char *str, bool check)
 
static bool connectmsg_command (struct connection *caller, char *str, bool check)
 
static enum command_id cmd_of_level (enum ai_level level)
 
void set_ai_level_direct (struct player *pplayer, enum ai_level level)
 
static bool team_command (struct connection *caller, char *str, bool check)
 
static void show_votes (struct connection *caller)
 
static const charvote_arg_accessor (int i)
 
static bool vote_command (struct connection *caller, char *str, bool check)
 
static bool cancelvote_command (struct connection *caller, char *arg, bool check)
 
static bool debug_command (struct connection *caller, char *str, bool check)
 
static struct settingvalidate_setting_arg (enum command_id cmd, struct connection *caller, char *arg)
 
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 bool observe_command (struct connection *caller, char *str, bool check)
 
static bool take_command (struct connection *caller, char *str, bool check)
 
static bool detach_command (struct connection *caller, char *str, bool check)
 
bool load_command (struct connection *caller, const char *filename, bool check, bool cmdline_load)
 
bool set_rulesetdir (struct connection *caller, const char *str, bool check, int read_recursion)
 
static bool ignore_command (struct connection *caller, char *str, bool check)
 
static bool unignore_command (struct connection *caller, char *str, bool check)
 
static bool quit_game (struct connection *caller, bool check)
 
bool handle_stdin_input (struct connection *caller, char *str)
 
bool handle_stdin_input_free (struct connection *caller, char *str)
 
static const charreset_accessor (int i)
 
static const charlua_accessor (int i)
 
static const chardelegate_accessor (int i)
 
static void start_cmd_reply (struct connection *caller, bool notify, char *msg)
 
bool start_command (struct connection *caller, bool check, bool notify)
 
bool conn_is_kicked (struct connection *pconn, int *time_remaining)
 
static void show_help_intro (struct connection *caller, enum command_id help_cmd)
 
static void show_help_command (struct connection *caller, enum command_id help_cmd, enum command_id id)
 
static void show_help_command_list (struct connection *caller, enum command_id help_cmd)
 
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 const charhelparg_accessor (int i)
 
static void show_connections (struct connection *caller)
 
static bool show_ignore (struct connection *caller)
 
void show_players (struct connection *caller)
 
static void ruleset_cache_listcmd_cb (const char *mp_name, const char *filename, void *data_in)
 
static void show_rulesets (struct connection *caller)
 
static void show_scenarios (struct connection *caller)
 
static void show_nationsets (struct connection *caller)
 
static void show_teams (struct connection *caller)
 
static const charlist_accessor (int i)
 

Variables

static enum cmdlevel default_access_level = ALLOW_BASIC
 
static enum cmdlevel first_access_level = ALLOW_BASIC
 
const charscript_extension = ".serv"
 
static struct kick_hashkick_table_by_addr = NULL
 
static struct kick_hashkick_table_by_user = NULL
 
static const char horiz_line []
 
static const char *const vote_args []
 

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 6581 of file stdinhand.c.

◆ LOOKUP_OPTION_AMBIGUOUS

#define LOOKUP_OPTION_AMBIGUOUS   (-2)

Definition at line 1731 of file stdinhand.c.

◆ LOOKUP_OPTION_LEVEL_NAME

#define LOOKUP_OPTION_LEVEL_NAME   (-3)

Definition at line 1732 of file stdinhand.c.

◆ LOOKUP_OPTION_NO_RESULT

#define LOOKUP_OPTION_NO_RESULT   (-1)

Definition at line 1730 of file stdinhand.c.

◆ LOOKUP_OPTION_RULESETDIR

#define LOOKUP_OPTION_RULESETDIR   (-4)

Definition at line 1733 of file stdinhand.c.

◆ OPTION_NAME_SPACE

#define OPTION_NAME_SPACE   25

Definition at line 96 of file stdinhand.c.

◆ SPECENUM_COUNT [1/3]

#define SPECENUM_COUNT   MAPIMG_COUNT

Definition at line 5678 of file stdinhand.c.

◆ SPECENUM_COUNT [2/3]

#define SPECENUM_COUNT   FCDB_COUNT

Definition at line 5678 of file stdinhand.c.

◆ SPECENUM_COUNT [3/3]

#define SPECENUM_COUNT   HELP_GENERAL_COUNT

Definition at line 5678 of file stdinhand.c.

◆ SPECENUM_NAME [1/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_NAME [2/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_NAME [3/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_NAME [4/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_NAME [5/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_NAME [6/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_NAME [7/7]

Definition at line 4821 of file stdinhand.c.

◆ SPECENUM_VALUE0 [1/7]

#define SPECENUM_VALUE0   RESET_GAME

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0 [2/7]

#define SPECENUM_VALUE0   LUA_CMD

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0 [3/7]

#define SPECENUM_VALUE0   DELEGATE_CANCEL

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0 [4/7]

#define SPECENUM_VALUE0   MAPIMG_COLORTEST

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0 [5/7]

#define SPECENUM_VALUE0   FCDB_RELOAD

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0 [6/7]

#define SPECENUM_VALUE0   HELP_GENERAL_COMMANDS

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0 [7/7]

#define SPECENUM_VALUE0   LIST_AIS

Definition at line 4822 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [1/7]

#define SPECENUM_VALUE0NAME   "game"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [2/7]

#define SPECENUM_VALUE0NAME   "cmd"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [3/7]

#define SPECENUM_VALUE0NAME   "cancel"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [4/7]

#define SPECENUM_VALUE0NAME   "colortest"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [5/7]

#define SPECENUM_VALUE0NAME   "reload"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [6/7]

#define SPECENUM_VALUE0NAME   "commands"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE0NAME [7/7]

#define SPECENUM_VALUE0NAME   "ais"

Definition at line 4823 of file stdinhand.c.

◆ SPECENUM_VALUE1 [1/7]

#define SPECENUM_VALUE1   RESET_RULESET

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE1 [2/7]

#define SPECENUM_VALUE1   LUA_FILE

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE1 [3/7]

#define SPECENUM_VALUE1   DELEGATE_RESTORE

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE1 [4/7]

#define SPECENUM_VALUE1   MAPIMG_CREATE

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE1 [5/7]

#define SPECENUM_VALUE1   FCDB_LUA

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE1 [6/7]

#define SPECENUM_VALUE1   HELP_GENERAL_OPTIONS

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE1 [7/7]

#define SPECENUM_VALUE1   LIST_COLORS

Definition at line 4824 of file stdinhand.c.

◆ SPECENUM_VALUE10

#define SPECENUM_VALUE10   LIST_TEAMS

Definition at line 7087 of file stdinhand.c.

◆ SPECENUM_VALUE10NAME

#define SPECENUM_VALUE10NAME   "teams"

Definition at line 7088 of file stdinhand.c.

◆ SPECENUM_VALUE11

#define SPECENUM_VALUE11   LIST_VOTES

Definition at line 7089 of file stdinhand.c.

◆ SPECENUM_VALUE11NAME

#define SPECENUM_VALUE11NAME   "votes"

Definition at line 7090 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [1/7]

#define SPECENUM_VALUE1NAME   "ruleset"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [2/7]

#define SPECENUM_VALUE1NAME   "file"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [3/7]

#define SPECENUM_VALUE1NAME   "restore"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [4/7]

#define SPECENUM_VALUE1NAME   "create"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [5/7]

#define SPECENUM_VALUE1NAME   "lua"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [6/7]

#define SPECENUM_VALUE1NAME   "options"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE1NAME [7/7]

#define SPECENUM_VALUE1NAME   "colors"

Definition at line 4825 of file stdinhand.c.

◆ SPECENUM_VALUE2 [1/5]

#define SPECENUM_VALUE2   RESET_SCRIPT

Definition at line 4826 of file stdinhand.c.

◆ SPECENUM_VALUE2 [2/5]

#define SPECENUM_VALUE2   LUA_UNSAFE_CMD

Definition at line 4826 of file stdinhand.c.

◆ SPECENUM_VALUE2 [3/5]

#define SPECENUM_VALUE2   DELEGATE_SHOW

Definition at line 4826 of file stdinhand.c.

◆ SPECENUM_VALUE2 [4/5]

#define SPECENUM_VALUE2   MAPIMG_DEFINE

Definition at line 4826 of file stdinhand.c.

◆ SPECENUM_VALUE2 [5/5]

#define SPECENUM_VALUE2   LIST_CONNECTIONS

Definition at line 4826 of file stdinhand.c.

◆ SPECENUM_VALUE2NAME [1/5]

#define SPECENUM_VALUE2NAME   "script"

Definition at line 4827 of file stdinhand.c.

◆ SPECENUM_VALUE2NAME [2/5]

#define SPECENUM_VALUE2NAME   "unsafe-cmd"

Definition at line 4827 of file stdinhand.c.

◆ SPECENUM_VALUE2NAME [3/5]

#define SPECENUM_VALUE2NAME   "show"

Definition at line 4827 of file stdinhand.c.

◆ SPECENUM_VALUE2NAME [4/5]

#define SPECENUM_VALUE2NAME   "define"

Definition at line 4827 of file stdinhand.c.

◆ SPECENUM_VALUE2NAME [5/5]

#define SPECENUM_VALUE2NAME   "connections"

Definition at line 4827 of file stdinhand.c.

◆ SPECENUM_VALUE3 [1/5]

#define SPECENUM_VALUE3   RESET_DEFAULT

Definition at line 4828 of file stdinhand.c.

◆ SPECENUM_VALUE3 [2/5]

#define SPECENUM_VALUE3   LUA_UNSAFE_FILE

Definition at line 4828 of file stdinhand.c.

◆ SPECENUM_VALUE3 [3/5]

#define SPECENUM_VALUE3   DELEGATE_TAKE

Definition at line 4828 of file stdinhand.c.

◆ SPECENUM_VALUE3 [4/5]

#define SPECENUM_VALUE3   MAPIMG_DELETE

Definition at line 4828 of file stdinhand.c.

◆ SPECENUM_VALUE3 [5/5]

#define SPECENUM_VALUE3   LIST_DELEGATIONS

Definition at line 4828 of file stdinhand.c.

◆ SPECENUM_VALUE3NAME [1/5]

#define SPECENUM_VALUE3NAME   "default"

Definition at line 4829 of file stdinhand.c.

◆ SPECENUM_VALUE3NAME [2/5]

#define SPECENUM_VALUE3NAME   "unsafe-file"

Definition at line 4829 of file stdinhand.c.

◆ SPECENUM_VALUE3NAME [3/5]

#define SPECENUM_VALUE3NAME   "take"

Definition at line 4829 of file stdinhand.c.

◆ SPECENUM_VALUE3NAME [4/5]

#define SPECENUM_VALUE3NAME   "delete"

Definition at line 4829 of file stdinhand.c.

◆ SPECENUM_VALUE3NAME [5/5]

#define SPECENUM_VALUE3NAME   "delegations"

Definition at line 4829 of file stdinhand.c.

◆ SPECENUM_VALUE4 [1/3]

#define SPECENUM_VALUE4   DELEGATE_TO

Definition at line 5178 of file stdinhand.c.

◆ SPECENUM_VALUE4 [2/3]

#define SPECENUM_VALUE4   MAPIMG_SHOW

Definition at line 5178 of file stdinhand.c.

◆ SPECENUM_VALUE4 [3/3]

#define SPECENUM_VALUE4   LIST_IGNORE

Definition at line 5178 of file stdinhand.c.

◆ SPECENUM_VALUE4NAME [1/3]

#define SPECENUM_VALUE4NAME   "to"

Definition at line 5179 of file stdinhand.c.

◆ SPECENUM_VALUE4NAME [2/3]

#define SPECENUM_VALUE4NAME   "show"

Definition at line 5179 of file stdinhand.c.

◆ SPECENUM_VALUE4NAME [3/3]

#define SPECENUM_VALUE4NAME   "ignored users"

Definition at line 5179 of file stdinhand.c.

◆ SPECENUM_VALUE5

#define SPECENUM_VALUE5   LIST_MAPIMG

Definition at line 7077 of file stdinhand.c.

◆ SPECENUM_VALUE5NAME

#define SPECENUM_VALUE5NAME   "map image definitions"

Definition at line 7078 of file stdinhand.c.

◆ SPECENUM_VALUE6

#define SPECENUM_VALUE6   LIST_PLAYERS

Definition at line 7079 of file stdinhand.c.

◆ SPECENUM_VALUE6NAME

#define SPECENUM_VALUE6NAME   "players"

Definition at line 7080 of file stdinhand.c.

◆ SPECENUM_VALUE7

#define SPECENUM_VALUE7   LIST_RULESETS

Definition at line 7081 of file stdinhand.c.

◆ SPECENUM_VALUE7NAME

#define SPECENUM_VALUE7NAME   "rulesets"

Definition at line 7082 of file stdinhand.c.

◆ SPECENUM_VALUE8

#define SPECENUM_VALUE8   LIST_SCENARIOS

Definition at line 7083 of file stdinhand.c.

◆ SPECENUM_VALUE8NAME

#define SPECENUM_VALUE8NAME   "scenarios"

Definition at line 7084 of file stdinhand.c.

◆ SPECENUM_VALUE9

#define SPECENUM_VALUE9   LIST_NATIONSETS

Definition at line 7085 of file stdinhand.c.

◆ SPECENUM_VALUE9NAME

#define SPECENUM_VALUE9NAME   "nationsets"

Definition at line 7086 of file stdinhand.c.

◆ SPECHASH_ASTR_KEY_TYPE

#define SPECHASH_ASTR_KEY_TYPE

Definition at line 105 of file stdinhand.c.

◆ SPECHASH_IDATA_COPY

#define SPECHASH_IDATA_COPY   time_duplicate

Definition at line 108 of file stdinhand.c.

◆ SPECHASH_IDATA_FREE

#define SPECHASH_IDATA_FREE   (kick_hash_data_free_fn_t) free

Definition at line 109 of file stdinhand.c.

◆ SPECHASH_IDATA_TO_UDATA

#define SPECHASH_IDATA_TO_UDATA (   p)    (NULL != p ? *p : 0)

Definition at line 111 of file stdinhand.c.

◆ SPECHASH_IDATA_TYPE

#define SPECHASH_IDATA_TYPE   time_t *

Definition at line 106 of file stdinhand.c.

◆ SPECHASH_TAG

#define SPECHASH_TAG   kick

Definition at line 104 of file stdinhand.c.

◆ SPECHASH_UDATA_TO_IDATA

#define SPECHASH_UDATA_TO_IDATA (   t)    (&(t))

Definition at line 110 of file stdinhand.c.

◆ SPECHASH_UDATA_TYPE

#define SPECHASH_UDATA_TYPE   time_t

Definition at line 107 of file stdinhand.c.

Function Documentation

◆ a_connection_exists()

static bool a_connection_exists ( void  )
static

Returns true if there is at least one established connection.

Definition at line 1415 of file stdinhand.c.

Referenced by access_level_for_next_connection().

◆ access_level_for_next_connection()

enum cmdlevel access_level_for_next_connection ( void  )

Return access level for next connection

Definition at line 1437 of file stdinhand.c.

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 5921 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ away_command()

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

Set user to away mode.

Definition at line 2086 of file stdinhand.c.

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 2629 of file stdinhand.c.

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 516 of file stdinhand.c.

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 1983 of file stdinhand.c.

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 420 of file stdinhand.c.

Referenced by aicmd_command(), away_command(), cancelvote_command(), close_metaserver_connection(), cmd_reply_matches(), cmd_reply_no_such_conn(), cmd_reply_no_such_player(), cmdlevel_command(), connectmsg_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(), lock_command(), 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(), ruleset_cache_listcmd_cb(), save_command(), scensave_command(), script_server_cmd_reply(), set_ai_level(), set_ai_level_direct(), set_cmdlevel(), set_command(), set_rulesetdir(), show_ais(), 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_command(), toggle_ai_player_direct(), unignore_command(), unlock_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 == NULL means console. No longer duplicate all output to console.

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

Definition at line 333 of file stdinhand.c.

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 6530 of file stdinhand.c.

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 468 of file stdinhand.c.

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 433 of file stdinhand.c.

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 407 of file stdinhand.c.

◆ 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_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 1465 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ 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 223 of file stdinhand.c.

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 6284 of file stdinhand.c.

Referenced by handle_login_request().

◆ 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 1942 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ 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 create_command_pregame()) and for a running game (see create_command_newcomer(). In the later case, first free player slots are used before the slots of dead players are (re)used.

Definition at line 754 of file stdinhand.c.

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 812 of file stdinhand.c.

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 996 of file stdinhand.c.

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 6241 of file stdinhand.c.

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 2724 of file stdinhand.c.

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 4952 of file stdinhand.c.

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 5185 of file stdinhand.c.

Referenced by delegate_command().

◆ delegate_command()

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

Handle delegation of control.

Definition at line 5194 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ delegate_player_str()

static const char * delegate_player_str ( struct player pplayer,
bool  observer 
)
static

Return static string describing what a connection is connected to.

Definition at line 5645 of file stdinhand.c.

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 NULL) then it will correctly detach from observing mode.

Definition at line 3685 of file stdinhand.c.

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 4762 of file stdinhand.c.

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 1897 of file stdinhand.c.

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 5995 of file stdinhand.c.

Referenced by fcdb_command().

◆ fcdb_command()

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

Handle the freeciv database script module.

Definition at line 6004 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ 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 1608 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ get_init_script_choices()

struct strvec * get_init_script_choices ( void  )

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 1270 of file stdinhand.c.

◆ handle_stdin_input()

bool handle_stdin_input ( struct connection caller,
char str 
)

Main entry point for "command input". Version to be used with statically allocated 'str'

Definition at line 4429 of file stdinhand.c.

Referenced by check_vote(), and handle_chat_msg_req().

◆ handle_stdin_input_free()

bool handle_stdin_input_free ( struct connection caller,
char str 
)

Entry point for "command input". Version that frees 'str' in the end.

Definition at line 4437 of file stdinhand.c.

Referenced by server_sniff_all_input().

◆ 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 == NULL 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 4456 of file stdinhand.c.

Referenced by handle_stdin_input(), handle_stdin_input_free(), handle_stdin_input_real(), and read_init_script_real().

◆ helparg_accessor()

static const char * helparg_accessor ( int  i)
static

Convert unified helparg index to string; see above.

Definition at line 6586 of file stdinhand.c.

Referenced by 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.c.

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 NULL-terminated string containing the reason.

Definition at line 3206 of file stdinhand.c.

Referenced by observe_command(), and take_command().

◆ is_first_access_level_taken()

static bool is_first_access_level_taken ( void  )
static

Return whether first access level is already taken.

Definition at line 1423 of file stdinhand.c.

Referenced by firstlevel_command(), and notify_if_first_access_level_is_available().

◆ 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 184 of file stdinhand.c.

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

◆ kick_command()

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

Kick command handler.

Definition at line 6332 of file stdinhand.c.

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 7096 of file stdinhand.c.

Referenced by show_list().

◆ 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 NULL 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 3791 of file stdinhand.c.

Referenced by handle_stdin_input_real(), and srv_prepare().

◆ lock_command()

static bool lock_command ( struct connection caller,
char str,
bool  check 
)
static

Handle lock command

Definition at line 3146 of file stdinhand.c.

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 1742 of file stdinhand.c.

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 1716 of file stdinhand.c.

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 4995 of file stdinhand.c.

Referenced by lua_command().

◆ 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 5004 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ mapimg_accessor()

static const char * mapimg_accessor ( int  i)
static

Returns possible parameters for the mapimg command.

Definition at line 5684 of file stdinhand.c.

Referenced by mapimg_command().

◆ mapimg_command()

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

Handle mapimg command

Definition at line 5693 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ may_use()

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

Whether the caller can use the specified command. caller == NULL means console.

Definition at line 283 of file stdinhand.c.

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 == NULL means console.

Definition at line 295 of file stdinhand.c.

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 529 of file stdinhand.c.

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 610 of file stdinhand.c.

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 585 of file stdinhand.c.

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 644 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ notify_if_first_access_level_is_available()

void notify_if_first_access_level_is_available ( void  )

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

Definition at line 1451 of file stdinhand.c.

Referenced by lost_connection_to_client().

◆ 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 3348 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ open_metaserver_connection()

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

Start sending game info to metaserver.

Definition at line 502 of file stdinhand.c.

Referenced by metaconnection_command().

◆ 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 1648 of file stdinhand.c.

Referenced by helparg_accessor(), and lookup_option().

◆ 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 193 of file stdinhand.c.

Referenced by create_command_newcomer(), and create_command_pregame().

◆ playercolor_command()

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

/playercolor command handler.

Definition at line 4203 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ playernation_command()

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

/playernation command handler.

Definition at line 4288 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ quit_game()

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

Definition at line 4415 of file stdinhand.c.

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 1160 of file stdinhand.c.

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 1169 of file stdinhand.c.

Referenced by handle_ruleset_select(), and srv_main().

◆ 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 1187 of file stdinhand.c.

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 1123 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ reset_accessor()

static const char * reset_accessor ( int  i)
static

Returns possible parameters for the reset command.

Definition at line 4835 of file stdinhand.c.

Referenced by reset_command().

◆ 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 4845 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ ruleset_cache_listcmd_cb()

static void ruleset_cache_listcmd_cb ( const char mp_name,
const char filename,
void data_in 
)
static

Callback called from modpack ruleset cache iteration.

Definition at line 6856 of file stdinhand.c.

Referenced by show_rulesets().

◆ 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 673 of file stdinhand.c.

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 690 of file stdinhand.c.

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 2030 of file stdinhand.c.

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 2005 of file stdinhand.c.

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 2019 of file stdinhand.c.

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 1380 of file stdinhand.c.

Referenced by cmdlevel_command().

◆ set_command()

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

Handle set command

Definition at line 2966 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ set_rulesetdir()

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

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 3978 of file stdinhand.c.

Referenced by handle_ruleset_select(), and handle_stdin_input_real().

◆ set_running_game_access_level()

void set_running_game_access_level ( void  )

Adjust default command level on game start.

Definition at line 1635 of file stdinhand.c.

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 == NULL means console.

Definition at line 307 of file stdinhand.c.

Referenced by show_settings_one().

◆ show_ais()

static void show_ais ( struct connection caller)
static

Show a list of AI types supported

Definition at line 7032 of file stdinhand.c.

Referenced by show_list().

◆ show_colors()

static void show_colors ( struct connection caller)
static

Show a list of all players with the assigned color.

Definition at line 7047 of file stdinhand.c.

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 2152 of file stdinhand.c.

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 6666 of file stdinhand.c.

Referenced by show_list().

◆ show_delegations()

static void show_delegations ( struct connection caller)
static

List all delegations of the current game.

Definition at line 6692 of file stdinhand.c.

Referenced by show_list().

◆ show_help()

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

Handle help command

Definition at line 6604 of file stdinhand.c.

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 6446 of file stdinhand.c.

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 6492 of file stdinhand.c.

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 6413 of file stdinhand.c.

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 1771 of file stdinhand.c.

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 1861 of file stdinhand.c.

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.c.

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 7105 of file stdinhand.c.

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 7011 of file stdinhand.c.

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 6944 of file stdinhand.c.

Referenced by show_list().

◆ show_players()

void show_players ( struct connection caller)

Show the list of the players of the game.

Definition at line 6756 of file stdinhand.c.

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 2127 of file stdinhand.c.

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

◆ show_rulesets()

static void show_rulesets ( struct connection caller)
static

List rulesets.

Definition at line 6895 of file stdinhand.c.

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 6918 of file stdinhand.c.

Referenced by show_list().

◆ show_serverid()

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

Returns the serverid

Definition at line 662 of file stdinhand.c.

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 2162 of file stdinhand.c.

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 2334 of file stdinhand.c.

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 6981 of file stdinhand.c.

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 2475 of file stdinhand.c.

Referenced by show_list(), and vote_command().

◆ start_cmd_reply()

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

Send start command related message

Definition at line 6107 of file stdinhand.c.

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 6118 of file stdinhand.c.

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

◆ stdinhand_free()

void stdinhand_free ( void  )

Deinitialize stuff related to this code module.

Definition at line 264 of file stdinhand.c.

Referenced by server_quit().

◆ stdinhand_init()

void stdinhand_init ( void  )

Initialize stuff related to this code module.

Definition at line 243 of file stdinhand.c.

Referenced by srv_prepare().

◆ stdinhand_turn()

void stdinhand_turn ( void  )

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

Definition at line 256 of file stdinhand.c.

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 4787 of file stdinhand.c.

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 3496 of file stdinhand.c.

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 2398 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ time_duplicate()

static time_t * time_duplicate ( const time_t t)
static

Utility for 'kick_hash' tables.

Definition at line 6273 of file stdinhand.c.

◆ timeout_command()

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

Set timeout options.

Definition at line 1672 of file stdinhand.c.

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 731 of file stdinhand.c.

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 706 of file stdinhand.c.

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 4114 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ unlock_command()

static bool unlock_command ( struct connection caller,
char str,
bool  check 
)
static

Handle unlock command

Definition at line 3174 of file stdinhand.c.

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 NULL on failure.

Definition at line 2932 of file stdinhand.c.

Referenced by default_command(), lock_command(), set_command(), and unlock_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 380 of file stdinhand.c.

Referenced by cmd_reply(), and cmd_reply_prefix().

◆ vote_arg_accessor()

static const char * vote_arg_accessor ( int  i)
static

Definition at line 2516 of file stdinhand.c.

Referenced by vote_command().

◆ vote_command()

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

Make or participate in a vote.

Definition at line 2524 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ wall()

static bool wall ( char str,
bool  check 
)
static

Send a message to all players

Definition at line 1930 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ 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 1341 of file stdinhand.c.

Referenced by handle_stdin_input_real().

◆ write_init_script()

static bool 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 1280 of file stdinhand.c.

Referenced by write_command().

Variable Documentation

◆ default_access_level

enum cmdlevel default_access_level = ALLOW_BASIC
static

◆ first_access_level

enum cmdlevel first_access_level = ALLOW_BASIC
static

◆ horiz_line

const char horiz_line[]
static

◆ kick_table_by_addr

struct kick_hash* kick_table_by_addr = NULL
static

Definition at line 116 of file stdinhand.c.

Referenced by conn_is_kicked(), kick_command(), stdinhand_free(), and stdinhand_init().

◆ kick_table_by_user

struct kick_hash* kick_table_by_user = NULL
static

Definition at line 117 of file stdinhand.c.

Referenced by conn_is_kicked(), kick_command(), stdinhand_free(), and stdinhand_init().

◆ script_extension

const char* script_extension = ".serv"

Definition at line 114 of file stdinhand.c.

Referenced by read_init_script_real(), and write_command().

◆ vote_args

const char* const vote_args[]
static
Initial value:
= {
"yes",
"no",
"abstain",
}
char * incite_cost
Definition comments.c:76

Vote command argument definitions.

Definition at line 2510 of file stdinhand.c.

Referenced by vote_arg_accessor().