Merge branch 'master' into NetHack-3.7
# Conflicts: # src/pline.c # sys/winnt/windmain.c # win/tty/topl.c # win/win32/scripts/fuzzer/longtest.bat # win/win32/scripts/fuzzer/restore.bat # win/win32/scripts/fuzzer/runtill.bat
This commit is contained in:
@@ -101,9 +101,6 @@ struct window_procs safe_procs = {
|
||||
safe_status_update,
|
||||
#endif
|
||||
safe_can_suspend,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
safe_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
struct window_procs *
|
||||
@@ -389,14 +386,6 @@ safe_can_suspend()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
boolean
|
||||
safe_keyboard_hit()
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
safe_nhbell()
|
||||
{
|
||||
|
||||
@@ -52,10 +52,10 @@ getlin_hook_proc hook;
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
boolean doprev = 0;
|
||||
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP))
|
||||
if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
|
||||
more();
|
||||
cw->flags &= ~WIN_STOP;
|
||||
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT;
|
||||
ttyDisplay->toplin = 3; /* special prompt state */
|
||||
ttyDisplay->inread++;
|
||||
|
||||
/* issue the prompt */
|
||||
@@ -193,7 +193,7 @@ getlin_hook_proc hook;
|
||||
} else
|
||||
tty_nhbell();
|
||||
}
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
ttyDisplay->toplin = 2; /* nonempty, no --More-- required */
|
||||
ttyDisplay->inread--;
|
||||
clear_nhwindow(WIN_MESSAGE); /* clean up after ourselves */
|
||||
|
||||
|
||||
205
win/tty/topl.c
205
win/tty/topl.c
@@ -138,8 +138,8 @@ const char *str;
|
||||
end_glyphout(); /* in case message printed during graphics output */
|
||||
putsyms(str);
|
||||
cl_end();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE;
|
||||
if (ttyDisplay->cury && otoplin != TOPLINE_SPECIAL_PROMPT)
|
||||
ttyDisplay->toplin = 1;
|
||||
if (ttyDisplay->cury && otoplin != 3)
|
||||
more();
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ const char *str;
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
|
||||
if (!(cw->flags & WIN_STOP)) {
|
||||
if (ttyDisplay->cury && ttyDisplay->toplin == TOPLINE_NON_EMPTY)
|
||||
if (ttyDisplay->cury && ttyDisplay->toplin == 2)
|
||||
tty_clear_nhwindow(WIN_MESSAGE);
|
||||
|
||||
cw->curx = cw->cury = 0;
|
||||
@@ -159,8 +159,8 @@ const char *str;
|
||||
cl_end();
|
||||
addtopl(str);
|
||||
|
||||
if (ttyDisplay->cury && ttyDisplay->toplin != TOPLINE_SPECIAL_PROMPT)
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
if (ttyDisplay->cury && ttyDisplay->toplin != 3)
|
||||
ttyDisplay->toplin = 2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ const char *s;
|
||||
tty_curs(BASE_WINDOW, cw->curx + 1, cw->cury);
|
||||
putsyms(s);
|
||||
cl_end();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE;
|
||||
ttyDisplay->toplin = 1;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -204,15 +204,12 @@ more()
|
||||
{
|
||||
struct WinDesc *cw = wins[WIN_MESSAGE];
|
||||
|
||||
/* avoid recursion -- only happens from interrupts */
|
||||
if (ttyDisplay->inmore++)
|
||||
return;
|
||||
if (iflags.debug_fuzzer)
|
||||
return;
|
||||
|
||||
/* avoid recursion -- only happens from interrupts */
|
||||
if (ttyDisplay->inmore)
|
||||
return;
|
||||
|
||||
ttyDisplay->inmore++;
|
||||
|
||||
if (ttyDisplay->toplin) {
|
||||
tty_curs(BASE_WINDOW, cw->curx + 1, cw->cury);
|
||||
if (cw->curx >= CO - 8)
|
||||
@@ -239,7 +236,7 @@ more()
|
||||
home();
|
||||
cl_end();
|
||||
}
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
ttyDisplay->inmore = 0;
|
||||
}
|
||||
|
||||
@@ -255,11 +252,10 @@ register const char *bp;
|
||||
/* If there is room on the line, print message on same line */
|
||||
/* But messages like "You die..." deserve their own line */
|
||||
n0 = strlen(bp);
|
||||
if ((ttyDisplay->toplin == TOPLINE_NEED_MORE || (cw->flags & WIN_STOP))
|
||||
if ((ttyDisplay->toplin == 1 || (cw->flags & WIN_STOP))
|
||||
&& cw->cury == 0
|
||||
&& n0 + (int) strlen(g.toplines) + 3 < CO - 8 /* room for --More-- */
|
||||
&& (notdied = strncmp(bp, "You die", 7)) != 0) {
|
||||
/* nhassert((long) strlen(g.toplines) == cw->curx); */
|
||||
Strcat(g.toplines, " ");
|
||||
Strcat(g.toplines, bp);
|
||||
cw->curx += 2;
|
||||
@@ -267,9 +263,9 @@ register const char *bp;
|
||||
addtopl(bp);
|
||||
return;
|
||||
} else if (!(cw->flags & WIN_STOP)) {
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) {
|
||||
if (ttyDisplay->toplin == 1) {
|
||||
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 */
|
||||
cw->curx = cw->cury = 0; /* from home--cls() & docorner(1,n) */
|
||||
}
|
||||
@@ -313,7 +309,6 @@ char c;
|
||||
if (ttyDisplay->curx == 0 && ttyDisplay->cury > 0)
|
||||
tty_curs(BASE_WINDOW, CO, (int) ttyDisplay->cury - 1);
|
||||
backsp();
|
||||
nhassert(ttyDisplay->curx > 0);
|
||||
ttyDisplay->curx--;
|
||||
cw->curx = ttyDisplay->curx;
|
||||
return;
|
||||
@@ -386,10 +381,10 @@ char def;
|
||||
char prompt[BUFSZ];
|
||||
|
||||
yn_number = 0L;
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE && !(cw->flags & WIN_STOP))
|
||||
if (ttyDisplay->toplin == 1 && !(cw->flags & WIN_STOP))
|
||||
more();
|
||||
cw->flags &= ~WIN_STOP;
|
||||
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT;
|
||||
ttyDisplay->toplin = 3; /* special prompt state */
|
||||
ttyDisplay->inread++;
|
||||
if (resp) {
|
||||
char *rb, respbuf[QBUFSZ];
|
||||
@@ -536,7 +531,7 @@ char def;
|
||||
dumplogmsg(g.toplines);
|
||||
#endif
|
||||
ttyDisplay->inread--;
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
ttyDisplay->toplin = 2;
|
||||
if (ttyDisplay->intr)
|
||||
ttyDisplay->intr--;
|
||||
if (wins[WIN_MESSAGE]->cury)
|
||||
@@ -545,64 +540,76 @@ char def;
|
||||
return q;
|
||||
}
|
||||
|
||||
static ptr_array_t *
|
||||
get_message_history()
|
||||
/* 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 void
|
||||
msghistory_snapshot(purge)
|
||||
boolean purge; /* clear message history buffer as we copy it */
|
||||
{
|
||||
char *mesg;
|
||||
int i;
|
||||
int i, inidx, outidx;
|
||||
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?) */
|
||||
if (WIN_MESSAGE == WIN_ERR || !wins[WIN_MESSAGE])
|
||||
return NULL;
|
||||
|
||||
return;
|
||||
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);
|
||||
|
||||
nhassert(cw->maxrow <= cw->rows);
|
||||
snapshot_mesgs = (char **) alloc((cw->rows + 1) * sizeof(char *));
|
||||
outidx = 0;
|
||||
inidx = cw->maxrow;
|
||||
for (i = 0; i < cw->rows; ++i) {
|
||||
mesg = cw->data[(i + cw->maxrow) % cw->rows];
|
||||
if (mesg && *mesg)
|
||||
a->elements[a->length++] = strdup(mesg);
|
||||
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;
|
||||
}
|
||||
if (*g.toplines)
|
||||
a->elements[a->length++] = strdup(g.toplines);
|
||||
snapshot_mesgs[cw->rows] = (char *) 0; /* sentinel */
|
||||
|
||||
return a;
|
||||
/* for a destructive snapshot, history is now completely empty */
|
||||
if (purge)
|
||||
cw->maxcol = cw->maxrow = 0;
|
||||
}
|
||||
|
||||
/* release memory allocated to message history snapshot */
|
||||
static void
|
||||
purge_message_history()
|
||||
free_msghistory_snapshot(purged)
|
||||
boolean purged; /* True: took history's pointers, False: just cloned them */
|
||||
{
|
||||
int i;
|
||||
struct WinDesc *cw;
|
||||
if (snapshot_mesgs) {
|
||||
/* snapshot pointers are no longer in use */
|
||||
if (purged) {
|
||||
int i;
|
||||
|
||||
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;
|
||||
for (i = 0; snapshot_mesgs[i]; ++i)
|
||||
free((genericptr_t) snapshot_mesgs[i]);
|
||||
}
|
||||
}
|
||||
|
||||
cw->maxcol = cw->maxrow = 0;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -619,25 +626,21 @@ char *
|
||||
tty_getmsghistory(init)
|
||||
boolean init;
|
||||
{
|
||||
static size_t nxtidx;
|
||||
static ptr_array_t * saved_messages = NULL;
|
||||
char *result = NULL;
|
||||
static int nxtidx;
|
||||
char *nextmesg;
|
||||
char *result = 0;
|
||||
|
||||
if (init) {
|
||||
nhassert(saved_messages == NULL);
|
||||
saved_messages = get_message_history();
|
||||
msghistory_snapshot(FALSE);
|
||||
nxtidx = 0;
|
||||
wins[WIN_MESSAGE]->flags |= WIN_LOCKHISTORY;
|
||||
}
|
||||
|
||||
if (saved_messages) {
|
||||
if (nxtidx < saved_messages->length)
|
||||
result = saved_messages->elements[nxtidx++];
|
||||
|
||||
if (result == NULL) {
|
||||
ptr_array_free(saved_messages);
|
||||
saved_messages = NULL;
|
||||
wins[WIN_MESSAGE]->flags &= ~WIN_LOCKHISTORY;
|
||||
if (snapshot_mesgs) {
|
||||
nextmesg = snapshot_mesgs[nxtidx++];
|
||||
if (nextmesg) {
|
||||
result = (char *) nextmesg;
|
||||
} else {
|
||||
free_msghistory_snapshot(FALSE);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -666,10 +669,7 @@ const char *msg;
|
||||
boolean restoring_msghist;
|
||||
{
|
||||
static boolean initd = FALSE;
|
||||
static ptr_array_t * saved_messages = NULL;
|
||||
size_t i;
|
||||
|
||||
nhassert(!(wins[WIN_MESSAGE]->flags & WIN_LOCKHISTORY));
|
||||
int idx;
|
||||
|
||||
if (restoring_msghist && !initd) {
|
||||
/* we're restoring history from the previous session, but new
|
||||
@@ -677,9 +677,7 @@ boolean restoring_msghist;
|
||||
for instance); collect current history (ie, those new messages),
|
||||
and also clear it out so that nothing will be present when the
|
||||
restored ones are being put into place */
|
||||
nhassert(saved_messages == NULL);
|
||||
saved_messages = get_message_history();
|
||||
purge_message_history();
|
||||
msghistory_snapshot(TRUE);
|
||||
initd = TRUE;
|
||||
#ifdef DUMPLOG
|
||||
/* this suffices; there's no need to scrub saved_pline[] pointers */
|
||||
@@ -688,52 +686,25 @@ boolean restoring_msghist;
|
||||
}
|
||||
|
||||
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 */
|
||||
remember_topl();
|
||||
Strcpy(g.toplines, msg);
|
||||
#ifdef DUMPLOG
|
||||
dumplogmsg(g.toplines);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
/* 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();
|
||||
nhassert(mesg);
|
||||
Strcpy(g.toplines, mesg);
|
||||
} else if (snapshot_mesgs) {
|
||||
/* done putting arbitrary messages in; put the snapshot ones back */
|
||||
for (idx = 0; snapshot_mesgs[idx]; ++idx) {
|
||||
remember_topl();
|
||||
Strcpy(g.toplines, snapshot_mesgs[idx]);
|
||||
#ifdef DUMPLOG
|
||||
dumplogmsg(g.toplines);
|
||||
dumplogmsg(g.toplines);
|
||||
#endif
|
||||
}
|
||||
ptr_array_free(saved_messages);
|
||||
saved_messages = NULL;
|
||||
}
|
||||
initd = FALSE;
|
||||
}
|
||||
/* now release the snapshot */
|
||||
free_msghistory_snapshot(TRUE);
|
||||
initd = FALSE; /* reset */
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif /* TTY_GRAPHICS */
|
||||
|
||||
141
win/tty/wintty.c
141
win/tty/wintty.c
@@ -36,12 +36,6 @@ extern void msmsg(const char *, ...);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
#if defined(UNIX)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
extern short glyph2tile[];
|
||||
#define TILE_ANSI_COMMAND 'z'
|
||||
@@ -137,9 +131,6 @@ struct window_procs tty_procs = {
|
||||
genl_status_update,
|
||||
#endif
|
||||
genl_can_suspend_yes,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
tty_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
static int maxwin = 0; /* number of windows in use */
|
||||
@@ -330,7 +321,7 @@ int sig_unused UNUSED;
|
||||
new_status_window();
|
||||
if (u.ux) {
|
||||
i = ttyDisplay->toplin;
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
docrt();
|
||||
bot();
|
||||
ttyDisplay->toplin = i;
|
||||
@@ -418,7 +409,7 @@ char **argv UNUSED;
|
||||
|
||||
/* set up tty descriptor */
|
||||
ttyDisplay = (struct DisplayDesc *) alloc(sizeof (struct DisplayDesc));
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
ttyDisplay->rows = hgt;
|
||||
ttyDisplay->cols = wid;
|
||||
ttyDisplay->curx = ttyDisplay->cury = 0;
|
||||
@@ -1619,12 +1610,12 @@ winid window;
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
if (ttyDisplay->toplin != TOPLINE_EMPTY) {
|
||||
if (ttyDisplay->toplin) {
|
||||
home();
|
||||
cl_end();
|
||||
if (cw->cury)
|
||||
docorner(1, cw->cury + 1);
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
}
|
||||
break;
|
||||
case NHW_STATUS:
|
||||
@@ -2315,13 +2306,12 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) {
|
||||
if (ttyDisplay->toplin == 1) {
|
||||
more();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
||||
ttyDisplay->toplin = 1; /* more resets this */
|
||||
tty_clear_nhwindow(window);
|
||||
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||
} else
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
cw->curx = cw->cury = 0;
|
||||
if (!cw->active)
|
||||
iflags.window_inited = TRUE;
|
||||
@@ -2329,8 +2319,8 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
case NHW_MAP:
|
||||
end_glyphout();
|
||||
if (blocking) {
|
||||
if (ttyDisplay->toplin != TOPLINE_EMPTY)
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE;
|
||||
if (!ttyDisplay->toplin)
|
||||
ttyDisplay->toplin = 1;
|
||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
return;
|
||||
}
|
||||
@@ -2360,7 +2350,7 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
cw->offx = 0;
|
||||
if (cw->type == NHW_MENU)
|
||||
cw->offy = 0;
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE)
|
||||
if (ttyDisplay->toplin == 1)
|
||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
#ifdef H2344_BROKEN
|
||||
if (cw->maxrow >= (int) ttyDisplay->rows
|
||||
@@ -2376,7 +2366,7 @@ boolean blocking; /* with ttys, all windows are blocking */
|
||||
cl_eos();
|
||||
} else
|
||||
clear_screen();
|
||||
ttyDisplay->toplin = TOPLINE_EMPTY;
|
||||
ttyDisplay->toplin = 0;
|
||||
} else {
|
||||
if (WIN_MESSAGE != WIN_ERR)
|
||||
tty_clear_nhwindow(WIN_MESSAGE);
|
||||
@@ -2405,9 +2395,8 @@ winid window;
|
||||
|
||||
switch (cw->type) {
|
||||
case NHW_MESSAGE:
|
||||
if (ttyDisplay->toplin != TOPLINE_EMPTY)
|
||||
if (ttyDisplay->toplin)
|
||||
tty_display_nhwindow(WIN_MESSAGE, TRUE);
|
||||
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||
/*FALLTHRU*/
|
||||
case NHW_STATUS:
|
||||
case NHW_BASE:
|
||||
@@ -3158,11 +3147,10 @@ const char *mesg;
|
||||
response to a prompt, we'll assume that the display is up to date */
|
||||
tty_putstr(WIN_MESSAGE, 0, mesg);
|
||||
/* if `mesg' didn't wrap (triggering --More--), force --More-- now */
|
||||
if (ttyDisplay->toplin == TOPLINE_NEED_MORE) {
|
||||
if (ttyDisplay->toplin == 1) {
|
||||
more();
|
||||
ttyDisplay->toplin = TOPLINE_NEED_MORE; /* more resets this */
|
||||
ttyDisplay->toplin = 1; /* more resets this */
|
||||
tty_clear_nhwindow(WIN_MESSAGE);
|
||||
nhassert(ttyDisplay->toplin == TOPLINE_EMPTY);
|
||||
}
|
||||
/* normally <ESC> means skip further messages, but in this case
|
||||
it means cancel the current prompt; any other messages should
|
||||
@@ -3202,7 +3190,7 @@ tty_wait_synch()
|
||||
(void) fflush(stdout);
|
||||
} else if (ttyDisplay->inread > g.program_state.gameover) {
|
||||
/* 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 */
|
||||
(void) tty_doprev_message();
|
||||
(void) tty_doprev_message();
|
||||
@@ -3489,7 +3477,6 @@ const char *str;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef NEW_KEYBOARD_HIT
|
||||
int
|
||||
tty_nhgetch()
|
||||
{
|
||||
@@ -3531,9 +3518,8 @@ tty_nhgetch()
|
||||
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;
|
||||
if (ttyDisplay && ttyDisplay->toplin == 1)
|
||||
ttyDisplay->toplin = 2;
|
||||
#ifdef TTY_TILES_ESCCODES
|
||||
{
|
||||
/* hack to force output of the window select code */
|
||||
@@ -3545,94 +3531,6 @@ tty_nhgetch()
|
||||
#endif /* TTY_TILES_ESCCODES */
|
||||
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
|
||||
@@ -3659,9 +3557,8 @@ int *x, *y, *mod;
|
||||
i = ntposkey(x, y, mod);
|
||||
if (!i && mod && (*mod == 0 || *mod == EOF))
|
||||
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 == TOPLINE_NEED_MORE)
|
||||
ttyDisplay->toplin = TOPLINE_NON_EMPTY;
|
||||
if (ttyDisplay && ttyDisplay->toplin == 1)
|
||||
ttyDisplay->toplin = 2;
|
||||
#else /* !WIN32CON */
|
||||
nhUse(x);
|
||||
nhUse(y);
|
||||
|
||||
@@ -116,9 +116,6 @@ struct window_procs mswin_procs = {
|
||||
mswin_status_init, mswin_status_finish, mswin_status_enablefield,
|
||||
mswin_status_update,
|
||||
genl_can_suspend_yes,
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
mswin_keyboard_hit
|
||||
#endif
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -1405,15 +1402,6 @@ mswin_nhgetch()
|
||||
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)
|
||||
-- Returns a single character input from the user or a
|
||||
|
||||
@@ -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%
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
echo off
|
||||
|
||||
SETLOCAL ENABLEEXTENSIONS
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
call setenv.bat
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
call clean.bat
|
||||
call setenv.bat
|
||||
|
||||
copy %FUZZER_DIR%\%SAVED_GAME% %BIN_DIR%\%SAVED_GAME%
|
||||
@@ -1,70 +0,0 @@
|
||||
REM
|
||||
REM runtill target_move
|
||||
REM
|
||||
echo on
|
||||
|
||||
SETLOCAL ENABLEEXTENSIONS
|
||||
SETLOCAL ENABLEDELAYEDEXPANSION
|
||||
|
||||
set TARGET_MOVE=%1
|
||||
|
||||
if %TARGET_MOVE% == "" (
|
||||
echo Usage:runtill target_move
|
||||
goto :eof
|
||||
)
|
||||
|
||||
call setenv.bat
|
||||
|
||||
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%
|
||||
|
||||
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.
|
||||
@@ -1,13 +0,0 @@
|
||||
echo on
|
||||
|
||||
set STEP_SIZE=5000
|
||||
set FINAL_MOVE=500000
|
||||
set START_MOVE=5000
|
||||
|
||||
set BIN_DIR=..\..\..\..\bin\Debug\Win32
|
||||
set SAVED_GAME=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
|
||||
@@ -167,9 +167,6 @@ void mswin_raw_print(const char *str);
|
||||
void mswin_raw_print_bold(const char *str);
|
||||
void mswin_raw_print_flush();
|
||||
int mswin_nhgetch(void);
|
||||
#ifdef NEW_KEYBOARD_HIT
|
||||
boolean mswin_keyboard_hit(void);
|
||||
#endif
|
||||
int mswin_nh_poskey(int *x, int *y, int *mod);
|
||||
void mswin_nhbell(void);
|
||||
int mswin_doprev_message(void);
|
||||
|
||||
Reference in New Issue
Block a user