Add key rebinding
[aNetHack.git] / src / sys.c
blobdeab17eb5ef82254bf138df689446ccf43aa0b56
1 /* NetHack 3.6 sys.c $NHDT-Date: 1448241785 2015/11/23 01:23:05 $ $NHDT-Branch: master $:$NHDT-Revision: 1.35 $ */
2 /* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
3 /* NetHack may be freely redistributed. See license for details. */
5 #include "hack.h"
7 #ifndef SYSCF
8 /* !SYSCF configurations need '#define DEBUGFILES "foo.c bar.c"'
9 * to enable debugging feedback for source files foo.c and bar.c;
10 * to activate debugpline(), set an appropriate value and uncomment
12 /* # define DEBUGFILES "*" */
14 /* note: DEBUGFILES value here or in sysconf.DEBUGFILES can be overridden
15 at runtime by setting up a value for "DEBUGFILES" in the environment */
16 #endif
18 struct sysopt sysopt;
20 void
21 sys_early_init()
23 sysopt.support = (char *) 0;
24 sysopt.recover = (char *) 0;
25 #ifdef SYSCF
26 sysopt.wizards = (char *) 0;
27 #else
28 sysopt.wizards = dupstr(WIZARD_NAME);
29 #endif
30 #if defined(SYSCF) || !defined(DEBUGFILES)
31 sysopt.debugfiles = (char *) 0;
32 #else
33 sysopt.debugfiles = dupstr(DEBUGFILES);
34 #endif
35 sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
36 sysopt.shellers = (char *) 0;
37 sysopt.explorers = (char *) 0;
38 sysopt.genericusers = (char *) 0;
39 sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
41 /* record file */
42 sysopt.persmax = PERSMAX;
43 sysopt.entrymax = ENTRYMAX;
44 sysopt.pointsmin = POINTSMIN;
45 sysopt.pers_is_uid = PERS_IS_UID;
46 sysopt.tt_oname_maxrank = 10;
48 /* sanity checks */
49 if (PERSMAX < 1)
50 sysopt.persmax = 1;
51 if (ENTRYMAX < 10)
52 sysopt.entrymax = 10;
53 if (POINTSMIN < 1)
54 sysopt.pointsmin = 1;
55 if (PERS_IS_UID != 0 && PERS_IS_UID != 1)
56 panic("config error: PERS_IS_UID must be either 0 or 1");
58 #ifdef PANICTRACE
59 /* panic options */
60 sysopt.gdbpath = dupstr(GDBPATH);
61 sysopt.greppath = dupstr(GREPPATH);
62 #ifdef BETA
63 sysopt.panictrace_gdb = 1;
64 #ifdef PANICTRACE_LIBC
65 sysopt.panictrace_libc = 2;
66 #endif
67 #else
68 sysopt.panictrace_gdb = 0;
69 #ifdef PANICTRACE_LIBC
70 sysopt.panictrace_libc = 0;
71 #endif
72 #endif
73 #endif
75 sysopt.check_save_uid = 1;
76 sysopt.check_plname = 0;
77 sysopt.seduce = 1; /* if it's compiled in, default to on */
78 sysopt_seduce_set(sysopt.seduce);
79 return;
82 void
83 sysopt_release()
85 if (sysopt.support)
86 free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;
87 if (sysopt.recover)
88 free((genericptr_t) sysopt.recover), sysopt.recover = (char *) 0;
89 if (sysopt.wizards)
90 free((genericptr_t) sysopt.wizards), sysopt.wizards = (char *) 0;
91 if (sysopt.explorers)
92 free((genericptr_t) sysopt.explorers), sysopt.explorers = (char *) 0;
93 if (sysopt.shellers)
94 free((genericptr_t) sysopt.shellers), sysopt.shellers = (char *) 0;
95 if (sysopt.debugfiles)
96 free((genericptr_t) sysopt.debugfiles),
97 sysopt.debugfiles = (char *) 0;
98 if (sysopt.genericusers)
99 free((genericptr_t) sysopt.genericusers),
100 sysopt.genericusers = (char *) 0;
101 #ifdef PANICTRACE
102 if (sysopt.gdbpath)
103 free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
104 if (sysopt.greppath)
105 free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
106 #endif
107 /* this one's last because it might be used in panic feedback, although
108 none of the preceding ones are likely to trigger a controlled panic */
109 if (sysopt.fmtd_wizard_list)
110 free((genericptr_t) sysopt.fmtd_wizard_list),
111 sysopt.fmtd_wizard_list = (char *) 0;
112 return;
115 extern struct attack sa_yes[NATTK];
116 extern struct attack sa_no[NATTK];
118 void
119 sysopt_seduce_set(val)
120 int val;
122 struct attack *setval = val ? sa_yes : sa_no;
123 int x;
125 for (x = 0; x < NATTK; x++) {
126 mons[PM_INCUBUS].mattk[x] = setval[x];
127 mons[PM_SUCCUBUS].mattk[x] = setval[x];
129 return;
132 /*sys.c*/