From 4c9603298a56cd565373f6ce9a902c29e93b55d7 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Sat, 1 Dec 2018 08:58:36 +0200 Subject: [PATCH 1/9] glyph variable is actually used --- src/windows.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/windows.c b/src/windows.c index 9e7ffe5b3..7326dd7a2 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1277,7 +1277,7 @@ winid win UNUSED; STATIC_OVL void dump_add_menu(win, glyph, identifier, ch, gch, attr, str, preselected) winid win UNUSED; -int glyph UNUSED; +int glyph; const anything *identifier UNUSED; char ch; char gch UNUSED; From a5a51814a195ef5494f1ac3dff4088db7e75f61b Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 1 Dec 2018 09:41:22 -0500 Subject: [PATCH 2/9] get rid of some gcc warnings with Windows build --- include/ntconf.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/ntconf.h b/include/ntconf.h index bf98fec65..6859d52b0 100644 --- a/include/ntconf.h +++ b/include/ntconf.h @@ -5,7 +5,7 @@ #ifndef NTCONF_H #define NTCONF_H -/* #define SHELL /* nt use of pcsys routines caused a hang */ +/* #define SHELL */ /* nt use of pcsys routines caused a hang */ #define RANDOM /* have Berkeley random(3) */ #define TEXTCOLOR /* Color text */ @@ -43,7 +43,7 @@ * The remaining code shouldn't need modification. * ----------------------------------------------------------------- */ -/* #define SHORT_FILENAMES /* All NT filesystems support long names now +/* #define SHORT_FILENAMES */ /* All NT filesystems support long names now */ #ifdef MICRO @@ -143,12 +143,14 @@ extern void FDECL(interject, (int)); #define strncmpi(a, b, c) strnicmp(a, b, c) #endif +#ifdef _MSC_VER /* Visual Studio defines this in their own headers, which we don't use */ #ifndef snprintf #define snprintf _snprintf #pragma warning( \ disable : 4996) /* deprecation warning suggesting snprintf_s */ #endif +#endif #include #include From 37b5e0e479a436089fddb70b07ea95b2afcf5c74 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 1 Dec 2018 11:31:08 -0500 Subject: [PATCH 3/9] make curses commented out by default (again) --- sys/winnt/Makefile.msc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 6763be545..3bc520282 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -73,8 +73,8 @@ DEBUGINFO = Y # PDCurses header (.h) files and PDCURSES_C to the location # of your PDCurses C files. # -ADD_CURSES=Y -PDCURSES_TOP=..\..\pdcurses +#ADD_CURSES=Y +#PDCURSES_TOP=..\..\pdcurses # #============================================================================== # This marks the end of the BUILD DECISIONS section. From e19ad7d2bc340314724f9d26e9445990c1165dc9 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 1 Dec 2018 19:24:22 -0500 Subject: [PATCH 4/9] Remove some Windows-specific code from src/cmd.c --- src/cmd.c | 59 ------------------------------------------------------- 1 file changed, 59 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index eba20ccd3..d59e9b87a 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -176,9 +176,6 @@ STATIC_DCL void FDECL(contained_stats, (winid, const char *, long *, long *)); STATIC_DCL void FDECL(misc_stats, (winid, long *, long *)); STATIC_PTR int NDECL(wiz_show_stats); STATIC_DCL boolean FDECL(accept_menu_prefix, (int NDECL((*)))); -#ifdef PORT_DEBUG -STATIC_DCL int NDECL(wiz_port_debug); -#endif STATIC_PTR int NDECL(wiz_rumor_check); STATIC_PTR int NDECL(doattributes); @@ -3272,10 +3269,6 @@ struct ext_func_tab extcmdlist[] = { { ',', "pickup", "pick up things at the current location", dopickup }, { '\0', "polyself", "polymorph self", wiz_polyself, IFBURIED | AUTOCOMPLETE | WIZMODECMD }, -#ifdef PORT_DEBUG - { '\0', "portdebug", "wizard port debug command", - wiz_port_debug, IFBURIED | AUTOCOMPLETE | WIZMODECMD }, -#endif { M('p'), "pray", "pray to the gods for help", dopray, IFBURIED | AUTOCOMPLETE }, { C('p'), "prevmsg", "view recent game messages", @@ -5707,58 +5700,6 @@ dotravel(VOID_ARGS) return 0; } -#ifdef PORT_DEBUG -#if defined(WIN32) && defined(TTY_GRAPHICS) -extern void NDECL(win32con_debug_keystrokes); -extern void NDECL(win32con_handler_info); -#endif - -int -wiz_port_debug() -{ - int n, k; - winid win; - anything any; - int item = 'a'; - int num_menu_selections; - struct menu_selection_struct { - char *menutext; - void NDECL((*fn)); - } menu_selections[] = { -#if defined(WIN32) && defined(TTY_GRAPHICS) - { "test win32 keystrokes (tty only)", win32con_debug_keystrokes }, - { "show keystroke handler information (tty only)", - win32con_handler_info }, -#endif - { (char *) 0, (void NDECL((*))) 0 } /* array terminator */ - }; - - num_menu_selections = SIZE(menu_selections) - 1; - if (num_menu_selections > 0) { - menu_item *pick_list; - - win = create_nhwindow(NHW_MENU); - start_menu(win); - for (k = 0; k < num_menu_selections; ++k) { - any.a_int = k + 1; - add_menu(win, NO_GLYPH, &any, item++, 0, ATR_NONE, - menu_selections[k].menutext, MENU_UNSELECTED); - } - end_menu(win, "Which port debugging feature?"); - n = select_menu(win, PICK_ONE, &pick_list); - destroy_nhwindow(win); - if (n > 0) { - n = pick_list[0].item.a_int - 1; - free((genericptr_t) pick_list); - /* execute the function */ - (*menu_selections[n].fn)(); - } - } else - pline("No port-specific debug capability defined."); - return 0; -} -#endif /*PORT_DEBUG*/ - /* * Parameter validator for generic yes/no function to prevent * the core from sending too long a prompt string to the From f12565398a90579747fce6144cc80074e1b1e5ac Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 1 Dec 2018 16:43:13 -0800 Subject: [PATCH 5/9] debug_fuzzer vs '!' and ^Z My sysconf allows shell escape, and the fuzzer seems fond of that. Suppress '!' and also '^Z', although I didn't notice it execute the latter. Without this hack, the sequence '!', sub-shell exit, '&' causes nethack to be killed via SIGTTOU while fiddling with terminal settings for introff(). --- src/cmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cmd.c b/src/cmd.c index d59e9b87a..a7f37ae25 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1542673290 2018/11/20 00:21:30 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.302 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1543711385 2018/12/02 00:43:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.309 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -5501,6 +5501,12 @@ parse() alt_esc = FALSE; /* readchar() reset */ #endif + if (iflags.debug_fuzzer /* if fuzzing, override '!' and ^Z */ + && (Cmd.commands[foo & 0x0ff] + && (Cmd.commands[foo & 0x0ff]->ef_funct == dosuspend_core + || Cmd.commands[foo & 0x0ff]->ef_funct == dosh))) + foo = Cmd.spkeys[NHKF_ESC]; + if (foo == Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ clear_nhwindow(WIN_MESSAGE); multi = last_multi = 0; From 9e047f871b173b9ac741af65a9162e34e85da8d7 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 2 Dec 2018 01:51:23 -0800 Subject: [PATCH 6/9] zap.c formatting bit that's been sitting around for a while and I want to get out of the way. --- src/zap.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/zap.c b/src/zap.c index d53468fe3..5a5a67c34 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 zap.c $NHDT-Date: 1542798627 2018/11/21 11:10:27 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.289 $ */ +/* NetHack 3.6 zap.c $NHDT-Date: 1543744276 2018/12/02 09:51:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.299 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -433,7 +433,8 @@ struct obj *otmp; dmg = spell_damage_bonus(dmg); if (resists_drli(mtmp)) { shieldeff(mtmp->mx, mtmp->my); - } else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) && !DEADMONSTER(mtmp)) { + } else if (!resist(mtmp, otmp->oclass, dmg, NOTELL) + && !DEADMONSTER(mtmp)) { mtmp->mhp -= dmg; mtmp->mhpmax -= dmg; /* die if already level 0, regardless of hit points */ @@ -782,7 +783,7 @@ boolean by_hero; if ((mons[montype].mlet == S_EEL && !IS_POOL(levl[x][y].typ)) || (mons[montype].mlet == S_TROLL && uwep && uwep->oartifact == ART_TROLLSBANE)) { - if (by_hero && cansee(x,y)) + if (by_hero && cansee(x, y)) pline("%s twitches feebly.", upstart(corpse_xname(corpse, (const char *) 0, CXN_PFX_THE))); return (struct monst *) 0; @@ -1831,10 +1832,9 @@ struct obj *obj, *otmp; * from its inventory as a result of the change. * If the items fall to the floor, they are not * subject to direct subsequent polymorphing - * themselves on that same zap. This makes it - * consistent with items that remain in the - * monster's inventory. They are not polymorphed - * either. + * themselves on that same zap. This makes it + * consistent with items that remain in the monster's + * inventory. They are not polymorphed either. * UNDEAD_TURNING - When an undead creature gets killed via * undead turning, prevent its corpse from being * immediately revived by the same effect. From 26a3a537865e098b1249c5a44db347f5111a8d04 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 2 Dec 2018 02:09:22 -0800 Subject: [PATCH 7/9] Sting revisited Replace recent "(light blue aura)" with "(flickering light blue)" if there are 1..4 orcs, "(glimmering light blue)" if 5..12, or "(gleaming light blue)" if there are 13 or more, and move its place in the formatted name. _3.6.1_: Sting (weapon in hand) (glowing light blue) _recent: Sting (weapon in hand) (light blue aura) _now___: Sting (weapon in hand, flickering light blue) The thresholds for intensity may need to be tweaked. The start message has been changed from "glows" to "flickers/glimmers/gleams" and is given when the intensity changes (up or down) as well as when first glowing. Stop message will usually be "stops flickering" but some form of mass kill (genocide for sure, maybe explosion, probably not wand zap) might result in stopping directly from higher intensity. It still "quivers" if hero is blind when there are orcs on the level, but no name augmentation shows in inventory for that situation; describing it as "(weapon in hand, quivering)" would be too silly. Also, the quiver or glow intermediate message if blindness is toggled while Sting is active only worked for make_blinded(), not for putting on and taking off a blindfold. Now fixed. I think becoming blind due to polymorphing into an eyeless form is still not handled, but there are no eyeless creatures capable of wielding weapons so that can wait. Polymorphing from eyeless to sighted is handled but moot for Sting. --- doc/fixes36.2 | 5 ++++ include/extern.h | 6 +++-- src/artifact.c | 54 +++++++++++++++++++++++++++++++++++++------- src/do_wear.c | 18 +++------------ src/objnam.c | 13 ++++++----- src/potion.c | 59 ++++++++++++++++++++++++++++-------------------- 6 files changed, 100 insertions(+), 55 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 94986c5b0..15d5b2d6d 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -234,6 +234,8 @@ dismount that kills steed because there is no room to put it on map blamed the to emphasize that it's not a light source, change description of wielded Sting from "(glowing light blue)" to "(light blue aura)" when sighted and from "(glowing)" to nothing (not warm enough to feel) when blind +glowing Sting quivers if hero becomes blind and quivering Sting glows if + blindness ends; it worked for timed blindness but not for blindfold Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository @@ -253,6 +255,9 @@ life-saving while poly'd and Unchanging wasn't restoring u.mh (HP as monster) change in searching stopped finding unseen monsters except hiders and eels buliding with EXTRA_SANITY_CHECKS enabled would issue "no monster to remove" warning if steed was killed out from under the hero +changing Sting's description to be "(weapon in hand) (light blue aura)" was + too close to feedback when objects become blessed; change it again, + to "(weapon in hand, flickering/glimmering/gleaming light blue)" 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/include/extern.h b/include/extern.h index e4c2f82fe..16b10859b 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1543185068 2018/11/25 22:31:08 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.663 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1543745352 2018/12/02 10:09:12 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.664 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -90,6 +90,7 @@ E boolean FDECL(artifact_has_invprop, (struct obj *, UCHAR_P)); E long FDECL(arti_cost, (struct obj *)); E struct obj *FDECL(what_gives, (long *)); E const char *FDECL(glow_color, (int)); +E const char *FDECL(glow_verb, (int, BOOLEAN_P)); E void FDECL(Sting_effects, (int)); E int FDECL(retouch_object, (struct obj **, BOOLEAN_P)); E void FDECL(retouch_equipment, (int)); @@ -1912,11 +1913,12 @@ E void FDECL(set_itimeout, (long *, long)); E void FDECL(incr_itimeout, (long *, int)); E void FDECL(make_confused, (long, BOOLEAN_P)); E void FDECL(make_stunned, (long, BOOLEAN_P)); -E void FDECL(make_blinded, (long, BOOLEAN_P)); E void FDECL(make_sick, (long, const char *, BOOLEAN_P, int)); E void FDECL(make_slimed, (long, const char *)); E void FDECL(make_stoned, (long, const char *, int, const char *)); E void FDECL(make_vomiting, (long, BOOLEAN_P)); +E void FDECL(make_blinded, (long, BOOLEAN_P)); +E void NDECL(toggle_blindness); E boolean FDECL(make_hallucinated, (long, BOOLEAN_P, long)); E void FDECL(make_deaf, (long, BOOLEAN_P)); E void NDECL(self_invis_message); diff --git a/src/artifact.c b/src/artifact.c index 87cbf3b61..80332f325 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 artifact.c $NHDT-Date: 1509836679 2017/11/04 23:04:39 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.106 $ */ +/* NetHack 3.6 artifact.c $NHDT-Date: 1543745353 2018/12/02 10:09:13 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.127 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -27,6 +27,7 @@ STATIC_DCL boolean FDECL(Mb_hit, (struct monst * magr, struct monst *mdef, struct obj *, int *, int, BOOLEAN_P, char *)); STATIC_DCL unsigned long FDECL(abil_to_spfx, (long *)); STATIC_DCL uchar FDECL(abil_to_adtyp, (long *)); +STATIC_DCL int FDECL(glow_strength, (int)); STATIC_DCL boolean FDECL(untouchable, (struct obj *, BOOLEAN_P)); STATIC_DCL int FDECL(count_surround_traps, (int, int)); @@ -1852,6 +1853,37 @@ int arti_indx; return hcolor(colorstr); } +/* glow verb; [0] holds the value used when blind */ +static const char *glow_verbs[] = { + "quiver", "flicker", "glimmer", "gleam" +}; + +/* relative strength that Sting is glowing (0..3), to select verb */ +STATIC_OVL int +glow_strength(count) +int count; +{ + /* glow strength should also be proportional to proximity and + probably difficulty, but we don't have that information and + gathering it is more trouble than this would be worth */ + return (count > 12) ? 3 : (count > 4) ? 2 : (count > 0); +} + +const char * +glow_verb(count, ingsfx) +int count; /* 0 means blind rather than no applicable creatures */ +boolean ingsfx; +{ + static char resbuf[20]; + + Strcpy(resbuf, glow_verbs[glow_strength(count)]); + /* ing_suffix() will double the last consonant for all the words + we're using and none of them should have that, so bypass it */ + if (ingsfx) + Strcat(resbuf, "ing"); + return resbuf; +} + /* use for warning "glow" for Sting, Orcrist, and Grimtooth */ void Sting_effects(orc_count) @@ -1861,22 +1893,28 @@ int orc_count; /* new count (warn_obj_cnt is old count); -1 is a flag value */ && (uwep->oartifact == ART_STING || uwep->oartifact == ART_ORCRIST || uwep->oartifact == ART_GRIMTOOTH)) { + int oldstr = glow_strength(warn_obj_cnt), + newstr = glow_strength(orc_count); + if (orc_count == -1 && warn_obj_cnt > 0) { /* -1 means that blindness has just been toggled; give a 'continue' message that eventual 'stop' message will match */ pline("%s is %s.", bare_artifactname(uwep), - !Blind ? "glowing" : "quivering"); - } else if (orc_count > 0 && warn_obj_cnt == 0) { + glow_verb(Blind ? 0 : warn_obj_cnt, TRUE)); + } else if (newstr > 0 && newstr != oldstr) { /* 'start' message */ if (!Blind) - pline("%s %s %s!", bare_artifactname(uwep), - otense(uwep, "glow"), glow_color(uwep->oartifact)); - else - pline("%s quivers slightly.", bare_artifactname(uwep)); + pline("%s %s %s%c", bare_artifactname(uwep), + otense(uwep, glow_verb(orc_count, FALSE)), + glow_color(uwep->oartifact), + (newstr > oldstr) ? '!' : '.'); + else if (oldstr == 0) /* quivers */ + pline("%s %s slightly.", bare_artifactname(uwep), + otense(uwep, glow_verb(0, FALSE))); } else if (orc_count == 0 && warn_obj_cnt > 0) { /* 'stop' message */ pline("%s stops %s.", bare_artifactname(uwep), - !Blind ? "glowing" : "quivering"); + glow_verb(Blind ? 0 : warn_obj_cnt, TRUE)); } } } diff --git a/src/do_wear.c b/src/do_wear.c index 7ab53a79e..8300bd0c2 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 do_wear.c $NHDT-Date: 1514072526 2017/12/23 23:42:06 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.100 $ */ +/* NetHack 3.6 do_wear.c $NHDT-Date: 1543745354 2018/12/02 10:09:14 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.103 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1112,13 +1112,7 @@ register struct obj *otmp; You("can see!"); } if (changed) { - /* blindness has just been toggled */ - if (Blind_telepat || Infravision) - see_monsters(); - vision_full_recalc = 1; /* recalc vision limits */ - if (!Blind) - learn_unseen_invent(); - context.botl = 1; + toggle_blindness(); /* potion.c */ } } @@ -1157,13 +1151,7 @@ register struct obj *otmp; } } if (changed) { - /* blindness has just been toggled */ - if (Blind_telepat || Infravision) - see_monsters(); - vision_full_recalc = 1; /* recalc vision limits */ - if (!Blind) - learn_unseen_invent(); - context.botl = 1; + toggle_blindness(); /* potion.c */ } } diff --git a/src/objnam.c b/src/objnam.c index af74c3bf0..7ed8f33fb 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 objnam.c $NHDT-Date: 1543544340 2018/11/30 02:19:00 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.226 $ */ +/* NetHack 3.6 objnam.c $NHDT-Date: 1543745355 2018/12/02 10:09:15 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.227 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1150,15 +1150,16 @@ unsigned doname_flags; if (bimanual(obj)) hand_s = makeplural(hand_s); + /* note: Sting's glow message, if added, will insert text + in front of "(weapon in hand)"'s closing paren */ Sprintf(eos(bp), " (%sweapon in %s)", (obj->otyp == AKLYS) ? "tethered " : "", hand_s); if (warn_obj_cnt && obj == uwep && (EWarn_of_mon & W_WEP) != 0L) { - /* this used to be "(glowing )" when sighted or - "(glowing)" when blind (via feeling warmth), but it - isn't a light source so describe something fainter */ - if (!Blind) - Sprintf(eos(bp), " (%s aura)", glow_color(obj->oartifact)); + if (!Blind) /* we know bp[] ends with ')'; overwrite that */ + Sprintf(eos(bp) - 1, ", %s %s)", + glow_verb(warn_obj_cnt, TRUE), + glow_color(obj->oartifact)); } } } diff --git a/src/potion.c b/src/potion.c index 8985755bb..dc96331e6 100644 --- a/src/potion.c +++ b/src/potion.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 potion.c $NHDT-Date: 1520797133 2018/03/11 19:38:53 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.144 $ */ +/* NetHack 3.6 potion.c $NHDT-Date: 1543745356 2018/12/02 10:09:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.155 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -306,32 +306,43 @@ boolean talk; set_itimeout(&Blinded, xtime); if (u_could_see ^ can_see_now) { /* one or the other but not both */ - context.botl = TRUE; - vision_full_recalc = 1; /* blindness just got toggled */ - /* this vision recalculation used to be deferred until - moveloop(), but that made it possible for vision - irregularities to occur (cited case was force bolt - hitting adjacent potion of blindness and then a - secret door; hero was blinded by vapors but then - got the message "a door appears in the wall") */ - vision_recalc(0); - if (Blind_telepat || Infravision) - see_monsters(); - - /* avoid either of the sequences - "Sting starts glowing", [become blind], "Sting stops quivering" or - "Sting starts quivering", [regain sight], "Sting stops glowing" - by giving "Sting is quivering" when becoming blind or - "Sting is glowing" when regaining sight so that the eventual - "stops" message matches */ - if (warn_obj_cnt && uwep && (EWarn_of_mon & W_WEP) != 0L) - Sting_effects(-1); - /* update dknown flag for inventory picked up while blind */ - if (can_see_now) - learn_unseen_invent(); + toggle_blindness(); } } +/* blindness has just started or just ended--caller enforces that; + called by Blindf_on(), Blindf_off(), and make_blinded() */ +void +toggle_blindness() +{ + boolean Stinging = (uwep && (EWarn_of_mon & W_WEP) != 0L); + + /* blindness has just been toggled */ + context.botl = TRUE; /* status conditions need update */ + vision_full_recalc = 1; /* vision has changed */ + /* this vision recalculation used to be deferred until moveloop(), + but that made it possible for vision irregularities to occur + (cited case was force bolt hitting an adjacent potion of blindness + and then a secret door; hero was blinded by vapors but then got the + message "a door appears in the wall" because wall spot was IN_SIGHT) */ + vision_recalc(0); + if (Blind_telepat || Infravision || Stinging) + see_monsters(); /* also counts EWarn_of_mon monsters */ + /* + * Avoid either of the sequences + * "Sting starts glowing", [become blind], "Sting stops quivering" or + * "Sting starts quivering", [regain sight], "Sting stops glowing" + * by giving "Sting is quivering" when becoming blind or + * "Sting is glowing" when regaining sight so that the eventual + * "stops" message matches the most recent "Sting is ..." one. + */ + if (Stinging) + Sting_effects(-1); + /* update dknown flag for inventory picked up while blind */ + if (!Blind) + learn_unseen_invent(); +} + boolean make_hallucinated(xtime, talk, mask) long xtime; /* nonzero if this is an attempt to turn on hallucination */ From 38b31dd9ca833dcc2a863af35eb92ce64d217ca8 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 2 Dec 2018 09:45:07 -0500 Subject: [PATCH 8/9] fix a build error in cmd.c --- src/cmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cmd.c b/src/cmd.c index a7f37ae25..e5ac4993f 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -5504,7 +5504,10 @@ parse() if (iflags.debug_fuzzer /* if fuzzing, override '!' and ^Z */ && (Cmd.commands[foo & 0x0ff] && (Cmd.commands[foo & 0x0ff]->ef_funct == dosuspend_core - || Cmd.commands[foo & 0x0ff]->ef_funct == dosh))) +#ifdef SHELL + || Cmd.commands[foo & 0x0ff]->ef_funct == dosh +#endif + ))) foo = Cmd.spkeys[NHKF_ESC]; if (foo == Cmd.spkeys[NHKF_ESC]) { /* esc cancels count (TH) */ From 4a4b3fb8f15a18175806b53499b1d87dc175f3d0 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 2 Dec 2018 09:56:44 -0500 Subject: [PATCH 9/9] add a macro to ease conditional testing based on active window port Add WINDOWPORT macro example: if (WINDOWPORT("tty")) pline("Look at me, I'm on tty at the moment!"); --- include/winprocs.h | 5 +++++ src/bones.c | 2 +- src/cmd.c | 2 +- src/files.c | 2 +- src/restore.c | 6 +++--- src/save.c | 4 ++-- sys/share/pcmain.c | 4 ++-- sys/share/pcunix.c | 4 ++-- sys/share/unixtty.c | 16 ++++++++-------- sys/winnt/winnt.c | 17 ++++++++++------- 10 files changed, 35 insertions(+), 27 deletions(-) diff --git a/include/winprocs.h b/include/winprocs.h index 326f44eb2..316af5171 100644 --- a/include/winprocs.h +++ b/include/winprocs.h @@ -260,6 +260,11 @@ struct wc_Opt { unsigned long wc_bit; }; +/* Macro for the currently active Window Port whose function + pointers have been loaded */ +#define WINDOWPORT(wn) \ + (windowprocs.name && !strncmpi((wn), windowprocs.name, strlen((wn)))) + /* role selection by player_selection(); this ought to be in the core... */ #define RS_NAME 0 #define RS_ROLE 1 diff --git a/src/bones.c b/src/bones.c index 77fc27124..7aadc3967 100644 --- a/src/bones.c +++ b/src/bones.c @@ -190,7 +190,7 @@ sanitize_name(namebuf) char *namebuf; { int c; - boolean strip_8th_bit = (!strcmp(windowprocs.name, "tty") + boolean strip_8th_bit = (WINDOWPORT("tty") && !iflags.wc_eight_bit_input); /* it's tempting to skip this for single-user platforms, since diff --git a/src/cmd.c b/src/cmd.c index e5ac4993f..20327366c 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1049,7 +1049,7 @@ wiz_show_wmodes(VOID_ARGS) int x, y; char row[COLNO + 1]; struct rm *lev; - boolean istty = !strcmp(windowprocs.name, "tty"); + boolean istty = WINDOWPORT("tty"); win = create_nhwindow(NHW_TEXT); if (istty) diff --git a/src/files.c b/src/files.c index bec88904f..3dd137743 100644 --- a/src/files.c +++ b/src/files.c @@ -1279,7 +1279,7 @@ boolean uncomp; int i = 0; int f; #ifdef TTY_GRAPHICS - boolean istty = !strncmpi(windowprocs.name, "tty", 3); + boolean istty = WINDOWPORT("tty"); #endif Strcpy(cfn, filename); diff --git a/src/restore.c b/src/restore.c index f26379967..25604f10d 100644 --- a/src/restore.c +++ b/src/restore.c @@ -828,7 +828,7 @@ register int fd; #ifdef AMII_GRAPHICS { extern struct window_procs amii_procs; - if (windowprocs.win_init_nhwindows == amii_procs.win_init_nhwindows) { + if (WINDOWPORT("amii") { extern winid WIN_BASE; clear_nhwindow(WIN_BASE); /* hack until there's a hook for this */ } @@ -844,7 +844,7 @@ register int fd; curs(WIN_MAP, 1, 1); dotcnt = 0; dotrow = 2; - if (strncmpi("X11", windowprocs.name, 3)) + if (!WINDOWPORT("X11")) putstr(WIN_MAP, 0, "Restoring:"); #endif restoreprocs.mread_flags = 1; /* return despite error */ @@ -859,7 +859,7 @@ register int fd; dotrow++; dotcnt = 0; } - if (strncmpi("X11", windowprocs.name, 3)) { + if (!WINDOWPORT("X11")) { putstr(WIN_MAP, 0, "."); } mark_synch(); diff --git a/src/save.c b/src/save.c index bca03c49e..095890f05 100644 --- a/src/save.c +++ b/src/save.c @@ -178,7 +178,7 @@ dosave0() dotcnt = 0; dotrow = 2; curs(WIN_MAP, 1, 1); - if (strncmpi("X11", windowprocs.name, 3)) + if (!WINDOWPORT("X11")) putstr(WIN_MAP, 0, "Saving:"); #endif #ifdef MFLOPPY @@ -242,7 +242,7 @@ dosave0() dotrow++; dotcnt = 0; } - if (strncmpi("X11", windowprocs.name, 3)) { + if (!WINDOWPORT("X11")) { putstr(WIN_MAP, 0, "."); } mark_synch(); diff --git a/sys/share/pcmain.c b/sys/share/pcmain.c index 20b73f728..8651ae8fe 100644 --- a/sys/share/pcmain.c +++ b/sys/share/pcmain.c @@ -499,12 +499,12 @@ _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);*/ #ifdef WIN32 /* - if (!strncmpi(windowprocs.name, "mswin", 5)) + if (WINDOWPORT("mswin")) NHWinMainInit(); else */ #ifdef TTY_GRAPHICS - if (!strncmpi(windowprocs.name, "tty", 3)) { + if (WINDOWPORT("tty")) { iflags.use_background_glyph = FALSE; nttty_open(1); } else { diff --git a/sys/share/pcunix.c b/sys/share/pcunix.c index 22bc4ae4e..bb746ca92 100644 --- a/sys/share/pcunix.c +++ b/sys/share/pcunix.c @@ -198,7 +198,7 @@ getlock() #ifndef SELF_RECOVER if (eraseoldlocks()) { #if defined(WIN32) && defined(TTY_GRAPHICS) - if (!strncmpi(windowprocs.name, "tty", 3)) + if (WINDOWPORT("tty")) clear_screen(); /* display gets fouled up otherwise */ #endif goto gotlock; @@ -212,7 +212,7 @@ getlock() #else /*SELF_RECOVER*/ if (recover_savefile()) { #if defined(WIN32) && defined(TTY_GRAPHICS) - if (!strncmpi(windowprocs.name, "tty", 3)) + if (WINDOWPORT("tty")) clear_screen(); /* display gets fouled up otherwise */ #endif goto gotlock; diff --git a/sys/share/unixtty.c b/sys/share/unixtty.c index 00d473204..39a859e79 100644 --- a/sys/share/unixtty.c +++ b/sys/share/unixtty.c @@ -305,7 +305,7 @@ void intron() /* enable kbd interupts if enabled when game started */ { #ifdef TTY_GRAPHICS /* Ugly hack to keep from changing tty modes for non-tty games -dlc */ - if (!strcmp(windowprocs.name, "tty") && intr_char != nonesuch + if (WINDOWPORT("tty") && intr_char != nonesuch && curttyb2.intr_sym != '\003') { curttyb2.intr_sym = '\003'; setctty(); @@ -317,7 +317,7 @@ void introff() /* disable kbd interrupts if required*/ { #ifdef TTY_GRAPHICS /* Ugly hack to keep from changing tty modes for non-tty games -dlc */ - if (!strcmp(windowprocs.name, "tty") && curttyb2.intr_sym != nonesuch) { + if (WINDOWPORT("tty") && curttyb2.intr_sym != nonesuch) { curttyb2.intr_sym = nonesuch; setctty(); } @@ -345,7 +345,7 @@ void sco_mapon() { #ifdef TTY_GRAPHICS - if (!strcmp(windowprocs.name, "tty") && sco_flag_console) { + if (WINDOWPORT("tty") && sco_flag_console) { if (sco_map_valid != -1) { ioctl(0, LDSMAP, sco_chanmap_buf); } @@ -358,7 +358,7 @@ void sco_mapoff() { #ifdef TTY_GRAPHICS - if (!strcmp(windowprocs.name, "tty") && sco_flag_console) { + if (WINDOWPORT("tty") && sco_flag_console) { sco_map_valid = ioctl(0, LDGMAP, sco_chanmap_buf); if (sco_map_valid != -1) { ioctl(0, LDNMAP, (char *) 0); @@ -379,7 +379,7 @@ void init_sco_cons() { #ifdef TTY_GRAPHICS - if (!strcmp(windowprocs.name, "tty") && sco_flag_console) { + if (WINDOWPORT("tty") && sco_flag_console) { atexit(sco_mapon); sco_mapoff(); load_symset("IBMGraphics", PRIMARY); @@ -409,7 +409,7 @@ void linux_mapon() { #ifdef TTY_GRAPHICS - if (!strcmp(windowprocs.name, "tty") && linux_flag_console) { + if (WINDOWPORT("tty") && linux_flag_console) { write(1, "\033(B", 3); } #endif @@ -419,7 +419,7 @@ void linux_mapoff() { #ifdef TTY_GRAPHICS - if (!strcmp(windowprocs.name, "tty") && linux_flag_console) { + if (WINDOWPORT("tty") && linux_flag_console) { write(1, "\033(U", 3); } #endif @@ -439,7 +439,7 @@ void init_linux_cons() { #ifdef TTY_GRAPHICS - if (!strcmp(windowprocs.name, "tty") && linux_flag_console) { + if (WINDOWPORT("tty") && linux_flag_console) { atexit(linux_mapon); linux_mapoff(); #ifdef TEXTCOLOR diff --git a/sys/winnt/winnt.c b/sys/winnt/winnt.c index 5b0fd8bc8..0be1da094 100644 --- a/sys/winnt/winnt.c +++ b/sys/winnt/winnt.c @@ -216,7 +216,7 @@ VA_DECL(const char *, s) /* error() may get called before tty is initialized */ if (iflags.window_inited) end_screen(); - if (windowprocs.name != NULL && !strncmpi(windowprocs.name, "tty", 3)) { + if (WINDOWPORT("tty")) { buf[0] = '\n'; (void) vsprintf(&buf[1], s, VA_ARGS); Strcat(buf, "\n"); @@ -239,6 +239,11 @@ Delay(int ms) void win32_abort() { + boolean is_tty = FALSE; + +#ifdef TTY_GRAPHICS + is_tty = WINDOWPORT("tty"); +#endif if (wizard) { int c, ci, ct; @@ -248,13 +253,11 @@ win32_abort() msmsg("Execute debug breakpoint wizard?"); while ((ci = nhgetch()) != '\n') { if (ct > 0) { -#ifdef TTY_GRAPHICS - backsp(); /* \b is visible on NT */ -#endif + if (is_tty) + backsp(); /* \b is visible on NT console */ (void) putchar(' '); -#ifdef TTY_GRAPHICS - backsp(); -#endif + if (is_tty) + backsp(); ct = 0; c = 'n'; }