comparison urogue/save.c @ 261:ac42afd962e4

UltraRogue: restrict changing name and save file. When the -n option is in use, player name and save file location cannot be changed. The score file is also restricted.
author John "Elwin" Edwards
date Sun, 12 Feb 2017 20:16:57 -0500
parents 096d3cfd9afd
children 1db299e868b8
comparison
equal deleted inserted replaced
260:b80e1bf4eaec 261:ac42afd962e4
23 #include <string.h> 23 #include <string.h>
24 #include <ctype.h> 24 #include <ctype.h>
25 #include <errno.h> 25 #include <errno.h>
26 #include "rogue.h" 26 #include "rogue.h"
27 27
28 int save_savedir_game(void);
29
28 int 30 int
29 save_game(void) 31 save_game(void)
30 { 32 {
31 FILE *savefd; 33 FILE *savefd;
32 char buf[2 * LINELEN]; 34 char buf[2 * LINELEN];
33 char oldfile[2*LINELEN]; 35 char oldfile[2*LINELEN];
36
37 if (use_savedir)
38 return save_savedir_game();
34 39
35 /* get file name */ 40 /* get file name */
36 41
37 strcpy(oldfile,file_name); 42 strcpy(oldfile,file_name);
38 43
75 80
76 /* write out [compressed?] file */ 81 /* write out [compressed?] file */
77 82
78 save_file(savefd); 83 save_file(savefd);
79 return(TRUE); 84 return(TRUE);
85 }
86
87 /*
88 * save_savedir_game()
89 * Simplified save function for when system savefiles are used.
90 */
91 int
92 save_savedir_game(void)
93 {
94 FILE *savef;
95 char c;
96
97 mpos = 0;
98 msg("Save game? ");
99 c = readcharw(cw);
100 if (c == 'y' || c == 'Y')
101 {
102 if ((savef = fopen(file_name, "w")) == NULL)
103 {
104 msg(strerror(errno));
105 return(FALSE);
106 }
107 msg("");
108 save_file(savef);
109 return(TRUE);
110 }
111 else
112 {
113 msg("");
114 return(FALSE);
115 }
80 } 116 }
81 117
82 int 118 int
83 restore(char *file) 119 restore(char *file)
84 { 120 {