Mercurial > hg > early-roguelike
diff 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 |
line wrap: on
line diff
--- a/urogue/save.c Thu Feb 09 20:13:25 2017 -0500 +++ b/urogue/save.c Sun Feb 12 20:16:57 2017 -0500 @@ -25,6 +25,8 @@ #include <errno.h> #include "rogue.h" +int save_savedir_game(void); + int save_game(void) { @@ -32,6 +34,9 @@ char buf[2 * LINELEN]; char oldfile[2*LINELEN]; + if (use_savedir) + return save_savedir_game(); + /* get file name */ strcpy(oldfile,file_name); @@ -79,6 +84,37 @@ return(TRUE); } +/* + * save_savedir_game() + * Simplified save function for when system savefiles are used. + */ +int +save_savedir_game(void) +{ + FILE *savef; + char c; + + mpos = 0; + msg("Save game? "); + c = readcharw(cw); + if (c == 'y' || c == 'Y') + { + if ((savef = fopen(file_name, "w")) == NULL) + { + msg(strerror(errno)); + return(FALSE); + } + msg(""); + save_file(savef); + return(TRUE); + } + else + { + msg(""); + return(FALSE); + } +} + int restore(char *file) {