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

Function paintTile

plugins/tiletypes.cpp:1078–1123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1076}
1077
1078static PaintResult paintTile(MapExtras::MapCache &map, const df::coord &pos,
1079 const TileType &target, const TileType &match = TileType()) {
1080 MapExtras::Block *blk = map.BlockAtTile(pos);
1081 if (!blk)
1082 return PaintResult();
1083
1084 df::tiletype source = map.tiletypeAt(pos);
1085 df::tile_designation des = map.designationAt(pos);
1086 df::tile_occupancy occ = map.occupancyAt(pos);
1087
1088 // Stone painting operates on the base layer
1089 if (target.stone_material >= 0)
1090 source = blk->baseTiletypeAt(pos);
1091
1092 t_matpair basemat = blk->baseMaterialAt(pos);
1093
1094 if (!match.matches(source, des, occ, basemat))
1095 return PaintResult();
1096
1097 if (paintTileProcessing(blk, df::coord2d(pos.x&15, pos.y&15), target)) {
1098 return PaintResult{
1099 .paintCount = 1,
1100 .postWrite = [target, pos](MapExtras::MapCache& map) {
1101 if (target.autocorrect > 0) {
1102 MapExtras::Block* block = map.BlockAtTile(pos);
1103 MapExtras::Block* topBlock = map.BlockAtTile(df::coord(pos.x, pos.y, pos.z + 1));
1104 MapExtras::Block* belowBlock = map.BlockAtTile(df::coord(pos.x, pos.y, pos.z - 1));
1105 bool updated = autocorrectTile(block, topBlock, df::coord2d(pos.x & 15, pos.y & 15), target);
1106 updated |= autocorrectTile(belowBlock, block, df::coord2d(pos.x & 15, pos.y & 15), target);
1107 block->enableBlockUpdates(true, true);
1108 if (updated)
1109 map.WriteAll();
1110 }
1111
1112 if (target.aquifer == 0)
1113 Maps::removeTileAquifer(pos);
1114 else if (target.aquifer > 0)
1115 Maps::setTileAquifer(pos, target.aquifer == 2);
1116
1117 // force the game to recompute its walkability cache on the next tick
1118 world->reindex_pathfinding = true;
1119 }
1120 };
1121 }
1122 return PaintResult();
1123}
1124
1125command_result executePaintJob(color_ostream &out,
1126 const tiletypes_options &opts)

Callers 15

screen_paintTileFunction · 0.85
paintStringMethod · 0.85
drawMethod · 0.85
Screen.hFile · 0.85
paint_screenFunction · 0.85
bump_layersFunction · 0.85
paintScreenWarmDampFunction · 0.85
paintScreenDesignatedFunction · 0.85
executePaintJobFunction · 0.85
setTileFunction · 0.85
renderMethod · 0.85
design_draw_shapeFunction · 0.85

Calls 10

TileTypeClass · 0.85
PaintResultClass · 0.85
paintTileProcessingFunction · 0.85
autocorrectTileFunction · 0.85
removeTileAquiferFunction · 0.85
setTileAquiferFunction · 0.85
tiletypeAtMethod · 0.80
enableBlockUpdatesMethod · 0.80
WriteAllMethod · 0.80
matchesMethod · 0.45

Tested by

no test coverage detected