Freeciv-3.3: /fast/freeciv/nightly/main/server/srv_main.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Macros | Functions | Variables
srv_main.c File Reference
`#include "fc_prehdrs.h"`
`#include <ctype.h>`
`#include <stdio.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <time.h>`
`#include "lua.h"`
`#include "astring.h"`
`#include "bitvector.h"`
`#include "bugs.h"`
`#include "capability.h"`
`#include "fc_cmdline.h"`
`#include "fciconv.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "netintf.h"`
`#include "rand.h"`
`#include "randseed.h"`
`#include "registry.h"`
`#include "support.h"`
`#include "timing.h"`
`#include "citymap.h"`
`#include "achievements.h"`
`#include "calendar.h"`
`#include "capstr.h"`
`#include "city.h"`
`#include "counters.h"`
`#include "culture.h"`
`#include "dataio.h"`
`#include "effects.h"`
`#include "events.h"`
`#include "fc_interface.h"`
`#include "government.h"`
`#include "map.h"`
`#include "mapimg.h"`
`#include "nation.h"`
`#include "packets.h"`
`#include "player.h"`
`#include "research.h"`
`#include "tech.h"`
`#include "unitlist.h"`
`#include "version.h"`
`#include "victory.h"`
`#include "aiiface.h"`
`#include "animals.h"`
`#include "auth.h"`
`#include "barbarian.h"`
`#include "cityhand.h"`
`#include "citytools.h"`
`#include "cityturn.h"`
`#include "connecthand.h"`
`#include "console.h"`
`#include "fcdb.h"`
`#include "diplhand.h"`
`#include "edithand.h"`
`#include "gamehand.h"`
`#include "handchat.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 "spacerace.h"`
`#include "srv_log.h"`
`#include "srv_signal.h"`
`#include "stdinhand.h"`
`#include "techtools.h"`
`#include "unithand.h"`
`#include "unittools.h"`
`#include "voting.h"`
`#include "advdata.h"`
`#include "autoworkers.h"`
`#include "advbuilding.h"`
`#include "advspace.h"`
`#include "infracache.h"`
`#include "savemain.h"`
`#include "script_fcdb.h"`
`#include "script_server.h"`
`#include "luascript_types.h"`
`#include "mapgen.h"`
`#include "mapgen_utils.h"`
`#include "aitraits.h"`
`#include "difficulty.h"`
`#include "srv_main.h"`
`#include "spechash.h"`

Go to the source code of this file.

## Macros

#define | SPECHASH_TAG startpos
#define | SPECHASH_IKEY_TYPE struct startpos *
#define | SPECHASH_INT_DATA_TYPE
#define | startpos_hash_iterate(hash, psp, c) TYPED_HASH_ITERATE(struct startpos *, intptr_t, hash, psp, c)
#define | startpos_hash_iterate_end HASH_ITERATE_END

## Functions

