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

Function setworn

src/worn.c:72–145  ·  view source on GitHub ↗

Updated to use the extrinsic and blocked fields. */

Source from the content-addressed store, hash-verified

70
71/* Updated to use the extrinsic and blocked fields. */
72void
73setworn(struct obj *obj, long mask)
74{
75 const struct worn *wp;
76 struct obj *oobj;
77 int p;
78
79 if ((mask & (W_ARM | I_SPECIAL)) == (W_ARM | I_SPECIAL)) {
80 /* restoring saved game; no properties are conferred via skin */
81 uskin = obj;
82 /* assert( !uarm ); */
83 } else {
84 for (wp = worn; wp->w_mask; wp++) {
85 if (wp->w_mask & mask) {
86 oobj = *(wp->w_obj);
87 if (oobj && !(oobj->owornmask & wp->w_mask))
88 impossible("Setworn: mask=0x%08lx.", wp->w_mask);
89 if (oobj) {
90 if (u.twoweap && (oobj->owornmask & (W_WEP | W_SWAPWEP)))
91 set_twoweap(FALSE); /* u.twoweap = FALSE */
92 oobj->owornmask &= ~wp->w_mask;
93 if (wp->w_mask & ~(W_SWAPWEP | W_QUIVER)) {
94 /* leave as "x = x <op> y", here and below, for broken
95 * compilers */
96 p = objects[oobj->otyp].oc_oprop;
97 u.uprops[p].extrinsic =
98 u.uprops[p].extrinsic & ~wp->w_mask;
99 /* if the hero removed an extrinsic-granting item,
100 nearby monsters will notice and attempt attacks of
101 that type again */
102 monstunseesu_prop(p);
103 if ((p = w_blocks(oobj, mask)) != 0)
104 u.uprops[p].blocked &= ~wp->w_mask;
105 if (oobj->oartifact)
106 set_artifact_intrinsic(oobj, 0, mask);
107 }
108 /* in case wearing or removal is in progress or removal
109 is pending (via 'A' command for multiple items) */
110 cancel_doff(oobj, wp->w_mask);
111 }
112 *(wp->w_obj) = obj;
113 if (obj) {
114 obj->owornmask |= wp->w_mask;
115 /* Prevent getting/blocking intrinsics from wielding
116 * potions, through the quiver, etc.
117 * Allow weapon-tools, too.
118 * wp_mask should be same as mask at this point.
119 */
120 if (wp->w_mask & ~(W_SWAPWEP | W_QUIVER)) {
121 if (obj->oclass == WEAPON_CLASS || is_weptool(obj)
122 || mask != W_WEP) {
123 p = objects[obj->otyp].oc_oprop;
124 u.uprops[p].extrinsic =
125 u.uprops[p].extrinsic | wp->w_mask;
126 if ((p = w_blocks(obj, mask)) != 0)
127 u.uprops[p].blocked |= wp->w_mask;
128 }
129 if (obj->oartifact)

Callers 15

setuwepFunction · 0.85
setuqwepFunction · 0.85
setuswapwepFunction · 0.85
uwepgoneFunction · 0.85
uswapwepgoneFunction · 0.85
uqwepgoneFunction · 0.85
remove_worn_itemFunction · 0.85
Boots_offFunction · 0.85
Cloak_offFunction · 0.85
Helmet_offFunction · 0.85
Gloves_offFunction · 0.85
Shield_offFunction · 0.85

Calls 6

set_twoweapFunction · 0.85
set_artifact_intrinsicFunction · 0.85
cancel_doffFunction · 0.85
update_inventoryFunction · 0.85
recalc_telepat_rangeFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected