changeset 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 d7d45e980791
files srogue/options.c srogue/save.c
diffstat 2 files changed, 29 insertions(+), 7 deletions(-) [+]
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 {
--- a/srogue/save.c	Thu Nov 25 17:28:29 2010 +0000
+++ b/srogue/save.c	Sat Nov 27 16:22:30 2010 +0000
@@ -58,7 +58,10 @@
 
 	mpos = 0;
 	if (file_name[0] != '\0') {
-		msg("Save file (%s)? ", file_name);
+		if (use_savedir)
+			msg("Save game? (y/n) ");
+		else
+			msg("Save file (%s)? ", file_name);
 		do {
 			c = wgetch(cw);
 			if(c == ESCAPE) {
@@ -70,6 +73,10 @@
 		if (c == 'y')
 			goto gotfile;
 	}
+	if (use_savedir) {
+		msg("");
+		return FALSE;
+	}
 	msg("File name: ");
 	mpos = 0;
 	buf[0] = '\0';