Feature #47 ยป 0019-Drop-unused-count_terrain_near_tile.patch
common/terrain.c | ||
---|---|---|
return check_self && ptile->terrain == pterrain;
|
||
}
|
||
/**********************************************************************//**
|
||
Return the number of adjacent tiles that have the given terrain.
|
||
**************************************************************************/
|
||
int count_terrain_near_tile(const struct tile *ptile,
|
||
bool cardinal_only, bool percentage,
|
||
const struct terrain *pterrain)
|
||
{
|
||
int count = 0, total = 0;
|
||
variable_adjc_iterate(&(wld.map), ptile, adjc_tile, cardinal_only) {
|
||
if (pterrain && tile_terrain(adjc_tile) == pterrain) {
|
||
count++;
|
||
}
|
||
total++;
|
||
} variable_adjc_iterate_end;
|
||
if (percentage && count > 0) { /* Latter condition avoids div by zero */
|
||
count = count * 100 / total;
|
||
}
|
||
return count;
|
||
}
|
||
/**********************************************************************//**
|
||
Return the number of adjacent tiles that have the given terrain property.
|
||
**************************************************************************/
|
common/terrain.h | ||
---|---|---|
bool is_terrain_near_tile(const struct tile *ptile,
|
||
const struct terrain *pterrain,
|
||
bool check_self);
|
||
int count_terrain_near_tile(const struct tile *ptile,
|
||
bool cardinal_only, bool percentage,
|
||
const struct terrain *pterrain);
|
||
int count_terrain_property_near_tile(const struct tile *ptile,
|
||
bool cardinal_only, bool percentage,
|
||
enum mapgen_terrain_property prop);
|