fix #H2589 - theft vs donning/doffing (trunk only)

From a bug report, having some
armor stolen while in the midst of putting on armor--when both items have
a multiple turn completion delay--could result in side-effects for the
latter item being reversed even though they hadn't been applied yet.  So
you'd lose points of Int and Wis when attempting to put on a positively
enchanted helm of brilliance, or gain such with a negatively enchanted one.

     steal() was assigning to afternmv before it had been used to finish the
action of putting on or taking off armor.  Fix by interrupting the attempt
to put on or take off armor when being victimized by theft (or being hit by
succubus or incubus seduction).  The existing stop_occupation() call wasn't
sufficient because afternmv is different from occupation.
This commit is contained in:
nethack.rankin
2012-02-04 08:13:26 +00:00
parent 9b61b368b4
commit ef888e065a
4 changed files with 53 additions and 7 deletions
+9 -7
View File
@@ -271,7 +271,7 @@ struct monst *mtmp;
char *objnambuf;
{
struct obj *otmp;
int tmp, could_petrify, named = 0, armordelay, retrycnt = 0;
int tmp, could_petrify, armordelay, olddelay, named = 0, retrycnt = 0;
boolean monkey_business; /* true iff an animal is doing the thievery */
if (objnambuf) *objnambuf = '\0';
@@ -391,6 +391,9 @@ gotobj:
o_unleash(otmp);
}
/* stop donning/doffing now so that afternmv won't be clobbered
below; stop_occupation doesn't handle donning/doffing */
olddelay = stop_donning(otmp);
/* you're going to notice the theft... */
stop_occupation();
@@ -404,14 +407,13 @@ gotobj:
break;
case ARMOR_CLASS:
armordelay = objects[otmp->otyp].oc_delay;
/* Stop putting on armor which has been stolen. */
if (donning(otmp)) {
remove_worn_item(otmp, TRUE);
break;
} else if (monkey_business) {
if (olddelay > 0 && olddelay < armordelay)
armordelay = olddelay;
if (monkey_business) {
/* animals usually don't have enough patience
to take off items which require extra time */
if (armordelay >= 1 && rn2(10)) goto cant_take;
if (armordelay >= 1 && !olddelay && rn2(10))
goto cant_take;
remove_worn_item(otmp, TRUE);
break;
} else {