Merge branch 'NetHack-3.6'
# Conflicts: # include/extern.h # src/allmain.c # win/tty/topl.c
This commit is contained in:
@@ -28,10 +28,7 @@ E void FDECL(welcome, (BOOLEAN_P));
|
||||
E time_t NDECL(get_realtime);
|
||||
E int FDECL(argcheck, (int, char **, enum earlyarg));
|
||||
E void NDECL(early_init);
|
||||
E void NDECL(fuzzer_start);
|
||||
E void NDECL(fuzzer_stop);
|
||||
E void NDECL(fuzzer_toggle);
|
||||
E void VDECL(fuzzer_log, (int, const char *, ...)) PRINTF_F(2, 3);
|
||||
E void NDECL(fuzzer_check);
|
||||
E void NDECL(fuzzer_auto_start);
|
||||
E boolean FDECL(fuzzer_msg_history, (const char *));
|
||||
@@ -1942,6 +1939,9 @@ E void VDECL(raw_printf, (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 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 ### */
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
/* various code that was replicated in *main.c */
|
||||
#define NEED_VARARGS
|
||||
#include "hack.h"
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -932,38 +931,6 @@ const char *opts;
|
||||
return;
|
||||
}
|
||||
|
||||
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_toggle() toggles fuzzer state */
|
||||
void
|
||||
fuzzer_toggle()
|
||||
@@ -974,29 +941,6 @@ fuzzer_toggle()
|
||||
fuzzer_start();
|
||||
}
|
||||
|
||||
/* 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, level, const char *, str)
|
||||
{
|
||||
VA_START(str);
|
||||
VA_INIT(str, char *);
|
||||
|
||||
if (!g_fuzzer_log_file)
|
||||
return;
|
||||
|
||||
if (iflags.verbose_logging_start != 0 && g.moves >= iflags.verbose_logging_start)
|
||||
g_fuzzer_log_level = LOG_VERBOSE;
|
||||
|
||||
if (level <= g_fuzzer_log_level)
|
||||
Vfprintf(g_fuzzer_log_file, str, VA_ARGS);
|
||||
|
||||
VA_END();
|
||||
}
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
@@ -1005,6 +949,7 @@ fuzzer_check()
|
||||
{
|
||||
if (iflags.debug_fuzzer)
|
||||
{
|
||||
unsigned long seed;
|
||||
if (g.moves >= iflags.fuzzer_stop_and_save) {
|
||||
iflags.fuzzer_saving = TRUE;
|
||||
dosave0();
|
||||
@@ -1013,7 +958,7 @@ fuzzer_check()
|
||||
nh_terminate(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
unsigned long seed = rul();
|
||||
seed = rul();
|
||||
set_random(seed, rn2);
|
||||
fuzzer_log(LOG_MINIMAL, "SEED:%ld:%lu\n", g.moves, seed);
|
||||
|
||||
@@ -1027,9 +972,10 @@ void
|
||||
fuzzer_auto_start()
|
||||
{
|
||||
if (iflags.fuzzer_auto_start) {
|
||||
unsigned long seed;
|
||||
nhassert(!iflags.debug_fuzzer);
|
||||
fuzzer_start();
|
||||
unsigned long seed = rul();
|
||||
seed = rul();
|
||||
set_random(seed, rn2);
|
||||
fuzzer_log(LOG_MINIMAL, "START:%ld:%lu\n", g.moves, seed);
|
||||
}
|
||||
|
||||
57
src/pline.c
57
src/pline.c
@@ -589,4 +589,61 @@ nhassert_failed(filepath, line)
|
||||
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*/
|
||||
|
||||
@@ -62,7 +62,7 @@ rul()
|
||||
unsigned long value;
|
||||
|
||||
value = (unsigned long) isaac64_next_uint64(&rnglist[CORE].rng_state);
|
||||
fuzzer_log(LOG_VERBOSE, "RANDOM:%llu\n", value);
|
||||
fuzzer_log(LOG_VERBOSE, "RANDOM:%lu\n", value);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -3742,7 +3742,7 @@ struct opvar *mc;
|
||||
{
|
||||
int x, y;
|
||||
schar mapc;
|
||||
uchar lit;
|
||||
xchar lit;
|
||||
struct opvar *ret = selection_opvar((char *) 0);
|
||||
|
||||
if (!ov || !mc || !ret)
|
||||
@@ -3762,7 +3762,7 @@ struct opvar *mc;
|
||||
break;
|
||||
case 0:
|
||||
case 1:
|
||||
if (levl[x][y].lit == lit)
|
||||
if (levl[x][y].lit == (unsigned int) lit)
|
||||
selection_setpoint(x, y, ret, 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
STATIC_DCL void FDECL(redotoplin, (const char *));
|
||||
STATIC_DCL void FDECL(topl_putsym, (CHAR_P));
|
||||
STATIC_DCL void FDECL(removetopl, (int));
|
||||
STATIC_DCL void FDECL(msghistory_snapshot, (BOOLEAN_P));
|
||||
STATIC_DCL void FDECL(free_msghistory_snapshot, (BOOLEAN_P));
|
||||
|
||||
int
|
||||
tty_doprev_message()
|
||||
@@ -545,78 +543,6 @@ char def;
|
||||
return q;
|
||||
}
|
||||
|
||||
/* shared by tty_getmsghistory() and tty_putmsghistory() */
|
||||
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;
|
||||
int i, inidx, outidx;
|
||||
struct WinDesc *cw;
|
||||
|
||||
/* paranoia (too early or too late panic save attempt?) */
|
||||
if (WIN_MESSAGE == WIN_ERR || !wins[WIN_MESSAGE])
|
||||
return;
|
||||
cw = wins[WIN_MESSAGE];
|
||||
|
||||
/* flush g.toplines[], moving most recent message to history */
|
||||
remember_topl();
|
||||
|
||||
/* 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;
|
||||
|
||||
snapshot_mesgs = (char **) alloc((cw->rows + 1) * sizeof(char *));
|
||||
outidx = 0;
|
||||
inidx = cw->maxrow;
|
||||
for (i = 0; i < cw->rows; ++i) {
|
||||
snapshot_mesgs[i] = (char *) 0;
|
||||
mesg = cw->data[inidx];
|
||||
if (mesg && *mesg) {
|
||||
snapshot_mesgs[outidx++] = mesg;
|
||||
if (purge) {
|
||||
/* we're taking this pointer away; subsequest history
|
||||
updates will eventually allocate a new one to replace it */
|
||||
cw->data[inidx] = (char *) 0;
|
||||
cw->datlen[inidx] = 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;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}
|
||||
|
||||
STATIC_OVL ptr_array_t *
|
||||
get_message_history()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user