ensure touch_artifact is always called via hold_another_object
- remove the touch_artifact calls just added - put a check into hold_another_object itself, based on the complete check removed from makewish
This commit is contained in:
@@ -2267,10 +2267,7 @@ struct obj *obj;
|
||||
pline("Snatching %s is a fatal mistake.", kbuf);
|
||||
instapetrify(kbuf);
|
||||
}
|
||||
if (!touch_artifact(otmp, &youmonst))
|
||||
dropy(otmp);
|
||||
else
|
||||
otmp = hold_another_object(otmp, "You drop %s!",
|
||||
otmp = hold_another_object(otmp, "You drop %s!",
|
||||
doname(otmp), (const char *)0);
|
||||
break;
|
||||
default:
|
||||
|
||||
26
src/invent.c
26
src/invent.c
@@ -365,10 +365,12 @@ struct obj *obj;
|
||||
#endif /* OVL1 */
|
||||
#ifdef OVLB
|
||||
|
||||
/* Add an item to the inventory unless we're fumbling, and give a message.
|
||||
/* Add an item to the inventory unless we're fumbling or it refuses to be
|
||||
* held (via touch_artifact), and give a message.
|
||||
* If there aren't any free inventory slots, we'll drop it instead.
|
||||
* If both success and failure messages are NULL, then we're just doing the
|
||||
* fumbling/slot-limit checking for a silent grab.
|
||||
* fumbling/slot-limit checking for a silent grab. In any case,
|
||||
* touch_artifact will print its own messages if they are warranted.
|
||||
*/
|
||||
struct obj *
|
||||
hold_another_object(obj, drop_fmt, drop_arg, hold_msg)
|
||||
@@ -378,12 +380,32 @@ const char *drop_fmt, *drop_arg, *hold_msg;
|
||||
char buf[BUFSZ];
|
||||
|
||||
if (!Blind) obj->dknown = 1; /* maximize mergibility */
|
||||
if (obj->oartifact) {
|
||||
/* place_object may change these */
|
||||
boolean crysknife = (obj->otyp == CRYSKNIFE);
|
||||
int oerode = obj->oerodeproof;
|
||||
|
||||
/* in case touching this object turns out to be fatal */
|
||||
place_object(obj, u.ux, u.uy);
|
||||
|
||||
if (!touch_artifact(obj, &youmonst)) {
|
||||
obj_extract_self(obj); /* remove it from the floor */
|
||||
dropy(obj); /* now put it back again :-) */
|
||||
return obj;
|
||||
}
|
||||
obj_extract_self(obj);
|
||||
if (crysknife) {
|
||||
obj->otyp = CRYSKNIFE;
|
||||
obj->oerodeproof = oerode;
|
||||
}
|
||||
}
|
||||
if (Fumbling) {
|
||||
if (drop_fmt) pline(drop_fmt, drop_arg);
|
||||
dropy(obj);
|
||||
} else {
|
||||
long oquan = obj->quan;
|
||||
int prev_encumbr = near_capacity(); /* before addinv() */
|
||||
|
||||
/* encumbrance only matters if it would now become worse
|
||||
than max( current_value, stressed ) */
|
||||
if (prev_encumbr < MOD_ENCUMBER) prev_encumbr = MOD_ENCUMBER;
|
||||
|
||||
@@ -1115,13 +1115,10 @@ struct attack *mattk;
|
||||
pline("%s finishes taking off %s suit.",
|
||||
Monnam(mdef), mhis(mdef));
|
||||
}
|
||||
if (!touch_artifact(otmp, &youmonst)) {
|
||||
dropy(otmp);
|
||||
continue;
|
||||
}
|
||||
/* give the object to the character */
|
||||
otmp = hold_another_object(otmp, "You steal %s.",
|
||||
doname(otmp), "You steal: ");
|
||||
if (otmp->where != OBJ_INVENT) continue;
|
||||
if (otmp->otyp == CORPSE &&
|
||||
touch_petrifies(&mons[otmp->corpsenm]) && !uarmg) {
|
||||
char kbuf[BUFSZ];
|
||||
|
||||
21
src/zap.c
21
src/zap.c
@@ -4055,24 +4055,8 @@ retry:
|
||||
u.uconduct.wishes++;
|
||||
|
||||
if (otmp != &zeroobj) {
|
||||
/* place_object looses these */
|
||||
boolean crysknife = (otmp->otyp == CRYSKNIFE);
|
||||
int oerode = otmp->oerodeproof;
|
||||
|
||||
/* in case touching this object turns out to be fatal */
|
||||
place_object(otmp, u.ux, u.uy);
|
||||
|
||||
if (otmp->oartifact && !touch_artifact(otmp,&youmonst)) {
|
||||
obj_extract_self(otmp); /* remove it from the floor */
|
||||
dropy(otmp); /* now put it back again :-) */
|
||||
} else {
|
||||
obj_extract_self(otmp);
|
||||
if (crysknife) {
|
||||
otmp->otyp = CRYSKNIFE;
|
||||
otmp->oerodeproof = oerode;
|
||||
}
|
||||
/* The(aobjnam()) is safe since otmp is unidentified -dlc */
|
||||
(void) hold_another_object(otmp, u.uswallow ?
|
||||
/* The(aobjnam()) is safe since otmp is unidentified -dlc */
|
||||
(void) hold_another_object(otmp, u.uswallow ?
|
||||
"Oops! %s out of your reach!" :
|
||||
(Is_airlevel(&u.uz) ||
|
||||
Is_waterlevel(&u.uz) ||
|
||||
@@ -4084,7 +4068,6 @@ retry:
|
||||
Is_airlevel(&u.uz) || u.uinwater ?
|
||||
"slip" : "drop")),
|
||||
(const char *)0);
|
||||
}
|
||||
u.ublesscnt += rn1(100,50); /* the gods take notice */
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user