forked from NetHack/NetHack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.c
More file actions
6098 lines (5688 loc) · 205 KB
/
Copy pathoptions.c
File metadata and controls
6098 lines (5688 loc) · 205 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* NetHack 3.6 options.c $NHDT-Date: 1470357737 2016/08/05 00:42:17 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.279 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#ifdef OPTION_LISTS_ONLY /* (AMIGA) external program for opt lists */
#include "config.h"
#include "objclass.h"
#include "flag.h"
NEARDATA struct flag flags; /* provide linkage */
#ifdef SYSFLAGS
NEARDATA struct sysflag sysflags; /* provide linkage */
#endif
NEARDATA struct instance_flags iflags; /* provide linkage */
#define static
#else
#include "hack.h"
#include "tcap.h"
#include <ctype.h>
#endif
#define BACKWARD_COMPAT
#define WINTYPELEN 16
#ifdef DEFAULT_WC_TILED_MAP
#define PREFER_TILED TRUE
#else
#define PREFER_TILED FALSE
#endif
#define MESSAGE_OPTION 1
#define STATUS_OPTION 2
#define MAP_OPTION 3
#define MENU_OPTION 4
#define TEXT_OPTION 5
#define PILE_LIMIT_DFLT 5
/*
* NOTE: If you add (or delete) an option, please update the short
* options help (option_help()), the long options help (dat/opthelp),
* and the current options setting display function (doset()),
* and also the Guidebooks.
*
* The order matters. If an option is a an initial substring of another
* option (e.g. time and timed_delay) the shorter one must come first.
*/
static struct Bool_Opt {
const char *name;
boolean *addr, initvalue;
int optflags;
} boolopt[] = {
{ "acoustics", &flags.acoustics, TRUE, SET_IN_GAME },
#if defined(SYSFLAGS) && defined(AMIGA)
/* Amiga altmeta causes Alt+key to be converted into Meta+key by
low level nethack code; on by default, can be toggled off if
Alt+key is needed for some ASCII chars on non-ASCII keyboard */
{ "altmeta", &sysflags.altmeta, TRUE, DISP_IN_GAME },
#else
#ifdef ALTMETA
/* non-Amiga altmeta causes nethack's top level command loop to treat
two character sequence "ESC c" as M-c, for terminals or emulators
which send "ESC c" when Alt+c is pressed; off by default, enabling
this can potentially make trouble if user types ESC when nethack
is honoring this conversion request (primarily after starting a
count prefix prior to a command and then deciding to cancel it) */
{ "altmeta", &iflags.altmeta, FALSE, SET_IN_GAME },
#else
{ "altmeta", (boolean *) 0, TRUE, DISP_IN_GAME },
#endif
#endif
{ "ascii_map", &iflags.wc_ascii_map, !PREFER_TILED, SET_IN_GAME }, /*WC*/
#if defined(SYSFLAGS) && defined(MFLOPPY)
{ "asksavedisk", &sysflags.asksavedisk, FALSE, SET_IN_GAME },
#else
{ "asksavedisk", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "autodescribe", &iflags.autodescribe, FALSE, SET_IN_GAME },
{ "autodig", &flags.autodig, FALSE, SET_IN_GAME },
{ "autoopen", &flags.autoopen, TRUE, SET_IN_GAME },
{ "autopickup", &flags.pickup, TRUE, SET_IN_GAME },
{ "autoquiver", &flags.autoquiver, FALSE, SET_IN_GAME },
#if defined(MICRO) && !defined(AMIGA)
{ "BIOS", &iflags.BIOS, FALSE, SET_IN_FILE },
#else
{ "BIOS", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "blind", &u.uroleplay.blind, FALSE, DISP_IN_GAME },
{ "bones", &flags.bones, TRUE, SET_IN_FILE },
#ifdef INSURANCE
{ "checkpoint", &flags.ins_chkpt, TRUE, SET_IN_GAME },
#else
{ "checkpoint", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
#ifdef MFLOPPY
{ "checkspace", &iflags.checkspace, TRUE, SET_IN_GAME },
#else
{ "checkspace", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "clicklook", &iflags.clicklook, FALSE, SET_IN_GAME },
{ "cmdassist", &iflags.cmdassist, TRUE, SET_IN_GAME },
#if defined(MICRO) || defined(WIN32)
{ "color", &iflags.wc_color, TRUE, SET_IN_GAME }, /*WC*/
#else /* systems that support multiple terminals, many monochrome */
{ "color", &iflags.wc_color, FALSE, SET_IN_GAME }, /*WC*/
#endif
{ "confirm", &flags.confirm, TRUE, SET_IN_GAME },
{ "dark_room", &flags.dark_room, TRUE, SET_IN_GAME },
{ "eight_bit_tty", &iflags.wc_eight_bit_input, FALSE,
SET_IN_GAME }, /*WC*/
#ifdef TTY_GRAPHICS
{ "extmenu", &iflags.extmenu, FALSE, SET_IN_GAME },
#else
{ "extmenu", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
#ifdef OPT_DISPMAP
{ "fast_map", &flags.fast_map, TRUE, SET_IN_GAME },
#else
{ "fast_map", (boolean *) 0, TRUE, SET_IN_FILE },
#endif
{ "female", &flags.female, FALSE, DISP_IN_GAME },
{ "fixinv", &flags.invlet_constant, TRUE, SET_IN_GAME },
#if defined(SYSFLAGS) && defined(AMIFLUSH)
{ "flush", &sysflags.amiflush, FALSE, SET_IN_GAME },
#else
{ "flush", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "fullscreen", &iflags.wc2_fullscreen, FALSE, SET_IN_FILE },
{ "help", &flags.help, TRUE, SET_IN_GAME },
{ "hilite_pet", &iflags.wc_hilite_pet, FALSE, SET_IN_GAME }, /*WC*/
{ "hilite_pile", &iflags.hilite_pile, FALSE, SET_IN_GAME },
#ifndef MAC
{ "ignintr", &flags.ignintr, FALSE, SET_IN_GAME },
#else
{ "ignintr", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "implicit_uncursed", &iflags.implicit_uncursed, TRUE, SET_IN_GAME },
{ "large_font", &iflags.obsolete, FALSE, SET_IN_FILE }, /* OBSOLETE */
{ "legacy", &flags.legacy, TRUE, DISP_IN_GAME },
{ "lit_corridor", &flags.lit_corridor, FALSE, SET_IN_GAME },
{ "lootabc", &flags.lootabc, FALSE, SET_IN_GAME },
#ifdef MAIL
{ "mail", &flags.biff, TRUE, SET_IN_GAME },
#else
{ "mail", (boolean *) 0, TRUE, SET_IN_FILE },
#endif
{ "mention_walls", &iflags.mention_walls, FALSE, SET_IN_GAME },
{ "menucolors", &iflags.use_menu_color, FALSE, SET_IN_GAME },
/* for menu debugging only*/
{ "menu_tab_sep", &iflags.menu_tab_sep, FALSE, SET_IN_WIZGAME },
{ "menu_objsyms", &iflags.menu_head_objsym, FALSE, SET_IN_GAME },
#ifdef TTY_GRAPHICS
{ "menu_overlay", &iflags.menu_overlay, TRUE, SET_IN_GAME },
#else
{ "menu_overlay", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "mouse_support", &iflags.wc_mouse_support, TRUE, DISP_IN_GAME }, /*WC*/
#ifdef NEWS
{ "news", &iflags.news, TRUE, DISP_IN_GAME },
#else
{ "news", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "nudist", &u.uroleplay.nudist, FALSE, DISP_IN_GAME },
{ "null", &flags.null, TRUE, SET_IN_GAME },
#if defined(SYSFLAGS) && defined(MAC)
{ "page_wait", &sysflags.page_wait, TRUE, SET_IN_GAME },
#else
{ "page_wait", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "perm_invent", &flags.perm_invent, FALSE, SET_IN_GAME },
{ "pickup_thrown", &flags.pickup_thrown, TRUE, SET_IN_GAME },
{ "popup_dialog", &iflags.wc_popup_dialog, FALSE, SET_IN_GAME }, /*WC*/
{ "preload_tiles", &iflags.wc_preload_tiles, TRUE, DISP_IN_GAME }, /*WC*/
{ "pushweapon", &flags.pushweapon, FALSE, SET_IN_GAME },
#if defined(MICRO) && !defined(AMIGA)
{ "rawio", &iflags.rawio, FALSE, DISP_IN_GAME },
#else
{ "rawio", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "rest_on_space", &flags.rest_on_space, FALSE, SET_IN_GAME },
#ifdef RLECOMP
{ "rlecomp", &iflags.rlecomp,
#if defined(COMPRESS) || defined(ZLIB_COMP)
FALSE,
#else
TRUE,
#endif
DISP_IN_GAME },
#endif
{ "safe_pet", &flags.safe_dog, TRUE, SET_IN_GAME },
{ "sanity_check", &iflags.sanity_check, FALSE, SET_IN_WIZGAME },
{ "selectsaved", &iflags.wc2_selectsaved, TRUE, DISP_IN_GAME }, /*WC*/
{ "showexp", &flags.showexp, FALSE, SET_IN_GAME },
{ "showrace", &flags.showrace, FALSE, SET_IN_GAME },
#ifdef SCORE_ON_BOTL
{ "showscore", &flags.showscore, FALSE, SET_IN_GAME },
#else
{ "showscore", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "silent", &flags.silent, TRUE, SET_IN_GAME },
{ "softkeyboard", &iflags.wc2_softkeyboard, FALSE, SET_IN_FILE },
{ "sortpack", &flags.sortpack, TRUE, SET_IN_GAME },
{ "sparkle", &flags.sparkle, TRUE, SET_IN_GAME },
{ "splash_screen", &iflags.wc_splash_screen, TRUE, DISP_IN_GAME }, /*WC*/
{ "standout", &flags.standout, FALSE, SET_IN_GAME },
#if defined(STATUS_VIA_WINDOWPORT) && defined(STATUS_HILITES)
{ "statushilites", &iflags.use_status_hilites, TRUE, SET_IN_GAME },
#else
{ "statushilites", &iflags.use_status_hilites, FALSE, DISP_IN_GAME },
#endif
{ "tiled_map", &iflags.wc_tiled_map, PREFER_TILED, DISP_IN_GAME }, /*WC*/
{ "time", &flags.time, FALSE, SET_IN_GAME },
#ifdef TIMED_DELAY
{ "timed_delay", &flags.nap, TRUE, SET_IN_GAME },
#else
{ "timed_delay", (boolean *) 0, FALSE, SET_IN_GAME },
#endif
{ "tombstone", &flags.tombstone, TRUE, SET_IN_GAME },
{ "toptenwin", &iflags.toptenwin, FALSE, SET_IN_GAME },
{ "travel", &flags.travelcmd, TRUE, SET_IN_GAME },
{ "use_darkgray", &iflags.wc2_darkgray, TRUE, SET_IN_FILE },
#ifdef WIN32
{ "use_inverse", &iflags.wc_inverse, TRUE, SET_IN_GAME }, /*WC*/
#else
{ "use_inverse", &iflags.wc_inverse, FALSE, SET_IN_GAME }, /*WC*/
#endif
{ "verbose", &flags.verbose, TRUE, SET_IN_GAME },
#ifdef TTY_TILES_ESCCODES
{ "vt_tiledata", &iflags.vt_tiledata, FALSE, SET_IN_FILE },
#else
{ "vt_tiledata", (boolean *) 0, FALSE, SET_IN_FILE },
#endif
{ "whatis_menu", &iflags.getloc_usemenu, FALSE, SET_IN_GAME },
{ "whatis_inview", &iflags.getloc_limitview, FALSE, SET_IN_GAME },
{ "wizweight", &iflags.wizweight, FALSE, SET_IN_WIZGAME },
{ "wraptext", &iflags.wc2_wraptext, FALSE, SET_IN_GAME },
#ifdef ZEROCOMP
{ "zerocomp", &iflags.zerocomp,
#if defined(COMPRESS) || defined(ZLIB_COMP)
FALSE,
#else
TRUE,
#endif
DISP_IN_GAME },
#endif
{ (char *) 0, (boolean *) 0, FALSE, 0 }
};
/* compound options, for option_help() and external programs like Amiga
* frontend */
static struct Comp_Opt {
const char *name, *descr;
int size; /* for frontends and such allocating space --
* usually allowed size of data in game, but
* occasionally maximum reasonable size for
* typing when game maintains information in
* a different format */
int optflags;
} compopt[] = {
{ "align", "your starting alignment (lawful, neutral, or chaotic)", 8,
DISP_IN_GAME },
{ "align_message", "message window alignment", 20, DISP_IN_GAME }, /*WC*/
{ "align_status", "status window alignment", 20, DISP_IN_GAME }, /*WC*/
{ "altkeyhandler", "alternate key handler", 20, DISP_IN_GAME },
#ifdef BACKWARD_COMPAT
{ "boulder", "deprecated (use S_boulder in sym file instead)", 1,
SET_IN_FILE },
#endif
{ "catname", "the name of your (first) cat (e.g., catname:Tabby)",
PL_PSIZ, DISP_IN_GAME },
{ "disclose", "the kinds of information to disclose at end of game",
sizeof(flags.end_disclose) * 2, SET_IN_GAME },
{ "dogname", "the name of your (first) dog (e.g., dogname:Fang)", PL_PSIZ,
DISP_IN_GAME },
{ "dungeon", "the symbols to use in drawing the dungeon map",
MAXDCHARS + 1, SET_IN_FILE },
{ "effects", "the symbols to use in drawing special effects",
MAXECHARS + 1, SET_IN_FILE },
{ "font_map", "the font to use in the map window", 40,
DISP_IN_GAME }, /*WC*/
{ "font_menu", "the font to use in menus", 40, DISP_IN_GAME }, /*WC*/
{ "font_message", "the font to use in the message window", 40,
DISP_IN_GAME }, /*WC*/
{ "font_size_map", "the size of the map font", 20, DISP_IN_GAME }, /*WC*/
{ "font_size_menu", "the size of the menu font", 20,
DISP_IN_GAME }, /*WC*/
{ "font_size_message", "the size of the message font", 20,
DISP_IN_GAME }, /*WC*/
{ "font_size_status", "the size of the status font", 20,
DISP_IN_GAME }, /*WC*/
{ "font_size_text", "the size of the text font", 20,
DISP_IN_GAME }, /*WC*/
{ "font_status", "the font to use in status window", 40,
DISP_IN_GAME }, /*WC*/
{ "font_text", "the font to use in text windows", 40,
DISP_IN_GAME }, /*WC*/
{ "fruit", "the name of a fruit you enjoy eating", PL_FSIZ, SET_IN_GAME },
{ "gender", "your starting gender (male or female)", 8, DISP_IN_GAME },
{ "horsename", "the name of your (first) horse (e.g., horsename:Silver)",
PL_PSIZ, DISP_IN_GAME },
{ "map_mode", "map display mode under Windows", 20, DISP_IN_GAME }, /*WC*/
{ "menustyle", "user interface for object selection", MENUTYPELEN,
SET_IN_GAME },
{ "menu_deselect_all", "deselect all items in a menu", 4, SET_IN_FILE },
{ "menu_deselect_page", "deselect all items on this page of a menu", 4,
SET_IN_FILE },
{ "menu_first_page", "jump to the first page in a menu", 4, SET_IN_FILE },
{ "menu_headings", "text attribute for menu headings", 9, SET_IN_GAME },
{ "menu_invert_all", "invert all items in a menu", 4, SET_IN_FILE },
{ "menu_invert_page", "invert all items on this page of a menu", 4,
SET_IN_FILE },
{ "menu_last_page", "jump to the last page in a menu", 4, SET_IN_FILE },
{ "menu_next_page", "goto the next menu page", 4, SET_IN_FILE },
{ "menu_previous_page", "goto the previous menu page", 4, SET_IN_FILE },
{ "menu_search", "search for a menu item", 4, SET_IN_FILE },
{ "menu_select_all", "select all items in a menu", 4, SET_IN_FILE },
{ "menu_select_page", "select all items on this page of a menu", 4,
SET_IN_FILE },
{ "monsters", "the symbols to use for monsters", MAXMCLASSES,
SET_IN_FILE },
{ "msghistory", "number of top line messages to save", 5, DISP_IN_GAME },
#ifdef TTY_GRAPHICS
{ "msg_window", "the type of message window required", 1, SET_IN_GAME },
#else
{ "msg_window", "the type of message window required", 1, SET_IN_FILE },
#endif
{ "name", "your character's name (e.g., name:Merlin-W)", PL_NSIZ,
DISP_IN_GAME },
{ "number_pad", "use the number pad for movement", 1, SET_IN_GAME },
{ "objects", "the symbols to use for objects", MAXOCLASSES, SET_IN_FILE },
{ "packorder", "the inventory order of the items in your pack",
MAXOCLASSES, SET_IN_GAME },
#ifdef CHANGE_COLOR
{ "palette",
#ifndef WIN32
"palette (00c/880/-fff is blue/yellow/reverse white)", 15,
SET_IN_GAME },
#else
"palette (adjust an RGB color in palette (color-R-G-B)", 15,
SET_IN_FILE },
#endif
#if defined(MAC)
{ "hicolor", "same as palette, only order is reversed", 15, SET_IN_FILE },
#endif
#endif
{ "paranoid_confirmation", "extra prompting in certain situations", 28,
SET_IN_GAME },
{ "pettype", "your preferred initial pet type", 4, DISP_IN_GAME },
{ "pickup_burden", "maximum burden picked up before prompt", 20,
SET_IN_GAME },
{ "pickup_types", "types of objects to pick up automatically",
MAXOCLASSES, SET_IN_GAME },
{ "pile_limit", "threshold for \"there are many objects here\"", 24,
SET_IN_GAME },
{ "playmode", "normal play, non-scoring explore mode, or debug mode", 8,
DISP_IN_GAME },
{ "player_selection", "choose character via dialog or prompts", 12,
DISP_IN_GAME },
{ "race", "your starting race (e.g., Human, Elf)", PL_CSIZ,
DISP_IN_GAME },
{ "role", "your starting role (e.g., Barbarian, Valkyrie)", PL_CSIZ,
DISP_IN_GAME },
{ "runmode", "display frequency when `running' or `travelling'",
sizeof "teleport", SET_IN_GAME },
{ "scores", "the parts of the score list you wish to see", 32,
SET_IN_GAME },
{ "scroll_amount", "amount to scroll map when scroll_margin is reached",
20, DISP_IN_GAME }, /*WC*/
{ "scroll_margin", "scroll map when this far from the edge", 20,
DISP_IN_GAME }, /*WC*/
{ "sortloot", "sort object selection lists by description", 4,
SET_IN_GAME },
#ifdef MSDOS
{ "soundcard", "type of sound card to use", 20, SET_IN_FILE },
#endif
{ "symset", "load a set of display symbols from the symbols file", 70,
SET_IN_GAME },
{ "roguesymset",
"load a set of rogue display symbols from the symbols file", 70,
SET_IN_GAME },
#ifdef WIN32
{ "subkeyvalue", "override keystroke value", 7, SET_IN_FILE },
#endif
{ "suppress_alert", "suppress alerts about version-specific features", 8,
SET_IN_GAME },
{ "tile_width", "width of tiles", 20, DISP_IN_GAME }, /*WC*/
{ "tile_height", "height of tiles", 20, DISP_IN_GAME }, /*WC*/
{ "tile_file", "name of tile file", 70, DISP_IN_GAME }, /*WC*/
{ "traps", "the symbols to use in drawing traps", MAXTCHARS + 1,
SET_IN_FILE },
{ "vary_msgcount", "show more old messages at a time", 20,
DISP_IN_GAME }, /*WC*/
#ifdef MSDOS
{ "video", "method of video updating", 20, SET_IN_FILE },
#endif
#ifdef VIDEOSHADES
{ "videocolors", "color mappings for internal screen routines", 40,
DISP_IN_GAME },
{ "videoshades", "gray shades to map to black/gray/white", 32,
DISP_IN_GAME },
#endif
{ "whatis_coord", "show coordinates when auto-describing cursor position",
1, SET_IN_GAME },
{ "windowcolors", "the foreground/background colors of windows", /*WC*/
80, DISP_IN_GAME },
{ "windowtype", "windowing system to use", WINTYPELEN, DISP_IN_GAME },
#ifdef WINCHAIN
{ "windowchain", "window processor to use", WINTYPELEN, SET_IN_SYS },
#endif
#ifdef BACKWARD_COMPAT
{ "DECgraphics", "load DECGraphics display symbols", 70, SET_IN_FILE },
{ "IBMgraphics", "load IBMGraphics display symbols", 70, SET_IN_FILE },
#ifdef MAC_GRAPHICS_ENV
{ "Macgraphics", "load MACGraphics display symbols", 70, SET_IN_FILE },
#endif
#endif
{ (char *) 0, (char *) 0, 0, 0 }
};
#ifdef OPTION_LISTS_ONLY
#undef static
#else /* use rest of file */
extern char configfile[]; /* for messages */
extern struct symparse loadsyms[];
static boolean need_redraw; /* for doset() */
#if defined(TOS) && defined(TEXTCOLOR)
extern boolean colors_changed; /* in tos.c */
#endif
#ifdef VIDEOSHADES
extern char *shade[3]; /* in sys/msdos/video.c */
extern char ttycolors[CLR_MAX]; /* in sys/msdos/video.c */
#endif
static char def_inv_order[MAXOCLASSES] = {
COIN_CLASS, AMULET_CLASS, WEAPON_CLASS, ARMOR_CLASS, FOOD_CLASS,
SCROLL_CLASS, SPBOOK_CLASS, POTION_CLASS, RING_CLASS, WAND_CLASS,
TOOL_CLASS, GEM_CLASS, ROCK_CLASS, BALL_CLASS, CHAIN_CLASS, 0,
};
/*
* Default menu manipulation command accelerators. These may _not_ be:
*
* + a number - reserved for counts
* + an upper or lower case US ASCII letter - used for accelerators
* + ESC - reserved for escaping the menu
* + NULL, CR or LF - reserved for commiting the selection(s). NULL
* is kind of odd, but the tty's xwaitforspace() will return it if
* someone hits a <ret>.
* + a default object class symbol - used for object class accelerators
*
* Standard letters (for now) are:
*
* < back 1 page
* > forward 1 page
* ^ first page
* | last page
* : search
*
* page all
* , select .
* \ deselect -
* ~ invert @
*
* The command name list is duplicated in the compopt array.
*/
typedef struct {
const char *name;
char cmd;
const char *desc;
} menu_cmd_t;
static const menu_cmd_t default_menu_cmd_info[] = {
{ "menu_first_page", MENU_FIRST_PAGE, "Go to first page" },
{ "menu_last_page", MENU_LAST_PAGE, "Go to last page" },
{ "menu_next_page", MENU_NEXT_PAGE, "Go to next page" },
{ "menu_previous_page", MENU_PREVIOUS_PAGE, "Go to previous page" },
{ "menu_select_all", MENU_SELECT_ALL, "Select all items" },
{ "menu_deselect_all", MENU_UNSELECT_ALL, "Unselect all items" },
{ "menu_invert_all", MENU_INVERT_ALL, "Insert selection" },
{ "menu_select_page", MENU_SELECT_PAGE, "Select items in current page" },
{ "menu_deselect_page", MENU_UNSELECT_PAGE, "Unselect items in current page" },
{ "menu_invert_page", MENU_INVERT_PAGE, "Invert current page selection" },
{ "menu_search", MENU_SEARCH, "Search and toggle matching items" },
};
/*
* Allow the user to map incoming characters to various menu commands.
* The accelerator list must be a valid C string.
*/
#define MAX_MENU_MAPPED_CMDS 32 /* some number */
char mapped_menu_cmds[MAX_MENU_MAPPED_CMDS + 1]; /* exported */
static char mapped_menu_op[MAX_MENU_MAPPED_CMDS + 1];
static short n_menu_mapped = 0;
static boolean initial, from_file;
STATIC_DCL void FDECL(nmcpy, (char *, const char *, int));
STATIC_DCL void FDECL(escapes, (const char *, char *));
STATIC_DCL void FDECL(rejectoption, (const char *));
STATIC_DCL void FDECL(badoptmsg, (const char *, const char *));
STATIC_DCL void FDECL(badoption, (const char *));
STATIC_DCL char *FDECL(string_for_opt, (char *, BOOLEAN_P));
STATIC_DCL char *FDECL(string_for_env_opt, (const char *, char *, BOOLEAN_P));
STATIC_DCL void FDECL(bad_negation, (const char *, BOOLEAN_P));
STATIC_DCL int FDECL(change_inv_order, (char *));
STATIC_DCL void FDECL(warning_opts, (char *, const char *));
STATIC_DCL int FDECL(feature_alert_opts, (char *, const char *));
STATIC_DCL boolean FDECL(duplicate_opt_detection, (const char *, int));
STATIC_DCL void FDECL(complain_about_duplicate, (const char *, int));
STATIC_DCL const char *FDECL(attr2attrname, (int));
STATIC_DCL int NDECL(query_color);
STATIC_DCL int FDECL(query_attr, (const char *));
STATIC_DCL const char * FDECL(msgtype2name, (int));
STATIC_DCL int NDECL(query_msgtype);
STATIC_DCL boolean FDECL(msgtype_add, (int, char *));
STATIC_DCL void FDECL(free_one_msgtype, (int));
STATIC_DCL int NDECL(msgtype_count);
STATIC_DCL boolean FDECL(add_menu_coloring_parsed, (char *, int, int));
STATIC_DCL void FDECL(free_one_menu_coloring, (int));
STATIC_DCL int NDECL(count_menucolors);
STATIC_DCL boolean FDECL(parse_role_opts, (BOOLEAN_P, const char *,
char *, char **));
STATIC_DCL void FDECL(oc_to_str, (char *, char *));
STATIC_DCL void FDECL(doset_add_menu, (winid, const char *, int));
STATIC_DCL void FDECL(opts_add_others, (winid, const char *, int,
char *, int));
STATIC_DCL int FDECL(handle_add_list_remove, (const char *, int));
STATIC_DCL boolean FDECL(special_handling, (const char *,
BOOLEAN_P, BOOLEAN_P));
STATIC_DCL const char *FDECL(get_compopt_value, (const char *, char *));
STATIC_DCL void FDECL(remove_autopickup_exception,
(struct autopickup_exception *));
STATIC_DCL int FDECL(count_ape_maps, (int *, int *));
STATIC_DCL boolean FDECL(is_wc_option, (const char *));
STATIC_DCL boolean FDECL(wc_supported, (const char *));
STATIC_DCL boolean FDECL(is_wc2_option, (const char *));
STATIC_DCL boolean FDECL(wc2_supported, (const char *));
STATIC_DCL void FDECL(wc_set_font_name, (int, char *));
STATIC_DCL int FDECL(wc_set_window_colors, (char *));
void
reglyph_darkroom()
{
xchar x, y;
for (x = 0; x < COLNO; x++)
for (y = 0; y < ROWNO; y++) {
struct rm *lev = &levl[x][y];
if (!flags.dark_room || !iflags.use_color
|| Is_rogue_level(&u.uz)) {
if (lev->glyph == cmap_to_glyph(S_darkroom))
lev->glyph = lev->waslit ? cmap_to_glyph(S_room)
: cmap_to_glyph(S_stone);
} else {
if (lev->glyph == cmap_to_glyph(S_room) && lev->seenv
&& lev->waslit && !cansee(x, y))
lev->glyph = cmap_to_glyph(S_darkroom);
else if (lev->glyph == cmap_to_glyph(S_stone)
&& lev->typ == ROOM && lev->seenv && !cansee(x, y))
lev->glyph = cmap_to_glyph(S_darkroom);
}
}
if (flags.dark_room && iflags.use_color)
showsyms[S_darkroom] = showsyms[S_room];
else
showsyms[S_darkroom] = showsyms[S_stone];
}
/* check whether a user-supplied option string is a proper leading
substring of a particular option name; option string might have
a colon or equals sign and arbitrary value appended to it */
boolean
match_optname(user_string, opt_name, min_length, val_allowed)
const char *user_string, *opt_name;
int min_length;
boolean val_allowed;
{
int len = (int) strlen(user_string);
if (val_allowed) {
const char *p = index(user_string, ':'),
*q = index(user_string, '=');
if (!p || (q && q < p))
p = q;
if (p) {
/* 'user_string' hasn't necessarily been through mungspaces()
so might have tabs or consecutive spaces */
while (p > user_string && isspace((uchar) *(p - 1)))
p--;
len = (int) (p - user_string);
}
}
return (boolean) (len >= min_length
&& !strncmpi(opt_name, user_string, len));
}
/* most environment variables will eventually be printed in an error
* message if they don't work, and most error message paths go through
* BUFSZ buffers, which could be overflowed by a maliciously long
* environment variable. If a variable can legitimately be long, or
* if it's put in a smaller buffer, the responsible code will have to
* bounds-check itself.
*/
char *
nh_getenv(ev)
const char *ev;
{
char *getev = getenv(ev);
if (getev && strlen(getev) <= (BUFSZ / 2))
return getev;
else
return (char *) 0;
}
/* process options, possibly including SYSCF */
void
initoptions()
{
initoptions_init();
#ifdef SYSCF
/* someday there may be other SYSCF alternatives besides text file */
#ifdef SYSCF_FILE
/* If SYSCF_FILE is specified, it _must_ exist... */
assure_syscf_file();
/* ... and _must_ parse correctly. */
if (!read_config_file(SYSCF_FILE, SET_IN_SYS)) {
raw_printf("Error(s) found in SYSCF_FILE, quitting.");
terminate(EXIT_FAILURE);
}
/*
* TODO [maybe]: parse the sysopt entries which are space-separated
* lists of usernames into arrays with one name per element.
*/
#endif
#endif
initoptions_finish();
}
void
initoptions_init()
{
#if defined(UNIX) || defined(VMS)
char *opts;
#endif
int i;
/* set up the command parsing */
reset_commands(TRUE); /* init */
/* initialize the random number generator */
setrandom();
/* for detection of configfile options specified multiple times */
iflags.opt_booldup = iflags.opt_compdup = (int *) 0;
for (i = 0; boolopt[i].name; i++) {
if (boolopt[i].addr)
*(boolopt[i].addr) = boolopt[i].initvalue;
}
#if defined(COMPRESS) || defined(ZLIB_COMP)
set_savepref("externalcomp");
set_restpref("externalcomp");
#ifdef RLECOMP
set_savepref("!rlecomp");
set_restpref("!rlecomp");
#endif
#else
#ifdef ZEROCOMP
set_savepref("zerocomp");
set_restpref("zerocomp");
#endif
#ifdef RLECOMP
set_savepref("rlecomp");
set_restpref("rlecomp");
#endif
#endif
#ifdef SYSFLAGS
Strcpy(sysflags.sysflagsid, "sysflags");
sysflags.sysflagsid[9] = (char) sizeof(struct sysflag);
#endif
flags.end_own = FALSE;
flags.end_top = 3;
flags.end_around = 2;
flags.paranoia_bits = PARANOID_PRAY; /* old prayconfirm=TRUE */
flags.pile_limit = PILE_LIMIT_DFLT; /* 5 */
flags.runmode = RUN_LEAP;
iflags.msg_history = 20;
#ifdef TTY_GRAPHICS
iflags.prevmsg_window = 's';
#endif
iflags.menu_headings = ATR_INVERSE;
iflags.getpos_coords = GPCOORDS_NONE;
/* hero's role, race, &c haven't been chosen yet */
flags.initrole = flags.initrace = flags.initgend = flags.initalign =
ROLE_NONE;
/* Set the default monster and object class symbols. */
init_symbols();
for (i = 0; i < WARNCOUNT; i++)
warnsyms[i] = def_warnsyms[i].sym;
iflags.bouldersym = 0;
iflags.travelcc.x = iflags.travelcc.y = -1;
/* assert( sizeof flags.inv_order == sizeof def_inv_order ); */
(void) memcpy((genericptr_t) flags.inv_order,
(genericptr_t) def_inv_order, sizeof flags.inv_order);
flags.pickup_types[0] = '\0';
flags.pickup_burden = MOD_ENCUMBER;
flags.sortloot = 'l'; /* sort only loot by default */
for (i = 0; i < NUM_DISCLOSURE_OPTIONS; i++)
flags.end_disclose[i] = DISCLOSE_PROMPT_DEFAULT_NO;
switch_symbols(FALSE); /* set default characters */
#if defined(UNIX) && defined(TTY_GRAPHICS)
/*
* Set defaults for some options depending on what we can
* detect about the environment's capabilities.
* This has to be done after the global initialization above
* and before reading user-specific initialization via
* config file/environment variable below.
*/
/* this detects the IBM-compatible console on most 386 boxes */
if ((opts = nh_getenv("TERM")) && !strncmp(opts, "AT", 2)) {
if (!symset[PRIMARY].name)
load_symset("IBMGraphics", PRIMARY);
if (!symset[ROGUESET].name)
load_symset("RogueIBM", ROGUESET);
switch_symbols(TRUE);
#ifdef TEXTCOLOR
iflags.use_color = TRUE;
#endif
}
#endif /* UNIX && TTY_GRAPHICS */
#if defined(UNIX) || defined(VMS)
#ifdef TTY_GRAPHICS
/* detect whether a "vt" terminal can handle alternate charsets */
if ((opts = nh_getenv("TERM"))
/* [could also check "xterm" which emulates vtXXX by default] */
&& !strncmpi(opts, "vt", 2)
&& AS && AE && index(AS, '\016') && index(AE, '\017')) {
if (!symset[PRIMARY].name)
load_symset("DECGraphics", PRIMARY);
switch_symbols(TRUE);
}
#endif
#endif /* UNIX || VMS */
#ifdef MAC_GRAPHICS_ENV
if (!symset[PRIMARY].name)
load_symset("MACGraphics", PRIMARY);
switch_symbols(TRUE);
#endif /* MAC_GRAPHICS_ENV */
flags.menu_style = MENU_FULL;
/* since this is done before init_objects(), do partial init here */
objects[SLIME_MOLD].oc_name_idx = SLIME_MOLD;
nmcpy(pl_fruit, OBJ_NAME(objects[SLIME_MOLD]), PL_FSIZ);
}
void
initoptions_finish()
{
#ifndef MAC
char *opts = getenv("NETHACKOPTIONS");
if (!opts)
opts = getenv("HACKOPTIONS");
if (opts) {
if (*opts == '/' || *opts == '\\' || *opts == '@') {
if (*opts == '@')
opts++; /* @filename */
/* looks like a filename */
if (strlen(opts) < BUFSZ / 2)
read_config_file(opts, SET_IN_FILE);
} else {
read_config_file((char *) 0, SET_IN_FILE);
/* let the total length of options be long;
* parseoptions() will check each individually
*/
parseoptions(opts, TRUE, FALSE);
}
} else
#endif
read_config_file((char *) 0, SET_IN_FILE);
(void) fruitadd(pl_fruit, (struct fruit *) 0);
/*
* Remove "slime mold" from list of object names. This will
* prevent it from being wished unless it's actually present
* as a named (or default) fruit. Wishing for "fruit" will
* result in the player's preferred fruit [better than "\033"].
*/
obj_descr[SLIME_MOLD].oc_name = "fruit";
if (iflags.bouldersym)
update_bouldersym();
reglyph_darkroom();
return;
}
STATIC_OVL void
nmcpy(dest, src, maxlen)
char *dest;
const char *src;
int maxlen;
{
int count;
for (count = 1; count < maxlen; count++) {
if (*src == ',' || *src == '\0')
break; /*exit on \0 terminator*/
*dest++ = *src++;
}
*dest = 0;
}
/*
* escapes(): escape expansion for showsyms. C-style escapes understood
* include \n, \b, \t, \r, \xnnn (hex), \onnn (octal), \nnn (decimal).
* The ^-prefix for control characters is also understood, and \[mM]
* has the effect of 'meta'-ing the value which follows (so that the
* alternate character set will be enabled).
*
* X normal key X
* ^X control-X
* \mX meta-X
*
* For 3.4.3 and earlier, input ending with "\M", backslash, or caret
* prior to terminating '\0' would pull that '\0' into the output and then
* keep processing past it, potentially overflowing the output buffer.
* Now, trailing \ or ^ will act like \\ or \^ and add '\\' or '^' to the
* output and stop there; trailing \M will fall through to \<other> and
* yield 'M', then stop. Any \X or \O followed by something other than
* an appropriate digit will also fall through to \<other> and yield 'X'
* or 'O', plus stop if the non-digit is end-of-string.
*/
STATIC_OVL void
escapes(cp, tp)
const char *cp;
char *tp;
{
static NEARDATA const char oct[] = "01234567", dec[] = "0123456789",
hex[] = "00112233445566778899aAbBcCdDeEfF";
const char *dp;
int cval, meta, dcount;
while (*cp) {
/* \M has to be followed by something to do meta conversion,
otherwise it will just be \M which ultimately yields 'M' */
meta = (*cp == '\\' && (cp[1] == 'm' || cp[1] == 'M') && cp[2]);
if (meta)
cp += 2;
cval = dcount = 0; /* for decimal, octal, hexadecimal cases */
if ((*cp != '\\' && *cp != '^') || !cp[1]) {
/* simple character, or nothing left for \ or ^ to escape */
cval = *cp++;
} else if (*cp == '^') { /* expand control-character syntax */
cval = (*++cp & 0x1f);
++cp;
/* remaining cases are all for backslash; we know cp[1] is not \0 */
} else if (index(dec, cp[1])) {
++cp; /* move past backslash to first digit */
do {
cval = (cval * 10) + (*cp - '0');
} while (*++cp && index(dec, *cp) && ++dcount < 3);
} else if ((cp[1] == 'o' || cp[1] == 'O') && cp[2]
&& index(oct, cp[2])) {
cp += 2; /* move past backslash and 'O' */
do {
cval = (cval * 8) + (*cp - '0');
} while (*++cp && index(oct, *cp) && ++dcount < 3);
} else if ((cp[1] == 'x' || cp[1] == 'X') && cp[2]
&& (dp = index(hex, cp[2])) != 0) {
cp += 2; /* move past backslash and 'X' */
do {
cval = (cval * 16) + ((int) (dp - hex) / 2);
} while (*++cp && (dp = index(hex, *cp)) != 0 && ++dcount < 2);
} else { /* C-style character escapes */
switch (*++cp) {
case '\\':
cval = '\\';
break;
case 'n':
cval = '\n';
break;
case 't':
cval = '\t';
break;
case 'b':
cval = '\b';
break;
case 'r':
cval = '\r';
break;
default:
cval = *cp;
}
++cp;
}
if (meta)
cval |= 0x80;
*tp++ = (char) cval;
}
*tp = '\0';
}
STATIC_OVL void
rejectoption(optname)
const char *optname;
{
#ifdef MICRO
pline("\"%s\" settable only from %s.", optname, configfile);
#else
pline("%s can be set only from NETHACKOPTIONS or %s.", optname,
configfile);
#endif
}
STATIC_OVL void
badoptmsg(opts, reason)
const char *opts;
const char *reason; /* "Bad syntax" or "Missing value" */
{
const char *linesplit = "";
if (!initial) {
if (!strncmp(opts, "h", 1) || !strncmp(opts, "?", 1))
option_help();
else
pline("%s: %s. Enter \"?g\" for help.", reason, opts);
return;
#ifdef MAC
} else {
return;
#endif
}
#ifdef WIN32
linesplit = "\n";
#endif
if (from_file)
raw_printf("%s in OPTIONS in %s: %s%s.\n",
reason, configfile, linesplit, opts);
else
raw_printf("%s in NETHACKOPTIONS: %s%s.\n",
reason, linesplit, opts);
wait_synch();
}
STATIC_OVL void
badoption(opts)
const char *opts;
{
badoptmsg(opts, "Bad syntax");
}
STATIC_OVL char *
string_for_opt(opts, val_optional)
char *opts;
boolean val_optional;
{
char *colon, *equals;
colon = index(opts, ':');
equals = index(opts, '=');
if (!colon || (equals && equals < colon))
colon = equals;
if (!colon || !*++colon) {
if (!val_optional)
badoptmsg(opts, "Missing value");
return (char *) 0;
}
return colon;
}
STATIC_OVL char *
string_for_env_opt(optname, opts, val_optional)
const char *optname;
char *opts;
boolean val_optional;
{
if (!initial) {