Freeciv-3.1
|
#include <stdio.h>
#include "capability.h"
#include "fcintl.h"
#include "log.h"
#include "mem.h"
#include "rand.h"
#include "registry.h"
#include "shared.h"
#include "string_vector.h"
#include "support.h"
#include "ai.h"
#include "calendar.h"
#include "events.h"
#include "game.h"
#include "improvement.h"
#include "movement.h"
#include "packets.h"
#include "citytools.h"
#include "connecthand.h"
#include "maphand.h"
#include "notify.h"
#include "plrhand.h"
#include "srv_main.h"
#include "stdinhand.h"
#include "unittools.h"
#include "advdata.h"
#include "gamehand.h"
#include "speclist.h"
#include "specpq.h"
Go to the source code of this file.
Data Structures | |
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) |
struct unit_type * | crole_to_unit_type (char crole, struct player *pplayer) |
static struct tile * | place_starting_unit (struct tile *starttile, struct player *pplayer, struct unit_type *ptype, char crole) |
static struct tile * | find_dispersed_position (struct player *pplayer, struct tile *pcenter) |
static int | team_placement_continent (const struct tile *ptile1, const struct tile *ptile2) |
static int | team_placement_horizontal (const struct tile *ptile1, const struct tile *ptile2) |
static int | team_placement_vertical (const struct tile *ptile1, const struct tile *ptile2) |
static void | team_placement_state_destroy (struct team_placement_state *pstate) |
static void | do_team_placement (const struct team_placement_config *pconfig, struct team_placement_state *pbest_state, int iter_max) |
void | init_new_game (void) |
void | send_year_to_clients (void) |
void | send_game_info (struct conn_list *dest) |
void | send_scenario_info (struct conn_list *dest) |
void | send_scenario_description (struct conn_list *dest) |
int | update_timeout (void) |
void | increase_timeout_because_unit_moved (void) |
static void | gen_challenge_filename (struct connection *pc) |
static const char * | get_challenge_filename (struct connection *pc) |
static const char * | get_challenge_fullname (struct connection *pc) |
const char * | new_challenge_filename (struct connection *pc) |
static void | send_ruleset_choices (struct connection *pc) |
void | handle_single_want_hack_req (struct connection *pc, const struct packet_single_want_hack_req *packet) |
#define CHALLENGE_ROOT "challenge" |
Definition at line 55 of file gamehand.c.
#define SPECLIST_TAG startpos |
Definition at line 57 of file gamehand.c.
#define SPECLIST_TYPE struct startpos |
Definition at line 58 of file gamehand.c.
#define SPECPQ_DATA_TYPE struct team_placement_state * |
Definition at line 78 of file gamehand.c.
#define SPECPQ_PRIORITY_TYPE long |
Definition at line 79 of file gamehand.c.
#define SPECPQ_TAG team_placement |
Definition at line 77 of file gamehand.c.
#define startpos_list_iterate | ( | list, | |
plink, | |||
psp | |||
) |
Definition at line 60 of file gamehand.c.
#define startpos_list_iterate_end LIST_BOTH_ITERATE_END |
Definition at line 63 of file gamehand.c.
#define team_placement_closest sq_map_distance |
Definition at line 254 of file gamehand.c.
enum unit_role_id crole_to_role_id | ( | char | crole | ) |
Get role_id for given role character
Definition at line 85 of file gamehand.c.
Referenced by crole_to_unit_type(), and startunits_callback().
Get unit_type for given role character. If pplayer given, will check also that they don't already have an unique unit.
Definition at line 118 of file gamehand.c.
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 308 of file gamehand.c.
Referenced by init_new_game().
|
static |
Find a valid position not far from our starting position.
Definition at line 220 of file gamehand.c.
Referenced by init_new_game().
|
static |
Generate challenge filename for this connection, cannot fail.
Definition at line 1050 of file gamehand.c.
Referenced by new_challenge_filename().
|
static |
Get challenge filename for this connection.
Definition at line 1057 of file gamehand.c.
Referenced by get_challenge_fullname(), and new_challenge_filename().
|
static |
Get challenge full filename for this connection.
Definition at line 1070 of file gamehand.c.
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 1137 of file gamehand.c.
Referenced by server_handle_packet().
void increase_timeout_because_unit_moved | ( | void | ) |
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 1034 of file gamehand.c.
Referenced by unit_move().
void init_new_game | ( | void | ) |
Initialize a new game: place the players' units onto the map, etc.
Definition at line 449 of file gamehand.c.
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 1094 of file gamehand.c.
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 NULL, crole will be used instead.
Definition at line 156 of file gamehand.c.
Referenced by init_new_game().
void send_game_info | ( | struct conn_list * | dest | ) |
Send game_info packet; some server options and various stuff... dest == NULL 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.c.
Referenced by api_edit_create_building(), api_edit_remove_building(), 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(), 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 1105 of file gamehand.c.
Referenced by handle_single_want_hack_req().
void send_scenario_description | ( | struct conn_list * | dest | ) |
Send description of the current scenario. dest NULL causes send to everyone
Definition at line 962 of file gamehand.c.
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 NULL causes send to everyone
Definition at line 948 of file gamehand.c.
Referenced by establish_new_connection(), handle_edit_game(), and load_command().
void send_year_to_clients | ( | void | ) |
Tell clients the year, and also update turn_done and nturns_idle fields for all players.
Definition at line 879 of file gamehand.c.
Referenced by end_turn().
|
static |
Calculate the distance between tiles, according to the 'teamplacement' setting set to 'CONTINENT'.
Definition at line 260 of file gamehand.c.
Referenced by do_team_placement().
|
static |
Calculate the distance between tiles, according to the 'teamplacement' setting set to 'HORIZONTAL'.
Definition at line 272 of file gamehand.c.
Referenced by do_team_placement().
|
static |
Destroys a team_placement_state structure.
Definition at line 299 of file gamehand.c.
Referenced by do_team_placement().
|
static |
Calculate the distance between tiles, according to the 'teamplacement' setting set to 'VERTICAL'.
Definition at line 286 of file gamehand.c.
Referenced by do_team_placement().
int update_timeout | ( | void | ) |
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 983 of file gamehand.c.
Referenced by end_turn().