static void | end_turn (void)
static void | announce_player (struct player *pplayer)
static void | fc_interface_init_server (void)
static enum known_type | mapimg_server_tile_known (const struct tile *ptile, const struct player *pplayer, bool knowledge)
static struct terrain * | mapimg_server_tile_terrain (const struct tile *ptile, const struct player *pplayer, bool knowledge)
static struct player * | mapimg_server_tile_owner (const struct tile *ptile, const struct player *pplayer, bool knowledge)
static struct player * | mapimg_server_tile_city (const struct tile *ptile, const struct player *pplayer, bool knowledge)
static struct player * | mapimg_server_tile_unit (const struct tile *ptile, const struct player *pplayer, bool knowledge)
static int | mapimg_server_plrcolor_count (void)
static struct rgbcolor * | mapimg_server_plrcolor_get (int i)
static void | save_all_map_images (void)
static void | handle_observer_ready (struct connection *pconn)
static void | world_peace_update (void)
void | init_game_seed (void)
void | srv_init (void)
void | handle_client_info (struct connection *pc, enum gui_type gui, int emerg_version, const char *distribution)
enum server_states | server_state (void)
void | set_server_state (enum server_states newstate)
bool | game_was_started (void)
bool | check_for_game_over (void)
void | send_all_info (struct conn_list *dest)
static void | do_reveal_effects (void)
static void | do_have_contacts_effect (void)
static void | do_border_vision_effect (void)
static void | update_environmental_upset (enum environment_upset_type type, int *current, int *accum, int *level, int percent, void(*upset_action_fn)(int))
static void | notify_illegal_armistice_units (struct player *phost, struct player *pguest, int turns_left)
static void | remove_illegal_armistice_units (struct player *plr1, struct player *plr2)
static void | update_diplomatics (void)
static void | kill_dying_players (void)
static void | ai_start_phase (void)
static void | begin_turn (bool is_new_turn)
static void | begin_phase (bool is_new_phase)
static void | end_phase (void)
void | save_game_auto (const char *save_reason, enum autosave_type type)
void | start_game (void)
void fc__noreturn | server_quit (void)
void | handle_report_req (struct connection *pconn, enum report_type type)
void | identity_number_release (int id)
void | identity_number_reserve (int id)
static bool | identity_number_is_used (int id)
static int | increment_identity_number (void)
int | identity_number (void)
static bool | is_client_edit_packet (int type)
bool | server_packet_input (struct connection *pconn, void *packet, int type)
void | check_for_full_turn_done (void)
void | update_nations_with_startpos (void)
void | handle_nation_select_req (struct connection *pc, int player_no, Nation_type_id nation_no, bool is_male, const char *name, int style)
void | handle_player_ready (struct player *requestor, int player_no, bool is_ready)
const char * | aifill (int amount)
static void | player_set_nation_full (struct player *pplayer, struct nation_type *pnation)
void | player_nation_defaults (struct player *pplayer, struct nation_type *pnation, bool set_name)
static void | generate_players (void)
const char * | pick_random_player_name (const struct nation_type *pnation)
static void | srv_running (void)
static void | srv_prepare (void)
static void | srv_scores (void)
static void | final_ruleset_adjustments (void)
static void | srv_ready (void)
void | server_game_init (bool keep_ruleset_value)
void | server_game_free (void)
void fc__noreturn | srv_main (void)
static void | server_gui_color_free (struct color *pcolor)
static int | server_plr_tile_city_id_get (const struct tile *ptile, const struct player *pplayer)
server_setting_id | server_ss_by_name (const char *name)
const char * | server_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)
static bool | world_peace_turn (void)

## Variables

struct server_arguments | srvarg
struct civserver | server
static enum server_states | civserver_state = S_S_INITIAL
bool | force_end_of_sniff
bv_id | identity_numbers_used
static bool | has_been_srv_init = FALSE
static struct timer * | eot_timer = NULL
static struct timer * | between_turns = NULL

## Macro Definition Documentation

## ◆ SPECHASH_IKEY_TYPE

#define SPECHASH_IKEY_TYPE struct startpos *

Definition at line 2598 of file srv_main.c.

## ◆ SPECHASH_INT_DATA_TYPE

#define SPECHASH_INT_DATA_TYPE

Definition at line 2599 of file srv_main.c.

## ◆ SPECHASH_TAG

#define SPECHASH_TAG startpos

Tool for generate_players().

Definition at line 2597 of file srv_main.c.

## ◆ startpos_hash_iterate

#define startpos_hash_iterate | ( |  | hash,
|  |  | psp,
|  |  | c
| ) |  | TYPED_HASH_ITERATE(struct startpos *, intptr_t, hash, psp, c)

Definition at line 2601 of file srv_main.c.

## ◆ startpos_hash_iterate_end

#define startpos_hash_iterate_end HASH_ITERATE_END

Definition at line 2603 of file srv_main.c.

## Function Documentation

## ◆ ai_start_phase()

static void ai_start_phase | ( | void |  | ) |

static

Called at the start of each (new) phase to do AI activities.

Definition at line 1137 of file srv_main.c.

Referenced by begin_phase().

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

## ◆ announce_player()

static void announce_player | ( | struct player * | pplayer | ) |

static

Announce what nation player rules to everyone.

Definition at line 2869 of file srv_main.c.

