Feature #707 ยป 0054-map_init_topology-Operate-on-any-map.patch
client/packhand.c | ||
---|---|---|
wld.map.topology_id = packet->topology_id;
|
||
wld.map.wrap_id = packet->wrap_id;
|
||
map_init_topology();
|
||
map_init_topology(&(wld.map));
|
||
main_map_allocate();
|
||
client_player_maps_reset();
|
||
init_client_goto();
|
common/map.c | ||
---|---|---|
imap->startpos_table = nullptr;
|
||
imap->iterate_outwards_indices = nullptr;
|
||
/* The [xy]size values are set in map_init_topology. It is initialized
|
||
/* The [xy]size values are set in map_init_topology(). It is initialized
|
||
* to a non-zero value because some places erroneously use these values
|
||
* before they're initialized. */
|
||
imap->xsize = MAP_DEFAULT_LINEAR_SIZE;
|
||
... | ... | |
This is done by the map generator code (server), when loading a savegame
|
||
or a scenario with map (server), and packhand code (client).
|
||
***********************************************************************/
|
||
void map_init_topology(void)
|
||
void map_init_topology(struct civ_map *nmap)
|
||
{
|
||
enum direction8 dir;
|
||
... | ... | |
fc_assert(map_num_tiles() >= MAP_MIN_SIZE * 1000);
|
||
fc_assert(map_num_tiles() <= MAP_MAX_SIZE * 1000);
|
||
wld.map.num_valid_dirs = wld.map.num_cardinal_dirs = 0;
|
||
nmap->num_valid_dirs = nmap->num_cardinal_dirs = 0;
|
||
/* Values for direction8_invalid() */
|
||
fc_assert(direction8_invalid() == 8);
|
||
... | ... | |
/* Values for actual directions */
|
||
for (dir = 0; dir < 8; dir++) {
|
||
if (is_valid_dir_calculate(dir)) {
|
||
wld.map.valid_dirs[wld.map.num_valid_dirs] = dir;
|
||
wld.map.num_valid_dirs++;
|
||
nmap->valid_dirs[nmap->num_valid_dirs] = dir;
|
||
nmap->num_valid_dirs++;
|
||
dir_validity[dir] = TRUE;
|
||
} else {
|
||
dir_validity[dir] = FALSE;
|
||
}
|
||
if (is_cardinal_dir_calculate(dir)) {
|
||
wld.map.cardinal_dirs[wld.map.num_cardinal_dirs] = dir;
|
||
wld.map.num_cardinal_dirs++;
|
||
nmap->cardinal_dirs[nmap->num_cardinal_dirs] = dir;
|
||
nmap->num_cardinal_dirs++;
|
||
dir_cardinality[dir] = TRUE;
|
||
} else {
|
||
dir_cardinality[dir] = FALSE;
|
||
}
|
||
}
|
||
fc_assert(wld.map.num_valid_dirs > 0 && wld.map.num_valid_dirs <= 8);
|
||
fc_assert(wld.map.num_cardinal_dirs > 0
|
||
&& wld.map.num_cardinal_dirs <= wld.map.num_valid_dirs);
|
||
fc_assert(nmap->num_valid_dirs > 0 && nmap->num_valid_dirs <= 8);
|
||
fc_assert(nmap->num_cardinal_dirs > 0
|
||
&& nmap->num_cardinal_dirs <= nmap->num_valid_dirs);
|
||
}
|
||
/*******************************************************************//**
|
common/map.h | ||
---|---|---|
bool map_is_empty(void);
|
||
void map_init(struct civ_map *imap, bool server_side);
|
||
void map_init_topology(void);
|
||
void map_init_topology(struct civ_map *nmap);
|
||
void map_allocate(struct civ_map *amap);
|
||
void main_map_allocate(void);
|
||
void map_free(struct civ_map *fmap, bool server_side);
|
server/generator/mapgen_topology.c | ||
---|---|---|
sqsize = get_sqsize();
|
||
/* initialize the ICE_BASE_LEVEL */
|
||
/* Initialize the ICE_BASE_LEVEL */
|
||
/* if maps has strip like poles we get smaller poles
|
||
/* If maps has strip like poles we get smaller poles
|
||
* (less playables than island poles)
|
||
* 5% for little maps
|
||
* 2% for big ones, if map.server.temperature == 50
|
||
* except if separate poles is set */
|
||
if (wld.map.server.separatepoles) {
|
||
/* with separatepoles option strip poles are useless */
|
||
/* With separatepoles option strip poles are useless */
|
||
ice_base_colatitude =
|
||
(MAX(0, 100 * COLD_LEVEL / 3 - 1 * MAX_COLATITUDE)
|
||
+ 1 * MAX_COLATITUDE * sqsize) / (100 * sqsize);
|
||
} else {
|
||
/* any way strip poles are not so playable as isle poles */
|
||
/* Any way strip poles are not so playable as isle poles */
|
||
ice_base_colatitude =
|
||
(MAX(0, 100 * COLD_LEVEL / 3 - 2 * MAX_COLATITUDE)
|
||
+ 2 * MAX_COLATITUDE * sqsize) / (100 * sqsize);
|
||
... | ... | |
wld.map.server.huts_absolute = -1;
|
||
}
|
||
map_init_topology();
|
||
map_init_topology(&(wld.map));
|
||
}
|
||
/************************************************************************//**
|
server/savegame/savegame2.c | ||
---|---|---|
/* Initialize the map for the current topology. 'map.xsize' and
|
||
* 'map.ysize' must be set. */
|
||
map_init_topology();
|
||
map_init_topology(&(wld.map));
|
||
/* Allocate map. */
|
||
main_map_allocate();
|
server/savegame/savegame3.c | ||
---|---|---|
/* Initialize the map for the current topology. 'map.xsize' and
|
||
* 'map.ysize' must be set. */
|
||
map_init_topology();
|
||
map_init_topology(&(wld.map));
|
||
/* Allocate map. */
|
||
main_map_allocate();
|