Advanced Rogue 7: ignore file locations in the save file when restoring.

The variables file_name, score_file, and home are no longer overwritten
with the values stored in the save file.  Those values could be
inaccurate if the files have been moved or configuration has changed.
This commit is contained in:
John "Elwin" Edwards 2021-05-02 21:54:11 -04:00
parent d1422feb80
commit 2b6d8bcb77

View file

@ -2511,6 +2511,7 @@ int
rs_save_file(FILE *savef)
{
int i;
char temp_buf[LINELEN];
if (write_error)
return(WRITESTAT);
@ -2583,9 +2584,17 @@ rs_save_file(FILE *savef)
rs_write_misc(savef);
rs_write(savef,whoami,LINELEN);
rs_write(savef,huh,LINELEN);
rs_write(savef,file_name,LINELEN);
rs_write(savef,score_file,LINELEN);
rs_write(savef,home,LINELEN);
/* These path names are no longer used when restoring. They are only
* written here for compatibility. */
strncpy(temp_buf, file_name, LINELEN);
temp_buf[LINELEN-1] = '\0';
rs_write(savef, temp_buf, LINELEN);
strncpy(temp_buf, score_file, LINELEN);
temp_buf[LINELEN-1] = '\0';
rs_write(savef, temp_buf, LINELEN);
strncpy(temp_buf, home, LINELEN);
temp_buf[LINELEN-1] = '\0';
rs_write(savef, temp_buf, LINELEN);
rs_write_window(savef, cw);
rs_write_window(savef, hw);
rs_write_window(savef, mw);
@ -2638,6 +2647,7 @@ int
rs_restore_file(FILE *inf)
{
int i;
char unused_buf[LINELEN];
if (read_error || format_error)
return(READSTAT);
@ -2715,9 +2725,10 @@ rs_restore_file(FILE *inf)
rs_read_misc(inf);
rs_read(inf,whoami,LINELEN);
rs_read(inf,huh,LINELEN);
rs_read(inf,file_name,LINELEN);
rs_read(inf,score_file,LINELEN);
rs_read(inf,home,LINELEN);
/* These three path names are now ignored. */
rs_read(inf, unused_buf, LINELEN); /* file_name */
rs_read(inf, unused_buf, LINELEN); /* score_file */
rs_read(inf, unused_buf, LINELEN); /* home */
rs_read_window(inf, cw);
rs_read_window(inf, hw);
rs_read_window(inf, mw);