Referenced by generate_players().

## ◆ begin_phase()

static void begin_phase | ( | bool | is_new_phase | ) |

static

Begin a phase of movement. This handles all beginning-of-phase actions for one or more players.

Definition at line 1259 of file srv_main.c.

Referenced by srv_running().

## ◆ begin_turn()

static void begin_turn | ( | bool | is_new_turn | ) |

static

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 1152 of file srv_main.c.

Referenced by srv_running().

## ◆ 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 2253 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 367 of file srv_main.c.

Referenced by srv_running().

## ◆ do_border_vision_effect()

static void do_border_vision_effect | ( | void |  | ) |

static

Handle the vision granting effect EFT_BORDER_VISION

Definition at line 801 of file srv_main.c.

Referenced by end_phase().

## ◆ do_have_contacts_effect()

static void do_have_contacts_effect | ( | void |  | ) |

static

Give contact to players with the EFT_HAVE_CONTACTS effect (traditionally from Marco Polo's Embassy).

Definition at line 784 of file srv_main.c.

Referenced by end_phase().

## ◆ do_reveal_effects()

static void do_reveal_effects | ( | void |  | ) |

static

Give map information to players with EFT_REVEAL_CITIES or EFT_REVEAL_MAP effects (traditionally from the Apollo Program).

Definition at line 761 of file srv_main.c.

Referenced by end_phase().

## ◆ end_phase()

static void end_phase | ( | void |  | ) |

static

End a phase of movement. This handles all end-of-phase actions for one or more players.

Definition at line 1437 of file srv_main.c.

Referenced by srv_running().

## ◆ end_turn()

static void end_turn | ( | void |  | ) |

static

Handle the end of each turn.

Definition at line 1603 of file srv_main.c.

Referenced by srv_running().

## ◆ fc_interface_init_server()

static void fc_interface_init_server | ( | void |  | ) |

static

Initialize server specific functions.

Definition at line 3741 of file srv_main.c.

Referenced by srv_init().

## ◆ final_ruleset_adjustments()

static void final_ruleset_adjustments | ( | void |  | ) |

static

Apply some final adjustments from the ruleset on to the game state. We cannot do this during ruleset loading, since some players may be added later than that.

Definition at line 3197 of file srv_main.c.

Referenced by srv_ready().

## ◆ game_was_started()

bool game_was_started | ( | void |  | ) |

Returns iff the game was started once upon a time.

Definition at line 353 of file srv_main.c.

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(), remove_player_command(), server_player_set_color(), set_rulesetdir(), sg_load_players(), sg_load_players(), sg_load_players_basic(), sg_load_players_basic(), sg_save_game(), sg_save_player_main(), sg_save_players(), split_player(), srv_main(), take_command(), team_command(), and update_nations_with_startpos().

## ◆ generate_players()

static void generate_players | ( | void |  | ) |

static

Assign random nations to players at game start. This includes human players, AI players created with "set aifill <X>", and players created with "create <PlayerName>".

If a player's name matches one of the leader names for some nation, and that nation is available, choose that nation, and set the leader sex appropriately. For example, when the Britons have not been chosen by anyone else, a player called Boudica whose nation has not been specified (for instance if they were created with "create Boudica") will become the Britons, and their sex will be female. Otherwise, the sex is chosen randomly, and the nation is chosen as below.

If this is a scenario and the scenario has specific start positions for some nations, try to pick those nations, favouring those with start positions which already-assigned players can't use. (Note that it's possible that we can't find enough nations with available start positions, depending on what nations players have already picked; in this case, it's OK to pick nations without start positions, as init_new_game() will fall back to mismatched start positions.)

Otherwise, pick available nations using pick_a_nation(), which tries to pick nations that look good with nations already in the game.

For 'aifill' players, the player name/sex is then reset to that of a random leader for the chosen nation.

Definition at line 2669 of file srv_main.c.

Referenced by srv_ready().

## ◆ handle_client_info()

void handle_client_info | ( | struct connection * | pc,
|  | enum gui_type | gui,
|  | int | emerg_version,
|  | const char * | distribution
| ) |  |

