From faa85e23b47cd8007266670653a03c627efaf363 Mon Sep 17 00:00:00 2001 From: PatR Date: Tue, 3 Jul 2018 16:39:34 -0700 Subject: [PATCH] fix #H7256 - bug WRT eating rings Wearing a negatively enchanted ring of increase 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. --- doc/fixes36.2 | 2 ++ src/eat.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index a4c3a8f09..d4fbba9f2 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -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 diff --git a/src/eat.c b/src/eat.c index 79fd56df0..1c055abbc 100644 --- a/src/eat.c +++ b/src/eat.c @@ -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