Freeciv21
Develop your civilization from humble roots to a global empire
fair_islands.cpp File Reference
#include "fair_islands.h"
#include "fc_types.h"
#include "map.h"
#include "nation.h"
#include "mapgen.h"
#include "mapgen_utils.h"
#include "rand.h"
+ Include dependency graph for fair_islands.cpp:

Go to the source code of this file.

Classes

struct  fair_tile
 
struct  fair_geometry_data
 

Macros

#define fair_do_iso_hex_symetry2   fair_do_rotation
 

Typedefs

typedef void(* fair_geometry_func) (int *x, int *y)
 

Enumerations

enum  fair_tile_flag {
  FTF_NONE = 0 , FTF_ASSIGNED = 1 << 0 , FTF_OCEAN = 1 << 1 , FTF_STARTPOS = 1 << 2 ,
  FTF_NO_RESOURCE = 1 << 3 , FTF_HAS_HUT = 1 << 4 , FTF_NO_HUT = 1 << 5
}
 Fair island generator types. More...
 

Functions

static void fair_map_destroy (struct fair_tile *pmap)
 Free a map. More...
 
static void fair_map_tile_pos (struct fair_tile *pmap, struct fair_tile *ptile, int *x, int *y)
 Get the coordinates of tile 'ptile'. More...
 
static struct fair_tilefair_map_pos_tile (struct fair_tile *pmap, int x, int y)
 Get the tile at the position ('x', 'y'). More...
 
static struct fair_tilefair_map_tile_step (struct fair_tile *pmap, struct fair_tile *ptile, enum direction8 dir)
 Get the next tile in direction 'dir'. More...
 
static bool fair_map_tile_border (struct fair_tile *pmap, struct fair_tile *ptile, int dist)
 Returns whether 'ptile' is at least at 'dist' tiles (in real distance) to the border. More...
 
static int fair_team_placement_closest (const void *a, const void *b)
 Compare two iter_index values for doing closest team placement. More...
 
static int fair_team_placement_horizontal (const void *a, const void *b)
 Compare two iter_index values for doing horizontal team placement. More...
 
static int fair_team_placement_vertical (const void *a, const void *b)
 Compare two iter_index values for doing vertical team placement. More...
 
static void fair_do_symetry1 (int *x, int *y)
 Symetry matrix. More...
 
static void fair_do_symetry2 (int *x, int *y)
 Symetry matrix. More...
 
static void fair_do_hex_symetry1 (int *x, int *y)
 Symetry matrix for hexagonal topologies. More...
 
static void fair_do_hex_symetry2 (int *x, int *y)
 Symetry matrix for hexagonal topologies. More...
 
static void fair_do_iso_hex_symetry1 (int *x, int *y)
 Symetry matrix for hexgonal-isometric topology. More...
 
static void fair_do_rotation (int *x, int *y)
 Rotation matrix, also symetry matrix for hexagonal-isometric topology. More...
 
static void fair_do_hex_rotation (int *x, int *y)
 Rotation matrix for hexgonal topology. More...
 
static void fair_do_iso_hex_rotation (int *x, int *y)
 Rotation matrix for hexgonal-isometric topology. More...
 
static void fair_do_geometry (const struct fair_geometry_data *data, int *x, int *y)
 Perform transformations defined into 'data' to position ('x', 'y'). More...
 
static void fair_geometry_rand (struct fair_geometry_data *data)
 Push random transformations to 'data'. More...
 
static bool fair_map_copy (struct fair_tile *ptarget, int tx, int ty, struct fair_tile *psource, const struct fair_geometry_data *data, int startpos_team_id)
 Copy 'psource' on 'ptarget' at position ('tx', 'ty'), performing transformations defined into 'data'. More...
 
static bool fair_map_place_island_rand (struct fair_tile *ptarget, struct fair_tile *psource)
 Attempts to copy 'psource' to 'ptarget' at a random position, with random geometric effects. More...
 
