Feature #110 ยป 0019-Add-MAP_-_DIRS-macros-to-world_object.h.patch
| common/map.c | ||
|---|---|---|
|
***********************************************************************/
|
||
|
enum direction8 rand_direction(void)
|
||
|
{
|
||
|
return wld.map.valid_dirs[fc_rand(wld.map.num_valid_dirs)];
|
||
|
return MAP_VALID_DIRS[fc_rand(MAP_NUM_VALID_DIRS)];
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
| common/terrain.c | ||
|---|---|---|
|
on the value of card_only.
|
||
|
**************************************************************************/
|
||
|
#define variable_adjc_iterate(nmap, center_tile, _tile, card_only) \
|
||
|
{ \
|
||
|
enum direction8 *_tile##_list; \
|
||
|
int _tile##_count; \
|
||
|
\
|
||
|
if (card_only) { \
|
||
|
_tile##_list = wld.map.cardinal_dirs; \
|
||
|
_tile##_count = wld.map.num_cardinal_dirs; \
|
||
|
} else { \
|
||
|
_tile##_list = wld.map.valid_dirs; \
|
||
|
_tile##_count = wld.map.num_valid_dirs; \
|
||
|
} \
|
||
|
{ \
|
||
|
enum direction8 *_tile##_list; \
|
||
|
int _tile##_count; \
|
||
|
\
|
||
|
if (card_only) { \
|
||
|
_tile##_list = MAP_CARDINAL_DIRS; \
|
||
|
_tile##_count = MAP_NUM_CARDINAL_DIRS; \
|
||
|
} else { \
|
||
|
_tile##_list = MAP_VALID_DIRS; \
|
||
|
_tile##_count = MAP_NUM_VALID_DIRS; \
|
||
|
} \
|
||
|
adjc_dirlist_iterate(nmap, center_tile, _tile, _tile##_dir, \
|
||
|
_tile##_list, _tile##_count) {
|
||
|
#define variable_adjc_iterate_end \
|
||
|
} adjc_dirlist_iterate_end; \
|
||
|
#define variable_adjc_iterate_end \
|
||
|
} adjc_dirlist_iterate_end; \
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| common/world_object.h | ||
|---|---|---|
|
#define MAP_NATURAL_WIDTH (MAP_IS_ISOMETRIC ? 2 * wld.map.xsize : wld.map.xsize)
|
||
|
#define MAP_NATURAL_HEIGHT wld.map.ysize
|
||
|
#define MAP_CARDINAL_DIRS wld.map.cardinal_dirs
|
||
|
#define MAP_NUM_CARDINAL_DIRS wld.map.num_cardinal_dirs
|
||
|
#define MAP_VALID_DIRS wld.map.valid_dirs
|
||
|
#define MAP_NUM_VALID_DIRS wld.map.num_valid_dirs
|
||
|
#ifdef __cplusplus
|
||
|
}
|
||
| server/advisors/autoexplorer.c | ||
|---|---|---|
|
}
|
||
|
} adjc_dir_iterate_end;
|
||
|
return 50 + (50 / wld.map.num_valid_dirs * (native - foreign));
|
||
|
return 50 + (50 / MAP_NUM_VALID_DIRS * (native - foreign));
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| server/generator/mapgen.c | ||
|---|---|---|
|
if (pftile->flags & FTF_OCEAN) {
|
||
|
bool land_around = FALSE;
|
||
|
for (j = 0; j < wld.map.num_valid_dirs; j++) {
|
||
|
pftile2 = fair_map_tile_step(pmap, pftile, wld.map.valid_dirs[j]);
|
||
|
for (j = 0; j < MAP_NUM_VALID_DIRS; j++) {
|
||
|
pftile2 = fair_map_tile_step(pmap, pftile, MAP_VALID_DIRS[j]);
|
||
|
if (pftile2 != NULL
|
||
|
&& pftile2->flags & FTF_ASSIGNED
|
||
|
&& !(pftile2->flags & FTF_OCEAN)) {
|
||
| ... | ... | |
|
* resource for the terrain. */
|
||
|
if (pftile->presource != NULL) {
|
||
|
pftile->flags |= FTF_NO_RESOURCE;
|
||
|
for (j = 0; j < wld.map.num_valid_dirs; j++) {
|
||
|
pftile2 = fair_map_tile_step(pmap, pftile, wld.map.valid_dirs[j]);
|
||
|
for (j = 0; j < MAP_NUM_VALID_DIRS; j++) {
|
||
|
pftile2 = fair_map_tile_step(pmap, pftile, MAP_VALID_DIRS[j]);
|
||
|
if (pftile2 != NULL) {
|
||
|
pftile2->flags |= FTF_NO_RESOURCE;
|
||
|
}
|
||
| ... | ... | |
|
while (i < fantasy) {
|
||
|
pftile = land_tiles[fc_rand(i)];
|
||
|
for (j = 0; j < wld.map.num_valid_dirs; j++) {
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile, wld.map.valid_dirs[j]);
|
||
|
for (j = 0; j < MAP_NUM_VALID_DIRS; j++) {
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile, MAP_VALID_DIRS[j]);
|
||
|
fc_assert(pftile2 != NULL);
|
||
|
if (fair_map_tile_border(pisland, pftile2, sea_around_island)) {
|
||
|
continue;
|
||
| ... | ... | |
|
}
|
||
|
while (i < size) {
|
||
|
pftile = land_tiles[i - fc_rand(fantasy) - 1];
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile, wld.map.cardinal_dirs
|
||
|
[fc_rand(wld.map.num_cardinal_dirs)]);
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile,
|
||
|
MAP_CARDINAL_DIRS[fc_rand(MAP_NUM_CARDINAL_DIRS)]);
|
||
|
fc_assert(pftile2 != NULL);
|
||
|
if (fair_map_tile_border(pisland, pftile2, sea_around_island)) {
|
||
|
continue;
|
||
| ... | ... | |
|
if (river_type_count > 0) {
|
||
|
struct extra_type *priver;
|
||
|
struct fair_tile *pend;
|
||
|
int n = ((river_pct * size * wld.map.num_cardinal_dirs
|
||
|
* wld.map.num_cardinal_dirs) / 200);
|
||
|
int n = ((river_pct * size * MAP_NUM_CARDINAL_DIRS
|
||
|
* MAP_NUM_CARDINAL_DIRS) / 200);
|
||
|
int length_max = 3, length, l;
|
||
|
enum direction8 dir;
|
||
|
int extra_idx;
|
||
| ... | ... | |
|
river_around = 0;
|
||
|
connectable_river_around = FALSE;
|
||
|
ocean_around = FALSE;
|
||
|
for (j = 0; j < wld.map.num_valid_dirs; j++) {
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile, wld.map.valid_dirs[j]);
|
||
|
for (j = 0; j < MAP_NUM_VALID_DIRS; j++) {
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile, MAP_VALID_DIRS[j]);
|
||
|
if (pftile2 == NULL) {
|
||
|
continue;
|
||
|
}
|
||
| ... | ... | |
|
break;
|
||
|
} else if (BV_ISSET(pftile2->extras, extra_idx)) {
|
||
|
river_around++;
|
||
|
if (!cardinal_only || is_cardinal_dir(wld.map.valid_dirs[j])) {
|
||
|
if (!cardinal_only || is_cardinal_dir(MAP_VALID_DIRS[j])) {
|
||
|
connectable_river_around = TRUE;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
length = -1;
|
||
|
dir = direction8_invalid();
|
||
|
dirs_num = 0;
|
||
|
for (j = 0; j < wld.map.num_valid_dirs; j++) {
|
||
|
if (cardinal_only && !is_cardinal_dir(wld.map.valid_dirs[j])) {
|
||
|
for (j = 0; j < MAP_NUM_VALID_DIRS; j++) {
|
||
|
if (cardinal_only && !is_cardinal_dir(MAP_VALID_DIRS[j])) {
|
||
|
continue;
|
||
|
}
|
||
|
finished = FALSE;
|
||
|
pftile2 = pftile;
|
||
|
for (l = 2; l < length_max; l++) {
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile2, wld.map.valid_dirs[j]);
|
||
|
pftile2 = fair_map_tile_step(pisland, pftile2, MAP_VALID_DIRS[j]);
|
||
|
if (pftile2 == NULL
|
||
|
|| !terrain_has_flag(pftile2->pterrain, TER_CAN_HAVE_RIVER)) {
|
||
|
break;
|
||
| ... | ... | |
|
river_around = 0;
|
||
|
connectable_river_around = FALSE;
|
||
|
ocean_around = FALSE;
|
||
|
for (k = 0; k < wld.map.num_valid_dirs; k++) {
|
||
|
if (wld.map.valid_dirs[k] == DIR_REVERSE(wld.map.valid_dirs[j])) {
|
||
|
for (k = 0; k < MAP_NUM_VALID_DIRS; k++) {
|
||
|
if (wld.map.valid_dirs[k] == DIR_REVERSE(MAP_VALID_DIRS[j])) {
|
||
|
continue;
|
||
|
}
|
||
|
pftile3 = fair_map_tile_step(pisland, pftile2,
|
||
|
wld.map.valid_dirs[k]);
|
||
|
MAP_VALID_DIRS[k]);
|
||
|
if (pftile3 == NULL) {
|
||
|
continue;
|
||
|
}
|
||
|
if (pftile3->flags & FTF_OCEAN) {
|
||
|
if (!cardinal_only || is_cardinal_dir(wld.map.valid_dirs[k])) {
|
||
|
if (!cardinal_only || is_cardinal_dir(MAP_VALID_DIRS[k])) {
|
||
|
ocean_around = TRUE;
|
||
|
}
|
||
|
} else if (BV_ISSET(pftile3->extras, extra_idx)) {
|
||
|
river_around++;
|
||
|
if (!cardinal_only || is_cardinal_dir(wld.map.valid_dirs[k])) {
|
||
|
if (!cardinal_only || is_cardinal_dir(MAP_VALID_DIRS[k])) {
|
||
|
connectable_river_around = TRUE;
|
||
|
}
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
}
|
||
|
if (finished && fc_rand(++dirs_num) == 0) {
|
||
|
dir = wld.map.valid_dirs[j];
|
||
|
dir = MAP_VALID_DIRS[j];
|
||
|
pend = pftile2;
|
||
|
length = l;
|
||
|
}
|
||
| server/generator/mapgen_utils.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
static struct terrain *most_adjacent_ocean_type(const struct tile *ptile)
|
||
|
{
|
||
|
const int need = 2 * wld.map.num_valid_dirs / 3;
|
||
|
const int need = 2 * MAP_NUM_VALID_DIRS / 3;
|
||
|
int count;
|
||
|
terrain_type_iterate(pterrain) {
|
||