bool World::deletePersistentTilemask(const PersistentDataItem &item, df::map_block *block) { if (!block) return false; int id = item.raw_id(); if (id > -100) return false; bool found = false; for (int i = block->block_events.size()-1; i >= 0; i--) { auto ev = block->block_events[i]; if (ev->getType() != block_square_event_type::world_construction) continue; auto wcsev = strict_virtual_cast<df::block_square_event_world_constructionst>(ev); if (!wcsev || wcsev->construction_id != id) continue; delete wcsev; vector_erase_at(block->block_events, i); found = true; } return found; }
bool World::DeletePersistentData(const PersistentDataItem &item) { int id = item.raw_id(); if (id > -100) return false; if (!BuildPersistentCache()) return false; stl::vector<df::historical_figure*> &hfvec = df::historical_figure::get_vector(); auto eqrange = persistent_index.equal_range(item.key()); for (auto it2 = eqrange.first; it2 != eqrange.second; ) { auto it = it2; ++it2; if (it->second != -id) continue; persistent_index.erase(it); int idx = binsearch_index(hfvec, id); if (idx >= 0) { delete hfvec[idx]; hfvec.erase(hfvec.begin()+idx); } return true; } return false; }