Source:NetHack 3.4.3/src/options.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to src/options.c from NetHack 3.4.3. To link to a particular line, write [[options.c#line123]], for example.

Top of file[edit]

  1. /*	SCCS Id: @(#)options.c	3.4	2003/11/14	*/
  2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  3. /* NetHack may be freely redistributed.  See license for details. */

The NetHack General Public License applies to screenshots, source code and other content from NetHack.

This content was modified from the original NetHack source code distribution (by splitting up NetHack content between wiki pages, and possibly further editing). See the page history for a list of who changed it, and on what dates.

  1. #ifdef OPTION_LISTS_ONLY	/* (AMIGA) external program for opt lists */
  2. #include "config.h"
  3. #include "objclass.h"
  4. #include "flag.h"
  5. NEARDATA struct flag flags;	/* provide linkage */
  6. NEARDATA struct instance_flags iflags;	/* provide linkage */
  7. #define static
  8. #else
  9. #include "hack.h"
  10. #include "tcap.h"
  11. #include <ctype.h>
  12. #endif
  13.  
  14. #define WINTYPELEN 16
  15.  
  16. #ifdef DEFAULT_WC_TILED_MAP
  17. #define PREFER_TILED TRUE
  18. #else
  19. #define PREFER_TILED FALSE
  20. #endif

Bool_Opt[edit]

  1. /*
  2. *  NOTE:  If you add (or delete) an option, please update the short
  3. *  options help (option_help()), the long options help (dat/opthelp),
  4. *  and the current options setting display function (doset()),
  5. *  and also the Guidebooks.
  6. *
  7. *  The order matters.  If an option is a an initial substring of another
  8. *  option (e.g. time and timed_delay) the shorter one must come first.
  9. */
  10.  
  11. static struct Bool_Opt
  12. {
  13. 	const char *name;
  14. 	boolean	*addr, initvalue;
  15. 	int optflags;
  16. } boolopt[] = {
  17. #ifdef AMIGA
  18. 	{"altmeta", &flags.altmeta, TRUE, DISP_IN_GAME},
  19. #else
  20. 	{"altmeta", (boolean *)0, TRUE, DISP_IN_GAME},
  21. #endif
  22. 	{"ascii_map",     &iflags.wc_ascii_map, !PREFER_TILED, SET_IN_GAME},	/*WC*/
  23. #ifdef MFLOPPY
  24. 	{"asksavedisk", &flags.asksavedisk, FALSE, SET_IN_GAME},
  25. #else
  26. 	{"asksavedisk", (boolean *)0, FALSE, SET_IN_FILE},
  27. #endif
  28. 	{"autodig", &flags.autodig, FALSE, SET_IN_GAME},
  29. 	{"autopickup", &flags.pickup, TRUE, SET_IN_GAME},
  30. 	{"autoquiver", &flags.autoquiver, FALSE, SET_IN_GAME},
  31. #if defined(MICRO) && !defined(AMIGA)
  32. 	{"BIOS", &iflags.BIOS, FALSE, SET_IN_FILE},
  33. #else
  34. 	{"BIOS", (boolean *)0, FALSE, SET_IN_FILE},
  35. #endif
  36. #ifdef INSURANCE
  37. 	{"checkpoint", &flags.ins_chkpt, TRUE, SET_IN_GAME},
  38. #else
  39. 	{"checkpoint", (boolean *)0, FALSE, SET_IN_FILE},
  40. #endif
  41. #ifdef MFLOPPY
  42. 	{"checkspace", &iflags.checkspace, TRUE, SET_IN_GAME},
  43. #else
  44. 	{"checkspace", (boolean *)0, FALSE, SET_IN_FILE},
  45. #endif
  46. 	{"cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME},
  47. # if defined(MICRO) || defined(WIN32)
  48. 	{"color",         &iflags.wc_color,TRUE, SET_IN_GAME},		/*WC*/
  49. # else	/* systems that support multiple terminals, many monochrome */
  50. 	{"color",         &iflags.wc_color, FALSE, SET_IN_GAME},	/*WC*/
  51. # endif
  52. 	{"confirm",&flags.confirm, TRUE, SET_IN_GAME},
  53. #if defined(TERMLIB) && !defined(MAC_GRAPHICS_ENV)
  54. 	{"DECgraphics", &iflags.DECgraphics, FALSE, SET_IN_GAME},
  55. #else
  56. 	{"DECgraphics", (boolean *)0, FALSE, SET_IN_FILE},
  57. #endif
  58. 	{"eight_bit_tty", &iflags.wc_eight_bit_input, FALSE, SET_IN_GAME},	/*WC*/
  59. #ifdef TTY_GRAPHICS
  60. 	{"extmenu", &iflags.extmenu, FALSE, SET_IN_GAME},
  61. #else
  62. 	{"extmenu", (boolean *)0, FALSE, SET_IN_FILE},
  63. #endif
  64. #ifdef OPT_DISPMAP
  65. 	{"fast_map", &flags.fast_map, TRUE, SET_IN_GAME},
  66. #else
  67. 	{"fast_map", (boolean *)0, TRUE, SET_IN_FILE},
  68. #endif
  69. 	{"female", &flags.female, FALSE, DISP_IN_GAME},
  70. 	{"fixinv", &flags.invlet_constant, TRUE, SET_IN_GAME},
  71. #ifdef AMIFLUSH
  72. 	{"flush", &flags.amiflush, FALSE, SET_IN_GAME},
  73. #else
  74. 	{"flush", (boolean *)0, FALSE, SET_IN_FILE},
  75. #endif
  76. 	{"fullscreen", &iflags.wc2_fullscreen, FALSE, SET_IN_FILE},
  77. 	{"help", &flags.help, TRUE, SET_IN_GAME},
  78. 	{"hilite_pet",    &iflags.wc_hilite_pet, FALSE, SET_IN_GAME},	/*WC*/
  79. #ifdef ASCIIGRAPH
  80. 	{"IBMgraphics", &iflags.IBMgraphics, FALSE, SET_IN_GAME},
  81. #else
  82. 	{"IBMgraphics", (boolean *)0, FALSE, SET_IN_FILE},
  83. #endif
  84. #ifndef MAC
  85. 	{"ignintr", &flags.ignintr, FALSE, SET_IN_GAME},
  86. #else
  87. 	{"ignintr", (boolean *)0, FALSE, SET_IN_FILE},
  88. #endif
  89. 	{"large_font", &iflags.obsolete, FALSE, SET_IN_FILE},	/* OBSOLETE */
  90. 	{"legacy", &flags.legacy, TRUE, DISP_IN_GAME},
  91. 	{"lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME},
  92. 	{"lootabc", &iflags.lootabc, FALSE, SET_IN_GAME},
  93. #ifdef MAC_GRAPHICS_ENV
  94. 	{"Macgraphics", &iflags.MACgraphics, TRUE, SET_IN_GAME},
  95. #else
  96. 	{"Macgraphics", (boolean *)0, FALSE, SET_IN_FILE},
  97. #endif
  98. #ifdef MAIL
  99. 	{"mail", &flags.biff, TRUE, SET_IN_GAME},
  100. #else
  101. 	{"mail", (boolean *)0, TRUE, SET_IN_FILE},
  102. #endif
  103. #ifdef WIZARD
  104. 	/* for menu debugging only*/
  105. 	{"menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_GAME},
  106. #else
  107. 	{"menu_tab_sep", (boolean *)0, FALSE, SET_IN_FILE},
  108. #endif
  109. 	{"mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME},	/*WC*/
  110. #ifdef NEWS
  111. 	{"news", &iflags.news, TRUE, DISP_IN_GAME},
  112. #else
  113. 	{"news", (boolean *)0, FALSE, SET_IN_FILE},
  114. #endif
  115. 	{"null", &flags.null, TRUE, SET_IN_GAME},
  116. #ifdef MAC
  117. 	{"page_wait", &flags.page_wait, TRUE, SET_IN_GAME},
  118. #else
  119. 	{"page_wait", (boolean *)0, FALSE, SET_IN_FILE},
  120. #endif
  121. 	{"perm_invent", &flags.perm_invent, FALSE, SET_IN_GAME},
  122. 	{"popup_dialog",  &iflags.wc_popup_dialog, FALSE, SET_IN_GAME},	/*WC*/
  123. 	{"prayconfirm", &flags.prayconfirm, TRUE, SET_IN_GAME},
  124. 	{"preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME},	/*WC*/
  125. 	{"pushweapon", &flags.pushweapon, FALSE, SET_IN_GAME},
  126. #if defined(MICRO) && !defined(AMIGA)
  127. 	{"rawio", &iflags.rawio, FALSE, DISP_IN_GAME},
  128. #else
  129. 	{"rawio", (boolean *)0, FALSE, SET_IN_FILE},
  130. #endif
  131. 	{"rest_on_space", &flags.rest_on_space, FALSE, SET_IN_GAME},
  132. 	{"safe_pet", &flags.safe_dog, TRUE, SET_IN_GAME},
  133. #ifdef WIZARD
  134. 	{"sanity_check", &iflags.sanity_check, FALSE, SET_IN_GAME},
  135. #else
  136. 	{"sanity_check", (boolean *)0, FALSE, SET_IN_FILE},
  137. #endif
  138. #ifdef EXP_ON_BOTL
  139. 	{"showexp", &flags.showexp, FALSE, SET_IN_GAME},
  140. #else
  141. 	{"showexp", (boolean *)0, FALSE, SET_IN_FILE},
  142. #endif
  143. 	{"showrace", &iflags.showrace, FALSE, SET_IN_GAME},
  144. #ifdef SCORE_ON_BOTL
  145. 	{"showscore", &flags.showscore, FALSE, SET_IN_GAME},
  146. #else
  147. 	{"showscore", (boolean *)0, FALSE, SET_IN_FILE},
  148. #endif
  149. 	{"silent", &flags.silent, TRUE, SET_IN_GAME},
  150. 	{"softkeyboard", &iflags.wc2_softkeyboard, FALSE, SET_IN_FILE},
  151. 	{"sortpack", &flags.sortpack, TRUE, SET_IN_GAME},
  152. 	{"sound", &flags.soundok, TRUE, SET_IN_GAME},
  153. 	{"sparkle", &flags.sparkle, TRUE, SET_IN_GAME},
  154. 	{"standout", &flags.standout, FALSE, SET_IN_GAME},
  155. 	{"splash_screen",     &iflags.wc_splash_screen, TRUE, DISP_IN_GAME},	/*WC*/
  156. 	{"tiled_map",     &iflags.wc_tiled_map, PREFER_TILED, DISP_IN_GAME},	/*WC*/
  157. 	{"time", &flags.time, FALSE, SET_IN_GAME},
  158. #ifdef TIMED_DELAY
  159. 	{"timed_delay", &flags.nap, TRUE, SET_IN_GAME},
  160. #else
  161. 	{"timed_delay", (boolean *)0, FALSE, SET_IN_GAME},
  162. #endif
  163. 	{"tombstone",&flags.tombstone, TRUE, SET_IN_GAME},
  164. 	{"toptenwin",&flags.toptenwin, FALSE, SET_IN_GAME},
  165. 	{"travel", &iflags.travelcmd, TRUE, SET_IN_GAME},
  166. #ifdef WIN32CON
  167. 	{"use_inverse",   &iflags.wc_inverse, TRUE, SET_IN_GAME},		/*WC*/
  168. #else
  169. 	{"use_inverse",   &iflags.wc_inverse, FALSE, SET_IN_GAME},		/*WC*/
  170. #endif
  171. 	{"verbose", &flags.verbose, TRUE, SET_IN_GAME},
  172. 	{"wraptext", &iflags.wc2_wraptext, FALSE, SET_IN_GAME},
  173. 	{(char *)0, (boolean *)0, FALSE, 0}
  174. };

Comp_Opt[edit]

  1. /* compound options, for option_help() and external programs like Amiga
  2. * frontend */
  3. static struct Comp_Opt
  4. {
  5. 	const char *name, *descr;
  6. 	int size;	/* for frontends and such allocating space --
  7. 			 * usually allowed size of data in game, but
  8. 			 * occasionally maximum reasonable size for
  9. 			 * typing when game maintains information in
  10. 			 * a different format */
  11. 	int optflags;
  12. } compopt[] = {
  13. 	{ "align",    "your starting alignment (lawful, neutral, or chaotic)",
  14. 						8, DISP_IN_GAME },
  15. 	{ "align_message", "message window alignment", 20, DISP_IN_GAME }, 	/*WC*/
  16. 	{ "align_status", "status window alignment", 20, DISP_IN_GAME }, 	/*WC*/
  17. 	{ "altkeyhandler", "alternate key handler", 20, DISP_IN_GAME },
  18. 	{ "boulder",  "the symbol to use for displaying boulders",
  19. 						1, SET_IN_GAME },
  20. 	{ "catname",  "the name of your (first) cat (e.g., catname:Tabby)",
  21. 						PL_PSIZ, DISP_IN_GAME },
  22. 	{ "disclose", "the kinds of information to disclose at end of game",
  23. 						sizeof(flags.end_disclose) * 2,
  24. 						SET_IN_GAME },
  25. 	{ "dogname",  "the name of your (first) dog (e.g., dogname:Fang)",
  26. 						PL_PSIZ, DISP_IN_GAME },
  27. 	{ "dungeon",  "the symbols to use in drawing the dungeon map",
  28. 						MAXDCHARS+1, SET_IN_FILE },
  29. 	{ "effects",  "the symbols to use in drawing special effects",
  30. 						MAXECHARS+1, SET_IN_FILE },
  31. 	{ "font_map", "the font to use in the map window", 40, DISP_IN_GAME },	/*WC*/
  32. 	{ "font_menu", "the font to use in menus", 40, DISP_IN_GAME },		/*WC*/
  33. 	{ "font_message", "the font to use in the message window",
  34. 						40, DISP_IN_GAME },		/*WC*/
  35. 	{ "font_size_map", "the size of the map font", 20, DISP_IN_GAME },	/*WC*/
  36. 	{ "font_size_menu", "the size of the menu font", 20, DISP_IN_GAME },	/*WC*/
  37. 	{ "font_size_message", "the size of the message font", 20, DISP_IN_GAME },	/*WC*/
  38. 	{ "font_size_status", "the size of the status font", 20, DISP_IN_GAME },	/*WC*/
  39. 	{ "font_size_text", "the size of the text font", 20, DISP_IN_GAME },	/*WC*/
  40. 	{ "font_status", "the font to use in status window", 40, DISP_IN_GAME }, /*WC*/
  41. 	{ "font_text", "the font to use in text windows", 40, DISP_IN_GAME },	/*WC*/
  42. 	{ "fruit",    "the name of a fruit you enjoy eating",
  43. 						PL_FSIZ, SET_IN_GAME },
  44. 	{ "gender",   "your starting gender (male or female)",
  45. 						8, DISP_IN_GAME },
  46. 	{ "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
  47. 						PL_PSIZ, DISP_IN_GAME },
  48. 	{ "map_mode", "map display mode under Windows", 20, DISP_IN_GAME },	/*WC*/
  49. 	{ "menustyle", "user interface for object selection",
  50. 						MENUTYPELEN, SET_IN_GAME },
  51. 	{ "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE },
  52. 	{ "menu_deselect_page", "deselect all items on this page of a menu",
  53. 						4, SET_IN_FILE },
  54. 	{ "menu_first_page", "jump to the first page in a menu",
  55. 						4, SET_IN_FILE },
  56. 	{ "menu_headings", "bold, inverse, or underline headings", 9, SET_IN_GAME },
  57. 	{ "menu_invert_all", "invert all items in a menu", 4, SET_IN_FILE },
  58. 	{ "menu_invert_page", "invert all items on this page of a menu",
  59. 						4, SET_IN_FILE },
  60. 	{ "menu_last_page", "jump to the last page in a menu", 4, SET_IN_FILE },
  61. 	{ "menu_next_page", "goto the next menu page", 4, SET_IN_FILE },
  62. 	{ "menu_previous_page", "goto the previous menu page", 4, SET_IN_FILE },
  63. 	{ "menu_search", "search for a menu item", 4, SET_IN_FILE },
  64. 	{ "menu_select_all", "select all items in a menu", 4, SET_IN_FILE },
  65. 	{ "menu_select_page", "select all items on this page of a menu",
  66. 						4, SET_IN_FILE },
  67. 	{ "monsters", "the symbols to use for monsters",
  68. 						MAXMCLASSES, SET_IN_FILE },
  69. 	{ "msghistory", "number of top line messages to save",
  70. 						5, DISP_IN_GAME },
  71. # ifdef TTY_GRAPHICS
  72. 	{"msg_window", "the type of message window required",1, SET_IN_GAME},
  73. # else
  74. 	{"msg_window", "the type of message window required", 1, SET_IN_FILE},
  75. # endif
  76. 	{ "name",     "your character's name (e.g., name:Merlin-W)",
  77. 						PL_NSIZ, DISP_IN_GAME },
  78. 	{ "number_pad", "use the number pad", 1, SET_IN_GAME},
  79. 	{ "objects",  "the symbols to use for objects",
  80. 						MAXOCLASSES, SET_IN_FILE },
  81. 	{ "packorder", "the inventory order of the items in your pack",
  82. 						MAXOCLASSES, SET_IN_GAME },
  83. #ifdef CHANGE_COLOR
  84. 	{ "palette",  "palette (00c/880/-fff is blue/yellow/reverse white)",
  85. 						15 , SET_IN_GAME },
  86. # if defined(MAC)
  87. 	{ "hicolor",  "same as palette, only order is reversed",
  88. 						15, SET_IN_FILE },
  89. # endif
  90. #endif
  91. 	{ "pettype",  "your preferred initial pet type", 4, DISP_IN_GAME },
  92. 	{ "pickup_burden",  "maximum burden picked up before prompt",
  93. 						20, SET_IN_GAME },
  94. 	{ "pickup_types", "types of objects to pick up automatically",
  95. 						MAXOCLASSES, SET_IN_GAME },
  96. 	{ "player_selection", "choose character via dialog or prompts",
  97. 						12, DISP_IN_GAME },
  98. 	{ "race",     "your starting race (e.g., Human, Elf)",
  99. 						PL_CSIZ, DISP_IN_GAME },
  100. 	{ "role",     "your starting role (e.g., Barbarian, Valkyrie)",
  101. 						PL_CSIZ, DISP_IN_GAME },
  102. 	{ "runmode", "display frequency when `running' or `travelling'",
  103. 						sizeof "teleport", SET_IN_GAME },
  104. 	{ "scores",   "the parts of the score list you wish to see",
  105. 						32, SET_IN_GAME },
  106. 	{ "scroll_amount", "amount to scroll map when scroll_margin is reached",
  107. 						20, DISP_IN_GAME }, /*WC*/
  108. 	{ "scroll_margin", "scroll map when this far from the edge", 20, DISP_IN_GAME }, /*WC*/
  109. #ifdef MSDOS
  110. 	{ "soundcard", "type of sound card to use", 20, SET_IN_FILE },
  111. #endif
  112. 	{ "suppress_alert", "suppress alerts about version-specific features",
  113. 						8, SET_IN_GAME },
  114. 	{ "tile_width", "width of tiles", 20, DISP_IN_GAME},	/*WC*/
  115. 	{ "tile_height", "height of tiles", 20, DISP_IN_GAME},	/*WC*/
  116. 	{ "tile_file", "name of tile file", 70, DISP_IN_GAME},	/*WC*/
  117. 	{ "traps",    "the symbols to use in drawing traps",
  118. 						MAXTCHARS+1, SET_IN_FILE },
  119. 	{ "vary_msgcount", "show more old messages at a time", 20, DISP_IN_GAME }, /*WC*/
  120. #ifdef MSDOS
  121. 	{ "video",    "method of video updating", 20, SET_IN_FILE },
  122. #endif
  123. #ifdef VIDEOSHADES
  124. 	{ "videocolors", "color mappings for internal screen routines",
  125. 						40, DISP_IN_GAME },
  126. 	{ "videoshades", "gray shades to map to black/gray/white",
  127. 						32, DISP_IN_GAME },
  128. #endif
  129. #ifdef WIN32CON
  130. 	{"subkeyvalue", "override keystroke value", 7, SET_IN_FILE},
  131. #endif
  132. 	{ "windowcolors",  "the foreground/background colors of windows",	/*WC*/
  133. 						80, DISP_IN_GAME },
  134. 	{ "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
  135. 	{ (char *)0, (char *)0, 0, 0 }
  136. };
  1. #ifdef OPTION_LISTS_ONLY
  2. #undef static
  3.  
  4. #else	/* use rest of file */
  5.  
  6. static boolean need_redraw; /* for doset() */
  7.  
  8. #if defined(TOS) && defined(TEXTCOLOR)
  9. extern boolean colors_changed;	/* in tos.c */
  10. #endif
  11.  
  12. #ifdef VIDEOSHADES
  13. extern char *shade[3];		  /* in sys/msdos/video.c */
  14. extern char ttycolors[CLR_MAX];	  /* in sys/msdos/video.c */
  15. #endif
  16.  
  17. static char def_inv_order[MAXOCLASSES] = {
  18. 	COIN_CLASS, AMULET_CLASS, WEAPON_CLASS, ARMOR_CLASS, FOOD_CLASS,
  19. 	SCROLL_CLASS, SPBOOK_CLASS, POTION_CLASS, RING_CLASS, WAND_CLASS,
  20. 	TOOL_CLASS, GEM_CLASS, ROCK_CLASS, BALL_CLASS, CHAIN_CLASS, 0,
  21. };

Menu accelerators[edit]

  1. /*
  2. * Default menu manipulation command accelerators.  These may _not_ be:
  3. *
  4. *	+ a number - reserved for counts
  5. *	+ an upper or lower case US ASCII letter - used for accelerators
  6. *	+ ESC - reserved for escaping the menu
  7. *	+ NULL, CR or LF - reserved for commiting the selection(s).  NULL
  8. *	  is kind of odd, but the tty's xwaitforspace() will return it if
  9. *	  someone hits a <ret>.
  10. *	+ a default object class symbol - used for object class accelerators
  11. *
  12. * Standard letters (for now) are:
  13. *
  14. *		<  back 1 page
  15. *		>  forward 1 page
  16. *		^  first page
  17. *		|  last page
  18. *		:  search
  19. *
  20. *		page		all
  21. *		 ,    select	 .
  22. *		 \    deselect	 -
  23. *		 ~    invert	 @
  24. *
  25. * The command name list is duplicated in the compopt array.
  26. */
  27. typedef struct {
  28. const char *name;
  29. char cmd;
  30. } menu_cmd_t;
  31.  
  32. #define NUM_MENU_CMDS 11
  33. static const menu_cmd_t default_menu_cmd_info[NUM_MENU_CMDS] = {
  34. /* 0*/	{ "menu_first_page",	MENU_FIRST_PAGE },
  35. 	{ "menu_last_page",	MENU_LAST_PAGE },
  36. 	{ "menu_next_page",	MENU_NEXT_PAGE },
  37. 	{ "menu_previous_page",	MENU_PREVIOUS_PAGE },
  38. 	{ "menu_select_all",	MENU_SELECT_ALL },
  39. /* 5*/	{ "menu_deselect_all",	MENU_UNSELECT_ALL },
  40. 	{ "menu_invert_all",	MENU_INVERT_ALL },
  41. 	{ "menu_select_page",	MENU_SELECT_PAGE },
  42. 	{ "menu_deselect_page",	MENU_UNSELECT_PAGE },
  43. 	{ "menu_invert_page",	MENU_INVERT_PAGE },
  44. /*10*/	{ "menu_search",		MENU_SEARCH },
  45. };
  1. /*
  2. * Allow the user to map incoming characters to various menu commands.
  3. * The accelerator list must be a valid C string.
  4. */
  5. #define MAX_MENU_MAPPED_CMDS 32	/* some number */
  6. char mapped_menu_cmds[MAX_MENU_MAPPED_CMDS+1];	/* exported */
  7. static char mapped_menu_op[MAX_MENU_MAPPED_CMDS+1];
  8. static short n_menu_mapped = 0;
  9.  
  10.  
  11. static boolean initial, from_file;
  12.  
  13. STATIC_DCL void FDECL(doset_add_menu, (winid,const char *,int));
  14. STATIC_DCL void FDECL(nmcpy, (char *, const char *, int));
  15. STATIC_DCL void FDECL(escapes, (const char *, char *));
  16. STATIC_DCL void FDECL(rejectoption, (const char *));
  17. STATIC_DCL void FDECL(badoption, (const char *));
  18. STATIC_DCL char *FDECL(string_for_opt, (char *,BOOLEAN_P));
  19. STATIC_DCL char *FDECL(string_for_env_opt, (const char *, char *,BOOLEAN_P));
  20. STATIC_DCL void FDECL(bad_negation, (const char *,BOOLEAN_P));
  21. STATIC_DCL int FDECL(change_inv_order, (char *));
  22. STATIC_DCL void FDECL(oc_to_str, (char *, char *));
  23. STATIC_DCL void FDECL(graphics_opts, (char *,const char *,int,int));
  24. STATIC_DCL int FDECL(feature_alert_opts, (char *, const char *));
  25. STATIC_DCL const char *FDECL(get_compopt_value, (const char *, char *));
  26. STATIC_DCL boolean FDECL(special_handling, (const char *, BOOLEAN_P, BOOLEAN_P));
  27. STATIC_DCL void FDECL(warning_opts, (char *,const char *));
  28. STATIC_DCL void FDECL(duplicate_opt_detection, (const char *, int));
  29.  
  30. STATIC_OVL void FDECL(wc_set_font_name, (int, char *));
  31. STATIC_OVL int FDECL(wc_set_window_colors, (char *));
  32. STATIC_OVL boolean FDECL(is_wc_option, (const char *));
  33. STATIC_OVL boolean FDECL(wc_supported, (const char *));
  34. STATIC_OVL boolean FDECL(is_wc2_option, (const char *));
  35. STATIC_OVL boolean FDECL(wc2_supported, (const char *));
  36. #ifdef AUTOPICKUP_EXCEPTIONS
  37. STATIC_DCL void FDECL(remove_autopickup_exception, (struct autopickup_exception *));
  38. STATIC_OVL int FDECL(count_ape_maps, (int *, int *));
  39. #endif

match_optname[edit]

  1. /* check whether a user-supplied option string is a proper leading
  2. substring of a particular option name; option string might have
  3. a colon or equals sign and arbitrary value appended to it */
  4. boolean
  5. match_optname(user_string, opt_name, min_length, val_allowed)
  6. const char *user_string, *opt_name;
  7. int min_length;
  8. boolean val_allowed;
  9. {
  10. 	int len = (int)strlen(user_string);
  11.  
  12. 	if (val_allowed) {
  13. 	    const char *p = index(user_string, ':'),
  14. 		       *q = index(user_string, '=');
  15.  
  16. 	    if (!p || (q && q < p)) p = q;
  17. 	    while(p && p > user_string && isspace(*(p-1))) p--;
  18. 	    if (p) len = (int)(p - user_string);
  19. 	}
  20.  
  21. 	return (len >= min_length) && !strncmpi(opt_name, user_string, len);
  22. }

nh_getenv[edit]

  1. /* most environment variables will eventually be printed in an error
  2. * message if they don't work, and most error message paths go through
  3. * BUFSZ buffers, which could be overflowed by a maliciously long
  4. * environment variable.  if a variable can legitimately be long, or
  5. * if it's put in a smaller buffer, the responsible code will have to
  6. * bounds-check itself.
  7. */
  8. char *
  9. nh_getenv(ev)
  10. const char *ev;
  11. {
  12. 	char *getev = getenv(ev);
  13.  
  14. 	if (getev && strlen(getev) <= (BUFSZ / 2))
  15. 		return getev;
  16. 	else
  17. 		return (char *)0;
  18. }

initoptions[edit]

  1. void
  2. initoptions()
  3. {
  4. #ifndef MAC
  5. 	char *opts;
  6. #endif
  7. 	int i;
  8.  
  9. 	/* initialize the random number generator */
  10. 	setrandom();
  11.  
  12. 	/* for detection of configfile options specified multiple times */
  13. 	iflags.opt_booldup = iflags.opt_compdup = (int *)0;
  14.  
  15. 	for (i = 0; boolopt[i].name; i++) {
  16. 		if (boolopt[i].addr)
  17. 			*(boolopt[i].addr) = boolopt[i].initvalue;
  18. 	}
  19. 	flags.end_own = FALSE;
  20. 	flags.end_top = 3;
  21. 	flags.end_around = 2;
  22. 	iflags.runmode = RUN_LEAP;
  23. 	iflags.msg_history = 20;
  24. #ifdef TTY_GRAPHICS
  25. 	iflags.prevmsg_window = 's';
  26. #endif
  27. 	iflags.menu_headings = ATR_INVERSE;
  28.  
  29. 	/* Use negative indices to indicate not yet selected */
  30. 	flags.initrole = -1;
  31. 	flags.initrace = -1;
  32. 	flags.initgend = -1;
  33. 	flags.initalign = -1;
  34.  
  35. 	/* Set the default monster and object class symbols.  Don't use */
  36. 	/* memcpy() --- sizeof char != sizeof uchar on some machines.	*/
  37. 	for (i = 0; i < MAXOCLASSES; i++)
  38. 		oc_syms[i] = (uchar) def_oc_syms[i];
  39. 	for (i = 0; i < MAXMCLASSES; i++)
  40. 		monsyms[i] = (uchar) def_monsyms[i];
  41. 	for (i = 0; i < WARNCOUNT; i++)
  42. 		warnsyms[i] = def_warnsyms[i].sym;
  43. 	iflags.bouldersym = 0;
  44. 	iflags.travelcc.x = iflags.travelcc.y = -1;
  45. 	flags.warnlevel = 1;
  46. 	flags.warntype = 0L;
  47.  
  48. /* assert( sizeof flags.inv_order == sizeof def_inv_order ); */
  49. 	(void)memcpy((genericptr_t)flags.inv_order,
  50. 		     (genericptr_t)def_inv_order, sizeof flags.inv_order);
  51. 	flags.pickup_types[0] = '\0';
  52. 	flags.pickup_burden = MOD_ENCUMBER;
  53.  
  54. 	for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++)
  55. 		flags.end_disclose[i] = DISCLOSE_PROMPT_DEFAULT_NO;
  56. 	switch_graphics(ASCII_GRAPHICS);	/* set default characters */
  57. #if defined(UNIX) && defined(TTY_GRAPHICS)
  58. 	/*
  59. 	 * Set defaults for some options depending on what we can
  60. 	 * detect about the environment's capabilities.
  61. 	 * This has to be done after the global initialization above
  62. 	 * and before reading user-specific initialization via
  63. 	 * config file/environment variable below.
  64. 	 */
  65. 	/* this detects the IBM-compatible console on most 386 boxes */
  66. 	if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) {
  67. 		switch_graphics(IBM_GRAPHICS);
  68. # ifdef TEXTCOLOR
  69. 		iflags.use_color = TRUE;
  70. # endif
  71. 	}
  72. #endif /* UNIX && TTY_GRAPHICS */
  73. #if defined(UNIX) || defined(VMS)
  74. # ifdef TTY_GRAPHICS
  75. 	/* detect whether a "vt" terminal can handle alternate charsets */
  76. 	if ((opts = nh_getenv("TERM")) &&
  77. 	    !strncmpi(opts, "vt", 2) && AS && AE &&
  78. 	    index(AS, '\016') && index(AE, '\017')) {
  79. 		switch_graphics(DEC_GRAPHICS);
  80. 	}
  81. # endif
  82. #endif /* UNIX || VMS */
  83.  
  84. #ifdef MAC_GRAPHICS_ENV
  85. 	switch_graphics(MAC_GRAPHICS);
  86. #endif /* MAC_GRAPHICS_ENV */
  87. 	flags.menu_style = MENU_FULL;
  88.  
  89. 	/* since this is done before init_objects(), do partial init here */
  90. 	objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD;
  91. 	nmcpy(pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ);
  92. #ifndef MAC
  93. 	opts = getenv("NETHACKOPTIONS");
  94. 	if (!opts) opts = getenv("HACKOPTIONS");
  95. 	if (opts) {
  96. 		if (*opts == '/' || *opts == '\\' || *opts == '@') {
  97. 			if (*opts == '@') opts++;	/* @filename */
  98. 			/* looks like a filename */
  99. 			if (strlen(opts) < BUFSZ/2)
  100. 			    read_config_file(opts);
  101. 		} else {
  102. 			read_config_file((char *)0);
  103. 			/* let the total length of options be long;
  104. 			 * parseoptions() will check each individually
  105. 			 */
  106. 			parseoptions(opts, TRUE, FALSE);
  107. 		}
  108. 	} else
  109. #endif
  110. 		read_config_file((char *)0);
  111.  
  112. 	(void)fruitadd(pl_fruit);
  113. 	/* Remove "slime mold" from list of object names; this will	*/
  114. 	/* prevent it from being wished unless it's actually present	*/
  115. 	/* as a named (or default) fruit.  Wishing for "fruit" will	*/
  116. 	/* result in the player's preferred fruit [better than "\033"].	*/
  117. 	obj_descr[SLIME_MOLD].oc_name = "fruit";
  118.  
  119. 	return;
  120. }

nmcpy[edit]

  1. STATIC_OVL void
  2. nmcpy(dest, src, maxlen)
  3. 	char	*dest;
  4. 	const char *src;
  5. 	int	maxlen;
  6. {
  7. 	int	count;
  8.  
  9. 	for(count = 1; count < maxlen; count++) {
  10. 		if(*src == ',' || *src == '\0') break; /*exit on \0 terminator*/
  11. 		*dest++ = *src++;
  12. 	}
  13. 	*dest = 0;
  14. }

escapes[edit]

  1. /*
  2. * escapes: escape expansion for showsyms. C-style escapes understood include
  3. * \n, \b, \t, \r, \xnnn (hex), \onnn (octal), \nnn (decimal). The ^-prefix
  4. * for control characters is also understood, and \[mM] followed by any of the
  5. * previous forms or by a character has the effect of 'meta'-ing the value (so
  6. * that the alternate character set will be enabled).
  7. */
  8. STATIC_OVL void
  9. escapes(cp, tp)
  10. const char	*cp;
  11. char *tp;
  12. {
  13. while (*cp)
  14. {
  15. 	int	cval = 0, meta = 0;
  16.  
  17. 	if (*cp == '\\' && index("mM", cp[1])) {
  18. 		meta = 1;
  19. 		cp += 2;
  20. 	}
  21. 	if (*cp == '\\' && index("0123456789xXoO", cp[1]))
  22. 	{
  23. 	    const char *dp, *hex = "00112233445566778899aAbBcCdDeEfF";
  24. 	    int dcount = 0;
  25.  
  26. 	    cp++;
  27. 	    if (*cp == 'x' || *cp == 'X')
  28. 		for (++cp; (dp = index(hex, *cp)) && (dcount++ < 2); cp++)
  29. 		    cval = (cval * 16) + (dp - hex) / 2;
  30. 	    else if (*cp == 'o' || *cp == 'O')
  31. 		for (++cp; (index("01234567",*cp)) && (dcount++ < 3); cp++)
  32. 		    cval = (cval * 8) + (*cp - '0');
  33. 	    else
  34. 		for (; (index("0123456789",*cp)) && (dcount++ < 3); cp++)
  35. 		    cval = (cval * 10) + (*cp - '0');
  36. 	}
  37. 	else if (*cp == '\\')		/* C-style character escapes */
  38. 	{
  39. 	    switch (*++cp)
  40. 	    {
  41. 	    case '\\': cval = '\\'; break;
  42. 	    case 'n': cval = '\n'; break;
  43. 	    case 't': cval = '\t'; break;
  44. 	    case 'b': cval = '\b'; break;
  45. 	    case 'r': cval = '\r'; break;
  46. 	    default: cval = *cp;
  47. 	    }
  48. 	    cp++;
  49. 	}
  50. 	else if (*cp == '^')		/* expand control-character syntax */
  51. 	{
  52. 	    cval = (*++cp & 0x1f);
  53. 	    cp++;
  54. 	}
  55. 	else
  56. 	    cval = *cp++;
  57. 	if (meta)
  58. 	    cval |= 0x80;
  59. 	*tp++ = cval;
  60. }
  61. *tp = '\0';
  62. }

rejectoption[edit]

  1. STATIC_OVL void
  2. rejectoption(optname)
  3. const char *optname;
  4. {
  5. #ifdef MICRO
  6. 	pline("\"%s\" settable only from %s.", optname, configfile);
  7. #else
  8. 	pline("%s can be set only from NETHACKOPTIONS or %s.", optname,
  9. 			configfile);
  10. #endif
  11. }

badoption[edit]

  1. STATIC_OVL void
  2. badoption(opts)
  3. const char *opts;
  4. {
  5. 	if (!initial) {
  6. 	    if (!strncmp(opts, "h", 1) || !strncmp(opts, "?", 1))
  7. 		option_help();
  8. 	    else
  9. 		pline("Bad syntax: %s.  Enter \"?g\" for help.", opts);
  10. 	    return;
  11. 	}
  12. #ifdef MAC
  13. 	else return;
  14. #endif
  15.  
  16. 	if(from_file)
  17. 	    raw_printf("Bad syntax in OPTIONS in %s: %s.", configfile, opts);
  18. 	else
  19. 	    raw_printf("Bad syntax in NETHACKOPTIONS: %s.", opts);
  20.  
  21. 	wait_synch();
  22. }

string_for_opt[edit]

  1. STATIC_OVL char *
  2. string_for_opt(opts, val_optional)
  3. char *opts;
  4. boolean val_optional;
  5. {
  6. 	char *colon, *equals;
  7.  
  8. 	colon = index(opts, ':');
  9. 	equals = index(opts, '=');
  10. 	if (!colon || (equals && equals < colon)) colon = equals;
  11.  
  12. 	if (!colon || !*++colon) {
  13. 		if (!val_optional) badoption(opts);
  14. 		return (char *)0;
  15. 	}
  16. 	return colon;
  17. }

string_for_env_opt[edit]

  1. STATIC_OVL char *
  2. string_for_env_opt(optname, opts, val_optional)
  3. const char *optname;
  4. char *opts;
  5. boolean val_optional;
  6. {
  7. 	if(!initial) {
  8. 		rejectoption(optname);
  9. 		return (char *)0;
  10. 	}
  11. 	return string_for_opt(opts, val_optional);
  12. }

bad_negation[edit]

  1. STATIC_OVL void
  2. bad_negation(optname, with_parameter)
  3. const char *optname;
  4. boolean with_parameter;
  5. {
  6. 	pline_The("%s option may not %sbe negated.",
  7. 		optname,
  8. 		with_parameter ? "both have a value and " : "");
  9. }

change_inv_order[edit]

  1. /*
  2. * Change the inventory order, using the given string as the new order.
  3. * Missing characters in the new order are filled in at the end from
  4. * the current inv_order, except for gold, which is forced to be first
  5. * if not explicitly present.
  6. *
  7. * This routine returns 1 unless there is a duplicate or bad char in
  8. * the string.
  9. */
  10. STATIC_OVL int
  11. change_inv_order(op)
  12. char *op;
  13. {
  14. int oc_sym, num;
  15. char *sp, buf[BUFSZ];
  16.  
  17. num = 0;
  18. #ifndef GOLDOBJ
  19. if (!index(op, GOLD_SYM))
  20. 	buf[num++] = COIN_CLASS;
  21. #else
  22. /*  !!!! probably unnecessary with gold as normal inventory */
  23. #endif
  24.  
  25. for (sp = op; *sp; sp++) {
  26. 	oc_sym = def_char_to_objclass(*sp);
  27. 	/* reject bad or duplicate entries */
  28. 	if (oc_sym == MAXOCLASSES ||
  29. 		oc_sym == RANDOM_CLASS || oc_sym == ILLOBJ_CLASS ||
  30. 		!index(flags.inv_order, oc_sym) || index(sp+1, *sp))
  31. 	    return 0;
  32. 	/* retain good ones */
  33. 	buf[num++] = (char) oc_sym;
  34. }
  35. buf[num] = '\0';
  36.  
  37. /* fill in any omitted classes, using previous ordering */
  38. for (sp = flags.inv_order; *sp; sp++)
  39. 	if (!index(buf, *sp)) {
  40. 	    buf[num++] = *sp;
  41. 	    buf[num] = '\0';	/* explicitly terminate for next index() */
  42. 	}
  43.  
  44. Strcpy(flags.inv_order, buf);
  45. return 1;
  46. }

graphics_opts[edit]

  1. STATIC_OVL void
  2. graphics_opts(opts, optype, maxlen, offset)
  3. register char *opts;
  4. const char *optype;
  5. int maxlen, offset;
  6. {
  7. 	uchar translate[MAXPCHARS+1];
  8. 	int length, i;
  9.  
  10. 	if (!(opts = string_for_env_opt(optype, opts, FALSE)))
  11. 		return;
  12. 	escapes(opts, opts);
  13.  
  14. 	length = strlen(opts);
  15. 	if (length > maxlen) length = maxlen;
  16. 	/* match the form obtained from PC configuration files */
  17. 	for (i = 0; i < length; i++)
  18. 		translate[i] = (uchar) opts[i];
  19. 	assign_graphics(translate, length, maxlen, offset);
  20. }

warning_opts[edit]

  1. STATIC_OVL void
  2. warning_opts(opts, optype)
  3. register char *opts;
  4. const char *optype;
  5. {
  6. 	uchar translate[MAXPCHARS+1];
  7. 	int length, i;
  8.  
  9. 	if (!(opts = string_for_env_opt(optype, opts, FALSE)))
  10. 		return;
  11. 	escapes(opts, opts);
  12.  
  13. 	length = strlen(opts);
  14. 	if (length > WARNCOUNT) length = WARNCOUNT;
  15. 	/* match the form obtained from PC configuration files */
  16. 	for (i = 0; i < length; i++)
  17. 	     translate[i] = (((i < WARNCOUNT) && opts[i]) ?
  18. 			   (uchar) opts[i] : def_warnsyms[i].sym);
  19. 	assign_warnings(translate);
  20. }

assign_warnings[edit]

  1. void
  2. assign_warnings(graph_chars)
  3. register uchar *graph_chars;
  4. {
  5. 	int i;
  6. 	for (i = 0; i < WARNCOUNT; i++)
  7. 	    if (graph_chars[i]) warnsyms[i] = graph_chars[i];
  8. }

feature_alert_opts[edit]

  1. STATIC_OVL int
  2. feature_alert_opts(op, optn)
  3. char *op;
  4. const char *optn;
  5. {
  6. 	char buf[BUFSZ];
  7. 	boolean rejectver = FALSE;
  8. 	unsigned long fnv = get_feature_notice_ver(op);		/* version.c */
  9. 	if (fnv == 0L) return 0;
  10. 	if (fnv > get_current_feature_ver())
  11. 		rejectver = TRUE;
  12. 	else
  13. 		flags.suppress_alert = fnv;
  14. 	if (rejectver) {
  15. 		if (!initial)
  16. 			You_cant("disable new feature alerts for future versions.");
  17. 		else {
  18. 			Sprintf(buf,
  19. 				"\n%s=%s Invalid reference to a future version ignored",
  20. 				optn, op);
  21. 			badoption(buf);
  22. 		}
  23. 		return 0;
  24. 	}
  25. 	if (!initial) {
  26. 		Sprintf(buf, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ,
  27. 			FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH);
  28. 		pline("Feature change alerts disabled for NetHack %s features and prior.",
  29. 			buf);
  30. 	}
  31. 	return 1;
  32. }

set_duplicate_opt_detection[edit]

  1. void
  2. set_duplicate_opt_detection(on_or_off)
  3. int on_or_off;
  4. {
  5. 	int k, *optptr;
  6. 	if (on_or_off != 0) {
  7. 		/*-- ON --*/
  8. 		if (iflags.opt_booldup)
  9. 			impossible("iflags.opt_booldup already on (memory leak)");
  10. 		iflags.opt_booldup = (int *)alloc(SIZE(boolopt) * sizeof(int));
  11. 		optptr = iflags.opt_booldup;
  12. 		for (k = 0; k < SIZE(boolopt); ++k)
  13. 			*optptr++ = 0;
  14.  
  15. 		if (iflags.opt_compdup)
  16. 			impossible("iflags.opt_compdup already on (memory leak)");
  17. 		iflags.opt_compdup = (int *)alloc(SIZE(compopt) * sizeof(int));
  18. 		optptr = iflags.opt_compdup;
  19. 		for (k = 0; k < SIZE(compopt); ++k)
  20. 			*optptr++ = 0;
  21. 	} else {
  22. 		/*-- OFF --*/
  23. 		if (iflags.opt_booldup) free((genericptr_t) iflags.opt_booldup);
  24. 		iflags.opt_booldup = (int *)0;
  25. 		if (iflags.opt_compdup) free((genericptr_t) iflags.opt_compdup);
  26. 		iflags.opt_compdup = (int *)0;
  27. 	} 
  28. }

duplicate_opt_detection[edit]

  1. STATIC_OVL void
  2. duplicate_opt_detection(opts, bool_or_comp)
  3. const char *opts;
  4. int bool_or_comp;	/* 0 == boolean option, 1 == compound */
  5. {
  6. 	int i, *optptr;
  7. #if defined(MAC)
  8. 	/* the Mac has trouble dealing with the output of messages while
  9. 	 * processing the config file.  That should get fixed one day.
  10. 	 * For now just return.
  11. 	 */
  12. 	return;
  13. #endif
  14. 	if ((bool_or_comp == 0) && iflags.opt_booldup && initial && from_file) {
  15. 	    for (i = 0; boolopt[i].name; i++) {
  16. 		if (match_optname(opts, boolopt[i].name, 3, FALSE)) {
  17. 			optptr = iflags.opt_booldup + i;
  18. 			if (*optptr == 1) {
  19. 			    raw_printf(
  20. 				"\nWarning - Boolean option specified multiple times: %s.\n",
  21. 					opts);
  22. 			        wait_synch();
  23. 			}
  24. 			*optptr += 1;
  25. 			break; /* don't match multiple options */
  26. 		}
  27. 	    }
  28. 	} else if ((bool_or_comp == 1) && iflags.opt_compdup && initial && from_file) {
  29. 	    for (i = 0; compopt[i].name; i++) {
  30. 		if (match_optname(opts, compopt[i].name, strlen(compopt[i].name), TRUE)) {
  31. 			optptr = iflags.opt_compdup + i;
  32. 			if (*optptr == 1) {
  33. 			    raw_printf(
  34. 				"\nWarning - compound option specified multiple times: %s.\n",
  35. 					compopt[i].name);
  36. 			        wait_synch();
  37. 			}
  38. 			*optptr += 1;
  39. 			break; /* don't match multiple options */
  40. 		}
  41. 	    }
  42. 	}
  43. }

parseoptions[edit]

  1. void
  2. parseoptions(opts, tinitial, tfrom_file)
  3. register char *opts;
  4. boolean tinitial, tfrom_file;
  5. {
  6. 	register char *op;
  7. 	unsigned num;
  8. 	boolean negated;
  9. 	int i;
  10. 	const char *fullname;
  11.  
  12. 	initial = tinitial;
  13. 	from_file = tfrom_file;
  14. 	if ((op = index(opts, ',')) != 0) {
  15. 		*op++ = 0;
  16. 		parseoptions(op, initial, from_file);
  17. 	}
  18. 	if (strlen(opts) > BUFSZ/2) {
  19. 		badoption("option too long");
  20. 		return;
  21. 	}
  22.  
  23. 	/* strip leading and trailing white space */
  24. 	while (isspace(*opts)) opts++;
  25. 	op = eos(opts);
  26. 	while (--op >= opts && isspace(*op)) *op = '\0';
  27.  
  28. 	if (!*opts) return;
  29. 	negated = FALSE;
  30. 	while ((*opts == '!') || !strncmpi(opts, "no", 2)) {
  31. 		if (*opts == '!') opts++; else opts += 2;
  32. 		negated = !negated;
  33. 	}
  34.  
  35. 	/* variant spelling */
  36.  
  37. 	if (match_optname(opts, "colour", 5, FALSE))
  38. 		Strcpy(opts, "color");	/* fortunately this isn't longer */
  39.  
  40. 	if (!match_optname(opts, "subkeyvalue", 11, TRUE)) /* allow multiple */
  41. 	duplicate_opt_detection(opts, 1);	/* 1 means compound opts */
  42.  
  43. 	/* special boolean options */
  44.  
  45. 	if (match_optname(opts, "female", 3, FALSE)) {
  46. 		if(!initial && flags.female == negated)
  47. 			pline("That is not anatomically possible.");
  48. 		else
  49. 			flags.initgend = flags.female = !negated;
  50. 		return;
  51. 	}
  52.  
  53. 	if (match_optname(opts, "male", 4, FALSE)) {
  54. 		if(!initial && flags.female != negated)
  55. 			pline("That is not anatomically possible.");
  56. 		else
  57. 			flags.initgend = flags.female = negated;
  58. 		return;
  59. 	}
  60.  
  61. #if defined(MICRO) && !defined(AMIGA)
  62. 	/* included for compatibility with old NetHack.cnf files */
  63. 	if (match_optname(opts, "IBM_", 4, FALSE)) {
  64. 		iflags.BIOS = !negated;
  65. 		return;
  66. 	}
  67. #endif /* MICRO */
  68.  
  69. 	/* compound options */
  70.  
  71. 	fullname = "pettype";
  72. 	if (match_optname(opts, fullname, 3, TRUE)) {
  73. 		if ((op = string_for_env_opt(fullname, opts, negated)) != 0) {
  74. 		    if (negated) bad_negation(fullname, TRUE);
  75. 		    else switch (*op) {
  76. 			case 'd':	/* dog */
  77. 			case 'D':
  78. 			    preferred_pet = 'd';
  79. 			    break;
  80. 			case 'c':	/* cat */
  81. 			case 'C':
  82. 			case 'f':	/* feline */
  83. 			case 'F':
  84. 			    preferred_pet = 'c';
  85. 			    break;
  86. 			case 'n':	/* no pet */
  87. 			case 'N':
  88. 			    preferred_pet = 'n';
  89. 			    break;
  90. 			default:
  91. 			    pline("Unrecognized pet type '%s'.", op);
  92. 			    break;
  93. 		    }
  94. 		} else if (negated) preferred_pet = 'n';
  95. 		return;
  96. 	}
  97.  
  98. 	fullname = "catname";
  99. 	if (match_optname(opts, fullname, 3, TRUE)) {
  100. 		if (negated) bad_negation(fullname, FALSE);
  101. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
  102. 			nmcpy(catname, op, PL_PSIZ);
  103. 		return;
  104. 	}
  105.  
  106. 	fullname = "dogname";
  107. 	if (match_optname(opts, fullname, 3, TRUE)) {
  108. 		if (negated) bad_negation(fullname, FALSE);
  109. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
  110. 			nmcpy(dogname, op, PL_PSIZ);
  111. 		return;
  112. 	}
  113.  
  114. 	fullname = "horsename";
  115. 	if (match_optname(opts, fullname, 5, TRUE)) {
  116. 		if (negated) bad_negation(fullname, FALSE);
  117. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
  118. 			nmcpy(horsename, op, PL_PSIZ);
  119. 		return;
  120. 	}
  121.  
  122. 	fullname = "number_pad";
  123. 	if (match_optname(opts, fullname, 10, TRUE)) {
  124. 		boolean compat = (strlen(opts) <= 10);
  125. 		number_pad(iflags.num_pad ? 1 : 0);
  126. 		op = string_for_opt(opts, (compat || !initial));
  127. 		if (!op) {
  128. 		    if (compat || negated || initial) {
  129. 			/* for backwards compatibility, "number_pad" without a
  130. 			   value is a synonym for number_pad:1 */
  131. 			iflags.num_pad = !negated;
  132. 			if (iflags.num_pad) iflags.num_pad_mode = 0;
  133. 		    }
  134. 		    return;
  135. 		}
  136. 		if (negated) {
  137. 		    bad_negation("number_pad", TRUE);
  138. 		    return;
  139. 		}
  140. 		if (*op == '1' || *op == '2') {
  141. 			iflags.num_pad = 1;
  142. 			if (*op == '2') iflags.num_pad_mode = 1;
  143. 			else iflags.num_pad_mode = 0;
  144. 		} else if (*op == '0') {
  145. 			iflags.num_pad = 0;
  146. 			iflags.num_pad_mode = 0;
  147. 		} else badoption(opts);
  148. 		return;
  149. 	}
  150.  
  151. 	fullname = "runmode";
  152. 	if (match_optname(opts, fullname, 4, TRUE)) {
  153. 		if (negated) {
  154. 			iflags.runmode = RUN_TPORT;
  155. 		} else if ((op = string_for_opt(opts, FALSE)) != 0) {
  156. 		    if (!strncmpi(op, "teleport", strlen(op)))
  157. 			iflags.runmode = RUN_TPORT;
  158. 		    else if (!strncmpi(op, "run", strlen(op)))
  159. 			iflags.runmode = RUN_LEAP;
  160. 		    else if (!strncmpi(op, "walk", strlen(op)))
  161. 			iflags.runmode = RUN_STEP;
  162. 		    else if (!strncmpi(op, "crawl", strlen(op)))
  163. 			iflags.runmode = RUN_CRAWL;
  164. 		    else
  165. 			badoption(opts);
  166. 		}
  167. 		return;
  168. 	}
  169.  
  170. 	fullname = "msghistory";
  171. 	if (match_optname(opts, fullname, 3, TRUE)) {
  172. 		op = string_for_env_opt(fullname, opts, negated);
  173. 		if ((negated && !op) || (!negated && op)) {
  174. 			iflags.msg_history = negated ? 0 : atoi(op);
  175. 		} else if (negated) bad_negation(fullname, TRUE);
  176. 		return;
  177. 	}
  178.  
  179. 	fullname="msg_window";
  180. 	/* msg_window:single, combo, full or reversed */
  181. 	if (match_optname(opts, fullname, 4, TRUE)) {
  182. 	/* allow option to be silently ignored by non-tty ports */
  183. #ifdef TTY_GRAPHICS
  184. 		int tmp;
  185. 		if (!(op = string_for_opt(opts, TRUE))) {
  186. 		    tmp = negated ? 's' : 'f';
  187. 		} else {
  188. 			  if (negated) {
  189. 			  	bad_negation(fullname, TRUE);
  190. 			  	return;
  191. 				  }
  192. 		    tmp = tolower(*op);
  193. 		}
  194. 		switch (tmp) {
  195. 			case 's':	/* single message history cycle (default if negated) */
  196. 				iflags.prevmsg_window = 's';
  197. 				break;
  198. 			case 'c':	/* combination: two singles, then full page reversed */
  199. 				iflags.prevmsg_window = 'c';
  200. 				break;
  201. 			case 'f':	/* full page (default if no opts) */
  202. 				iflags.prevmsg_window = 'f';
  203. 				break;
  204. 			case 'r':	/* full page (reversed) */
  205. 				iflags.prevmsg_window = 'r';
  206. 				break;
  207. 			default:
  208. 				badoption(opts);
  209. 		}
  210. #endif
  211. 		return;
  212. 	}
  213.  
  214. 	/* WINCAP
  215. 	 * setting font options  */
  216. 	fullname = "font";
  217. 	if (!strncmpi(opts, fullname, 4))
  218. 	{
  219. 		int wintype = -1;
  220. 		char *fontopts = opts + 4;
  221.  
  222. 		if (!strncmpi(fontopts, "map", 3) ||
  223. 		    !strncmpi(fontopts, "_map", 4))
  224. 			wintype = NHW_MAP;
  225. 		else if (!strncmpi(fontopts, "message", 7) ||
  226. 			 !strncmpi(fontopts, "_message", 8))
  227. 			wintype = NHW_MESSAGE;
  228. 		else if (!strncmpi(fontopts, "text", 4) ||
  229. 			 !strncmpi(fontopts, "_text", 5))
  230. 			wintype = NHW_TEXT;			
  231. 		else if (!strncmpi(fontopts, "menu", 4) ||
  232. 			 !strncmpi(fontopts, "_menu", 5))
  233. 			wintype = NHW_MENU;
  234. 		else if (!strncmpi(fontopts, "status", 6) ||
  235. 			 !strncmpi(fontopts, "_status", 7))
  236. 			wintype = NHW_STATUS;
  237. 		else if (!strncmpi(fontopts, "_size", 5)) {
  238. 			if (!strncmpi(fontopts, "_size_map", 8))
  239. 				wintype = NHW_MAP;
  240. 			else if (!strncmpi(fontopts, "_size_message", 12))
  241. 				wintype = NHW_MESSAGE;
  242. 			else if (!strncmpi(fontopts, "_size_text", 9))
  243. 				wintype = NHW_TEXT;
  244. 			else if (!strncmpi(fontopts, "_size_menu", 9))
  245. 				wintype = NHW_MENU;
  246. 			else if (!strncmpi(fontopts, "_size_status", 11))
  247. 				wintype = NHW_STATUS;
  248. 			else {
  249. 				badoption(opts);
  250. 				return;
  251. 			}
  252. 			if (wintype > 0 && !negated &&
  253. 			    (op = string_for_opt(opts, FALSE)) != 0) {
  254. 			    switch(wintype)  {
  255. 			    	case NHW_MAP:
  256. 					iflags.wc_fontsiz_map = atoi(op);
  257. 					break;
  258. 			    	case NHW_MESSAGE:
  259. 					iflags.wc_fontsiz_message = atoi(op);
  260. 					break;
  261. 			    	case NHW_TEXT:
  262. 					iflags.wc_fontsiz_text = atoi(op);
  263. 					break;
  264. 			    	case NHW_MENU:
  265. 					iflags.wc_fontsiz_menu = atoi(op);
  266. 					break;
  267. 			    	case NHW_STATUS:
  268. 					iflags.wc_fontsiz_status = atoi(op);
  269. 					break;
  270. 			    }
  271. 			}
  272. 			return;
  273. 		} else {
  274. 			badoption(opts);
  275. 		}
  276. 		if (wintype > 0 &&
  277. 		    (op = string_for_opt(opts, FALSE)) != 0) {
  278. 			wc_set_font_name(wintype, op);
  279. #ifdef MAC
  280. 			set_font_name (wintype, op);
  281. #endif
  282. 			return;
  283. 		} else if (negated) bad_negation(fullname, TRUE);
  284. 		return;
  285. 	}
  286. #ifdef CHANGE_COLOR
  287. 	if (match_optname(opts, "palette", 3, TRUE)
  288. # ifdef MAC
  289. 	    || match_optname(opts, "hicolor", 3, TRUE)
  290. # endif
  291. 							) {
  292. 	    int color_number, color_incr;
  293.  
  294. # ifdef MAC
  295. 	    if (match_optname(opts, "hicolor", 3, TRUE)) {
  296. 		if (negated) {
  297. 		    bad_negation("hicolor", FALSE);
  298. 		    return;
  299. 		}
  300. 		color_number = CLR_MAX + 4;	/* HARDCODED inverse number */
  301. 		color_incr = -1;
  302. 	    } else {
  303. # endif
  304. 		if (negated) {
  305. 		    bad_negation("palette", FALSE);
  306. 		    return;
  307. 		}
  308. 		color_number = 0;
  309. 		color_incr = 1;
  310. # ifdef MAC
  311. 	    }
  312. # endif
  313. 	    if ((op = string_for_opt(opts, FALSE)) != (char *)0) {
  314. 		char *pt = op;
  315. 		int cnt, tmp, reverse;
  316. 		long rgb;
  317.  
  318. 		while (*pt && color_number >= 0) {
  319. 		    cnt = 3;
  320. 		    rgb = 0L;
  321. 		    if (*pt == '-') {
  322. 			reverse = 1;
  323. 			pt++;
  324. 		    } else {
  325. 			reverse = 0;
  326. 		    }
  327. 		    while (cnt-- > 0) {
  328. 			if (*pt && *pt != '/') {
  329. # ifdef AMIGA
  330. 			    rgb <<= 4;
  331. # else
  332. 			    rgb <<= 8;
  333. # endif
  334. 			    tmp = *(pt++);
  335. 			    if (isalpha(tmp)) {
  336. 				tmp = (tmp + 9) & 0xf;	/* Assumes ASCII... */
  337. 			    } else {
  338. 				tmp &= 0xf;	/* Digits in ASCII too... */
  339. 			    }
  340. # ifndef AMIGA
  341. 			    /* Add an extra so we fill f -> ff and 0 -> 00 */
  342. 			    rgb += tmp << 4;
  343. # endif
  344. 			    rgb += tmp;
  345. 			}
  346. 		    }
  347. 		    if (*pt == '/') {
  348. 			pt++;
  349. 		    }
  350. 		    change_color(color_number, rgb, reverse);
  351. 		    color_number += color_incr;
  352. 		}
  353. 	    }
  354. 	    if (!initial) {
  355. 		need_redraw = TRUE;
  356. 	    }
  357. 	    return;
  358. 	}
  359. #endif /* CHANGE_COLOR */
  360.  
  361. 	if (match_optname(opts, "fruit", 2, TRUE)) {
  362. 		char empty_str = '\0';
  363. 		op = string_for_opt(opts, negated);
  364. 		if (negated) {
  365. 		    if (op) {
  366. 			bad_negation("fruit", TRUE);
  367. 			return;
  368. 		    }
  369. 		    op = &empty_str;
  370. 		    goto goodfruit;
  371. 		}
  372. 		if (!op) return;
  373. 		if (!initial) {
  374. 		    struct fruit *f;
  375.  
  376. 		    num = 0;
  377. 		    for(f=ffruit; f; f=f->nextf) {
  378. 			if (!strcmp(op, f->fname)) goto goodfruit;
  379. 			num++;
  380. 		    }
  381. 		    if (num >= 100) {
  382. 			pline("Doing that so many times isn't very fruitful.");
  383. 			return;
  384. 		    }
  385. 		}
  386. goodfruit:
  387. 		nmcpy(pl_fruit, op, PL_FSIZ);
  388. 	/* OBJ_NAME(objects[SLIME_MOLD]) won't work after initialization */
  389. 		if (!*pl_fruit)
  390. 		    nmcpy(pl_fruit, "slime mold", PL_FSIZ);
  391. 		if (!initial)
  392. 		    (void)fruitadd(pl_fruit);
  393. 		/* If initial, then initoptions is allowed to do it instead
  394. 		 * of here (initoptions always has to do it even if there's
  395. 		 * no fruit option at all.  Also, we don't want people
  396. 		 * setting multiple fruits in their options.)
  397. 		 */
  398. 		return;
  399. 	}
  400.  
  401. 	/* graphics:string */
  402. 	fullname = "graphics";
  403. 	if (match_optname(opts, fullname, 2, TRUE)) {
  404. 		if (negated) bad_negation(fullname, FALSE);
  405. 		else graphics_opts(opts, fullname, MAXPCHARS, 0);
  406. 		return;
  407. 	}
  408. 	fullname = "dungeon";
  409. 	if (match_optname(opts, fullname, 2, TRUE)) {
  410. 		if (negated) bad_negation(fullname, FALSE);
  411. 		else graphics_opts(opts, fullname, MAXDCHARS, 0);
  412. 		return;
  413. 	}
  414. 	fullname = "traps";
  415. 	if (match_optname(opts, fullname, 2, TRUE)) {
  416. 		if (negated) bad_negation(fullname, FALSE);
  417. 		else graphics_opts(opts, fullname, MAXTCHARS, MAXDCHARS);
  418. 		return;
  419. 	}
  420. 	fullname = "effects";
  421. 	if (match_optname(opts, fullname, 2, TRUE)) {
  422. 		if (negated) bad_negation(fullname, FALSE);
  423. 		else
  424. 		 graphics_opts(opts, fullname, MAXECHARS, MAXDCHARS+MAXTCHARS);
  425. 		return;
  426. 	}
  427.  
  428. 	/* objects:string */
  429. 	fullname = "objects";
  430. 	if (match_optname(opts, fullname, 7, TRUE)) {
  431. 		int length;
  432.  
  433. 		if (negated) {
  434. 		    bad_negation(fullname, FALSE);
  435. 		    return;
  436. 		}
  437. 		if (!(opts = string_for_env_opt(fullname, opts, FALSE)))
  438. 			return;
  439. 		escapes(opts, opts);
  440.  
  441. 		/*
  442. 		 * Override the default object class symbols.  The first
  443. 		 * object in the object class is the "random object".  I
  444. 		 * don't want to use 0 as an object class, so the "random
  445. 		 * object" is basically a place holder.
  446. 		 *
  447. 		 * The object class symbols have already been initialized in
  448. 		 * initoptions().
  449. 		 */
  450. 		length = strlen(opts);
  451. 		if (length >= MAXOCLASSES)
  452. 		    length = MAXOCLASSES-1;	/* don't count RANDOM_OBJECT */
  453.  
  454. 		for (i = 0; i < length; i++)
  455. 		    oc_syms[i+1] = (uchar) opts[i];
  456. 		return;
  457. 	}
  458.  
  459. 	/* monsters:string */
  460. 	fullname = "monsters";
  461. 	if (match_optname(opts, fullname, 8, TRUE)) {
  462. 		int length;
  463.  
  464. 		if (negated) {
  465. 		    bad_negation(fullname, FALSE);
  466. 		    return;
  467. 		}
  468. 		if (!(opts = string_for_env_opt(fullname, opts, FALSE)))
  469. 			return;
  470. 		escapes(opts, opts);
  471.  
  472. 		/* Override default mon class symbols set in initoptions(). */
  473. 		length = strlen(opts);
  474. 		if (length >= MAXMCLASSES)
  475. 		    length = MAXMCLASSES-1;	/* mon class 0 unused */
  476.  
  477. 		for (i = 0; i < length; i++)
  478. 		    monsyms[i+1] = (uchar) opts[i];
  479. 		return;
  480. 	}
  481. 	fullname = "warnings";
  482. 	if (match_optname(opts, fullname, 5, TRUE)) {
  483. 		if (negated) bad_negation(fullname, FALSE);
  484. 		else warning_opts(opts, fullname);
  485. 		return;
  486. 	}
  487. 	/* boulder:symbol */
  488. 	fullname = "boulder";
  489. 	if (match_optname(opts, fullname, 7, TRUE)) {
  490. 		int clash = 0;
  491. 		if (negated) {
  492. 		    bad_negation(fullname, FALSE);
  493. 		    return;
  494. 		}
  495. /*		if (!(opts = string_for_env_opt(fullname, opts, FALSE))) */
  496. 		if (!(opts = string_for_opt(opts, FALSE)))
  497. 			return;
  498. 		escapes(opts, opts);
  499. 		if (def_char_to_monclass(opts[0]) != MAXMCLASSES)
  500. 			clash = 1;
  501. 		else if (opts[0] >= '1' && opts[0] <= '5')
  502. 			clash = 2;
  503. 		if (clash) {
  504. 			/* symbol chosen matches a used monster or warning
  505. 			   symbol which is not good - reject it*/
  506. 			pline(
  507. 		  "Badoption - boulder symbol '%c' conflicts with a %s symbol.",
  508. 				opts[0], (clash == 1) ? "monster" : "warning");
  509. 		} else {
  510. 			/*
  511. 			 * Override the default boulder symbol.
  512. 			 */
  513. 			iflags.bouldersym = (uchar) opts[0];
  514. 		}
  515. 		if (!initial) need_redraw = TRUE;
  516. 		return;
  517. 	}
  518.  
  519. 	/* name:string */
  520. 	fullname = "name";
  521. 	if (match_optname(opts, fullname, 4, TRUE)) {
  522. 		if (negated) bad_negation(fullname, FALSE);
  523. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
  524. 			nmcpy(plname, op, PL_NSIZ);
  525. 		return;
  526. 	}
  527.  
  528. 	/* role:string or character:string */
  529. 	fullname = "role";
  530. 	if (match_optname(opts, fullname, 4, TRUE) ||
  531. 	    match_optname(opts, (fullname = "character"), 4, TRUE)) {
  532. 		if (negated) bad_negation(fullname, FALSE);
  533. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
  534. 			if ((flags.initrole = str2role(op)) == ROLE_NONE)
  535. 				badoption(opts);
  536. 			else  /* Backwards compatibility */
  537. 				nmcpy(pl_character, op, PL_NSIZ);
  538. 		}
  539. 		return;
  540. 	}
  541.  
  542. 	/* race:string */
  543. 	fullname = "race";
  544. 	if (match_optname(opts, fullname, 4, TRUE)) {
  545. 		if (negated) bad_negation(fullname, FALSE);
  546. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
  547. 			if ((flags.initrace = str2race(op)) == ROLE_NONE)
  548. 				badoption(opts);
  549. 			else /* Backwards compatibility */
  550. 				pl_race = *op;
  551. 		}
  552. 		return;
  553. 	}
  554.  
  555. 	/* gender:string */
  556. 	fullname = "gender";
  557. 	if (match_optname(opts, fullname, 4, TRUE)) {
  558. 		if (negated) bad_negation(fullname, FALSE);
  559. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
  560. 			if ((flags.initgend = str2gend(op)) == ROLE_NONE)
  561. 				badoption(opts);
  562. 			else
  563. 				flags.female = flags.initgend;
  564. 		}
  565. 		return;
  566. 	}
  567.  
  568. 	/* altkeyhandler:string */
  569. 	fullname = "altkeyhandler";
  570. 	if (match_optname(opts, fullname, 4, TRUE)) {
  571. 		if (negated) bad_negation(fullname, FALSE);
  572. 		else if ((op = string_for_opt(opts, negated))) {
  573. #ifdef WIN32CON
  574. 		    (void)strncpy(iflags.altkeyhandler, op, MAX_ALTKEYHANDLER - 5);
  575. 		    load_keyboard_handler();
  576. #endif
  577. 		}
  578. 		return;
  579. 	}
  580.  
  581. 	/* WINCAP
  582. 	 * align_status:[left|top|right|bottom] */
  583. 	fullname = "align_status";
  584. 	if (match_optname(opts, fullname, sizeof("align_status")-1, TRUE)) {
  585. 		op = string_for_opt(opts, negated);
  586. 		if (op && !negated) {
  587. 		    if (!strncmpi (op, "left", sizeof("left")-1))
  588. 			iflags.wc_align_status = ALIGN_LEFT;
  589. 		    else if (!strncmpi (op, "top", sizeof("top")-1))
  590. 			iflags.wc_align_status = ALIGN_TOP;
  591. 		    else if (!strncmpi (op, "right", sizeof("right")-1))
  592. 			iflags.wc_align_status = ALIGN_RIGHT;
  593. 		    else if (!strncmpi (op, "bottom", sizeof("bottom")-1))
  594. 			iflags.wc_align_status = ALIGN_BOTTOM;
  595. 		    else
  596. 			badoption(opts);
  597. 		} else if (negated) bad_negation(fullname, TRUE);
  598. 		return;
  599. 	}
  600. 	/* WINCAP
  601. 	 * align_message:[left|top|right|bottom] */
  602. 	fullname = "align_message";
  603. 	if (match_optname(opts, fullname, sizeof("align_message")-1, TRUE)) {
  604. 		op = string_for_opt(opts, negated);
  605. 		if (op && !negated) {
  606. 		    if (!strncmpi (op, "left", sizeof("left")-1))
  607. 			iflags.wc_align_message = ALIGN_LEFT;
  608. 		    else if (!strncmpi (op, "top", sizeof("top")-1))
  609. 			iflags.wc_align_message = ALIGN_TOP;
  610. 		    else if (!strncmpi (op, "right", sizeof("right")-1))
  611. 			iflags.wc_align_message = ALIGN_RIGHT;
  612. 		    else if (!strncmpi (op, "bottom", sizeof("bottom")-1))
  613. 			iflags.wc_align_message = ALIGN_BOTTOM;
  614. 		    else
  615. 			badoption(opts);
  616. 		} else if (negated) bad_negation(fullname, TRUE);
  617. 		return;
  618. 	}
  619. 	/* align:string */
  620. 	fullname = "align";
  621. 	if (match_optname(opts, fullname, sizeof("align")-1, TRUE)) {
  622. 		if (negated) bad_negation(fullname, FALSE);
  623. 		else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0)
  624. 			if ((flags.initalign = str2align(op)) == ROLE_NONE)
  625. 				badoption(opts);
  626. 		return;
  627. 	}
  628.  
  629. 	/* the order to list the pack */
  630. 	fullname = "packorder";
  631. 	if (match_optname(opts, fullname, 4, TRUE)) {
  632. 		if (negated) {
  633. 		    bad_negation(fullname, FALSE);
  634. 		    return;
  635. 		} else if (!(op = string_for_opt(opts, FALSE))) return;
  636.  
  637. 		if (!change_inv_order(op))
  638. 			badoption(opts);
  639. 		return;
  640. 	}
  641.  
  642. 	/* maximum burden picked up before prompt (Warren Cheung) */
  643. 	fullname = "pickup_burden";
  644. 	if (match_optname(opts, fullname, 8, TRUE)) {
  645. 		if (negated) {
  646. 			bad_negation(fullname, FALSE);
  647. 			return;
  648. 		} else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
  649. 		    switch (tolower(*op)) {
  650. 				/* Unencumbered */
  651. 				case 'u':
  652. 					flags.pickup_burden = UNENCUMBERED;
  653. 					break;
  654. 				/* Burdened (slight encumbrance) */
  655. 				case 'b':
  656. 					flags.pickup_burden = SLT_ENCUMBER;
  657. 					break;
  658. 				/* streSsed (moderate encumbrance) */
  659. 				case 's':
  660. 					flags.pickup_burden = MOD_ENCUMBER;
  661. 					break;
  662. 				/* straiNed (heavy encumbrance) */
  663. 				case 'n':
  664. 					flags.pickup_burden = HVY_ENCUMBER;
  665. 					break;
  666. 				/* OverTaxed (extreme encumbrance) */
  667. 				case 'o':
  668. 				case 't':
  669. 					flags.pickup_burden = EXT_ENCUMBER;
  670. 					break;
  671. 				/* overLoaded */
  672. 				case 'l':
  673. 					flags.pickup_burden = OVERLOADED;
  674. 					break;
  675. 				default:
  676. 				badoption(opts);
  677. 		    }
  678. 		}
  679. 		return;
  680. 	}
  681.  
  682. 	/* types of objects to pick up automatically */
  683. 	if (match_optname(opts, "pickup_types", 8, TRUE)) {
  684. 		char ocl[MAXOCLASSES + 1], tbuf[MAXOCLASSES + 1],
  685. 		     qbuf[QBUFSZ], abuf[BUFSZ];
  686. 		int oc_sym;
  687. 		boolean badopt = FALSE, compat = (strlen(opts) <= 6), use_menu;
  688.  
  689. 		oc_to_str(flags.pickup_types, tbuf);
  690. 		flags.pickup_types[0] = '\0';	/* all */
  691. 		op = string_for_opt(opts, (compat || !initial));
  692. 		if (!op) {
  693. 		    if (compat || negated || initial) {
  694. 			/* for backwards compatibility, "pickup" without a
  695. 			   value is a synonym for autopickup of all types
  696. 			   (and during initialization, we can't prompt yet) */
  697. 			flags.pickup = !negated;
  698. 			return;
  699. 		    }
  700. 		    oc_to_str(flags.inv_order, ocl);
  701. 		    use_menu = TRUE;
  702. 		    if (flags.menu_style == MENU_TRADITIONAL ||
  703. 			    flags.menu_style == MENU_COMBINATION) {
  704. 			use_menu = FALSE;
  705. 			Sprintf(qbuf, "New pickup_types: [%s am] (%s)",
  706. 				ocl, *tbuf ? tbuf : "all");
  707. 			getlin(qbuf, abuf);
  708. 			op = mungspaces(abuf);
  709. 			if (abuf[0] == '\0' || abuf[0] == '\033')
  710. 			    op = tbuf;		/* restore */
  711. 			else if (abuf[0] == 'm')
  712. 			    use_menu = TRUE;
  713. 		    }
  714. 		    if (use_menu) {
  715. 			(void) choose_classes_menu("Auto-Pickup what?", 1,
  716. 						   TRUE, ocl, tbuf);
  717. 			op = tbuf;
  718. 		    }
  719. 		}
  720. 		if (negated) {
  721. 		    bad_negation("pickup_types", TRUE);
  722. 		    return;
  723. 		}
  724. 		while (*op == ' ') op++;
  725. 		if (*op != 'a' && *op != 'A') {
  726. 		    num = 0;
  727. 		    while (*op) {
  728. 			oc_sym = def_char_to_objclass(*op);
  729. 			/* make sure all are valid obj symbols occuring once */
  730. 			if (oc_sym != MAXOCLASSES &&
  731. 			    !index(flags.pickup_types, oc_sym)) {
  732. 			    flags.pickup_types[num] = (char)oc_sym;
  733. 			    flags.pickup_types[++num] = '\0';
  734. 			} else
  735. 			    badopt = TRUE;
  736. 			op++;
  737. 		    }
  738. 		    if (badopt) badoption(opts);
  739. 		}
  740. 		return;
  741. 	}
  742. 	/* WINCAP
  743. 	 * player_selection: dialog | prompts */
  744. 	fullname = "player_selection";
  745. 	if (match_optname(opts, fullname, sizeof("player_selection")-1, TRUE)) {
  746. 		op = string_for_opt(opts, negated);
  747. 		if (op && !negated) {
  748. 		    if (!strncmpi (op, "dialog", sizeof("dialog")-1))
  749. 			iflags.wc_player_selection = VIA_DIALOG;
  750. 		    else if (!strncmpi (op, "prompt", sizeof("prompt")-1))
  751. 			iflags.wc_player_selection = VIA_PROMPTS;
  752. 		    else
  753. 		    	badoption(opts);
  754. 		} else if (negated) bad_negation(fullname, TRUE);
  755. 		return;
  756. 	}
  757.  
  758. 	/* things to disclose at end of game */
  759. 	if (match_optname(opts, "disclose", 7, TRUE)) {
  760. 		/*
  761. 		 * The order that the end_disclore options are stored:
  762. 		 * inventory, attribs, vanquished, genocided, conduct
  763. 		 * There is an array in flags:
  764. 		 *	end_disclose[NUM_DISCLOSURE_OPT];
  765. 		 * with option settings for the each of the following:
  766. 		 * iagvc [see disclosure_options in decl.c]:
  767. 		 * Legal setting values in that array are:
  768. 		 *	DISCLOSE_PROMPT_DEFAULT_YES  ask with default answer yes
  769. 		 *	DISCLOSE_PROMPT_DEFAULT_NO   ask with default answer no
  770. 		 *	DISCLOSE_YES_WITHOUT_PROMPT  always disclose and don't ask
  771. 		 *	DISCLOSE_NO_WITHOUT_PROMPT   never disclose and don't ask
  772. 		 *
  773. 		 * Those setting values can be used in the option
  774. 		 * string as a prefix to get the desired behaviour.
  775. 		 *
  776. 		 * For backward compatibility, no prefix is required,
  777. 		 * and the presence of a i,a,g,v, or c without a prefix
  778. 		 * sets the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT.
  779. 		 */
  780. 		boolean badopt = FALSE;
  781. 		int idx, prefix_val;
  782.  
  783. 		op = string_for_opt(opts, TRUE);
  784. 		if (op && negated) {
  785. 			bad_negation("disclose", TRUE);
  786. 			return;
  787. 		}
  788. 		/* "disclose" without a value means "all with prompting"
  789. 		   and negated means "none without prompting" */
  790. 		if (!op || !strcmpi(op, "all") || !strcmpi(op, "none")) {
  791. 			if (op && !strcmpi(op, "none")) negated = TRUE;
  792. 			for (num = 0; num < NUM_DISCLOSURE_OPTIONS; num++)
  793. 			    flags.end_disclose[num] = negated ?
  794. 						DISCLOSE_NO_WITHOUT_PROMPT :
  795. 						DISCLOSE_PROMPT_DEFAULT_YES;
  796. 			return;
  797. 		}
  798.  
  799. 		num = 0;
  800. 		prefix_val = -1;
  801. 		while (*op && num < sizeof flags.end_disclose - 1) {
  802. 			register char c, *dop;
  803. 			static char valid_settings[] = {
  804. 				DISCLOSE_PROMPT_DEFAULT_YES,
  805. 				DISCLOSE_PROMPT_DEFAULT_NO,
  806. 				DISCLOSE_YES_WITHOUT_PROMPT,
  807. 				DISCLOSE_NO_WITHOUT_PROMPT,
  808. 				'\0'
  809. 			};
  810. 			c = lowc(*op);
  811. 			if (c == 'k') c = 'v';	/* killed -> vanquished */
  812. 			dop = index(disclosure_options, c);
  813. 			if (dop) {
  814. 				idx = dop - disclosure_options;
  815. 				if (idx < 0 || idx > NUM_DISCLOSURE_OPTIONS - 1) {
  816. 				    impossible("bad disclosure index %d %c",
  817. 							idx, c);
  818. 				    continue;
  819. 				}
  820. 				if (prefix_val != -1) {
  821. 				    flags.end_disclose[idx] = prefix_val;
  822. 				    prefix_val = -1;
  823. 				} else
  824. 				    flags.end_disclose[idx] = DISCLOSE_YES_WITHOUT_PROMPT;
  825. 			} else if (index(valid_settings, c)) {
  826. 				prefix_val = c;
  827. 			} else if (c == ' ') {
  828. 				/* do nothing */
  829. 			} else
  830. 				badopt = TRUE;				
  831. 			op++;
  832. 		}
  833. 		if (badopt) badoption(opts);
  834. 		return;
  835. 	}
  836.  
  837. 	/* scores:5t[op] 5a[round] o[wn] */
  838. 	if (match_optname(opts, "scores", 4, TRUE)) {
  839. 	    if (negated) {
  840. 		bad_negation("scores", FALSE);
  841. 		return;
  842. 	    }
  843. 	    if (!(op = string_for_opt(opts, FALSE))) return;
  844.  
  845. 	    while (*op) {
  846. 		int inum = 1;
  847.  
  848. 		if (digit(*op)) {
  849. 		    inum = atoi(op);
  850. 		    while (digit(*op)) op++;
  851. 		} else if (*op == '!') {
  852. 		    negated = !negated;
  853. 		    op++;
  854. 		}
  855. 		while (*op == ' ') op++;
  856.  
  857. 		switch (*op) {
  858. 		 case 't':
  859. 		 case 'T':  flags.end_top = inum;
  860. 			    break;
  861. 		 case 'a':
  862. 		 case 'A':  flags.end_around = inum;
  863. 			    break;
  864. 		 case 'o':
  865. 		 case 'O':  flags.end_own = !negated;
  866. 			    break;
  867. 		 default:   badoption(opts);
  868. 			    return;
  869. 		}
  870. 		while (letter(*++op) || *op == ' ') continue;
  871. 		if (*op == '/') op++;
  872. 	    }
  873. 	    return;
  874. 	}
  875.  
  876. 	fullname = "suppress_alert";
  877. 	if (match_optname(opts, fullname, 4, TRUE)) {
  878. 		op = string_for_opt(opts, negated);
  879. 		if (negated) bad_negation(fullname, FALSE);
  880. 		else if (op) (void) feature_alert_opts(op,fullname);
  881. 		return;
  882. 	}
  883.  
  884. #ifdef VIDEOSHADES
  885. 	/* videocolors:string */
  886. 	fullname = "videocolors";
  887. 	if (match_optname(opts, fullname, 6, TRUE) ||
  888. 	    match_optname(opts, "videocolours", 10, TRUE)) {
  889. 		if (negated) {
  890. 			bad_negation(fullname, FALSE);
  891. 			return;
  892. 		}
  893. 		else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
  894. 			return;
  895. 		}
  896. 		if (!assign_videocolors(opts))
  897. 			badoption(opts);
  898. 		return;
  899. 	}
  900. 	/* videoshades:string */
  901. 	fullname = "videoshades";
  902. 	if (match_optname(opts, fullname, 6, TRUE)) {
  903. 		if (negated) {
  904. 			bad_negation(fullname, FALSE);
  905. 			return;
  906. 		}
  907. 		else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
  908. 			return;
  909. 		}
  910. 		if (!assign_videoshades(opts))
  911. 			badoption(opts);
  912. 		return;
  913. 	}
  914. #endif /* VIDEOSHADES */
  915. #ifdef MSDOS
  916. # ifdef NO_TERMS
  917. 	/* video:string -- must be after longer tests */
  918. 	fullname = "video";
  919. 	if (match_optname(opts, fullname, 5, TRUE)) {
  920. 		if (negated) {
  921. 			bad_negation(fullname, FALSE);
  922. 			return;
  923. 		}
  924. 		else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
  925. 			return;
  926. 		}
  927. 		if (!assign_video(opts))
  928. 			badoption(opts);
  929. 		return;
  930. 	}
  931. # endif /* NO_TERMS */
  932. 	/* soundcard:string -- careful not to match boolean 'sound' */
  933. 	fullname = "soundcard";
  934. 	if (match_optname(opts, fullname, 6, TRUE)) {
  935. 		if (negated) {
  936. 			bad_negation(fullname, FALSE);
  937. 			return;
  938. 		}
  939. 		else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
  940. 			return;
  941. 		}
  942. 		if (!assign_soundcard(opts))
  943. 			badoption(opts);
  944. 		return;
  945. 	}
  946. #endif /* MSDOS */
  947.  
  948. 	/* WINCAP
  949. 	 * map_mode:[tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|ascii7x12|ascii8x12|
  950. 			ascii16x12|ascii12x16|ascii10x18|fit_to_screen] */
  951. 	fullname = "map_mode";
  952. 	if (match_optname(opts, fullname, sizeof("map_mode")-1, TRUE)) {
  953. 		op = string_for_opt(opts, negated);
  954. 		if (op && !negated) {
  955. 		    if (!strncmpi (op, "tiles", sizeof("tiles")-1))
  956. 			iflags.wc_map_mode = MAP_MODE_TILES;
  957. 		    else if (!strncmpi (op, "ascii4x6", sizeof("ascii4x6")-1))
  958. 			iflags.wc_map_mode = MAP_MODE_ASCII4x6;
  959. 		    else if (!strncmpi (op, "ascii6x8", sizeof("ascii6x8")-1))
  960. 			iflags.wc_map_mode = MAP_MODE_ASCII6x8;
  961. 		    else if (!strncmpi (op, "ascii8x8", sizeof("ascii8x8")-1))
  962. 			iflags.wc_map_mode = MAP_MODE_ASCII8x8;
  963. 		    else if (!strncmpi (op, "ascii16x8", sizeof("ascii16x8")-1))
  964. 			iflags.wc_map_mode = MAP_MODE_ASCII16x8;
  965. 		    else if (!strncmpi (op, "ascii7x12", sizeof("ascii7x12")-1))
  966. 			iflags.wc_map_mode = MAP_MODE_ASCII7x12;
  967. 		    else if (!strncmpi (op, "ascii8x12", sizeof("ascii8x12")-1))
  968. 			iflags.wc_map_mode = MAP_MODE_ASCII8x12;
  969. 		    else if (!strncmpi (op, "ascii16x12", sizeof("ascii16x12")-1))
  970. 			iflags.wc_map_mode = MAP_MODE_ASCII16x12;
  971. 		    else if (!strncmpi (op, "ascii12x16", sizeof("ascii12x16")-1))
  972. 			iflags.wc_map_mode = MAP_MODE_ASCII12x16;
  973. 		    else if (!strncmpi (op, "ascii10x18", sizeof("ascii10x18")-1))
  974. 			iflags.wc_map_mode = MAP_MODE_ASCII10x18;
  975. 		    else if (!strncmpi (op, "fit_to_screen", sizeof("fit_to_screen")-1))
  976. 			iflags.wc_map_mode = MAP_MODE_ASCII_FIT_TO_SCREEN;
  977. 		    else
  978. 		    	badoption(opts);
  979. 		} else if (negated) bad_negation(fullname, TRUE);
  980. 		return;
  981. 	}
  982. 	/* WINCAP
  983. 	 * scroll_amount:nn */
  984. 	fullname = "scroll_amount";
  985. 	if (match_optname(opts, fullname, sizeof("scroll_amount")-1, TRUE)) {
  986. 		op = string_for_opt(opts, negated);
  987. 		if ((negated && !op) || (!negated && op)) {
  988. 			iflags.wc_scroll_amount = negated ? 1 : atoi(op);
  989. 		} else if (negated) bad_negation(fullname, TRUE);
  990. 		return;
  991. 	}
  992. 	/* WINCAP
  993. 	 * scroll_margin:nn */
  994. 	fullname = "scroll_margin";
  995. 	if (match_optname(opts, fullname, sizeof("scroll_margin")-1, TRUE)) {
  996. 		op = string_for_opt(opts, negated);
  997. 		if ((negated && !op) || (!negated && op)) {
  998. 			iflags.wc_scroll_margin = negated ? 5 : atoi(op);
  999. 		} else if (negated) bad_negation(fullname, TRUE);
  1000. 		return;
  1001. 	}
  1002. 	fullname = "subkeyvalue";
  1003. 	if (match_optname(opts, fullname, 5, TRUE)) {
  1004. 		if (negated) bad_negation(fullname, FALSE);
  1005. 		else {
  1006. #if defined(WIN32CON)
  1007. 			op = string_for_opt(opts, 0);
  1008. 			map_subkeyvalue(op);
  1009. #endif
  1010. 		}
  1011. 		return;
  1012. 	}
  1013. 	/* WINCAP
  1014. 	 * tile_width:nn */
  1015. 	fullname = "tile_width";
  1016. 	if (match_optname(opts, fullname, sizeof("tile_width")-1, TRUE)) {
  1017. 		op = string_for_opt(opts, negated);
  1018. 		if ((negated && !op) || (!negated && op)) {
  1019. 			iflags.wc_tile_width = negated ? 0 : atoi(op);
  1020. 		} else if (negated) bad_negation(fullname, TRUE);
  1021. 		return;
  1022. 	}
  1023. 	/* WINCAP
  1024. 	 * tile_file:name */
  1025. 	fullname = "tile_file";
  1026. 	if (match_optname(opts, fullname, sizeof("tile_file")-1, TRUE)) {
  1027. 		if ((op = string_for_opt(opts, FALSE)) != 0) {
  1028. 			if (iflags.wc_tile_file) free(iflags.wc_tile_file);
  1029. 			iflags.wc_tile_file = (char *)alloc(strlen(op) + 1);
  1030. 			Strcpy(iflags.wc_tile_file, op);
  1031. 		}
  1032. 		return;
  1033. 	}
  1034. 	/* WINCAP
  1035. 	 * tile_height:nn */
  1036. 	fullname = "tile_height";
  1037. 	if (match_optname(opts, fullname, sizeof("tile_height")-1, TRUE)) {
  1038. 		op = string_for_opt(opts, negated);
  1039. 		if ((negated && !op) || (!negated && op)) {
  1040. 			iflags.wc_tile_height = negated ? 0 : atoi(op);
  1041. 		} else if (negated) bad_negation(fullname, TRUE);
  1042. 		return;
  1043. 	}
  1044. 	/* WINCAP
  1045. 	 * vary_msgcount:nn */
  1046. 	fullname = "vary_msgcount";
  1047. 	if (match_optname(opts, fullname, sizeof("vary_msgcount")-1, TRUE)) {
  1048. 		op = string_for_opt(opts, negated);
  1049. 		if ((negated && !op) || (!negated && op)) {
  1050. 			iflags.wc_vary_msgcount = negated ? 0 : atoi(op);
  1051. 		} else if (negated) bad_negation(fullname, TRUE);
  1052. 		return;
  1053. 	}
  1054. 	fullname = "windowtype";
  1055. 	if (match_optname(opts, fullname, 3, TRUE)) {
  1056. 	    if (negated) {
  1057. 		bad_negation(fullname, FALSE);
  1058. 		return;
  1059. 	    } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) {
  1060. 		char buf[WINTYPELEN];
  1061. 		nmcpy(buf, op, WINTYPELEN);
  1062. 		choose_windows(buf);
  1063. 	    }
  1064. 	    return;
  1065. 	}
  1066.  
  1067. 	/* WINCAP
  1068. 	 * setting window colors
  1069. * syntax: windowcolors=menu foregrnd/backgrnd text foregrnd/backgrnd
  1070. */
  1071. 	fullname = "windowcolors";
  1072. 	if (match_optname(opts, fullname, 7, TRUE)) {
  1073. 		if ((op = string_for_opt(opts, FALSE)) != 0) {
  1074. 			if (!wc_set_window_colors(op))
  1075. 				badoption(opts);
  1076. 		} else if (negated) bad_negation(fullname, TRUE);
  1077. 		return;
  1078. 	}
  1079.  
  1080. 	/* menustyle:traditional or combo or full or partial */
  1081. 	if (match_optname(opts, "menustyle", 4, TRUE)) {
  1082. 		int tmp;
  1083. 		boolean val_required = (strlen(opts) > 5 && !negated);
  1084.  
  1085. 		if (!(op = string_for_opt(opts, !val_required))) {
  1086. 		    if (val_required) return; /* string_for_opt gave feedback */
  1087. 		    tmp = negated ? 'n' : 'f';
  1088. 		} else {
  1089. 		    tmp = tolower(*op);
  1090. 		}
  1091. 		switch (tmp) {
  1092. 			case 'n':	/* none */
  1093. 			case 't':	/* traditional */
  1094. 				flags.menu_style = MENU_TRADITIONAL;
  1095. 				break;
  1096. 			case 'c':	/* combo: trad.class sel+menu */
  1097. 				flags.menu_style = MENU_COMBINATION;
  1098. 				break;
  1099. 			case 'p':	/* partial: no class menu */
  1100. 				flags.menu_style = MENU_PARTIAL;
  1101. 				break;
  1102. 			case 'f':	/* full: class menu + menu */
  1103. 				flags.menu_style = MENU_FULL;
  1104. 				break;
  1105. 			default:
  1106. 				badoption(opts);
  1107. 		}
  1108. 		return;
  1109. 	}
  1110.  
  1111. 	fullname = "menu_headings";
  1112. 	if (match_optname(opts, fullname, 12, TRUE)) {
  1113. 		if (negated) {
  1114. 			bad_negation(fullname, FALSE);
  1115. 			return;
  1116. 		}
  1117. 		else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) {
  1118. 			return;
  1119. 		}
  1120. 		if (!strcmpi(opts,"bold"))
  1121. 			iflags.menu_headings = ATR_BOLD;
  1122. 		else if (!strcmpi(opts,"inverse"))
  1123. 			iflags.menu_headings = ATR_INVERSE;
  1124. 		else if (!strcmpi(opts,"underline"))
  1125. 			iflags.menu_headings = ATR_ULINE;
  1126. 		else
  1127. 			badoption(opts);
  1128. 		return;
  1129. 	}
  1130.  
  1131. 	/* check for menu command mapping */
  1132. 	for (i = 0; i < NUM_MENU_CMDS; i++) {
  1133. 	    fullname = default_menu_cmd_info[i].name;
  1134. 	    if (match_optname(opts, fullname, (int)strlen(fullname), TRUE)) {
  1135. 		if (negated)
  1136. 		    bad_negation(fullname, FALSE);
  1137. 		else if ((op = string_for_opt(opts, FALSE)) != 0) {
  1138. 		    int j;
  1139. 		    char c, op_buf[BUFSZ];
  1140. 		    boolean isbad = FALSE;
  1141.  
  1142. 		    escapes(op, op_buf);
  1143. 		    c = *op_buf;
  1144.  
  1145. 		    if (c == 0 || c == '\r' || c == '\n' || c == '\033' ||
  1146. 			    c == ' ' || digit(c) || (letter(c) && c != '@'))
  1147. 			isbad = TRUE;
  1148. 		    else	/* reject default object class symbols */
  1149. 			for (j = 1; j < MAXOCLASSES; j++)
  1150. 			    if (c == def_oc_syms[i]) {
  1151. 				isbad = TRUE;
  1152. 				break;
  1153. 			    }
  1154.  
  1155. 		    if (isbad)
  1156. 			badoption(opts);
  1157. 		    else
  1158. 			add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd);
  1159. 		}
  1160. 		return;
  1161. 	    }
  1162. 	}
  1163.  
  1164. 	/* OK, if we still haven't recognized the option, check the boolean
  1165. 	 * options list
  1166. 	 */
  1167. 	for (i = 0; boolopt[i].name; i++) {
  1168. 		if (match_optname(opts, boolopt[i].name, 3, FALSE)) {
  1169. 			/* options that don't exist */
  1170. 			if (!boolopt[i].addr) {
  1171. 			    if (!initial && !negated)
  1172. 				pline_The("\"%s\" option is not available.",
  1173. 					boolopt[i].name);
  1174. 			    return;
  1175. 			}
  1176. 			/* options that must come from config file */
  1177. 			if (!initial && (boolopt[i].optflags == SET_IN_FILE)) {
  1178. 			    rejectoption(boolopt[i].name);
  1179. 			    return;
  1180. 			}
  1181.  
  1182. 			*(boolopt[i].addr) = !negated;
  1183.  
  1184. 			duplicate_opt_detection(boolopt[i].name, 0);
  1185.  
  1186. #if defined(TERMLIB) || defined(ASCIIGRAPH) || defined(MAC_GRAPHICS_ENV)
  1187. 			if (FALSE
  1188. # ifdef TERMLIB
  1189. 				 || (boolopt[i].addr) == &iflags.DECgraphics
  1190. # endif
  1191. # ifdef ASCIIGRAPH
  1192. 				 || (boolopt[i].addr) == &iflags.IBMgraphics
  1193. # endif
  1194. # ifdef MAC_GRAPHICS_ENV
  1195. 				 || (boolopt[i].addr) == &iflags.MACgraphics
  1196. # endif
  1197. 				) {
  1198. # ifdef REINCARNATION
  1199. 			    if (!initial && Is_rogue_level(&u.uz))
  1200. 				assign_rogue_graphics(FALSE);
  1201. # endif
  1202. 			    need_redraw = TRUE;
  1203. # ifdef TERMLIB
  1204. 			    if ((boolopt[i].addr) == &iflags.DECgraphics)
  1205. 				switch_graphics(iflags.DECgraphics ?
  1206. 						DEC_GRAPHICS : ASCII_GRAPHICS);
  1207. # endif
  1208. # ifdef ASCIIGRAPH
  1209. 			    if ((boolopt[i].addr) == &iflags.IBMgraphics)
  1210. 				switch_graphics(iflags.IBMgraphics ?
  1211. 						IBM_GRAPHICS : ASCII_GRAPHICS);
  1212. # endif
  1213. # ifdef MAC_GRAPHICS_ENV
  1214. 			    if ((boolopt[i].addr) == &iflags.MACgraphics)
  1215. 				switch_graphics(iflags.MACgraphics ?
  1216. 						MAC_GRAPHICS : ASCII_GRAPHICS);
  1217. # endif
  1218. # ifdef REINCARNATION
  1219. 			    if (!initial && Is_rogue_level(&u.uz))
  1220. 				assign_rogue_graphics(TRUE);
  1221. # endif
  1222. 			}
  1223. #endif /* TERMLIB || ASCIIGRAPH || MAC_GRAPHICS_ENV */
  1224.  
  1225. 			/* only do processing below if setting with doset() */
  1226. 			if (initial) return;
  1227.  
  1228. 			if ((boolopt[i].addr) == &flags.time
  1229. #ifdef EXP_ON_BOTL
  1230. 			 || (boolopt[i].addr) == &flags.showexp
  1231. #endif
  1232. #ifdef SCORE_ON_BOTL
  1233. 			 || (boolopt[i].addr) == &flags.showscore
  1234. #endif
  1235. 			    )
  1236. 			    flags.botl = TRUE;
  1237.  
  1238. 			else if ((boolopt[i].addr) == &flags.invlet_constant) {
  1239. 			    if (flags.invlet_constant) reassign();
  1240. 			}
  1241. #ifdef LAN_MAIL
  1242. 			else if ((boolopt[i].addr) == &flags.biff) {
  1243. 			    if (flags.biff) lan_mail_init();
  1244. 			    else lan_mail_finish();
  1245. 			}
  1246. #endif
  1247. 			else if ((boolopt[i].addr) == &flags.lit_corridor) {
  1248. 			    /*
  1249. 			     * All corridor squares seen via night vision or
  1250. 			     * candles & lamps change.  Update them by calling
  1251. 			     * newsym() on them.  Don't do this if we are
  1252. 			     * initializing the options --- the vision system
  1253. 			     * isn't set up yet.
  1254. 			     */
  1255. 			    vision_recalc(2);		/* shut down vision */
  1256. 			    vision_full_recalc = 1;	/* delayed recalc */
  1257. 			}
  1258. 			else if ((boolopt[i].addr) == &iflags.use_inverse ||
  1259. 					(boolopt[i].addr) == &iflags.showrace ||
  1260. 					(boolopt[i].addr) == &iflags.hilite_pet) {
  1261. 			    need_redraw = TRUE;
  1262. 			}
  1263. #ifdef TEXTCOLOR
  1264. 			else if ((boolopt[i].addr) == &iflags.use_color) {
  1265. 			    need_redraw = TRUE;
  1266. # ifdef TOS
  1267. 			    if ((boolopt[i].addr) == &iflags.use_color
  1268. 				&& iflags.BIOS) {
  1269. 				if (colors_changed)
  1270. 				    restore_colors();
  1271. 				else
  1272. 				    set_colors();
  1273. 			    }
  1274. # endif
  1275. 			}
  1276. #endif
  1277.  
  1278. 			return;
  1279. 		}
  1280. 	}
  1281.  
  1282. 	/* out of valid options */
  1283. 	badoption(opts);
  1284. }
  1. static NEARDATA const char *menutype[] = {
  2. 	"traditional", "combination", "partial", "full"
  3. };
  4.  
  5. static NEARDATA const char *burdentype[] = {
  6. 	"unencumbered", "burdened", "stressed",
  7. 	"strained", "overtaxed", "overloaded"
  8. };
  9.  
  10. static NEARDATA const char *runmodes[] = {
  11. 	"teleport", "run", "walk", "crawl"
  12. };