static bool fair_map_place_island_team (struct fair_tile *ptarget, int tx, int ty, struct fair_tile *psource, const struct iter_index *outwards_indices, int startpos_team_id)
 Attempts to copy 'psource' to 'ptarget' as close as possible of position 'x', 'y' for players of the team 'team_id'. More...
 
static void fair_map_make_resources (struct fair_tile *pmap)
 Add resources on 'pmap'. More...
 
static void fair_map_make_huts (struct fair_tile *pmap)
 Add huts on 'pmap'. More...
 
static struct fair_tilefair_map_island_new (int size, int startpos_num)
 Generate a map where an island would be placed in the center. More...
 
bool map_generate_fair_islands ()
 Build a map using generator 'FAIR'. More...
 

Macro Definition Documentation

◆ fair_do_iso_hex_symetry2

#define fair_do_iso_hex_symetry2   fair_do_rotation

Definition at line 205 of file fair_islands.cpp.

Typedef Documentation

◆ fair_geometry_func

typedef void(* fair_geometry_func) (int *x, int *y)

Definition at line 41 of file fair_islands.cpp.

Enumeration Type Documentation

◆ fair_tile_flag

Fair island generator types.

Enumerator
FTF_NONE 
FTF_ASSIGNED 
FTF_OCEAN 
FTF_STARTPOS 
FTF_NO_RESOURCE 
FTF_HAS_HUT 
FTF_NO_HUT 

Definition at line 23 of file fair_islands.cpp.

Function Documentation

◆ fair_do_geometry()

static void fair_do_geometry ( const struct fair_geometry_data data,
int *  x,
int *  y 
)
static

Perform transformations defined into 'data' to position ('x', 'y').

Definition at line 243 of file fair_islands.cpp.

Referenced by fair_map_copy().

◆ fair_do_hex_rotation()

static void fair_do_hex_rotation ( int *  x,
int *  y 
)
static

Rotation matrix for hexgonal topology.

Definition at line 221 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_hex_symetry1()

static void fair_do_hex_symetry1 ( int *  x,
int *  y 
)
static

Symetry matrix for hexagonal topologies.

Definition at line 189 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_hex_symetry2()

static void fair_do_hex_symetry2 ( int *  x,
int *  y 
)
static

Symetry matrix for hexagonal topologies.

Definition at line 194 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_iso_hex_rotation()

static void fair_do_iso_hex_rotation ( int *  x,
int *  y 
)
static

Rotation matrix for hexgonal-isometric topology.

Definition at line 232 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_iso_hex_symetry1()

static void fair_do_iso_hex_symetry1 ( int *  x,
int *  y 
)
static

Symetry matrix for hexgonal-isometric topology.

Definition at line 203 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_rotation()

static void fair_do_rotation ( int *  x,
int *  y 
)
static

Rotation matrix, also symetry matrix for hexagonal-isometric topology.

Definition at line 210 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_symetry1()

static void fair_do_symetry1 ( int *  x,
int *  y 
)
static

Symetry matrix.

Definition at line 179 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_do_symetry2()

static void fair_do_symetry2 ( int *  x,
int *  y 
)
static

Symetry matrix.

Definition at line 184 of file fair_islands.cpp.

Referenced by fair_geometry_rand().

◆ fair_geometry_rand()

static void fair_geometry_rand ( struct fair_geometry_data data)
static

Push random transformations to 'data'.

Definition at line 256 of file fair_islands.cpp.

Referenced by fair_map_place_island_rand(), and fair_map_place_island_team().

◆ fair_map_copy()

static bool fair_map_copy ( struct fair_tile ptarget,
int  tx,
int  ty,
struct fair_tile psource,
const struct fair_geometry_data data,
int  startpos_team_id 
)
static

Copy 'psource' on 'ptarget' at position ('tx', 'ty'), performing transformations defined into 'data'.

Assign start positions for team 'startpos_team_id'. Return TRUE if we have copied the map, FALSE if the copy was not possible.

Definition at line 307 of file fair_islands.cpp.

