Mercurial > hg > early-roguelike
changeset 309:11aeff9acc07
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.
author | John "Elwin" Edwards |
---|---|
date | Sun, 02 May 2021 21:54:11 -0400 |
parents | 13b482bd9e66 |
children | 827441d05b3e |
files | arogue7/state.c |
diffstat | 1 files changed, 17 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/arogue7/state.c Sat May 01 09:51:30 2021 -0400 +++ b/arogue7/state.c Sun May 02 21:54:11 2021 -0400 @@ -2511,6 +2511,7 @@ rs_save_file(FILE *savef) { int i; + char temp_buf[LINELEN]; if (write_error) return(WRITESTAT); @@ -2583,9 +2584,17 @@ 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 @@ rs_restore_file(FILE *inf) { int i; + char unused_buf[LINELEN]; if (read_error || format_error) return(READSTAT); @@ -2715,9 +2725,10 @@ 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);