From b8ed7412dc38bcf2c4c0ee3b1bfedcc203099bb3 Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Tue, 30 Dec 2008 21:45:41 +0000 Subject: [PATCH] exerchk fix (trunk only) Post-3.4.3 problem noticed by Michael: some code which was supposed to be inside the end of a loop got placed in front of the wrong closing brace, ending up beyond that loop. As a result, decay of old attribute exercise wasn't working as intended, and out of bounds array modification was occurring (clobbering u.abon.a[0], which probably messed up resetting strength when taking off rings of gain strength which were worn during an exercise check). --- src/attrib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/attrib.c b/src/attrib.c index 7b4757c25..6a02f8e4e 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -526,15 +526,15 @@ exerchk() (mod_val > 0) ? "must have been" : "haven't been", exertext[i][(mod_val > 0) ? 0 : 1]); } + nextattrib: + /* this used to be ``AEXE(i) /= 2'' but that would produce + platform-dependent rounding/truncation for negative vals */ + AEXE(i) = (abs(ax) / 2) * mod_val; } context.next_attrib_check += rn1(200,800); #ifdef DEBUG pline("exerchk: next check at %ld.", context.next_attrib_check); #endif - nextattrib: - /* this used to be ``AEXE(i) /= 2'' but that would produce - platform-dependent rounding/truncation for negative values */ - AEXE(i) = (abs(ax) / 2) * mod_val; } }