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

Method find_liquids

plugins/steam-engine.cpp:241–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239 // Find liquids to consume below the engine.
240
241 bool find_liquids(df::coord *pwater, df::coord *pmagma, bool is_magma, int min_level)
242 {
243 if (!is_magma)
244 pmagma = NULL;
245
246 for (int x = x1; x <= x2; x++)
247 {
248 for (int y = y1; y <= y2; y++)
249 {
250 auto ptile = Maps::getTileType(x,y,z);
251 if (!ptile || !FlowPassableDown(*ptile))
252 continue;
253
254 auto pltile = Maps::getTileType(x,y,z-1);
255 if (!pltile || !FlowPassable(*pltile))
256 continue;
257
258 auto pldes = Maps::getTileDesignation(x,y,z-1);
259 if (!pldes || pldes->bits.flow_size < min_level)
260 continue;
261
262 if (pldes->bits.liquid_type == tile_liquid::Magma)
263 {
264 if (pmagma)
265 *pmagma = df::coord(x,y,z-1);
266 if (pwater->isValid())
267 return true;
268 }
269 else
270 {
271 *pwater = df::coord(x,y,z-1);
272 if (!pmagma || pmagma->isValid())
273 return true;
274 }
275 }
276 }
277
278 return false;
279 }
280
281 // Absorbs a water item produced by stoke reaction into the engine.
282

Callers

nothing calls this directly

Calls 5

getTileTypeFunction · 0.85
FlowPassableDownFunction · 0.85
FlowPassableFunction · 0.85
getTileDesignationFunction · 0.85
isValidMethod · 0.45

Tested by

no test coverage detected