distinguish global variables that get written to savefile

The g? structs had a mix of variables that were written to
the savefile, and those that were not.

For better clarity and to distinguish those that end up in
the savefile, relocate some g? variables that get written
directly to the savefile into different structs.

This updates EDITLEVEL, although technically it probably
didn't need to, since savefile contents are not changing.

Details:

    gb.bases            -> svb.bases
    gb.bbubbles         -> svb.bbubbles
    gb.branches         -> svb.branches
    gc.context          -> svc.context
    gd.disco            -> svd.disco
    gd.dndest           -> svd.dndest
    gd.doors            -> svd.doors
    gd.doors_alloc      -> svd.doors_alloc
    gd.dungeon_topology -> svd.dungeon_topology
    gd.dungeons         -> svd.dungeons
    ge.exclusion_zones  -> sve.exclusion_zones
    gh.hackpid          -> svh.hackpid
    gi.inv_pos          -> svi.inv_pos
    gk.killer           -> svk.killer
    gl.lastseentyp      -> svl.lastseentyp
    gl.level            -> svl.level
    gl.level_info       -> svl.level_info
    gm.mapseenchn       -> svm.mapseenchn
    gm.moves            -> svm.moves
    gm.mvitals          -> svm.mvitals
    gn.n_dgns           -> svn.n_dgns
    gn.n_regions        -> svn.n_regions
    gn.nroom            -> svn.nroom
    go.oracle_cnt       -> svo.oracle_cnt
    gp.pl_character     -> svp.pl_character
    gp.pl_fruit         -> svp.pl_fruit
    gp.plname           -> svp.plname
    gp.program_state    -> svp.program_state
    gq.quest_status     -> svq.quest_status
    gr.rooms            -> svr.rooms
    gs.sp_levchn        -> svs.sp_levchn
    gs.spl_book         -> svs.spl_book
    gt.timer_id         -> svt.timer_id
    gt.tune             -> svt.tune
    gu.updest           -> svu.updest
    gx.xmax             -> svx.xmax
    gx.xmin             -> svx.xmin
    gy.ymax             -> svy.ymax
    gy.ymin             -> svy.ymin

Related note:
There are some pointer variables that are heads of chains that were not
moved from 'g?' to 'sv?', because they are not actually written to the
savefile directly, but the objects/monst/trap/lightsource/timer in the
chains they point to are. That can be changed, if desired.
Examples: gi.invent, gm.migrating_objs, gb.billobjs, gm.migrating_mons,
          gf.ftrap, gl.light_base, gt.timer_base
This commit is contained in:
nhmall
2024-07-13 14:57:50 -04:00
parent 0e4083153c
commit 6c0ae092c6
174 changed files with 3502 additions and 3305 deletions

View File

