Source:NetHack 3.6.3/src/options.c
Jump to navigation
Jump to search
Below is the full text to options.c from the source code of NetHack 3.6.3. To link to a particular line, write [[Source:NetHack 3.6.3/src/options.c#line12]], for example.
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. /* NetHack 3.6 options.c $NHDT-Date: 1575245078 2019/12/02 00:04:38 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.391 $ */ 2. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3. /*-Copyright (c) Michael Allison, 2008. */ 4. /* NetHack may be freely redistributed. See license for details. */ 5. 6. #ifdef OPTION_LISTS_ONLY /* (AMIGA) external program for opt lists */ 7. #include "config.h" 8. #include "objclass.h" 9. #include "flag.h" 10. NEARDATA struct flag flags; /* provide linkage */ 11. #ifdef SYSFLAGS 12. NEARDATA struct sysflag sysflags; /* provide linkage */ 13. #endif 14. NEARDATA struct instance_flags iflags; /* provide linkage */ 15. #define static 16. #else 17. #include "hack.h" 18. #include "tcap.h" 19. #include <ctype.h> 20. #endif 21. 22. #define BACKWARD_COMPAT 23. 24. #ifdef DEFAULT_WC_TILED_MAP 25. #define PREFER_TILED TRUE 26. #else 27. #define PREFER_TILED FALSE 28. #endif 29. 30. #ifdef CURSES_GRAPHICS 31. extern int curses_read_attrs(const char *attrs); 32. extern char *curses_fmt_attrs(char *); 33. #endif 34. 35. enum window_option_types { 36. MESSAGE_OPTION = 1, 37. STATUS_OPTION, 38. MAP_OPTION, 39. MENU_OPTION, 40. TEXT_OPTION 41. }; 42. 43. #define PILE_LIMIT_DFLT 5 44. 45. /* 46. * NOTE: If you add (or delete) an option, please update the short 47. * options help (option_help()), the long options help (dat/opthelp), 48. * and the current options setting display function (doset()), 49. * and also the Guidebooks. 50. * 51. * The order matters. If an option is a an initial substring of another 52. * option (e.g. time and timed_delay) the shorter one must come first. 53. */ 54. 55. static struct Bool_Opt { 56. const char *name; 57. boolean *addr, initvalue; 58. int optflags; 59. } boolopt[] = { 60. { "acoustics", &flags.acoustics, TRUE, SET_IN_GAME }, 61. #if defined(SYSFLAGS) && defined(AMIGA) 62. /* Amiga altmeta causes Alt+key to be converted into Meta+key by 63. low level nethack code; on by default, can be toggled off if 64. Alt+key is needed for some ASCII chars on non-ASCII keyboard */ 65. { "altmeta", &sysflags.altmeta, TRUE, DISP_IN_GAME }, 66. #else 67. #ifdef ALTMETA 68. /* non-Amiga altmeta causes nethack's top level command loop to treat 69. two character sequence "ESC c" as M-c, for terminals or emulators 70. which send "ESC c" when Alt+c is pressed; off by default, enabling 71. this can potentially make trouble if user types ESC when nethack 72. is honoring this conversion request (primarily after starting a 73. count prefix prior to a command and then deciding to cancel it) */ 74. { "altmeta", &iflags.altmeta, FALSE, SET_IN_GAME }, 75. #else 76. { "altmeta", (boolean *) 0, TRUE, DISP_IN_GAME }, 77. #endif 78. #endif 79. { "ascii_map", &iflags.wc_ascii_map, !PREFER_TILED, SET_IN_GAME }, /*WC*/ 80. #if defined(SYSFLAGS) && defined(MFLOPPY) 81. { "asksavedisk", &sysflags.asksavedisk, FALSE, SET_IN_GAME }, 82. #else 83. { "asksavedisk", (boolean *) 0, FALSE, SET_IN_FILE }, 84. #endif 85. { "autodescribe", &iflags.autodescribe, TRUE, SET_IN_GAME }, 86. { "autodig", &flags.autodig, FALSE, SET_IN_GAME }, 87. { "autoopen", &flags.autoopen, TRUE, SET_IN_GAME }, 88. { "autopickup", &flags.pickup, TRUE, SET_IN_GAME }, 89. { "autoquiver", &flags.autoquiver, FALSE, SET_IN_GAME }, 90. #if defined(MICRO) && !defined(AMIGA) 91. { "BIOS", &iflags.BIOS, FALSE, SET_IN_FILE }, 92. #else 93. { "BIOS", (boolean *) 0, FALSE, SET_IN_FILE }, 94. #endif 95. { "blind", &u.uroleplay.blind, FALSE, DISP_IN_GAME }, 96. { "bones", &flags.bones, TRUE, SET_IN_FILE }, 97. #ifdef INSURANCE 98. { "checkpoint", &flags.ins_chkpt, TRUE, SET_IN_GAME }, 99. #else 100. { "checkpoint", (boolean *) 0, FALSE, SET_IN_FILE }, 101. #endif 102. #ifdef MFLOPPY 103. { "checkspace", &iflags.checkspace, TRUE, SET_IN_GAME }, 104. #else 105. { "checkspace", (boolean *) 0, FALSE, SET_IN_FILE }, 106. #endif 107. { "clicklook", &iflags.clicklook, FALSE, SET_IN_GAME }, 108. { "cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME }, 109. #if defined(MICRO) || defined(WIN32) || defined(CURSES_GRAPHICS) 110. { "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /* on/off: use WC or not */ 111. #else /* systems that support multiple terminals, many monochrome */ 112. { "color", &iflags.wc_color, FALSE, SET_IN_GAME }, 113. #endif 114. { "confirm", &flags.confirm, TRUE, SET_IN_GAME }, 115. { "dark_room", &flags.dark_room, TRUE, SET_IN_GAME }, 116. { "eight_bit_tty", &iflags.wc_eight_bit_input, FALSE, SET_IN_GAME }, /*WC*/ 117. #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) || defined(X11_GRAPHICS) 118. { "extmenu", &iflags.extmenu, FALSE, SET_IN_GAME }, 119. #else 120. { "extmenu", (boolean *) 0, FALSE, SET_IN_FILE }, 121. #endif 122. #ifdef OPT_DISPMAP 123. { "fast_map", &flags.fast_map, TRUE, SET_IN_GAME }, 124. #else 125. { "fast_map", (boolean *) 0, TRUE, SET_IN_FILE }, 126. #endif 127. { "female", &flags.female, FALSE, DISP_IN_GAME }, 128. { "fixinv", &flags.invlet_constant, TRUE, SET_IN_GAME }, 129. #if defined(SYSFLAGS) && defined(AMIFLUSH) 130. { "flush", &sysflags.amiflush, FALSE, SET_IN_GAME }, 131. #else 132. { "flush", (boolean *) 0, FALSE, SET_IN_FILE }, 133. #endif 134. { "force_invmenu", &iflags.force_invmenu, FALSE, SET_IN_GAME }, 135. { "fullscreen", &iflags.wc2_fullscreen, FALSE, SET_IN_FILE }, /*WC2*/ 136. { "goldX", &iflags.goldX, FALSE, SET_IN_GAME }, 137. { "guicolor", &iflags.wc2_guicolor, TRUE, SET_IN_GAME}, /*WC2*/ 138. { "help", &flags.help, TRUE, SET_IN_GAME }, 139. { "herecmd_menu", &iflags.herecmd_menu, FALSE, SET_IN_GAME }, 140. { "hilite_pet", &iflags.wc_hilite_pet, FALSE, SET_IN_GAME }, /*WC*/ 141. { "hilite_pile", &iflags.hilite_pile, FALSE, SET_IN_GAME }, 142. { "hitpointbar", &iflags.wc2_hitpointbar, FALSE, SET_IN_GAME }, /*WC2*/ 143. #ifndef MAC 144. { "ignintr", &flags.ignintr, FALSE, SET_IN_GAME }, 145. #else 146. { "ignintr", (boolean *) 0, FALSE, SET_IN_FILE }, 147. #endif 148. { "implicit_uncursed", &iflags.implicit_uncursed, TRUE, SET_IN_GAME }, 149. { "large_font", &iflags.obsolete, FALSE, SET_IN_FILE }, /* OBSOLETE */ 150. { "legacy", &flags.legacy, TRUE, DISP_IN_GAME }, 151. { "lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME }, 152. { "lootabc", &flags.lootabc, FALSE, SET_IN_GAME }, 153. #ifdef MAIL 154. { "mail", &flags.biff, TRUE, SET_IN_GAME }, 155. #else 156. { "mail", (boolean *) 0, TRUE, SET_IN_FILE }, 157. #endif 158. { "mention_walls", &iflags.mention_walls, FALSE, SET_IN_GAME }, 159. { "menucolors", &iflags.use_menu_color, FALSE, SET_IN_GAME }, 160. /* for menu debugging only*/ 161. { "menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_WIZGAME }, 162. { "menu_objsyms", &iflags.menu_head_objsym, FALSE, SET_IN_GAME }, 163. #ifdef TTY_GRAPHICS 164. { "menu_overlay", &iflags.menu_overlay, TRUE, SET_IN_GAME }, 165. #else 166. { "menu_overlay", (boolean *) 0, FALSE, SET_IN_FILE }, 167. #endif 168. { "monpolycontrol", &iflags.mon_polycontrol, FALSE, SET_IN_WIZGAME }, 169. #ifdef NEWS 170. { "news", &iflags.news, TRUE, DISP_IN_GAME }, 171. #else 172. { "news", (boolean *) 0, FALSE, SET_IN_FILE }, 173. #endif 174. { "nudist", &u.uroleplay.nudist, FALSE, DISP_IN_GAME }, 175. { "null", &flags.null, TRUE, SET_IN_GAME }, 176. #if defined(SYSFLAGS) && defined(MAC) 177. { "page_wait", &sysflags.page_wait, TRUE, SET_IN_GAME }, 178. #else 179. { "page_wait", (boolean *) 0, FALSE, SET_IN_FILE }, 180. #endif 181. /* moved perm_invent from flags to iflags and out of save file in 3.6.2 */ 182. { "perm_invent", &iflags.perm_invent, FALSE, SET_IN_GAME }, 183. { "pickup_thrown", &flags.pickup_thrown, TRUE, SET_IN_GAME }, 184. { "popup_dialog", &iflags.wc_popup_dialog, FALSE, SET_IN_GAME }, /*WC*/ 185. { "preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME }, /*WC*/ 186. { "pushweapon", &flags.pushweapon, FALSE, SET_IN_GAME }, 187. #if defined(MICRO) && !defined(AMIGA) 188. { "rawio", &iflags.rawio, FALSE, DISP_IN_GAME }, 189. #else 190. { "rawio", (boolean *) 0, FALSE, SET_IN_FILE }, 191. #endif 192. { "rest_on_space", &flags.rest_on_space, FALSE, SET_IN_GAME }, 193. #ifdef RLECOMP 194. { "rlecomp", &iflags.rlecomp, 195. #if defined(COMPRESS) || defined(ZLIB_COMP) 196. FALSE, 197. #else 198. TRUE, 199. #endif 200. DISP_IN_GAME }, 201. #endif 202. { "safe_pet", &flags.safe_dog, TRUE, SET_IN_GAME }, 203. { "sanity_check", &iflags.sanity_check, FALSE, SET_IN_WIZGAME }, 204. { "selectsaved", &iflags.wc2_selectsaved, TRUE, DISP_IN_GAME }, /*WC*/ 205. { "showexp", &flags.showexp, FALSE, SET_IN_GAME }, 206. { "showrace", &flags.showrace, FALSE, SET_IN_GAME }, 207. #ifdef SCORE_ON_BOTL 208. { "showscore", &flags.showscore, FALSE, SET_IN_GAME }, 209. #else 210. { "showscore", (boolean *) 0, FALSE, SET_IN_FILE }, 211. #endif 212. { "silent", &flags.silent, TRUE, SET_IN_GAME }, 213. { "softkeyboard", &iflags.wc2_softkeyboard, FALSE, SET_IN_FILE }, /*WC2*/ 214. { "sortpack", &flags.sortpack, TRUE, SET_IN_GAME }, 215. { "sparkle", &flags.sparkle, TRUE, SET_IN_GAME }, 216. { "splash_screen", &iflags.wc_splash_screen, TRUE, DISP_IN_GAME }, /*WC*/ 217. { "standout", &flags.standout, FALSE, SET_IN_GAME }, 218. { "status_updates", &iflags.status_updates, TRUE, DISP_IN_GAME }, 219. { "tiled_map", &iflags.wc_tiled_map, PREFER_TILED, DISP_IN_GAME }, /*WC*/ 220. { "time", &flags.time, FALSE, SET_IN_GAME }, 221. #ifdef TIMED_DELAY 222. { "timed_delay", &flags.nap, TRUE, SET_IN_GAME }, 223. #else 224. { "timed_delay", (boolean *) 0, FALSE, SET_IN_GAME }, 225. #endif 226. { "tombstone", &flags.tombstone, TRUE, SET_IN_GAME }, 227. { "toptenwin", &iflags.toptenwin, FALSE, SET_IN_GAME }, 228. { "travel", &flags.travelcmd, TRUE, SET_IN_GAME }, 229. #ifdef DEBUG 230. { "travel_debug", &iflags.trav_debug, FALSE, SET_IN_WIZGAME }, /*hack.c*/ 231. #endif 232. { "use_darkgray", &iflags.wc2_darkgray, TRUE, SET_IN_FILE }, /*WC2*/ 233. #ifdef WIN32 234. { "use_inverse", &iflags.wc_inverse, TRUE, SET_IN_GAME }, /*WC*/ 235. #else 236. { "use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME }, /*WC*/ 237. #endif 238. { "verbose", &flags.verbose, TRUE, SET_IN_GAME }, 239. #ifdef TTY_TILES_ESCCODES 240. { "vt_tiledata", &iflags.vt_tiledata, FALSE, SET_IN_FILE }, 241. #else 242. { "vt_tiledata", (boolean *) 0, FALSE, SET_IN_FILE }, 243. #endif 244. { "whatis_menu", &iflags.getloc_usemenu, FALSE, SET_IN_GAME }, 245. { "whatis_moveskip", &iflags.getloc_moveskip, FALSE, SET_IN_GAME }, 246. { "wizweight", &iflags.wizweight, FALSE, SET_IN_WIZGAME }, 247. { "wraptext", &iflags.wc2_wraptext, FALSE, SET_IN_GAME }, /*WC2*/ 248. #ifdef ZEROCOMP 249. { "zerocomp", &iflags.zerocomp, 250. #if defined(COMPRESS) || defined(ZLIB_COMP) 251. FALSE, 252. #else 253. TRUE, 254. #endif 255. DISP_IN_GAME }, 256. #endif 257. { (char *) 0, (boolean *) 0, FALSE, 0 } 258. }; 259. 260. /* compound options, for option_help() and external programs like Amiga 261. * frontend */ 262. static struct Comp_Opt { 263. const char *name, *descr; 264. int size; /* for frontends and such allocating space -- 265. * usually allowed size of data in game, but 266. * occasionally maximum reasonable size for 267. * typing when game maintains information in 268. * a different format */ 269. int optflags; 270. } compopt[] = { 271. { "align", "your starting alignment (lawful, neutral, or chaotic)", 8, 272. DISP_IN_GAME }, 273. { "align_message", "message window alignment", 20, DISP_IN_GAME }, /*WC*/ 274. { "align_status", "status window alignment", 20, DISP_IN_GAME }, /*WC*/ 275. { "altkeyhandler", "alternate key handler", 20, SET_IN_GAME }, 276. #ifdef BACKWARD_COMPAT 277. { "boulder", "deprecated (use S_boulder in sym file instead)", 1, 278. SET_IN_GAME }, 279. #endif 280. { "catname", "the name of your (first) cat (e.g., catname:Tabby)", 281. PL_PSIZ, DISP_IN_GAME }, 282. { "disclose", "the kinds of information to disclose at end of game", 283. sizeof flags.end_disclose * 2, SET_IN_GAME }, 284. { "dogname", "the name of your (first) dog (e.g., dogname:Fang)", PL_PSIZ, 285. DISP_IN_GAME }, 286. { "dungeon", "the symbols to use in drawing the dungeon map", 287. MAXDCHARS + 1, SET_IN_FILE }, 288. { "effects", "the symbols to use in drawing special effects", 289. MAXECHARS + 1, SET_IN_FILE }, 290. { "font_map", "the font to use in the map window", 40, 291. DISP_IN_GAME }, /*WC*/ 292. { "font_menu", "the font to use in menus", 40, DISP_IN_GAME }, /*WC*/ 293. { "font_message", "the font to use in the message window", 40, 294. DISP_IN_GAME }, /*WC*/ 295. { "font_size_map", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/ 296. { "font_size_menu", "the size of the menu font", 20, 297. DISP_IN_GAME }, /*WC*/ 298. { "font_size_message", "the size of the message font", 20, 299. DISP_IN_GAME }, /*WC*/ 300. { "font_size_status", "the size of the status font", 20, 301. DISP_IN_GAME }, /*WC*/ 302. { "font_size_text", "the size of the text font", 20, 303. DISP_IN_GAME }, /*WC*/ 304. { "font_status", "the font to use in status window", 40, 305. DISP_IN_GAME }, /*WC*/ 306. { "font_text", "the font to use in text windows", 40, 307. DISP_IN_GAME }, /*WC*/ 308. { "fruit", "the name of a fruit you enjoy eating", PL_FSIZ, SET_IN_GAME }, 309. { "gender", "your starting gender (male or female)", 8, DISP_IN_GAME }, 310. { "horsename", "the name of your (first) horse (e.g., horsename:Silver)", 311. PL_PSIZ, DISP_IN_GAME }, 312. { "map_mode", "map display mode under Windows", 20, DISP_IN_GAME }, /*WC*/ 313. { "menustyle", "user interface for object selection", MENUTYPELEN, 314. SET_IN_GAME }, 315. { "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE }, 316. { "menu_deselect_page", "deselect all items on this page of a menu", 4, 317. SET_IN_FILE }, 318. { "menu_first_page", "jump to the first page in a menu", 4, SET_IN_FILE }, 319. { "menu_headings", "text attribute for menu headings", 9, SET_IN_GAME }, 320. { "menu_invert_all", "invert all items in a menu", 4, SET_IN_FILE }, 321. { "menu_invert_page", "invert all items on this page of a menu", 4, 322. SET_IN_FILE }, 323. { "menu_last_page", "jump to the last page in a menu", 4, SET_IN_FILE }, 324. { "menu_next_page", "goto the next menu page", 4, SET_IN_FILE }, 325. { "menu_previous_page", "goto the previous menu page", 4, SET_IN_FILE }, 326. { "menu_search", "search for a menu item", 4, SET_IN_FILE }, 327. { "menu_select_all", "select all items in a menu", 4, SET_IN_FILE }, 328. { "menu_select_page", "select all items on this page of a menu", 4, 329. SET_IN_FILE }, 330. { "monsters", "the symbols to use for monsters", MAXMCLASSES, 331. SET_IN_FILE }, 332. { "msghistory", "number of top line messages to save", 5, DISP_IN_GAME }, 333. #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) 334. { "msg_window", "the type of message window required", 1, SET_IN_GAME }, 335. #else 336. { "msg_window", "the type of message window required", 1, SET_IN_FILE }, 337. #endif 338. { "name", "your character's name (e.g., name:Merlin-W)", PL_NSIZ, 339. DISP_IN_GAME }, 340. { "mouse_support", "game receives click info from mouse", 0, SET_IN_GAME }, 341. { "number_pad", "use the number pad for movement", 1, SET_IN_GAME }, 342. { "objects", "the symbols to use for objects", MAXOCLASSES, SET_IN_FILE }, 343. { "packorder", "the inventory order of the items in your pack", 344. MAXOCLASSES, SET_IN_GAME }, 345. #ifdef CHANGE_COLOR 346. { "palette", 347. #ifndef WIN32 348. "palette (00c/880/-fff is blue/yellow/reverse white)", 15, SET_IN_GAME 349. #else 350. "palette (adjust an RGB color in palette (color-R-G-B)", 15, SET_IN_FILE 351. #endif 352. }, 353. #if defined(MAC) 354. { "hicolor", "same as palette, only order is reversed", 15, SET_IN_FILE }, 355. #endif 356. #endif 357. { "paranoid_confirmation", "extra prompting in certain situations", 28, 358. SET_IN_GAME }, 359. { "petattr", "attributes for highlighting pets", 88, SET_IN_GAME }, 360. { "pettype", "your preferred initial pet type", 4, DISP_IN_GAME }, 361. { "pickup_burden", "maximum burden picked up before prompt", 20, 362. SET_IN_GAME }, 363. { "pickup_types", "types of objects to pick up automatically", 364. MAXOCLASSES, SET_IN_GAME }, 365. { "pile_limit", "threshold for \"there are many objects here\"", 24, 366. SET_IN_GAME }, 367. { "playmode", "normal play, non-scoring explore mode, or debug mode", 8, 368. DISP_IN_GAME }, 369. { "player_selection", "choose character via dialog or prompts", 12, 370. DISP_IN_GAME }, 371. { "race", "your starting race (e.g., Human, Elf)", PL_CSIZ, 372. DISP_IN_GAME }, 373. { "role", "your starting role (e.g., Barbarian, Valkyrie)", PL_CSIZ, 374. DISP_IN_GAME }, 375. { "runmode", "display frequency when `running' or `travelling'", 376. sizeof "teleport", SET_IN_GAME }, 377. { "scores", "the parts of the score list you wish to see", 32, 378. SET_IN_GAME }, 379. { "scroll_amount", "amount to scroll map when scroll_margin is reached", 380. 20, DISP_IN_GAME }, /*WC*/ 381. { "scroll_margin", "scroll map when this far from the edge", 20, 382. DISP_IN_GAME }, /*WC*/ 383. { "sortloot", "sort object selection lists by description", 4, 384. SET_IN_GAME }, 385. #ifdef MSDOS 386. { "soundcard", "type of sound card to use", 20, SET_IN_FILE }, 387. #endif 388. { "statushilites", 389. #ifdef STATUS_HILITES 390. "0=no status highlighting, N=show highlights for N turns", 391. 20, SET_IN_GAME 392. #else 393. "highlight control", 20, SET_IN_FILE 394. #endif 395. }, 396. { "statuslines", 397. #ifdef CURSES_GRAPHICS 398. "2 or 3 lines for horizonal (bottom or top) status display", 399. 20, SET_IN_GAME 400. #else 401. "2 or 3 lines for status display", 402. 20, SET_IN_FILE 403. #endif 404. }, /*WC2*/ 405. { "symset", "load a set of display symbols from the symbols file", 70, 406. SET_IN_GAME }, 407. { "roguesymset", 408. "load a set of rogue display symbols from the symbols file", 70, 409. SET_IN_GAME }, 410. #ifdef WIN32 411. { "subkeyvalue", "override keystroke value", 7, SET_IN_FILE }, 412. #endif 413. { "suppress_alert", "suppress alerts about version-specific features", 8, 414. SET_IN_GAME }, 415. /* term_cols,term_rows -> WC2_TERM_SIZE (6: room to format 1..32767) */ 416. { "term_cols", "number of columns", 6, SET_IN_FILE }, /*WC2*/ 417. { "term_rows", "number of rows", 6, SET_IN_FILE }, /*WC2*/ 418. { "tile_width", "width of tiles", 20, DISP_IN_GAME }, /*WC*/ 419. { "tile_height", "height of tiles", 20, DISP_IN_GAME }, /*WC*/ 420. { "tile_file", "name of tile file", 70, DISP_IN_GAME }, /*WC*/ 421. { "traps", "the symbols to use in drawing traps", MAXTCHARS + 1, 422. SET_IN_FILE }, 423. { "vary_msgcount", "show more old messages at a time", 20, 424. DISP_IN_GAME }, /*WC*/ 425. #ifdef MSDOS 426. { "video", "method of video updating", 20, SET_IN_FILE }, 427. #endif 428. #ifdef VIDEOSHADES 429. { "videocolors", "color mappings for internal screen routines", 40, 430. DISP_IN_GAME }, 431. { "videoshades", "gray shades to map to black/gray/white", 32, 432. DISP_IN_GAME }, 433. #endif 434. { "whatis_coord", "show coordinates when auto-describing cursor position", 435. 1, SET_IN_GAME }, 436. { "whatis_filter", 437. "filter coordinate locations when targeting next or previous", 438. 1, SET_IN_GAME }, 439. { "windowborders", "0 (off), 1 (on), 2 (auto)", 9, SET_IN_GAME }, /*WC2*/ 440. { "windowcolors", "the foreground/background colors of windows", /*WC*/ 441. 80, DISP_IN_GAME }, 442. { "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME }, 443. #ifdef WINCHAIN 444. { "windowchain", "window processor to use", WINTYPELEN, SET_IN_SYS }, 445. #endif 446. #ifdef BACKWARD_COMPAT 447. { "DECgraphics", "load DECGraphics display symbols", 70, SET_IN_FILE }, 448. { "IBMgraphics", "load IBMGraphics display symbols", 70, SET_IN_FILE }, 449. #ifdef CURSES_GRAPHICS 450. { "cursesgraphics", "load curses display symbols", 70, SET_IN_FILE }, 451. #endif 452. #ifdef MAC_GRAPHICS_ENV 453. { "Macgraphics", "load MACGraphics display symbols", 70, SET_IN_FILE }, 454. #endif 455. #endif 456. { (char *) 0, (char *) 0, 0, 0 } 457. }; 458. 459. #ifdef OPTION_LISTS_ONLY 460. #undef static 461. 462. #else /* use rest of file */ 463. 464. extern char configfile[]; /* for messages */ 465. 466. extern struct symparse loadsyms[]; 467. static boolean need_redraw; /* for doset() */ 468. 469. #if defined(TOS) && defined(TEXTCOLOR) 470. extern boolean colors_changed; /* in tos.c */ 471. #endif 472. 473. #ifdef VIDEOSHADES 474. extern char *shade[3]; /* in sys/msdos/video.c */ 475. extern char ttycolors[CLR_MAX]; /* in sys/msdos/video.c */ 476. #endif 477. 478. static char def_inv_order[MAXOCLASSES] = { 479. COIN_CLASS, AMULET_CLASS, WEAPON_CLASS, ARMOR_CLASS, FOOD_CLASS, 480. SCROLL_CLASS, SPBOOK_CLASS, POTION_CLASS, RING_CLASS, WAND_CLASS, 481. TOOL_CLASS, GEM_CLASS, ROCK_CLASS, BALL_CLASS, CHAIN_CLASS, 0, 482. }; 483. 484. /* 485. * Default menu manipulation command accelerators. These may _not_ be: 486. * 487. * + a number - reserved for counts 488. * + an upper or lower case US ASCII letter - used for accelerators 489. * + ESC - reserved for escaping the menu 490. * + NULL, CR or LF - reserved for commiting the selection(s). NULL 491. * is kind of odd, but the tty's xwaitforspace() will return it if 492. * someone hits a <ret>. 493. * + a default object class symbol - used for object class accelerators 494. * 495. * Standard letters (for now) are: 496. * 497. * < back 1 page 498. * > forward 1 page 499. * ^ first page 500. * | last page 501. * : search 502. * 503. * page all 504. * , select . 505. * \ deselect - 506. * ~ invert @ 507. * 508. * The command name list is duplicated in the compopt array. 509. */ 510. typedef struct { 511. const char *name; 512. char cmd; 513. const char *desc; 514. } menu_cmd_t; 515. 516. static const menu_cmd_t default_menu_cmd_info[] = { 517. { "menu_first_page", MENU_FIRST_PAGE, "Go to first page" }, 518. { "menu_last_page", MENU_LAST_PAGE, "Go to last page" }, 519. { "menu_next_page", MENU_NEXT_PAGE, "Go to next page" }, 520. { "menu_previous_page", MENU_PREVIOUS_PAGE, "Go to previous page" }, 521. { "menu_select_all", MENU_SELECT_ALL, "Select all items" }, 522. { "menu_deselect_all", MENU_UNSELECT_ALL, "Unselect all items" }, 523. { "menu_invert_all", MENU_INVERT_ALL, "Invert selection" }, 524. { "menu_select_page", MENU_SELECT_PAGE, "Select items in current page" }, 525. { "menu_deselect_page", MENU_UNSELECT_PAGE, 526. "Unselect items in current page" }, 527. { "menu_invert_page", MENU_INVERT_PAGE, "Invert current page selection" }, 528. { "menu_search", MENU_SEARCH, "Search and toggle matching items" }, 529. }; 530. 531. /* 532. * Allow the user to map incoming characters to various menu commands. 533. * The accelerator list must be a valid C string. 534. */ 535. #define MAX_MENU_MAPPED_CMDS 32 /* some number */ 536. char mapped_menu_cmds[MAX_MENU_MAPPED_CMDS + 1]; /* exported */ 537. static char mapped_menu_op[MAX_MENU_MAPPED_CMDS + 1]; 538. static short n_menu_mapped = 0; 539. 540. static boolean initial, from_file; 541. 542. STATIC_DCL void FDECL(nmcpy, (char *, const char *, int)); 543. STATIC_DCL void FDECL(escapes, (const char *, char *)); 544. STATIC_DCL void FDECL(rejectoption, (const char *)); 545. STATIC_DCL char *FDECL(string_for_opt, (char *, BOOLEAN_P)); 546. STATIC_DCL char *FDECL(string_for_env_opt, (const char *, char *, BOOLEAN_P)); 547. STATIC_DCL void FDECL(bad_negation, (const char *, BOOLEAN_P)); 548. STATIC_DCL int FDECL(change_inv_order, (char *)); 549. STATIC_DCL boolean FDECL(warning_opts, (char *, const char *)); 550. STATIC_DCL int FDECL(feature_alert_opts, (char *, const char *)); 551. STATIC_DCL boolean FDECL(duplicate_opt_detection, (const char *, int)); 552. STATIC_DCL void FDECL(complain_about_duplicate, (const char *, int)); 553. 554. STATIC_DCL const char *FDECL(attr2attrname, (int)); 555. STATIC_DCL const char * FDECL(msgtype2name, (int)); 556. STATIC_DCL int NDECL(query_msgtype); 557. STATIC_DCL boolean FDECL(msgtype_add, (int, char *)); 558. STATIC_DCL void FDECL(free_one_msgtype, (int)); 559. STATIC_DCL int NDECL(msgtype_count); 560. STATIC_DCL boolean FDECL(test_regex_pattern, (const char *, const char *)); 561. STATIC_DCL boolean FDECL(add_menu_coloring_parsed, (char *, int, int)); 562. STATIC_DCL void FDECL(free_one_menu_coloring, (int)); 563. STATIC_DCL int NDECL(count_menucolors); 564. STATIC_DCL boolean FDECL(parse_role_opts, (BOOLEAN_P, const char *, 565. char *, char **)); 566. 567. STATIC_DCL void FDECL(doset_add_menu, (winid, const char *, int)); 568. STATIC_DCL void FDECL(opts_add_others, (winid, const char *, int, 569. char *, int)); 570. STATIC_DCL int FDECL(handle_add_list_remove, (const char *, int)); 571. STATIC_DCL boolean FDECL(special_handling, (const char *, 572. BOOLEAN_P, BOOLEAN_P)); 573. STATIC_DCL const char *FDECL(get_compopt_value, (const char *, char *)); 574. STATIC_DCL void FDECL(remove_autopickup_exception, 575. (struct autopickup_exception *)); 576. 577. STATIC_DCL boolean FDECL(is_wc_option, (const char *)); 578. STATIC_DCL boolean FDECL(wc_supported, (const char *)); 579. STATIC_DCL boolean FDECL(is_wc2_option, (const char *)); 580. STATIC_DCL boolean FDECL(wc2_supported, (const char *)); 581. STATIC_DCL void FDECL(wc_set_font_name, (int, char *)); 582. STATIC_DCL int FDECL(wc_set_window_colors, (char *)); 583. 584. void 585. reglyph_darkroom() 586. { 587. xchar x, y; 588. 589. for (x = 0; x < COLNO; x++) 590. for (y = 0; y < ROWNO; y++) { 591. struct rm *lev = &levl[x][y]; 592. 593. if (!flags.dark_room || !iflags.use_color 594. || Is_rogue_level(&u.uz)) { 595. if (lev->glyph == cmap_to_glyph(S_darkroom)) 596. lev->glyph = lev->waslit ? cmap_to_glyph(S_room) 597. : cmap_to_glyph(S_stone); 598. } else { 599. if (lev->glyph == cmap_to_glyph(S_room) && lev->seenv 600. && lev->waslit && !cansee(x, y)) 601. lev->glyph = cmap_to_glyph(S_darkroom); 602. else if (lev->glyph == cmap_to_glyph(S_stone) 603. && lev->typ == ROOM && lev->seenv && !cansee(x, y)) 604. lev->glyph = cmap_to_glyph(S_darkroom); 605. } 606. } 607. if (flags.dark_room && iflags.use_color) 608. showsyms[S_darkroom] = showsyms[S_room]; 609. else 610. showsyms[S_darkroom] = showsyms[S_stone]; 611. } 612. 613. /* check whether a user-supplied option string is a proper leading 614. substring of a particular option name; option string might have 615. a colon or equals sign and arbitrary value appended to it */ 616. boolean 617. match_optname(user_string, opt_name, min_length, val_allowed) 618. const char *user_string, *opt_name; 619. int min_length; 620. boolean val_allowed; 621. { 622. int len = (int) strlen(user_string); 623. 624. if (val_allowed) { 625. const char *p = index(user_string, ':'), 626. *q = index(user_string, '='); 627. 628. if (!p || (q && q < p)) 629. p = q; 630. if (p) { 631. /* 'user_string' hasn't necessarily been through mungspaces() 632. so might have tabs or consecutive spaces */ 633. while (p > user_string && isspace((uchar) *(p - 1))) 634. p--; 635. len = (int) (p - user_string); 636. } 637. } 638. 639. return (boolean) (len >= min_length 640. && !strncmpi(opt_name, user_string, len)); 641. } 642. 643. /* most environment variables will eventually be printed in an error 644. * message if they don't work, and most error message paths go through 645. * BUFSZ buffers, which could be overflowed by a maliciously long 646. * environment variable. If a variable can legitimately be long, or 647. * if it's put in a smaller buffer, the responsible code will have to 648. * bounds-check itself. 649. */ 650. char * 651. nh_getenv(ev) 652. const char *ev; 653. { 654. char *getev = getenv(ev); 655. 656. if (getev && strlen(getev) <= (BUFSZ / 2)) 657. return getev; 658. else 659. return (char *) 0; 660. } 661. 662. /* process options, possibly including SYSCF */ 663. void 664. initoptions() 665. { 666. initoptions_init(); 667. #ifdef SYSCF 668. /* someday there may be other SYSCF alternatives besides text file */ 669. #ifdef SYSCF_FILE 670. /* If SYSCF_FILE is specified, it _must_ exist... */ 671. assure_syscf_file(); 672. config_error_init(TRUE, SYSCF_FILE, FALSE); 673. 674. /* ... and _must_ parse correctly. */ 675. if (!read_config_file(SYSCF_FILE, SET_IN_SYS)) { 676. if (config_error_done() && !iflags.initoptions_noterminate) 677. nh_terminate(EXIT_FAILURE); 678. } 679. config_error_done(); 680. /* 681. * TODO [maybe]: parse the sysopt entries which are space-separated 682. * lists of usernames into arrays with one name per element. 683. */ 684. #endif 685. #endif /* SYSCF */ 686. initoptions_finish(); 687. } 688. 689. void 690. initoptions_init() 691. { 692. #if (defined(UNIX) || defined(VMS)) && defined(TTY_GRAPHICS) 693. char *opts; 694. #endif 695. int i; 696. 697. /* set up the command parsing */ 698. reset_commands(TRUE); /* init */ 699. 700. /* initialize the random number generator(s) */ 701. init_random(rn2); 702. init_random(rn2_on_display_rng); 703. 704. /* for detection of configfile options specified multiple times */ 705. iflags.opt_booldup = iflags.opt_compdup = (int *) 0; 706. 707. for (i = 0; boolopt[i].name; i++) { 708. if (boolopt[i].addr) 709. *(boolopt[i].addr) = boolopt[i].initvalue; 710. } 711. #if defined(COMPRESS) || defined(ZLIB_COMP) 712. set_savepref("externalcomp"); 713. set_restpref("externalcomp"); 714. #ifdef RLECOMP 715. set_savepref("!rlecomp"); 716. set_restpref("!rlecomp"); 717. #endif 718. #else 719. #ifdef ZEROCOMP 720. set_savepref("zerocomp"); 721. set_restpref("zerocomp"); 722. #endif 723. #ifdef RLECOMP 724. set_savepref("rlecomp"); 725. set_restpref("rlecomp"); 726. #endif 727. #endif 728. #ifdef SYSFLAGS 729. Strcpy(sysflags.sysflagsid, "sysflags"); 730. sysflags.sysflagsid[9] = (char) sizeof (struct sysflag); 731. #endif 732. flags.end_own = FALSE; 733. flags.end_top = 3; 734. flags.end_around = 2; 735. flags.paranoia_bits = PARANOID_PRAY; /* old prayconfirm=TRUE */ 736. flags.pile_limit = PILE_LIMIT_DFLT; /* 5 */ 737. flags.runmode = RUN_LEAP; 738. iflags.msg_history = 20; 739. /* msg_window has conflicting defaults for multi-interface binary */ 740. #ifdef TTY_GRAPHICS 741. iflags.prevmsg_window = 's'; 742. #else 743. #ifdef CURSES_GRAPHICS 744. iflags.prevmsg_window = 'r'; 745. #endif 746. #endif 747. iflags.menu_headings = ATR_INVERSE; 748. iflags.getpos_coords = GPCOORDS_NONE; 749. 750. /* hero's role, race, &c haven't been chosen yet */ 751. flags.initrole = flags.initrace = flags.initgend = flags.initalign 752. = ROLE_NONE; 753. 754. init_ov_primary_symbols(); 755. init_ov_rogue_symbols(); 756. /* Set the default monster and object class symbols. */ 757. init_symbols(); 758. for (i = 0; i < WARNCOUNT; i++) 759. warnsyms[i] = def_warnsyms[i].sym; 760. 761. /* for "special achievement" tracking (see obj.h, 762. create_object(sp_lev.c), addinv_core1(invent.c) */ 763. iflags.mines_prize_type = LUCKSTONE; 764. iflags.soko_prize_type1 = BAG_OF_HOLDING; 765. iflags.soko_prize_type2 = AMULET_OF_REFLECTION; 766. 767. /* assert( sizeof flags.inv_order == sizeof def_inv_order ); */ 768. (void) memcpy((genericptr_t) flags.inv_order, 769. (genericptr_t) def_inv_order, sizeof flags.inv_order); 770. flags.pickup_types[0] = '\0'; 771. flags.pickup_burden = MOD_ENCUMBER; 772. flags.sortloot = 'l'; /* sort only loot by default */ 773. 774. for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) 775. flags.end_disclose[i] = DISCLOSE_PROMPT_DEFAULT_NO; 776. switch_symbols(FALSE); /* set default characters */ 777. init_rogue_symbols(); 778. #if defined(UNIX) && defined(TTY_GRAPHICS) 779. /* 780. * Set defaults for some options depending on what we can 781. * detect about the environment's capabilities. 782. * This has to be done after the global initialization above 783. * and before reading user-specific initialization via 784. * config file/environment variable below. 785. */ 786. /* this detects the IBM-compatible console on most 386 boxes */ 787. if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) { 788. if (!symset[PRIMARY].explicitly) 789. load_symset("IBMGraphics", PRIMARY); 790. if (!symset[ROGUESET].explicitly) 791. load_symset("RogueIBM", ROGUESET); 792. switch_symbols(TRUE); 793. #ifdef TEXTCOLOR 794. iflags.use_color = TRUE; 795. #endif 796. } 797. #endif /* UNIX && TTY_GRAPHICS */ 798. #if defined(UNIX) || defined(VMS) 799. #ifdef TTY_GRAPHICS 800. /* detect whether a "vt" terminal can handle alternate charsets */ 801. if ((opts = nh_getenv("TERM")) 802. /* [could also check "xterm" which emulates vtXXX by default] */ 803. && !strncmpi(opts, "vt", 2) 804. && AS && AE && index(AS, '\016') && index(AE, '\017')) { 805. if (!symset[PRIMARY].explicitly) 806. load_symset("DECGraphics", PRIMARY); 807. switch_symbols(TRUE); 808. } 809. #endif 810. #endif /* UNIX || VMS */ 811. 812. #if defined(MSDOS) || defined(WIN32) 813. /* Use IBM defaults. Can be overridden via config file */ 814. if (!symset[PRIMARY].explicitly) 815. load_symset("IBMGraphics_2", PRIMARY); 816. if (!symset[ROGUESET].explicitly) 817. load_symset("RogueEpyx", ROGUESET); 818. #endif 819. #ifdef MAC_GRAPHICS_ENV 820. if (!symset[PRIMARY].explicitly) 821. load_symset("MACGraphics", PRIMARY); 822. switch_symbols(TRUE); 823. #endif /* MAC_GRAPHICS_ENV */ 824. flags.menu_style = MENU_FULL; 825. 826. iflags.wc_align_message = ALIGN_TOP; 827. iflags.wc_align_status = ALIGN_BOTTOM; 828. /* used by tty and curses */ 829. iflags.wc2_statuslines = 2; 830. /* only used by curses */ 831. iflags.wc2_windowborders = 2; /* 'Auto' */ 832. 833. /* since this is done before init_objects(), do partial init here */ 834. objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD; 835. nmcpy(pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ); 836. } 837. 838. void 839. initoptions_finish() 840. { 841. nhsym sym = 0; 842. #ifndef MAC 843. char *opts = getenv("NETHACKOPTIONS"); 844. 845. if (!opts) 846. opts = getenv("HACKOPTIONS"); 847. if (opts) { 848. if (*opts == '/' || *opts == '\\' || *opts == '@') { 849. if (*opts == '@') 850. opts++; /* @filename */ 851. /* looks like a filename */ 852. if (strlen(opts) < BUFSZ / 2) { 853. config_error_init(TRUE, opts, CONFIG_ERROR_SECURE); 854. read_config_file(opts, SET_IN_FILE); 855. config_error_done(); 856. } 857. } else { 858. config_error_init(TRUE, (char *) 0, FALSE); 859. read_config_file((char *) 0, SET_IN_FILE); 860. config_error_done(); 861. /* let the total length of options be long; 862. * parseoptions() will check each individually 863. */ 864. config_error_init(FALSE, "NETHACKOPTIONS", FALSE); 865. (void) parseoptions(opts, TRUE, FALSE); 866. config_error_done(); 867. } 868. } else 869. #endif /* !MAC */ 870. /*else*/ { 871. config_error_init(TRUE, (char *) 0, FALSE); 872. read_config_file((char *) 0, SET_IN_FILE); 873. config_error_done(); 874. } 875. 876. (void) fruitadd(pl_fruit, (struct fruit *) 0); 877. /* 878. * Remove "slime mold" from list of object names. This will 879. * prevent it from being wished unless it's actually present 880. * as a named (or default) fruit. Wishing for "fruit" will 881. * result in the player's preferred fruit [better than "\033"]. 882. */ 883. obj_descr[SLIME_MOLD].oc_name = "fruit"; 884. 885. sym = get_othersym(SYM_BOULDER, 886. Is_rogue_level(&u.uz) ? ROGUESET : PRIMARY); 887. if (sym) 888. showsyms[SYM_BOULDER + SYM_OFF_X] = sym; 889. reglyph_darkroom(); 890. 891. #ifdef STATUS_HILITES 892. /* 893. * A multi-interface binary might only support status highlighting 894. * for some of the interfaces; check whether we asked for it but are 895. * using one which doesn't. 896. * 897. * Option processing can take place before a user-decided WindowPort 898. * is even initialized, so check for that too. 899. */ 900. if (!WINDOWPORT("safe-startup")) { 901. if (iflags.hilite_delta && !wc2_supported("statushilites")) { 902. raw_printf("Status highlighting not supported for %s interface.", 903. windowprocs.name); 904. iflags.hilite_delta = 0; 905. } 906. } 907. #endif 908. return; 909. } 910. 911. /* copy up to maxlen-1 characters; 'dest' must be able to hold maxlen; 912. treat comma as alternate end of 'src' */ 913. STATIC_OVL void 914. nmcpy(dest, src, maxlen) 915. char *dest; 916. const char *src; 917. int maxlen; 918. { 919. int count; 920. 921. for (count = 1; count < maxlen; count++) { 922. if (*src == ',' || *src == '\0') 923. break; /*exit on \0 terminator*/ 924. *dest++ = *src++; 925. } 926. *dest = '\0'; 927. } 928. 929. /* 930. * escapes(): escape expansion for showsyms. C-style escapes understood 931. * include \n, \b, \t, \r, \xnnn (hex), \onnn (octal), \nnn (decimal). 932. * (Note: unlike in C, leading digit 0 is not used to indicate octal; 933. * the letter o (either upper or lower case) is used for that. 934. * The ^-prefix for control characters is also understood, and \[mM] 935. * has the effect of 'meta'-ing the value which follows (so that the 936. * alternate character set will be enabled). 937. * 938. * X normal key X 939. * ^X control-X 940. * \mX meta-X 941. * 942. * For 3.4.3 and earlier, input ending with "\M", backslash, or caret 943. * prior to terminating '\0' would pull that '\0' into the output and then 944. * keep processing past it, potentially overflowing the output buffer. 945. * Now, trailing \ or ^ will act like \\ or \^ and add '\\' or '^' to the 946. * output and stop there; trailing \M will fall through to \<other> and 947. * yield 'M', then stop. Any \X or \O followed by something other than 948. * an appropriate digit will also fall through to \<other> and yield 'X' 949. * or 'O', plus stop if the non-digit is end-of-string. 950. */ 951. STATIC_OVL void 952. escapes(cp, tp) 953. const char *cp; 954. char *tp; 955. { 956. static NEARDATA const char oct[] = "01234567", dec[] = "0123456789", 957. hex[] = "00112233445566778899aAbBcCdDeEfF"; 958. const char *dp; 959. int cval, meta, dcount; 960. 961. while (*cp) { 962. /* \M has to be followed by something to do meta conversion, 963. otherwise it will just be \M which ultimately yields 'M' */ 964. meta = (*cp == '\\' && (cp[1] == 'm' || cp[1] == 'M') && cp[2]); 965. if (meta) 966. cp += 2; 967. 968. cval = dcount = 0; /* for decimal, octal, hexadecimal cases */ 969. if ((*cp != '\\' && *cp != '^') || !cp[1]) { 970. /* simple character, or nothing left for \ or ^ to escape */ 971. cval = *cp++; 972. } else if (*cp == '^') { /* expand control-character syntax */ 973. cval = (*++cp & 0x1f); 974. ++cp; 975. 976. /* remaining cases are all for backslash; we know cp[1] is not \0 */ 977. } else if (index(dec, cp[1])) { 978. ++cp; /* move past backslash to first digit */ 979. do { 980. cval = (cval * 10) + (*cp - '0'); 981. } while (*++cp && index(dec, *cp) && ++dcount < 3); 982. } else if ((cp[1] == 'o' || cp[1] == 'O') && cp[2] 983. && index(oct, cp[2])) { 984. cp += 2; /* move past backslash and 'O' */ 985. do { 986. cval = (cval * 8) + (*cp - '0'); 987. } while (*++cp && index(oct, *cp) && ++dcount < 3); 988. } else if ((cp[1] == 'x' || cp[1] == 'X') && cp[2] 989. && (dp = index(hex, cp[2])) != 0) { 990. cp += 2; /* move past backslash and 'X' */ 991. do { 992. cval = (cval * 16) + ((int) (dp - hex) / 2); 993. } while (*++cp && (dp = index(hex, *cp)) != 0 && ++dcount < 2); 994. } else { /* C-style character escapes */ 995. switch (*++cp) { 996. case '\\': 997. cval = '\\'; 998. break; 999. case 'n': 1000. cval = '\n'; 1001. break; 1002. case 't': 1003. cval = '\t'; 1004. break; 1005. case 'b': 1006. cval = '\b'; 1007. break; 1008. case 'r': 1009. cval = '\r'; 1010. break; 1011. default: 1012. cval = *cp; 1013. } 1014. ++cp; 1015. } 1016. 1017. if (meta) 1018. cval |= 0x80; 1019. *tp++ = (char) cval; 1020. } 1021. *tp = '\0'; 1022. } 1023. 1024. STATIC_OVL void 1025. rejectoption(optname) 1026. const char *optname; 1027. { 1028. #ifdef MICRO 1029. pline("\"%s\" settable only from %s.", optname, configfile); 1030. #else 1031. pline("%s can be set only from NETHACKOPTIONS or %s.", optname, 1032. configfile); 1033. #endif 1034. } 1035. 1036. /* 1037. 1038. # errors: 1039. OPTIONS=aaaaaaaaaa[ more than 247 (255 - 8 for 'OPTIONS=') total ]aaaaaaaaaa 1040. OPTIONS 1041. OPTIONS= 1042. MSGTYPE=stop"You swap places with " 1043. MSGTYPE=st.op "You swap places with " 1044. MSGTYPE=stop "You swap places with \" 1045. MENUCOLOR=" blessed "green&none 1046. MENUCOLOR=" holy " = green&reverse 1047. MENUCOLOR=" cursed " = red&uline 1048. MENUCOLOR=" unholy " = reed 1049. OPTIONS=!legacy:true,fooo 1050. OPTIONS=align:!pin 1051. OPTIONS=gender 1052. 1053. */ 1054. 1055. STATIC_OVL char * 1056. string_for_opt(opts, val_optional) 1057. char *opts; 1058. boolean val_optional; 1059. { 1060. char *colon, *equals; 1061. 1062. colon = index(opts, ':'); 1063. equals = index(opts, '='); 1064. if (!colon || (equals && equals < colon)) 1065. colon = equals; 1066. 1067. if (!colon || !*++colon) { 1068. if (!val_optional) 1069. config_error_add("Missing parameter for '%s'", opts); 1070. return (char *) 0; 1071. } 1072. return colon; 1073. } 1074. 1075. STATIC_OVL char * 1076. string_for_env_opt(optname, opts, val_optional) 1077. const char *optname; 1078. char *opts; 1079. boolean val_optional; 1080. { 1081. if (!initial) { 1082. rejectoption(optname); 1083. return (char *) 0; 1084. } 1085. return string_for_opt(opts, val_optional); 1086. } 1087. 1088. STATIC_OVL void 1089. bad_negation(optname, with_parameter) 1090. const char *optname; 1091. boolean with_parameter; 1092. { 1093. pline_The("%s option may not %sbe negated.", optname, 1094. with_parameter ? "both have a value and " : ""); 1095. } 1096. 1097. /* 1098. * Change the inventory order, using the given string as the new order. 1099. * Missing characters in the new order are filled in at the end from 1100. * the current inv_order, except for gold, which is forced to be first 1101. * if not explicitly present. 1102. * 1103. * This routine returns 1 unless there is a duplicate or bad char in 1104. * the string. 1105. */ 1106. STATIC_OVL int 1107. change_inv_order(op) 1108. char *op; 1109. { 1110. int oc_sym, num; 1111. char *sp, buf[QBUFSZ]; 1112. int retval = 1; 1113. 1114. num = 0; 1115. if (!index(op, GOLD_SYM)) 1116. buf[num++] = COIN_CLASS; 1117. 1118. for (sp = op; *sp; sp++) { 1119. boolean fail = FALSE; 1120. oc_sym = def_char_to_objclass(*sp); 1121. /* reject bad or duplicate entries */ 1122. if (oc_sym == MAXOCLASSES) { /* not an object class char */ 1123. config_error_add("Not an object class '%c'", *sp); 1124. retval = 0; 1125. fail = TRUE; 1126. } else if (!index(flags.inv_order, oc_sym)) { 1127. /* VENOM_CLASS, RANDOM_CLASS, and ILLOBJ_CLASS are excluded 1128. because they aren't in def_inv_order[] so don't make it 1129. into flags.inv_order, hence always fail this index() test */ 1130. config_error_add("Object class '%c' not allowed", *sp); 1131. retval = 0; 1132. fail = TRUE; 1133. } else if (index(sp + 1, *sp)) { 1134. config_error_add("Duplicate object class '%c'", *sp); 1135. retval = 0; 1136. fail = TRUE; 1137. } 1138. /* retain good ones */ 1139. if (!fail) 1140. buf[num++] = (char) oc_sym; 1141. } 1142. buf[num] = '\0'; 1143. 1144. /* fill in any omitted classes, using previous ordering */ 1145. for (sp = flags.inv_order; *sp; sp++) 1146. if (!index(buf, *sp)) 1147. (void) strkitten(&buf[num++], *sp); 1148. buf[MAXOCLASSES - 1] = '\0'; 1149. 1150. Strcpy(flags.inv_order, buf); 1151. return retval; 1152. } 1153. 1154. STATIC_OVL boolean 1155. warning_opts(opts, optype) 1156. register char *opts; 1157. const char *optype; 1158. { 1159. uchar translate[WARNCOUNT]; 1160. int length, i; 1161. 1162. if (!(opts = string_for_env_opt(optype, opts, FALSE))) 1163. return FALSE; 1164. escapes(opts, opts); 1165. 1166. length = (int) strlen(opts); 1167. /* match the form obtained from PC configuration files */ 1168. for (i = 0; i < WARNCOUNT; i++) 1169. translate[i] = (i >= length) ? 0 1170. : opts[i] ? (uchar) opts[i] 1171. : def_warnsyms[i].sym; 1172. assign_warnings(translate); 1173. return TRUE; 1174. } 1175. 1176. void 1177. assign_warnings(graph_chars) 1178. register uchar *graph_chars; 1179. { 1180. int i; 1181. 1182. for (i = 0; i < WARNCOUNT; i++) 1183. if (graph_chars[i]) 1184. warnsyms[i] = graph_chars[i]; 1185. } 1186. 1187. STATIC_OVL int 1188. feature_alert_opts(op, optn) 1189. char *op; 1190. const char *optn; 1191. { 1192. char buf[BUFSZ]; 1193. unsigned long fnv = get_feature_notice_ver(op); /* version.c */ 1194. 1195. if (fnv == 0L) 1196. return 0; 1197. if (fnv > get_current_feature_ver()) { 1198. if (!initial) { 1199. You_cant("disable new feature alerts for future versions."); 1200. } else { 1201. config_error_add( 1202. "%s=%s Invalid reference to a future version ignored", 1203. optn, op); 1204. } 1205. return 0; 1206. } 1207. 1208. flags.suppress_alert = fnv; 1209. if (!initial) { 1210. Sprintf(buf, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ, 1211. FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH); 1212. pline( 1213. "Feature change alerts disabled for NetHack %s features and prior.", 1214. buf); 1215. } 1216. return 1; 1217. } 1218. 1219. void 1220. set_duplicate_opt_detection(on_or_off) 1221. int on_or_off; 1222. { 1223. int k, *optptr; 1224. 1225. if (on_or_off != 0) { 1226. /*-- ON --*/ 1227. if (iflags.opt_booldup) 1228. impossible("iflags.opt_booldup already on (memory leak)"); 1229. iflags.opt_booldup = (int *) alloc(SIZE(boolopt) * sizeof (int)); 1230. optptr = iflags.opt_booldup; 1231. for (k = 0; k < SIZE(boolopt); ++k) 1232. *optptr++ = 0; 1233. 1234. if (iflags.opt_compdup) 1235. impossible("iflags.opt_compdup already on (memory leak)"); 1236. iflags.opt_compdup = (int *) alloc(SIZE(compopt) * sizeof (int)); 1237. optptr = iflags.opt_compdup; 1238. for (k = 0; k < SIZE(compopt); ++k) 1239. *optptr++ = 0; 1240. } else { 1241. /*-- OFF --*/ 1242. if (iflags.opt_booldup) 1243. free((genericptr_t) iflags.opt_booldup); 1244. iflags.opt_booldup = (int *) 0; 1245. if (iflags.opt_compdup) 1246. free((genericptr_t) iflags.opt_compdup); 1247. iflags.opt_compdup = (int *) 0; 1248. } 1249. } 1250. 1251. STATIC_OVL boolean 1252. duplicate_opt_detection(opts, iscompound) 1253. const char *opts; 1254. int iscompound; /* 0 == boolean option, 1 == compound */ 1255. { 1256. int i, *optptr; 1257. 1258. if (!iscompound && iflags.opt_booldup && initial && from_file) { 1259. for (i = 0; boolopt[i].name; i++) { 1260. if (match_optname(opts, boolopt[i].name, 3, FALSE)) { 1261. optptr = iflags.opt_booldup + i; 1262. *optptr += 1; 1263. if (*optptr > 1) 1264. return TRUE; 1265. else 1266. return FALSE; 1267. } 1268. } 1269. } else if (iscompound && iflags.opt_compdup && initial && from_file) { 1270. for (i = 0; compopt[i].name; i++) { 1271. if (match_optname(opts, compopt[i].name, strlen(compopt[i].name), 1272. TRUE)) { 1273. optptr = iflags.opt_compdup + i; 1274. *optptr += 1; 1275. if (*optptr > 1) 1276. return TRUE; 1277. else 1278. return FALSE; 1279. } 1280. } 1281. } 1282. return FALSE; 1283. } 1284. 1285. STATIC_OVL void 1286. complain_about_duplicate(opts, iscompound) 1287. const char *opts; 1288. int iscompound; /* 0 == boolean option, 1 == compound */ 1289. { 1290. #ifdef MAC 1291. /* the Mac has trouble dealing with the output of messages while 1292. * processing the config file. That should get fixed one day. 1293. * For now just return. 1294. */ 1295. #else /* !MAC */ 1296. config_error_add("%s option specified multiple times: %s", 1297. iscompound ? "compound" : "boolean", opts); 1298. #endif /* ?MAC */ 1299. return; 1300. } 1301. 1302. /* paranoia[] - used by parseoptions() and special_handling() */ 1303. STATIC_VAR const struct paranoia_opts { 1304. int flagmask; /* which paranoid option */ 1305. const char *argname; /* primary name */ 1306. int argMinLen; /* minimum number of letters to match */ 1307. const char *synonym; /* alternate name (optional) */ 1308. int synMinLen; 1309. const char *explain; /* for interactive menu */ 1310. } paranoia[] = { 1311. /* there are some initial-letter conflicts: "a"ttack vs "a"ll, "attack" 1312. takes precedence and "all" isn't present in the interactive menu, 1313. and "d"ie vs "d"eath, synonyms for each other so doesn't matter; 1314. (also "p"ray vs "P"aranoia, "pray" takes precedence since "Paranoia" 1315. is just a synonym for "Confirm"); "b"ones vs "br"eak-wand, the 1316. latter requires at least two letters; "e"at vs "ex"plore, 1317. "cont"inue eating vs "C"onfirm; "wand"-break vs "Were"-change, 1318. both require at least two letters during config processing and use 1319. case-senstivity for 'O's interactive menu */ 1320. { PARANOID_CONFIRM, "Confirm", 1, "Paranoia", 2, 1321. "for \"yes\" confirmations, require \"no\" to reject" }, 1322. { PARANOID_QUIT, "quit", 1, "explore", 2, 1323. "yes vs y to quit or to enter explore mode" }, 1324. { PARANOID_DIE, "die", 1, "death", 2, 1325. "yes vs y to die (explore mode or debug mode)" }, 1326. { PARANOID_BONES, "bones", 1, 0, 0, 1327. "yes vs y to save bones data when dying in debug mode" }, 1328. { PARANOID_HIT, "attack", 1, "hit", 1, 1329. "yes vs y to attack a peaceful monster" }, 1330. { PARANOID_BREAKWAND, "wand-break", 2, "break-wand", 2, 1331. "yes vs y to break a wand via (a)pply" }, 1332. { PARANOID_EATING, "eat", 1, "continue", 4, 1333. "yes vs y to continue eating after first bite when satiated" }, 1334. { PARANOID_WERECHANGE, "Were-change", 2, (const char *) 0, 0, 1335. "yes vs y to change form when lycanthropy is controllable" }, 1336. { PARANOID_PRAY, "pray", 1, 0, 0, 1337. "y to pray (supersedes old \"prayconfirm\" option)" }, 1338. { PARANOID_REMOVE, "Remove", 1, "Takeoff", 1, 1339. "always pick from inventory for Remove and Takeoff" }, 1340. /* for config file parsing; interactive menu skips these */ 1341. { 0, "none", 4, 0, 0, 0 }, /* require full word match */ 1342. { ~0, "all", 3, 0, 0, 0 }, /* ditto */ 1343. }; 1344. 1345. extern struct menucoloring *menu_colorings; 1346. 1347. static const struct { 1348. const char *name; 1349. const int color; 1350. } colornames[] = { 1351. { "black", CLR_BLACK }, 1352. { "red", CLR_RED }, 1353. { "green", CLR_GREEN }, 1354. { "brown", CLR_BROWN }, 1355. { "blue", CLR_BLUE }, 1356. { "magenta", CLR_MAGENTA }, 1357. { "cyan", CLR_CYAN }, 1358. { "gray", CLR_GRAY }, 1359. { "orange", CLR_ORANGE }, 1360. { "light green", CLR_BRIGHT_GREEN }, 1361. { "yellow", CLR_YELLOW }, 1362. { "light blue", CLR_BRIGHT_BLUE }, 1363. { "light magenta", CLR_BRIGHT_MAGENTA }, 1364. { "light cyan", CLR_BRIGHT_CYAN }, 1365. { "white", CLR_WHITE }, 1366. { "no color", NO_COLOR }, 1367. { NULL, CLR_BLACK }, /* everything after this is an alias */ 1368. { "transparent", NO_COLOR }, 1369. { "purple", CLR_MAGENTA }, 1370. { "light purple", CLR_BRIGHT_MAGENTA }, 1371. { "bright purple", CLR_BRIGHT_MAGENTA }, 1372. { "grey", CLR_GRAY }, 1373. { "bright red", CLR_ORANGE }, 1374. { "bright green", CLR_BRIGHT_GREEN }, 1375. { "bright blue", CLR_BRIGHT_BLUE }, 1376. { "bright magenta", CLR_BRIGHT_MAGENTA }, 1377. { "bright cyan", CLR_BRIGHT_CYAN } 1378. }; 1379. 1380. static const struct { 1381. const char *name; 1382. const int attr; 1383. } attrnames[] = { 1384. { "none", ATR_NONE }, 1385. { "bold", ATR_BOLD }, 1386. { "dim", ATR_DIM }, 1387. { "underline", ATR_ULINE }, 1388. { "blink", ATR_BLINK }, 1389. { "inverse", ATR_INVERSE }, 1390. { NULL, ATR_NONE }, /* everything after this is an alias */ 1391. { "normal", ATR_NONE }, 1392. { "uline", ATR_ULINE }, 1393. { "reverse", ATR_INVERSE }, 1394. }; 1395. 1396. const char * 1397. clr2colorname(clr) 1398. int clr; 1399. { 1400. int i; 1401. 1402. for (i = 0; i < SIZE(colornames); i++) 1403. if (colornames[i].name && colornames[i].color == clr) 1404. return colornames[i].name; 1405. return (char *) 0; 1406. } 1407. 1408. int 1409. match_str2clr(str) 1410. char *str; 1411. { 1412. int i, c = CLR_MAX; 1413. 1414. /* allow "lightblue", "light blue", and "light-blue" to match "light blue" 1415. (also junk like "_l i-gh_t---b l u e" but we won't worry about that); 1416. also copes with trailing space; caller has removed any leading space */ 1417. for (i = 0; i < SIZE(colornames); i++) 1418. if (colornames[i].name 1419. && fuzzymatch(str, colornames[i].name, " -_", TRUE)) { 1420. c = colornames[i].color; 1421. break; 1422. } 1423. if (i == SIZE(colornames) && (*str >= '0' && *str <= '9')) 1424. c = atoi(str); 1425. 1426. if (c == CLR_MAX) 1427. config_error_add("Unknown color '%s'", str); 1428. 1429. return c; 1430. } 1431. 1432. STATIC_OVL const char * 1433. attr2attrname(attr) 1434. int attr; 1435. { 1436. int i; 1437. 1438. for (i = 0; i < SIZE(attrnames); i++) 1439. if (attrnames[i].attr == attr) 1440. return attrnames[i].name; 1441. return (char *) 0; 1442. } 1443. 1444. int 1445. match_str2attr(str, complain) 1446. const char *str; 1447. boolean complain; 1448. { 1449. int i, a = -1; 1450. 1451. for (i = 0; i < SIZE(attrnames); i++) 1452. if (attrnames[i].name 1453. && fuzzymatch(str, attrnames[i].name, " -_", TRUE)) { 1454. a = attrnames[i].attr; 1455. break; 1456. } 1457. 1458. if (a == -1 && complain) 1459. config_error_add("Unknown text attribute '%s'", str); 1460. 1461. return a; 1462. } 1463. 1464. int 1465. query_color(prompt) 1466. const char *prompt; 1467. { 1468. winid tmpwin; 1469. anything any; 1470. int i, pick_cnt; 1471. menu_item *picks = (menu_item *) 0; 1472. 1473. tmpwin = create_nhwindow(NHW_MENU); 1474. start_menu(tmpwin); 1475. any = zeroany; 1476. for (i = 0; i < SIZE(colornames); i++) { 1477. if (!colornames[i].name) 1478. break; 1479. any.a_int = i + 1; 1480. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, colornames[i].name, 1481. (colornames[i].color == NO_COLOR) ? MENU_SELECTED 1482. : MENU_UNSELECTED); 1483. } 1484. end_menu(tmpwin, (prompt && *prompt) ? prompt : "Pick a color"); 1485. pick_cnt = select_menu(tmpwin, PICK_ONE, &picks); 1486. destroy_nhwindow(tmpwin); 1487. if (pick_cnt > 0) { 1488. i = colornames[picks[0].item.a_int - 1].color; 1489. /* pick_cnt==2: explicitly picked something other than the 1490. preselected entry */ 1491. if (pick_cnt == 2 && i == NO_COLOR) 1492. i = colornames[picks[1].item.a_int - 1].color; 1493. free((genericptr_t) picks); 1494. return i; 1495. } else if (pick_cnt == 0) { 1496. /* pick_cnt==0: explicitly picking preselected entry toggled it off */ 1497. return NO_COLOR; 1498. } 1499. return -1; 1500. } 1501. 1502. /* ask about highlighting attribute; for menu headers and menu 1503. coloring patterns, only one attribute at a time is allowed; 1504. for status highlighting, multiple attributes are allowed [overkill; 1505. life would be much simpler if that were restricted to one also...] */ 1506. int 1507. query_attr(prompt) 1508. const char *prompt; 1509. { 1510. winid tmpwin; 1511. anything any; 1512. int i, pick_cnt; 1513. menu_item *picks = (menu_item *) 0; 1514. boolean allow_many = (prompt && !strncmpi(prompt, "Choose", 6)); 1515. int default_attr = ATR_NONE; 1516. 1517. if (prompt && strstri(prompt, "menu headings")) 1518. default_attr = iflags.menu_headings; 1519. tmpwin = create_nhwindow(NHW_MENU); 1520. start_menu(tmpwin); 1521. any = zeroany; 1522. for (i = 0; i < SIZE(attrnames); i++) { 1523. if (!attrnames[i].name) 1524. break; 1525. any.a_int = i + 1; 1526. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, attrnames[i].attr, 1527. attrnames[i].name, 1528. (attrnames[i].attr == default_attr) ? MENU_SELECTED 1529. : MENU_UNSELECTED); 1530. } 1531. end_menu(tmpwin, (prompt && *prompt) ? prompt : "Pick an attribute"); 1532. pick_cnt = select_menu(tmpwin, allow_many ? PICK_ANY : PICK_ONE, &picks); 1533. destroy_nhwindow(tmpwin); 1534. if (pick_cnt > 0) { 1535. int j, k = 0; 1536. 1537. if (allow_many) { 1538. /* PICK_ANY, with one preselected entry (ATR_NONE) which 1539. should be excluded if any other choices were picked */ 1540. for (i = 0; i < pick_cnt; ++i) { 1541. j = picks[i].item.a_int - 1; 1542. if (attrnames[j].attr != ATR_NONE || pick_cnt == 1) { 1543. switch (attrnames[j].attr) { 1544. case ATR_DIM: 1545. k |= HL_DIM; 1546. break; 1547. case ATR_BLINK: 1548. k |= HL_BLINK; 1549. break; 1550. case ATR_ULINE: 1551. k |= HL_ULINE; 1552. break; 1553. case ATR_INVERSE: 1554. k |= HL_INVERSE; 1555. break; 1556. case ATR_BOLD: 1557. k |= HL_BOLD; 1558. break; 1559. case ATR_NONE: 1560. k = HL_NONE; 1561. break; 1562. } 1563. } 1564. } 1565. } else { 1566. /* PICK_ONE, but might get 0 or 2 due to preselected entry */ 1567. j = picks[0].item.a_int - 1; 1568. /* pick_cnt==2: explicitly picked something other than the 1569. preselected entry */ 1570. if (pick_cnt == 2 && attrnames[j].attr == default_attr) 1571. j = picks[1].item.a_int - 1; 1572. k = attrnames[j].attr; 1573. } 1574. free((genericptr_t) picks); 1575. return k; 1576. } else if (pick_cnt == 0 && !allow_many) { 1577. /* PICK_ONE, preselected entry explicitly chosen */ 1578. return default_attr; 1579. } 1580. /* either ESC to explicitly cancel (pick_cnt==-1) or 1581. PICK_ANY with preselected entry toggled off and nothing chosen */ 1582. return -1; 1583. } 1584. 1585. static const struct { 1586. const char *name; 1587. xchar msgtyp; 1588. const char *descr; 1589. } msgtype_names[] = { 1590. { "show", MSGTYP_NORMAL, "Show message normally" }, 1591. { "hide", MSGTYP_NOSHOW, "Hide message" }, 1592. { "noshow", MSGTYP_NOSHOW, NULL }, 1593. { "stop", MSGTYP_STOP, "Prompt for more after the message" }, 1594. { "more", MSGTYP_STOP, NULL }, 1595. { "norep", MSGTYP_NOREP, "Do not repeat the message" } 1596. }; 1597. 1598. STATIC_OVL const char * 1599. msgtype2name(typ) 1600. int typ; 1601. { 1602. int i; 1603. 1604. for (i = 0; i < SIZE(msgtype_names); i++) 1605. if (msgtype_names[i].descr && msgtype_names[i].msgtyp == typ) 1606. return msgtype_names[i].name; 1607. return (char *) 0; 1608. } 1609. 1610. STATIC_OVL int 1611. query_msgtype() 1612. { 1613. winid tmpwin; 1614. anything any; 1615. int i, pick_cnt; 1616. menu_item *picks = (menu_item *) 0; 1617. 1618. tmpwin = create_nhwindow(NHW_MENU); 1619. start_menu(tmpwin); 1620. any = zeroany; 1621. for (i = 0; i < SIZE(msgtype_names); i++) 1622. if (msgtype_names[i].descr) { 1623. any.a_int = msgtype_names[i].msgtyp + 1; 1624. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, 1625. msgtype_names[i].descr, MENU_UNSELECTED); 1626. } 1627. end_menu(tmpwin, "How to show the message"); 1628. pick_cnt = select_menu(tmpwin, PICK_ONE, &picks); 1629. destroy_nhwindow(tmpwin); 1630. if (pick_cnt > 0) { 1631. i = picks->item.a_int - 1; 1632. free((genericptr_t) picks); 1633. return i; 1634. } 1635. return -1; 1636. } 1637. 1638. STATIC_OVL boolean 1639. msgtype_add(typ, pattern) 1640. int typ; 1641. char *pattern; 1642. { 1643. struct plinemsg_type *tmp = (struct plinemsg_type *) alloc(sizeof *tmp); 1644. 1645. tmp->msgtype = typ; 1646. tmp->regex = regex_init(); 1647. if (!regex_compile(pattern, tmp->regex)) { 1648. static const char *re_error = "MSGTYPE regex error"; 1649. 1650. config_error_add("%s: %s", re_error, regex_error_desc(tmp->regex)); 1651. regex_free(tmp->regex); 1652. free((genericptr_t) tmp); 1653. return FALSE; 1654. } 1655. tmp->pattern = dupstr(pattern); 1656. tmp->next = plinemsg_types; 1657. plinemsg_types = tmp; 1658. return TRUE; 1659. } 1660. 1661. void 1662. msgtype_free() 1663. { 1664. struct plinemsg_type *tmp, *tmp2 = 0; 1665. 1666. for (tmp = plinemsg_types; tmp; tmp = tmp2) { 1667. tmp2 = tmp->next; 1668. free((genericptr_t) tmp->pattern); 1669. regex_free(tmp->regex); 1670. free((genericptr_t) tmp); 1671. } 1672. plinemsg_types = (struct plinemsg_type *) 0; 1673. } 1674. 1675. STATIC_OVL void 1676. free_one_msgtype(idx) 1677. int idx; /* 0 .. */ 1678. { 1679. struct plinemsg_type *tmp = plinemsg_types; 1680. struct plinemsg_type *prev = NULL; 1681. 1682. while (tmp) { 1683. if (idx == 0) { 1684. struct plinemsg_type *next = tmp->next; 1685. 1686. regex_free(tmp->regex); 1687. free((genericptr_t) tmp->pattern); 1688. free((genericptr_t) tmp); 1689. if (prev) 1690. prev->next = next; 1691. else 1692. plinemsg_types = next; 1693. return; 1694. } 1695. idx--; 1696. prev = tmp; 1697. tmp = tmp->next; 1698. } 1699. } 1700. 1701. int 1702. msgtype_type(msg, norepeat) 1703. const char *msg; 1704. boolean norepeat; /* called from Norep(via pline) */ 1705. { 1706. struct plinemsg_type *tmp = plinemsg_types; 1707. 1708. while (tmp) { 1709. /* we don't exclude entries with negative msgtype values 1710. because then the msg might end up matching a later pattern */ 1711. if (regex_match(msg, tmp->regex)) 1712. return tmp->msgtype; 1713. tmp = tmp->next; 1714. } 1715. return norepeat ? MSGTYP_NOREP : MSGTYP_NORMAL; 1716. } 1717. 1718. /* negate one or more types of messages so that their type handling will 1719. be disabled or re-enabled; MSGTYPE_NORMAL (value 0) is not affected */ 1720. void 1721. hide_unhide_msgtypes(hide, hide_mask) 1722. boolean hide; 1723. int hide_mask; 1724. { 1725. struct plinemsg_type *tmp; 1726. int mt; 1727. 1728. /* negative msgtype value won't be recognized by pline, so does nothing */ 1729. for (tmp = plinemsg_types; tmp; tmp = tmp->next) { 1730. mt = tmp->msgtype; 1731. if (!hide) 1732. mt = -mt; /* unhide: negate negative, yielding positive */ 1733. if (mt > 0 && ((1 << mt) & hide_mask)) 1734. tmp->msgtype = -tmp->msgtype; 1735. } 1736. } 1737. 1738. STATIC_OVL int 1739. msgtype_count(VOID_ARGS) 1740. { 1741. int c = 0; 1742. struct plinemsg_type *tmp = plinemsg_types; 1743. 1744. while (tmp) { 1745. c++; 1746. tmp = tmp->next; 1747. } 1748. return c; 1749. } 1750. 1751. boolean 1752. msgtype_parse_add(str) 1753. char *str; 1754. { 1755. char pattern[256]; 1756. char msgtype[11]; 1757. 1758. if (sscanf(str, "%10s \"%255[^\"]\"", msgtype, pattern) == 2) { 1759. int typ = -1; 1760. int i; 1761. 1762. for (i = 0; i < SIZE(msgtype_names); i++) 1763. if (!strncmpi(msgtype_names[i].name, msgtype, strlen(msgtype))) { 1764. typ = msgtype_names[i].msgtyp; 1765. break; 1766. } 1767. if (typ != -1) 1768. return msgtype_add(typ, pattern); 1769. else 1770. config_error_add("Unknown message type '%s'", msgtype); 1771. } else { 1772. config_error_add("Malformed MSGTYPE"); 1773. } 1774. return FALSE; 1775. } 1776. 1777. STATIC_OVL boolean 1778. test_regex_pattern(str, errmsg) 1779. const char *str; 1780. const char *errmsg; 1781. { 1782. static const char re_error[] = "Regex error"; 1783. struct nhregex *match; 1784. boolean retval = TRUE; 1785. 1786. if (!str) 1787. return FALSE; 1788. 1789. match = regex_init(); 1790. if (!match) { 1791. config_error_add("NHregex error"); 1792. return FALSE; 1793. } 1794. 1795. if (!regex_compile(str, match)) { 1796. config_error_add("%s: %s", errmsg ? errmsg : re_error, 1797. regex_error_desc(match)); 1798. retval = FALSE; 1799. } 1800. regex_free(match); 1801. return retval; 1802. } 1803. 1804. STATIC_OVL boolean 1805. add_menu_coloring_parsed(str, c, a) 1806. char *str; 1807. int c, a; 1808. { 1809. static const char re_error[] = "Menucolor regex error"; 1810. struct menucoloring *tmp; 1811. 1812. if (!str) 1813. return FALSE; 1814. tmp = (struct menucoloring *) alloc(sizeof *tmp); 1815. tmp->match = regex_init(); 1816. if (!regex_compile(str, tmp->match)) { 1817. config_error_add("%s: %s", re_error, regex_error_desc(tmp->match)); 1818. regex_free(tmp->match); 1819. free(tmp); 1820. return FALSE; 1821. } else { 1822. tmp->next = menu_colorings; 1823. tmp->origstr = dupstr(str); 1824. tmp->color = c; 1825. tmp->attr = a; 1826. menu_colorings = tmp; 1827. return TRUE; 1828. } 1829. } 1830. 1831. /* parse '"regex_string"=color&attr' and add it to menucoloring */ 1832. boolean 1833. add_menu_coloring(tmpstr) 1834. char *tmpstr; 1835. { 1836. int c = NO_COLOR, a = ATR_NONE; 1837. char *tmps, *cs, *amp; 1838. char str[BUFSZ]; 1839. 1840. Sprintf(str, "%s", tmpstr); 1841. 1842. if (!tmpstr || (cs = index(str, '=')) == 0) { 1843. config_error_add("Malformed MENUCOLOR"); 1844. return FALSE; 1845. } 1846. 1847. tmps = cs + 1; /* advance past '=' */ 1848. mungspaces(tmps); 1849. if ((amp = index(tmps, '&')) != 0) 1850. *amp = '\0'; 1851. 1852. c = match_str2clr(tmps); 1853. if (c >= CLR_MAX) 1854. return FALSE; 1855. 1856. if (amp) { 1857. tmps = amp + 1; /* advance past '&' */ 1858. a = match_str2attr(tmps, TRUE); 1859. if (a == -1) 1860. return FALSE; 1861. } 1862. 1863. /* the regexp portion here has not been condensed by mungspaces() */ 1864. *cs = '\0'; 1865. tmps = str; 1866. if (*tmps == '"' || *tmps == '\) { 1867. cs--; 1868. while (isspace((uchar) *cs)) 1869. cs--; 1870. if (*cs == *tmps) { 1871. *cs = '\0'; 1872. tmps++; 1873. } 1874. } 1875. return add_menu_coloring_parsed(tmps, c, a); 1876. } 1877. 1878. boolean 1879. get_menu_coloring(str, color, attr) 1880. const char *str; 1881. int *color, *attr; 1882. { 1883. struct menucoloring *tmpmc; 1884. 1885. if (iflags.use_menu_color) 1886. for (tmpmc = menu_colorings; tmpmc; tmpmc = tmpmc->next) 1887. if (regex_match(str, tmpmc->match)) { 1888. *color = tmpmc->color; 1889. *attr = tmpmc->attr; 1890. return TRUE; 1891. } 1892. return FALSE; 1893. } 1894. 1895. void 1896. free_menu_coloring() 1897. { 1898. struct menucoloring *tmp, *tmp2; 1899. 1900. for (tmp = menu_colorings; tmp; tmp = tmp2) { 1901. tmp2 = tmp->next; 1902. regex_free(tmp->match); 1903. free((genericptr_t) tmp->origstr); 1904. free((genericptr_t) tmp); 1905. } 1906. } 1907. 1908. STATIC_OVL void 1909. free_one_menu_coloring(idx) 1910. int idx; /* 0 .. */ 1911. { 1912. struct menucoloring *tmp = menu_colorings; 1913. struct menucoloring *prev = NULL; 1914. 1915. while (tmp) { 1916. if (idx == 0) { 1917. struct menucoloring *next = tmp->next; 1918. 1919. regex_free(tmp->match); 1920. free((genericptr_t) tmp->origstr); 1921. free((genericptr_t) tmp); 1922. if (prev) 1923. prev->next = next; 1924. else 1925. menu_colorings = next; 1926. return; 1927. } 1928. idx--; 1929. prev = tmp; 1930. tmp = tmp->next; 1931. } 1932. } 1933. 1934. STATIC_OVL int 1935. count_menucolors(VOID_ARGS) 1936. { 1937. struct menucoloring *tmp; 1938. int count = 0; 1939. 1940. for (tmp = menu_colorings; tmp; tmp = tmp->next) 1941. count++; 1942. return count; 1943. } 1944. 1945. STATIC_OVL boolean 1946. parse_role_opts(negated, fullname, opts, opp) 1947. boolean negated; 1948. const char *fullname; 1949. char *opts; 1950. char **opp; 1951. { 1952. char *op = *opp; 1953. 1954. if (negated) { 1955. bad_negation(fullname, FALSE); 1956. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 1957. boolean val_negated = FALSE; 1958. 1959. while ((*op == '!') || !strncmpi(op, "no", 2)) { 1960. if (*op == '!') 1961. op++; 1962. else 1963. op += 2; 1964. val_negated = !val_negated; 1965. } 1966. if (val_negated) { 1967. if (!setrolefilter(op)) { 1968. config_error_add("Unknown negated parameter '%s'", op); 1969. return FALSE; 1970. } 1971. } else { 1972. if (duplicate_opt_detection(opts, 1)) 1973. complain_about_duplicate(opts, 1); 1974. *opp = op; 1975. return TRUE; 1976. } 1977. } 1978. return FALSE; 1979. } 1980. 1981. /* Check if character c is illegal as a menu command key */ 1982. boolean 1983. illegal_menu_cmd_key(c) 1984. char c; 1985. { 1986. if (c == 0 || c == '\r' || c == '\n' || c == '\033' 1987. || c == ' ' || digit(c) || (letter(c) && c != '@')) { 1988. config_error_add("Reserved menu command key '%s'", visctrl(c)); 1989. return TRUE; 1990. } else { /* reject default object class symbols */ 1991. int j; 1992. for (j = 1; j < MAXOCLASSES; j++) 1993. if (c == def_oc_syms[j].sym) { 1994. config_error_add("Menu command key '%s' is an object class", 1995. visctrl(c)); 1996. return TRUE; 1997. } 1998. } 1999. return FALSE; 2000. } 2001. 2002. boolean 2003. parseoptions(opts, tinitial, tfrom_file) 2004. register char *opts; 2005. boolean tinitial, tfrom_file; 2006. { 2007. char *op; 2008. unsigned num; 2009. boolean negated, duplicate; 2010. int i; 2011. const char *fullname; 2012. boolean retval = TRUE; 2013. 2014. initial = tinitial; 2015. from_file = tfrom_file; 2016. if ((op = index(opts, ',')) != 0) { 2017. *op++ = 0; 2018. if (!parseoptions(op, initial, from_file)) 2019. retval = FALSE; 2020. } 2021. if (strlen(opts) > BUFSZ / 2) { 2022. config_error_add("Option too long, max length is %i characters", 2023. (BUFSZ / 2)); 2024. return FALSE; 2025. } 2026. 2027. /* strip leading and trailing white space */ 2028. while (isspace((uchar) *opts)) 2029. opts++; 2030. op = eos(opts); 2031. while (--op >= opts && isspace((uchar) *op)) 2032. *op = '\0'; 2033. 2034. if (!*opts) { 2035. config_error_add("Empty statement"); 2036. return FALSE; 2037. } 2038. negated = FALSE; 2039. while ((*opts == '!') || !strncmpi(opts, "no", 2)) { 2040. if (*opts == '!') 2041. opts++; 2042. else 2043. opts += 2; 2044. negated = !negated; 2045. } 2046. 2047. /* variant spelling */ 2048. 2049. if (match_optname(opts, "colour", 5, FALSE)) 2050. Strcpy(opts, "color"); /* fortunately this isn't longer */ 2051. 2052. /* special boolean options */ 2053. 2054. if (match_optname(opts, "female", 3, FALSE)) { 2055. if (duplicate_opt_detection(opts, 0)) 2056. complain_about_duplicate(opts, 0); 2057. if (!initial && flags.female == negated) { 2058. config_error_add("That is not anatomically possible."); 2059. return FALSE; 2060. } else 2061. flags.initgend = flags.female = !negated; 2062. return retval; 2063. } 2064. 2065. if (match_optname(opts, "male", 4, FALSE)) { 2066. if (duplicate_opt_detection(opts, 0)) 2067. complain_about_duplicate(opts, 0); 2068. if (!initial && flags.female != negated) { 2069. config_error_add("That is not anatomically possible."); 2070. return FALSE; 2071. } else 2072. flags.initgend = flags.female = negated; 2073. return retval; 2074. } 2075. 2076. #if defined(MICRO) && !defined(AMIGA) 2077. /* included for compatibility with old NetHack.cnf files */ 2078. if (match_optname(opts, "IBM_", 4, FALSE)) { 2079. iflags.BIOS = !negated; 2080. return retval; 2081. } 2082. #endif /* MICRO */ 2083. 2084. /* compound options */ 2085. 2086. /* This first batch can be duplicated if their values are negated */ 2087. 2088. /* align:string */ 2089. fullname = "align"; 2090. if (match_optname(opts, fullname, sizeof "align" - 1, TRUE)) { 2091. if (parse_role_opts(negated, fullname, opts, &op)) { 2092. if ((flags.initalign = str2align(op)) == ROLE_NONE) { 2093. config_error_add("Unknown %s '%s'", fullname, op); 2094. return FALSE; 2095. } 2096. } else 2097. return FALSE; 2098. return retval; 2099. } 2100. 2101. /* role:string or character:string */ 2102. fullname = "role"; 2103. if (match_optname(opts, fullname, 4, TRUE) 2104. || match_optname(opts, (fullname = "character"), 4, TRUE)) { 2105. if (parse_role_opts(negated, fullname, opts, &op)) { 2106. if ((flags.initrole = str2role(op)) == ROLE_NONE) { 2107. config_error_add("Unknown %s '%s'", fullname, op); 2108. return FALSE; 2109. } else /* Backwards compatibility */ 2110. nmcpy(pl_character, op, PL_NSIZ); 2111. } else 2112. return FALSE; 2113. return retval; 2114. } 2115. 2116. /* race:string */ 2117. fullname = "race"; 2118. if (match_optname(opts, fullname, 4, TRUE)) { 2119. if (parse_role_opts(negated, fullname, opts, &op)) { 2120. if ((flags.initrace = str2race(op)) == ROLE_NONE) { 2121. config_error_add("Unknown %s '%s'", fullname, op); 2122. return FALSE; 2123. } else /* Backwards compatibility */ 2124. pl_race = *op; 2125. } else 2126. return FALSE; 2127. return retval; 2128. } 2129. 2130. /* gender:string */ 2131. fullname = "gender"; 2132. if (match_optname(opts, fullname, 4, TRUE)) { 2133. if (parse_role_opts(negated, fullname, opts, &op)) { 2134. if ((flags.initgend = str2gend(op)) == ROLE_NONE) { 2135. config_error_add("Unknown %s '%s'", fullname, op); 2136. return FALSE; 2137. } else 2138. flags.female = flags.initgend; 2139. } else 2140. return FALSE; 2141. return retval; 2142. } 2143. 2144. /* We always check for duplicates on the remaining compound options, 2145. although individual option processing can choose to complain or not */ 2146. 2147. duplicate = duplicate_opt_detection(opts, 1); /* 1: check compounds */ 2148. 2149. fullname = "pettype"; 2150. if (match_optname(opts, fullname, 3, TRUE)) { 2151. if (duplicate) 2152. complain_about_duplicate(opts, 1); 2153. if ((op = string_for_env_opt(fullname, opts, negated)) != 0) { 2154. if (negated) { 2155. bad_negation(fullname, TRUE); 2156. return FALSE; 2157. } else 2158. switch (lowc(*op)) { 2159. case 'd': /* dog */ 2160. preferred_pet = 'd'; 2161. break; 2162. case 'c': /* cat */ 2163. case 'f': /* feline */ 2164. preferred_pet = 'c'; 2165. break; 2166. case 'h': /* horse */ 2167. case 'q': /* quadruped */ 2168. /* avoids giving "unrecognized type of pet" but 2169. pet_type(dog.c) won't actually honor this */ 2170. preferred_pet = 'h'; 2171. break; 2172. case 'n': /* no pet */ 2173. preferred_pet = 'n'; 2174. break; 2175. case '*': /* random */ 2176. preferred_pet = '\0'; 2177. break; 2178. default: 2179. config_error_add("Unrecognized pet type '%s'.", op); 2180. return FALSE; 2181. break; 2182. } 2183. } else if (negated) 2184. preferred_pet = 'n'; 2185. return retval; 2186. } 2187. 2188. fullname = "catname"; 2189. if (match_optname(opts, fullname, 3, TRUE)) { 2190. if (duplicate) 2191. complain_about_duplicate(opts, 1); 2192. if (negated) { 2193. bad_negation(fullname, FALSE); 2194. return FALSE; 2195. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2196. nmcpy(catname, op, PL_PSIZ); 2197. } else 2198. return FALSE; 2199. sanitize_name(catname); 2200. return retval; 2201. } 2202. 2203. fullname = "dogname"; 2204. if (match_optname(opts, fullname, 3, TRUE)) { 2205. if (duplicate) 2206. complain_about_duplicate(opts, 1); 2207. if (negated) { 2208. bad_negation(fullname, FALSE); 2209. return FALSE; 2210. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2211. nmcpy(dogname, op, PL_PSIZ); 2212. } else 2213. return FALSE; 2214. sanitize_name(dogname); 2215. return retval; 2216. } 2217. 2218. fullname = "horsename"; 2219. if (match_optname(opts, fullname, 5, TRUE)) { 2220. if (duplicate) 2221. complain_about_duplicate(opts, 1); 2222. if (negated) { 2223. bad_negation(fullname, FALSE); 2224. return FALSE; 2225. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2226. nmcpy(horsename, op, PL_PSIZ); 2227. } else 2228. return FALSE; 2229. sanitize_name(horsename); 2230. return retval; 2231. } 2232. 2233. fullname = "mouse_support"; 2234. if (match_optname(opts, fullname, 13, TRUE)) { 2235. boolean compat = (strlen(opts) <= 13); 2236. 2237. if (duplicate) 2238. complain_about_duplicate(opts, 1); 2239. op = string_for_opt(opts, (compat || !initial)); 2240. if (!op) { 2241. if (compat || negated || initial) { 2242. /* for backwards compatibility, "mouse_support" without a 2243. value is a synonym for mouse_support:1 */ 2244. iflags.wc_mouse_support = !negated; 2245. } 2246. } else if (negated) { 2247. bad_negation(fullname, TRUE); 2248. return FALSE; 2249. } else { 2250. int mode = atoi(op); 2251. 2252. if (mode < 0 || mode > 2 || (mode == 0 && *op != '0')) { 2253. config_error_add("Illegal %s parameter '%s'", fullname, op); 2254. return FALSE; 2255. } else { /* mode >= 0 */ 2256. iflags.wc_mouse_support = mode; 2257. } 2258. } 2259. return retval; 2260. } 2261. 2262. fullname = "number_pad"; 2263. if (match_optname(opts, fullname, 10, TRUE)) { 2264. boolean compat = (strlen(opts) <= 10); 2265. 2266. if (duplicate) 2267. complain_about_duplicate(opts, 1); 2268. op = string_for_opt(opts, (compat || !initial)); 2269. if (!op) { 2270. if (compat || negated || initial) { 2271. /* for backwards compatibility, "number_pad" without a 2272. value is a synonym for number_pad:1 */ 2273. iflags.num_pad = !negated; 2274. iflags.num_pad_mode = 0; 2275. } 2276. } else if (negated) { 2277. bad_negation(fullname, TRUE); 2278. return FALSE; 2279. } else { 2280. int mode = atoi(op); 2281. 2282. if (mode < -1 || mode > 4 || (mode == 0 && *op != '0')) { 2283. config_error_add("Illegal %s parameter '%s'", fullname, op); 2284. return FALSE; 2285. } else if (mode <= 0) { 2286. iflags.num_pad = FALSE; 2287. /* German keyboard; y and z keys swapped */ 2288. iflags.num_pad_mode = (mode < 0); /* 0 or 1 */ 2289. } else { /* mode > 0 */ 2290. iflags.num_pad = TRUE; 2291. iflags.num_pad_mode = 0; 2292. /* PC Hack / MSDOS compatibility */ 2293. if (mode == 2 || mode == 4) 2294. iflags.num_pad_mode |= 1; 2295. /* phone keypad layout */ 2296. if (mode == 3 || mode == 4) 2297. iflags.num_pad_mode |= 2; 2298. } 2299. } 2300. reset_commands(FALSE); 2301. number_pad(iflags.num_pad ? 1 : 0); 2302. return retval; 2303. } 2304. 2305. fullname = "roguesymset"; 2306. if (match_optname(opts, fullname, 7, TRUE)) { 2307. if (duplicate) 2308. complain_about_duplicate(opts, 1); 2309. if (negated) { 2310. bad_negation(fullname, FALSE); 2311. return FALSE; 2312. } else if ((op = string_for_opt(opts, FALSE)) != 0) { 2313. symset[ROGUESET].name = dupstr(op); 2314. if (!read_sym_file(ROGUESET)) { 2315. clear_symsetentry(ROGUESET, TRUE); 2316. config_error_add( 2317. "Unable to load symbol set \"%s\" from \"%s\"", 2318. op, SYMBOLS); 2319. return FALSE; 2320. } else { 2321. if (!initial && Is_rogue_level(&u.uz)) 2322. assign_graphics(ROGUESET); 2323. need_redraw = TRUE; 2324. } 2325. } else 2326. return FALSE; 2327. return retval; 2328. } 2329. 2330. fullname = "symset"; 2331. if (match_optname(opts, fullname, 6, TRUE)) { 2332. if (duplicate) 2333. complain_about_duplicate(opts, 1); 2334. if (negated) { 2335. bad_negation(fullname, FALSE); 2336. return FALSE; 2337. } else if ((op = string_for_opt(opts, FALSE)) != 0) { 2338. symset[PRIMARY].name = dupstr(op); 2339. if (!read_sym_file(PRIMARY)) { 2340. clear_symsetentry(PRIMARY, TRUE); 2341. config_error_add( 2342. "Unable to load symbol set \"%s\" from \"%s\"", 2343. op, SYMBOLS); 2344. return FALSE; 2345. } else { 2346. switch_symbols(symset[PRIMARY].name != (char *) 0); 2347. need_redraw = TRUE; 2348. } 2349. } else 2350. return FALSE; 2351. return retval; 2352. } 2353. 2354. fullname = "runmode"; 2355. if (match_optname(opts, fullname, 4, TRUE)) { 2356. if (duplicate) 2357. complain_about_duplicate(opts, 1); 2358. if (negated) { 2359. flags.runmode = RUN_TPORT; 2360. } else if ((op = string_for_opt(opts, FALSE)) != 0) { 2361. if (!strncmpi(op, "teleport", strlen(op))) 2362. flags.runmode = RUN_TPORT; 2363. else if (!strncmpi(op, "run", strlen(op))) 2364. flags.runmode = RUN_LEAP; 2365. else if (!strncmpi(op, "walk", strlen(op))) 2366. flags.runmode = RUN_STEP; 2367. else if (!strncmpi(op, "crawl", strlen(op))) 2368. flags.runmode = RUN_CRAWL; 2369. else { 2370. config_error_add("Unknown %s parameter '%s'", fullname, op); 2371. return FALSE; 2372. } 2373. } else 2374. return FALSE; 2375. return retval; 2376. } 2377. 2378. /* menucolor:"regex_string"=color */ 2379. fullname = "menucolor"; 2380. if (match_optname(opts, fullname, 9, TRUE)) { 2381. if (negated) { 2382. bad_negation(fullname, FALSE); 2383. return FALSE; 2384. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2385. if (!add_menu_coloring(op)) 2386. return FALSE; 2387. } else 2388. return FALSE; 2389. return retval; 2390. } 2391. 2392. fullname = "msghistory"; 2393. if (match_optname(opts, fullname, 3, TRUE)) { 2394. if (duplicate) 2395. complain_about_duplicate(opts, 1); 2396. op = string_for_env_opt(fullname, opts, negated); 2397. if ((negated && !op) || (!negated && op)) { 2398. iflags.msg_history = negated ? 0 : atoi(op); 2399. } else if (negated) { 2400. bad_negation(fullname, TRUE); 2401. return FALSE; 2402. } 2403. return retval; 2404. } 2405. 2406. fullname = "msg_window"; 2407. /* msg_window:single, combo, full or reversed */ 2408. if (match_optname(opts, fullname, 4, TRUE)) { 2409. /* allow option to be silently ignored by non-tty ports */ 2410. #ifdef TTY_GRAPHICS 2411. int tmp; 2412. 2413. if (duplicate) 2414. complain_about_duplicate(opts, 1); 2415. if (!(op = string_for_opt(opts, TRUE))) { 2416. tmp = negated ? 's' : 'f'; 2417. } else { 2418. if (negated) { 2419. bad_negation(fullname, TRUE); 2420. return FALSE; 2421. } 2422. tmp = lowc(*op); 2423. } 2424. switch (tmp) { 2425. case 's': /* single message history cycle (default if negated) */ 2426. iflags.prevmsg_window = 's'; 2427. break; 2428. case 'c': /* combination: two singles, then full page */ 2429. iflags.prevmsg_window = 'c'; 2430. break; 2431. case 'f': /* full page (default if specified without argument) */ 2432. iflags.prevmsg_window = 'f'; 2433. break; 2434. case 'r': /* full page (reversed) */ 2435. iflags.prevmsg_window = 'r'; 2436. break; 2437. default: 2438. config_error_add("Unknown %s parameter '%s'", fullname, op); 2439. retval = FALSE; 2440. } 2441. #endif 2442. return retval; 2443. } 2444. 2445. /* WINCAP 2446. * setting font options */ 2447. fullname = "font"; 2448. if (!strncmpi(opts, fullname, 4)) { 2449. int opttype = -1; 2450. char *fontopts = opts + 4; 2451. 2452. if (!strncmpi(fontopts, "map", 3) || !strncmpi(fontopts, "_map", 4)) 2453. opttype = MAP_OPTION; 2454. else if (!strncmpi(fontopts, "message", 7) 2455. || !strncmpi(fontopts, "_message", 8)) 2456. opttype = MESSAGE_OPTION; 2457. else if (!strncmpi(fontopts, "text", 4) 2458. || !strncmpi(fontopts, "_text", 5)) 2459. opttype = TEXT_OPTION; 2460. else if (!strncmpi(fontopts, "menu", 4) 2461. || !strncmpi(fontopts, "_menu", 5)) 2462. opttype = MENU_OPTION; 2463. else if (!strncmpi(fontopts, "status", 6) 2464. || !strncmpi(fontopts, "_status", 7)) 2465. opttype = STATUS_OPTION; 2466. else if (!strncmpi(fontopts, "_size", 5)) { 2467. if (!strncmpi(fontopts, "_size_map", 8)) 2468. opttype = MAP_OPTION; 2469. else if (!strncmpi(fontopts, "_size_message", 12)) 2470. opttype = MESSAGE_OPTION; 2471. else if (!strncmpi(fontopts, "_size_text", 9)) 2472. opttype = TEXT_OPTION; 2473. else if (!strncmpi(fontopts, "_size_menu", 9)) 2474. opttype = MENU_OPTION; 2475. else if (!strncmpi(fontopts, "_size_status", 11)) 2476. opttype = STATUS_OPTION; 2477. else { 2478. config_error_add("Unknown %s parameter '%s'", fullname, opts); 2479. return FALSE; 2480. } 2481. if (duplicate) 2482. complain_about_duplicate(opts, 1); 2483. if (opttype > 0 && !negated 2484. && (op = string_for_opt(opts, FALSE)) != 0) { 2485. switch (opttype) { 2486. case MAP_OPTION: 2487. iflags.wc_fontsiz_map = atoi(op); 2488. break; 2489. case MESSAGE_OPTION: 2490. iflags.wc_fontsiz_message = atoi(op); 2491. break; 2492. case TEXT_OPTION: 2493. iflags.wc_fontsiz_text = atoi(op); 2494. break; 2495. case MENU_OPTION: 2496. iflags.wc_fontsiz_menu = atoi(op); 2497. break; 2498. case STATUS_OPTION: 2499. iflags.wc_fontsiz_status = atoi(op); 2500. break; 2501. } 2502. } 2503. return retval; 2504. } else { 2505. config_error_add("Unknown %s parameter '%s'", fullname, opts); 2506. return FALSE; 2507. } 2508. if (opttype > 0 && (op = string_for_opt(opts, FALSE)) != 0) { 2509. wc_set_font_name(opttype, op); 2510. #ifdef MAC 2511. set_font_name(opttype, op); 2512. #endif 2513. return retval; 2514. } else if (negated) { 2515. bad_negation(fullname, TRUE); 2516. return FALSE; 2517. } 2518. return retval; 2519. } 2520. 2521. #ifdef CHANGE_COLOR 2522. if (match_optname(opts, "palette", 3, TRUE) 2523. #ifdef MAC 2524. || match_optname(opts, "hicolor", 3, TRUE) 2525. #endif 2526. ) { 2527. int color_number, color_incr; 2528. 2529. #ifndef WIN32 2530. if (duplicate) 2531. complain_about_duplicate(opts, 1); 2532. #endif 2533. #ifdef MAC 2534. if (match_optname(opts, "hicolor", 3, TRUE)) { 2535. if (negated) { 2536. bad_negation("hicolor", FALSE); 2537. return FALSE; 2538. } 2539. color_number = CLR_MAX + 4; /* HARDCODED inverse number */ 2540. color_incr = -1; 2541. } else 2542. #endif 2543. { 2544. if (negated) { 2545. bad_negation("palette", FALSE); 2546. return FALSE; 2547. } 2548. color_number = 0; 2549. color_incr = 1; 2550. } 2551. #ifdef WIN32 2552. op = string_for_opt(opts, TRUE); 2553. if (!alternative_palette(op)) { 2554. config_error_add("Error in palette parameter '%s'", op); 2555. return FALSE; 2556. } 2557. #else 2558. if ((op = string_for_opt(opts, FALSE)) != (char *) 0) { 2559. char *pt = op; 2560. int cnt, tmp, reverse; 2561. long rgb; 2562. 2563. while (*pt && color_number >= 0) { 2564. cnt = 3; 2565. rgb = 0L; 2566. if (*pt == '-') { 2567. reverse = 1; 2568. pt++; 2569. } else { 2570. reverse = 0; 2571. } 2572. while (cnt-- > 0) { 2573. if (*pt && *pt != '/') { 2574. #ifdef AMIGA 2575. rgb <<= 4; 2576. #else 2577. rgb <<= 8; 2578. #endif 2579. tmp = *pt++; 2580. if (isalpha((uchar) tmp)) { 2581. tmp = (tmp + 9) & 0xf; /* Assumes ASCII... */ 2582. } else { 2583. tmp &= 0xf; /* Digits in ASCII too... */ 2584. } 2585. #ifndef AMIGA 2586. /* Add an extra so we fill f -> ff and 0 -> 00 */ 2587. rgb += tmp << 4; 2588. #endif 2589. rgb += tmp; 2590. } 2591. } 2592. if (*pt == '/') 2593. pt++; 2594. change_color(color_number, rgb, reverse); 2595. color_number += color_incr; 2596. } 2597. } 2598. #endif /* !WIN32 */ 2599. if (!initial) { 2600. need_redraw = TRUE; 2601. } 2602. return retval; 2603. } 2604. #endif /* CHANGE_COLOR */ 2605. 2606. if (match_optname(opts, "fruit", 2, TRUE)) { 2607. struct fruit *forig = 0; 2608. char empty_str = '\0'; 2609. 2610. if (duplicate) 2611. complain_about_duplicate(opts, 1); 2612. op = string_for_opt(opts, negated || !initial); 2613. if (negated) { 2614. if (op) { 2615. bad_negation("fruit", TRUE); 2616. return FALSE; 2617. } 2618. op = &empty_str; 2619. goto goodfruit; 2620. } 2621. if (!op) 2622. return FALSE; 2623. /* stripped leading and trailing spaces, condensed internal ones in 3.6.2 */ 2624. mungspaces(op); 2625. if (!initial) { 2626. struct fruit *f; 2627. int fnum = 0; 2628. 2629. /* count number of named fruits; if 'op' is found among them, 2630. then the count doesn't matter because we won't be adding it */ 2631. f = fruit_from_name(op, FALSE, &fnum); 2632. if (!f) { 2633. if (!flags.made_fruit) 2634. forig = fruit_from_name(pl_fruit, FALSE, (int *) 0); 2635. 2636. if (!forig && fnum >= 100) { 2637. config_error_add( 2638. "Doing that so many times isn't very fruitful."); 2639. return retval; 2640. } 2641. } 2642. } 2643. goodfruit: 2644. nmcpy(pl_fruit, op, PL_FSIZ); 2645. sanitize_name(pl_fruit); 2646. /* OBJ_NAME(objects[SLIME_MOLD]) won't work for this after 2647. initialization; it gets changed to generic "fruit" */ 2648. if (!*pl_fruit) 2649. nmcpy(pl_fruit, "slime mold", PL_FSIZ); 2650. if (!initial) { 2651. /* if 'forig' is nonNull, we replace it rather than add 2652. a new fruit; it can only be nonNull if no fruits have 2653. been created since the previous name was put in place */ 2654. (void) fruitadd(pl_fruit, forig); 2655. pline("Fruit is now \"%s\".", pl_fruit); 2656. } 2657. /* If initial, then initoptions is allowed to do it instead 2658. * of here (initoptions always has to do it even if there's 2659. * no fruit option at all. Also, we don't want people 2660. * setting multiple fruits in their options.) 2661. */ 2662. return retval; 2663. } 2664. 2665. fullname = "whatis_coord"; 2666. if (match_optname(opts, fullname, 8, TRUE)) { 2667. if (duplicate) 2668. complain_about_duplicate(opts, 1); 2669. if (negated) { 2670. iflags.getpos_coords = GPCOORDS_NONE; 2671. return retval; 2672. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2673. static char gpcoords[] = { GPCOORDS_NONE, GPCOORDS_COMPASS, 2674. GPCOORDS_COMFULL, GPCOORDS_MAP, 2675. GPCOORDS_SCREEN, '\0' }; 2676. char c = lowc(*op); 2677. 2678. if (c && index(gpcoords, c)) 2679. iflags.getpos_coords = c; 2680. else { 2681. config_error_add("Unknown %s parameter '%s'", fullname, op); 2682. return FALSE; 2683. } 2684. } else 2685. return FALSE; 2686. return retval; 2687. } 2688. 2689. fullname = "whatis_filter"; 2690. if (match_optname(opts, fullname, 8, TRUE)) { 2691. if (duplicate) 2692. complain_about_duplicate(opts, 1); 2693. if (negated) { 2694. iflags.getloc_filter = GFILTER_NONE; 2695. return retval; 2696. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2697. char c = lowc(*op); 2698. 2699. switch (c) { 2700. case 'n': 2701. iflags.getloc_filter = GFILTER_NONE; 2702. break; 2703. case 'v': 2704. iflags.getloc_filter = GFILTER_VIEW; 2705. break; 2706. case 'a': 2707. iflags.getloc_filter = GFILTER_AREA; 2708. break; 2709. default: { 2710. config_error_add("Unknown %s parameter '%s'", fullname, op); 2711. return FALSE; 2712. } 2713. } 2714. } else 2715. return FALSE; 2716. return retval; 2717. } 2718. 2719. fullname = "warnings"; 2720. if (match_optname(opts, fullname, 5, TRUE)) { 2721. if (duplicate) 2722. complain_about_duplicate(opts, 1); 2723. if (negated) { 2724. bad_negation(fullname, FALSE); 2725. return FALSE; 2726. } 2727. return warning_opts(opts, fullname); 2728. } 2729. 2730. /* boulder:symbol */ 2731. fullname = "boulder"; 2732. if (match_optname(opts, fullname, 7, TRUE)) { 2733. #ifdef BACKWARD_COMPAT 2734. int clash = 0; 2735. 2736. if (duplicate) 2737. complain_about_duplicate(opts, 1); 2738. if (negated) { 2739. bad_negation(fullname, FALSE); 2740. return FALSE; 2741. } 2742. /* if (!(opts = string_for_env_opt(fullname, opts, FALSE))) 2743. */ 2744. if (!(opts = string_for_opt(opts, FALSE))) 2745. return FALSE; 2746. escapes(opts, opts); 2747. /* note: dummy monclass #0 has symbol value '\0'; we allow that-- 2748. attempting to set bouldersym to '^@'/'\0' will reset to default */ 2749. if (def_char_to_monclass(opts[0]) != MAXMCLASSES) 2750. clash = opts[0] ? 1 : 0; 2751. else if (opts[0] >= '1' && opts[0] < WARNCOUNT + '0') 2752. clash = 2; 2753. if (clash) { 2754. /* symbol chosen matches a used monster or warning 2755. symbol which is not good - reject it */ 2756. config_error_add( 2757. "Badoption - boulder symbol '%s' would conflict with a %s symbol", 2758. visctrl(opts[0]), 2759. (clash == 1) ? "monster" : "warning"); 2760. } else { 2761. /* 2762. * Override the default boulder symbol. 2763. */ 2764. ov_primary_syms[SYM_BOULDER + SYM_OFF_X] = (nhsym) opts[0]; 2765. ov_rogue_syms[SYM_BOULDER + SYM_OFF_X] = (nhsym) opts[0]; 2766. /* for 'initial', update of BOULDER symbol is done in 2767. initoptions_finish(), after all symset options 2768. have been processed */ 2769. if (!initial) { 2770. nhsym sym = get_othersym(SYM_BOULDER, 2771. Is_rogue_level(&u.uz) ? ROGUESET : PRIMARY); 2772. if (sym) 2773. showsyms[SYM_BOULDER + SYM_OFF_X] = sym; 2774. need_redraw = TRUE; 2775. } 2776. } 2777. return retval; 2778. #else 2779. config_error_add("'%s' no longer supported; use S_boulder:c instead", 2780. fullname); 2781. return FALSE; 2782. #endif 2783. } 2784. 2785. /* name:string */ 2786. fullname = "name"; 2787. if (match_optname(opts, fullname, 4, TRUE)) { 2788. if (duplicate) 2789. complain_about_duplicate(opts, 1); 2790. if (negated) { 2791. bad_negation(fullname, FALSE); 2792. return FALSE; 2793. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2794. nmcpy(plname, op, PL_NSIZ); 2795. } else 2796. return FALSE; 2797. return retval; 2798. } 2799. 2800. /* altkeyhandler:string */ 2801. fullname = "altkeyhandler"; 2802. if (match_optname(opts, fullname, 4, TRUE)) { 2803. if (duplicate) 2804. complain_about_duplicate(opts, 1); 2805. if (negated) { 2806. bad_negation(fullname, FALSE); 2807. return FALSE; 2808. } else if ((op = string_for_opt(opts, negated)) != 0) { 2809. #if defined(WIN32) && defined(TTY_GRAPHICS) 2810. set_altkeyhandler(op); 2811. #endif 2812. } else 2813. return FALSE; 2814. return retval; 2815. } 2816. 2817. /* WINCAP 2818. * align_status:[left|top|right|bottom] */ 2819. fullname = "align_status"; 2820. if (match_optname(opts, fullname, sizeof "align_status" - 1, TRUE)) { 2821. op = string_for_opt(opts, negated); 2822. if (op && !negated) { 2823. if (!strncmpi(op, "left", sizeof "left" - 1)) 2824. iflags.wc_align_status = ALIGN_LEFT; 2825. else if (!strncmpi(op, "top", sizeof "top" - 1)) 2826. iflags.wc_align_status = ALIGN_TOP; 2827. else if (!strncmpi(op, "right", sizeof "right" - 1)) 2828. iflags.wc_align_status = ALIGN_RIGHT; 2829. else if (!strncmpi(op, "bottom", sizeof "bottom" - 1)) 2830. iflags.wc_align_status = ALIGN_BOTTOM; 2831. else { 2832. config_error_add("Unknown %s parameter '%s'", fullname, op); 2833. return FALSE; 2834. } 2835. } else if (negated) { 2836. bad_negation(fullname, TRUE); 2837. return FALSE; 2838. } 2839. return retval; 2840. } 2841. 2842. /* WINCAP 2843. * align_message:[left|top|right|bottom] */ 2844. fullname = "align_message"; 2845. if (match_optname(opts, fullname, sizeof "align_message" - 1, TRUE)) { 2846. if (duplicate) 2847. complain_about_duplicate(opts, 1); 2848. op = string_for_opt(opts, negated); 2849. if (op && !negated) { 2850. if (!strncmpi(op, "left", sizeof "left" - 1)) 2851. iflags.wc_align_message = ALIGN_LEFT; 2852. else if (!strncmpi(op, "top", sizeof "top" - 1)) 2853. iflags.wc_align_message = ALIGN_TOP; 2854. else if (!strncmpi(op, "right", sizeof "right" - 1)) 2855. iflags.wc_align_message = ALIGN_RIGHT; 2856. else if (!strncmpi(op, "bottom", sizeof "bottom" - 1)) 2857. iflags.wc_align_message = ALIGN_BOTTOM; 2858. else { 2859. config_error_add("Unknown %s parameter '%s'", fullname, op); 2860. return FALSE; 2861. } 2862. } else if (negated) { 2863. bad_negation(fullname, TRUE); 2864. return FALSE; 2865. } 2866. return retval; 2867. } 2868. 2869. /* the order to list inventory */ 2870. fullname = "packorder"; 2871. if (match_optname(opts, fullname, 4, TRUE)) { 2872. if (duplicate) 2873. complain_about_duplicate(opts, 1); 2874. if (negated) { 2875. bad_negation(fullname, FALSE); 2876. return FALSE; 2877. } else if (!(op = string_for_opt(opts, FALSE))) 2878. return FALSE; 2879. 2880. if (!change_inv_order(op)) 2881. return FALSE; 2882. return retval; 2883. } 2884. 2885. /* user can change required response for some prompts (quit, die, hit), 2886. or add an extra prompt (pray, Remove) that isn't ordinarily there */ 2887. fullname = "paranoid_confirmation"; 2888. if (match_optname(opts, fullname, 8, TRUE)) { 2889. /* at present we don't complain about duplicates for this 2890. option, but we do throw away the old settings whenever 2891. we process a new one [clearing old flags is essential 2892. for handling default paranoid_confirm:pray sanely] */ 2893. flags.paranoia_bits = 0; /* clear all */ 2894. if (negated) { 2895. flags.paranoia_bits = 0; /* [now redundant...] */ 2896. } else if ((op = string_for_opt(opts, TRUE)) != 0) { 2897. char *pp, buf[BUFSZ]; 2898. 2899. strncpy(buf, op, sizeof buf - 1); 2900. buf[sizeof buf - 1] = '\0'; 2901. op = mungspaces(buf); 2902. for (;;) { 2903. /* We're looking to parse 2904. "paranoid_confirm:whichone wheretwo whothree" 2905. and "paranoid_confirm:" prefix has already 2906. been stripped off by the time we get here */ 2907. pp = index(op, ' '); 2908. if (pp) 2909. *pp = '\0'; 2910. /* we aren't matching option names but match_optname() 2911. does what we want once we've broken the space 2912. delimited aggregate into separate tokens */ 2913. for (i = 0; i < SIZE(paranoia); ++i) { 2914. if (match_optname(op, paranoia[i].argname, 2915. paranoia[i].argMinLen, FALSE) 2916. || (paranoia[i].synonym 2917. && match_optname(op, paranoia[i].synonym, 2918. paranoia[i].synMinLen, FALSE))) { 2919. if (paranoia[i].flagmask) 2920. flags.paranoia_bits |= paranoia[i].flagmask; 2921. else /* 0 == "none", so clear all */ 2922. flags.paranoia_bits = 0; 2923. break; 2924. } 2925. } 2926. if (i == SIZE(paranoia)) { 2927. /* didn't match anything, so arg is bad; 2928. any flags already set will stay set */ 2929. config_error_add("Unknown %s parameter '%s'", 2930. fullname, op); 2931. return FALSE; 2932. } 2933. /* move on to next token */ 2934. if (pp) 2935. op = pp + 1; 2936. else 2937. break; /* no next token */ 2938. } /* for(;;) */ 2939. } else 2940. return FALSE; 2941. return retval; 2942. } 2943. 2944. /* accept deprecated boolean; superseded by paranoid_confirm:pray */ 2945. fullname = "prayconfirm"; 2946. if (match_optname(opts, fullname, 4, FALSE)) { 2947. if (negated) 2948. flags.paranoia_bits &= ~PARANOID_PRAY; 2949. else 2950. flags.paranoia_bits |= PARANOID_PRAY; 2951. return retval; 2952. } 2953. 2954. /* maximum burden picked up before prompt (Warren Cheung) */ 2955. fullname = "pickup_burden"; 2956. if (match_optname(opts, fullname, 8, TRUE)) { 2957. if (duplicate) 2958. complain_about_duplicate(opts, 1); 2959. if (negated) { 2960. bad_negation(fullname, FALSE); 2961. return FALSE; 2962. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 2963. switch (lowc(*op)) { 2964. case 'u': /* Unencumbered */ 2965. flags.pickup_burden = UNENCUMBERED; 2966. break; 2967. case 'b': /* Burdened (slight encumbrance) */ 2968. flags.pickup_burden = SLT_ENCUMBER; 2969. break; 2970. case 's': /* streSsed (moderate encumbrance) */ 2971. flags.pickup_burden = MOD_ENCUMBER; 2972. break; 2973. case 'n': /* straiNed (heavy encumbrance) */ 2974. flags.pickup_burden = HVY_ENCUMBER; 2975. break; 2976. case 'o': /* OverTaxed (extreme encumbrance) */ 2977. case 't': 2978. flags.pickup_burden = EXT_ENCUMBER; 2979. break; 2980. case 'l': /* overLoaded */ 2981. flags.pickup_burden = OVERLOADED; 2982. break; 2983. default: 2984. config_error_add("Unknown %s parameter '%s'", fullname, op); 2985. return FALSE; 2986. } 2987. } else 2988. return FALSE; 2989. return retval; 2990. } 2991. 2992. /* types of objects to pick up automatically */ 2993. fullname = "pickup_types"; 2994. if (match_optname(opts, fullname, 8, TRUE)) { 2995. char ocl[MAXOCLASSES + 1], tbuf[MAXOCLASSES + 1], 2996. qbuf[QBUFSZ], abuf[BUFSZ]; 2997. int oc_sym; 2998. boolean badopt = FALSE, compat = (strlen(opts) <= 6), use_menu; 2999. 3000. if (duplicate) 3001. complain_about_duplicate(opts, 1); 3002. oc_to_str(flags.pickup_types, tbuf); 3003. flags.pickup_types[0] = '\0'; /* all */ 3004. op = string_for_opt(opts, (compat || !initial)); 3005. if (!op) { 3006. if (compat || negated || initial) { 3007. /* for backwards compatibility, "pickup" without a 3008. value is a synonym for autopickup of all types 3009. (and during initialization, we can't prompt yet) */ 3010. flags.pickup = !negated; 3011. return retval; 3012. } 3013. oc_to_str(flags.inv_order, ocl); 3014. use_menu = TRUE; 3015. if (flags.menu_style == MENU_TRADITIONAL 3016. || flags.menu_style == MENU_COMBINATION) { 3017. boolean wasspace; 3018. 3019. use_menu = FALSE; 3020. Sprintf(qbuf, "New %s: [%s am] (%s)", fullname, ocl, 3021. *tbuf ? tbuf : "all"); 3022. abuf[0] = '\0'; 3023. getlin(qbuf, abuf); 3024. wasspace = (abuf[0] == ' '); /* before mungspaces */ 3025. op = mungspaces(abuf); 3026. if (wasspace && !abuf[0]) 3027. ; /* one or more spaces will remove old value */ 3028. else if (!abuf[0] || abuf[0] == '\033') 3029. op = tbuf; /* restore */ 3030. else if (abuf[0] == 'm') 3031. use_menu = TRUE; 3032. /* note: abuf[0]=='a' is already handled via clearing the 3033. the old value (above) as a default action */ 3034. } 3035. if (use_menu) { 3036. if (wizard && !index(ocl, VENOM_SYM)) 3037. strkitten(ocl, VENOM_SYM); 3038. (void) choose_classes_menu("Autopickup what?", 1, TRUE, ocl, 3039. tbuf); 3040. op = tbuf; 3041. } 3042. } 3043. if (negated) { 3044. bad_negation(fullname, TRUE); 3045. return FALSE; 3046. } 3047. while (*op == ' ') 3048. op++; 3049. if (*op != 'a' && *op != 'A') { 3050. num = 0; 3051. while (*op) { 3052. oc_sym = def_char_to_objclass(*op); 3053. /* make sure all are valid obj symbols occurring once */ 3054. if (oc_sym != MAXOCLASSES 3055. && !index(flags.pickup_types, oc_sym)) { 3056. flags.pickup_types[num] = (char) oc_sym; 3057. flags.pickup_types[++num] = '\0'; 3058. } else 3059. badopt = TRUE; 3060. op++; 3061. } 3062. if (badopt) { 3063. config_error_add("Unknown %s parameter '%s'", fullname, op); 3064. return FALSE; 3065. } 3066. } 3067. return retval; 3068. } 3069. 3070. /* pile limit: when walking over objects, number which triggers 3071. "there are several/many objects here" instead of listing them */ 3072. fullname = "pile_limit"; 3073. if (match_optname(opts, fullname, 4, TRUE)) { 3074. if (duplicate) 3075. complain_about_duplicate(opts, 1); 3076. op = string_for_opt(opts, negated); 3077. if ((negated && !op) || (!negated && op)) 3078. flags.pile_limit = negated ? 0 : atoi(op); 3079. else if (negated) { 3080. bad_negation(fullname, TRUE); 3081. return FALSE; 3082. } else /* !op */ 3083. flags.pile_limit = PILE_LIMIT_DFLT; 3084. /* sanity check */ 3085. if (flags.pile_limit < 0) 3086. flags.pile_limit = PILE_LIMIT_DFLT; 3087. return retval; 3088. } 3089. 3090. /* play mode: normal, explore/discovery, or debug/wizard */ 3091. fullname = "playmode"; 3092. if (match_optname(opts, fullname, 4, TRUE)) { 3093. if (duplicate) 3094. complain_about_duplicate(opts, 1); 3095. if (negated) 3096. bad_negation(fullname, FALSE); 3097. if (duplicate || negated) 3098. return FALSE; 3099. op = string_for_opt(opts, FALSE); 3100. if (!op) 3101. return FALSE; 3102. if (!strncmpi(op, "normal", 6) || !strcmpi(op, "play")) { 3103. wizard = discover = FALSE; 3104. } else if (!strncmpi(op, "explore", 6) 3105. || !strncmpi(op, "discovery", 6)) { 3106. wizard = FALSE, discover = TRUE; 3107. } else if (!strncmpi(op, "debug", 5) || !strncmpi(op, "wizard", 6)) { 3108. wizard = TRUE, discover = FALSE; 3109. } else { 3110. config_error_add("Invalid value for \"%s\":%s", fullname, op); 3111. return FALSE; 3112. } 3113. return retval; 3114. } 3115. 3116. /* WINCAP 3117. * player_selection: dialog | prompt/prompts/prompting */ 3118. fullname = "player_selection"; 3119. if (match_optname(opts, fullname, sizeof "player_selection" - 1, TRUE)) { 3120. if (duplicate) 3121. complain_about_duplicate(opts, 1); 3122. op = string_for_opt(opts, negated); 3123. if (op && !negated) { 3124. if (!strncmpi(op, "dialog", sizeof "dialog" - 1)) { 3125. iflags.wc_player_selection = VIA_DIALOG; 3126. } else if (!strncmpi(op, "prompt", sizeof "prompt" - 1)) { 3127. iflags.wc_player_selection = VIA_PROMPTS; 3128. } else { 3129. config_error_add("Unknown %s parameter '%s'", fullname, op); 3130. return FALSE; 3131. } 3132. } else if (negated) { 3133. bad_negation(fullname, TRUE); 3134. return FALSE; 3135. } 3136. return retval; 3137. } 3138. 3139. /* things to disclose at end of game */ 3140. fullname = "disclose"; 3141. if (match_optname(opts, fullname, 7, TRUE)) { 3142. /* 3143. * The order that the end_disclose options are stored: 3144. * inventory, attribs, vanquished, genocided, 3145. * conduct, overview. 3146. * There is an array in flags: 3147. * end_disclose[NUM_DISCLOSURE_OPT]; 3148. * with option settings for the each of the following: 3149. * iagvc [see disclosure_options in decl.c]: 3150. * Allowed setting values in that array are: 3151. * DISCLOSE_PROMPT_DEFAULT_YES ask with default answer yes 3152. * DISCLOSE_PROMPT_DEFAULT_NO ask with default answer no 3153. * DISCLOSE_YES_WITHOUT_PROMPT always disclose and don't ask 3154. * DISCLOSE_NO_WITHOUT_PROMPT never disclose and don't ask 3155. * DISCLOSE_PROMPT_DEFAULT_SPECIAL for 'vanquished' only... 3156. * DISCLOSE_SPECIAL_WITHOUT_PROMPT ...to set up sort order. 3157. * 3158. * Those setting values can be used in the option 3159. * string as a prefix to get the desired behaviour. 3160. * 3161. * For backward compatibility, no prefix is required, 3162. * and the presence of a i,a,g,v, or c without a prefix 3163. * sets the corresponding value to DISCLOSE_YES_WITHOUT_PROMPT. 3164. */ 3165. int idx, prefix_val; 3166. 3167. if (duplicate) 3168. complain_about_duplicate(opts, 1); 3169. op = string_for_opt(opts, TRUE); 3170. if (op && negated) { 3171. bad_negation(fullname, TRUE); 3172. return FALSE; 3173. } 3174. /* "disclose" without a value means "all with prompting" 3175. and negated means "none without prompting" */ 3176. if (!op || !strcmpi(op, "all") || !strcmpi(op, "none")) { 3177. if (op && !strcmpi(op, "none")) 3178. negated = TRUE; 3179. for (num = 0; num < NUM_DISCLOSURE_OPTIONS; num++) 3180. flags.end_disclose[num] = negated 3181. ? DISCLOSE_NO_WITHOUT_PROMPT 3182. : DISCLOSE_PROMPT_DEFAULT_YES; 3183. return retval; 3184. } 3185. 3186. num = 0; 3187. prefix_val = -1; 3188. while (*op && num < sizeof flags.end_disclose - 1) { 3189. static char valid_settings[] = { 3190. DISCLOSE_PROMPT_DEFAULT_YES, DISCLOSE_PROMPT_DEFAULT_NO, 3191. DISCLOSE_PROMPT_DEFAULT_SPECIAL, 3192. DISCLOSE_YES_WITHOUT_PROMPT, DISCLOSE_NO_WITHOUT_PROMPT, 3193. DISCLOSE_SPECIAL_WITHOUT_PROMPT, '\0' 3194. }; 3195. register char c, *dop; 3196. 3197. c = lowc(*op); 3198. if (c == 'k') 3199. c = 'v'; /* killed -> vanquished */ 3200. if (c == 'd') 3201. c = 'o'; /* dungeon -> overview */ 3202. dop = index(disclosure_options, c); 3203. if (dop) { 3204. idx = (int) (dop - disclosure_options); 3205. if (idx < 0 || idx > NUM_DISCLOSURE_OPTIONS - 1) { 3206. impossible("bad disclosure index %d %c", idx, c); 3207. continue; 3208. } 3209. if (prefix_val != -1) { 3210. if (*dop != 'v') { 3211. if (prefix_val == DISCLOSE_PROMPT_DEFAULT_SPECIAL) 3212. prefix_val = DISCLOSE_PROMPT_DEFAULT_YES; 3213. if (prefix_val == DISCLOSE_SPECIAL_WITHOUT_PROMPT) 3214. prefix_val = DISCLOSE_YES_WITHOUT_PROMPT; 3215. } 3216. flags.end_disclose[idx] = prefix_val; 3217. prefix_val = -1; 3218. } else 3219. flags.end_disclose[idx] = DISCLOSE_YES_WITHOUT_PROMPT; 3220. } else if (index(valid_settings, c)) { 3221. prefix_val = c; 3222. } else if (c == ' ') { 3223. ; /* do nothing */ 3224. } else { 3225. config_error_add("Unknown %s parameter '%c'", fullname, *op); 3226. return FALSE; 3227. } 3228. op++; 3229. } 3230. return retval; 3231. } 3232. 3233. /* scores:5t[op] 5a[round] o[wn] */ 3234. fullname = "scores"; 3235. if (match_optname(opts, fullname, 4, TRUE)) { 3236. if (duplicate) 3237. complain_about_duplicate(opts, 1); 3238. if (negated) { 3239. bad_negation(fullname, FALSE); 3240. return FALSE; 3241. } 3242. if (!(op = string_for_opt(opts, FALSE))) 3243. return FALSE; 3244. 3245. while (*op) { 3246. int inum = 1; 3247. 3248. if (digit(*op)) { 3249. inum = atoi(op); 3250. while (digit(*op)) 3251. op++; 3252. } else if (*op == '!') { 3253. negated = !negated; 3254. op++; 3255. } 3256. while (*op == ' ') 3257. op++; 3258. 3259. switch (*op) { 3260. case 't': 3261. case 'T': 3262. flags.end_top = inum; 3263. break; 3264. case 'a': 3265. case 'A': 3266. flags.end_around = inum; 3267. break; 3268. case 'o': 3269. case 'O': 3270. flags.end_own = !negated; 3271. break; 3272. default: 3273. config_error_add("Unknown %s parameter '%s'", fullname, op); 3274. return FALSE; 3275. } 3276. /* "3a" is sufficient but accept "3around" (or "3abracadabra") */ 3277. while (letter(*op)) 3278. op++; 3279. /* t, a, and o can be separated by space(s) or slash or both */ 3280. while (*op == ' ') 3281. op++; 3282. if (*op == '/') 3283. op++; 3284. } 3285. return retval; 3286. } 3287. 3288. fullname = "sortloot"; 3289. if (match_optname(opts, fullname, 4, TRUE)) { 3290. op = string_for_env_opt(fullname, opts, FALSE); 3291. if (op) { 3292. char c = lowc(*op); 3293. 3294. switch (c) { 3295. case 'n': /* none */ 3296. case 'l': /* loot (pickup) */ 3297. case 'f': /* full (pickup + invent) */ 3298. flags.sortloot = c; 3299. break; 3300. default: 3301. config_error_add("Unknown %s parameter '%s'", fullname, op); 3302. return FALSE; 3303. } 3304. } else 3305. return FALSE; 3306. return retval; 3307. } 3308. 3309. fullname = "suppress_alert"; 3310. if (match_optname(opts, fullname, 4, TRUE)) { 3311. if (duplicate) 3312. complain_about_duplicate(opts, 1); 3313. op = string_for_opt(opts, negated); 3314. if (negated) { 3315. bad_negation(fullname, FALSE); 3316. return FALSE; 3317. } else if (op) 3318. (void) feature_alert_opts(op, fullname); 3319. return retval; 3320. } 3321. 3322. #ifdef VIDEOSHADES 3323. /* videocolors:string */ 3324. fullname = "videocolors"; 3325. if (match_optname(opts, fullname, 6, TRUE) 3326. || match_optname(opts, "videocolours", 10, TRUE)) { 3327. if (duplicate) 3328. complain_about_duplicate(opts, 1); 3329. if (negated) { 3330. bad_negation(fullname, FALSE); 3331. return FALSE; 3332. } else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { 3333. return FALSE; 3334. } 3335. if (!assign_videocolors(opts)) { 3336. config_error_add("Unknown error handling '%s'", fullname); 3337. return FALSE; 3338. } 3339. return retval; 3340. } 3341. /* videoshades:string */ 3342. fullname = "videoshades"; 3343. if (match_optname(opts, fullname, 6, TRUE)) { 3344. if (duplicate) 3345. complain_about_duplicate(opts, 1); 3346. if (negated) { 3347. bad_negation(fullname, FALSE); 3348. return FALSE; 3349. } else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { 3350. return FALSE; 3351. } 3352. if (!assign_videoshades(opts)) { 3353. config_error_add("Unknown error handling '%s'", fullname); 3354. return FALSE; 3355. } 3356. return retval; 3357. } 3358. #endif /* VIDEOSHADES */ 3359. 3360. #ifdef MSDOS 3361. #ifdef NO_TERMS 3362. /* video:string -- must be after longer tests */ 3363. fullname = "video"; 3364. if (match_optname(opts, fullname, 5, TRUE)) { 3365. if (duplicate) 3366. complain_about_duplicate(opts, 1); 3367. if (negated) { 3368. bad_negation(fullname, FALSE); 3369. return FALSE; 3370. } else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { 3371. return FALSE; 3372. } 3373. if (!assign_video(opts)) { 3374. config_error_add("Unknown error handling '%s'", fullname); 3375. return FALSE; 3376. } 3377. return retval; 3378. } 3379. #endif /* NO_TERMS */ 3380. /* soundcard:string -- careful not to match boolean 'sound' */ 3381. fullname = "soundcard"; 3382. if (match_optname(opts, fullname, 6, TRUE)) { 3383. if (duplicate) 3384. complain_about_duplicate(opts, 1); 3385. if (negated) { 3386. bad_negation(fullname, FALSE); 3387. return FALSE; 3388. } else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { 3389. return FALSE; 3390. } 3391. if (!assign_soundcard(opts)) { 3392. config_error_add("Unknown error handling '%s'", fullname); 3393. return FALSE; 3394. } 3395. return retval; 3396. } 3397. #endif /* MSDOS */ 3398. 3399. /* WINCAP 3400. * 3401. * map_mode:[tiles|ascii4x6|ascii6x8|ascii8x8|ascii16x8|ascii7x12 3402. * |ascii8x12|ascii16x12|ascii12x16|ascii10x18|fit_to_screen 3403. * |ascii_fit_to_screen|tiles_fit_to_screen] 3404. */ 3405. fullname = "map_mode"; 3406. if (match_optname(opts, fullname, sizeof "map_mode" - 1, TRUE)) { 3407. if (duplicate) 3408. complain_about_duplicate(opts, 1); 3409. op = string_for_opt(opts, negated); 3410. if (op && !negated) { 3411. if (!strcmpi(op, "tiles")) 3412. iflags.wc_map_mode = MAP_MODE_TILES; 3413. else if (!strncmpi(op, "ascii4x6", sizeof "ascii4x6" - 1)) 3414. iflags.wc_map_mode = MAP_MODE_ASCII4x6; 3415. else if (!strncmpi(op, "ascii6x8", sizeof "ascii6x8" - 1)) 3416. iflags.wc_map_mode = MAP_MODE_ASCII6x8; 3417. else if (!strncmpi(op, "ascii8x8", sizeof "ascii8x8" - 1)) 3418. iflags.wc_map_mode = MAP_MODE_ASCII8x8; 3419. else if (!strncmpi(op, "ascii16x8", sizeof "ascii16x8" - 1)) 3420. iflags.wc_map_mode = MAP_MODE_ASCII16x8; 3421. else if (!strncmpi(op, "ascii7x12", sizeof "ascii7x12" - 1)) 3422. iflags.wc_map_mode = MAP_MODE_ASCII7x12; 3423. else if (!strncmpi(op, "ascii8x12", sizeof "ascii8x12" - 1)) 3424. iflags.wc_map_mode = MAP_MODE_ASCII8x12; 3425. else if (!strncmpi(op, "ascii16x12", sizeof "ascii16x12" - 1)) 3426. iflags.wc_map_mode = MAP_MODE_ASCII16x12; 3427. else if (!strncmpi(op, "ascii12x16", sizeof "ascii12x16" - 1)) 3428. iflags.wc_map_mode = MAP_MODE_ASCII12x16; 3429. else if (!strncmpi(op, "ascii10x18", sizeof "ascii10x18" - 1)) 3430. iflags.wc_map_mode = MAP_MODE_ASCII10x18; 3431. else if (!strncmpi(op, "fit_to_screen", 3432. sizeof "fit_to_screen" - 1)) 3433. iflags.wc_map_mode = MAP_MODE_ASCII_FIT_TO_SCREEN; 3434. else if (!strncmpi(op, "ascii_fit_to_screen", 3435. sizeof "ascii_fit_to_screen" - 1)) 3436. iflags.wc_map_mode = MAP_MODE_ASCII_FIT_TO_SCREEN; 3437. else if (!strncmpi(op, "tiles_fit_to_screen", 3438. sizeof "tiles_fit_to_screen" - 1)) 3439. iflags.wc_map_mode = MAP_MODE_TILES_FIT_TO_SCREEN; 3440. else { 3441. config_error_add("Unknown %s parameter '%s'", fullname, op); 3442. return FALSE; 3443. } 3444. } else if (negated) { 3445. bad_negation(fullname, TRUE); 3446. return FALSE; 3447. } 3448. return retval; 3449. } 3450. 3451. /* WINCAP 3452. * scroll_amount:nn */ 3453. fullname = "scroll_amount"; 3454. if (match_optname(opts, fullname, sizeof "scroll_amount" - 1, TRUE)) { 3455. if (duplicate) 3456. complain_about_duplicate(opts, 1); 3457. op = string_for_opt(opts, negated); 3458. if ((negated && !op) || (!negated && op)) { 3459. iflags.wc_scroll_amount = negated ? 1 : atoi(op); 3460. } else if (negated) { 3461. bad_negation(fullname, TRUE); 3462. return FALSE; 3463. } 3464. return retval; 3465. } 3466. 3467. /* WINCAP 3468. * scroll_margin:nn */ 3469. fullname = "scroll_margin"; 3470. if (match_optname(opts, fullname, sizeof "scroll_margin" - 1, TRUE)) { 3471. if (duplicate) 3472. complain_about_duplicate(opts, 1); 3473. op = string_for_opt(opts, negated); 3474. if ((negated && !op) || (!negated && op)) { 3475. iflags.wc_scroll_margin = negated ? 5 : atoi(op); 3476. } else if (negated) { 3477. bad_negation(fullname, TRUE); 3478. return FALSE; 3479. } 3480. return retval; 3481. } 3482. 3483. fullname = "subkeyvalue"; 3484. if (match_optname(opts, fullname, 5, TRUE)) { 3485. /* no duplicate complaint here */ 3486. if (negated) { 3487. bad_negation(fullname, FALSE); 3488. return FALSE; 3489. #if defined(WIN32) 3490. } else { 3491. op = string_for_opt(opts, 0); 3492. if (!op) 3493. return FALSE; 3494. #ifdef TTY_GRAPHICS 3495. map_subkeyvalue(op); 3496. #endif 3497. #endif 3498. } 3499. return retval; 3500. } 3501. 3502. /* WINCAP 3503. * tile_width:nn */ 3504. fullname = "tile_width"; 3505. if (match_optname(opts, fullname, sizeof "tile_width" - 1, TRUE)) { 3506. if (duplicate) 3507. complain_about_duplicate(opts, 1); 3508. op = string_for_opt(opts, negated); 3509. if ((negated && !op) || (!negated && op)) { 3510. iflags.wc_tile_width = negated ? 0 : atoi(op); 3511. } else if (negated) { 3512. bad_negation(fullname, TRUE); 3513. return FALSE; 3514. } 3515. return retval; 3516. } 3517. /* WINCAP 3518. * tile_file:name */ 3519. fullname = "tile_file"; 3520. if (match_optname(opts, fullname, sizeof "tile_file" - 1, TRUE)) { 3521. if (duplicate) 3522. complain_about_duplicate(opts, 1); 3523. if ((op = string_for_opt(opts, FALSE)) != 0) { 3524. if (iflags.wc_tile_file) 3525. free(iflags.wc_tile_file); 3526. iflags.wc_tile_file = dupstr(op); 3527. } else 3528. return FALSE; 3529. return retval; 3530. } 3531. /* WINCAP 3532. * tile_height:nn */ 3533. fullname = "tile_height"; 3534. if (match_optname(opts, fullname, sizeof "tile_height" - 1, TRUE)) { 3535. if (duplicate) 3536. complain_about_duplicate(opts, 1); 3537. op = string_for_opt(opts, negated); 3538. if ((negated && !op) || (!negated && op)) { 3539. iflags.wc_tile_height = negated ? 0 : atoi(op); 3540. } else if (negated) { 3541. bad_negation(fullname, TRUE); 3542. return FALSE; 3543. } 3544. return retval; 3545. } 3546. 3547. /* WINCAP 3548. * vary_msgcount:nn */ 3549. fullname = "vary_msgcount"; 3550. if (match_optname(opts, fullname, sizeof "vary_msgcount" - 1, TRUE)) { 3551. if (duplicate) 3552. complain_about_duplicate(opts, 1); 3553. op = string_for_opt(opts, negated); 3554. if ((negated && !op) || (!negated && op)) { 3555. iflags.wc_vary_msgcount = negated ? 0 : atoi(op); 3556. } else if (negated) { 3557. bad_negation(fullname, TRUE); 3558. return FALSE; 3559. } 3560. return retval; 3561. } 3562. 3563. /* 3564. * windowtype: option to choose the interface for binaries built 3565. * with support for more than one interface (tty + X11, for instance). 3566. * 3567. * Ideally, 'windowtype' should be processed first, because it 3568. * causes the wc_ and wc2_ flags to be set up. 3569. * For user, making it be first in a config file is trivial, use 3570. * OPTIONS=windowtype:Foo 3571. * as the first non-comment line of the file. 3572. * Making it first in NETHACKOPTIONS requires it to be at the _end_ 3573. * because comma-separated option strings are processed from right 3574. * to left. 3575. */ 3576. fullname = "windowtype"; 3577. if (match_optname(opts, fullname, 3, TRUE)) { 3578. if (iflags.windowtype_locked) 3579. return retval; 3580. if (duplicate) 3581. complain_about_duplicate(opts, 1); 3582. if (negated) { 3583. bad_negation(fullname, FALSE); 3584. return FALSE; 3585. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 3586. if (!iflags.windowtype_deferred) { 3587. char buf[WINTYPELEN]; 3588. 3589. nmcpy(buf, op, WINTYPELEN); 3590. choose_windows(buf); 3591. } else { 3592. nmcpy(chosen_windowtype, op, WINTYPELEN); 3593. } 3594. } else 3595. return FALSE; 3596. return retval; 3597. } 3598. 3599. #ifdef WINCHAIN 3600. fullname = "windowchain"; 3601. if (match_optname(opts, fullname, 3, TRUE)) { 3602. if (negated) { 3603. bad_negation(fullname, FALSE); 3604. return FALSE; 3605. } else if ((op = string_for_env_opt(fullname, opts, FALSE)) != 0) { 3606. char buf[WINTYPELEN]; 3607. 3608. nmcpy(buf, op, WINTYPELEN); 3609. addto_windowchain(buf); 3610. } else 3611. return FALSE; 3612. return retval; 3613. } 3614. #endif 3615. 3616. /* WINCAP 3617. * setting window colors 3618. * syntax: windowcolors=menu foregrnd/backgrnd text foregrnd/backgrnd 3619. */ 3620. fullname = "windowcolors"; 3621. if (match_optname(opts, fullname, 7, TRUE)) { 3622. if (duplicate) 3623. complain_about_duplicate(opts, 1); 3624. if ((op = string_for_opt(opts, FALSE)) != 0) { 3625. if (!wc_set_window_colors(op)) { 3626. config_error_add("Could not set %s '%s'", fullname, op); 3627. return FALSE; 3628. } 3629. } else if (negated) { 3630. bad_negation(fullname, TRUE); 3631. return FALSE; 3632. } 3633. return retval; 3634. } 3635. 3636. #ifdef CURSES_GRAPHICS 3637. /* WINCAP2 3638. * term_cols:amount or term_rows:amount */ 3639. fullname = "term_cols"; 3640. if (match_optname(opts, fullname, 8, TRUE) 3641. /* alternate spelling */ 3642. || match_optname(opts, "term_columns", 9, TRUE) 3643. /* different option but identical handlng */ 3644. || (fullname = "term_rows", match_optname(opts, fullname, 8, TRUE))) { 3645. long ltmp; 3646. 3647. op = string_for_opt(opts, negated); 3648. ltmp = atol(op); 3649. if (negated) { 3650. bad_negation(fullname, FALSE); 3651. retval = FALSE; 3652. 3653. /* this just checks atol() sanity, not logical window size sanity */ 3654. } else if (ltmp <= 0L || ltmp >= (long) LARGEST_INT) { 3655. config_error_add("Invalid %s: %ld", fullname, ltmp); 3656. retval = FALSE; 3657. 3658. } else { 3659. if (!strcmp(fullname, "term_rows")) 3660. iflags.wc2_term_rows = (int) ltmp; 3661. else /* !strcmp(fullname, "term_cols") */ 3662. iflags.wc2_term_cols = (int) ltmp; 3663. } 3664. return retval; 3665. } 3666. 3667. /* WINCAP2 3668. * petattr:string */ 3669. fullname = "petattr"; 3670. if (match_optname(opts, fullname, sizeof "petattr" - 1, TRUE)) { 3671. op = string_for_opt(opts, negated); 3672. if (op && negated) { 3673. bad_negation(fullname, TRUE); 3674. retval = FALSE; 3675. } else if (op) { 3676. #ifdef CURSES_GRAPHICS 3677. int itmp = curses_read_attrs(op); 3678. 3679. if (itmp == -1) { 3680. config_error_add("Unknown %s parameter '%s'", fullname, opts); 3681. retval = FALSE; 3682. } else 3683. iflags.wc2_petattr = itmp; 3684. #else 3685. /* non-curses windowports will not use this flag anyway 3686. * but the above will not compile if we don't have curses. 3687. * Just set it to a sensible default: */ 3688. iflags.wc2_petattr = ATR_INVERSE; 3689. #endif 3690. } else if (negated) { 3691. iflags.wc2_petattr = ATR_NONE; 3692. } 3693. if (retval) { 3694. iflags.hilite_pet = (iflags.wc2_petattr != ATR_NONE); 3695. if (!initial) 3696. need_redraw = TRUE; 3697. } 3698. return retval; 3699. } 3700. 3701. /* WINCAP2 3702. * windowborders:n */ 3703. fullname = "windowborders"; 3704. if (match_optname(opts, fullname, 10, TRUE)) { 3705. op = string_for_opt(opts, negated); 3706. if (negated && op) { 3707. bad_negation(fullname, TRUE); 3708. retval = FALSE; 3709. } else { 3710. int itmp; 3711. 3712. if (negated) 3713. itmp = 0; /* Off */ 3714. else if (!op) 3715. itmp = 1; /* On */ 3716. else /* Value supplied; expect 0 (off), 1 (on), or 2 (auto) */ 3717. itmp = atoi(op); 3718. 3719. if (itmp < 0 || itmp > 2) { 3720. config_error_add("Invalid %s (should be 0, 1, or 2): %s", 3721. fullname, opts); 3722. retval = FALSE; 3723. } else { 3724. iflags.wc2_windowborders = itmp; 3725. } 3726. } 3727. return retval; 3728. } 3729. #endif /* CURSES_GRAPHICS */ 3730. 3731. /* WINCAP2 3732. * statuslines:n */ 3733. fullname = "statuslines"; 3734. if (match_optname(opts, fullname, 11, TRUE)) { 3735. int itmp = 0; 3736. 3737. op = string_for_opt(opts, negated); 3738. if (negated) { 3739. bad_negation(fullname, TRUE); 3740. itmp = 2; 3741. retval = FALSE; 3742. } else if (op) { 3743. itmp = atoi(op); 3744. } 3745. if (itmp < 2 || itmp > 3) { 3746. config_error_add("'%s' requires a value of 2 or 3", fullname); 3747. retval = FALSE; 3748. } else { 3749. iflags.wc2_statuslines = itmp; 3750. if (!initial) 3751. need_redraw = TRUE; 3752. } 3753. return retval; 3754. } 3755. 3756. /* menustyle:traditional or combination or full or partial */ 3757. fullname = "menustyle"; 3758. if (match_optname(opts, fullname, 4, TRUE)) { 3759. int tmp; 3760. boolean val_required = (strlen(opts) > 5 && !negated); 3761. 3762. if (duplicate) 3763. complain_about_duplicate(opts, 1); 3764. if (!(op = string_for_opt(opts, !val_required))) { 3765. if (val_required) 3766. return FALSE; /* string_for_opt gave feedback */ 3767. tmp = negated ? 'n' : 'f'; 3768. } else { 3769. tmp = lowc(*op); 3770. } 3771. switch (tmp) { 3772. case 'n': /* none */ 3773. case 't': /* traditional: prompt for class(es) by symbol, 3774. prompt for each item within class(es) one at a time */ 3775. flags.menu_style = MENU_TRADITIONAL; 3776. break; 3777. case 'c': /* combination: prompt for class(es) by symbol, 3778. choose items within selected class(es) by menu */ 3779. flags.menu_style = MENU_COMBINATION; 3780. break; 3781. case 'f': /* full: choose class(es) by first menu, 3782. choose items within selected class(es) by second menu */ 3783. flags.menu_style = MENU_FULL; 3784. break; 3785. case 'p': /* partial: skip class filtering, 3786. choose items among all classes by menu */ 3787. flags.menu_style = MENU_PARTIAL; 3788. break; 3789. default: 3790. config_error_add("Unknown %s parameter '%s'", fullname, op); 3791. return FALSE; 3792. } 3793. return retval; 3794. } 3795. 3796. fullname = "menu_headings"; 3797. if (match_optname(opts, fullname, 12, TRUE)) { 3798. int tmpattr; 3799. 3800. if (duplicate) 3801. complain_about_duplicate(opts, 1); 3802. if (negated) { 3803. bad_negation(fullname, FALSE); 3804. return FALSE; 3805. } else if (!(opts = string_for_env_opt(fullname, opts, FALSE))) { 3806. return FALSE; 3807. } 3808. tmpattr = match_str2attr(opts, TRUE); 3809. if (tmpattr == -1) 3810. return FALSE; 3811. else 3812. iflags.menu_headings = tmpattr; 3813. return retval; 3814. } 3815. 3816. /* check for menu command mapping */ 3817. for (i = 0; i < SIZE(default_menu_cmd_info); i++) { 3818. fullname = default_menu_cmd_info[i].name; 3819. if (duplicate) 3820. complain_about_duplicate(opts, 1); 3821. if (match_optname(opts, fullname, (int) strlen(fullname), TRUE)) { 3822. if (negated) { 3823. bad_negation(fullname, FALSE); 3824. return FALSE; 3825. } else if ((op = string_for_opt(opts, FALSE)) != 0) { 3826. char c, op_buf[BUFSZ]; 3827. 3828. escapes(op, op_buf); 3829. c = *op_buf; 3830. 3831. if (illegal_menu_cmd_key(c)) 3832. return FALSE; 3833. 3834. add_menu_cmd_alias(c, default_menu_cmd_info[i].cmd); 3835. } 3836. return retval; 3837. } 3838. } 3839. 3840. /* hilite fields in status prompt */ 3841. fullname = "hilite_status"; 3842. if (match_optname(opts, fullname, 13, TRUE)) { 3843. #ifdef STATUS_HILITES 3844. if (duplicate) 3845. complain_about_duplicate(opts, 1); 3846. op = string_for_opt(opts, TRUE); 3847. if (op && negated) { 3848. clear_status_hilites(); 3849. return retval; 3850. } else if (!op) { 3851. config_error_add("Value is mandatory for hilite_status"); 3852. return FALSE; 3853. } 3854. if (!parse_status_hl1(op, tfrom_file)) 3855. return FALSE; 3856. return retval; 3857. #else 3858. config_error_add("'%s' is not supported", fullname); 3859. return FALSE; 3860. #endif 3861. } 3862. 3863. /* control over whether highlights should be displayed, and for how long */ 3864. fullname = "statushilites"; 3865. if (match_optname(opts, fullname, 9, TRUE)) { 3866. #ifdef STATUS_HILITES 3867. if (negated) { 3868. iflags.hilite_delta = 0L; 3869. } else { 3870. op = string_for_opt(opts, TRUE); 3871. iflags.hilite_delta = (!op || !*op) ? 3L : atol(op); 3872. if (iflags.hilite_delta < 0L) 3873. iflags.hilite_delta = 1L; 3874. } 3875. if (!tfrom_file) 3876. reset_status_hilites(); 3877. return retval; 3878. #else 3879. config_error_add("'%s' is not supported", fullname); 3880. return FALSE; 3881. #endif 3882. } 3883. 3884. fullname = "DECgraphics"; 3885. if (match_optname(opts, fullname, 3, TRUE)) { 3886. #ifdef BACKWARD_COMPAT 3887. boolean badflag = FALSE; 3888. 3889. if (duplicate) 3890. complain_about_duplicate(opts, 1); 3891. if (!negated) { 3892. /* There is no rogue level DECgraphics-specific set */ 3893. if (symset[PRIMARY].name) { 3894. badflag = TRUE; 3895. } else { 3896. symset[PRIMARY].name = dupstr(fullname); 3897. if (!read_sym_file(PRIMARY)) { 3898. badflag = TRUE; 3899. clear_symsetentry(PRIMARY, TRUE); 3900. } else 3901. switch_symbols(TRUE); 3902. } 3903. if (badflag) { 3904. config_error_add("Failure to load symbol set %s.", fullname); 3905. return FALSE; 3906. } 3907. } 3908. return retval; 3909. #else 3910. config_error_add("'%s' no longer supported; use 'symset:%s' instead", 3911. fullname, fullname); 3912. return FALSE; 3913. #endif 3914. } /* "DECgraphics" */ 3915. 3916. fullname = "IBMgraphics"; 3917. if (match_optname(opts, fullname, 3, TRUE)) { 3918. #ifdef BACKWARD_COMPAT 3919. const char *sym_name = fullname; 3920. boolean badflag = FALSE; 3921. 3922. if (duplicate) 3923. complain_about_duplicate(opts, 1); 3924. if (!negated) { 3925. for (i = 0; i < NUM_GRAPHICS; ++i) { 3926. if (symset[i].name) { 3927. badflag = TRUE; 3928. } else { 3929. if (i == ROGUESET) 3930. sym_name = "RogueIBM"; 3931. symset[i].name = dupstr(sym_name); 3932. if (!read_sym_file(i)) { 3933. badflag = TRUE; 3934. clear_symsetentry(i, TRUE); 3935. break; 3936. } 3937. } 3938. } 3939. if (badflag) { 3940. config_error_add("Failure to load symbol set %s.", sym_name); 3941. return FALSE; 3942. } else { 3943. switch_symbols(TRUE); 3944. if (!initial && Is_rogue_level(&u.uz)) 3945. assign_graphics(ROGUESET); 3946. } 3947. } 3948. return retval; 3949. #else 3950. config_error_add("'%s' no longer supported; use 'symset:%s' instead", 3951. fullname, fullname); 3952. return FALSE; 3953. #endif 3954. } /* "IBMgraphics" */ 3955. 3956. fullname = "MACgraphics"; 3957. if (match_optname(opts, fullname, 3, TRUE)) { 3958. #if defined(MAC_GRAPHICS_ENV) && defined(BACKWARD_COMPAT) 3959. boolean badflag = FALSE; 3960. 3961. if (duplicate) 3962. complain_about_duplicate(opts, 1); 3963. if (!negated) { 3964. if (symset[PRIMARY].name) { 3965. badflag = TRUE; 3966. } else { 3967. symset[PRIMARY].name = dupstr(fullname); 3968. if (!read_sym_file(PRIMARY)) { 3969. badflag = TRUE; 3970. clear_symsetentry(PRIMARY, TRUE); 3971. } 3972. } 3973. if (badflag) { 3974. config_error_add("Failure to load symbol set %s.", fullname); 3975. return FALSE; 3976. } else { 3977. switch_symbols(TRUE); 3978. if (!initial && Is_rogue_level(&u.uz)) 3979. assign_graphics(ROGUESET); 3980. } 3981. } 3982. return retval; 3983. #else /* !(MAC_GRAPHICS_ENV && BACKWARD_COMPAT) */ 3984. config_error_add("'%s' %s; use 'symset:%s' instead", 3985. fullname, 3986. #ifdef MAC_GRAPHICS_ENV /* implies BACKWARD_COMPAT is not defined */ 3987. "no longer supported", 3988. #else 3989. "is not supported", 3990. #endif 3991. fullname); 3992. return FALSE; 3993. #endif /* ?(MAC_GRAPHICS_ENV && BACKWARD_COMPAT) */ 3994. } /* "MACgraphics" */ 3995. 3996. /* 3997. * OK, if we still haven't recognized the option, check the boolean 3998. * options list. 3999. */ 4000. for (i = 0; boolopt[i].name; i++) { 4001. if (match_optname(opts, boolopt[i].name, 3, TRUE)) { 4002. /* options that don't exist */ 4003. if (!boolopt[i].addr) { 4004. if (!initial && !negated) 4005. pline_The("\"%s\" option is not available.", 4006. boolopt[i].name); 4007. return retval; 4008. } 4009. /* options that must come from config file */ 4010. if (!initial && (boolopt[i].optflags == SET_IN_FILE)) { 4011. rejectoption(boolopt[i].name); 4012. return retval; 4013. } 4014. 4015. op = string_for_opt(opts, TRUE); 4016. if (op) { 4017. if (negated) { 4018. config_error_add( 4019. "Negated boolean '%s' should not have a parameter", 4020. boolopt[i].name); 4021. return FALSE; 4022. } 4023. if (!strcmp(op, "true") || !strcmp(op, "yes")) { 4024. negated = FALSE; 4025. } else if (!strcmp(op, "false") || !strcmp(op, "no")) { 4026. negated = TRUE; 4027. } else { 4028. config_error_add("Illegal parameter for a boolean"); 4029. return FALSE; 4030. } 4031. } 4032. if (iflags.debug_fuzzer && !initial) { 4033. /* don't randomly toggle this/these */ 4034. if (boolopt[i].addr == &flags.silent) 4035. return TRUE; 4036. } 4037. 4038. *(boolopt[i].addr) = !negated; 4039. 4040. /* 0 means boolean opts */ 4041. if (duplicate_opt_detection(boolopt[i].name, 0)) 4042. complain_about_duplicate(boolopt[i].name, 0); 4043. #ifdef RLECOMP 4044. if (boolopt[i].addr == &iflags.rlecomp) 4045. set_savepref(iflags.rlecomp ? "rlecomp" : "!rlecomp"); 4046. #endif 4047. #ifdef ZEROCOMP 4048. if (boolopt[i].addr == &iflags.zerocomp) 4049. set_savepref(iflags.zerocomp ? "zerocomp" : "externalcomp"); 4050. #endif 4051. if (boolopt[i].addr == &iflags.wc_ascii_map) { 4052. /* toggling ascii_map; set tiled_map to its opposite; 4053. what does it mean to turn off ascii map if tiled map 4054. isn't supported? -- right now, we do nothing */ 4055. iflags.wc_tiled_map = negated; 4056. } else if (boolopt[i].addr == &iflags.wc_tiled_map) { 4057. /* toggling tiled_map; set ascii_map to its opposite; 4058. as with ascii_map, what does it mean to turn off tiled 4059. map if ascii map isn't supported? */ 4060. iflags.wc_ascii_map = negated; 4061. } 4062. /* only do processing below if setting with doset() */ 4063. if (initial) 4064. return retval; 4065. 4066. if (boolopt[i].addr == &flags.time 4067. #ifdef SCORE_ON_BOTL 4068. || boolopt[i].addr == &flags.showscore 4069. #endif 4070. || boolopt[i].addr == &flags.showexp) { 4071. if (VIA_WINDOWPORT()) 4072. status_initialize(REASSESS_ONLY); 4073. context.botl = TRUE; 4074. } else if (boolopt[i].addr == &flags.invlet_constant 4075. || boolopt[i].addr == &flags.sortpack 4076. || boolopt[i].addr == &iflags.implicit_uncursed) { 4077. if (!flags.invlet_constant) 4078. reassign(); 4079. update_inventory(); 4080. } else if (boolopt[i].addr == &flags.lit_corridor 4081. || boolopt[i].addr == &flags.dark_room) { 4082. /* 4083. * All corridor squares seen via night vision or 4084. * candles & lamps change. Update them by calling 4085. * newsym() on them. Don't do this if we are 4086. * initializing the options --- the vision system 4087. * isn't set up yet. 4088. */ 4089. vision_recalc(2); /* shut down vision */ 4090. vision_full_recalc = 1; /* delayed recalc */ 4091. if (iflags.use_color) 4092. need_redraw = TRUE; /* darkroom refresh */ 4093. } else if (boolopt[i].addr == &flags.showrace 4094. || boolopt[i].addr == &iflags.use_inverse 4095. || boolopt[i].addr == &iflags.hilite_pile 4096. || boolopt[i].addr == &iflags.perm_invent 4097. #ifdef CURSES_GRAPHICS 4098. || boolopt[i].addr == &iflags.cursesgraphics 4099. #endif 4100. || boolopt[i].addr == &iflags.wc_ascii_map 4101. || boolopt[i].addr == &iflags.wc_tiled_map) { 4102. need_redraw = TRUE; 4103. } else if (boolopt[i].addr == &iflags.hilite_pet) { 4104. #ifdef CURSES_GRAPHICS 4105. if (WINDOWPORT("curses")) { 4106. /* if we're enabling hilite_pet and petattr isn't set, 4107. set it to Inverse; if we're disabling, leave petattr 4108. alone so that re-enabling will get current value back */ 4109. if (iflags.hilite_pet && !iflags.wc2_petattr) 4110. iflags.wc2_petattr = curses_read_attrs("I"); 4111. } 4112. #endif 4113. need_redraw = TRUE; 4114. } else if (boolopt[i].addr == &iflags.wc2_hitpointbar) { 4115. if (VIA_WINDOWPORT()) { 4116. /* [is reassessment really needed here?] */ 4117. status_initialize(REASSESS_ONLY); 4118. need_redraw = TRUE; 4119. } 4120. #ifdef TEXTCOLOR 4121. } else if (boolopt[i].addr == &iflags.use_color) { 4122. need_redraw = TRUE; 4123. #ifdef TOS 4124. if (iflags.BIOS) { 4125. if (colors_changed) 4126. restore_colors(); 4127. else 4128. set_colors(); 4129. } 4130. #endif 4131. } else if (boolopt[i].addr == &iflags.use_menu_color 4132. || boolopt[i].addr == &iflags.wc2_guicolor) { 4133. update_inventory(); 4134. #endif /* TEXTCOLOR */ 4135. } 4136. return retval; 4137. } 4138. } 4139. 4140. /* Is it a symbol? */ 4141. if (strstr(opts, "S_") == opts && parsesymbols(opts, PRIMARY)) { 4142. switch_symbols(TRUE); 4143. check_gold_symbol(); 4144. return retval; 4145. } 4146. 4147. /* out of valid options */ 4148. config_error_add("Unknown option '%s'", opts); 4149. return FALSE; 4150. } 4151. 4152. /* parse key:command */ 4153. boolean 4154. parsebindings(bindings) 4155. char* bindings; 4156. { 4157. char *bind; 4158. char key; 4159. int i; 4160. boolean ret = FALSE; 4161. 4162. /* break off first binding from the rest; parse the rest */ 4163. if ((bind = index(bindings, ',')) != 0) { 4164. *bind++ = 0; 4165. ret |= parsebindings(bind); 4166. } 4167. 4168. /* parse a single binding: first split around : */ 4169. if (! (bind = index(bindings, ':'))) 4170. return FALSE; /* it's not a binding */ 4171. *bind++ = 0; 4172. 4173. /* read the key to be bound */ 4174. key = txt2key(bindings); 4175. if (!key) { 4176. config_error_add("Unknown key binding key '%s'", bindings); 4177. return FALSE; 4178. } 4179. 4180. bind = trimspaces(bind); 4181. 4182. /* is it a special key? */ 4183. if (bind_specialkey(key, bind)) 4184. return TRUE; 4185. 4186. /* is it a menu command? */ 4187. for (i = 0; i < SIZE(default_menu_cmd_info); i++) { 4188. if (!strcmp(default_menu_cmd_info[i].name, bind)) { 4189. if (illegal_menu_cmd_key(key)) { 4190. config_error_add("Bad menu key %s:%s", visctrl(key), bind); 4191. return FALSE; 4192. } else 4193. add_menu_cmd_alias(key, default_menu_cmd_info[i].cmd); 4194. return TRUE; 4195. } 4196. } 4197. 4198. /* extended command? */ 4199. if (!bind_key(key, bind)) { 4200. config_error_add("Unknown key binding command '%s'", bind); 4201. return FALSE; 4202. } 4203. return TRUE; 4204. } 4205. 4206. static NEARDATA const char *menutype[] = { "traditional", "combination", 4207. "full", "partial" }; 4208. 4209. static NEARDATA const char *burdentype[] = { "unencumbered", "burdened", 4210. "stressed", "strained", 4211. "overtaxed", "overloaded" }; 4212. 4213. static NEARDATA const char *runmodes[] = { "teleport", "run", "walk", 4214. "crawl" }; 4215. 4216. static NEARDATA const char *sortltype[] = { "none", "loot", "full" }; 4217. 4218. /* 4219. * Convert the given string of object classes to a string of default object 4220. * symbols. 4221. */ 4222. void 4223. oc_to_str(src, dest) 4224. char *src, *dest; 4225. { 4226. int i; 4227. 4228. while ((i = (int) *src++) != 0) { 4229. if (i < 0 || i >= MAXOCLASSES) 4230. impossible("oc_to_str: illegal object class %d", i); 4231. else 4232. *dest++ = def_oc_syms[i].sym; 4233. } 4234. *dest = '\0'; 4235. } 4236. 4237. /* 4238. * Add the given mapping to the menu command map list. Always keep the 4239. * maps valid C strings. 4240. */ 4241. void 4242. add_menu_cmd_alias(from_ch, to_ch) 4243. char from_ch, to_ch; 4244. { 4245. if (n_menu_mapped >= MAX_MENU_MAPPED_CMDS) { 4246. pline("out of menu map space."); 4247. } else { 4248. mapped_menu_cmds[n_menu_mapped] = from_ch; 4249. mapped_menu_op[n_menu_mapped] = to_ch; 4250. n_menu_mapped++; 4251. mapped_menu_cmds[n_menu_mapped] = '\0'; 4252. mapped_menu_op[n_menu_mapped] = '\0'; 4253. } 4254. } 4255. 4256. char 4257. get_menu_cmd_key(ch) 4258. char ch; 4259. { 4260. char *found = index(mapped_menu_op, ch); 4261. 4262. if (found) { 4263. int idx = (int) (found - mapped_menu_op); 4264. 4265. ch = mapped_menu_cmds[idx]; 4266. } 4267. return ch; 4268. } 4269. 4270. /* 4271. * Map the given character to its corresponding menu command. If it 4272. * doesn't match anything, just return the original. 4273. */ 4274. char 4275. map_menu_cmd(ch) 4276. char ch; 4277. { 4278. char *found = index(mapped_menu_cmds, ch); 4279. 4280. if (found) { 4281. int idx = (int) (found - mapped_menu_cmds); 4282. 4283. ch = mapped_menu_op[idx]; 4284. } 4285. return ch; 4286. } 4287. 4288. void 4289. show_menu_controls(win, dolist) 4290. winid win; 4291. boolean dolist; 4292. { 4293. char buf[BUFSZ]; 4294. 4295. putstr(win, 0, "Menu control keys:"); 4296. if (dolist) { 4297. int i; 4298. 4299. for (i = 0; i < SIZE(default_menu_cmd_info); i++) { 4300. Sprintf(buf, "%-8s %s", 4301. visctrl(get_menu_cmd_key(default_menu_cmd_info[i].cmd)), 4302. default_menu_cmd_info[i].desc); 4303. putstr(win, 0, buf); 4304. } 4305. } else { 4306. const char 4307. fmt3[] = " %-12s %-2s %-2s %s", 4308. fmt2[] = " %-12s %-2s %-2s", 4309. fmt1[] = " %10s %-2s %s", 4310. fmt0[] = " %14s %s"; 4311. 4312. putstr(win, 0, ""); 4313. putstr(win, 0, "Selection: On page Full menu"); 4314. Sprintf(buf, fmt2, "Select all", 4315. visctrl(get_menu_cmd_key(MENU_SELECT_PAGE)), 4316. visctrl(get_menu_cmd_key(MENU_SELECT_ALL))); 4317. putstr(win, 0, buf); 4318. Sprintf(buf, fmt2, "Deselect all", 4319. visctrl(get_menu_cmd_key(MENU_UNSELECT_PAGE)), 4320. visctrl(get_menu_cmd_key(MENU_UNSELECT_ALL))); 4321. putstr(win, 0, buf); 4322. Sprintf(buf, fmt2, "Invert all", 4323. visctrl(get_menu_cmd_key(MENU_INVERT_PAGE)), 4324. visctrl(get_menu_cmd_key(MENU_INVERT_ALL))); 4325. putstr(win, 0, buf); 4326. Sprintf(buf, fmt3, "Text match", "", 4327. visctrl(get_menu_cmd_key(MENU_SEARCH)), 4328. "Search and toggle matching entries"); 4329. putstr(win, 0, buf); 4330. putstr(win, 0, ""); 4331. putstr(win, 0, "Navigation:"); 4332. Sprintf(buf, fmt1, "Go to ", 4333. visctrl(get_menu_cmd_key(MENU_NEXT_PAGE)), 4334. "Next page"); 4335. putstr(win, 0, buf); 4336. Sprintf(buf, fmt1, "", 4337. visctrl(get_menu_cmd_key(MENU_PREVIOUS_PAGE)), 4338. "Previous page"); 4339. putstr(win, 0, buf); 4340. Sprintf(buf, fmt1, "", 4341. visctrl(get_menu_cmd_key(MENU_FIRST_PAGE)), 4342. "First page"); 4343. putstr(win, 0, buf); 4344. Sprintf(buf, fmt1, "", 4345. visctrl(get_menu_cmd_key(MENU_LAST_PAGE)), 4346. "Last page"); 4347. putstr(win, 0, buf); 4348. Sprintf(buf, fmt0, "SPACE", "Next page, if any, otherwise RETURN"); 4349. putstr(win, 0, buf); 4350. Sprintf(buf, fmt0, "RETURN/ENTER", 4351. "Finish menu with any selection(s) made"); 4352. putstr(win, 0, buf); 4353. Sprintf(buf, fmt0, "ESCAPE", 4354. "Cancel menu without selecting anything"); 4355. putstr(win, 0, buf); 4356. } 4357. } 4358. 4359. #if defined(MICRO) || defined(MAC) || defined(WIN32) 4360. #define OPTIONS_HEADING "OPTIONS" 4361. #else 4362. #define OPTIONS_HEADING "NETHACKOPTIONS" 4363. #endif 4364. 4365. static char fmtstr_doset[] = "%s%-15s [%s] "; 4366. static char fmtstr_doset_tab[] = "%s\t[%s]"; 4367. static char n_currently_set[] = "(%d currently set)"; 4368. 4369. /* doset('O' command) menu entries for compound options */ 4370. STATIC_OVL void 4371. doset_add_menu(win, option, indexoffset) 4372. winid win; /* window to add to */ 4373. const char *option; /* option name */ 4374. int indexoffset; /* value to add to index in compopt[], or zero 4375. if option cannot be changed */ 4376. { 4377. const char *value = "unknown"; /* current value */ 4378. char buf[BUFSZ], buf2[BUFSZ]; 4379. anything any; 4380. int i; 4381. 4382. any = zeroany; 4383. if (indexoffset == 0) { 4384. any.a_int = 0; 4385. value = get_compopt_value(option, buf2); 4386. } else { 4387. for (i = 0; compopt[i].name; i++) 4388. if (strcmp(option, compopt[i].name) == 0) 4389. break; 4390. 4391. if (compopt[i].name) { 4392. any.a_int = i + 1 + indexoffset; 4393. value = get_compopt_value(option, buf2); 4394. } else { 4395. /* We are trying to add an option not found in compopt[]. 4396. This is almost certainly bad, but we'll let it through anyway 4397. (with a zero value, so it can't be selected). */ 4398. any.a_int = 0; 4399. } 4400. } 4401. /* " " replaces "a - " -- assumes menus follow that style */ 4402. if (!iflags.menu_tab_sep) 4403. Sprintf(buf, fmtstr_doset, any.a_int ? "" : " ", option, 4404. value); 4405. else 4406. Sprintf(buf, fmtstr_doset_tab, option, value); 4407. add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); 4408. } 4409. 4410. STATIC_OVL void 4411. opts_add_others(win, name, id, bufx, nset) 4412. winid win; 4413. const char *name; 4414. int id; 4415. char *bufx; 4416. int nset; 4417. { 4418. char buf[BUFSZ], buf2[BUFSZ]; 4419. anything any = zeroany; 4420. 4421. any.a_int = id; 4422. if (!bufx) 4423. Sprintf(buf2, n_currently_set, nset); 4424. else 4425. Sprintf(buf2, "%s", bufx); 4426. if (!iflags.menu_tab_sep) 4427. Sprintf(buf, fmtstr_doset, any.a_int ? "" : " ", 4428. name, buf2); 4429. else 4430. Sprintf(buf, fmtstr_doset_tab, name, buf2); 4431. add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); 4432. } 4433. 4434. int 4435. count_apes(VOID_ARGS) 4436. { 4437. int numapes = 0; 4438. struct autopickup_exception *ape = apelist; 4439. 4440. while (ape) { 4441. numapes++; 4442. ape = ape->next; 4443. } 4444. 4445. return numapes; 4446. } 4447. 4448. enum opt_other_enums { 4449. OPT_OTHER_MSGTYPE = -4, 4450. OPT_OTHER_MENUCOLOR = -3, 4451. OPT_OTHER_STATHILITE = -2, 4452. OPT_OTHER_APEXC = -1 4453. /* these must be < 0 */ 4454. }; 4455. 4456. static struct other_opts { 4457. const char *name; 4458. int optflags; 4459. enum opt_other_enums code; 4460. int NDECL((*othr_count_func)); 4461. } othropt[] = { 4462. { "autopickup exceptions", SET_IN_GAME, OPT_OTHER_APEXC, count_apes }, 4463. { "menu colors", SET_IN_GAME, OPT_OTHER_MENUCOLOR, count_menucolors }, 4464. { "message types", SET_IN_GAME, OPT_OTHER_MSGTYPE, msgtype_count }, 4465. #ifdef STATUS_HILITES 4466. { "status hilite rules", SET_IN_GAME, OPT_OTHER_STATHILITE, 4467. count_status_hilites }, 4468. #endif 4469. { (char *) 0, 0, (enum opt_other_enums) 0 }, 4470. }; 4471. 4472. /* the 'O' command */ 4473. int 4474. doset() /* changing options via menu by Per Liboriussen */ 4475. { 4476. static boolean made_fmtstr = FALSE; 4477. char buf[BUFSZ]; 4478. const char *name; 4479. int i = 0, pass, boolcount, pick_cnt, pick_idx, opt_indx; 4480. boolean *bool_p; 4481. winid tmpwin; 4482. anything any; 4483. menu_item *pick_list; 4484. int indexoffset, startpass, endpass, optflags; 4485. boolean setinitial = FALSE, fromfile = FALSE; 4486. unsigned longest_name_len; 4487. 4488. tmpwin = create_nhwindow(NHW_MENU); 4489. start_menu(tmpwin); 4490. 4491. #ifdef notyet /* SYSCF */ 4492. /* XXX I think this is still fragile. Fixing initial/from_file and/or 4493. changing the SET_* etc to bitmaps will let me make this better. */ 4494. if (wizard) 4495. startpass = SET_IN_SYS; 4496. else 4497. #endif 4498. startpass = DISP_IN_GAME; 4499. endpass = (wizard) ? SET_IN_WIZGAME : SET_IN_GAME; 4500. 4501. if (!made_fmtstr && !iflags.menu_tab_sep) { 4502. /* spin through the options to find the longest name 4503. and adjust the format string accordingly */ 4504. longest_name_len = 0; 4505. for (pass = 0; pass <= 2; pass++) 4506. for (i = 0; (name = ((pass == 0) ? boolopt[i].name 4507. : (pass == 1) ? compopt[i].name 4508. : othropt[i].name)) != 0; i++) { 4509. if (pass == 0 && !boolopt[i].addr) 4510. continue; 4511. optflags = (pass == 0) ? boolopt[i].optflags 4512. : (pass == 1) ? compopt[i].optflags 4513. : othropt[i].optflags; 4514. if (optflags < startpass || optflags > endpass) 4515. continue; 4516. if ((is_wc_option(name) && !wc_supported(name)) 4517. || (is_wc2_option(name) && !wc2_supported(name))) 4518. continue; 4519. 4520. if (strlen(name) > longest_name_len) 4521. longest_name_len = strlen(name); 4522. } 4523. Sprintf(fmtstr_doset, "%%s%%-%us [%%s]", longest_name_len); 4524. made_fmtstr = TRUE; 4525. } 4526. 4527. any = zeroany; 4528. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, 4529. "Booleans (selecting will toggle value):", MENU_UNSELECTED); 4530. any.a_int = 0; 4531. /* first list any other non-modifiable booleans, then modifiable ones */ 4532. for (pass = 0; pass <= 1; pass++) 4533. for (i = 0; (name = boolopt[i].name) != 0; i++) 4534. if ((bool_p = boolopt[i].addr) != 0 4535. && ((boolopt[i].optflags <= DISP_IN_GAME && pass == 0) 4536. || (boolopt[i].optflags >= SET_IN_GAME && pass == 1))) { 4537. if (bool_p == &flags.female) 4538. continue; /* obsolete */ 4539. if (boolopt[i].optflags == SET_IN_WIZGAME && !wizard) 4540. continue; 4541. if ((is_wc_option(name) && !wc_supported(name)) 4542. || (is_wc2_option(name) && !wc2_supported(name))) 4543. continue; 4544. 4545. any.a_int = (pass == 0) ? 0 : i + 1; 4546. if (!iflags.menu_tab_sep) 4547. Sprintf(buf, fmtstr_doset, (pass == 0) ? " " : "", 4548. name, *bool_p ? "true" : "false"); 4549. else 4550. Sprintf(buf, fmtstr_doset_tab, 4551. name, *bool_p ? "true" : "false"); 4552. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, 4553. MENU_UNSELECTED); 4554. } 4555. 4556. boolcount = i; 4557. indexoffset = boolcount; 4558. any = zeroany; 4559. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); 4560. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, 4561. "Compounds (selecting will prompt for new value):", 4562. MENU_UNSELECTED); 4563. 4564. /* deliberately put playmode, name, role+race+gender+align first */ 4565. doset_add_menu(tmpwin, "playmode", 0); 4566. doset_add_menu(tmpwin, "name", 0); 4567. doset_add_menu(tmpwin, "role", 0); 4568. doset_add_menu(tmpwin, "race", 0); 4569. doset_add_menu(tmpwin, "gender", 0); 4570. doset_add_menu(tmpwin, "align", 0); 4571. 4572. for (pass = startpass; pass <= endpass; pass++) 4573. for (i = 0; (name = compopt[i].name) != 0; i++) 4574. if (compopt[i].optflags == pass) { 4575. if (!strcmp(name, "playmode") || !strcmp(name, "name") 4576. || !strcmp(name, "role") || !strcmp(name, "race") 4577. || !strcmp(name, "gender") || !strcmp(name, "align")) 4578. continue; 4579. if ((is_wc_option(name) && !wc_supported(name)) 4580. || (is_wc2_option(name) && !wc2_supported(name))) 4581. continue; 4582. 4583. doset_add_menu(tmpwin, name, 4584. (pass == DISP_IN_GAME) ? 0 : indexoffset); 4585. } 4586. 4587. any = zeroany; 4588. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); 4589. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, 4590. "Other settings:", MENU_UNSELECTED); 4591. 4592. for (i = 0; (name = othropt[i].name) != 0; i++) { 4593. if ((is_wc_option(name) && !wc_supported(name)) 4594. || (is_wc2_option(name) && !wc2_supported(name))) 4595. continue; 4596. opts_add_others(tmpwin, name, othropt[i].code, 4597. (char *) 0, othropt[i].othr_count_func()); 4598. } 4599. 4600. #ifdef PREFIXES_IN_USE 4601. any = zeroany; 4602. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); 4603. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, 4604. "Variable playground locations:", MENU_UNSELECTED); 4605. for (i = 0; i < PREFIX_COUNT; i++) 4606. doset_add_menu(tmpwin, fqn_prefix_names[i], 0); 4607. #endif 4608. end_menu(tmpwin, "Set what options?"); 4609. need_redraw = FALSE; 4610. if ((pick_cnt = select_menu(tmpwin, PICK_ANY, &pick_list)) > 0) { 4611. /* 4612. * Walk down the selection list and either invert the booleans 4613. * or prompt for new values. In most cases, call parseoptions() 4614. * to take care of options that require special attention, like 4615. * redraws. 4616. */ 4617. for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) { 4618. opt_indx = pick_list[pick_idx].item.a_int - 1; 4619. if (opt_indx < -1) 4620. opt_indx++; /* -1 offset for select_menu() */ 4621. if (opt_indx == OPT_OTHER_APEXC) { 4622. (void) special_handling("autopickup_exception", setinitial, 4623. fromfile); 4624. #ifdef STATUS_HILITES 4625. } else if (opt_indx == OPT_OTHER_STATHILITE) { 4626. if (!status_hilite_menu()) { 4627. pline("Bad status hilite(s) specified."); 4628. } else { 4629. if (wc2_supported("hilite_status")) 4630. preference_update("hilite_status"); 4631. } 4632. #endif 4633. } else if (opt_indx == OPT_OTHER_MENUCOLOR) { 4634. (void) special_handling("menu_colors", setinitial, 4635. fromfile); 4636. } else if (opt_indx == OPT_OTHER_MSGTYPE) { 4637. (void) special_handling("msgtype", setinitial, fromfile); 4638. } else if (opt_indx < boolcount) { 4639. /* boolean option */ 4640. Sprintf(buf, "%s%s", *boolopt[opt_indx].addr ? "!" : "", 4641. boolopt[opt_indx].name); 4642. (void) parseoptions(buf, setinitial, fromfile); 4643. if (wc_supported(boolopt[opt_indx].name) 4644. || wc2_supported(boolopt[opt_indx].name)) 4645. preference_update(boolopt[opt_indx].name); 4646. } else { 4647. /* compound option */ 4648. opt_indx -= boolcount; 4649. 4650. if (!special_handling(compopt[opt_indx].name, setinitial, 4651. fromfile)) { 4652. char abuf[BUFSZ]; 4653. 4654. Sprintf(buf, "Set %s to what?", compopt[opt_indx].name); 4655. abuf[0] = '\0'; 4656. getlin(buf, abuf); 4657. if (abuf[0] == '\033') 4658. continue; 4659. Sprintf(buf, "%s:", compopt[opt_indx].name); 4660. (void) strncat(eos(buf), abuf, 4661. (sizeof buf - 1 - strlen(buf))); 4662. /* pass the buck */ 4663. (void) parseoptions(buf, setinitial, fromfile); 4664. } 4665. if (wc_supported(compopt[opt_indx].name) 4666. || wc2_supported(compopt[opt_indx].name)) 4667. preference_update(compopt[opt_indx].name); 4668. } 4669. } 4670. free((genericptr_t) pick_list), pick_list = (menu_item *) 0; 4671. } 4672. 4673. destroy_nhwindow(tmpwin); 4674. if (need_redraw) { 4675. check_gold_symbol(); 4676. reglyph_darkroom(); 4677. (void) doredraw(); 4678. } 4679. return 0; 4680. } 4681. 4682. /* common to msg-types, menu-colors, autopickup-exceptions */ 4683. STATIC_OVL int 4684. handle_add_list_remove(optname, numtotal) 4685. const char *optname; 4686. int numtotal; 4687. { 4688. winid tmpwin; 4689. anything any; 4690. int i, pick_cnt, opt_idx; 4691. menu_item *pick_list = (menu_item *) 0; 4692. static const struct action { 4693. char letr; 4694. const char *desc; 4695. } action_titles[] = { 4696. { 'a', "add new %s" }, /* [0] */ 4697. { 'l', "list %s" }, /* [1] */ 4698. { 'r', "remove existing %s" }, /* [2] */ 4699. { 'x', "exit this menu" }, /* [3] */ 4700. }; 4701. 4702. opt_idx = 0; 4703. tmpwin = create_nhwindow(NHW_MENU); 4704. start_menu(tmpwin); 4705. any = zeroany; 4706. for (i = 0; i < SIZE(action_titles); i++) { 4707. char tmpbuf[BUFSZ]; 4708. 4709. any.a_int++; 4710. /* omit list and remove if there aren't any yet */ 4711. if (!numtotal && (i == 1 || i == 2)) 4712. continue; 4713. Sprintf(tmpbuf, action_titles[i].desc, 4714. (i == 1) ? makeplural(optname) : optname); 4715. add_menu(tmpwin, NO_GLYPH, &any, action_titles[i].letr, 0, ATR_NONE, 4716. tmpbuf, (i == 3) ? MENU_SELECTED : MENU_UNSELECTED); 4717. } 4718. end_menu(tmpwin, "Do what?"); 4719. if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &pick_list)) > 0) { 4720. opt_idx = pick_list[0].item.a_int - 1; 4721. if (pick_cnt > 1 && opt_idx == 3) 4722. opt_idx = pick_list[1].item.a_int - 1; 4723. free((genericptr_t) pick_list); 4724. } else 4725. opt_idx = 3; /* none selected, exit menu */ 4726. destroy_nhwindow(tmpwin); 4727. return opt_idx; 4728. } 4729. 4730. struct symsetentry *symset_list = 0; /* files.c will populate this with 4731. * list of available sets */ 4732. 4733. STATIC_OVL boolean 4734. special_handling(optname, setinitial, setfromfile) 4735. const char *optname; 4736. boolean setinitial, setfromfile; 4737. { 4738. winid tmpwin; 4739. anything any; 4740. int i, n; 4741. char buf[BUFSZ]; 4742. 4743. /* Special handling of menustyle, pickup_burden, pickup_types, 4744. * disclose, runmode, msg_window, menu_headings, sortloot, 4745. * and number_pad options. 4746. * Also takes care of interactive autopickup_exception_handling changes. 4747. */ 4748. if (!strcmp("menustyle", optname)) { 4749. const char *style_name; 4750. menu_item *style_pick = (menu_item *) 0; 4751. 4752. tmpwin = create_nhwindow(NHW_MENU); 4753. start_menu(tmpwin); 4754. any = zeroany; 4755. for (i = 0; i < SIZE(menutype); i++) { 4756. style_name = menutype[i]; 4757. /* note: separate `style_name' variable used 4758. to avoid an optimizer bug in VAX C V2.3 */ 4759. any.a_int = i + 1; 4760. add_menu(tmpwin, NO_GLYPH, &any, *style_name, 0, ATR_NONE, 4761. style_name, MENU_UNSELECTED); 4762. } 4763. end_menu(tmpwin, "Select menustyle:"); 4764. if (select_menu(tmpwin, PICK_ONE, &style_pick) > 0) { 4765. flags.menu_style = style_pick->item.a_int - 1; 4766. free((genericptr_t) style_pick); 4767. } 4768. destroy_nhwindow(tmpwin); 4769. } else if (!strcmp("paranoid_confirmation", optname)) { 4770. menu_item *paranoia_picks = (menu_item *) 0; 4771. 4772. tmpwin = create_nhwindow(NHW_MENU); 4773. start_menu(tmpwin); 4774. any = zeroany; 4775. for (i = 0; paranoia[i].flagmask != 0; ++i) { 4776. if (paranoia[i].flagmask == PARANOID_BONES && !wizard) 4777. continue; 4778. any.a_int = paranoia[i].flagmask; 4779. add_menu(tmpwin, NO_GLYPH, &any, *paranoia[i].argname, 0, 4780. ATR_NONE, paranoia[i].explain, 4781. (flags.paranoia_bits & paranoia[i].flagmask) 4782. ? MENU_SELECTED 4783. : MENU_UNSELECTED); 4784. } 4785. end_menu(tmpwin, "Actions requiring extra confirmation:"); 4786. i = select_menu(tmpwin, PICK_ANY, ¶noia_picks); 4787. if (i >= 0) { 4788. /* player didn't cancel; we reset all the paranoia options 4789. here even if there were no items picked, since user 4790. could have toggled off preselected ones to end up with 0 */ 4791. flags.paranoia_bits = 0; 4792. if (i > 0) { 4793. /* at least 1 item set, either preselected or newly picked */ 4794. while (--i >= 0) 4795. flags.paranoia_bits |= paranoia_picks[i].item.a_int; 4796. free((genericptr_t) paranoia_picks); 4797. } 4798. } 4799. destroy_nhwindow(tmpwin); 4800. } else if (!strcmp("pickup_burden", optname)) { 4801. const char *burden_name, *burden_letters = "ubsntl"; 4802. menu_item *burden_pick = (menu_item *) 0; 4803. 4804. tmpwin = create_nhwindow(NHW_MENU); 4805. start_menu(tmpwin); 4806. any = zeroany; 4807. for (i = 0; i < SIZE(burdentype); i++) { 4808. burden_name = burdentype[i]; 4809. any.a_int = i + 1; 4810. add_menu(tmpwin, NO_GLYPH, &any, burden_letters[i], 0, ATR_NONE, 4811. burden_name, MENU_UNSELECTED); 4812. } 4813. end_menu(tmpwin, "Select encumbrance level:"); 4814. if (select_menu(tmpwin, PICK_ONE, &burden_pick) > 0) { 4815. flags.pickup_burden = burden_pick->item.a_int - 1; 4816. free((genericptr_t) burden_pick); 4817. } 4818. destroy_nhwindow(tmpwin); 4819. } else if (!strcmp("pickup_types", optname)) { 4820. /* parseoptions will prompt for the list of types */ 4821. (void) parseoptions(strcpy(buf, "pickup_types"), 4822. setinitial, setfromfile); 4823. } else if (!strcmp("disclose", optname)) { 4824. /* order of disclose_names[] must correspond to 4825. disclosure_options in decl.c */ 4826. static const char *disclosure_names[] = { 4827. "inventory", "attributes", "vanquished", 4828. "genocides", "conduct", "overview", 4829. }; 4830. int disc_cat[NUM_DISCLOSURE_OPTIONS]; 4831. int pick_cnt, pick_idx, opt_idx; 4832. char c; 4833. menu_item *disclosure_pick = (menu_item *) 0; 4834. 4835. tmpwin = create_nhwindow(NHW_MENU); 4836. start_menu(tmpwin); 4837. any = zeroany; 4838. for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) { 4839. Sprintf(buf, "%-12s[%c%c]", disclosure_names[i], 4840. flags.end_disclose[i], disclosure_options[i]); 4841. any.a_int = i + 1; 4842. add_menu(tmpwin, NO_GLYPH, &any, disclosure_options[i], 0, 4843. ATR_NONE, buf, MENU_UNSELECTED); 4844. disc_cat[i] = 0; 4845. } 4846. end_menu(tmpwin, "Change which disclosure options categories:"); 4847. pick_cnt = select_menu(tmpwin, PICK_ANY, &disclosure_pick); 4848. if (pick_cnt > 0) { 4849. for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) { 4850. opt_idx = disclosure_pick[pick_idx].item.a_int - 1; 4851. disc_cat[opt_idx] = 1; 4852. } 4853. free((genericptr_t) disclosure_pick); 4854. disclosure_pick = (menu_item *) 0; 4855. } 4856. destroy_nhwindow(tmpwin); 4857. 4858. for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) { 4859. if (disc_cat[i]) { 4860. c = flags.end_disclose[i]; 4861. Sprintf(buf, "Disclosure options for %s:", 4862. disclosure_names[i]); 4863. tmpwin = create_nhwindow(NHW_MENU); 4864. start_menu(tmpwin); 4865. any = zeroany; 4866. /* 'y','n',and '+' work as alternate selectors; '-' doesn't */ 4867. any.a_char = DISCLOSE_NO_WITHOUT_PROMPT; 4868. add_menu(tmpwin, NO_GLYPH, &any, 0, any.a_char, ATR_NONE, 4869. "Never disclose, without prompting", 4870. (c == any.a_char) ? MENU_SELECTED : MENU_UNSELECTED); 4871. any.a_char = DISCLOSE_YES_WITHOUT_PROMPT; 4872. add_menu(tmpwin, NO_GLYPH, &any, 0, any.a_char, ATR_NONE, 4873. "Always disclose, without prompting", 4874. (c == any.a_char) ? MENU_SELECTED : MENU_UNSELECTED); 4875. if (*disclosure_names[i] == 'v') { 4876. any.a_char = DISCLOSE_SPECIAL_WITHOUT_PROMPT; /* '#' */ 4877. add_menu(tmpwin, NO_GLYPH, &any, 0, any.a_char, ATR_NONE, 4878. "Always disclose, pick sort order from menu", 4879. (c == any.a_char) ? MENU_SELECTED 4880. : MENU_UNSELECTED); 4881. } 4882. any.a_char = DISCLOSE_PROMPT_DEFAULT_NO; 4883. add_menu(tmpwin, NO_GLYPH, &any, 0, any.a_char, ATR_NONE, 4884. "Prompt, with default answer of \"No\"", 4885. (c == any.a_char) ? MENU_SELECTED : MENU_UNSELECTED); 4886. any.a_char = DISCLOSE_PROMPT_DEFAULT_YES; 4887. add_menu(tmpwin, NO_GLYPH, &any, 0, any.a_char, ATR_NONE, 4888. "Prompt, with default answer of \"Yes\"", 4889. (c == any.a_char) ? MENU_SELECTED : MENU_UNSELECTED); 4890. if (*disclosure_names[i] == 'v') { 4891. any.a_char = DISCLOSE_PROMPT_DEFAULT_SPECIAL; /* '?' */ 4892. add_menu(tmpwin, NO_GLYPH, &any, 0, any.a_char, ATR_NONE, 4893. "Prompt, with default answer of \"Ask\" to request sort menu", 4894. (c == any.a_char) ? MENU_SELECTED 4895. : MENU_UNSELECTED); 4896. } 4897. end_menu(tmpwin, buf); 4898. n = select_menu(tmpwin, PICK_ONE, &disclosure_pick); 4899. if (n > 0) { 4900. flags.end_disclose[i] = disclosure_pick[0].item.a_char; 4901. if (n > 1 && flags.end_disclose[i] == c) 4902. flags.end_disclose[i] = disclosure_pick[1].item.a_char; 4903. free((genericptr_t) disclosure_pick); 4904. } 4905. destroy_nhwindow(tmpwin); 4906. } 4907. } 4908. } else if (!strcmp("runmode", optname)) { 4909. const char *mode_name; 4910. menu_item *mode_pick = (menu_item *) 0; 4911. 4912. tmpwin = create_nhwindow(NHW_MENU); 4913. start_menu(tmpwin); 4914. any = zeroany; 4915. for (i = 0; i < SIZE(runmodes); i++) { 4916. mode_name = runmodes[i]; 4917. any.a_int = i + 1; 4918. add_menu(tmpwin, NO_GLYPH, &any, *mode_name, 0, ATR_NONE, 4919. mode_name, MENU_UNSELECTED); 4920. } 4921. end_menu(tmpwin, "Select run/travel display mode:"); 4922. if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) { 4923. flags.runmode = mode_pick->item.a_int - 1; 4924. free((genericptr_t) mode_pick); 4925. } 4926. destroy_nhwindow(tmpwin); 4927. } else if (!strcmp("whatis_coord", optname)) { 4928. menu_item *window_pick = (menu_item *) 0; 4929. int pick_cnt; 4930. char gp = iflags.getpos_coords; 4931. 4932. tmpwin = create_nhwindow(NHW_MENU); 4933. start_menu(tmpwin); 4934. any = zeroany; 4935. any.a_char = GPCOORDS_COMPASS; 4936. add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMPASS, 0, ATR_NONE, 4937. "compass ('east' or '3s' or '2n,4w')", 4938. (gp == GPCOORDS_COMPASS) ? MENU_SELECTED : MENU_UNSELECTED); 4939. any.a_char = GPCOORDS_COMFULL; 4940. add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_COMFULL, 0, ATR_NONE, 4941. "full compass ('east' or '3south' or '2north,4west')", 4942. (gp == GPCOORDS_COMFULL) ? MENU_SELECTED : MENU_UNSELECTED); 4943. any.a_char = GPCOORDS_MAP; 4944. add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_MAP, 0, ATR_NONE, 4945. "map <x,y>", 4946. (gp == GPCOORDS_MAP) ? MENU_SELECTED : MENU_UNSELECTED); 4947. any.a_char = GPCOORDS_SCREEN; 4948. add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_SCREEN, 0, ATR_NONE, 4949. "screen [row,column]", 4950. (gp == GPCOORDS_SCREEN) ? MENU_SELECTED : MENU_UNSELECTED); 4951. any.a_char = GPCOORDS_NONE; 4952. add_menu(tmpwin, NO_GLYPH, &any, GPCOORDS_NONE, 0, ATR_NONE, 4953. "none (no coordinates displayed)", 4954. (gp == GPCOORDS_NONE) ? MENU_SELECTED : MENU_UNSELECTED); 4955. any.a_long = 0L; 4956. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); 4957. Sprintf(buf, "map: upper-left: <%d,%d>, lower-right: <%d,%d>%s", 4958. 1, 0, COLNO - 1, ROWNO - 1, 4959. flags.verbose ? "; column 0 unused, off left edge" : ""); 4960. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); 4961. if (strcmp(windowprocs.name, "tty")) /* only show for non-tty */ 4962. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, 4963. "screen: row is offset to accommodate tty interface's use of top line", 4964. MENU_UNSELECTED); 4965. #if COLNO == 80 4966. #define COL80ARG flags.verbose ? "; column 80 is not used" : "" 4967. #else 4968. #define COL80ARG "" 4969. #endif 4970. Sprintf(buf, "screen: upper-left: [%02d,%02d], lower-right: [%d,%d]%s", 4971. 0 + 2, 1, ROWNO - 1 + 2, COLNO - 1, COL80ARG); 4972. #undef COL80ARG 4973. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, MENU_UNSELECTED); 4974. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); 4975. end_menu(tmpwin, 4976. "Select coordinate display when auto-describing a map position:"); 4977. if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &window_pick)) > 0) { 4978. iflags.getpos_coords = window_pick[0].item.a_char; 4979. /* PICK_ONE doesn't unselect preselected entry when 4980. selecting another one */ 4981. if (pick_cnt > 1 && iflags.getpos_coords == gp) 4982. iflags.getpos_coords = window_pick[1].item.a_char; 4983. free((genericptr_t) window_pick); 4984. } 4985. destroy_nhwindow(tmpwin); 4986. } else if (!strcmp("whatis_filter", optname)) { 4987. menu_item *window_pick = (menu_item *) 0; 4988. int pick_cnt; 4989. char gf = iflags.getloc_filter; 4990. 4991. tmpwin = create_nhwindow(NHW_MENU); 4992. start_menu(tmpwin); 4993. any = zeroany; 4994. any.a_char = (GFILTER_NONE + 1); 4995. add_menu(tmpwin, NO_GLYPH, &any, 'n', 4996. 0, ATR_NONE, "no filtering", 4997. (gf == GFILTER_NONE) ? MENU_SELECTED : MENU_UNSELECTED); 4998. any.a_char = (GFILTER_VIEW + 1); 4999. add_menu(tmpwin, NO_GLYPH, &any, 'v', 5000. 0, ATR_NONE, "in view only", 5001. (gf == GFILTER_VIEW) ? MENU_SELECTED : MENU_UNSELECTED); 5002. any.a_char = (GFILTER_AREA + 1); 5003. add_menu(tmpwin, NO_GLYPH, &any, 'a', 5004. 0, ATR_NONE, "in same area", 5005. (gf == GFILTER_AREA) ? MENU_SELECTED : MENU_UNSELECTED); 5006. end_menu(tmpwin, 5007. "Select location filtering when going for next/previous map position:"); 5008. if ((pick_cnt = select_menu(tmpwin, PICK_ONE, &window_pick)) > 0) { 5009. iflags.getloc_filter = (window_pick[0].item.a_char - 1); 5010. /* PICK_ONE doesn't unselect preselected entry when 5011. selecting another one */ 5012. if (pick_cnt > 1 && iflags.getloc_filter == gf) 5013. iflags.getloc_filter = (window_pick[1].item.a_char - 1); 5014. free((genericptr_t) window_pick); 5015. } 5016. destroy_nhwindow(tmpwin); 5017. } else if (!strcmp("msg_window", optname)) { 5018. #if defined(TTY_GRAPHICS) || defined(CURSES_GRAPHICS) 5019. if (WINDOWPORT("tty") || WINDOWPORT("curses")) { 5020. /* by Christian W. Cooper */ 5021. menu_item *window_pick = (menu_item *) 0; 5022. 5023. tmpwin = create_nhwindow(NHW_MENU); 5024. start_menu(tmpwin); 5025. any = zeroany; 5026. if (!WINDOWPORT("curses")) { 5027. any.a_char = 's'; 5028. add_menu(tmpwin, NO_GLYPH, &any, 's', 0, ATR_NONE, 5029. "single", MENU_UNSELECTED); 5030. any.a_char = 'c'; 5031. add_menu(tmpwin, NO_GLYPH, &any, 'c', 0, ATR_NONE, 5032. "combination", MENU_UNSELECTED); 5033. } 5034. any.a_char = 'f'; 5035. add_menu(tmpwin, NO_GLYPH, &any, 'f', 0, ATR_NONE, "full", 5036. MENU_UNSELECTED); 5037. any.a_char = 'r'; 5038. add_menu(tmpwin, NO_GLYPH, &any, 'r', 0, ATR_NONE, "reversed", 5039. MENU_UNSELECTED); 5040. end_menu(tmpwin, "Select message history display type:"); 5041. if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) { 5042. iflags.prevmsg_window = window_pick->item.a_char; 5043. free((genericptr_t) window_pick); 5044. } 5045. destroy_nhwindow(tmpwin); 5046. } else 5047. #endif /* msg_window for tty or curses */ 5048. pline("'%s' option is not supported for '%s'.", 5049. optname, windowprocs.name); 5050. } else if (!strcmp("sortloot", optname)) { 5051. const char *sortl_name; 5052. menu_item *sortl_pick = (menu_item *) 0; 5053. 5054. tmpwin = create_nhwindow(NHW_MENU); 5055. start_menu(tmpwin); 5056. any = zeroany; 5057. for (i = 0; i < SIZE(sortltype); i++) { 5058. sortl_name = sortltype[i]; 5059. any.a_char = *sortl_name; 5060. add_menu(tmpwin, NO_GLYPH, &any, *sortl_name, 0, ATR_NONE, 5061. sortl_name, (flags.sortloot == *sortl_name) 5062. ? MENU_SELECTED : MENU_UNSELECTED); 5063. } 5064. end_menu(tmpwin, "Select loot sorting type:"); 5065. n = select_menu(tmpwin, PICK_ONE, &sortl_pick); 5066. if (n > 0) { 5067. char c = sortl_pick[0].item.a_char; 5068. 5069. if (n > 1 && c == flags.sortloot) 5070. c = sortl_pick[1].item.a_char; 5071. flags.sortloot = c; 5072. free((genericptr_t) sortl_pick); 5073. } 5074. destroy_nhwindow(tmpwin); 5075. } else if (!strcmp("align_message", optname) 5076. || !strcmp("align_status", optname)) { 5077. menu_item *window_pick = (menu_item *) 0; 5078. char abuf[BUFSZ]; 5079. boolean msg = (*(optname + 6) == 'm'); 5080. 5081. tmpwin = create_nhwindow(NHW_MENU); 5082. start_menu(tmpwin); 5083. any = zeroany; 5084. any.a_int = ALIGN_TOP; 5085. add_menu(tmpwin, NO_GLYPH, &any, 't', 0, ATR_NONE, "top", 5086. MENU_UNSELECTED); 5087. any.a_int = ALIGN_BOTTOM; 5088. add_menu(tmpwin, NO_GLYPH, &any, 'b', 0, ATR_NONE, "bottom", 5089. MENU_UNSELECTED); 5090. any.a_int = ALIGN_LEFT; 5091. add_menu(tmpwin, NO_GLYPH, &any, 'l', 0, ATR_NONE, "left", 5092. MENU_UNSELECTED); 5093. any.a_int = ALIGN_RIGHT; 5094. add_menu(tmpwin, NO_GLYPH, &any, 'r', 0, ATR_NONE, "right", 5095. MENU_UNSELECTED); 5096. Sprintf(abuf, "Select %s window placement relative to the map:", 5097. msg ? "message" : "status"); 5098. end_menu(tmpwin, abuf); 5099. if (select_menu(tmpwin, PICK_ONE, &window_pick) > 0) { 5100. if (msg) 5101. iflags.wc_align_message = window_pick->item.a_int; 5102. else 5103. iflags.wc_align_status = window_pick->item.a_int; 5104. free((genericptr_t) window_pick); 5105. } 5106. destroy_nhwindow(tmpwin); 5107. } else if (!strcmp("number_pad", optname)) { 5108. static const char *npchoices[] = { 5109. " 0 (off)", " 1 (on)", " 2 (on, MSDOS compatible)", 5110. " 3 (on, phone-style digit layout)", 5111. " 4 (on, phone-style layout, MSDOS compatible)", 5112. "-1 (off, 'z' to move upper-left, 'y' to zap wands)" 5113. }; 5114. menu_item *mode_pick = (menu_item *) 0; 5115. 5116. tmpwin = create_nhwindow(NHW_MENU); 5117. start_menu(tmpwin); 5118. any = zeroany; 5119. for (i = 0; i < SIZE(npchoices); i++) { 5120. any.a_int = i + 1; 5121. add_menu(tmpwin, NO_GLYPH, &any, 'a' + i, 0, ATR_NONE, 5122. npchoices[i], MENU_UNSELECTED); 5123. } 5124. end_menu(tmpwin, "Select number_pad mode:"); 5125. if (select_menu(tmpwin, PICK_ONE, &mode_pick) > 0) { 5126. switch (mode_pick->item.a_int - 1) { 5127. case 0: 5128. iflags.num_pad = FALSE; 5129. iflags.num_pad_mode = 0; 5130. break; 5131. case 1: 5132. iflags.num_pad = TRUE; 5133. iflags.num_pad_mode = 0; 5134. break; 5135. case 2: 5136. iflags.num_pad = TRUE; 5137. iflags.num_pad_mode = 1; 5138. break; 5139. case 3: 5140. iflags.num_pad = TRUE; 5141. iflags.num_pad_mode = 2; 5142. break; 5143. case 4: 5144. iflags.num_pad = TRUE; 5145. iflags.num_pad_mode = 3; 5146. break; 5147. /* last menu choice: number_pad == -1 */ 5148. case 5: 5149. iflags.num_pad = FALSE; 5150. iflags.num_pad_mode = 1; 5151. break; 5152. } 5153. reset_commands(FALSE); 5154. number_pad(iflags.num_pad ? 1 : 0); 5155. free((genericptr_t) mode_pick); 5156. } 5157. destroy_nhwindow(tmpwin); 5158. } else if (!strcmp("menu_headings", optname)) { 5159. int mhattr = query_attr("How to highlight menu headings:"); 5160. 5161. if (mhattr != -1) 5162. iflags.menu_headings = mhattr; 5163. } else if (!strcmp("msgtype", optname)) { 5164. int opt_idx, nmt, mttyp; 5165. char mtbuf[BUFSZ]; 5166. 5167. msgtypes_again: 5168. nmt = msgtype_count(); 5169. opt_idx = handle_add_list_remove("message type", nmt); 5170. if (opt_idx == 3) { /* done */ 5171. return TRUE; 5172. } else if (opt_idx == 0) { /* add new */ 5173. mtbuf[0] = '\0'; 5174. getlin("What new message pattern?", mtbuf); 5175. if (*mtbuf == '\033') 5176. return TRUE; 5177. if (*mtbuf 5178. && test_regex_pattern(mtbuf, (const char *)0) 5179. && (mttyp = query_msgtype()) != -1 5180. && !msgtype_add(mttyp, mtbuf)) { 5181. pline("Error adding the message type."); 5182. wait_synch(); 5183. } 5184. goto msgtypes_again; 5185. } else { /* list (1) or remove (2) */ 5186. int pick_idx, pick_cnt; 5187. int mt_idx; 5188. unsigned ln; 5189. const char *mtype; 5190. menu_item *pick_list = (menu_item *) 0; 5191. struct plinemsg_type *tmp = plinemsg_types; 5192. 5193. tmpwin = create_nhwindow(NHW_MENU); 5194. start_menu(tmpwin); 5195. any = zeroany; 5196. mt_idx = 0; 5197. while (tmp) { 5198. mtype = msgtype2name(tmp->msgtype); 5199. any.a_int = ++mt_idx; 5200. Sprintf(mtbuf, "%-5s \"", mtype); 5201. ln = sizeof mtbuf - strlen(mtbuf) - sizeof "\""; 5202. if (strlen(tmp->pattern) > ln) 5203. Strcat(strncat(mtbuf, tmp->pattern, ln - 3), "...\""); 5204. else 5205. Strcat(strcat(mtbuf, tmp->pattern), "\""); 5206. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mtbuf, 5207. MENU_UNSELECTED); 5208. tmp = tmp->next; 5209. } 5210. Sprintf(mtbuf, "%s message types", 5211. (opt_idx == 1) ? "List of" : "Remove which"); 5212. end_menu(tmpwin, mtbuf); 5213. pick_cnt = select_menu(tmpwin, 5214. (opt_idx == 1) ? PICK_NONE : PICK_ANY, 5215. &pick_list); 5216. if (pick_cnt > 0) { 5217. for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) 5218. free_one_msgtype(pick_list[pick_idx].item.a_int - 1 5219. - pick_idx); 5220. free((genericptr_t) pick_list), pick_list = (menu_item *) 0; 5221. } 5222. destroy_nhwindow(tmpwin); 5223. if (pick_cnt >= 0) 5224. goto msgtypes_again; 5225. } 5226. } else if (!strcmp("menu_colors", optname)) { 5227. int opt_idx, nmc, mcclr, mcattr; 5228. char mcbuf[BUFSZ]; 5229. 5230. menucolors_again: 5231. nmc = count_menucolors(); 5232. opt_idx = handle_add_list_remove("menucolor", nmc); 5233. if (opt_idx == 3) { /* done */ 5234. menucolors_done: 5235. /* in case we've made a change which impacts current persistent 5236. inventory window; we don't track whether an actual changed 5237. occurred, so just assume there was one and that it matters; 5238. if we're wrong, a redundant update is cheap... */ 5239. if (iflags.use_menu_color) 5240. update_inventory(); 5241. 5242. /* menu colors aren't being used; if any are defined, remind 5243. player how to use them */ 5244. else if (nmc > 0) 5245. pline( 5246. "To have menu colors become active, toggle 'menucolors' option to True."); 5247. return TRUE; 5248. 5249. } else if (opt_idx == 0) { /* add new */ 5250. mcbuf[0] = '\0'; 5251. getlin("What new menucolor pattern?", mcbuf); 5252. if (*mcbuf == '\033') 5253. goto menucolors_done; 5254. if (*mcbuf 5255. && test_regex_pattern(mcbuf, (const char *)0) 5256. && (mcclr = query_color((char *) 0)) != -1 5257. && (mcattr = query_attr((char *) 0)) != -1 5258. && !add_menu_coloring_parsed(mcbuf, mcclr, mcattr)) { 5259. pline("Error adding the menu color."); 5260. wait_synch(); 5261. } 5262. goto menucolors_again; 5263. 5264. } else { /* list (1) or remove (2) */ 5265. int pick_idx, pick_cnt; 5266. int mc_idx; 5267. unsigned ln; 5268. const char *sattr, *sclr; 5269. menu_item *pick_list = (menu_item *) 0; 5270. struct menucoloring *tmp = menu_colorings; 5271. char clrbuf[QBUFSZ]; 5272. 5273. tmpwin = create_nhwindow(NHW_MENU); 5274. start_menu(tmpwin); 5275. any = zeroany; 5276. mc_idx = 0; 5277. while (tmp) { 5278. sattr = attr2attrname(tmp->attr); 5279. sclr = strcpy(clrbuf, clr2colorname(tmp->color)); 5280. (void) strNsubst(clrbuf, " ", "-", 0); 5281. any.a_int = ++mc_idx; 5282. /* construct suffix */ 5283. Sprintf(buf, "\"\"=%s%s%s", sclr, 5284. (tmp->attr != ATR_NONE) ? "&" : "", 5285. (tmp->attr != ATR_NONE) ? sattr : ""); 5286. /* now main string */ 5287. ln = sizeof buf - strlen(buf) - 1; /* length available */ 5288. Strcpy(mcbuf, "\""); 5289. if (strlen(tmp->origstr) > ln) 5290. Strcat(strncat(mcbuf, tmp->origstr, ln - 3), "..."); 5291. else 5292. Strcat(mcbuf, tmp->origstr); 5293. /* combine main string and suffix */ 5294. Strcat(mcbuf, &buf[1]); /* skip buf[]'s initial quote */ 5295. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, mcbuf, 5296. MENU_UNSELECTED); 5297. tmp = tmp->next; 5298. } 5299. Sprintf(mcbuf, "%s menu colors", 5300. (opt_idx == 1) ? "List of" : "Remove which"); 5301. end_menu(tmpwin, mcbuf); 5302. pick_cnt = select_menu(tmpwin, 5303. (opt_idx == 1) ? PICK_NONE : PICK_ANY, 5304. &pick_list); 5305. if (pick_cnt > 0) { 5306. for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) 5307. free_one_menu_coloring(pick_list[pick_idx].item.a_int - 1 5308. - pick_idx); 5309. free((genericptr_t) pick_list), pick_list = (menu_item *) 0; 5310. } 5311. destroy_nhwindow(tmpwin); 5312. if (pick_cnt >= 0) 5313. goto menucolors_again; 5314. } 5315. } else if (!strcmp("autopickup_exception", optname)) { 5316. int opt_idx, numapes = 0; 5317. char apebuf[2 + BUFSZ]; /* so &apebuf[1] is BUFSZ long for getlin() */ 5318. struct autopickup_exception *ape; 5319. 5320. ape_again: 5321. numapes = count_apes(); 5322. opt_idx = handle_add_list_remove("autopickup exception", numapes); 5323. if (opt_idx == 3) { /* done */ 5324. return TRUE; 5325. } else if (opt_idx == 0) { /* add new */ 5326. /* EDIT_GETLIN: assume user doesn't user want previous 5327. exception used as default input string for this one... */ 5328. apebuf[0] = apebuf[1] = '\0'; 5329. getlin("What new autopickup exception pattern?", &apebuf[1]); 5330. mungspaces(&apebuf[1]); /* regularize whitespace */ 5331. if (apebuf[1] == '\033') 5332. return TRUE; 5333. if (apebuf[1]) { 5334. apebuf[0] = '\"'; 5335. /* guarantee room for \" prefix and \"\0 suffix; 5336. -2 is good enough for apebuf[] but -3 makes 5337. sure the whole thing fits within normal BUFSZ */ 5338. apebuf[sizeof apebuf - 2] = '\0'; 5339. Strcat(apebuf, "\""); 5340. add_autopickup_exception(apebuf); 5341. } 5342. goto ape_again; 5343. } else { /* list (1) or remove (2) */ 5344. int pick_idx, pick_cnt; 5345. menu_item *pick_list = (menu_item *) 0; 5346. 5347. tmpwin = create_nhwindow(NHW_MENU); 5348. start_menu(tmpwin); 5349. if (numapes) { 5350. ape = apelist; 5351. any = zeroany; 5352. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, iflags.menu_headings, 5353. "Always pickup '<'; never pickup '>'", 5354. MENU_UNSELECTED); 5355. for (i = 0; i < numapes && ape; i++) { 5356. any.a_void = (opt_idx == 1) ? 0 : ape; 5357. /* length of pattern plus quotes (plus '<'/'>') is 5358. less than BUFSZ */ 5359. Sprintf(apebuf, "\"%c%s\"", ape->grab ? '<' : '>', 5360. ape->pattern); 5361. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, apebuf, 5362. MENU_UNSELECTED); 5363. ape = ape->next; 5364. } 5365. } 5366. Sprintf(apebuf, "%s autopickup exceptions", 5367. (opt_idx == 1) ? "List of" : "Remove which"); 5368. end_menu(tmpwin, apebuf); 5369. pick_cnt = select_menu(tmpwin, 5370. (opt_idx == 1) ? PICK_NONE : PICK_ANY, 5371. &pick_list); 5372. if (pick_cnt > 0) { 5373. for (pick_idx = 0; pick_idx < pick_cnt; ++pick_idx) 5374. remove_autopickup_exception( 5375. (struct autopickup_exception *) 5376. pick_list[pick_idx].item.a_void); 5377. free((genericptr_t) pick_list), pick_list = (menu_item *) 0; 5378. } 5379. destroy_nhwindow(tmpwin); 5380. if (pick_cnt >= 0) 5381. goto ape_again; 5382. } 5383. } else if (!strcmp("symset", optname) 5384. || !strcmp("roguesymset", optname)) { 5385. menu_item *symset_pick = (menu_item *) 0; 5386. boolean rogueflag = (*optname == 'r'), 5387. ready_to_switch = FALSE, 5388. nothing_to_do = FALSE; 5389. char *symset_name, fmtstr[20]; 5390. struct symsetentry *sl; 5391. int res, which_set, setcount = 0, chosen = -2, defindx = 0; 5392. 5393. which_set = rogueflag ? ROGUESET : PRIMARY; 5394. symset_list = (struct symsetentry *) 0; 5395. /* clear symset[].name as a flag to read_sym_file() to build list */ 5396. symset_name = symset[which_set].name; 5397. symset[which_set].name = (char *) 0; 5398. 5399. res = read_sym_file(which_set); 5400. /* put symset name back */ 5401. symset[which_set].name = symset_name; 5402. 5403. if (res && symset_list) { 5404. int thissize, 5405. biggest = (int) (sizeof "Default Symbols" - sizeof ""), 5406. big_desc = 0; 5407. 5408. for (sl = symset_list; sl; sl = sl->next) { 5409. /* check restrictions */ 5410. if (rogueflag ? sl->primary : sl->rogue) 5411. continue; 5412. #ifndef MAC_GRAPHICS_ENV 5413. if (sl->handling == H_MAC) 5414. continue; 5415. #endif 5416. 5417. setcount++; 5418. /* find biggest name */ 5419. thissize = sl->name ? (int) strlen(sl->name) : 0; 5420. if (thissize > biggest) 5421. biggest = thissize; 5422. thissize = sl->desc ? (int) strlen(sl->desc) : 0; 5423. if (thissize > big_desc) 5424. big_desc = thissize; 5425. } 5426. if (!setcount) { 5427. pline("There are no appropriate %s symbol sets available.", 5428. rogueflag ? "rogue level" : "primary"); 5429. return TRUE; 5430. } 5431. 5432. Sprintf(fmtstr, "%%-%ds %%s", biggest + 2); 5433. tmpwin = create_nhwindow(NHW_MENU); 5434. start_menu(tmpwin); 5435. any = zeroany; 5436. any.a_int = 1; /* -1 + 2 [see 'if (sl->name) {' below]*/ 5437. if (!symset_name) 5438. defindx = any.a_int; 5439. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, 5440. "Default Symbols", 5441. (any.a_int == defindx) ? MENU_SELECTED 5442. : MENU_UNSELECTED); 5443. 5444. for (sl = symset_list; sl; sl = sl->next) { 5445. /* check restrictions */ 5446. if (rogueflag ? sl->primary : sl->rogue) 5447. continue; 5448. #ifndef MAC_GRAPHICS_ENV 5449. if (sl->handling == H_MAC) 5450. continue; 5451. #endif 5452. if (sl->name) { 5453. /* +2: sl->idx runs from 0 to N-1 for N symsets; 5454. +1 because Defaults are implicitly in slot [0]; 5455. +1 again so that valid data is never 0 */ 5456. any.a_int = sl->idx + 2; 5457. if (symset_name && !strcmpi(sl->name, symset_name)) 5458. defindx = any.a_int; 5459. Sprintf(buf, fmtstr, sl->name, sl->desc ? sl->desc : ""); 5460. add_menu(tmpwin, NO_GLYPH, &any, 0, 0, ATR_NONE, buf, 5461. (any.a_int == defindx) ? MENU_SELECTED 5462. : MENU_UNSELECTED); 5463. } 5464. } 5465. Sprintf(buf, "Select %ssymbol set:", 5466. rogueflag ? "rogue level " : ""); 5467. end_menu(tmpwin, buf); 5468. n = select_menu(tmpwin, PICK_ONE, &symset_pick); 5469. if (n > 0) { 5470. chosen = symset_pick[0].item.a_int; 5471. /* if picking non-preselected entry yields 2, make sure 5472. that we're going with the non-preselected one */ 5473. if (n == 2 && chosen == defindx) 5474. chosen = symset_pick[1].item.a_int; 5475. chosen -= 2; /* convert menu index to symset index; 5476. * "Default symbols" have index -1 */ 5477. free((genericptr_t) symset_pick); 5478. } else if (n == 0 && defindx > 0) { 5479. chosen = defindx - 2; 5480. } 5481. destroy_nhwindow(tmpwin); 5482. 5483. if (chosen > -1) { 5484. /* chose an actual symset name from file */ 5485. for (sl = symset_list; sl; sl = sl->next) 5486. if (sl->idx == chosen) 5487. break; 5488. if (sl) { 5489. /* free the now stale attributes */ 5490. clear_symsetentry(which_set, TRUE); 5491. 5492. /* transfer only the name of the symbol set */ 5493. symset[which_set].name = dupstr(sl->name); 5494. ready_to_switch = TRUE; 5495. } 5496. } else if (chosen == -1) { 5497. /* explicit selection of defaults */ 5498. /* free the now stale symset attributes */ 5499. clear_symsetentry(which_set, TRUE); 5500. } else 5501. nothing_to_do = TRUE; 5502. } else if (!res) { 5503. /* The symbols file could not be accessed */ 5504. pline("Unable to access \"%s\" file.", SYMBOLS); 5505. return TRUE; 5506. } else if (!symset_list) { 5507. /* The symbols file was empty */ 5508. pline("There were no symbol sets found in \"%s\".", SYMBOLS); 5509. return TRUE; 5510. } 5511. 5512. /* clean up */ 5513. while ((sl = symset_list) != 0) { 5514. symset_list = sl->next; 5515. if (sl->name) 5516. free((genericptr_t) sl->name), sl->name = (char *) 0; 5517. if (sl->desc) 5518. free((genericptr_t) sl->desc), sl->desc = (char *) 0; 5519. free((genericptr_t) sl); 5520. } 5521. 5522. if (nothing_to_do) 5523. return TRUE; 5524. 5525. /* Set default symbols and clear the handling value */ 5526. if (rogueflag) 5527. init_rogue_symbols(); 5528. else 5529. init_primary_symbols(); 5530. 5531. if (symset[which_set].name) { 5532. /* non-default symbols */ 5533. if (read_sym_file(which_set)) { 5534. ready_to_switch = TRUE; 5535. } else { 5536. clear_symsetentry(which_set, TRUE); 5537. return TRUE; 5538. } 5539. } 5540. 5541. if (ready_to_switch) 5542. switch_symbols(TRUE); 5543. 5544. if (Is_rogue_level(&u.uz)) { 5545. if (rogueflag) 5546. assign_graphics(ROGUESET); 5547. } else if (!rogueflag) 5548. assign_graphics(PRIMARY); 5549. preference_update("symset"); 5550. need_redraw = TRUE; 5551. 5552. } else { 5553. /* didn't match any of the special options */ 5554. return FALSE; 5555. } 5556. return TRUE; 5557. } 5558. 5559. #define rolestring(val, array, field) \ 5560. ((val >= 0) ? array[val].field : (val == ROLE_RANDOM) ? randomrole : none) 5561. 5562. /* This is ugly. We have all the option names in the compopt[] array, 5563. but we need to look at each option individually to get the value. */ 5564. STATIC_OVL const char * 5565. get_compopt_value(optname, buf) 5566. const char *optname; 5567. char *buf; 5568. { 5569. static const char none[] = "(none)", randomrole[] = "random", 5570. to_be_done[] = "(to be done)", 5571. defopt[] = "default", defbrief[] = "def"; 5572. char ocl[MAXOCLASSES + 1]; 5573. int i; 5574. 5575. buf[0] = '\0'; 5576. if (!strcmp(optname, "align_message") 5577. || !strcmp(optname, "align_status")) { 5578. int which = !strcmp(optname, "align_status") ? iflags.wc_align_status 5579. : iflags.wc_align_message; 5580. Sprintf(buf, "%s", 5581. (which == ALIGN_TOP) ? "top" 5582. : (which == ALIGN_LEFT) ? "left" 5583. : (which == ALIGN_BOTTOM) ? "bottom" 5584. : (which == ALIGN_RIGHT) ? "right" 5585. : defopt); 5586. } else if (!strcmp(optname, "align")) 5587. Sprintf(buf, "%s", rolestring(flags.initalign, aligns, adj)); 5588. #ifdef WIN32 5589. else if (!strcmp(optname, "altkeyhandler")) 5590. Sprintf(buf, "%s", 5591. iflags.altkeyhandler[0] ? iflags.altkeyhandler : "default"); 5592. #endif 5593. #ifdef BACKWARD_COMPAT 5594. else if (!strcmp(optname, "boulder")) 5595. Sprintf(buf, "%c", 5596. ov_primary_syms[SYM_BOULDER + SYM_OFF_X] 5597. ? ov_primary_syms[SYM_BOULDER + SYM_OFF_X] 5598. : showsyms[(int) objects[BOULDER].oc_class + SYM_OFF_O]); 5599. #endif 5600. else if (!strcmp(optname, "catname")) 5601. Sprintf(buf, "%s", catname[0] ? catname : none); 5602. else if (!strcmp(optname, "disclose")) 5603. for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++) { 5604. if (i) 5605. (void) strkitten(buf, ' '); 5606. (void) strkitten(buf, flags.end_disclose[i]); 5607. (void) strkitten(buf, disclosure_options[i]); 5608. } 5609. else if (!strcmp(optname, "dogname")) 5610. Sprintf(buf, "%s", dogname[0] ? dogname : none); 5611. else if (!strcmp(optname, "dungeon")) 5612. Sprintf(buf, "%s", to_be_done); 5613. else if (!strcmp(optname, "effects")) 5614. Sprintf(buf, "%s", to_be_done); 5615. else if (!strcmp(optname, "font_map")) 5616. Sprintf(buf, "%s", iflags.wc_font_map ? iflags.wc_font_map : defopt); 5617. else if (!strcmp(optname, "font_message")) 5618. Sprintf(buf, "%s", 5619. iflags.wc_font_message ? iflags.wc_font_message : defopt); 5620. else if (!strcmp(optname, "font_status")) 5621. Sprintf(buf, "%s", 5622. iflags.wc_font_status ? iflags.wc_font_status : defopt); 5623. else if (!strcmp(optname, "font_menu")) 5624. Sprintf(buf, "%s", 5625. iflags.wc_font_menu ? iflags.wc_font_menu : defopt); 5626. else if (!strcmp(optname, "font_text")) 5627. Sprintf(buf, "%s", 5628. iflags.wc_font_text ? iflags.wc_font_text : defopt); 5629. else if (!strcmp(optname, "font_size_map")) { 5630. if (iflags.wc_fontsiz_map) 5631. Sprintf(buf, "%d", iflags.wc_fontsiz_map); 5632. else 5633. Strcpy(buf, defopt); 5634. } else if (!strcmp(optname, "font_size_message")) { 5635. if (iflags.wc_fontsiz_message) 5636. Sprintf(buf, "%d", iflags.wc_fontsiz_message); 5637. else 5638. Strcpy(buf, defopt); 5639. } else if (!strcmp(optname, "font_size_status")) { 5640. if (iflags.wc_fontsiz_status) 5641. Sprintf(buf, "%d", iflags.wc_fontsiz_status); 5642. else 5643. Strcpy(buf, defopt); 5644. } else if (!strcmp(optname, "font_size_menu")) { 5645. if (iflags.wc_fontsiz_menu) 5646. Sprintf(buf, "%d", iflags.wc_fontsiz_menu); 5647. else 5648. Strcpy(buf, defopt); 5649. } else if (!strcmp(optname, "font_size_text")) { 5650. if (iflags.wc_fontsiz_text) 5651. Sprintf(buf, "%d", iflags.wc_fontsiz_text); 5652. else 5653. Strcpy(buf, defopt); 5654. } else if (!strcmp(optname, "fruit")) 5655. Sprintf(buf, "%s", pl_fruit); 5656. else if (!strcmp(optname, "gender")) 5657. Sprintf(buf, "%s", rolestring(flags.initgend, genders, adj)); 5658. else if (!strcmp(optname, "horsename")) 5659. Sprintf(buf, "%s", horsename[0] ? horsename : none); 5660. else if (!strcmp(optname, "map_mode")) { 5661. i = iflags.wc_map_mode; 5662. Sprintf(buf, "%s", 5663. (i == MAP_MODE_TILES) ? "tiles" 5664. : (i == MAP_MODE_ASCII4x6) ? "ascii4x6" 5665. : (i == MAP_MODE_ASCII6x8) ? "ascii6x8" 5666. : (i == MAP_MODE_ASCII8x8) ? "ascii8x8" 5667. : (i == MAP_MODE_ASCII16x8) ? "ascii16x8" 5668. : (i == MAP_MODE_ASCII7x12) ? "ascii7x12" 5669. : (i == MAP_MODE_ASCII8x12) ? "ascii8x12" 5670. : (i == MAP_MODE_ASCII16x12) ? "ascii16x12" 5671. : (i == MAP_MODE_ASCII12x16) ? "ascii12x16" 5672. : (i == MAP_MODE_ASCII10x18) ? "ascii10x18" 5673. : (i == MAP_MODE_ASCII_FIT_TO_SCREEN) 5674. ? "fit_to_screen" 5675. : defopt); 5676. } else if (!strcmp(optname, "menustyle")) 5677. Sprintf(buf, "%s", menutype[(int) flags.menu_style]); 5678. else if (!strcmp(optname, "menu_deselect_all")) 5679. Sprintf(buf, "%s", to_be_done); 5680. else if (!strcmp(optname, "menu_deselect_page")) 5681. Sprintf(buf, "%s", to_be_done); 5682. else if (!strcmp(optname, "menu_first_page")) 5683. Sprintf(buf, "%s", to_be_done); 5684. else if (!strcmp(optname, "menu_invert_all")) 5685. Sprintf(buf, "%s", to_be_done); 5686. else if (!strcmp(optname, "menu_headings")) 5687. Sprintf(buf, "%s", attr2attrname(iflags.menu_headings)); 5688. else if (!strcmp(optname, "menu_invert_page")) 5689. Sprintf(buf, "%s", to_be_done); 5690. else if (!strcmp(optname, "menu_last_page")) 5691. Sprintf(buf, "%s", to_be_done); 5692. else if (!strcmp(optname, "menu_next_page")) 5693. Sprintf(buf, "%s", to_be_done); 5694. else if (!strcmp(optname, "menu_previous_page")) 5695. Sprintf(buf, "%s", to_be_done); 5696. else if (!strcmp(optname, "menu_search")) 5697. Sprintf(buf, "%s", to_be_done); 5698. else if (!strcmp(optname, "menu_select_all")) 5699. Sprintf(buf, "%s", to_be_done); 5700. else if (!strcmp(optname, "menu_select_page")) 5701. Sprintf(buf, "%s", to_be_done); 5702. else if (!strcmp(optname, "monsters")) { 5703. Sprintf(buf, "%s", to_be_done); 5704. } else if (!strcmp(optname, "msghistory")) { 5705. Sprintf(buf, "%u", iflags.msg_history); 5706. #ifdef TTY_GRAPHICS 5707. } else if (!strcmp(optname, "msg_window")) { 5708. Sprintf(buf, "%s", (iflags.prevmsg_window == 's') ? "single" 5709. : (iflags.prevmsg_window == 'c') ? "combination" 5710. : (iflags.prevmsg_window == 'f') ? "full" 5711. : "reversed"); 5712. #endif 5713. } else if (!strcmp(optname, "name")) { 5714. Sprintf(buf, "%s", plname); 5715. } else if (!strcmp(optname, "mouse_support")) { 5716. #ifdef WIN32 5717. #define MOUSEFIX1 ", QuickEdit off" 5718. #define MOUSEFIX2 ", QuickEdit unchanged" 5719. #else 5720. #define MOUSEFIX1 ", O/S adjusted" 5721. #define MOUSEFIX2 ", O/S unchanged" 5722. #endif 5723. static const char *mousemodes[][2] = { 5724. { "0=off", "" }, 5725. { "1=on", MOUSEFIX1 }, 5726. { "2=on", MOUSEFIX2 }, 5727. }; 5728. #undef MOUSEFIX1 5729. #undef MOUSEFIX2 5730. int ms = iflags.wc_mouse_support; 5731. 5732. if (ms >= 0 && ms <= 2) 5733. Sprintf(buf, "%s%s", mousemodes[ms][0], mousemodes[ms][1]); 5734. } else if (!strcmp(optname, "number_pad")) { 5735. static const char *numpadmodes[] = { 5736. "0=off", "1=on", "2=on, MSDOS compatible", 5737. "3=on, phone-style layout", 5738. "4=on, phone layout, MSDOS compatible", 5739. "-1=off, y & z swapped", /*[5]*/ 5740. }; 5741. int indx = Cmd.num_pad 5742. ? (Cmd.phone_layout ? (Cmd.pcHack_compat ? 4 : 3) 5743. : (Cmd.pcHack_compat ? 2 : 1)) 5744. : Cmd.swap_yz ? 5 : 0; 5745. 5746. Strcpy(buf, numpadmodes[indx]); 5747. } else if (!strcmp(optname, "objects")) { 5748. Sprintf(buf, "%s", to_be_done); 5749. } else if (!strcmp(optname, "packorder")) { 5750. oc_to_str(flags.inv_order, ocl); 5751. Sprintf(buf, "%s", ocl); 5752. #ifdef CHANGE_COLOR 5753. } else if (!strcmp(optname, "palette")) { 5754. Sprintf(buf, "%s", get_color_string()); 5755. #endif 5756. } else if (!strcmp(optname, "paranoid_confirmation")) { 5757. char tmpbuf[QBUFSZ]; 5758. 5759. tmpbuf[0] = '\0'; 5760. for (i = 0; paranoia[i].flagmask != 0; ++i) 5761. if (flags.paranoia_bits & paranoia[i].flagmask) 5762. Sprintf(eos(tmpbuf), " %s", paranoia[i].argname); 5763. Strcpy(buf, tmpbuf[0] ? &tmpbuf[1] : "none"); 5764. } else if (!strcmp(optname, "petattr")) { 5765. #ifdef CURSES_GRAPHICS 5766. if (WINDOWPORT("curses")) { 5767. char tmpbuf[QBUFSZ]; 5768. 5769. Strcpy(buf, curses_fmt_attrs(tmpbuf)); 5770. } else 5771. #endif 5772. if (iflags.wc2_petattr != 0) 5773. Sprintf(buf, "0x%08x", iflags.wc2_petattr); 5774. else 5775. Strcpy(buf, defopt); 5776. } else if (!strcmp(optname, "pettype")) { 5777. Sprintf(buf, "%s", (preferred_pet == 'c') ? "cat" 5778. : (preferred_pet == 'd') ? "dog" 5779. : (preferred_pet == 'h') ? "horse" 5780. : (preferred_pet == 'n') ? "none" 5781. : "random"); 5782. } else if (!strcmp(optname, "pickup_burden")) { 5783. Sprintf(buf, "%s", burdentype[flags.pickup_burden]); 5784. } else if (!strcmp(optname, "pickup_types")) { 5785. oc_to_str(flags.pickup_types, ocl); 5786. Sprintf(buf, "%s", ocl[0] ? ocl : "all"); 5787. } else if (!strcmp(optname, "pile_limit")) { 5788. Sprintf(buf, "%d", flags.pile_limit); 5789. } else if (!strcmp(optname, "playmode")) { 5790. Strcpy(buf, wizard ? "debug" : discover ? "explore" : "normal"); 5791. } else if (!strcmp(optname, "race")) { 5792. Sprintf(buf, "%s", rolestring(flags.initrace, races, noun)); 5793. } else if (!strcmp(optname, "roguesymset")) { 5794. Sprintf(buf, "%s", 5795. symset[ROGUESET].name ? symset[ROGUESET].name : "default"); 5796. if (currentgraphics == ROGUESET && symset[ROGUESET].name) 5797. Strcat(buf, ", active"); 5798. } else if (!strcmp(optname, "role")) { 5799. Sprintf(buf, "%s", rolestring(flags.initrole, roles, name.m)); 5800. } else if (!strcmp(optname, "runmode")) { 5801. Sprintf(buf, "%s", runmodes[flags.runmode]); 5802. } else if (!strcmp(optname, "whatis_coord")) { 5803. Sprintf(buf, "%s", 5804. (iflags.getpos_coords == GPCOORDS_MAP) ? "map" 5805. : (iflags.getpos_coords == GPCOORDS_COMPASS) ? "compass" 5806. : (iflags.getpos_coords == GPCOORDS_COMFULL) ? "full compass" 5807. : (iflags.getpos_coords == GPCOORDS_SCREEN) ? "screen" 5808. : "none"); 5809. } else if (!strcmp(optname, "whatis_filter")) { 5810. Sprintf(buf, "%s", 5811. (iflags.getloc_filter == GFILTER_VIEW) ? "view" 5812. : (iflags.getloc_filter == GFILTER_AREA) ? "area" 5813. : "none"); 5814. } else if (!strcmp(optname, "scores")) { 5815. Sprintf(buf, "%d top/%d around%s", flags.end_top, flags.end_around, 5816. flags.end_own ? "/own" : ""); 5817. } else if (!strcmp(optname, "scroll_amount")) { 5818. if (iflags.wc_scroll_amount) 5819. Sprintf(buf, "%d", iflags.wc_scroll_amount); 5820. else 5821. Strcpy(buf, defopt); 5822. } else if (!strcmp(optname, "scroll_margin")) { 5823. if (iflags.wc_scroll_margin) 5824. Sprintf(buf, "%d", iflags.wc_scroll_margin); 5825. else 5826. Strcpy(buf, defopt); 5827. } else if (!strcmp(optname, "sortloot")) { 5828. for (i = 0; i < SIZE(sortltype); i++) 5829. if (flags.sortloot == sortltype[i][0]) { 5830. Strcpy(buf, sortltype[i]); 5831. break; 5832. } 5833. } else if (!strcmp(optname, "player_selection")) { 5834. Sprintf(buf, "%s", iflags.wc_player_selection ? "prompts" : "dialog"); 5835. #ifdef MSDOS 5836. } else if (!strcmp(optname, "soundcard")) { 5837. Sprintf(buf, "%s", to_be_done); 5838. #endif 5839. #ifdef STATUS_HILITES 5840. } else if (!strcmp("statushilites", optname)) { 5841. if (!iflags.hilite_delta) 5842. Strcpy(buf, "0 (off: don't highlight status fields)"); 5843. else 5844. Sprintf(buf, "%ld (on: highlight status for %ld turns)", 5845. iflags.hilite_delta, iflags.hilite_delta); 5846. #endif 5847. } else if (!strcmp(optname,"statuslines")) { 5848. if (wc2_supported(optname)) 5849. Strcpy(buf, (iflags.wc2_statuslines < 3) ? "2" : "3"); 5850. /* else default to "unknown" */ 5851. } else if (!strcmp(optname, "suppress_alert")) { 5852. if (flags.suppress_alert == 0L) 5853. Strcpy(buf, none); 5854. else 5855. Sprintf(buf, "%lu.%lu.%lu", FEATURE_NOTICE_VER_MAJ, 5856. FEATURE_NOTICE_VER_MIN, FEATURE_NOTICE_VER_PATCH); 5857. } else if (!strcmp(optname, "symset")) { 5858. Sprintf(buf, "%s", 5859. symset[PRIMARY].name ? symset[PRIMARY].name : "default"); 5860. if (currentgraphics == PRIMARY && symset[PRIMARY].name) 5861. Strcat(buf, ", active"); 5862. } else if (!strcmp(optname, "term_cols")) { 5863. if (iflags.wc2_term_cols) 5864. Sprintf(buf, "%d", iflags.wc2_term_cols); 5865. else 5866. Strcpy(buf, defopt); 5867. } else if (!strcmp(optname, "term_rows")) { 5868. if (iflags.wc2_term_rows) 5869. Sprintf(buf, "%d", iflags.wc2_term_rows); 5870. else 5871. Strcpy(buf, defopt); 5872. } else if (!strcmp(optname, "tile_file")) { 5873. Sprintf(buf, "%s", 5874. iflags.wc_tile_file ? iflags.wc_tile_file : defopt); 5875. } else if (!strcmp(optname, "tile_height")) { 5876. if (iflags.wc_tile_height) 5877. Sprintf(buf, "%d", iflags.wc_tile_height); 5878. else 5879. Strcpy(buf, defopt); 5880. } else if (!strcmp(optname, "tile_width")) { 5881. if (iflags.wc_tile_width) 5882. Sprintf(buf, "%d", iflags.wc_tile_width); 5883. else 5884. Strcpy(buf, defopt); 5885. } else if (!strcmp(optname, "traps")) { 5886. Sprintf(buf, "%s", to_be_done); 5887. } else if (!strcmp(optname, "vary_msgcount")) { 5888. if (iflags.wc_vary_msgcount) 5889. Sprintf(buf, "%d", iflags.wc_vary_msgcount); 5890. else 5891. Strcpy(buf, defopt); 5892. #ifdef MSDOS 5893. } else if (!strcmp(optname, "video")) { 5894. Sprintf(buf, "%s", to_be_done); 5895. #endif 5896. #ifdef VIDEOSHADES 5897. } else if (!strcmp(optname, "videoshades")) { 5898. Sprintf(buf, "%s-%s-%s", shade[0], shade[1], shade[2]); 5899. } else if (!strcmp(optname, "videocolors")) { 5900. Sprintf(buf, "%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d-%d", 5901. ttycolors[CLR_RED], ttycolors[CLR_GREEN], 5902. ttycolors[CLR_BROWN], ttycolors[CLR_BLUE], 5903. ttycolors[CLR_MAGENTA], ttycolors[CLR_CYAN], 5904. ttycolors[CLR_ORANGE], ttycolors[CLR_BRIGHT_GREEN], 5905. ttycolors[CLR_YELLOW], ttycolors[CLR_BRIGHT_BLUE], 5906. ttycolors[CLR_BRIGHT_MAGENTA], ttycolors[CLR_BRIGHT_CYAN]); 5907. #endif /* VIDEOSHADES */ 5908. } else if (!strcmp(optname,"windowborders")) { 5909. Sprintf(buf, "%s", 5910. (iflags.wc2_windowborders == 0) ? "0=off" 5911. : (iflags.wc2_windowborders == 1) ? "1=on" 5912. : (iflags.wc2_windowborders == 2) ? "2=auto" 5913. : defopt); 5914. } else if (!strcmp(optname, "windowtype")) { 5915. Sprintf(buf, "%s", windowprocs.name); 5916. } else if (!strcmp(optname, "windowcolors")) { 5917. Sprintf( 5918. buf, "%s/%s %s/%s %s/%s %s/%s", 5919. iflags.wc_foregrnd_menu ? iflags.wc_foregrnd_menu : defbrief, 5920. iflags.wc_backgrnd_menu ? iflags.wc_backgrnd_menu : defbrief, 5921. iflags.wc_foregrnd_message ? iflags.wc_foregrnd_message 5922. : defbrief, 5923. iflags.wc_backgrnd_message ? iflags.wc_backgrnd_message 5924. : defbrief, 5925. iflags.wc_foregrnd_status ? iflags.wc_foregrnd_status : defbrief, 5926. iflags.wc_backgrnd_status ? iflags.wc_backgrnd_status : defbrief, 5927. iflags.wc_foregrnd_text ? iflags.wc_foregrnd_text : defbrief, 5928. iflags.wc_backgrnd_text ? iflags.wc_backgrnd_text : defbrief); 5929. #ifdef PREFIXES_IN_USE 5930. } else { 5931. for (i = 0; i < PREFIX_COUNT; ++i) 5932. if (!strcmp(optname, fqn_prefix_names[i]) && fqn_prefix[i]) 5933. Sprintf(buf, "%s", fqn_prefix[i]); 5934. #endif 5935. } 5936. 5937. if (!buf[0]) 5938. Strcpy(buf, "unknown"); 5939. return buf; 5940. } 5941. 5942. int 5943. dotogglepickup() 5944. { 5945. char buf[BUFSZ], ocl[MAXOCLASSES + 1]; 5946. 5947. flags.pickup = !flags.pickup; 5948. if (flags.pickup) { 5949. oc_to_str(flags.pickup_types, ocl); 5950. Sprintf(buf, "ON, for %s objects%s", ocl[0] ? ocl : "all", 5951. (apelist) 5952. ? ((count_apes() == 1) 5953. ? ", with one exception" 5954. : ", with some exceptions") 5955. : ""); 5956. } else { 5957. Strcpy(buf, "OFF"); 5958. } 5959. pline("Autopickup: %s.", buf); 5960. return 0; 5961. } 5962. 5963. int 5964. add_autopickup_exception(mapping) 5965. const char *mapping; 5966. { 5967. static const char 5968. APE_regex_error[] = "regex error in AUTOPICKUP_EXCEPTION", 5969. APE_syntax_error[] = "syntax error in AUTOPICKUP_EXCEPTION"; 5970. 5971. struct autopickup_exception *ape; 5972. char text[256], end; 5973. int n; 5974. boolean grab = FALSE; 5975. 5976. /* scan length limit used to be 255, but smaller size allows the 5977. quoted value to fit within BUFSZ, simplifying formatting elsewhere; 5978. this used to ignore the possibility of trailing junk but now checks 5979. for it, accepting whitespace but rejecting anything else unless it 5980. starts with '#" for a comment */ 5981. end = '\0'; 5982. if ((n = sscanf(mapping, "\"<%253[^\"]\" %c", text, &end)) == 1 5983. || (n == 2 && end == '#')) { 5984. grab = TRUE; 5985. } else if ((n = sscanf(mapping, "\">%253[^\"]\" %c", text, &end)) == 1 5986. || (n = sscanf(mapping, "\"%253[^\"]\" %c", text, &end)) == 1 5987. || (n == 2 && end == '#')) { 5988. grab = FALSE; 5989. } else { 5990. config_error_add("%s", APE_syntax_error); 5991. return 0; 5992. } 5993. 5994. ape = (struct autopickup_exception *) alloc(sizeof *ape); 5995. ape->regex = regex_init(); 5996. if (!regex_compile(text, ape->regex)) { 5997. config_error_add("%s: %s", APE_regex_error, 5998. regex_error_desc(ape->regex)); 5999. regex_free(ape->regex); 6000. free((genericptr_t) ape); 6001. return 0; 6002. } 6003. 6004. ape->pattern = dupstr(text); 6005. ape->grab = grab; 6006. ape->next = apelist; 6007. apelist = ape; 6008. return 1; 6009. } 6010. 6011. STATIC_OVL void 6012. remove_autopickup_exception(whichape) 6013. struct autopickup_exception *whichape; 6014. { 6015. struct autopickup_exception *ape, *freeape, *prev = 0; 6016. 6017. for (ape = apelist; ape;) { 6018. if (ape == whichape) { 6019. freeape = ape; 6020. ape = ape->next; 6021. if (prev) 6022. prev->next = ape; 6023. else 6024. apelist = ape; 6025. regex_free(freeape->regex); 6026. free((genericptr_t) freeape->pattern); 6027. free((genericptr_t) freeape); 6028. } else { 6029. prev = ape; 6030. ape = ape->next; 6031. } 6032. } 6033. } 6034. 6035. void 6036. free_autopickup_exceptions() 6037. { 6038. struct autopickup_exception *ape = apelist; 6039. 6040. while ((ape = apelist) != 0) { 6041. regex_free(ape->regex); 6042. free((genericptr_t) ape->pattern); 6043. apelist = ape->next; 6044. free((genericptr_t) ape); 6045. } 6046. } 6047. 6048. /* bundle some common usage into one easy-to-use routine */ 6049. int 6050. load_symset(s, which_set) 6051. const char *s; 6052. int which_set; 6053. { 6054. clear_symsetentry(which_set, TRUE); 6055. 6056. if (symset[which_set].name) 6057. free((genericptr_t) symset[which_set].name); 6058. symset[which_set].name = dupstr(s); 6059. 6060. if (read_sym_file(which_set)) { 6061. switch_symbols(TRUE); 6062. } else { 6063. clear_symsetentry(which_set, TRUE); 6064. return 0; 6065. } 6066. return 1; 6067. } 6068. 6069. void 6070. free_symsets() 6071. { 6072. clear_symsetentry(PRIMARY, TRUE); 6073. clear_symsetentry(ROGUESET, TRUE); 6074. 6075. /* symset_list is cleaned up as soon as it's used, so we shouldn't 6076. have to anything about it here */ 6077. /* assert( symset_list == NULL ); */ 6078. } 6079. 6080. /* Parse the value of a SYMBOLS line from a config file */ 6081. boolean 6082. parsesymbols(opts, which_set) 6083. register char *opts; 6084. int which_set; 6085. { 6086. int val; 6087. char *op, *symname, *strval; 6088. struct symparse *symp; 6089. 6090. if ((op = index(opts, ',')) != 0) { 6091. *op++ = 0; 6092. if (!parsesymbols(op, which_set)) 6093. return FALSE; 6094. } 6095. 6096. /* S_sample:string */ 6097. symname = opts; 6098. strval = index(opts, ':'); 6099. if (!strval) 6100. strval = index(opts, '='); 6101. if (!strval) 6102. return FALSE; 6103. *strval++ = '\0'; 6104. 6105. /* strip leading and trailing white space from symname and strval */ 6106. mungspaces(symname); 6107. mungspaces(strval); 6108. 6109. symp = match_sym(symname); 6110. if (!symp) 6111. return FALSE; 6112. 6113. if (symp->range && symp->range != SYM_CONTROL) { 6114. val = sym_val(strval); 6115. if (which_set == ROGUESET) 6116. update_ov_rogue_symset(symp, val); 6117. else 6118. update_ov_primary_symset(symp, val); 6119. } 6120. return TRUE; 6121. } 6122. 6123. struct symparse * 6124. match_sym(buf) 6125. char *buf; 6126. { 6127. size_t len = strlen(buf); 6128. const char *p = index(buf, ':'), *q = index(buf, '='); 6129. struct symparse *sp = loadsyms; 6130. 6131. if (!p || (q && q < p)) 6132. p = q; 6133. if (p) { 6134. /* note: there will be at most one space before the '=' 6135. because caller has condensed buf[] with mungspaces() */ 6136. if (p > buf && p[-1] == ' ') 6137. p--; 6138. len = (int) (p - buf); 6139. } 6140. while (sp->range) { 6141. if ((len >= strlen(sp->name)) && !strncmpi(buf, sp->name, len)) 6142. return sp; 6143. sp++; 6144. } 6145. return (struct symparse *) 0; 6146. } 6147. 6148. int 6149. sym_val(strval) 6150. const char *strval; 6151. { 6152. char buf[QBUFSZ]; 6153. 6154. buf[0] = '\0'; 6155. if (!strval[0] || !strval[1]) { /* empty, or single character */ 6156. /* if single char is space or tab, leave buf[0]=='\0' */ 6157. if (!isspace((uchar) strval[0])) 6158. buf[0] = strval[0]; 6159. } else if (strval[0] == '\) { /* single quote */ 6160. /* simple matching single quote; we know strval[1] isn't '\0' */ 6161. if (strval[2] == '\ && !strval[3]) { 6162. /* accepts '\' as backslash and as single quote */ 6163. buf[0] = strval[1]; 6164. 6165. /* if backslash, handle single or double quote or second backslash */ 6166. } else if (strval[1] == '\\' && strval[2] && strval[3] == '\ 6167. && index("'\"\\", strval[2]) && !strval[4]) { 6168. buf[0] = strval[2]; 6169. 6170. /* not simple quote or basic backslash; 6171. strip closing quote and let escapes() deal with it */ 6172. } else { 6173. char *p, tmp[QBUFSZ]; 6174. 6175. (void) strncpy(tmp, strval + 1, sizeof tmp - 1); 6176. tmp[sizeof tmp - 1] = '\0'; 6177. if ((p = rindex(tmp, '\)) != 0) { 6178. *p = '\0'; 6179. escapes(tmp, buf); 6180. } /* else buf[0] stays '\0' */ 6181. } 6182. } else /* not lone char nor single quote */ 6183. escapes(strval, buf); 6184. 6185. return (int) *buf; 6186. } 6187. 6188. /* data for option_help() */ 6189. static const char *opt_intro[] = { 6190. "", 6191. " NetHack Options Help:", "", 6192. #define CONFIG_SLOT 3 /* fill in next value at run-time */ 6193. (char *) 0, 6194. #if !defined(MICRO) && !defined(MAC) 6195. "or use `NETHACKOPTIONS=\"<options>\"' in your environment", 6196. #endif 6197. "(<options> is a list of options separated by commas)", 6198. #ifdef VMS 6199. "-- for example, $ DEFINE NETHACKOPTIONS \"noautopickup,fruit:kumquat\"", 6200. #endif 6201. "or press \"O\" while playing and use the menu.", 6202. "", 6203. "Boolean options (which can be negated by prefixing them with '!' or \"no\"):", 6204. (char *) 0 6205. }; 6206. 6207. static const char *opt_epilog[] = { 6208. "", 6209. "Some of the options can be set only before the game is started; those", 6210. "items will not be selectable in the 'O' command's menu.", 6211. (char *) 0 6212. }; 6213. 6214. void 6215. option_help() 6216. { 6217. char buf[BUFSZ], buf2[BUFSZ]; 6218. register int i; 6219. winid datawin; 6220. 6221. datawin = create_nhwindow(NHW_TEXT); 6222. Sprintf(buf, "Set options as OPTIONS=<options> in %s", configfile); 6223. opt_intro[CONFIG_SLOT] = (const char *) buf; 6224. for (i = 0; opt_intro[i]; i++) 6225. putstr(datawin, 0, opt_intro[i]); 6226. 6227. /* Boolean options */ 6228. for (i = 0; boolopt[i].name; i++) { 6229. if (boolopt[i].addr) { 6230. if (boolopt[i].addr == &iflags.sanity_check && !wizard) 6231. continue; 6232. if (boolopt[i].addr == &iflags.menu_tab_sep && !wizard) 6233. continue; 6234. next_opt(datawin, boolopt[i].name); 6235. } 6236. } 6237. next_opt(datawin, ""); 6238. 6239. /* Compound options */ 6240. putstr(datawin, 0, "Compound options:"); 6241. for (i = 0; compopt[i].name; i++) { 6242. Sprintf(buf2, "`%s'", compopt[i].name); 6243. Sprintf(buf, "%-20s - %s%c", buf2, compopt[i].descr, 6244. compopt[i + 1].name ? ',' : '.'); 6245. putstr(datawin, 0, buf); 6246. } 6247. 6248. for (i = 0; opt_epilog[i]; i++) 6249. putstr(datawin, 0, opt_epilog[i]); 6250. 6251. display_nhwindow(datawin, FALSE); 6252. destroy_nhwindow(datawin); 6253. return; 6254. } 6255. 6256. /* 6257. * prints the next boolean option, on the same line if possible, on a new 6258. * line if not. End with next_opt(""). 6259. */ 6260. void 6261. next_opt(datawin, str) 6262. winid datawin; 6263. const char *str; 6264. { 6265. static char *buf = 0; 6266. int i; 6267. char *s; 6268. 6269. if (!buf) 6270. *(buf = (char *) alloc(BUFSZ)) = '\0'; 6271. 6272. if (!*str) { 6273. s = eos(buf); 6274. if (s > &buf[1] && s[-2] == ',') 6275. Strcpy(s - 2, "."); /* replace last ", " */ 6276. i = COLNO; /* (greater than COLNO - 2) */ 6277. } else { 6278. i = strlen(buf) + strlen(str) + 2; 6279. } 6280. 6281. if (i > COLNO - 2) { /* rule of thumb */ 6282. putstr(datawin, 0, buf); 6283. buf[0] = 0; 6284. } 6285. if (*str) { 6286. Strcat(buf, str); 6287. Strcat(buf, ", "); 6288. } else { 6289. putstr(datawin, 0, str); 6290. free((genericptr_t) buf), buf = 0; 6291. } 6292. return; 6293. } 6294. 6295. /* Returns the fid of the fruit type; if that type already exists, it 6296. * returns the fid of that one; if it does not exist, it adds a new fruit 6297. * type to the chain and returns the new one. 6298. * If replace_fruit is sent in, replace the fruit in the chain rather than 6299. * adding a new entry--for user specified fruits only. 6300. */ 6301. int 6302. fruitadd(str, replace_fruit) 6303. char *str; 6304. struct fruit *replace_fruit; 6305. { 6306. register int i; 6307. register struct fruit *f; 6308. int highest_fruit_id = 0, globpfx; 6309. char buf[PL_FSIZ], altname[PL_FSIZ]; 6310. boolean user_specified = (str == pl_fruit); 6311. /* if not user-specified, then it's a fruit name for a fruit on 6312. * a bones level or from orctown raider's loot... 6313. */ 6314. 6315. /* Note: every fruit has an id (kept in obj->spe) of at least 1; 6316. * 0 is an error. 6317. */ 6318. if (user_specified) { 6319. boolean found = FALSE, numeric = FALSE; 6320. 6321. /* force fruit to be singular; this handling is not 6322. needed--or wanted--for fruits from bones because 6323. they already received it in their original game; 6324. str==pl_fruit but makesingular() creates a copy 6325. so we need to copy that back into pl_fruit */ 6326. nmcpy(pl_fruit, makesingular(str), PL_FSIZ); 6327. /* (assertion doesn't matter; we use 'pl_fruit' from here on out) */ 6328. /* assert( str == pl_fruit ); */ 6329. 6330. /* disallow naming after other foods (since it'd be impossible 6331. * to tell the difference); globs might have a size prefix which 6332. * needs to be skipped in order to match the object type name 6333. */ 6334. globpfx = (!strncmp(pl_fruit, "small ", 6) 6335. || !strncmp(pl_fruit, "large ", 6)) ? 6 6336. : (!strncmp(pl_fruit, "very large ", 11)) ? 11 6337. : 0; 6338. for (i = bases[FOOD_CLASS]; objects[i].oc_class == FOOD_CLASS; i++) { 6339. if (!strcmp(OBJ_NAME(objects[i]), pl_fruit) 6340. || (globpfx > 0 6341. && !strcmp(OBJ_NAME(objects[i]), &pl_fruit[globpfx]))) { 6342. found = TRUE; 6343. break; 6344. } 6345. } 6346. if (!found) { 6347. char *c; 6348. 6349. for (c = pl_fruit; *c >= '0' && *c <= '9'; c++) 6350. continue; 6351. if (!*c || isspace((uchar) *c)) 6352. numeric = TRUE; 6353. } 6354. if (found || numeric 6355. /* these checks for applying food attributes to actual items 6356. are case sensitive; "glob of foo" is caught by 'found' 6357. if 'foo' is a valid glob; when not valid, allow it as-is */ 6358. || !strncmp(pl_fruit, "cursed ", 7) 6359. || !strncmp(pl_fruit, "uncursed ", 9) 6360. || !strncmp(pl_fruit, "blessed ", 8) 6361. || !strncmp(pl_fruit, "partly eaten ", 13) 6362. || (!strncmp(pl_fruit, "tin of ", 7) 6363. && (!strcmp(pl_fruit + 7, "spinach") 6364. || name_to_mon(pl_fruit + 7) >= LOW_PM)) 6365. || !strcmp(pl_fruit, "empty tin") 6366. || (!strcmp(pl_fruit, "glob") 6367. || (globpfx > 0 && !strcmp("glob", &pl_fruit[globpfx]))) 6368. || ((str_end_is(pl_fruit, " corpse") 6369. || str_end_is(pl_fruit, " egg")) 6370. && name_to_mon(pl_fruit) >= LOW_PM)) { 6371. Strcpy(buf, pl_fruit); 6372. Strcpy(pl_fruit, "candied "); 6373. nmcpy(pl_fruit + 8, buf, PL_FSIZ - 8); 6374. } 6375. *altname = '\0'; 6376. /* This flag indicates that a fruit has been made since the 6377. * last time the user set the fruit. If it hasn't, we can 6378. * safely overwrite the current fruit, preventing the user from 6379. * setting many fruits in a row and overflowing. 6380. * Possible expansion: check for specific fruit IDs, not for 6381. * any fruit. 6382. */ 6383. flags.made_fruit = FALSE; 6384. if (replace_fruit) { 6385. /* replace_fruit is already part of the fruit chain; 6386. update it in place rather than looking it up again */ 6387. f = replace_fruit; 6388. copynchars(f->fname, pl_fruit, PL_FSIZ - 1); 6389. goto nonew; 6390. } 6391. } else { 6392. /* not user_supplied, so assumed to be from bones (or orc gang) */ 6393. copynchars(altname, str, PL_FSIZ - 1); 6394. sanitize_name(altname); 6395. flags.made_fruit = TRUE; /* for safety. Any fruit name added from a 6396. * bones level should exist anyway. */ 6397. } 6398. f = fruit_from_name(*altname ? altname : str, FALSE, &highest_fruit_id); 6399. if (f) 6400. goto nonew; 6401. 6402. /* Maximum number of named fruits is 127, even if obj->spe can 6403. handle bigger values. If adding another fruit would overflow, 6404. use a random fruit instead... we've got a lot to choose from. 6405. current_fruit remains as is. */ 6406. if (highest_fruit_id >= 127) 6407. return rnd(127); 6408. 6409. f = newfruit(); 6410. (void) memset((genericptr_t) f, 0, sizeof (struct fruit)); 6411. copynchars(f->fname, *altname ? altname : str, PL_FSIZ - 1); 6412. f->fid = ++highest_fruit_id; 6413. /* we used to go out of our way to add it at the end of the list, 6414. but the order is arbitrary so use simpler insertion at start */ 6415. f->nextf = ffruit; 6416. ffruit = f; 6417. nonew: 6418. if (user_specified) 6419. context.current_fruit = f->fid; 6420. return f->fid; 6421. } 6422. 6423. /* 6424. * This is a somewhat generic menu for taking a list of NetHack style 6425. * class choices and presenting them via a description 6426. * rather than the traditional NetHack characters. 6427. * (Benefits users whose first exposure to NetHack is via tiles). 6428. * 6429. * prompt 6430. * The title at the top of the menu. 6431. * 6432. * category: 0 = monster class 6433. * 1 = object class 6434. * 6435. * way 6436. * FALSE = PICK_ONE, TRUE = PICK_ANY 6437. * 6438. * class_list 6439. * a null terminated string containing the list of choices. 6440. * 6441. * class_selection 6442. * a null terminated string containing the selected characters. 6443. * 6444. * Returns number selected. 6445. */ 6446. int 6447. choose_classes_menu(prompt, category, way, class_list, class_select) 6448. const char *prompt; 6449. int category; 6450. boolean way; 6451. char *class_list; 6452. char *class_select; 6453. { 6454. menu_item *pick_list = (menu_item *) 0; 6455. winid win; 6456. anything any; 6457. char buf[BUFSZ]; 6458. int i, n; 6459. int ret; 6460. int next_accelerator, accelerator; 6461. 6462. if (class_list == (char *) 0 || class_select == (char *) 0) 6463. return 0; 6464. accelerator = 0; 6465. next_accelerator = 'a'; 6466. any = zeroany; 6467. win = create_nhwindow(NHW_MENU); 6468. start_menu(win); 6469. while (*class_list) { 6470. const char *text; 6471. boolean selected; 6472. 6473. text = (char *) 0; 6474. selected = FALSE; 6475. switch (category) { 6476. case 0: 6477. text = def_monsyms[def_char_to_monclass(*class_list)].explain; 6478. accelerator = *class_list; 6479. Sprintf(buf, "%s", text); 6480. break; 6481. case 1: 6482. text = def_oc_syms[def_char_to_objclass(*class_list)].explain; 6483. accelerator = next_accelerator; 6484. Sprintf(buf, "%c %s", *class_list, text); 6485. break; 6486. default: 6487. impossible("choose_classes_menu: invalid category %d", category); 6488. } 6489. if (way && *class_select) { /* Selections there already */ 6490. if (index(class_select, *class_list)) { 6491. selected = TRUE; 6492. } 6493. } 6494. any.a_int = *class_list; 6495. add_menu(win, NO_GLYPH, &any, accelerator, category ? *class_list : 0, 6496. ATR_NONE, buf, selected); 6497. ++class_list; 6498. if (category > 0) { 6499. ++next_accelerator; 6500. if (next_accelerator == ('z' + 1)) 6501. next_accelerator = 'A'; 6502. if (next_accelerator == ('Z' + 1)) 6503. break; 6504. } 6505. } 6506. if (category == 1 && next_accelerator <= 'z') { 6507. /* for objects, add "A - ' ' all classes", after a separator */ 6508. any = zeroany; 6509. add_menu(win, NO_GLYPH, &any, 0, 0, ATR_NONE, "", MENU_UNSELECTED); 6510. any.a_int = (int) ' '; 6511. Sprintf(buf, "%c %s", (char) any.a_int, "all classes of objects"); 6512. /* we won't preselect this even if the incoming list is empty; 6513. having it selected means that it would have to be explicitly 6514. de-selected in order to select anything else */ 6515. add_menu(win, NO_GLYPH, &any, 'A', 0, ATR_NONE, buf, MENU_UNSELECTED); 6516. } 6517. end_menu(win, prompt); 6518. n = select_menu(win, way ? PICK_ANY : PICK_ONE, &pick_list); 6519. destroy_nhwindow(win); 6520. if (n > 0) { 6521. if (category == 1) { 6522. /* for object classes, first check for 'all'; it means 'use 6523. a blank list' rather than 'collect every possible choice' */ 6524. for (i = 0; i < n; ++i) 6525. if (pick_list[i].item.a_int == ' ') { 6526. pick_list[0].item.a_int = ' '; 6527. n = 1; /* return 1; also an implicit 'break;' */ 6528. } 6529. } 6530. for (i = 0; i < n; ++i) 6531. *class_select++ = (char) pick_list[i].item.a_int; 6532. free((genericptr_t) pick_list); 6533. ret = n; 6534. } else if (n == -1) { 6535. class_select = eos(class_select); 6536. ret = -1; 6537. } else 6538. ret = 0; 6539. *class_select = '\0'; 6540. return ret; 6541. } 6542. 6543. static struct wc_Opt wc_options[] = { 6544. { "ascii_map", WC_ASCII_MAP }, 6545. { "color", WC_COLOR }, 6546. { "eight_bit_tty", WC_EIGHT_BIT_IN }, 6547. { "hilite_pet", WC_HILITE_PET }, 6548. { "popup_dialog", WC_POPUP_DIALOG }, 6549. { "player_selection", WC_PLAYER_SELECTION }, 6550. { "preload_tiles", WC_PRELOAD_TILES }, 6551. { "tiled_map", WC_TILED_MAP }, 6552. { "tile_file", WC_TILE_FILE }, 6553. { "tile_width", WC_TILE_WIDTH }, 6554. { "tile_height", WC_TILE_HEIGHT }, 6555. { "use_inverse", WC_INVERSE }, 6556. { "align_message", WC_ALIGN_MESSAGE }, 6557. { "align_status", WC_ALIGN_STATUS }, 6558. { "font_map", WC_FONT_MAP }, 6559. { "font_menu", WC_FONT_MENU }, 6560. { "font_message", WC_FONT_MESSAGE }, 6561. #if 0 6562. {"perm_invent", WC_PERM_INVENT}, 6563. #endif 6564. { "font_size_map", WC_FONTSIZ_MAP }, 6565. { "font_size_menu", WC_FONTSIZ_MENU }, 6566. { "font_size_message", WC_FONTSIZ_MESSAGE }, 6567. { "font_size_status", WC_FONTSIZ_STATUS }, 6568. { "font_size_text", WC_FONTSIZ_TEXT }, 6569. { "font_status", WC_FONT_STATUS }, 6570. { "font_text", WC_FONT_TEXT }, 6571. { "map_mode", WC_MAP_MODE }, 6572. { "scroll_amount", WC_SCROLL_AMOUNT }, 6573. { "scroll_margin", WC_SCROLL_MARGIN }, 6574. { "splash_screen", WC_SPLASH_SCREEN }, 6575. { "vary_msgcount", WC_VARY_MSGCOUNT }, 6576. { "windowcolors", WC_WINDOWCOLORS }, 6577. { "mouse_support", WC_MOUSE_SUPPORT }, 6578. { (char *) 0, 0L } 6579. }; 6580. static struct wc_Opt wc2_options[] = { 6581. { "fullscreen", WC2_FULLSCREEN }, 6582. { "softkeyboard", WC2_SOFTKEYBOARD }, 6583. { "wraptext", WC2_WRAPTEXT }, 6584. { "use_darkgray", WC2_DARKGRAY }, 6585. { "hitpointbar", WC2_HITPOINTBAR }, 6586. { "hilite_status", WC2_HILITE_STATUS }, 6587. /* name shown in 'O' menu is different */ 6588. { "status hilite rules", WC2_HILITE_STATUS }, 6589. /* statushilites doesn't have its own bit */ 6590. { "statushilites", WC2_HILITE_STATUS }, 6591. { "term_cols", WC2_TERM_SIZE }, 6592. { "term_rows", WC2_TERM_SIZE }, 6593. { "petattr", WC2_PETATTR }, 6594. { "guicolor", WC2_GUICOLOR }, 6595. { "statuslines", WC2_STATUSLINES }, 6596. { "windowborders", WC2_WINDOWBORDERS }, 6597. { (char *) 0, 0L } 6598. }; 6599. 6600. /* 6601. * If a port wants to change or ensure that the SET_IN_SYS, 6602. * SET_IN_FILE, DISP_IN_GAME, or SET_IN_GAME status of an option is 6603. * correct (for controlling its display in the option menu) call 6604. * set_option_mod_status() 6605. * with the appropriate second argument. 6606. */ 6607. void 6608. set_option_mod_status(optnam, status) 6609. const char *optnam; 6610. int status; 6611. { 6612. int k; 6613. 6614. if (SET__IS_VALUE_VALID(status)) { 6615. impossible("set_option_mod_status: status out of range %d.", status); 6616. return; 6617. } 6618. for (k = 0; boolopt[k].name; k++) { 6619. if (!strncmpi(boolopt[k].name, optnam, strlen(optnam))) { 6620. boolopt[k].optflags = status; 6621. return; 6622. } 6623. } 6624. for (k = 0; compopt[k].name; k++) { 6625. if (!strncmpi(compopt[k].name, optnam, strlen(optnam))) { 6626. compopt[k].optflags = status; 6627. return; 6628. } 6629. } 6630. } 6631. 6632. /* 6633. * You can set several wc_options in one call to 6634. * set_wc_option_mod_status() by setting 6635. * the appropriate bits for each option that you 6636. * are setting in the optmask argument 6637. * prior to calling. 6638. * example: set_wc_option_mod_status(WC_COLOR|WC_SCROLL_MARGIN, 6639. * SET_IN_GAME); 6640. */ 6641. void 6642. set_wc_option_mod_status(optmask, status) 6643. unsigned long optmask; 6644. int status; 6645. { 6646. int k = 0; 6647. 6648. if (SET__IS_VALUE_VALID(status)) { 6649. impossible("set_wc_option_mod_status: status out of range %d.", 6650. status); 6651. return; 6652. } 6653. while (wc_options[k].wc_name) { 6654. if (optmask & wc_options[k].wc_bit) { 6655. set_option_mod_status(wc_options[k].wc_name, status); 6656. } 6657. k++; 6658. } 6659. } 6660. 6661. STATIC_OVL boolean 6662. is_wc_option(optnam) 6663. const char *optnam; 6664. { 6665. int k = 0; 6666. 6667. while (wc_options[k].wc_name) { 6668. if (strcmp(wc_options[k].wc_name, optnam) == 0) 6669. return TRUE; 6670. k++; 6671. } 6672. return FALSE; 6673. } 6674. 6675. STATIC_OVL boolean 6676. wc_supported(optnam) 6677. const char *optnam; 6678. { 6679. int k; 6680. 6681. for (k = 0; wc_options[k].wc_name; ++k) { 6682. if (!strcmp(wc_options[k].wc_name, optnam)) 6683. return (windowprocs.wincap & wc_options[k].wc_bit) ? TRUE : FALSE; 6684. } 6685. return FALSE; 6686. } 6687. 6688. /* 6689. * You can set several wc2_options in one call to 6690. * set_wc2_option_mod_status() by setting 6691. * the appropriate bits for each option that you 6692. * are setting in the optmask argument 6693. * prior to calling. 6694. * example: 6695. * set_wc2_option_mod_status(WC2_FULLSCREEN|WC2_SOFTKEYBOARD|WC2_WRAPTEXT, 6696. * SET_IN_FILE); 6697. */ 6698. 6699. void 6700. set_wc2_option_mod_status(optmask, status) 6701. unsigned long optmask; 6702. int status; 6703. { 6704. int k = 0; 6705. 6706. if (SET__IS_VALUE_VALID(status)) { 6707. impossible("set_wc2_option_mod_status: status out of range %d.", 6708. status); 6709. return; 6710. } 6711. while (wc2_options[k].wc_name) { 6712. if (optmask & wc2_options[k].wc_bit) { 6713. set_option_mod_status(wc2_options[k].wc_name, status); 6714. } 6715. k++; 6716. } 6717. } 6718. 6719. STATIC_OVL boolean 6720. is_wc2_option(optnam) 6721. const char *optnam; 6722. { 6723. int k = 0; 6724. 6725. while (wc2_options[k].wc_name) { 6726. if (strcmp(wc2_options[k].wc_name, optnam) == 0) 6727. return TRUE; 6728. k++; 6729. } 6730. return FALSE; 6731. } 6732. 6733. STATIC_OVL boolean 6734. wc2_supported(optnam) 6735. const char *optnam; 6736. { 6737. int k; 6738. 6739. for (k = 0; wc2_options[k].wc_name; ++k) { 6740. if (!strcmp(wc2_options[k].wc_name, optnam)) 6741. return (windowprocs.wincap2 & wc2_options[k].wc_bit) ? TRUE 6742. : FALSE; 6743. } 6744. return FALSE; 6745. } 6746. 6747. STATIC_OVL void 6748. wc_set_font_name(opttype, fontname) 6749. int opttype; 6750. char *fontname; 6751. { 6752. char **fn = (char **) 0; 6753. 6754. if (!fontname) 6755. return; 6756. switch (opttype) { 6757. case MAP_OPTION: 6758. fn = &iflags.wc_font_map; 6759. break; 6760. case MESSAGE_OPTION: 6761. fn = &iflags.wc_font_message; 6762. break; 6763. case TEXT_OPTION: 6764. fn = &iflags.wc_font_text; 6765. break; 6766. case MENU_OPTION: 6767. fn = &iflags.wc_font_menu; 6768. break; 6769. case STATUS_OPTION: 6770. fn = &iflags.wc_font_status; 6771. break; 6772. default: 6773. return; 6774. } 6775. if (fn) { 6776. if (*fn) 6777. free((genericptr_t) *fn); 6778. *fn = dupstr(fontname); 6779. } 6780. return; 6781. } 6782. 6783. STATIC_OVL int 6784. wc_set_window_colors(op) 6785. char *op; 6786. { 6787. /* syntax: 6788. * menu white/black message green/yellow status white/blue text 6789. * white/black 6790. */ 6791. int j; 6792. char buf[BUFSZ]; 6793. char *wn, *tfg, *tbg, *newop; 6794. static const char *wnames[] = { "menu", "message", "status", "text" }; 6795. static const char *shortnames[] = { "mnu", "msg", "sts", "txt" }; 6796. static char **fgp[] = { &iflags.wc_foregrnd_menu, 6797. &iflags.wc_foregrnd_message, 6798. &iflags.wc_foregrnd_status, 6799. &iflags.wc_foregrnd_text }; 6800. static char **bgp[] = { &iflags.wc_backgrnd_menu, 6801. &iflags.wc_backgrnd_message, 6802. &iflags.wc_backgrnd_status, 6803. &iflags.wc_backgrnd_text }; 6804. 6805. Strcpy(buf, op); 6806. newop = mungspaces(buf); 6807. while (newop && *newop) { 6808. wn = tfg = tbg = (char *) 0; 6809. 6810. /* until first non-space in case there's leading spaces - before 6811. * colorname*/ 6812. if (*newop == ' ') 6813. newop++; 6814. if (*newop) 6815. wn = newop; 6816. else 6817. return 0; 6818. 6819. /* until first space - colorname*/ 6820. while (*newop && *newop != ' ') 6821. newop++; 6822. if (*newop) 6823. *newop = '\0'; 6824. else 6825. return 0; 6826. newop++; 6827. 6828. /* until first non-space - before foreground*/ 6829. if (*newop == ' ') 6830. newop++; 6831. if (*newop) 6832. tfg = newop; 6833. else 6834. return 0; 6835. 6836. /* until slash - foreground */ 6837. while (*newop && *newop != '/') 6838. newop++; 6839. if (*newop) 6840. *newop = '\0'; 6841. else 6842. return 0; 6843. newop++; 6844. 6845. /* until first non-space (in case there's leading space after slash) - 6846. * before background */ 6847. if (*newop == ' ') 6848. newop++; 6849. if (*newop) 6850. tbg = newop; 6851. else 6852. return 0; 6853. 6854. /* until first space - background */ 6855. while (*newop && *newop != ' ') 6856. newop++; 6857. if (*newop) 6858. *newop++ = '\0'; 6859. 6860. for (j = 0; j < 4; ++j) { 6861. if (!strcmpi(wn, wnames[j]) || !strcmpi(wn, shortnames[j])) { 6862. if (tfg && !strstri(tfg, " ")) { 6863. if (*fgp[j]) 6864. free((genericptr_t) *fgp[j]); 6865. *fgp[j] = dupstr(tfg); 6866. } 6867. if (tbg && !strstri(tbg, " ")) { 6868. if (*bgp[j]) 6869. free((genericptr_t) *bgp[j]); 6870. *bgp[j] = dupstr(tbg); 6871. } 6872. break; 6873. } 6874. } 6875. } 6876. return 1; 6877. } 6878. 6879. /* set up for wizard mode if player or save file has requested to it; 6880. called from port-specific startup code to handle `nethack -D' or 6881. OPTIONS=playmode:debug, or from dorecover()'s restgamestate() if 6882. restoring a game which was saved in wizard mode */ 6883. void 6884. set_playmode() 6885. { 6886. if (wizard) { 6887. if (authorize_wizard_mode()) 6888. Strcpy(plname, "wizard"); 6889. else 6890. wizard = FALSE; /* not allowed or not available */ 6891. /* force explore mode if we didn't make it into wizard mode */ 6892. discover = !wizard; 6893. iflags.deferred_X = FALSE; 6894. } 6895. /* don't need to do anything special for explore mode or normal play */ 6896. } 6897. 6898. #endif /* OPTION_LISTS_ONLY */ 6899. 6900. /*options.c*/