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