Freeciv21
Develop your civilization from humble roots to a global empire
packhand.cpp File Reference
#include <fc_config.h>
#include <QBitArray>
#include <QDateTime>
#include <cstring>
#include "bitvector.h"
#include "fcintl.h"
#include "log.h"
#include "rand.h"
#include "support.h"
#include "fc_version.h"
#include "achievements.h"
#include "actions.h"
#include "capability.h"
#include "capstr.h"
#include "citizens.h"
#include "events.h"
#include "extras.h"
#include "game.h"
#include "government.h"
#include "helpdata.h"
#include "idex.h"
#include "map.h"
#include "movement.h"
#include "multipliers.h"
#include "name_translation.h"
#include "nation.h"
#include "packets.h"
#include "packhand_gen.h"
#include "player.h"
#include "research.h"
#include "rgbcolor.h"
#include "road.h"
#include "spaceship.h"
#include "specialist.h"
#include "style.h"
#include "tile.h"
#include "traderoutes.h"
#include "unit.h"
#include "unitlist.h"
#include "workertask.h"
#include "worklist.h"
#include "citydlg_g.h"
#include "cityrep_g.h"
#include "dialogs_g.h"
#include "gui_main_g.h"
#include "mapctrl_g.h"
#include "mapview_g.h"
#include "menu_g.h"
#include "pages_g.h"
#include "ratesdlg_g.h"
#include "repodlgs_g.h"
#include "spaceshipdlg_g.h"
#include "voteinfo_bar_g.h"
#include "attribute.h"
#include "audio/audio.h"
#include "chatline_common.h"
#include "citydlg.h"
#include "citydlg_common.h"
#include "client_main.h"
#include "climap.h"
#include "climisc.h"
#include "connectdlg_common.h"
#include "control.h"
#include "editor.h"
#include "goto.h"
#include "governor.h"
#include "helpdlg.h"
#include "messagewin_common.h"
#include "music.h"
#include "options.h"
#include "overview_common.h"
#include "page_game.h"
#include "qtg_cxxside.h"
#include "tileset/tilespec.h"
#include "update_queue.h"
#include "views/view_map.h"
#include "views/view_map_common.h"
#include "views/view_nations_data.h"
#include "voteinfo.h"
#include "script_client.h"
#include "packhand.h"

Go to the source code of this file.

Macros

#define VALIDATE(_count, _maximum, _string)
 
#define VALIDATE(_count, _maximum, _string)
 

Functions

static void city_packet_common (struct city *pcity, struct tile *pcenter, struct player *powner, struct tile_list *worked_tiles, bool is_new, bool popup, bool investigate)
 A helper function for handling city-info and city-short-info packets. More...
 
static bool handle_unit_packet_common (struct unit *packet_unit)
 Called to do basic handling for a unit_info or short_unit_info packet. More...
 
void packhand_free ()
 Called below, and by client/client_main.c client_game_free() More...
 
static void packhand_init ()
 Called only by handle_map_info() below. More...
 
static struct unitunpackage_unit (const struct packet_unit_info *packet)
 Unpackage the unit information into a newly allocated unit structure. More...
 
static struct unitunpackage_short_unit (const struct packet_unit_short_info *packet)
 Unpackage a short_unit_info packet. More...
 
void handle_server_join_reply (bool you_can_join, const char *message, const char *capability, const char *challenge_file, int conn_id)
 After we send a join packet to the server we receive a reply. More...
 
void handle_city_remove (int city_id)
 Handles a remove-city packet, used by the server to tell us any time a city is no longer there. More...
 
void handle_unit_remove (int unit_id)
 Handle a remove-unit packet, sent by the server to tell us any time a unit is no longer there. More...
 
void handle_nuke_tile_info (int tile)
 The tile (x,y) has been nuked! More...
 
void handle_team_name_info (int team_id, const char *team_name)
 The name of team 'team_id'. More...
 
void handle_unit_combat_info (const struct packet_unit_combat_info *packet)
 A combat packet. More...
 
void handle_unit_bombard_info (int attacker_unit_id, int target_tile_id)
 A bombardment packet. More...
 
static bool update_improvement_from_packet (struct city *pcity, struct impr_type *pimprove, bool have_impr)
 Updates a city's list of improvements from packet data. More...
 
void handle_city_info (const struct packet_city_info *packet)
 A city-info packet contains all information about a city. More...
 
void handle_traderoute_info (const struct packet_traderoute_info *packet)
 A traderoute-info packet contains information about one end of a traderoute. More...
 
void handle_city_short_info (const struct packet_city_short_info *packet)
 A city-short-info packet is sent to tell us about any cities we can't see the internals of. More...
 
void handle_worker_task (const struct packet_worker_task *packet)
 Handle worker task assigned to the city. More...
 
void handle_new_year (int year, int fragments, int turn)
 Handle turn and year advancement. More...
 
void handle_end_phase ()
 Called by the network code when an end-phase packet is received. More...
 
void handle_start_phase (int phase)
 Called by the network code when an start-phase packet is received. More...
 
void handle_begin_turn ()
 Called when begin-turn packet is received. More...
 
void handle_end_turn ()
 Called when end-turn packet is received. More...
 
void play_sound_for_event (enum event_type type)
 Plays sound associated with event. More...
 
void handle_chat_msg (const struct packet_chat_msg *packet)
 Handle a message packet. More...
 
void handle_early_chat_msg (const struct packet_early_chat_msg *packet)
 Handle an early message packet. More...
 
void handle_connect_msg (const char *message)
 Handle a connect message packet. More...
 
void handle_server_info (const char *version_label, int major_version, int minor_version, int patch_version, int emerg_version)
 Handle server info packet. More...
 
void handle_page_msg (const char *caption, const char *headline, enum event_type event, int len, int parts)
 Page_msg header handler. More...
 
