Merge branch 'NetHack-3.6'

# Conflicts:
#	DEVEL/Developer.txt
#	include/config.h
#	include/decl.h
#	include/display.h
#	include/extern.h
#	include/global.h
#	include/hack.h
#	include/patchlevel.h
#	src/display.c
#	src/dothrow.c
#	src/makemon.c
#	src/monst.c
#	src/objnam.c
#	src/sp_lev.c
#	src/wield.c
#	src/zap.c
#	sys/share/pmatchregex.c
#	sys/winnt/Makefile.msc
This commit is contained in:
Bart House
2019-07-14 23:36:56 -07:00
32 changed files with 162 additions and 822 deletions
+2 -6
View File
@@ -564,13 +564,9 @@ typedef unsigned char uchar;
%N first character of player name %N first character of player name
DUMPLOG_FILE is not used if SYSCF is defined DUMPLOG_FILE is not used if SYSCF is defined
*/ */
#endif /* DUMPLOG_FILE */ #endif
#endif /* DUMPLOG */ #endif
/* NEW_KEYBOARD_HIT adds new window proc to return whether keyboard has been hit
and character input is available */
/* #define NEW_KEYBOARD_HIT */
#define USE_ISAAC64 /* Use cross-plattform, bundled RNG */ #define USE_ISAAC64 /* Use cross-plattform, bundled RNG */
-11
View File
@@ -470,17 +470,6 @@ struct early_opt {
boolean valallowed; boolean valallowed;
}; };
struct ptr_array {
size_t length;
size_t max_length;
void ** elements;
};
typedef struct ptr_array ptr_array_t;
/* logging verbosity levels */
#define LOG_MINIMAL 0
#define LOG_VERBOSE 1
/* special key functions */ /* special key functions */
enum nh_keyfunc { enum nh_keyfunc {
NHKF_ESC = 0, NHKF_ESC = 0,
-27
View File
@@ -28,10 +28,6 @@ E void FDECL(welcome, (BOOLEAN_P));
E time_t NDECL(get_realtime); E time_t NDECL(get_realtime);
E int FDECL(argcheck, (int, char **, enum earlyarg)); E int FDECL(argcheck, (int, char **, enum earlyarg));
E void NDECL(early_init); E void NDECL(early_init);
E void NDECL(fuzzer_toggle);
E void NDECL(fuzzer_check);
E void NDECL(fuzzer_auto_start);
E boolean FDECL(fuzzer_msg_history, (const char *));
/* ### apply.c ### */ /* ### apply.c ### */
@@ -955,7 +951,6 @@ E boolean
FDECL(fuzzymatch, (const char *, const char *, const char *, BOOLEAN_P)); FDECL(fuzzymatch, (const char *, const char *, const char *, BOOLEAN_P));
E void FDECL(init_random, (int FDECL((*fn), (int)))); E void FDECL(init_random, (int FDECL((*fn), (int))));
E void FDECL(reseed_random, (int FDECL((*fn), (int)))); E void FDECL(reseed_random, (int FDECL((*fn), (int))));
E void FDECL(set_random, (unsigned long, int FDECL((*fn), (int))));
E time_t NDECL(getnow); E time_t NDECL(getnow);
E int NDECL(getyear); E int NDECL(getyear);
#if 0 #if 0
@@ -974,8 +969,6 @@ E void FDECL(strbuf_append, (strbuf_t *, const char *));
E void FDECL(strbuf_reserve, (strbuf_t *, int)); E void FDECL(strbuf_reserve, (strbuf_t *, int));
E void FDECL(strbuf_empty, (strbuf_t *)); E void FDECL(strbuf_empty, (strbuf_t *));
E void FDECL(strbuf_nl_to_crlf, (strbuf_t *)); E void FDECL(strbuf_nl_to_crlf, (strbuf_t *));
E struct ptr_array * FDECL(ptr_array_new, (size_t length));
E void FDECL(ptr_array_free, (struct ptr_array *));
/* ### invent.c ### */ /* ### invent.c ### */
@@ -1151,9 +1144,6 @@ E void NDECL(gettty);
E void NDECL(setftty); E void NDECL(setftty);
E void FDECL(settty, (const char *)); E void FDECL(settty, (const char *));
E int NDECL(tgetch); E int NDECL(tgetch);
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tkbhit);
#endif
E void FDECL(cmov, (int x, int y)); E void FDECL(cmov, (int x, int y));
E void FDECL(nocmov, (int x, int y)); E void FDECL(nocmov, (int x, int y));
@@ -1560,9 +1550,6 @@ E void FDECL(mplayer_talk, (struct monst *));
#ifndef WIN32 #ifndef WIN32
E int NDECL(tgetch); E int NDECL(tgetch);
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tkbhit);
#endif
#endif #endif
#ifndef TOS #ifndef TOS
E char NDECL(switchar); E char NDECL(switchar);
@@ -1593,9 +1580,7 @@ E void FDECL(gotoxy, (int, int));
#endif #endif
#ifdef TOS #ifdef TOS
E int FDECL(_copyfile, (char *, char *)); E int FDECL(_copyfile, (char *, char *));
#ifndef NEW_KEYBOARD_HIT
E int NDECL(kbhit); E int NDECL(kbhit);
#endif
E void NDECL(set_colors); E void NDECL(set_colors);
E void NDECL(restore_colors); E void NDECL(restore_colors);
#ifdef SUSPEND #ifdef SUSPEND
@@ -1605,9 +1590,7 @@ E int NDECL(dosuspend);
#ifdef WIN32 #ifdef WIN32
E char *FDECL(get_username, (int *)); E char *FDECL(get_username, (int *));
E void FDECL(nt_regularize, (char *)); E void FDECL(nt_regularize, (char *));
#ifndef NEW_KEYBOARD_HIT
E int NDECL((*nt_kbhit)); E int NDECL((*nt_kbhit));
#endif
E void FDECL(Delay, (int)); E void FDECL(Delay, (int));
#endif /* WIN32 */ #endif /* WIN32 */
#endif /* MICRO || WIN32 */ #endif /* MICRO || WIN32 */
@@ -1675,15 +1658,10 @@ E void FDECL(regex_free, (struct nhregex *));
#ifdef WIN32 #ifdef WIN32
E void NDECL(get_scr_size); E void NDECL(get_scr_size);
#ifndef NEW_KEYBOARD_HIT
E int NDECL(nttty_kbhit); E int NDECL(nttty_kbhit);
#endif
E void FDECL(nttty_open, (int)); E void FDECL(nttty_open, (int));
E void NDECL(nttty_rubout); E void NDECL(nttty_rubout);
E int NDECL(tgetch); E int NDECL(tgetch);
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tkbhit);
#endif
E int FDECL(ntposkey, (int *, int *, int *)); E int FDECL(ntposkey, (int *, int *, int *));
E void FDECL(set_output_mode, (int)); E void FDECL(set_output_mode, (int));
E void NDECL(synch_cursor); E void NDECL(synch_cursor);
@@ -1938,10 +1916,6 @@ E void VDECL(verbalize, (const char *, ...)) PRINTF_F(1, 2);
E void VDECL(raw_printf, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(raw_printf, (const char *, ...)) PRINTF_F(1, 2);
E void VDECL(impossible, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(impossible, (const char *, ...)) PRINTF_F(1, 2);
E void VDECL(config_error_add, (const char *, ...)) PRINTF_F(1, 2); E void VDECL(config_error_add, (const char *, ...)) PRINTF_F(1, 2);
E void FDECL(nhassert_failed, (const char *, int));
E void NDECL(fuzzer_start);
E void NDECL(fuzzer_stop);
E void VDECL(fuzzer_log, (int, const char *, ...)) PRINTF_F(2, 3);
/* ### polyself.c ### */ /* ### polyself.c ### */
@@ -2167,7 +2141,6 @@ E int FDECL(rnd, (int));
E int FDECL(d, (int, int)); E int FDECL(d, (int, int));
E int FDECL(rne, (int)); E int FDECL(rne, (int));
E int FDECL(rnz, (int)); E int FDECL(rnz, (int));
E unsigned long NDECL(rul);
/* ### role.c ### */ /* ### role.c ### */
-4
View File
@@ -433,10 +433,6 @@ struct instance_flags {
chosen_windowport[], but do not switch to chosen_windowport[], but do not switch to
it in the midst of options processing */ it in the midst of options processing */
boolean obsolete; /* obsolete options can point at this, it isn't used */ boolean obsolete; /* obsolete options can point at this, it isn't used */
boolean fuzzer_auto_start; /* start fuzzer automatically */
int fuzzer_stop_and_save; /* move when fuzzer stops and saves game */
boolean fuzzer_saving; /* fuzzer is saving game */
int verbose_logging_start; /* move when verbose fuzzer logging starts */
}; };
/* /*
-5
View File
@@ -382,10 +382,5 @@ struct savefile_info {
#define nhassert(e) ((void)0) #define nhassert(e) ((void)0)
#endif #endif
/* Supply nhassert macro if not supplied by port */
#ifndef nhassert
#define nhassert(expression) (void)((!!(expression)) || \
(nhassert_failed(__FILE__, __LINE__), 0))
#endif
#endif /* GLOBAL_H */ #endif /* GLOBAL_H */
+18 -15
View File
@@ -134,8 +134,6 @@ extern void NDECL(getlock);
#ifndef HAS_STDINT_H #ifndef HAS_STDINT_H
#define HAS_STDINT_H /* force include of stdint.h in integer.h */ #define HAS_STDINT_H /* force include of stdint.h in integer.h */
#endif #endif
/* Turn on some additional warnings */
#pragma warning(3:4389)
#endif /* _MSC_VER */ #endif /* _MSC_VER */
/* The following is needed for prototypes of certain functions */ /* The following is needed for prototypes of certain functions */
@@ -148,6 +146,14 @@ extern void NDECL(getlock);
#define strncmpi(a, b, c) strnicmp(a, b, c) #define strncmpi(a, b, c) strnicmp(a, b, c)
#endif #endif
#ifdef _MSC_VER
/* Visual Studio defines this in their own headers, which we don't use */
#ifndef snprintf
#define snprintf _snprintf
#pragma warning( \
disable : 4996) /* deprecation warning suggesting snprintf_s */
#endif
#endif
#include <sys/types.h> #include <sys/types.h>
#include <stdlib.h> #include <stdlib.h>
@@ -245,11 +251,8 @@ int _RTLENTRY _EXPFUNC read(int __handle, void _FAR *__buf, unsigned __len);
#ifndef CURSES_GRAPHICS #ifndef CURSES_GRAPHICS
#include <conio.h> /* conflicting definitions with curses.h */ #include <conio.h> /* conflicting definitions with curses.h */
#endif #endif
#ifndef NEW_KEYBOARD_HIT
#undef kbhit /* Use our special NT kbhit */ #undef kbhit /* Use our special NT kbhit */
#define kbhit (*nt_kbhit) #define kbhit (*nt_kbhit)
#endif
#ifdef LAN_FEATURES #ifdef LAN_FEATURES
#define MAX_LAN_USERNAME 20 #define MAX_LAN_USERNAME 20
@@ -268,17 +271,17 @@ extern int FDECL(set_win32_option, (const char *, const char *));
extern int FDECL(alternative_palette, (char *)); extern int FDECL(alternative_palette, (char *));
#endif #endif
#ifdef NDEBUG
#define nhassert(expression) ((void)0)
#else
extern void FDECL(nhassert_failed, (const char * exp, const char * file,
int line));
#define nhassert(expression) (void)((!!(expression)) || \
(nhassert_failed(#expression, __FILE__, __LINE__), 0))
#endif
#define nethack_enter(argc, argv) nethack_enter_winnt() #define nethack_enter(argc, argv) nethack_enter_winnt()
extern void FDECL(nethack_exit, (int)) NORETURN; extern void FDECL(nethack_exit, (int)) NORETURN;
extern boolean FDECL(file_exists, (const char *)); extern boolean FDECL(file_exists, (const char *));
/* Override the default version of nhassert. The default version is unable
* to generate a string form of the expression due to the need to be
* compatible with compilers which do not support macro stringization (i.e.
* #x to turn x into its string form).
*/
extern void FDECL(nt_assert_failed, (const char *, const char *, int));
#define nhassert(expression) (void)((!!(expression)) || \
(nt_assert_failed(#expression, __FILE__, __LINE__), 0))
#endif /* NTCONF_H */ #endif /* NTCONF_H */
-2
View File
@@ -305,9 +305,7 @@
#define HLOCK "perm" /* an empty file used for locking purposes */ #define HLOCK "perm" /* an empty file used for locking purposes */
#ifndef NEW_KEYBOARD_HIT
#define tgetch getchar #define tgetch getchar
#endif
#ifndef NOSHELL #ifndef NOSHELL
#define SHELL /* do not delete the '!' command */ #define SHELL /* do not delete the '!' command */
-12
View File
@@ -79,9 +79,6 @@ struct window_procs {
(int, const char *, const char *, BOOLEAN_P)); (int, const char *, const char *, BOOLEAN_P));
void FDECL((*win_status_update), (int, genericptr_t, int, int, int, unsigned long *)); void FDECL((*win_status_update), (int, genericptr_t, int, int, int, unsigned long *));
boolean NDECL((*win_can_suspend)); boolean NDECL((*win_can_suspend));
#ifdef NEW_KEYBOARD_HIT
boolean NDECL((*win_keyboard_hit));
#endif
}; };
extern extern
@@ -163,9 +160,6 @@ extern
*/ */
#define status_enablefield (*windowprocs.win_status_enablefield) #define status_enablefield (*windowprocs.win_status_enablefield)
#define status_update (*windowprocs.win_status_update) #define status_update (*windowprocs.win_status_update)
#ifdef NEW_KEYBOARD_HIT
#define keyboard_hit (*windowprocs.win_keyboard_hit)
#endif
/* /*
* WINCAP * WINCAP
@@ -385,9 +379,6 @@ struct chain_procs {
(CARGS, int, const char *, const char *, BOOLEAN_P)); (CARGS, int, const char *, const char *, BOOLEAN_P));
void FDECL((*win_status_update), (CARGS, int, genericptr_t, int, int, int, unsigned long *)); void FDECL((*win_status_update), (CARGS, int, genericptr_t, int, int, int, unsigned long *));
boolean FDECL((*win_can_suspend), (CARGS)); boolean FDECL((*win_can_suspend), (CARGS));
#ifdef NEW_KEYBOARD_HIT
boolean FDECL((*keyboard_hit), (CARGS));
#endif
}; };
#endif /* WINCHAIN */ #endif /* WINCHAIN */
@@ -458,9 +449,6 @@ extern void FDECL(safe_status_enablefield,
(int, const char *, const char *, BOOLEAN_P)); (int, const char *, const char *, BOOLEAN_P));
extern void FDECL(safe_status_update, (int, genericptr_t, int, int, int, unsigned long *)); extern void FDECL(safe_status_update, (int, genericptr_t, int, int, int, unsigned long *));
extern boolean NDECL(safe_can_suspend); extern boolean NDECL(safe_can_suspend);
#ifdef NEW_KEYBOARD_HIT
extern boolean NDECL(safe_keyboard_hit);
#endif
extern void FDECL(stdio_raw_print, (const char *)); extern void FDECL(stdio_raw_print, (const char *));
extern void FDECL(stdio_raw_print_bold, (const char *)); extern void FDECL(stdio_raw_print_bold, (const char *));
extern void NDECL(stdio_wait_synch); extern void NDECL(stdio_wait_synch);
-10
View File
@@ -50,12 +50,6 @@ struct WinDesc {
#define WIN_STOP 1 /* for NHW_MESSAGE; stops output */ #define WIN_STOP 1 /* for NHW_MESSAGE; stops output */
#define WIN_LOCKHISTORY 2 /* for NHW_MESSAGE; suppress history updates */ #define WIN_LOCKHISTORY 2 /* for NHW_MESSAGE; suppress history updates */
/* topline states */
#define TOPLINE_EMPTY 0 /* empty */
#define TOPLINE_NEED_MORE 1 /* non-empty, need --More-- */
#define TOPLINE_NON_EMPTY 2 /* non-empty, no --More-- required */
#define TOPLINE_SPECIAL_PROMPT 3 /* special prompt state */
/* descriptor for tty-based displays -- all the per-display data */ /* descriptor for tty-based displays -- all the per-display data */
struct DisplayDesc { struct DisplayDesc {
short rows, cols; /* width and height of tty display */ short rows, cols; /* width and height of tty display */
@@ -253,10 +247,6 @@ E void FDECL(genl_outrip, (winid, int, time_t));
E char *FDECL(tty_getmsghistory, (BOOLEAN_P)); E char *FDECL(tty_getmsghistory, (BOOLEAN_P));
E void FDECL(tty_putmsghistory, (const char *, BOOLEAN_P)); E void FDECL(tty_putmsghistory, (const char *, BOOLEAN_P));
#ifdef NEW_KEYBOARD_HIT
E boolean NDECL(tty_keyboard_hit);
#endif
#ifdef NO_TERMS #ifdef NO_TERMS
#ifdef MAC #ifdef MAC
#ifdef putchar #ifdef putchar
+1 -82
View File
@@ -4,6 +4,7 @@
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
/* various code that was replicated in *main.c */ /* various code that was replicated in *main.c */
#include "hack.h" #include "hack.h"
#include <ctype.h> #include <ctype.h>
@@ -378,11 +379,7 @@ boolean resuming;
if (g.multi >= 0 && g.occupation) { if (g.multi >= 0 && g.occupation) {
#if defined(MICRO) || defined(WIN32) #if defined(MICRO) || defined(WIN32)
abort_lev = 0; abort_lev = 0;
#ifdef NEW_KEYBOARD_HIT
if (keyboard_hit()) {
#else
if (kbhit()) { if (kbhit()) {
#endif
if ((ch = pgetchar()) == ABORT) if ((ch = pgetchar()) == ABORT)
abort_lev++; abort_lev++;
else else
@@ -440,8 +437,6 @@ boolean resuming;
#ifdef MAIL #ifdef MAIL
ckmailstatus(); ckmailstatus();
#endif #endif
fuzzer_check();
rhack((char *) 0); rhack((char *) 0);
} }
if (u.utotype) /* change dungeon level */ if (u.utotype) /* change dungeon level */
@@ -589,8 +584,6 @@ newgame()
{ {
int i; int i;
fuzzer_auto_start();
#ifdef MFLOPPY #ifdef MFLOPPY
gameDiskPrompt(); gameDiskPrompt();
#endif #endif
@@ -930,78 +923,4 @@ const char *opts;
#endif #endif
return; return;
} }
/* fuzzer_toggle() toggles fuzzer state */
void
fuzzer_toggle()
{
if (iflags.debug_fuzzer)
fuzzer_stop();
else
fuzzer_start();
}
/* fuzzer_check() is called prior to rhack(0) to allow the fuzzer to
* check if it should stop and to allow it to reseed the game.
*/
void
fuzzer_check()
{
if (iflags.debug_fuzzer)
{
unsigned long seed;
if (g.moves >= iflags.fuzzer_stop_and_save) {
iflags.fuzzer_saving = TRUE;
dosave0();
exit_nhwindows("Goodbye from the fuzzer...");
fuzzer_stop();
nh_terminate(EXIT_SUCCESS);
}
seed = rul();
set_random(seed, rn2);
fuzzer_log(LOG_MINIMAL, "SEED:%ld:%lu\n", g.moves, seed);
}
}
/* fuzzer_auto_start is called when creating a new game to allow
* the fuzzer to start itself.
*/
void
fuzzer_auto_start()
{
if (iflags.fuzzer_auto_start) {
unsigned long seed;
nhassert(!iflags.debug_fuzzer);
fuzzer_start();
seed = rul();
set_random(seed, rn2);
fuzzer_log(LOG_MINIMAL, "START:%ld:%lu\n", g.moves, seed);
}
}
/* fuzzer_msg_history is called during save file recovery to allow
* the fuzzer to snoop the messages being recovered. The fuzzer
* saves a seed as a message in save files and this is the mechanism
* used to recover that seed if the fuzzer is being auto started.
*/
boolean
fuzzer_msg_history(msg)
const char * msg;
{
long saved_moves;
unsigned long saved_seed;
if (sscanf(msg, "SEED:%ld:%lu", &saved_moves, &saved_seed) == 2) {
nhassert(saved_moves == g.moves);
if (iflags.fuzzer_auto_start) {
fuzzer_start();
set_random(saved_seed, rn2);
fuzzer_log(LOG_MINIMAL, "START:%ld:%lu\n", g.moves, saved_seed);
}
return TRUE;
}
return FALSE;
}
/*allmain.c*/ /*allmain.c*/
+1 -2
View File
@@ -2516,8 +2516,7 @@ recalc_mapseen()
struct cemetery *bp, **bonesaddr; struct cemetery *bp, **bonesaddr;
struct trap *t; struct trap *t;
unsigned i, ridx; unsigned i, ridx;
int x, y, ltyp, count; int x, y, ltyp, count, atmp;
unsigned int atmp;
/* Should not happen in general, but possible if in the process /* Should not happen in general, but possible if in the process
* of being booted from the quest. The mapseen object gets * of being booted from the quest. The mapseen object gets
+5 -49
View File
@@ -854,7 +854,7 @@ STATIC_DCL struct tm *NDECL(getlt);
/* Sets the seed for the random number generator */ /* Sets the seed for the random number generator */
#ifdef USE_ISAAC64 #ifdef USE_ISAAC64
void static void
set_random(seed, fn) set_random(seed, fn)
unsigned long seed; unsigned long seed;
int FDECL((*fn), (int)); int FDECL((*fn), (int));
@@ -865,7 +865,7 @@ int FDECL((*fn), (int));
#else /* USE_ISAAC64 */ #else /* USE_ISAAC64 */
/*ARGSUSED*/ /*ARGSUSED*/
void static void
set_random(seed, fn) set_random(seed, fn)
unsigned long seed; unsigned long seed;
int FDECL((*fn), (int)) UNUSED; int FDECL((*fn), (int)) UNUSED;
@@ -917,7 +917,7 @@ int FDECL((*fn), (int));
{ {
/* only reseed if we are certain that the seed generation is unguessable /* only reseed if we are certain that the seed generation is unguessable
* by the players. */ * by the players. */
if (has_strong_rngseed && !iflags.debug_fuzzer) if (has_strong_rngseed)
init_random(fn); init_random(fn);
} }
@@ -1108,9 +1108,6 @@ phase_of_the_moon() /* 0-7, with 0: new, 4: full */
register struct tm *lt = getlt(); register struct tm *lt = getlt();
register int epact, diy, goldn; register int epact, diy, goldn;
if(iflags.debug_fuzzer)
return rn2(8);
diy = lt->tm_yday; diy = lt->tm_yday;
goldn = (lt->tm_year % 19) + 1; goldn = (lt->tm_year % 19) + 1;
epact = (11 * goldn + 18) % 30; epact = (11 * goldn + 18) % 30;
@@ -1125,9 +1122,6 @@ friday_13th()
{ {
register struct tm *lt = getlt(); register struct tm *lt = getlt();
if(iflags.debug_fuzzer)
return rn2(30);
/* tm_wday (day of week; 0==Sunday) == 5 => Friday */ /* tm_wday (day of week; 0==Sunday) == 5 => Friday */
return (boolean) (lt->tm_wday == 5 && lt->tm_mday == 13); return (boolean) (lt->tm_wday == 5 && lt->tm_mday == 13);
} }
@@ -1135,8 +1129,7 @@ friday_13th()
int int
night() night()
{ {
register int hour = (iflags.debug_fuzzer ? (g.moves / 1000) % 24 : register int hour = getlt()->tm_hour;
getlt()->tm_hour);
return (hour < 6 || hour > 21); return (hour < 6 || hour > 21);
} }
@@ -1144,10 +1137,7 @@ night()
int int
midnight() midnight()
{ {
register int hour = (iflags.debug_fuzzer ? (g.moves / 1000) % 24 : return (getlt()->tm_hour == 0);
getlt()->tm_hour);
return (hour == 0);
} }
/* strbuf_init() initializes strbuf state for use */ /* strbuf_init() initializes strbuf state for use */
@@ -1229,38 +1219,4 @@ strbuf_t *strbuf;
} }
} }
ptr_array_t *
ptr_array_new(max_length)
size_t max_length;
{
size_t esize = max_length * sizeof(void *);
ptr_array_t * a = (ptr_array_t *) malloc(sizeof(ptr_array_t) + esize);
a->elements = (void **)(a + 1);
a->length = 0;
a->max_length = max_length;
memset(a->elements, 0, esize);
return a;
}
void
ptr_array_free(a)
ptr_array_t * a;
{
size_t i;
nhassert(a->length <= a->max_length);
for(i = 0; i < a->length; i++)
if(a->elements[i])
free(a->elements[i]);
for (i = a->length; i < a->max_length; i++) {
nhassert(a->elements[i] == NULL);
if(a->elements[i])
free(a->elements[i]);
}
free(a);
}
/*hacklib.c*/ /*hacklib.c*/
-74
View File
@@ -572,78 +572,4 @@ VA_DECL(const char *, str)
#endif #endif
} }
/* nhassert_failed is called when an nhassert's condition is false */
void
nhassert_failed(filepath, line)
const char * filepath;
int line;
{
const char * filename;
/* attempt to get filename from path. TODO: we really need a port provided
* function to return a filename from a path */
filename = strrchr(filepath, '/');
filename = (filename == NULL ? strrchr(filepath, '\\') : filename);
filename = (filename == NULL ? filepath : filename + 1);
impossible("nhassert failed in file '%s' at line %d", filename, line);
}
static FILE * g_fuzzer_log_file = NULL;
static int g_fuzzer_log_level = LOG_MINIMAL;
/* fuzzer_start() starts the fuzzer opening the fuzzer log file */
void
fuzzer_start()
{
if (!iflags.debug_fuzzer) {
const char * fq_replay;
iflags.debug_fuzzer = TRUE;
iflags.fuzzer_auto_start = FALSE;
nhassert(g_fuzzer_log_file == NULL);
fq_replay = fqname("fuzzer.log", SAVEPREFIX, 0);
g_fuzzer_log_file = fopen(fq_replay, "w");
}
}
/* fuzzer_stop() stops the fuzzer and close the fuzzer log file */
void
fuzzer_stop()
{
if (iflags.debug_fuzzer) {
if(g_fuzzer_log_file != NULL) {
fclose(g_fuzzer_log_file);
g_fuzzer_log_file = NULL;
}
}
}
/* fuzzer_log() is used to place messages in the file 'fuzzer.log'. This
* log is the primary tool for monitoring fuzzer activity and tracking down
* issues that the fuzzer is able to reproduce.
*/
void
fuzzer_log
VA_DECL2(int, lvl, const char *, str)
{
VA_START(str);
VA_INIT(str, char *);
if (!g_fuzzer_log_file)
return;
if (iflags.verbose_logging_start != 0 &&
moves >= iflags.verbose_logging_start)
g_fuzzer_log_level = LOG_VERBOSE;
if (lvl <= g_fuzzer_log_level)
Vfprintf(g_fuzzer_log_file, str, VA_ARGS);
VA_END();
}
/*pline.c*/ /*pline.c*/
-2
View File
@@ -1509,8 +1509,6 @@ NHFILE *nhfp;
if (nhfp->fieldlevel) if (nhfp->fieldlevel)
sfi_str(nhfp, msg, "msghistory", "msg", msgsize); sfi_str(nhfp, msg, "msghistory", "msg", msgsize);
msg[msgsize] = '\0'; msg[msgsize] = '\0';
if(fuzzer_msg_history(msg))
continue;
putmsghistory(msg, TRUE); putmsghistory(msg, TRUE);
++msgcount; ++msgcount;
} }
+1 -28
View File
@@ -56,21 +56,10 @@ int FDECL((*fn), (int));
(int) sizeof seed); (int) sizeof seed);
} }
unsigned long
rul()
{
unsigned long value;
value = (unsigned long) isaac64_next_uint64(&rnglist[CORE].rng_state);
fuzzer_log(LOG_VERBOSE, "RANDOM:%lu\n", value);
return value;
}
static int static int
RND(int x) RND(int x)
{ {
return (rul() % x); return (isaac64_next_uint64(&rnglist[CORE].rng_state) % x);
} }
/* 0 <= rn2(x) < x, but on a different sequence from the "main" rn2; /* 0 <= rn2(x) < x, but on a different sequence from the "main" rn2;
@@ -80,8 +69,6 @@ int
rn2_on_display_rng(x) rn2_on_display_rng(x)
register int x; register int x;
{ {
if (iflags.debug_fuzzer)
return rn2(x);
return (isaac64_next_uint64(&rnglist[DISP].rng_state) % x); return (isaac64_next_uint64(&rnglist[DISP].rng_state) % x);
} }
@@ -107,20 +94,6 @@ register int x;
seed *= 2739110765; seed *= 2739110765;
return (int)((seed >> 16) % (unsigned)x); return (int)((seed >> 16) % (unsigned)x);
} }
unsigned long
rul()
{
#if defined(LINT) && defined(UNIX)
return (unsigned long) rand();
#else /* LINT */
#if defined(UNIX) || defined(RANDOM)
return (unsigned long) Rand();
#else
return (unsigned long) (Rand() >> 3);
#endif /* defined(UNIX) || defined(RANDOM) */
#endif /* LINT */
}
#endif /* USE_ISAAC64 */ #endif /* USE_ISAAC64 */
/* 0 <= rn2(x) < x */ /* 0 <= rn2(x) < x */
+1 -20
View File
@@ -132,7 +132,7 @@ dosave0()
return 0; return 0;
#endif #endif
HUP if (!iflags.debug_fuzzer && iflags.window_inited) { HUP if (iflags.window_inited) {
nh_uncompress(fq_save); nh_uncompress(fq_save);
nhfp = open_savefile(); nhfp = open_savefile();
if (nhfp) { if (nhfp) {
@@ -1225,25 +1225,6 @@ NHFILE *nhfp;
} }
++msgcount; ++msgcount;
} }
/* If the fuzzer is stopping and saving, save a seed as a message.
In 3.7, we will modify the save file format and save the seed
directly in the saved game state. */
if (iflags.fuzzer_saving) {
char message[BUFSIZ];
unsigned long seed = rul();
sprintf(message, "SEED:%ld:%lu", g.moves, seed);
fuzzer_log(LOG_MINIMAL, "STOP:%ld:%lu\n", g.moves, seed);
msglen = strlen(message);
if (nhfp->structlevel) {
bwrite(nhfp->fd, (genericptr_t) &msglen, sizeof msglen);
bwrite(nhfp->fd, (genericptr_t) message, msglen);
}
if (nhfp->fieldlevel) {
sfo_int(nhfp, &msglen, "msghistory", "msghistory_length", 1);
sfo_str(nhfp, message, "msghistory", "msg", msglen);
}
}
if (nhfp->structlevel) if (nhfp->structlevel)
bwrite(nhfp->fd, (genericptr_t) &minusone, sizeof (int)); bwrite(nhfp->fd, (genericptr_t) &minusone, sizeof (int));
if (nhfp->fieldlevel) if (nhfp->fieldlevel)
+1 -1
View File
@@ -3762,7 +3762,7 @@ struct opvar *mc;
break; break;
case 0: case 0:
case 1: case 1:
if (levl[x][y].lit == (unsigned int) lit) if (levl[x][y].lit == lit)
selection_setpoint(x, y, ret, 1); selection_setpoint(x, y, ret, 1);
break; break;
} }
+2 -2
View File
@@ -1140,10 +1140,10 @@ struct monst *mtmp;
sent out of his room (caller might resort to goodpos() if sent out of his room (caller might resort to goodpos() if
we report failure here, so this isn't full prevention) */ we report failure here, so this isn't full prevention) */
if (mtmp->isshk && inhishop(mtmp)) { if (mtmp->isshk && inhishop(mtmp)) {
if (levl[x][y].roomno != (unsigned char) ESHK(mtmp)->shoproom) if (levl[x][y].roomno != ESHK(mtmp)->shoproom)
return FALSE; return FALSE;
} else if (mtmp->ispriest && inhistemple(mtmp)) { } else if (mtmp->ispriest && inhistemple(mtmp)) {
if (levl[x][y].roomno != (unsigned char) EPRI(mtmp)->shroom) if (levl[x][y].roomno != EPRI(mtmp)->shroom)
return FALSE; return FALSE;
} }
/* current location is <xx,yy> */ /* current location is <xx,yy> */
-14
View File
@@ -521,9 +521,6 @@ static void NDECL(hup_void_ndecl);
static void FDECL(hup_void_fdecl_int, (int)); static void FDECL(hup_void_fdecl_int, (int));
static void FDECL(hup_void_fdecl_winid, (winid)); static void FDECL(hup_void_fdecl_winid, (winid));
static void FDECL(hup_void_fdecl_constchar_p, (const char *)); static void FDECL(hup_void_fdecl_constchar_p, (const char *));
#ifdef NEW_KEYBOARD_HIT
static boolean NDECL(hup_keyboard_hit);
#endif
static struct window_procs hup_procs = { static struct window_procs hup_procs = {
"hup", 0L, 0L, hup_init_nhwindows, "hup", 0L, 0L, hup_init_nhwindows,
@@ -571,9 +568,6 @@ static struct window_procs hup_procs = {
hup_void_ndecl, /* status_finish */ hup_void_ndecl, /* status_finish */
genl_status_enablefield, hup_status_update, genl_status_enablefield, hup_status_update,
genl_can_suspend_no, genl_can_suspend_no,
#ifdef NEW_KEYBOARD_HIT
hup_keyboard_hit
#endif
}; };
static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0; static void FDECL((*previnterface_exit_nhwindows), (const char *)) = 0;
@@ -628,14 +622,6 @@ hup_nhgetch(VOID_ARGS)
return '\033'; /* ESC */ return '\033'; /* ESC */
} }
#ifdef NEW_KEYBOARD_HIT
static boolean
hup_keyboard_hit(VOID_ARGS)
{
return FALSE;
}
#endif
/*ARGSUSED*/ /*ARGSUSED*/
static char static char
hup_yn_function(prompt, resp, deflt) hup_yn_function(prompt, resp, deflt)
-10
View File
@@ -398,12 +398,10 @@ int mode; // unused
{ {
DWORD cmode; DWORD cmode;
#ifndef NEW_KEYBOARD_HIT
/* Initialize the function pointer that points to /* Initialize the function pointer that points to
* the kbhit() equivalent, in this TTY case nttty_kbhit() * the kbhit() equivalent, in this TTY case nttty_kbhit()
*/ */
nt_kbhit = nttty_kbhit; nt_kbhit = nttty_kbhit;
#endif
if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) { if (!SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE)) {
/* Unable to set control handler */ /* Unable to set control handler */
@@ -438,19 +436,11 @@ int portdebug;
return ch; return ch;
} }
#ifndef NEW_KEYBOARD_HIT
int int
nttty_kbhit() nttty_kbhit()
{ {
return keyboard_handler.pNHkbhit(console.hConIn, &ir); return keyboard_handler.pNHkbhit(console.hConIn, &ir);
} }
#else
boolean
tkbhit()
{
return keyboard_handler.pNHkbhit(console.hConIn, &ir) != 0;
}
#endif
int int
tgetch() tgetch()
+1 -18
View File
@@ -337,7 +337,7 @@ attempt_restore:
resuming = TRUE; /* not starting new game */ resuming = TRUE; /* not starting new game */
if (discover) if (discover)
You("are in non-scoring discovery mode."); You("are in non-scoring discovery mode.");
if ((discover || wizard) && !iflags.fuzzer_auto_start) { if (discover || wizard) {
if (yn("Do you want to keep the save file?") == 'n') if (yn("Do you want to keep the save file?") == 'n')
(void) delete_savefile(); (void) delete_savefile();
else { else {
@@ -462,23 +462,6 @@ char *argv[];
case 'X': case 'X':
discover = TRUE, wizard = FALSE; discover = TRUE, wizard = FALSE;
break; break;
case 'F':
{
iflags.fuzzer_auto_start = 1;
if (argc > 1 && argv[1][0] != '-') {
argc--;
argv++;
iflags.fuzzer_stop_and_save = atoi(*argv);
if (argc > 1 && argv[1][0] != '-') {
argc--;
argv++;
iflags.verbose_logging_start = atoi(*argv);
}
}
}
break;
#ifdef NEWS #ifdef NEWS
case 'n': case 'n':
iflags.news = FALSE; iflags.news = FALSE;
+17 -32
View File
@@ -56,7 +56,6 @@ extern void NDECL(backsp);
int NDECL(windows_console_custom_nhgetch); int NDECL(windows_console_custom_nhgetch);
extern void NDECL(safe_routines); extern void NDECL(safe_routines);
#ifndef NEW_KEYBOARD_HIT
/* The function pointer nt_kbhit contains a kbhit() equivalent /* The function pointer nt_kbhit contains a kbhit() equivalent
* which varies depending on which window port is active. * which varies depending on which window port is active.
* For the tty port it is tty_kbhit() [from nttty.c] * For the tty port it is tty_kbhit() [from nttty.c]
@@ -66,7 +65,6 @@ extern void NDECL(safe_routines);
int def_kbhit(void); int def_kbhit(void);
int (*nt_kbhit)() = def_kbhit; int (*nt_kbhit)() = def_kbhit;
#endif
char char
switchar() switchar()
@@ -160,13 +158,11 @@ max_filename()
return 0; return 0;
} }
#ifndef NEW_KEYBOARD_HIT
int int
def_kbhit() def_kbhit()
{ {
return 0; return 0;
} }
#endif
/* /*
* Strip out troublesome file system characters. * Strip out troublesome file system characters.
@@ -475,6 +471,23 @@ char *buf;
} }
#endif /* RUNTIME_PORT_ID */ #endif /* RUNTIME_PORT_ID */
/* nhassert_failed is called when an nhassert's condition is false */
void nhassert_failed(const char * exp, const char * file, int line)
{
char message[128];
_snprintf(message, sizeof(message),
"NHASSERT(%s) in '%s' at line %d\n", exp, file, line);
if (IsDebuggerPresent()) {
OutputDebugStringA(message);
DebugBreak();
}
// strip off the newline
message[strlen(message) - 1] = '\0';
error(message);
}
void void
nethack_exit(code) nethack_exit(code)
int code; int code;
@@ -499,9 +512,7 @@ int code;
exit(code); exit(code);
} }
#ifndef NEW_KEYBOARD_HIT
#undef kbhit #undef kbhit
#endif
#include <conio.h> #include <conio.h>
int int
@@ -711,32 +722,6 @@ sys_random_seed(VOID_ARGS)
return ourseed; return ourseed;
} }
/* nt_assert_failed is called when an nhassert's condition is false */
void
nt_assert_failed(expression, filepath, line)
const char * expression;
const char * filepath;
int line;
{
const char * filename;
filename = strrchr(filepath, '\\');
filename = (filename == NULL ? filepath : filename + 1);
if (IsDebuggerPresent()) {
char message[BUFSIZ];
snprintf(message, sizeof(message),
"nhassert(%s) failed in file '%s' at line %d",
expression, filename, line);
OutputDebugStringA(message);
DebugBreak();
}
/* get file name from path */
impossible("nhassert(%s) failed in file '%s' at line %d",
expression, filename, line);
}
#endif /* WIN32 */ #endif /* WIN32 */
/*winnt.c*/ /*winnt.c*/
-11
View File
@@ -101,9 +101,6 @@ struct window_procs safe_procs = {
safe_status_update, safe_status_update,
#endif #endif
safe_can_suspend, safe_can_suspend,
#ifdef NEW_KEYBOARD_HIT
safe_keyboard_hit
#endif
}; };
struct window_procs * struct window_procs *
@@ -389,14 +386,6 @@ safe_can_suspend()
return FALSE; return FALSE;
} }
#ifdef NEW_KEYBOARD_HIT
boolean
safe_keyboard_hit()
{
return FALSE;
}
#endif
void void
safe_nhbell() safe_nhbell()
{ {
+3 -3
View File
@@ -52,10 +52,10 @@ getlin_hook_proc hook;
struct WinDesc *cw = wins[WIN_MESSAGE]; struct WinDesc *cw = wins[WIN_MESSAGE];
boolean doprev = 0; boolean doprev = 0;
if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP)) if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
more(); more();
cw->flags &= ~WIN_STOP; cw->flags &= ~WIN_STOP;
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT; ttyDisplay->toplin = 3; /* special prompt state */
ttyDisplay->inread++; ttyDisplay->inread++;
/* issue the prompt */ /* issue the prompt */
@@ -193,7 +193,7 @@ getlin_hook_proc hook;
} else } else
tty_nhbell(); tty_nhbell();
} }
ttyDisplay->toplin = TOPLINE_NON_EMPTY; ttyDisplay->toplin = 2; /* nonempty, no --More-- required */
ttyDisplay->inread--; ttyDisplay->inread--;
clear_nhwindow(WIN_MESSAGE); /* clean up after ourselves */ clear_nhwindow(WIN_MESSAGE); /* clean up after ourselves */
+92 -119
View File
@@ -17,6 +17,8 @@
STATIC_DCL void FDECL(redotoplin, (const char *)); STATIC_DCL void FDECL(redotoplin, (const char *));
STATIC_DCL void FDECL(topl_putsym, (CHAR_P)); STATIC_DCL void FDECL(topl_putsym, (CHAR_P));
STATIC_DCL void FDECL(removetopl, (int)); STATIC_DCL void FDECL(removetopl, (int));
STATIC_DCL void FDECL(msghistory_snapshot, (BOOLEAN_P));
STATIC_DCL void FDECL(free_msghistory_snapshot, (BOOLEAN_P));
int int
tty_doprev_message() tty_doprev_message()
@@ -136,8 +138,8 @@ const char *str;
end_glyphout(); /* in case message printed during graphics output */ end_glyphout(); /* in case message printed during graphics output */
putsyms(str); putsyms(str);
cl_end(); cl_end();
ttyDisplay->toplin = TOPLINE_NEED_MORE; ttyDisplay->toplin = 1;
if (ttyDisplay->cury && otoplin != TOPLINE_SPECIAL_PROMPT) if (ttyDisplay->cury && otoplin != 3)
more(); more();
} }
@@ -149,7 +151,7 @@ const char *str;
struct WinDesc *cw = wins[WIN_MESSAGE]; struct WinDesc *cw = wins[WIN_MESSAGE];
if (!(cw->flags & WIN_STOP)) { if (!(cw->flags & WIN_STOP)) {
if (ttyDisplay->cury && ttyDisplay->toplin == TOPLINE_NON_EMPTY) if (ttyDisplay->cury && ttyDisplay->toplin == 2)
tty_clear_nhwindow(WIN_MESSAGE); tty_clear_nhwindow(WIN_MESSAGE);
cw->curx = cw->cury = 0; cw->curx = cw->cury = 0;
@@ -157,8 +159,8 @@ const char *str;
cl_end(); cl_end();
addtopl(str); addtopl(str);
if (ttyDisplay->cury && ttyDisplay->toplin != TOPLINE_SPECIAL_PROMPT) if (ttyDisplay->cury && ttyDisplay->toplin != 3)
ttyDisplay->toplin = TOPLINE_NON_EMPTY; ttyDisplay->toplin = 2;
} }
} }
@@ -194,7 +196,7 @@ const char *s;
tty_curs(BASE_WINDOW, cw->curx + 1, cw->cury); tty_curs(BASE_WINDOW, cw->curx + 1, cw->cury);
putsyms(s); putsyms(s);
cl_end(); cl_end();
ttyDisplay->toplin = TOPLINE_NEED_MORE; ttyDisplay->toplin = 1;
} }
void void
@@ -202,15 +204,12 @@ more()
{ {
struct WinDesc *cw = wins[WIN_MESSAGE]; struct WinDesc *cw = wins[WIN_MESSAGE];
/* avoid recursion -- only happens from interrupts */
if (ttyDisplay->inmore++)
return;
if (iflags.debug_fuzzer) if (iflags.debug_fuzzer)
return; return;
/* avoid recursion -- only happens from interrupts */
if (ttyDisplay->inmore)
return;
ttyDisplay->inmore++;
if (ttyDisplay->toplin) { if (ttyDisplay->toplin) {
tty_curs(BASE_WINDOW, cw->curx + 1, cw->cury); tty_curs(BASE_WINDOW, cw->curx + 1, cw->cury);
if (cw->curx >= CO - 8) if (cw->curx >= CO - 8)
@@ -237,7 +236,7 @@ more()
home(); home();
cl_end(); cl_end();
} }
ttyDisplay->toplin = TOPLINE_EMPTY; ttyDisplay->toplin = 0;
ttyDisplay->inmore = 0; ttyDisplay->inmore = 0;
} }
@@ -253,11 +252,10 @@ register const char *bp;
/* If there is room on the line, print message on same line */ /* If there is room on the line, print message on same line */
/* But messages like "You die..." deserve their own line */ /* But messages like "You die..." deserve their own line */
n0 = strlen(bp); n0 = strlen(bp);
if ((ttyDisplay->toplin == TOPLINE_NEED_MORE || (cw->flags & WIN_STOP)) if ((ttyDisplay->toplin == 1 || (cw->flags & WIN_STOP))
&& cw->cury == 0 && cw->cury == 0
&& n0 + (int) strlen(g.toplines) + 3 < CO - 8 /* room for --More-- */ && n0 + (int) strlen(g.toplines) + 3 < CO - 8 /* room for --More-- */
&& (notdied = strncmp(bp, "You die", 7)) != 0) { && (notdied = strncmp(bp, "You die", 7)) != 0) {
/* nhassert((long) strlen(g.toplines) == cw->curx); */
Strcat(g.toplines, " "); Strcat(g.toplines, " ");
Strcat(g.toplines, bp); Strcat(g.toplines, bp);
cw->curx += 2; cw->curx += 2;
@@ -265,9 +263,9 @@ register const char *bp;
addtopl(bp); addtopl(bp);
return; return;
} else if (!(cw->flags & WIN_STOP)) { } else if (!(cw->flags & WIN_STOP)) {
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) { if (ttyDisplay->toplin == 1) {
more(); more();
} else if (cw->cury) { /* for toplin == TOPLINE_NON_EMPTY && cury > 1 */ } else if (cw->cury) { /* for when flags.toplin == 2 && cury > 1 */
docorner(1, cw->cury + 1); /* reset cury = 0 if redraw screen */ docorner(1, cw->cury + 1); /* reset cury = 0 if redraw screen */
cw->curx = cw->cury = 0; /* from home--cls() & docorner(1,n) */ cw->curx = cw->cury = 0; /* from home--cls() & docorner(1,n) */
} }
@@ -311,7 +309,6 @@ char c;
if (ttyDisplay->curx == 0 && ttyDisplay->cury > 0) if (ttyDisplay->curx == 0 && ttyDisplay->cury > 0)
tty_curs(BASE_WINDOW, CO, (int) ttyDisplay->cury - 1); tty_curs(BASE_WINDOW, CO, (int) ttyDisplay->cury - 1);
backsp(); backsp();
nhassert(ttyDisplay->curx > 0);
ttyDisplay->curx--; ttyDisplay->curx--;
cw->curx = ttyDisplay->curx; cw->curx = ttyDisplay->curx;
return; return;
@@ -384,10 +381,10 @@ char def;
char prompt[BUFSZ]; char prompt[BUFSZ];
yn_number = 0L; yn_number = 0L;
if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP)) if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
more(); more();
cw->flags &= ~WIN_STOP; cw->flags &= ~WIN_STOP;
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT; ttyDisplay->toplin = 3; /* special prompt state */
ttyDisplay->inread++; ttyDisplay->inread++;
if (resp) { if (resp) {
char *rb, respbuf[QBUFSZ]; char *rb, respbuf[QBUFSZ];
@@ -534,7 +531,7 @@ char def;
dumplogmsg(g.toplines); dumplogmsg(g.toplines);
#endif #endif
ttyDisplay->inread--; ttyDisplay->inread--;
ttyDisplay->toplin = TOPLINE_NON_EMPTY; ttyDisplay->toplin = 2;
if (ttyDisplay->intr) if (ttyDisplay->intr)
ttyDisplay->intr--; ttyDisplay->intr--;
if (wins[WIN_MESSAGE]->cury) if (wins[WIN_MESSAGE]->cury)
@@ -543,66 +540,78 @@ char def;
return q; return q;
} }
STATIC_OVL ptr_array_t * /* shared by tty_getmsghistory() and tty_putmsghistory() */
get_message_history() static char **snapshot_mesgs = 0;
/* collect currently available message history data into a sequential array;
optionally, purge that data from the active circular buffer set as we go */
STATIC_OVL void
msghistory_snapshot(purge)
boolean purge; /* clear message history buffer as we copy it */
{ {
char *mesg; char *mesg;
int i; int i, inidx, outidx;
struct WinDesc *cw; struct WinDesc *cw;
size_t max_length;
ptr_array_t * a;
nhassert(WIN_MESSAGE != WIN_ERR);
nhassert(wins[WIN_MESSAGE] != NULL);
/* paranoia (too early or too late panic save attempt?) */ /* paranoia (too early or too late panic save attempt?) */
if (WIN_MESSAGE == WIN_ERR || !wins[WIN_MESSAGE]) if (WIN_MESSAGE == WIN_ERR || !wins[WIN_MESSAGE])
return NULL; return;
cw = wins[WIN_MESSAGE]; cw = wins[WIN_MESSAGE];
max_length = cw->rows; /* flush g.toplines[], moving most recent message to history */
remember_topl();
if (*g.toplines) max_length++; /* for a passive snapshot, we just copy pointers, so can't allow further
history updating to take place because that could clobber them */
if (!purge)
cw->flags |= WIN_LOCKHISTORY;
a = ptr_array_new(max_length); snapshot_mesgs = (char **) alloc((cw->rows + 1) * sizeof(char *));
outidx = 0;
nhassert(cw->maxrow <= cw->rows); inidx = cw->maxrow;
for (i = 0; i < cw->rows; ++i) { for (i = 0; i < cw->rows; ++i) {
mesg = cw->data[(i + cw->maxrow) % cw->rows]; snapshot_mesgs[i] = (char *) 0;
if (mesg && *mesg) mesg = cw->data[inidx];
a->elements[a->length++] = strdup(mesg); if (mesg && *mesg) {
} snapshot_mesgs[outidx++] = mesg;
if (*g.toplines) if (purge) {
a->elements[a->length++] = strdup(g.toplines); /* we're taking this pointer away; subsequest history
updates will eventually allocate a new one to replace it */
return a; cw->data[inidx] = (char *) 0;
} cw->datlen[inidx] = 0;
STATIC_OVL void
purge_message_history()
{
int i;
struct WinDesc *cw;
nhassert(WIN_MESSAGE != WIN_ERR);
nhassert(wins[WIN_MESSAGE] != NULL);
cw = wins[WIN_MESSAGE];
*g.toplines = '\0';
for (i = 0; i < cw->rows; ++i) {
if (cw->data[i]) {
free(cw->data[i]);
cw->data[i] = (char *) 0;
cw->datlen[i] = 0;
} }
} }
inidx = (inidx + 1) % cw->rows;
}
snapshot_mesgs[cw->rows] = (char *) 0; /* sentinel */
/* for a destructive snapshot, history is now completely empty */
if (purge)
cw->maxcol = cw->maxrow = 0; cw->maxcol = cw->maxrow = 0;
} }
/* release memory allocated to message history snapshot */
STATIC_OVL void
free_msghistory_snapshot(purged)
boolean purged; /* True: took history's pointers, False: just cloned them */
{
if (snapshot_mesgs) {
/* snapshot pointers are no longer in use */
if (purged) {
int i;
for (i = 0; snapshot_mesgs[i]; ++i)
free((genericptr_t) snapshot_mesgs[i]);
}
free((genericptr_t) snapshot_mesgs), snapshot_mesgs = (char **) 0;
/* history can resume being updated at will now... */
if (!purged)
wins[WIN_MESSAGE]->flags &= ~WIN_LOCKHISTORY;
}
}
/* /*
* This is called by the core save routines. * This is called by the core save routines.
* Each time we are called, we return one string from the * Each time we are called, we return one string from the
@@ -617,25 +626,21 @@ char *
tty_getmsghistory(init) tty_getmsghistory(init)
boolean init; boolean init;
{ {
static size_t nxtidx; static int nxtidx;
static ptr_array_t * saved_messages = NULL; char *nextmesg;
char *result = NULL; char *result = 0;
if (init) { if (init) {
nhassert(saved_messages == NULL); msghistory_snapshot(FALSE);
saved_messages = get_message_history();
nxtidx = 0; nxtidx = 0;
wins[WIN_MESSAGE]->flags |= WIN_LOCKHISTORY;
} }
if (saved_messages) { if (snapshot_mesgs) {
if (nxtidx < saved_messages->length) nextmesg = snapshot_mesgs[nxtidx++];
result = saved_messages->elements[nxtidx++]; if (nextmesg) {
result = (char *) nextmesg;
if (result == NULL) { } else {
ptr_array_free(saved_messages); free_msghistory_snapshot(FALSE);
saved_messages = NULL;
wins[WIN_MESSAGE]->flags &= ~WIN_LOCKHISTORY;
} }
} }
return result; return result;
@@ -664,10 +669,7 @@ const char *msg;
boolean restoring_msghist; boolean restoring_msghist;
{ {
static boolean initd = FALSE; static boolean initd = FALSE;
static ptr_array_t * saved_messages = NULL; int idx;
size_t i;
nhassert(!(wins[WIN_MESSAGE]->flags & WIN_LOCKHISTORY));
if (restoring_msghist && !initd) { if (restoring_msghist && !initd) {
/* we're restoring history from the previous session, but new /* we're restoring history from the previous session, but new
@@ -675,9 +677,7 @@ boolean restoring_msghist;
for instance); collect current history (ie, those new messages), for instance); collect current history (ie, those new messages),
and also clear it out so that nothing will be present when the and also clear it out so that nothing will be present when the
restored ones are being put into place */ restored ones are being put into place */
nhassert(saved_messages == NULL); msghistory_snapshot(TRUE);
saved_messages = get_message_history();
purge_message_history();
initd = TRUE; initd = TRUE;
#ifdef DUMPLOG #ifdef DUMPLOG
/* this suffices; there's no need to scrub saved_pline[] pointers */ /* this suffices; there's no need to scrub saved_pline[] pointers */
@@ -686,52 +686,25 @@ boolean restoring_msghist;
} }
if (msg) { if (msg) {
/* Caller is asking us to remember a top line that needed more.
Should we call more? This can happen when the player has set
iflags.force_invmenu and they attempt to shoot with nothing in
the quiver. */
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE)
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
/* move most recent message to history, make this become most recent */ /* move most recent message to history, make this become most recent */
remember_topl(); remember_topl();
Strcpy(g.toplines, msg); Strcpy(g.toplines, msg);
#ifdef DUMPLOG #ifdef DUMPLOG
dumplogmsg(g.toplines); dumplogmsg(g.toplines);
#endif #endif
return; } else if (snapshot_mesgs) {
} /* done putting arbitrary messages in; put the snapshot ones back */
for (idx = 0; snapshot_mesgs[idx]; ++idx) {
/* tty_putmsghistory() is called with msg==NULL to indidate that
* we are finished restoring the message history. If we saved
* some message history when we started, its time now to appened
* those saved messages.
*
* We don't otherwise expect to get called with msg==NULL.
*
*/
nhassert(restoring_msghist && initd);
if (initd && restoring_msghist) {
if (saved_messages) {
nhassert(ttyDisplay == NULL ||
ttyDisplay->toplin != TOPLINE_NEED_MORE);
for (i = 0; i < saved_messages->length; i++) {
const char * mesg = saved_messages->elements[i];
remember_topl(); remember_topl();
nhassert(mesg); Strcpy(g.toplines, snapshot_mesgs[idx]);
Strcpy(g.toplines, mesg);
#ifdef DUMPLOG #ifdef DUMPLOG
dumplogmsg(g.toplines); dumplogmsg(g.toplines);
#endif #endif
} }
ptr_array_free(saved_messages); /* now release the snapshot */
saved_messages = NULL; free_msghistory_snapshot(TRUE);
initd = FALSE; /* reset */
} }
initd = FALSE;
}
} }
#endif /* TTY_GRAPHICS */ #endif /* TTY_GRAPHICS */
+19 -122
View File
@@ -36,12 +36,6 @@ extern void msmsg(const char *, ...);
#endif #endif
#endif #endif
#ifdef NEW_KEYBOARD_HIT
#if defined(UNIX)
#include <fcntl.h>
#endif
#endif
#ifdef TTY_TILES_ESCCODES #ifdef TTY_TILES_ESCCODES
extern short glyph2tile[]; extern short glyph2tile[];
#define TILE_ANSI_COMMAND 'z' #define TILE_ANSI_COMMAND 'z'
@@ -137,9 +131,6 @@ struct window_procs tty_procs = {
genl_status_update, genl_status_update,
#endif #endif
genl_can_suspend_yes, genl_can_suspend_yes,
#ifdef NEW_KEYBOARD_HIT
tty_keyboard_hit
#endif
}; };
static int maxwin = 0; /* number of windows in use */ static int maxwin = 0; /* number of windows in use */
@@ -330,7 +321,7 @@ int sig_unused UNUSED;
new_status_window(); new_status_window();
if (u.ux) { if (u.ux) {
i = ttyDisplay->toplin; i = ttyDisplay->toplin;
ttyDisplay->toplin = TOPLINE_EMPTY; ttyDisplay->toplin = 0;
docrt(); docrt();
bot(); bot();
ttyDisplay->toplin = i; ttyDisplay->toplin = i;
@@ -418,7 +409,7 @@ char **argv UNUSED;
/* set up tty descriptor */ /* set up tty descriptor */
ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc)); ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
ttyDisplay->toplin = TOPLINE_EMPTY; ttyDisplay->toplin = 0;
ttyDisplay->rows = hgt; ttyDisplay->rows = hgt;
ttyDisplay->cols = wid; ttyDisplay->cols = wid;
ttyDisplay->curx = ttyDisplay->cury = 0; ttyDisplay->curx = ttyDisplay->cury = 0;
@@ -1619,12 +1610,12 @@ winid window;
switch (cw->type) { switch (cw->type) {
case NHW_MESSAGE: case NHW_MESSAGE:
if (ttyDisplay->toplin != TOPLINE_EMPTY) { if (ttyDisplay->toplin) {
home(); home();
cl_end(); cl_end();
if (cw->cury) if (cw->cury)
docorner(1, cw->cury + 1); docorner(1, cw->cury + 1);
ttyDisplay->toplin = TOPLINE_EMPTY; ttyDisplay->toplin = 0;
} }
break; break;
case NHW_STATUS: case NHW_STATUS:
@@ -2315,13 +2306,12 @@ boolean blocking; /* with ttys, all windows are blocking */
switch (cw->type) { switch (cw->type) {
case NHW_MESSAGE: case NHW_MESSAGE:
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) { if (ttyDisplay->toplin == 1) {
more(); more();
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */ ttyDisplay->toplin = 1; /* more resets this */
tty_clear_nhwindow(window); tty_clear_nhwindow(window);
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
} else } else
ttyDisplay->toplin = TOPLINE_EMPTY; ttyDisplay->toplin = 0;
cw->curx = cw->cury = 0; cw->curx = cw->cury = 0;
if (!cw->active) if (!cw->active)
iflags.window_inited = TRUE; iflags.window_inited = TRUE;
@@ -2329,8 +2319,8 @@ boolean blocking; /* with ttys, all windows are blocking */
case NHW_MAP: case NHW_MAP:
end_glyphout(); end_glyphout();
if (blocking) { if (blocking) {
if (ttyDisplay->toplin != TOPLINE_EMPTY) if (!ttyDisplay->toplin)
ttyDisplay->toplin = TOPLINE_NEED_MORE; ttyDisplay->toplin = 1;
tty_display_nhwindow(WIN_MESSAGE, TRUE); tty_display_nhwindow(WIN_MESSAGE, TRUE);
return; return;
} }
@@ -2360,7 +2350,7 @@ boolean blocking; /* with ttys, all windows are blocking */
cw->offx = 0; cw->offx = 0;
if (cw->type == NHW_MENU) if (cw->type == NHW_MENU)
cw->offy = 0; cw->offy = 0;
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) if (ttyDisplay->toplin == 1)
tty_display_nhwindow(WIN_MESSAGE, TRUE); tty_display_nhwindow(WIN_MESSAGE, TRUE);
#ifdef H2344_BROKEN #ifdef H2344_BROKEN
if (cw->maxrow >= (int) ttyDisplay->rows if (cw->maxrow >= (int) ttyDisplay->rows
@@ -2376,7 +2366,7 @@ boolean blocking; /* with ttys, all windows are blocking */
cl_eos(); cl_eos();
} else } else
clear_screen(); clear_screen();
ttyDisplay->toplin = TOPLINE_EMPTY; ttyDisplay->toplin = 0;
} else { } else {
if (WIN_MESSAGE != WIN_ERR) if (WIN_MESSAGE != WIN_ERR)
tty_clear_nhwindow(WIN_MESSAGE); tty_clear_nhwindow(WIN_MESSAGE);
@@ -2405,9 +2395,8 @@ winid window;
switch (cw->type) { switch (cw->type) {
case NHW_MESSAGE: case NHW_MESSAGE:
if (ttyDisplay->toplin != TOPLINE_EMPTY) if (ttyDisplay->toplin)
tty_display_nhwindow(WIN_MESSAGE, TRUE); tty_display_nhwindow(WIN_MESSAGE, TRUE);
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
/*FALLTHRU*/ /*FALLTHRU*/
case NHW_STATUS: case NHW_STATUS:
case NHW_BASE: case NHW_BASE:
@@ -3158,11 +3147,10 @@ const char *mesg;
response to a prompt, we'll assume that the display is up to date */ response to a prompt, we'll assume that the display is up to date */
tty_putstr(WIN_MESSAGE, 0, mesg); tty_putstr(WIN_MESSAGE, 0, mesg);
/* if `mesg' didn't wrap (triggering --More--), force --More-- now */ /* if `mesg' didn't wrap (triggering --More--), force --More-- now */
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) { if (ttyDisplay->toplin == 1) {
more(); more();
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */ ttyDisplay->toplin = 1; /* more resets this */
tty_clear_nhwindow(WIN_MESSAGE); tty_clear_nhwindow(WIN_MESSAGE);
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
} }
/* normally <ESC> means skip further messages, but in this case /* normally <ESC> means skip further messages, but in this case
it means cancel the current prompt; any other messages should it means cancel the current prompt; any other messages should
@@ -3202,7 +3190,7 @@ tty_wait_synch()
(void) fflush(stdout); (void) fflush(stdout);
} else if (ttyDisplay->inread > g.program_state.gameover) { } else if (ttyDisplay->inread > g.program_state.gameover) {
/* this can only happen if we were reading and got interrupted */ /* this can only happen if we were reading and got interrupted */
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT; ttyDisplay->toplin = 3;
/* do this twice; 1st time gets the Quit? message again */ /* do this twice; 1st time gets the Quit? message again */
(void) tty_doprev_message(); (void) tty_doprev_message();
(void) tty_doprev_message(); (void) tty_doprev_message();
@@ -3489,7 +3477,6 @@ const char *str;
#endif #endif
} }
#ifndef NEW_KEYBOARD_HIT
int int
tty_nhgetch() tty_nhgetch()
{ {
@@ -3531,9 +3518,8 @@ tty_nhgetch()
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */ i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
else if (i == EOF) else if (i == EOF)
i = '\033'; /* same for EOF */ i = '\033'; /* same for EOF */
/* topline has been seen - we can clear need for more */ if (ttyDisplay && ttyDisplay->toplin == 1)
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE) ttyDisplay->toplin = 2;
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
#ifdef TTY_TILES_ESCCODES #ifdef TTY_TILES_ESCCODES
{ {
/* hack to force output of the window select code */ /* hack to force output of the window select code */
@@ -3545,94 +3531,6 @@ tty_nhgetch()
#endif /* TTY_TILES_ESCCODES */ #endif /* TTY_TILES_ESCCODES */
return i; return i;
} }
#else /* NEW_KEYBOARD_HIT */
#ifdef UNIX
static boolean stdin_non_blocking = FALSE;
int
tgetch()
{
static volatile int nesting = 0;
int i;
char nestbuf;
if (stdin_non_blocking) {
fcntl(0, F_SETFL, fcntl(0, F_GETFL) & ~O_NONBLOCK);
stdin_non_blocking = FALSE;
}
/* kludge alert: Some Unix variants return funny values if getc()
* is called, interrupted, and then called again. There
* is non-reentrant code in the internal _filbuf() routine, called by
* getc().
*/
i = (++nesting == 1)
? getchar()
: (read(fileno(stdin), (genericptr_t) &nestbuf, 1) == 1)
? (int) nestbuf : EOF;
--nesting;
return i;
}
boolean
tkbhit()
{
int i;
if (!stdin_non_blocking) {
fcntl(0, F_SETFL, fcntl(0, F_GETFL) | O_NONBLOCK);
stdin_non_blocking = TRUE;
}
i = getchar();
if (i != EOF) ungetc(i, stdin);
return (i != EOF);
}
#endif
int
tty_nhgetch()
{
int i;
HUPSKIP_RESULT('\033');
print_vt_code1(AVTC_INLINE_SYNC);
(void) fflush(stdout);
/* Note: if raw_print() and wait_synch() get called to report terminal
* initialization problems, then wins[] and ttyDisplay might not be
* available yet. Such problems will probably be fatal before we get
* here, but validate those pointers just in case...
*/
if (WIN_MESSAGE != WIN_ERR && wins[WIN_MESSAGE])
wins[WIN_MESSAGE]->flags &= ~WIN_STOP;
if (iflags.debug_fuzzer) {
i = randomkey();
} else {
i = tgetch();
}
if (!i)
i = '\033'; /* map NUL to ESC since nethack doesn't expect NUL */
else if (i == EOF)
i = '\033'; /* same for EOF */
/* topline has been seen - we can clear need for more */
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE)
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
#ifdef TTY_TILES_ESCCODES
{
/* hack to force output of the window select code */
int tmp = vt_tile_current_window;
vt_tile_current_window++;
print_vt_code2(AVTC_SELECT_WINDOW, tmp);
}
#endif /* TTY_TILES_ESCCODES */
return i;
}
boolean tty_keyboard_hit()
{
/* tgetch provider needs to also provide tkbhit() */
return tkbhit();
}
#endif /* NEW_KEYBOARD_HIT */
/* /*
* return a key, or 0, in which case a mouse button was pressed * return a key, or 0, in which case a mouse button was pressed
@@ -3659,9 +3557,8 @@ int *x, *y, *mod;
i = ntposkey(x, y, mod); i = ntposkey(x, y, mod);
if (!i && mod && (*mod == 0 || *mod == EOF)) if (!i && mod && (*mod == 0 || *mod == EOF))
i = '\033'; /* map NUL or EOF to ESC, nethack doesn't expect either */ i = '\033'; /* map NUL or EOF to ESC, nethack doesn't expect either */
/* topline has been seen - we can clear need for more */ if (ttyDisplay && ttyDisplay->toplin == 1)
if (ttyDisplay && ttyDisplay->toplin == TOPLINE_NEED_MORE) ttyDisplay->toplin = 2;
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
#else /* !WIN32CON */ #else /* !WIN32CON */
nhUse(x); nhUse(x);
nhUse(y); nhUse(y);
-12
View File
@@ -116,9 +116,6 @@ struct window_procs mswin_procs = {
mswin_status_init, mswin_status_finish, mswin_status_enablefield, mswin_status_init, mswin_status_finish, mswin_status_enablefield,
mswin_status_update, mswin_status_update,
genl_can_suspend_yes, genl_can_suspend_yes,
#ifdef NEW_KEYBOARD_HIT
mswin_keyboard_hit
#endif
}; };
/* /*
@@ -1405,15 +1402,6 @@ mswin_nhgetch()
return (key); return (key);
} }
#ifdef NEW_KEYBOARD_HIT
/* boolean keyboard_hit() -- returns TRUE if input is available */
boolean
mswin_keyboard_hit()
{
return mswin_have_input() != 0;
}
#endif
/* /*
int nh_poskey(int *x, int *y, int *mod) int nh_poskey(int *x, int *y, int *mod)
-- Returns a single character input from the user or a -- Returns a single character input from the user or a
-8
View File
@@ -1,8 +0,0 @@
set BIN_DIR=..\..\..\..\bin\Debug\Win32
set FUZZER_LOG=%BIN_DIR%\fuzzer.log
set FUZZER_DIR=%BIN_DIR%\fuzzer
if exist %BIN_DIR%\%USERNAME%* del %BIN_DIR%\%USERNAME%*
if exist %FUZZER_LOG% del %FUZZER_LOG%
-36
View File
@@ -1,36 +0,0 @@
echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set STEP_SIZE=5000
set FINAL_MOVE=500000
set START_MOVE=5000
set BIN_DIR=..\..\..\..\bin\Debug\Win32
set SAVED_GAME=%USERNAME%-wizard.NetHack-saved-game
set LOG_FILE=%BIN_DIR%\runtil.log
set FUZZER_LOG=%BIN_DIR%\fuzzer.log
set FUZZER_DIR=%BIN_DIR%\fuzzer
set SAVE_DIR=%FUZZER_DIR%\save
set BASELINE=%FUZZER_DIR%\fuzzer.log
if exist %FUZZER_DIR% rmdir /s /q %FUZZER_DIR%
mkdir %FUZZER_DIR%
mkdir %SAVE_DIR%
for /L %%i in (%START_MOVE%, %STEP_SIZE%, %FINAL_MOVE%) do (
call runtill.bat %%i
if ERRORLEVEL 1 (
echo FAILED getting running to %%i.
exit /b 1
)
)
echo SUCCESS.
-7
View File
@@ -1,7 +0,0 @@
call clean.bat
set BIN_DIR=..\..\..\..\bin\Debug\Win32
set SAVED_GAME=%USERNAME%-wizard.NetHack-saved-game
set FUZZER_DIR=%BIN_DIR%\fuzzer
copy %FUZZER_DIR%\%SAVED_GAME% %BIN_DIR%\%SAVED_GAME%
-77
View File
@@ -1,77 +0,0 @@
REM
REM runtill target_move
REM
echo off
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
set TARGET_MOVE=%1
if %TARGET_MOVE% == "" (
echo Usage:runtill target_move
goto :eof
)
set BIN_DIR=..\..\..\..\bin\Debug\Win32
set SAVED_GAME=%USERNAME%-wizard.NetHack-saved-game
set LOG_FILE=%BIN_DIR%\runtil.log
set FUZZER_LOG=%BIN_DIR%\fuzzer.log
set FUZZER_DIR=%BIN_DIR%\fuzzer
set SAVE_DIR=%FUZZER_DIR%\save
set BASELINE=%FUZZER_DIR%\fuzzer.log
if not exist %FUZZER_DIR% mkdir %FUZZER_DIR%
if not exist %SAVE_DIR% mkdir %SAVE_DIR%
call clean.bat
if not exist %FUZZER_DIR%\%SAVED_GAME% (
%BIN_DIR%\nethack -D -F 0
copy %BIN_DIR%\%SAVED_GAME% %FUZZER_DIR%
copy %BIN_DIR%\%SAVED_GAME% %SAVE_DIR%\0.save
)
call restore.bat
%BIN_DIR%\nethack -D -F %TARGET_MOVE%
move %BIN_DIR%\*.snap %BIN_DIR%\snapshots
copy %FUZZER_LOG% %BASELINE%
for /f "tokens=2,3 delims=: usebackq" %%i in (`findstr /c:START %BASELINE%`) do (
set START_SEED=%%j
set START_MOVE=%%i
)
for /f "tokens=2,3 delims=: usebackq" %%i in (`findstr /c:STOP %BASELINE%`) do (
set STOP_SEED=%%j
set STOP_MOVE=%%i
)
if !STOP_MOVE! LSS %TARGET_MOVE% (
cls
echo FAILED: Failed to reach target move. !STOP_MOVE! is not GTE %TARGET_MOVE%.
exit /b 1
)
call restore.bat
%BIN_DIR%\nethack -D -F %TARGET_MOVE%
fc %FUZZER_LOG% %BASELINE%
if ERRORLEVEL 1 (
cls
echo FAILED: Unable to reproduce same timeline
exit /b 1
)
del /q %FUZZER_DIR%\%SAVED_GAME%
copy %BIN_DIR%\%SAVED_GAME% %FUZZER_DIR%
copy %BIN_DIR%\%SAVED_GAME% %SAVE_DIR%\!STOP_MOVE!.save
echo !START_MOVE! to !STOP_MOVE!.
echo SUCCESS.
-3
View File
@@ -167,9 +167,6 @@ void mswin_raw_print(const char *str);
void mswin_raw_print_bold(const char *str); void mswin_raw_print_bold(const char *str);
void mswin_raw_print_flush(); void mswin_raw_print_flush();
int mswin_nhgetch(void); int mswin_nhgetch(void);
#ifdef NEW_KEYBOARD_HIT
boolean mswin_keyboard_hit(void);
#endif
int mswin_nh_poskey(int *x, int *y, int *mod); int mswin_nh_poskey(int *x, int *y, int *mod);
void mswin_nhbell(void); void mswin_nhbell(void);
int mswin_doprev_message(void); int mswin_doprev_message(void);