Freeciv21
Develop your civilization from humble roots to a global empire
client_main.h File Reference
#include "packets.h"
+ Include dependency graph for client_main.h:

Go to the source code of this file.

Classes

struct  civclient
 

Macros

#define TIMER_INTERVAL   (int) (real_timer_callback() * 1000)
 

Enumerations

enum  client_states {
  C_S_INITIAL , C_S_DISCONNECTED , C_S_PREPARING , C_S_RUNNING ,
  C_S_OVER
}
 

Functions

int client_main (int argc, char *argv[])
 Entry point for common client code. More...
 
void client_packet_input (void *packet, int type)
 Handle packet received from server. More...
 
void send_report_request (enum report_type type)
 Send request for some report to server. More...
 
void send_attribute_block_request ()
 Send attribute block. More...
 
void send_turn_done ()
 Send information about player having finished his/her turn to server. More...
 
void user_ended_turn ()
 Handle user ending his/her turn. More...
 
void set_client_state (enum client_states newstate)
 Change client state. More...
 
enum client_states client_state ()
 Return current client state. More...
 
void set_server_busy (bool busy)
 Sets if server is considered busy. More...
 
bool is_server_busy ()
 Returns if server is considered busy at the moment. More...
 
void client_remove_cli_conn (struct connection *pconn)
 Remove pconn from all connection lists in client, then free it. More...
 
void client_remove_all_cli_conn ()
 Remove (and free) all connections from all connection lists in client. More...
 
QUrl & client_url ()
 Returns the URL that this client connects to. More...
 
bool client_is_observer ()
 Returns whether client is observer. More...
 
bool client_is_global_observer ()
 Returns whether client is global observer. More...
 
int client_player_number ()
 Returns number of player attached to client. More...
 
bool client_has_player ()
 Either controlling or observing. More...
 
struct playerclient_player ()
 Either controlling or observing. More...
 
bool client_map_is_known_and_seen (const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
 Return the vision of the player on a tile. More...
 
void set_miliseconds_to_turndone (int miliseconds)
 Reset the number of seconds to turndone from an "authentic" source. More...
 
int get_seconds_to_turndone ()
 Return the number of seconds until turn-done. More...
 
bool is_waiting_turn_change ()
 Are we in turn-change wait state? More...
 
void start_turn_change_wait ()
 Start waiting of the server turn change activities. More...
 
void stop_turn_change_wait ()
 Server is responsive again. More...
 
int get_seconds_to_new_turn ()
 Return the number of seconds until turn-done. More...
 
double real_timer_callback ()
 This function should be called at least once per second. More...
 
bool can_client_control ()
 Returns TRUE iff the client can control player. More...
 
bool can_client_issue_orders ()
 Returns TRUE iff the client can issue orders (such as giving unit commands). More...
 
bool can_client_change_view ()
 Return TRUE if the client can change the view; i.e. More...
 
bool can_meet_with_player (const struct player *pplayer)
 Returns TRUE iff the client can do diplomatic meetings with another given player. More...
 
void client_exit ()
 Main client execution stop function. More...
 
bool is_client_quitting ()
 Is the client marked as one going down? More...
 
void start_quitting ()
 Mark client as one going to quit as soon as possible,. More...
 

Variables

QString logfile
 
QString scriptfile
 
QString savefile
 
QString sound_plugin_name
 
QString sound_set_name
 
QString music_set_name
 
QString cmd_metaserver
 
bool auto_connect
 
bool auto_spawn
 
bool waiting_for_end_turn
 
struct civclient client
 
const char *const gui_character_encoding
 
const bool gui_use_transliteration
 

Macro Definition Documentation

◆ TIMER_INTERVAL

#define TIMER_INTERVAL   (int) (real_timer_callback() * 1000)

Definition at line 26 of file client_main.h.

Enumeration Type Documentation

◆ client_states

Enumerator
C_S_INITIAL 
C_S_DISCONNECTED 
C_S_PREPARING 
C_S_RUNNING 
C_S_OVER 

Definition at line 39 of file client_main.h.

Function Documentation

◆ can_client_change_view()

◆ can_client_control()

bool can_client_control ( )

Returns TRUE iff the client can control player.

Definition at line 1146 of file client_main.cpp.

Referenced by can_client_issue_orders(), draw_calculated_trade_routes(), page_pregame::slot_pregame_start(), page_pregame::update_buttons(), and voteinfo_do_vote().

◆ can_client_issue_orders()

bool can_client_issue_orders ( )

Returns TRUE iff the client can issue orders (such as giving unit commands).

This function should be called each time before allowing the user to give an order.

Definition at line 1156 of file client_main.cpp.

Referenced by action_decision_request(), freeciv::improvement_seller::add_to_menu(), adjust_workers_button_pressed(), city_dialog::buy(), can_end_turn(), can_meet_with_player(), city_can_buy(), city_packet_common(), city_dialog::city_rename(), city_dialog::clear_worklist(), clipboard_copy_production(), clipboard_paste_production(), city_dialog::cma_double_clicked(), science_report::current_tech_changed(), disband_all_units(), city_widget::display_list_menu(), city_dialog::display_worklist_menu(), do_disband_alternative(), do_map_click(), science_report::goal_tech_changed(), handle_city_name_suggestion_info(), handle_city_sabotage_list(), diplo_dlg::init(), freeciv::upkeep_widget::item_double_clicked(), maybe_activate_keyboardless_goto(), mr_menu::menus_sensitive(), city_label::mousePressEvent(), plr_widget::mousePressEvent(), research_diagram::mousePressEvent(), freeciv::improvement_seller::operator()(), popup_multiplier_dialog(), science_report::push_research(), request_new_unit_activity_targeted(), request_orders_cleared(), request_unit_load(), request_unit_unload(), unit_list_widget::selected_playable_units(), sell_all_improvements(), set_government_choice(), spaceship_autoplace(), city_dialog::update_disabled(), city_dialog::update_prod_buttons(), plr_report::update_report(), upgrade_canvas_clipboard(), wakeup_button_pressed(), and wakeup_sentried_units().

◆ can_meet_with_player()

bool can_meet_with_player ( const struct player pplayer)

Returns TRUE iff the client can do diplomatic meetings with another given player.

Definition at line 1165 of file client_main.cpp.

Referenced by plr_report::update_report().

◆ client_exit()

void client_exit ( )

Main client execution stop function.

This calls ui_exit() and not the other way around.

Definition at line 658 of file client_main.cpp.

Referenced by client_main().

◆ client_has_player()

◆ client_is_global_observer()

◆ client_is_observer()

◆ client_main()

int client_main ( int  argc,
char *  argv[] 
)

Entry point for common client code.

Definition at line 302 of file client_main.cpp.

Referenced by main().

◆ client_map_is_known_and_seen()

bool client_map_is_known_and_seen ( const struct tile ptile,
const struct player pplayer,
enum vision_layer  vlayer 
)

Return the vision of the player on a tile.

Client version of ./server/maphand/map_is_known_and_seen().

Definition at line 1236 of file client_main.cpp.

Referenced by fc_interface_init_client().

◆ client_packet_input()

void client_packet_input ( void *  packet,
int  type 
)

Handle packet received from server.

Definition at line 699 of file client_main.cpp.

Referenced by input_from_server().

◆ client_player()

struct player* client_player ( )

Either controlling or observing.

Definition at line 1230 of file client_main.cpp.

Referenced by trade_generator::add_tile(), diplo_wdg::all_advances(), attribute_flush(), attribute_restore(), city_dialog::buy(), center_next_enemy_city(), center_next_player_capital(), center_next_player_city(), center_on_something(), city_packet_common(), client_city_can_work_tile(), client_plr_tile_city_id_get(), client_remove_unit(), client_research_sprite(), client_state(), collect_eventually_buildable_targets(), collect_production_targets(), control_mouse_cursor(), cycle_enemy_units(), city_widget::display_list_menu(), do_disband_alternative(), draw_reqtree(), draw_trade_routes(), editor_apply_tool(), editor_grab_applied_player(), editor_grab_tool(), enter_goto_state(), freeciv::layer_grid::fill_sprite_array(), mr_menu::find_last_unit_pos(), find_nearest_unit(), get_act_sel_action_custom_text(), get_airlift_text(), get_bulbs_per_turn(), get_edge_type(), get_info_label_text_popup(), get_science_goal_text(), get_science_target_text(), get_units_upgrade_info(), get_units_view_data(), diplo_wdg::give_advance(), diplo_wdg::give_city(), handle_achievement_info(), handle_city_name_suggestion_info(), handle_city_sabotage_list(), handle_endgame_player(), handle_event(), handle_page_msg(), handle_player_attribute_chunk(), handle_player_diplstate(), handle_player_info(), handle_player_remove(), handle_research_info(), handle_spaceship_info(), handle_unit_action_answer(), handle_unit_packet_common(), handle_unit_remove(), unit_hud_selector::island_filter(), key_center_capital(), science_report::locate_goal(), science_report::locate_researching(), make_path_orders(), manual_turn_done_callback(), meswin_add(), research_diagram::mousePressEvent(), multipler_rates_dialog::multipler_rates_dialog(), plr_widget::nation_selected(), node_rectangle_minimum_size(), simple_citybar_painter::paint(), traditional_citybar_painter::paint(), polished_citybar_painter::paint(), pregame_options::pick_nation(), city_model::populate(), popup_bribe_dialog(), popup_incite_dialog(), popup_info_text(), science_report::push_research(), real_science_report_dialog_update(), request_units_return(), research_diagram::reset(), mr_menu::save_image(), science_dialog_text(), unit_hud_selector::select_units(), unit_list_widget::selected_playable_units(), send_rally_tile(), map_view::shortcut_pressed(), diplo_wdg::show_menu(), show_new_turn_info(), mr_menu::slot_execute_orders(), page_pregame::slot_pregame_start(), top_bar_right_click_science(), unit_hud_selector::uhs_select(), unit_description(), page_pregame::update_buttons(), pregame_options::update_buttons(), goto_dialog::update_dlg(), science_report::update_report(), plr_report::update_report(), pageGame::updateSidebarTooltips(), and units_view::upgrade_units().

◆ client_player_number()

int client_player_number ( )

Returns number of player attached to client.

Definition at line 1214 of file client_main.cpp.

Referenced by diplo_wdg::diplo_wdg(), and editor_apply_tool().

◆ client_remove_all_cli_conn()

void client_remove_all_cli_conn ( )

Remove (and free) all connections from all connection lists in client.

Assumes game.all_connections is properly maintained with all connections.

Definition at line 973 of file client_main.cpp.

Referenced by client_exit(), and client_state().

◆ client_remove_cli_conn()

void client_remove_cli_conn ( struct connection pconn)

Remove pconn from all connection lists in client, then free it.

Definition at line 955 of file client_main.cpp.

Referenced by client_remove_all_cli_conn(), and handle_conn_info().

◆ client_state()

◆ client_url()

◆ get_seconds_to_new_turn()

int get_seconds_to_new_turn ( )

Return the number of seconds until turn-done.

Don't call this unless current_turn_timeout() != 0.

Definition at line 1077 of file client_main.cpp.

Referenced by turn_done_button::update_timeout_label().

◆ get_seconds_to_turndone()

int get_seconds_to_turndone ( )

Return the number of seconds until turn-done.

Don't call this unless current_turn_timeout() != 0.

Definition at line 1063 of file client_main.cpp.

Referenced by turn_done_button::update_timeout_label().

◆ is_client_quitting()

bool is_client_quitting ( )

Is the client marked as one going down?

Definition at line 1503 of file client_main.cpp.

Referenced by client_state().

◆ is_server_busy()

bool is_server_busy ( )

Returns if server is considered busy at the moment.

Definition at line 1201 of file client_main.cpp.

Referenced by can_end_turn(), and control_mouse_cursor().

◆ is_waiting_turn_change()

bool is_waiting_turn_change ( )

Are we in turn-change wait state?

Definition at line 1037 of file client_main.cpp.

Referenced by real_menus_update(), and turn_done_button::update_timeout_label().

◆ real_timer_callback()

double real_timer_callback ( )

This function should be called at least once per second.

It does various updates (idle animations and timeout updates). It returns the number of seconds until it should be called again.

Definition at line 1084 of file client_main.cpp.

Referenced by fc_client::timerEvent().

◆ send_attribute_block_request()

void send_attribute_block_request ( )

Send attribute block.

Definition at line 991 of file client_main.cpp.

◆ send_report_request()

void send_report_request ( enum report_type  type)

Send request for some report to server.

Definition at line 754 of file client_main.cpp.

Referenced by mr_menu::slot_achievements(), mr_menu::slot_demographics(), mr_menu::slot_top_five(), and mr_menu::slot_traveler().

◆ send_turn_done()

void send_turn_done ( )

Send information about player having finished his/her turn to server.

Definition at line 725 of file client_main.cpp.

Referenced by key_end_turn(), update_turn_done_button_state(), and user_ended_turn().

◆ set_client_state()

void set_client_state ( enum client_states  newstate)

◆ set_miliseconds_to_turndone()

void set_miliseconds_to_turndone ( int  miliseconds)

Reset the number of seconds to turndone from an "authentic" source.

The seconds are taken as a double even though most callers will just know an integer value.

Definition at line 1022 of file client_main.cpp.

Referenced by handle_new_year(), and handle_timeout_info().

◆ set_server_busy()

void set_server_busy ( bool  busy)

Sets if server is considered busy.

Currently it is considered busy between turns.

Definition at line 1187 of file client_main.cpp.

Referenced by client_state(), handle_end_turn(), handle_server_join_reply(), and handle_start_phase().

◆ start_quitting()

void start_quitting ( )

Mark client as one going to quit as soon as possible,.

Definition at line 1508 of file client_main.cpp.

Referenced by popup_quit_dialog().

◆ start_turn_change_wait()

void start_turn_change_wait ( )

Start waiting of the server turn change activities.

Definition at line 1042 of file client_main.cpp.

Referenced by handle_end_turn().

◆ stop_turn_change_wait()

void stop_turn_change_wait ( )

Server is responsive again.

Definition at line 1053 of file client_main.cpp.

Referenced by disconnect_from_server(), and handle_begin_turn().

◆ user_ended_turn()

void user_ended_turn ( )

Handle user ending his/her turn.

Definition at line 720 of file client_main.cpp.

Referenced by handle_player_info(), handle_start_phase(), and manual_turn_done_callback().

Variable Documentation

◆ auto_connect

bool auto_connect
extern

Definition at line 132 of file client_main.cpp.

Referenced by client_main(), client_state(), and handle_server_join_reply().

◆ auto_spawn

bool auto_spawn
extern

Definition at line 134 of file client_main.cpp.

Referenced by client_main(), and client_state().

◆ client

struct civclient client

◆ cmd_metaserver

QString cmd_metaserver
extern

Definition at line 131 of file client_main.cpp.

Referenced by begin_metaserver_scan(), client_main(), and meta_read_response().

◆ gui_character_encoding

const char* const gui_character_encoding
extern

Definition at line 47 of file gui_main.cpp.

Referenced by client_main().

◆ gui_use_transliteration

const bool gui_use_transliteration
extern

Definition at line 46 of file gui_main.cpp.

Referenced by client_main().

◆ logfile

QString logfile
extern

Definition at line 124 of file client_main.cpp.

Referenced by client_main(), and client_start_server().

◆ music_set_name

◆ savefile

QString savefile
extern

Definition at line 126 of file client_main.cpp.

Referenced by client_main(), and client_start_server().

◆ scriptfile

QString scriptfile
extern

Definition at line 125 of file client_main.cpp.

Referenced by client_main(), and client_start_server().

◆ sound_plugin_name

QString sound_plugin_name
extern

Definition at line 128 of file client_main.cpp.

Referenced by audio_restart(), and client_main().

◆ sound_set_name

◆ waiting_for_end_turn

bool waiting_for_end_turn
extern

Definition at line 142 of file client_main.cpp.

Referenced by send_turn_done(), and update_turn_done_button_state().