Updated to use the extrinsic and blocked fields. */
| 70 | |
| 71 | /* Updated to use the extrinsic and blocked fields. */ |
| 72 | void |
| 73 | setworn(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) |
no test coverage detected