oc_to_str[edit]

  1. /*
  2. * Convert the given string of object classes to a string of default object
  3. * symbols.
  4. */
  5. STATIC_OVL void
  6. oc_to_str(src,dest)
  7. char *src, *dest;
  8. {
  9. int i;
  10.  
  11. while ((i = (int) *src++) != 0) {
  12. 	if (i < 0 || i >= MAXOCLASSES)
  13. 	    impossible("oc_to_str:  illegal object class %d", i);
  14. 	else
  15. 	    *dest++ = def_oc_syms[i];
  16. }
  17. *dest = '\0';
  18. }

add_menu_cmd_alias[edit]

  1. /*
  2. * Add the given mapping to the menu command map list.  Always keep the
  3. * maps valid C strings.
  4. */
  5. void
  6. add_menu_cmd_alias(from_ch, to_ch)
  7. char from_ch, to_ch;
  8. {
  9. if (n_menu_mapped >= MAX_MENU_MAPPED_CMDS)
  10. 	pline("out of menu map space.");
  11. else {
  12. 	mapped_menu_cmds[n_menu_mapped] = from_ch;
  13. 	mapped_menu_op[n_menu_mapped] = to_ch;
  14. 	n_menu_mapped++;
  15. 	mapped_menu_cmds[n_menu_mapped] = 0;
  16. 	mapped_menu_op[n_menu_mapped] = 0;
  17. }
  18. }

map_menu_cmd[edit]

  1. /*
  2. * Map the given character to its corresponding menu command.  If it
  3. * doesn't match anything, just return the original.
  4. */
  5. char
  6. map_menu_cmd(ch)
  7. char ch;
  8. {
  9. char *found = index(mapped_menu_cmds, ch);
  10. if (found) {
  11. 	int idx = found - mapped_menu_cmds;
  12. 	ch = mapped_menu_op[idx];
  13. }
  14. return ch;
  15. }

doset_add_menu[edit]

  1. #if defined(MICRO) || defined(MAC) || defined(WIN32)
  2. # define OPTIONS_HEADING "OPTIONS"
  3. #else
  4. # define OPTIONS_HEADING "NETHACKOPTIONS"
  5. #endif
  6.  
  7. static char fmtstr_doset_add_menu[] = "%s%-15s [%s]   "; 
  8. static char fmtstr_doset_add_menu_tab[] = "%s\t[%s]";
  9.  
  10. STATIC_OVL void
  11. doset_add_menu(win, option, indexoffset)
  12. winid win;			/* window to add to */
  13. const char *option;		/* option name */
  14. int indexoffset;		/* value to add to index in compopt[], or zero
  15. 				   if option cannot be changed */
  16. {
  17. const char *value = "unknown";		/* current value */
  18. char buf[BUFSZ], buf2[BUFSZ];
  19. anything any;
  20. int i;
  21.  
  22. any.a_void = 0;
  23. if (indexoffset == 0) {
  24. 	any.a_int = 0;
  25. 	value = get_compopt_value(option, buf2);
  26. } else {
  27. 	for (i=0; compopt[i].name; i++)
  28. 	    if (strcmp(option, compopt[i].name) == 0) break;
  29.  
  30. 	if (compopt[i].name) {
  31. 	    any.a_int = i + 1 + indexoffset;
  32. 	    value = get_compopt_value(option, buf2);
  33. 	} else {
  34. 	    /* We are trying to add an option not found in compopt[].
  35. 	       This is almost certainly bad, but we'll let it through anyway
  36. 	       (with a zero value, so it can't be selected). */
  37. 	    any.a_int = 0;
  38. 	}
  39. }
  40. /* "    " replaces "a - " -- assumes menus follow that style */
  41. if (!iflags.menu_tab_sep)
  42. 	Sprintf(buf, fmtstr_doset_add_menu, any.a_int ? "" : "    ", option, value);
  43. else
  44. 	Sprintf(buf, fmtstr_doset_add_menu_tab, option, value);
  45. add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
  46. }