Handle client info packet

Definition at line 314 of file srv_main.c.

Referenced by server_handle_packet().

## ◆ handle_nation_select_req()

void handle_nation_select_req | ( | struct connection * | pc,
|  | int | player_no,
|  | Nation_type_id | nation_no,
|  | bool | is_male,
|  | const char * | name,
|  | int | style
| ) |  |

Handles a pick-nation packet from the client. These packets are handled by connection because ctrl users may edit anyone's nation in pregame, and editing is possible during a running game.

Definition at line 2367 of file srv_main.c.

Referenced by server_handle_packet().

## ◆ handle_observer_ready()

static void handle_observer_ready | ( | struct connection * | pconn | ) |

static

Handle a player-ready packet from global observer.

Definition at line 2433 of file srv_main.c.

Referenced by server_packet_input().

## ◆ handle_player_ready()

void handle_player_ready | ( | struct player * | requestor,
|  | int | player_no,
|  | bool | is_ready
| ) |  |

Handle a player-ready packet.

Definition at line 2449 of file srv_main.c.

Referenced by server_handle_packet(), and start_command().

## ◆ handle_report_req()

void handle_report_req | ( | struct connection * | pconn,
|  | enum report_type | type
| ) |  |

Handle request asking report to be sent to client.

Definition at line 1986 of file srv_main.c.

Referenced by server_handle_packet().

## ◆ 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 2059 of file srv_main.c.

Referenced by create_city(), and place_unit().

## ◆ identity_number_is_used()

static bool identity_number_is_used | ( | int | id | ) |

static

Check whether identity number is currently allocated.

Definition at line 2041 of file srv_main.c.

Referenced by identity_number().

## ◆ identity_number_release()

void identity_number_release | ( | int | id | ) |

Mark identity number free.

Definition at line 2025 of file srv_main.c.

Referenced by srv_init().

## ◆ identity_number_reserve()

void identity_number_reserve | ( | int | id | ) |

Mark identity number allocated.

Definition at line 2033 of file srv_main.c.

Referenced by identity_number(), server_game_init(), sg_load_player_cities(), sg_load_player_cities(), sg_load_player_units(), sg_load_player_units(), sg_load_player_vision(), and sg_load_player_vision().

## ◆ increment_identity_number()

static int increment_identity_number | ( | void |  | ) |

static

Increment identity_number and return result.

Definition at line 2049 of file srv_main.c.

Referenced by identity_number().

## ◆ init_game_seed()

void init_game_seed | ( | void |  | ) |

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

Definition at line 207 of file srv_main.c.

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

## ◆ is_client_edit_packet()

static bool is_client_edit_packet | ( | int | type | ) |

static

Returns TRUE if the packet type is an edit packet sent by the client.

NB: The first and last client edit packets here must match those defined in common/networking/packets.def.

Definition at line 2081 of file srv_main.c.

Referenced by server_packet_input().

## ◆ kill_dying_players()

static void kill_dying_players | ( | void |  | ) |

static

Check all players to see whether they are dying.

WARNING: do not call this while doing any handling of players, units, etc. If a player dies, all their units will be wiped and other data will be overwritten.

Definition at line 1111 of file srv_main.c.

Referenced by ai_start_phase(), end_phase(), and server_packet_input().

## ◆ mapimg_server_plrcolor_count()

static int mapimg_server_plrcolor_count | ( | void |  | ) |

static

Helper function for the mapimg module - number of player colors.

Definition at line 3858 of file srv_main.c.

Referenced by srv_prepare().

## ◆ mapimg_server_plrcolor_get()

static struct rgbcolor * mapimg_server_plrcolor_get | ( | int | i | ) |

static

Helper function for the mapimg module - one player color.

Definition at line 3866 of file srv_main.c.

Referenced by srv_prepare().

## ◆ mapimg_server_tile_city()

static struct player * mapimg_server_tile_city | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | bool | knowledge
| ) |  |

static

Helper function for the mapimg module - city owner.

Definition at line 3811 of file srv_main.c.

Referenced by srv_prepare().

## ◆ mapimg_server_tile_known()

static enum known_type mapimg_server_tile_known | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | bool | knowledge
| ) |  |

static

Helper function for the mapimg module - tile knowledge.

Definition at line 3766 of file srv_main.c.

Referenced by srv_prepare().

## ◆ mapimg_server_tile_owner()

static struct player * mapimg_server_tile_owner | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | bool | knowledge
| ) |  |

static

Helper function for the mapimg module - tile owner.

Definition at line 3795 of file srv_main.c.

Referenced by srv_prepare().

## ◆ mapimg_server_tile_terrain()

static struct terrain * mapimg_server_tile_terrain | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | bool | knowledge
| ) |  |

static

Helper function for the mapimg module - tile terrain.

Definition at line 3781 of file srv_main.c.

Referenced by srv_prepare().

## ◆ mapimg_server_tile_unit()

static struct player * mapimg_server_tile_unit | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | bool | knowledge
| ) |  |

static

Helper function for the mapimg module - unit owner.

Definition at line 3837 of file srv_main.c.

Referenced by srv_prepare().

## ◆ notify_illegal_armistice_units()

static void notify_illegal_armistice_units | ( | struct player * | phost,
|  | struct player * | pguest,
|  | int | turns_left
| ) |  |

static

Notify about units at risk of disband due to armistice.

Definition at line 866 of file srv_main.c.

Referenced by update_diplomatics().

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

## ◆ player_set_nation_full()

static void player_set_nation_full | ( | struct player * | pplayer,
|  | struct nation_type * | pnation
| ) |  |

static

Tool for generate_players().

Definition at line 2608 of file srv_main.c.

Referenced by generate_players().

## ◆ remove_illegal_armistice_units()

static void remove_illegal_armistice_units | ( | struct player * | plr1,
|  | struct player * | plr2
| ) |  |

static

Remove illegal units when armistice turns into peace treaty.

Definition at line 910 of file srv_main.c.

Referenced by update_diplomatics().

## ◆ save_all_map_images()

static void save_all_map_images | ( | void |  | ) |

static

Save all defined map images.

Definition at line 3874 of file srv_main.c.

Referenced by srv_running(), and srv_scores().

## ◆ save_game_auto()

void save_game_auto | ( | const char * | save_reason,
|  | enum autosave_type | type
| ) |  |

Save game with autosave filename

Definition at line 1836 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 729 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 3517 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 3493 of file srv_main.c.

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

## ◆ server_gui_color_free()

static void server_gui_color_free | ( | struct color * | pcolor | ) |

inlinestatic

Definition at line 3628 of file srv_main.c.

Referenced by fc_interface_init_server().

## ◆ 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 2090 of file srv_main.c.

Referenced by incoming_client_packets().

## ◆ server_plr_tile_city_id_get()

static int server_plr_tile_city_id_get | ( | const struct tile * | ptile,
|  | const struct player * | pplayer
| ) |  |

static

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 3639 of file srv_main.c.

Referenced by fc_interface_init_server().

## ◆ server_quit()

void fc__noreturn server_quit | ( | void |  | ) |

Quit the server and exit.

Definition at line 1914 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 3651 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 3666 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 3681 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 3726 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 3696 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 3711 of file srv_main.c.

Referenced by fc_interface_init_server(), and fc_interface_init_tool().

## ◆ server_state()

enum server_states server_state | ( | void |  | ) |

Return current server state.

Definition at line 337 of file srv_main.c.

Referenced by api_edit_tile_set_label(), autosaves_callback(), check_for_full_turn_done(), connection_attach_real(), dai_assess_danger_player(), end_command(), 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(), handle_ruleset_select(), load_command(), map_claim_border_ownership(), maxplayers_callback(), notify_conn_packet(), player_info_level(), player_set_to_ai_mode(), remove_shared_vision(), reset_all_start_commands(), reset_command(), send_city_info(), send_lanserver_response(), server_packet_input(), server_quit(), server_sniff_all_input(), setting_is_free_to_change(), sg_save_game(), show_players(), srv_main(), srv_running(), start_command(), start_game(), surrender_command(), timeout_action(), and update_tile_knowledge().

## ◆ set_server_state()

void set_server_state | ( | enum server_states | newstate | ) |

Set current server state.

Definition at line 345 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 231 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 3562 of file srv_main.c.

Referenced by main().

## ◆ srv_prepare()

static void srv_prepare | ( | void |  | ) |

static

Server initialization.

Definition at line 3066 of file srv_main.c.

Referenced by srv_main().

## ◆ srv_ready()

static void srv_ready | ( | void |  | ) |

static

Set up one game.

Definition at line 3223 of file srv_main.c.

Referenced by srv_main().

## ◆ srv_running()

static void srv_running | ( | void |  | ) |

static

Play the game! Returns when S_S_RUNNING != server_state().

Definition at line 2887 of file srv_main.c.

Referenced by srv_main().

## ◆ srv_scores()

static void srv_scores | ( | void |  | ) |

static

Score calculation.

Definition at line 3165 of file srv_main.c.

Referenced by srv_main().

## ◆ start_game()

void start_game | ( | void |  | ) |

Start actual game. Everything has been set up already.

Definition at line 1877 of file srv_main.c.

Referenced by start_command().

## ◆ update_diplomatics()

static void update_diplomatics | ( | void |  | ) |

static

Check for cease-fires and armistices running out; update cancelling reasons and contact information.

Definition at line 949 of file srv_main.c.

Referenced by end_turn().

## ◆ update_environmental_upset()

static void update_environmental_upset | ( | enum environment_upset_type | type,
|  | int * | current,
|  | int * | accum,
|  | int * | level,
|  | int | percent,
|  | void(*)(int) | upset_action_fn
| ) |  |

static

Handle environmental upsets, meaning currently pollution or fallout.

Definition at line 828 of file srv_main.c.

Referenced by end_turn().

## ◆ 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 2308 of file srv_main.c.

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

## ◆ world_peace_turn()

static bool world_peace_turn | ( | void |  | ) |

static

Does this turn count as world peace turn?

Definition at line 3895 of file srv_main.c.

Referenced by world_peace_update().

## ◆ world_peace_update()

static void world_peace_update | ( | void |  | ) |

static

Update world peace data.

Definition at line 3925 of file srv_main.c.

Referenced by end_turn().

## Variable Documentation

## ◆ between_turns

struct timer* between_turns = NULL

static

Definition at line 202 of file srv_main.c.

Referenced by server_quit(), and srv_running().

## ◆ civserver_state

enum server_states civserver_state = S_S_INITIAL

static

Definition at line 186 of file srv_main.c.

Referenced by server_state(), and set_server_state().

## ◆ eot_timer

struct timer* eot_timer = NULL

static

Definition at line 200 of file srv_main.c.

Referenced by server_quit(), srv_prepare(), and srv_running().

## ◆ force_end_of_sniff

bool force_end_of_sniff

Definition at line 192 of file srv_main.c.

Referenced by check_for_full_turn_done(), end_command(), server_sniff_all_input(), srv_running(), and start_game().

## ◆ has_been_srv_init

bool has_been_srv_init = FALSE

static

Definition at line 197 of file srv_main.c.

Referenced by srv_init(), and srv_prepare().

## ◆ identity_numbers_used

bv_id identity_numbers_used

Definition at line 194 of file srv_main.c.

Referenced by identity_number_is_used(), identity_number_release(), identity_number_reserve(), and server_game_init().

## ◆ server

struct civserver server

Definition at line 183 of file srv_main.c.

## ◆ srvarg

struct server_arguments srvarg

Definition at line 180 of file srv_main.c.

Referenced by auth_user(), 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(), main(), mapimg_command(), meta_addr_port(), metaserver_command(), rank_users(), reset_command(), save_all_map_images(), save_game(), script_fcdb_init(), send_lanserver_response(), server_open_socket(), server_quit(), server_sniff_all_input(), set_rulesetdir(), sg_load_game(), sg_load_game(), sg_save_game(), show_serverid(), srv_init(), srv_main(), srv_prepare(), srv_ready(), srv_scores(), and write_init_script().