Merge pull request #3459 from myk002/myk_dig_now

[dig-now] clear item occupancy flags for channeled tiles
develop
Myk 2023-06-07 01:18:47 -07:00 committed by GitHub
commit 32c1801bbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

@ -36,6 +36,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## New Plugins
## Fixes
- `dig-now`: clear item occupancy flags for channeled tiles that had items on them
## Misc Improvements
- `autonick`: additional nicknames based on burrowing animals, colours, gems and minerals added

@ -968,10 +968,20 @@ static void post_process_dug_tiles(color_ostream &out,
}
if (to.bits.item) {
for (auto item : world->items.other.IN_PLAY) {
if (item->pos == pos && item->flags.bits.on_ground)
item->moveToGround(
resting_pos.x, resting_pos.y, resting_pos.z);
std::vector<df::item*> items;
if (auto b = Maps::ensureTileBlock(pos)) {
for (auto item_id : b->items) {
auto item = df::item::find(item_id);
if (item && item->pos == pos)
items.emplace_back(item);
}
}
if (!items.empty()) {
// fresh MapCache since tile properties are being actively changed
MapExtras::MapCache mc;
for (auto item : items)
Items::moveToGround(mc, item, resting_pos);
mc.WriteAll();
}
}
}