ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/init.C
(Generate patch)

Comparing deliantra/server/server/init.C (file contents):
Revision 1.78 by root, Fri Mar 26 00:59:22 2010 UTC vs.
Revision 1.88 by root, Sat Nov 17 23:40:04 2018 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
4 * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team 6 * Copyright (©) 2002 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992 Frank Tore Johansen 7 * Copyright (©) 1992 Frank Tore Johansen
7 * 8 *
8 * Deliantra is free software: you can redistribute it and/or modify it under 9 * Deliantra is free software: you can redistribute it and/or modify it under
9 * the terms of the Affero GNU General Public License as published by the 10 * the terms of the Affero GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your 11 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version. 12 * option) any later version.
12 * 13 *
13 * This program is distributed in the hope that it will be useful, 14 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 17 * GNU General Public License for more details.
17 * 18 *
18 * You should have received a copy of the Affero GNU General Public License 19 * You should have received a copy of the Affero GNU General Public License
19 * and the GNU General Public License along with this program. If not, see 20 * and the GNU General Public License along with this program. If not, see
20 * <http://www.gnu.org/licenses/>. 21 * <http://www.gnu.org/licenses/>.
21 * 22 *
22 * The authors can be reached via e-mail to <support@deliantra.net> 23 * The authors can be reached via e-mail to <support@deliantra.net>
23 */ 24 */
24 25
25#include <global.h> 26#include <global.h>
26#include <material.h> 27#include <material.h>
31 * information, having it here probably makes more sense. 32 * information, having it here probably makes more sense.
32 */ 33 */
33void 34void
34load_settings () 35load_settings ()
35{ 36{
36 char buf[MAX_BUF], *cp; 37 object_thawer thawer (settings.confdir, "settings");
37 int has_val, comp;
38 FILE *fp;
39 38
40 sprintf (buf, "%s/settings", settings.confdir); 39 if (!thawer)
41
42 /* We don't require a settings file at current time, but down the road,
43 * there will probably be so many values that not having a settings file
44 * will not be a good thing.
45 */
46 if (!(fp = open_and_uncompress (buf, 0, &comp)))
47 { 40 {
48 LOG (llevError, "Error: No settings file found\n"); 41 LOG (llevError, "Error: No settings file found\n");
49 exit (1); 42 exit (1);
50 } 43 }
51 44
52 while (fgets (buf, MAX_BUF - 1, fp) != NULL) 45 while (thawer.kw)
53 { 46 {
54 if (buf[0] == '#') 47 const char *buf = thawer.kw_str;
55 continue; 48 const char *cp = thawer.value_nn;
56 /* eliminate newline */
57 if ((cp = strrchr (buf, '\n')) != NULL)
58 *cp = '\0';
59 49
60 /* Skip over empty lines */
61 if (buf[0] == 0)
62 continue;
63
64 /* Skip all the spaces and set them to nulls. If not space,
65 * set cp to "" to make strcpy's and the like easier down below.
66 */
67 if ((cp = strchr (buf, ' ')) != NULL)
68 {
69 while (*cp == ' ')
70 *cp++ = 0;
71 has_val = 1;
72 }
73 else
74 {
75 cp = (char *)"";
76 has_val = 0;
77 }
78
79 if (!strcasecmp (buf, "not_permadeth")) 50 if (!strcmp (buf, "not_permadeth"))
80 { 51 {
81 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 52 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
82 { 53 {
83 settings.not_permadeth = TRUE; 54 settings.not_permadeth = TRUE;
84 } 55 }
85 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 56 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
86 { 57 {
87 settings.not_permadeth = FALSE; 58 settings.not_permadeth = FALSE;
88 } 59 }
89 else 60 else
90 { 61 {
91 LOG (llevError, "load_settings: Unknown value for not_permadeth" ": %s\n", cp); 62 LOG (llevError, "load_settings: Unknown value for not_permadeth" ": %s\n", cp);
92 } 63 }
93 } 64 }
94 else if (!strcasecmp (buf, "resurrection")) 65 else if (!strcmp (buf, "resurrection"))
95 { 66 {
96 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 67 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
97 { 68 {
98 settings.resurrection = TRUE; 69 settings.resurrection = TRUE;
99 } 70 }
100 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 71 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
101 { 72 {
102 settings.resurrection = FALSE; 73 settings.resurrection = FALSE;
103 } 74 }
104 else 75 else
105 { 76 {
106 LOG (llevError, "load_settings: Unknown value for resurrection" ": %s\n", cp); 77 LOG (llevError, "load_settings: Unknown value for resurrection" ": %s\n", cp);
107 } 78 }
108 } 79 }
109 else if (!strcasecmp (buf, "set_title")) 80 else if (!strcmp (buf, "set_title"))
110 { 81 {
111 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 82 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
112 { 83 {
113 settings.set_title = TRUE; 84 settings.set_title = TRUE;
114 } 85 }
115 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 86 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
116 { 87 {
117 settings.set_title = FALSE; 88 settings.set_title = FALSE;
118 } 89 }
119 else 90 else
120 { 91 {
121 LOG (llevError, "load_settings: Unknown value for set_title" ": %s\n", cp); 92 LOG (llevError, "load_settings: Unknown value for set_title" ": %s\n", cp);
122 } 93 }
123 } 94 }
124 else if (!strcasecmp (buf, "search_items")) 95 else if (!strcmp (buf, "search_items"))
125 { 96 {
126 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 97 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
127 { 98 {
128 settings.search_items = TRUE; 99 settings.search_items = TRUE;
129 } 100 }
130 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 101 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
131 { 102 {
132 settings.search_items = FALSE; 103 settings.search_items = FALSE;
133 } 104 }
134 else 105 else
135 { 106 {
136 LOG (llevError, "load_settings: Unknown value for search_items" ": %s\n", cp); 107 LOG (llevError, "load_settings: Unknown value for search_items" ": %s\n", cp);
137 } 108 }
138 } 109 }
139 else if (!strcasecmp (buf, "spell_encumbrance")) 110 else if (!strcmp (buf, "spell_encumbrance"))
140 { 111 {
141 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 112 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
142 { 113 {
143 settings.spell_encumbrance = TRUE; 114 settings.spell_encumbrance = TRUE;
144 } 115 }
145 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 116 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
146 { 117 {
147 settings.spell_encumbrance = FALSE; 118 settings.spell_encumbrance = FALSE;
148 } 119 }
149 else 120 else
150 { 121 {
151 LOG (llevError, "load_settings: Unknown value for " "spell_encumbrance: %s\n", cp); 122 LOG (llevError, "load_settings: Unknown value for " "spell_encumbrance: %s\n", cp);
152 } 123 }
153 } 124 }
154 else if (!strcasecmp (buf, "spell_failure_effects")) 125 else if (!strcmp (buf, "spell_failure_effects"))
155 { 126 {
156 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 127 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
157 { 128 {
158 settings.spell_failure_effects = TRUE; 129 settings.spell_failure_effects = TRUE;
159 } 130 }
160 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 131 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
161 { 132 {
162 settings.spell_failure_effects = FALSE; 133 settings.spell_failure_effects = FALSE;
163 } 134 }
164 else 135 else
165 { 136 {
166 LOG (llevError, "load_settings: Unknown value for " "spell_failure_effects: %s\n", cp); 137 LOG (llevError, "load_settings: Unknown value for " "spell_failure_effects: %s\n", cp);
167 } 138 }
168 } 139 }
169 else if (!strcasecmp (buf, "spellpoint_level_depend")) 140 else if (!strcmp (buf, "spellpoint_level_depend"))
170 { 141 {
171 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 142 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
172 { 143 {
173 settings.spellpoint_level_depend = TRUE; 144 settings.spellpoint_level_depend = TRUE;
174 } 145 }
175 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 146 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
176 { 147 {
177 settings.spellpoint_level_depend = FALSE; 148 settings.spellpoint_level_depend = FALSE;
178 } 149 }
179 else 150 else
180 { 151 {
181 LOG (llevError, "load_settings: Unknown value for " "spellpoint_level_depend: %s\n", cp); 152 LOG (llevError, "load_settings: Unknown value for " "spellpoint_level_depend: %s\n", cp);
182 } 153 }
183 } 154 }
184 else if (!strcasecmp (buf, "stat_loss_on_death")) 155 else if (!strcmp (buf, "stat_loss_on_death"))
185 { 156 {
186 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 157 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
187 { 158 {
188 settings.stat_loss_on_death = TRUE; 159 settings.stat_loss_on_death = TRUE;
189 } 160 }
190 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 161 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
191 { 162 {
192 settings.stat_loss_on_death = FALSE; 163 settings.stat_loss_on_death = FALSE;
193 } 164 }
194 else 165 else
195 { 166 {
196 LOG (llevError, "load_settings: Unknown value for " "stat_loss_on_death: %s\n", cp); 167 LOG (llevError, "load_settings: Unknown value for " "stat_loss_on_death: %s\n", cp);
197 } 168 }
198 } 169 }
199 else if (!strcasecmp (buf, "use_permanent_experience")) 170 else if (!strcmp (buf, "use_permanent_experience"))
200 { 171 {
201 LOG (llevError, "use_permanent_experience is deprecated, use" "permenent_experience_percentage instead\n"); 172 LOG (llevError, "use_permanent_experience is deprecated, use" "permenent_experience_percentage instead\n");
202 } 173 }
203 else if (!strcasecmp (buf, "permanent_experience_percentage")) 174 else if (!strcmp (buf, "permanent_experience_percentage"))
204 { 175 {
205 int val = atoi (cp); 176 int val = atoi (cp);
206 177
207 if (val < 0 || val > 100) 178 if (val < 0 || val > 100)
208 LOG (llevError, "load_settings: permenent_experience_percentage" "must be between 0 and 100, %d is invalid\n", val); 179 LOG (llevError, "load_settings: permenent_experience_percentage" "must be between 0 and 100, %d is invalid\n", val);
209 else 180 else
210 settings.permanent_exp_ratio = val; 181 settings.permanent_exp_ratio = val;
211 } 182 }
212 else if (!strcasecmp (buf, "death_penalty_percentage")) 183 else if (!strcmp (buf, "death_penalty_percentage"))
213 { 184 {
214 int val = atoi (cp); 185 int val = atoi (cp);
215 186
216 if (val < 0 || val > 100) 187 if (val < 0 || val > 100)
217 LOG (llevError, "load_settings: death_penalty_percentage" "must be between 0 and 100, %d is invalid\n", val); 188 LOG (llevError, "load_settings: death_penalty_percentage" "must be between 0 and 100, %d is invalid\n", val);
218 else 189 else
219 settings.death_penalty_ratio = val; 190 settings.death_penalty_ratio = val;
220 } 191 }
221 else if (!strcasecmp (buf, "death_penalty_levels")) 192 else if (!strcmp (buf, "death_penalty_levels"))
222 { 193 {
223 int val = atoi (cp); 194 int val = atoi (cp);
224 195
225 if (val < 0 || val > 255) 196 if (val < 0 || val > 255)
226 LOG (llevError, "load_settings: death_penalty_levels" "can not be negative, %d is invalid\n", val); 197 LOG (llevError, "load_settings: death_penalty_levels" "can not be negative, %d is invalid\n", val);
227 else 198 else
228 settings.death_penalty_level = val; 199 settings.death_penalty_level = val;
229 } 200 }
230 else if (!strcasecmp (buf, "balanced_stat_loss")) 201 else if (!strcmp (buf, "balanced_stat_loss"))
231 { 202 {
232 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 203 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
233 { 204 {
234 settings.balanced_stat_loss = TRUE; 205 settings.balanced_stat_loss = TRUE;
235 } 206 }
236 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 207 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
237 { 208 {
238 settings.balanced_stat_loss = FALSE; 209 settings.balanced_stat_loss = FALSE;
239 } 210 }
240 else 211 else
241 { 212 {
242 LOG (llevError, "load_settings: Unknown value for " "balanced_stat_loss: %s\n", cp); 213 LOG (llevError, "load_settings: Unknown value for " "balanced_stat_loss: %s\n", cp);
243 } 214 }
244 } 215 }
245 else if (!strcasecmp (buf, "simple_exp")) 216 else if (!strcmp (buf, "simple_exp"))
246 { 217 {
247 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 218 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
248 { 219 {
249 settings.simple_exp = TRUE; 220 settings.simple_exp = TRUE;
250 } 221 }
251 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 222 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
252 { 223 {
253 settings.simple_exp = FALSE; 224 settings.simple_exp = FALSE;
254 } 225 }
255 else 226 else
256 { 227 {
257 LOG (llevError, "load_settings: Unknown value for simple_exp: %s\n", cp); 228 LOG (llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
258 } 229 }
259 } 230 }
260 else if (!strcasecmp (buf, "item_power_factor")) 231 else if (!strcmp (buf, "item_power_factor"))
261 { 232 {
262 float tmp = atof (cp); 233 float tmp = atof (cp);
263 234
264 if (tmp < 0) 235 if (tmp < 0)
265 LOG (llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp); 236 LOG (llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
266 else 237 else
267 settings.item_power_factor = tmp; 238 settings.item_power_factor = tmp;
268 } 239 }
269 else if (!strcasecmp (buf, "pk_luck_penalty")) 240 else if (!strcmp (buf, "pk_luck_penalty"))
270 { 241 {
271 sint16 val = atoi (cp); 242 sint16 val = atoi (cp);
272 243
273 if (val < -100 || val > 100) 244 if (val < -100 || val > 100)
274 LOG (llevError, "load_settings: pk_luck_penalty must be between -100 and 100" ", %d is invalid\n", val); 245 LOG (llevError, "load_settings: pk_luck_penalty must be between -100 and 100" ", %d is invalid\n", val);
275 else 246 else
276 settings.pk_luck_penalty = val; 247 settings.pk_luck_penalty = val;
277 } 248 }
278 else if (!strcasecmp (buf, "set_friendly_fire")) 249 else if (!strcmp (buf, "set_friendly_fire"))
279 { 250 {
280 int val = atoi (cp); 251 int val = atoi (cp);
281 252
282 if (val < 0 || val > 100) 253 if (val < 0 || val > 100)
283 LOG (llevError, "load_settings: set_friendly_fire must be between 0 an 100" ", %d is invalid\n", val); 254 LOG (llevError, "load_settings: set_friendly_fire must be between 0 an 100" ", %d is invalid\n", val);
284 else 255 else
285 settings.set_friendly_fire = val; 256 settings.set_friendly_fire = val;
286 } 257 }
287 else if (!strcasecmp (buf, "armor_max_enchant")) 258 else if (!strcmp (buf, "armor_max_enchant"))
288 { 259 {
289 int max_e = atoi (cp); 260 int max_e = atoi (cp);
290 261
291 if (max_e <= 0) 262 if (max_e <= 0)
292 LOG (llevError, "load_settings: armor_max_enchant is %d\n", max_e); 263 LOG (llevError, "load_settings: armor_max_enchant is %d\n", max_e);
293 else 264 else
294 settings.armor_max_enchant = max_e; 265 settings.armor_max_enchant = max_e;
295 } 266 }
296 else if (!strcasecmp (buf, "armor_weight_reduction")) 267 else if (!strcmp (buf, "armor_weight_reduction"))
297 { 268 {
298 int wr = atoi (cp); 269 int wr = atoi (cp);
299 270
300 if (wr < 0) 271 if (wr < 0)
301 LOG (llevError, "load_settings: armor_weight_reduction is %d\n", wr); 272 LOG (llevError, "load_settings: armor_weight_reduction is %d\n", wr);
302 else 273 else
303 settings.armor_weight_reduction = wr; 274 settings.armor_weight_reduction = wr;
304 } 275 }
305 else if (!strcasecmp (buf, "armor_weight_linear")) 276 else if (!strcmp (buf, "armor_weight_linear"))
306 { 277 {
307 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 278 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
308 { 279 {
309 settings.armor_weight_linear = TRUE; 280 settings.armor_weight_linear = TRUE;
310 } 281 }
311 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 282 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
312 { 283 {
313 settings.armor_weight_linear = FALSE; 284 settings.armor_weight_linear = FALSE;
314 } 285 }
315 else 286 else
316 { 287 {
317 LOG (llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp); 288 LOG (llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
318 } 289 }
319 290
320 } 291 }
321 else if (!strcasecmp (buf, "armor_speed_improvement")) 292 else if (!strcmp (buf, "armor_speed_improvement"))
322 { 293 {
323 int wr = atoi (cp); 294 int wr = atoi (cp);
324 295
325 if (wr < 0) 296 if (wr < 0)
326 LOG (llevError, "load_settings: armor_speed_improvement is %d\n", wr); 297 LOG (llevError, "load_settings: armor_speed_improvement is %d\n", wr);
327 else 298 else
328 settings.armor_speed_improvement = wr; 299 settings.armor_speed_improvement = wr;
329 } 300 }
330 else if (!strcasecmp (buf, "armor_speed_linear")) 301 else if (!strcmp (buf, "armor_speed_linear"))
331 { 302 {
332 if (!strcasecmp (cp, "on") || !strcasecmp (cp, "true")) 303 if (!strcmp (cp, "on") || !strcmp (cp, "true"))
333 { 304 {
334 settings.armor_speed_linear = TRUE; 305 settings.armor_speed_linear = TRUE;
335 } 306 }
336 else if (!strcasecmp (cp, "off") || !strcasecmp (cp, "false")) 307 else if (!strcmp (cp, "off") || !strcmp (cp, "false"))
337 { 308 {
338 settings.armor_speed_linear = FALSE; 309 settings.armor_speed_linear = FALSE;
339 } 310 }
340 else 311 else
341 { 312 {
342 LOG (llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp); 313 LOG (llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
343 } 314 }
344 315
345 } 316 }
346 else 317 else
347 LOG (llevError, "Unknown value in settings file: %s\n", buf); 318 thawer.parse_error ("settings file");
319
320 thawer.next ();
348 } 321 }
349
350 close_and_delete (fp, comp);
351} 322}
352 323
353/* 324/*
354 * init() is called only once, when starting the program. 325 * init() is called only once, when starting the program.
355 */ 326 */
361 init_environ (); 332 init_environ ();
362 cfperl_init (); 333 cfperl_init ();
363 init_done = 1; 334 init_done = 1;
364} 335}
365 336
366void
367usage ()
368{
369 fprintf (stderr, "Usage: deliantra-server [-h] [-<flags>]...\n");
370}
371
372void
373help ()
374{
375
376/* The information in usage is redundant with what is given below, so why call it? */
377
378/* usage();*/
379 printf ("Flags:\n");
380 printf (" -csport <port> Specifies the port to use for the new client/server code.\n");
381 printf (" -d Turns on some debugging.\n");
382 printf (" +d Turns off debugging (useful if server compiled with debugging\n");
383 printf (" as default).\n");
384 printf (" -detach The server will go in the background, closing all\n");
385 printf (" connections to the tty.\n");
386 printf (" -h Display this information.\n");
387 printf (" -log <file> Specifies which file to send output to.\n");
388 printf (" Only has meaning if -detach is specified.\n");
389 printf (" -mon Turns on monster debugging.\n");
390 printf (" -o Prints out info on what was defined at compile time.\n");
391 printf (" -s Display the high-score list.\n");
392 printf (" -score <name or class> Displays all high scores with matching name/class.\n");
393 printf (" -v Print version and contributors.\n");
394 printf (" -data Sets the lib dir (archetypes, treasures, etc.)\n");
395 printf (" -local Read/write local data (hiscore, unique items, etc.)\n");
396 printf (" -maps Sets the directory for maps.\n");
397 printf (" -arch Sets the archetype file to use.\n");
398 printf (" -regions Sets the regions file to use.\n");
399 printf (" -playerdir Sets the directory for the player files.\n");
400 printf (" -templatedir Sets the directory for template generate maps.\n");
401 printf (" -treasures Sets the treasures file to use.\n");
402 printf (" -uniquedir Sets the unique items/maps directory.\n");
403 printf (" -tmpdir Sets the directory for temporary files (mostly maps.)\n");
404 printf (" -m Lists out suggested experience for all monsters.\n");
405 printf (" -m2 Dumps out abilities.\n");
406 printf (" -m3 Dumps out artifact information.\n");
407 printf (" -m4 Dumps out spell information.\n");
408 printf (" -m5 Dumps out skill information.\n");
409 printf (" -m6 Dumps out race information.\n");
410 printf (" -m7 Dumps out alchemy information.\n");
411 printf (" -m8 Dumps out gods information.\n");
412 printf (" -m9 Dumps out more alchemy information (formula checking).\n");
413 printf (" -mt <name> Dumps out list of treasures for a monster.\n");
414 exit (0);
415}
416
417/* Signal handlers: */ 337/* Signal handlers: */
418 338
419static void 339static void
420rec_sigabrt (int i) 340rec_sigabrt (int i)
421{ 341{
424 LOG (llevError, "SIGABRT received.\n"); 344 LOG (llevError, "SIGABRT received.\n");
425 cleanup ("SIGABRT received", 1); 345 cleanup ("SIGABRT received", 1);
426} 346}
427 347
428static void 348static void
349rec_sigquit (int i)
350{
351 signal (SIGQUIT, SIG_IGN);
352
353 LOG (llevInfo, "SIGQUIT received\n");
354 cleanup ("SIGQUIT received", 1);
355}
356
357static void
429rec_sigsegv (int i) 358rec_sigsegv (int i)
430{ 359{
431 signal (SIGSEGV, SIG_DFL); 360 signal (SIGSEGV, SIG_DFL);
432 361
433 LOG (llevError, "SIGSEGV received.\n"); 362 LOG (llevError, "SIGSEGV received.\n");
434 cleanup ("SIGSEGV received", 1); 363 cleanup ("SIGSEGV received", 1);
435} 364}
436 365
437static void 366static void
438rec_sigquit (int i)
439{
440 signal (SIGQUIT, SIG_IGN);
441
442 LOG (llevInfo, "SIGQUIT received\n");
443 cleanup ("SIGQUIT received", 1);
444}
445
446static void
447rec_sigbus (int i) 367rec_sigbus (int i)
448{ 368{
449 signal (SIGBUS, SIG_DFL); 369 signal (SIGBUS, SIG_DFL);
450 370
451 LOG (llevError, "SIGBUS received\n"); 371 LOG (llevError, "SIGBUS received\n");
452 cleanup ("SIGBUS received", 1); 372 cleanup ("SIGBUS received", 1);
373}
374
375static void
376rec_sigfpe (int i)
377{
378 signal (SIGFPE, SIG_DFL);
379
380 LOG (llevError, "SIGFPE received.\n");
381 cleanup ("SIGFPE received", 1);
453} 382}
454 383
455void 384void
456reset_signals () 385reset_signals ()
457{ 386{
458 signal (SIGABRT, SIG_DFL); 387 signal (SIGABRT, SIG_DFL);
459 signal (SIGQUIT, SIG_DFL); 388 signal (SIGQUIT, SIG_DFL);
460 signal (SIGSEGV, SIG_DFL); 389 signal (SIGSEGV, SIG_DFL);
390#ifdef SIGBUS
461 signal (SIGBUS , SIG_DFL); 391 signal (SIGBUS , SIG_DFL);
392#endif
393 signal (SIGFPE , SIG_DFL);
462 signal (SIGINT , SIG_DFL); 394 signal (SIGINT , SIG_DFL);
463 signal (SIGTERM, SIG_DFL); 395 signal (SIGTERM, SIG_DFL);
464} 396}
465 397
466void 398void
482 sa.sa_flags = SA_RESTART; 414 sa.sa_flags = SA_RESTART;
483 415
484 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0); 416 sa.sa_handler = SIG_IGN; sigaction (SIGPIPE, &sa, 0);
485 sa.sa_handler = rec_sigabrt; sigaction (SIGABRT, &sa, 0); 417 sa.sa_handler = rec_sigabrt; sigaction (SIGABRT, &sa, 0);
486 sa.sa_handler = rec_sigquit; sigaction (SIGQUIT, &sa, 0); 418 sa.sa_handler = rec_sigquit; sigaction (SIGQUIT, &sa, 0);
419#ifdef SIGBUS
487 sa.sa_handler = rec_sigbus; sigaction (SIGBUS, &sa, 0); 420 sa.sa_handler = rec_sigbus; sigaction (SIGBUS, &sa, 0);
421#endif
422 sa.sa_handler = rec_sigfpe; sigaction (SIGFPE, &sa, 0);
488 423
489 sa.sa_flags |= SA_ONSTACK; 424 sa.sa_flags |= SA_ONSTACK;
490 sa.sa_handler = rec_sigsegv; sigaction (SIGSEGV, &sa, 0); 425 sa.sa_handler = rec_sigsegv; sigaction (SIGSEGV, &sa, 0);
491} 426}
492 427
622 557
623 mon->race = race; 558 mon->race = race;
624 } 559 }
625 560
626 /* if the arch is a monster, add it to the race list */ 561 /* if the arch is a monster, add it to the race list */
627 if (set_list && QUERY_FLAG (mon, FLAG_MONSTER)) 562 if (set_list && mon->flag [FLAG_MONSTER])
628 add_to_racelist (race, mon); 563 add_to_racelist (race, mon);
629 } 564 }
630 } 565 }
631 } 566 }
632 567

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines