| 1205 | * touch_artifact will print its own messages if they are warranted. |
| 1206 | */ |
| 1207 | struct obj * |
| 1208 | hold_another_object( |
| 1209 | struct obj *obj, /* object to be held */ |
| 1210 | const char *drop_fmt, /* format string for message if it can't be held */ |
| 1211 | const char *drop_arg, /* argument to use when formatting message */ |
| 1212 | const char *hold_msg) /* message to display if successfully held */ |
| 1213 | { |
| 1214 | char buf[BUFSZ]; |
| 1215 | |
| 1216 | if (!Blind) |
| 1217 | observe_object(obj); /* maximize mergeability */ |
| 1218 | if (obj->oartifact) { |
| 1219 | /* place_object may change these */ |
| 1220 | boolean crysknife = (obj->otyp == CRYSKNIFE); |
| 1221 | int oerode = obj->oerodeproof; |
| 1222 | boolean wasUpolyd = Upolyd; |
| 1223 | |
| 1224 | /* in case touching this object turns out to be fatal */ |
| 1225 | place_object(obj, u.ux, u.uy); |
| 1226 | |
| 1227 | if (!touch_artifact(obj, &gy.youmonst)) { |
| 1228 | obj_extract_self(obj); /* remove it from the floor */ |
| 1229 | dropy(obj); /* now put it back again :-) */ |
| 1230 | return obj; |
| 1231 | } else if (wasUpolyd && !Upolyd) { |
| 1232 | /* lose your grip if you revert your form */ |
| 1233 | if (drop_fmt) |
| 1234 | pline(drop_fmt, drop_arg); |
| 1235 | obj_extract_self(obj); |
| 1236 | dropy(obj); |
| 1237 | return obj; |
| 1238 | } |
| 1239 | obj_extract_self(obj); |
| 1240 | if (crysknife) { |
| 1241 | obj->otyp = CRYSKNIFE; |
| 1242 | obj->oerodeproof = oerode; |
| 1243 | } |
| 1244 | } |
| 1245 | if (Fumbling) { |
| 1246 | obj->nomerge = 1; |
| 1247 | /* dropping expects obj to be in invent; since it's going to be |
| 1248 | dropped, avoid perminv update when temporarily adding it */ |
| 1249 | obj = addinv_core0(obj, (struct obj *) 0, FALSE); |
| 1250 | goto drop_it; |
| 1251 | } else if (obj->otyp == CORPSE |
| 1252 | && !u_safe_from_fatal_corpse(obj, st_all) |
| 1253 | && obj->wishedfor) { |
| 1254 | obj->wishedfor = 0; |
| 1255 | obj = addinv_core0(obj, (struct obj *) 0, FALSE); |
| 1256 | goto drop_it; |
| 1257 | } else { |
| 1258 | long oquan = obj->quan; |
| 1259 | int prev_encumbr = near_capacity(); /* before addinv() */ |
| 1260 | |
| 1261 | /* encumbrance limit is max( current_state, pickup_burden ); |
| 1262 | this used to use hardcoded MOD_ENCUMBER (stressed) instead |
| 1263 | of the 'pickup_burden' option (which defaults to stressed) */ |
| 1264 | if (prev_encumbr < flags.pickup_burden) |
no test coverage detected