75 nullptr, start_worker,
nullptr,
nullptr,
85 if (nextra !=
nullptr) {
103 if (nextra !=
nullptr) {
120 value +=
MAX(0,
MAX(mine_bonus, irrig_bonus)) / 2;
137 const struct tile *ptile,
int min_area)
140 struct tile_list *tlist = tile_list_new();
144 tile_list_append(tlist, central);
146 while (tile_list_size(tlist) > 0 && tiles < min_area) {
155 tile_list_append(tlist, ptile3);
157 if (tiles >= min_area) {
165 tile_list_remove(tlist, ptile2);
167 if (tiles >= min_area) {
175 tile_list_destroy(tlist);
178 return tiles >= min_area;
250 <= (sqrt(cont_size / island->
total))))
316 int *tile_value_aux =
nullptr;
317 int *tile_value =
nullptr;
318 int min_goodies_per_player = 1500;
319 int total_goodies = 0;
323 bool failure =
false;
329 qDebug(
"Map has no land, so cannot assign start positions!");
344 qDebug(
"Using startpos=VARIABLE");
361 int this_tile_value = tile_value_aux[
tile_index(value_tile)];
362 int lcount = 0, bcount = 0;
367 if (this_tile_value > tile_value_aux[
tile_index(ptile1)]) {
369 }
else if (this_tile_value < tile_value_aux[
tile_index(ptile1)]) {
375 if (lcount <= bcount) {
378 tile_value[
tile_index(value_tile)] = 100 * this_tile_value;
396 total_goodies += tile_value[
tile_index(starter_tile)];
413 qDebug(
"Not enough continents; falling back to startpos=2or3");
419 qDebug(
"Not enough continents; falling back to startpos=VARIABLE");
426 < total_goodies * (0.5 + 0.8 * efactor) / (1 + efactor))) {
427 qDebug(
"No good enough island; falling back to startpos=VARIABLE");
433 min_goodies_per_player = total_goodies * (0.65 + 0.8 * efactor)
450 float var_goodies, best = HUGE_VAL;
455 if (
islands[nr + num_islands - 1].goodies < min_goodies_per_player) {
460 / (
islands[nr + num_islands - 1].goodies);
462 if (var_goodies < best * 0.9) {
488 MAX(1,
islands[nr].goodies /
MAX(1, min_goodies_per_player));
494 data.
value = tile_value;
501 qDebug(
"starters on isle %i", k);
512 log_debug(
"Adding (%d, %d) as starting position %d, %d goodies on "
520 qInfo(
_(
"The server appears to have gotten into an infinite "
521 "loop in the allocation of starting positions.\nMaybe "
522 "the number of players is too high for this map."));
538 delete[] tile_value_aux;
540 tile_value_aux =
nullptr;
541 tile_value =
nullptr;
int city_tile_output(const struct city *pcity, const struct tile *ptile, bool is_celebrating, Output_type_id otype)
Calculate the output for the tile.
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define output_type_iterate(output)
#define CITY_MAP_DEFAULT_RADIUS_SQ
#define city_tile_iterate_end
#define output_type_iterate_end
signed short Continent_id
enum output_type_id Output_type_id
#define fc_assert_ret_val(condition, val)
#define fc_assert_action(condition, action)
#define log_debug(message,...)
int map_startpos_count()
Is there start positions set for map.
struct startpos * map_startpos_new(struct tile *ptile)
Create a new start position at the given tile and return it.
struct tile * startpos_tile(const struct startpos *psp)
Returns the tile where this start position is located.
int real_map_distance(const struct tile *tile0, const struct tile *tile1)
Return real distance between two tiles.
struct terrain_misc terrain_control
struct tile * rand_map_pos_filtered(const struct civ_map *nmap, void *data, bool(*filter)(const struct tile *ptile, const void *data))
Give a random tile anywhere on the map for which the 'filter' function returns TRUE.
#define adjc_iterate(nmap, center_tile, itr_tile)
#define whole_map_iterate(_map, _tile)
#define map_size_checked()
#define whole_map_iterate_end
int get_continent_size(Continent_id id)
Return size in tiles of the given continent (not ocean)
void smooth_int_map(int *int_map, bool zeroes_at_edges)
Apply a Gaussian diffusion filter on the map.
void adjust_int_map_filtered(int *int_map, int int_map_max, void *data, bool(*filter)(const struct tile *ptile, const void *data))
Change the values of the integer map, so that they contain ranking of each tile scaled to [0 .
bool is_native_tile(const struct unit_type *punittype, const struct tile *ptile)
This tile is native to unit.
int player_count()
Return the number of players.
bool are_reqs_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement(s) to see if they are active on the given target.
bool road_can_be_built(const struct road_type *proad, const struct tile *ptile)
Tells if road can build to tile if all other requirements are met.
static int compare_islands(const void *A_, const void *B_)
Helper function for qsort.
bool create_start_positions(enum map_startpos mode, struct unit_type *initial_unit)
where do the different nations start on the map? well this function tries to spread them out on the d...
static bool filter_starters(const struct tile *ptile, const void *data)
A function that filters for TER_STARTER tiles.
static int * islands_index
static struct islands_data_type * islands
static int get_tile_value(struct tile *ptile)
Return an approximation of the goodness of a tile to a civilization.
static void initialize_isle_data()
Initialize islands data.
static bool check_native_area(const struct unit_type *utype, const struct tile *ptile, int min_area)
Check if number of reachable native tiles is sufficient.
static bool is_valid_start_pos(const struct tile *ptile, const void *dataptr)
Return TRUE if (x,y) is a good starting position.
struct civ_game::@28::@32 server
QHash< struct tile *, struct startpos * > * startpos_table
struct unit_type * initial_unit
bool temperature_is_initialized()
Returns one line (given by the y coordinate) of the temperature map.
bool tmap_is(const struct tile *ptile, temperature_type tt)
Return true if the tile has tt temperature type.
void destroy_tmap()
Free the tmap.
void create_tmap(bool real)
Initialize the temperature_map if arg is FALSE, create a dummy tmap == map_colatitude to be used if h...
#define terrain_has_flag(terr, flag)
void tile_add_extra(struct tile *ptile, const struct extra_type *pextra)
Adds extra to tile.
void tile_virtual_destroy(struct tile *vtile)
Frees all memory used by the virtual tile, including freeing virtual units in the tile's unit list an...
bool tile_apply_activity(struct tile *ptile, Activity_type_id act, struct extra_type *tgt)
Apply an activity (Activity_type_id, e.g., ACTIVITY_TRANSFORM) to a tile.
struct tile * tile_virtual_new(const struct tile *ptile)
Returns a virtual tile.
#define tile_list_iterate(tile_list, ptile)
#define tile_terrain(_tile)
#define tile_list_iterate_end
#define tile_continent(_tile)
int num_role_units(int role)
How many unit types have specified role/flag.
struct unit_type * get_role_unit(int role, int role_index)
Return index-th unit with specified role/flag.