void handle_page_msg_part (const char *lines)
 Page_msg part handler. More...
 
void handle_unit_info (const struct packet_unit_info *packet)
 Packet unit_info. More...
 
void handle_unit_short_info (const struct packet_unit_short_info *packet)
 Receive a short_unit info packet. More...
 
void handle_set_topology (int topology_id)
 Server requested topology change. More...
 
void handle_map_info (int xsize, int ysize, int topology_id)
 Receive information about the map size and topology from the server. More...
 
void handle_game_info (const struct packet_game_info *pinfo)
 Packet game_info handler. More...
 
void handle_calendar_info (const struct packet_calendar_info *pcalendar)
 Packet calendar_info handler. More...
 
void handle_timeout_info (float seconds_to_phasedone, float last_turn_change_time)
 Sets the remaining turn time. More...
 
void set_government_choice (struct government *government)
 Sets the target government. More...
 
void start_revolution ()
 Begin a revolution by telling the server to start it. More...
 
void handle_player_remove (int playerno)
 Handle a notification that the player slot identified by 'playerno' has become unused. More...
 
void handle_player_info (const struct packet_player_info *pinfo)
 Handle information about a player. More...
 
void handle_research_info (const struct packet_research_info *packet)
 Receive a research info packet. More...
 
void handle_player_diplstate (const struct packet_player_diplstate *packet)
 Packet player_diplstate handler. More...
 
void handle_conn_info (const struct packet_conn_info *pinfo)
 Remove, add, or update dummy connection struct representing some connection to the server, with info from packet_conn_info. More...
 
void handle_conn_ping_info (int connections, const int *conn_id, const float *ping_time)
 Handles a conn_ping_info packet from the server. More...
 
void handle_achievement_info (int id, bool gained, bool first)
 Received package about gaining an achievement. More...
 
static bool spaceship_autoplace (struct player *pplayer, struct player_spaceship *ship)
 Ideally the client should let the player choose which type of modules and components to build, and (possibly) where to extend structurals. More...
 
void handle_spaceship_info (const struct packet_spaceship_info *p)
 Packet spaceship_info handler. More...
 
void handle_tile_info (const struct packet_tile_info *packet)
 Packet tile_info handler. More...
 
void handle_scenario_info (const struct packet_scenario_info *packet)
 Received packet containing info about current scenario. More...
 
void handle_scenario_description (const char *description)
 Received packet containing description of current scenario. More...
 
void handle_ruleset_control (const struct packet_ruleset_control *packet)
 Take arrival of ruleset control packet to indicate that current allocated governments should be free'd, and new memory allocated for new size. More...
 
void handle_ruleset_summary (const struct packet_ruleset_summary *packet)
 Ruleset summary. More...
 
void handle_ruleset_description_part (const struct packet_ruleset_description_part *packet)
 Next part of ruleset description. More...
 
void handle_rulesets_ready ()
 Received packet indicating that all rulesets have now been received. More...
 
void handle_ruleset_unit_class (const struct packet_ruleset_unit_class *p)
 Packet ruleset_unit_class handler. More...
 
void handle_ruleset_unit (const struct packet_ruleset_unit *p)
 Packet ruleset_unit handler. More...
 
void handle_ruleset_unit_bonus (const struct packet_ruleset_unit_bonus *p)
 Packet ruleset_unit_bonus handler. More...
 
void handle_ruleset_unit_flag (const struct packet_ruleset_unit_flag *p)
 Packet ruleset_unit_flag handler. More...
 
void handle_ruleset_unit_class_flag (const struct packet_ruleset_unit_class_flag *p)
 Packet ruleset_unit_class_flag handler. More...
 
static int unpack_tech_req (const enum tech_req r_num, const int reqs_size, const struct requirement *reqs, struct advance *a, int i)
 Unpack a traditional tech req from a standard requirement vector (that still is in the network serialized format rather than a proper requirement vector). More...
 
void handle_ruleset_tech (const struct packet_ruleset_tech *p)
 Packet ruleset_tech handler. More...
 
void handle_ruleset_tech_class (const struct packet_ruleset_tech_class *p)
 Packet ruleset_tech_class handler. More...
 
void handle_ruleset_tech_flag (const struct packet_ruleset_tech_flag *p)
 Packet ruleset_tech_flag handler. More...
 
void handle_ruleset_building (const struct packet_ruleset_building *p)
 Packet ruleset_building handler. More...
 
void handle_ruleset_multiplier (const struct packet_ruleset_multiplier *p)
 Packet ruleset_multiplier handler. More...
 
void handle_ruleset_government (const struct packet_ruleset_government *p)
 Packet ruleset_government handler. More...
 
void handle_ruleset_government_ruler_title (const struct packet_ruleset_government_ruler_title *packet)
 Packet ruleset_government_ruler_title handler. More...
 
void handle_ruleset_terrain (const struct packet_ruleset_terrain *p)
 Packet ruleset_terrain handler. More...
 
void handle_ruleset_terrain_flag (const struct packet_ruleset_terrain_flag *p)
 Packet ruleset_terrain_flag handler. More...
 
void handle_ruleset_resource (const struct packet_ruleset_resource *p)
 Handle a packet about a particular terrain resource. More...
 
void handle_ruleset_extra (const struct packet_ruleset_extra *p)
 Handle a packet about a particular extra type. More...
 
void handle_ruleset_extra_flag (const struct packet_ruleset_extra_flag *p)
 Packet ruleset_extra_flag handler. More...
 
void handle_ruleset_base (const struct packet_ruleset_base *p)
 Handle a packet about a particular base type. More...
 
void handle_ruleset_road (const struct packet_ruleset_road *p)
 Handle a packet about a particular road type. More...
 
void handle_ruleset_goods (const struct packet_ruleset_goods *p)
 Handle a packet about a particular goods type. More...
 
