follow-up, program_state
This commit is contained in:
@@ -498,7 +498,7 @@ void NetHackQtBind::qt_update_inventory(int arg UNUSED)
|
||||
main->updateInventory(); // update the paper doll inventory subset
|
||||
|
||||
/* doesn't work yet
|
||||
if (svp.program_state.something_worth_saving && iflags.perm_invent)
|
||||
if (program_state.something_worth_saving && iflags.perm_invent)
|
||||
display_inventory(NULL, false);
|
||||
*/
|
||||
}
|
||||
@@ -667,7 +667,7 @@ char NetHackQtBind::qt_more()
|
||||
// ^C comment in that routine] when the core triggers --More-- via
|
||||
// done2() -> really_done() -> display_nhwindow(WIN_MESSAGE, TRUE)
|
||||
// (get rid of this if the exec() loop issue gets properly fixed)
|
||||
if (::svp.program_state.gameover)
|
||||
if (::program_state.gameover)
|
||||
return ch; // bypass --More-- and just continue with program exit
|
||||
|
||||
NetHackQtMessageWindow *mesgwin = main ? main->GetMessageWindow() : NULL;
|
||||
|
||||
@@ -1015,7 +1015,7 @@ bool NetHackQtMainWindow::ok_for_command()
|
||||
* FIXME: it would be much better to gray-out inapplicable entries
|
||||
* when popping up a command menu instead of needing this.
|
||||
*/
|
||||
if (::svp.program_state.input_state != commandInp) {
|
||||
if (::program_state.input_state != commandInp) {
|
||||
NetHackQtBind::qt_nhbell();
|
||||
// possibly call doKeys("\033"); here?
|
||||
return false;
|
||||
@@ -1059,7 +1059,7 @@ void NetHackQtMainWindow::doQuit(bool)
|
||||
// in case someone wants to change that
|
||||
#ifdef MACOS
|
||||
QString info = nh_qsprintf("This will end your NetHack session.%s",
|
||||
!svp.program_state.something_worth_saving ? ""
|
||||
!program_state.something_worth_saving ? ""
|
||||
: "\n(Cancel quitting and use the Save command"
|
||||
"\nto save your current game.)");
|
||||
/* this is similar to closeEvent but the details are different;
|
||||
@@ -1077,7 +1077,7 @@ void NetHackQtMainWindow::doQuit(bool)
|
||||
break; // return to game
|
||||
case 1:
|
||||
// quit -- bypass the prompting preformed by done2()
|
||||
svp.program_state.stopprint++;
|
||||
program_state.stopprint++;
|
||||
::done(QUIT);
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
@@ -1406,7 +1406,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
|
||||
void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
|
||||
{
|
||||
int ok = 0;
|
||||
if ( svp.program_state.something_worth_saving ) {
|
||||
if ( program_state.something_worth_saving ) {
|
||||
/* this used to offer "Save" and "Cancel"
|
||||
but cancel (ignoring the close attempt) won't work
|
||||
if user has clicked on the window's Close button */
|
||||
@@ -1421,7 +1421,7 @@ void NetHackQtMainWindow::closeEvent(QCloseEvent *e UNUSED)
|
||||
case 1:
|
||||
// quit -- bypass the prompting preformed by done2()
|
||||
ok = 1;
|
||||
svp.program_state.stopprint++;
|
||||
program_state.stopprint++;
|
||||
::done(QUIT);
|
||||
/*NOTREACHED*/
|
||||
break;
|
||||
|
||||
@@ -220,7 +220,7 @@ char NetHackQtYnDialog::Exec()
|
||||
// for "ynaq" (where "all" is a choice) it's "stop"
|
||||
// and for end of game disclosure it really is "quit"
|
||||
if (question.left(10) == QString("Dump core?")
|
||||
|| (::svp.program_state.gameover
|
||||
|| (::program_state.gameover
|
||||
&& question.left(11) == QString("Do you want")))
|
||||
button_name = "Quit";
|
||||
else if (is_ynaq)
|
||||
|
||||
@@ -1282,7 +1282,7 @@ X11_update_inventory(int arg)
|
||||
|
||||
if (iflags.perm_invent) {
|
||||
/* skip any calls to update_inventory() before in_moveloop starts */
|
||||
if (svp.program_state.in_moveloop || svp.program_state.gameover) {
|
||||
if (program_state.in_moveloop || program_state.gameover) {
|
||||
updated_inventory = 1; /* hack to avoid mapping&raising window */
|
||||
if (!arg) {
|
||||
(void) display_inventory((char *) 0, FALSE);
|
||||
@@ -1798,7 +1798,7 @@ X11_hangup(Widget w, XEvent *event, String *params, Cardinal *num_params)
|
||||
static void
|
||||
X11_bail(const char *mesg)
|
||||
{
|
||||
svp.program_state.something_worth_saving = 0;
|
||||
program_state.something_worth_saving = 0;
|
||||
clearlocks();
|
||||
X11_exit_nhwindows(mesg);
|
||||
nh_terminate(EXIT_SUCCESS);
|
||||
@@ -2041,7 +2041,7 @@ X11_getlin(
|
||||
/* we get here after the popup has exited;
|
||||
put prompt and response into the message window (and into
|
||||
core's dumplog history) unless play hasn't started yet */
|
||||
if (svp.program_state.in_moveloop || svp.program_state.gameover) {
|
||||
if (program_state.in_moveloop || program_state.gameover) {
|
||||
/* single space has meaning (to remove a previously applied name) so
|
||||
show it clearly; don't care about legibility of multiple spaces */
|
||||
const char *visanswer = !input[0] ? "<empty>"
|
||||
|
||||
@@ -1988,7 +1988,7 @@ x_event(int exit_condition)
|
||||
/* pkey(retval); */
|
||||
keep_going = FALSE;
|
||||
#if defined(HANGUPHANDLING)
|
||||
} else if (svp.program_state.done_hup) {
|
||||
} else if (program_state.done_hup) {
|
||||
retval = '\033';
|
||||
inptr = (inptr + 1) % INBUF_SIZE;
|
||||
keep_going = FALSE;
|
||||
@@ -2009,7 +2009,7 @@ x_event(int exit_condition)
|
||||
}
|
||||
keep_going = FALSE;
|
||||
#if defined(HANGUPHANDLING)
|
||||
} else if (svp.program_state.done_hup) {
|
||||
} else if (program_state.done_hup) {
|
||||
retval = '\033';
|
||||
inptr = (inptr + 1) % INBUF_SIZE;
|
||||
keep_going = FALSE;
|
||||
|
||||
@@ -1222,7 +1222,7 @@ X11_player_selection_dialog(void)
|
||||
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| svp.program_state.done_hup
|
||||
|| program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
@@ -1300,7 +1300,7 @@ X11_player_selection_prompts(void)
|
||||
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| svp.program_state.done_hup
|
||||
|| program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
@@ -1373,7 +1373,7 @@ X11_player_selection_prompts(void)
|
||||
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| svp.program_state.done_hup
|
||||
|| program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
@@ -1445,7 +1445,7 @@ X11_player_selection_prompts(void)
|
||||
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| svp.program_state.done_hup
|
||||
|| program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
@@ -1515,7 +1515,7 @@ X11_player_selection_prompts(void)
|
||||
|
||||
if (ps_selected == PS_QUIT
|
||||
#if defined(HANGUPHANDLING)
|
||||
|| svp.program_state.done_hup
|
||||
|| program_state.done_hup
|
||||
#endif
|
||||
) {
|
||||
clearlocks();
|
||||
|
||||
@@ -789,7 +789,7 @@ curses_display_nhmenu(
|
||||
menu_determine_pages(current_menu);
|
||||
|
||||
/* Display pre and post-game menus centered */
|
||||
if ((svm.moves <= 1 && !gi.invent) || svp.program_state.gameover) {
|
||||
if ((svm.moves <= 1 && !gi.invent) || program_state.gameover) {
|
||||
win = curses_create_window(wid, current_menu->width,
|
||||
current_menu->height, CENTER);
|
||||
} else { /* Display during-game menus on the right out of the way */
|
||||
@@ -1033,7 +1033,7 @@ menu_win_size(nhmenu *menu)
|
||||
int maxheaderwidth = menu->prompt ? (int) strlen(menu->prompt) : 0;
|
||||
nhmenu_item *menu_item_ptr, *last_item_ptr = NULL;
|
||||
|
||||
if (svp.program_state.gameover) {
|
||||
if (program_state.gameover) {
|
||||
/* for final inventory disclosure, use full width */
|
||||
maxwidth = term_cols - 2; /* +2: borders assumed */
|
||||
} else {
|
||||
|
||||
@@ -782,7 +782,7 @@ curses_update_inventory(int arg)
|
||||
}
|
||||
|
||||
/* skip inventory updating during character initialization */
|
||||
if (!svp.program_state.in_moveloop && !svp.program_state.gameover)
|
||||
if (!program_state.in_moveloop && !program_state.gameover)
|
||||
return;
|
||||
|
||||
if (!arg) {
|
||||
|
||||
@@ -776,7 +776,7 @@ Currently this is limited to arrow keys, but this may be expanded. */
|
||||
int
|
||||
curses_convert_keys(int key)
|
||||
{
|
||||
boolean reject = (svp.program_state.input_state == otherInp),
|
||||
boolean reject = (program_state.input_state == otherInp),
|
||||
as_is = FALSE, numpad_esc = FALSE;
|
||||
int ret = key;
|
||||
|
||||
|
||||
@@ -232,7 +232,7 @@ xwaitforspace(const char *s) /* chars allowed besides return */
|
||||
morc = 0;
|
||||
while (
|
||||
#ifdef HANGUPHANDLING
|
||||
!svp.program_state.done_hup &&
|
||||
!program_state.done_hup &&
|
||||
#endif
|
||||
(c = tty_nhgetch()) != EOF) {
|
||||
if (c == '\n' || c == '\r')
|
||||
|
||||
@@ -184,7 +184,7 @@ remember_topl(void)
|
||||
cw->datlen[idx] = (short) len;
|
||||
}
|
||||
Strcpy(cw->data[idx], gt.toplines);
|
||||
if (!svp.program_state.in_checkpoint) {
|
||||
if (!program_state.in_checkpoint) {
|
||||
*gt.toplines = '\0';
|
||||
cw->maxcol = cw->maxrow = (idx + 1) % cw->rows;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ extern void msmsg(const char *, ...);
|
||||
*/
|
||||
#define HUPSKIP() \
|
||||
do { \
|
||||
if (svp.program_state.done_hup) { \
|
||||
if (program_state.done_hup) { \
|
||||
morc = '\033'; \
|
||||
return; \
|
||||
} \
|
||||
@@ -92,7 +92,7 @@ extern void msmsg(const char *, ...);
|
||||
/* morc=ESC - in case we bypass xwaitforspace() which sets that */
|
||||
#define HUPSKIP_RESULT(RES) \
|
||||
do { \
|
||||
if (svp.program_state.done_hup) \
|
||||
if (program_state.done_hup) \
|
||||
return (RES); \
|
||||
} while (0)
|
||||
#else /* !HANGUPHANDLING */
|
||||
@@ -376,11 +376,11 @@ winch_handler(int sig_unused UNUSED)
|
||||
}
|
||||
#endif
|
||||
|
||||
svp.program_state.resize_pending++; /* resize_tty() will reset it */
|
||||
program_state.resize_pending++; /* resize_tty() will reset it */
|
||||
/* if nethack is waiting for input, which is the most likely scenario,
|
||||
we will go ahead and respond to the resize immediately; otherwise,
|
||||
tty_nhgetch() will do so the next time it's called */
|
||||
if (svp.program_state.getting_char) {
|
||||
if (program_state.getting_char) {
|
||||
resize_tty();
|
||||
#if 0 /* [this doesn't work as intended and seems to be unnecessary] */
|
||||
if (resize_mesg) {
|
||||
@@ -402,7 +402,7 @@ resize_tty(void)
|
||||
struct WinDesc *cw;
|
||||
|
||||
/* reset to 0 rather than just decrement */
|
||||
svp.program_state.resize_pending = 0;
|
||||
program_state.resize_pending = 0;
|
||||
resize_mesg = 0;
|
||||
|
||||
getwindowsz(); /* update LI and CO */
|
||||
@@ -1978,7 +1978,7 @@ tty_dismiss_nhwindow(winid window)
|
||||
can't refresh--force the screen to be cleared instead
|
||||
(affects dismissal of 'reset role filtering' menu if
|
||||
screen height forces that to need a second page) */
|
||||
if (svp.program_state.in_role_selection)
|
||||
if (program_state.in_role_selection)
|
||||
clearscreen = TRUE;
|
||||
|
||||
erase_menu_or_text(window, cw, clearscreen);
|
||||
@@ -3041,7 +3041,7 @@ ttyinv_add_menu(
|
||||
: !show_gold ? 26
|
||||
: 27);
|
||||
|
||||
if (!svp.program_state.in_moveloop)
|
||||
if (!program_state.in_moveloop)
|
||||
return;
|
||||
slot = selector_to_slot(ch, ttyinvmode, &ignore);
|
||||
if (inuse_only && slot > 2 * rows_per_side)
|
||||
@@ -3216,7 +3216,7 @@ ttyinv_end_menu(int window, struct WinDesc *cw)
|
||||
{
|
||||
if (iflags.perm_invent
|
||||
|| gp.perm_invent_toggling_direction == toggling_on) {
|
||||
if (svp.program_state.in_moveloop) {
|
||||
if (program_state.in_moveloop) {
|
||||
boolean inuse_only = ((ttyinvmode & InvInUse) != 0);
|
||||
int rows_per_side = inuse_only ? cw->maxrow - 2 : 0;
|
||||
int old_slots_used = ttyinv_slots_used; /* value before render */
|
||||
@@ -3245,7 +3245,7 @@ ttyinv_render(winid window, struct WinDesc *cw)
|
||||
uint32 current_row_color = NO_COLOR;
|
||||
struct tty_perminvent_cell *cell;
|
||||
char invbuf[BUFSZ];
|
||||
boolean force_redraw = svp.program_state.in_docrt ? TRUE : FALSE,
|
||||
boolean force_redraw = program_state.in_docrt ? TRUE : FALSE,
|
||||
inuse_only = (ttyinvmode & InvInUse) != 0,
|
||||
show_gold = (ttyinvmode & InvShowGold) != 0 && !inuse_only,
|
||||
sparse = (ttyinvmode & InvSparse) != 0 && !inuse_only;
|
||||
@@ -3603,7 +3603,7 @@ tty_wait_synch(void)
|
||||
if (ttyDisplay->inmore) {
|
||||
addtopl("--More--");
|
||||
(void) fflush(stdout);
|
||||
} else if (ttyDisplay->inread > svp.program_state.gameover) {
|
||||
} else if (ttyDisplay->inread > program_state.gameover) {
|
||||
/* this can only happen if we were reading and got interrupted */
|
||||
ttyDisplay->toplin = TOPLINE_SPECIAL_PROMPT;
|
||||
/* do this twice; 1st time gets the Quit? message again */
|
||||
@@ -4036,19 +4036,19 @@ tty_nhgetch(void)
|
||||
i = randomkey();
|
||||
} else {
|
||||
#ifdef RESIZABLE
|
||||
if (svp.program_state.resize_pending)
|
||||
if (program_state.resize_pending)
|
||||
resize_tty();
|
||||
#endif
|
||||
svp.program_state.getting_char++;
|
||||
program_state.getting_char++;
|
||||
#ifdef UNIX
|
||||
i = (svp.program_state.getting_char == 1)
|
||||
i = (program_state.getting_char == 1)
|
||||
? tgetch()
|
||||
: ((read(fileno(stdin), (genericptr_t) &nestbuf, 1) == 1)
|
||||
? (int) nestbuf : EOF);
|
||||
#else
|
||||
i = tgetch();
|
||||
#endif
|
||||
svp.program_state.getting_char--;
|
||||
program_state.getting_char--;
|
||||
#ifdef RESIZABLE
|
||||
if (resize_mesg) {
|
||||
resize_mesg = 0;
|
||||
|
||||
@@ -39,7 +39,7 @@ mswin_have_input(void)
|
||||
return
|
||||
#ifdef SAFERHANGUP
|
||||
/* we always have input (ESC) if hangup was requested */
|
||||
svp.program_state.done_hup ||
|
||||
program_state.done_hup ||
|
||||
#endif
|
||||
(nhi_read_pos != nhi_write_pos);
|
||||
}
|
||||
@@ -69,7 +69,7 @@ mswin_input_pop(void)
|
||||
|
||||
#ifdef SAFERHANGUP
|
||||
/* always return ESC when hangup was requested */
|
||||
if (svp.program_state.done_hup) {
|
||||
if (program_state.done_hup) {
|
||||
static MSNHEvent hangup_event;
|
||||
hangup_event.type = NHEVENT_CHAR;
|
||||
hangup_event.ei.kbd.ch = '\033';
|
||||
@@ -98,7 +98,7 @@ mswin_input_peek(void)
|
||||
|
||||
#ifdef SAFERHANGUP
|
||||
/* always return ESC when hangup was requested */
|
||||
if (svp.program_state.done_hup) {
|
||||
if (program_state.done_hup) {
|
||||
static MSNHEvent hangup_event;
|
||||
hangup_event.type = NHEVENT_CHAR;
|
||||
hangup_event.ei.kbd.ch = '\033';
|
||||
|
||||
@@ -457,16 +457,16 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
case WM_CLOSE: {
|
||||
/* exit gracefully */
|
||||
if (svp.program_state.gameover) {
|
||||
if (program_state.gameover) {
|
||||
/* assume the user really meant this, as the game is already
|
||||
* over... */
|
||||
/* to make sure we still save bones, just set stop printing flag
|
||||
*/
|
||||
svp.program_state.stopprint++;
|
||||
program_state.stopprint++;
|
||||
NHEVENT_KBD(
|
||||
'\033'); /* and send keyboard input as if user pressed ESC */
|
||||
/* additional code for this is done in menu and rip windows */
|
||||
} else if (!svp.program_state.something_worth_saving) {
|
||||
} else if (!program_state.something_worth_saving) {
|
||||
/* User exited before the game started, e.g. during splash display
|
||||
*/
|
||||
/* Just get out. */
|
||||
@@ -842,7 +842,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
case IDM_SAVE:
|
||||
if (iflags.debug_fuzzer)
|
||||
break;
|
||||
if (!svp.program_state.gameover && !svp.program_state.done_hup)
|
||||
if (!program_state.gameover && !program_state.done_hup)
|
||||
dosave();
|
||||
else
|
||||
MessageBeep(0);
|
||||
|
||||
@@ -351,10 +351,10 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
return FALSE;
|
||||
|
||||
case WM_CLOSE:
|
||||
if (svp.program_state.gameover) {
|
||||
if (program_state.gameover) {
|
||||
data->result = -1;
|
||||
data->done = 1;
|
||||
svp.program_state.stopprint++;
|
||||
program_state.stopprint++;
|
||||
return TRUE;
|
||||
} else
|
||||
return FALSE;
|
||||
|
||||
@@ -227,7 +227,7 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
GetNHApp()->hMainWnd = NULL;
|
||||
DestroyWindow(hWnd);
|
||||
SetFocus(GetNHApp()->hMainWnd);
|
||||
svp.program_state.stopprint++;
|
||||
program_state.stopprint++;
|
||||
return TRUE;
|
||||
|
||||
case WM_DESTROY:
|
||||
|
||||
@@ -1251,7 +1251,7 @@ void
|
||||
mswin_update_inventory(int arg)
|
||||
{
|
||||
logDebug("mswin_update_inventory(%d)\n", arg);
|
||||
if (iflags.perm_invent && svp.program_state.something_worth_saving
|
||||
if (iflags.perm_invent && program_state.something_worth_saving
|
||||
&& iflags.window_inited && WIN_INVEN != WIN_ERR)
|
||||
display_inventory(NULL, FALSE);
|
||||
}
|
||||
@@ -2862,7 +2862,7 @@ int
|
||||
NHMessageBox(HWND hWnd, LPCTSTR text, UINT type)
|
||||
{
|
||||
TCHAR title[MAX_LOADSTRING];
|
||||
if (svp.program_state.exiting && !strcmp(text, "\n"))
|
||||
if (program_state.exiting && !strcmp(text, "\n"))
|
||||
text = "Press Enter to exit";
|
||||
|
||||
LoadString(GetNHApp()->hApp, IDS_APP_TITLE_SHORT, title, MAX_LOADSTRING);
|
||||
|
||||
Reference in New Issue
Block a user