doset[edit]

  1. /* Changing options via menu by Per Liboriussen */
  2. int
  3. doset()
  4. {
  5. 	char buf[BUFSZ], buf2[BUFSZ];
  6. 	int i, pass, boolcount, pick_cnt, pick_idx, opt_indx;
  7. 	boolean *bool_p;
  8. 	winid tmpwin;
  9. 	anything any;
  10. 	menu_item *pick_list;
  11. 	int indexoffset, startpass, endpass;
  12. 	boolean setinitial = FALSE, fromfile = FALSE;
  13. 	int biggest_name = 0;
  14.  
  15. 	tmpwin = create_nhwindow(NHW_MENU);
  16. 	start_menu(tmpwin);
  17.  
  18. 	any.a_void = 0;
  19. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
  20. 		 "Booleans (selecting will toggle value):", MENU_UNSELECTED);
  21. 	any.a_int = 0;
  22. 	/* first list any other non-modifiable booleans, then modifiable ones */
  23. 	for (pass = 0; pass <= 1; pass++)
  24. 	    for (i = 0; boolopt[i].name; i++)
  25. 		if ((bool_p = boolopt[i].addr) != 0 &&
  26. 			((boolopt[i].optflags == DISP_IN_GAME && pass == 0) ||
  27. 			 (boolopt[i].optflags == SET_IN_GAME && pass == 1))) {
  28. 		    if (bool_p == &flags.female) continue;  /* obsolete */
  29. #ifdef WIZARD
  30. 		    if (bool_p == &iflags.sanity_check && !wizard) continue;
  31. 		    if (bool_p == &iflags.menu_tab_sep && !wizard) continue;
  32. #endif
  33. 		    if (is_wc_option(boolopt[i].name) &&
  34. 			!wc_supported(boolopt[i].name)) continue;
  35. 		    if (is_wc2_option(boolopt[i].name) &&
  36. 			!wc2_supported(boolopt[i].name)) continue;
  37. 		    any.a_int = (pass == 0) ? 0 : i + 1;
  38. 		    if (!iflags.menu_tab_sep)
  39. 			Sprintf(buf, "%s%-13s [%s]",
  40. 			    pass == 0 ? "    " : "",
  41. 			    boolopt[i].name, *bool_p ? "true" : "false");
  42. 		    else
  43. 			Sprintf(buf, "%s\t[%s]",
  44. 			    boolopt[i].name, *bool_p ? "true" : "false");
  45. 		    add_menu(tmpwin, NO_GLYPH, &any, 0, 0,
  46. 			     ATR_NONE, buf, MENU_UNSELECTED);
  47. 		}
  48.  
  49. 	boolcount = i;
  50. 	indexoffset = boolcount;
  51. 	any.a_void = 0;
  52. 	add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
  53. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
  54. 		 "Compounds (selecting will prompt for new value):",
  55. 		 MENU_UNSELECTED);
  56.  
  57. 	startpass = DISP_IN_GAME;
  58. 	endpass = SET_IN_GAME;
  59.  
  60. 	/* spin through the options to find the biggest name
  61. and adjust the format string accordingly if needed */
  62. 	biggest_name = 0;
  63. 	for (i = 0; compopt[i].name; i++)
  64. 		if (compopt[i].optflags >= startpass && compopt[i].optflags <= endpass &&
  65. 		    strlen(compopt[i].name) > (unsigned) biggest_name)
  66. 			biggest_name = (int) strlen(compopt[i].name);
  67. 	if (biggest_name > 30) biggest_name = 30;
  68. 	if (!iflags.menu_tab_sep)
  69. 		Sprintf(fmtstr_doset_add_menu, "%%s%%-%ds [%%s]", biggest_name);
  70.  
  71. 	/* deliberately put `name', `role', `race', `gender' first */
  72. 	doset_add_menu(tmpwin, "name", 0);
  73. 	doset_add_menu(tmpwin, "role", 0);
  74. 	doset_add_menu(tmpwin, "race", 0);
  75. 	doset_add_menu(tmpwin, "gender", 0);
  76.  
  77. 	for (pass = startpass; pass <= endpass; pass++) 
  78. 	    for (i = 0; compopt[i].name; i++)
  79. 		if (compopt[i].optflags == pass) {
  80. 		    	if (!strcmp(compopt[i].name, "name") ||
  81. 		    	    !strcmp(compopt[i].name, "role") ||
  82. 		    	    !strcmp(compopt[i].name, "race") ||
  83. 		    	    !strcmp(compopt[i].name, "gender"))
  84. 		    	    	continue;
  85. 		    	else if (is_wc_option(compopt[i].name) &&
  86. 					!wc_supported(compopt[i].name))
  87. 		    		continue;
  88. 		    	else if (is_wc2_option(compopt[i].name) &&
  89. 					!wc2_supported(compopt[i].name))
  90. 		    		continue;
  91. 		    	else
  92. 				doset_add_menu(tmpwin, compopt[i].name,
  93. 					(pass == DISP_IN_GAME) ? 0 : indexoffset);
  94. 		}
  95. #ifdef AUTOPICKUP_EXCEPTIONS
  96. 	any.a_int = -1;
  97. 	Sprintf(buf, "autopickup exceptions (%d currently set)",
  98. 		count_ape_maps((int *)0, (int *)0));
  99. 	add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED);
  100.  
  101. #endif /* AUTOPICKUP_EXCEPTIONS */
  102. #ifdef PREFIXES_IN_USE
  103. 	any.a_void = 0;
  104. 	add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED);
  105. 	add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
  106. 		 "Variable playground locations:", MENU_UNSELECTED);
  107. 	for (i = 0; i < PREFIX_COUNT; i++)
  108. 		doset_add_menu(tmpwin, fqn_prefix_names[i], 0);
  109. #endif
  110. 	end_menu(tmpwin, "Set what options?");
  111. 	need_redraw = FALSE;
  112. 	if ((pick_cnt = select_menu(tmpwin, PICK_ANY, &pick_list)) > 0) {
  113. 	    /*
  114. 	     * Walk down the selection list and either invert the booleans
  115. 	     * or prompt for new values. In most cases, call parseoptions()
  116. 	     * to take care of options that require special attention, like
  117. 	     * redraws.
  118. 	     */
  119. 	    for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
  120. 		opt_indx = pick_list[pick_idx].item.a_int - 1;
  121. #ifdef AUTOPICKUP_EXCEPTIONS
  122. 		if (opt_indx == -2) {
  123. 		    special_handling("autopickup_exception",
  124. 		    			setinitial, fromfile);
  125. 		} else
  126. #endif
  127. 		if (opt_indx < boolcount) {
  128. 		    /* boolean option */
  129. 		    Sprintf(buf, "%s%s", *boolopt[opt_indx].addr ? "!" : "",
  130. 			    boolopt[opt_indx].name);
  131. 		    parseoptions(buf, setinitial, fromfile);
  132. 		    if (wc_supported(boolopt[opt_indx].name) ||
  133. 		    	wc2_supported(boolopt[opt_indx].name))
  134. 			preference_update(boolopt[opt_indx].name);
  135. 		} else {
  136. 		    /* compound option */
  137. 		    opt_indx -= boolcount;
  138.  
  139. 		    if (!special_handling(compopt[opt_indx].name,
  140. 							setinitial, fromfile)) {
  141. 			Sprintf(buf, "Set %s to what?", compopt[opt_indx].name);
  142. 			getlin(buf, buf2);
  143. 			if (buf2[0] == '\033')
  144. 			    continue;
  145. 			Sprintf(buf, "%s:%s", compopt[opt_indx].name, buf2);
  146. 			/* pass the buck */
  147. 			parseoptions(buf, setinitial, fromfile);
  148. 		    }
  149. 		    if (wc_supported(compopt[opt_indx].name) ||
  150. 			wc2_supported(compopt[opt_indx].name))
  151. 			preference_update(compopt[opt_indx].name);
  152. 		}
  153. 	    }
  154. 	    free((genericptr_t)pick_list);
  155. 	    pick_list = (menu_item *)0;
  156. 	}
  157.  
  158. 	destroy_nhwindow(tmpwin);
  159. 	if (need_redraw)
  160. 	    (void) doredraw();
  161. 	return 0;
  162. }

