Freeciv-3.3
Loading...
Searching...
No Matches
Functions
stdinhand.h File Reference
#include "chat.h"
#include "connection.h"
#include "fc_types.h"
#include "commands.h"
#include "console.h"

Go to the source code of this file.

Functions

void stdinhand_init (void)
 
void stdinhand_turn (void)
 
void stdinhand_free (void)
 
void cmd_reply (enum command_id cmd, struct connection *caller, enum rfc_status rfc_status, const char *format,...) fc__attribute((__format__(__printf__
 
void bool handle_stdin_input (struct connection *caller, char *str)
 
bool handle_stdin_input_free (struct connection *caller, char *str)
 
void set_ai_level_direct (struct player *pplayer, enum ai_level level)
 
bool read_init_script (struct connection *caller, const char *script_filename, bool from_cmdline, bool check)
 
bool set_rulesetdir (struct connection *caller, const char *str, bool check, int read_recursion)
 
struct strvecget_init_script_choices (void)
 
void show_players (struct connection *caller)
 
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)
 
bool load_command (struct connection *caller, const char *filename, bool check, bool cmdline_load)
 
bool start_command (struct connection *caller, bool check, bool notify)
 
void toggle_ai_player_direct (struct connection *caller, struct player *pplayer)
 
enum cmdlevel access_level_for_next_connection (void)
 
void notify_if_first_access_level_is_available (void)
 
bool conn_is_kicked (struct connection *pconn, int *time_remaining)
 
void set_running_game_access_level (void)
 

Function Documentation

◆ 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().

◆ cmd_reply()

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

◆ 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().

◆ 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().

◆ 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()

void 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().

◆ 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().

◆ 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().

◆ 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().

◆ 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_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().

◆ 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().

◆ 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().

◆ 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().