OSDN Git Service

import nethack-3.6.0
[jnethack/source.git] / src / sys.c
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. */
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     sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
36     sysopt.shellers = (char *) 0;
37     sysopt.explorers = (char *) 0;
38     sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
39
40     /* record file */
41     sysopt.persmax = PERSMAX;
42     sysopt.entrymax = ENTRYMAX;
43     sysopt.pointsmin = POINTSMIN;
44     sysopt.pers_is_uid = PERS_IS_UID;
45     sysopt.tt_oname_maxrank = 10;
46
47     /* sanity checks */
48     if (PERSMAX < 1)
49         sysopt.persmax = 1;
50     if (ENTRYMAX < 10)
51         sysopt.entrymax = 10;
52     if (POINTSMIN < 1)
53         sysopt.pointsmin = 1;
54     if (PERS_IS_UID != 0 && PERS_IS_UID != 1)
55         panic("config error: PERS_IS_UID must be either 0 or 1");
56
57 #ifdef PANICTRACE
58     /* panic options */
59     sysopt.gdbpath = dupstr(GDBPATH);
60     sysopt.greppath = dupstr(GREPPATH);
61 #ifdef BETA
62     sysopt.panictrace_gdb = 1;
63 #ifdef PANICTRACE_LIBC
64     sysopt.panictrace_libc = 2;
65 #endif
66 #else
67     sysopt.panictrace_gdb = 0;
68 #ifdef PANICTRACE_LIBC
69     sysopt.panictrace_libc = 0;
70 #endif
71 #endif
72 #endif
73
74     sysopt.check_save_uid = 1;
75     sysopt.seduce = 1; /* if it's compiled in, default to on */
76     sysopt_seduce_set(sysopt.seduce);
77     return;
78 }
79
80 void
81 sysopt_release()
82 {
83     if (sysopt.support)
84         free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;
85     if (sysopt.recover)
86         free((genericptr_t) sysopt.recover), sysopt.recover = (char *) 0;
87     if (sysopt.wizards)
88         free((genericptr_t) sysopt.wizards), sysopt.wizards = (char *) 0;
89     if (sysopt.explorers)
90         free((genericptr_t) sysopt.explorers), sysopt.explorers = (char *) 0;
91     if (sysopt.shellers)
92         free((genericptr_t) sysopt.shellers), sysopt.shellers = (char *) 0;
93     if (sysopt.debugfiles)
94         free((genericptr_t) sysopt.debugfiles),
95         sysopt.debugfiles = (char *) 0;
96 #ifdef PANICTRACE
97     if (sysopt.gdbpath)
98         free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
99     if (sysopt.greppath)
100         free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
101 #endif
102     /* this one's last because it might be used in panic feedback, although
103        none of the preceding ones are likely to trigger a controlled panic */
104     if (sysopt.fmtd_wizard_list)
105         free((genericptr_t) sysopt.fmtd_wizard_list),
106         sysopt.fmtd_wizard_list = (char *) 0;
107     return;
108 }
109
110 extern struct attack sa_yes[NATTK];
111 extern struct attack sa_no[NATTK];
112
113 void
114 sysopt_seduce_set(val)
115 int val;
116 {
117     struct attack *setval = val ? sa_yes : sa_no;
118     int x;
119
120     for (x = 0; x < NATTK; x++) {
121         mons[PM_INCUBUS].mattk[x] = setval[x];
122         mons[PM_SUCCUBUS].mattk[x] = setval[x];
123     }
124     return;
125 }
126
127 /*sys.c*/