Feature #71 » 0008-Make-terrain.c-functions-to-take-map-as-parameter.patch
| ai/default/aiferry.c | ||
|---|---|---|
|
bool aiferry_gobyboat(struct ai_type *ait, struct player *pplayer,
|
||
|
struct unit *punit, struct tile *dest_tile, bool with_bodyguard)
|
||
|
{
|
||
|
struct civ_map *nmap = &(wld.map);
|
||
|
if (!unit_transported(punit)) {
|
||
|
/* We are not on a boat and we cannot walk */
|
||
|
int boatid;
|
||
| ... | ... | |
|
UNIT_LOG(LOGLEVEL_GOBYBOAT, punit, "will have to go to (%d,%d) by boat",
|
||
|
TILE_XY(dest_tile));
|
||
|
if (!is_terrain_class_near_tile(unit_tile(punit), TC_OCEAN)) {
|
||
|
if (!is_terrain_class_near_tile(nmap, unit_tile(punit), TC_OCEAN)) {
|
||
|
struct pf_path *path_to_ferry = NULL;
|
||
|
boatid = aiferry_find_boat(ait, punit, cap, &path_to_ferry);
|
||
| ... | ... | |
|
pf_path_destroy(path_to_ferry);
|
||
|
}
|
||
|
if (!is_terrain_class_near_tile(unit_tile(punit), TC_OCEAN)) {
|
||
|
if (!is_terrain_class_near_tile(nmap, unit_tile(punit), TC_OCEAN)) {
|
||
|
/* Still haven't reached the coast */
|
||
|
return FALSE;
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
/* ===================== boat management ================================= */
|
||
|
/* ===================== Boat management ================================= */
|
||
|
/**********************************************************************//**
|
||
|
A helper for ai_manage_ferryboat. Finds a passenger for the ferry.
|
||
|
A helper for ai_manage_ferryboat. Finds a passenger for the ferry.
|
||
|
Potential passengers signal the boats by setting their ai.ferry field to
|
||
|
FERRY_WANTED.
|
||
|
TODO: lift the path off the map
|
||
|
TODO: Lift the path off the map
|
||
|
**************************************************************************/
|
||
|
static bool aiferry_findcargo(struct ai_type *ait, struct unit *pferry)
|
||
|
{
|
||
| ai/default/aiunit.c | ||
|---|---|---|
|
atype = unit_type_get(aunit);
|
||
|
/* dealing with invasion stuff */
|
||
|
/* Dealing with invasion stuff */
|
||
|
if (IS_ATTACKER(atype)) {
|
||
|
if (aunit->activity == ACTIVITY_GOTO) {
|
||
|
invasion_funct(ait, aunit, TRUE, 0,
|
||
| ... | ... | |
|
aiferry_find_boat(ait, punit, 1, NULL));
|
||
|
}
|
||
|
if (0 == punit->id && is_terrain_class_near_tile(punit_tile, TC_OCEAN)) {
|
||
|
if (punit->id == 0 && is_terrain_class_near_tile(nmap, punit_tile, TC_OCEAN)) {
|
||
|
harbor = TRUE;
|
||
|
}
|
||
|
}
|
||
| ai/default/daieffects.c | ||
|---|---|---|
|
v += (get_entertainers(pcity) + pcity->feel[CITIZEN_UNHAPPY][FEELING_FINAL]) * 5 * amount;
|
||
|
if (city_list_size(pplayer->cities)
|
||
|
> get_player_bonus(pplayer, EFT_EMPIRE_SIZE_BASE)) {
|
||
|
v += c * amount; /* offset large empire size */
|
||
|
v += c * amount; /* Offset large empire size */
|
||
|
}
|
||
|
v += c * amount;
|
||
|
break;
|
||
| ... | ... | |
|
case EFT_HAVE_CONTACTS:
|
||
|
{
|
||
|
int new_contacts = 0;
|
||
|
|
||
|
players_iterate_alive(theother) {
|
||
|
if (player_diplstate_get(pplayer, theother)->contact_turns_left <= 0) {
|
||
|
new_contacts++;
|
||
| ... | ... | |
|
/* FIXME: This ignores riverboats on some rulesets.
|
||
|
We should analyze rulesets when game starts
|
||
|
and have relevant checks here. */
|
||
|
&& is_terrain_class_near_tile(pcity->tile, TC_OCEAN))) {
|
||
|
&& is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN))) {
|
||
|
if (place > 0 && adv->threats.continent[place]) {
|
||
|
v += amount * 4 / 5;
|
||
|
} else {
|
||
| ai/default/daisettler.c | ||
|---|---|---|
|
*****************************************************************************/
|
||
|
static adv_want naval_bonus(const struct cityresult *result)
|
||
|
{
|
||
|
bool ocean_adjacent = is_terrain_class_near_tile(result->tile, TC_OCEAN);
|
||
|
bool ocean_adjacent = is_terrain_class_near_tile(&(wld.map),
|
||
|
result->tile, TC_OCEAN);
|
||
|
/* Adjust for ocean adjacency, which is nice */
|
||
|
if (ocean_adjacent) {
|
||
| ... | ... | |
|
}
|
||
|
if (ferry || (use_virt_boat
|
||
|
&& is_terrain_class_near_tile(unit_tile(punit), TC_OCEAN)
|
||
|
&& is_terrain_class_near_tile(&(wld.map),
|
||
|
unit_tile(punit), TC_OCEAN)
|
||
|
&& tile_city(unit_tile(punit)))) {
|
||
|
if (!ferry) {
|
||
|
/* No boat? Get a virtual one! */
|
||
| ... | ... | |
|
if (is_ai(pplayer)) {
|
||
|
struct cityresult *result;
|
||
|
bool is_coastal = is_terrain_class_near_tile(pcenter, TC_OCEAN);
|
||
|
bool is_coastal = is_terrain_class_near_tile(&(wld.map), pcenter, TC_OCEAN);
|
||
|
struct ai_city *city_data = def_ai_city_data(pcity, ait);
|
||
|
result = find_best_city_placement(ait, virtualunit, is_coastal, is_coastal);
|
||
| client/gui-gtk-3.22/cityrep.c | ||
|---|---|---|
|
for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
|
||
|
struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
|
||
|
if (NULL != pcity && is_terrain_class_near_tile(pcity->tile, TC_OCEAN)) {
|
||
|
if (pcity != NULL
|
||
|
&& is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
|
||
|
itree_select(city_selection, &it);
|
||
|
}
|
||
|
}
|
||
| client/gui-gtk-4.0/cityrep.c | ||
|---|---|---|
|
for (itree_begin(model, &it); !itree_end(&it); itree_next(&it)) {
|
||
|
struct city *pcity = city_model_get(model, TREE_ITER_PTR(it));
|
||
|
if (NULL != pcity && is_terrain_class_near_tile(pcity->tile, TC_OCEAN)) {
|
||
|
if (pcity != NULL
|
||
|
&& is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
|
||
|
itree_select(city_selection, &it);
|
||
|
}
|
||
|
}
|
||
| client/gui-qt/cityrep.cpp | ||
|---|---|---|
|
continue;
|
||
|
}
|
||
|
pcity = reinterpret_cast<city *>(qvar.value<void *>());
|
||
|
if (NULL != pcity && is_terrain_class_near_tile(pcity->tile, TC_OCEAN)) {
|
||
|
if (pcity != nullptr
|
||
|
&& is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
|
||
|
selection.append(QItemSelectionRange(i));
|
||
|
}
|
||
|
}
|
||
| common/map.c | ||
|---|---|---|
|
***********************************************************************/
|
||
|
bool can_reclaim_ocean(const struct tile *ptile)
|
||
|
{
|
||
|
int land_tiles = 100 - count_terrain_class_near_tile(ptile, FALSE, TRUE,
|
||
|
int land_tiles = 100 - count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
FALSE, TRUE,
|
||
|
TC_OCEAN);
|
||
|
return land_tiles >= terrain_control.ocean_reclaim_requirement_pct;
|
||
| ... | ... | |
|
***********************************************************************/
|
||
|
bool can_channel_land(const struct tile *ptile)
|
||
|
{
|
||
|
int ocean_tiles = count_terrain_class_near_tile(ptile, FALSE, TRUE, TC_OCEAN);
|
||
|
int ocean_tiles = count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
FALSE, TRUE, TC_OCEAN);
|
||
|
return ocean_tiles >= terrain_control.land_channel_requirement_pct;
|
||
|
}
|
||
|
/*******************************************************************//**
|
||
|
Returns true if the tile at the given location can be thawed from
|
||
|
terrain with a 'Frozen' flag to terrain without. This requires a
|
||
|
sufficient number of adjacent unfrozen tiles.
|
||
|
terrain with a 'Frozen' flag to terrain without. This requires
|
||
|
a sufficient number of adjacent unfrozen tiles.
|
||
|
***********************************************************************/
|
||
|
bool can_thaw_terrain(const struct tile *ptile)
|
||
|
{
|
||
|
int unfrozen_tiles = 100 - count_terrain_flag_near_tile(ptile, FALSE, TRUE,
|
||
|
int unfrozen_tiles = 100 - count_terrain_flag_near_tile(&(wld.map), ptile,
|
||
|
FALSE, TRUE,
|
||
|
TER_FROZEN);
|
||
|
return unfrozen_tiles >= terrain_control.terrain_thaw_requirement_pct;
|
||
| ... | ... | |
|
/*******************************************************************//**
|
||
|
Returns true if the tile at the given location can be turned from
|
||
|
terrain without a 'Frozen' flag to terrain with. This requires a
|
||
|
sufficient number of adjacent frozen tiles.
|
||
|
terrain without a 'Frozen' flag to terrain with. This requires
|
||
|
a sufficient number of adjacent frozen tiles.
|
||
|
***********************************************************************/
|
||
|
bool can_freeze_terrain(const struct tile *ptile)
|
||
|
{
|
||
|
int frozen_tiles = count_terrain_flag_near_tile(ptile, FALSE, TRUE,
|
||
|
int frozen_tiles = count_terrain_flag_near_tile(&(wld.map), ptile,
|
||
|
FALSE, TRUE,
|
||
|
TER_FROZEN);
|
||
|
return frozen_tiles >= terrain_control.terrain_freeze_requirement_pct;
|
||
| common/requirements.c | ||
|---|---|---|
|
if (!context->tile) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(pterrain && is_terrain_card_near(context->tile, pterrain, TRUE));
|
||
|
return BOOL_TO_TRISTATE(pterrain && is_terrain_card_near(nmap, context->tile, pterrain, TRUE));
|
||
|
case REQ_RANGE_ADJACENT:
|
||
|
if (!context->tile) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(pterrain && is_terrain_near_tile(context->tile, pterrain, TRUE));
|
||
|
return BOOL_TO_TRISTATE(pterrain && is_terrain_near_tile(nmap, context->tile, pterrain, TRUE));
|
||
|
case REQ_RANGE_CITY:
|
||
|
if (!context->city) {
|
||
|
return TRI_MAYBE;
|
||
| ... | ... | |
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(terrain_type_terrain_class(tile_terrain(context->tile)) == pclass
|
||
|
|| is_terrain_class_card_near(context->tile, pclass));
|
||
|
|| is_terrain_class_card_near(nmap, context->tile, pclass));
|
||
|
case REQ_RANGE_ADJACENT:
|
||
|
if (!context->tile) {
|
||
|
return TRI_MAYBE;
|
||
|
}
|
||
|
return BOOL_TO_TRISTATE(terrain_type_terrain_class(tile_terrain(context->tile)) == pclass
|
||
|
|| is_terrain_class_near_tile(context->tile, pclass));
|
||
|
|| is_terrain_class_near_tile(nmap, context->tile, pclass));
|
||
|
case REQ_RANGE_CITY:
|
||
|
if (!context->city) {
|
||
|
return TRI_MAYBE;
|
||
| ... | ... | |
|
}
|
||
|
return BOOL_TO_TRISTATE(terrain_has_flag(tile_terrain(context->tile),
|
||
|
terrflag)
|
||
|
|| is_terrain_flag_card_near(context->tile,
|
||
|
|| is_terrain_flag_card_near(nmap, context->tile,
|
||
|
terrflag));
|
||
|
case REQ_RANGE_ADJACENT:
|
||
|
if (!context->tile) {
|
||
| ... | ... | |
|
}
|
||
|
return BOOL_TO_TRISTATE(terrain_has_flag(tile_terrain(context->tile),
|
||
|
terrflag)
|
||
|
|| is_terrain_flag_near_tile(context->tile,
|
||
|
|| is_terrain_flag_near_tile(nmap, context->tile,
|
||
|
terrflag));
|
||
|
case REQ_RANGE_CITY:
|
||
|
if (!context->city) {
|
||
| common/terrain.c | ||
|---|---|---|
|
/**********************************************************************//**
|
||
|
Returns TRUE iff any cardinally adjacent tile contains the given terrain.
|
||
|
**************************************************************************/
|
||
|
bool is_terrain_card_near(const struct tile *ptile,
|
||
|
const struct terrain *pterrain,
|
||
|
bool is_terrain_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct terrain *pterrain,
|
||
|
bool check_self)
|
||
|
{
|
||
|
if (!pterrain) {
|
||
|
if (pterrain == NULL) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
cardinal_adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
if (tile_terrain(adjc_tile) == pterrain) {
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Returns TRUE iff any adjacent tile contains the given terrain.
|
||
|
**************************************************************************/
|
||
|
bool is_terrain_near_tile(const struct tile *ptile,
|
||
|
const struct terrain *pterrain,
|
||
|
bool is_terrain_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct terrain *pterrain,
|
||
|
bool check_self)
|
||
|
{
|
||
|
if (!pterrain) {
|
||
|
if (pterrain == NULL) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
if (tile_terrain(adjc_tile) == pterrain) {
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Return the number of adjacent tiles that have the given terrain property.
|
||
|
**************************************************************************/
|
||
|
int count_terrain_property_near_tile(const struct tile *ptile,
|
||
|
int count_terrain_property_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
bool cardinal_only, bool percentage,
|
||
|
enum mapgen_terrain_property prop)
|
||
|
{
|
||
|
int count = 0, total = 0;
|
||
|
variable_adjc_iterate(&(wld.map), ptile, adjc_tile, cardinal_only) {
|
||
|
variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
|
||
|
struct terrain *pterrain = tile_terrain(adjc_tile);
|
||
|
if (pterrain->property[prop] > 0) {
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Returns TRUE iff any cardinally adjacent tile contains the given resource.
|
||
|
**************************************************************************/
|
||
|
bool is_resource_card_near(const struct tile *ptile,
|
||
|
bool is_resource_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct extra_type *pres,
|
||
|
bool check_self)
|
||
|
{
|
||
|
if (!pres) {
|
||
|
if (pres == NULL) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
cardinal_adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
if (tile_resource(adjc_tile) == pres) {
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
/**********************************************************************//**
|
||
|
Returns TRUE iff any adjacent tile contains the given resource.
|
||
|
**************************************************************************/
|
||
|
bool is_resource_near_tile(const struct tile *ptile,
|
||
|
bool is_resource_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct extra_type *pres,
|
||
|
bool check_self)
|
||
|
{
|
||
|
if (!pres) {
|
||
|
if (pres == NULL) {
|
||
|
return FALSE;
|
||
|
}
|
||
|
adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
if (tile_resource(adjc_tile) == pres) {
|
||
|
return TRUE;
|
||
|
}
|
||
| ... | ... | |
|
Returns TRUE iff any cardinally adjacent tile contains terrain with the
|
||
|
given flag (does not check ptile itself).
|
||
|
**************************************************************************/
|
||
|
bool is_terrain_flag_card_near(const struct tile *ptile,
|
||
|
bool is_terrain_flag_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
enum terrain_flag_id flag)
|
||
|
{
|
||
|
cardinal_adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
struct terrain* pterrain = tile_terrain(adjc_tile);
|
||
|
if (T_UNKNOWN != pterrain
|
||
|
&& terrain_has_flag(pterrain, flag)) {
|
||
|
&& terrain_has_flag(pterrain, flag)) {
|
||
|
return TRUE;
|
||
|
}
|
||
|
} cardinal_adjc_iterate_end;
|
||
| ... | ... | |
|
Returns TRUE iff any adjacent tile contains terrain with the given flag
|
||
|
(does not check ptile itself).
|
||
|
**************************************************************************/
|
||
|
bool is_terrain_flag_near_tile(const struct tile *ptile,
|
||
|
bool is_terrain_flag_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
enum terrain_flag_id flag)
|
||
|
{
|
||
|
adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
struct terrain* pterrain = tile_terrain(adjc_tile);
|
||
|
if (T_UNKNOWN != pterrain
|
||
|
&& terrain_has_flag(pterrain, flag)) {
|
||
|
&& terrain_has_flag(pterrain, flag)) {
|
||
|
return TRUE;
|
||
|
}
|
||
|
} adjc_iterate_end;
|
||
| ... | ... | |
|
Return the number of adjacent tiles that have terrain with the given flag
|
||
|
(not including ptile itself).
|
||
|
**************************************************************************/
|
||
|
int count_terrain_flag_near_tile(const struct tile *ptile,
|
||
|
int count_terrain_flag_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
bool cardinal_only, bool percentage,
|
||
|
enum terrain_flag_id flag)
|
||
|
{
|
||
|
int count = 0, total = 0;
|
||
|
variable_adjc_iterate(&(wld.map), ptile, adjc_tile, cardinal_only) {
|
||
|
variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
|
||
|
struct terrain *pterrain = tile_terrain(adjc_tile);
|
||
|
if (T_UNKNOWN != pterrain
|
||
|
&& terrain_has_flag(pterrain, flag)) {
|
||
|
&& terrain_has_flag(pterrain, flag)) {
|
||
|
count++;
|
||
|
}
|
||
|
total++;
|
||
| ... | ... | |
|
Is there terrain of the given class cardinally near tile?
|
||
|
(Does not check ptile itself.)
|
||
|
**************************************************************************/
|
||
|
bool is_terrain_class_card_near(const struct tile *ptile,
|
||
|
bool is_terrain_class_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
enum terrain_class tclass)
|
||
|
{
|
||
|
cardinal_adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
cardinal_adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
struct terrain* pterrain = tile_terrain(adjc_tile);
|
||
|
if (pterrain != T_UNKNOWN) {
|
||
| ... | ... | |
|
Is there terrain of the given class near tile?
|
||
|
(Does not check ptile itself.)
|
||
|
**************************************************************************/
|
||
|
bool is_terrain_class_near_tile(const struct tile *ptile,
|
||
|
bool is_terrain_class_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
enum terrain_class tclass)
|
||
|
{
|
||
|
adjc_iterate(&(wld.map), ptile, adjc_tile) {
|
||
|
adjc_iterate(nmap, ptile, adjc_tile) {
|
||
|
struct terrain* pterrain = tile_terrain(adjc_tile);
|
||
|
if (pterrain != T_UNKNOWN) {
|
||
| ... | ... | |
|
Return the number of adjacent tiles that have given terrain class
|
||
|
(not including ptile itself).
|
||
|
**************************************************************************/
|
||
|
int count_terrain_class_near_tile(const struct tile *ptile,
|
||
|
int count_terrain_class_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
bool cardinal_only, bool percentage,
|
||
|
enum terrain_class tclass)
|
||
|
{
|
||
|
int count = 0, total = 0;
|
||
|
variable_adjc_iterate(&(wld.map), ptile, adjc_tile, cardinal_only) {
|
||
|
variable_adjc_iterate(nmap, ptile, adjc_tile, cardinal_only) {
|
||
|
struct terrain *pterrain = tile_terrain(adjc_tile);
|
||
|
if (T_UNKNOWN != pterrain
|
||
| common/terrain.h | ||
|---|---|---|
|
/* Functions to operate on a terrain flag. */
|
||
|
#define terrain_has_flag(terr, flag) BV_ISSET((terr)->flags, flag)
|
||
|
bool is_terrain_flag_card_near(const struct tile *ptile,
|
||
|
bool is_terrain_flag_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
enum terrain_flag_id flag);
|
||
|
bool is_terrain_flag_near_tile(const struct tile *ptile,
|
||
|
bool is_terrain_flag_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
enum terrain_flag_id flag);
|
||
|
int count_terrain_flag_near_tile(const struct tile *ptile,
|
||
|
int count_terrain_flag_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
bool cardinal_only, bool percentage,
|
||
|
enum terrain_flag_id flag);
|
||
|
void user_terrain_flags_init(void);
|
||
| ... | ... | |
|
const struct extra_type *presource);
|
||
|
/* Functions to operate on a general terrain type. */
|
||
|
bool is_terrain_card_near(const struct tile *ptile,
|
||
|
bool is_terrain_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct terrain *pterrain,
|
||
|
bool check_self);
|
||
|
bool is_terrain_near_tile(const struct tile *ptile,
|
||
|
bool is_terrain_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct terrain *pterrain,
|
||
|
bool check_self);
|
||
|
int count_terrain_property_near_tile(const struct tile *ptile,
|
||
|
int count_terrain_property_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
bool cardinal_only, bool percentage,
|
||
|
enum mapgen_terrain_property prop);
|
||
|
bool is_resource_card_near(const struct tile *ptile,
|
||
|
bool is_resource_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct extra_type *pres,
|
||
|
bool check_self);
|
||
|
bool is_resource_near_tile(const struct tile *ptile,
|
||
|
bool is_resource_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
const struct extra_type *pres,
|
||
|
bool check_self);
|
||
| ... | ... | |
|
const char *terrain_class_name_translation(enum terrain_class tclass);
|
||
|
enum terrain_class terrain_type_terrain_class(const struct terrain *pterrain);
|
||
|
bool is_terrain_class_card_near(const struct tile *ptile, enum terrain_class tclass);
|
||
|
bool is_terrain_class_near_tile(const struct tile *ptile, enum terrain_class tclass);
|
||
|
int count_terrain_class_near_tile(const struct tile *ptile,
|
||
|
bool is_terrain_class_card_near(const struct civ_map *nmap,
|
||
|
const struct tile *ptile, enum terrain_class tclass);
|
||
|
bool is_terrain_class_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile, enum terrain_class tclass);
|
||
|
int count_terrain_class_near_tile(const struct civ_map *nmap,
|
||
|
const struct tile *ptile,
|
||
|
bool cardinal_only, bool percentage,
|
||
|
enum terrain_class tclass);
|
||
| server/advisors/advbuilding.c | ||
|---|---|---|
|
}
|
||
|
}
|
||
|
if (is_terrain_class_near_tile(pcity->tile, TC_OCEAN)) {
|
||
|
if (is_terrain_class_near_tile(&(wld.map), pcity->tile, TC_OCEAN)) {
|
||
|
value /= 2;
|
||
|
}
|
||
| server/citytools.c | ||
|---|---|---|
|
terrain_type_iterate(pterrain) {
|
||
|
/* Now we do the same for every available terrain. */
|
||
|
goodness = nation_city_terrain_preference(pncity, pterrain);
|
||
|
if (!is_terrain_near_tile(ptile, pterrain, TRUE)) {
|
||
|
if (!is_terrain_near_tile(&(wld.map), ptile, pterrain, TRUE)) {
|
||
|
goodness = nation_city_preference_revert(goodness);
|
||
|
}
|
||
|
switch (goodness) {
|
||
| ... | ... | |
|
* - (if required) only cities native to the class */
|
||
|
if ((best_dist == -1 || city_dist < best_dist)
|
||
|
&& (!only_continent || con == tile_continent(pcity->tile))
|
||
|
&& (!only_ocean || is_terrain_class_near_tile(city_tile(pcity), TC_OCEAN))
|
||
|
&& (!only_ocean || is_terrain_class_near_tile(&(wld.map),
|
||
|
city_tile(pcity), TC_OCEAN))
|
||
|
&& (!only_known
|
||
|
|| (map_is_known(city_tile(pcity), pplayer)
|
||
|
&& map_get_player_site(city_tile(pcity), pplayer)->identity
|
||
| server/generator/fracture_map.c | ||
|---|---|---|
|
int total_mtns;
|
||
|
int iter;
|
||
|
/* compute the land area */
|
||
|
/* Compute the land area */
|
||
|
landarea = 0;
|
||
|
whole_map_iterate(&(wld.map), ptile) {
|
||
|
if (hmap(ptile) > hmap_shore_level) {
|
||
| ... | ... | |
|
*/
|
||
|
total_mtns = 0;
|
||
|
whole_map_iterate(&(wld.map), ptile) {
|
||
|
if (not_placed(ptile) && hmap(ptile) > hmap_shore_level) { /* place on land only */
|
||
|
/* mountains */
|
||
|
if (not_placed(ptile) && hmap(ptile) > hmap_shore_level) { /* Place on land only */
|
||
|
/* Mountains */
|
||
|
choose_mountain = (hmap(ptile) > local_ave_elevation(ptile) * 1.20)
|
||
|
|| (area_is_too_flat(ptile, hmap_mountain_level, hmap(ptile)) && (fc_rand(10) < 4));
|
||
|
choose_hill = (hmap(ptile) > local_ave_elevation(ptile) * 1.10)
|
||
|
|| (area_is_too_flat(ptile, hmap_mountain_level, hmap(ptile)) && (fc_rand(10) < 4));
|
||
|
/* The following avoids hills and mountains directly along the coast. */
|
||
|
if (count_terrain_class_near_tile(ptile, TRUE, TRUE, TC_OCEAN) > 0) {
|
||
|
if (count_terrain_class_near_tile(&(wld.map), ptile, TRUE, TRUE, TC_OCEAN) > 0) {
|
||
|
choose_mountain = FALSE;
|
||
|
choose_hill = FALSE;
|
||
|
}
|
||
| server/generator/mapgen.c | ||
|---|---|---|
|
#define map_pos_is_dry(ptile) \
|
||
|
(map_colatitude((ptile)) <= DRY_MAX_LEVEL \
|
||
|
&& map_colatitude((ptile)) > DRY_MIN_LEVEL \
|
||
|
&& count_terrain_class_near_tile((ptile), FALSE, TRUE, TC_OCEAN) <= 35)
|
||
|
&& count_terrain_class_near_tile(&(wld.map), (ptile), \
|
||
|
FALSE, TRUE, TC_OCEAN) <= 35)
|
||
|
typedef enum { WC_ALL = 200, WC_DRY, WC_NDRY } wetness_c;
|
||
|
/* MISCELANEOUS (OTHER CONDITIONS) */
|
||
| ... | ... | |
|
struct tile *ptile,
|
||
|
struct extra_type *priver)
|
||
|
{
|
||
|
return 100 - count_terrain_class_near_tile(ptile, TRUE, TRUE, TC_OCEAN);
|
||
|
return 100 - count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
TRUE, TRUE, TC_OCEAN);
|
||
|
}
|
||
|
/**********************************************************************//**
|
||
| ... | ... | |
|
/* Test if the river is done. */
|
||
|
/* We arbitrarily make rivers end at the poles. */
|
||
|
if (count_river_near_tile(&(wld.map), ptile, priver) > 0
|
||
|
|| count_terrain_class_near_tile(ptile, TRUE, TRUE, TC_OCEAN) > 0
|
||
|
|| count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
TRUE, TRUE, TC_OCEAN) > 0
|
||
|
|| (tile_terrain(ptile)->property[MG_FROZEN] > 0
|
||
|
&& map_colatitude(ptile) < 0.8 * COLD_LEVEL)) {
|
||
| ... | ... | |
|
/* Don't start a river on river. */
|
||
|
&& !tile_has_river(ptile)
|
||
|
/* Don't start a river on a tile is surrounded by > 1 river +
|
||
|
ocean tile. */
|
||
|
&& (count_river_near_tile(&(wld.map), ptile, NULL)
|
||
|
+ count_terrain_class_near_tile(ptile, TRUE, FALSE, TC_OCEAN) <= 1)
|
||
|
/* Don't start a river on a tile is surrounded by > 1 river +
|
||
|
ocean tile. */
|
||
|
&& (count_river_near_tile(&(wld.map), ptile, NULL)
|
||
|
+ count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
TRUE, FALSE, TC_OCEAN) <= 1)
|
||
|
/* Don't start a river on a tile that is surrounded by hills or
|
||
|
mountains unless it is hard to find somewhere else to start
|
||
|
it. */
|
||
|
&& (count_terrain_property_near_tile(ptile, TRUE, TRUE,
|
||
|
MG_MOUNTAINOUS) < 90
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 5)
|
||
|
/* Don't start a river on a tile that is surrounded by hills or
|
||
|
mountains unless it is hard to find somewhere else to start
|
||
|
it. */
|
||
|
&& (count_terrain_property_near_tile(&(wld.map), ptile, TRUE, TRUE,
|
||
|
MG_MOUNTAINOUS) < 90
|
||
|
|| iteration_counter >= RIVERS_MAXTRIES / 10 * 5)
|
||
|
/* Don't start a river on hills unless it is hard to find
|
||
|
somewhere else to start it. */
|
||
| ... | ... | |
|
struct terrain *pterrain = pick_terrain(ptersel->target, ptersel->prefer,
|
||
|
ptersel->avoid);
|
||
|
/* the first condition helps make terrain more contiguous,
|
||
|
/* The first condition helps make terrain more contiguous,
|
||
|
the second lets it avoid the coast: */
|
||
|
if ((i * 3 > k * 2
|
||
|
|| fc_rand(100) < 50
|
||
|
|| is_terrain_near_tile(ptile, pterrain, FALSE))
|
||
|
&& (!is_terrain_class_card_near(ptile, TC_OCEAN)
|
||
|
|| is_terrain_near_tile(&(wld.map), ptile, pterrain, FALSE))
|
||
|
&& (!is_terrain_class_card_near(&(wld.map), ptile, TC_OCEAN)
|
||
|
|| fc_rand(100) < coast)) {
|
||
|
tile_set_terrain(ptile, pterrain);
|
||
|
map_set_placed(ptile);
|
||
| ... | ... | |
|
{
|
||
|
int num_card_ocean, pct_adj_ocean, num_adj_river;
|
||
|
num_card_ocean = count_terrain_class_near_tile(ptile, C_CARDINAL, C_NUMBER,
|
||
|
num_card_ocean = count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
C_CARDINAL, C_NUMBER,
|
||
|
TC_OCEAN);
|
||
|
pct_adj_ocean = count_terrain_class_near_tile(ptile, C_ADJACENT, C_PERCENT,
|
||
|
pct_adj_ocean = count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
C_ADJACENT, C_PERCENT,
|
||
|
TC_OCEAN);
|
||
|
num_adj_river = count_river_type_tile_card(&(wld.map), ptile, priver, FALSE);
|
||
| ... | ... | |
|
int pct_adj_ocean, num_card_ocean, pct_adj_river, num_card_river;
|
||
|
num_card_river = count_river_type_tile_card(&(wld.map), ptile, priver, FALSE);
|
||
|
num_card_ocean = count_terrain_class_near_tile(ptile, C_CARDINAL, C_NUMBER,
|
||
|
num_card_ocean = count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
C_CARDINAL, C_NUMBER,
|
||
|
TC_OCEAN);
|
||
|
pct_adj_ocean = count_terrain_class_near_tile(ptile, C_ADJACENT, C_PERCENT,
|
||
|
pct_adj_ocean = count_terrain_class_near_tile(&(wld.map), ptile,
|
||
|
C_ADJACENT, C_PERCENT,
|
||
|
TC_OCEAN);
|
||
|
pct_adj_river = count_river_type_near_tile(&(wld.map), ptile, priver, TRUE);
|
||
| ... | ... | |
|
i++;
|
||
|
*bucket -= i * capac;
|
||
|
/* generate 75% more rivers than generator 1 */
|
||
|
/* Generate 75% more rivers than generator 1 */
|
||
|
i = (i * 175) / 100;
|
||
|
k = i;
|
||
| server/generator/temperature_map.c | ||
|---|---|---|
|
/* high land can be 30% cooler */
|
||
|
float height = - 0.3 * MAX(0, hmap(ptile) - hmap_shore_level)
|
||
|
/ (hmap_max_level - hmap_shore_level);
|
||
|
int tcn = count_terrain_class_near_tile(ptile, FALSE, TRUE, TC_OCEAN);
|
||
|
int tcn = count_terrain_class_near_tile(&(wld.map), ptile, FALSE, TRUE, TC_OCEAN);
|
||
|
/* near ocean temperature can be 15% more "temperate" */
|
||
|
float temperate = (0.15 * (wld.map.server.temperature / 100 - t
|
||
|
/ MAX_COLATITUDE)
|
||
| server/maphand.c | ||
|---|---|---|
|
**************************************************************************/
|
||
|
static bool is_terrain_ecologically_wet(struct tile *ptile)
|
||
|
{
|
||
|
return (is_terrain_class_near_tile(ptile, TC_OCEAN)
|
||
|
return (is_terrain_class_near_tile(&(wld.map), ptile, TC_OCEAN)
|
||
|
|| tile_has_river(ptile)
|
||
|
|| count_river_near_tile(&(wld.map), ptile, NULL) > 0);
|
||
|
}
|
||