special_handling[edit]

  1. STATIC_OVL boolean
  2. special_handling(optname, setinitial, setfromfile)
  3. const char *optname;
  4. boolean setinitial,setfromfile;
  5. {
  6. winid tmpwin;
  7. anything any;
  8. int i;
  9. char buf[BUFSZ];
  10. boolean retval = FALSE;
  11.  
  12. /* Special handling of menustyle, pickup_burden, pickup_types,
  13. * disclose, runmode, msg_window, menu_headings, and number_pad options.
  14. #ifdef AUTOPICKUP_EXCEPTIONS
  15. * Also takes care of interactive autopickup_exception_handling changes.
  16. #endif
  17. */
  18. if (!strcmp("menustyle", optname)) {
  19. 	const char *style_name;
  20. 	menu_item *style_pick = (menu_item *)0;
  21. tmpwin = create_nhwindow(NHW_MENU);
  22. 	start_menu(tmpwin);
  23. 	for (i = 0; i < SIZE(menutype); i++) {
  24. 		style_name = menutype[i];
  25. 		/* note: separate `style_name' variable used
  26. 		   to avoid an optimizer bug in VAX C V2.3 */
  27. 		any.a_int = i + 1;
  28. 		add_menu(tmpwin, NO_GLYPH, &any, *style_name, 0,
  29. 			 ATR_NONE, style_name, MENU_UNSELECTED);
  30. }
  31. 	end_menu(tmpwin, "Select menustyle:");
  32. 	if (select_menu(tmpwin, PICK_ONE, &style_pick) > 0) {
  33. 		flags.menu_style = style_pick->item.a_int - 1;
  34. 		free((genericptr_t)style_pick);
  35. }
  36. 	destroy_nhwindow(tmpwin);
  37. retval = TRUE;
  38. } else if (!strcmp("pickup_burden", optname)) {
  39. 	const char *burden_name, *burden_letters = "ubsntl";
  40. 	menu_item *burden_pick = (menu_item *)0;
  41. tmpwin = create_nhwindow(NHW_MENU);
  42. 	start_menu(tmpwin);
  43. 	for (i = 0; i < SIZE(burdentype); i++) {
  44. 		burden_name = burdentype[i];
  45. 		any.a_int = i + 1;
  46. 		add_menu(tmpwin, NO_GLYPH, &any, burden_letters[i], 0,
  47. 			 ATR_NONE, burden_name, MENU_UNSELECTED);
  48. }
  49. 	end_menu(tmpwin, "Select encumbrance level:");
  50. 	if (select_menu(tmpwin, PICK_ONE, &burden_pick) > 0) {
  51. 		flags.pickup_burden = burden_pick->item.a_int - 1;
  52. 		free((genericptr_t)burden_pick);
  53. 	}
  54. 	destroy_nhwindow(tmpwin);
  55. 	retval = TRUE;
  56. } else if (!strcmp("pickup_types", optname)) {
  57. 	/* parseoptions will prompt for the list of types */
  58. 	parseoptions(strcpy(buf, "pickup_types"), setinitial, setfromfile);
  59. 	retval = TRUE;
  60. } else if (!strcmp("disclose", optname)) {
  61. 	int pick_cnt, pick_idx, opt_idx;
  62. 	menu_item *disclosure_category_pick = (menu_item *)0;
  63. 	/*
  64. 	 * The order of disclose_names[]
  65. * must correspond to disclosure_options in decl.h
  66. */
  67. 	static const char *disclosure_names[] = {
  68. 		"inventory", "attributes", "vanquished", "genocides", "conduct"
  69. 	};
  70. 	int disc_cat[NUM_DISCLOSURE_OPTIONS];
  71. 	const char *disclosure_name;
  72.  
  73. tmpwin = create_nhwindow(NHW_MENU);
  74. 	start_menu(tmpwin);
  75. 	for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
  76. 		disclosure_name = disclosure_names[i];
  77. 		any.a_int = i + 1;
  78. 		add_menu(tmpwin, NO_GLYPH, &any, disclosure_options[i], 0,
  79. 			 ATR_NONE, disclosure_name, MENU_UNSELECTED);
  80. 		disc_cat[i] = 0;
  81. }
  82. 	end_menu(tmpwin, "Change which disclosure options categories:");
  83. 	if ((pick_cnt = select_menu(tmpwin, PICK_ANY, &disclosure_category_pick)) > 0) {
  84. 	    for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
  85. 		opt_idx = disclosure_category_pick[pick_idx].item.a_int - 1;
  86. 		disc_cat[opt_idx] = 1;
  87. 	    }
  88. 	    free((genericptr_t)disclosure_category_pick);
  89. 	    disclosure_category_pick = (menu_item *)0;
  90. 	}
  91. 	destroy_nhwindow(tmpwin);
  92.  
  93. 	for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
  94. 	    if (disc_cat[i]) {
  95. 	    	char dbuf[BUFSZ];
  96. 		menu_item *disclosure_option_pick = (menu_item *)0;
  97. 		Sprintf(dbuf, "Disclosure options for %s:", disclosure_names[i]);
  98. 	        tmpwin = create_nhwindow(NHW_MENU);
  99. 		start_menu(tmpwin);
  100. 		any.a_char = DISCLOSE_NO_WITHOUT_PROMPT;
  101. 		add_menu(tmpwin, NO_GLYPH, &any, 'a', 0,
  102. 			ATR_NONE,"Never disclose and don't prompt", MENU_UNSELECTED);
  103. 		any.a_void = 0;
  104. 		any.a_char = DISCLOSE_YES_WITHOUT_PROMPT;
  105. 		add_menu(tmpwin, NO_GLYPH, &any, 'b', 0,
  106. 			ATR_NONE,"Always disclose and don't prompt", MENU_UNSELECTED);
  107. 		any.a_void = 0;
  108. 		any.a_char = DISCLOSE_PROMPT_DEFAULT_NO;
  109. 		add_menu(tmpwin, NO_GLYPH, &any, 'c', 0,
  110. 			ATR_NONE,"Prompt and default answer to \"No\"", MENU_UNSELECTED);
  111. 		any.a_void = 0;
  112. 		any.a_char = DISCLOSE_PROMPT_DEFAULT_YES;
  113. 		add_menu(tmpwin, NO_GLYPH, &any, 'd', 0,
  114. 			ATR_NONE,"Prompt and default answer to \"Yes\"", MENU_UNSELECTED);
  115. 		end_menu(tmpwin, dbuf);
  116. 		if (select_menu(tmpwin, PICK_ONE, &disclosure_option_pick) > 0) {
  117. 			flags.end_disclose[i] = disclosure_option_pick->item.a_char;
  118. 			free((genericptr_t)disclosure_option_pick);
  119. 		}
  120. 		destroy_nhwindow(tmpwin);
  121. 	    }
  122. 	}
  123. 	retval = TRUE;
  124. } else if (!strcmp("runmode", optname)) {
  125. 	const char *mode_name;
  126. 	menu_item *mode_pick = (menu_item *)0;
  127. 	tmpwin = create_nhwindow(NHW_MENU);
  128. 	start_menu(tmpwin);
  129. 	for (i = 0; i < SIZE(runmodes); i++) {
  130. 		mode_name = runmodes[i];
  131. 		any.a_int = i + 1;
  132. 		add_menu(tmpwin, NO_GLYPH, &any, *mode_name, 0,
  133. 			 ATR_NONE, mode_name, MENU_UNSELECTED);
  134. 	}
  135. 	end_menu(tmpwin, "Select run/travel display mode:");
  136. 	if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) {
  137. 		iflags.runmode = mode_pick->item.a_int - 1;
  138. 		free((genericptr_t)mode_pick);
  139. 	}
  140. 	destroy_nhwindow(tmpwin);
  141. 	retval = TRUE;
  142. } 
  143. #ifdef TTY_GRAPHICS
  144. else if (!strcmp("msg_window", optname)) {
  145. 	/* by Christian W. Cooper */
  146. 	menu_item *window_pick = (menu_item *)0;
  147. 	tmpwin = create_nhwindow(NHW_MENU);
  148. 	start_menu(tmpwin);
  149. 	any.a_char = 's';
  150. 	add_menu(tmpwin, NO_GLYPH, &any, 's', 0,
  151. 		ATR_NONE, "single", MENU_UNSELECTED);
  152. 	any.a_char = 'c';
  153. 	add_menu(tmpwin, NO_GLYPH, &any, 'c', 0,
  154. 		ATR_NONE, "combination", MENU_UNSELECTED);
  155. 	any.a_char = 'f';
  156. 	add_menu(tmpwin, NO_GLYPH, &any, 'f', 0,
  157. 		ATR_NONE, "full", MENU_UNSELECTED);
  158. 	any.a_char = 'r';
  159. 	add_menu(tmpwin, NO_GLYPH, &any, 'r', 0,
  160. 		ATR_NONE, "reversed", MENU_UNSELECTED);
  161. 	end_menu(tmpwin, "Select message history display type:");
  162. 	if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) {
  163. 		iflags.prevmsg_window = window_pick->item.a_char;
  164. 		free((genericptr_t)window_pick);
  165. 	}
  166. 	destroy_nhwindow(tmpwin);
  167. retval = TRUE;
  168. }
  169. #endif
  170. else if (!strcmp("align_message", optname) ||
  171. 		!strcmp("align_status", optname)) {
  172. 	menu_item *window_pick = (menu_item *)0;
  173. 	char abuf[BUFSZ];
  174. 	boolean msg = (*(optname+6) == 'm');
  175.  
  176. 	tmpwin = create_nhwindow(NHW_MENU);
  177. 	start_menu(tmpwin);
  178. 	any.a_int = ALIGN_TOP;
  179. 	add_menu(tmpwin, NO_GLYPH, &any, 't', 0,
  180. 		ATR_NONE, "top", MENU_UNSELECTED);
  181. 	any.a_int = ALIGN_BOTTOM;
  182. 	add_menu(tmpwin, NO_GLYPH, &any, 'b', 0,
  183. 		ATR_NONE, "bottom", MENU_UNSELECTED);
  184. 	any.a_int = ALIGN_LEFT;
  185. 	add_menu(tmpwin, NO_GLYPH, &any, 'l', 0,
  186. 		ATR_NONE, "left", MENU_UNSELECTED);
  187. 	any.a_int = ALIGN_RIGHT;
  188. 	add_menu(tmpwin, NO_GLYPH, &any, 'r', 0,
  189. 		ATR_NONE, "right", MENU_UNSELECTED);
  190. 	Sprintf(abuf, "Select %s window placement relative to the map:",
  191. 		msg ? "message" : "status");
  192. 	end_menu(tmpwin, abuf);
  193. 	if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) {		
  194. 		if (msg) iflags.wc_align_message = window_pick->item.a_int;
  195. 		else iflags.wc_align_status = window_pick->item.a_int;
  196. 		free((genericptr_t)window_pick);
  197. 	}
  198. 	destroy_nhwindow(tmpwin);
  199. retval = TRUE;
  200. } else if (!strcmp("number_pad", optname)) {
  201. 	static const char *npchoices[3] =
  202. 		{"0 (off)", "1 (on)", "2 (on, DOS compatible)"};
  203. 	const char *npletters = "abc";
  204. 	menu_item *mode_pick = (menu_item *)0;
  205.  
  206. 	tmpwin = create_nhwindow(NHW_MENU);
  207. 	start_menu(tmpwin);
  208. 	for (i = 0; i < SIZE(npchoices); i++) {
  209. 		any.a_int = i + 1;
  210. 		add_menu(tmpwin, NO_GLYPH, &any, npletters[i], 0,
  211. 			 ATR_NONE, npchoices[i], MENU_UNSELECTED);
  212. }
  213. 	end_menu(tmpwin, "Select number_pad mode:");
  214. 	if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) {
  215. 		int mode = mode_pick->item.a_int - 1;
  216. 		switch(mode) {
  217. 			case 2:
  218. 				iflags.num_pad = 1;
  219. 				iflags.num_pad_mode = 1;
  220. 				break;
  221. 			case 1:
  222. 				iflags.num_pad = 1;
  223. 				iflags.num_pad_mode = 0;
  224. 				break;
  225. 			case 0:
  226. 			default:
  227. 				iflags.num_pad = 0;
  228. 				iflags.num_pad_mode = 0;
  229. 		}
  230. 		free((genericptr_t)mode_pick);
  231. }
  232. 	destroy_nhwindow(tmpwin);
  233. retval = TRUE;
  234. } else if (!strcmp("menu_headings", optname)) {
  235. 	static const char *mhchoices[3] = {"bold", "inverse", "underline"};
  236. 	const char *npletters = "biu";
  237. 	menu_item *mode_pick = (menu_item *)0;
  238.  
  239. 	tmpwin = create_nhwindow(NHW_MENU);
  240. 	start_menu(tmpwin);
  241. 	for (i = 0; i < SIZE(mhchoices); i++) {
  242. 		any.a_int = i + 1;
  243. 		add_menu(tmpwin, NO_GLYPH, &any, npletters[i], 0,
  244. 			 ATR_NONE, mhchoices[i], MENU_UNSELECTED);
  245. }
  246. 	end_menu(tmpwin, "How to highlight menu headings:");
  247. 	if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) {
  248. 		int mode = mode_pick->item.a_int - 1;
  249. 		switch(mode) {
  250. 			case 2:
  251. 				iflags.menu_headings = ATR_ULINE;
  252. 				break;
  253. 			case 0:
  254. 				iflags.menu_headings = ATR_BOLD;
  255. 				break;
  256. 			case 1:
  257. 			default:
  258. 				iflags.menu_headings = ATR_INVERSE;
  259. 		}
  260. 		free((genericptr_t)mode_pick);
  261. }
  262. 	destroy_nhwindow(tmpwin);
  263. retval = TRUE;
  264. #ifdef AUTOPICKUP_EXCEPTIONS
  265. } else if (!strcmp("autopickup_exception", optname)) {
  266. 	boolean retval;
  267. 	int pick_cnt, pick_idx, opt_idx, pass;
  268. 	int totalapes = 0, numapes[2] = {0,0};
  269. 	menu_item *pick_list = (menu_item *)0;
  270. 	anything any;
  271. 	char apebuf[BUFSZ];
  272. 	struct autopickup_exception *ape;
  273. 	static const char *action_titles[] = {
  274. 		"a", "add new autopickup exception",
  275. 		"l", "list autopickup exceptions",
  276. 		"r", "remove existing autopickup exception",
  277. 		"e", "exit this menu",
  278. 	};
  279. ape_again:
  280. 	opt_idx = 0;
  281. 	totalapes = count_ape_maps(&numapes[AP_LEAVE], &numapes[AP_GRAB]);
  282. 	tmpwin = create_nhwindow(NHW_MENU);
  283. 	start_menu(tmpwin);
  284. 	any.a_int = 0;
  285. 	for (i = 0; i < SIZE(action_titles) ; i += 2) {
  286. 		any.a_int++;
  287. 		if (!totalapes && (i >= 2 && i < 6)) continue;
  288. 		add_menu(tmpwin, NO_GLYPH, &any, *action_titles[i],
  289. 		      0, ATR_NONE, action_titles[i+1], MENU_UNSELECTED);
  290. }
  291. 	end_menu(tmpwin, "Do what?");
  292. 	if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &pick_list)) > 0) {
  293. 		for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) {
  294. 			opt_idx = pick_list[pick_idx].item.a_int - 1;
  295. 		}
  296. 		free((genericptr_t)pick_list);
  297. 		pick_list = (menu_item *)0;
  298. 	}
  299. 	destroy_nhwindow(tmpwin);
  300. 	if (pick_cnt < 1) return FALSE;
  301.  
  302. 	if (opt_idx == 0) {	/* add new */
  303. 		getlin("What new autopickup exception pattern?", &apebuf[1]);
  304. 		if (apebuf[1] == '\033') return FALSE;
  305. 		apebuf[0] = '"';
  306. 		Strcat(apebuf,"\"");
  307. 		add_autopickup_exception(apebuf);
  308. 		goto ape_again;
  309. 	} else if (opt_idx == 3) {
  310. 		retval = TRUE;
  311. 	} else {	/* remove */
  312. 		tmpwin = create_nhwindow(NHW_MENU);
  313. 		start_menu(tmpwin);
  314. 		for (pass = AP_LEAVE; pass <= AP_GRAB; ++pass) {
  315. 		    if (numapes[pass] == 0) continue;
  316. 		    ape = iflags.autopickup_exceptions[pass];
  317. 		    any.a_void = 0;
  318. 		    add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings,
  319. 				(pass == 0) ? "Never pickup" : "Always pickup",
  320. 				MENU_UNSELECTED);
  321. 		    for (i = 0; i < numapes[pass] && ape; i++) {
  322. 			any.a_void = (opt_idx == 1) ? 0 : ape;
  323. 			Sprintf(apebuf, "\"%s\"", ape->pattern);
  324. 			add_menu(tmpwin, NO_GLYPH, &any,
  325. 				0, 0, ATR_NONE, apebuf, MENU_UNSELECTED);
  326. 			ape = ape->next;
  327. 		    }
  328. 		}
  329. 		Sprintf(apebuf, "%s autopickup exceptions",
  330. 			(opt_idx == 1) ? "List of" : "Remove which");
  331. 		end_menu(tmpwin, apebuf);
  332. 		pick_cnt = select_menu(tmpwin,
  333. 					(opt_idx == 1) ?  PICK_NONE : PICK_ANY,
  334. 					&pick_list);
  335. 		if (pick_cnt > 0) {
  336. 	    	    for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx)
  337. 			remove_autopickup_exception(
  338. 			 (struct autopickup_exception *)pick_list[pick_idx].item.a_void);
  339. 	        }
  340. 	        free((genericptr_t)pick_list);
  341. 	        pick_list = (menu_item *)0;
  342. 		destroy_nhwindow(tmpwin);
  343. 		goto ape_again;
  344. 	}
  345. 	retval = TRUE;
  346. #endif /* AUTOPICKUP_EXCEPTIONS */
  347. }
  348. return retval;
  349. }

