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:
@@ -185,7 +185,7 @@ time_t when;
|
||||
SetDrMd(rp, JAM1);
|
||||
|
||||
/* Put name on stone */
|
||||
Sprintf(buf, "%s", gp.plname);
|
||||
Sprintf(buf, "%s", svp.plname);
|
||||
buf[STONE_LINE_LEN] = 0;
|
||||
tomb_text(buf);
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ menu_item **retmip;
|
||||
nw->Screen = HackScreen;
|
||||
|
||||
if (win == WIN_INVEN) {
|
||||
sprintf(title, "%s the %s's Inventory", gp.plname, gp.pl_character);
|
||||
sprintf(title, "%s the %s's Inventory", svp.plname, svp.pl_character);
|
||||
nw->Title = title;
|
||||
if (lastinvent.MaxX != 0) {
|
||||
nw->LeftEdge = lastinvent.MinX;
|
||||
|
||||
@@ -438,10 +438,10 @@ amii_askname()
|
||||
amii_getlin("Who are you?", plnametmp);
|
||||
} while (strlen(plnametmp) == 0);
|
||||
|
||||
strncpy(gp.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
|
||||
gp.plname[PL_NSIZ - 1] = 0;
|
||||
strncpy(svp.plname, plnametmp, PL_NSIZ - 1); /* Avoid overflowing plname[] */
|
||||
svp.plname[PL_NSIZ - 1] = 0;
|
||||
|
||||
if (*gp.plname == '\33') {
|
||||
if (*svp.plname == '\33') {
|
||||
clearlocks();
|
||||
exit_nhwindows(NULL);
|
||||
nh_terminate(0);
|
||||
@@ -475,9 +475,9 @@ amii_player_selection()
|
||||
#if 0 /* Don't query the user ... instead give random character -jhsa */
|
||||
|
||||
#if 0 /* OBSOLETE */
|
||||
if( *gp.pl_character ){
|
||||
gp.pl_character[ 0 ] = toupper( gp.pl_character[ 0 ] );
|
||||
if( strchr( pl_classes, gp.pl_character[ 0 ] ) )
|
||||
if( *svp.pl_character ){
|
||||
svp.pl_character[ 0 ] = toupper( svp.pl_character[ 0 ] );
|
||||
if( strchr( pl_classes, svp.pl_character[ 0 ] ) )
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -531,19 +531,19 @@ amii_player_selection()
|
||||
case VANILLAKEY:
|
||||
if( strchr( pl_classes, toupper( code ) ) )
|
||||
{
|
||||
gp.pl_character[0] = toupper( code );
|
||||
svp.pl_character[0] = toupper( code );
|
||||
aredone = 1;
|
||||
}
|
||||
else if( code == ' ' || code == '\n' || code == '\r' )
|
||||
{
|
||||
flags.initrole = randrole(FALSE);
|
||||
#if 0 /* OBSOLETE */
|
||||
strcpy( gp.pl_character, roles[ rnd( 11 ) ] );
|
||||
strcpy( svp.pl_character, roles[ rnd( 11 ) ] );
|
||||
#endif
|
||||
aredone = 1;
|
||||
amii_clear_nhwindow( WIN_BASE );
|
||||
CloseShWindow( cwin );
|
||||
RandomWindow( gp.pl_character );
|
||||
RandomWindow( svp.pl_character );
|
||||
return;
|
||||
}
|
||||
else if( code == 'q' || code == 'Q' )
|
||||
@@ -563,15 +563,15 @@ amii_player_selection()
|
||||
case 1: /* Random Character */
|
||||
flags.initrole = randrole(FALSE);
|
||||
#if 0 /* OBSOLETE */
|
||||
strcpy( gp.pl_character, roles[ rnd( 11 ) ] );
|
||||
strcpy( svp.pl_character, roles[ rnd( 11 ) ] );
|
||||
#endif
|
||||
amii_clear_nhwindow( WIN_BASE );
|
||||
CloseShWindow( cwin );
|
||||
RandomWindow( gp.pl_character );
|
||||
RandomWindow( svp.pl_character );
|
||||
return;
|
||||
|
||||
default:
|
||||
gp.pl_character[0] = gd->GadgetID;
|
||||
svp.pl_character[0] = gd->GadgetID;
|
||||
break;
|
||||
}
|
||||
aredone = 1;
|
||||
|
||||
@@ -132,14 +132,14 @@ whoami(void)
|
||||
*/
|
||||
char *s;
|
||||
|
||||
if (*gp.plname)
|
||||
if (*svp.plname)
|
||||
return;
|
||||
if (s = nh_getenv("USER")) {
|
||||
(void) strncpy(gp.plname, s, sizeof(gp.plname) - 1);
|
||||
(void) strncpy(svp.plname, s, sizeof(svp.plname) - 1);
|
||||
return;
|
||||
}
|
||||
if (s = nh_getenv("LOGNAME")) {
|
||||
(void) strncpy(gp.plname, s, sizeof(gp.plname) - 1);
|
||||
(void) strncpy(svp.plname, s, sizeof(svp.plname) - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -177,11 +177,11 @@ process_options(int argc, char **argv)
|
||||
#endif
|
||||
case 'u':
|
||||
if (argv[0][2])
|
||||
(void) strncpy(gp.plname, argv[0] + 2, sizeof(gp.plname) - 1);
|
||||
(void) strncpy(svp.plname, argv[0] + 2, sizeof(svp.plname) - 1);
|
||||
else if (argc > 1) {
|
||||
argc--;
|
||||
argv++;
|
||||
(void) strncpy(gp.plname, argv[0], sizeof(gp.plname) - 1);
|
||||
(void) strncpy(svp.plname, argv[0], sizeof(svp.plname) - 1);
|
||||
} else
|
||||
raw_print("Player name expected after -u");
|
||||
break;
|
||||
@@ -236,15 +236,15 @@ getlock(void)
|
||||
{
|
||||
int fd;
|
||||
|
||||
Sprintf(gl.lock, "%d%s", getuid(), gp.plname);
|
||||
Sprintf(gl.lock, "%d%s", getuid(), svp.plname);
|
||||
regularize(gl.lock);
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
fd = creat(gl.lock, FCMASK);
|
||||
if (fd == -1) {
|
||||
error("cannot creat lock file.");
|
||||
} else {
|
||||
if (write(fd, (genericptr_t) &gh.hackpid, sizeof(gh.hackpid))
|
||||
!= sizeof(gh.hackpid)) {
|
||||
if (write(fd, (genericptr_t) &svh.hackpid, sizeof(svh.hackpid))
|
||||
!= sizeof(svh.hackpid)) {
|
||||
error("cannot write lock");
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
|
||||
@@ -228,7 +228,7 @@ macopen(const char *name, int flags, long fileType)
|
||||
Handle name;
|
||||
Str255 plnamep;
|
||||
|
||||
C2P(gp.plname, plnamep);
|
||||
C2P(svp.plname, plnamep);
|
||||
name = (Handle)NewString(plnamep);
|
||||
if (name)
|
||||
replace_resource(name, 'STR ', PLAYER_NAME_RES_ID,
|
||||
|
||||
@@ -225,7 +225,7 @@ process_openfile(short src_vol, long src_dir, Str255 fName, OSType ftype)
|
||||
Handle name = Get1Resource('STR ', PLAYER_NAME_RES_ID);
|
||||
if (name) {
|
||||
Str255 save_f_p;
|
||||
P2C(*(StringHandle) name, gp.plname);
|
||||
P2C(*(StringHandle) name, svp.plname);
|
||||
set_savefile_name(TRUE);
|
||||
C2P(fqname(gs.SAVEF, SAVEPREFIX, 0), save_f_p);
|
||||
force_hdelete(theDirs.dataRefNum, theDirs.dataDirID,
|
||||
|
||||
@@ -493,8 +493,8 @@ mac_askname()
|
||||
SetPortDialogPort(askdialog);
|
||||
|
||||
/* Initialize the name text item */
|
||||
ask_restring(gp.plname, str);
|
||||
if (gp.plname[0]) {
|
||||
ask_restring(svp.plname, str);
|
||||
if (svp.plname[0]) {
|
||||
GetDialogItem(askdialog, RSRC_ASK_NAME, &type, &handle, &rect);
|
||||
SetDialogItemText(handle, str);
|
||||
}
|
||||
@@ -502,8 +502,8 @@ mac_askname()
|
||||
{
|
||||
Str32 pName;
|
||||
pName [0] = 0;
|
||||
if (gp.plname && gp.plname [0]) {
|
||||
strcpy ((char *) pName, gp.plname);
|
||||
if (svp.plname && svp.plname [0]) {
|
||||
strcpy ((char *) pName, svp.plname);
|
||||
c2pstr ((char *) pName);
|
||||
} else {
|
||||
Handle h;
|
||||
@@ -548,7 +548,7 @@ mac_askname()
|
||||
if (flags.initrole >= 0)
|
||||
currrole = flags.initrole;
|
||||
/* Check for backward compatibility */
|
||||
else if ((currrole = str2role(gp.pl_character)) < 0)
|
||||
else if ((currrole = str2role(svp.pl_character)) < 0)
|
||||
currrole = randrole(FALSE);
|
||||
|
||||
/* Initialize the race popup menu */
|
||||
@@ -735,8 +735,8 @@ mac_askname()
|
||||
GetDialogItemText(handle, str);
|
||||
if (str[0] > PL_NSIZ - 1)
|
||||
str[0] = PL_NSIZ - 1;
|
||||
BlockMove(&str[1], gp.plname, str[0]);
|
||||
gp.plname[str[0]] = '\0';
|
||||
BlockMove(&str[1], svp.plname, str[0]);
|
||||
svp.plname[str[0]] = '\0';
|
||||
|
||||
/* Destroy the dialog */
|
||||
for (i = RSRC_ASK_ROLE; i <= RSRC_ASK_MODE; i++) {
|
||||
@@ -758,14 +758,14 @@ mac_askname()
|
||||
break;
|
||||
case 2: /* Debug */
|
||||
wizard = 1;
|
||||
strcpy(gp.plname, WIZARD_NAME);
|
||||
strcpy(svp.plname, WIZARD_NAME);
|
||||
break;
|
||||
default: /* Quit */
|
||||
ExitToShell();
|
||||
}
|
||||
|
||||
/* Process the role */
|
||||
strcpy(gp.pl_character, roles[currrole].name.m);
|
||||
strcpy(svp.pl_character, roles[currrole].name.m);
|
||||
flags.initrole = currrole;
|
||||
|
||||
/* Process the race */
|
||||
|
||||
@@ -24,7 +24,7 @@ getlock(void)
|
||||
int fd;
|
||||
int pid = getpid(); /* Process ID */
|
||||
|
||||
Sprintf(gl.lock, "%d%s", getuid(), gp.plname);
|
||||
Sprintf(gl.lock, "%d%s", getuid(), svp.plname);
|
||||
set_levelfile_name(gl.lock, 0);
|
||||
|
||||
if ((fd = open(gl.lock, O_RDWR | O_EXCL | O_CREAT, LEVL_TYPE)) == -1) {
|
||||
|
||||
@@ -459,7 +459,7 @@ plselInitDialog(HWND hWnd)
|
||||
TCHAR wbuf[BUFSZ];
|
||||
|
||||
/* set player name */
|
||||
SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(gp.plname, wbuf, sizeof(wbuf)));
|
||||
SetDlgItemText(hWnd, IDC_PLSEL_NAME, NH_A2W(svp.plname, wbuf, sizeof(wbuf)));
|
||||
|
||||
/* check flags for consistency */
|
||||
if (flags.initrole >= 0) {
|
||||
|
||||
@@ -39,7 +39,7 @@ mswin_have_input()
|
||||
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()
|
||||
|
||||
#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.kbd.ch = '\033';
|
||||
@@ -98,7 +98,7 @@ mswin_input_peek()
|
||||
|
||||
#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.kbd.ch = '\033';
|
||||
|
||||
@@ -826,7 +826,7 @@ mswin_layout_main_window(HWND changed_child)
|
||||
/* show command window only if it exists and
|
||||
the game is ready (plname is set) */
|
||||
if (GetNHApp()->bCmdPad && cmd_size.cx > 0 && cmd_size.cy > 0
|
||||
&& *gp.plname) {
|
||||
&& *svp.plname) {
|
||||
MoveWindow(GetNHApp()->hCmdWnd, cmd_org.x, cmd_org.y, cmd_size.cx,
|
||||
cmd_size.cy, TRUE);
|
||||
ShowWindow(GetNHApp()->hCmdWnd, SW_SHOW);
|
||||
|
||||
@@ -533,7 +533,7 @@ onMSNHCommand(HWND hWnd, WPARAM wParam, LPARAM lParam)
|
||||
|
||||
if (!data->text.text) {
|
||||
data->text.text = mswin_init_text_buffer(
|
||||
gp.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
svp.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
if (!data->text.text)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ FormatStatusString(char *text, int format)
|
||||
int hp, hpmax;
|
||||
int cap = near_capacity();
|
||||
|
||||
Strcpy(text, gp.plname);
|
||||
Strcpy(text, svp.plname);
|
||||
if ('a' <= text[0] && text[0] <= 'z')
|
||||
text[0] += 'A' - 'a';
|
||||
text[10] = 0;
|
||||
@@ -253,7 +253,7 @@ FormatStatusString(char *text, int format)
|
||||
|
||||
/* forth line */
|
||||
if (flags.time)
|
||||
Sprintf(nb = eos(nb), "T:%ld ", gm.moves);
|
||||
Sprintf(nb = eos(nb), "T:%ld ", svm.moves);
|
||||
|
||||
if (strcmp(hu_stat[u.uhs], " ")) {
|
||||
Strcat(text, hu_stat[u.uhs]);
|
||||
|
||||
@@ -39,7 +39,7 @@ mswin_init_text_window()
|
||||
|
||||
ZeroMemory(data, sizeof(NHTextWindow));
|
||||
data->window_text = mswin_init_text_buffer(
|
||||
gp.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
svp.program_state.gameover ? FALSE : GetNHApp()->bWrapText);
|
||||
SetWindowLong(ret, GWL_USERDATA, (LONG) data);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -646,7 +646,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 */
|
||||
}
|
||||
|
||||
@@ -226,8 +226,8 @@ gotlock:
|
||||
if (fd == -1) {
|
||||
error("cannot creat lock file (%s.)", fq_lock);
|
||||
} else {
|
||||
if (write(fd, (char *) &gh.hackpid, sizeof(gh.hackpid))
|
||||
!= sizeof(gh.hackpid)) {
|
||||
if (write(fd, (char *) &svh.hackpid, sizeof(svh.hackpid))
|
||||
!= sizeof(svh.hackpid)) {
|
||||
error("cannot write lock (%s)", fq_lock);
|
||||
}
|
||||
if (close(fd) == -1) {
|
||||
|
||||
Reference in New Issue
Block a user