| 566 | */ |
| 567 | |
| 568 | bool VeinGenerator::init_biomes() |
| 569 | { |
| 570 | auto &mats = df::inorganic_raw::get_vector(); |
| 571 | materials.resize(world->raws.inorganics.all.size()); |
| 572 | |
| 573 | for (size_t i = 0; i < mats.size(); i++) |
| 574 | { |
| 575 | materials[i].can_support_aquifer = mats[i]->flags.is_set(inorganic_flags::AQUIFER); |
| 576 | |
| 577 | // Be silent about slade veins, which can happen below hell |
| 578 | if (mats[i]->flags.is_set(inorganic_flags::DEEP_SURFACE)) |
| 579 | materials[i].valid_type[0] = -2; |
| 580 | } |
| 581 | |
| 582 | biome_by_idx.resize(map.getBiomeCount()); |
| 583 | |
| 584 | size = df::coord2d(map.maxBlockX()+1, map.maxBlockY()+1); |
| 585 | base = df::coord2d(world->map.region_x*3, world->map.region_y*3); |
| 586 | |
| 587 | for (size_t i = 0; i < biome_by_idx.size(); i++) |
| 588 | { |
| 589 | const BiomeInfo &info = map.getBiomeByIndex(i); |
| 590 | |
| 591 | if (info.geo_index < 0 || !info.geobiome) |
| 592 | { |
| 593 | WARN(process, out).print("Biome {} is not defined.\n", i); |
| 594 | return false; |
| 595 | } |
| 596 | |
| 597 | GeoBiome *&biome = biomes[info.geo_index]; |
| 598 | if (!biome) |
| 599 | { |
| 600 | biome = new GeoBiome(info, base, size); |
| 601 | |
| 602 | if (!biome->init_layers()) |
| 603 | return false; |
| 604 | |
| 605 | // Mark valid vein types |
| 606 | auto &layers = info.geobiome->layers; |
| 607 | |
| 608 | for (size_t i = 0; i < layers.size(); i++) |
| 609 | { |
| 610 | auto layer = layers[i]; |
| 611 | |
| 612 | for (size_t j = 0; j < layer->vein_mat.size(); j++) |
| 613 | { |
| 614 | if (unsigned(layer->vein_mat[j]) >= materials.size() || |
| 615 | unsigned(layer->vein_type[j]) >= NUM_INCLUSIONS) |
| 616 | continue; |
| 617 | |
| 618 | auto &minfo = materials[layer->vein_mat[j]]; |
| 619 | int type = layer->vein_type[j]; |
| 620 | minfo.valid_type[type] = type; |
| 621 | if (minfo.default_type < 0 || type == inclusion_type::CLUSTER) |
| 622 | minfo.default_type = type; |
| 623 | } |
| 624 | } |
| 625 | } |
no test coverage detected