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

Function mbag_explodes

src/pickup.c:2487–2507  ·  view source on GitHub ↗

* Decide whether an object being placed into a magic bag will cause * it to explode. If the object is a bag itself, check recursively. */

Source from the content-addressed store, hash-verified

2485 * it to explode. If the object is a bag itself, check recursively.
2486 */
2487staticfn boolean
2488mbag_explodes(struct obj *obj, int depthin)
2489{
2490 /* these won't cause an explosion when they're empty */
2491 if ((obj->otyp == WAN_CANCELLATION || obj->otyp == BAG_OF_TRICKS)
2492 && obj->spe <= 0)
2493 return FALSE;
2494
2495 /* odds: 1/1, 2/2, 3/4, 4/8, 5/16, 6/32, 7/64, 8/128, 9/128, 10/128,... */
2496 if ((Is_mbag(obj) || obj->otyp == WAN_CANCELLATION)
2497 && (rn2(1 << (depthin > 7 ? 7 : depthin)) <= depthin))
2498 return TRUE;
2499 else if (Has_contents(obj)) {
2500 struct obj *otmp;
2501
2502 for (otmp = obj->cobj; otmp; otmp = otmp->nobj)
2503 if (mbag_explodes(otmp, depthin + 1))
2504 return TRUE;
2505 }
2506 return FALSE;
2507}
2508
2509staticfn boolean
2510is_boh_item_gone(void)

Callers 2

in_containerFunction · 0.85
tipcontainerFunction · 0.85

Calls 1

rn2Function · 0.85

Tested by

no test coverage detected