void handle_ruleset_action (const struct packet_ruleset_action *p)
 Handle a packet about a particular action. More...
 
void handle_ruleset_action_enabler (const struct packet_ruleset_action_enabler *p)
 Handle a packet about a particular action enabler. More...
 
void handle_ruleset_action_auto (const struct packet_ruleset_action_auto *p)
 Handle a packet about a particular action auto performer rule. More...
 
void handle_ruleset_disaster (const struct packet_ruleset_disaster *p)
 Handle a packet about a particular disaster type. More...
 
void handle_ruleset_achievement (const struct packet_ruleset_achievement *p)
 Handle a packet about a particular achievement type. More...
 
void handle_ruleset_trade (const struct packet_ruleset_trade *p)
 Handle a packet about a particular trade route type. More...
 
void handle_ruleset_terrain_control (const struct packet_ruleset_terrain_control *p)
 Handle the terrain control ruleset packet sent by the server. More...
 
void handle_ruleset_nation_sets (const struct packet_ruleset_nation_sets *packet)
 Handle the list of nation sets, sent as part of the ruleset. More...
 
void handle_ruleset_nation_groups (const struct packet_ruleset_nation_groups *packet)
 Handle the list of nation groups, sent as part of the ruleset. More...
 
void handle_ruleset_nation (const struct packet_ruleset_nation *packet)
 Handle initial ruleset nation info. More...
 
void handle_nation_availability (int ncount, const bool *is_pickable, bool nationset_change)
 Handle nation availability info. More...
 
void handle_ruleset_style (const struct packet_ruleset_style *p)
 Handle a packet about a particular style. More...
 
void handle_ruleset_clause (const struct packet_ruleset_clause *p)
 Handle a packet about a particular clause. More...
 
void handle_ruleset_city (const struct packet_ruleset_city *packet)
 Handle city style packet. More...
 
void handle_ruleset_music (const struct packet_ruleset_music *packet)
 Handle music style packet. More...
 
void handle_ruleset_game (const struct packet_ruleset_game *packet)
 Packet ruleset_game handler. More...
 
void handle_ruleset_specialist (const struct packet_ruleset_specialist *p)
 Handle info about a single specialist. More...
 
void handle_city_name_suggestion_info (int unit_id, const char *name)
 Handle reply to our city name request. More...
 
void handle_unit_action_answer (int actor_id, int target_id, int cost, action_id action_type, bool disturb_player)
 Handle the requested follow up question about an action. More...
 
static action_id auto_attack_act (const struct act_prob *act_probs)
 Returns a possibly legal attack action iff it is the only interesting action that currently is legal. More...
 
void handle_unit_actions (const struct packet_unit_actions *packet)
 Handle reply to possible actions. More...
 
void handle_city_sabotage_list (int actor_id, int city_id, bv_imprs improvements, action_id act_id, bool disturb_player)
 Handle list of potenttial buildings to sabotage. More...
 
void handle_endgame_report (const struct packet_endgame_report *packet)
 Pass the header information about things be displayed in a gui-specific endgame dialog. More...
 
void handle_endgame_player (const struct packet_endgame_player *packet)
 Pass endgame report about single player. More...
 
void handle_player_attribute_chunk (const struct packet_player_attribute_chunk *packet)
 Packet player_attribute_chunk handler. More...
 
void handle_processing_started ()
 Handle request to start processing packet. More...
 
void handle_processing_finished ()
 Handle request to stop processing packet. More...
 
void notify_about_incoming_packet (struct connection *pc, int packet_type, int size)
 Notify interested parties about incoming packet. More...
 
void notify_about_outgoing_packet (struct connection *pc, int packet_type, int size, int request_id)
 Notify interested parties about outgoing packet. More...
 
void handle_freeze_client ()
 We have received PACKET_FREEZE_CLIENT. More...
 
void handle_thaw_client ()
 We have received PACKET_THAW_CLIENT. More...
 
void handle_conn_ping ()
 Reply to 'ping' packet with 'pong'. More...
 
void handle_server_shutdown ()
 Handle server shutdown. More...
 
void handle_ruleset_effect (const struct packet_ruleset_effect *packet)
 Add effect data to ruleset cache. More...
 
void handle_edit_object_created (int tag, int id)
 Handle a notification from the server that an object was successfully created. More...
 
void handle_edit_startpos (const struct packet_edit_startpos *packet)
 Handle start position creation/removal. More...
 
void handle_edit_startpos_full (const struct packet_edit_startpos_full *packet)
 Handle start position internal information. More...
 
void handle_vote_remove (int vote_no)
 A vote no longer exists. More...
 
void handle_vote_update (int vote_no, int yes, int no, int abstain, int num_voters)
 Find and update the corresponding vote and refresh the GUI. More...
 
void handle_vote_new (const struct packet_vote_new *packet)
 Create a new vote and add it to the queue. More...
 
void handle_vote_resolve (int vote_no, bool passed)
 Update the vote's status and refresh the GUI. More...
 
void handle_play_music (const char *tag)
 Play suitable music. More...
 

Variables

struct {
   struct city_list *   cities
 
   struct player *   placeholder
 
invisible = {.cities = nullptr, .placeholder = nullptr}
 
struct {
   int   len
 
   enum event_type   event
 
   char *   caption
 
   char *   headline
 
   char *   lines
 
   int   parts
 
page_msg_report = {.parts = 0}
 
QString forced_tileset_name
 
static int last_turn = 0
 

Macro Definition Documentation

◆ VALIDATE [1/2]

#define VALIDATE (   _count,
  _maximum,
  _string 
)
Value:
if (game.info._count > _maximum) { \
qCritical("handle_game_info(): Too many " _string "; using %d of %d", \
_maximum, game.info._count); \
game.info._count = _maximum; \
}
struct civ_game game
Definition: game.cpp:47
struct packet_game_info info
Definition: game.h:80

◆ VALIDATE [2/2]

#define VALIDATE (   _count,
  _maximum,
  _string 
)
Value:
if (game.control._count > _maximum) { \
qCritical("handle_ruleset_control(): Too many " _string \
"; using %d of %d", \
_maximum, game.control._count); \
game.control._count = _maximum; \
}
struct packet_ruleset_control control
Definition: game.h:74

