Mercurial > hg > early-roguelike
comparison rogue4/save.c @ 14:e7dc81b41168
rogue4: prevent changing name or save file when using system savedir
author | edwarj4 |
---|---|
date | Sat, 31 Oct 2009 13:20:00 +0000 |
parents | 63b9fd7d70ce |
children | 09da55b986ca |
comparison
equal
deleted
inserted
replaced
13:63b9fd7d70ce | 14:e7dc81b41168 |
---|---|
30 | 30 |
31 /* | 31 /* |
32 * save_game: | 32 * save_game: |
33 * Implement the "save game" command | 33 * Implement the "save game" command |
34 */ | 34 */ |
35 /* This has to be cleaned up, these goto's are annoying. */ | |
35 save_game() | 36 save_game() |
36 { | 37 { |
37 register FILE *savef; | 38 register FILE *savef; |
38 register int c; | 39 register int c; |
39 char buf[MAXSTR]; | 40 char buf[MAXSTR]; |
63 if (c == 'y' || c == 'Y') | 64 if (c == 'y' || c == 'Y') |
64 { | 65 { |
65 strcpy(buf, file_name); | 66 strcpy(buf, file_name); |
66 goto gotfile; | 67 goto gotfile; |
67 } | 68 } |
69 } | |
70 | |
71 if (use_savedir) | |
72 { | |
73 /* You can't change the savefile if you're using the system | |
74 savedir, because that means you have privileges. */ | |
75 msg(""); | |
76 return FALSE; | |
68 } | 77 } |
69 | 78 |
70 do | 79 do |
71 { | 80 { |
72 mpos = 0; | 81 mpos = 0; |
100 } | 109 } |
101 msg("file name: %s", buf); | 110 msg("file name: %s", buf); |
102 } | 111 } |
103 strcpy(file_name, buf); | 112 strcpy(file_name, buf); |
104 if ((savef = fopen(file_name, "w")) == NULL) | 113 if ((savef = fopen(file_name, "w")) == NULL) |
114 { | |
105 msg(strerror(errno)); /* fake perror() */ | 115 msg(strerror(errno)); /* fake perror() */ |
116 if (use_savedir) | |
117 return FALSE; | |
118 } | |
106 } while (savef == NULL); | 119 } while (savef == NULL); |
107 | 120 |
108 /* | 121 /* |
109 * write out encrpyted file (after a stat) | 122 * write out encrpyted file (after a stat) |
110 * The fwrite is to force allocation of the buffer before the write | 123 * The fwrite is to force allocation of the buffer before the write |