rogue5: add savedir, logfile, bugfixes
This commit is contained in:
parent
3741c4867d
commit
53a15a3e2e
13 changed files with 2124 additions and 1397 deletions
|
|
@ -41,7 +41,10 @@ over:
|
|||
{
|
||||
for (;;)
|
||||
{
|
||||
msg("save file (%s)? ", file_name);
|
||||
if (use_savedir)
|
||||
msg("Save game? ");
|
||||
else
|
||||
msg("Save file (%s)? ", file_name);
|
||||
c = readchar();
|
||||
mpos = 0;
|
||||
if (c == ESCAPE)
|
||||
|
|
@ -63,6 +66,8 @@ over:
|
|||
}
|
||||
}
|
||||
|
||||
if (use_savedir) /* User chose N, changing location isn't allowed. */
|
||||
goto quit_it;
|
||||
do
|
||||
{
|
||||
mpos = 0;
|
||||
|
|
@ -79,7 +84,7 @@ gotfile:
|
|||
/*
|
||||
* test to see if the file exists
|
||||
*/
|
||||
if (stat(buf, &sbuf) >= 0)
|
||||
if (stat(buf, &sbuf) >= 0 && !use_savedir)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
|
|
@ -99,7 +104,11 @@ gotfile:
|
|||
}
|
||||
strcpy(file_name, buf);
|
||||
if ((savef = fopen(file_name, "w")) == NULL)
|
||||
{
|
||||
msg(strerror(errno));
|
||||
if (use_savedir)
|
||||
return;
|
||||
}
|
||||
} while (savef == NULL);
|
||||
msg("");
|
||||
save_file(savef);
|
||||
|
|
@ -138,13 +147,14 @@ save_file(FILE *savef)
|
|||
putchar('\n');
|
||||
endwin();
|
||||
resetltchars();
|
||||
md_chmod(file_name, 0400);
|
||||
md_chmod(file_name, 0644);
|
||||
encwrite(version, strlen(version)+1, savef);
|
||||
sprintf(buf,"%d x %d\n", LINES, COLS);
|
||||
encwrite(buf,80,savef);
|
||||
rs_save_file(savef);
|
||||
fflush(savef);
|
||||
fclose(savef);
|
||||
printf("See you soon, %s!\n", whoami);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
@ -167,8 +177,11 @@ restore(const char *file)
|
|||
|
||||
md_tstphold();
|
||||
|
||||
if ((inf = fopen(file,"r")) == NULL)
|
||||
if ((inf = fopen(file,"r")) == NULL)
|
||||
{
|
||||
/* If a system savefile doesn't exist, start a new game. */
|
||||
if (use_savedir && errno == ENOENT)
|
||||
return TRUE;
|
||||
perror(file);
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue