Freeciv21
Develop your civilization from humble roots to a global empire
islands.cpp File Reference
#include "islands.h"
#include "game.h"
#include "map.h"
#include "map_types.h"
#include "terrain.h"
#include "height_map.h"
#include "mapgen.h"
#include "mapgen_topology.h"
#include "mapgen_utils.h"
#include "temperature_map.h"
#include "rand.h"
#include "speclist.h"
+ Include dependency graph for islands.cpp:

Go to the source code of this file.

Classes

struct  gen234_state
 
struct  terrain_select
 

Macros

#define SPECLIST_TAG   terrain_select
 
#define terrain_select_list_iterate(tersel_list, ptersel)    TYPED_LIST_ITERATE(struct terrain_select, tersel_list, ptersel)
 
#define terrain_select_list_iterate_end   LIST_ITERATE_END
 
#define DMSIS   10
 

Functions

static struct terrain_selecttersel_new (int weight, enum mapgen_terrain_property target, enum mapgen_terrain_property prefer, enum mapgen_terrain_property avoid, int temp_condition, int wet_condition)
 Allocate and initialize new terrain_select structure. More...
 
static void tersel_free (struct terrain_select *ptersel)
 Free resources allocated for terrain_select structure. More...
 
static void fill_island (int coast, long int *bucket, const struct terrain_select_list *tersel_list, const struct gen234_state *const pstate)
 Fill an island with different types of terrains; rivers have extra code. More...
 
static bool make_island (int islemass, int starters, struct gen234_state *pstate, int min_specific_island_size)
 make an island, fill every tile type except plains note: you have to create big islands first. More...
 
static bool create_island (int islemass, struct gen234_state *pstate)
 finds a place and drop the island created when called with islemass != 0 More...
 
static void fill_island_rivers (int coast, long int *bucket, const struct gen234_state *const pstate)
 Fill an island with rivers. More...
 
static void island_terrain_init ()
 Initialize terrain selection lists for make_island(). More...
 
static void island_terrain_free ()
 Free memory allocated for terrain selection lists. More...
 
static void initworld (struct gen234_state *pstate)
 fill ocean and make polar A temperature map is created in map_fractal_generate(). More...
 
static bool map_generate_island_variable ()
 island base map generators More...
 
static bool map_generate_island_single ()
 On popular demand, this tries to mimick the generator 3 as best as possible. More...
 
static bool map_generate_island_2or3 ()
 Generator for placing a couple of players to each island. More...
 
bool map_generate_island ()
 Generate a map with the ISLAND family of generators. More...
 
static struct tileget_random_map_position_from_state (const struct gen234_state *const pstate)
 Returns a random position in the rectangle denoted by the given state. More...
 
static bool island_river_mouth_suitability (const struct tile *ptile, const struct extra_type *priver)
 Returns TRUE if ptile is suitable for a river mouth. More...
 
static bool island_river_suitability (const struct tile *ptile, const struct extra_type *priver)
 Returns TRUE if there is a river in a cardinal direction near the tile and the tile is suitable for extending it. More...
 
static bool is_near_land (struct tile *ptile)
 Return TRUE if the ocean position is near land. More...
 
static bool place_island (struct gen234_state *pstate)
 Finds a place and drop the island created when called with islemass != 0. More...
 
static int count_card_adjc_elevated_tiles (struct tile *ptile)
 Returns the number of cardinally adjacent tiles have a non-zero elevation. More...
 

Variables

struct {
   bool   init
 
   struct terrain_select_list *   forest
 
   struct terrain_select_list *   desert
 
   struct terrain_select_list *   mountain
 
   struct terrain_select_list *   swamp
 
island_terrain = {.init = false}
 
static long int checkmass
 

Macro Definition Documentation

◆ DMSIS

#define DMSIS   10

Definition at line 303 of file islands.cpp.

◆ SPECLIST_TAG

#define SPECLIST_TAG   terrain_select

Definition at line 40 of file islands.cpp.

◆ terrain_select_list_iterate

#define terrain_select_list_iterate (   tersel_list,
  ptersel 
)     TYPED_LIST_ITERATE(struct terrain_select, tersel_list, ptersel)

Definition at line 43 of file islands.cpp.

◆ terrain_select_list_iterate_end

#define terrain_select_list_iterate_end   LIST_ITERATE_END

Definition at line 45 of file islands.cpp.

Function Documentation

◆ count_card_adjc_elevated_tiles()

static int count_card_adjc_elevated_tiles ( struct tile ptile)
static

Returns the number of cardinally adjacent tiles have a non-zero elevation.

Definition at line 922 of file islands.cpp.

Referenced by create_island().

◆ create_island()

static bool create_island ( int  islemass,
struct gen234_state pstate 
)
static

finds a place and drop the island created when called with islemass != 0

Definition at line 940 of file islands.cpp.

Referenced by make_island().

◆ fill_island()

static void fill_island ( int  coast,
long int *  bucket,
const struct terrain_select_list *  tersel_list,
const struct gen234_state *const  pstate 
)
static