get_compopbt_value[edit]

  1. #define rolestring(val,array,field) ((val >= 0) ? array[val].field : \
  2. 				     (val == ROLE_RANDOM) ? randomrole : none)
  3.  
  4. /* This is ugly. We have all the option names in the compopt[] array,
  5. but we need to look at each option individually to get the value. */
  6. STATIC_OVL const char *
  7. get_compopt_value(optname, buf)
  8. const char *optname;
  9. char *buf;
  10. {
  11. 	char ocl[MAXOCLASSES+1];
  12. 	static const char none[] = "(none)", randomrole[] = "random",
  13. 		     to_be_done[] = "(to be done)",
  14. 		     defopt[] = "default",
  15. 		     defbrief[] = "def";
  16. 	int i;
  17.  
  18. 	buf[0] = '\0';
  19. 	if (!strcmp(optname,"align_message"))
  20. 		Sprintf(buf, "%s", iflags.wc_align_message == ALIGN_TOP     ? "top" :
  21. 				   iflags.wc_align_message == ALIGN_LEFT    ? "left" :
  22. 				   iflags.wc_align_message == ALIGN_BOTTOM  ? "bottom" :
  23. 				   iflags.wc_align_message == ALIGN_RIGHT   ? "right" :
  24. 				   defopt);
  25. 	else if (!strcmp(optname,"align_status"))
  26. 		Sprintf(buf, "%s", iflags.wc_align_status == ALIGN_TOP     ? "top" :
  27. 				   iflags.wc_align_status == ALIGN_LEFT    ? "left" :
  28. 				   iflags.wc_align_status == ALIGN_BOTTOM  ? "bottom" :
  29. 				   iflags.wc_align_status == ALIGN_RIGHT   ? "right" :
  30. 				   defopt);
  31. 	else if (!strcmp(optname,"align"))
  32. 		Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj));
  33. #ifdef WIN32CON
  34. 	else if (!strcmp(optname,"altkeyhandler"))
  35. 		Sprintf(buf, "%s", iflags.altkeyhandler[0] ?
  36. 			iflags.altkeyhandler : "default");
  37. #endif
  38. 	else if (!strcmp(optname, "boulder"))
  39. 		Sprintf(buf, "%c", iflags.bouldersym ?
  40. 			iflags.bouldersym : oc_syms[(int)objects[BOULDER].oc_class]);
  41. 	else if (!strcmp(optname, "catname")) 
  42. 		Sprintf(buf, "%s", catname[0] ? catname : none );
  43. 	else if (!strcmp(optname, "disclose")) {
  44. 		for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) {
  45. 			char topt[2];
  46. 			if (i) Strcat(buf," ");
  47. 			topt[1] = '\0';
  48. 			topt[0] = flags.end_disclose[i];
  49. 			Strcat(buf, topt);
  50. 			topt[0] = disclosure_options[i];
  51. 			Strcat(buf, topt);
  52. 		}
  53. 	}
  54. 	else if (!strcmp(optname, "dogname")) 
  55. 		Sprintf(buf, "%s", dogname[0] ? dogname : none );
  56. 	else if (!strcmp(optname, "dungeon"))
  57. 		Sprintf(buf, "%s", to_be_done);
  58. 	else if (!strcmp(optname, "effects"))
  59. 		Sprintf(buf, "%s", to_be_done);
  60. 	else if (!strcmp(optname, "font_map"))
  61. 		Sprintf(buf, "%s", iflags.wc_font_map ? iflags.wc_font_map : defopt);
  62. 	else if (!strcmp(optname, "font_message"))
  63. 		Sprintf(buf, "%s", iflags.wc_font_message ? iflags.wc_font_message : defopt);
  64. 	else if (!strcmp(optname, "font_status"))
  65. 		Sprintf(buf, "%s", iflags.wc_font_status ? iflags.wc_font_status : defopt);
  66. 	else if (!strcmp(optname, "font_menu"))
  67. 		Sprintf(buf, "%s", iflags.wc_font_menu ? iflags.wc_font_menu : defopt);
  68. 	else if (!strcmp(optname, "font_text"))
  69. 		Sprintf(buf, "%s", iflags.wc_font_text ? iflags.wc_font_text : defopt);
  70. 	else if (!strcmp(optname, "font_size_map")) {
  71. 		if (iflags.wc_fontsiz_map) Sprintf(buf, "%d", iflags.wc_fontsiz_map);
  72. 		else Strcpy(buf, defopt);
  73. 	}
  74. 	else if (!strcmp(optname, "font_size_message")) {
  75. 		if (iflags.wc_fontsiz_message) Sprintf(buf, "%d",
  76. 							iflags.wc_fontsiz_message);
  77. 		else Strcpy(buf, defopt);
  78. 	}
  79. 	else if (!strcmp(optname, "font_size_status")) {
  80. 		if (iflags.wc_fontsiz_status) Sprintf(buf, "%d", iflags.wc_fontsiz_status);
  81. 		else Strcpy(buf, defopt);
  82. 	}
  83. 	else if (!strcmp(optname, "font_size_menu")) {
  84. 		if (iflags.wc_fontsiz_menu) Sprintf(buf, "%d", iflags.wc_fontsiz_menu);
  85. 		else Strcpy(buf, defopt);
  86. 	}
  87. 	else if (!strcmp(optname, "font_size_text")) {
  88. 		if (iflags.wc_fontsiz_text) Sprintf(buf, "%d",iflags.wc_fontsiz_text);
  89. 		else Strcpy(buf, defopt);
  90. 	}
  91. 	else if (!strcmp(optname, "fruit")) 
  92. 		Sprintf(buf, "%s", pl_fruit);
  93. 	else if (!strcmp(optname, "gender"))
  94. 		Sprintf(buf, "%s", rolestring(flags.initgend, genders, adj));
  95. 	else if (!strcmp(optname, "horsename")) 
  96. 		Sprintf(buf, "%s", horsename[0] ? horsename : none);
  97. 	else if (!strcmp(optname, "map_mode"))
  98. 		Sprintf(buf, "%s",
  99. 			iflags.wc_map_mode == MAP_MODE_TILES      ? "tiles" :
  100. 			iflags.wc_map_mode == MAP_MODE_ASCII4x6   ? "ascii4x6" :
  101. 			iflags.wc_map_mode == MAP_MODE_ASCII6x8   ? "ascii6x8" :
  102. 			iflags.wc_map_mode == MAP_MODE_ASCII8x8   ? "ascii8x8" :
  103. 			iflags.wc_map_mode == MAP_MODE_ASCII16x8  ? "ascii16x8" :
  104. 			iflags.wc_map_mode == MAP_MODE_ASCII7x12  ? "ascii7x12" :
  105. 			iflags.wc_map_mode == MAP_MODE_ASCII8x12  ? "ascii8x12" :
  106. 			iflags.wc_map_mode == MAP_MODE_ASCII16x12 ? "ascii16x12" :
  107. 			iflags.wc_map_mode == MAP_MODE_ASCII12x16 ? "ascii12x16" :
  108. 			iflags.wc_map_mode == MAP_MODE_ASCII10x18 ? "ascii10x18" :
  109. 			iflags.wc_map_mode == MAP_MODE_ASCII_FIT_TO_SCREEN ?
  110. 			"fit_to_screen" : defopt);
  111. 	else if (!strcmp(optname, "menustyle")) 
  112. 		Sprintf(buf, "%s", menutype[(int)flags.menu_style] );
  113. 	else if (!strcmp(optname, "menu_deselect_all"))
  114. 		Sprintf(buf, "%s", to_be_done);
  115. 	else if (!strcmp(optname, "menu_deselect_page"))
  116. 		Sprintf(buf, "%s", to_be_done);
  117. 	else if (!strcmp(optname, "menu_first_page"))
  118. 		Sprintf(buf, "%s", to_be_done);
  119. 	else if (!strcmp(optname, "menu_invert_all"))
  120. 		Sprintf(buf, "%s", to_be_done);
  121. 	else if (!strcmp(optname, "menu_headings")) {
  122. 		Sprintf(buf, "%s", (iflags.menu_headings == ATR_BOLD) ?
  123. 			"bold" :   (iflags.menu_headings == ATR_INVERSE) ?
  124. 			"inverse" :   (iflags.menu_headings == ATR_ULINE) ?
  125. 			"underline" : "unknown");
  126. 	}
  127. 	else if (!strcmp(optname, "menu_invert_page"))
  128. 		Sprintf(buf, "%s", to_be_done);
  129. 	else if (!strcmp(optname, "menu_last_page"))
  130. 		Sprintf(buf, "%s", to_be_done);
  131. 	else if (!strcmp(optname, "menu_next_page"))
  132. 		Sprintf(buf, "%s", to_be_done);
  133. 	else if (!strcmp(optname, "menu_previous_page"))
  134. 		Sprintf(buf, "%s", to_be_done);
  135. 	else if (!strcmp(optname, "menu_search"))
  136. 		Sprintf(buf, "%s", to_be_done);
  137. 	else if (!strcmp(optname, "menu_select_all"))
  138. 		Sprintf(buf, "%s", to_be_done);
  139. 	else if (!strcmp(optname, "menu_select_page"))
  140. 		Sprintf(buf, "%s", to_be_done);
  141. 	else if (!strcmp(optname, "monsters"))
  142. 		Sprintf(buf, "%s", to_be_done);
  143. 	else if (!strcmp(optname, "msghistory"))
  144. 		Sprintf(buf, "%u", iflags.msg_history);
  145. #ifdef TTY_GRAPHICS
  146. 	else if (!strcmp(optname, "msg_window"))
  147. 		Sprintf(buf, "%s", (iflags.prevmsg_window=='s') ? "single" :
  148. 					(iflags.prevmsg_window=='c') ? "combination" :
  149. 					(iflags.prevmsg_window=='f') ? "full" : "reversed");
  150. #endif
  151. 	else if (!strcmp(optname, "name"))
  152. 		Sprintf(buf, "%s", plname);
  153. 	else if (!strcmp(optname, "number_pad"))
  154. 		Sprintf(buf, "%s",
  155. 			(!iflags.num_pad) ? "0=off" :
  156. 			(iflags.num_pad_mode) ? "2=on, DOS compatible" : "1=on");
  157. 	else if (!strcmp(optname, "objects"))
  158. 		Sprintf(buf, "%s", to_be_done);
  159. 	else if (!strcmp(optname, "packorder")) {
  160. 		oc_to_str(flags.inv_order, ocl);
  161. 		Sprintf(buf, "%s", ocl);
  162. 	     }
  163. #ifdef CHANGE_COLOR
  164. 	else if (!strcmp(optname, "palette")) 
  165. 		Sprintf(buf, "%s", get_color_string());
  166. #endif
  167. 	else if (!strcmp(optname, "pettype")) 
  168. 		Sprintf(buf, "%s", (preferred_pet == 'c') ? "cat" :
  169. 				(preferred_pet == 'd') ? "dog" :
  170. 				(preferred_pet == 'n') ? "none" : "random");
  171. 	else if (!strcmp(optname, "pickup_burden"))
  172. 		Sprintf(buf, "%s", burdentype[flags.pickup_burden] );
  173. 	else if (!strcmp(optname, "pickup_types")) {
  174. 		oc_to_str(flags.pickup_types, ocl);
  175. 		Sprintf(buf, "%s", ocl[0] ? ocl : "all" );
  176. 	     }
  177. 	else if (!strcmp(optname, "race"))
  178. 		Sprintf(buf, "%s", rolestring(flags.initrace, races, noun));
  179. 	else if (!strcmp(optname, "role"))
  180. 		Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m));
  181. 	else if (!strcmp(optname, "runmode"))
  182. 		Sprintf(buf, "%s", runmodes[iflags.runmode]);
  183. 	else if (!strcmp(optname, "scores")) {
  184. 		Sprintf(buf, "%d top/%d around%s", flags.end_top,
  185. 				flags.end_around, flags.end_own ? "/own" : "");
  186. 	}
  187. 	else if (!strcmp(optname, "scroll_amount")) {
  188. 		if (iflags.wc_scroll_amount) Sprintf(buf, "%d",iflags.wc_scroll_amount);
  189. 		else Strcpy(buf, defopt);
  190. 	}
  191. 	else if (!strcmp(optname, "scroll_margin")) {
  192. 		if (iflags.wc_scroll_margin) Sprintf(buf, "%d",iflags.wc_scroll_margin);
  193. 		else Strcpy(buf, defopt);
  194. 	}
  195. 	else if (!strcmp(optname, "player_selection"))
  196. 		Sprintf(buf, "%s", iflags.wc_player_selection ? "prompts" : "dialog");
  197. #ifdef MSDOS
  198. 	else if (!strcmp(optname, "soundcard"))
  199. 		Sprintf(buf, "%s", to_be_done);
  200. #endif
  201. 	else if (!strcmp(optname, "suppress_alert")) {
  202. 	    if (flags.suppress_alert == 0L)
  203. 		Strcpy(buf, none);
  204. 	    else
  205. 		Sprintf(buf, "%lu.%lu.%lu",
  206. 			FEATURE_NOTICE_VER_MAJ,
  207. 			FEATURE_NOTICE_VER_MIN,
  208. 			FEATURE_NOTICE_VER_PATCH);
  209. 	}
  210. 	else if (!strcmp(optname, "tile_file"))
  211. 		Sprintf(buf, "%s", iflags.wc_tile_file ? iflags.wc_tile_file : defopt);
  212. 	else if (!strcmp(optname, "tile_height")) {
  213. 		if (iflags.wc_tile_height) Sprintf(buf, "%d",iflags.wc_tile_height);
  214. 		else Strcpy(buf, defopt);
  215. 	}
  216. 	else if (!strcmp(optname, "tile_width")) {
  217. 		if (iflags.wc_tile_width) Sprintf(buf, "%d",iflags.wc_tile_width);
  218. 		else Strcpy(buf, defopt);
  219. 	}
  220. 	else if (!strcmp(optname, "traps"))
  221. 		Sprintf(buf, "%s", to_be_done);
  222. 	else if (!strcmp(optname, "vary_msgcount")) {
  223. 		if (iflags.wc_vary_msgcount) Sprintf(buf, "%d",iflags.wc_vary_msgcount);
  224. 		else Strcpy(buf, defopt);
  225. 	}
  226. #ifdef MSDOS
  227. 	else if (!strcmp(optname, "video"))
  228. 		Sprintf(buf, "%s", to_be_done);
  229. #endif
  230. #ifdef VIDEOSHADES
  231. 	else if (!strcmp(optname, "videoshades"))
  232. 		Sprintf(buf, "%s-%s-%s", shade[0],shade[1],shade[2]);
  233. 	else if (!strcmp(optname, "videocolors"))
  234. 		Sprintf(buf, "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d",
  235. 			ttycolors[CLR_RED], ttycolors[CLR_GREEN],
  236. 			ttycolors[CLR_BROWN], ttycolors[CLR_BLUE],
  237. 			ttycolors[CLR_MAGENTA], ttycolors[CLR_CYAN],
  238. 			ttycolors[CLR_ORANGE], ttycolors[CLR_BRIGHT_GREEN],
  239. 			ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE],
  240. 			ttycolors[CLR_BRIGHT_MAGENTA],
  241. 			ttycolors[CLR_BRIGHT_CYAN]);
  242. #endif /* VIDEOSHADES */
  243. 	else if (!strcmp(optname, "windowtype"))
  244. 		Sprintf(buf, "%s", windowprocs.name);
  245. 	else if (!strcmp(optname, "windowcolors"))
  246. 		Sprintf(buf, "%s/%s %s/%s %s/%s %s/%s",
  247. 			iflags.wc_foregrnd_menu    ? iflags.wc_foregrnd_menu : defbrief,
  248. 			iflags.wc_backgrnd_menu    ? iflags.wc_backgrnd_menu : defbrief,
  249. 			iflags.wc_foregrnd_message ? iflags.wc_foregrnd_message : defbrief,
  250. 			iflags.wc_backgrnd_message ? iflags.wc_backgrnd_message : defbrief,
  251. 			iflags.wc_foregrnd_status  ? iflags.wc_foregrnd_status : defbrief,
  252. 			iflags.wc_backgrnd_status  ? iflags.wc_backgrnd_status : defbrief,
  253. 			iflags.wc_foregrnd_text    ? iflags.wc_foregrnd_text : defbrief,
  254. 			iflags.wc_backgrnd_text    ? iflags.wc_backgrnd_text : defbrief);
  255. #ifdef PREFIXES_IN_USE
  256. 	else {
  257. 	    for (i = 0; i < PREFIX_COUNT; ++i)
  258. 		if (!strcmp(optname, fqn_prefix_names[i]) && fqn_prefix[i])
  259. 			Sprintf(buf, "%s", fqn_prefix[i]);
  260. 	}
  261. #endif
  262.  
  263. 	if (buf[0]) return buf;
  264. 	else return "unknown";
  265. }

dotogglepickup[edit]

  1. int
  2. dotogglepickup()
  3. {
  4. 	char buf[BUFSZ], ocl[MAXOCLASSES+1];
  5.  
  6. 	flags.pickup = !flags.pickup;
  7. 	if (flags.pickup) {
  8. 	    oc_to_str(flags.pickup_types, ocl);
  9. 	    Sprintf(buf, "ON, for %s objects%s", ocl[0] ? ocl : "all",
  10. #ifdef AUTOPICKUP_EXCEPTIONS
  11. 			(iflags.autopickup_exceptions[AP_LEAVE] ||
  12. 			 iflags.autopickup_exceptions[AP_GRAB]) ?
  13. 			 ((count_ape_maps((int *)0, (int *)0) == 1) ?
  14. 			    ", with one exception" : ", with some exceptions") :
  15. #endif
  16. 			"");
  17. 	} else {
  18. 	    Strcpy(buf, "OFF");
  19. 	}
  20. 	pline("Autopickup: %s.", buf);
  21. 	return 0;
  22. }

add_autopickup_exception[edit]

  1. #ifdef AUTOPICKUP_EXCEPTIONS
  2. int
  3. add_autopickup_exception(mapping)
  4. const char *mapping;
  5. {
  6. 	struct autopickup_exception *ape, **apehead;
  7. 	char text[256], *text2;
  8. 	int textsize = 0;
  9. 	boolean grab = FALSE;
  10.  
  11. 	if (sscanf(mapping, "\"%255[^\"]\"", text) == 1) {
  12. 		text2 = &text[0];
  13. 		if (*text2 == '<') {		/* force autopickup */
  14. 			grab = TRUE;
  15. 			++text2;
  16. 		} else if (*text2 == '>') {	/* default - Do not pickup */
  17. 			grab = FALSE;
  18. 			++text2;
  19. 		}
  20. 		textsize = strlen(text2);
  21. 		apehead = (grab) ? &iflags.autopickup_exceptions[AP_GRAB] :
  22. 				   &iflags.autopickup_exceptions[AP_LEAVE];
  23. 		ape = (struct autopickup_exception *)
  24. 				alloc(sizeof(struct autopickup_exception));
  25. 		ape->pattern = (char *) alloc(textsize+1);
  26. 		Strcpy(ape->pattern, text2);
  27. 		ape->grab = grab;
  28. 		if (!*apehead) ape->next = (struct autopickup_exception *)0;
  29. 		else ape->next = *apehead;
  30. 		*apehead = ape;
  31. 	} else {
  32. 	    raw_print("syntax error in AUTOPICKUP_EXCEPTION");
  33. 	    return 0;
  34. 	}
  35. 	return 1;
  36. }

remove_autopickuo_exception[edit]

  1. STATIC_OVL void
  2. remove_autopickup_exception(whichape)
  3. struct autopickup_exception *whichape;
  4. {
  5. struct autopickup_exception *ape, *prev = 0;
  6. int chain = whichape->grab ? AP_GRAB : AP_LEAVE;
  7.  
  8. for (ape = iflags.autopickup_exceptions[chain]; ape;) {
  9. 	if (ape == whichape) {
  10. 	    struct autopickup_exception *freeape = ape;
  11. 	    ape = ape->next;
  12. 	    if (prev) prev->next = ape;
  13. 	    else iflags.autopickup_exceptions[chain] = ape;
  14. 	    free(freeape->pattern);
  15. 	    free(freeape);
  16. 	} else {
  17. 	    prev = ape;
  18. 	    ape = ape->next;
  19. 	}
  20. }
  21. }

count_ape_maps[edit]

  1. STATIC_OVL int
  2. count_ape_maps(leave, grab)
  3. int *leave, *grab;
  4. {
  5. 	struct autopickup_exception *ape;
  6. 	int pass, totalapes, numapes[2] = {0,0};
  7.  
  8. 	for (pass = AP_LEAVE; pass <= AP_GRAB; ++pass) {
  9. 		ape = iflags.autopickup_exceptions[pass];
  10. 		while(ape) {
  11. 			ape = ape->next;
  12. 			numapes[pass]++;
  13. 		}
  14. 	}
  15. 	totalapes = numapes[AP_LEAVE] + numapes[AP_GRAB];
  16. 	if (leave) *leave = numapes[AP_LEAVE];
  17. 	if (grab) *grab = numapes[AP_GRAB];
  18. 	return totalapes;
  19. }

free_autopickup_exceptions[edit]

  1. void
  2. free_autopickup_exceptions()
  3. {
  4. 	struct autopickup_exception *ape;
  5. 	int pass;
  6.  
  7. 	for (pass = AP_LEAVE; pass <= AP_GRAB; ++pass) {
  8. 		while((ape = iflags.autopickup_exceptions[pass]) != 0) {
  9. 			free(ape->pattern);
  10. 			iflags.autopickup_exceptions[pass] = ape->next;
  11. 			free(ape);
  12. 		}
  13. 	}
  14. }
  15. #endif /* AUTOPICKUP_EXCEPTIONS */

