program_state moved to g.

This commit is contained in:
Bart House
2018-12-25 10:09:04 -08:00
parent ab73df996f
commit b1ab64db43
45 changed files with 130 additions and 132 deletions
+3 -2
View File
@@ -98,7 +98,7 @@ E NEARDATA char tune[6];
#define MAXLINFO (MAXDUNGEON * MAXLEVEL) #define MAXLINFO (MAXDUNGEON * MAXLEVEL)
E NEARDATA struct sinfo { struct sinfo {
int gameover; /* self explanatory? */ int gameover; /* self explanatory? */
int stopprint; /* inhibit further end of game disclosure */ int stopprint; /* inhibit further end of game disclosure */
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
@@ -115,7 +115,7 @@ E NEARDATA struct sinfo {
int in_paniclog; int in_paniclog;
#endif #endif
int wizkit_wishing; int wizkit_wishing;
} program_state; };
E const char quitchars[]; E const char quitchars[];
E const char vowels[]; E const char vowels[];
@@ -713,6 +713,7 @@ struct instance_globals {
const char *alllevels = "levels.*"; const char *alllevels = "levels.*";
const char *allbones = "bones*.*"; const char *allbones = "bones*.*";
#endif #endif
struct sinfo program_state;
/* dig.c */ /* dig.c */
+3 -3
View File
@@ -72,10 +72,10 @@ boolean resuming;
g.youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */ g.youmonst.movement = NORMAL_SPEED; /* give the hero some movement points */
g.context.move = 0; g.context.move = 0;
program_state.in_moveloop = 1; g.program_state.in_moveloop = 1;
for (;;) { for (;;) {
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
if (program_state.done_hup) if (g.program_state.done_hup)
end_of_input(); end_of_input();
#endif #endif
get_nh_event(); get_nh_event();
@@ -623,7 +623,7 @@ newgame()
#ifdef INSURANCE #ifdef INSURANCE
save_currentstate(); save_currentstate();
#endif #endif
program_state.something_worth_saving++; /* useful data now exists */ g.program_state.something_worth_saving++; /* useful data now exists */
/* Success! */ /* Success! */
welcome(TRUE); welcome(TRUE);
+9 -9
View File
@@ -4475,7 +4475,7 @@ register char *cmd;
iflags.menu_requested = FALSE; iflags.menu_requested = FALSE;
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
if (program_state.done_hup) if (g.program_state.done_hup)
end_of_input(); end_of_input();
#endif #endif
if (firsttime) { if (firsttime) {
@@ -5612,8 +5612,8 @@ void
hangup(sig_unused) /* called as signal() handler, so sent at least one arg */ hangup(sig_unused) /* called as signal() handler, so sent at least one arg */
int sig_unused UNUSED; int sig_unused UNUSED;
{ {
if (program_state.exiting) if (g.program_state.exiting)
program_state.in_moveloop = 0; g.program_state.in_moveloop = 0;
nhwindows_hangup(); nhwindows_hangup();
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* When using SAFERHANGUP, the done_hup flag it tested in rhack /* When using SAFERHANGUP, the done_hup flag it tested in rhack
@@ -5622,9 +5622,9 @@ int sig_unused UNUSED;
protects against losing objects in the process of being thrown, protects against losing objects in the process of being thrown,
but also potentially riskier because the disconnected program but also potentially riskier because the disconnected program
must continue running longer before attempting a hangup save. */ must continue running longer before attempting a hangup save. */
program_state.done_hup++; g.program_state.done_hup++;
/* defer hangup iff game appears to be in progress */ /* defer hangup iff game appears to be in progress */
if (program_state.in_moveloop && program_state.something_worth_saving) if (g.program_state.in_moveloop && g.program_state.something_worth_saving)
return; return;
#endif /* SAFERHANGUP */ #endif /* SAFERHANGUP */
end_of_input(); end_of_input();
@@ -5635,16 +5635,16 @@ end_of_input()
{ {
#ifdef NOSAVEONHANGUP #ifdef NOSAVEONHANGUP
#ifdef INSURANCE #ifdef INSURANCE
if (flags.ins_chkpt && program_state.something_worth_saving) if (flags.ins_chkpt && g.program_state.something_worth_saving)
program_statue.preserve_locks = 1; /* keep files for recovery */ program_statue.preserve_locks = 1; /* keep files for recovery */
#endif #endif
program_state.something_worth_saving = 0; /* don't save */ g.program_state.something_worth_saving = 0; /* don't save */
#endif #endif
#ifndef SAFERHANGUP #ifndef SAFERHANGUP
if (!program_state.done_hup++) if (!g.program_state.done_hup++)
#endif #endif
if (program_state.something_worth_saving) if (g.program_state.something_worth_saving)
(void) dosave0(); (void) dosave0();
if (iflags.window_inited) if (iflags.window_inited)
exit_nhwindows((char *) 0); exit_nhwindows((char *) 0);
+5 -7
View File
@@ -5,8 +5,6 @@
#include "hack.h" #include "hack.h"
/* from xxxmain.c */
const char quitchars[] = " \r\n\033"; const char quitchars[] = " \r\n\033";
const char vowels[] = "aeiouAEIOU"; const char vowels[] = "aeiouAEIOU";
const char ynchars[] = "yn"; const char ynchars[] = "yn";
@@ -17,8 +15,6 @@ NEARDATA long yn_number = 0L;
const char disclosure_options[] = "iavgco"; const char disclosure_options[] = "iavgco";
NEARDATA struct sinfo program_state;
/* x/y/z deltas for the 10 movement directions (8 compass pts, 2 up/down) */ /* x/y/z deltas for the 10 movement directions (8 compass pts, 2 up/down) */
const schar xdir[10] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 }; const schar xdir[10] = { -1, -1, 0, 1, 1, 1, 0, -1, 0, 0 };
const schar ydir[10] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 }; const schar ydir[10] = { 0, -1, -1, -1, 0, 1, 1, 1, 0, 0 };
@@ -108,9 +104,7 @@ const char *materialnm[] = { "mysterious", "liquid", "wax", "organic",
"gemstone", "stone" }; "gemstone", "stone" };
/* Global windowing data, defined here for multi-window-system support */ /* Global windowing data, defined here for multi-window-system support */
NEARDATA winid WIN_MESSAGE = WIN_ERR; NEARDATA winid WIN_MESSAGE, WIN_STATUS, WIN_MAP, WIN_INVEN;
NEARDATA winid WIN_STATUS = WIN_ERR;
NEARDATA winid WIN_MAP = WIN_ERR, WIN_INVEN = WIN_ERR;
#ifdef PREFIXES_IN_USE #ifdef PREFIXES_IN_USE
const char *fqn_prefix_names[PREFIX_COUNT] = { const char *fqn_prefix_names[PREFIX_COUNT] = {
@@ -296,6 +290,7 @@ const struct instance_globals g_init = {
"levels.*", /* alllevels */ "levels.*", /* alllevels */
"bones*.*", /* allbones */ "bones*.*", /* allbones */
#endif #endif
UNDEFINED_VALUES, /* program_state */
/* dig.c */ /* dig.c */
UNDEFINED_VALUE, /* did_dig_msg */ UNDEFINED_VALUE, /* did_dig_msg */
@@ -628,6 +623,9 @@ decl_globals_init()
uarmh = uarms = uarmg = uarmf = uamul = uright = uleft = NULL; uarmh = uarms = uarmg = uarmf = uamul = uright = uleft = NULL;
ublindf = uchain = uball = NULL; ublindf = uchain = uball = NULL;
WIN_MESSAGE = WIN_STATUS = WIN_MAP = WIN_INVEN = WIN_ERR;
} }
/*decl.c*/ /*decl.c*/
+2 -2
View File
@@ -719,7 +719,7 @@ register int x, y;
if (g.in_mklev) if (g.in_mklev)
return; return;
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
if (program_state.done_hup) if (g.program_state.done_hup)
return; return;
#endif #endif
@@ -1561,7 +1561,7 @@ int cursor_on_u;
return; /* if already flushing then return */ return; /* if already flushing then return */
flushing = 1; flushing = 1;
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
if (program_state.done_hup) if (g.program_state.done_hup)
return; return;
#endif #endif
+1 -1
View File
@@ -744,7 +744,7 @@ struct obj *obj;
*/ */
if (!obj->oerodeproof || !rn2(10)) { if (!obj->oerodeproof || !rn2(10)) {
/* if monsters aren't moving, assume player is responsible */ /* if monsters aren't moving, assume player is responsible */
if (!g.context.mon_moving && !program_state.gameover) if (!g.context.mon_moving && !g.program_state.gameover)
costly_alteration(obj, COST_DEGRD); costly_alteration(obj, COST_DEGRD);
obj->otyp = WORM_TOOTH; obj->otyp = WORM_TOOTH;
obj->oerodeproof = 0; obj->oerodeproof = 0;
+2 -2
View File
@@ -1622,7 +1622,7 @@ boolean called;
boolean name_at_start, has_adjectives; boolean name_at_start, has_adjectives;
char *bp; char *bp;
if (program_state.gameover) if (g.program_state.gameover)
suppress |= SUPPRESS_HALLUCINATION; suppress |= SUPPRESS_HALLUCINATION;
if (article == ARTICLE_YOUR && !mtmp->mtame) if (article == ARTICLE_YOUR && !mtmp->mtame)
article = ARTICLE_THE; article = ARTICLE_THE;
@@ -1630,7 +1630,7 @@ boolean called;
do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION); do_hallu = Hallucination && !(suppress & SUPPRESS_HALLUCINATION);
do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE); do_invis = mtmp->minvis && !(suppress & SUPPRESS_INVISIBLE);
do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR do_it = !canspotmon(mtmp) && article != ARTICLE_YOUR
&& !program_state.gameover && mtmp != u.usteed && !g.program_state.gameover && mtmp != u.usteed
&& !(u.uswallow && mtmp == u.ustuck) && !(suppress & SUPPRESS_IT); && !(u.uswallow && mtmp == u.ustuck) && !(suppress & SUPPRESS_IT);
do_saddle = !(suppress & SUPPRESS_SADDLE); do_saddle = !(suppress & SUPPRESS_SADDLE);
do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat); do_name = !(suppress & SUPPRESS_NAME) || type_is_pname(mdat);
+17 -17
View File
@@ -49,7 +49,7 @@ extern void FDECL(nethack_exit, (int));
#define nethack_exit exit #define nethack_exit exit
#endif #endif
#define done_stopprint program_state.stopprint #define done_stopprint g.program_state.stopprint
#ifndef PANICTRACE #ifndef PANICTRACE
#define NH_abort NH_abort_ #define NH_abort NH_abort_
@@ -380,7 +380,7 @@ static void
done_hangup(sig) done_hangup(sig)
int sig; int sig;
{ {
program_state.done_hup++; g.program_state.done_hup++;
sethanguphandler((void FDECL((*), (int) )) SIG_IGN); sethanguphandler((void FDECL((*), (int) )) SIG_IGN);
done_intr(sig); done_intr(sig);
return; return;
@@ -545,7 +545,7 @@ VA_DECL(const char *, str)
VA_START(str); VA_START(str);
VA_INIT(str, char *); VA_INIT(str, char *);
if (program_state.panicking++) if (g.program_state.panicking++)
NH_abort(); /* avoid loops - this should never happen*/ NH_abort(); /* avoid loops - this should never happen*/
if (iflags.window_inited) { if (iflags.window_inited) {
@@ -555,9 +555,9 @@ VA_DECL(const char *, str)
iflags.window_inited = 0; /* they're gone; force raw_print()ing */ iflags.window_inited = 0; /* they're gone; force raw_print()ing */
} }
raw_print(program_state.gameover raw_print(g.program_state.gameover
? "Postgame wrapup disrupted." ? "Postgame wrapup disrupted."
: !program_state.something_worth_saving : !g.program_state.something_worth_saving
? "Program initialization has failed." ? "Program initialization has failed."
: "Suddenly, the dungeon collapses."); : "Suddenly, the dungeon collapses.");
#ifndef MICRO #ifndef MICRO
@@ -565,11 +565,11 @@ VA_DECL(const char *, str)
if (!wizard) if (!wizard)
raw_printf("Report the following error to \"%s\" or at \"%s\".", raw_printf("Report the following error to \"%s\" or at \"%s\".",
DEVTEAM_EMAIL, DEVTEAM_URL); DEVTEAM_EMAIL, DEVTEAM_URL);
else if (program_state.something_worth_saving) else if (g.program_state.something_worth_saving)
raw_print("\nError save file being written.\n"); raw_print("\nError save file being written.\n");
#else /* !NOTIFY_NETHACK_BUGS */ #else /* !NOTIFY_NETHACK_BUGS */
if (!wizard) { if (!wizard) {
const char *maybe_rebuild = !program_state.something_worth_saving const char *maybe_rebuild = !g.program_state.something_worth_saving
? "." ? "."
: "\nand it may be possible to rebuild."; : "\nand it may be possible to rebuild.";
@@ -587,7 +587,7 @@ VA_DECL(const char *, str)
/* XXX can we move this above the prints? Then we'd be able to /* XXX can we move this above the prints? Then we'd be able to
* suppress "it may be possible to rebuild" based on dosave0() * suppress "it may be possible to rebuild" based on dosave0()
* or say it's NOT possible to rebuild. */ * or say it's NOT possible to rebuild. */
if (program_state.something_worth_saving && !iflags.debug_fuzzer) { if (g.program_state.something_worth_saving && !iflags.debug_fuzzer) {
set_error_savefile(); set_error_savefile();
if (dosave0()) { if (dosave0()) {
/* os/win port specific recover instructions */ /* os/win port specific recover instructions */
@@ -1018,9 +1018,9 @@ int how;
return; return;
} }
} }
if (program_state.panicking if (g.program_state.panicking
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
|| program_state.done_hup || g.program_state.done_hup
#endif #endif
) { ) {
/* skip status update if panicking or disconnected */ /* skip status update if panicking or disconnected */
@@ -1032,7 +1032,7 @@ int how;
} }
if (iflags.debug_fuzzer) { if (iflags.debug_fuzzer) {
if (!(program_state.panicking || how == PANICKED)) { if (!(g.program_state.panicking || how == PANICKED)) {
savelife(how); savelife(how);
/* periodically restore characteristics and lost exp levels /* periodically restore characteristics and lost exp levels
or cure lycanthropy */ or cure lycanthropy */
@@ -1123,9 +1123,9 @@ int how;
/* /*
* The game is now over... * The game is now over...
*/ */
program_state.gameover = 1; g.program_state.gameover = 1;
/* in case of a subsequent panic(), there's no point trying to save */ /* in case of a subsequent panic(), there's no point trying to save */
program_state.something_worth_saving = 0; g.program_state.something_worth_saving = 0;
/* render vision subsystem inoperative */ /* render vision subsystem inoperative */
iflags.vision_inited = 0; iflags.vision_inited = 0;
@@ -1611,13 +1611,13 @@ void
nh_terminate(status) nh_terminate(status)
int status; int status;
{ {
program_state.in_moveloop = 0; /* won't be returning to normal play */ g.program_state.in_moveloop = 0; /* won't be returning to normal play */
#ifdef MAC #ifdef MAC
getreturn("to exit"); getreturn("to exit");
#endif #endif
/* don't bother to try to release memory if we're in panic mode, to /* 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 */ avoid trouble in case that happens to be due to memory problems */
if (!program_state.panicking) { if (!g.program_state.panicking) {
freedynamicdata(); freedynamicdata();
dlb_cleanup(); dlb_cleanup();
} }
@@ -1630,10 +1630,10 @@ int status;
*/ */
/* don't call exit() if already executing within an exit handler; /* don't call exit() if already executing within an exit handler;
that would cancel any other pending user-mode handlers */ that would cancel any other pending user-mode handlers */
if (program_state.exiting) if (g.program_state.exiting)
return; return;
#endif #endif
program_state.exiting = 1; g.program_state.exiting = 1;
nethack_exit(status); nethack_exit(status);
} }
+9 -9
View File
@@ -577,7 +577,7 @@ void
clearlocks() clearlocks()
{ {
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
if (program_state.preserve_locks) if (g.program_state.preserve_locks)
return; return;
#endif #endif
#if !defined(PC_LOCKING) && defined(MFLOPPY) && !defined(AMIGA) #if !defined(PC_LOCKING) && defined(MFLOPPY) && !defined(AMIGA)
@@ -1611,7 +1611,7 @@ static int lockfd; /* for lock_file() to pass to unlock_file() */
struct flock sflock; /* for unlocking, same as above */ struct flock sflock; /* for unlocking, same as above */
#endif #endif
#define HUP if (!program_state.done_hup) #define HUP if (!g.program_state.done_hup)
#ifndef USE_FCNTL #ifndef USE_FCNTL
STATIC_OVL char * STATIC_OVL char *
@@ -2341,13 +2341,13 @@ char *origbuf;
*ptr = '\0'; *ptr = '\0';
#ifdef MFLOPPY #ifdef MFLOPPY
if (*(ptr + 1) == 'n' || *(ptr + 1) == 'N') { if (*(ptr + 1) == 'n' || *(ptr + 1) == 'N') {
g.g.saveprompt = FALSE; g.saveprompt = FALSE;
} }
#endif #endif
} }
#if defined(SYSFLAGS) && defined(MFLOPPY) #if defined(SYSFLAGS) && defined(MFLOPPY)
else else
g.g.g.saveprompt = sysflags.asksavedisk; g.saveprompt = sysflags.asksavedisk;
#endif #endif
(void) strncpy(SAVEP, bufp, SAVESIZE - 1); (void) strncpy(SAVEP, bufp, SAVESIZE - 1);
@@ -2974,14 +2974,14 @@ read_wizkit()
if (!wizard || !(fp = fopen_wizkit_file())) if (!wizard || !(fp = fopen_wizkit_file()))
return; return;
program_state.wizkit_wishing = 1; g.program_state.wizkit_wishing = 1;
config_error_init(TRUE, "WIZKIT", FALSE); config_error_init(TRUE, "WIZKIT", FALSE);
parse_conf_file(fp, proc_wizkit_line); parse_conf_file(fp, proc_wizkit_line);
(void) fclose(fp); (void) fclose(fp);
config_error_done(); config_error_done();
program_state.wizkit_wishing = 0; g.program_state.wizkit_wishing = 0;
return; return;
} }
@@ -3531,8 +3531,8 @@ const char *reason; /* explanation */
FILE *lfile; FILE *lfile;
char buf[BUFSZ]; char buf[BUFSZ];
if (!program_state.in_paniclog) { if (!g.program_state.in_paniclog) {
program_state.in_paniclog = 1; g.program_state.in_paniclog = 1;
lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX); lfile = fopen_datafile(PANICLOG, "a", TROUBLEPREFIX);
if (lfile) { if (lfile) {
#ifdef PANICLOG_FMT2 #ifdef PANICLOG_FMT2
@@ -3550,7 +3550,7 @@ const char *reason; /* explanation */
#endif /* !PANICLOG_FMT2 */ #endif /* !PANICLOG_FMT2 */
(void) fclose(lfile); (void) fclose(lfile);
} }
program_state.in_paniclog = 0; g.program_state.in_paniclog = 0;
} }
#endif /* PANICLOG */ #endif /* PANICLOG */
return; return;
+2 -2
View File
@@ -220,7 +220,7 @@ struct obj *obj;
if (wizard) { /* flags.debug */ if (wizard) { /* flags.debug */
/* paranoia: before toggling off wizard mode, guard against a /* paranoia: before toggling off wizard mode, guard against a
panic in xname() producing a normal mode panic save file */ panic in xname() producing a normal mode panic save file */
program_state.something_worth_saving = 0; g.program_state.something_worth_saving = 0;
flags.debug = FALSE; flags.debug = FALSE;
} }
@@ -228,7 +228,7 @@ struct obj *obj;
if (save_debug) { if (save_debug) {
flags.debug = TRUE; flags.debug = TRUE;
program_state.something_worth_saving = 1; g.program_state.something_worth_saving = 1;
} }
/* restore the object */ /* restore the object */
if (obj->oclass == POTION_CLASS) { if (obj->oclass == POTION_CLASS) {
+1 -1
View File
@@ -739,7 +739,7 @@ movemon()
if (u.utotype if (u.utotype
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* or if the program has lost contact with the user */ /* or if the program has lost contact with the user */
|| program_state.done_hup || g.program_state.done_hup
#endif #endif
) { ) {
somebody_can_move = FALSE; somebody_can_move = FALSE;
+1 -1
View File
@@ -360,7 +360,7 @@ boolean credit_hero;
exercise(A_WIS, TRUE); exercise(A_WIS, TRUE);
} }
/* moves==1L => initial inventory, gameover => final disclosure */ /* moves==1L => initial inventory, gameover => final disclosure */
if (g.moves > 1L && !program_state.gameover) { if (g.moves > 1L && !g.program_state.gameover) {
if (objects[oindx].oc_class == GEM_CLASS) if (objects[oindx].oc_class == GEM_CLASS)
gem_learned(oindx); /* could affect price of unpaid gems */ gem_learned(oindx); /* could affect price of unpaid gems */
update_inventory(); update_inventory();
+3 -3
View File
@@ -204,7 +204,7 @@ struct obj *obj;
{ {
if (!obj->oartifact || !has_oname(obj)) if (!obj->oartifact || !has_oname(obj))
return FALSE; return FALSE;
if (!program_state.gameover && !iflags.override_ID) { if (!g.program_state.gameover && !iflags.override_ID) {
if (not_fully_identified(obj)) if (not_fully_identified(obj))
return FALSE; return FALSE;
} }
@@ -692,7 +692,7 @@ unsigned cxn_flags; /* bitmask of CXN_xxx values */
if (pluralize) if (pluralize)
Strcpy(buf, makeplural(buf)); Strcpy(buf, makeplural(buf));
if (obj->otyp == T_SHIRT && program_state.gameover) { if (obj->otyp == T_SHIRT && g.program_state.gameover) {
char tmpbuf[BUFSZ]; char tmpbuf[BUFSZ];
Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf)); Sprintf(eos(buf), " with text \"%s\"", tshirt_text(obj, tmpbuf));
@@ -3550,7 +3550,7 @@ srch:
* Disallow such topology tweaks for WIZKIT startup wishes. * Disallow such topology tweaks for WIZKIT startup wishes.
*/ */
wiztrap: wiztrap:
if (wizard && !program_state.wizkit_wishing) { if (wizard && !g.program_state.wizkit_wishing) {
struct rm *lev; struct rm *lev;
int trap, x = u.ux, y = u.uy; int trap, x = u.ux, y = u.uy;
+6 -6
View File
@@ -103,10 +103,10 @@ VA_DECL(const char *, line)
if (!line || !*line) if (!line || !*line)
return; return;
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
if (program_state.done_hup) if (g.program_state.done_hup)
return; return;
#endif #endif
if (program_state.wizkit_wishing) if (g.program_state.wizkit_wishing)
return; return;
if (index(line, '%')) { if (index(line, '%')) {
@@ -445,10 +445,10 @@ VA_DECL(const char *, s)
VA_START(s); VA_START(s);
VA_INIT(s, const char *); VA_INIT(s, const char *);
if (program_state.in_impossible) if (g.program_state.in_impossible)
panic("impossible called impossible"); panic("impossible called impossible");
program_state.in_impossible = 1; g.program_state.in_impossible = 1;
Vsprintf(pbuf, s, VA_ARGS); Vsprintf(pbuf, s, VA_ARGS);
pbuf[BUFSZ - 1] = '\0'; /* sanity */ pbuf[BUFSZ - 1] = '\0'; /* sanity */
paniclog("impossible", pbuf); paniclog("impossible", pbuf);
@@ -457,11 +457,11 @@ VA_DECL(const char *, s)
pline("%s", VA_PASS1(pbuf)); pline("%s", VA_PASS1(pbuf));
/* reuse pbuf[] */ /* reuse pbuf[] */
Strcpy(pbuf, "Program in disorder!"); Strcpy(pbuf, "Program in disorder!");
if (program_state.something_worth_saving) if (g.program_state.something_worth_saving)
Strcat(pbuf, " (Saving and reloading may fix this problem.)"); Strcat(pbuf, " (Saving and reloading may fix this problem.)");
pline("%s", VA_PASS1(pbuf)); pline("%s", VA_PASS1(pbuf));
program_state.in_impossible = 0; g.program_state.in_impossible = 0;
VA_END(); VA_END();
} }
+1 -1
View File
@@ -335,7 +335,7 @@ char *pname; /* caller-supplied output buffer */
Strcat(pname, what); Strcat(pname, what);
/* same as distant_monnam(), more or less... */ /* same as distant_monnam(), more or less... */
if (do_hallu || !high_priest || !Is_astralevel(&u.uz) if (do_hallu || !high_priest || !Is_astralevel(&u.uz)
|| distu(mon->mx, mon->my) <= 2 || program_state.gameover) { || distu(mon->mx, mon->my) <= 2 || g.program_state.gameover) {
Strcat(pname, " of "); Strcat(pname, " of ");
Strcat(pname, halu_gname(mon_aligntyp(mon))); Strcat(pname, halu_gname(mon_aligntyp(mon)));
} }
+1 -1
View File
@@ -574,7 +574,7 @@ skip_pager(common)
boolean common; boolean common;
{ {
/* WIZKIT: suppress plot feedback if starting with quest artifact */ /* WIZKIT: suppress plot feedback if starting with quest artifact */
if (program_state.wizkit_wishing) if (g.program_state.wizkit_wishing)
return TRUE; return TRUE;
if (!(common ? g.qt_list.common : g.qt_list.chrole)) { if (!(common ? g.qt_list.common : g.qt_list.chrole)) {
panic("%s: no %s quest text data available", panic("%s: no %s quest text data available",
+1 -1
View File
@@ -888,7 +888,7 @@ register int fd;
reset_restpref(); reset_restpref();
restlevelstate(stuckid, steedid); restlevelstate(stuckid, steedid);
program_state.something_worth_saving = 1; /* useful data now exists */ g.program_state.something_worth_saving = 1; /* useful data now exists */
if (!wizard && !discover) if (!wizard && !discover)
(void) delete_savefile(); (void) delete_savefile();
+3 -3
View File
@@ -544,16 +544,16 @@ STATIC_OVL void
couldnt_open_file(filename) couldnt_open_file(filename)
const char *filename; const char *filename;
{ {
int save_something = program_state.something_worth_saving; int save_something = g.program_state.something_worth_saving;
/* most likely the file is missing, so suppress impossible()'s /* most likely the file is missing, so suppress impossible()'s
"saving and restoring might fix this" (unless the fuzzer, "saving and restoring might fix this" (unless the fuzzer,
which escalates impossible to panic, is running) */ which escalates impossible to panic, is running) */
if (!iflags.debug_fuzzer) if (!iflags.debug_fuzzer)
program_state.something_worth_saving = 0; g.program_state.something_worth_saving = 0;
impossible("Can't open '%s' file.", filename); impossible("Can't open '%s' file.", filename);
program_state.something_worth_saving = save_something; g.program_state.something_worth_saving = save_something;
} }
/*rumors.c*/ /*rumors.c*/
+7 -7
View File
@@ -66,7 +66,7 @@ static struct save_procs {
}; };
#if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32) #if defined(UNIX) || defined(VMS) || defined(__EMX__) || defined(WIN32)
#define HUP if (!program_state.done_hup) #define HUP if (!g.program_state.done_hup)
#else #else
#define HUP #define HUP
#endif #endif
@@ -85,7 +85,7 @@ dosave()
clear_nhwindow(WIN_MESSAGE); clear_nhwindow(WIN_MESSAGE);
pline("Saving..."); pline("Saving...");
#if defined(UNIX) || defined(VMS) || defined(__EMX__) #if defined(UNIX) || defined(VMS) || defined(__EMX__)
program_state.done_hup = 0; g.program_state.done_hup = 0;
#endif #endif
if (dosave0()) { if (dosave0()) {
u.uhp = -1; /* universal game's over indicator */ u.uhp = -1; /* universal game's over indicator */
@@ -120,7 +120,7 @@ dosave0()
if (iflags.save_uburied) if (iflags.save_uburied)
u.uburied = 1, iflags.save_uburied = 0; u.uburied = 1, iflags.save_uburied = 0;
if (!program_state.something_worth_saving || !SAVEF[0]) if (!g.program_state.something_worth_saving || !SAVEF[0])
return 0; return 0;
fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */ fq_save = fqname(SAVEF, SAVEPREFIX, 1); /* level files take 0 */
@@ -269,7 +269,7 @@ dosave0()
delete_levelfile(0); delete_levelfile(0);
nh_compress(fq_save); nh_compress(fq_save);
/* this should probably come sooner... */ /* this should probably come sooner... */
program_state.something_worth_saving = 0; g.program_state.something_worth_saving = 0;
return 1; return 1;
} }
@@ -726,7 +726,7 @@ register unsigned num;
if (failed) { if (failed) {
#if defined(UNIX) || defined(VMS) || defined(__EMX__) #if defined(UNIX) || defined(VMS) || defined(__EMX__)
if (program_state.done_hup) if (g.program_state.done_hup)
nh_terminate(EXIT_FAILURE); nh_terminate(EXIT_FAILURE);
else else
#endif #endif
@@ -832,7 +832,7 @@ register int fd;
if (outbufp) { if (outbufp) {
if (write(fd, outbuf, outbufp) != outbufp) { if (write(fd, outbuf, outbufp) != outbufp) {
#if defined(UNIX) || defined(VMS) || defined(__EMX__) #if defined(UNIX) || defined(VMS) || defined(__EMX__)
if (program_state.done_hup) if (g.program_state.done_hup)
nh_terminate(EXIT_FAILURE); nh_terminate(EXIT_FAILURE);
else else
#endif #endif
@@ -858,7 +858,7 @@ register unsigned num;
#endif #endif
if ((unsigned) write(fd, loc, num) != num) { if ((unsigned) write(fd, loc, num) != num) {
#if defined(UNIX) || defined(VMS) || defined(__EMX__) #if defined(UNIX) || defined(VMS) || defined(__EMX__)
if (program_state.done_hup) if (g.program_state.done_hup)
nh_terminate(EXIT_FAILURE); nh_terminate(EXIT_FAILURE);
else else
#endif #endif
+1 -1
View File
@@ -851,7 +851,7 @@ struct monst *mtmp;
} else { } else {
const char *shknm = ESHK(mtmp)->shknam; const char *shknm = ESHK(mtmp)->shknam;
if (Hallucination && !program_state.gameover) { if (Hallucination && !g.program_state.gameover) {
const char *const *nlp; const char *const *nlp;
int num; int num;
+3 -3
View File
@@ -27,7 +27,7 @@
static long final_fpos; static long final_fpos;
#endif #endif
#define done_stopprint program_state.stopprint #define done_stopprint g.program_state.stopprint
#define newttentry() (struct toptenentry *) alloc(sizeof (struct toptenentry)) #define newttentry() (struct toptenentry *) alloc(sizeof (struct toptenentry))
#define dealloc_ttentry(ttent) free((genericptr_t) (ttent)) #define dealloc_ttentry(ttent) free((genericptr_t) (ttent))
@@ -511,7 +511,7 @@ time_t when;
* topten uses alloc() several times, which will lead to * topten uses alloc() several times, which will lead to
* problems if the panic was the result of an alloc() failure. * problems if the panic was the result of an alloc() failure.
*/ */
if (program_state.panicking) if (g.program_state.panicking)
return; return;
if (iflags.toptenwin) { if (iflags.toptenwin) {
@@ -519,7 +519,7 @@ time_t when;
} }
#if defined(UNIX) || defined(VMS) || defined(__EMX__) #if defined(UNIX) || defined(VMS) || defined(__EMX__)
#define HUP if (!program_state.done_hup) #define HUP if (!g.program_state.done_hup)
#else #else
#define HUP #define HUP
#endif #endif
+2 -2
View File
@@ -812,9 +812,9 @@ skip:
/* This newsym() caused a crash delivering msg about failure to open /* This newsym() caused a crash delivering msg about failure to open
* dungeon file init_dungeons() -> panic() -> done(11) -> * dungeon file init_dungeons() -> panic() -> done(11) ->
* vision_recalc(2) -> newsym() -> crash! u.ux and u.uy are 0 and * vision_recalc(2) -> newsym() -> crash! u.ux and u.uy are 0 and
* program_state.panicking == 1 under those circumstances * g.program_state.panicking == 1 under those circumstances
*/ */
if (!program_state.panicking) if (!g.program_state.panicking)
newsym(u.ux, u.uy); /* Make sure the hero shows up! */ newsym(u.ux, u.uy); /* Make sure the hero shows up! */
/* Set the new min and max pointers. */ /* Set the new min and max pointers. */
+2 -2
View File
@@ -191,7 +191,7 @@ char *argv[];
* It seems you really want to play. * It seems you really want to play.
*/ */
u.uhp = 1; /* prevent RIP on early quits */ u.uhp = 1; /* prevent RIP on early quits */
program_state.preserve_locks = 1; g.program_state.preserve_locks = 1;
#ifndef NO_SIGNAL #ifndef NO_SIGNAL
sethanguphandler((SIG_RET_TYPE) hangup); sethanguphandler((SIG_RET_TYPE) hangup);
#endif #endif
@@ -277,7 +277,7 @@ attempt_restore:
*/ */
if (*g.plname) { if (*g.plname) {
getlock(); getlock();
program_state.preserve_locks = 0; /* after getlock() */ g.program_state.preserve_locks = 0; /* after getlock() */
} }
if (*g.plname && (fd = restore_saved_game()) >= 0) { if (*g.plname && (fd = restore_saved_game()) >= 0) {
+1 -1
View File
@@ -75,7 +75,7 @@ eraseoldlocks()
{ {
register int i; register int i;
program_state.preserve_locks = 0; /* not required but shows intent */ g.program_state.preserve_locks = 0; /* not required but shows intent */
/* cannot use maxledgerno() here, because we need to find a lock name /* cannot use maxledgerno() here, because we need to find a lock name
* before starting everything (including the dungeon initialization * before starting everything (including the dungeon initialization
* that sets astral_level, needed for maxledgerno()) up * that sets astral_level, needed for maxledgerno()) up
+2 -2
View File
@@ -391,7 +391,7 @@ byebye()
/* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */ /* SIGHUP doesn't seem to do anything on VMS, so we fudge it here... */
hup = (void FDECL((*), (int) )) signal(SIGHUP, SIG_IGN); hup = (void FDECL((*), (int) )) signal(SIGHUP, SIG_IGN);
if (!program_state.exiting++ && hup != (void FDECL((*), (int) )) SIG_DFL if (!g.program_state.exiting++ && hup != (void FDECL((*), (int) )) SIG_DFL
&& hup != (void FDECL((*), (int) )) SIG_IGN) { && hup != (void FDECL((*), (int) )) SIG_IGN) {
(*hup)(SIGHUP); (*hup)(SIGHUP);
} }
@@ -414,7 +414,7 @@ genericptr_t sigargs, mechargs; /* [0] is argc, [1..argc] are the real args */
if (condition == SS$_ACCVIO /* access violation */ if (condition == SS$_ACCVIO /* access violation */
|| (condition >= SS$_ASTFLT && condition <= SS$_TBIT) || (condition >= SS$_ASTFLT && condition <= SS$_TBIT)
|| (condition >= SS$_ARTRES && condition <= SS$_INHCHME)) { || (condition >= SS$_ARTRES && condition <= SS$_INHCHME)) {
program_state.done_hup = TRUE; /* pretend hangup has been attempted */ g.program_state.done_hup = TRUE; /* pretend hangup has been attempted */
#ifndef BETA #ifndef BETA
if (wizard) if (wizard)
#endif #endif
+1 -1
View File
@@ -146,7 +146,7 @@ vms_getchar()
static volatile int recurse = 0; /* SMG is not AST re-entrant! */ static volatile int recurse = 0; /* SMG is not AST re-entrant! */
#endif #endif
if (program_state.done_hup) { if (g.program_state.done_hup) {
/* hangup has occurred; do not attempt to get further user input */ /* hangup has occurred; do not attempt to get further user input */
return ESC; return ESC;
} }
+3 -3
View File
@@ -39,7 +39,7 @@ mswin_have_input()
return return
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* we always have input (ESC) if hangup was requested */ /* we always have input (ESC) if hangup was requested */
program_state.done_hup || g.program_state.done_hup ||
#endif #endif
(nhi_read_pos != nhi_write_pos); (nhi_read_pos != nhi_write_pos);
} }
@@ -69,7 +69,7 @@ mswin_input_pop()
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* always return ESC when hangup was requested */ /* always return ESC when hangup was requested */
if (program_state.done_hup) { if (g.program_state.done_hup) {
static MSNHEvent hangup_event; static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR; hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033'; hangup_event.kbd.ch = '\033';
@@ -98,7 +98,7 @@ mswin_input_peek()
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* always return ESC when hangup was requested */ /* always return ESC when hangup was requested */
if (program_state.done_hup) { if (g.program_state.done_hup) {
static MSNHEvent hangup_event; static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR; hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033'; hangup_event.kbd.ch = '\033';
+1 -1
View File
@@ -533,7 +533,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
if (!data->text.text) { if (!data->text.text) {
data->text.text = mswin_init_text_buffer( data->text.text = mswin_init_text_buffer(
program_state.gameover ? FALSE : GetNHApp()->bWrapText); g.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
if (!data->text.text) if (!data->text.text)
break; break;
} }
+1 -1
View File
@@ -39,7 +39,7 @@ mswin_init_text_window()
ZeroMemory(data, sizeof(NHTextWindow)); ZeroMemory(data, sizeof(NHTextWindow));
data->window_text = mswin_init_text_buffer( data->window_text = mswin_init_text_buffer(
program_state.gameover ? FALSE : GetNHApp()->bWrapText); g.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
SetWindowLong(ret, GWL_USERDATA, (LONG) data); SetWindowLong(ret, GWL_USERDATA, (LONG) data);
return ret; return ret;
} }
-1
View File
@@ -25,7 +25,6 @@ static char author[] = "The NetHack Development Team";
extern HANDLE hConIn; extern HANDLE hConIn;
extern INPUT_RECORD ir; extern INPUT_RECORD ir;
extern struct sinfo program_state;
char dllname[512]; char dllname[512];
char *shortdllname; char *shortdllname;
+2 -2
View File
@@ -443,7 +443,7 @@ tgetch()
really_move_cursor(); really_move_cursor();
if (iflags.debug_fuzzer) if (iflags.debug_fuzzer)
return randomkey(); return randomkey();
return (program_state.done_hup) return (g.program_state.done_hup)
? '\033' ? '\033'
: keyboard_handler.pCheckInput( : keyboard_handler.pCheckInput(
console.hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc); console.hConIn, &ir, &count, iflags.num_pad, 0, &mod, &cc);
@@ -459,7 +459,7 @@ int *x, *y, *mod;
really_move_cursor(); really_move_cursor();
if (iflags.debug_fuzzer) if (iflags.debug_fuzzer)
return randomkey(); return randomkey();
ch = (program_state.done_hup) ch = (g.program_state.done_hup)
? '\033' ? '\033'
: keyboard_handler.pCheckInput( : keyboard_handler.pCheckInput(
console.hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc); console.hConIn, &ir, &count, iflags.num_pad, 1, mod, &cc);
+7 -7
View File
@@ -4029,7 +4029,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
void NetHackQtMainWindow::closeEvent(QCloseEvent* e) void NetHackQtMainWindow::closeEvent(QCloseEvent* e)
{ {
if ( program_state.something_worth_saving ) { if ( g.program_state.something_worth_saving ) {
switch ( QMessageBox::information( this, "NetHack", switch ( QMessageBox::information( this, "NetHack",
"This will end your NetHack session", "This will end your NetHack session",
"&Save", "&Cancel", 0, 1 ) ) "&Save", "&Cancel", 0, 1 ) )
@@ -4840,7 +4840,7 @@ void NetHackQtBind::qt_update_inventory()
if (main) if (main)
main->updateInventory(); main->updateInventory();
/* doesn't work yet /* doesn't work yet
if (program_state.something_worth_saving && iflags.perm_invent) if (g.program_state.something_worth_saving && iflags.perm_invent)
display_inventory(NULL, FALSE); display_inventory(NULL, FALSE);
*/ */
} }
@@ -4894,14 +4894,14 @@ int NetHackQtBind::qt_nhgetch()
// //
while (keybuffer.Empty() while (keybuffer.Empty()
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
&& !program_state.done_hup && !g.program_state.done_hup
#endif #endif
) { ) {
qApp->enter_loop(); qApp->enter_loop();
} }
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
if (program_state.done_hup && keybuffer.Empty()) return '\033'; if (g.program_state.done_hup && keybuffer.Empty()) return '\033';
#endif #endif
return keybuffer.GetAscii(); return keybuffer.GetAscii();
} }
@@ -4915,13 +4915,13 @@ int NetHackQtBind::qt_nh_poskey(int *x, int *y, int *mod)
// //
while (keybuffer.Empty() && clickbuffer.Empty() while (keybuffer.Empty() && clickbuffer.Empty()
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
&& !program_state.done_hup && !g.program_state.done_hup
#endif #endif
) { ) {
qApp->enter_loop(); qApp->enter_loop();
} }
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
if (program_state.done_hup && keybuffer.Empty()) return '\033'; if (g.program_state.done_hup && keybuffer.Empty()) return '\033';
#endif #endif
if (!keybuffer.Empty()) { if (!keybuffer.Empty()) {
return keybuffer.GetAscii(); return keybuffer.GetAscii();
@@ -5170,7 +5170,7 @@ bool NetHackQtBind::notify(QObject *receiver, QEvent *event)
bool result=QApplication::notify(receiver,event); bool result=QApplication::notify(receiver,event);
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
if (program_state.done_hup) { if (g.program_state.done_hup) {
keybuffer.Put('\033'); keybuffer.Put('\033');
qApp->exit_loop(); qApp->exit_loop();
return TRUE; return TRUE;
+1 -1
View File
@@ -401,7 +401,7 @@ void NetHackQtBind::qt_update_inventory()
if (main) if (main)
main->updateInventory(); main->updateInventory();
/* doesn't work yet /* doesn't work yet
if (program_state.something_worth_saving && iflags.perm_invent) if (g.program_state.something_worth_saving && iflags.perm_invent)
display_inventory(NULL, false); display_inventory(NULL, false);
*/ */
} }
+1 -1
View File
@@ -1029,7 +1029,7 @@ void NetHackQtMainWindow::keyPressEvent(QKeyEvent* event)
void NetHackQtMainWindow::closeEvent(QCloseEvent* e) void NetHackQtMainWindow::closeEvent(QCloseEvent* e)
{ {
if ( program_state.something_worth_saving ) { if ( g.program_state.something_worth_saving ) {
switch ( QMessageBox::information( this, "NetHack", switch ( QMessageBox::information( this, "NetHack",
"This will end your NetHack session", "This will end your NetHack session",
"&Save", "&Cancel", 0, 1 ) ) "&Save", "&Cancel", 0, 1 ) )
+2 -2
View File
@@ -1701,7 +1701,7 @@ int exit_condition;
inptr = (inptr + 1) % INBUF_SIZE; inptr = (inptr + 1) % INBUF_SIZE;
/* pkey(retval); */ /* pkey(retval); */
keep_going = FALSE; keep_going = FALSE;
} else if (program_state.done_hup) { } else if (g.program_state.done_hup) {
retval = '\033'; retval = '\033';
inptr = (inptr + 1) % INBUF_SIZE; inptr = (inptr + 1) % INBUF_SIZE;
keep_going = FALSE; keep_going = FALSE;
@@ -1720,7 +1720,7 @@ int exit_condition;
/* pkey(retval); */ /* pkey(retval); */
} }
keep_going = FALSE; keep_going = FALSE;
} else if (program_state.done_hup) { } else if (g.program_state.done_hup) {
retval = '\033'; retval = '\033';
inptr = (inptr + 1) % INBUF_SIZE; inptr = (inptr + 1) % INBUF_SIZE;
keep_going = FALSE; keep_going = FALSE;
+5 -5
View File
@@ -1266,7 +1266,7 @@ X11_player_selection_dialog()
if (plsel_align_radios) if (plsel_align_radios)
free(plsel_align_radios); free(plsel_align_radios);
if (ps_selected == PS_QUIT || program_state.done_hup) { if (ps_selected == PS_QUIT || g.program_state.done_hup) {
clearlocks(); clearlocks();
X11_exit_nhwindows((char *) 0); X11_exit_nhwindows((char *) 0);
nh_terminate(0); nh_terminate(0);
@@ -1341,7 +1341,7 @@ X11_player_selection_prompts()
XtDestroyWidget(popup); XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0; free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || program_state.done_hup) { if (ps_selected == PS_QUIT || g.program_state.done_hup) {
clearlocks(); clearlocks();
X11_exit_nhwindows((char *) 0); X11_exit_nhwindows((char *) 0);
nh_terminate(0); nh_terminate(0);
@@ -1410,7 +1410,7 @@ X11_player_selection_prompts()
XtDestroyWidget(popup); XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0; free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || program_state.done_hup) { if (ps_selected == PS_QUIT || g.program_state.done_hup) {
clearlocks(); clearlocks();
X11_exit_nhwindows((char *) 0); X11_exit_nhwindows((char *) 0);
nh_terminate(0); nh_terminate(0);
@@ -1478,7 +1478,7 @@ X11_player_selection_prompts()
XtDestroyWidget(popup); XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0; free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || program_state.done_hup) { if (ps_selected == PS_QUIT || g.program_state.done_hup) {
clearlocks(); clearlocks();
X11_exit_nhwindows((char *) 0); X11_exit_nhwindows((char *) 0);
nh_terminate(0); nh_terminate(0);
@@ -1544,7 +1544,7 @@ X11_player_selection_prompts()
XtDestroyWidget(popup); XtDestroyWidget(popup);
free((genericptr_t) choices), choices = 0; free((genericptr_t) choices), choices = 0;
if (ps_selected == PS_QUIT || program_state.done_hup) { if (ps_selected == PS_QUIT || g.program_state.done_hup) {
clearlocks(); clearlocks();
X11_exit_nhwindows((char *) 0); X11_exit_nhwindows((char *) 0);
nh_terminate(0); nh_terminate(0);
+1 -1
View File
@@ -623,7 +623,7 @@ curses_display_nhmenu(winid wid, int how, MENU_ITEM_P ** _selected)
menu_determine_pages(current_menu); menu_determine_pages(current_menu);
/* Display pre and post-game menus centered */ /* Display pre and post-game menus centered */
if (((g.moves <= 1) && !g.invent) || program_state.gameover) { if (((g.moves <= 1) && !g.invent) || g.program_state.gameover) {
win = curses_create_window(current_menu->width, win = curses_create_window(current_menu->width,
current_menu->height, CENTER); current_menu->height, CENTER);
} else { /* Display during-game menus on the right out of the way */ } else { /* Display during-game menus on the right out of the way */
+2 -2
View File
@@ -907,7 +907,7 @@ gnome_nhgetch()
g_askingQuestion = 1; g_askingQuestion = 1;
/* Process events until a key press event arrives. */ /* Process events until a key press event arrives. */
while (g_numKeys == 0) { while (g_numKeys == 0) {
if (program_state.done_hup) if (g.program_state.done_hup)
return '\033'; return '\033';
gtk_main_iteration(); gtk_main_iteration();
} }
@@ -945,7 +945,7 @@ gnome_nh_poskey(int *x, int *y, int *mod)
g_askingQuestion = 0; g_askingQuestion = 0;
/* Process events until a key or map-click arrives. */ /* Process events until a key or map-click arrives. */
while (g_numKeys == 0 && g_numClicks == 0) { while (g_numKeys == 0 && g_numClicks == 0) {
if (program_state.done_hup) if (g.program_state.done_hup)
return '\033'; return '\033';
gtk_main_iteration(); gtk_main_iteration();
} }
+1 -1
View File
@@ -218,7 +218,7 @@ register const char *s; /* chars allowed besides return */
morc = 0; morc = 0;
while ( while (
#ifdef HANGUPHANDLING #ifdef HANGUPHANDLING
!program_state.done_hup && !g.program_state.done_hup &&
#endif #endif
(c = tty_nhgetch()) != EOF) { (c = tty_nhgetch()) != EOF) {
if (c == '\n' || c == '\r') if (c == '\n' || c == '\r')
+3 -3
View File
@@ -56,7 +56,7 @@ extern short glyph2tile[];
*/ */
#define HUPSKIP() \ #define HUPSKIP() \
do { \ do { \
if (program_state.done_hup) { \ if (g.program_state.done_hup) { \
morc = '\033'; \ morc = '\033'; \
return; \ return; \
} \ } \
@@ -64,7 +64,7 @@ extern short glyph2tile[];
/* morc=ESC - in case we bypass xwaitforspace() which sets that */ /* morc=ESC - in case we bypass xwaitforspace() which sets that */
#define HUPSKIP_RESULT(RES) \ #define HUPSKIP_RESULT(RES) \
do { \ do { \
if (program_state.done_hup) \ if (g.program_state.done_hup) \
return (RES); \ return (RES); \
} while (0) } while (0)
#else /* !HANGUP_HANDLING */ #else /* !HANGUP_HANDLING */
@@ -3085,7 +3085,7 @@ tty_wait_synch()
if (ttyDisplay->inmore) { if (ttyDisplay->inmore) {
addtopl("--More--"); addtopl("--More--");
(void) fflush(stdout); (void) fflush(stdout);
} else if (ttyDisplay->inread > program_state.gameover) { } else if (ttyDisplay->inread > g.program_state.gameover) {
/* this can only happen if we were reading and got interrupted */ /* this can only happen if we were reading and got interrupted */
ttyDisplay->toplin = 3; ttyDisplay->toplin = 3;
/* do this twice; 1st time gets the Quit? message again */ /* do this twice; 1st time gets the Quit? message again */
+3 -3
View File
@@ -39,7 +39,7 @@ mswin_have_input()
return return
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* we always have input (ESC) if hangup was requested */ /* we always have input (ESC) if hangup was requested */
program_state.done_hup || g.program_state.done_hup ||
#endif #endif
(nhi_read_pos != nhi_write_pos); (nhi_read_pos != nhi_write_pos);
} }
@@ -69,7 +69,7 @@ mswin_input_pop()
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* always return ESC when hangup was requested */ /* always return ESC when hangup was requested */
if (program_state.done_hup) { if (g.program_state.done_hup) {
static MSNHEvent hangup_event; static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR; hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033'; hangup_event.kbd.ch = '\033';
@@ -98,7 +98,7 @@ mswin_input_peek()
#ifdef SAFERHANGUP #ifdef SAFERHANGUP
/* always return ESC when hangup was requested */ /* always return ESC when hangup was requested */
if (program_state.done_hup) { if (g.program_state.done_hup) {
static MSNHEvent hangup_event; static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR; hangup_event.type = NHEVENT_CHAR;
hangup_event.kbd.ch = '\033'; hangup_event.kbd.ch = '\033';
+4 -4
View File
@@ -452,16 +452,16 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CLOSE: { case WM_CLOSE: {
/* exit gracefully */ /* exit gracefully */
if (program_state.gameover) { if (g.program_state.gameover) {
/* assume the user really meant this, as the game is already /* assume the user really meant this, as the game is already
* over... */ * over... */
/* to make sure we still save bones, just set stop printing flag /* to make sure we still save bones, just set stop printing flag
*/ */
program_state.stopprint++; g.program_state.stopprint++;
NHEVENT_KBD( NHEVENT_KBD(
'\033'); /* and send keyboard input as if user pressed ESC */ '\033'); /* and send keyboard input as if user pressed ESC */
/* additional code for this is done in menu and rip windows */ /* additional code for this is done in menu and rip windows */
} else if (!program_state.something_worth_saving) { } else if (!g.program_state.something_worth_saving) {
/* User exited before the game started, e.g. during splash display /* User exited before the game started, e.g. during splash display
*/ */
/* Just get out. */ /* Just get out. */
@@ -837,7 +837,7 @@ onWMCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
case IDM_SAVE: case IDM_SAVE:
if (iflags.debug_fuzzer) if (iflags.debug_fuzzer)
break; break;
if (!program_state.gameover && !program_state.done_hup) if (!g.program_state.gameover && !g.program_state.done_hup)
dosave(); dosave();
else else
MessageBeep(0); MessageBeep(0);
+2 -2
View File
@@ -348,10 +348,10 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE; return FALSE;
case WM_CLOSE: case WM_CLOSE:
if (program_state.gameover) { if (g.program_state.gameover) {
data->result = -1; data->result = -1;
data->done = 1; data->done = 1;
program_state.stopprint++; g.program_state.stopprint++;
return TRUE; return TRUE;
} else } else
return FALSE; return FALSE;
+1 -1
View File
@@ -227,7 +227,7 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
GetNHApp()->hMainWnd = NULL; GetNHApp()->hMainWnd = NULL;
DestroyWindow(hWnd); DestroyWindow(hWnd);
SetFocus(GetNHApp()->hMainWnd); SetFocus(GetNHApp()->hMainWnd);
program_state.stopprint++; g.program_state.stopprint++;
return TRUE; return TRUE;
case WM_DESTROY: case WM_DESTROY:
+1 -1
View File
@@ -1224,7 +1224,7 @@ void
mswin_update_inventory() mswin_update_inventory()
{ {
logDebug("mswin_update_inventory()\n"); logDebug("mswin_update_inventory()\n");
if (iflags.perm_invent && program_state.something_worth_saving if (iflags.perm_invent && g.program_state.something_worth_saving
&& iflags.window_inited && WIN_INVEN != WIN_ERR) && iflags.window_inited && WIN_INVEN != WIN_ERR)
display_inventory(NULL, FALSE); display_inventory(NULL, FALSE);
} }