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

Method designateRemove

library/modules/Constructions.cpp:117–161  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115}
116
117bool Constructions::designateRemove(df::coord pos, bool *immediate)
118{
119 using df::global::process_dig;
120
121 if (immediate)
122 *immediate = false;
123
124 if (auto current = Buildings::findAtTile(pos))
125 {
126 auto cons = strict_virtual_cast<df::building_constructionst>(current);
127 if (!cons)
128 return false;
129
130 if (Buildings::deconstruct(cons))
131 {
132 if (immediate)
133 *immediate = true;
134 }
135
136 return true;
137 }
138
139 auto block = Maps::getTileBlock(pos);
140 if (!block)
141 return false;
142
143 auto ttype = block->tiletype[pos.x&15][pos.y&15];
144
145 if (tileMaterial(ttype) == tiletype_material::CONSTRUCTION)
146 {
147 // don't designate pseudo-constructions
148 auto constr = df::construction::find(pos);
149 if (!constr || constr->flags.bits.top_of_wall)
150 return false;
151
152 auto &dsgn = block->designation[pos.x&15][pos.y&15];
153 dsgn.bits.dig = tile_dig_designation::Default;
154 block->flags.bits.designated = true;
155 if (process_dig)
156 *process_dig = true;
157 return true;
158 }
159
160 return false;
161}

Callers

nothing calls this directly

Calls 3

getTileBlockFunction · 0.85
tileMaterialFunction · 0.85
findFunction · 0.50

Tested by

no test coverage detected