![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "log.h"#include "net_types.h"#include "fc_types.h"#include "game.h"#include <QHostAddress>#include "specenum_gen.h"
Include dependency graph for srv_main.h:
This graph shows which files directly or indirectly include this file:Go to the source code of this file.
Classes | |
| 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_SKIP (100) |
Functions | |
| void | init_game_seed () |
| Initialize the game seed. More... | |
| void | srv_init () |
| Initialize freeciv server. More... | |
| void | server_quit () |
| Quit the server and exit. More... | |
| void | save_game_auto (const char *save_reason, enum autosave_type type) |
| Save game with autosave filename. More... | |
| enum server_states | server_state () |
| Return current server state. More... | |
| void | set_server_state (enum server_states newstate) |
| Set current server state. More... | |
| void | check_for_full_turn_done () |
| Check if turn is really done. More... | |
| bool | check_for_game_over () |
| Returns TRUE if any one game end condition is fulfilled, FALSE otherwise. More... | |
| bool | game_was_started () |
| Returns iff the game was started once upon a time. More... | |
| int | server_plr_tile_city_id_get (const struct tile *ptile, const struct player *pplayer) |
| Returns the id of the city the player map of 'pplayer' has at 'ptile' or IDENTITY_NUMBER_ZERO if the player map don't have a city there. More... | |
| server_setting_id | server_ss_by_name (const char *name) |
| Returns the id of the server setting with the specified name. More... | |
| const char * | server_ss_name_get (server_setting_id id) |
| Returns the name of the server setting with the specified id. More... | |
| enum sset_type | server_ss_type_get (server_setting_id id) |
| Returns the type of the server setting with the specified id. More... | |
| bool | server_ss_val_bool_get (server_setting_id id) |
| Returns the value of the boolean server setting with the specified id. More... | |
| int | server_ss_val_int_get (server_setting_id id) |
| Returns the value of the integer server setting with the specified id. More... | |
| unsigned int | server_ss_val_bitwise_get (server_setting_id id) |
| Returns the value of the bitwise server setting with the specified id. More... | |
| bool | server_packet_input (struct connection *pconn, void *packet, int type) |
| Returns FALSE if connection should be closed (because the clients was rejected). More... | |
| void | start_game () |
| Start actual game. More... | |
| 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. More... | |
| void | player_nation_defaults (struct player *pplayer, struct nation_type *pnation, bool set_name) |
| Set nation for player with nation default values. More... | |
| void | send_all_info (struct conn_list *dest) |
| Send all information for when game starts or client reconnects. More... | |
| void | begin_turn (bool is_new_turn) |
| Handle the beginning of each turn. More... | |
| void | begin_phase (bool is_new_phase) |
| Begin a phase of movement. More... | |
| void | end_phase () |
| End a phase of movement. More... | |
| void | end_turn () |
| Handle the end of each turn. More... | |
| void | identity_number_release (int id) |
| Mark identity number free. More... | |
| void | identity_number_reserve (int id) |
| Mark identity number allocated. More... | |
| int | identity_number () |
| Identity ids wrap at IDENTITY_NUMBER_SIZE, skipping IDENTITY_NUMBER_ZERO Setup in server_game_init() More... | |
| void | srv_ready () |
| Set up one game. More... | |
| void | srv_scores () |
| Score calculation. More... | |
| void | server_game_init (bool keep_ruleset_value) |
| Initialize game data for the server (corresponds to server_game_free). More... | |
| void | server_game_free () |
| Free game data that we reinitialize as part of a server soft restart. More... | |
| const char * | aifill (int amount) |
| Fill or remove players to meet the given aifill. More... | |
| void | update_nations_with_startpos () |
| Update information about which nations have start positions on the map. More... | |
| known_type | mapimg_server_tile_known (const struct tile *ptile, const struct player *pplayer, bool knowledge) |
| Helper function for the mapimg module - tile knowledge. More... | |
| terrain * | mapimg_server_tile_terrain (const struct tile *ptile, const struct player *pplayer, bool knowledge) |
| Helper function for the mapimg module - tile terrain. More... | |
| player * | mapimg_server_tile_owner (const struct tile *ptile, const struct player *pplayer, bool knowledge) |
| Helper function for the mapimg module - tile owner. More... | |
| player * | mapimg_server_tile_city (const struct tile *ptile, const struct player *pplayer, bool knowledge) |
| Helper function for the mapimg module - city owner. More... | |
| player * | mapimg_server_tile_unit (const struct tile *ptile, const struct player *pplayer, bool knowledge) |
| Helper function for the mapimg module - unit owner. More... | |
| int | mapimg_server_plrcolor_count () |
| Helper function for the mapimg module - number of player colors. More... | |
| rgbcolor * | mapimg_server_plrcolor_get (int i) |
| Helper function for the mapimg module - one player color. More... | |
Variables | |
| struct civserver | server |
| struct server_arguments | srvarg |
| bool | force_end_of_sniff |
| #define IDENTITY_NUMBER_SKIP (100) |
Definition at line 85 of file srv_main.h.
| #define SPECENUM_NAME server_states |
Definition at line 68 of file srv_main.h.
| #define SPECENUM_VALUE0 S_S_INITIAL |
Definition at line 69 of file srv_main.h.
| #define SPECENUM_VALUE1 S_S_RUNNING |
Definition at line 70 of file srv_main.h.
| #define SPECENUM_VALUE2 S_S_OVER |
Definition at line 71 of file srv_main.h.
| const char* aifill | ( | int | amount | ) |
Fill or remove players to meet the given aifill.
If return is non-nullptr, points to a translated string explaining why the total number of players is less than 'amount'.
Definition at line 2440 of file srv_main.cpp.
Referenced by aifill_action(), connection_attach_real(), connection_detach(), load_command(), load_rulesetdir(), nationset_action(), freeciv::server::prepare_game(), remove_player_command(), pregame_options::set_aifill(), sg_load_savefile(), and sg_load_scenario().
| void begin_phase | ( | bool | is_new_phase | ) |
Begin a phase of movement.
This handles all beginning-of-phase actions for one or more players.
Definition at line 1213 of file srv_main.cpp.
| void begin_turn | ( | bool | is_new_turn | ) |
Handle the beginning of each turn.
Note: This does not give "time" to any player; it is solely for updating turn-dependent data.
Definition at line 1083 of file srv_main.cpp.
| void check_for_full_turn_done | ( | ) |
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 2179 of file srv_main.cpp.
Referenced by freeciv::server::begin_phase(), detach_command(), handle_player_phase_done(), lost_connection_to_client(), and player_set_to_ai_mode().
| bool check_for_game_over | ( | ) |
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 265 of file srv_main.cpp.
Referenced by freeciv::server::end_turn().
| void end_phase | ( | ) |
End a phase of movement.
This handles all end-of-phase actions for one or more players.
Definition at line 1397 of file srv_main.cpp.
| void end_turn | ( | ) |
Handle the end of each turn.
Definition at line 1554 of file srv_main.cpp.
| bool game_was_started | ( | ) |
Returns iff the game was started once upon a time.
Definition at line 251 of file srv_main.cpp.
Referenced by aifill(), api_edit_create_player(), api_server_was_started(), connection_attach_real(), connection_detach(), create_barbarian_player(), create_command(), delegate_command(), establish_new_connection(), handle_edit_player_create(), is_allowed_to_take(), mapimg_command(), observe_command(), player_color_changeable(), playercolor_command(), playernation_command(), plrcol_action(), freeciv::server::prepare_game(), remove_player_command(), server_player_set_color(), set_rulesetdir(), sg_load_players(), sg_load_players_basic(), sg_save_game(), sg_save_player_main(), sg_save_players(), split_player(), take_command(), team_command(), and update_nations_with_startpos().
| int identity_number | ( | ) |
Identity ids wrap at IDENTITY_NUMBER_SIZE, skipping IDENTITY_NUMBER_ZERO Setup in server_game_init()
Definition at line 1993 of file srv_main.cpp.
Referenced by create_city(), and create_unit_full().
| void identity_number_release | ( | int | id | ) |
| void identity_number_reserve | ( | int | id | ) |
Mark identity number allocated.
Definition at line 1969 of file srv_main.cpp.
Referenced by identity_number(), server_game_init(), sg_load_player_cities(), sg_load_player_units(), and sg_load_player_vision().
| void init_game_seed | ( | ) |
Initialize the game seed.
This may safely be called multiple times.
Definition at line 147 of file srv_main.cpp.
Referenced by sg_load_random(), and srv_ready().
| int mapimg_server_plrcolor_count | ( | ) |
Helper function for the mapimg module - number of player colors.
Definition at line 3446 of file srv_main.cpp.
| rgbcolor* mapimg_server_plrcolor_get | ( | int | i | ) |
Helper function for the mapimg module - one player color.
Definition at line 3451 of file srv_main.cpp.
| player* mapimg_server_tile_city | ( | const struct tile * | ptile, |
| const struct player * | pplayer, | ||
| bool | knowledge | ||
| ) |
Helper function for the mapimg module - city owner.
Definition at line 3401 of file srv_main.cpp.
| known_type mapimg_server_tile_known | ( | const struct tile * | ptile, |
| const struct player * | pplayer, | ||
| bool | knowledge | ||
| ) |
Helper function for the mapimg module - tile knowledge.
Definition at line 3356 of file srv_main.cpp.
| player* mapimg_server_tile_owner | ( | const struct tile * | ptile, |
| const struct player * | pplayer, | ||
| bool | knowledge | ||
| ) |
Helper function for the mapimg module - tile owner.
Definition at line 3385 of file srv_main.cpp.
| terrain* mapimg_server_tile_terrain | ( | const struct tile * | ptile, |
| const struct player * | pplayer, | ||
| bool | knowledge | ||
| ) |
Helper function for the mapimg module - tile terrain.
Definition at line 3370 of file srv_main.cpp.
| player* mapimg_server_tile_unit | ( | const struct tile * | ptile, |
| const struct player * | pplayer, | ||
| bool | knowledge | ||
| ) |
Helper function for the mapimg module - unit owner.
Definition at line 3426 of file srv_main.cpp.
| 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 nullptr if no unique name is available.
Definition at line 2787 of file srv_main.cpp.
Referenced by create_barbarian_player(), and 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 2545 of file srv_main.cpp.
Referenced by create_animals(), create_barbarian_player(), handle_edit_player_create(), player_set_nation_full(), and split_player().
| void save_game_auto | ( | const char * | save_reason, |
| enum autosave_type | type | ||
| ) |
Save game with autosave filename.
Definition at line 1788 of file srv_main.cpp.
Referenced by freeciv::server::begin_phase(), freeciv::server::pulse(), and srv_scores().
| 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 607 of file srv_main.cpp.
Referenced by connection_attach_real(), and srv_ready().
| void server_game_free | ( | ) |
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 3204 of file srv_main.cpp.
Referenced by load_command(), savegame2_load(), savegame3_load(), server_quit(), and freeciv::server::shut_game_down().
| void server_game_init | ( | bool | keep_ruleset_value | ) |
Initialize game data for the server (corresponds to server_game_free).
Definition at line 3179 of file srv_main.cpp.
Referenced by load_command(), savegame2_load(), savegame3_load(), and freeciv::server::shut_game_down().
| 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 2024 of file srv_main.cpp.
Referenced by incoming_client_packets().
Returns the id of the city the player map of 'pplayer' has at 'ptile' or IDENTITY_NUMBER_ZERO if the player map don't have a city there.
Definition at line 3254 of file srv_main.cpp.
| void server_quit | ( | ) |
Quit the server and exit.
Definition at line 1869 of file srv_main.cpp.
Referenced by freeciv::server::~server().
| server_setting_id server_ss_by_name | ( | const char * | name | ) |
Returns the id of the server setting with the specified name.
Definition at line 3266 of file srv_main.cpp.
Referenced by fc_interface_init_tool().
| const char* server_ss_name_get | ( | server_setting_id | id | ) |
Returns the name of the server setting with the specified id.
Definition at line 3281 of file srv_main.cpp.
Referenced by fc_interface_init_tool().
| 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 3281 of file srv_main.cpp.
Referenced by fc_interface_init_tool().
| 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 3341 of file srv_main.cpp.
Referenced by fc_interface_init_tool().
| 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 3311 of file srv_main.cpp.
Referenced by fc_interface_init_tool().
| 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 3326 of file srv_main.cpp.
Referenced by fc_interface_init_tool().
| enum server_states server_state | ( | ) |
Return current server state.
Definition at line 222 of file srv_main.cpp.
Referenced by api_edit_tile_set_label(), autosaves_callback(), check_for_full_turn_done(), connection_attach_real(), dai_assess_danger_player(), end_command(), freeciv::server::end_phase(), freeciv::server::end_turn(), establish_new_connection(), event_cache_add_for_all(), event_cache_add_for_global_observers(), event_cache_add_for_player(), event_cache_add_for_players(), event_cache_match(), first_timeout_action(), game_was_started(), give_shared_vision(), handle_player_rates(), handle_player_ready(), handle_report_req(), load_command(), map_claim_border_ownership(), notify_conn_packet(), package_player_diplstate(), package_player_info(), player_set_to_ai_mode(), freeciv::server::pulse(), remove_shared_vision(), reset_all_start_commands(), reset_command(), send_city_info(), send_lanserver_response(), send_to_metaserver(), server_packet_input(), server_quit(), setting_is_free_to_change(), sg_save_game(), show_players(), start_command(), start_game(), surrender_command(), timeout_action(), timeout_set_command(), timeout_show_command(), freeciv::server::update_game_state(), and update_tile_knowledge().
| void set_server_state | ( | enum server_states | newstate | ) |
Set current server state.
Definition at line 243 of file srv_main.cpp.
Referenced by end_command(), freeciv::server::end_turn(), freeciv::server::prepare_game(), freeciv::server::quit_idle(), server_quit(), and srv_ready().
| void srv_init | ( | ) |
| void srv_ready | ( | ) |
Set up one game.
Definition at line 2888 of file srv_main.cpp.
Referenced by freeciv::server::update_game_state().
| void srv_scores | ( | ) |
Score calculation.
Definition at line 2834 of file srv_main.cpp.
Referenced by freeciv::server::end_turn().
| void start_game | ( | ) |
Start actual game.
Everything has been set up already.
Definition at line 1830 of file srv_main.cpp.
Referenced by start_command().
| void update_nations_with_startpos | ( | ) |
Update information about which nations have start positions on the map.
Call this on server start, or when loading a scenario.
Definition at line 2239 of file srv_main.cpp.
Referenced by load_rulesetdir(), and sg_load_map_startpos().
|
extern |
Definition at line 130 of file srv_main.cpp.
Referenced by freeciv::server::begin_phase(), check_for_full_turn_done(), end_command(), freeciv::server::pulse(), freeciv::server::quit_idle(), start_game(), and freeciv::server::update_game_state().
|
extern |
Definition at line 115 of file srv_main.cpp.
Referenced by auth_user(), freeciv::server::begin_phase(), close_connections_and_socket(), delegate_command(), establish_new_connection(), fcdb_command(), get_challenge_filename(), get_lanserver_announcement(), handle_login_request(), is_allowed_to_take(), load_command(), main(), mapimg_command(), meta_addr_port(), metaserver_command(), freeciv::server::prepare_game(), freeciv::server::pulse(), freeciv::server::quit_idle(), rank_users(), reset_command(), save_game(), send_lanserver_response(), send_metaserver_post(), send_to_metaserver(), server_open_socket(), server_quit(), sg_load_game(), sg_save_game(), show_serverid(), freeciv::server::shut_game_down(), srv_init(), freeciv::server::update_game_state(), and write_init_script().