@@ -237,7 +237,7 @@ void NetHackQtBind::qt_askname()
int ch = -1; // -1 => new game
have_asked = true;
str_copy(default_plname, gp.plname, PL_NSIZ);
str_copy(default_plname, svp.plname, PL_NSIZ);
// We do it all here (plus qt_plsel.cpp and qt_svsel.cpp),
// nothing in player_selection().
@@ -252,7 +252,7 @@ void NetHackQtBind::qt_askname()
NetHackQtSavedGameSelector sgsel((const char **) saved);
ch = sgsel.choose();
if (ch >= 0)
str_copy(gp.plname, saved[ch], SIZE(gp.plname));
str_copy(svp.plname, saved[ch], SIZE(svp.plname));
// caller needs new lock name even if plname[] hasn't changed
// because successful get_saved_games() clobbers gs.SAVEF[]
::iflags.renameinprogress = TRUE;
@@ -282,10 +282,10 @@ void NetHackQtBind::qt_askname()
break;
}
if (!*gp.plname)
if (!*svp.plname)
// in case Choose() returns with plname[] empty
Strcpy(gp.plname, default_plname);
else if (strcmp(gp.plname, default_plname) != 0)
Strcpy(svp.plname, default_plname);
else if (strcmp(svp.plname, default_plname) != 0)
// caller needs to set new lock file name
::iflags.renameinprogress = TRUE;
return;
@@ -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 (gp.program_state.something_worth_saving && iflags.perm_invent)
if (svp.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 (::gp.program_state.gameover)
if (::svp.program_state.gameover)
return ch; // bypass --More-- and just continue with program exit
NetHackQtMessageWindow *mesgwin = main ? main->GetMessageWindow() : NULL;

View File

@@ -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 (::gp.program_state.input_state != commandInp) {
if (::svp.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",
!gp.program_state.something_worth_saving ? ""
!svp.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()
gp.program_state.stopprint++;
svp.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 ( gp.program_state.something_worth_saving ) {
if ( svp.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;
gp.program_state.stopprint++;
svp.program_state.stopprint++;
::done(QUIT);
/*NOTREACHED*/
break;

View File

@@ -1071,7 +1071,7 @@ void NetHackQtTextWindow::UseRIP(int how, time_t when)
/* Put name on stone */
(void) snprintf(rip_line[NAME_LINE], STONE_LINE_LEN + 1,
"%.*s", STONE_LINE_LEN, gp.plname);
"%.*s", STONE_LINE_LEN, svp.plname);
/* Put $ on stone;
to keep things safe and relatively simple, impose an arbitrary

View File

@@ -40,17 +40,17 @@ extern "C" {
/* check whether plname[] is among the list of generic user names */
static bool generic_plname()
{
if (*gp.plname) {
if (*svp.plname) {
const char *sptr, *p;
const char *genericusers = sysopt.genericusers;
int ln = (int) strlen(gp.plname);
int ln = (int) strlen(svp.plname);
if (!genericusers || !*genericusers)
genericusers = "player games";
else if (!strcmp(genericusers, "*")) /* "*" => always ask for name */
return true;
while ((sptr = strstri(genericusers, gp.plname)) != NULL) {
while ((sptr = strstri(genericusers, svp.plname)) != NULL) {
/* check for full word: start of list or following a space */
if ((sptr == genericusers || sptr[-1] == ' ')
/* and also preceding a space or at end of list */
@@ -263,8 +263,8 @@ NetHackQtPlayerSelector::NetHackQtPlayerSelector(
// if plname[] contains a generic user name, clear it
if (generic_plname())
*gp.plname = '\0';
name->setText(gp.plname);
*svp.plname = '\0';
name->setText(svp.plname);
connect(name, SIGNAL(textChanged(const QString&)),
this, SLOT(selectName(const QString&)));
name->setFocus();
@@ -545,7 +545,7 @@ void NetHackQtPlayerSelector::Randomize()
// if plname[] is empty, disable [Play], otherwise [Play] is the default
void NetHackQtPlayerSelector::plnamePlayVsQuit()
{
if (*gp.plname) {
if (*svp.plname) {
play_btn->setEnabled(true);
play_btn->setDefault(true);
//quit_btn->setDefault(false);
@@ -564,7 +564,7 @@ void NetHackQtPlayerSelector::selectName(const QString& n)
// (it would be better to set up a validator that rejects leading spaces)
while (*name_str == ' ')
++name_str;
str_copy(gp.plname, name_str, PL_NSIZ);
str_copy(svp.plname, name_str, PL_NSIZ);
// possibly enable or disable the [Play] button
plnamePlayVsQuit();
}

View File

@@ -858,17 +858,17 @@ void NetHackQtStatusWindow::updateStats()
buf = nh_capitalize_words(pmname(&mons[u.umonnum],
::flags.female ? FEMALE : MALE));
} else {
buf = rank_of(u.ulevel, gp.pl_character[0], ::flags.female);
buf = rank_of(u.ulevel, svp.pl_character[0], ::flags.female);
}
QString buf2;
char buf3[BUFSZ];
buf2 = nh_qsprintf("%s the %s", upstart(strcpy(buf3, gp.plname)),
buf2 = nh_qsprintf("%s the %s", upstart(strcpy(buf3, svp.plname)),
buf.toLatin1().constData());
name.setLabel(buf2, NetHackQtLabelledIcon::NoNum, u.ulevel);
if (!describe_level(buf3, 0)) {
Sprintf(buf3, "%s, level %d",
gd.dungeons[u.uz.dnum].dname, ::depth(&u.uz));
svd.dungeons[u.uz.dnum].dname, ::depth(&u.uz));
}
dlevel.setLabel(buf3);
@@ -966,7 +966,7 @@ void NetHackQtStatusWindow::updateStats()
if (::flags.time) {
// hypothetically Time could grow to enough digits to have trouble
// fitting, but it's not worth worrying about
time.setLabel("Time:", (long) gm.moves);
time.setLabel("Time:", (long) svm.moves);
} else {
time.setLabel("");
}

View File

@@ -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?")
|| (::gp.program_state.gameover
|| (::svp.program_state.gameover
&& question.left(11) == QString("Do you want")))
button_name = "Quit";
else if (is_ynaq)

View File

@@ -1282,7 +1282,7 @@ X11_update_inventory(int arg)
if (iflags.perm_invent) {
/* skip any calls to update_inventory() before in_moveloop starts */
if (gp.program_state.in_moveloop || gp.program_state.gameover) {
if (svp.program_state.in_moveloop || svp.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)
{
gp.program_state.something_worth_saving = 0;
svp.program_state.something_worth_saving = 0;
clearlocks();
X11_exit_nhwindows(mesg);
nh_terminate(EXIT_SUCCESS);
@@ -1815,7 +1815,7 @@ askname_delete(Widget w, XEvent *event, String *params, Cardinal *num_params)
nhUse(num_params);
nh_XtPopdown(w);
(void) strcpy(gp.plname, "Mumbles"); /* give them a name... ;-) */
(void) strcpy(svp.plname, "Mumbles"); /* give them a name... ;-) */
exit_x_event = TRUE;
}
@@ -1840,11 +1840,11 @@ askname_done(Widget w, XtPointer client_data, XtPointer call_data)
}
/* Truncate name if necessary */
if (len >= sizeof gp.plname - 1)
len = sizeof gp.plname - 1;
if (len >= sizeof svp.plname - 1)
len = sizeof svp.plname - 1;
(void) strncpy(gp.plname, s, len);
gp.plname[len] = '\0';
(void) strncpy(svp.plname, s, len);
svp.plname[len] = '\0';
XtFree(s);
nh_XtPopdown(XtParent(dialog));
@@ -1892,7 +1892,7 @@ X11_askname(void)
(XtCallbackProc) 0);
SetDialogPrompt(dialog, nhStr("What is your name?")); /* set prompt */
SetDialogResponse(dialog, gp.plname, PL_NSIZ); /* set default answer */
SetDialogResponse(dialog, svp.plname, PL_NSIZ); /* set default answer */
XtRealizeWidget(popup);
positionpopup(popup, TRUE); /* center,bottom */
@@ -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 (gp.program_state.in_moveloop || gp.program_state.gameover) {
if (svp.program_state.in_moveloop || svp.program_state.gameover) {
/* single space has meaning (to remove a previously applied name) so
show it clearly; don't care about legibility of multiple spaces */
const char *visanswer = !input[0] ? "<empty>"

View File

@@ -1988,7 +1988,7 @@ x_event(int exit_condition)
/* pkey(retval); */
keep_going = FALSE;
#if defined(HANGUPHANDLING)
} else if (gp.program_state.done_hup) {
} else if (svp.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 (gp.program_state.done_hup) {
} else if (svp.program_state.done_hup) {
retval = '\033';
inptr = (inptr + 1) % INBUF_SIZE;
keep_going = FALSE;

View File

@@ -352,11 +352,11 @@ plsel_dialog_acceptvalues(void)
XtSetArg(args[0], nhStr(XtNstring), &s);
XtGetValues(plsel_name_input, args, ONE);
(void) strncpy(gp.plname, (char *) s, sizeof gp.plname - 1);
gp.plname[sizeof gp.plname - 1] = '\0';
(void) mungspaces(gp.plname);
if (strlen(gp.plname) < 1)
(void) strcpy(gp.plname, "Mumbles");
(void) strncpy(svp.plname, (char *) s, sizeof svp.plname - 1);
svp.plname[sizeof svp.plname - 1] = '\0';
(void) mungspaces(svp.plname);
if (strlen(svp.plname) < 1)
(void) strcpy(svp.plname, "Mumbles");
iflags.renameinprogress = FALSE;
}
@@ -779,8 +779,8 @@ X11_create_player_selection_name(Widget form)
XtSetArg(args[num_args], nhStr(XtNeditType),
!plsel_ask_name ? XawtextRead : XawtextEdit); num_args++;
XtSetArg(args[num_args], nhStr(XtNresize), XawtextResizeWidth); num_args++;
XtSetArg(args[num_args], nhStr(XtNstring), gp.plname); num_args++;
XtSetArg(args[num_args], XtNinsertPosition, strlen(gp.plname)); num_args++;
XtSetArg(args[num_args], nhStr(XtNstring), svp.plname); num_args++;
XtSetArg(args[num_args], XtNinsertPosition, strlen(svp.plname)); num_args++;
XtSetArg(args[num_args], nhStr(XtNaccelerators),
XtParseAcceleratorTable(plsel_input_accelerators)); num_args++;
plsel_name_input = XtCreateManagedWidget("name_input",
@@ -1222,7 +1222,7 @@ X11_player_selection_dialog(void)
if (ps_selected == PS_QUIT
#if defined(HANGUPHANDLING)
|| gp.program_state.done_hup
|| svp.program_state.done_hup
#endif
) {
clearlocks();
@@ -1300,7 +1300,7 @@ X11_player_selection_prompts(void)
if (ps_selected == PS_QUIT
#if defined(HANGUPHANDLING)
|| gp.program_state.done_hup
|| svp.program_state.done_hup
#endif
) {
clearlocks();
@@ -1373,7 +1373,7 @@ X11_player_selection_prompts(void)
if (ps_selected == PS_QUIT
#if defined(HANGUPHANDLING)
|| gp.program_state.done_hup
|| svp.program_state.done_hup
#endif
) {
clearlocks();
@@ -1445,7 +1445,7 @@ X11_player_selection_prompts(void)
if (ps_selected == PS_QUIT
#if defined(HANGUPHANDLING)
|| gp.program_state.done_hup
|| svp.program_state.done_hup
#endif
) {
clearlocks();
@@ -1515,7 +1515,7 @@ X11_player_selection_prompts(void)
if (ps_selected == PS_QUIT
#if defined(HANGUPHANDLING)
|| gp.program_state.done_hup
|| svp.program_state.done_hup
#endif
) {
clearlocks();
@@ -1539,15 +1539,15 @@ void
X11_player_selection(void)
{
if (iflags.wc_player_selection == VIA_DIALOG) {
if (!*gp.plname) {
if (!*svp.plname) {
#ifdef UNIX
char *defplname = get_login_name();
#else
char *defplname = (char *)0;
#endif
(void) strncpy(gp.plname, defplname ? defplname : "Mumbles",
sizeof gp.plname - 1);
gp.plname[sizeof gp.plname - 1] = '\0';
(void) strncpy(svp.plname, defplname ? defplname : "Mumbles",
sizeof svp.plname - 1);
svp.plname[sizeof svp.plname - 1] = '\0';
iflags.renameinprogress = TRUE;
}
X11_player_selection_dialog();

View File

@@ -1535,7 +1535,7 @@ update_val(struct X_status_value *attr_rec, long new_value)
if (attr_rec->type == SV_LABEL) {
if (attr_rec == &shown_stats[F_NAME]) {
Strcpy(buf, gp.plname);
Strcpy(buf, svp.plname);
buf[0] = highc(buf[0]);
Strcat(buf, " the ");
if (Upolyd) {
@@ -1550,12 +1550,12 @@ update_val(struct X_status_value *attr_rec, long new_value)
Strcat(buf, mnam);
} else {
Strcat(buf,
rank_of(u.ulevel, gp.pl_character[0], flags.female));
rank_of(u.ulevel, svp.pl_character[0], flags.female));
}
} else if (attr_rec == &shown_stats[F_DLEVEL]) {
if (!describe_level(buf, 0)) {
Strcpy(buf, gd.dungeons[u.uz.dnum].dname);
Strcpy(buf, svd.dungeons[u.uz.dnum].dname);
Sprintf(eos(buf), ", level %d", depth(&u.uz));
}
} else if (attr_rec == &shown_stats[F_VERS]) {
@@ -1987,7 +1987,7 @@ update_fancy_status_field(int i, int color, int attributes)
val = (long) u.ualign.type;
break;
case F_TIME:
val = flags.time ? (long) gm.moves : 0L;
val = flags.time ? (long) svm.moves : 0L;
break;
case F_SCORE:
#ifdef SCORE_ON_BOTL

View File

@@ -296,7 +296,7 @@ create_text_window(struct xwindow *wp)
XtParseTranslationTable(text_translations));
num_args++;
wp->w = XtCreateManagedWidget(gk.killer.name[0] && WIN_MAP == WIN_ERR
wp->w = XtCreateManagedWidget(svk.killer.name[0] && WIN_MAP == WIN_ERR
? "tombstone"
: "text_text", /* name */
asciiTextWidgetClass,
@@ -467,7 +467,7 @@ calculate_rip_text(int how, time_t when)
long cash;
/* Put name on stone */
Sprintf(rip_line[NAME_LINE], "%.16s", gp.plname); /* STONE_LINE_LEN */
Sprintf(rip_line[NAME_LINE], "%.16s", svp.plname); /* STONE_LINE_LEN */
/* Put $ on stone */
cash = max(gd.done_money, 0L);

View File

@@ -227,7 +227,7 @@ curses_character_input_dialog(
re-activate them now that input is being requested */
curses_got_input();
if (gi.invent || (gm.moves > 1)) {
if (gi.invent || (svm.moves > 1)) {
curses_get_window_size(MAP_WIN, &map_height, &map_width);
} else {
map_height = term_rows;
@@ -789,7 +789,7 @@ curses_display_nhmenu(
menu_determine_pages(current_menu);
/* Display pre and post-game menus centered */
if ((gm.moves <= 1 && !gi.invent) || gp.program_state.gameover) {
if ((svm.moves <= 1 && !gi.invent) || svp.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 (gp.program_state.gameover) {
if (svp.program_state.gameover) {
/* for final inventory disclosure, use full width */
maxwidth = term_cols - 2; /* +2: borders assumed */
} else {

View File

@@ -326,9 +326,9 @@ curses_askname(void)
}
#endif /* SELECTSAVED */
curses_line_input_dialog("Who are you?", gp.plname, PL_NSIZ);
(void) mungspaces(gp.plname);
if (!gp.plname[0] || gp.plname[0] == '\033')
curses_line_input_dialog("Who are you?", svp.plname, PL_NSIZ);
(void) mungspaces(svp.plname);
if (!svp.plname[0] || svp.plname[0] == '\033')
goto bail;
iflags.renameallowed = TRUE; /* tty uses this, we don't [yet?] */
@@ -782,7 +782,7 @@ curses_update_inventory(int arg)
}
/* skip inventory updating during character initialization */
if (!gp.program_state.in_moveloop && !gp.program_state.gameover)
if (!svp.program_state.in_moveloop && !svp.program_state.gameover)
return;
if (!arg) {

View File

@@ -776,7 +776,7 @@ Currently this is limited to arrow keys, but this may be expanded. */
int
curses_convert_keys(int key)
{
boolean reject = (gp.program_state.input_state == otherInp),
boolean reject = (svp.program_state.input_state == otherInp),
as_is = FALSE, numpad_esc = FALSE;
int ret = key;

View File

@@ -1886,7 +1886,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
wmove(win, y, x);
get_playerrank(rank);
sprintf(buf, "%s the %s", gp.plname, rank);
sprintf(buf, "%s the %s", svp.plname, rank);
/* Use the title as HP bar (similar to hitpointbar) */
draw_bar(TRUE, hp, hpmax, buf);
@@ -1954,7 +1954,7 @@ draw_horizontal(int x, int y, int hp, int hpmax)
print_statdiff(" Exp:", &prevlevel, u.ulevel, STAT_OTHER);
if (flags.time)
print_statdiff(" T:", &prevtime, gm.moves, STAT_TIME);
print_statdiff(" T:", &prevtime, svm.moves, STAT_TIME);
curses_add_statuses(win, FALSE, FALSE, NULL, NULL);
}
@@ -1973,7 +1973,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax)
char race[BUFSZ];
Strcpy(race, gu.urace.adj);
race[0] = highc(race[0]);
wprintw(win, "%s the %s %s%s%s", gp.plname,
wprintw(win, "%s the %s %s%s%s", svp.plname,
(u.ualign.type == A_CHAOTIC ? "Chaotic" :
u.ualign.type == A_NEUTRAL ? "Neutral" : "Lawful"),
Upolyd ? "" : race, Upolyd ? "" : " ",
@@ -2035,7 +2035,7 @@ draw_horizontal_new(int x, int y, int hp, int hpmax)
#endif /* SCORE_ON_BOTL */
if (flags.time)
print_statdiff(" T:", &prevtime, gm.moves, STAT_TIME);
print_statdiff(" T:", &prevtime, svm.moves, STAT_TIME);
curses_add_statuses(win, TRUE, FALSE, &x, &y);
@@ -2092,7 +2092,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
get_playerrank(rank);
int ranklen = strlen(rank);
int namelen = strlen(gp.plname);
int namelen = strlen(svp.plname);
int maxlen = 19;
#ifdef STATUS_COLORS
if (!iflags.hitpointbar)
@@ -2109,7 +2109,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
while ((ranklen + namelen) > maxlen)
ranklen--; /* Still doesn't fit, strip rank */
}
sprintf(buf, "%-*s the %-*s", namelen, gp.plname, ranklen, rank);
sprintf(buf, "%-*s the %-*s", namelen, svp.plname, ranklen, rank);
draw_bar(TRUE, hp, hpmax, buf);
wmove(win, y++, x);
wprintw(win, "%s", dungeons[u.uz.dnum].dname);
@@ -2188,7 +2188,7 @@ draw_vertical(int x, int y, int hp, int hpmax)
wmove(win, y++, x);
if (flags.time) {
print_statdiff("Time: ", &prevtime, gm.moves, STAT_TIME);
print_statdiff("Time: ", &prevtime, svm.moves, STAT_TIME);
wmove(win, y++, x);
}

View File

@@ -69,7 +69,7 @@ curses_create_window(int wid, int width, int height, orient orientation)
if ((orientation == UP) || (orientation == DOWN) ||
(orientation == LEFT) || (orientation == RIGHT)) {
if (gi.invent || (gm.moves > 1)) {
if (gi.invent || (svm.moves > 1)) {
map_border = curses_window_has_border(MAP_WIN);
curses_get_window_xy(MAP_WIN, &mapx, &mapy);
curses_get_window_size(MAP_WIN, &maph, &mapw);
@@ -104,7 +104,7 @@ curses_create_window(int wid, int width, int height, orient orientation)
starty = (term_rows / 2) - (height / 2);
break;
case UP:
if (gi.invent || (gm.moves > 1)) {
if (gi.invent || (svm.moves > 1)) {
startx = (mapw / 2) - (width / 2) + mapx + mapb_offset;
} else {
startx = 0;
@@ -113,7 +113,7 @@ curses_create_window(int wid, int width, int height, orient orientation)
starty = mapy + mapb_offset;
break;
case DOWN:
if (gi.invent || (gm.moves > 1)) {
if (gi.invent || (svm.moves > 1)) {
startx = (mapw / 2) - (width / 2) + mapx + mapb_offset;
} else {
startx = 0;
@@ -129,7 +129,7 @@ curses_create_window(int wid, int width, int height, orient orientation)
starty = term_rows - height;
break;
case RIGHT:
if (gi.invent || (gm.moves > 1)) {
if (gi.invent || (svm.moves > 1)) {
startx = (mapw + mapx + (mapb_offset * 2)) - width;
} else {
startx = term_cols - width;
@@ -222,7 +222,7 @@ curses_refresh_nethack_windows(void)
return;
}
if ((gm.moves <= 1) && !gi.invent) {
if ((svm.moves <= 1) && !gi.invent) {
/* Main windows not yet displayed; refresh base window instead */
touchwin(stdscr);
refresh();

View File

@@ -232,7 +232,7 @@ xwaitforspace(const char *s) /* chars allowed besides return */
morc = 0;
while (
#ifdef HANGUPHANDLING
!gp.program_state.done_hup &&
!svp.program_state.done_hup &&
#endif
(c = tty_nhgetch()) != EOF) {
if (c == '\n' || c == '\r')

View File

@@ -184,7 +184,7 @@ remember_topl(void)
cw->datlen[idx] = (short) len;
}
Strcpy(cw->data[idx], gt.toplines);
if (!gp.program_state.in_checkpoint) {
if (!svp.program_state.in_checkpoint) {
*gt.toplines = '\0';
cw->maxcol = cw->maxrow = (idx + 1) % cw->rows;
}

View File

@@ -84,7 +84,7 @@ extern void msmsg(const char *, ...);
*/
#define HUPSKIP() \
do { \
if (gp.program_state.done_hup) { \
if (svp.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 (gp.program_state.done_hup) \
if (svp.program_state.done_hup) \
return (RES); \
} while (0)
#else /* !HANGUPHANDLING */
@@ -376,11 +376,11 @@ winch_handler(int sig_unused UNUSED)
}
#endif
gp.program_state.resize_pending++; /* resize_tty() will reset it */
svp.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 (gp.program_state.getting_char) {
if (svp.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 */
gp.program_state.resize_pending = 0;
svp.program_state.resize_pending = 0;
resize_mesg = 0;
getwindowsz(); /* update LI and CO */
@@ -647,7 +647,7 @@ tty_player_selection(void)
}
/*
* gp.plname is filled either by an option (-u Player or -uPlayer) or
* svp.plname is filled either by an option (-u Player or -uPlayer) or
* explicitly (by being the wizard) or by askname.
* It may still contain a suffix denoting the role, etc.
* Always called after init_nhwindows() and before
@@ -668,7 +668,7 @@ tty_askname(void)
case 0:
break; /* no game chosen; start new game */
case 1:
return; /* gp.plname[] has been set */
return; /* svp.plname[] has been set */
}
#endif /* SELECTSAVED */
@@ -731,7 +731,7 @@ tty_askname(void)
&& !(c >= '0' && c <= '9' && ct > 0))
c = '_';
#endif
if (ct < (int) (sizeof gp.plname) - 1) {
if (ct < (int) (sizeof svp.plname) - 1) {
#if defined(MICRO)
#if defined(MSDOS)
if (iflags.grmode) {
@@ -742,13 +742,13 @@ tty_askname(void)
#else
(void) putchar(c);
#endif
gp.plname[ct++] = c;
svp.plname[ct++] = c;
#ifdef WIN32CON
ttyDisplay->curx++;
#endif
}
}
gp.plname[ct] = 0;
svp.plname[ct] = 0;
} while (ct == 0);
/* move to next line to simulate echo of user's <return> */
@@ -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 (gp.program_state.in_role_selection)
if (svp.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 (!gp.program_state.in_moveloop)
if (!svp.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 (gp.program_state.in_moveloop) {
if (svp.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 = gp.program_state.in_docrt ? TRUE : FALSE,
boolean force_redraw = svp.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 > gp.program_state.gameover) {
} else if (ttyDisplay->inread > svp.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 (gp.program_state.resize_pending)
if (svp.program_state.resize_pending)
resize_tty();
#endif
gp.program_state.getting_char++;
svp.program_state.getting_char++;
#ifdef UNIX
i = (gp.program_state.getting_char == 1)
i = (svp.program_state.getting_char == 1)
? tgetch()
: ((read(fileno(stdin), (genericptr_t) &nestbuf, 1) == 1)
? (int) nestbuf : EOF);
#else
i = tgetch();
#endif
gp.program_state.getting_char--;
svp.program_state.getting_char--;
#ifdef RESIZABLE
if (resize_mesg) {
resize_mesg = 0;

View File

@@ -648,7 +648,7 @@ plselInitDialog(struct plsel_data * data)
/* set player name */
control_t * name_box = &data->controls[psc_name_box];
SetDlgItemText(data->dialog, name_box->id, NH_A2W(gp.plname, wbuf, sizeof(wbuf)));
SetDlgItemText(data->dialog, name_box->id, NH_A2W(svp.plname, wbuf, sizeof(wbuf)));
plselRandomize(data);

View File

@@ -39,7 +39,7 @@ mswin_have_input(void)
return
#ifdef SAFERHANGUP
/* we always have input (ESC) if hangup was requested */
gp.program_state.done_hup ||
svp.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 (gp.program_state.done_hup) {
if (svp.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 (gp.program_state.done_hup) {
if (svp.program_state.done_hup) {
static MSNHEvent hangup_event;
hangup_event.type = NHEVENT_CHAR;
hangup_event.ei.kbd.ch = '\033';

View File

@@ -457,16 +457,16 @@ MainWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CLOSE: {
/* exit gracefully */
if (gp.program_state.gameover) {
if (svp.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
*/
gp.program_state.stopprint++;
svp.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 (!gp.program_state.something_worth_saving) {
} else if (!svp.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 (!gp.program_state.gameover && !gp.program_state.done_hup)
if (!svp.program_state.gameover && !svp.program_state.done_hup)
dosave();
else
MessageBeep(0);

View File

@@ -351,10 +351,10 @@ MenuWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
return FALSE;
case WM_CLOSE:
if (gp.program_state.gameover) {
if (svp.program_state.gameover) {
data->result = -1;
data->done = 1;
gp.program_state.stopprint++;
svp.program_state.stopprint++;
return TRUE;
} else
return FALSE;

View File

@@ -227,7 +227,7 @@ NHRIPWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
GetNHApp()->hMainWnd = NULL;
DestroyWindow(hWnd);
SetFocus(GetNHApp()->hMainWnd);
gp.program_state.stopprint++;
svp.program_state.stopprint++;
return TRUE;
case WM_DESTROY:

View File

@@ -696,7 +696,7 @@ mswin_askname(void)
{
logDebug("mswin_askname()\n");
if (mswin_getlin_window("Who are you?", gp.plname, PL_NSIZ) == IDCANCEL) {
if (mswin_getlin_window("Who are you?", svp.plname, PL_NSIZ) == IDCANCEL) {
bail("bye-bye");
/* not reached */
}
@@ -1251,7 +1251,7 @@ void
mswin_update_inventory(int arg)
{
logDebug("mswin_update_inventory(%d)\n", arg);
if (iflags.perm_invent && gp.program_state.something_worth_saving
if (iflags.perm_invent && svp.program_state.something_worth_saving
&& iflags.window_inited && WIN_INVEN != WIN_ERR)
display_inventory(NULL, FALSE);
}
@@ -1963,7 +1963,7 @@ mswin_outrip(winid wid, int how, time_t when)
}
/* Put name on stone */
Sprintf(buf, "%s", gp.plname);
Sprintf(buf, "%s", svp.plname);
buf[STONE_LINE_LEN] = 0;
putstr(wid, 0, buf);
@@ -2862,7 +2862,7 @@ int
NHMessageBox(HWND hWnd, LPCTSTR text, UINT type)
{
TCHAR title[MAX_LOADSTRING];
if (gp.program_state.exiting && !strcmp(text, "\n"))
if (svp.program_state.exiting && !strcmp(text, "\n"))
text = "Press Enter to exit";
LoadString(GetNHApp()->hApp, IDS_APP_TITLE_SHORT, title, MAX_LOADSTRING);