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

Method scan_block_tiles

plugins/3dveins.cpp:911–1016  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

909}
910
911bool VeinGenerator::scan_block_tiles(Block *b, df::coord2d column, int z)
912{
913 bool aquifer = b->getRaw()->flags.bits.has_aquifer;
914
915 for (int x = 0; x < 16; x++)
916 {
917 for (int y = 0; y < 16; y++)
918 {
919 df::coord2d tile(x,y);
920
921 GeoLayer *layer = mapLayer(b, tile);
922 if (!layer)
923 continue;
924
925 auto tt = b->baseTiletypeAt(tile);
926 bool wall = isWallTerrain(tt);
927 bool matches = false;
928
929 switch (tileMaterial(tt))
930 {
931 case tiletype_material::MINERAL:
932 {
933 t_veinkey key(b->veinMaterialAt(tile),b->veinTypeAt(tile));
934
935 // Check if the vein material and type is reasonable
936 if (unsigned(key.first) >= materials.size() ||
937 unsigned(key.second) >= NUM_INCLUSIONS)
938 {
939 WARN(process, out).print("Invalid vein code: {} {} - aborting.\n",key.first,ENUM_AS_STR(key.second));
940 return false;
941 }
942
943 int8_t &status = materials[key.first].valid_type[key.second];
944
945 if (status == -1)
946 {
947 // Report first occurence of unreasonable vein spec
948 WARN(process, out).print(
949 "Unexpected vein {} {} - ",
950 MaterialInfo(0,key.first).getToken(),
951 ENUM_KEY_STR(inclusion_type, key.second)
952 );
953
954 status = materials[key.first].default_type;
955 if (status < 0)
956 WARN(process, out).print("will be left in place.\n");
957 else
958 WARN(process, out).print(
959 "correcting to {}.\n",
960 ENUM_KEY_STR(inclusion_type, df::inclusion_type(status))
961 );
962 }
963
964 if (status >= 0)
965 {
966 key.second = df::inclusion_type(status);
967 matches = true;
968

Callers

nothing calls this directly

Calls 7

isWallTerrainFunction · 0.85
tileMaterialFunction · 0.85
blockAtMethod · 0.80
MaterialInfoClass · 0.50
sizeMethod · 0.45
printMethod · 0.45
getTokenMethod · 0.45

Tested by

no test coverage detected