option_help[edit]

  1. /* data for option_help() */
  2. static const char *opt_intro[] = {
  3. 	"",
  4. 	"                 NetHack Options Help:",
  5. 	"",
  6. #define CONFIG_SLOT 3	/* fill in next value at run-time */
  7. 	(char *)0,
  8. #if !defined(MICRO) && !defined(MAC)
  9. 	"or use `NETHACKOPTIONS=\"<options>\"' in your environment",
  10. #endif
  11. 	"(<options> is a list of options separated by commas)",
  12. #ifdef VMS
  13. 	"-- for example, $ DEFINE NETHACKOPTIONS \"noautopickup,fruit:kumquat\"",
  14. #endif
  15. 	"or press \"O\" while playing and use the menu.",
  16. 	"",
  17. "Boolean options (which can be negated by prefixing them with '!' or \"no\"):",
  18. 	(char *)0
  19. };
  20.  
  21. static const char *opt_epilog[] = {
  22. 	"",
  23. "Some of the options can be set only before the game is started; those",
  24. 	"items will not be selectable in the 'O' command's menu.",
  25. 	(char *)0
  26. };
  27.  
  28. void
  29. option_help()
  30. {
  31. char buf[BUFSZ], buf2[BUFSZ];
  32. register int i;
  33. winid datawin;
  34.  
  35. datawin = create_nhwindow(NHW_TEXT);
  36. Sprintf(buf, "Set options as OPTIONS=<options> in %s", configfile);
  37. opt_intro[CONFIG_SLOT] = (const char *) buf;
  38. for (i = 0; opt_intro[i]; i++)
  39. 	putstr(datawin, 0, opt_intro[i]);
  40.  
  41. /* Boolean options */
  42. for (i = 0; boolopt[i].name; i++) {
  43. 	if (boolopt[i].addr) {
  44. #ifdef WIZARD
  45. 	    if (boolopt[i].addr == &iflags.sanity_check && !wizard) continue;
  46. 	    if (boolopt[i].addr == &iflags.menu_tab_sep && !wizard) continue;
  47. #endif
  48. 	    next_opt(datawin, boolopt[i].name);
  49. 	}
  50. }
  51. next_opt(datawin, "");
  52.  
  53. /* Compound options */
  54. putstr(datawin, 0, "Compound options:");
  55. for (i = 0; compopt[i].name; i++) {
  56. 	Sprintf(buf2, "`%s'", compopt[i].name);
  57. 	Sprintf(buf, "%-20s - %s%c", buf2, compopt[i].descr,
  58. 		compopt[i+1].name ? ',' : '.');
  59. 	putstr(datawin, 0, buf);
  60. }
  61.  
  62. for (i = 0; opt_epilog[i]; i++)
  63. 	putstr(datawin, 0, opt_epilog[i]);
  64.  
  65. display_nhwindow(datawin, FALSE);
  66. destroy_nhwindow(datawin);
  67. return;
  68. }

next_opt[edit]

  1. /*
  2. * prints the next boolean option, on the same line if possible, on a new
  3. * line if not. End with next_opt("").
  4. */
  5. void
  6. next_opt(datawin, str)
  7. winid datawin;
  8. const char *str;
  9. {
  10. 	static char *buf = 0;
  11. 	int i;
  12. 	char *s;
  13.  
  14. 	if (!buf) *(buf = (char *)alloc(BUFSZ)) = '\0';
  15.  
  16. 	if (!*str) {
  17. 		s = eos(buf);
  18. 		if (s > &buf[1] && s[-2] == ',')
  19. 		    Strcpy(s - 2, ".");	/* replace last ", " */
  20. 		i = COLNO;	/* (greater than COLNO - 2) */
  21. 	} else {
  22. 		i = strlen(buf) + strlen(str) + 2;
  23. 	}
  24.  
  25. 	if (i > COLNO - 2) { /* rule of thumb */
  26. 		putstr(datawin, 0, buf);
  27. 		buf[0] = 0;
  28. 	}
  29. 	if (*str) {
  30. 		Strcat(buf, str);
  31. 		Strcat(buf, ", ");
  32. 	} else {
  33. 		putstr(datawin, 0, str);
  34. 		free(buf),  buf = 0;
  35. 	}
  36. 	return;
  37. }

fruitadd[edit]

  1. /* Returns the fid of the fruit type; if that type already exists, it
  2. * returns the fid of that one; if it does not exist, it adds a new fruit
  3. * type to the chain and returns the new one.
  4. */
  5. int
  6. fruitadd(str)
  7. char *str;
  8. {
  9. 	register int i;
  10. 	register struct fruit *f;
  11. 	struct fruit *lastf = 0;
  12. 	int highest_fruit_id = 0;
  13. 	char buf[PL_FSIZ];
  14. 	boolean user_specified = (str == pl_fruit);
  15. 	/* if not user-specified, then it's a fruit name for a fruit on
  16. 	 * a bones level...
  17. 	 */
  18.  
  19. 	/* Note: every fruit has an id (spe for fruit objects) of at least
  20. 	 * 1; 0 is an error.
  21. 	 */
  22. 	if (user_specified) {
  23. 		/* disallow naming after other foods (since it'd be impossible
  24. 		 * to tell the difference)
  25. 		 */
  26.  
  27. 		boolean found = FALSE, numeric = FALSE;
  28.  
  29. 		for (i = bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS;
  30. 						i++) {
  31. 			if (!strcmp(OBJ_NAME(objects[i]), pl_fruit)) {
  32. 				found = TRUE;
  33. 				break;
  34. 			}
  35. 		}
  36. 		{
  37. 		    char *c;
  38.  
  39. 		    c = pl_fruit;
  40.  
  41. 		    for(c = pl_fruit; *c >= '0' && *c <= '9'; c++)
  42. 			;
  43. 		    if (isspace(*c) || *c == 0) numeric = TRUE;
  44. 		}
  45. 		if (found || numeric ||
  46. 		    !strncmp(str, "cursed ", 7) ||
  47. 		    !strncmp(str, "uncursed ", 9) ||
  48. 		    !strncmp(str, "blessed ", 8) ||
  49. 		    !strncmp(str, "partly eaten ", 13) ||
  50. 		    (!strncmp(str, "tin of ", 7) &&
  51. 			(!strcmp(str+7, "spinach") ||
  52. 			 name_to_mon(str+7) >= LOW_PM)) ||
  53. 		    !strcmp(str, "empty tin") ||
  54. 		    ((!strncmp(eos(str)-7," corpse",7) ||
  55. 			    !strncmp(eos(str)-4, " egg",4)) &&
  56. 			name_to_mon(str) >= LOW_PM))
  57. 			{
  58. 				Strcpy(buf, pl_fruit);
  59. 				Strcpy(pl_fruit, "candied ");
  60. 				nmcpy(pl_fruit+8, buf, PL_FSIZ-8);
  61. 		}
  62. 	}
  63. 	for(f=ffruit; f; f = f->nextf) {
  64. 		lastf = f;
  65. 		if(f->fid > highest_fruit_id) highest_fruit_id = f->fid;
  66. 		if(!strncmp(str, f->fname, PL_FSIZ))
  67. 			goto nonew;
  68. 	}
  69. 	/* if adding another fruit would overflow spe, use a random
  70. 	   fruit instead... we've got a lot to choose from. */
  71. 	if (highest_fruit_id >= 127) return rnd(127);
  72. 	highest_fruit_id++;
  73. 	f = newfruit();
  74. 	if (ffruit) lastf->nextf = f;
  75. 	else ffruit = f;
  76. 	Strcpy(f->fname, str);
  77. 	f->fid = highest_fruit_id;
  78. 	f->nextf = 0;
  79. nonew:
  80. 	if (user_specified) current_fruit = highest_fruit_id;
  81. 	return f->fid;
  82. }

choose_classes_menu[edit]

  1. /*
  2. * This is a somewhat generic menu for taking a list of NetHack style
  3. * class choices and presenting them via a description
  4. * rather than the traditional NetHack characters.
  5. * (Benefits users whose first exposure to NetHack is via tiles).
  6. *
  7. * prompt
  8. *	     The title at the top of the menu.
  9. *
  10. * category: 0 = monster class
  11. *           1 = object  class
  12. *
  13. * way
  14. *	     FALSE = PICK_ONE, TRUE = PICK_ANY
  15. *
  16. * class_list
  17. *	     a null terminated string containing the list of choices.
  18. *
  19. * class_selection
  20. *	     a null terminated string containing the selected characters.
  21. *
  22. * Returns number selected.
  23. */
  24. int
  25. choose_classes_menu(prompt, category, way, class_list, class_select)
  26. const char *prompt;
  27. int category;
  28. boolean way;
  29. char *class_list;
  30. char *class_select;
  31. {
  32. menu_item *pick_list = (menu_item *)0;
  33. winid win;
  34. anything any;
  35. char buf[BUFSZ];
  36. int i, n;
  37. int ret;
  38. int next_accelerator, accelerator;
  39.  
  40. if (class_list == (char *)0 || class_select == (char *)0) return 0;
  41. accelerator = 0;
  42. next_accelerator = 'a';
  43. any.a_void = 0;
  44. win = create_nhwindow(NHW_MENU);
  45. start_menu(win);
  46. while (*class_list) {
  47. 	const char *text;
  48. 	boolean selected;
  49.  
  50. 	text = (char *)0;
  51. 	selected = FALSE;
  52. 	switch (category) {
  53. 		case 0:
  54. 			text = monexplain[def_char_to_monclass(*class_list)];
  55. 			accelerator = *class_list;
  56. 			Sprintf(buf, "%s", text);
  57. 			break;
  58. 		case 1:
  59. 			text = objexplain[def_char_to_objclass(*class_list)];
  60. 			accelerator = next_accelerator;
  61. 			Sprintf(buf, "%c  %s", *class_list, text);
  62. 			break;
  63. 		default:
  64. 			impossible("choose_classes_menu: invalid category %d",
  65. 					category);
  66. 	}
  67. 	if (way && *class_select) {	/* Selections there already */
  68. 		if (index(class_select, *class_list)) {
  69. 			selected = TRUE;
  70. 		}
  71. 	}
  72. 	any.a_int = *class_list;
  73. 	add_menu(win, NO_GLYPH, &any, accelerator,
  74. 		  category ? *class_list : 0,
  75. 		  ATR_NONE, buf, selected);
  76. 	++class_list;
  77. 	if (category > 0) {
  78. 		++next_accelerator;
  79. 		if (next_accelerator == ('z' + 1)) next_accelerator = 'A';
  80. 		if (next_accelerator == ('Z' + 1)) break;
  81. 	}
  82. }
  83. end_menu(win, prompt);
  84. n = select_menu(win, way ? PICK_ANY : PICK_ONE, &pick_list);
  85. destroy_nhwindow(win);
  86. if (n > 0) {
  87. 	for (i = 0; i < n; ++i)
  88. 	    *class_select++ = (char)pick_list[i].item.a_int;
  89. 	free((genericptr_t)pick_list);
  90. 	ret = n;
  91. } else if (n == -1) {
  92. 	class_select = eos(class_select);
  93. 	ret = -1;
  94. } else
  95. 	ret = 0;
  96. *class_select = '\0';
  97. return ret;
  98. }
  1. struct wc_Opt wc_options[] = {
  2. 	{"ascii_map", WC_ASCII_MAP},
  3. 	{"color", WC_COLOR},
  4. 	{"eight_bit_tty", WC_EIGHT_BIT_IN},
  5. 	{"hilite_pet", WC_HILITE_PET},
  6. 	{"popup_dialog", WC_POPUP_DIALOG},
  7. 	{"player_selection", WC_PLAYER_SELECTION},
  8. 	{"preload_tiles", WC_PRELOAD_TILES},
  9. 	{"tiled_map", WC_TILED_MAP},
  10. 	{"tile_file", WC_TILE_FILE},
  11. 	{"tile_width", WC_TILE_WIDTH},
  12. 	{"tile_height", WC_TILE_HEIGHT},
  13. 	{"use_inverse", WC_INVERSE},
  14. 	{"align_message", WC_ALIGN_MESSAGE},
  15. 	{"align_status", WC_ALIGN_STATUS},
  16. 	{"font_map", WC_FONT_MAP},
  17. 	{"font_menu", WC_FONT_MENU},
  18. 	{"font_message",WC_FONT_MESSAGE},
  19. #if 0
  20. 	{"perm_invent",WC_PERM_INVENT},
  21. #endif
  22. 	{"font_size_map", WC_FONTSIZ_MAP},
  23. 	{"font_size_menu", WC_FONTSIZ_MENU},
  24. 	{"font_size_message", WC_FONTSIZ_MESSAGE},
  25. 	{"font_size_status", WC_FONTSIZ_STATUS},
  26. 	{"font_size_text", WC_FONTSIZ_TEXT},
  27. 	{"font_status", WC_FONT_STATUS},
  28. 	{"font_text", WC_FONT_TEXT},
  29. 	{"map_mode", WC_MAP_MODE},
  30. 	{"scroll_amount", WC_SCROLL_AMOUNT},
  31. 	{"scroll_margin", WC_SCROLL_MARGIN},
  32. 	{"splash_screen", WC_SPLASH_SCREEN},
  33. 	{"vary_msgcount",WC_VARY_MSGCOUNT},
  34. 	{"windowcolors", WC_WINDOWCOLORS},
  35. 	{"mouse_support", WC_MOUSE_SUPPORT},
  36. 	{(char *)0, 0L}
  37. };
  38.  
  39. struct wc_Opt wc2_options[] = {
  40. 	{"fullscreen", WC2_FULLSCREEN},
  41. 	{"softkeyboard", WC2_SOFTKEYBOARD},
  42. 	{"wraptext", WC2_WRAPTEXT},
  43. 	{(char *)0, 0L}
  44. };

set_option_mod_status[edit]

  1. /*
  2. * If a port wants to change or ensure that the
  3. * SET_IN_FILE, DISP_IN_GAME, or SET_IN_GAME status of an option is
  4. * correct (for controlling its display in the option menu) call
  5. * set_option_mod_status()
  6. * with the second argument of 0,2, or 3 respectively.
  7. */
  8. void
  9. set_option_mod_status(optnam, status)
  10. const char *optnam;
  11. int status;
  12. {
  13. 	int k;
  14. 	if (status < SET_IN_FILE || status > SET_IN_GAME) {
  15. 		impossible("set_option_mod_status: status out of range %d.",
  16. 			   status);
  17. 		return;
  18. 	}
  19. 	for (k = 0; boolopt[k].name; k++) {
  20. 		if (!strncmpi(boolopt[k].name, optnam, strlen(optnam))) {
  21. 			boolopt[k].optflags = status;
  22. 			return;
  23. 		}
  24. 	}
  25. 	for (k = 0; compopt[k].name; k++) {
  26. 		if (!strncmpi(compopt[k].name, optnam, strlen(optnam))) {
  27. 			compopt[k].optflags = status;
  28. 			return;
  29. 		}
  30. 	}
  31. }

set_wc_option_mod_status[edit]

  1. /*
  2. * You can set several wc_options in one call to
  3. * set_wc_option_mod_status() by setting
  4. * the appropriate bits for each option that you
  5. * are setting in the optmask argument
  6. * prior to calling.
  7. *    example: set_wc_option_mod_status(WC_COLOR|WC_SCROLL_MARGIN, SET_IN_GAME);
  8. */
  9. void
  10. set_wc_option_mod_status(optmask, status)
  11. unsigned long optmask;
  12. int status;
  13. {
  14. 	int k = 0;
  15. 	if (status < SET_IN_FILE || status > SET_IN_GAME) {
  16. 		impossible("set_wc_option_mod_status: status out of range %d.",
  17. 			   status);
  18. 		return;
  19. 	}
  20. 	while (wc_options[k].wc_name) {
  21. 		if (optmask & wc_options[k].wc_bit) {
  22. 			set_option_mod_status(wc_options[k].wc_name, status);
  23. 		}
  24. 		k++;
  25. 	}
  26. }

is_wc_option[edit]

  1. STATIC_OVL boolean
  2. is_wc_option(optnam)
  3. const char *optnam;
  4. {
  5. 	int k = 0;
  6. 	while (wc_options[k].wc_name) {
  7. 		if (strcmp(wc_options[k].wc_name, optnam) == 0)
  8. 			return TRUE;
  9. 		k++;
  10. 	}
  11. 	return FALSE;
  12. }

wc_supported[edit]

  1. STATIC_OVL boolean
  2. wc_supported(optnam)
  3. const char *optnam;
  4. {
  5. 	int k = 0;
  6. 	while (wc_options[k].wc_name) {
  7. 		if (!strcmp(wc_options[k].wc_name, optnam) &&
  8. 		    (windowprocs.wincap & wc_options[k].wc_bit))
  9. 			return TRUE;
  10. 		k++;
  11. 	}
  12. 	return FALSE;
  13. }

set_wc2_option_mod_status[edit]

  1. /*
  2. * You can set several wc2_options in one call to
  3. * set_wc2_option_mod_status() by setting
  4. * the appropriate bits for each option that you
  5. * are setting in the optmask argument
  6. * prior to calling.
  7. *    example: set_wc2_option_mod_status(WC2_FULLSCREEN|WC2_SOFTKEYBOARD|WC2_WRAPTEXT, SET_IN_FILE);
  8. */
  9.  
  10. void
  11. set_wc2_option_mod_status(optmask, status)
  12. unsigned long optmask;
  13. int status;
  14. {
  15. 	int k = 0;
  16. 	if (status < SET_IN_FILE || status > SET_IN_GAME) {
  17. 		impossible("set_wc2_option_mod_status: status out of range %d.",
  18. 			   status);
  19. 		return;
  20. 	}
  21. 	while (wc2_options[k].wc_name) {
  22. 		if (optmask & wc2_options[k].wc_bit) {
  23. 			set_option_mod_status(wc2_options[k].wc_name, status);
  24. 		}
  25. 		k++;
  26. 	}
  27. }

is_wc2_option[edit]

  1. STATIC_OVL boolean
  2. is_wc2_option(optnam)
  3. const char *optnam;
  4. {
  5. 	int k = 0;
  6. 	while (wc2_options[k].wc_name) {
  7. 		if (strcmp(wc2_options[k].wc_name, optnam) == 0)
  8. 			return TRUE;
  9. 		k++;
  10. 	}
  11. 	return FALSE;
  12. }

wc2_supported[edit]

  1. STATIC_OVL boolean
  2. wc2_supported(optnam)
  3. const char *optnam;
  4. {
  5. 	int k = 0;
  6. 	while (wc2_options[k].wc_name) {
  7. 		if (!strcmp(wc2_options[k].wc_name, optnam) &&
  8. 		    (windowprocs.wincap2 & wc2_options[k].wc_bit))
  9. 			return TRUE;
  10. 		k++;
  11. 	}
  12. 	return FALSE;
  13. }

wc_set_font_name[edit]

  1. STATIC_OVL void
  2. wc_set_font_name(wtype, fontname)
  3. int wtype;
  4. char *fontname;
  5. {
  6. 	char **fn = (char **)0;
  7. 	if (!fontname) return;
  8. 	switch(wtype) {
  9. 	    case NHW_MAP:
  10. 	    		fn = &iflags.wc_font_map;
  11. 			break;
  12. 	    case NHW_MESSAGE:
  13. 	    		fn = &iflags.wc_font_message;
  14. 			break;
  15. 	    case NHW_TEXT:
  16. 	    		fn = &iflags.wc_font_text;
  17. 			break;
  18. 	    case NHW_MENU:
  19. 	    		fn = &iflags.wc_font_menu;
  20. 			break;
  21. 	    case NHW_STATUS:
  22. 	    		fn = &iflags.wc_font_status;
  23. 			break;
  24. 	    default:
  25. 	    		return;
  26. 	}
  27. 	if (fn) {
  28. 		if (*fn) free(*fn);
  29. 		*fn = (char *)alloc(strlen(fontname) + 1);
  30. 		Strcpy(*fn, fontname);
  31. 	}
  32. 	return;
  33. }

wc_set_window_colors[edit]

  1. STATIC_OVL int
  2. wc_set_window_colors(op)
  3. char *op;
  4. {
  5. 	/* syntax:
  6. 	 *  menu white/black message green/yellow status white/blue text white/black
  7. 	 */
  8.  
  9. 	int j;
  10. 	char buf[BUFSZ];
  11. 	char *wn, *tfg, *tbg, *newop;
  12. 	static const char *wnames[] = { "menu", "message", "status", "text" };
  13. 	static const char *shortnames[] = { "mnu", "msg", "sts", "txt" };
  14. 	static char **fgp[] = {
  15. 		&iflags.wc_foregrnd_menu,
  16. 		&iflags.wc_foregrnd_message,
  17. 		&iflags.wc_foregrnd_status,
  18. 		&iflags.wc_foregrnd_text
  19. 	};
  20. 	static char **bgp[] = {
  21. 		&iflags.wc_backgrnd_menu,
  22. 		&iflags.wc_backgrnd_message,
  23. 		&iflags.wc_backgrnd_status,
  24. 		&iflags.wc_backgrnd_text
  25. 	};
  26.  
  27. 	Strcpy(buf, op);
  28. 	newop = mungspaces(buf);
  29. 	while (newop && *newop) {
  30.  
  31. 		wn = tfg = tbg = (char *)0;
  32.  
  33. 		/* until first non-space in case there's leading spaces - before colorname*/
  34. 		while(*newop && isspace(*newop)) newop++;
  35. 		if (*newop) wn = newop;
  36. 		else return 0;
  37.  
  38. 		/* until first space - colorname*/
  39. 		while(*newop && !isspace(*newop)) newop++;
  40. 		if (*newop) *newop = '\0';
  41. 		else return 0;
  42. 		newop++;
  43.  
  44. 		/* until first non-space - before foreground*/
  45. 		while(*newop && isspace(*newop)) newop++;
  46. 		if (*newop) tfg = newop;
  47. 		else return 0;
  48.  
  49. 		/* until slash - foreground */
  50. 		while(*newop && *newop != '/') newop++;
  51. 		if (*newop) *newop = '\0';
  52. 		else return 0;
  53. 		newop++;
  54.  
  55. 		/* until first non-space (in case there's leading space after slash) - before background */
  56. 		while(*newop && isspace(*newop)) newop++;
  57. 		if (*newop) tbg = newop;
  58. 		else return 0;
  59.  
  60. 		/* until first space - background */
  61. 		while(*newop && !isspace(*newop)) newop++;
  62. 		if (*newop) *newop++ = '\0';
  63.  
  64. 		for (j = 0; j < 4; ++j) {
  65. 			if (!strcmpi(wn, wnames[j]) ||
  66. 			    !strcmpi(wn, shortnames[j])) {
  67. 				if (tfg && !strstri(tfg, " ")) {
  68. 					if (*fgp[j]) free(*fgp[j]);
  69. 					*fgp[j] = (char *)alloc(strlen(tfg) + 1);
  70. 					Strcpy(*fgp[j], tfg);
  71. 				}
  72. 				if (tbg && !strstri(tbg, " ")) {
  73. 					if (*bgp[j]) free(*bgp[j]);
  74. 					*bgp[j] = (char *)alloc(strlen(tbg) + 1);
  75. 					Strcpy(*bgp[j], tbg);
  76. 				}
  77. 				break;
  78. 			}
  79. 		}
  80. 	}
  81. 	return 1;
  82. }
  83.  
  84. #endif	/* OPTION_LISTS_ONLY */
  85.  
  86. /*options.c*/