Mercurial > hg > early-roguelike
comparison arogue7/state.c @ 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 | e52a8a7ad4c5 |
| children |
comparison
equal
deleted
inserted
replaced
| 308:13b482bd9e66 | 309:11aeff9acc07 |
|---|---|
| 2509 | 2509 |
| 2510 int | 2510 int |
| 2511 rs_save_file(FILE *savef) | 2511 rs_save_file(FILE *savef) |
| 2512 { | 2512 { |
| 2513 int i; | 2513 int i; |
| 2514 char temp_buf[LINELEN]; | |
| 2514 | 2515 |
| 2515 if (write_error) | 2516 if (write_error) |
| 2516 return(WRITESTAT); | 2517 return(WRITESTAT); |
| 2517 | 2518 |
| 2518 rs_write_object_list(savef, lvl_obj); | 2519 rs_write_object_list(savef, lvl_obj); |
| 2581 rs_write_rings(savef); | 2582 rs_write_rings(savef); |
| 2582 rs_write_sticks(savef); | 2583 rs_write_sticks(savef); |
| 2583 rs_write_misc(savef); | 2584 rs_write_misc(savef); |
| 2584 rs_write(savef,whoami,LINELEN); | 2585 rs_write(savef,whoami,LINELEN); |
| 2585 rs_write(savef,huh,LINELEN); | 2586 rs_write(savef,huh,LINELEN); |
| 2586 rs_write(savef,file_name,LINELEN); | 2587 /* These path names are no longer used when restoring. They are only |
| 2587 rs_write(savef,score_file,LINELEN); | 2588 * written here for compatibility. */ |
| 2588 rs_write(savef,home,LINELEN); | 2589 strncpy(temp_buf, file_name, LINELEN); |
| 2590 temp_buf[LINELEN-1] = '\0'; | |
| 2591 rs_write(savef, temp_buf, LINELEN); | |
| 2592 strncpy(temp_buf, score_file, LINELEN); | |
| 2593 temp_buf[LINELEN-1] = '\0'; | |
| 2594 rs_write(savef, temp_buf, LINELEN); | |
| 2595 strncpy(temp_buf, home, LINELEN); | |
| 2596 temp_buf[LINELEN-1] = '\0'; | |
| 2597 rs_write(savef, temp_buf, LINELEN); | |
| 2589 rs_write_window(savef, cw); | 2598 rs_write_window(savef, cw); |
| 2590 rs_write_window(savef, hw); | 2599 rs_write_window(savef, hw); |
| 2591 rs_write_window(savef, mw); | 2600 rs_write_window(savef, mw); |
| 2592 rs_write_window(savef, msgw); | 2601 rs_write_window(savef, msgw); |
| 2593 rs_write_window(savef, stdscr); | 2602 rs_write_window(savef, stdscr); |
| 2636 | 2645 |
| 2637 int | 2646 int |
| 2638 rs_restore_file(FILE *inf) | 2647 rs_restore_file(FILE *inf) |
| 2639 { | 2648 { |
| 2640 int i; | 2649 int i; |
| 2650 char unused_buf[LINELEN]; | |
| 2641 | 2651 |
| 2642 if (read_error || format_error) | 2652 if (read_error || format_error) |
| 2643 return(READSTAT); | 2653 return(READSTAT); |
| 2644 | 2654 |
| 2645 rs_read_object_list(inf, &lvl_obj); | 2655 rs_read_object_list(inf, &lvl_obj); |
| 2713 rs_read_rings(inf); | 2723 rs_read_rings(inf); |
| 2714 rs_read_sticks(inf); | 2724 rs_read_sticks(inf); |
| 2715 rs_read_misc(inf); | 2725 rs_read_misc(inf); |
| 2716 rs_read(inf,whoami,LINELEN); | 2726 rs_read(inf,whoami,LINELEN); |
| 2717 rs_read(inf,huh,LINELEN); | 2727 rs_read(inf,huh,LINELEN); |
| 2718 rs_read(inf,file_name,LINELEN); | 2728 /* These three path names are now ignored. */ |
| 2719 rs_read(inf,score_file,LINELEN); | 2729 rs_read(inf, unused_buf, LINELEN); /* file_name */ |
| 2720 rs_read(inf,home,LINELEN); | 2730 rs_read(inf, unused_buf, LINELEN); /* score_file */ |
| 2731 rs_read(inf, unused_buf, LINELEN); /* home */ | |
| 2721 rs_read_window(inf, cw); | 2732 rs_read_window(inf, cw); |
| 2722 rs_read_window(inf, hw); | 2733 rs_read_window(inf, hw); |
| 2723 rs_read_window(inf, mw); | 2734 rs_read_window(inf, mw); |
| 2724 rs_read_window(inf, msgw); | 2735 rs_read_window(inf, msgw); |
| 2725 rs_read_window(inf, stdscr); | 2736 rs_read_window(inf, stdscr); |
