From ab9e28d1aaa7a009e5051dcbee6bbbccf62804e5 Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 4 Dec 2018 11:58:05 -0500 Subject: [PATCH 01/26] some fixes provided from Hardfought --- include/flag.h | 3 +- include/wincurs.h | 3 -- src/files.c | 9 +++++- src/options.c | 67 ++++++++++++++++++++++++++++++++++++++++++- sys/unix/Makefile.src | 8 ++++++ 5 files changed, 84 insertions(+), 6 deletions(-) diff --git a/include/flag.h b/include/flag.h index 0623ec526..e3d0a5143 100644 --- a/include/flag.h +++ b/include/flag.h @@ -322,12 +322,13 @@ struct instance_flags { #endif #endif uchar bouldersym; /* symbol for boulder display */ -#ifdef TTY_GRAPHICS +#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) char prevmsg_window; /* type of old message window to use */ #endif #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) boolean extmenu; /* extended commands use menu interface */ #endif + #ifdef MFLOPPY boolean checkspace; /* check disk space before writing files */ /* (in iflags to allow restore after moving diff --git a/include/wincurs.h b/include/wincurs.h index 55e7f1d22..be79256b7 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -259,9 +259,6 @@ extern void curses_del_menu(winid wid); extern void curses_status_init(void); extern void curses_status_update(int, genericptr_t, int, int, int, unsigned long *); -/* extern attr_t curses_color_attr(int nh_color, int bg_color); */ -/* extern void curses_update_stats(void); */ -/* extern void curses_decrement_highlight(void); */ /* cursinvt.c */ diff --git a/src/files.c b/src/files.c index 3dd137743..2fd0f89c1 100644 --- a/src/files.c +++ b/src/files.c @@ -3185,7 +3185,14 @@ int which_set; if (symset[which_set].name && (fuzzymatch(symset[which_set].name, "Default symbols", " -_", TRUE) - || !strcmpi(symset[which_set].name, "default"))) + || !strcmpi(symset[which_set].name, "default") +#ifdef CURSES_GRAPHICS + /* we don't maintain static symbols for curses + * the system defines these at runtime + */ + || !strcmpi(symset[which_set].name, "curses") +#endif + )) clear_symsetentry(which_set, TRUE); config_error_done(); return (symset[which_set].name == 0) ? 1 : 0; diff --git a/src/options.c b/src/options.c index 8be8cfcd3..51f0d6d8f 100644 --- a/src/options.c +++ b/src/options.c @@ -106,7 +106,7 @@ static struct Bool_Opt { #endif { "clicklook", &iflags.clicklook, FALSE, SET_IN_GAME }, { "cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME }, -#if defined(MICRO) || defined(WIN32) +#if defined(MICRO) || defined(WIN32) || defined(CURSES_GRAPHICS) { "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /*WC*/ #else /* systems that support multiple terminals, many monochrome */ { "color", &iflags.wc_color, FALSE, SET_IN_GAME }, /*WC*/ @@ -3626,6 +3626,71 @@ boolean tinitial, tfrom_file; } #endif + /* WINCAP2 + * term_cols:amount */ + fullname = "term_cols"; + if (match_optname(opts, fullname, sizeof("term_cols")-1, TRUE)) { + op = string_for_opt(opts, negated); + iflags.wc2_term_cols = atoi(op); + if (negated) bad_negation(fullname, FALSE); + return retval; + } + + /* WINCAP2 + * term_rows:amount */ + fullname = "term_rows"; + if (match_optname(opts, fullname, sizeof("term_rows")-1, TRUE)) { + op = string_for_opt(opts, negated); + iflags.wc2_term_rows = atoi(op); + if (negated) bad_negation(fullname, FALSE); + return retval; + } + + /* WINCAP2 + * petattr:string */ + fullname = "petattr"; + if (match_optname(opts, fullname, sizeof("petattr")-1, TRUE)) { + op = string_for_opt(opts, negated); + if (op && !negated) { +#ifdef CURSES_GRAPHICS + iflags.wc2_petattr = curses_read_attrs(op); + if (!curses_read_attrs(op)) + config_error_add("Unknown %s parameter '%s'", fullname, opts); + return FALSE; +#else + /* non-curses windowports will not use this flag anyway + * but the above will not compile if we don't have curses. + * Just set it to a sensible default: */ + iflags.wc2_petattr = ATR_INVERSE +#endif + } else if (negated) bad_negation(fullname, TRUE); + return retval; + } + + /* WINCAP2 + * windowborders:n */ + fullname = "windowborders"; + if (match_optname(opts, fullname, sizeof("windowborders")-1, TRUE)) { + op = string_for_opt(opts, negated); + if (negated && op) bad_negation(fullname, TRUE); + else { + if (negated) + iflags.wc2_windowborders = 2; /* Off */ + else if (!op) + iflags.wc2_windowborders = 1; /* On */ + else /* Value supplied */ + iflags.wc2_windowborders = atoi(op); + if ((iflags.wc2_windowborders > 3) || + (iflags.wc2_windowborders < 1)) { + iflags.wc2_windowborders = 0; + config_error_add("Unknown %s parameter '%s'", fullname, opts); + return FALSE; + + } + } + return retval; + } + /* menustyle:traditional or combination or full or partial */ fullname = "menustyle"; if (match_optname(opts, fullname, 4, TRUE)) { diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 07d5d5920..38523fd36 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -198,6 +198,14 @@ REGEXOBJ = posixregex.o WINTTYSRC = ../win/tty/getline.c ../win/tty/termcap.c ../win/tty/topl.c \ ../win/tty/wintty.c WINTTYOBJ = getline.o termcap.o topl.o wintty.o +# Files for curses interface +WINCURSESSRC = ../win/curses/cursmain.c ../win/curses/curswins.c \ + ../win/curses/cursmisc.c ../win/curses/cursdial.c \ + ../win/curses/cursstat.c ../win/curses/cursinit.c \ + ../win/curses/cursmesg.c ../win/curses/cursinvt.c +WINCURSESOBJ = cursmain.o curswins.o cursmisc.o cursdial.o cursstat.o \ + cursinit.o cursmesg.o cursinvt.o + # # Files for curses interface WINCURSESSRC = ../win/curses/cursmain.c ../win/curses/curswins.c \ From dc2539701a05e1cb90362dd45e9f576eee4a21c2 Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 4 Dec 2018 11:59:41 -0500 Subject: [PATCH 02/26] Revert "some fixes provided from Hardfought" This reverts commit ab9e28d1aaa7a009e5051dcbee6bbbccf62804e5. --- include/flag.h | 3 +- include/wincurs.h | 3 ++ src/files.c | 9 +----- src/options.c | 67 +------------------------------------------ sys/unix/Makefile.src | 8 ------ 5 files changed, 6 insertions(+), 84 deletions(-) diff --git a/include/flag.h b/include/flag.h index e3d0a5143..0623ec526 100644 --- a/include/flag.h +++ b/include/flag.h @@ -322,13 +322,12 @@ struct instance_flags { #endif #endif uchar bouldersym; /* symbol for boulder display */ -#if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) +#ifdef TTY_GRAPHICS char prevmsg_window; /* type of old message window to use */ #endif #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) boolean extmenu; /* extended commands use menu interface */ #endif - #ifdef MFLOPPY boolean checkspace; /* check disk space before writing files */ /* (in iflags to allow restore after moving diff --git a/include/wincurs.h b/include/wincurs.h index be79256b7..55e7f1d22 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -259,6 +259,9 @@ extern void curses_del_menu(winid wid); extern void curses_status_init(void); extern void curses_status_update(int, genericptr_t, int, int, int, unsigned long *); +/* extern attr_t curses_color_attr(int nh_color, int bg_color); */ +/* extern void curses_update_stats(void); */ +/* extern void curses_decrement_highlight(void); */ /* cursinvt.c */ diff --git a/src/files.c b/src/files.c index 2fd0f89c1..3dd137743 100644 --- a/src/files.c +++ b/src/files.c @@ -3185,14 +3185,7 @@ int which_set; if (symset[which_set].name && (fuzzymatch(symset[which_set].name, "Default symbols", " -_", TRUE) - || !strcmpi(symset[which_set].name, "default") -#ifdef CURSES_GRAPHICS - /* we don't maintain static symbols for curses - * the system defines these at runtime - */ - || !strcmpi(symset[which_set].name, "curses") -#endif - )) + || !strcmpi(symset[which_set].name, "default"))) clear_symsetentry(which_set, TRUE); config_error_done(); return (symset[which_set].name == 0) ? 1 : 0; diff --git a/src/options.c b/src/options.c index 51f0d6d8f..8be8cfcd3 100644 --- a/src/options.c +++ b/src/options.c @@ -106,7 +106,7 @@ static struct Bool_Opt { #endif { "clicklook", &iflags.clicklook, FALSE, SET_IN_GAME }, { "cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME }, -#if defined(MICRO) || defined(WIN32) || defined(CURSES_GRAPHICS) +#if defined(MICRO) || defined(WIN32) { "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /*WC*/ #else /* systems that support multiple terminals, many monochrome */ { "color", &iflags.wc_color, FALSE, SET_IN_GAME }, /*WC*/ @@ -3626,71 +3626,6 @@ boolean tinitial, tfrom_file; } #endif - /* WINCAP2 - * term_cols:amount */ - fullname = "term_cols"; - if (match_optname(opts, fullname, sizeof("term_cols")-1, TRUE)) { - op = string_for_opt(opts, negated); - iflags.wc2_term_cols = atoi(op); - if (negated) bad_negation(fullname, FALSE); - return retval; - } - - /* WINCAP2 - * term_rows:amount */ - fullname = "term_rows"; - if (match_optname(opts, fullname, sizeof("term_rows")-1, TRUE)) { - op = string_for_opt(opts, negated); - iflags.wc2_term_rows = atoi(op); - if (negated) bad_negation(fullname, FALSE); - return retval; - } - - /* WINCAP2 - * petattr:string */ - fullname = "petattr"; - if (match_optname(opts, fullname, sizeof("petattr")-1, TRUE)) { - op = string_for_opt(opts, negated); - if (op && !negated) { -#ifdef CURSES_GRAPHICS - iflags.wc2_petattr = curses_read_attrs(op); - if (!curses_read_attrs(op)) - config_error_add("Unknown %s parameter '%s'", fullname, opts); - return FALSE; -#else - /* non-curses windowports will not use this flag anyway - * but the above will not compile if we don't have curses. - * Just set it to a sensible default: */ - iflags.wc2_petattr = ATR_INVERSE -#endif - } else if (negated) bad_negation(fullname, TRUE); - return retval; - } - - /* WINCAP2 - * windowborders:n */ - fullname = "windowborders"; - if (match_optname(opts, fullname, sizeof("windowborders")-1, TRUE)) { - op = string_for_opt(opts, negated); - if (negated && op) bad_negation(fullname, TRUE); - else { - if (negated) - iflags.wc2_windowborders = 2; /* Off */ - else if (!op) - iflags.wc2_windowborders = 1; /* On */ - else /* Value supplied */ - iflags.wc2_windowborders = atoi(op); - if ((iflags.wc2_windowborders > 3) || - (iflags.wc2_windowborders < 1)) { - iflags.wc2_windowborders = 0; - config_error_add("Unknown %s parameter '%s'", fullname, opts); - return FALSE; - - } - } - return retval; - } - /* menustyle:traditional or combination or full or partial */ fullname = "menustyle"; if (match_optname(opts, fullname, 4, TRUE)) { diff --git a/sys/unix/Makefile.src b/sys/unix/Makefile.src index 38523fd36..07d5d5920 100644 --- a/sys/unix/Makefile.src +++ b/sys/unix/Makefile.src @@ -198,14 +198,6 @@ REGEXOBJ = posixregex.o WINTTYSRC = ../win/tty/getline.c ../win/tty/termcap.c ../win/tty/topl.c \ ../win/tty/wintty.c WINTTYOBJ = getline.o termcap.o topl.o wintty.o -# Files for curses interface -WINCURSESSRC = ../win/curses/cursmain.c ../win/curses/curswins.c \ - ../win/curses/cursmisc.c ../win/curses/cursdial.c \ - ../win/curses/cursstat.c ../win/curses/cursinit.c \ - ../win/curses/cursmesg.c ../win/curses/cursinvt.c -WINCURSESOBJ = cursmain.o curswins.o cursmisc.o cursdial.o cursstat.o \ - cursinit.o cursmesg.o cursinvt.o - # # Files for curses interface WINCURSESSRC = ../win/curses/cursmain.c ../win/curses/curswins.c \ From 37b7243c57af7465f8526bf1bf9d85b9b7f5875b Mon Sep 17 00:00:00 2001 From: nhmall Date: Tue, 4 Dec 2018 22:22:43 -0500 Subject: [PATCH 03/26] some updates to curses Tangles updates --- include/flag.h | 4 +--- include/wincurs.h | 3 --- src/options.c | 2 +- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/flag.h b/include/flag.h index 0623ec526..a459c5bb9 100644 --- a/include/flag.h +++ b/include/flag.h @@ -322,10 +322,8 @@ struct instance_flags { #endif #endif uchar bouldersym; /* symbol for boulder display */ -#ifdef TTY_GRAPHICS - char prevmsg_window; /* type of old message window to use */ -#endif #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) + char prevmsg_window; /* type of old message window to use */ boolean extmenu; /* extended commands use menu interface */ #endif #ifdef MFLOPPY diff --git a/include/wincurs.h b/include/wincurs.h index 55e7f1d22..be79256b7 100644 --- a/include/wincurs.h +++ b/include/wincurs.h @@ -259,9 +259,6 @@ extern void curses_del_menu(winid wid); extern void curses_status_init(void); extern void curses_status_update(int, genericptr_t, int, int, int, unsigned long *); -/* extern attr_t curses_color_attr(int nh_color, int bg_color); */ -/* extern void curses_update_stats(void); */ -/* extern void curses_decrement_highlight(void); */ /* cursinvt.c */ diff --git a/src/options.c b/src/options.c index d4b7daf4d..7dc622687 100644 --- a/src/options.c +++ b/src/options.c @@ -106,7 +106,7 @@ static struct Bool_Opt { #endif { "clicklook", &iflags.clicklook, FALSE, SET_IN_GAME }, { "cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME }, -#if defined(MICRO) || defined(WIN32) +#if defined(MICRO) || defined(WIN32) || defined(CURSES_GRAPHICS) { "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /*WC*/ #else /* systems that support multiple terminals, many monochrome */ { "color", &iflags.wc_color, FALSE, SET_IN_GAME }, /*WC*/ From 95a6c458bc9bbc2b76d6700f1f2269b4eb4f811e Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 5 Dec 2018 01:45:16 -0800 Subject: [PATCH 04/26] fix #H6292 - green slime & genocide Report suggested that if hero is turning into green slime, genociding green slime should cure it. I went another direction: if life-saved while dying due to turning into green slime, you survive polymorphed into green slime form. If green slimes have been genocided (probably after becoming infected with slime or hero wouldn't have faced any slimes to cause infection, but that could be from eating a glob of green slime created prior to genocide, or from #wizintrinsic), you'll immediately die again, this time from genocide. --- doc/fixes36.2 | 1 + src/end.c | 16 +++++++++---- src/timeout.c | 66 +++++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 67 insertions(+), 16 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 4073cef20..f87856d44 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -242,6 +242,7 @@ level change after being interruped locking or unlocking a container might access freed memory if a restore attempt failed and a new game was started instead, it would use stale context from old game if restoration got far enough to load that +if hero survives turning into slime (life-saving), survive as a green slime Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/end.c b/src/end.c index a433acc07..cbc312598 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 end.c $NHDT-Date: 1542798619 2018/11/21 11:10:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.152 $ */ +/* NetHack 3.6 end.c $NHDT-Date: 1544003110 2018/12/05 09:45:10 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.156 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1184,7 +1184,12 @@ int how; u.ugrave_arise = (NON_PM - 2); /* leave no corpse */ else if (how == STONING) u.ugrave_arise = (NON_PM - 1); /* statue instead of corpse */ - else if (how == TURNED_SLIME) + else if (how == TURNED_SLIME + /* it's possible to turn into slime even though green slimes + have been genocided: genocide could occur after hero is + already infected or hero could eat a glob of one created + before genocide; don't try to arise as one if they're gone */ + && !(mvitals[PM_GREEN_SLIME].mvflags & G_GENOD)) u.ugrave_arise = PM_GREEN_SLIME; if (how == QUIT) { @@ -1310,11 +1315,14 @@ int how; } } - if (u.ugrave_arise >= LOW_PM && u.ugrave_arise != PM_GREEN_SLIME) { + if (u.ugrave_arise >= LOW_PM) { /* give this feedback even if bones aren't going to be created, so that its presence or absence doesn't tip off the player to new bones or their lack; it might be a lie if makemon fails */ - Your("body rises from the dead as %s...", + Your("%s as %s...", + (u.ugrave_arise != PM_GREEN_SLIME) + ? "body rises from the dead" + : "revenant persists", an(mons[u.ugrave_arise].mname)); display_nhwindow(WIN_MESSAGE, FALSE); } diff --git a/src/timeout.c b/src/timeout.c index 110aa03ad..e4347c5b3 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 timeout.c $NHDT-Date: 1541902953 2018/11/11 02:22:33 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.84 $ */ +/* NetHack 3.6 timeout.c $NHDT-Date: 1544003111 2018/12/05 09:45:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.87 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -11,6 +11,7 @@ STATIC_DCL void NDECL(vomiting_dialogue); STATIC_DCL void NDECL(choke_dialogue); STATIC_DCL void NDECL(levitation_dialogue); STATIC_DCL void NDECL(slime_dialogue); +STATIC_DCL void FDECL(slimed_to_death, (struct kinfo *)); STATIC_DCL void NDECL(slip_or_trip); STATIC_DCL void FDECL(see_lamp_flicker, (struct obj *, const char *)); STATIC_DCL void FDECL(lantern_message, (struct obj *)); @@ -357,6 +358,57 @@ burn_away_slime() } } +/* countdown timer for turning into green slime has run out; kill our hero */ +STATIC_OVL void +slimed_to_death(kptr) +struct kinfo *kptr; +{ + /* redundant: polymon() cures sliming when polying into green slime */ + if (Upolyd && youmonst.data == &mons[PM_GREEN_SLIME]) { + dealloc_killer(kptr); + return; + } + /* more sure killer reason is set up */ + if (kptr && kptr->name[0]) { + killer.format = kptr->format; + Strcpy(killer.name, kptr->name); + } else { + killer.format = NO_KILLER_PREFIX; + Strcpy(killer.name, "turned into green slime"); + } + dealloc_killer(kptr); + /* involuntarily break "never changed form" conduct */ + u.uconduct.polyselfs++; + done(TURNED_SLIME); + + /* life-saved; even so, hero still has turned into green slime; + player may have genocided green slimes after being infected */ + if ((mvitals[PM_GREEN_SLIME].mvflags & G_GENOD) != 0) { + killer.format = KILLED_BY; + Strcpy(killer.name, "slimicide"); + /* immediately follows "OK, so you don't die." */ + pline("Yes, you do. Green slime has been genocided..."); + done(GENOCIDED); + /* could be life-saved again (only in explore or wizard mode) + but green slimes are gone; just stay in current form */ + + /* not geno'd; survive as a green slime */ + } else { + /* this part of polyself() isn't in polymon(); + we assume that green slimes don't emit light */ + if (emits_light(youmonst.data)) + del_light_source(LS_MONSTER, monst_to_any(&youmonst)); + /* undo the 'involuntarily break "never changed form"' + increment so that this change isn't counted twice */ + u.uconduct.polyselfs--; + /* can't be Unchanging even if life-saving wasn't due to amulet; + hero infected with slime wouldn't have turned into green slime + to get here if Unchanging */ + (void) polymon(PM_GREEN_SLIME); + } + return; +} + /* Intrinsic Passes_walls is temporary when your god is trying to fix all troubles and then TROUBLE_STUCK_IN_WALL calls safe_teleds() but it can't find anywhere to place you. If that happens you get a small @@ -469,17 +521,7 @@ nh_timeout() done(STONING); break; case SLIMED: - if (kptr && kptr->name[0]) { - killer.format = kptr->format; - Strcpy(killer.name, kptr->name); - } else { - killer.format = NO_KILLER_PREFIX; - Strcpy(killer.name, "turned into green slime"); - } - dealloc_killer(kptr); - /* involuntarily break "never changed form" conduct */ - u.uconduct.polyselfs++; - done(TURNED_SLIME); + slimed_to_death(kptr); /* done(TURNED_SLIME) */ break; case VOMITING: make_vomiting(0L, TRUE); From 6e0a9cad5a5b46f5eaf98a68362af06a9e81c5fc Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 5 Dec 2018 22:35:59 +0200 Subject: [PATCH 05/26] Fake leash object is not attached When farlooking at a fake leash object, make it explicitly not be attached to a monster. --- src/pager.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/pager.c b/src/pager.c index e9fe016ed..22df977e4 100644 --- a/src/pager.c +++ b/src/pager.c @@ -187,6 +187,8 @@ struct obj **obj_p; otmp->quan = 2L; /* to force pluralization */ else if (otmp->otyp == SLIME_MOLD) otmp->spe = context.current_fruit; /* give it a type */ + else if (otmp->otyp == LEASH) + otmp->leashmon = 0; if (mtmp && has_mcorpsenm(mtmp)) /* mimic as corpse/statue */ otmp->corpsenm = MCORPSENM(mtmp); else if (otmp->otyp == CORPSE && glyph_is_body(glyph)) From f020595fb7cf993067047a43c528e1709f571c52 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 5 Dec 2018 22:39:11 +0200 Subject: [PATCH 06/26] Valid cursor locations showed null When getting a cursor location, and there was no "valid" location function defined, trying to go to the next or previous valid location showed null. Fix this by using the "interesting" locations if no valid ones. --- src/do_name.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/do_name.c b/src/do_name.c index c1210bbd9..38665135e 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -378,6 +378,10 @@ int x, y, gloc; || IS_UNEXPLORED_LOC(x - 1, y) || IS_UNEXPLORED_LOC(x, y + 1) || IS_UNEXPLORED_LOC(x, y - 1))); + case GLOC_VALID: + if (getpos_getvalid) + return (getpos_getvalid(x,y)); + /*FALLTHRU*/ case GLOC_INTERESTING: return gather_locs_interesting(x,y, GLOC_DOOR) || !(glyph_is_cmap(glyph) @@ -395,8 +399,6 @@ int x, y, gloc; || glyph_to_cmap(glyph) == S_darkroom || glyph_to_cmap(glyph) == S_corr || glyph_to_cmap(glyph) == S_litcorr)); - case GLOC_VALID: - return (getpos_getvalid && getpos_getvalid(x,y)); } /*NOTREACHED*/ return FALSE; From 857b8af2eec85ae7fccbdc1bf9cd637ce7b36f09 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Wed, 5 Dec 2018 23:15:14 +0200 Subject: [PATCH 07/26] Add missing valid location descriptors --- src/do_name.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/do_name.c b/src/do_name.c index 38665135e..01feca7e7 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -57,7 +57,9 @@ static const char *const gloc_descr[NUM_GLOCS][4] = { { "any unexplored areas", "unexplored area", "unexplored location", "unexplored locations" }, { "anything interesting", "interesting thing", "anything interesting", - "anything interesting" } + "anything interesting" }, + { "any valid locations", "valid location", "valid location", + "valid locations" } }; static const char *const gloc_filtertxt[NUM_GFILTER] = { From c258f9c3f83008ca46e55ce343ff44c660d6a26a Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:40:33 -0500 Subject: [PATCH 08/26] update header on cursdial --- win/curses/cursdial.c | 2 +- win/curses/cursdial.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index 99e5eb830..2e63b6f82 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursdial.c */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #include "curses.h" #include "hack.h" diff --git a/win/curses/cursdial.h b/win/curses/cursdial.h index dea396178..9c15a0775 100644 --- a/win/curses/cursdial.h +++ b/win/curses/cursdial.h @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursdial.h */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #ifndef CURSDIAL_H # define CURSDIAL_H From 14335ea90c66609fc9a0555d577a3e309af51baa Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:41:30 -0500 Subject: [PATCH 09/26] update header on cursinit --- win/curses/cursinit.c | 2 +- win/curses/cursinit.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win/curses/cursinit.c b/win/curses/cursinit.c index f787bf1a0..04adbb853 100644 --- a/win/curses/cursinit.c +++ b/win/curses/cursinit.c @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursinit.c */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #include "curses.h" #include "hack.h" diff --git a/win/curses/cursinit.h b/win/curses/cursinit.h index ef4e232fb..c611d59f6 100644 --- a/win/curses/cursinit.h +++ b/win/curses/cursinit.h @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursinit.h */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #ifndef CURSINIT_H # define CURSINIT_H From 86281c5555d91e94d32f6b9c12301de5a1cdd5c8 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:42:11 -0500 Subject: [PATCH 10/26] update header on cursinvt --- win/curses/cursinvt.c | 6 +++--- win/curses/cursinvt.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/win/curses/cursinvt.c b/win/curses/cursinvt.c index aa9970caf..ebf04a4f4 100644 --- a/win/curses/cursinvt.c +++ b/win/curses/cursinvt.c @@ -1,7 +1,7 @@ -/* NetHack 3.6 cursinvt.c */ -/* Copyright (c) Karl Garrison, 2010. */ -/* NetHack may be freely redistributed. See license for details. */ /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ +/* NetHack 3.6 cursinvt.c */ +/* Copyright (c) Fredrik Ljungdahl, 2017. */ +/* NetHack may be freely redistributed. See license for details. */ #include "curses.h" #include "hack.h" diff --git a/win/curses/cursinvt.h b/win/curses/cursinvt.h index 9d9d65cb2..db2df6586 100644 --- a/win/curses/cursinvt.h +++ b/win/curses/cursinvt.h @@ -1,7 +1,7 @@ -/* NetHack 3.6 cursinvt.h */ -/* Copyright (c) Karl Garrison, 2010. */ -/* NetHack may be freely redistributed. See license for details. */ /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ +/* NetHack 3.6 cursinvt.h */ +/* Copyright (c) Fredrik Ljungdahl, 2017. */ +/* NetHack may be freely redistributed. See license for details. */ #ifndef CURSINVT_H # define CURSINVT_H From 661ffb0133924f0777e1a97b47d60b0be95d5f81 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:42:49 -0500 Subject: [PATCH 11/26] update header on cursmain --- win/curses/cursmain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 2412def4b..62abc71f1 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursmain.c */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #include "curses.h" #include "hack.h" From c260911f38deaa1bb7c966579234acf81a6d7293 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:43:33 -0500 Subject: [PATCH 12/26] update header on cursmesg --- win/curses/cursmesg.c | 2 +- win/curses/cursmesg.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win/curses/cursmesg.c b/win/curses/cursmesg.c index ef351a27a..dd0f6e349 100644 --- a/win/curses/cursmesg.c +++ b/win/curses/cursmesg.c @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursmesg.c */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #include "curses.h" #include "hack.h" diff --git a/win/curses/cursmesg.h b/win/curses/cursmesg.h index 588bf883b..f6002356d 100644 --- a/win/curses/cursmesg.h +++ b/win/curses/cursmesg.h @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursmesg.h */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #ifndef CURSMESG_H # define CURSMESG_H From 2458281d425d4c25a521c07958397ad8a0c13235 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:44:08 -0500 Subject: [PATCH 13/26] update header on cursmisc --- win/curses/cursmisc.c | 2 +- win/curses/cursmisc.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 8ee1f68fe..0c47d775d 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursmisc.c */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #include "curses.h" #include "hack.h" diff --git a/win/curses/cursmisc.h b/win/curses/cursmisc.h index 4d0f78003..364901267 100644 --- a/win/curses/cursmisc.h +++ b/win/curses/cursmisc.h @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursmisc.h */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #ifndef CURSMISC_H # define CURSMISC_H From 9c873712b6ebc5a40826d76781cd94c16700978f Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:45:15 -0500 Subject: [PATCH 14/26] update header on cursstat --- win/curses/cursstat.c | 6 +++--- win/curses/cursstat.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index b2e45f28b..4c901736f 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -1,7 +1,7 @@ -/* NetHack 3.6 cursstat.c */ -/* Copyright (c) Karl Garrison, 2010. */ -/* NetHack may be freely redistributed. See license for details. */ /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ +/* NetHack 3.6 cursstat.c */ +/* Copyright (c) Karl Garrison, 2010. */ +/* NetHack may be freely redistributed. See license for details. */ #include /* toupper() */ #include "curses.h" diff --git a/win/curses/cursstat.h b/win/curses/cursstat.h index 8b8120545..e10977bb2 100644 --- a/win/curses/cursstat.h +++ b/win/curses/cursstat.h @@ -1,7 +1,7 @@ -/* NetHack 3.6 cursstat.c */ -/* Copyright (c) Karl Garrison, 2010. */ -/* NetHack may be freely redistributed. See license for details. */ /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ +/* NetHack 3.6 cursstat.h */ +/* Copyright (c) Karl Garrison, 2010. */ +/* NetHack may be freely redistributed. See license for details. */ #ifndef CURSSTAT_H # define CURSSTAT_H From c4930c678207372bb036a2cb9b2c906828b03104 Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 17:45:40 -0500 Subject: [PATCH 15/26] update header on curswins --- win/curses/curswins.c | 2 +- win/curses/curswins.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/win/curses/curswins.c b/win/curses/curswins.c index 017450830..c74a39871 100644 --- a/win/curses/curswins.c +++ b/win/curses/curswins.c @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 curswins.c */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #include "curses.h" #include "hack.h" diff --git a/win/curses/curswins.h b/win/curses/curswins.h index 8a5c00fd6..dfa7b7a1e 100644 --- a/win/curses/curswins.h +++ b/win/curses/curswins.h @@ -1,7 +1,7 @@ +/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 curswins.h */ /* Copyright (c) Karl Garrison, 2010. */ /* NetHack may be freely redistributed. See license for details. */ -/* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ #ifndef CURSWIN_H # define CURSWIN_H From e5b232104eff331136382509acd061c0ad2f846e Mon Sep 17 00:00:00 2001 From: PatR Date: Wed, 5 Dec 2018 14:56:03 -0800 Subject: [PATCH 16/26] more green slime When a hero dies due to turning into green slime, actually polymorph him into a green slime monster before killing him off. That way he'll show as a green 'P' on the map instead of white '@' during final disclosure. Also, armor that gets destroyed by polymorphing into that form will be absent from resulting bones file. --- src/cmd.c | 9 +++++++-- src/timeout.c | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index 8924923da..67170cec7 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1543972186 2018/12/05 01:09:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.313 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1544050555 2018/12/05 22:55:55 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.314 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2740,7 +2740,12 @@ int final; } if (Polymorph_control) you_have("polymorph control", from_what(POLYMORPH_CONTROL)); - if (Upolyd && u.umonnum != u.ulycn) { + if (Upolyd && u.umonnum != u.ulycn + /* if we've died from turning into slime, we're polymorphed + right now but don't want to list it as a temporary attribute + [we need a more reliable way to detect this situation] */ + && !(final == ENL_GAMEOVERDEAD + && u.umonnum == PM_GREEN_SLIME && !Unchanging)) { /* foreign shape (except were-form which is handled below) */ Sprintf(buf, "polymorphed into %s", an(youmonst.data->mname)); if (wizard) diff --git a/src/timeout.c b/src/timeout.c index e4347c5b3..29b740fcc 100644 --- a/src/timeout.c +++ b/src/timeout.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 timeout.c $NHDT-Date: 1544003111 2018/12/05 09:45:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.87 $ */ +/* NetHack 3.6 timeout.c $NHDT-Date: 1544050558 2018/12/05 22:55:58 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.88 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -311,6 +311,13 @@ slime_dialogue() { register long i = (Slimed & TIMEOUT) / 2L; + if (i == 1L) { + /* display as green slime during "You have become green slime." + but don't worry about not being able to see self; if already + mimicking something else at the time, implicitly be revealed */ + youmonst.m_ap_type = M_AP_MONSTER; + youmonst.mappearance = PM_GREEN_SLIME; + } if (((Slimed & TIMEOUT) % 2L) && i >= 0L && i < SIZE(slime_texts)) { char buf[BUFSZ]; @@ -363,6 +370,8 @@ STATIC_OVL void slimed_to_death(kptr) struct kinfo *kptr; { + uchar save_mvflags; + /* redundant: polymon() cures sliming when polying into green slime */ if (Upolyd && youmonst.data == &mons[PM_GREEN_SLIME]) { dealloc_killer(kptr); @@ -377,8 +386,25 @@ struct kinfo *kptr; Strcpy(killer.name, "turned into green slime"); } dealloc_killer(kptr); - /* involuntarily break "never changed form" conduct */ - u.uconduct.polyselfs++; + + /* + * Polymorph into a green slime, which might destroy some worn armor + * (potentially affecting bones) and dismount from steed. + * Can't be Unchanging; wouldn't have turned into slime if we were. + * Despite lack of Unchanging, neither done() nor savelife() calls + * rehumanize() if hero dies while polymorphed. + * polymon() undoes the slime countdown's mimick-green-slime hack + * but does not perform polyself()'s light source bookkeeping. + * No longer need to manually increment uconduct.polyselfs to reflect + * [formerly implicit] change of form; polymon() takes care of that. + * Temporarily ungenocide if necessary. + */ + if (emits_light(youmonst.data)) + del_light_source(LS_MONSTER, monst_to_any(&youmonst)); + save_mvflags = mvitals[PM_GREEN_SLIME].mvflags; + mvitals[PM_GREEN_SLIME].mvflags = save_mvflags & ~G_GENOD; + (void) polymon(PM_GREEN_SLIME); + mvitals[PM_GREEN_SLIME].mvflags = save_mvflags; done(TURNED_SLIME); /* life-saved; even so, hero still has turned into green slime; @@ -391,20 +417,6 @@ struct kinfo *kptr; done(GENOCIDED); /* could be life-saved again (only in explore or wizard mode) but green slimes are gone; just stay in current form */ - - /* not geno'd; survive as a green slime */ - } else { - /* this part of polyself() isn't in polymon(); - we assume that green slimes don't emit light */ - if (emits_light(youmonst.data)) - del_light_source(LS_MONSTER, monst_to_any(&youmonst)); - /* undo the 'involuntarily break "never changed form"' - increment so that this change isn't counted twice */ - u.uconduct.polyselfs--; - /* can't be Unchanging even if life-saving wasn't due to amulet; - hero infected with slime wouldn't have turned into green slime - to get here if Unchanging */ - (void) polymon(PM_GREEN_SLIME); } return; } From 1baa20dfc5fbbfc2c16e11d947794129639a4a1f Mon Sep 17 00:00:00 2001 From: nhmall Date: Wed, 5 Dec 2018 23:43:59 -0500 Subject: [PATCH 17/26] header update on cursstat.c --- win/curses/cursstat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/curses/cursstat.c b/win/curses/cursstat.c index 4c901736f..a4f708163 100644 --- a/win/curses/cursstat.c +++ b/win/curses/cursstat.c @@ -1,6 +1,6 @@ /* vim:set cin ft=c sw=4 sts=4 ts=8 et ai cino=Ls\:0t0(0 : -*- mode:c;fill-column:80;tab-width:8;c-basic-offset:4;indent-tabs-mode:nil;c-file-style:"k&r" -*-*/ /* NetHack 3.6 cursstat.c */ -/* Copyright (c) Karl Garrison, 2010. */ +/* Copyright (c) Andy Thomson, 2018. */ /* NetHack may be freely redistributed. See license for details. */ #include /* toupper() */ From e9624f25837e1d6c4ee6b0e0b873b0b3db14b71b Mon Sep 17 00:00:00 2001 From: PatR Date: Thu, 6 Dec 2018 17:27:36 -0800 Subject: [PATCH 18/26] fix #H7686 - destroy_item()'s inventory traversal Inventory traversal can be disrupted when items being traversed are able to change inventory. I've lost track of how many times this sort of thing has been discovered. Report claimed that boiled potion of polymorph caused transformation which resulted in dropped weapon and dropped or destroyed worn armor. That was evidently a guess; potionbreathe() for that potion only abuses constitution. The traceback showed 'you_were()' was involved. Boiled potion of unholy water triggers human-to-beast transformation of hero inflicted with lycanthropy, yielding similar situation. I didn't notice anything unusual when reproducing this but inventory was definitely vulnerable. My 'one line' fixes entries are steadily getting to be more verbose; I may have to go back to 'fix bug'. :-} --- doc/fixes36.2 | 8 ++++++++ src/zap.c | 39 ++++++++++++++++++++++++++++++--------- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index f87856d44..7f0673f39 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -243,6 +243,14 @@ level change after being interruped locking or unlocking a container might if a restore attempt failed and a new game was started instead, it would use stale context from old game if restoration got far enough to load that if hero survives turning into slime (life-saving), survive as a green slime +hero hit by something that causes inventory items to be destroyed with loss of + any of those causing other inventory items to be dropped or destroyed, + inventory traversal became unreliable (known sequence: potions hit by + fire then breahing vapor from boiled unholy water triggering were + transformation to beast form; possible sequence: ring of levitation + blasted by lightning and dropping hero onto fire trap); [3.6.1 fixed a + similar problem with more obvious symptom, an "object lost" panic when + the unholy water was wielded; the fix for that wasn't general enough] Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/zap.c b/src/zap.c index 5a5a67c34..8f7adf338 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* 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 $ */ +/* NetHack 3.6 zap.c $NHDT-Date: 1544146046 2018/12/07 01:27:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.300 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4719,15 +4719,32 @@ void destroy_item(osym, dmgtyp) register int osym, dmgtyp; { - register struct obj *obj, *obj2; + register struct obj *obj; int dmg, xresist, skip; long i, cnt, quan; int dindx; const char *mult; boolean physical_damage; - for (obj = invent; obj; obj = obj2) { - obj2 = obj->nobj; + /* + * Sometimes destroying an item can change inventory aside from the + * item itself (cited case was a potion of polymorph; when destroyed, + * potion_breathe() caused hero to transform and that resulted in + * destruction of some worn armor). Unlike other uses of the object + * bybass mechanism, destroy_item() can be called multiple times for + * same event. So we have to explicitly clear it before each use and + * hope no other section of code expects it to retain previous value. + * + * FIXME? Destruction of a ring of levitation could drop hero onto + * a fire trap which could destroy other items and we'll get called + * recursively. This should still work, but items beyond the ring + * which survive the fire will be marked as already processed by the + * inner call, so will always survive the remainder of the outer call + * instead of being subjected to original chance of destruction. + */ + bypass_objlist(invent, FALSE); /* clear bypass bit for invent */ + + while ((obj = nxt_unbypassed_obj(invent)) != 0) { physical_damage = FALSE; if (obj->oclass != osym) continue; /* test only objs of type osym */ @@ -4820,6 +4837,7 @@ register int osym, dmgtyp; skip++; break; } + if (!skip) { if (obj->in_use) --quan; /* one will be used up elsewhere */ @@ -4852,9 +4870,9 @@ register int osym, dmgtyp; for (i = 0; i < cnt; i++) useup(obj); if (dmg) { - if (xresist) + if (xresist) { You("aren't hurt!"); - else { + } else { const char *how = destroy_strings[dindx][2]; boolean one = (cnt == 1L); @@ -4877,7 +4895,7 @@ destroy_mitem(mtmp, osym, dmgtyp) struct monst *mtmp; int osym, dmgtyp; { - struct obj *obj, *obj2; + struct obj *obj; int skip, tmp = 0; long i, cnt, quan; int dindx; @@ -4889,8 +4907,11 @@ int osym, dmgtyp; } vis = canseemon(mtmp); - for (obj = mtmp->minvent; obj; obj = obj2) { - obj2 = obj->nobj; + + /* see destroy_item(); object destruction could disrupt inventory list */ + bypass_objlist(mtmp->minvent, FALSE); /* clear bypass bit for invent */ + + while ((obj = nxt_unbypassed_obj(mtmp->minvent)) != 0) { if (obj->oclass != osym) continue; /* test only objs of type osym */ skip = 0; From 150d01a9651e0f0c0f26aa8ecf40c553ce0d5ebe Mon Sep 17 00:00:00 2001 From: nhmall Date: Thu, 6 Dec 2018 22:30:15 -0500 Subject: [PATCH 19/26] add MM_ASLEEP makemon() flag and honor it for fill_zoo --- doc/fixes36.2 | 1 + include/hack.h | 13 +++++++------ src/makemon.c | 23 +++++++++++++---------- src/mkroom.c | 2 +- 4 files changed, 22 insertions(+), 17 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 7f0673f39..421792d38 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -251,6 +251,7 @@ hero hit by something that causes inventory items to be destroyed with loss of blasted by lightning and dropping hero onto fire trap); [3.6.1 fixed a similar problem with more obvious symptom, an "object lost" panic when the unholy water was wielded; the fix for that wasn't general enough] +add MM_ASLEEP makemon() flag and honor it when creating group for fill_zoo Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/include/hack.h b/include/hack.h index 5785b8590..beab7da8a 100644 --- a/include/hack.h +++ b/include/hack.h @@ -253,13 +253,14 @@ typedef struct sortloot_item Loot; #define MM_IGNOREWATER 0x00008 /* ignore water when positioning */ #define MM_ADJACENTOK \ 0x00010 /* it is acceptable to use adjacent coordinates */ -#define MM_ANGRY 0x00020 /* monster is created angry */ +#define MM_ANGRY 0x00020 /* monster is created angry */ #define MM_NONAME 0x00040 /* monster is not christened */ -#define MM_EGD 0x00100 /* add egd structure */ -#define MM_EPRI 0x00200 /* add epri structure */ -#define MM_ESHK 0x00400 /* add eshk structure */ -#define MM_EMIN 0x00800 /* add emin structure */ -#define MM_EDOG 0x01000 /* add edog structure */ +#define MM_EGD 0x00100 /* add egd structure */ +#define MM_EPRI 0x00200 /* add epri structure */ +#define MM_ESHK 0x00400 /* add eshk structure */ +#define MM_EMIN 0x00800 /* add emin structure */ +#define MM_EDOG 0x01000 /* add edog structure */ +#define MM_ASLEEP 0x02000 /* monsters should be generated asleep */ /* flags for make_corpse() and mkcorpstat() */ #define CORPSTAT_NONE 0x00 diff --git a/src/makemon.c b/src/makemon.c index 33cc7709c..e4d799e9b 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -18,15 +18,15 @@ STATIC_DCL boolean FDECL(uncommon, (int)); STATIC_DCL int FDECL(align_shift, (struct permonst *)); STATIC_DCL boolean FDECL(mk_gen_ok, (int, int, int)); STATIC_DCL boolean FDECL(wrong_elem_type, (struct permonst *)); -STATIC_DCL void FDECL(m_initgrp, (struct monst *, int, int, int)); +STATIC_DCL void FDECL(m_initgrp, (struct monst *, int, int, int, int)); STATIC_DCL void FDECL(m_initthrow, (struct monst *, int, int)); STATIC_DCL void FDECL(m_initweap, (struct monst *)); STATIC_DCL void FDECL(m_initinv, (struct monst *)); STATIC_DCL boolean FDECL(makemon_rnd_goodpos, (struct monst *, unsigned, coord *)); -#define m_initsgrp(mtmp, x, y) m_initgrp(mtmp, x, y, 3) -#define m_initlgrp(mtmp, x, y) m_initgrp(mtmp, x, y, 10) +#define m_initsgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 3, mmf) +#define m_initlgrp(mtmp, x, y, mmf) m_initgrp(mtmp, x, y, 10, mmf) #define toostrong(monindx, lev) (mons[monindx].difficulty > lev) #define tooweak(monindx, lev) (mons[monindx].difficulty < lev) @@ -76,9 +76,9 @@ struct permonst *ptr; /* make a group just like mtmp */ STATIC_OVL void -m_initgrp(mtmp, x, y, n) -register struct monst *mtmp; -register int x, y, n; +m_initgrp(mtmp, x, y, n, mmflags) +struct monst *mtmp; +int x, y, n, mmflags; { coord mm; register int cnt = rnd(n); @@ -131,6 +131,8 @@ register int x, y, n; if (enexto(&mm, mm.x, mm.y, mtmp->data)) { mon = makemon(mtmp->data, mm.x, mm.y, NO_MM_FLAGS); if (mon) { + if (mmflags & MM_ASLEEP) + mon->msleeping = 1; mon->mpeaceful = FALSE; mon->mavenge = 0; set_malign(mon); @@ -1193,7 +1195,8 @@ int mmflags; newemin(mtmp); if (mmflags & MM_EDOG) newedog(mtmp); - + if (mmflags & MM_ASLEEP) + mtmp->msleeping = 1; mtmp->nmon = fmon; fmon = mtmp; mtmp->m_id = context.ident++; @@ -1366,12 +1369,12 @@ int mmflags; set_malign(mtmp); /* having finished peaceful changes */ if (anymon) { if ((ptr->geno & G_SGROUP) && rn2(2)) { - m_initsgrp(mtmp, mtmp->mx, mtmp->my); + m_initsgrp(mtmp, mtmp->mx, mtmp->my, mmflags); } else if (ptr->geno & G_LGROUP) { if (rn2(3)) - m_initlgrp(mtmp, mtmp->mx, mtmp->my); + m_initlgrp(mtmp, mtmp->mx, mtmp->my, mmflags); else - m_initsgrp(mtmp, mtmp->mx, mtmp->my); + m_initsgrp(mtmp, mtmp->mx, mtmp->my, mmflags); } } diff --git a/src/mkroom.c b/src/mkroom.c index 15cffdc7f..d0995c7f1 100644 --- a/src/mkroom.c +++ b/src/mkroom.c @@ -341,7 +341,7 @@ struct mkroom *sroom; : (type == ANTHOLE) ? antholemon() : (struct permonst *) 0, - sx, sy, NO_MM_FLAGS); + sx, sy, MM_ASLEEP); if (mon) { mon->msleeping = 1; if (type == COURT && mon->mpeaceful) { From 9e170baecc766553a89ff413f95161a572881892 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 7 Dec 2018 00:36:38 -0800 Subject: [PATCH 20/26] fix #H7655 - highlighting gold With options along the line of OPTIONS=statushilites:4 HILITE_STATUS=gold/always/yellow gold started out unhighlighted (unhighlit?). I didn't try to figure out why, just changed things to force a full status update when gold requires internal changes (different \G encoding or different glyph) which is something that happens when session first enters moveloop(). --- doc/fixes36.2 | 1 + src/botl.c | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 421792d38..68d6c3229 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -252,6 +252,7 @@ hero hit by something that causes inventory items to be destroyed with loss of similar problem with more obvious symptom, an "object lost" panic when the unholy water was wielded; the fix for that wasn't general enough] add MM_ASLEEP makemon() flag and honor it when creating group for fill_zoo +at start of session (new game or restore), HILITE_STATUS for gold was ignored Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/botl.c b/src/botl.c index 4af749105..e0008d2b5 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1527042178 2018/05/23 02:22:58 $ $NHDT-Branch: NetHack-3.6.2 $:$NHDT-Revision: 1.101 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1544171789 2018/12/07 08:36:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.128 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -732,15 +732,14 @@ boolean *valsetlist; * NNNN = the glyph portion * 25 = the gold amount * + * Setting 'chg = 2' is enough to render the field properly, but + * not to honor an initial highlight, so force 'update_all = 1'. */ - if (fld == BL_GOLD) { - if (context.rndencode != oldrndencode) { - chg = 2; + if (context.rndencode != oldrndencode + || showsyms[COIN_CLASS + SYM_OFF_O] != oldgoldsym) { + update_all = 1; /* chg = 2; */ oldrndencode = context.rndencode; - } - if (oldgoldsym != showsyms[COIN_CLASS + SYM_OFF_O]) { - chg = 2; oldgoldsym = showsyms[COIN_CLASS + SYM_OFF_O]; } } From f3c4a52e36ffb4736aac198964fabf575a00d921 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 7 Dec 2018 01:20:20 -0800 Subject: [PATCH 21/26] menucolors In the 'special options' section at the end of 'O's menu, change the spelling for the menucolors entry to "menu colors" so that it isn't spelled exactly the same as the 'menucolors' boolean option. Only affects what the player sees when reading that menu. If player uses 'O' to add any menu colors and 'menucolors' boolean is Off at the time, give a reminder to toggle it to On in order to have those menu colorings become active. (Adding hilite_status entries has a similar reminder for 'statushilites' if done while that is 0.) --- doc/fixes36.2 | 2 ++ src/options.c | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 68d6c3229..aaff66ca0 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -253,6 +253,8 @@ hero hit by something that causes inventory items to be destroyed with loss of the unholy water was wielded; the fix for that wasn't general enough] add MM_ASLEEP makemon() flag and honor it when creating group for fill_zoo at start of session (new game or restore), HILITE_STATUS for gold was ignored +if player creates any menu colors via 'O' while menucolors is off, issue a + reminder that it needs to be on in order for those to become effective Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/options.c b/src/options.c index 7dc622687..b3595a6ad 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 options.c $NHDT-Date: 1543972192 2018/12/05 01:09:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.335 $ */ +/* NetHack 3.6 options.c $NHDT-Date: 1544174413 2018/12/07 09:20:13 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.339 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4283,7 +4283,7 @@ static struct other_opts { int NDECL((*othr_count_func)); } othropt[] = { { "autopickup exceptions", SET_IN_GAME, OPT_OTHER_APEXC, count_apes }, - { "menucolors", SET_IN_GAME, OPT_OTHER_MENUCOLOR, count_menucolors }, + { "menu colors", SET_IN_GAME, OPT_OTHER_MENUCOLOR, count_menucolors }, { "message types", SET_IN_GAME, OPT_OTHER_MSGTYPE, msgtype_count }, #ifdef STATUS_HILITES { "status hilite rules", SET_IN_GAME, OPT_OTHER_STATHILITE, @@ -4457,7 +4457,7 @@ doset() /* changing options via menu by Per Liboriussen */ } #endif } else if (opt_indx == OPT_OTHER_MENUCOLOR) { - (void) special_handling("menucolors", setinitial, + (void) special_handling("menu_colors", setinitial, fromfile); } else if (opt_indx == OPT_OTHER_MSGTYPE) { (void) special_handling("msgtype", setinitial, fromfile); @@ -5036,7 +5036,7 @@ boolean setinitial, setfromfile; if (pick_cnt >= 0) goto msgtypes_again; } - } else if (!strcmp("menucolors", optname)) { + } else if (!strcmp("menu_colors", optname)) { int opt_idx, nmc, mcclr, mcattr; char mcbuf[BUFSZ] = DUMMY; @@ -5044,11 +5044,15 @@ boolean setinitial, setfromfile; nmc = count_menucolors(); opt_idx = handle_add_list_remove("menucolor", nmc); if (opt_idx == 3) { /* done */ + menucolors_done: + if (nmc > 0 && !iflags.use_menu_color) + pline( + "To have menu colors become active, toggle 'menucolors' option to True."); return TRUE; } else if (opt_idx == 0) { /* add new */ getlin("What new menucolor pattern?", mcbuf); if (*mcbuf == '\033') - return TRUE; + goto menucolors_done; if (*mcbuf && test_regex_pattern(mcbuf, (const char *)0) && (mcclr = query_color((char *) 0)) != -1 From a1c1acdd2423300a7771a2ab3001ffb51c0ce861 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 7 Dec 2018 09:29:01 -0500 Subject: [PATCH 22/26] add MM_NOGRP makemon() flag add MM_NOGRP makemon() flag as a means of suppressing groups of monsters in a couple places that warrant it when a specific monster type isn't specified on the call to makemon() --- doc/fixes36.2 | 3 +++ include/hack.h | 1 + src/makemon.c | 6 ++---- src/mklev.c | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 421792d38..538c632ca 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -252,6 +252,9 @@ hero hit by something that causes inventory items to be destroyed with loss of similar problem with more obvious symptom, an "object lost" panic when the unholy water was wielded; the fix for that wasn't general enough] add MM_ASLEEP makemon() flag and honor it when creating group for fill_zoo +add MM_NOGRP makemon() flag as a means of suppressing groups of monsters in + a couple places that warrant it when a specific monster type isn't + specified on the call to makemon() Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/include/hack.h b/include/hack.h index beab7da8a..e59693d5f 100644 --- a/include/hack.h +++ b/include/hack.h @@ -261,6 +261,7 @@ typedef struct sortloot_item Loot; #define MM_EMIN 0x00800 /* add emin structure */ #define MM_EDOG 0x01000 /* add edog structure */ #define MM_ASLEEP 0x02000 /* monsters should be generated asleep */ +#define MM_NOGRP 0x04000 /* suppress creation of monster groups */ /* flags for make_corpse() and mkcorpstat() */ #define CORPSTAT_NONE 0x00 diff --git a/src/makemon.c b/src/makemon.c index e4d799e9b..20912b8da 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -129,10 +129,8 @@ int x, y, n, mmflags; * smaller group. */ if (enexto(&mm, mm.x, mm.y, mtmp->data)) { - mon = makemon(mtmp->data, mm.x, mm.y, NO_MM_FLAGS); + mon = makemon(mtmp->data, mm.x, mm.y, (mmflags | MM_NOGRP)); if (mon) { - if (mmflags & MM_ASLEEP) - mon->msleeping = 1; mon->mpeaceful = FALSE; mon->mavenge = 0; set_malign(mon); @@ -1367,7 +1365,7 @@ int mmflags; : eminp->renegade; } set_malign(mtmp); /* having finished peaceful changes */ - if (anymon) { + if (anymon && !(mmflags & MM_NOGRP)) { if ((ptr->geno & G_SGROUP) && rn2(2)) { m_initsgrp(mtmp, mtmp->mx, mtmp->my, mmflags); } else if (ptr->geno & G_LGROUP) { diff --git a/src/mklev.c b/src/mklev.c index 11067b931..35b0d9378 100644 --- a/src/mklev.c +++ b/src/mklev.c @@ -803,7 +803,7 @@ skip0: if (u.uhave.amulet || !rn2(3)) { x = somex(croom); y = somey(croom); - tmonst = makemon((struct permonst *) 0, x, y, NO_MM_FLAGS); + tmonst = makemon((struct permonst *) 0, x, y, (MM_NOGRP | MM_ASLEEP)); if (tmonst && tmonst->data == &mons[PM_GIANT_SPIDER] && !occupied(x, y)) (void) maketrap(x, y, WEB); From 8319227b557c98db99776f2a3ea1fe3022643497 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Fri, 7 Dec 2018 22:18:50 +0200 Subject: [PATCH 23/26] Clear the getlin buffer Recent change to this bit of code didn't clear the buffer, which causes garbage in the string if compiled with EDIT_GETLIN --- win/tty/wintty.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 47bac195b..b5c4451df 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -2046,7 +2046,7 @@ struct WinDesc *cw; tty_nhbell(); break; } else { - char searchbuf[BUFSZ + 2], tmpbuf[BUFSZ]; + char searchbuf[BUFSZ + 2], tmpbuf[BUFSZ] = DUMMY; boolean on_curr_page = FALSE; int lineno = 0; From 6ff9753029ab187ca238169d68beb9313efea031 Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 7 Dec 2018 19:12:56 -0500 Subject: [PATCH 24/26] back out some spider changes After consultation with the original committer, this is being pulled out, possibly revisited later. There was originally meant to be a follow-up piece to this that he never had a chance to integrate for various reasons. --- doc/fixes36.2 | 1 - src/monmove.c | 40 ---------------------------------------- 2 files changed, 41 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 11aa182ff..b4403f0fe 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -384,7 +384,6 @@ make it clear when a leprechaun dodges your attack wizard mode #wizidentify can now select individual items for permanent identification and don't display the selection to permanently identify everything if everything is already fully identified -spiders will occasionally spin webs when moving around make mine town "orctown" variation a multiple level feature of the mines replace #monpolycontrol command with monpolycontrol boolean option replace #wizdebug_traveldisplay command with travel_debug boolean option diff --git a/src/monmove.c b/src/monmove.c index 5694a31b8..c501cf421 100644 --- a/src/monmove.c +++ b/src/monmove.c @@ -14,7 +14,6 @@ STATIC_DCL int FDECL(disturb, (struct monst *)); STATIC_DCL void FDECL(release_hero, (struct monst *)); STATIC_DCL void FDECL(distfleeck, (struct monst *, int *, int *, int *)); STATIC_DCL int FDECL(m_arrival, (struct monst *)); -STATIC_DCL int FDECL(count_webbing_walls, (XCHAR_P, XCHAR_P)); STATIC_DCL boolean FDECL(stuff_prevents_passage, (struct monst *)); STATIC_DCL int FDECL(vamp_shift, (struct monst *, struct permonst *, BOOLEAN_P)); @@ -759,24 +758,6 @@ xchar nix,niy; return FALSE; } -/* returns the number of walls in the four cardinal directions that could - hold up a web */ -STATIC_OVL int -count_webbing_walls(x, y) -xchar x, y; -{ -#define holds_up_web(X, Y) ((!isok((X), (Y)) \ - || IS_ROCK(levl[X][Y].typ) \ - || (levl[X][Y].typ == STAIRS \ - && (X) == xupstair && (Y) == yupstair) \ - || (levl[X][Y].typ == LADDER \ - && (X) == xupladder && (Y) == yupladder) \ - || levl[X][Y].typ == IRONBARS) ? 1 : 0) - return (holds_up_web(x, y - 1) + holds_up_web(x + 1, y) - + holds_up_web(x, y + 1) + holds_up_web(x - 1, y)); -#undef holds_up_web -} - /* Return values: * 0: did not move, but can still attack and do other stuff. * 1: moved, possibly can attack. @@ -1472,27 +1453,6 @@ postmov: } } - /* maybe spin a web -- this needs work; if the spider is far away, - it might spin a lot of webs before hero encounters it */ - if (webmaker(ptr) && !mtmp->mspec_used && !t_at(mtmp->mx, mtmp->my)) { - struct trap *trap; - int prob = ((ptr == &mons[PM_GIANT_SPIDER]) ? 15 : 5) - * (count_webbing_walls(mtmp->mx, mtmp->my) + 1); - - if (rn2(1000) < prob - && (trap = maketrap(mtmp->mx, mtmp->my, WEB)) != 0) { - mtmp->mspec_used = d(4, 4); /* 4..16 */ - if (cansee(mtmp->mx, mtmp->my)) { - char mbuf[BUFSZ]; - - Strcpy(mbuf, - canspotmon(mtmp) ? y_monnam(mtmp) : something); - pline("%s spins a web.", upstart(mbuf)); - trap->tseen = 1; - } - } - } - if (hides_under(ptr) || ptr->mlet == S_EEL) { /* Always set--or reset--mundetected if it's already hidden (just in case the object it was hiding under went away); From e8a5ff6dffd2b98bdc29bab208f6630389c1ece6 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 7 Dec 2018 16:37:24 -0800 Subject: [PATCH 25/26] gold highlight bit Keep type/value straight: 'update_all' is boolean, not ordinary int. --- src/botl.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/botl.c b/src/botl.c index e0008d2b5..2fa84afe0 100644 --- a/src/botl.c +++ b/src/botl.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 botl.c $NHDT-Date: 1544171789 2018/12/07 08:36:29 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.128 $ */ +/* NetHack 3.6 botl.c $NHDT-Date: 1544229439 2018/12/08 00:37:19 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.129 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2006. */ /* NetHack may be freely redistributed. See license for details. */ @@ -733,15 +733,14 @@ boolean *valsetlist; * 25 = the gold amount * * Setting 'chg = 2' is enough to render the field properly, but - * not to honor an initial highlight, so force 'update_all = 1'. + * not to honor an initial highlight, so force 'update_all = TRUE'. */ - if (fld == BL_GOLD) { - if (context.rndencode != oldrndencode - || showsyms[COIN_CLASS + SYM_OFF_O] != oldgoldsym) { - update_all = 1; /* chg = 2; */ - oldrndencode = context.rndencode; - oldgoldsym = showsyms[COIN_CLASS + SYM_OFF_O]; - } + if (fld == BL_GOLD + && (context.rndencode != oldrndencode + || showsyms[COIN_CLASS + SYM_OFF_O] != oldgoldsym)) { + update_all = TRUE; /* chg = 2; */ + oldrndencode = context.rndencode; + oldgoldsym = showsyms[COIN_CLASS + SYM_OFF_O]; } reset = FALSE; From 22555438004cc173da19a32eafdb61c28335dd12 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 7 Dec 2018 16:51:18 -0800 Subject: [PATCH 26/26] recursive destroy_item() Make the sequence: be zapped by lightning, have worn ring of levitation be destroyed, fall onto fire trap work better. The fire trap handling will mark everything in inventory as already processed; anything vulnerable to lightning past the destroyed ring would not be checked. So delay destroying such a ring until after all of inventory has been subjected to lightning. --- src/zap.c | 369 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 215 insertions(+), 154 deletions(-) diff --git a/src/zap.c b/src/zap.c index 8f7adf338..1e6e3b1b3 100644 --- a/src/zap.c +++ b/src/zap.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 zap.c $NHDT-Date: 1544146046 2018/12/07 01:27:26 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.300 $ */ +/* NetHack 3.6 zap.c $NHDT-Date: 1544230271 2018/12/08 00:51:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.301 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -28,11 +28,12 @@ STATIC_DCL void FDECL(zhitu, (int, int, const char *, XCHAR_P, XCHAR_P)); STATIC_DCL void FDECL(revive_egg, (struct obj *)); STATIC_DCL boolean FDECL(zap_steed, (struct obj *)); STATIC_DCL void FDECL(skiprange, (int, int *, int *)); - STATIC_DCL int FDECL(zap_hit, (int, int)); STATIC_OVL void FDECL(disintegrate_mon, (struct monst *, int, const char *)); STATIC_DCL void FDECL(backfire, (struct obj *)); STATIC_DCL int FDECL(spell_hit_bonus, (int)); +STATIC_DCL void FDECL(destroy_one_item, (struct obj *, int, int)); +STATIC_DCL void FDECL(wishcmdassist, (int)); #define ZT_MAGIC_MISSILE (AD_MAGM - 1) #define ZT_FIRE (AD_FIRE - 1) @@ -1846,6 +1847,10 @@ struct obj *obj, *otmp; * menu_drop(), askchain() - inventory traversal where multiple * Drop can alter the invent chain while traversal * is in progress (bhito isn't involved). + * destroy_item(), destroy_mitem() - inventory traversal where + * item destruction can trigger drop or destruction of + * other item(s) and alter the invent or mon->minvent + * chain, possibly recursively. * * The bypass bit on all objects is reset each turn, whenever * context.bypasses is set. @@ -4715,178 +4720,234 @@ const char *const destroy_strings[][3] = { { "breaks apart and explodes", "", "exploding wand" }, }; -void -destroy_item(osym, dmgtyp) -register int osym, dmgtyp; +/* guts of destroy_item(), which ought to be called maybe_destroy_items(); + caller must decide whether obj is eligible */ +STATIC_OVL void +destroy_one_item(obj, osym, dmgtyp) +struct obj *obj; +int osym, dmgtyp; { - register struct obj *obj; - int dmg, xresist, skip; long i, cnt, quan; - int dindx; + int dmg, xresist, skip, dindx; const char *mult; boolean physical_damage; - /* - * Sometimes destroying an item can change inventory aside from the - * item itself (cited case was a potion of polymorph; when destroyed, - * potion_breathe() caused hero to transform and that resulted in - * destruction of some worn armor). Unlike other uses of the object - * bybass mechanism, destroy_item() can be called multiple times for - * same event. So we have to explicitly clear it before each use and - * hope no other section of code expects it to retain previous value. - * - * FIXME? Destruction of a ring of levitation could drop hero onto - * a fire trap which could destroy other items and we'll get called - * recursively. This should still work, but items beyond the ring - * which survive the fire will be marked as already processed by the - * inner call, so will always survive the remainder of the outer call - * instead of being subjected to original chance of destruction. - */ - bypass_objlist(invent, FALSE); /* clear bypass bit for invent */ + physical_damage = FALSE; + xresist = skip = 0; + /* lint suppression */ + dmg = dindx = 0; + quan = 0L; - while ((obj = nxt_unbypassed_obj(invent)) != 0) { - physical_damage = FALSE; - if (obj->oclass != osym) - continue; /* test only objs of type osym */ - if (obj->oartifact) - continue; /* don't destroy artifacts */ - if (obj->in_use && obj->quan == 1L) - continue; /* not available */ - xresist = skip = 0; - /* lint suppression */ - dmg = dindx = 0; - quan = 0L; - - switch (dmgtyp) { - case AD_COLD: - if (osym == POTION_CLASS && obj->otyp != POT_OIL) { - quan = obj->quan; - dindx = 0; - dmg = rnd(4); - } else - skip++; - break; - case AD_FIRE: - xresist = (Fire_resistance && obj->oclass != POTION_CLASS - && obj->otyp != GLOB_OF_GREEN_SLIME); - - if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL) - skip++; - if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { - skip++; - if (!Blind) - pline("%s glows a strange %s, but remains intact.", - The(xname(obj)), hcolor("dark red")); - } + switch (dmgtyp) { + case AD_COLD: + if (osym == POTION_CLASS && obj->otyp != POT_OIL) { quan = obj->quan; - switch (osym) { - case POTION_CLASS: - dindx = (obj->otyp != POT_OIL) ? 1 : 2; - dmg = rnd(6); - break; - case SCROLL_CLASS: - dindx = 3; - dmg = 1; - break; - case SPBOOK_CLASS: - dindx = 4; - dmg = 1; - break; - case FOOD_CLASS: - if (obj->otyp == GLOB_OF_GREEN_SLIME) { - dindx = 1; /* boil and explode */ - dmg = (obj->owt + 19) / 20; - } else { - skip++; - } - break; - default: - skip++; - break; - } + dindx = 0; + dmg = rnd(4); + } else + skip++; + break; + case AD_FIRE: + xresist = (Fire_resistance && obj->oclass != POTION_CLASS + && obj->otyp != GLOB_OF_GREEN_SLIME); + if (obj->otyp == SCR_FIRE || obj->otyp == SPE_FIREBALL) + skip++; + if (obj->otyp == SPE_BOOK_OF_THE_DEAD) { + skip++; + if (!Blind) + pline("%s glows a strange %s, but remains intact.", + The(xname(obj)), hcolor("dark red")); + } + quan = obj->quan; + switch (osym) { + case POTION_CLASS: + dindx = (obj->otyp != POT_OIL) ? 1 : 2; + dmg = rnd(6); break; - case AD_ELEC: - xresist = (Shock_resistance && obj->oclass != RING_CLASS); - quan = obj->quan; - switch (osym) { - case RING_CLASS: - if (obj->otyp == RIN_SHOCK_RESISTANCE) { - skip++; - break; - } - dindx = 5; - dmg = 0; - break; - case WAND_CLASS: - if (obj->otyp == WAN_LIGHTNING) { - skip++; - break; - } -#if 0 - if (obj == current_wand) { skip++; break; } -#endif - dindx = 6; - dmg = rnd(10); - break; - default: + case SCROLL_CLASS: + dindx = 3; + dmg = 1; + break; + case SPBOOK_CLASS: + dindx = 4; + dmg = 1; + break; + case FOOD_CLASS: + if (obj->otyp == GLOB_OF_GREEN_SLIME) { + dindx = 1; /* boil and explode */ + dmg = (obj->owt + 19) / 20; + } else { skip++; - break; } break; default: skip++; break; } - - if (!skip) { - if (obj->in_use) - --quan; /* one will be used up elsewhere */ - for (i = cnt = 0L; i < quan; i++) - if (!rn2(3)) - cnt++; - - if (!cnt) - continue; - mult = (cnt == 1L) - ? (quan == 1L) ? "Your" /* 1 of 1 */ - : "One of your" /* 1 of N */ - : (cnt < quan) ? "Some of your" /* n of N */ - : (quan == 2L) ? "Both of your" /* 2 of 2 */ - : "All of your"; /* N of N */ - pline("%s %s %s!", mult, xname(obj), - destroy_strings[dindx][(cnt > 1L)]); - if (osym == POTION_CLASS && dmgtyp != AD_COLD) { - if (!breathless(youmonst.data) || haseyes(youmonst.data)) - potionbreathe(obj); + break; + case AD_ELEC: + xresist = (Shock_resistance && obj->oclass != RING_CLASS); + quan = obj->quan; + switch (osym) { + case RING_CLASS: + if (obj->otyp == RIN_SHOCK_RESISTANCE) { + skip++; + break; } - if (obj->owornmask) { - if (obj->owornmask & W_RING) /* ring being worn */ - Ring_gone(obj); - else - setnotworn(obj); + dindx = 5; + dmg = 0; + break; + case WAND_CLASS: + if (obj->otyp == WAN_LIGHTNING) { + skip++; + break; } - if (obj == current_wand) - current_wand = 0; /* destroyed */ - for (i = 0; i < cnt; i++) - useup(obj); - if (dmg) { - if (xresist) { - You("aren't hurt!"); - } else { - const char *how = destroy_strings[dindx][2]; - boolean one = (cnt == 1L); +#if 0 + if (obj == current_wand) { skip++; break; } +#endif + dindx = 6; + dmg = rnd(10); + break; + default: + skip++; + break; + } + break; + default: + skip++; + break; + } - if (dmgtyp == AD_FIRE && osym == FOOD_CLASS) - how = "exploding glob of slime"; - if (physical_damage) - dmg = Maybe_Half_Phys(dmg); - losehp(dmg, one ? how : (const char *) makeplural(how), - one ? KILLED_BY_AN : KILLED_BY); - exercise(A_STR, FALSE); - } + if (!skip) { + if (obj->in_use) + --quan; /* one will be used up elsewhere */ + for (i = cnt = 0L; i < quan; i++) + if (!rn2(3)) + cnt++; + + if (!cnt) + return; + mult = (cnt == 1L) + ? ((quan == 1L) ? "Your" /* 1 of 1 */ + : "One of your") /* 1 of N */ + : ((cnt < quan) ? "Some of your" /* n of N */ + : (quan == 2L) ? "Both of your" /* 2 of 2 */ + : "All of your"); /* N of N */ + pline("%s %s %s!", mult, xname(obj), + destroy_strings[dindx][(cnt > 1L)]); + if (osym == POTION_CLASS && dmgtyp != AD_COLD) { + if (!breathless(youmonst.data) || haseyes(youmonst.data)) + potionbreathe(obj); + } + if (obj->owornmask) { + if (obj->owornmask & W_RING) /* ring being worn */ + Ring_gone(obj); + else + setnotworn(obj); + } + if (obj == current_wand) + current_wand = 0; /* destroyed */ + for (i = 0; i < cnt; i++) + useup(obj); + if (dmg) { + if (xresist) { + You("aren't hurt!"); + } else { + const char *how = destroy_strings[dindx][2]; + boolean one = (cnt == 1L); + + if (dmgtyp == AD_FIRE && osym == FOOD_CLASS) + how = "exploding glob of slime"; + if (physical_damage) + dmg = Maybe_Half_Phys(dmg); + losehp(dmg, one ? how : (const char *) makeplural(how), + one ? KILLED_BY_AN : KILLED_BY); + exercise(A_STR, FALSE); } } } +} + +/* target items of specified class for possible destruction */ +void +destroy_item(osym, dmgtyp) +int osym, dmgtyp; +{ + register struct obj *obj; + int i, deferral_indx = 0; + /* 1+52+1: try to handle a full inventory; it doesn't matter if + inventory actually has more, even if everything should be deferred */ + unsigned short deferrals[1 + 52 + 1]; /* +1: gold, overflow */ + + (void) memset((genericptr_t) deferrals, 0, sizeof deferrals); + /* + * Sometimes destroying an item can change inventory aside from + * the item itself (cited case was a potion of unholy water; when + * boiled, potionbreathe() caused hero to transform into were-beast + * form and that resulted in dropping or destroying some worn armor). + * + * Unlike other uses of the object bybass mechanism, destroy_item() + * can be called multiple times for the same event. So we have to + * explicitly clear it before each use and hope no other section of + * code expects it to retain previous value. + * + * Destruction of a ring of levitation or form change which pushes + * off levitation boots could drop hero onto a fire trap that + * could destroy other items and we'll get called recursively. Or + * onto a trap which transports hero elsewhere, which won't disrupt + * traversal but could yield message sequencing issues. So we + * defer handling such things until after rest of inventory has + * been processed. If some other combination of items and events + * triggers a recursive call, rest of inventory after the triggering + * item will be skipped by the outer call since the inner one will + * have set the bypass bits of the whole list. + * + * [Unfortunately, death while poly'd into flyer and subsequent + * rehumanization could also drop hero onto a trap, and there's no + * straightforward way to defer that. Things could be improved by + * redoing this to use two passes, first to collect a list or array + * of o_id and quantity of what is targetted for destruction, + * second pass to handle the destruction.] + */ + bypass_objlist(invent, FALSE); /* clear bypass bit for invent */ + + while ((obj = nxt_unbypassed_obj(invent)) != 0) { + if (obj->oclass != osym) + continue; /* test only objs of type osym */ + if (obj->oartifact) + continue; /* don't destroy artifacts */ + if (obj->in_use && obj->quan == 1L) + continue; /* not available */ + + /* if loss of this item might dump us onto a trap, hold off + until later because potential recursive destroy_item() will + result in setting bypass bits on whole chain--we would skip + the rest as already processed once control returns here */ + if (deferral_indx < SIZE(deferrals) + && ((obj->owornmask != 0L + && (objects[obj->otyp].oc_oprop == LEVITATION + || objects[obj->otyp].oc_oprop == FLYING)) + /* destroyed wands and potions of polymorph don't trigger + polymorph so don't need to be deferred */ + || (obj->otyp == POT_WATER && u.ulycn >= LOW_PM + && (Upolyd ? obj->blessed : obj->cursed)))) { + deferrals[deferral_indx++] = obj->o_id; + continue; + } + /* obj is eligible; maybe destroy it */ + destroy_one_item(obj, osym, dmgtyp); + } + /* if we saved some items for later (most likely just a worn ring + of levitation) and they're still in inventory, handle them now */ + for (i = 0; i < deferral_indx; ++i) { + /* note: obj->nobj is only referenced when obj is skipped; + having obj be dropped or destroyed won't affect traversal */ + for (obj = invent; obj; obj = obj->nobj) + if (obj->o_id == deferrals[i]) { + destroy_one_item(obj, osym, dmgtyp); + break; + } + } return; } @@ -4909,7 +4970,7 @@ int osym, dmgtyp; vis = canseemon(mtmp); /* see destroy_item(); object destruction could disrupt inventory list */ - bypass_objlist(mtmp->minvent, FALSE); /* clear bypass bit for invent */ + bypass_objlist(mtmp->minvent, FALSE); /* clear bypass bit for minvent */ while ((obj = nxt_unbypassed_obj(mtmp->minvent)) != 0) { if (obj->oclass != osym)