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

Method getPersistentTilemask

library/modules/World.cpp:299–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

297}
298
299df::tile_bitmask *World::getPersistentTilemask(PersistentDataItem &item, df::map_block *block, bool create) {
300 if (!block)
301 return NULL;
302
303 int id = item.fake_df_id();
304 if (id > -100)
305 return NULL;
306
307 for (auto ev : block->block_events) {
308 if (ev->getType() != block_square_event_type::world_construction)
309 continue;
310 auto wcsev = strict_virtual_cast<df::block_square_event_world_constructionst>(ev);
311 if (!wcsev || wcsev->construction_id != id)
312 continue;
313 return &wcsev->tile_bitmask;
314 }
315
316 if (!create)
317 return NULL;
318
319 auto ev = df::allocate<df::block_square_event_world_constructionst>();
320 if (!ev)
321 return NULL;
322
323 ev->construction_id = id;
324 ev->tile_bitmask.clear();
325 vector_insert_at(block->block_events, 0, (df::block_square_event*)ev);
326
327 return &ev->tile_bitmask;
328}
329
330bool World::deletePersistentTilemask(PersistentDataItem &item, df::map_block *block) {
331 if (!block)

Callers

nothing calls this directly

Calls 4

vector_insert_atFunction · 0.85
fake_df_idMethod · 0.80
getTypeMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected