Freeciv21
Develop your civilization from humble roots to a global empire
startpos.cpp File Reference
#include <QBitArray>
#include <cmath>
#include "fcintl.h"
#include "log.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "maphand.h"
#include "mapgen_utils.h"
#include "startpos.h"
#include "temperature_map.h"
+ Include dependency graph for startpos.cpp:

Go to the source code of this file.

Classes

struct  islands_data_type
 
struct  start_filter_data
 

Functions

static int get_tile_value (struct tile *ptile)
 Return an approximation of the goodness of a tile to a civilization. More...
 
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. More...
 
static bool is_valid_start_pos (const struct tile *ptile, const void *dataptr)
 Return TRUE if (x,y) is a good starting position. More...
 
static int compare_islands (const void *A_, const void *B_)
 Helper function for qsort. More...
 
static void initialize_isle_data ()
 Initialize islands data. More...
 
static bool filter_starters (const struct tile *ptile, const void *data)
 A function that filters for TER_STARTER tiles. More...
 
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 different islands. More...
 

Variables

static struct islands_data_typeislands
 
static int * islands_index
 

Function Documentation

◆ check_native_area()

static bool check_native_area ( const struct unit_type utype,
const struct tile ptile,
int  min_area 
)
static

Check if number of reachable native tiles is sufficient.

Initially given tile is assumed to be native (not checked by this function)

Definition at line 136 of file startpos.cpp.

Referenced by is_valid_start_pos().

◆ compare_islands()

static int compare_islands ( const void *  A_,
const void *  B_ 
)
static

Helper function for qsort.

Definition at line 261 of file startpos.cpp.

Referenced by create_start_positions().

◆ create_start_positions()

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 different islands.

MAPSTARTPOS_SINGLE: one player per isle. MAPSTARTPOS_2or3: 2 players per isle (maybe one isle with 3). MAPSTARTPOS_ALL: all players in asingle isle. MAPSTARTPOS_VARIABLE: at least 2 player per isle.

Assumes assign_continent_numbers() has already been done! Returns true on success

Definition at line 310 of file startpos.cpp.

Referenced by map_generate().

◆ filter_starters()

static bool filter_starters ( const struct tile ptile,
const void *  data 
)
static

A function that filters for TER_STARTER tiles.

Definition at line 293 of file startpos.cpp.

Referenced by create_start_positions().

◆ get_tile_value()

static int get_tile_value ( struct tile ptile)
static

Return an approximation of the goodness of a tile to a civilization.

Definition at line 47 of file startpos.cpp.

Referenced by create_start_positions().

◆ initialize_isle_data()

static void initialize_isle_data ( )
static

Initialize islands data.

Definition at line 274 of file startpos.cpp.

Referenced by create_start_positions().

◆ is_valid_start_pos()

static bool is_valid_start_pos ( const struct tile ptile,
const void *  dataptr 
)
static

Return TRUE if (x,y) is a good starting position.

Bad places:

  • Islands with no room.
  • Non-suitable terrain;
  • On a hut;
  • Too close to another starter on the same continent: 'dist' is too close (real_map_distance) 'nr' is the number of other start positions to check for too closeness.

Definition at line 192 of file startpos.cpp.

Referenced by create_start_positions().

Variable Documentation

◆ islands

struct islands_data_type* islands
static

Definition at line 41 of file startpos.cpp.

Referenced by create_start_positions(), initialize_isle_data(), and is_valid_start_pos().

◆ islands_index

int* islands_index
static

Definition at line 42 of file startpos.cpp.

Referenced by create_start_positions(), initialize_isle_data(), and is_valid_start_pos().