| 296 | } |
| 297 | |
| 298 | bool estimate_underground(color_ostream &out, EmbarkTileLayout &tile, df::world_region_details *details, int x, int y) |
| 299 | { |
| 300 | if (x < 0 || y < 0 || x > 15 || y > 15) { |
| 301 | out.printerr("Invalid embark coordinates: x={}, y={}\n", x, y); |
| 302 | return false; |
| 303 | } |
| 304 | // Find actual biome |
| 305 | int bv = clip_range(details->biome[x][y] & 15, 1, 9); |
| 306 | tile.biome_off = biome_delta[bv-1]; |
| 307 | |
| 308 | df::world_data *data = world->world_data; |
| 309 | int bx = clip_range(details->pos.x + tile.biome_off.x, 0, data->world_width-1); |
| 310 | int by = clip_range(details->pos.y + tile.biome_off.y, 0, data->world_height-1); |
| 311 | tile.biome_pos = coord2d(bx, by); |
| 312 | tile.biome = &data->region_map[bx][by]; |
| 313 | |
| 314 | tile.geo_biome = df::world_geo_biome::find(tile.biome->geo_index); |
| 315 | |
| 316 | // Compute surface elevation |
| 317 | tile.elevation = details->elevation[x][y]; |
| 318 | tile.max_soil_depth = std::max((154-tile.elevation)/5,1); |
| 319 | tile.penalty.clear(); |
| 320 | |
| 321 | // Special biome adjustments |
| 322 | if (!tile.biome->flags.is_set(region_map_entry_flags::is_lake)) |
| 323 | { |
| 324 | // Mountain biome |
| 325 | if (tile.biome->elevation >= 150) |
| 326 | tile.max_soil_depth = 0; |
| 327 | // Ocean biome |
| 328 | else if (tile.biome->elevation < 100) |
| 329 | { |
| 330 | if (tile.elevation == 99) |
| 331 | tile.elevation = 98; |
| 332 | |
| 333 | if (tile.geo_biome && (tile.geo_biome->type == 4 || tile.geo_biome->type == 5)) |
| 334 | { |
| 335 | auto b_details = get_details(data, tile.biome_pos); |
| 336 | |
| 337 | if (b_details && b_details->ocean_beach_comp.soil_freq < 500) |
| 338 | tile.max_soil_depth = 0; |
| 339 | } |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | tile.base_z = tile.elevation-1; |
| 344 | |
| 345 | auto &features = details->features[x][y]; |
| 346 | |
| 347 | // Collect global feature layer depths and apply penalties |
| 348 | std::map<int, int> layer_bottom, layer_top; |
| 349 | bool sea_found = false; |
| 350 | |
| 351 | for (size_t i = 0; i < features.size(); i++) |
| 352 | { |
| 353 | auto feature = features[i]; |
| 354 | auto layer = df::world_underground_region::find(feature->layer); |
| 355 | if (!layer || feature->min_z == -30000) continue; |
no test coverage detected