From bb08a46480569ee6d14058a1e3e29cb5936249f5 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 24 Nov 2018 15:01:30 -0800 Subject: [PATCH 1/7] fix #H7596 - magic trap 'deafening roar' outcome doesn't wake monsters. Now it does. --- doc/fixes36.2 | 1 + src/mon.c | 42 ++++++++++++++++++------------------------ src/trap.c | 7 +++++-- 3 files changed, 24 insertions(+), 26 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index c83806f8d..b9bfdfd95 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -220,6 +220,7 @@ end of game while carrying Schroedinger's Box would reveal cat-or-corpse for inventory disclosure or put that info into dumplog, but not both attempting to untrap an adjacent trap while on the edge of--not in--a pit failed due to not being able to reach the floor +magic trap's deafening roar effect wasn't waking nearby monsters Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/mon.c b/src/mon.c index 03cd1eb9c..126f64f7b 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1543052701 2018/11/24 09:45:01 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.270 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1543100460 2018/11/24 23:01:00 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.271 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2827,40 +2827,34 @@ boolean via_attack; void wake_nearby() { - register struct monst *mtmp; - - for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { - if (DEADMONSTER(mtmp)) - continue; - if (distu(mtmp->mx, mtmp->my) < u.ulevel * 20) { - mtmp->msleeping = 0; - if (!unique_corpstat(mtmp->data)) - mtmp->mstrategy &= ~STRAT_WAITMASK; - if (mtmp->mtame) { - if (!mtmp->isminion) - EDOG(mtmp)->whistletime = moves; - /* Clear mtrack. This is to fix up a pet who is - stuck "fleeing" its master. */ - memset(mtmp->mtrack, 0, sizeof(mtmp->mtrack)); - } - } - } + wake_nearto(u.ux, u.uy, u.ulevel * 20); } /* Wake up monsters near some particular location. */ void wake_nearto(x, y, distance) -register int x, y, distance; +int x, y, distance; { - register struct monst *mtmp; + struct monst *mtmp; for (mtmp = fmon; mtmp; mtmp = mtmp->nmon) { if (DEADMONSTER(mtmp)) continue; if (distance == 0 || dist2(mtmp->mx, mtmp->my, x, y) < distance) { - mtmp->msleeping = 0; - if (!unique_corpstat(mtmp->data)) - mtmp->mstrategy &= ~STRAT_WAITMASK; + /* sleep for N turns uses mtmp->mfrozen, but so does paralysis + so we leave mfrozen monsters alone */ + mtmp->msleeping = 0; /* wake indeterminate sleep */ + if (!(mtmp->data->geno & G_UNIQ)) + mtmp->mstrategy &= ~STRAT_WAITMASK; /* wake 'meditation' */ + if (context.mon_moving) + continue; + if (mtmp->mtame) { + if (!mtmp->isminion) + EDOG(mtmp)->whistletime = moves; + /* Clear mtrack. This is to fix up a pet who is + stuck "fleeing" its master. */ + memset(mtmp->mtrack, 0, sizeof mtmp->mtrack); + } } } } diff --git a/src/trap.c b/src/trap.c index 330fa73e2..d43117e43 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 trap.c $NHDT-Date: 1542856572 2018/11/22 03:16:12 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.304 $ */ +/* NetHack 3.6 trap.c $NHDT-Date: 1543100476 2018/11/24 23:01:16 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.311 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3164,7 +3164,7 @@ domagictrap() if (fate < 10) { /* Most of the time, it creates some monsters. */ - register int cnt = rnd(4); + int cnt = rnd(4); /* blindness effects */ if (!resists_blnd(&youmonst)) { @@ -3189,6 +3189,9 @@ domagictrap() } while (cnt--) (void) makemon((struct permonst *) 0, u.ux, u.uy, NO_MM_FLAGS); + /* roar: wake monsters in vicinity, after placing trap-created ones */ + wake_nearto(u.ux, u.uy, 7 * 7); + /* [flash: should probably also hit nearby gremlins with light] */ } else switch (fate) { case 10: From e5c488b15e73662217f33245d34142dc24a66d89 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 24 Nov 2018 15:22:33 -0800 Subject: [PATCH 2/7] fix github pull request #161 - scatter() Fixes #161 Report states that scattering objects might leave a 'pile' glyph when no longer appropriate. I didn't try to reproduce that, just took it on faith. The fix tried to be too efficient and might have missed fixing the display if breaks() or ohitmon() destroyed the objects being scattered and left 'total' at 0. --- doc/fixes36.2 | 1 + src/explode.c | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index b9bfdfd95..5e4d30edf 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -221,6 +221,7 @@ end of game while carrying Schroedinger's Box would reveal cat-or-corpse attempting to untrap an adjacent trap while on the edge of--not in--a pit failed due to not being able to reach the floor magic trap's deafening roar effect wasn't waking nearby monsters +scattering of objects might leave source location with wrong thing displayed Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/src/explode.c b/src/explode.c index fc2855c1d..46d3b327f 100644 --- a/src/explode.c +++ b/src/explode.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 explode.c $NHDT-Date: 1522454717 2018/03/31 00:05:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.56 $ */ +/* NetHack 3.6 explode.c $NHDT-Date: 1543101719 2018/11/24 23:21:59 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.59 $ */ /* Copyright (C) 1990 by Ken Arromdee */ /* NetHack may be freely redistributed. See license for details. */ @@ -616,6 +616,10 @@ struct obj *obj; /* only scatter this obj */ struct scatter_chain *schain = (struct scatter_chain *) 0; long total = 0L; + if (individual_object && (obj->ox != sx || obj->oy != sy)) + impossible("scattered object <%d,%d> not at scatter site <%d,%d>", + obj->ox, obj->oy, sx, sy); + while ((otmp = (individual_object ? obj : level.objects[sx][sy])) != 0) { if (otmp->quan > 1L) { qtmp = otmp->quan - 1L; @@ -759,7 +763,7 @@ struct obj *obj; /* only scatter this obj */ free((genericptr_t) stmp); newsym(x, y); } - + newsym(sx, sy); return total; } From 57a02d05bf274ba2899c40d586d1ee294fa1c77e Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 24 Nov 2018 21:41:22 -0500 Subject: [PATCH 3/7] build fix when STATUS_HILITES is not defined --- win/tty/wintty.c | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/win/tty/wintty.c b/win/tty/wintty.c index d5cac96c3..47bac195b 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -3612,26 +3612,10 @@ const char *fmt; boolean enable; { genl_status_enablefield(fieldidx, nm, fmt, enable); +#ifdef STATUS_HILITES /* force re-evaluation of last field on the row */ setlast = FALSE; -} - -void -do_setlast() -{ - int i, row, fld; - - setlast = TRUE; - for (row = 0; row < 2; ++row) - for (i = MAX_PER_ROW - 1; i > 0; --i) { - fld = fieldorder[row][i]; - - if (fld == BL_FLUSH || !status_activefields[fld]) - continue; - - last_on_row[row] = fld; - break; - } +#endif } #ifdef STATUS_HILITES @@ -3807,6 +3791,24 @@ unsigned long *colormasks; return; } +void +do_setlast() +{ + int i, row, fld; + + setlast = TRUE; + for (row = 0; row < 2; ++row) + for (i = MAX_PER_ROW - 1; i > 0; --i) { + fld = fieldorder[row][i]; + + if (fld == BL_FLUSH || !status_activefields[fld]) + continue; + + last_on_row[row] = fld; + break; + } +} + STATIC_OVL int make_things_fit(force_update) boolean force_update; From 03e6c26af6de62f6a970d5b0c9845f924bfc93f4 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sat, 24 Nov 2018 23:14:20 -0500 Subject: [PATCH 4/7] adjust sample config file when STATUS_HILITES isn't defined On Windows, if you build without STATUS_HILITES defined, you'll be greeted by the following barrage of errors when you start the game. On Windows, use makedefs to detect that STATUS_HILITES isn't defined, and comment out the offending lines in the sample config file. Errors received before this change: OPTIONS=statushilites * Line 197: 'statushilites' is not supported. OPTIONS=hilite_status:hitpoints/100%/gray&normal * Line 200: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<100%/green&normal * Line 201: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<66%/yellow&normal * Line 202: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<50%/orange&normal * Line 203: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<33%/red&bold * Line 204: 'hilite_status' is not supported. OPTIONS=hilite_status:hitpoints/<15%/red&inverse * Line 205: 'hilite_status' is not supported. OPTIONS=hilite_status:power/100%/gray&normal * Line 208: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<100%/green&normal * Line 209: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<66%/yellow&normal * Line 210: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<50%/orange&normal * Line 211: 'hilite_status' is not supported. OPTIONS=hilite_status:power/<33%/red&bold * Line 212: 'hilite_status' is not supported. OPTIONS=hilite_status:cap/burdened/yellow/stressed/orange/strained/red&bold/ove rtaxed/red&inverse/overloaded/red&inverse&blink * Line 215: 'hilite_status' is not supported. OPTIONS=hilite_status:hunger/satiated/yellow/hungry/orange/weak/red&bold/fainti ng/red&inverse/fainted/red&inverse&blink * Line 218: 'hilite_status' is not supported. Hit to continue. --- sys/winnt/Makefile.msc | 4 ++- util/makedefs.c | 58 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/sys/winnt/Makefile.msc b/sys/winnt/Makefile.msc index 926eed8ad..3f2c76fd5 100644 --- a/sys/winnt/Makefile.msc +++ b/sys/winnt/Makefile.msc @@ -686,7 +686,8 @@ $(O)install.tag: $(DAT)\data $(DAT)\rumors $(DAT)\dungeon \ if exist $(DOC)\nethack.txt copy $(DOC)\nethack.txt $(GAMEDIR)\NetHack.txt @if exist $(GAMEDIR)\NetHack.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHack.PDB to conserve space @if exist $(GAMEDIR)\NetHackW.PDB echo NOTE: You may want to remove $(GAMEDIR:\=/)/NetHackW.PDB to conserve space - -if not exist $(GAMEDIR)\defaults.nh copy $(MSWSYS)\defaults.nh $(GAMEDIR)\defaults.nh + $(U)makedefs -c + -if not exist $(GAMEDIR)\defaults.nh copy fixed_defaults.nh $(GAMEDIR)\defaults.nh -if not exist $(GAMEDIR)\record. goto>$(GAMEDIR)\record. echo install done > $@ @@ -1359,6 +1360,7 @@ clean: if exist $(U)dgncomp.exe del $(U)dgncomp.exe if exist $(SRC)\*.lnk del $(SRC)\*.lnk if exist $(SRC)\*.map del $(SRC)\*.map + if exist $(SRC)\fixed_defaults.nh del $(SRC)\fixed_defaults.nh if exist $(O)install.tag del $(O)install.tag if exist $(O)console.res del $(O)console.res if exist $(O)dgncomp.MAP del $(O)dgncomp.MAP diff --git a/util/makedefs.c b/util/makedefs.c index 0b97a8bcb..29a528f01 100644 --- a/util/makedefs.c +++ b/util/makedefs.c @@ -111,6 +111,15 @@ static const char SCCS_Id[] UNUSED = "@(#)makedefs.c\t3.6\t2018/03/02"; #endif /* else !MAC */ #endif /* else !AMIGA */ +#if !defined(STATUS_HILITES) && defined(WIN32) +#define FIX_SAMPLECONFIG +#endif + +#ifdef WIN32 +#define SAMPLE_CONFIGFILE "../sys/winnt/defaults.nh" +#define FIXED_CONFIGFILE "./fixed_defaults.nh" +#endif + static const char *Dont_Edit_Code = "/* This source file is generated by 'makedefs'. Do not edit. */\n", @@ -162,6 +171,9 @@ void NDECL(do_questtxt); void NDECL(do_rumors); void NDECL(do_oracles); void NDECL(do_vision); +#ifdef WIN32 +void NDECL(do_fix_sampleconfig); +#endif extern void NDECL(monst_init); /* monst.c */ extern void NDECL(objects_init); /* objects.c */ @@ -364,7 +376,12 @@ char *options; case 'Z': do_vision(); break; - +#ifdef WIN32 + case 'c': + case 'C': + do_fix_sampleconfig(); + break; +#endif default: Fprintf(stderr, "Unknown option '%c'.\n", *options); (void) fflush(stderr); @@ -1457,6 +1474,45 @@ char *githash, *gitbranch; return FALSE; } +#ifdef WIN32 +void +do_fix_sampleconfig() +{ + FILE *scfp, *ofcfp; + char fixedline[600]; + char *line; + + if (!(scfp = fopen(SAMPLE_CONFIGFILE, RDTMODE))) { + return; + } + if (!(ofcfp = fopen(FIXED_CONFIGFILE, WRTMODE))) { + return; + } + + /* read the sample config file */ + while ((line = fgetline(scfp)) != 0) { + /* comment out the STATUS_HILITES related lines */ + if (strlen(line) < (600 - 1)) { + if (strstr(line, "statushilites") || strstr(line, "hilite_status:")) { +#ifdef FIX_SAMPLECONFIG + fixedline[0] = '#'; + Strcpy(&fixedline[1], line); +#else + Strcpy(fixedline, line); +#endif + fputs(fixedline, ofcfp); + } else { + fputs(line, ofcfp); + } + } + free(line); + } + Fclose(scfp); + Fclose(ofcfp); + return; +} +#endif /* WIN32 */ + static int case_insensitive_comp(s1, s2) const char *s1; From ccd6f1cf226c902e42b1e16a7a20259536b0eb53 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 25 Nov 2018 12:47:53 -0500 Subject: [PATCH 5/7] more orctown-related follow-up Under some circumstances, when all the marauding orcs belonging to the horde operating within the gnomish mines had been provided with their spoils and placed appropriately, there could still be some pillaged stuff left-over on the migrating obj chain. Orcs created by regular monster generation elsewhere would then be susceptable to receiving that stuff until it was used up. That part is fine, except that the orcs were then being named as part of the same horde operating within the mines. Now they will no longer be named as part of the Gnomish Mines horde. Mythos: There's a good chance that these particular orcs received the stolen goods from the Gnomish Mines horde. --- doc/fixes36.2 | 2 ++ include/extern.h | 2 +- src/do_name.c | 22 ++++++++++++++------ src/dokick.c | 11 +++++++--- src/mkmaze.c | 2 +- src/pager.c | 54 ++++++++++++++++++++++++++++++++++-------------- 6 files changed, 67 insertions(+), 26 deletions(-) diff --git a/doc/fixes36.2 b/doc/fixes36.2 index 5e4d30edf..9c54cd357 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -231,6 +231,8 @@ setting the inverse attribute for gold had the space before "$:" getting highlighted along with the gold field sortloot segfaulted when filtering a subset of items (seen with 'A' command) orctown: prevent Bad fruit #0 and some minor tuning +orctown: orcs beyond the mines were being given any left-over booty and named + as part of the same marauding gang operating within the mines make long extended commands list be more navigable simplify #wizidentify; don't rely on having bold menu entries ensure tmp_at() structures are initialized for all code paths when swallowed diff --git a/include/extern.h b/include/extern.h index 89910b0bb..ccd54c605 100644 --- a/include/extern.h +++ b/include/extern.h @@ -431,7 +431,7 @@ E struct obj *FDECL(realloc_obj, (struct obj *, int, genericptr_t, int, const char *)); E char *FDECL(coyotename, (struct monst *, char *)); E char *FDECL(rndorcname, (char *)); -E struct monst *FDECL(christen_orc, (struct monst *, char *)); +E struct monst *FDECL(christen_orc, (struct monst *, char *, char *)); E const char *FDECL(noveltitle, (int *)); E const char *FDECL(lookup_novel, (const char *, int *)); diff --git a/src/do_name.c b/src/do_name.c index aa688765a..e2e249b93 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -2088,18 +2088,28 @@ char *s; } struct monst * -christen_orc(mtmp, gang) +christen_orc(mtmp, gang, other) struct monst *mtmp; -char *gang; +char *gang, *other; { int sz = 0; char buf[BUFSZ], buf2[BUFSZ], *orcname; orcname = rndorcname(buf2); - sz = (int) (strlen(gang) + strlen(orcname) + sizeof " of " - sizeof ""); - if (gang && orcname && sz < BUFSZ) { - Sprintf(buf, "%s of %s", upstart(orcname), upstart(gang)); - mtmp = christen_monst(mtmp, buf); + sz = (int) ((gang ? strlen(gang) : other ? strlen(other) : 0) + + strlen(orcname) + sizeof " of " - sizeof ""); + if (sz < BUFSZ) { + boolean nameit = FALSE; + + if (gang && orcname) { + Sprintf(buf, "%s of %s", upstart(orcname), upstart(gang)); + nameit = TRUE; + } else if (other && orcname) { + Sprintf(buf, "%s%s", upstart(orcname), other); + nameit = TRUE; + } + if (nameit) + mtmp = christen_monst(mtmp, buf); } return mtmp; } diff --git a/src/dokick.c b/src/dokick.c index 3cce7395f..3274b15e9 100644 --- a/src/dokick.c +++ b/src/dokick.c @@ -1680,7 +1680,8 @@ unsigned long deliverflags; { struct obj *otmp, *otmp2; int where, maxobj = 1; - + boolean at_crime_scene = In_mines(&u.uz); + if ((deliverflags & DF_RANDOM) && cnt > 1) maxobj = rnd(cnt); else if (deliverflags & DF_ALL) @@ -1702,8 +1703,12 @@ unsigned long deliverflags; /* special treatment for orcs and their kind */ if ((otmp->corpsenm & M2_ORC) != 0 && has_oname(otmp)) { - if (!has_mname(mtmp)) - mtmp = christen_orc(mtmp, ONAME(otmp)); + if (!has_mname(mtmp)) { + if (at_crime_scene || (!at_crime_scene && !rn2(2))) + mtmp = christen_orc(mtmp, + at_crime_scene ? ONAME(otmp) : (char *) 0, + " the Fence"); /* bought the stolen goods */ + } free_oname(otmp); } otmp->corpsenm = 0; diff --git a/src/mkmaze.c b/src/mkmaze.c index 6300fe56f..1dd52cb98 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -785,7 +785,7 @@ stolen_booty(VOID_ARGS) * member of the main orc horde. */ if (mtmp->data != &mons[PM_ORC_CAPTAIN]) - mtmp = christen_orc(mtmp, upstart(gang)); + mtmp = christen_orc(mtmp, upstart(gang), ""); } } /* Lastly, ensure there's several more orcs from the gang along the way. diff --git a/src/pager.c b/src/pager.c index f8146615d..b6776b497 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1346,8 +1346,9 @@ char *name; struct permonst *pm; boolean without_asking; { + int textidx = 0; winid datawin = WIN_ERR; - char *entrytext = name, *bp; + char *entrytext = name, *bp = (char *) 0, *bp2 = (char *) 0; char question[QBUFSZ]; boolean yes_to_moreinfo = FALSE; @@ -1357,7 +1358,8 @@ boolean without_asking; * available from data.base or other sources. */ if (name && pm && is_orc(pm) && (strlen(name) < (BUFSZ - 1)) - && (bp = strstri(name, " of ")) != 0) { + && ((bp = strstri(name, " of ")) != 0) || + (bp2 = strstri(name, " the Fence")) != 0) { char fullname[BUFSZ]; Strcpy(fullname, name); @@ -1372,28 +1374,50 @@ boolean without_asking; } if (yes_to_moreinfo) { int i, subs = 0; - char *gang = bp + 4; - static const char *text[] = { - "%s is a member of a marauding horde of orcs", - "rumored to have brutally attacked and plundered the ordinarily", - "sheltered town that is located deep within The Gnomish Mines.", - "", - "The members of that vicious horde proudly and defiantly acclaim", - "their allegiance to their leader %s in their names.", + char *gang = (char *) 0; + + if (bp) + textidx = 0; + else + textidx = 1; + + static const char *text[2][6] = { + { + "%s is a member of a marauding horde of orcs", + "rumored to have brutally attacked and plundered the ordinarily", + "sheltered town that is located deep within The Gnomish Mines.", + "", + "The members of that vicious horde proudly and defiantly acclaim", + "their allegiance to their leader %s in their names.", + }, + { + "%s is a nefarious orc who is known to acquire property", + "from thieves and sell it off for profit or gain.", + "The perpetrator was last seen hanging around the stairs leading", + "to the Gnomish Mines.", + "", + "", + } }; - *bp = '\0'; + if (bp) { + gang = bp + 4; + *bp = '\0'; + } else { + gang = ""; + } + datawin = create_nhwindow(NHW_MENU); - for (i = 0; i < SIZE(text); i++) { + for (i = 0; i < SIZE(text[textidx]); i++) { char buf[BUFSZ]; const char *txt; - if (strstri(text[i], "%s") != 0) { - Sprintf(buf, text[i], + if (strstri(text[textidx][i], "%s") != 0) { + Sprintf(buf, text[textidx][i], subs++ ? gang : fullname); txt = buf; } else - txt = text[i]; + txt = text[textidx][i]; putstr(datawin, 0, txt); } display_nhwindow(datawin, FALSE); From 5c27a3693693bd1f2611667d87ecaac541d2d86f Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 25 Nov 2018 13:39:48 -0500 Subject: [PATCH 6/7] try to silence clang warning --- src/pager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pager.c b/src/pager.c index b6776b497..fc1711723 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1357,7 +1357,7 @@ boolean without_asking; * meant to support in-game mythology, and not * available from data.base or other sources. */ - if (name && pm && is_orc(pm) && (strlen(name) < (BUFSZ - 1)) + if ((name && pm && is_orc(pm) && (strlen(name) < (BUFSZ - 1))) && ((bp = strstri(name, " of ")) != 0) || (bp2 = strstri(name, " the Fence")) != 0) { char fullname[BUFSZ]; From 457d3a0d26efeb56a99df15c71f3c61b8d0ba4a2 Mon Sep 17 00:00:00 2001 From: nhmall Date: Sun, 25 Nov 2018 14:16:22 -0500 Subject: [PATCH 7/7] more warning quiet --- src/pager.c | 120 ++++++++++++++++++++++++++-------------------------- 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/src/pager.c b/src/pager.c index fc1711723..894d3e7d5 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1340,88 +1340,88 @@ boolean do_mons; /* True => monsters, False => objects */ destroy_nhwindow(win); } +static const char *suptext1[] = { + "%s is a member of a marauding horde of orcs", + "rumored to have brutally attacked and plundered", + "the ordinarily sheltered town that is located ", + "deep within The Gnomish Mines.", + "", + "The members of that vicious horde proudly and ", + "defiantly acclaim their allegiance to their", + "leader %s in their names.", + (char *) 0, +}; + +static const char *suptext2[] = { + "%s is a nefarious orc who is known to acquire", + "property from thieves and sell it off for profit", + "or gain. The perpetrator was last seen hanging", + "around the stairs leading to the Gnomish Mines.", + (char *) 0, +}; + void do_supplemental_info(name, pm, without_asking) char *name; struct permonst *pm; boolean without_asking; { - int textidx = 0; + const char **textp; winid datawin = WIN_ERR; char *entrytext = name, *bp = (char *) 0, *bp2 = (char *) 0; char question[QBUFSZ]; boolean yes_to_moreinfo = FALSE; + boolean is_marauder = (name && pm && is_orc(pm)); /* * Provide some info on some specific things * meant to support in-game mythology, and not * available from data.base or other sources. */ - if ((name && pm && is_orc(pm) && (strlen(name) < (BUFSZ - 1))) - && ((bp = strstri(name, " of ")) != 0) || - (bp2 = strstri(name, " the Fence")) != 0) { + if (is_marauder && (strlen(name) < (BUFSZ - 1))) { char fullname[BUFSZ]; - Strcpy(fullname, name); - if (!without_asking) { - Strcpy(question, "More info about \""); - /* +2 => length of "\"?" */ - copynchars(eos(question), entrytext, - (int) (sizeof question - 1 - (strlen(question) + 2))); - Strcat(question, "\"?"); - if (yn(question) == 'y') - yes_to_moreinfo = TRUE; - } - if (yes_to_moreinfo) { - int i, subs = 0; - char *gang = (char *) 0; + bp = strstri(name, " of "); + bp2 = strstri(name, " the Fence"); - if (bp) - textidx = 0; - else - textidx = 1; + if (bp || bp2) { + Strcpy(fullname, name); + if (!without_asking) { + Strcpy(question, "More info about \""); + /* +2 => length of "\"?" */ + copynchars(eos(question), entrytext, + (int) (sizeof question - 1 - (strlen(question) + 2))); + Strcat(question, "\"?"); + if (yn(question) == 'y') + yes_to_moreinfo = TRUE; + } + if (yes_to_moreinfo) { + int i, subs = 0; + char *gang = (char *) 0; - static const char *text[2][6] = { - { - "%s is a member of a marauding horde of orcs", - "rumored to have brutally attacked and plundered the ordinarily", - "sheltered town that is located deep within The Gnomish Mines.", - "", - "The members of that vicious horde proudly and defiantly acclaim", - "their allegiance to their leader %s in their names.", - }, - { - "%s is a nefarious orc who is known to acquire property", - "from thieves and sell it off for profit or gain.", - "The perpetrator was last seen hanging around the stairs leading", - "to the Gnomish Mines.", - "", - "", + if (bp) { + textp = suptext1; + gang = bp + 4; + *bp = '\0'; + } else { + textp = suptext2; + gang = ""; + } + datawin = create_nhwindow(NHW_MENU); + for (i = 0; textp[i]; i++) { + char buf[BUFSZ]; + const char *txt; + + if (strstri(textp[i], "%s") != 0) { + Sprintf(buf, textp[i], subs++ ? gang : fullname); + txt = buf; + } else + txt = textp[i]; + putstr(datawin, 0, txt); } - }; - - if (bp) { - gang = bp + 4; - *bp = '\0'; - } else { - gang = ""; + display_nhwindow(datawin, FALSE); + destroy_nhwindow(datawin), datawin = WIN_ERR; } - - datawin = create_nhwindow(NHW_MENU); - for (i = 0; i < SIZE(text[textidx]); i++) { - char buf[BUFSZ]; - const char *txt; - - if (strstri(text[textidx][i], "%s") != 0) { - Sprintf(buf, text[textidx][i], - subs++ ? gang : fullname); - txt = buf; - } else - txt = text[textidx][i]; - putstr(datawin, 0, txt); - } - display_nhwindow(datawin, FALSE); - destroy_nhwindow(datawin), datawin = WIN_ERR; } } }