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

Function removeItemOnGround

library/modules/Items.cpp:776–800  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

774}
775
776static bool removeItemOnGround(df::item *item)
777{ // Replaces the MapCache fn
778 auto block = Maps::getTileBlock(item->pos);
779 if (!block)
780 return false;
781
782 erase_from_vector(block->items, item->id);
783
784 for (auto b_item : block->items)
785 {
786 auto other_item = df::item::find(b_item);
787 if (other_item && other_item->pos == item->pos)
788 return true; // Don't touch occupancy
789 }
790
791 auto &occ = index_tile(block->occupancy, item->pos);
792 occ.bits.item = false;
793
794 if (occ.bits.building == tile_building_occ::Planned)
795 if (auto bld = Buildings::findAtTile(item->pos))
796 { // TODO: Maybe recheck other tiles like the game does.
797 bld->flags.bits.site_blocked = false;
798 }
799 return true;
800}
801
802static void resetUnitInvFlags(df::unit *unit, df::unit_inventory_item *inv_item) {
803 if (inv_item->mode == df::inv_item_role_type::Worn ||

Callers 1

detachItemFunction · 0.85

Calls 4

getTileBlockFunction · 0.85
erase_from_vectorFunction · 0.85
index_tileFunction · 0.85
findFunction · 0.50

Tested by

no test coverage detected