Function Documentation

◆ auto_attack_act()

static action_id auto_attack_act ( const struct act_prob act_probs)
static

Returns a possibly legal attack action iff it is the only interesting action that currently is legal.

Definition at line 4821 of file packhand.cpp.

Referenced by handle_unit_actions().

◆ city_packet_common()

static void city_packet_common ( struct city pcity,
struct tile pcenter,
struct player powner,
struct tile_list *  worked_tiles,
bool  is_new,
bool  popup,
bool  investigate 
)
static

A helper function for handling city-info and city-short-info packets.

Naturally, both require many of the same operations to be done on the data.

Definition at line 993 of file packhand.cpp.

Referenced by handle_city_info(), and handle_city_short_info().

◆ handle_achievement_info()

void handle_achievement_info ( int  id,
bool  gained,
bool  first 
)

Received package about gaining an achievement.

Definition at line 2866 of file packhand.cpp.

◆ handle_begin_turn()

void handle_begin_turn ( )

Called when begin-turn packet is received.

Server has finished processing turn change.

Definition at line 1449 of file packhand.cpp.

◆ handle_calendar_info()

void handle_calendar_info ( const struct packet_calendar_info *  pcalendar)

Packet calendar_info handler.

Definition at line 2226 of file packhand.cpp.

◆ handle_chat_msg()

void handle_chat_msg ( const struct packet_chat_msg *  packet)

Handle a message packet.

This includes all messages - both in-game messages and chats from other players.

Definition at line 1499 of file packhand.cpp.

◆ handle_city_info()

void handle_city_info ( const struct packet_city_info *  packet)

A city-info packet contains all information about a city.

If we receive this packet then we know everything about the city internals.

Definition at line 639 of file packhand.cpp.

◆ handle_city_name_suggestion_info()

void handle_city_name_suggestion_info ( int  unit_id,
const char *  name 
)

Handle reply to our city name request.

Definition at line 4673 of file packhand.cpp.

◆ handle_city_remove()

void handle_city_remove ( int  city_id)

Handles a remove-city packet, used by the server to tell us any time a city is no longer there.

Definition at line 393 of file packhand.cpp.

◆ handle_city_sabotage_list()

void handle_city_sabotage_list ( int  actor_id,
int  city_id,
bv_imprs  improvements,
action_id  act_id,
bool  disturb_player 
)

Handle list of potenttial buildings to sabotage.

Definition at line 5046 of file packhand.cpp.

◆ handle_city_short_info()

void handle_city_short_info ( const struct packet_city_short_info *  packet)

A city-short-info packet is sent to tell us about any cities we can't see the internals of.

Most of the time this includes any cities owned by someone else.

Definition at line 1131 of file packhand.cpp.

◆ handle_conn_info()

void handle_conn_info ( const struct packet_conn_info *  pinfo)

Remove, add, or update dummy connection struct representing some connection to the server, with info from packet_conn_info.

Updates player and game connection lists. Calls players_dialog_update() in case info for that has changed.

Definition at line 2748 of file packhand.cpp.

◆ handle_conn_ping()

void handle_conn_ping ( )

Reply to 'ping' packet with 'pong'.

Definition at line 5231 of file packhand.cpp.

◆ handle_conn_ping_info()

void handle_conn_ping_info ( int  connections,
const int *  conn_id,
const float *  ping_time 
)

Handles a conn_ping_info packet from the server.

This packet contains ping times for each connection. FIXME Only present for backward compatibility.

Definition at line 2855 of file packhand.cpp.

◆ handle_connect_msg()

void handle_connect_msg ( const char *  message)

Handle a connect message packet.

Server sends connect message to client immediately when client connects.

Definition at line 1525 of file packhand.cpp.

◆ handle_early_chat_msg()

void handle_early_chat_msg ( const struct packet_early_chat_msg *  packet)

Handle an early message packet.

Thease have format like other chat messages but server sends them only about events related to establishing the connection and other setup in the early phase. They are a separate packet just so that client knows thse to be already relevant when it's only setting itself up - other chat messages might be just something sent to all clients, and we might want to still consider ourselves "not connected" (not receivers of those messages) until we are fully in the game.

Definition at line 1515 of file packhand.cpp.

◆ handle_edit_object_created()

void handle_edit_object_created ( int  tag,
int  id 
)

Handle a notification from the server that an object was successfully created.

The 'tag' was previously sent to the server when the client requested the creation. The 'id' is the identifier of the newly created object.

Definition at line 5252 of file packhand.cpp.

◆ handle_edit_startpos()

void handle_edit_startpos ( const struct packet_edit_startpos *  packet)

Handle start position creation/removal.

Definition at line 5260 of file packhand.cpp.

◆ handle_edit_startpos_full()

void handle_edit_startpos_full ( const struct packet_edit_startpos_full *  packet)

Handle start position internal information.

Definition at line 5297 of file packhand.cpp.

◆ handle_end_phase()

void handle_end_phase ( )

Called by the network code when an end-phase packet is received.

This signifies the end of our phase (it's not sent for other player's phases).

Definition at line 1377 of file packhand.cpp.

◆ handle_end_turn()

void handle_end_turn ( )

Called when end-turn packet is received.

Server starts processing turn change.

Definition at line 1463 of file packhand.cpp.

◆ handle_endgame_player()

void handle_endgame_player ( const struct packet_endgame_player *  packet)

Pass endgame report about single player.

Definition at line 5117 of file packhand.cpp.

◆ handle_endgame_report()

void handle_endgame_report ( const struct packet_endgame_report *  packet)

Pass the header information about things be displayed in a gui-specific endgame dialog.

Definition at line 5108 of file packhand.cpp.

◆ handle_freeze_client()

void handle_freeze_client ( )

We have received PACKET_FREEZE_CLIENT.

Definition at line 5210 of file packhand.cpp.

◆ handle_game_info()

void handle_game_info ( const struct packet_game_info *  pinfo)

Packet game_info handler.

Definition at line 2153 of file packhand.cpp.

◆ handle_map_info()

void handle_map_info ( int  xsize,
int  ysize,
int  topology_id 
)

Receive information about the map size and topology from the server.

We initialize some global variables at the same time.

Definition at line 2119 of file packhand.cpp.

◆ handle_nation_availability()

void handle_nation_availability ( int  ncount,
const bool *  is_pickable,
bool  nationset_change 
)

Handle nation availability info.

This can change during pregame so is separate from ruleset_nation.

Definition at line 4501 of file packhand.cpp.

◆ handle_new_year()

void handle_new_year ( int  year,
int  fragments,
int  turn 
)

Handle turn and year advancement.

Definition at line 1330 of file packhand.cpp.

◆ handle_nuke_tile_info()

void handle_nuke_tile_info ( int  tile)

The tile (x,y) has been nuked!

Definition at line 468 of file packhand.cpp.

◆ handle_page_msg()

void handle_page_msg ( const char *  caption,
const char *  headline,
enum event_type  event,
int  len,
int  parts 
)

Page_msg header handler.

Definition at line 1550 of file packhand.cpp.

◆ handle_page_msg_part()

void handle_page_msg_part ( const char *  lines)

Page_msg part handler.

Definition at line 1580 of file packhand.cpp.

Referenced by handle_page_msg().

◆ handle_play_music()

void handle_play_music ( const char *  tag)

Play suitable music.

Definition at line 5391 of file packhand.cpp.

◆ handle_player_attribute_chunk()

void handle_player_attribute_chunk ( const struct packet_player_attribute_chunk *  packet)

Packet player_attribute_chunk handler.

Definition at line 5133 of file packhand.cpp.

◆ handle_player_diplstate()

void handle_player_diplstate ( const struct packet_player_diplstate *  packet)

Packet player_diplstate handler.

Definition at line 2647 of file packhand.cpp.

◆ handle_player_info()

void handle_player_info ( const struct packet_player_info *  pinfo)

Handle information about a player.

If the packet refers to a player slot that is not currently used, then this function will set that slot to used and update the total player count.

Definition at line 2323 of file packhand.cpp.

◆ handle_player_remove()

void handle_player_remove ( int  playerno)

Handle a notification that the player slot identified by 'playerno' has become unused.

If the slot is already unused, then just ignore. Otherwise update the total player count and the GUI.

Definition at line 2276 of file packhand.cpp.

◆ handle_processing_finished()

void handle_processing_finished ( )

Handle request to stop processing packet.

Definition at line 5167 of file packhand.cpp.

◆ handle_processing_started()

void handle_processing_started ( )

Handle request to start processing packet.

Definition at line 5152 of file packhand.cpp.

◆ handle_research_info()

void handle_research_info ( const struct packet_research_info *  packet)

Receive a research info packet.

Definition at line 2559 of file packhand.cpp.

◆ handle_ruleset_achievement()

void handle_ruleset_achievement ( const struct packet_ruleset_achievement *  p)

Handle a packet about a particular achievement type.

Definition at line 4328 of file packhand.cpp.

◆ handle_ruleset_action()

void handle_ruleset_action ( const struct packet_ruleset_action *  p)

Handle a packet about a particular action.

Definition at line 4217 of file packhand.cpp.

◆ handle_ruleset_action_auto()

void handle_ruleset_action_auto ( const struct packet_ruleset_action_auto *  p)

Handle a packet about a particular action auto performer rule.

Definition at line 4284 of file packhand.cpp.

◆ handle_ruleset_action_enabler()

void handle_ruleset_action_enabler ( const struct packet_ruleset_action_enabler *  p)

Handle a packet about a particular action enabler.

Definition at line 4249 of file packhand.cpp.

◆ handle_ruleset_base()

void handle_ruleset_base ( const struct packet_ruleset_base *  p)

Handle a packet about a particular base type.

Definition at line 4143 of file packhand.cpp.

◆ handle_ruleset_building()

void handle_ruleset_building ( const struct packet_ruleset_building *  p)

Packet ruleset_building handler.

Definition at line 3746 of file packhand.cpp.

◆ handle_ruleset_city()

void handle_ruleset_city ( const struct packet_ruleset_city *  packet)

Handle city style packet.

Definition at line 4554 of file packhand.cpp.

◆ handle_ruleset_clause()

void handle_ruleset_clause ( const struct packet_ruleset_clause *  p)

Handle a packet about a particular clause.

Definition at line 4531 of file packhand.cpp.

◆ handle_ruleset_control()

void handle_ruleset_control ( const struct packet_ruleset_control *  packet)

Take arrival of ruleset control packet to indicate that current allocated governments should be free'd, and new memory allocated for new size.

The same for nations.

Definition at line 3252 of file packhand.cpp.

◆ handle_ruleset_description_part()

void handle_ruleset_description_part ( const struct packet_ruleset_description_part *  packet)

Next part of ruleset description.

Definition at line 3360 of file packhand.cpp.

◆ handle_ruleset_disaster()

void handle_ruleset_disaster ( const struct packet_ruleset_disaster *  p)

Handle a packet about a particular disaster type.

Definition at line 4306 of file packhand.cpp.

◆ handle_ruleset_effect()

void handle_ruleset_effect ( const struct packet_ruleset_effect *  packet)

Add effect data to ruleset cache.

Definition at line 5241 of file packhand.cpp.

◆ handle_ruleset_extra()

void handle_ruleset_extra ( const struct packet_ruleset_extra *  p)

Handle a packet about a particular extra type.

Definition at line 3982 of file packhand.cpp.

◆ handle_ruleset_extra_flag()

void handle_ruleset_extra_flag ( const struct packet_ruleset_extra_flag *  p)

Packet ruleset_extra_flag handler.

Definition at line 4116 of file packhand.cpp.

◆ handle_ruleset_game()

void handle_ruleset_game ( const struct packet_ruleset_game *  packet)

Packet ruleset_game handler.

Definition at line 4604 of file packhand.cpp.

◆ handle_ruleset_goods()

void handle_ruleset_goods ( const struct packet_ruleset_goods *  p)

Handle a packet about a particular goods type.

Definition at line 4192 of file packhand.cpp.

◆ handle_ruleset_government()

void handle_ruleset_government ( const struct packet_ruleset_government *  p)

Packet ruleset_government handler.

Definition at line 3825 of file packhand.cpp.

◆ handle_ruleset_government_ruler_title()

void handle_ruleset_government_ruler_title ( const struct packet_ruleset_government_ruler_title *  packet)

Packet ruleset_government_ruler_title handler.

Definition at line 3851 of file packhand.cpp.

◆ handle_ruleset_multiplier()

void handle_ruleset_multiplier ( const struct packet_ruleset_multiplier *  p)

Packet ruleset_multiplier handler.

Definition at line 3798 of file packhand.cpp.

◆ handle_ruleset_music()

void handle_ruleset_music ( const struct packet_ruleset_music *  packet)

Handle music style packet.

Definition at line 4581 of file packhand.cpp.

◆ handle_ruleset_nation()

void handle_ruleset_nation ( const struct packet_ruleset_nation *  packet)

Handle initial ruleset nation info.

Definition at line 4408 of file packhand.cpp.

◆ handle_ruleset_nation_groups()

void handle_ruleset_nation_groups ( const struct packet_ruleset_nation_groups *  packet)

Handle the list of nation groups, sent as part of the ruleset.

Definition at line 4390 of file packhand.cpp.

◆ handle_ruleset_nation_sets()

void handle_ruleset_nation_sets ( const struct packet_ruleset_nation_sets *  packet)

Handle the list of nation sets, sent as part of the ruleset.

Definition at line 4372 of file packhand.cpp.

◆ handle_ruleset_resource()

void handle_ruleset_resource ( const struct packet_ruleset_resource *  p)

Handle a packet about a particular terrain resource.

Definition at line 3964 of file packhand.cpp.

◆ handle_ruleset_road()

void handle_ruleset_road ( const struct packet_ruleset_road *  p)

Handle a packet about a particular road type.

Definition at line 4161 of file packhand.cpp.

◆ handle_ruleset_specialist()

void handle_ruleset_specialist ( const struct packet_ruleset_specialist *  p)

Handle info about a single specialist.

Definition at line 4647 of file packhand.cpp.

◆ handle_ruleset_style()

void handle_ruleset_style ( const struct packet_ruleset_style *  p)

Handle a packet about a particular style.

Definition at line 4519 of file packhand.cpp.

◆ handle_ruleset_summary()

void handle_ruleset_summary ( const struct packet_ruleset_summary *  packet)

Ruleset summary.

Definition at line 3346 of file packhand.cpp.

◆ handle_ruleset_tech()

void handle_ruleset_tech ( const struct packet_ruleset_tech *  p)

Packet ruleset_tech handler.

Definition at line 3636 of file packhand.cpp.

◆ handle_ruleset_tech_class()

void handle_ruleset_tech_class ( const struct packet_ruleset_tech_class *  p)

Packet ruleset_tech_class handler.

Definition at line 3706 of file packhand.cpp.

◆ handle_ruleset_tech_flag()

void handle_ruleset_tech_flag ( const struct packet_ruleset_tech_flag *  p)

Packet ruleset_tech_flag handler.

Definition at line 3719 of file packhand.cpp.

◆ handle_ruleset_terrain()

void handle_ruleset_terrain ( const struct packet_ruleset_terrain *  p)

Packet ruleset_terrain handler.

Definition at line 3866 of file packhand.cpp.

◆ handle_ruleset_terrain_control()

void handle_ruleset_terrain_control ( const struct packet_ruleset_terrain_control *  p)

Handle the terrain control ruleset packet sent by the server.

Definition at line 4359 of file packhand.cpp.

◆ handle_ruleset_terrain_flag()

void handle_ruleset_terrain_flag ( const struct packet_ruleset_terrain_flag *  p)

Packet ruleset_terrain_flag handler.

Definition at line 3937 of file packhand.cpp.

◆ handle_ruleset_trade()

void handle_ruleset_trade ( const struct packet_ruleset_trade *  p)

Handle a packet about a particular trade route type.

Definition at line 4344 of file packhand.cpp.

◆ handle_ruleset_unit()

void handle_ruleset_unit ( const struct packet_ruleset_unit *  p)

Packet ruleset_unit handler.

Definition at line 3457 of file packhand.cpp.

◆ handle_ruleset_unit_bonus()

void handle_ruleset_unit_bonus ( const struct packet_ruleset_unit_bonus *  p)

Packet ruleset_unit_bonus handler.

Definition at line 3528 of file packhand.cpp.

◆ handle_ruleset_unit_class()

void handle_ruleset_unit_class ( const struct packet_ruleset_unit_class *  p)

Packet ruleset_unit_class handler.

Definition at line 3438 of file packhand.cpp.

◆ handle_ruleset_unit_class_flag()

void handle_ruleset_unit_class_flag ( const struct packet_ruleset_unit_class_flag *  p)

