diff arogue7/options.c @ 239:837044d2c362

Merge the GCC5 and build fix branches. This fixes all warnings produced by GCC 5, except the ones related to system functions. Those could be fixed by including the proper headers, but it would be better to replace the system-dependent code with functions from mdport.c.
author John "Elwin" Edwards
date Fri, 11 Mar 2016 19:47:52 -0500
parents 50b89f165a34
children e940e6c00751
line wrap: on
line diff
--- a/arogue7/options.c	Tue Mar 08 19:45:41 2016 -0500
+++ b/arogue7/options.c	Fri Mar 11 19:47:52 2016 -0500
@@ -33,8 +33,8 @@
 struct optstruct {
     char	*o_name;	/* option name */
     char	*o_prompt;	/* prompt for interactive entry */
-    int		*o_opt;		/* pointer to thing to set */
-    int		(*o_putfunc)();	/* function to print value */
+    void	*o_opt;		/* pointer to thing to set */
+    void	(*o_putfunc)();	/* function to print value */
     int		(*o_getfunc)();	/* function to get value interactively */
 };
 
@@ -45,9 +45,9 @@
 void put_str(char *str, WINDOW *win);
 int get_str(char *opt, WINDOW *win);
 void put_abil(int *ability, WINDOW *win);
-void get_abil(int *abil, WINDOW *win);
+int get_abil(int *abil, WINDOW *win);
 void put_quest(int *quest, WINDOW *win);
-void get_quest(int *quest, WINDOW *win);
+int get_quest(int *quest, WINDOW *win);
 int get_ro(WINDOW *win, int oy, int ox);
 
 int get_str_prot(char *opt, WINDOW *win);
@@ -56,55 +56,55 @@
 
 OPTION	optlist[] = {
     {"terse",	 "Terse output: ",
-		 (int *) &terse,	put_bool,	get_bool	},
+		 (void *) &terse,	put_bool,	get_bool	},
     {"flush",	 "Flush typeahead during battle: ",
-		 (int *) &fight_flush,	put_bool,	get_bool	},
+		 (void *) &fight_flush,	put_bool,	get_bool	},
     {"jump",	 "Show position only at end of run: ",
-		 (int *) &jump,		put_bool,	get_bool	},
+		 (void *) &jump,	put_bool,	get_bool	},
     {"step",	"Do inventories one line at a time: ",
-		(int *) &slow_invent,	put_bool,	get_bool	},
+		(void *) &slow_invent,	put_bool,	get_bool	},
     {"askme",	"Ask me about unidentified things: ",
-		(int *) &askme,		put_bool,	get_bool	},
+		(void *) &askme,	put_bool,	get_bool	},
     {"pickup",  "Pick things up automatically: ",
-		(int *) &auto_pickup,	put_bool,	get_bool	},
+		(void *) &auto_pickup,	put_bool,	get_bool	},
     {"overlay", "Overlay menu: ",
-		(int *) &menu_overlay,	put_bool,	get_bool	},
+		(void *) &menu_overlay,	put_bool,	get_bool	},
     {"name",	 "Name: ",
-		(int *) whoami,		put_str,	get_str_prot	},
+		(void *) whoami,	put_str,	get_str_prot	},
     {"file",	 "Save file: ",
-		(int *) file_name,	put_str,	get_str_prot	},
+		(void *) file_name,	put_str,	get_str_prot	},
     {"score",	 "Score file: ",
-		(int *) score_file,	put_str,	get_score	},
+		(void *) score_file,	put_str,	get_score	},
     {"class",	"Character class: ",
-		(int *)&char_type,	put_abil,	get_abil	},
+		(void *)&char_type,	put_abil,	get_abil	},
     {"quest",	"Quest item: ",
-		(int *) &quest_item,	put_quest,	get_quest	}
+		(void *) &quest_item,	put_quest,	get_quest	}
 };
 
 /*
  * The ability field is read-only
  */
-void
+int
 get_abil(int *abil, WINDOW *win)
 {
     register int oy, ox;
 
     getyx(win, oy, ox);
     put_abil(abil, win);
-    get_ro(win, oy, ox);
+    return get_ro(win, oy, ox);
 }
 
 /*
  * The quest field is read-only
  */
-void
+int
 get_quest(int *quest, WINDOW *win)
 {
     register int oy, ox;
 
     getyx(win, oy, ox);
     waddstr(win, rel_magic[*quest].mi_name);
-    get_ro(win, oy, ox);
+    return get_ro(win, oy, ox);
 }
 
 /*
@@ -387,14 +387,15 @@
 			    strcpy((char *)op->o_opt, (char *)value);
 		    }
 
-		    else if (*op->o_opt == -1) { /* Only init ability once */
+		    else if (*(int *)op->o_opt == -1) {
+			/* Only init ability once */
 			register int len = strlen(value);
 			register int i;
 
 			if (isupper(value[0])) value[0] = tolower(value[0]);
 			for (i=0; i<NUM_CHARTYPES-1; i++) {
 			    if (EQSTR(value, char_class[i].name, len)) {
-				*op->o_opt = i;
+				*(int *)op->o_opt = i;
 				break;
 			    }
 			}