Crossfire Server, Branches 1.12  R18729
init.c
Go to the documentation of this file.
1 /*
2  * static char *rcsid_init_c =
3  * "$Id: init.c 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  CrossFire, A Multiplayer game for X-windows
8 
9  Copyright (C) 2002 Mark Wedel & Crossfire Development Team
10  Copyright (C) 1992 Frank Tore Johansen
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 
26  The authors can be reached via e-mail at crossfire-devel@real-time.com
27 */
28 
34 #include <global.h>
35 #include <loader.h>
36 #include <version.h>
37 #ifndef __CEXTRACT__
38 #include <sproto.h>
39 #endif
40 
41 /* Needed for strcasecmp(). */
42 #include <strings.h>
43 
44 static void help(void);
45 static void usage(void);
46 static void init_beforeplay(void);
47 static void init_startup(void);
48 static void compile_info(void);
49 static void init_signals(void);
50 static void init_races(void);
51 static void dump_races(void);
52 static void add_to_racelist(const char *race_name, object *op);
53 static racelink *get_racelist(void);
54 static void fatal_signal(int make_core);
55 
57 static char default_daemon_log[] = "logfile";
58 
59 static void set_logfile(char *val) {
60  settings.logfilename = val;
61 }
62 
63 static void call_version(void) {
64  version(NULL);
65  exit(0);
66 }
67 
68 static void showscores(void) {
69  display_high_score(NULL, 9999, NULL);
70  exit(0);
71 }
72 
73 static void set_debug(void) {
75 }
76 
77 static void unset_debug(void) {
79 }
80 
81 static void set_mondebug(void) {
83 }
84 
85 static void set_dumpmon1(void) {
86  settings.dumpvalues = 1;
87 }
88 
89 static void set_dumpmon2(void) {
90  settings.dumpvalues = 2;
91 }
92 
93 static void set_dumpmon3(void) {
94  settings.dumpvalues = 3;
95 }
96 
97 static void set_dumpmon4(void) {
98  settings.dumpvalues = 4;
99 }
100 
101 static void set_dumpmon5(void) {
102  settings.dumpvalues = 5;
103 }
104 
105 static void set_dumpmon6(void) {
106  settings.dumpvalues = 6;
107 }
108 
109 static void set_dumpmon7(void) {
110  settings.dumpvalues = 7;
111 }
112 
113 static void set_dumpmon8(void) {
114  settings.dumpvalues = 8;
115 }
116 
117 static void set_dumpmon9(void) {
118  settings.dumpvalues = 9;
119 }
120 
121 static void set_dumpmont(const char *name) {
122  settings.dumpvalues = 10;
123  settings.dumparg = name;
124 }
125 
126 static void set_daemon(void) {
127  settings.daemonmode = 1;
128  if (settings.logfilename[0] == '\0') {
130  }
131 }
132 
133 static void set_datadir(const char *path) {
134  settings.datadir = path;
135 }
136 
137 static void set_confdir(const char *path) {
138  settings.confdir = path;
139 }
140 
141 static void set_localdir(const char *path) {
142  settings.localdir = path;
143 }
144 
145 static void set_mapdir(const char *path) {
146  settings.mapdir = path;
147 }
148 
149 static void set_archetypes(const char *path) {
150  settings.archetypes = path;
151 }
152 
153 static void set_regions(const char *path) {
154  settings.regions = path;
155 }
156 
157 static void set_treasures(const char *path) {
158  settings.treasures = path;
159 }
160 
161 static void set_uniquedir(const char *path) {
162  settings.uniquedir = path;
163 }
164 
165 static void set_templatedir(const char *path) {
166  settings.templatedir = path;
167 }
168 
169 static void set_playerdir(const char *path) {
170  settings.playerdir = path;
171 }
172 
173 static void set_tmpdir(const char *path) {
174  settings.tmpdir = path;
175 }
176 
177 static void free_races(void);
178 
179 static void free_materials(void);
180 
181 static void showscoresparm(const char *data) {
182  display_high_score(NULL, 9999, data);
183  exit(0);
184 }
185 
192 static void set_csport(const char *val) {
193  settings.csport = atoi(val);
194 #ifndef WIN32 /* ***win32: set_csport: we remove csport error secure check here, do this later */
195  if (settings.csport <= 0
196  || settings.csport > 32765
197  || (settings.csport < 1024 && getuid() != 0)) {
198  LOG(llevError, "%d is an invalid csport number.\n", settings.csport);
199  exit(1);
200  }
201 #endif /* win32 */
202 }
203 
206 typedef void (*cmdlinefunc_args0)(void);
207 typedef void (*cmdlinefunc_args1)(const char* arg1);
208 typedef void (*cmdlinefunc_args2)(const char* arg1, const char* arg2);
217  const char *cmd_option;
220  void (*func)();
224 };
225 
234 static struct Command_Line_Options options[] = {
238  { "-h", 0, 1, help },
239  /* Honor -help also, since it is somewhat common */
240  { "-help", 0, 1, help },
241  { "-v", 0, 1, call_version },
242  { "-d", 0, 1, set_debug },
243  { "+d", 0, 1, unset_debug },
244  { "-mon", 0, 1, set_mondebug },
245  { "-data", 1, 1, set_datadir },
246  { "-conf", 1, 1, set_confdir },
247  { "-local", 1, 1, set_localdir },
248  { "-maps", 1, 1, set_mapdir },
249  { "-arch", 1, 1, set_archetypes },
250  { "-regions", 1, 1, set_regions },
251  { "-playerdir", 1, 1, set_playerdir },
252  { "-treasures", 1, 1, set_treasures },
253  { "-uniquedir", 1, 1, set_uniquedir },
254  { "-templatedir", 1, 1, set_templatedir },
255  { "-tmpdir", 1, 1, set_tmpdir },
256  { "-log", 1, 1, set_logfile },
257  { "-detach", 0, 1, set_daemon },
258 
259 #ifdef WIN32
260  /* Windows service stuff */
261  { "-regsrv", 0, 1, service_register },
262  { "-unregsrv", 0, 1, service_unregister },
263  { "-srv", 0, 1, service_handle },
264 #endif
265 
269  { "-csport", 1, 2, set_csport },
270 
274  { "-o", 0, 3, compile_info },
275  { "-m", 0, 3, set_dumpmon1 },
276  { "-m2", 0, 3, set_dumpmon2 },
277  { "-m3", 0, 3, set_dumpmon3 },
278  { "-m4", 0, 3, set_dumpmon4 },
279  { "-m5", 0, 3, set_dumpmon5 },
280  { "-m6", 0, 3, set_dumpmon6 },
281  { "-m7", 0, 3, set_dumpmon7 },
282  { "-m8", 0, 3, set_dumpmon8 },
283  { "-m9", 0, 3, set_dumpmon9 },
284  { "-mt", 1, 3, set_dumpmont },
285  { "-mexp", 0, 3, dump_experience },
286  { "-s", 0, 3, showscores },
287  { "-score", 1, 3, showscoresparm }
288 };
289 
304 static void parse_args(int argc, char *argv[], int pass) {
305  size_t i;
306  int on_arg = 1;
307 
308  while (on_arg < argc) {
309  for (i = 0; i < sizeof(options)/sizeof(struct Command_Line_Options); i++) {
310  if (!strcmp(options[i].cmd_option, argv[on_arg])) {
311  /* Found a matching option, but should not be processed on
312  * this pass. Just skip over it
313  */
314  if (options[i].pass != pass) {
315  on_arg += options[i].num_args+1;
316  break;
317  }
318  if (options[i].num_args) {
319  if ((on_arg+options[i].num_args) >= argc) {
320  fprintf(stderr, "%s requires an argument.\n", options[i].cmd_option);
321  exit(1);
322  } else {
323  if (options[i].num_args == 1)
324  ((cmdlinefunc_args1)options[i].func)(argv[on_arg+1]);
325  if (options[i].num_args == 2)
326  ((cmdlinefunc_args2)options[i].func)(argv[on_arg+1], argv[on_arg+2]);
327  on_arg += options[i].num_args+1;
328  }
329  } else { /* takes no args */
330  ((cmdlinefunc_args0)options[i].func)();
331  on_arg++;
332  }
333  break;
334  }
335  }
336  if (i == sizeof(options)/sizeof(struct Command_Line_Options)) {
337  fprintf(stderr, "Unknown option: %s\n", argv[on_arg]);
338  usage();
339  exit(1);
340  }
341  }
342 }
343 
346 
356  materialtype_t *mt;
357  int i;
358 
359  mt = (materialtype_t *)malloc(sizeof(materialtype_t));
360  if (mt == NULL)
362  mt->name = NULL;
363  mt->description = NULL;
364  for (i = 0; i < NROFATTACKS; i++) {
365  mt->save[i] = 0;
366  mt->mod[i] = 0;
367  }
368  mt->chance = 0;
369  mt->difficulty = 0;
370  mt->magic = 0;
371  mt->damage = 0;
372  mt->wc = 0;
373  mt->ac = 0;
374  mt->sp = 0;
375  mt->weight = 100;
376  mt->value = 100;
377  mt->next = NULL;
378  return mt;
379 }
380 
385 static void load_materials(void) {
386  char buf[MAX_BUF], filename[MAX_BUF], *cp, *next;
387  FILE *fp;
388  materialtype_t *mt;
389  int i, value;
390 
391  snprintf(filename, sizeof(filename), "%s/materials", settings.datadir);
392  LOG(llevDebug, "Reading material type data from %s...\n", filename);
393  if ((fp = fopen(filename, "r")) == NULL) {
394  LOG(llevError, "Cannot open %s for reading\n", filename);
395  mt = get_empty_mat();
396  mt->next = NULL;
397  materialt = mt;
398  return;
399  }
400  mt = get_empty_mat();
401  materialt = mt;
402  while (fgets(buf, MAX_BUF, fp) != NULL) {
403  if (*buf == '#')
404  continue;
405  if ((cp = strchr(buf, '\n')) != NULL)
406  *cp = '\0';
407  cp = buf;
408  while (*cp == ' ') /* Skip blanks */
409  cp++;
410  if (!strncmp(cp, "name", 4)) {
411  /* clean up the previous entry */
412  if (mt->next != NULL) {
413  if (mt->description == NULL)
414  mt->description = add_string(mt->name);
415  mt = mt->next;
416  }
417  mt->next = get_empty_mat();
418  mt->name = add_string(strchr(cp, ' ')+1);
419  } else if (!strncmp(cp, "description", 11)) {
420  mt->description = add_string(strchr(cp, ' ')+1);
421  } else if (sscanf(cp, "material %d", &value)) {
422  mt->material = value;
423  } else if (!strncmp(cp, "saves", 5)) {
424  cp = strchr(cp, ' ')+1;
425  for (i = 0; i < NROFATTACKS; i++) {
426  if (cp == NULL) {
427  mt->save[i] = 0;
428  continue;
429  }
430  if ((next = strchr(cp, ',')) != NULL)
431  *(next++) = '\0';
432  sscanf(cp, "%d", &value);
433  mt->save[i] = (sint8)value;
434  cp = next;
435  }
436  } else if (!strncmp(cp, "mods", 4)) {
437  cp = strchr(cp, ' ')+1;
438  for (i = 0; i < NROFATTACKS; i++) {
439  if (cp == NULL) {
440  mt->save[i] = 0;
441  continue;
442  }
443  if ((next = strchr(cp, ',')) != NULL)
444  *(next++) = '\0';
445  sscanf(cp, "%d", &value);
446  mt->mod[i] = (sint8)value;
447  cp = next;
448  }
449  } else if (sscanf(cp, "chance %d\n", &value)) {
450  mt->chance = (sint8)value;
451  } else if (sscanf(cp, "diff %d\n", &value)) {
452  mt->difficulty = (sint8)value;
453  } else if (sscanf(cp, "magic %d\n", &value)) {
454  mt->magic = (sint8)value;
455  } else if (sscanf(cp, "damage %d\n", &value)) {
456  mt->damage = (sint8)value;
457  } else if (sscanf(cp, "wc %d\n", &value)) {
458  mt->wc = (sint8)value;
459  } else if (sscanf(cp, "ac %d\n", &value)) {
460  mt->ac = (sint8)value;
461  } else if (sscanf(cp, "sp %d\n", &value)) {
462  mt->sp = (sint8)value;
463  } else if (sscanf(cp, "weight %d\n", &value)) {
464  mt->weight = value;
465  } else if (sscanf(cp, "value %d\n", &value)) {
466  mt->value = value;
467  }
468  }
469  if (mt->next) {
470  free(mt->next);
471  mt->next = NULL;
472  }
473  LOG(llevDebug, "Done.\n");
474  fclose(fp);
475 
476 }
477 
481 static void free_materials(void) {
482  materialtype_t *next;
483 
484  while (materialt) {
485  next = materialt->next;
486  free(materialt);
487  materialt = next;
488  }
489  materialt = NULL;
490 }
491 
497 static void load_settings(void) {
498  char buf[MAX_BUF], *cp;
499  int has_val, comp;
500  FILE *fp;
501 
502  snprintf(buf, sizeof(buf), "%s/settings", settings.confdir);
503 
504  /* We don't require a settings file at current time, but down the road,
505  * there will probably be so many values that not having a settings file
506  * will not be a good thing.
507  */
508  if ((fp = open_and_uncompress(buf, 0, &comp)) == NULL) {
509  LOG(llevError, "Warning: No settings file found\n");
510  return;
511  }
512  while (fgets(buf, MAX_BUF-1, fp) != NULL) {
513  if (buf[0] == '#')
514  continue;
515  /* eliminate newline */
516  if ((cp = strrchr(buf, '\n')) != NULL)
517  *cp = '\0';
518 
519  /* Skip over empty lines */
520  if (buf[0] == 0)
521  continue;
522 
523  /* Skip all the spaces and set them to nulls. If not space,
524  * set cp to "" to make strcpy's and the like easier down below.
525  */
526  if ((cp = strchr(buf, ' ')) != NULL) {
527  while (*cp == ' ')
528  *cp++ = 0;
529  has_val = 1;
530  } else {
531  cp = "";
532  has_val = 0;
533  }
534 
535  if (!strcasecmp(buf, "metaserver_notification")) {
536  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
538  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
540  } else {
541  LOG(llevError, "load_settings: Unknown value for metaserver_notification: %s\n", cp);
542  }
543  } else if (!strcasecmp(buf, "metaserver_server")) {
544  if (has_val)
545  strcpy(settings.meta_server, cp);
546  else
547  LOG(llevError, "load_settings: metaserver_server must have a value.\n");
548  } else if (!strcasecmp(buf, "motd")) {
549  if (has_val)
550  strcpy(settings.motd, cp);
551  else
552  LOG(llevError, "load_settings: motd must have a value.\n");
553  } else if (!strcasecmp(buf, "dm_mail")) {
554  if (has_val)
555  strcpy(settings.dm_mail, cp);
556  else
557  LOG(llevError, "load_settings: dm_mail must have a value.\n");
558  } else if (!strcasecmp(buf, "metaserver_host")) {
559  if (has_val)
560  strcpy(settings.meta_host, cp);
561  else
562  LOG(llevError, "load_settings: metaserver_host must have a value.\n");
563  } else if (!strcasecmp(buf, "port")) {
564  set_csport(cp);
565  } else if (!strcasecmp(buf, "metaserver_port")) {
566  int port = atoi(cp);
567 
568  if (port < 1 || port > 65535)
569  LOG(llevError, "load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
570  else
571  settings.meta_port = port;
572  } else if (!strcasecmp(buf, "metaserver_comment")) {
573  strcpy(settings.meta_comment, cp);
574  } else if (!strcasecmp(buf, "worldmapstartx")) {
575  int size = atoi(cp);
576 
577  if (size < 0)
578  LOG(llevError, "load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
579  else
580  settings.worldmapstartx = size;
581  } else if (!strcasecmp(buf, "worldmapstarty")) {
582  int size = atoi(cp);
583 
584  if (size < 0)
585  LOG(llevError, "load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
586  else
587  settings.worldmapstarty = size;
588  } else if (!strcasecmp(buf, "worldmaptilesx")) {
589  int size = atoi(cp);
590 
591  if (size < 1)
592  LOG(llevError, "load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
593  else
594  settings.worldmaptilesx = size;
595  } else if (!strcasecmp(buf, "worldmaptilesy")) {
596  int size = atoi(cp);
597 
598  if (size < 1)
599  LOG(llevError, "load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
600  else
601  settings.worldmaptilesy = size;
602  } else if (!strcasecmp(buf, "worldmaptilesizex")) {
603  int size = atoi(cp);
604 
605  if (size < 1)
606  LOG(llevError, "load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
607  else
609  } else if (!strcasecmp(buf, "worldmaptilesizey")) {
610  int size = atoi(cp);
611 
612  if (size < 1)
613  LOG(llevError, "load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
614  else
616  } else if (!strcasecmp(buf, "fastclock")) {
617  int lev = atoi(cp);
618 
619  if (lev < 0)
620  LOG(llevError, "load_settings: fastclock must be at least 0, %d is invalid\n", lev);
621  else
622  settings.fastclock = lev;
623  } else if (!strcasecmp(buf, "not_permadeth")) {
624  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
626  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
628  } else {
629  LOG(llevError, "load_settings: Unknown value for not_permadeth: %s\n", cp);
630  }
631  } else if (!strcasecmp(buf, "resurrection")) {
632  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
634  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
636  } else {
637  LOG(llevError, "load_settings: Unknown value for resurrection: %s\n", cp);
638  }
639  } else if (!strcasecmp(buf, "set_title")) {
640  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
642  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
644  } else {
645  LOG(llevError, "load_settings: Unknown value for set_title: %s\n", cp);
646  }
647  } else if (!strcasecmp(buf, "search_items")) {
648  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
650  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
652  } else {
653  LOG(llevError, "load_settings: Unknown value for search_items: %s\n", cp);
654  }
655  } else if (!strcasecmp(buf, "spell_encumbrance")) {
656  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
658  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
660  } else {
661  LOG(llevError, "load_settings: Unknown value for spell_encumbrance: %s\n", cp);
662  }
663  } else if (!strcasecmp(buf, "spell_failure_effects")) {
664  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
666  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
668  } else {
669  LOG(llevError, "load_settings: Unknown value for spell_failure_effects: %s\n", cp);
670  }
671  } else if (!strcasecmp(buf, "casting_time")) {
672  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
674  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
676  } else {
677  LOG(llevError, "load_settings: Unknown value for casting_time: %s\n", cp);
678  }
679  } else if (!strcasecmp(buf, "real_wiz")) {
680  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
682  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
684  } else {
685  LOG(llevError, "load_settings: Unknown value for real_wiz: %s\n", cp);
686  }
687  } else if (!strcasecmp(buf, "recycle_tmp_maps")) {
688  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
690  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
692  } else {
693  LOG(llevError, "load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
694  }
695  } else if (!strcasecmp(buf, "explore_mode")) {
696  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
698  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
700  } else {
701  LOG(llevError, "load_settings: Unknown value for explore_mode: %s\n", cp);
702  }
703  } else if (!strcasecmp(buf, "who_format")) {
704  if (has_val)
705  strcpy(settings.who_format, cp);
706  } else if (!strcasecmp(buf, "who_wiz_format")) {
707  if (has_val)
708  strcpy(settings.who_wiz_format, cp);
709  } else if (!strcasecmp(buf, "spellpoint_level_depend")) {
710  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
712  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
714  } else {
715  LOG(llevError, "load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
716  }
717  } else if (!strcasecmp(buf, "stat_loss_on_death")) {
718  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
720  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
722  } else {
723  LOG(llevError, "load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
724  }
725  } else if (!strcasecmp(buf, "use_permanent_experience")) {
726  LOG(llevError, "use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
727  } else if (!strcasecmp(buf, "permanent_experience_percentage")) {
728  int val = atoi(cp);
729  if (val < 0 || val > 100)
730  LOG(llevError, "load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
731  else
733  } else if (!strcasecmp(buf, "death_penalty_percentage")) {
734  int val = atoi(cp);
735  if (val < 0 || val > 100)
736  LOG(llevError, "load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
737  else
739  } else if (!strcasecmp(buf, "death_penalty_levels")) {
740  int val = atoi(cp);
741  if (val < 0 || val > 255)
742  LOG(llevError, "load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
743  else
745  } else if (!strcasecmp(buf, "balanced_stat_loss")) {
746  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
748  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
750  } else {
751  LOG(llevError, "load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
752  }
753  } else if (!strcasecmp(buf, "simple_exp")) {
754  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
756  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
758  } else {
759  LOG(llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
760  }
761  } else if (!strcasecmp(buf, "item_power_factor")) {
762  float tmp = atof(cp);
763  if (tmp < 0)
764  LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
765  else
767  } else if (!strcasecmp(buf, "pk_luck_penalty")) {
768  sint16 val = atoi(cp);
769 
770  if (val < -100 || val > 100)
771  LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
772  else
774  } else if (!strcasecmp(buf, "set_friendly_fire")) {
775  int val = atoi(cp);
776 
777  if (val < 1 || val > 100)
778  LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
779  else
781  } else if (!strcasecmp(buf, "armor_max_enchant")) {
782  int max_e = atoi(cp);
783  if (max_e <= 0)
784  LOG(llevError, "load_settings: armor_max_enchant is %d\n", max_e);
785  else
786  settings.armor_max_enchant = max_e;
787  } else if (!strcasecmp(buf, "armor_weight_reduction")) {
788  int wr = atoi(cp);
789  if (wr < 0)
790  LOG(llevError, "load_settings: armor_weight_reduction is %d\n", wr);
791  else
793  } else if (!strcasecmp(buf, "armor_weight_linear")) {
794  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
796  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
798  } else {
799  LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
800  }
801 
802  } else if (!strcasecmp(buf, "armor_speed_improvement")) {
803  int wr = atoi(cp);
804  if (wr < 0)
805  LOG(llevError, "load_settings: armor_speed_improvement is %d\n", wr);
806  else
808  } else if (!strcasecmp(buf, "armor_speed_linear")) {
809  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
811  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
813  } else {
814  LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
815  }
816 
817  } else if (!strcasecmp(buf, "no_player_stealing")) {
818  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
820  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
822  } else {
823  LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp);
824  }
825 
826  } else if (!strcasecmp(buf, "create_home_portals")) {
827  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
829  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
831  } else {
832  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
833  }
834  } else if (!strcasecmp(buf, "personalized_blessings")) {
835  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
837  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
839  } else {
840  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
841  }
842  } else if (!strcasecmp(buf, "pk_max_experience")) {
843  sint64 pkme = atoll(cp);
844  if (pkme < 0)
845  pkme = -1;
847  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
848  int pkmep = atoi(cp);
849  if (pkmep < 0) {
850  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero\n", cp);
851  } else
853  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
854  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
856  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
858  } else {
859  LOG(llevError, "load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
860  }
861  } else if (!strcasecmp(buf, "allow_broken_converters")) {
862  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
864  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
866  } else {
867  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
868  }
869  } else if (!strcasecmp(buf, "log_timestamp")) {
870  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
872  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
874  } else {
875  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
876  }
877  } else if (!strcasecmp(buf, "log_timestamp_format")) {
880  } else {
881  LOG(llevError, "Unknown value in settings file: %s\n", buf);
882  }
883  }
884  close_and_delete(fp, comp);
885  if (settings.log_timestamp_format == NULL)
886  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
887 
888  /*
889  * The who formats are defined in config to be blank. They should have been
890  * overridden by the settings file, if there are no entries however, it will
891  * have stayed blank. Since this probably isn't what is wanted, we will check if
892  * new formats have been specified, and if not we will use the old defaults.
893  */
894  if (!strcmp(settings.who_format, ""))
895  strcpy(settings.who_format, "%N_%T%t%h%d%b%n<%m>");
896  if (!strcmp(settings.who_wiz_format, ""))
897  strcpy(settings.who_wiz_format, "%N_%T%t%h%d%b%nLevel %l <%m>(@%i)(%c)");
898 }
899 
905 void init(int argc, char **argv) {
906 
907  init_done = 0; /* Must be done before init_signal() */
908  logfile = stderr;
909  parse_args(argc, argv, 1); /* First arg pass - right now it does
910  * nothing, but in future specifying the
911  * LibDir in this pass would be reasonable*/
912 
913  init_library(); /* Must be called early */
914  load_settings(); /* Load the settings file */
915  load_materials();
916  parse_args(argc, argv, 2);
917  fprintf(logfile, "Welcome to CrossFire, v%s\n", FULL_VERSION);
918  fprintf(logfile, "Copyright (C) 1994 Mark Wedel.\n");
919  fprintf(logfile, "Copyright (C) 1992 Frank Tore Johansen.\n");
920 
921  if (strcmp(settings.dm_mail, "") != 0) {
922  fprintf(logfile, "Maintained locally by: %s\n", settings.dm_mail);
923  fprintf(logfile, "Questions and bugs should be mailed to above address.\n");
924  }
925  SRANDOM(time(NULL));
926 
927  init_startup(); /* Write (C), check shutdown/forbid files */
928  init_signals(); /* Sets up signal interceptions */
929  init_commands(); /* Sort command tables */
930  read_map_log(); /* Load up the old temp map files */
931  init_skills();
932  init_ob_methods();
933  cftimer_init();
934 
935  parse_args(argc, argv, 3);
936 
937 #ifndef WIN32 /* ***win32: no become_daemon in windows */
938  if (settings.daemonmode)
939  become_daemon();
940 #endif
941 
942  init_beforeplay();
943  init_server();
944  metaserver_init();
946  reset_sleep();
947  init_done = 1;
948 }
949 
955 void free_server(void) {
956  free_materials();
957  free_races();
958 }
959 
960 static void usage(void) {
961  (void)fprintf(logfile, "Usage: crossfire [-h] [-<flags>]...\n");
962 }
963 
964 static void help(void) {
965  /* The information in usage is redundant with what is given below, so why call it? */
966  /* usage();*/
967  printf("Flags:\n");
968  printf(" -csport <port> Specifies the port to use for the new client/server code.\n");
969  printf(" -d Turns on some debugging.\n");
970  printf(" +d Turns off debugging (useful if server compiled with debugging\n");
971  printf(" as default).\n");
972  printf(" -detach The server will go in the background, closing all\n");
973  printf(" connections to the tty.\n");
974  printf(" -h Display this information.\n");
975  printf(" -log <file> Specifies which file to send output to.\n");
976  printf(" Only has meaning if -detach is specified.\n");
977  printf(" -mon Turns on monster debugging.\n");
978  printf(" -o Prints out info on what was defined at compile time.\n");
979  printf(" -s Display the high-score list.\n");
980  printf(" -score <name or class> Displays all high scores with matching name/class.\n");
981  printf(" -v Print version and contributors.\n");
982  printf(" -conf Sets the configuration dir (settings, motd, etc.)\n");
983  printf(" -data Sets the lib dir (archetypes, treasures, etc.)\n");
984  printf(" -local Read/write local data (hiscore, unique items, etc.)\n");
985  printf(" -maps Sets the directory for maps.\n");
986  printf(" -arch Sets the archetype file to use.\n");
987  printf(" -regions Sets the regions file to use.\n");
988  printf(" -playerdir Sets the directory for the player files.\n");
989  printf(" -templatedir Sets the directory for template generate maps.\n");
990  printf(" -treasures Sets the treasures file to use.\n");
991  printf(" -uniquedir Sets the unique items/maps directory.\n");
992  printf(" -tmpdir Sets the directory for temporary files (mostly maps.)\n");
993  printf(" -m Lists out suggested experience for all monsters.\n");
994  printf(" -m2 Dumps out abilities.\n");
995  printf(" -m3 Dumps out artifact information.\n");
996  printf(" -m4 Dumps out spell information.\n");
997  printf(" -m5 Dumps out skill information.\n");
998  printf(" -m6 Dumps out race information.\n");
999  printf(" -m7 Dumps out alchemy information.\n");
1000  printf(" -m8 Dumps out gods information.\n");
1001  printf(" -m9 Dumps out more alchemy information (formula checking).\n");
1002  printf(" -mt <name> Dumps out list of treasures for a monster.\n");
1003  exit(0);
1004 }
1005 
1006 static void init_beforeplay(void) {
1007  init_archetypes(); /* If not called before, reads all archetypes from file */
1008  init_artifacts(); /* If not called before, reads all artifacts from file */
1009  check_spells(); /* If not called before, links archtypes used by spells */
1010  init_regions(); /* If not called before, reads all regions from file */
1011  init_archetype_pointers(); /* Setup global pointers to archetypes */
1012  init_races(); /* overwrite race designations using entries in lib/races file */
1013  init_gods(); /* init linked list of gods from archs*/
1014  init_readable(); /* inits useful arrays for readable texts */
1015  init_formulae(); /* If not called before, reads formulae from file */
1016 
1017  switch (settings.dumpvalues) {
1018  case 1:
1019  print_monsters();
1020  cleanup();
1021 
1022  case 2:
1023  dump_abilities();
1024  cleanup();
1025 
1026  case 3:
1027  dump_artifacts();
1028  cleanup();
1029 
1030  case 4:
1031  dump_spells();
1032  cleanup();
1033 
1034  case 5:
1035  cleanup();
1036 
1037  case 6:
1038  dump_races();
1039  cleanup();
1040 
1041  case 7:
1042  dump_alchemy();
1043  cleanup();
1044 
1045  case 8:
1046  dump_gods();
1047  cleanup();
1048 
1049  case 9:
1051  cleanup();
1052 
1053  case 10:
1055  cleanup();
1056  }
1057 }
1058 
1064 static void init_startup(void) {
1065  char buf[MAX_BUF];
1066  FILE *fp;
1067  int comp;
1068 
1069 #ifdef SHUTDOWN_FILE
1070  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1071  if ((fp = open_and_uncompress(buf, 0, &comp)) != NULL) {
1072  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1073  printf("%s", buf);
1074  close_and_delete(fp, comp);
1075  exit(1);
1076  }
1077 #endif
1078 
1079  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1080  LOG(llevError, "CrossFire: Playing not allowed.\n");
1081  exit(-1);
1082  }
1083 }
1084 
1091 static void compile_info(void) {
1092  int i = 0;
1093  char err[MAX_BUF];
1094 
1095  printf("Non-standard include files:\n");
1096 #if !defined(__STRICT_ANSI__) || defined(__sun__)
1097 #if !defined(Mips)
1098  printf("<stdlib.h>\n");
1099  i = 1;
1100 #endif
1101 #if !defined(MACH) && !defined(sony)
1102  printf("<malloc.h>\n");
1103  i = 1;
1104 #endif
1105 #endif
1106 #ifndef __STRICT_ANSI__
1107 #ifndef MACH
1108  printf("<memory.h\n");
1109  i = 1;
1110 #endif
1111 #endif
1112 #ifndef sgi
1113  printf("<sys/timeb.h>\n");
1114  i = 1;
1115 #endif
1116  if (!i)
1117  printf("(none)\n");
1118  printf("Datadir:\t\t%s\n", settings.datadir);
1119  printf("Localdir:\t\t%s\n", settings.localdir);
1120 #ifdef PERM_FILE
1121  printf("Perm file:\t<ETC>/%s\n", PERM_FILE);
1122 #endif
1123 #ifdef SHUTDOWN_FILE
1124  printf("Shutdown file:\t<ETC>/%s\n", SHUTDOWN_FILE);
1125 #endif
1126  printf("Save player:\t<true>\n");
1127  printf("Save mode:\t%4.4o\n", SAVE_MODE);
1128  printf("Playerdir:\t<VAR>/%s\n", settings.playerdir);
1129  printf("Itemsdir:\t<VAR>/%s\n", settings.uniquedir);
1130  printf("Tmpdir:\t\t%s\n", settings.tmpdir);
1131  printf("Map max timeout:\t%d\n", MAP_MAXTIMEOUT);
1132  printf("Max objects:\t%d\n", MAX_OBJECTS);
1133 #ifdef USE_CALLOC
1134  printf("Use_calloc:\t<true>\n");
1135 #else
1136  printf("Use_calloc:\t<false>\n");
1137 #endif
1138 
1139  printf("Max_time:\t%d\n", MAX_TIME);
1140 
1141 #ifdef WIN32 /* ***win32 compile_info(): remove execl... */
1142  printf("Logfilename:\t%s\n", settings.logfilename);
1143  exit(0);
1144 #else
1145  execl("/bin/uname", "uname", "-a", NULL);
1146  LOG(llevError, "Oops, shouldn't have gotten here: execl(/bin/uname) failed: %s\n", strerror_local(errno, err, sizeof(err)));
1147  exit(-1);
1148 #endif
1149 }
1150 
1151 /* Signal handlers: */
1152 
1158 static void rec_sigsegv(int i) {
1159  LOG(llevError, "\nSIGSEGV received.\n");
1160  fatal_signal(1);
1161 }
1162 
1168 static void rec_sigint(int i) {
1169  LOG(llevInfo, "\nSIGINT received.\n");
1170  fatal_signal(0);
1171 }
1172 
1185 static void rec_sighup(int i) {
1186  /* Don't call LOG(). It calls non-reentrant functions. The other
1187  * signal handlers shouldn't really call LOG() either. */
1188  if (logfile != stderr) {
1189  reopen_logfile = 1;
1190  }
1191 }
1192 
1199 static void rec_sigquit(int i) {
1200  LOG(llevInfo, "\nSIGQUIT received\n");
1201  fatal_signal(1);
1202 }
1203 
1217 static void rec_sigpipe(int i) {
1218  LOG(llevError, "\nSIGPIPE--------------\n------------\n--------\n---\n");
1219 #if 1 && !defined(WIN32) /* ***win32: we don't want send SIGPIPE */
1220  LOG(llevInfo, "\nReceived SIGPIPE, ignoring...\n");
1221  signal(SIGPIPE, rec_sigpipe);/* hocky-pux clears signal handlers */
1222 #else
1223  LOG(llevError, "\nSIGPIPE received, not ignoring...\n");
1224  fatal_signal(1); /*Might consider to uncomment this line */
1225 #endif
1226 }
1227 
1234 static void rec_sigbus(int i) {
1235 #ifdef SIGBUS
1236  LOG(llevError, "\nSIGBUS received\n");
1237  fatal_signal(1);
1238 #endif
1239 }
1240 
1247 static void rec_sigterm(int i) {
1248  LOG(llevInfo, "\nSIGTERM received\n");
1249  fatal_signal(0);
1250 }
1251 
1258 static void fatal_signal(int make_core) {
1259  if (init_done) {
1260  emergency_save(0);
1261  clean_tmp_files();
1262  }
1263  if (make_core)
1264  abort();
1265  exit(0);
1266 }
1267 
1271 static void init_signals(void) {
1272 #ifndef WIN32 /* init_signals() remove signals */
1273  struct sigaction sa;
1274 
1275  sa.sa_sigaction = NULL;
1276  sigemptyset(&sa.sa_mask);
1277  sa.sa_flags = 0;
1278  sa.sa_handler = rec_sighup;
1279  sigaction(SIGHUP, &sa, NULL);
1280  signal(SIGINT, rec_sigint);
1281 #ifndef DEBUG
1282  signal(SIGQUIT, rec_sigquit);
1283  signal(SIGSEGV, rec_sigsegv);
1284  LOG(llevInfo, "\n---------registering SIGPIPE\n");
1285  signal(SIGPIPE, rec_sigpipe);
1286 #ifdef SIGBUS
1287  signal(SIGBUS, rec_sigbus);
1288 #endif
1289  signal(SIGTERM, rec_sigterm);
1290 #endif
1291 #endif /* win32 */
1292 }
1293 
1300 static void init_races(void) {
1301  FILE *file;
1302  char race[MAX_BUF], fname[MAX_BUF], buf[MAX_BUF], *cp, variable[MAX_BUF];
1303  archetype *mon = NULL;
1304  static int init_done = 0;
1305 
1306  if (init_done)
1307  return;
1308  init_done = 1;
1309  first_race = NULL;
1310 
1311  snprintf(fname, sizeof(fname), "%s/races", settings.datadir);
1312  LOG(llevDebug, "Reading races from %s...\n", fname);
1313  if (!(file = fopen(fname, "r"))) {
1314  LOG(llevError, "Cannot open races file %s: %s\n", fname, strerror_local(errno, buf, sizeof(buf)));
1315  return;
1316  }
1317 
1318  while (fgets(buf, MAX_BUF, file) != NULL) {
1319  int set_race = 1, set_list = 1;
1320  if (*buf == '#')
1321  continue;
1322  if ((cp = strchr(buf, '\n')) != NULL)
1323  *cp = '\0';
1324  cp = buf;
1325  while (*cp == ' ' || *cp == '!' || *cp == '@') {
1326  if (*cp == '!')
1327  set_race = 0;
1328  if (*cp == '@')
1329  set_list = 0;
1330  cp++;
1331  }
1332  if (sscanf(cp, "RACE %s", variable)) { /* set new race value */
1333  strcpy(race, variable);
1334  } else {
1335  char *cp1;
1336 
1337  /* Take out beginning spaces */
1338  for (cp1 = cp; *cp1 == ' '; cp1++)
1339  ;
1340  /* Remove newline and trailing spaces */
1341  for (cp1 = cp+strlen(cp)-1; *cp1 == '\n' || *cp1 == ' '; cp1--) {
1342  *cp1 = '\0';
1343  if (cp == cp1)
1344  break;
1345  }
1346 
1347  if (cp[strlen(cp)-1] == '\n')
1348  cp[strlen(cp)-1] = '\0';
1349  /* set creature race to race value */
1350  if ((mon = find_archetype(cp)) == NULL)
1351  LOG(llevError, "Creature %s in race file lacks archetype\n", cp);
1352  else {
1353  if (set_race && (!mon->clone.race || strcmp(mon->clone.race, race))) {
1354  if (mon->clone.race) {
1355  LOG(llevDebug, " Resetting race to %s from %s for archetype %s\n", race, mon->clone.race, mon->name);
1356  free_string(mon->clone.race);
1357  }
1358  mon->clone.race = add_string(race);
1359  }
1360  /* if the arch is a monster, add it to the race list */
1361  if (set_list && QUERY_FLAG(&mon->clone, FLAG_MONSTER))
1362  add_to_racelist(race, &mon->clone);
1363  }
1364  }
1365  }
1366  fclose(file);
1367  LOG(llevDebug, "done races.\n");
1368 }
1369 
1373 static void dump_races(void) {
1374  racelink *list;
1375  objectlink *tmp;
1376 
1377  for (list = first_race; list; list = list->next) {
1378  fprintf(stderr, "\nRACE %s:\t", list->name);
1379  for (tmp = list->member; tmp; tmp = tmp->next)
1380  fprintf(stderr, "%s(%d), ", tmp->ob->arch->name, tmp->ob->level);
1381  }
1382  fprintf(stderr, "\n");
1383 }
1384 
1388 static void free_races(void) {
1389  racelink *race;
1390  objectlink *link;
1391 
1392  LOG(llevDebug, "Freeing race information.\n");
1393  while (first_race) {
1394  race = first_race->next;
1395  while (first_race->member) {
1396  link = first_race->member->next;
1397  free(first_race->member);
1398  first_race->member = link;
1399  }
1401  free(first_race);
1402  first_race = race;
1403  }
1404 }
1405 
1414 static void add_to_racelist(const char *race_name, object *op) {
1415  racelink *race;
1416 
1417  if (!op || !race_name)
1418  return;
1419  race = find_racelink(race_name);
1420 
1421  if (!race) { /* add in a new race list */
1422  race = get_racelist();
1423  race->next = first_race;
1424  first_race = race;
1425  race->name = add_string(race_name);
1426  }
1427 
1428  if (race->member->ob) {
1429  objectlink *tmp = get_objectlink();
1430 
1431  tmp->next = race->member;
1432  race->member = tmp;
1433  }
1434  race->nrof++;
1435  race->member->ob = op;
1436 }
1437 
1446 static racelink *get_racelist(void) {
1447  racelink *list;
1448 
1449  list = (racelink *)malloc(sizeof(racelink));
1450  if (!list)
1452  list->name = NULL;
1453  list->nrof = 0;
1454  list->member = get_objectlink();
1455  list->next = NULL;
1456 
1457  return list;
1458 }
1459 
1468 racelink *find_racelink(const char *name) {
1469  racelink *test = NULL;
1470 
1471  if (name && first_race)
1472  for (test = first_race; test && test != test->next; test = test->next)
1473  if (!test->name || !strcmp(name, test->name))
1474  break;
1475 
1476  return test;
1477 }
EXTERN FILE * logfile
Definition: global.h:220
static void set_dumpmon2(void)
Definition: init.c:89
void clean_tmp_files(void)
Definition: standalone.c:194
uint8 spell_encumbrance
Definition: global.h:356
signed char sint8
Definition: global.h:80
archetype * find_archetype(const char *name)
Definition: arch.c:700
static void set_dumpmon8(void)
Definition: init.c:113
static void rec_sigpipe(int i)
Definition: init.c:1217
uint32 worldmapstarty
Definition: global.h:381
uint32 worldmapstartx
Definition: global.h:380
#define FALSE
Definition: exp.c:42
#define OUT_OF_MEMORY
Definition: define.h:94
char meta_host[MAX_BUF]
Definition: global.h:376
signed short sint16
Definition: global.h:72
uint8 dumpvalues
Definition: global.h:328
Definition: object.h:298
static void free_materials(void)
Definition: init.c:481
const char * race
Definition: object.h:171
static void set_dumpmon7(void)
Definition: init.c:109
static void rec_sigsegv(int i)
Definition: init.c:1158
uint32 worldmaptilesx
Definition: global.h:382
const char * name
Definition: material.h:63
unsigned int meta_on
Definition: global.h:374
static void set_mondebug(void)
Definition: init.c:81
void dump_artifacts(void)
Definition: treasure.c:1446
static struct Command_Line_Options options[]
Definition: init.c:234
void print_monsters(void)
Definition: info.c:71
uint8 death_penalty_ratio
Definition: global.h:347
uint8 recycle_tmp_maps
Definition: global.h:360
Definition: race.h:12
char who_wiz_format[MAX_BUF]
Definition: global.h:365
static void set_dumpmon1(void)
Definition: init.c:85
uint8 fastclock
Definition: global.h:386
int nrof
Definition: race.h:14
char motd[MAX_BUF]
Definition: global.h:366
int forbid_play(void)
Definition: server.c:1296
static void set_csport(const char *val)
Definition: init.c:192
object * mon
Definition: comet_perf.c:74
uint8 casting_time
Definition: global.h:358
const char * playerdir
Definition: global.h:336
void free_string(sstring str)
Definition: shstr.c:272
static void unset_debug(void)
Definition: init.c:77
static void rec_sigbus(int i)
Definition: init.c:1234
void(* cmdlinefunc_args1)(const char *arg1)
Definition: init.c:207
int reopen_logfile
Definition: logger.c:6
object clone
Definition: object.h:326
uint8 set_title
Definition: global.h:353
const char * regions
Definition: global.h:339
int allow_broken_converters
Definition: global.h:405
void init_archetypes(void)
Definition: arch.c:195
int armor_max_enchant
Definition: global.h:394
static void fatal_signal(int make_core)
Definition: init.c:1258
uint8 spellpoint_level_depend
Definition: global.h:362
static void parse_args(int argc, char *argv[], int pass)
Definition: init.c:304
void dump_gods(void)
Definition: holy.c:161
uint32 worldmaptilesizey
Definition: global.h:385
int material
Definition: material.h:65
void init_library(void)
Definition: init.c:201
void close_and_delete(FILE *fp, int compressed)
Definition: porting.c:748
void dump_experience(void)
Definition: exp.c:257
uint32 worldmaptilesy
Definition: global.h:383
LogLevel debug
Definition: global.h:327
#define PERM_FILE
Definition: config.h:503
uint8 search_items
Definition: global.h:355
static void set_playerdir(const char *path)
Definition: init.c:169
void(* cmdlinefunc_args0)(void)
Definition: init.c:206
uint8 no_player_stealing
Definition: global.h:399
char meta_server[MAX_BUF]
Definition: global.h:375
static void set_datadir(const char *path)
Definition: init.c:133
void(* func)()
Definition: init.c:220
uint8 balanced_stat_loss
Definition: global.h:349
uint8 explore_mode
Definition: global.h:361
const char * treasures
Definition: global.h:340
Definition: object.h:321
racelink * find_racelink(const char *name)
Definition: init.c:1468
const char * logfilename
Definition: global.h:325
uint8 not_permadeth
Definition: global.h:350
void dump_alchemy_costs(void)
Definition: recipe.c:495
static void set_localdir(const char *path)
Definition: init.c:141
char meta_comment[MAX_BUF]
Definition: global.h:378
sint8 magic
Definition: material.h:70
static void set_mapdir(const char *path)
Definition: init.c:145
void cleanup(void)
Definition: server.c:1196
void version(object *op)
Definition: server.c:81
static void rec_sigterm(int i)
Definition: init.c:1247
uint8 daemonmode
Definition: global.h:330
void init_formulae(void)
Definition: recipe.c:159
static void add_to_racelist(const char *race_name, object *op)
Definition: init.c:1414
uint8 resurrection
Definition: global.h:354
object * ob
Definition: object.h:299
materialtype_t * materialt
Definition: init.c:345
static void set_dumpmon4(void)
Definition: init.c:97
void init_server(void)
Definition: init.c:173
struct oblnk * member
Definition: race.h:15
struct ralnk * next
Definition: race.h:16
char * log_timestamp_format
Definition: global.h:408
int armor_speed_improvement
Definition: global.h:397
void init(int argc, char **argv)
Definition: init.c:905
const char * dumparg
Definition: global.h:329
uint8 spell_failure_effects
Definition: global.h:357
void become_daemon(void)
Definition: daemon.c:72
static void usage(void)
Definition: init.c:960
uint8 create_home_portals
Definition: global.h:400
void free_server(void)
Definition: init.c:955
static void init_signals(void)
Definition: init.c:1271
uint8 stat_loss_on_death
Definition: global.h:344
sint16 pk_luck_penalty
Definition: global.h:345
const char * tmpdir
Definition: global.h:343
void service_unregister()
Definition: win32.c:266
static void rec_sigquit(int i)
Definition: init.c:1199
static void init_startup(void)
Definition: init.c:1064
void dump_alchemy(void)
Definition: recipe.c:293
static void load_settings(void)
Definition: init.c:497
void read_map_log(void)
Definition: swap.c:83
static void set_dumpmon3(void)
Definition: init.c:93
const char * cmd_option
Definition: init.c:217
#define MAX_TIME
Definition: config.h:221
static void load_materials(void)
Definition: init.c:385
static void set_tmpdir(const char *path)
Definition: init.c:173
void fatal(int err)
Definition: glue.c:60
#define TRUE
Definition: exp.c:41
#define MAP_MAXTIMEOUT
Definition: config.h:412
static void help(void)
Definition: init.c:964
unsigned char uint8
Definition: global.h:75
EXTERN racelink * first_race
Definition: global.h:198
static void showscores(void)
Definition: init.c:68
void cftimer_init(void)
Definition: timers.c:166
const char * templatedir
Definition: global.h:342
static void set_templatedir(const char *path)
Definition: init.c:165
static void set_archetypes(const char *path)
Definition: init.c:149
const char * archetypes
Definition: global.h:338
static void compile_info(void)
Definition: init.c:1091
static void set_treasures(const char *path)
Definition: init.c:157
#define QUERY_FLAG(xyz, p)
Definition: define.h:514
char * strdup_local(const char *str)
Definition: porting.c:310
void emergency_save(int flag)
Definition: standalone.c:191
void init_readable(void)
Definition: readable.c:952
static void showscoresparm(const char *data)
Definition: init.c:181
sint8 save[NROFATTACKS]
Definition: material.h:66
#define MAX_BUF
Definition: define.h:81
static void set_logfile(char *val)
Definition: init.c:59
static void set_confdir(const char *path)
Definition: init.c:137
uint32 worldmaptilesizex
Definition: global.h:384
char who_format[MAX_BUF]
Definition: global.h:364
static char default_daemon_log[]
Definition: init.c:57
static void dump_races(void)
Definition: init.c:1373
void reset_sleep(void)
Definition: time.c:141
sint8 difficulty
Definition: material.h:69
const char * confdir
Definition: global.h:333
#define MAX_OBJECTS
Definition: config.h:447
const char * uniquedir
Definition: global.h:341
static void set_dumpmont(const char *name)
Definition: init.c:121
static void set_regions(const char *path)
Definition: init.c:153
uint16 meta_port
Definition: global.h:377
int log_timestamp
Definition: global.h:407
const char * datadir
Definition: global.h:334
void dump_spells(void)
Definition: spell_util.c:157
int snprintf(char *dest, int max, const char *format,...)
Definition: porting.c:498
void check_spells(void)
Definition: spell_util.c:120
sint8 wc
Definition: material.h:72
sint8 ac
Definition: material.h:73
int armor_weight_reduction
Definition: global.h:395
void dump_abilities(void)
Definition: info.c:40
static void set_debug(void)
Definition: init.c:73
static void set_dumpmon9(void)
Definition: init.c:117
uint8 armor_weight_linear
Definition: global.h:396
const char * localdir
Definition: global.h:335
uint8 death_penalty_level
Definition: global.h:348
struct archt * arch
Definition: object.h:263
struct oblnk * next
Definition: object.h:300
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
Definition: init.c:208
void dump_monster_treasure(const char *name)
Definition: treasure.c:1515
const char * name
Definition: race.h:13
const char * mapdir
Definition: global.h:337
struct Settings settings
Definition: init.c:48
static void init_beforeplay(void)
Definition: init.c:1006
void service_handle()
Definition: win32.c:384
#define SAVE_MODE
Definition: config.h:634
sint8 mod[NROFATTACKS]
Definition: material.h:67
char dm_mail[MAX_BUF]
Definition: global.h:369
#define NROFATTACKS
Definition: attack.h:45
void init_gods(void)
Definition: holy.c:63
void init_commands(void)
Definition: commands.c:293
void init_regions(void)
Definition: region.c:301
void service_register()
Definition: win32.c:221
sstring add_string(const char *str)
Definition: shstr.c:116
uint16 csport
Definition: global.h:326
static void call_version(void)
Definition: init.c:63
int strcasecmp(const char *s1, const char *s2)
Definition: porting.c:434
static void init_races(void)
Definition: init.c:1300
#define FLAG_MONSTER
Definition: define.h:541
EXTERN long init_done
Definition: global.h:210
uint8 personalized_blessings
Definition: global.h:401
uint8 permanent_exp_ratio
Definition: global.h:346
static void free_races(void)
Definition: init.c:1388
void display_high_score(object *op, int max, const char *match)
Definition: hiscore.c:402
uint16 set_friendly_fire
Definition: global.h:363
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:63
static void set_daemon(void)
Definition: init.c:126
static void set_dumpmon5(void)
Definition: init.c:101
void metaserver_init(void)
Definition: metaserver.c:68
struct _materialtype * next
Definition: material.h:77
static void rec_sighup(int i)
Definition: init.c:1185
#define FULL_VERSION
Definition: version.h:6
int metaserver2_init(void)
Definition: metaserver.c:255
static void rec_sigint(int i)
Definition: init.c:1168
sint8 chance
Definition: material.h:68
int allow_denied_spells_writing
Definition: global.h:404
#define SHUTDOWN_FILE
Definition: config.h:512
char * strerror_local(int errnum, char *buf, size_t size)
Definition: porting.c:525
sint64 pk_max_experience
Definition: global.h:402
static void set_uniquedir(const char *path)
Definition: init.c:161
int pk_max_experience_percent
Definition: global.h:403
sint16 level
Definition: object.h:202
void init_archetype_pointers(void)
Definition: treasure.c:66
uint8 real_wiz
Definition: global.h:359
sint8 damage
Definition: material.h:71
FILE * open_and_uncompress(const char *name, int flag, int *compressed)
Definition: porting.c:724
void init_ob_methods(void)
Definition: ob_methods.c:49
float item_power_factor
Definition: global.h:392
const char * name
Definition: object.h:322
uint8 armor_speed_linear
Definition: global.h:398
static void set_dumpmon6(void)
Definition: init.c:105
sint8 sp
Definition: material.h:74
void init_artifacts(void)
Definition: treasure.c:1539
static materialtype_t * get_empty_mat(void)
Definition: init.c:355
uint8 simple_exp
Definition: global.h:351
void init_skills(void)
Definition: skill_util.c:71
const char * description
Definition: material.h:64
static racelink * get_racelist(void)
Definition: init.c:1446