Refuse to restore if the character is dead.

This prevents recovering from death by killing the game between death
and exit, producing an automatic save.
This commit is contained in:
John "Elwin" Edwards 2013-08-09 09:34:07 -07:00
parent 5a47554e45
commit 2d117230ed
4 changed files with 28 additions and 0 deletions

View file

@ -245,6 +245,12 @@ char **envp;
} }
} }
if (pstats.s_hpt <= 0) {
endwin();
printf("This character is already dead.\n");
return FALSE;
}
environ = envp; environ = envp;
strcpy(file_name, file); strcpy(file_name, file);
setup(); setup();

View file

@ -234,6 +234,12 @@ restore(char *file, char **envp)
return FALSE; return FALSE;
} }
if (pstats.s_hpt <= 0) {
endwin();
printf("This character is already dead.\n");
return FALSE;
}
environ = envp; environ = envp;
strcpy(file_name, file); strcpy(file_name, file);
setup(); setup();

View file

@ -245,6 +245,7 @@ char **envp;
if (slines > LINES) if (slines > LINES)
{ {
endwin();
printf("Sorry, original game was played on a screen with %d lines.\n",slines); printf("Sorry, original game was played on a screen with %d lines.\n",slines);
printf("Current screen only has %d lines. Unable to restore game\n",LINES); printf("Current screen only has %d lines. Unable to restore game\n",LINES);
return(FALSE); return(FALSE);
@ -252,6 +253,7 @@ char **envp;
if (scols > COLS) if (scols > COLS)
{ {
endwin();
printf("Sorry, original game was played on a screen with %d columns.\n",scols); printf("Sorry, original game was played on a screen with %d columns.\n",scols);
printf("Current screen only has %d columns. Unable to restore game\n",COLS); printf("Current screen only has %d columns. Unable to restore game\n",COLS);
return(FALSE); return(FALSE);
@ -276,6 +278,7 @@ char **envp;
#endif #endif
md_unlink(file) < 0) md_unlink(file) < 0)
{ {
endwin();
printf("Cannot unlink file\n"); printf("Cannot unlink file\n");
return FALSE; return FALSE;
} }
@ -288,10 +291,17 @@ char **envp;
#endif #endif
if (sbuf2.st_nlink != 1 || syml) if (sbuf2.st_nlink != 1 || syml)
{ {
endwin();
printf("Cannot restore from a linked file\n"); printf("Cannot restore from a linked file\n");
return FALSE; return FALSE;
} }
if (pstats.s_hpt <= 0) {
endwin();
printf("This character is already dead.\n");
return FALSE;
}
#ifdef SIGTSTP #ifdef SIGTSTP
signal(SIGTSTP, tstp); signal(SIGTSTP, tstp);
#endif #endif

View file

@ -342,6 +342,12 @@ char *file, **envp;
} }
if (him->s_hpt <= 0) {
endwin();
printf("This character is already dead.\n");
return FALSE;
}
environ = envp; environ = envp;
strcpy(file_name, file); strcpy(file_name, file);