Packet ruleset_unit_class_flag handler.

Definition at line 3576 of file packhand.cpp.

◆ handle_ruleset_unit_flag()

void handle_ruleset_unit_flag ( const struct packet_ruleset_unit_flag *  p)

Packet ruleset_unit_flag handler.

Definition at line 3548 of file packhand.cpp.

◆ handle_rulesets_ready()

void handle_rulesets_ready ( )

Received packet indicating that all rulesets have now been received.

Definition at line 3370 of file packhand.cpp.

◆ handle_scenario_description()

void handle_scenario_description ( const char *  description)

Received packet containing description of current scenario.

Definition at line 3240 of file packhand.cpp.

◆ handle_scenario_info()

void handle_scenario_info ( const struct packet_scenario_info *  packet)

Received packet containing info about current scenario.

Definition at line 3219 of file packhand.cpp.

◆ handle_server_info()

void handle_server_info ( const char *  version_label,
int  major_version,
int  minor_version,
int  patch_version,
int  emerg_version 
)

Handle server info packet.

Server sends info packet as soon as it knows client to be compatible.

Definition at line 1534 of file packhand.cpp.

◆ handle_server_join_reply()

void handle_server_join_reply ( bool  you_can_join,
const char *  message,
const char *  capability,
const char *  challenge_file,
int  conn_id 
)

After we send a join packet to the server we receive a reply.

This function handles the reply.

Definition at line 332 of file packhand.cpp.

◆ handle_server_shutdown()

void handle_server_shutdown ( )

Handle server shutdown.

Definition at line 5236 of file packhand.cpp.

◆ handle_set_topology()

void handle_set_topology ( int  topology_id)

Server requested topology change.

Definition at line 2096 of file packhand.cpp.

◆ handle_spaceship_info()

void handle_spaceship_info ( const struct packet_spaceship_info *  p)

Packet spaceship_info handler.

Definition at line 2922 of file packhand.cpp.

◆ handle_start_phase()

void handle_start_phase ( int  phase)

Called by the network code when an start-phase packet is received.

This may be the start of our phase or someone else's phase.

Definition at line 1388 of file packhand.cpp.

◆ handle_team_name_info()

void handle_team_name_info ( int  team_id,
const char *  team_name 
)

The name of team 'team_id'.

Definition at line 476 of file packhand.cpp.

◆ handle_thaw_client()

void handle_thaw_client ( )

We have received PACKET_THAW_CLIENT.

Definition at line 5220 of file packhand.cpp.

◆ handle_tile_info()

void handle_tile_info ( const struct packet_tile_info *  packet)

Packet tile_info handler.

Definition at line 2967 of file packhand.cpp.

◆ handle_timeout_info()

void handle_timeout_info ( float  seconds_to_phasedone,
float  last_turn_change_time 
)

Sets the remaining turn time.

Definition at line 2234 of file packhand.cpp.

◆ handle_traderoute_info()

void handle_traderoute_info ( const struct packet_traderoute_info *  packet)

A traderoute-info packet contains information about one end of a traderoute.

Definition at line 1096 of file packhand.cpp.

◆ handle_unit_action_answer()

void handle_unit_action_answer ( int  actor_id,
int  target_id,
int  cost,
action_id  action_type,
bool  disturb_player 
)

Handle the requested follow up question about an action.

The action can be a valid action or the special value ACTION_NONE. ACTION_NONE indicates that performing the action is impossible.

Definition at line 4710 of file packhand.cpp.

◆ handle_unit_actions()

void handle_unit_actions ( const struct packet_unit_actions *  packet)

Handle reply to possible actions.

Note that a reply to a foreground request (a reply where disturb_player is true) must result in its clean up.

Definition at line 4942 of file packhand.cpp.

◆ handle_unit_bombard_info()

void handle_unit_bombard_info ( int  attacker_unit_id,
int  target_tile_id 
)

A bombardment packet.

The server tells us the attacker and the bombarded tile.

Definition at line 547 of file packhand.cpp.

◆ handle_unit_combat_info()

void handle_unit_combat_info ( const struct packet_unit_combat_info *  packet)

A combat packet.

The server tells us the attacker and defender as well as both of their hitpoints after the combat is over (in most combat, one unit always dies and their HP drops to zero). If make_winner_veteran is set then the surviving unit becomes veteran.

Definition at line 491 of file packhand.cpp.

◆ handle_unit_info()

void handle_unit_info ( const struct packet_unit_info *  packet)

Packet unit_info.

Definition at line 1605 of file packhand.cpp.

◆ handle_unit_packet_common()

static bool handle_unit_packet_common ( struct unit packet_unit)
static

Called to do basic handling for a unit_info or short_unit_info packet.

Both owned and foreign units are handled; you may need to check unit owner, or if unit equals focus unit, depending on what you are doing.

Note: Normally the server informs client about a new "activity" here. For owned units, the new activity can be a result of:

  • The player issued a command (a request) with the client.
  • The server side AI did something.
  • An enemy encounter caused a sentry to idle. (See "Wakeup Focus").

Depending on what caused the change, different actions may be taken. Therefore, this function is a bit of a jungle, and it is advisable to read thoroughly before changing.

Definition at line 1632 of file packhand.cpp.

Referenced by handle_unit_info(), and handle_unit_short_info().

◆ handle_unit_remove()

void handle_unit_remove ( int  unit_id)

Handle a remove-unit packet, sent by the server to tell us any time a unit is no longer there.

Definition at line 416 of file packhand.cpp.

Referenced by handle_unit_packet_common().

◆ handle_unit_short_info()

void handle_unit_short_info ( const struct packet_unit_short_info *  packet)

Receive a short_unit info packet.

Definition at line 2033 of file packhand.cpp.

◆ handle_vote_new()

void handle_vote_new ( const struct packet_vote_new *  packet)

