![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <QtWidgets/QtWidgets>#include <cstdio>#include "fcintl.h"#include "log.h"#include "rand.h"#include "section_file.h"#include "shared.h"#include "support.h"#include "ai.h"#include "calendar.h"#include "events.h"#include "game.h"#include "movement.h"#include "nation.h"#include "citytools.h"#include "connecthand.h"#include "maphand.h"#include "notify.h"#include "srv_main.h"#include "stdinhand.h"#include "unittools.h"#include "advdata.h"#include "gamehand.h"#include "speclist.h"#include "specpq.h"
Include dependency graph for gamehand.cpp:Go to the source code of this file.
Classes | |
| struct | team_placement_config |
| struct | team_placement_state |
Macros | |
| #define | CHALLENGE_ROOT "challenge" |
| #define | SPECLIST_TAG startpos |
| #define | SPECLIST_TYPE struct startpos |
| #define | startpos_list_iterate(list, plink, psp) |
| #define | startpos_list_iterate_end LIST_BOTH_ITERATE_END |
| #define | SPECPQ_TAG team_placement |
| #define | SPECPQ_DATA_TYPE struct team_placement_state * |
| #define | SPECPQ_PRIORITY_TYPE long |
| #define | team_placement_closest sq_map_distance |
Functions | |
| enum unit_role_id | crole_to_role_id (char crole) |
| Get role_id for given role character. More... | |
| struct unit_type * | crole_to_unit_type (char crole, struct player *pplayer) |
| Get unit_type for given role character. More... | |
| static struct tile * | place_starting_unit (struct tile *starttile, struct player *pplayer, struct unit_type *ptype, char crole) |
| Place a starting unit for the player. More... | |
| static struct tile * | find_dispersed_position (struct player *pplayer, struct tile *pcenter) |
| Find a valid position not far from our starting position. More... | |
| static int | team_placement_continent (const struct tile *ptile1, const struct tile *ptile2) |
| Calculate the distance between tiles, according to the 'teamplacement' setting set to 'CONTINENT'. More... | |
| static int | team_placement_horizontal (const struct tile *ptile1, const struct tile *ptile2) |
| Calculate the distance between tiles, according to the 'teamplacement' setting set to 'HORIZONTAL'. More... | |
| static int | team_placement_vertical (const struct tile *ptile1, const struct tile *ptile2) |
| Calculate the distance between tiles, according to the 'teamplacement' setting set to 'VERTICAL'. More... | |
| static void | team_placement_state_destroy (struct team_placement_state *pstate) |
| Destroys a team_placement_state structure. More... | |
| static void | do_team_placement (const struct team_placement_config *pconfig, struct team_placement_state *pbest_state, int iter_max) |
| Find the best team placement, according to the 'team_placement' setting. More... | |
| void | init_new_game () |
| Initialize a new game: place the players' units onto the map, etc. More... | |
| void | send_year_to_clients () |
| Tell clients the year, and also update turn_done and nturns_idle fields for all players. More... | |
| void | send_game_info (struct conn_list *dest) |
| Send game_info packet; some server options and various stuff... More... | |
| void | send_scenario_info (struct conn_list *dest) |
| Send current scenario info. More... | |
| void | send_scenario_description (struct conn_list *dest) |
| Send description of the current scenario. More... | |
| int | update_timeout () |
| adjusts game.info.timeout based on various server options More... | |
| void | increase_timeout_because_unit_moved () |
| adjusts game.seconds_to_turn_done when enemy moves a unit, we see it and the remaining timeout is smaller than the timeoutaddenemymove option. More... | |
| static void | gen_challenge_filename (struct connection *pc) |
| Generate challenge filename for this connection, cannot fail. More... | |
| static const char * | get_challenge_filename (struct connection *pc) |
| Get challenge filename for this connection. More... | |
| static const char * | get_challenge_fullname (struct connection *pc) |
| Get challenge full filename for this connection. More... | |
| const char * | new_challenge_filename (struct connection *pc) |
| Find a file that we can write too, and return it's name. More... | |
| static void | send_ruleset_choices (struct connection *pc) |
| Call this on a connection with HACK access to send it a set of ruleset choices. More... | |
| void | handle_single_want_hack_req (struct connection *pc, const struct packet_single_want_hack_req *packet) |
| Opens a file specified by the packet and compares the packet values with the file values. More... | |
| #define CHALLENGE_ROOT "challenge" |
Definition at line 47 of file gamehand.cpp.
| #define SPECLIST_TAG startpos |
Definition at line 49 of file gamehand.cpp.
| #define SPECLIST_TYPE struct startpos |
Definition at line 50 of file gamehand.cpp.
| #define SPECPQ_DATA_TYPE struct team_placement_state * |
Definition at line 70 of file gamehand.cpp.
| #define SPECPQ_PRIORITY_TYPE long |
Definition at line 71 of file gamehand.cpp.
| #define SPECPQ_TAG team_placement |
Definition at line 69 of file gamehand.cpp.
| #define startpos_list_iterate | ( | list, | |
| plink, | |||
| psp | |||
| ) |
Definition at line 52 of file gamehand.cpp.
| #define startpos_list_iterate_end LIST_BOTH_ITERATE_END |
Definition at line 55 of file gamehand.cpp.
| #define team_placement_closest sq_map_distance |
Definition at line 221 of file gamehand.cpp.
| enum unit_role_id crole_to_role_id | ( | char | crole | ) |
Get role_id for given role character.
Definition at line 1 of file gamehand.cpp.
Referenced by crole_to_unit_type(), and startunits_callback().
Get unit_type for given role character.
Definition at line 108 of file gamehand.cpp.
Referenced by give_midgame_initial_units(), place_starting_unit(), and srv_ready().
|
static |
Find the best team placement, according to the 'team_placement' setting.
Definition at line 275 of file gamehand.cpp.
Referenced by init_new_game().
|
static |
Find a valid position not far from our starting position.
Definition at line 199 of file gamehand.cpp.
Referenced by init_new_game().
|
static |
Generate challenge filename for this connection, cannot fail.
Definition at line 1056 of file gamehand.cpp.
Referenced by new_challenge_filename().
|
static |
Get challenge filename for this connection.
Definition at line 1061 of file gamehand.cpp.
Referenced by get_challenge_fullname(), and new_challenge_filename().
|
static |
Get challenge full filename for this connection.
Definition at line 1074 of file gamehand.cpp.
Referenced by handle_single_want_hack_req().
| void handle_single_want_hack_req | ( | struct connection * | pc, |
| const struct packet_single_want_hack_req * | packet | ||
| ) |
Opens a file specified by the packet and compares the packet values with the file values.
Sends an answer to the client once it's done.
Definition at line 1144 of file gamehand.cpp.
| void increase_timeout_because_unit_moved | ( | ) |
adjusts game.seconds_to_turn_done when enemy moves a unit, we see it and the remaining timeout is smaller than the timeoutaddenemymove option.
It's possible to use a similar function to do that per-player. In theory there should be a separate timeout for each player and the added time should only go onto the victim's timer.
Definition at line 1040 of file gamehand.cpp.
Referenced by unit_move().
| void init_new_game | ( | ) |
Initialize a new game: place the players' units onto the map, etc.
Definition at line 416 of file gamehand.cpp.
Referenced by srv_ready().
| const char* new_challenge_filename | ( | struct connection * | pc | ) |
Find a file that we can write too, and return it's name.
Definition at line 1099 of file gamehand.cpp.
Referenced by establish_new_connection().
|
static |
Place a starting unit for the player.
Returns tile where unit was really placed. By default the ptype is used and crole does not matter, but if former is nullptr, crole will be used instead.
Definition at line 136 of file gamehand.cpp.
Referenced by init_new_game().
| void send_game_info | ( | struct conn_list * | dest | ) |
Send game_info packet; some server options and various stuff...
dest == nullptr means game.est_connections
It may be sent at any time. It MUST be sent before any player info, as it contains the number of players. To avoid inconsistency, it SHOULD be sent after rulesets and any other server settings.
Definition at line 905 of file gamehand.cpp.
Referenced by begin_phase(), begin_turn(), city_build_free_buildings(), end_turn(), establish_new_connection(), first_timeout_action(), found_new_tech(), handle_edit_city(), handle_edit_game(), handle_edit_mode(), handle_edit_player(), increase_timeout_because_unit_moved(), load_command(), remove_city(), set_ai_level(), set_command(), timeout_action(), timeout_set_command(), and transfer_city().
|
static |
Call this on a connection with HACK access to send it a set of ruleset choices.
Probably this should be called immediately when granting HACK access to a connection.
Definition at line 1110 of file gamehand.cpp.
Referenced by handle_single_want_hack_req().
| void send_scenario_description | ( | struct conn_list * | dest | ) |
Send description of the current scenario.
dest nullptr causes send to everyone
Definition at line 967 of file gamehand.cpp.
Referenced by establish_new_connection(), handle_edit_scenario_desc(), and load_command().
| void send_scenario_info | ( | struct conn_list * | dest | ) |
Send current scenario info.
dest nullptr causes send to everyone
Definition at line 950 of file gamehand.cpp.
Referenced by establish_new_connection(), handle_edit_game(), and load_command().
| void send_year_to_clients | ( | ) |
Tell clients the year, and also update turn_done and nturns_idle fields for all players.
Definition at line 880 of file gamehand.cpp.
Referenced by end_turn().
|
static |
Calculate the distance between tiles, according to the 'teamplacement' setting set to 'CONTINENT'.
Definition at line 227 of file gamehand.cpp.
Referenced by do_team_placement().
|
static |
Calculate the distance between tiles, according to the 'teamplacement' setting set to 'HORIZONTAL'.
Definition at line 239 of file gamehand.cpp.
Referenced by do_team_placement().
|
static |
Destroys a team_placement_state structure.
Definition at line 266 of file gamehand.cpp.
Referenced by do_team_placement().
|
static |
Calculate the distance between tiles, according to the 'teamplacement' setting set to 'VERTICAL'.
Definition at line 253 of file gamehand.cpp.
Referenced by do_team_placement().
| int update_timeout | ( | ) |
adjusts game.info.timeout based on various server options
timeoutint: adjust game.info.timeout every timeoutint turns timeoutinc: adjust game.info.timeout by adding timeoutinc to it. timeoutintinc: every time we adjust game.info.timeout, we add timeoutintinc to timeoutint. timeoutincmult: every time we adjust game.info.timeout, we multiply timeoutinc by timeoutincmult
Definition at line 989 of file gamehand.cpp.
Referenced by end_turn().