Freeciv21
Develop your civilization from humble roots to a global empire
stdinhand.h File Reference
#include <QString>
#include <QVector>
#include "chat.h"
#include "connection.h"
#include "fc_types.h"
#include "commands.h"
#include "console.h"
+ Include dependency graph for stdinhand.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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...
 
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)
 Main entry point for "command input". More...
 
void set_ai_level_direct (struct player *pplayer, enum ai_level level)
 Set an AI level from the server prompt. 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...
 
void show_players (struct connection *caller)
 Show the list of the players of the game. 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...
 
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...
 
bool start_command (struct connection *caller, bool check, bool notify)
 Handle start command. More...
 
void toggle_ai_player_direct (struct connection *caller, struct player *pplayer)
 Handle ai player ai toggling. 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...
 
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...
 
void set_running_game_access_level ()
 Adjust default command level on game start. More...
 
char ** freeciv_completion (const char *text, int start, int end)
 Attempt to complete on the contents of TEXT. More...
 
bool should_quit ()
 Returns whether the server should exit after a command. More...
 

Function Documentation

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

◆ 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 6280 of file stdinhand.cpp.

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

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

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

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

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

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

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

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

◆ should_quit()

bool should_quit ( )

Returns whether the server should exit after a command.

Definition at line 4440 of file stdinhand.cpp.

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

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

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