OSDN Git Service

upgrade to 3.6.2
[jnethack/source.git] / src / sys.c
1 /* NetHack 3.6  sys.c   $NHDT-Date: 1547118632 2019/01/10 11:10:32 $  $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.43 $ */
2 /* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
3 /* NetHack may be freely redistributed.  See license for details. */
4
5 #include "hack.h"
6
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
11  */
12 /* # define DEBUGFILES "*" */
13
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
17
18 struct sysopt sysopt;
19
20 void
21 sys_early_init()
22 {
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 #ifdef DUMPLOG
36     sysopt.dumplogfile = (char *) 0;
37 #endif
38     sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
39     sysopt.shellers = (char *) 0;
40     sysopt.explorers = (char *) 0;
41     sysopt.genericusers = (char *) 0;
42     sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
43     sysopt.bones_pools = 0;
44
45     /* record file */
46     sysopt.persmax = PERSMAX;
47     sysopt.entrymax = ENTRYMAX;
48     sysopt.pointsmin = POINTSMIN;
49     sysopt.pers_is_uid = PERS_IS_UID;
50     sysopt.tt_oname_maxrank = 10;
51
52     /* sanity checks */
53     if (PERSMAX < 1)
54         sysopt.persmax = 1;
55     if (ENTRYMAX < 10)
56         sysopt.entrymax = 10;
57     if (POINTSMIN < 1)
58         sysopt.pointsmin = 1;
59     if (PERS_IS_UID != 0 && PERS_IS_UID != 1)
60         panic("config error: PERS_IS_UID must be either 0 or 1");
61
62 #ifdef PANICTRACE
63     /* panic options */
64     sysopt.gdbpath = dupstr(GDBPATH);
65     sysopt.greppath = dupstr(GREPPATH);
66 #ifdef BETA
67     sysopt.panictrace_gdb = 1;
68 #ifdef PANICTRACE_LIBC
69     sysopt.panictrace_libc = 2;
70 #endif
71 #else
72     sysopt.panictrace_gdb = 0;
73 #ifdef PANICTRACE_LIBC
74     sysopt.panictrace_libc = 0;
75 #endif
76 #endif
77 #endif
78
79     sysopt.check_save_uid = 1;
80     sysopt.check_plname = 0;
81     sysopt.seduce = 1; /* if it's compiled in, default to on */
82     sysopt_seduce_set(sysopt.seduce);
83     return;
84 }
85
86 void
87 sysopt_release()
88 {
89     if (sysopt.support)
90         free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;
91     if (sysopt.recover)
92         free((genericptr_t) sysopt.recover), sysopt.recover = (char *) 0;
93     if (sysopt.wizards)
94         free((genericptr_t) sysopt.wizards), sysopt.wizards = (char *) 0;
95     if (sysopt.explorers)
96         free((genericptr_t) sysopt.explorers), sysopt.explorers = (char *) 0;
97     if (sysopt.shellers)
98         free((genericptr_t) sysopt.shellers), sysopt.shellers = (char *) 0;
99     if (sysopt.debugfiles)
100         free((genericptr_t) sysopt.debugfiles),
101         sysopt.debugfiles = (char *) 0;
102 #ifdef DUMPLOG
103     if (sysopt.dumplogfile)
104         free((genericptr_t)sysopt.dumplogfile), sysopt.dumplogfile=(char *)0;
105 #endif
106     if (sysopt.genericusers)
107         free((genericptr_t) sysopt.genericusers),
108         sysopt.genericusers = (char *) 0;
109 #ifdef PANICTRACE
110     if (sysopt.gdbpath)
111         free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
112     if (sysopt.greppath)
113         free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
114 #endif
115     /* this one's last because it might be used in panic feedback, although
116        none of the preceding ones are likely to trigger a controlled panic */
117     if (sysopt.fmtd_wizard_list)
118         free((genericptr_t) sysopt.fmtd_wizard_list),
119         sysopt.fmtd_wizard_list = (char *) 0;
120     return;
121 }
122
123 extern const struct attack sa_yes[NATTK];
124 extern const struct attack sa_no[NATTK];
125
126 void
127 sysopt_seduce_set(val)
128 int val;
129 {
130 #if 0
131 /*
132  * Attack substitution is now done on the fly in getmattk(mhitu.c).
133  */
134     struct attack *setval = val ? sa_yes : sa_no;
135     int x;
136
137     for (x = 0; x < NATTK; x++) {
138         mons[PM_INCUBUS].mattk[x] = setval[x];
139         mons[PM_SUCCUBUS].mattk[x] = setval[x];
140     }
141 #else
142     nhUse(val);
143 #endif /*0*/
144     return;
145 }
146
147 /*sys.c*/