diff xrogue/save.c @ 137:443c8bd3e290

xrogue: restrict changes to the save file location. When using the -n option, disallow changing file_name or whoami via options or dialogs.
author John "Elwin" Edwards
date Sat, 02 May 2015 07:31:14 -0400
parents 1fbdefa82533
children 6e6fb0955095
line wrap: on
line diff
--- a/xrogue/save.c	Wed Apr 22 16:03:00 2015 -0400
+++ b/xrogue/save.c	Sat May 02 07:31:14 2015 -0400
@@ -43,7 +43,10 @@
     mpos = 0;
     if (file_name[0] != '\0')
     {
-        msg("Save file (%s)? ", file_name);
+        if (use_savedir)
+            msg("Save game? ");
+        else
+            msg("Save file (%s)? ", file_name);
         do
         {
             c = wgetch(cw);
@@ -59,6 +62,11 @@
     else
         goto gotfile; /* must save to file restored from */
 
+    if (use_savedir) {
+        msg("");
+        return FALSE;
+    }
+
     do
     {
         msg("File name: ");
@@ -72,8 +80,11 @@
         strcpy(file_name, buf);
 gotfile:
 
-        if ((savef = fopen(file_name, "wb")) == NULL)
+        if ((savef = fopen(file_name, "wb")) == NULL) {
              msg(strerror(errno));
+             if (use_savedir)
+                 return FALSE;
+        }
     } while (savef == NULL);
 
     msg("");