| 1047 | } |
| 1048 | |
| 1049 | void VeinGenerator::write_block_tiles(Block *b, df::coord2d column, int z) |
| 1050 | { |
| 1051 | bool aquifer = b->getRaw()->flags.bits.has_aquifer; |
| 1052 | |
| 1053 | for (int x = 0; x < 16; x++) |
| 1054 | { |
| 1055 | for (int y = 0; y < 16; y++) |
| 1056 | { |
| 1057 | df::coord2d tile(x,y); |
| 1058 | GeoLayer *layer = mapLayer(b, tile); |
| 1059 | if (!layer) |
| 1060 | continue; |
| 1061 | |
| 1062 | auto &col_info = layer->biome->columns(column); |
| 1063 | int max_level = col_info.max_level[x][y][layer->index] + layer->z_bias; |
| 1064 | GeoBlock *block = layer->getBlockAt(df::coord(column, max_level-z)); |
| 1065 | |
| 1066 | auto tt = b->baseTiletypeAt(tile); |
| 1067 | |
| 1068 | if (block && block->material[x][y] != SMC_NO_MAPPING) |
| 1069 | { |
| 1070 | bool ok; |
| 1071 | int mat = block->material[x][y]; |
| 1072 | df::inclusion_type vein = inclusion_type::CLUSTER; |
| 1073 | |
| 1074 | bool aquifer_tile = aquifer |
| 1075 | && (z-col_info.min_level[x][y][layer->index]) < layer->aquifer_depth; |
| 1076 | |
| 1077 | if (mat < 0) |
| 1078 | { |
| 1079 | if (layer->is_soil) |
| 1080 | ok = b->setSoilAt(tile, tt, true); |
| 1081 | else |
| 1082 | ok = b->setStoneAt(tile, tt, layer->material, vein, true, true); |
| 1083 | } |
| 1084 | else |
| 1085 | { |
| 1086 | aquifer_tile = aquifer_tile && materials[mat].can_support_aquifer; |
| 1087 | |
| 1088 | vein = (df::inclusion_type)block->veintype[x][y]; |
| 1089 | ok = b->setStoneAt(tile, tt, mat, vein, true, true); |
| 1090 | } |
| 1091 | |
| 1092 | if (aquifer) |
| 1093 | b->setFlagAt(tile, df::tile_designation::mask_water_table, aquifer_tile); |
| 1094 | |
| 1095 | if (!ok) |
| 1096 | { |
| 1097 | WARN(process, out).print( |
| 1098 | "Couldn't write {} vein at ({} {} {})\n", |
| 1099 | mat, x+column.x*16, y+column.y*16, z |
| 1100 | ); |
| 1101 | } |
| 1102 | } |
| 1103 | else |
| 1104 | { |
| 1105 | // Otherwise just kill latent veins if they happen to be there |
| 1106 | if (tileMaterial(tt) != tiletype_material::MINERAL) |
nothing calls this directly
no test coverage detected