diff rogue5/options.c @ 34:655c317b6237

rogue5: add savedir, logfile, bugfixes
author elwin
date Mon, 24 May 2010 20:16:15 +0000
parents f502bf60e6e4
children
line wrap: on
line diff
--- a/rogue5/options.c	Mon May 24 20:10:59 2010 +0000
+++ b/rogue5/options.c	Mon May 24 20:16:15 2010 +0000
@@ -38,6 +38,7 @@
 typedef struct optstruct	OPTION;
 
 void	pr_optname(const OPTION *op);
+int     allowchange(const OPTION *op);
 
 static const OPTION	optlist[] = {
     {"terse",	 "Terse output",
@@ -79,9 +80,12 @@
      */
     for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++)
     {
-	pr_optname(op);
-	(*op->o_putfunc)(op->o_opt);
-	waddch(hw, '\n');
+        if (allowchange(op))
+        {
+	    pr_optname(op);
+	    (*op->o_putfunc)(op->o_opt);
+	    waddch(hw, '\n');
+        }
     }
     /*
      * Set values
@@ -89,12 +93,16 @@
     wmove(hw, 0, 0);
     for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++)
     {
+        if (!allowchange(op))
+            continue;
 	pr_optname(op);
 	retval = (*op->o_getfunc)(op->o_opt, hw);
 	if (retval)
 	{
 	    if (retval == QUIT)
 		break;
+#if 0
+/* Support for MINUS removed until this section is rewritten. */
 	    else if (op > optlist) {	/* MINUS */
 		wmove(hw, (int)(op - optlist) - 1, 0);
 		op -= 2;
@@ -105,6 +113,9 @@
 		wmove(hw, 0, 0);
 		op--;
 	    }
+#else
+            break;
+#endif
 	}
     }
     /*
@@ -418,6 +429,9 @@
 	 * Look it up and deal with it
 	 */
 	for (op = optlist; op <= &optlist[NUM_OPTS-1]; op++)
+        {
+            if (!allowchange(op))
+                continue;
 	    if (EQSTR(str, op->o_name, len))
 	    {
 		if (op->o_putfunc == put_bool)	/* if option is a boolean */
@@ -471,6 +485,7 @@
 		*(int *)op->o_opt = FALSE;	/* NOSTRICT */
 		break;
 	    }
+        }
 
 	/*
 	 * skip to start of next option name
@@ -499,3 +514,16 @@
     }
     *s1 = '\0';
 }
+
+/* Tells whether the user is allowed to change the option. */
+int
+allowchange(const OPTION *opt)
+{
+    if (!use_savedir)
+        return TRUE;
+    if (!strcmp(opt->o_name, "name"))
+        return FALSE;
+    if (!strcmp(opt->o_name, "file"))
+        return FALSE;
+    return TRUE;
+}