comparison rogue4/options.c @ 229:50b89f165a34

Use uniform return types for functions related to options. Functions for printing options now return void. Functions for setting options now return int. Argument types still vary, though converting all the option pointers to void* would be possible.
author John "Elwin" Edwards
date Sun, 06 Mar 2016 14:45:18 -0500
parents 1b73a8641b37
children e52a8a7ad4c5
comparison
equal deleted inserted replaced
228:b67b99f6c92b 229:50b89f165a34
25 * description of an option and what to do with it 25 * description of an option and what to do with it
26 */ 26 */
27 struct optstruct { 27 struct optstruct {
28 char *o_name; /* option name */ 28 char *o_name; /* option name */
29 char *o_prompt; /* prompt for interactive entry */ 29 char *o_prompt; /* prompt for interactive entry */
30 int *o_opt; /* pointer to thing to set */ 30 void *o_opt; /* pointer to thing to set */
31 int (*o_putfunc)(); /* function to print value */ 31 void (*o_putfunc)(); /* function to print value */
32 int (*o_getfunc)(); /* function to get value interactively */ 32 int (*o_getfunc)(); /* function to get value interactively */
33 }; 33 };
34 34
35 typedef struct optstruct OPTION; 35 typedef struct optstruct OPTION;
36 36
41 int get_bool(bool *bp, WINDOW *win); 41 int get_bool(bool *bp, WINDOW *win);
42 int get_str(char *opt, WINDOW *win); 42 int get_str(char *opt, WINDOW *win);
43 43
44 OPTION optlist[] = { 44 OPTION optlist[] = {
45 {"terse", "Terse output: ", 45 {"terse", "Terse output: ",
46 (int *) &terse, put_bool, get_bool }, 46 (void *) &terse, put_bool, get_bool },
47 {"flush", "Flush typeahead during battle: ", 47 {"flush", "Flush typeahead during battle: ",
48 (int *) &fight_flush, put_bool, get_bool }, 48 (void *) &fight_flush, put_bool, get_bool },
49 {"jump", "Show position only at end of run: ", 49 {"jump", "Show position only at end of run: ",
50 (int *) &jump, put_bool, get_bool }, 50 (void *) &jump, put_bool, get_bool },
51 {"step", "Do inventories one line at a time: ", 51 {"step", "Do inventories one line at a time: ",
52 (int *) &slow_invent, put_bool, get_bool }, 52 (void *) &slow_invent, put_bool, get_bool },
53 {"askme", "Ask me about unidentified things: ", 53 {"askme", "Ask me about unidentified things: ",
54 (int *) &askme, put_bool, get_bool }, 54 (void *) &askme, put_bool, get_bool },
55 {"passgo", "Follow turnings in passageways: ", 55 {"passgo", "Follow turnings in passageways: ",
56 (int *) &passgo, put_bool, get_bool }, 56 (void *) &passgo, put_bool, get_bool },
57 {"name", "Name: ", 57 {"name", "Name: ",
58 (int *) whoami, put_str, get_str }, 58 (void *) whoami, put_str, get_str },
59 {"fruit", "Fruit: ", 59 {"fruit", "Fruit: ",
60 (int *) fruit, put_str, get_str }, 60 (void *) fruit, put_str, get_str },
61 {"file", "Save file: ", 61 {"file", "Save file: ",
62 (int *) file_name, put_str, get_str } 62 (void *) file_name, put_str, get_str }
63 }; 63 };
64 64
65 /* 65 /*
66 * option: 66 * option:
67 * Print and then set options from the terminal 67 * Print and then set options from the terminal