diff rogue4/save.c @ 14:e7dc81b41168

rogue4: prevent changing name or save file when using system savedir
author edwarj4
date Sat, 31 Oct 2009 13:20:00 +0000
parents 63b9fd7d70ce
children 09da55b986ca
line wrap: on
line diff
--- a/rogue4/save.c	Sat Oct 31 01:51:52 2009 +0000
+++ b/rogue4/save.c	Sat Oct 31 13:20:00 2009 +0000
@@ -32,6 +32,7 @@
  * save_game:
  *	Implement the "save game" command
  */
+/* This has to be cleaned up, these goto's are annoying. */
 save_game()
 {
     register FILE *savef;
@@ -67,6 +68,14 @@
 	}
     }
 
+    if (use_savedir)
+    {
+        /* You can't change the savefile if you're using the system 
+           savedir, because that means you have privileges. */
+        msg("");
+        return FALSE;
+    }
+
     do
     {
 	mpos = 0;
@@ -102,7 +111,11 @@
 	}
 	strcpy(file_name, buf);
 	if ((savef = fopen(file_name, "w")) == NULL)
+        {
 	    msg(strerror(errno));	/* fake perror() */
+            if (use_savedir)
+                return FALSE;
+        }
     } while (savef == NULL);
 
     /*