From ebae4337117381b149b0faaf82128f5d5be79ecf Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 21 Mar 2019 18:26:31 -0700 Subject: [PATCH 1/2] highlighting status condition via 'O' bug It took me a while to track this down: if you use 'O' to create hilite_status rule(s) for status condition(s) and you specify multiple attributes in the rule creation menu, it accepts them but it was parsing the new rule(s) incorrectly and only supported one attribute. if (mask & bit) something; else if (mask & other_bit) something_else; else if (mask & yet_another_bit) ... effectively stops at the first bit matched. (At the time that that was written, the menu leading to it only accepted a single attribute.) --- doc/fixes36.2 | 5 ++++- src/botl.c | 17 +++++++++-------- src/options.c | 8 ++++---- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index e76a86e04..9522e1eae 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.277 $ $NHDT-Date: 1553204013 2019/03/21 21:33:33 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.278 $ $NHDT-Date: 1553217908 2019/03/22 01:25:08 $ This fixes36.2 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.1 in April 2018. Please note, however, @@ -460,6 +460,9 @@ when persistent inventory window is enabled, wearing armor didn't immediately update it with armor's newly observed +/- value having an artifact wish be refused ("for a moment you feel in your hands, but it disappears") would immediately segfault +using 'O' to set status hilites for any status condition (Blind, &c) and + specifying more than one attribute (Bold, Inverse, &c) it would only + retain one of the chosen attributes tty: turn off an optimization that is the suspected cause of Windows reported partial status lines following level changes tty: ensure that current status fields are always copied to prior status diff --git a/src/botl.c b/src/botl.c index 152503a10..4a329eec4 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1552697495 2019/03/16 00:51:35 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.135 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1553217909 2019/03/22 01:25:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.136 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -765,7 +765,7 @@ boolean *valsetlist; if (anytype != ANY_MASK32) { #ifdef STATUS_HILITES if ((chg || *curr->val)) { - get_hilite_color(idx, fld, (genericptr_t)&curr->a, + get_hilite_color(idx, fld, (genericptr_t) &curr->a, chg, pc, &color); if (chg == 2) { color = NO_COLOR; @@ -2322,7 +2322,7 @@ int sidx; /* * We have the conditions_bitmask with bits set for * each ailment we want in a particular color and/or - * attribute, but we need to assign it to an arry of + * attribute, but we need to assign it to an array of * bitmasks indexed by the color chosen * (0 to (CLR_MAX - 1)) * and/or attributes chosen @@ -2363,6 +2363,7 @@ int sidx; for (i = 0; i < sf; ++i) { int a = match_str2attr(subfields[i], FALSE); + if (a == ATR_DIM) cond_hilites[HL_ATTCLR_DIM] |= conditions_bitmask; else if (a == ATR_BLINK) @@ -3275,15 +3276,15 @@ choose_color: if (atr & HL_DIM) cond_hilites[HL_ATTCLR_DIM] |= cond; - else if (atr & HL_BLINK) + if (atr & HL_BLINK) cond_hilites[HL_ATTCLR_BLINK] |= cond; - else if (atr & HL_ULINE) + if (atr & HL_ULINE) cond_hilites[HL_ATTCLR_ULINE] |= cond; - else if (atr & HL_INVERSE) + if (atr & HL_INVERSE) cond_hilites[HL_ATTCLR_INVERSE] |= cond; - else if (atr & HL_BOLD) + if (atr & HL_BOLD) cond_hilites[HL_ATTCLR_BOLD] |= cond; - else if (atr == HL_NONE) { + if (atr == HL_NONE) { cond_hilites[HL_ATTCLR_DIM] &= ~cond; cond_hilites[HL_ATTCLR_BLINK] &= ~cond; cond_hilites[HL_ATTCLR_ULINE] &= ~cond; diff --git a/src/options.c b/src/options.c index 7bdde27a9..551eca6de 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 options.c $NHDT-Date: 1553204012 2019/03/21 21:33:32 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.358 $ */ +/* NetHack 3.6 options.c $NHDT-Date: 1553217909 2019/03/22 01:25:09 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.359 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1516,14 +1516,14 @@ const char *prompt; : MENU_UNSELECTED); } end_menu(tmpwin, (prompt && *prompt) ? prompt : "Pick an attribute"); - pick_cnt = select_menu(tmpwin, allow_many ? PICK_ANY: PICK_ONE, &picks); + pick_cnt = select_menu(tmpwin, allow_many ? PICK_ANY : PICK_ONE, &picks); destroy_nhwindow(tmpwin); if (pick_cnt > 0) { int j, k = 0; if (allow_many) { - /* PICK_ANY, with one preselected entry which should be - excluded if any other choices were picked */ + /* PICK_ANY, with one preselected entry (ATR_NONE) which + should be excluded if any other choices were picked */ for (i = 0; i < pick_cnt; ++i) { j = picks[i].item.a_int - 1; if (attrnames[j].attr != ATR_NONE || pick_cnt == 1) { From 02bf042ab43da1354520a5cfd13fc8488f6e4ad7 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 22 Mar 2019 16:13:21 -0700 Subject: [PATCH 2/2] status updating I've noticed (with curses interface) that there are a lot of update_status(BL_FLUSH) calls when nothing on the status lines has changed. It happens while just wondering around, not due to deliberate botlx update. This eliminates one of the causes. Updating hero's experience points or score (via u.urexp) was requesting a bottom lines refresh even if the relevant options to see those changed values was off. The botl code would send a flush directive even though nothing visible was modified. (I have a fix for that too, but am holding back while hoping to find some of the other causes of unnecessary botl requests.) --- doc/fixes36.2 | 4 +++- src/exper.c | 31 +++++++++++++++++++------------ 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 9522e1eae..fedb1a3aa 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.278 $ $NHDT-Date: 1553217908 2019/03/22 01:25:08 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.279 $ $NHDT-Date: 1553296396 2019/03/22 23:13:16 $ This fixes36.2 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.1 in April 2018. Please note, however, @@ -394,6 +394,8 @@ kicking an object stack moves the topmost 1, but range calculation used the yielding "thump" result with no movement despite being a light item status lines' dungeon location field in the elemental planes now shows Earth or Air or Fire or Water instead of generic End Game +avoid spurious status refresh when hero gains experience while 'showexp' and + 'showscore' options are off Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/exper.c b/src/exper.c index bb13aa901..0cead3e97 100644 --- a/src/exper.c +++ b/src/exper.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 exper.c $NHDT-Date: 1544917599 2018/12/15 23:46:39 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.31 $ */ +/* NetHack 3.6 exper.c $NHDT-Date: 1553296396 2019/03/22 23:13:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.32 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2007. */ /* NetHack may be freely redistributed. See license for details. */ @@ -161,24 +161,31 @@ void more_experienced(exper, rexp) register int exper, rexp; { - long newexp = u.uexp + exper; - long rexpincr = 4 * exper + rexp; - long newrexp = u.urexp + rexpincr; + long oldexp = u.uexp, + oldrexp = u.urexp, + newexp = oldexp + exper, + rexpincr = 4 * exper + rexp, + newrexp = oldrexp + rexpincr; /* cap experience and score on wraparound */ if (newexp < 0 && exper > 0) newexp = LONG_MAX; if (newrexp < 0 && rexpincr > 0) newrexp = LONG_MAX; - u.uexp = newexp; - u.urexp = newrexp; - if (exper + if (newexp != oldexp) { + u.uexp = newexp; + if (flags.showexp) + context.botl = TRUE; + } + /* newrexp will always differ from oldrexp unless they're LONG_MAX */ + if (newrexp != oldrexp) { + u.urexp = newrexp; #ifdef SCORE_ON_BOTL - || flags.showscore + if (flags.showscore) + context.botl = TRUE; #endif - ) - context.botl = 1; + } if (u.urexp >= (Role_if(PM_WIZARD) ? 1000 : 2000)) flags.beginner = 0; } @@ -243,7 +250,7 @@ const char *drainer; /* cause of death, if drain should be fatal */ rehumanize(); } - context.botl = 1; + context.botl = TRUE; } /* @@ -303,7 +310,7 @@ boolean incr; /* true iff via incremental experience growth */ adjabil(u.ulevel - 1, u.ulevel); /* give new intrinsics */ reset_rndmonst(NON_PM); /* new monster selection */ } - context.botl = 1; + context.botl = TRUE; } /* compute a random amount of experience points suitable for the hero's