diff --git a/include/decl.h b/include/decl.h index f4c8abbe9..1a63ea1a6 100644 --- a/include/decl.h +++ b/include/decl.h @@ -1194,7 +1194,6 @@ struct instance_globals_saved_p { char plname[PL_NSIZ]; /* player name */ char pl_character[PL_CSIZ]; char pl_fruit[PL_FSIZ]; - struct sinfo program_state; /* flags describing game's current state */ }; struct instance_globals_saved_q { @@ -1280,6 +1279,7 @@ extern struct instance_globals_saved_t svt; extern struct instance_globals_saved_u svu; extern struct instance_globals_saved_x svx; extern struct instance_globals_saved_y svy; +extern struct sinfo program_state; /* flags describing game's current state */ struct const_globals { const struct obj zeroobj; /* used to zero out a struct obj */ diff --git a/outdated/sys/wince/mhinput.c b/outdated/sys/wince/mhinput.c index 4d0f8db47..a7b169342 100644 --- a/outdated/sys/wince/mhinput.c +++ b/outdated/sys/wince/mhinput.c @@ -39,7 +39,7 @@ mswin_have_input() 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() #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.kbd.ch = '\033'; @@ -98,7 +98,7 @@ mswin_input_peek() #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.kbd.ch = '\033'; diff --git a/outdated/sys/wince/mhmenu.c b/outdated/sys/wince/mhmenu.c index e69ddeb62..4aa5f19f4 100644 --- a/outdated/sys/wince/mhmenu.c +++ b/outdated/sys/wince/mhmenu.c @@ -533,7 +533,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam) if (!data->text.text) { data->text.text = mswin_init_text_buffer( - svp.program_state.gameover ? FALSE : GetNHApp()->bWrapText); + program_state.gameover ? FALSE : GetNHApp()->bWrapText); if (!data->text.text) break; } diff --git a/outdated/sys/wince/mhtext.c b/outdated/sys/wince/mhtext.c index e99b900ba..a6b813507 100644 --- a/outdated/sys/wince/mhtext.c +++ b/outdated/sys/wince/mhtext.c @@ -39,7 +39,7 @@ mswin_init_text_window() ZeroMemory(data, sizeof(NHTextWindow)); data->window_text = mswin_init_text_buffer( - svp.program_state.gameover ? FALSE : GetNHApp()->bWrapText); + program_state.gameover ? FALSE : GetNHApp()->bWrapText); SetWindowLong(ret, GWL_USERDATA, (LONG) data); return ret; } diff --git a/outdated/win/Qt3/qt3_win.cpp b/outdated/win/Qt3/qt3_win.cpp index 0f9b028cd..483761cfd 100644 --- a/outdated/win/Qt3/qt3_win.cpp +++ b/outdated/win/Qt3/qt3_win.cpp @@ -4037,7 +4037,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event) void NetHackQtMainWindow::closeEvent(QCloseEvent* e) { - if ( svp.program_state.something_worth_saving ) { + if ( program_state.something_worth_saving ) { switch ( QMessageBox::information( this, "NetHack", "This will end your NetHack session", "&Save", "&Cancel", 0, 1 ) ) @@ -4849,7 +4849,7 @@ void NetHackQtBind::qt_update_inventory() if (main) main->updateInventory(); /* 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); */ } @@ -4903,14 +4903,14 @@ int NetHackQtBind::qt_nhgetch() // while (keybuffer.Empty() #ifdef SAFERHANGUP - && !svp.program_state.done_hup + && !program_state.done_hup #endif ) { qApp->enter_loop(); } #ifdef SAFERHANGUP - if (svp.program_state.done_hup && keybuffer.Empty()) return '\033'; + if (program_state.done_hup && keybuffer.Empty()) return '\033'; #endif return keybuffer.GetAscii(); } @@ -4924,13 +4924,13 @@ int NetHackQtBind::qt_nh_poskey(int *x, int *y, int *mod) // while (keybuffer.Empty() && clickbuffer.Empty() #ifdef SAFERHANGUP - && !svp.program_state.done_hup + && !program_state.done_hup #endif ) { qApp->enter_loop(); } #ifdef SAFERHANGUP - if (svp.program_state.done_hup && keybuffer.Empty()) return '\033'; + if (program_state.done_hup && keybuffer.Empty()) return '\033'; #endif if (!keybuffer.Empty()) { return keybuffer.GetAscii(); @@ -5179,7 +5179,7 @@ bool NetHackQtBind::notify(QObject *receiver, QEvent *event) bool result=QApplication::notify(receiver,event); #ifdef SAFERHANGUP - if (svp.program_state.done_hup) { + if (program_state.done_hup) { keybuffer.Put('\033'); qApp->exit_loop(); return TRUE; diff --git a/outdated/win/gnome/gnbind.c b/outdated/win/gnome/gnbind.c index 0eeb57f98..6fb043e21 100644 --- a/outdated/win/gnome/gnbind.c +++ b/outdated/win/gnome/gnbind.c @@ -907,7 +907,7 @@ gnome_nhgetch() g_askingQuestion = 1; /* Process events until a key press event arrives. */ while (g_numKeys == 0) { - if (svp.program_state.done_hup) + if (program_state.done_hup) return '\033'; gtk_main_iteration(); } @@ -945,7 +945,7 @@ gnome_nh_poskey(int *x, int *y, int *mod) g_askingQuestion = 0; /* Process events until a key or map-click arrives. */ while (g_numKeys == 0 && g_numClicks == 0) { - if (svp.program_state.done_hup) + if (program_state.done_hup) return '\033'; gtk_main_iteration(); } diff --git a/src/allmain.c b/src/allmain.c index fd22e17a2..957763b8d 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -71,7 +71,7 @@ moveloop_preamble(boolean resuming) } if (!resuming) { /* new game */ - svp.program_state.beyond_savefile_load = 1; /* for TTY_PERM_INVENT */ + program_state.beyond_savefile_load = 1; /* for TTY_PERM_INVENT */ svc.context.rndencode = rnd(9000); set_wear((struct obj *) 0); /* for side-effects of starting gear */ reset_justpicked(gi.invent); @@ -100,7 +100,7 @@ moveloop_preamble(boolean resuming) u.uz0.dlevel = u.uz.dlevel; svc.context.move = 0; - svp.program_state.in_moveloop = 1; + program_state.in_moveloop = 1; /* for perm_invent preset at startup, display persistent inventory after invent is fully populated and the in_moveloop flag has been set */ if (iflags.perm_invent) @@ -166,7 +166,7 @@ moveloop_core(void) boolean monscanmove = FALSE; #ifdef SAFERHANGUP - if (svp.program_state.done_hup) + if (program_state.done_hup) end_of_input(); #endif get_nh_event(); @@ -781,7 +781,7 @@ newgame(void) #ifdef INSURANCE save_currentstate(); #endif - svp.program_state.something_worth_saving++; /* useful data now exists */ + program_state.something_worth_saving++; /* useful data now exists */ /* Success! */ welcome(TRUE); diff --git a/src/artifact.c b/src/artifact.c index 80599729d..c02a6cfb7 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -705,7 +705,7 @@ set_artifact_intrinsic(struct obj *otmp, boolean on, long wp_mask) * when restoring a game */ (void) make_hallucinated((long) !on, - svp.program_state.restoring ? FALSE : TRUE, + program_state.restoring ? FALSE : TRUE, wp_mask); } if (spfx & SPFX_ESP) { diff --git a/src/attrib.c b/src/attrib.c index c7ad35dca..e8d2bd3d1 100644 --- a/src/attrib.c +++ b/src/attrib.c @@ -191,7 +191,7 @@ adjattrib( disp.botl = TRUE; if (msgflg <= 0) You_feel("%s%s!", (incr > 1 || incr < -1) ? "very " : "", attrstr); - if (svp.program_state.in_moveloop && (ndx == A_STR || ndx == A_CON)) + if (program_state.in_moveloop && (ndx == A_STR || ndx == A_CON)) (void) encumber_msg(); return TRUE; } diff --git a/src/cmd.c b/src/cmd.c index ea3caa5de..cd2b4b135 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -3294,7 +3294,7 @@ rhack(int key) svc.context.nopick = 0; got_prefix_input: #ifdef SAFERHANGUP - if (svp.program_state.done_hup) + if (program_state.done_hup) end_of_input(); #endif if ((cmdq = cmdq_pop()) != 0) { @@ -3634,7 +3634,7 @@ getdir(const char *s) } retry: - svp.program_state.input_state = getdirInp; + program_state.input_state = getdirInp; if (gi.in_doagain || *readchar_queue) dirsym = readchar(); else @@ -4648,7 +4648,7 @@ get_count( unsigned gc_flags) /* control flags: GC_SAVEHIST, GC_ECHOFIRST */ { char qbuf[QBUFSZ]; - int key, save_input_state = svp.program_state.input_state; + int key, save_input_state = program_state.input_state; long cnt = 0L, first = inkey ? (long) (inkey - '0') : 0L; boolean backspaced = FALSE, showzero = TRUE, /* should "Count: 123" go into message history? */ @@ -4670,7 +4670,7 @@ get_count( } else { /* if readchar() has already been called in this loop, it will have reset input_state; put that back to its previous value */ - svp.program_state.input_state = save_input_state; + program_state.input_state = save_input_state; key = readchar(); } @@ -4737,7 +4737,7 @@ parse(void) /* affects readchar() behavior for ESC iff 'altmeta' option is On; is always reset to otherInp by readchar() */ - svp.program_state.input_state = commandInp; + program_state.input_state = commandInp; if (!gc.Cmd.num_pad || (foo = readchar()) == gc.Cmd.spkeys[NHKF_COUNT]) { /* if 'num_pad' is On then readchar() has just reset input_state; @@ -4745,7 +4745,7 @@ parse(void) otherwise "nESC" becomes "nESC" (with not read from keyboard yet) rather than intended count and meta keystroke "nM-" */ - svp.program_state.input_state = commandInp; + program_state.input_state = commandInp; foo = get_count((char *) 0, '\0', LARGEST_INT, &gc.command_count, GC_NOFLAGS); @@ -4791,8 +4791,8 @@ hangup( int sig_unused UNUSED) /* called as signal() handler, so sent * at least one arg */ { - if (svp.program_state.exiting) - svp.program_state.in_moveloop = 0; + if (program_state.exiting) + program_state.in_moveloop = 0; nhwindows_hangup(); #ifdef SAFERHANGUP /* When using SAFERHANGUP, the done_hup flag is tested in rhack @@ -4801,10 +4801,10 @@ hangup( protects against losing objects in the process of being thrown, but also potentially riskier because the disconnected program must continue running longer before attempting a hangup save. */ - svp.program_state.done_hup++; + program_state.done_hup++; /* defer hangup iff game appears to be in progress */ - if (svp.program_state.in_moveloop - && svp.program_state.something_worth_saving) + if (program_state.in_moveloop + && program_state.something_worth_saving) return; #endif /* SAFERHANGUP */ end_of_input(); @@ -4815,16 +4815,16 @@ end_of_input(void) { #ifdef NOSAVEONHANGUP #ifdef INSURANCE - if (flags.ins_chkpt && svp.program_state.something_worth_saving) + if (flags.ins_chkpt && program_state.something_worth_saving) program_state.preserve_locks = 1; /* keep files for recovery */ #endif - svp.program_state.something_worth_saving = 0; /* don't save */ + program_state.something_worth_saving = 0; /* don't save */ #endif #ifndef SAFERHANGUP - if (!svp.program_state.done_hup++) + if (!program_state.done_hup++) #endif - if (svp.program_state.something_worth_saving) + if (program_state.something_worth_saving) (void) dosave0(); if (soundprocs.sound_exit_nhsound) (*soundprocs.sound_exit_nhsound)("end_of_input"); @@ -4875,7 +4875,7 @@ readchar_core(coordxy *x, coordxy *y, int *mod) sym = '\033'; #ifdef ALTMETA } else if (sym == '\033' && iflags.altmeta - && svp.program_state.input_state != otherInp) { + && program_state.input_state != otherInp) { /* iflags.altmeta: treat two character ``ESC c'' as single `M-c' but only when we're called by parse() [possibly via get_count()] or getpos() [to support Alt+digit] or getdir() [for arrow keys @@ -4895,7 +4895,7 @@ readchar_core(coordxy *x, coordxy *y, int *mod) readchar_done: /* next readchar() will be for an ordinary char unless parse() sets this back to non-zero */ - svp.program_state.input_state = otherInp; + program_state.input_state = otherInp; return (char) sym; } @@ -4917,7 +4917,7 @@ readchar_poskey(coordxy *x, coordxy *y, int *mod) { char ch; - svp.program_state.input_state = getposInp; + program_state.input_state = getposInp; ch = readchar_core(x, y, mod); return ch; } @@ -5171,7 +5171,7 @@ yn_function( res = altres; } /* in case we're called via getdir() which sets input_state */ - svp.program_state.input_state = otherInp; + program_state.input_state = otherInp; return res; } diff --git a/src/decl.c b/src/decl.c index 2fd8f2ea4..d11887dd9 100644 --- a/src/decl.c +++ b/src/decl.c @@ -986,7 +986,6 @@ static const struct instance_globals_saved_p init_svp = { DUMMY, /* plname */ DUMMY, /* pl_character */ DUMMY, /* pl_fruit */ - UNDEFINED_VALUES, /* program_state */ }; static const struct instance_globals_saved_q init_svq = { @@ -1029,6 +1028,8 @@ static const struct instance_globals_saved_y init_svy = { UNDEFINED_VALUE /* ymax */ }; +static const struct sinfo init_program_state = { 0 }; + #if 0 struct instance_globals g; #endif /* 0 */ @@ -1078,6 +1079,7 @@ struct instance_globals_saved_t svt; struct instance_globals_saved_u svu; struct instance_globals_saved_x svx; struct instance_globals_saved_y svy; +struct sinfo program_state; const struct const_globals cg = { DUMMY, /* zeroobj */ @@ -1154,6 +1156,7 @@ decl_globals_init(void) svu = init_svu; svx = init_svx; svy = init_svy; + program_state = init_program_state; gv.valuables[0].list = gg.gems; gv.valuables[0].size = SIZE(gg.gems); diff --git a/src/display.c b/src/display.c index 8a47e5058..6a3d5fcda 100644 --- a/src/display.c +++ b/src/display.c @@ -676,10 +676,10 @@ next_to_gas( boolean suppress_map_output(void) { - if (gi.in_mklev || svp.program_state.saving || svp.program_state.restoring) + if (gi.in_mklev || program_state.saving || program_state.restoring) return TRUE; #ifdef HANGUPHANDLING - if (svp.program_state.done_hup) + if (program_state.done_hup) return TRUE; #endif return FALSE; @@ -1658,10 +1658,10 @@ docrt_flags(int refresh_flags) redrawonly = (refresh_flags & docrtRefresh) != 0, nocls = (refresh_flags & docrtNocls) != 0; - if (!u.ux || svp.program_state.in_docrt) + if (!u.ux || program_state.in_docrt) return; /* display isn't ready yet */ - svp.program_state.in_docrt = TRUE; + program_state.in_docrt = TRUE; if (redrawonly) { redraw_map(FALSE); @@ -1713,7 +1713,7 @@ docrt_flags(int refresh_flags) disp.botlx = TRUE; /* force a redraw of the bottom lines */ /* note: caller needs to call bot() to actually redraw status */ } - svp.program_state.in_docrt = FALSE; + program_state.in_docrt = FALSE; } /* for panning beyond a clipped region; resend the current map data to @@ -1949,8 +1949,8 @@ show_glyph(coordxy x, coordxy y, int glyph) oldglyph = gg.gbuf[y][x].glyphinfo.glyph; if (a11y.glyph_updates && !a11y.mon_notices_blocked - && !svp.program_state.in_docrt - && !svp.program_state.in_getlev + && !program_state.in_docrt + && !program_state.in_getlev && (oldglyph != glyph || gg.gbuf[y][x].gnew)) { int c = glyph_to_cmap(glyph); if ((glyph_is_nothing(oldglyph) || glyph_is_unexplored(oldglyph) @@ -2165,7 +2165,7 @@ flush_screen(int cursor_on_u) return; /* if already flushing then return */ flushing = 1; #ifdef HANGUPHANDLING - if (svp.program_state.done_hup) + if (program_state.done_hup) return; #endif diff --git a/src/do.c b/src/do.c index 8f7aa4293..41aaadc6d 100644 --- a/src/do.c +++ b/src/do.c @@ -900,7 +900,7 @@ obj_no_longer_held(struct obj *obj) */ if (!obj->oerodeproof || !rn2(10)) { /* if monsters aren't moving, assume player is responsible */ - if (!svc.context.mon_moving && !svp.program_state.gameover) + if (!svc.context.mon_moving && !program_state.gameover) costly_alteration(obj, COST_DEGRD); obj->otyp = WORM_TOOTH; obj->oerodeproof = 0; @@ -1348,7 +1348,7 @@ save_currentstate(void) { NHFILE *nhfp; - svp.program_state.in_checkpoint++; + program_state.in_checkpoint++; if (flags.ins_chkpt) { /* write out just-attained level, with pets and everything */ nhfp = currentlevel_rewrite(); @@ -1363,7 +1363,7 @@ save_currentstate(void) /* write out non-level state */ savestateinlock(); - svp.program_state.in_checkpoint--; + program_state.in_checkpoint--; } #endif diff --git a/src/do_name.c b/src/do_name.c index f52ea3425..071539677 100644 --- a/src/do_name.c +++ b/src/do_name.c @@ -839,7 +839,7 @@ x_monnam( if (mtmp == &gy.youmonst) return strcpy(buf, "you"); /* ignore article, "invisible", &c */ - if (svp.program_state.gameover) + if (program_state.gameover) suppress |= SUPPRESS_HALLUCINATION; if (article == ARTICLE_YOUR && !mtmp->mtame) article = ARTICLE_THE; @@ -857,7 +857,7 @@ x_monnam( do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION); do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE); do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR - && !svp.program_state.gameover && mtmp != u.usteed + && !program_state.gameover && mtmp != u.usteed && !engulfing_u(mtmp) && !(suppress & SUPPRESS_IT); do_saddle = !(suppress & SUPPRESS_SADDLE); do_mappear = mappear_as_mon && !(suppress & SUPPRESS_MAPPEARANCE); @@ -1481,7 +1481,7 @@ const char * hliquid( const char *liquidpref) /* use as-is when not hallucintg (unless empty) */ { - boolean hallucinate = Hallucination && !svp.program_state.gameover; + boolean hallucinate = Hallucination && !program_state.gameover; if (hallucinate || !liquidpref || !*liquidpref) { int indx, count = SIZE(hliquids); diff --git a/src/do_wear.c b/src/do_wear.c index 21f32504e..51b9059a6 100644 --- a/src/do_wear.c +++ b/src/do_wear.c @@ -810,7 +810,7 @@ dragon_armor_handling( case GOLD_DRAGON_SCALES: case GOLD_DRAGON_SCALE_MAIL: (void) make_hallucinated((long) !puton, - svp.program_state.restoring ? FALSE : TRUE, + program_state.restoring ? FALSE : TRUE, W_ARM); break; case ORANGE_DRAGON_SCALES: diff --git a/src/end.c b/src/end.c index c894e7021..3078a0ad3 100644 --- a/src/end.c +++ b/src/end.c @@ -43,7 +43,7 @@ ATTRNORETURN extern void nethack_exit(int) NORETURN; #define nethack_exit exit #endif -#define done_stopprint svp.program_state.stopprint +#define done_stopprint program_state.stopprint /* * The order of these needs to match the macros in hack.h. @@ -175,7 +175,7 @@ staticfn void done_hangup(int sig) { #ifdef HANGUPHANDLING - svp.program_state.done_hup++; + program_state.done_hup++; #endif sethanguphandler((void (*)(int)) SIG_IGN); done_intr(sig); @@ -391,7 +391,7 @@ panic VA_DECL(const char *, str) VA_START(str); VA_INIT(str, char *); - if (svp.program_state.panicking++) + if (program_state.panicking++) NH_abort(NULL); /* avoid loops - this should never happen*/ gb.bot_disabled = TRUE; @@ -404,9 +404,9 @@ panic VA_DECL(const char *, str) iflags.window_inited = FALSE; /* they're gone; force raw_print()ing */ } - raw_print(svp.program_state.gameover + raw_print(program_state.gameover ? "Postgame wrapup disrupted." - : !svp.program_state.something_worth_saving + : !program_state.something_worth_saving ? "Program initialization has failed." : "Suddenly, the dungeon collapses."); #ifndef MICRO @@ -414,11 +414,11 @@ panic VA_DECL(const char *, str) if (!wizard) raw_printf("Report the following error to \"%s\" or at \"%s\".", DEVTEAM_EMAIL, DEVTEAM_URL); - else if (svp.program_state.something_worth_saving) + else if (program_state.something_worth_saving) raw_print("\nError save file being written.\n"); #else /* !NOTIFY_NETHACK_BUGS */ if (!wizard) { - const char *maybe_rebuild = !svp.program_state.something_worth_saving + const char *maybe_rebuild = !program_state.something_worth_saving ? "." : "\nand it may be possible to rebuild."; @@ -437,7 +437,7 @@ panic VA_DECL(const char *, str) /* XXX can we move this above the prints? Then we'd be able to * suppress "it may be possible to rebuild" based on dosave0() * or say it's NOT possible to rebuild. */ - if (svp.program_state.something_worth_saving && !iflags.debug_fuzzer) { + if (program_state.something_worth_saving && !iflags.debug_fuzzer) { set_error_savefile(); if (dosave0()) { /* os/win port specific recover instructions */ @@ -937,7 +937,7 @@ fuzzer_savelife(int how) * Some debugging code pulled out of done() to unclutter it. * 'done_seq' is maintained in done(). */ - if (!svp.program_state.panicking + if (!program_state.panicking && how != PANICKED && how != TRICKED) { savelife(how); @@ -1019,9 +1019,9 @@ done(int how) return; } } - if (svp.program_state.panicking + if (program_state.panicking #ifdef HANGUPHANDLING - || svp.program_state.done_hup + || program_state.done_hup #endif || (how == QUIT && done_stopprint)) { /* skip status update if panicking or disconnected @@ -1094,7 +1094,7 @@ done(int how) /* if hangup has occurred, the only possible answer to a paranoid query is 'no'; we want 'no' as the default for "Die?" but can't accept it more than once if there's no user supplying it */ - && !(svp.program_state.done_hup && gd.done_seq++ == gh.hero_seq) + && !(program_state.done_hup && gd.done_seq++ == gh.hero_seq) #endif && !paranoid_query(ParanoidDie, "Die?")) { pline("OK, so you don't %s.", (how == CHOKING) ? "choke" : "die"); @@ -1128,11 +1128,11 @@ really_done(int how) /* * The game is now over... */ - svp.program_state.gameover = 1; + program_state.gameover = 1; /* in case of a subsequent panic(), there's no point trying to save */ - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; #ifdef HANGUPHANDLING - if (svp.program_state.done_hup) + if (program_state.done_hup) done_stopprint++; #endif /* render vision subsystem inoperative */ @@ -1140,7 +1140,7 @@ really_done(int how) /* maybe use up active invent item(s), place thrown/kicked missile, deal with ball and chain possibly being temporarily off the map */ - if (!svp.program_state.panicking) + if (!program_state.panicking) done_object_cleanup(); /* in case we're panicking; normally cleared by done_object_cleanup() */ iflags.perm_invent = FALSE; @@ -1657,7 +1657,7 @@ container_contents( ATTRNORETURN void nh_terminate(int status) { - svp.program_state.in_moveloop = 0; /* won't be returning to normal play */ + program_state.in_moveloop = 0; /* won't be returning to normal play */ l_nhcore_call(NHCORE_GAME_EXIT); #ifdef MAC @@ -1665,7 +1665,7 @@ nh_terminate(int status) #endif /* don't bother to try to release memory if we're in panic mode, to avoid trouble in case that happens to be due to memory problems */ - if (!svp.program_state.panicking) { + if (!program_state.panicking) { freedynamicdata(); dlb_cleanup(); l_nhcore_done(); @@ -1679,10 +1679,10 @@ nh_terminate(int status) */ /* don't call exit() if already executing within an exit handler; that would cancel any other pending user-mode handlers */ - if (svp.program_state.exiting) + if (program_state.exiting) return; #endif - svp.program_state.exiting = 1; + program_state.exiting = 1; nethack_exit(status); } diff --git a/src/files.c b/src/files.c index 5ff98d560..31f3fa9a0 100644 --- a/src/files.c +++ b/src/files.c @@ -703,7 +703,7 @@ clearlocks(void) int x; #ifdef HANGUPHANDLING - if (svp.program_state.preserve_locks) + if (program_state.preserve_locks) return; #endif #ifndef NO_SIGNAL @@ -1101,7 +1101,7 @@ create_savefile(void) nhfp->fieldlevel = FALSE; nhfp->ftype = NHF_SAVEFILE; nhfp->mode = WRITING; - if (svp.program_state.in_self_recover || do_historical) { + if (program_state.in_self_recover || do_historical) { do_historical = TRUE; /* force it */ nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; @@ -1155,7 +1155,7 @@ open_savefile(void) nhfp->fieldlevel = FALSE; nhfp->ftype = NHF_SAVEFILE; nhfp->mode = READING; - if (svp.program_state.in_self_recover || do_historical) { + if (program_state.in_self_recover || do_historical) { do_historical = TRUE; /* force it */ nhfp->structlevel = TRUE; nhfp->fieldlevel = FALSE; @@ -1875,7 +1875,7 @@ static struct flock sflock; /* for unlocking, same as above */ #endif #if defined(HANGUPHANDLING) -#define HUP if (!svp.program_state.done_hup) +#define HUP if (!program_state.done_hup) #else #define HUP #endif @@ -3447,7 +3447,7 @@ config_error_init(boolean from_file, const char *sourcename, boolean secure) tmp->next = config_error_data; config_error_data = tmp; - svp.program_state.config_error_ready = TRUE; + program_state.config_error_ready = TRUE; } staticfn boolean @@ -3513,7 +3513,7 @@ config_erradd(const char *buf) punct = c_eos((char *) buf) - 1; /* eos(buf)-1 is valid */ punct = strchr(".!?", *punct) ? "" : "."; - if (!svp.program_state.config_error_ready) { + if (!program_state.config_error_ready) { /* either very early, where pline() will use raw_print(), or player gave bad value when prompted by interactive 'O' command */ pline("%s%s%s", !iflags.window_inited ? "config_error_add: " : "", @@ -3575,7 +3575,7 @@ config_error_done(void) } config_error_data = tmp->next; free(tmp); - svp.program_state.config_error_ready = (config_error_data != 0); + program_state.config_error_ready = (config_error_data != 0); return n; } @@ -3978,14 +3978,14 @@ read_wizkit(void) if (!wizard || !(fp = fopen_wizkit_file())) return; - svp.program_state.wizkit_wishing = 1; + program_state.wizkit_wishing = 1; config_error_init(TRUE, "WIZKIT", FALSE); parse_conf_file(fp, proc_wizkit_line); (void) fclose(fp); config_error_done(); - svp.program_state.wizkit_wishing = 0; + program_state.wizkit_wishing = 0; return; } @@ -4195,8 +4195,8 @@ paniclog( #ifdef PANICLOG FILE *lfile; - if (!svp.program_state.in_paniclog) { - svp.program_state.in_paniclog = 1; + if (!program_state.in_paniclog) { + program_state.in_paniclog = 1; lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX); if (lfile) { #ifdef PANICLOG_FMT2 @@ -4216,7 +4216,7 @@ paniclog( #endif /* !PANICLOG_FMT2 */ (void) fclose(lfile); } - svp.program_state.in_paniclog = 0; + program_state.in_paniclog = 0; } #endif /* PANICLOG */ return; @@ -4323,9 +4323,9 @@ recover_savefile(void) /* * Set a flag for the savefile routines to know the * circumstances and act accordingly: - * svp.program_state.in_self_recover + * program_state.in_self_recover */ - svp.program_state.in_self_recover = TRUE; + program_state.in_self_recover = TRUE; set_savefile_name(TRUE); snhfp = create_savefile(); if (!snhfp) { @@ -4433,11 +4433,11 @@ recover_savefile(void) close_nhfile(gnhfp); close_nhfile(snhfp); close_nhfile(lnhfp); - svp.program_state.in_self_recover = FALSE; + program_state.in_self_recover = FALSE; delete_savefile(); return FALSE; } - /* we don't clear svp.program_state.in_self_recover here, we + /* we don't clear program_state.in_self_recover here, we leave it as a flag to reload the structlevel savefile in the caller. The caller should then clear it. */ return TRUE; diff --git a/src/insight.c b/src/insight.c index 163855db4..fbc9fcacb 100644 --- a/src/insight.c +++ b/src/insight.c @@ -2395,7 +2395,7 @@ record_achievement(schar achidx) /* avoid livelog for achievements recorded during final disclosure: nudist and blind-from-birth; also ascension which is suppressed by this gets logged separately in really_done() */ - if (svp.program_state.gameover) + if (program_state.gameover) return; if (absidx >= ACH_RNK1 && absidx <= ACH_RNK8) { @@ -2717,7 +2717,7 @@ dovanquished(void) #define UniqCritterIndx(mndx) \ ((mons[mndx].geno & G_UNIQ) != 0 && mndx != PM_HIGH_CLERIC) -#define done_stopprint svp.program_state.stopprint +#define done_stopprint program_state.stopprint void list_vanquished(char defquery, boolean ask) @@ -2852,7 +2852,7 @@ list_vanquished(char defquery, boolean ask) * still in progress, so use present tense via pline(), or for dumplog * which needs putstr() and past tense. */ - } else if (!svp.program_state.gameover) { + } else if (!program_state.gameover) { /* #vanquished rather than final disclosure, so pline() is ok */ pline("No creatures have been vanquished."); #ifdef DUMPLOG @@ -2927,7 +2927,7 @@ list_genocided(char defquery, boolean ask) char buf[BUFSZ]; boolean genoing, /* prompting for genocide or class genocide */ dumping; /* for DUMPLOG; doesn't need to be conditional */ - boolean both = (svp.program_state.gameover || wizard || discover); + boolean both = (program_state.gameover || wizard || discover); dumping = (defquery == 'd'); genoing = (defquery == 'g'); @@ -3031,7 +3031,7 @@ list_genocided(char defquery, boolean ask) } /* See the comment for similar code near the end of list_vanquished(). */ - } else if (!svp.program_state.gameover) { + } else if (!program_state.gameover) { /* #genocided rather than final disclosure, so pline() is ok and extinction has been ignored */ pline("No creatures have been genocided%s.", genoing ? " yet" : ""); diff --git a/src/invent.c b/src/invent.c index bfac244f6..76df37740 100644 --- a/src/invent.c +++ b/src/invent.c @@ -355,7 +355,7 @@ loot_xname(struct obj *obj) if (wizard) { /* flags.debug */ /* paranoia: before toggling off wizard mode, guard against a panic in xname() producing a normal mode panic save file */ - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; flags.debug = FALSE; } @@ -363,7 +363,7 @@ loot_xname(struct obj *obj) if (save_debug) { flags.debug = TRUE; - svp.program_state.something_worth_saving = 1; + program_state.something_worth_saving = 1; } /* restore the object */ if (obj->oclass == POTION_CLASS) { @@ -2650,7 +2650,7 @@ update_inventory(void) { int save_suppress_price; - if (!svp.program_state.in_moveloop) /* not covered by suppress_map_output */ + if (!program_state.in_moveloop) /* not covered by suppress_map_output */ return; if (suppress_map_output()) /* despite name, used for perm_invent too */ return; @@ -6120,7 +6120,7 @@ sync_perminvent(void) WIN_INVEN = create_nhwindow(NHW_MENU); } - if (WIN_INVEN != WIN_ERR && svp.program_state.beyond_savefile_load) { + if (WIN_INVEN != WIN_ERR && program_state.beyond_savefile_load) { gi.in_sync_perminvent = 1; (void) display_inventory((char *) 0, FALSE); gi.in_sync_perminvent = 0; diff --git a/src/mkmaze.c b/src/mkmaze.c index adc2cd649..0b96a0c6c 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1755,7 +1755,7 @@ restore_waterlevel(NHFILE *nhfp) b->next = (struct bubble *) 0; } else { /* avoid "saving and reloading may fix this" */ - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; /* during restore, information about what level this is might not be available so we're wishy-washy about what we describe */ impossible("No %s to restore?", @@ -1764,7 +1764,7 @@ restore_waterlevel(NHFILE *nhfp) : (Is_airlevel(&u.uz) || Is_airlevel(&gu.uz_save)) ? "clouds" : "air bubbles or clouds"); - svp.program_state.something_worth_saving = 1; + program_state.something_worth_saving = 1; } } diff --git a/src/mon.c b/src/mon.c index 23c7ccde2..1fb32fd86 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1176,7 +1176,7 @@ movemon_singlemon(struct monst *mtmp) if (u.utotype #ifdef SAFERHANGUP /* or if the program has lost contact with the user */ - || svp.program_state.done_hup + || program_state.done_hup #endif ) { gs.somebody_can_move = FALSE; diff --git a/src/o_init.c b/src/o_init.c index 23c62cfd6..e066daf87 100644 --- a/src/o_init.c +++ b/src/o_init.c @@ -460,7 +460,7 @@ discover_object( exercise(A_WIS, TRUE); } /* !in_moveloop => initial inventory, gameover => final disclosure */ - if (svp.program_state.in_moveloop && !svp.program_state.gameover) { + if (program_state.in_moveloop && !program_state.gameover) { if (objects[oindx].oc_class == GEM_CLASS) gem_learned(oindx); /* could affect price of unpaid gems */ update_inventory(); diff --git a/src/objnam.c b/src/objnam.c index c9e4efd9b..6cc8a2aeb 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -325,7 +325,7 @@ obj_is_pname(struct obj *obj) { if (!obj->oartifact || !has_oname(obj)) return FALSE; - if (!svp.program_state.gameover && !iflags.override_ID) { + if (!program_state.gameover && !iflags.override_ID) { if (not_fully_identified(obj)) return FALSE; } @@ -371,7 +371,7 @@ distant_name( against a potential extra chance to browse the map with getpos() during final disclosure (not currently implemented, nor planned) */ save_oid = obj->o_id; - if (svp.program_state.gameover) + if (program_state.gameover) obj->o_id = 0; /* this maybe-nearby part used to be replicated in multiple callers */ @@ -955,7 +955,7 @@ xname_flags( "You were acid resistant because of your alchemy smock \ with text \"Kiss the cook\"." when disclosing attributes anyway */ - if (svp.program_state.gameover && obj->o_id && bufspaceleft > 0) { + if (program_state.gameover && obj->o_id && bufspaceleft > 0) { const char *lbl; char tmpbuf[BUFSZ]; @@ -1625,7 +1625,7 @@ doname_base( bill might not be available yet while restore is in progress (objects won't normally be formatted during that time, but if 'perm_invent' is enabled then they might be [not any more...]) */ - if (iflags.suppress_price || svp.program_state.restoring) { + if (iflags.suppress_price || program_state.restoring) { ; /* don't attempt to obtain any shop pricing, even if 'with_price' */ } else if (is_unpaid(obj)) { /* in inventory or in container in invent */ char pricebuf[40]; @@ -4894,7 +4894,7 @@ readobjnam(char *bp, struct obj *no_wish) * Disallow such topology tweaks for WIZKIT startup wishes. */ wiztrap: - if (wizard && !svp.program_state.wizkit_wishing && !d.oclass) { + if (wizard && !program_state.wizkit_wishing && !d.oclass) { /* [inline code moved to separate routine to unclutter readobjnam] */ if ((d.otmp = wizterrainwish(&d)) != 0) return d.otmp; @@ -4982,7 +4982,7 @@ readobjnam(char *bp, struct obj *no_wish) if (rn1cnt > 6 - d.gsize) rn1cnt = 6 - d.gsize; if (d.cnt > rn1cnt - && (!wizard || svp.program_state.wizkit_wishing + && (!wizard || program_state.wizkit_wishing || y_n("Override glob weight limit?") != 'y')) d.cnt = rn1cnt; d.otmp->owt *= (unsigned) d.cnt; diff --git a/src/options.c b/src/options.c index 73c87703d..e454aa31f 100644 --- a/src/options.c +++ b/src/options.c @@ -578,7 +578,7 @@ parseoptions( } /* allow optfn's to test whether they were called from parseoptions() */ - svp.program_state.in_parseoptions++; + program_state.in_parseoptions++; if (got_match && matchidx >= 0) { duplicate = duplicate_opt_detection(matchidx); @@ -604,8 +604,8 @@ parseoptions( } } - if (svp.program_state.in_parseoptions > 0) - svp.program_state.in_parseoptions--; + if (program_state.in_parseoptions > 0) + program_state.in_parseoptions--; #if 0 /* This specialization shouldn't be needed any longer because each of diff --git a/src/pager.c b/src/pager.c index 96dab253b..5c2b8de8d 100644 --- a/src/pager.c +++ b/src/pager.c @@ -507,7 +507,7 @@ waterbody_name(coordxy x, coordxy y) { static char pooltype[40]; schar ltyp; - boolean hallucinate = Hallucination && !svp.program_state.gameover; + boolean hallucinate = Hallucination && !program_state.gameover; if (!isok(x, y)) return "drink"; /* should never happen */ @@ -1203,7 +1203,7 @@ do_screen_description( skipped_venom = 0, found = 0; /* count of matching syms found */ boolean hit_trap, need_to_look = FALSE, submerged = (Underwater && !Is_waterlevel(&u.uz)), - hallucinate = (Hallucination && !svp.program_state.gameover); + hallucinate = (Hallucination && !program_state.gameover); const char *x_str; nhsym tmpsym; glyph_info glyphinfo = nul_glyphinfo; diff --git a/src/pline.c b/src/pline.c index e837780dc..010dea488 100644 --- a/src/pline.c +++ b/src/pline.c @@ -157,10 +157,10 @@ vpline(const char *line, va_list the_args) if (!line || !*line) return; #ifdef HANGUPHANDLING - if (svp.program_state.done_hup) + if (program_state.done_hup) return; #endif - if (svp.program_state.wizkit_wishing) + if (program_state.wizkit_wishing) return; if (a11y.accessiblemsg && isok(a11y.msg_loc.x,a11y.msg_loc.y)) { @@ -542,7 +542,7 @@ raw_printf(const char *line, ...) va_start(the_args, line); vraw_printf(line, the_args); va_end(the_args); - if (!svp.program_state.beyond_savefile_load) + if (!program_state.beyond_savefile_load) ge.early_raw_messages++; } @@ -567,7 +567,7 @@ vraw_printf(const char *line, va_list the_args) #if defined(MSGHANDLER) execplinehandler(line); #endif - if (!svp.program_state.beyond_savefile_load) + if (!program_state.beyond_savefile_load) ge.early_raw_messages++; } @@ -579,10 +579,10 @@ impossible(const char *s, ...) char pbuf2[BUFSZ]; va_start(the_args, s); - if (svp.program_state.in_impossible) + if (program_state.in_impossible) panic("impossible called impossible"); - svp.program_state.in_impossible = 1; + program_state.in_impossible = 1; (void) vsnprintf(pbuf, sizeof pbuf, s, the_args); va_end(the_args); pbuf[BUFSZ - 1] = '\0'; /* sanity */ @@ -594,14 +594,14 @@ impossible(const char *s, ...) pline("%s", pbuf); gp.pline_flags = 0; - if (svp.program_state.in_sanity_check) { + if (program_state.in_sanity_check) { /* skip rest of multi-line feedback */ - svp.program_state.in_impossible = 0; + program_state.in_impossible = 0; return; } Strcpy(pbuf2, "Program in disorder!"); - if (svp.program_state.something_worth_saving) + if (program_state.something_worth_saving) Strcat(pbuf2, " (Saving and reloading may fix this problem.)"); pline("%s", pbuf2); pline("Please report these messages to %s.", DEVTEAM_EMAIL); @@ -621,7 +621,7 @@ impossible(const char *s, ...) } #endif - svp.program_state.in_impossible = 0; + program_state.in_impossible = 0; } RESTORE_WARNING_FORMAT_NONLITERAL diff --git a/src/polyself.c b/src/polyself.c index 2cc1807f0..a40570f83 100644 --- a/src/polyself.c +++ b/src/polyself.c @@ -109,7 +109,7 @@ set_uasmon(void) which won't be known during the restore process: but BFlying and BStealth should be set correctly already in that case, so there's nothing to do */ - if (!svp.program_state.restoring) + if (!program_state.restoring) float_vs_flight(); /* maybe toggle (BFlying & I_SPECIAL) */ polysense(); diff --git a/src/priest.c b/src/priest.c index d1ab0cdb1..57de18440 100644 --- a/src/priest.c +++ b/src/priest.c @@ -365,7 +365,7 @@ priestname( /* same as distant_monnam(), more or less... */ if (do_hallu || !high_priest || reveal_high_priest || !Is_astralevel(&u.uz) - || m_next2u(mon) || svp.program_state.gameover) { + || m_next2u(mon) || program_state.gameover) { Strcat(pname, " of "); Strcat(pname, halu_gname(mon_aligntyp(mon))); } diff --git a/src/questpgr.c b/src/questpgr.c index d7a2ec448..29ef494c8 100644 --- a/src/questpgr.c +++ b/src/questpgr.c @@ -456,7 +456,7 @@ staticfn boolean skip_pager(boolean common UNUSED) { /* WIZKIT: suppress plot feedback if starting with quest artifact */ - if (svp.program_state.wizkit_wishing) + if (program_state.wizkit_wishing) return TRUE; return FALSE; } diff --git a/src/restore.c b/src/restore.c index 31b57d2e3..fe02aff0c 100644 --- a/src/restore.c +++ b/src/restore.c @@ -721,7 +721,7 @@ restlevelfile(xint8 ltmp) nhfp = create_levelfile(ltmp, whynot); if (!nhfp) { /* failed to create a new file; don't attempt to make a panic save */ - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; panic("restlevelfile: %s", whynot); } bufon(nhfp->fd); @@ -738,7 +738,7 @@ dorecover(NHFILE *nhfp) int rtmp; /* suppress map display if some part of the code tries to update that */ - svp.program_state.restoring = REST_GSTATE; + program_state.restoring = REST_GSTATE; get_plname_from_file(nhfp, svp.plname); getlev(nhfp, 0, (xint8) 0); @@ -755,7 +755,7 @@ dorecover(NHFILE *nhfp) close_nhfile(nhfp); (void) delete_savefile(); u.usteed_mid = u.ustuck_mid = 0; - svp.program_state.restoring = 0; + program_state.restoring = 0; return 0; } /* after restgamestate() -> restnames() so that 'bases[]' is populated */ @@ -769,7 +769,7 @@ dorecover(NHFILE *nhfp) if (rtmp < 2) return rtmp; /* dorecover called recursively */ - svp.program_state.restoring = REST_LEVELS; + program_state.restoring = REST_LEVELS; /* these pointers won't be valid while we're processing the * other levels, but they'll be reset again by restlevelstate() @@ -831,12 +831,12 @@ dorecover(NHFILE *nhfp) get_plname_from_file(nhfp, svp.plname); /* not 0 nor REST_GSTATE nor REST_LEVELS */ - svp.program_state.restoring = REST_CURRENT_LEVEL; + program_state.restoring = REST_CURRENT_LEVEL; getlev(nhfp, 0, (xint8) 0); close_nhfile(nhfp); restlevelstate(); - svp.program_state.something_worth_saving = 1; /* useful data now exists */ + program_state.something_worth_saving = 1; /* useful data now exists */ if (!wizard && !discover) (void) delete_savefile(); @@ -866,9 +866,9 @@ dorecover(NHFILE *nhfp) gv.vision_full_recalc = 1; /* recompute vision (not saved) */ run_timers(); /* expire all timers that have gone off while away */ - svp.program_state.restoring = 0; /* affects bot() so clear before docrt() */ + program_state.restoring = 0; /* affects bot() so clear before docrt() */ - if (ge.early_raw_messages && !svp.program_state.beyond_savefile_load) { + if (ge.early_raw_messages && !program_state.beyond_savefile_load) { /* * We're about to obliterate some potentially important * startup messages, so give the player a chance to see them. @@ -877,7 +877,7 @@ dorecover(NHFILE *nhfp) wait_synch(); } u.usteed_mid = u.ustuck_mid = 0; - svp.program_state.beyond_savefile_load = 1; + program_state.beyond_savefile_load = 1; docrt(); clear_nhwindow(WIN_MESSAGE); @@ -907,7 +907,7 @@ rest_stairs(NHFILE *nhfp) if (nhfp->structlevel) { Mread(nhfp->fd, &stway, sizeof stway); } - if (svp.program_state.restoring != REST_GSTATE + if (program_state.restoring != REST_GSTATE && stway.tolev.dnum == u.uz.dnum) { /* stairway dlevel is relative, make it absolute */ stway.tolev.dlevel += u.uz.dlevel; @@ -1012,7 +1012,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev) short tlev; #endif - svp.program_state.in_getlev = TRUE; + program_state.in_getlev = TRUE; if (ghostly) clear_id_mapping(); @@ -1096,7 +1096,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev) if (nhfp->structlevel) Mread(nhfp->fd, trap, sizeof *trap); if (trap->tx != 0) { - if (svp.program_state.restoring != REST_GSTATE + if (program_state.restoring != REST_GSTATE && trap->dst.dnum == u.uz.dnum) { /* convert relative destination to absolute */ trap->dst.dlevel += u.uz.dlevel; @@ -1140,7 +1140,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev) } /* regenerate monsters while on another level */ - if (!u.uz.dlevel || svp.program_state.restoring == REST_LEVELS) + if (!u.uz.dlevel || program_state.restoring == REST_LEVELS) continue; if (ghostly) { /* reset peaceful/malign relative to new character; @@ -1242,7 +1242,7 @@ getlev(NHFILE *nhfp, int pid, xint8 lev) if (ghostly) clear_id_mapping(); - svp.program_state.in_getlev = FALSE; + program_state.in_getlev = FALSE; } void diff --git a/src/role.c b/src/role.c index 7707e34c7..cc490642f 100644 --- a/src/role.c +++ b/src/role.c @@ -2204,7 +2204,7 @@ genl_player_setup(int screenheight) char pick4u = 'n'; int result = 0; /* assume failure (player chooses to 'quit') */ - svp.program_state.in_role_selection++; /* affects tty menu cleanup */ + program_state.in_role_selection++; /* affects tty menu cleanup */ /* Used to avoid "Is this ok?" if player has already specified all * four facets of role. * Note that rigid_role_checks might force any unspecified facets to @@ -2704,7 +2704,7 @@ genl_player_setup(int screenheight) result = 1; setup_done: - svp.program_state.in_role_selection--; + program_state.in_role_selection--; return result; } diff --git a/src/rumors.c b/src/rumors.c index 540e6f214..11545fb6d 100644 --- a/src/rumors.c +++ b/src/rumors.c @@ -763,16 +763,16 @@ doconsult(struct monst *oracl) staticfn void couldnt_open_file(const char *filename) { - int save_something = svp.program_state.something_worth_saving; + int save_something = program_state.something_worth_saving; /* most likely the file is missing, so suppress impossible()'s "saving and restoring might fix this" (unless the fuzzer, which escalates impossible to panic, is running) */ if (!iflags.debug_fuzzer) - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; impossible("Can't open '%s' file.", filename); - svp.program_state.something_worth_saving = save_something; + program_state.something_worth_saving = save_something; } /* is 'word' a capitalized monster name that should be preceded by "the"? diff --git a/src/save.c b/src/save.c index 864f17ead..d46d18633 100644 --- a/src/save.c +++ b/src/save.c @@ -41,7 +41,7 @@ staticfn void zerocomp_bputc(int); #endif #if defined(HANGUPHANDLING) -#define HUP if (!svp.program_state.done_hup) +#define HUP if (!program_state.done_hup) #else #define HUP #endif @@ -59,7 +59,7 @@ dosave(void) clear_nhwindow(WIN_MESSAGE); pline("Saving..."); #if defined(HANGUPHANDLING) - svp.program_state.done_hup = 0; + program_state.done_hup = 0; #endif if (dosave0()) { u.uhp = -1; /* universal game's over indicator */ @@ -86,7 +86,7 @@ dosave0(void) NHFILE *nhfp, *onhfp; int res = 0; - svp.program_state.saving++; /* inhibit status and perm_invent updates */ + program_state.saving++; /* inhibit status and perm_invent updates */ /* we may get here via hangup signal, in which case we want to fix up a few of things before saving so that they won't be restored in an improper state; these will be no-ops for normal save sequence */ @@ -103,7 +103,7 @@ dosave0(void) when punished, make sure ball and chain are placed too */ done_object_cleanup(); /* maybe force some items onto map */ - if (!svp.program_state.something_worth_saving || !gs.SAVEF[0]) + if (!program_state.something_worth_saving || !gs.SAVEF[0]) goto done; fq_save = fqname(gs.SAVEF, SAVEPREFIX, 1); /* level files take 0 */ @@ -230,11 +230,11 @@ dosave0(void) delete_levelfile(0); nh_compress(fq_save); /* this should probably come sooner... */ - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; res = 1; done: - svp.program_state.saving--; + program_state.saving--; return res; } @@ -276,7 +276,7 @@ savegamestate(NHFILE *nhfp) { unsigned long uid; - svp.program_state.saving++; /* caller should/did already set this... */ + program_state.saving++; /* caller should/did already set this... */ uid = (unsigned long) getuid(); if (nhfp->structlevel) { bwrite(nhfp->fd, (genericptr_t) &uid, sizeof uid); @@ -338,7 +338,7 @@ savegamestate(NHFILE *nhfp) save_luadata(nhfp); if (nhfp->structlevel) bflush(nhfp->fd); - svp.program_state.saving--; + program_state.saving--; return; } @@ -364,7 +364,7 @@ savestateinlock(void) char whynot[BUFSZ]; NHFILE *nhfp; - svp.program_state.saving++; /* inhibit status and perm_invent updates */ + program_state.saving++; /* inhibit status and perm_invent updates */ /* When checkpointing is on, the full state needs to be written * on each checkpoint. When checkpointing is off, only the pid * needs to be in the level.0 file, so it does not need to be @@ -385,7 +385,7 @@ savestateinlock(void) */ nhfp = open_levelfile(0, whynot); if (tricked_fileremoved(nhfp, whynot)) { - svp.program_state.saving--; + program_state.saving--; return; } @@ -408,7 +408,7 @@ savestateinlock(void) than after so that screen updating behaves normally; game data shouldn't be inconsistent yet, unlike it would become midway through saving */ - svp.program_state.saving--; + program_state.saving--; done(TRICKED); return; } @@ -433,7 +433,7 @@ savestateinlock(void) } close_nhfile(nhfp); } - svp.program_state.saving--; + program_state.saving--; gh.havestate = flags.ins_chkpt; return; } @@ -450,7 +450,7 @@ savelev(NHFILE *nhfp, xint8 lev) but we'll be called during run-down */ if (set_uz_save && perform_bwrite(nhfp)) { if (u.uz.dnum == 0 && u.uz.dlevel == 0) { - svp.program_state.something_worth_saving = 0; + program_state.something_worth_saving = 0; panic("savelev: where are we?"); } gu.uz_save = u.uz; @@ -469,7 +469,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) short tlev; #endif - svp.program_state.saving++; /* even if current mode is FREEING */ + program_state.saving++; /* even if current mode is FREEING */ if (!nhfp) panic("Save on bad file!"); /* impossible */ @@ -564,7 +564,7 @@ savelev_core(NHFILE *nhfp, xint8 lev) if (nhfp->structlevel) bflush(nhfp->fd); } - svp.program_state.saving--; + program_state.saving--; if (release_data(nhfp)) { clear_level_structures(); gf.ftrap = 0; @@ -717,7 +717,7 @@ save_stairs(NHFILE *nhfp) while (stway) { if (perform_bwrite(nhfp)) { - boolean use_relative = (svp.program_state.restoring != REST_GSTATE + boolean use_relative = (program_state.restoring != REST_GSTATE && stway->tolev.dnum == u.uz.dnum); if (use_relative) { /* make dlevel relative to current level */ @@ -988,7 +988,7 @@ savetrapchn(NHFILE *nhfp, struct trap *trap) struct trap *trap2; while (trap) { - boolean use_relative = (svp.program_state.restoring != REST_GSTATE + boolean use_relative = (program_state.restoring != REST_GSTATE && trap->dst.dnum == u.uz.dnum); trap2 = trap->ntrap; if (use_relative) diff --git a/src/sfstruct.c b/src/sfstruct.c index 4c19b6403..ae0b2c5fd 100644 --- a/src/sfstruct.c +++ b/src/sfstruct.c @@ -194,7 +194,7 @@ bwrite(int fd, const genericptr_t loc, unsigned num) } if (failed) { #if defined(HANGUPHANDLING) - if (svp.program_state.done_hup) + if (program_state.done_hup) nh_terminate(EXIT_FAILURE); else #endif @@ -230,7 +230,7 @@ mread(int fd, genericptr_t buf, unsigned len) } else { pline("Read %d instead of %u bytes.", (int) rlen, len); display_nhwindow(WIN_MESSAGE, TRUE); /* flush before error() */ - if (svp.program_state.restoring) { + if (program_state.restoring) { (void) nhclose(fd); (void) delete_savefile(); error("Error restoring old game."); diff --git a/src/shk.c b/src/shk.c index aa2abdb8a..b91a3bc8b 100644 --- a/src/shk.c +++ b/src/shk.c @@ -4908,7 +4908,7 @@ after_shk_move(struct monst *shkp) /* reset bill_p, need to re-calc player's occupancy too */ eshkp->bill_p = &eshkp->bill[0]; /* only re-check occupancy if game hasn't just ended */ - if (!svp.program_state.gameover) + if (!program_state.gameover) check_special_room(FALSE); } } diff --git a/src/shknam.c b/src/shknam.c index 994e6238d..7bd9f4e21 100644 --- a/src/shknam.c +++ b/src/shknam.c @@ -865,7 +865,7 @@ shkname(struct monst *mtmp) } else { const char *shknm = ESHK(mtmp)->shknam; - if (Hallucination && !svp.program_state.gameover) { + if (Hallucination && !program_state.gameover) { const char *const *nlp; int num; diff --git a/src/topten.c b/src/topten.c index 7bd993ca0..4742b9b02 100644 --- a/src/topten.c +++ b/src/topten.c @@ -24,7 +24,7 @@ static long final_fpos; /* [note: do not move this to the 'g' struct] */ #endif -#define done_stopprint svp.program_state.stopprint +#define done_stopprint program_state.stopprint #define newttentry() (struct toptenentry *) alloc(sizeof (struct toptenentry)) #define dealloc_ttentry(ttent) free((genericptr_t) (ttent)) @@ -642,7 +642,7 @@ topten(int how, time_t when) * topten uses alloc() several times, which will lead to * problems if the panic was the result of an alloc() failure. */ - if (svp.program_state.panicking) + if (program_state.panicking) return; if (iflags.toptenwin) { @@ -650,7 +650,7 @@ topten(int how, time_t when) } #if defined(HANGUPHANDLING) -#define HUP if (!svp.program_state.done_hup) +#define HUP if (!program_state.done_hup) #else #define HUP #endif diff --git a/src/vault.c b/src/vault.c index a30a3406d..eca749697 100644 --- a/src/vault.c +++ b/src/vault.c @@ -49,7 +49,7 @@ clear_fcorr(struct monst *grd, boolean forceshow) coordxy fcx, fcy, fcbeg; struct monst *mtmp; boolean sawcorridor = FALSE, - silently = svp.program_state.stopprint ? TRUE : FALSE; + silently = program_state.stopprint ? TRUE : FALSE; struct egd *egrd = EGD(grd); struct trap *trap; struct rm *lev; diff --git a/src/vision.c b/src/vision.c index ff80a29bf..34759bcad 100644 --- a/src/vision.c +++ b/src/vision.c @@ -521,7 +521,7 @@ vision_recalc(int control) int oldseenv; /* previous seenv value */ gv.vision_full_recalc = 0; /* reset flag */ - if (gi.in_mklev || svp.program_state.in_getlev || !iflags.vision_inited) + if (gi.in_mklev || program_state.in_getlev || !iflags.vision_inited) return; /* @@ -825,9 +825,9 @@ vision_recalc(int control) /* This newsym() caused a crash delivering msg about failure to open * dungeon file init_dungeons() -> panic() -> done(11) -> * vision_recalc(2) -> newsym() -> crash! u.ux and u.uy are 0 and - * svp.program_state.panicking == 1 under those circumstances + * program_state.panicking == 1 under those circumstances */ - if (!svp.program_state.panicking) + if (!program_state.panicking) newsym(u.ux, u.uy); /* Make sure the hero shows up! */ /* Set the new min and max pointers. */ diff --git a/src/windows.c b/src/windows.c index 8d4c7e6ff..967b8db8d 100644 --- a/src/windows.c +++ b/src/windows.c @@ -1814,7 +1814,7 @@ add_menu_heading(winid tmpwin, const char *buf) color = iflags.menu_headings.color; /* suppress highlighting during end-of-game disclosure */ - if (svp.program_state.gameover) + if (program_state.gameover) attr = ATR_NONE, color = NO_COLOR; add_menu(tmpwin, &nul_glyphinfo, &any, '\0', '\0', attr, color, @@ -1862,10 +1862,10 @@ getlin(const char *query, char *bufp) { boolean old_bot_disabled = gb.bot_disabled; - svp.program_state.in_getlin = 1; + program_state.in_getlin = 1; gb.bot_disabled = TRUE; (*windowprocs.win_getlin)(query, bufp); gb.bot_disabled = old_bot_disabled; - svp.program_state.in_getlin = 0; + program_state.in_getlin = 0; } /*windows.c*/ diff --git a/src/wizcmds.c b/src/wizcmds.c index abab4313a..197a08bee 100644 --- a/src/wizcmds.c +++ b/src/wizcmds.c @@ -1435,7 +1435,7 @@ sanity_check(void) iflags.sanity_no_check = FALSE; return; } - svp.program_state.in_sanity_check++; + program_state.in_sanity_check++; you_sanity_check(); obj_sanity_check(); timer_sanity_check(); @@ -1444,7 +1444,7 @@ sanity_check(void) bc_sanity_check(); trap_sanity_check(); engraving_sanity_check(); - svp.program_state.in_sanity_check--; + program_state.in_sanity_check--; } /* qsort() comparison routine for use in list_migrating_mons() */ diff --git a/sys/libnh/libnhmain.c b/sys/libnh/libnhmain.c index 48a6c17f6..06f8c93d0 100644 --- a/sys/libnh/libnhmain.c +++ b/sys/libnh/libnhmain.c @@ -193,7 +193,7 @@ nhmain(int argc, char *argv[]) * It seems you really want to play. */ u.uhp = 1; /* prevent RIP on early quits */ - svp.program_state.preserve_locks = 1; + program_state.preserve_locks = 1; #ifndef NO_SIGNAL sethanguphandler((SIG_RET_TYPE) hangup); #endif @@ -272,7 +272,7 @@ nhmain(int argc, char *argv[]) */ if (*svp.plname) { getlock(); - svp.program_state.preserve_locks = 0; /* after getlock() */ + program_state.preserve_locks = 0; /* after getlock() */ } if (*svp.plname && (nhfp = restore_saved_game()) != 0) { diff --git a/sys/msdos/vidvesa.c b/sys/msdos/vidvesa.c index db7f05bf3..08d92b7a3 100644 --- a/sys/msdos/vidvesa.c +++ b/sys/msdos/vidvesa.c @@ -794,7 +794,7 @@ vesa_cliparound(int x, int y) clipymax = ROWNO - 1; } if (clipx != oldx || clipy != oldy) { - if (on_level(&u.uz0, &u.uz) && !svp.program_state.restoring) + if (on_level(&u.uz0, &u.uz) && !program_state.restoring) /* (void) doredraw(); */ vesa_redrawmap(); } diff --git a/sys/msdos/vidvga.c b/sys/msdos/vidvga.c index 035343cad..f2473cfc5 100644 --- a/sys/msdos/vidvga.c +++ b/sys/msdos/vidvga.c @@ -472,7 +472,7 @@ vga_cliparound(int x, int y UNUSED) clipx = clipxmax - (viewport_size - 1); } if (clipx != oldx) { - if (on_level(&u.uz0, &u.uz) && !svp.program_state.restoring) + if (on_level(&u.uz0, &u.uz) && !program_state.restoring) /* (void) doredraw(); */ vga_redrawmap(1); } diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index d81748e80..679f5e627 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -164,7 +164,7 @@ main(int argc, char *argv[]) */ u.uhp = 1; /* prevent RIP on early quits */ #if defined(HANGUPHANDLING) - svp.program_state.preserve_locks = 1; + program_state.preserve_locks = 1; #ifndef NO_SIGNAL sethanguphandler((SIG_RET_TYPE) hangup); #endif @@ -239,7 +239,7 @@ main(int argc, char *argv[]) if (*svp.plname) { getlock(); #if defined(HANGUPHANDLING) - svp.program_state.preserve_locks = 0; /* after getlock() */ + program_state.preserve_locks = 0; /* after getlock() */ #endif } @@ -276,8 +276,8 @@ main(int argc, char *argv[]) } } } - if (svp.program_state.in_self_recover) { - svp.program_state.in_self_recover = FALSE; + if (program_state.in_self_recover) { + program_state.in_self_recover = FALSE; } } diff --git a/sys/unix/unixunix.c b/sys/unix/unixunix.c index 725c790c3..8450da5f8 100644 --- a/sys/unix/unixunix.c +++ b/sys/unix/unixunix.c @@ -82,7 +82,7 @@ eraseoldlocks(void) int i; #if defined(HANGUPHANDLING) - svp.program_state.preserve_locks = 0; /* not required but shows intent */ + program_state.preserve_locks = 0; /* not required but shows intent */ /* cannot use maxledgerno() here, because we need to find a lock name * before starting everything (including the dungeon initialization * that sets astral_level, needed for maxledgerno()) up @@ -216,7 +216,7 @@ getlock(void) } #ifdef SELF_RECOVER if (c == 'r' || c == 'R') { - if (recover_savefile() && svp.program_state.in_self_recover) { + if (recover_savefile() && program_state.in_self_recover) { set_levelfile_name(gl.lock, 0); fq_lock = fqname(gl.lock, LEVELPREFIX, 0); goto gotlock; diff --git a/sys/vms/vmsmain.c b/sys/vms/vmsmain.c index 0c5045ab9..dcb681caa 100644 --- a/sys/vms/vmsmain.c +++ b/sys/vms/vmsmain.c @@ -412,7 +412,7 @@ byebye(void) (void) sys$delprc(&mail_pid, (genericptr_t) 0), mail_pid = 0; #endif #ifdef FREE_ALL_MEMORY - if (progname && !svp.program_state.panicking) { + if (progname && !program_state.panicking) { if (gh.hname == progname) gh.hname = (char *) 0; free((genericptr_t) progname), progname = (char *) 0; @@ -421,7 +421,7 @@ byebye(void) /* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */ hup = (void (*)(int)) signal(SIGHUP, SIG_IGN); - if (!svp.program_state.exiting++ + if (!program_state.exiting++ && hup != (void (*)(int)) SIG_DFL && hup != (void (*)(int)) SIG_IGN) { (*hup)(SIGHUP); @@ -446,7 +446,7 @@ genericptr_t mechargs) /* [0] is argc, [1..argc] are the real args */ if (condition == SS$_ACCVIO /* access violation */ || (condition >= SS$_ASTFLT && condition <= SS$_TBIT) || (condition >= SS$_ARTRES && condition <= SS$_INHCHME)) { - svp.program_state.done_hup = TRUE; /* pretend hangup has been attempted */ + program_state.done_hup = TRUE; /* pretend hangup has been attempted */ #if (NH_DEVEL_STATUS == NH_STATUS_RELEASED) if (wizard) #endif diff --git a/sys/vms/vmstty.c b/sys/vms/vmstty.c index 5ff2f8ce4..9bd26a9a5 100644 --- a/sys/vms/vmstty.c +++ b/sys/vms/vmstty.c @@ -158,7 +158,7 @@ vms_getchar(void) static volatile int recurse = 0; /* SMG is not AST re-entrant! */ #endif - if (svp.program_state.done_hup) { + if (program_state.done_hup) { /* hangup has occurred; do not attempt to get further user input */ return ESC; } diff --git a/sys/windows/consoletty.c b/sys/windows/consoletty.c index c38a4b36a..770c0f19b 100644 --- a/sys/windows/consoletty.c +++ b/sys/windows/consoletty.c @@ -936,7 +936,7 @@ void buffer_fill_to_end(cell_t * buffer, cell_t * fill, int x, int y) while (dst != sentinel) *dst++ = *fill; - if ((iflags.debug.immediateflips || !svp.program_state.in_moveloop) + if ((iflags.debug.immediateflips || !program_state.in_moveloop) && buffer == console.back_buffer) back_buffer_flip(); } @@ -952,7 +952,7 @@ static void buffer_clear_to_end_of_line(cell_t * buffer, int x, int y) while (dst != sentinel) *dst++ = clear_cell; - if (iflags.debug.immediateflips || !svp.program_state.in_moveloop) + if (iflags.debug.immediateflips || !program_state.in_moveloop) back_buffer_flip(); } @@ -964,7 +964,7 @@ void buffer_write(cell_t * buffer, cell_t * cell, COORD pos) cell_t * dst = buffer + (console.width * pos.Y) + pos.X; *dst = *cell; - if ((iflags.debug.immediateflips || !svp.program_state.in_moveloop) + if ((iflags.debug.immediateflips || !program_state.in_moveloop) && buffer == console.back_buffer) back_buffer_flip(); } @@ -1149,7 +1149,7 @@ tgetch(void) numpad |= 0x10; #endif - return (svp.program_state.done_hup) + return (program_state.done_hup) ? '\033' : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 0, &mod, &cc); @@ -1177,7 +1177,7 @@ console_poskey(coordxy *x, coordxy *y, int *mod) if (gc.Cmd.swap_yz) numpad |= 0x10; #endif - ch = (svp.program_state.done_hup) + ch = (program_state.done_hup) ? '\033' : keyboard_handling.pCheckInput( console.hConIn, &ir, &count, numpad, 1, mod, &cc); diff --git a/sys/windows/windmain.c b/sys/windows/windmain.c index 7f3868560..efa09ebb9 100644 --- a/sys/windows/windmain.c +++ b/sys/windows/windmain.c @@ -771,8 +771,8 @@ attempt_restore: } } } - if (svp.program_state.in_self_recover) { - svp.program_state.in_self_recover = FALSE; + if (program_state.in_self_recover) { + program_state.in_self_recover = FALSE; set_savefile_name(TRUE); } } diff --git a/win/Qt/qt_bind.cpp b/win/Qt/qt_bind.cpp index 6cfd17e58..d0128cc62 100644 --- a/win/Qt/qt_bind.cpp +++ b/win/Qt/qt_bind.cpp @@ -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; diff --git a/win/Qt/qt_main.cpp b/win/Qt/qt_main.cpp index eb22d36d7..73bade00f 100644 --- a/win/Qt/qt_main.cpp +++ b/win/Qt/qt_main.cpp @@ -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; diff --git a/win/Qt/qt_yndlg.cpp b/win/Qt/qt_yndlg.cpp index a23d9e616..57e2f212f 100644 --- a/win/Qt/qt_yndlg.cpp +++ b/win/Qt/qt_yndlg.cpp @@ -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) diff --git a/win/X11/winX.c b/win/X11/winX.c index b70bee5ea..f808541d5 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -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] ? "" diff --git a/win/X11/winmap.c b/win/X11/winmap.c index 62e1f44a3..d27f0ac88 100644 --- a/win/X11/winmap.c +++ b/win/X11/winmap.c @@ -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; diff --git a/win/X11/winmisc.c b/win/X11/winmisc.c index a6a421e57..1fcdf471c 100644 --- a/win/X11/winmisc.c +++ b/win/X11/winmisc.c @@ -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(); diff --git a/win/curses/cursdial.c b/win/curses/cursdial.c index c1c9c1534..8e6949d7b 100644 --- a/win/curses/cursdial.c +++ b/win/curses/cursdial.c @@ -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 { diff --git a/win/curses/cursmain.c b/win/curses/cursmain.c index 2fd1947ec..5dee9900b 100644 --- a/win/curses/cursmain.c +++ b/win/curses/cursmain.c @@ -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) { diff --git a/win/curses/cursmisc.c b/win/curses/cursmisc.c index 886233e94..73a939f2a 100644 --- a/win/curses/cursmisc.c +++ b/win/curses/cursmisc.c @@ -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; diff --git a/win/tty/getline.c b/win/tty/getline.c index 8a648c27d..1a8215c06 100644 --- a/win/tty/getline.c +++ b/win/tty/getline.c @@ -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') diff --git a/win/tty/topl.c b/win/tty/topl.c index 89de9e6a6..c20dfa288 100644 --- a/win/tty/topl.c +++ b/win/tty/topl.c @@ -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; } diff --git a/win/tty/wintty.c b/win/tty/wintty.c index 5ca2d5c45..17dcd1cc2 100644 --- a/win/tty/wintty.c +++ b/win/tty/wintty.c @@ -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; diff --git a/win/win32/mhinput.c b/win/win32/mhinput.c index c96aa168d..9ad6c32f0 100644 --- a/win/win32/mhinput.c +++ b/win/win32/mhinput.c @@ -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'; diff --git a/win/win32/mhmain.c b/win/win32/mhmain.c index 1bfa7fdb6..bd1a5be79 100644 --- a/win/win32/mhmain.c +++ b/win/win32/mhmain.c @@ -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); diff --git a/win/win32/mhmenu.c b/win/win32/mhmenu.c index a65bf9823..89d90e2ab 100644 --- a/win/win32/mhmenu.c +++ b/win/win32/mhmenu.c @@ -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; diff --git a/win/win32/mhrip.c b/win/win32/mhrip.c index 0f951ece5..3fb9ac9ba 100644 --- a/win/win32/mhrip.c +++ b/win/win32/mhrip.c @@ -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: diff --git a/win/win32/mswproc.c b/win/win32/mswproc.c index 9cdb7c2ec..40bfeb7ba 100644 --- a/win/win32/mswproc.c +++ b/win/win32/mswproc.c @@ -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);