Create a new vote and add it to the queue.

Refresh the GUI.

Definition at line 5358 of file packhand.cpp.

◆ handle_vote_remove()

void handle_vote_remove ( int  vote_no)

A vote no longer exists.

Remove from queue and update gui.

Definition at line 5328 of file packhand.cpp.

◆ handle_vote_resolve()

void handle_vote_resolve ( int  vote_no,
bool  passed 
)

Update the vote's status and refresh the GUI.

Definition at line 5373 of file packhand.cpp.

◆ handle_vote_update()

void handle_vote_update ( int  vote_no,
int  yes,
int  no,
int  abstain,
int  num_voters 
)

Find and update the corresponding vote and refresh the GUI.

Definition at line 5337 of file packhand.cpp.

◆ handle_worker_task()

void handle_worker_task ( const struct packet_worker_task *  packet)

Handle worker task assigned to the city.

Definition at line 1278 of file packhand.cpp.

◆ notify_about_incoming_packet()

void notify_about_incoming_packet ( struct connection pc,
int  packet_type,
int  size 
)

Notify interested parties about incoming packet.

Definition at line 5187 of file packhand.cpp.

Referenced by make_connection().

◆ notify_about_outgoing_packet()

void notify_about_outgoing_packet ( struct connection pc,
int  packet_type,
int  size,
int  request_id 
)

Notify interested parties about outgoing packet.

Definition at line 5197 of file packhand.cpp.

Referenced by make_connection().

◆ packhand_free()

void packhand_free ( )

Called below, and by client/client_main.c client_game_free()

Definition at line 142 of file packhand.cpp.

Referenced by client_game_free(), client_game_reset(), and packhand_init().

◆ packhand_init()

static void packhand_init ( )
static

Called only by handle_map_info() below.

Definition at line 165 of file packhand.cpp.

Referenced by handle_map_info().

◆ play_sound_for_event()

void play_sound_for_event ( enum event_type  type)

Plays sound associated with event.

Definition at line 1486 of file packhand.cpp.

Referenced by handle_event(), and handle_page_msg_part().

◆ set_government_choice()

void set_government_choice ( struct government government)

Sets the target government.

This will automatically start a revolution if the target government differs from the current one.

Definition at line 2252 of file packhand.cpp.

Referenced by revolution_response().

◆ spaceship_autoplace()

static bool spaceship_autoplace ( struct player pplayer,
struct player_spaceship ship 
)
static

Ideally the client should let the player choose which type of modules and components to build, and (possibly) where to extend structurals.

The protocol now makes this possible, but the client is not yet that good (would require GUI improvements) so currently the client choices stuff automatically if there is anything unplaced.

This function makes a choice (sends spaceship_action) and returns 1 if we placed something, else 0.

Do things one at a time; the server will send us an updated spaceship_info packet, and we'll be back here to do anything which is left.

Definition at line 2903 of file packhand.cpp.

Referenced by handle_spaceship_info().

◆ start_revolution()

void start_revolution ( )

Begin a revolution by telling the server to start it.

This also clears the current government choice.

Definition at line 2265 of file packhand.cpp.

Referenced by revolution_response().

◆ unpack_tech_req()

static int unpack_tech_req ( const enum tech_req  r_num,
const int  reqs_size,
const struct requirement reqs,
struct advance a,
int  i 
)
static

Unpack a traditional tech req from a standard requirement vector (that still is in the network serialized format rather than a proper requirement vector).

Returns the position in the requirement vector after unpacking. It will increase if a tech req was extracted.

Definition at line 3609 of file packhand.cpp.

Referenced by handle_ruleset_tech().

◆ unpackage_short_unit()

static struct unit* unpackage_short_unit ( const struct packet_unit_short_info *  packet)
static

Unpackage a short_unit_info packet.

This extracts a limited amount of information about the unit, and is sent for units we shouldn't know everything about (like our enemies' units).

Information for the client must also be processed in handle_unit_packet_common()! Especially notice that unit structure filled here is just temporary one. Values must be copied to real unit in handle_unit_packet_common().

Definition at line 294 of file packhand.cpp.

Referenced by handle_unit_short_info().

◆ unpackage_unit()

static struct unit* unpackage_unit ( const struct packet_unit_info *  packet)
static

Unpackage the unit information into a newly allocated unit structure.

Information for the client must also be processed in handle_unit_packet_common()! Especially notice that unit structure filled here is just temporary one. Values must be copied to real unit in handle_unit_packet_common().

Definition at line 189 of file packhand.cpp.

Referenced by handle_unit_info().

◆ update_improvement_from_packet()

static bool update_improvement_from_packet ( struct city pcity,
struct impr_type pimprove,
bool  have_impr 
)
static

Updates a city's list of improvements from packet data.

"have_impr" specifies whether the improvement should be added (TRUE) or removed (FALSE). Returns TRUE if the improvement has been actually added or removed.

Definition at line 617 of file packhand.cpp.

Referenced by handle_city_info(), handle_city_sabotage_list(), and handle_city_short_info().

Variable Documentation

◆ caption

char* caption

Definition at line 129 of file packhand.cpp.

Referenced by handle_page_msg(), page_conn(), page_conn_etype(), and popup_notify_dialog().

◆ cities

◆ event

enum event_type event

Definition at line 127 of file packhand.cpp.

Referenced by handle_page_msg().

◆ forced_tileset_name

QString forced_tileset_name
extern

Definition at line 127 of file client_main.cpp.

Referenced by client_main(), and handle_set_topology().

◆ headline

◆ 

◆ last_turn

int last_turn = 0
static

Definition at line 137 of file packhand.cpp.

Referenced by handle_new_year().

◆ len

◆ lines

◆ 

struct { ... } page_msg_report

◆ parts

◆ placeholder

struct player* placeholder

Definition at line 123 of file packhand.cpp.