MCPcopy Index your code
hub / github.com/NetHack/NetHack / obj_extract_self

Function obj_extract_self

src/mkobj.c:2556–2592  ·  view source on GitHub ↗

* Free obj from whatever list it is on in preparation for deleting it * or moving it elsewhere; obj->where will end up set to OBJ_FREE unless * it is already OBJ_LUAFREE or OBJ_DELETED. * Doesn't handle unwearing of objects in hero's or monsters' inventories. * * Object positions: * OBJ_FREE not on any list * OBJ_FLOOR fobj, level.locations[][] chains (use remove_obje

Source from the content-addressed store, hash-verified

2554 * OBJ_DELETED obj has been deleted from play but not yet deallocated
2555 */
2556void
2557obj_extract_self(struct obj *obj)
2558{
2559 switch (obj->where) {
2560 case OBJ_FREE:
2561 case OBJ_LUAFREE:
2562 case OBJ_DELETED:
2563 break;
2564 case OBJ_FLOOR:
2565 remove_object(obj);
2566 break;
2567 case OBJ_CONTAINED:
2568 extract_nobj(obj, &obj->ocontainer->cobj);
2569 container_weight(obj->ocontainer);
2570 obj->ocontainer = (struct obj *) 0; /* clear stale back-link */
2571 break;
2572 case OBJ_INVENT:
2573 freeinv(obj);
2574 break;
2575 case OBJ_MINVENT:
2576 extract_nobj(obj, &obj->ocarry->minvent);
2577 obj->ocarry = (struct monst *) 0; /* clear stale back-link */
2578 break;
2579 case OBJ_MIGRATING:
2580 extract_nobj(obj, &gm.migrating_objs);
2581 break;
2582 case OBJ_BURIED:
2583 extract_nobj(obj, &svl.level.buriedobjlist);
2584 break;
2585 case OBJ_ONBILL:
2586 extract_nobj(obj, &gb.billobjs);
2587 break;
2588 default:
2589 panic("obj_extract_self, where=%d", obj->where);
2590 break;
2591 }
2592}
2593
2594/* Extract the given object from the chain, following nobj chain. */
2595void

Callers 15

resetobjsFunction · 0.85
drop_upon_deathFunction · 0.85
stealgoldFunction · 0.85
relobjFunction · 0.85
hold_potionFunction · 0.85
l_obj_gcFunction · 0.85
l_obj_add_to_containerFunction · 0.85
nhl_obj_u_giveobjFunction · 0.85
l_obj_placeobjFunction · 0.85
steal_itFunction · 0.85
mhitm_ad_sgldFunction · 0.85
rlocoFunction · 0.85

Calls 5

remove_objectFunction · 0.85
extract_nobjFunction · 0.85
container_weightFunction · 0.85
freeinvFunction · 0.85
panicFunction · 0.50

Tested by

no test coverage detected