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

@@ -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();