]> granicus.if.org Git - nethack/commitdiff
fix #H7256 - bug WRT eating rings
authorPatR <rankin@nethack.org>
Tue, 3 Jul 2018 23:39:34 +0000 (16:39 -0700)
committerPatR <rankin@nethack.org>
Tue, 3 Jul 2018 23:39:34 +0000 (16:39 -0700)
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.

doc/fixes36.2
src/eat.c

index a4c3a8f09e3e9d721a9ca6b6032cb0aaa5026ab6..d4fbba9f259c6b7c1d35ddce14a8f0dcf0f1f6ea 100644 (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
index 79fd56df077554d10791e899bd31b4bb28489e1f..1c055abbc0b2f17eb0c26b19d602f1f450f5a9b3 100644 (file)
--- 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