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

Method init_biomes

plugins/3dveins.cpp:568–631  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

566 */
567
568bool 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 }

Callers 1

cmd_3dveinsFunction · 0.80

Calls 5

is_setMethod · 0.80
init_layersMethod · 0.80
resizeMethod · 0.45
sizeMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected