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

Method moveToBuilding

library/modules/Items.cpp:974–1007  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

972}
973
974bool DFHack::Items::moveToBuilding(df::item *item, df::building_actual *building,
975 df::building_item_role_type use_mode, bool force_in_building)
976{
977 CHECK_NULL_POINTER(item);
978 CHECK_NULL_POINTER(building);
979 CHECK_INVALID_ARGUMENT(use_mode == building_item_role_type::TEMP ||
980 use_mode == building_item_role_type::PERM);
981
982 auto ref = df::allocate<df::general_ref_building_holderst>();
983 if(!ref) {
984 Core::printerr("Could not allocate building holder refs.\n");
985 return false;
986 }
987 else if (!detachItem(item)) {
988 delete ref;
989 return false;
990 }
991
992 item->pos.x = building->centerx;
993 item->pos.y = building->centery;
994 item->pos.z = building->z;
995 if (use_mode == building_item_role_type::PERM || force_in_building)
996 item->flags.bits.in_building = true;
997
998 ref->building_id = building->id;
999 item->general_refs.push_back(ref);
1000
1001 auto con = new df::buildingitemst;
1002 con->item = item;
1003 con->use_mode = use_mode;
1004 building->contained_items.push_back(con);
1005
1006 return true;
1007}
1008
1009bool DFHack::Items::moveToInventory(df::item *item, df::unit *unit,
1010 df::inv_item_role_type mode, int body_part)

Callers

nothing calls this directly

Calls 2

detachItemFunction · 0.85
printerrFunction · 0.50

Tested by

no test coverage detected