fix #H7256 - bug WRT eating rings

Wearing a negatively enchanted ring of increase <foo> would enhance
the bonus gained from eating another ring of the same type when you
got "the magic spreads through your body" effect so could be eploited.
Conversely, wearing a positively enchanted one would make you lose
that worn amount when gaining any bonus from eating one.
This commit is contained in:
PatR
2018-07-03 16:39:34 -07:00
parent a7daa522a4
commit faa85e23b4
2 changed files with 12 additions and 4 deletions

View File

@@ -60,6 +60,8 @@ make stone-to-flesh behave the same on statues of petrified monsters as it
becoming a corpse when there's already a monster at statue's location)
special level loader didn't support populating several types of special rooms
(ant hole, cockatrice nest, leprechaun hall)
eating rings while polymorphed didn't handle bonus/penalty for increase damage,
increase accuracy, or protection correctly
Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository

View File

@@ -1877,10 +1877,11 @@ int old, inc, typ;
{
int absold, absinc, sgnold, sgninc;
/* don't include any amount coming from worn rings */
if (uright && uright->otyp == typ)
/* don't include any amount coming from worn rings (caller handles
'protection' differently) */
if (uright && uright->otyp == typ && typ != RIN_PROTECTION)
old -= uright->spe;
if (uleft && uleft->otyp == typ)
if (uleft && uleft->otyp == typ && typ != RIN_PROTECTION)
old -= uleft->spe;
absold = abs(old), absinc = abs(inc);
sgnold = sgn(old), sgninc = sgn(inc);
@@ -1900,6 +1901,11 @@ int old, inc, typ;
} else {
inc = 0; /* no further increase allowed via this method */
}
/* put amount from worn rings back */
if (uright && uright->otyp == typ && typ != RIN_PROTECTION)
old += uright->spe;
if (uleft && uleft->otyp == typ && typ != RIN_PROTECTION)
old += uleft->spe;
return old + inc;
}
@@ -1908,7 +1914,7 @@ accessory_has_effect(otmp)
struct obj *otmp;
{
pline("Magic spreads through your body as you digest the %s.",
otmp->oclass == RING_CLASS ? "ring" : "amulet");
(otmp->oclass == RING_CLASS) ? "ring" : "amulet");
}
STATIC_OVL void