MCPcopy Create free account
hub / github.com/NetHack/NetHack / wizkit_addinv

Function wizkit_addinv

src/files.c:2536–2559  ·  view source on GitHub ↗

add to hero's inventory if there's room, otherwise put item on floor */

Source from the content-addressed store, hash-verified

2534
2535/* add to hero's inventory if there's room, otherwise put item on floor */
2536staticfn void
2537wizkit_addinv(struct obj *obj)
2538{
2539 if (!obj || obj == &hands_obj)
2540 return;
2541
2542 /* subset of starting inventory pre-ID */
2543 observe_object(obj);
2544 if (Role_if(PM_CLERIC))
2545 obj->bknown = 1; /* ok to bypass set_bknown() */
2546 /* same criteria as lift_object()'s check for available inventory slot */
2547 if (obj->oclass != COIN_CLASS && inv_cnt(FALSE) >= invlet_basic
2548 && !merge_choice(gi.invent, obj)) {
2549 /* inventory overflow; can't just place & stack object since
2550 hero isn't in position yet, so schedule for arrival later */
2551 add_to_migration(obj);
2552 obj->ox = 0; /* index of main dungeon */
2553 obj->oy = 1; /* starting level number */
2554 obj->owornmask =
2555 (long) (MIGR_WITH_HERO | MIGR_NOBREAK | MIGR_NOSCATTER);
2556 } else {
2557 (void) addinv(obj);
2558 }
2559}
2560
2561boolean
2562proc_wizkit_line(char *buf)

Callers 1

proc_wizkit_lineFunction · 0.85

Calls 5

observe_objectFunction · 0.85
inv_cntFunction · 0.85
merge_choiceFunction · 0.85
add_to_migrationFunction · 0.85
addinvFunction · 0.85

Tested by

no test coverage detected