Mercurial > hg > early-roguelike
comparison rogue4/save.c @ 84:a0d4caead33b
rogue4: don't delete the savefile if the terminal is too small.
Let the user resize the terminal and try again.
| author | John "Elwin" Edwards |
|---|---|
| date | Thu, 08 Aug 2013 14:30:12 -0700 |
| parents | 0e212d46b68f |
| children | d852b8f088c5 |
comparison
equal
deleted
inserted
replaced
| 83:09db0cf536af | 84:a0d4caead33b |
|---|---|
| 228 } | 228 } |
| 229 | 229 |
| 230 fstat(inf, &sbuf2); | 230 fstat(inf, &sbuf2); |
| 231 fflush(stdout); | 231 fflush(stdout); |
| 232 syml = issymlink(file); | 232 syml = issymlink(file); |
| 233 if ( | |
| 234 #ifdef WIZARD | |
| 235 !wizard && | |
| 236 #endif | |
| 237 md_unlink(file) < 0) | |
| 238 { | |
| 239 printf("Cannot unlink file\n"); | |
| 240 return FALSE; | |
| 241 } | |
| 242 | 233 |
| 243 fflush(stdout); | 234 fflush(stdout); |
| 244 | 235 |
| 245 encread(&slines,sizeof(slines),inf); | 236 encread(&slines,sizeof(slines),inf); |
| 246 encread(&scols,sizeof(scols),inf); | 237 encread(&scols,sizeof(scols),inf); |
| 270 keypad(stdscr,1); | 261 keypad(stdscr,1); |
| 271 | 262 |
| 272 mpos = 0; | 263 mpos = 0; |
| 273 mvprintw(0, 0, "%s: %s", file, ctime(&sbuf2.st_mtime)); | 264 mvprintw(0, 0, "%s: %s", file, ctime(&sbuf2.st_mtime)); |
| 274 | 265 |
| 266 if (rs_restore_file(inf) == FALSE) | |
| 267 { | |
| 268 endwin(); | |
| 269 printf("Cannot restore file\n"); | |
| 270 return(FALSE); | |
| 271 } | |
| 272 | |
| 273 if ( | |
| 274 #ifdef WIZARD | |
| 275 !wizard && | |
| 276 #endif | |
| 277 md_unlink(file) < 0) | |
| 278 { | |
| 279 printf("Cannot unlink file\n"); | |
| 280 return FALSE; | |
| 281 } | |
| 282 | |
| 275 /* | 283 /* |
| 276 * defeat multiple restarting from the same place | 284 * defeat multiple restarting from the same place |
| 277 */ | 285 */ |
| 278 #ifdef WIZARD | 286 #ifdef WIZARD |
| 279 if (!wizard) | 287 if (!wizard) |
| 281 if (sbuf2.st_nlink != 1 || syml) | 289 if (sbuf2.st_nlink != 1 || syml) |
| 282 { | 290 { |
| 283 printf("Cannot restore from a linked file\n"); | 291 printf("Cannot restore from a linked file\n"); |
| 284 return FALSE; | 292 return FALSE; |
| 285 } | 293 } |
| 286 | |
| 287 if (rs_restore_file(inf) == FALSE) | |
| 288 { | |
| 289 endwin(); | |
| 290 printf("Cannot restore file\n"); | |
| 291 return(FALSE); | |
| 292 } | |
| 293 | 294 |
| 294 #ifdef SIGTSTP | 295 #ifdef SIGTSTP |
| 295 signal(SIGTSTP, tstp); | 296 signal(SIGTSTP, tstp); |
| 296 #endif | 297 #endif |
| 297 environ = envp; | 298 environ = envp; |
