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

Function basic_wet_dry_effect

library/modules/Maps.cpp:1203–1241  ·  view source on GitHub ↗

* Biomes */

Source from the content-addressed store, hash-verified

1201* Biomes
1202*/
1203static int16_t basic_wet_dry_effect(int16_t region_y, int16_t rain)
1204{ // Reverse-engineered from DF function "basic_wet_dry_effect" FUN_14057ab10 (v50.11 win64 Steam)
1205 // A result < 66 indicates wet/dry seasons instead of spring/autumn
1206 auto dimy = world->world_data->world_height;
1207 auto pole = world->world_data->flip_latitude;
1208
1209 if (dimy > 65 && pole != df::pole_type::None)
1210 { // Medium and Large worlds with at least one pole
1211 auto latitude = region_y;
1212
1213 if (pole == df::pole_type::South)
1214 latitude = dimy - region_y - 1;
1215 else if (pole == df::pole_type::Both)
1216 {
1217 if (region_y < dimy / 2)
1218 latitude = region_y * 2;
1219 else
1220 latitude = clip_range(((dimy / 2 - region_y) * 2 + dimy - 1), 0, (dimy - 1));
1221 }
1222
1223 if (dimy == 129) // Medium world
1224 latitude *= 2;
1225 // else Large world
1226
1227 if (latitude > 170 && latitude < 221)
1228 {
1229 int16_t result = 0;
1230
1231 if (latitude < 191)
1232 result = (184 - latitude) * 16 - rain;
1233 else if (latitude > 200)
1234 result = (latitude - 207) * 16 + rain;
1235
1236 return clip_range(result, 0, 100);
1237 }
1238 }
1239
1240 return 100;
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)

Callers 1

getBiomeTypeWithRefMethod · 0.85

Calls 1

clip_rangeFunction · 0.85

Tested by

no test coverage detected