Referenced by fair_map_place_island_rand(), and fair_map_place_island_team().

◆ fair_map_destroy()

static void fair_map_destroy ( struct fair_tile pmap)
inlinestatic

Free a map.

Definition at line 50 of file fair_islands.cpp.

◆ fair_map_island_new()

static struct fair_tile* fair_map_island_new ( int  size,
int  startpos_num 
)
static

Generate a map where an island would be placed in the center.

Definition at line 561 of file fair_islands.cpp.

◆ fair_map_make_huts()

static void fair_map_make_huts ( struct fair_tile pmap)
static

Add huts on 'pmap'.

Definition at line 505 of file fair_islands.cpp.

Referenced by fair_map_island_new().

◆ fair_map_make_resources()

static void fair_map_make_resources ( struct fair_tile pmap)
static

Add resources on 'pmap'.

Definition at line 449 of file fair_islands.cpp.

Referenced by fair_map_island_new().

◆ fair_map_place_island_rand()

static bool fair_map_place_island_rand ( struct fair_tile ptarget,
struct fair_tile psource 
)
static

Attempts to copy 'psource' to 'ptarget' at a random position, with random geometric effects.

Definition at line 386 of file fair_islands.cpp.

◆ fair_map_place_island_team()

static bool fair_map_place_island_team ( struct fair_tile ptarget,
int  tx,
int  ty,
struct fair_tile psource,
const struct iter_index outwards_indices,
int  startpos_team_id 
)
static

Attempts to copy 'psource' to 'ptarget' as close as possible of position 'x', 'y' for players of the team 'team_id'.

Definition at line 420 of file fair_islands.cpp.

◆ fair_map_pos_tile()

static struct fair_tile* fair_map_pos_tile ( struct fair_tile pmap,
int  x,
int  y 
)
inlinestatic

Get the tile at the position ('x', 'y').

Definition at line 67 of file fair_islands.cpp.

Referenced by fair_map_copy(), fair_map_island_new(), and fair_map_tile_step().

◆ fair_map_tile_border()

static bool fair_map_tile_border ( struct fair_tile pmap,
struct fair_tile ptile,
int  dist 
)
inlinestatic

Returns whether 'ptile' is at least at 'dist' tiles (in real distance) to the border.

Note is also take in account map wrapping.

Definition at line 111 of file fair_islands.cpp.

Referenced by fair_map_island_new().

◆ fair_map_tile_pos()

static void fair_map_tile_pos ( struct fair_tile pmap,
struct fair_tile ptile,
int *  x,
int *  y 
)
inlinestatic

Get the coordinates of tile 'ptile'.

Definition at line 58 of file fair_islands.cpp.

Referenced by fair_map_copy(), and fair_map_tile_step().

◆ fair_map_tile_step()

static struct fair_tile* fair_map_tile_step ( struct fair_tile pmap,
struct fair_tile ptile,
enum direction8  dir 
)
inlinestatic

Get the next tile in direction 'dir'.

Definition at line 96 of file fair_islands.cpp.

Referenced by fair_map_island_new(), and fair_map_make_resources().

◆ fair_team_placement_closest()

static int fair_team_placement_closest ( const void *  a,
const void *  b 
)
static

Compare two iter_index values for doing closest team placement.

Definition at line 138 of file fair_islands.cpp.

◆ fair_team_placement_horizontal()

static int fair_team_placement_horizontal ( const void *  a,
const void *  b 
)
static

Compare two iter_index values for doing horizontal team placement.

Definition at line 149 of file fair_islands.cpp.

◆ fair_team_placement_vertical()

static int fair_team_placement_vertical ( const void *  a,
const void *  b 
)
static

Compare two iter_index values for doing vertical team placement.

Definition at line 164 of file fair_islands.cpp.

◆ map_generate_fair_islands()

bool map_generate_fair_islands ( )

Build a map using generator 'FAIR'.

Definition at line 880 of file fair_islands.cpp.

Referenced by map_generate().