forked from NetHack/NetHack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsys.c
More file actions
147 lines (133 loc) · 4.18 KB
/
sys.c
File metadata and controls
147 lines (133 loc) · 4.18 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
/* 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 $ */
/* Copyright (c) Kenneth Lorber, Kensington, Maryland, 2008. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
#ifndef SYSCF
/* !SYSCF configurations need '#define DEBUGFILES "foo.c bar.c"'
* to enable debugging feedback for source files foo.c and bar.c;
* to activate debugpline(), set an appropriate value and uncomment
*/
/* # define DEBUGFILES "*" */
/* note: DEBUGFILES value here or in sysconf.DEBUGFILES can be overridden
at runtime by setting up a value for "DEBUGFILES" in the environment */
#endif
struct sysopt sysopt;
void
sys_early_init()
{
sysopt.support = (char *) 0;
sysopt.recover = (char *) 0;
#ifdef SYSCF
sysopt.wizards = (char *) 0;
#else
sysopt.wizards = dupstr(WIZARD_NAME);
#endif
#if defined(SYSCF) || !defined(DEBUGFILES)
sysopt.debugfiles = (char *) 0;
#else
sysopt.debugfiles = dupstr(DEBUGFILES);
#endif
#ifdef DUMPLOG
sysopt.dumplogfile = (char *) 0;
#endif
sysopt.env_dbgfl = 0; /* haven't checked getenv("DEBUGFILES") yet */
sysopt.shellers = (char *) 0;
sysopt.explorers = (char *) 0;
sysopt.genericusers = (char *) 0;
sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
sysopt.bones_pools = 0;
/* record file */
sysopt.persmax = PERSMAX;
sysopt.entrymax = ENTRYMAX;
sysopt.pointsmin = POINTSMIN;
sysopt.pers_is_uid = PERS_IS_UID;
sysopt.tt_oname_maxrank = 10;
/* sanity checks */
if (PERSMAX < 1)
sysopt.persmax = 1;
if (ENTRYMAX < 10)
sysopt.entrymax = 10;
if (POINTSMIN < 1)
sysopt.pointsmin = 1;
if (PERS_IS_UID != 0 && PERS_IS_UID != 1)
panic("config error: PERS_IS_UID must be either 0 or 1");
#ifdef PANICTRACE
/* panic options */
sysopt.gdbpath = dupstr(GDBPATH);
sysopt.greppath = dupstr(GREPPATH);
#if (NH_DEVEL_STATUS != NH_STATUS_RELEASED)
sysopt.panictrace_gdb = 1;
#ifdef PANICTRACE_LIBC
sysopt.panictrace_libc = 2;
#endif
#else
sysopt.panictrace_gdb = 0;
#ifdef PANICTRACE_LIBC
sysopt.panictrace_libc = 0;
#endif
#endif
#endif
sysopt.check_save_uid = 1;
sysopt.check_plname = 0;
sysopt.seduce = 1; /* if it's compiled in, default to on */
sysopt_seduce_set(sysopt.seduce);
return;
}
void
sysopt_release()
{
if (sysopt.support)
free((genericptr_t) sysopt.support), sysopt.support = (char *) 0;
if (sysopt.recover)
free((genericptr_t) sysopt.recover), sysopt.recover = (char *) 0;
if (sysopt.wizards)
free((genericptr_t) sysopt.wizards), sysopt.wizards = (char *) 0;
if (sysopt.explorers)
free((genericptr_t) sysopt.explorers), sysopt.explorers = (char *) 0;
if (sysopt.shellers)
free((genericptr_t) sysopt.shellers), sysopt.shellers = (char *) 0;
if (sysopt.debugfiles)
free((genericptr_t) sysopt.debugfiles),
sysopt.debugfiles = (char *) 0;
#ifdef DUMPLOG
if (sysopt.dumplogfile)
free((genericptr_t)sysopt.dumplogfile), sysopt.dumplogfile=(char *)0;
#endif
if (sysopt.genericusers)
free((genericptr_t) sysopt.genericusers),
sysopt.genericusers = (char *) 0;
#ifdef PANICTRACE
if (sysopt.gdbpath)
free((genericptr_t) sysopt.gdbpath), sysopt.gdbpath = (char *) 0;
if (sysopt.greppath)
free((genericptr_t) sysopt.greppath), sysopt.greppath = (char *) 0;
#endif
/* this one's last because it might be used in panic feedback, although
none of the preceding ones are likely to trigger a controlled panic */
if (sysopt.fmtd_wizard_list)
free((genericptr_t) sysopt.fmtd_wizard_list),
sysopt.fmtd_wizard_list = (char *) 0;
return;
}
extern const struct attack sa_yes[NATTK];
extern const struct attack sa_no[NATTK];
void
sysopt_seduce_set(val)
int val;
{
#if 0
/*
* Attack substitution is now done on the fly in getmattk(mhitu.c).
*/
struct attack *setval = val ? sa_yes : sa_no;
int x;
for (x = 0; x < NATTK; x++) {
mons[PM_INCUBUS].mattk[x] = setval[x];
mons[PM_SUCCUBUS].mattk[x] = setval[x];
}
#else
nhUse(val);
#endif /*0*/
return;
}
/*sys.c*/