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

Function stop_donning

src/do_wear.c:1687–1727  ·  view source on GitHub ↗

called by steal() during theft from hero; interrupt donning/doffing */

Source from the content-addressed store, hash-verified

1685
1686/* called by steal() during theft from hero; interrupt donning/doffing */
1687int
1688stop_donning(
1689 struct obj *stolenobj) /* no mesg if stolenobj is already being doffed */
1690{
1691 char buf[BUFSZ];
1692 struct obj *otmp;
1693 boolean putting_on;
1694 int result = 0;
1695
1696 for (otmp = gi.invent; otmp; otmp = otmp->nobj)
1697 if ((otmp->owornmask & W_ARMOR) && donning(otmp))
1698 break;
1699 /* at most one item will pass donning() test at any given time */
1700 if (!otmp)
1701 return 0;
1702
1703 /* donning() returns True when doffing too; doffing() is more specific */
1704 putting_on = !doffing(otmp);
1705 /* cancel_don() looks at afternmv; it can also cancel doffing */
1706 cancel_don();
1707 /* don't want <armor>_on() or <armor>_off() being called
1708 by unmul() since the on or off action isn't completing */
1709 ga.afternmv = (int (*)(void)) 0;
1710 if (putting_on || otmp != stolenobj) {
1711 Sprintf(buf, "You stop %s %s.",
1712 putting_on ? "putting on" : "taking off",
1713 thesimpleoname(otmp));
1714 } else {
1715 buf[0] = '\0'; /* silently stop doffing stolenobj */
1716 result = (int) -gm.multi; /* remember this before calling unmul() */
1717 }
1718 unmul(buf);
1719 /* while putting on, item becomes worn immediately but side-effects are
1720 deferred until the delay expires; when interrupted, make it unworn
1721 (while taking off, item stays worn until the delay expires; when
1722 interrupted, leave it worn) */
1723 if (putting_on)
1724 remove_worn_item(otmp, FALSE);
1725
1726 return result;
1727}
1728
1729static NEARDATA int Narmorpieces, Naccessories;
1730

Callers 3

stealFunction · 0.85
dosinkfallFunction · 0.85
doseduceFunction · 0.85

Calls 6

donningFunction · 0.85
doffingFunction · 0.85
cancel_donFunction · 0.85
thesimpleonameFunction · 0.85
unmulFunction · 0.85
remove_worn_itemFunction · 0.85

Tested by

no test coverage detected