changeset 85:d852b8f088c5

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.
author John "Elwin" Edwards
date Fri, 09 Aug 2013 09:34:07 -0700
parents a0d4caead33b
children 8757a0593e6e
files arogue5/save.c rogue3/save.c rogue4/save.c srogue/save.c
diffstat 4 files changed, 28 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/arogue5/save.c	Thu Aug 08 14:30:12 2013 -0700
+++ b/arogue5/save.c	Fri Aug 09 09:34:07 2013 -0700
@@ -245,6 +245,12 @@
 	}
     }
 
+    if (pstats.s_hpt <= 0) {
+        endwin();
+        printf("This character is already dead.\n");
+        return FALSE;
+    }
+
     environ = envp;
     strcpy(file_name, file);
     setup();
--- a/rogue3/save.c	Thu Aug 08 14:30:12 2013 -0700
+++ b/rogue3/save.c	Fri Aug 09 09:34:07 2013 -0700
@@ -234,6 +234,12 @@
 	return FALSE;
     }
 
+    if (pstats.s_hpt <= 0) {
+        endwin();
+        printf("This character is already dead.\n");
+        return FALSE;
+    }
+
     environ = envp;
     strcpy(file_name, file);
     setup();
--- a/rogue4/save.c	Thu Aug 08 14:30:12 2013 -0700
+++ b/rogue4/save.c	Fri Aug 09 09:34:07 2013 -0700
@@ -245,6 +245,7 @@
 
     if (slines > LINES) 
     { 
+        endwin();
         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); 
         return(FALSE); 
@@ -252,6 +253,7 @@
     
     if (scols > COLS) 
     { 
+        endwin();
         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); 
         return(FALSE); 
@@ -276,6 +278,7 @@
 #endif
     md_unlink(file) < 0)
     {
+        endwin();
 	printf("Cannot unlink file\n");
 	return FALSE;
     }
@@ -288,10 +291,17 @@
 #endif
 	if (sbuf2.st_nlink != 1 || syml)
 	{
+            endwin();
 	    printf("Cannot restore from a linked file\n");
 	    return FALSE;
 	}
 
+    if (pstats.s_hpt <= 0) {
+        endwin();
+        printf("This character is already dead.\n");
+        return FALSE;
+    }
+
 #ifdef SIGTSTP
     signal(SIGTSTP, tstp);
 #endif
--- a/srogue/save.c	Thu Aug 08 14:30:12 2013 -0700
+++ b/srogue/save.c	Fri Aug 09 09:34:07 2013 -0700
@@ -342,6 +342,12 @@
 
 	}
 
+	if (him->s_hpt <= 0) {
+		endwin();
+		printf("This character is already dead.\n");
+		return FALSE;
+	}
+
 	environ = envp;
 
 	strcpy(file_name, file);