From 24d6d6b070e8e23fdc4bfe3ba78da7c3b3007c36 Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 17 Jun 2019 09:31:01 -0700 Subject: [PATCH 1/2] fuzzer tweaks Prevent the fuzzer from randomly toggling the 'silent' option. If you use the default value of True then this eliminates most--but not all--of the beeping that happens when it is running. I'm not sure where the remaining beeps are coming from. Modify the random keystroke selection to implement some bias towards direction keys that I thought had already been there, plus a higher chance to entering digits to initiate number responses. --- src/cmd.c | 51 ++++++++++++++++++++++++++++++++++++++++----------- src/options.c | 8 ++++++-- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/src/cmd.c b/src/cmd.c index d674be6f5..2aa2df4db 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 cmd.c $NHDT-Date: 1559382745 2019/06/01 09:52:25 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.335 $ */ +/* NetHack 3.6 cmd.c $NHDT-Date: 1560789049 2019/06/17 16:30:49 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.336 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4530,21 +4530,50 @@ int NDECL((*cmd_func)); char randomkey() { - static int i = 0; + static unsigned i = 0; char c; - switch (rn2(12)) { - default: c = '\033'; break; - case 0: c = '\n'; break; + switch (rn2(16)) { + default: + c = '\033'; + break; + case 0: + c = '\n'; + break; case 1: case 2: case 3: - case 4: c = (char)(' ' + rn2((int)('~' - ' '))); break; - case 5: c = '\t'; break; - case 6: c = (char)('a' + rn2((int)('z' - 'a'))); break; - case 7: c = (char)('A' + rn2((int)('Z' - 'A'))); break; - case 8: c = extcmdlist[(i++) % SIZE(extcmdlist)].key; break; - case 9: c = '#'; break; + case 4: + c = (char) rn1('~' - ' ' + 1, ' '); + break; + case 5: + c = (char) (rn2(2) ? '\t' : ' '); + break; + case 6: + c = (char) rn1('z' - 'a' + 1, 'a'); + break; + case 7: + c = (char) rn1('Z' - 'A' + 1, 'A'); + break; + case 8: + c = extcmdlist[i++ % SIZE(extcmdlist)].key; + break; + case 9: + c = '#'; + break; + case 10: + case 11: + case 12: + c = Cmd.dirchars[rn2(8)]; + if (!rn2(7)) + c = !Cmd.num_pad ? (!rn2(3) ? C(c) : (c + 'A' - 'a')) : M(c); + break; + case 13: + c = (char) rn1('9' - '0' + 1, '0'); + break; + case 14: + c = (char) rn2(iflags.wc_eight_bit_input ? 256 : 128); + break; } return c; diff --git a/src/options.c b/src/options.c index a0446bfbc..c92c5ab35 100644 --- a/src/options.c +++ b/src/options.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 options.c $NHDT-Date: 1554591224 2019/04/06 22:53:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.363 $ */ +/* NetHack 3.6 options.c $NHDT-Date: 1560789054 2019/06/17 16:30:54 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.364 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Michael Allison, 2008. */ /* NetHack may be freely redistributed. See license for details. */ @@ -3993,7 +3993,6 @@ boolean tinitial, tfrom_file; } op = string_for_opt(opts, TRUE); - if (op) { if (negated) { config_error_add( @@ -4010,6 +4009,11 @@ boolean tinitial, tfrom_file; return FALSE; } } + if (iflags.debug_fuzzer && !initial) { + /* don't randomly toggle this/these */ + if (boolopt[i].addr == &flags.silent) + return TRUE; + } *(boolopt[i].addr) = !negated; From 273662c58c796d4e915ce27b9d912f357e61d85e Mon Sep 17 00:00:00 2001 From: PatR Date: Mon, 17 Jun 2019 10:09:16 -0700 Subject: [PATCH 2/2] monster overflow on Plane of Air Make Air behave the same as Earth, Fire, and Water if monsters are forced off the level for some reason. --- src/mon.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/mon.c b/src/mon.c index 1c7fe5424..2a8a7f350 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1560597210 2019/06/15 11:13:30 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.293 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1560791350 2019/06/17 17:09:10 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.294 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2687,31 +2687,20 @@ struct monst *mon; mtmp->mstate |= MON_OBLITERATE; mongone(mtmp); - /* some places in the code might still reference mtmp->mx, mtmp->my */ + /* places in the code might still reference mtmp->mx, mtmp->my */ /* mtmp->mx = mtmp->my = 0; */ rloc_to(mon, mx, my); /* note: mon, not mtmp */ - } else { - /* last resort - migrate mon to the next plane */ - if (Is_waterlevel(&u.uz) || Is_firelevel(&u.uz) - || Is_earthlevel(&u.uz)) { - /* try sending mon on to the next plane */ - xchar target_lev = 0, xyloc = 0; - struct trap *trap = ftrap; - while (trap) { - if (trap->ttyp == MAGIC_PORTAL) - break; - trap = trap->ntrap; - } - if (trap) { - target_lev = ledger_no(&trap->dst); - xyloc = MIGR_RANDOM; - } - if (target_lev) { - mon->mstate |= MON_ENDGAME_MIGR; - migrate_mon(mon, target_lev, xyloc); - } - } + /* last resort - migrate mon to the next plane */ + } else if (!Is_astralevel(&u.uz)) { + d_level dest; + xchar target_lev; + + dest = u.uz; + dest.dlevel--; + target_lev = ledger_no(&dest); + mon->mstate |= MON_ENDGAME_MIGR; + migrate_mon(mon, target_lev, MIGR_RANDOM); } } }