Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
srv_main.h File Reference
#include "log.h"
#include "net_types.h"
#include "fc_types.h"
#include "game.h"
#include "specenum_gen.h"

Go to the source code of this file.

Data Structures

struct  server_arguments
 
struct  civserver
 

Macros

#define SPECENUM_NAME   server_states
 
#define SPECENUM_VALUE0   S_S_INITIAL
 
#define SPECENUM_VALUE1   S_S_RUNNING
 
#define SPECENUM_VALUE2   S_S_OVER
 
#define IDENTITY_NUMBER_SIZE   250000
 
#define IDENTITY_NUMBER_SKIP   (100)
 

Functions

 BV_DEFINE (bv_id, IDENTITY_NUMBER_SIZE)
 
void init_game_seed (void)
 
void srv_init (void)
 
void fc__noreturn srv_main (void)
 
void fc__noreturn server_quit (void)
 
void save_game_auto (const char *save_reason, enum autosave_type type)
 
enum server_states server_state (void)
 
void set_server_state (enum server_states newstate)
 
void check_for_full_turn_done (void)
 
bool check_for_game_over (void)
 
bool game_was_started (void)
 
server_setting_id server_ss_by_name (const char *name)
 
const charserver_ss_name_get (server_setting_id id)
 
enum sset_type server_ss_type_get (server_setting_id id)
 
bool server_ss_val_bool_get (server_setting_id id)
 
int server_ss_val_int_get (server_setting_id id)
 
unsigned int server_ss_val_bitwise_get (server_setting_id id)
 
bool server_packet_input (struct connection *pconn, void *packet, int type)
 
void start_game (void)
 
const charpick_random_player_name (const struct nation_type *pnation)
 
void player_nation_defaults (struct player *pplayer, struct nation_type *pnation, bool set_name)
 
void send_all_info (struct conn_list *dest)
 
void identity_number_release (int id)
 
void identity_number_reserve (int id)
 
int identity_number (void)
 
void server_game_init (bool keep_ruleset_value)
 
void server_game_free (void)
 
const charaifill (int amount)
 
void update_nations_with_startpos (void)
 

Variables

struct civserver server
 
struct server_arguments srvarg
 
bool force_end_of_sniff
 

Macro Definition Documentation

◆ IDENTITY_NUMBER_SIZE

#define IDENTITY_NUMBER_SIZE   250000

Definition at line 71 of file srv_main.h.

◆ IDENTITY_NUMBER_SKIP

#define IDENTITY_NUMBER_SKIP   (100)

Definition at line 85 of file srv_main.h.

◆ SPECENUM_NAME

Definition at line 65 of file srv_main.h.

◆ SPECENUM_VALUE0

#define SPECENUM_VALUE0   S_S_INITIAL

Definition at line 66 of file srv_main.h.

◆ SPECENUM_VALUE1

#define SPECENUM_VALUE1   S_S_RUNNING

Definition at line 67 of file srv_main.h.

◆ SPECENUM_VALUE2

#define SPECENUM_VALUE2   S_S_OVER

Definition at line 68 of file srv_main.h.

Function Documentation

◆ aifill()

const char * aifill ( int  amount)

Fill or remove players to meet the given aifill. If return is non-NULL, points to a translated string explaining why the total number of players is less than 'amount'.

Definition at line 2465 of file srv_main.c.

Referenced by ai_fill_changed_by_server(), aifill_action(), connection_attach_real(), connection_detach(), create_command_newcomer(), create_command_pregame(), load_command(), load_rulesetdir(), nationset_action(), receive_packet_game_info_100(), remove_player_command(), pregame_options::set_aifill(), sg_load_savefile(), sg_load_scenario(), and srv_main().

◆ BV_DEFINE()

BV_DEFINE ( bv_id  ,
IDENTITY_NUMBER_SIZE   
)

◆ check_for_full_turn_done()

void check_for_full_turn_done ( void  )

Check if turn is really done. Returns nothing, but as a side effect sets force_end_of_sniff if no more input is expected this turn (i.e. turn done)

Definition at line 2215 of file srv_main.c.

Referenced by detach_command(), handle_player_phase_done(), lost_connection_to_client(), player_set_to_ai_mode(), and srv_running().

◆ check_for_game_over()

bool check_for_game_over ( void  )

Returns TRUE if any one game end condition is fulfilled, FALSE otherwise.

This function will notify players but will not set the server_state(). The caller must set the server state to S_S_OVER if the function returns TRUE.

Also send notifications about impending, predictable game end conditions.

Definition at line 363 of file srv_main.c.

Referenced by srv_running().

◆ game_was_started()

bool game_was_started ( void  )

◆ identity_number()

int identity_number ( void  )

Identity ids wrap at IDENTITY_NUMBER_SIZE, skipping IDENTITY_NUMBER_ZERO Setup in server_game_init()

Definition at line 2020 of file srv_main.c.

Referenced by create_city(), and place_unit().

◆ identity_number_release()

void identity_number_release ( int  id)

Mark identity number free.

