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

Method form_veins

plugins/3dveins.cpp:1274–1334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1272}
1273
1274bool GeoLayer::form_veins(color_ostream &out)
1275{
1276 std::vector<VeinExtent::Ptr> refs;
1277
1278 // Defunct layers cannot have veins
1279 if (tiles <= 0)
1280 return true;
1281
1282 for (size_t i = 0; i < info->vein_mat.size(); i++)
1283 {
1284 int parent_id = info->vein_nested_in[i];
1285
1286 if (parent_id >= (int)refs.size())
1287 {
1288 WARN(process, out).print("Forward vein reference in biome {}.\n", biome->info.geo_index);
1289 return false;
1290 }
1291
1292 t_veinkey key(info->vein_mat[i], info->vein_type[i]);
1293 VeinExtent::Ptr &vptr = veins[key];
1294
1295 if (vptr)
1296 {
1297 int tgt_pmat = parent_id < 0 ? SMC_LAYER : info->vein_mat[parent_id];
1298 int cur_pmat = vptr->parent_mat();
1299 if (parent_id < 0)
1300 vptr->set_parent(VeinExtent::Ptr());
1301
1302 if (cur_pmat != tgt_pmat)
1303 {
1304 std::string ctx = "be anywhere";
1305 if (vptr->parent)
1306 ctx = "only be in "+MaterialInfo(0,vptr->parent_mat()).getToken();
1307
1308 WARN(process, out).print(
1309 "Duplicate vein {} {} in biome {} layer {} - will {}.\n",
1310 MaterialInfo(0,key.first).getToken(),
1311 ENUM_KEY_STR(inclusion_type, key.second),
1312 biome->info.geo_index, index, ctx
1313 );
1314 }
1315
1316 vptr->probability = std::max<int>(vptr->probability, info->vein_freq[i]);
1317 }
1318 else
1319 {
1320 vptr = VeinExtent::Ptr(new VeinExtent(key));
1321 vptr->probability = info->vein_freq[i];
1322 if (parent_id >= 0)
1323 vptr->set_parent(refs[parent_id]);
1324
1325 vptr->add_tiles(mineral_count[key]);
1326 mineral_count.erase(key);
1327
1328 vptr->link(this);
1329 refs.push_back(vptr);
1330 }
1331 }

Callers 1

cmd_3dveinsFunction · 0.80

Calls 15

map_findFunction · 0.85
parent_matMethod · 0.80
set_parentMethod · 0.80
add_tilesMethod · 0.80
linkMethod · 0.80
is_similarMethod · 0.80
merge_intoMethod · 0.80
MaterialInfoClass · 0.50
sizeMethod · 0.45
printMethod · 0.45
getTokenMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected