diff srogue/options.c @ 38:8a9525231fb6

Prevent changing name or savefile when SAVEDIR is used.
author elwin
date Sat, 27 Nov 2010 16:22:30 +0000
parents 34d7a614855e
children 3aa87373c908
line wrap: on
line diff
--- a/srogue/options.c	Thu Nov 25 17:28:29 2010 +0000
+++ b/srogue/options.c	Sat Nov 27 16:22:30 2010 +0000
@@ -40,6 +40,10 @@
 	{ "file", 	"Save file: ",	file_name }
 };
 #define	NUM_OPTS	(sizeof optlist / sizeof (OPTION))
+OPTION safeoptlist[] = {
+	{ "fruit",	"Fruit: ",		fruit },
+};
+#define	NUM_SOPTS	(sizeof safeoptlist / sizeof (OPTION))
 
 /*
  * print and then set options from the terminal
@@ -48,14 +52,25 @@
 {
 	reg OPTION	*op;
 	reg int	wh;
+	OPTION *olist;
+	int olen;
+
+	if (use_savedir) {
+		olist = safeoptlist;
+		olen = NUM_SOPTS;
+	}
+	else {
+		olist = optlist;
+		olen = NUM_OPTS;
+	}
 
 	wclear(hw);
 	touchwin(hw);
 	/*
 	 * Display current values of options
 	 */
-	for (op = optlist; op < &optlist[NUM_OPTS]; op++) {
-		wh = op - optlist;
+	for (op = olist; op < &olist[olen]; op++) {
+		wh = op - olist;
 		mvwaddstr(hw, wh, 0, op->o_prompt);
 		mvwaddstr(hw, wh, 16, op->o_opt);
 	}
@@ -63,13 +78,13 @@
 	 * Set values
 	 */
 	wmove(hw, 0, 0);
-	for (op = optlist; op < &optlist[NUM_OPTS]; op++) {
-		wmove(hw, op - optlist, 16);
+	for (op = olist; op < &olist[olen]; op++) {
+		wmove(hw, op - olist, 16);
 		if ((wh = get_str(op->o_opt, hw))) {
 			if (wh == QUIT)
 				break;
-			else if (op > optlist) {
-				wmove(hw, op - optlist, 0);
+			else if (op > olist) {
+				wmove(hw, op - olist, 0);
 				op -= 2;
 			}
 			else {