| 297 | } |
| 298 | |
| 299 | df::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 | |
| 330 | bool World::deletePersistentTilemask(PersistentDataItem &item, df::map_block *block) { |
| 331 | if (!block) |
nothing calls this directly
no test coverage detected