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