MCPcopy Create free account
hub / github.com/DFHack/dfhack / getBiomeTypeWithRef

Method getBiomeTypeWithRef

library/modules/Maps.cpp:1243–1397  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1241}
1242
1243df::enums::biome_type::biome_type Maps::getBiomeTypeWithRef(int16_t region_x, int16_t region_y, int16_t region_ref_y)
1244{ // Based on reverse-engineering of FUN_140bfe460 (v50.11 win64 Steam)
1245 auto region = getRegionBiome(df::coord2d(region_x, region_y));
1246 CHECK_NULL_POINTER(region);
1247
1248 auto dimy = world->world_data->world_height;
1249 auto pole = world->world_data->flip_latitude;
1250
1251 bool potential_tropical;
1252 bool tropical;
1253
1254 // Determine tropicality
1255 if (pole == df::pole_type::None)
1256 {
1257 potential_tropical = region->temperature > 74;
1258 tropical = region->temperature > 84;
1259 }
1260 else
1261 {
1262 auto latitude = region_ref_y; // DF just uses region_y, but embark assistant needs region_ref_y
1263
1264 if (pole == df::pole_type::South)
1265 latitude = dimy - region_ref_y - 1;
1266 else if (pole == df::pole_type::Both)
1267 {
1268 if (region_ref_y < dimy / 2)
1269 latitude = region_ref_y * 2;
1270 else
1271 latitude = clip_range(((dimy / 2 - region_ref_y) * 2 + dimy - 1), 0, (dimy - 1));
1272 }
1273
1274 if (dimy == 17) // Pocket world
1275 latitude *= 16;
1276 else if (dimy == 33) // Smaller world
1277 latitude *= 8;
1278 else if (dimy == 65) // Small world
1279 latitude *= 4;
1280 else if (dimy == 129) // Medium world
1281 latitude *= 2;
1282 // else Large world
1283
1284 potential_tropical = latitude > 170;
1285 tropical = latitude > 199;
1286 }
1287
1288 // Start checking biomes
1289 if (region->flags.is_set(df::region_map_entry_flags::is_lake))
1290 {
1291 if (region->salinity > 65)
1292 return potential_tropical ? biome_type::LAKE_TROPICAL_SALTWATER : biome_type::LAKE_TEMPERATE_SALTWATER;
1293 else if (region->salinity < 33)
1294 return potential_tropical ? biome_type::LAKE_TROPICAL_FRESHWATER : biome_type::LAKE_TEMPERATE_FRESHWATER;
1295 else
1296 return potential_tropical ? biome_type::LAKE_TROPICAL_BRACKISHWATER : biome_type::LAKE_TEMPERATE_BRACKISHWATER;
1297 }
1298
1299 if (region->elevation > 149)
1300 return biome_type::MOUNTAIN;

Callers

nothing calls this directly

Calls 3

clip_rangeFunction · 0.85
basic_wet_dry_effectFunction · 0.85
is_setMethod · 0.80

Tested by

no test coverage detected