Definition at line 1986 of file srv_main.c.

Referenced by srv_init().

◆ identity_number_reserve()

void identity_number_reserve ( int  id)

◆ init_game_seed()

void init_game_seed ( void  )

Initialize the game seed. This may safely be called multiple times.

Definition at line 203 of file srv_main.c.

Referenced by sg_load_random(), sg_load_random(), and srv_ready().

◆ pick_random_player_name()

const char * pick_random_player_name ( const struct nation_type pnation)

Returns a random ruler name picked from given nation's ruler names that is not already in use. May return NULL if no unique name is available.

Definition at line 2803 of file srv_main.c.

Referenced by create_barbarian_player(), and player_nation_defaults().

◆ player_nation_defaults()

void player_nation_defaults ( struct player pplayer,
struct nation_type pnation,
bool  set_name 
)

Set nation for player with nation default values.

Definition at line 2580 of file srv_main.c.

Referenced by create_animals(), create_barbarian_player(), create_command_newcomer(), handle_edit_player_create(), player_set_nation_full(), and split_player().

◆ save_game_auto()

void save_game_auto ( const char save_reason,
enum autosave_type  type 
)

Save game with autosave filename

Definition at line 1797 of file srv_main.c.

Referenced by server_sniff_all_input(), srv_running(), and srv_scores().

◆ send_all_info()

void send_all_info ( struct conn_list dest)

Send all information for when game starts or client reconnects. Initial packets should have been sent before calling this function. See comment in connecthand.c::establish_new_connection().

Definition at line 692 of file srv_main.c.

Referenced by connection_attach_real(), and srv_ready().

◆ server_game_free()

void server_game_free ( void  )

Free game data that we reinitialize as part of a server soft restart. Bear in mind that this function is called when the 'load' command is used, for instance.

Definition at line 3487 of file srv_main.c.

Referenced by load_command(), savegame2_load(), savegame3_load(), server_quit(), and srv_main().

◆ server_game_init()

void server_game_init ( bool  keep_ruleset_value)

Initialize game data for the server (corresponds to server_game_free() ).

Definition at line 3463 of file srv_main.c.

Referenced by load_command(), savegame2_load(), savegame3_load(), srv_main(), and srv_prepare().

◆ server_packet_input()

bool server_packet_input ( struct connection pconn,
void packet,
int  type 
)

Returns FALSE if connection should be closed (because the clients was rejected). Returns TRUE else.

Definition at line 2051 of file srv_main.c.

Referenced by incoming_client_packets().

◆ server_quit()

void fc__noreturn server_quit ( void  )

Quit the server and exit.

Definition at line 1875 of file srv_main.c.

Referenced by quit_game(), server_sniff_all_input(), and srv_main().

◆ server_ss_by_name()

server_setting_id server_ss_by_name ( const char name)

Returns the id of the server setting with the specified name.

Definition at line 3621 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

◆ server_ss_name_get()

const char * server_ss_name_get ( server_setting_id  id)

Returns the name of the server setting with the specified id.

Definition at line 3636 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

◆ server_ss_type_get()

enum sset_type server_ss_type_get ( server_setting_id  id)

Returns the type of the server setting with the specified id.

Definition at line 3651 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

◆ server_ss_val_bitwise_get()

unsigned int server_ss_val_bitwise_get ( server_setting_id  id)

Returns the value of the bitwise server setting with the specified id.

Definition at line 3696 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

◆ server_ss_val_bool_get()

bool server_ss_val_bool_get ( server_setting_id  id)

Returns the value of the boolean server setting with the specified id.

Definition at line 3666 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

◆ server_ss_val_int_get()

int server_ss_val_int_get ( server_setting_id  id)

Returns the value of the integer server setting with the specified id.

Definition at line 3681 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

◆ server_state()

enum server_states server_state ( void  )

◆ set_server_state()

void set_server_state ( enum server_states  newstate)

Set current server state.

Definition at line 341 of file srv_main.c.

Referenced by end_command(), server_quit(), server_sniff_all_input(), srv_main(), srv_ready(), and srv_running().

◆ srv_init()

void srv_init ( void  )

Initialize freeciv server.

Definition at line 227 of file srv_main.c.

Referenced by main(), and srv_prepare().

◆ srv_main()

void fc__noreturn srv_main ( void  )

Server main loop.

Definition at line 3532 of file srv_main.c.

Referenced by main().

◆ start_game()

void start_game ( void  )

Start actual game. Everything has been set up already.

Definition at line 1838 of file srv_main.c.

Referenced by start_command().

◆ update_nations_with_startpos()

void update_nations_with_startpos ( void  )

Update information about which nations have start positions on the map.

Call this on server start, or when loading a scenario.

Definition at line 2270 of file srv_main.c.

Referenced by load_rulesetdir(), sg_load_map_startpos(), and sg_load_map_startpos().

Variable Documentation

◆ force_end_of_sniff

bool force_end_of_sniff
extern

◆ server

◆ srvarg

struct server_arguments srvarg
extern