Fill an island with different types of terrains; rivers have extra code.

Definition at line 658 of file islands.cpp.

Referenced by make_island().

◆ fill_island_rivers()

static void fill_island_rivers ( int  coast,
long int *  bucket,
const struct gen234_state *const  pstate 
)
static

Fill an island with rivers.

Definition at line 779 of file islands.cpp.

Referenced by make_island().

◆ get_random_map_position_from_state()

static struct tile* get_random_map_position_from_state ( const struct gen234_state *const  pstate)
static

Returns a random position in the rectangle denoted by the given state.

Definition at line 609 of file islands.cpp.

Referenced by create_island(), fill_island(), and fill_island_rivers().

◆ initworld()

static void initworld ( struct gen234_state pstate)
static

fill ocean and make polar A temperature map is created in map_fractal_generate().

Definition at line 268 of file islands.cpp.

Referenced by map_generate_island_2or3(), map_generate_island_single(), and map_generate_island_variable().

◆ is_near_land()

static bool is_near_land ( struct tile ptile)
static

Return TRUE if the ocean position is near land.

This is used in the creation of islands, so it differs logically from near_safe_tiles().

Definition at line 835 of file islands.cpp.

Referenced by place_island().

◆ island_river_mouth_suitability()

static bool island_river_mouth_suitability ( const struct tile ptile,
const struct extra_type priver 
)
static

Returns TRUE if ptile is suitable for a river mouth.

Definition at line 739 of file islands.cpp.

Referenced by fill_island_rivers().

◆ island_river_suitability()

static bool island_river_suitability ( const struct tile ptile,
const struct extra_type priver 
)
static

Returns TRUE if there is a river in a cardinal direction near the tile and the tile is suitable for extending it.

Definition at line 757 of file islands.cpp.

Referenced by fill_island_rivers().

◆ island_terrain_free()

static void island_terrain_free ( )
static

Free memory allocated for terrain selection lists.

Definition at line 136 of file islands.cpp.

Referenced by map_generate_island().

◆ island_terrain_init()

static void island_terrain_init ( )
static

Initialize terrain selection lists for make_island().

Definition at line 80 of file islands.cpp.

Referenced by map_generate_island().

◆ make_island()

static bool make_island ( int  islemass,
int  starters,
struct gen234_state pstate,
int  min_specific_island_size 
)
static

make an island, fill every tile type except plains note: you have to create big islands first.

Return TRUE if successful. min_specific_island_size is a percent value.

Definition at line 156 of file islands.cpp.

Referenced by initworld(), map_generate_island_2or3(), map_generate_island_single(), and map_generate_island_variable().

◆ map_generate_island()

bool map_generate_island ( )

Generate a map with the ISLAND family of generators.

Returns true on success.

Definition at line 574 of file islands.cpp.

Referenced by map_generate().

◆ map_generate_island_2or3()

static bool map_generate_island_2or3 ( )
static

Generator for placing a couple of players to each island.

PS: The weights NEED to sum up to totalweight (dammit)

Definition at line 505 of file islands.cpp.

Referenced by map_generate_island().

◆ map_generate_island_single()

static bool map_generate_island_single ( )
static

On popular demand, this tries to mimick the generator 3 as best as possible.

PS: I'd like to mult by 3/2, but starters might make trouble then

Definition at line 405 of file islands.cpp.

Referenced by map_generate_island().

◆ map_generate_island_variable()

static bool map_generate_island_variable ( )
static

island base map generators

Definition at line 308 of file islands.cpp.

Referenced by map_generate_island().

◆ place_island()

static bool place_island ( struct gen234_state pstate)
static

Finds a place and drop the island created when called with islemass != 0.

Definition at line 852 of file islands.cpp.

Referenced by create_island().

◆ tersel_free()

static void tersel_free ( struct terrain_select ptersel)
static

Free resources allocated for terrain_select structure.

Definition at line 649 of file islands.cpp.

Referenced by island_terrain_init().

◆ tersel_new()

static struct terrain_select * tersel_new ( int  weight,
enum mapgen_terrain_property  target,
enum mapgen_terrain_property  prefer,
enum mapgen_terrain_property  avoid,
int  temp_condition,
int  wet_condition 
)
static

Allocate and initialize new terrain_select structure.

Definition at line 627 of file islands.cpp.

Referenced by island_terrain_init().

Variable Documentation

◆ checkmass

long int checkmass
static

◆ desert

struct terrain_select_list* desert

Definition at line 59 of file islands.cpp.

◆ forest

struct terrain_select_list* forest

Definition at line 58 of file islands.cpp.

◆ init

bool init

Definition at line 57 of file islands.cpp.

◆ 

struct { ... } island_terrain

◆ mountain

struct terrain_select_list* mountain

Definition at line 60 of file islands.cpp.

◆ swamp

struct terrain_select_list* swamp

Definition at line 61 of file islands.cpp.