Crossfire Server, Trunk
init.c
Go to the documentation of this file.
1 /*
2  * Crossfire -- cooperative multi-player graphical RPG and adventure game
3  *
4  * Copyright (c) 1999-2014 Mark Wedel and the Crossfire Development Team
5  * Copyright (c) 1992 Frank Tore Johansen
6  *
7  * Crossfire is free software and comes with ABSOLUTELY NO WARRANTY. You are
8  * welcome to redistribute it under certain conditions. For details, please
9  * see COPYING and LICENSE.
10  *
11  * The authors can be reached via e-mail at <crossfire@metalforge.org>.
12  */
13 
19 #include "global.h"
20 
21 #include <errno.h>
22 #include <signal.h>
23 #include <stdlib.h>
24 #include <string.h>
25 
26 /* Needed for strcasecmp(). */
27 #ifndef WIN32
28 #include <strings.h>
29 #endif
30 
31 #include "loader.h"
32 #include "version.h"
33 #include "server.h"
34 #include "sproto.h"
35 #include "assets.h"
36 #include "modules.h"
37 
38 static void help(void);
39 static void init_beforeplay(void);
40 static void init_startup(void);
41 
43 static int should_exit = 0;
44 
45 typedef struct module_information {
46  const char *name;
47  char const *description;
48  bool enabled;
49  void (*init)();
50  void (*close)();
52 
55  { "citybell", "Ring bells every hour for defined temples", true, cfcitybell_init, cfcitybell_close },
56  { "citylife", "Add NPCs in towns", true, citylife_init, citylife_close },
57  { "rhg", "Add random maps to exits in towns", false, random_house_generator_init, random_house_generator_close },
58  { NULL, NULL, false, NULL, NULL }
59 };
60 
64 void init_modules() {
65  LOG(llevInfo, "Initializing modules\n");
66  for (int module = 0; modules[module].name != NULL; module++) {
67  module_information *mod = &modules[module];
68  if (!mod->enabled) {
69  LOG(llevInfo, " %s (%s): disabled\n", mod->name, mod->description);
70  } else {
71  mod->init(&settings);
72  LOG(llevInfo, " %s (%s): activated\n", mod->name, mod->description);
73  }
74  }
75 }
76 
80 void close_modules() {
81  LOG(llevInfo, "Cleaning modules\n");
82  for (int module = 0; modules[module].name != NULL; module++) {
83  module_information *mod = &modules[module];
84  if (mod->enabled) {
85  mod->close(&settings);
86  LOG(llevInfo, " %s (%s): closed\n", mod->name, mod->description);
87  }
88  }
89 }
90 
94 static void list_modules() {
95  LOG(llevInfo, "Built-in modules:\n");
96  for (int module = 0; modules[module].name != NULL; module++) {
97  LOG(llevInfo, " %s: %s -> %s\n", modules[module].name, modules[module].description, modules[module].enabled ? "enabled" : "disabled");
98  }
99  should_exit = 1;
100 }
101 
106 static void set_logfile(char *val) {
107  settings.logfilename = val;
108 }
109 
111 static void call_version(void) {
112  puts(FULL_VERSION);
113  exit(EXIT_SUCCESS);
114 }
115 
117 static void set_debug(void) {
119 }
120 
122 static void unset_debug(void) {
124 }
125 
127 static void set_mondebug(void) {
129 }
130 
132 static void set_dumpmon1(void) {
133  settings.dumpvalues = 1;
134 }
135 
137 static void set_dumpmon2(void) {
138  settings.dumpvalues = 2;
139 }
140 
142 static void set_dumpmon3(void) {
143  settings.dumpvalues = 3;
144 }
145 
147 static void set_dumpmon4(void) {
148  settings.dumpvalues = 4;
149 }
150 
152 static void set_dumpmon5(void) {
153  settings.dumpvalues = 5;
154 }
155 
157 static void set_dumpmon6(void) {
158  settings.dumpvalues = 6;
159 }
160 
162 static void set_dumpmon7(void) {
163  settings.dumpvalues = 7;
164 }
165 
167 static void set_dumpmon8(void) {
168  settings.dumpvalues = 8;
169 }
170 
172 static void set_dumpmon9(void) {
173  settings.dumpvalues = 9;
174 }
175 
180 static void set_dumpmont(const char *name) {
181  settings.dumpvalues = 10;
183 }
184 
189 static void set_datadir(const char *path) {
191 }
192 
197 static void set_confdir(const char *path) {
199 }
200 
205 static void set_localdir(const char *path) {
207 }
208 
213 static void set_mapdir(const char *path) {
214  settings.mapdir = path;
215 }
216 
221 static void set_regions(const char *path) {
223 }
224 
229 static void set_uniquedir(const char *path) {
231 }
232 
237 static void set_templatedir(const char *path) {
239 }
240 
245 static void set_playerdir(const char *path) {
247 }
248 
253 static void set_tmpdir(const char *path) {
254  settings.tmpdir = path;
255 }
256 
262 }
263 
264 static void server_pack_assets(const char *assets, const char *filename) {
265  assets_pack(assets, filename);
266  should_exit = 1;
267 }
268 
269 static void free_materials(void);
270 
277 static void set_csport(const char *val) {
278  int port = atoi(val);
279  if (port <= 0 || port > 65535) {
280  LOG(llevError, "%d is an invalid csport number, must be between 1 and 65535.\n", port);
281  exit(1);
282  }
283  settings.csport = port;
284 }
285 
290 static void set_disable_plugin(const char *name) {
291  linked_char *disable = calloc(1, sizeof(linked_char));
292  disable->next = settings.disabled_plugins;
293  disable->name = strdup(name);
294  settings.disabled_plugins = disable;
295 }
296 
303 static void do_module(const char *name, bool enabled) {
304  bool one = false;
305  for (int module = 0; modules[module].name; module++) {
306  if (strcmp("All", name) == 0 || strcmp(modules[module].name, name) == 0) {
307  modules[module].enabled = enabled;
308  one = true;
309  }
310  }
311  if (!one) {
312  LOG(llevError, "Invalid module name %s\n", name);
314  }
315 }
316 
321 static void set_disable_module(const char *name) {
322  do_module(name, false);
323 }
324 
329 static void set_enable_module(const char *name) {
330  do_module(name, true);
331 }
332 
336 static void server_dump_animations(void) {
337  dump_animations();
338  cleanup();
339 }
340 
344 static void server_dump_faces(void) {
345  dump_faces();
346  cleanup();
347 }
348 
352 typedef void (*cmdlinefunc_args1)(const char* arg1);
353 typedef void (*cmdlinefunc_args2)(const char* arg1, const char* arg2);
362  const char *cmd_option;
363  uint8_t num_args;
364  uint8_t pass;
365  void (*func)();
369 };
370 
379 static struct Command_Line_Options options[] = {
383  { "-conf", 1, 1, set_confdir },
384  { "-d", 0, 1, set_debug },
385  { "-data", 1, 1, set_datadir },
386  { "-disable-plugin", 1, 1, set_disable_plugin },
387  { "-disable-module", 1, 1, set_disable_module },
388  { "-enable-module", 1, 1, set_enable_module },
389  { "-list-modules", 0, 1, list_modules },
390  { "-h", 0, 1, help },
391  { "-ignore-assets-errors", 0, 1, set_ignore_assets_errors },
392  { "-local", 1, 1, set_localdir },
393  { "-log", 1, 1, set_logfile },
394  { "-maps", 1, 1, set_mapdir },
395  { "-mon", 0, 1, set_mondebug },
396  { "-n", 0, 1, unset_debug },
397  { "-playerdir", 1, 1, set_playerdir },
398  { "-regions", 1, 1, set_regions },
399  { "-templatedir", 1, 1, set_templatedir },
400  { "-tmpdir", 1, 1, set_tmpdir },
401  { "-uniquedir", 1, 1, set_uniquedir },
402  { "-v", 0, 1, call_version },
403 
404 #ifdef WIN32
405  /* Windows service stuff */
406  { "-regsrv", 0, 1, service_register },
407  { "-unregsrv", 0, 1, service_unregister },
408  { "-srv", 0, 1, service_handle },
409 #endif
410 
414  { "-p", 1, 2, set_csport },
415 
419  { "-m", 0, 3, set_dumpmon1 },
420  { "-m2", 0, 3, set_dumpmon2 },
421  { "-m3", 0, 3, set_dumpmon3 },
422  { "-m4", 0, 3, set_dumpmon4 },
423  { "-m5", 0, 3, set_dumpmon5 },
424  { "-m6", 0, 3, set_dumpmon6 },
425  { "-m7", 0, 3, set_dumpmon7 },
426  { "-m8", 0, 3, set_dumpmon8 },
427  { "-m9", 0, 3, set_dumpmon9 },
428  { "-mt", 1, 3, set_dumpmont },
429  { "-mexp", 0, 3, dump_experience },
430  { "-mq", 0, 3, dump_quests },
431  { "-dump-anims", 0, 3, server_dump_animations },
432  { "-dump-faces", 0, 3, server_dump_faces },
433  { "-pack-assets", 2, 3, server_pack_assets },
434 };
435 
450 static void parse_args(int argc, char *argv[], int pass) {
451  size_t i;
452  int on_arg = 1;
453 
454  while (on_arg < argc) {
455  for (i = 0; i < sizeof(options)/sizeof(struct Command_Line_Options); i++) {
456  if (!strcmp(options[i].cmd_option, argv[on_arg])) {
457  /* Found a matching option, but should not be processed on
458  * this pass. Just skip over it
459  */
460  if (options[i].pass != pass) {
461  on_arg += options[i].num_args+1;
462  break;
463  }
464  if (options[i].num_args) {
465  if ((on_arg+options[i].num_args) >= argc) {
466  fprintf(stderr, "%s requires an argument.\n", options[i].cmd_option);
467  exit(1);
468  }
469 
470  if (options[i].num_args == 1)
471  ((cmdlinefunc_args1)options[i].func)(argv[on_arg+1]);
472  if (options[i].num_args == 2)
473  ((cmdlinefunc_args2)options[i].func)(argv[on_arg+1], argv[on_arg+2]);
474  on_arg += options[i].num_args+1;
475  } else { /* takes no args */
477  on_arg++;
478  }
479  break;
480  }
481  }
482  if (i == sizeof(options)/sizeof(struct Command_Line_Options)) {
483  fprintf(stderr, "Unknown option: %s\n", argv[on_arg]);
484  fprintf(stderr, "Type '%s -h' for usage.\n", argv[0]);
485  exit(1);
486  }
487  }
488 
489  if (should_exit) {
490  cleanup();
491  }
492 }
493 
503  materialtype_t *mt;
504  int i;
505 
506  mt = (materialtype_t *)malloc(sizeof(materialtype_t));
507  if (mt == NULL)
509  mt->name = NULL;
510  mt->description = NULL;
511  for (i = 0; i < NROFATTACKS; i++) {
512  mt->save[i] = 0;
513  mt->mod[i] = 0;
514  }
515  mt->next = NULL;
516  return mt;
517 }
518 
523 static void load_materials(BufferReader *reader, const char *filename) {
524  char *buf, *cp, *next;
525  materialtype_t *mt;
526  int i, value;
527  (void)filename;
528 
529  mt = get_empty_mat();
530  if (!materialt) {
531  materialt = mt;
532  } else {
534  while (a->next != NULL) {
535  a = a->next;
536  }
537  a->next = mt;
538  }
539 
540  while ((buf = bufferreader_next_line(reader)) != NULL) {
541  if (*buf == '#')
542  continue;
543  cp = buf;
544  while (*cp == ' ') /* Skip blanks */
545  cp++;
546  if (!strncmp(cp, "name", 4)) {
547  /* clean up the previous entry */
548  if (mt->next != NULL) {
549  if (mt->description == NULL)
550  mt->description = add_string(mt->name);
551  mt = mt->next;
552  }
553  mt->next = get_empty_mat();
554  mt->name = add_string(strchr(cp, ' ')+1);
555  } else if (!strncmp(cp, "description", 11)) {
556  mt->description = add_string(strchr(cp, ' ')+1);
557  } else if (sscanf(cp, "material %d", &value)) {
558  mt->material = value;
559  } else if (!strncmp(cp, "saves", 5)) {
560  cp = strchr(cp, ' ')+1;
561  for (i = 0; i < NROFATTACKS; i++) {
562  if (cp == NULL) {
563  mt->save[i] = 0;
564  continue;
565  }
566  if ((next = strchr(cp, ',')) != NULL)
567  *(next++) = '\0';
568  sscanf(cp, "%d", &value);
569  mt->save[i] = (int8_t)value;
570  cp = next;
571  }
572  } else if (!strncmp(cp, "mods", 4)) {
573  cp = strchr(cp, ' ')+1;
574  for (i = 0; i < NROFATTACKS; i++) {
575  if (cp == NULL) {
576  mt->save[i] = 0;
577  continue;
578  }
579  if ((next = strchr(cp, ',')) != NULL)
580  *(next++) = '\0';
581  sscanf(cp, "%d", &value);
582  mt->mod[i] = (int8_t)value;
583  cp = next;
584  }
585  }
586  }
587  free(mt->next);
588  mt->next = NULL;
589  LOG(llevDebug, "loaded material type data\n");
590 }
591 
595 static void free_materials(void) {
597 
598  while (materialt) {
599  next = materialt->next;
600  free(materialt);
601  materialt = next;
602  }
603  materialt = NULL;
604 }
605 
611 static void load_settings(void) {
612  char buf[MAX_BUF], *cp, dummy[1];
613  int has_val;
614  FILE *fp;
615 
616  dummy[0] = '\0';
617  snprintf(buf, sizeof(buf), "%s/settings", settings.confdir);
618 
619  /* We don't require a settings file at current time, but down the road,
620  * there will probably be so many values that not having a settings file
621  * will not be a good thing.
622  */
623  if ((fp = fopen(buf, "r")) == NULL) {
624  LOG(llevError, "Warning: No settings file found\n");
625  return;
626  }
627  while (fgets(buf, MAX_BUF-1, fp) != NULL) {
628  if (buf[0] == '#')
629  continue;
630  /* eliminate newline */
631  if ((cp = strrchr(buf, '\n')) != NULL)
632  *cp = '\0';
633 
634  /* Skip over empty lines */
635  if (buf[0] == 0)
636  continue;
637 
638  /* Skip all the spaces and set them to nulls. If not space,
639  * set cp to "" to make strcpy's and the like easier down below.
640  */
641  if ((cp = strchr(buf, ' ')) != NULL) {
642  while (*cp == ' ')
643  *cp++ = 0;
644  has_val = 1;
645  } else {
646  cp = dummy;
647  has_val = 0;
648  }
649 
650  if (!strcasecmp(buf, "metaserver_notification")) {
651  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
653  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
655  } else {
656  LOG(llevError, "load_settings: Unknown value for metaserver_notification: %s\n", cp);
657  }
658  } else if (!strcasecmp(buf, "metaserver_server")) {
659  if (has_val)
661  else
662  LOG(llevError, "load_settings: metaserver_server must have a value.\n");
663  } else if (!strcasecmp(buf, "motd")) {
664  if (has_val)
665  safe_strncpy(settings.motd, cp, sizeof(settings.motd));
666  else
667  LOG(llevError, "load_settings: motd must have a value.\n");
668  } else if (!strcasecmp(buf, "metaserver_host")) {
669  if (has_val)
671  else
672  LOG(llevError, "load_settings: metaserver_host must have a value.\n");
673  } else if (!strcasecmp(buf, "port")) {
674  set_csport(cp);
675  } else if (!strcasecmp(buf, "metaserver_port")) {
676  int port = atoi(cp);
677 
678  if (port < 1 || port > 65535)
679  LOG(llevError, "load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
680  else
681  settings.meta_port = port;
682  } else if (!strcasecmp(buf, "metaserver_comment")) {
684  } else if (!strcasecmp(buf, "worldmapstartx")) {
685  int size = atoi(cp);
686 
687  if (size < 0)
688  LOG(llevError, "load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
689  else
690  settings.worldmapstartx = size;
691  } else if (!strcasecmp(buf, "worldmapstarty")) {
692  int size = atoi(cp);
693 
694  if (size < 0)
695  LOG(llevError, "load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
696  else
697  settings.worldmapstarty = size;
698  } else if (!strcasecmp(buf, "worldmaptilesx")) {
699  int size = atoi(cp);
700 
701  if (size < 1)
702  LOG(llevError, "load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
703  else
704  settings.worldmaptilesx = size;
705  } else if (!strcasecmp(buf, "worldmaptilesy")) {
706  int size = atoi(cp);
707 
708  if (size < 1)
709  LOG(llevError, "load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
710  else
711  settings.worldmaptilesy = size;
712  } else if (!strcasecmp(buf, "worldmaptilesizex")) {
713  int size = atoi(cp);
714 
715  if (size < 1)
716  LOG(llevError, "load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
717  else
719  } else if (!strcasecmp(buf, "worldmaptilesizey")) {
720  int size = atoi(cp);
721 
722  if (size < 1)
723  LOG(llevError, "load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
724  else
726  } else if (!strcasecmp(buf, "fastclock")) {
727  int lev = atoi(cp);
728 
729  if (lev < 0)
730  LOG(llevError, "load_settings: fastclock must be at least 0, %d is invalid\n", lev);
731  else
732  settings.fastclock = lev;
733  } else if (!strcasecmp(buf, "not_permadeth")) {
734  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
736  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
738  } else {
739  LOG(llevError, "load_settings: Unknown value for not_permadeth: %s\n", cp);
740  }
741  } else if (!strcasecmp(buf, "resurrection")) {
742  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
744  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
746  } else {
747  LOG(llevError, "load_settings: Unknown value for resurrection: %s\n", cp);
748  }
749  } else if (!strcasecmp(buf, "set_title")) {
750  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
752  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
754  } else {
755  LOG(llevError, "load_settings: Unknown value for set_title: %s\n", cp);
756  }
757  } else if (!strcasecmp(buf, "search_items")) {
758  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
760  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
762  } else {
763  LOG(llevError, "load_settings: Unknown value for search_items: %s\n", cp);
764  }
765  } else if (!strcasecmp(buf, "spell_encumbrance")) {
766  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
768  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
770  } else {
771  LOG(llevError, "load_settings: Unknown value for spell_encumbrance: %s\n", cp);
772  }
773  } else if (!strcasecmp(buf, "spell_failure_effects")) {
774  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
776  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
778  } else {
779  LOG(llevError, "load_settings: Unknown value for spell_failure_effects: %s\n", cp);
780  }
781  } else if (!strcasecmp(buf, "casting_time")) {
782  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
784  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
786  } else {
787  LOG(llevError, "load_settings: Unknown value for casting_time: %s\n", cp);
788  }
789  } else if (!strcasecmp(buf, "real_wiz")) {
790  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
792  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
794  } else {
795  LOG(llevError, "load_settings: Unknown value for real_wiz: %s\n", cp);
796  }
797  } else if (!strcasecmp(buf, "recycle_tmp_maps")) {
798  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
800  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
802  } else {
803  LOG(llevError, "load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
804  }
805  } else if (!strcasecmp(buf, "always_show_hp")) {
806  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
808  } else if (!strcasecmp(cp, "damaged")) {
810  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
812  } else {
813  LOG(llevError, "load_settings: Unknown value for always_show_hp: %s\n", cp);
814  }
815  } else if (!strcasecmp(buf, "who_format")) {
816  if (has_val)
818  sizeof(settings.who_format));
819  } else if (!strcasecmp(buf, "who_wiz_format")) {
820  if (has_val) {
822  sizeof(settings.who_wiz_format));
823  }
824  } else if (!strcasecmp(buf, "spellpoint_level_depend")) {
825  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
827  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
829  } else {
830  LOG(llevError, "load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
831  }
832  } else if (!strcasecmp(buf, "stat_loss_on_death")) {
833  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
835  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
837  } else {
838  LOG(llevError, "load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
839  }
840  } else if (!strcasecmp(buf, "use_permanent_experience")) {
841  LOG(llevError, "use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
842  } else if (!strcasecmp(buf, "permanent_experience_percentage")) {
843  int val = atoi(cp);
844  if (val < 0 || val > 100)
845  LOG(llevError, "load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
846  else
848  } else if (!strcasecmp(buf, "death_penalty_percentage")) {
849  int val = atoi(cp);
850  if (val < 0 || val > 100)
851  LOG(llevError, "load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
852  else
854  } else if (!strcasecmp(buf, "death_penalty_levels")) {
855  int val = atoi(cp);
856  if (val < 0 || val > 255)
857  LOG(llevError, "load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
858  else
860  } else if (!strcasecmp(buf, "balanced_stat_loss")) {
861  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
863  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
865  } else {
866  LOG(llevError, "load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
867  }
868  } else if (!strcasecmp(buf, "simple_exp")) {
869  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
871  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
873  } else {
874  LOG(llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
875  }
876  } else if (!strcasecmp(buf, "item_power_factor")) {
877  float tmp = atof(cp);
878  if (tmp < 0)
879  LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
880  else
882  } else if (!strcasecmp(buf, "pk_luck_penalty")) {
883  int16_t val = atoi(cp);
884 
885  if (val < -100 || val > 100)
886  LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
887  else
889  } else if (!strcasecmp(buf, "set_friendly_fire")) {
890  int val = atoi(cp);
891 
892  if (val < 1 || val > 100)
893  LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
894  else
896  } else if (!strcasecmp(buf, "armor_max_enchant")) {
897  int max_e = atoi(cp);
898  if (max_e <= 0)
899  LOG(llevError, "load_settings: armor_max_enchant is %d\n", max_e);
900  else
901  settings.armor_max_enchant = max_e;
902  } else if (!strcasecmp(buf, "armor_weight_reduction")) {
903  int wr = atoi(cp);
904  if (wr < 0)
905  LOG(llevError, "load_settings: armor_weight_reduction is %d\n", wr);
906  else
908  } else if (!strcasecmp(buf, "armor_weight_linear")) {
909  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
911  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
913  } else {
914  LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
915  }
916  } else if (!strcasecmp(buf, "armor_speed_improvement")) {
917  int wr = atoi(cp);
918  if (wr < 0)
919  LOG(llevError, "load_settings: armor_speed_improvement is %d\n", wr);
920  else
922  } else if (!strcasecmp(buf, "armor_speed_linear")) {
923  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
925  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
927  } else {
928  LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
929  }
930  } else if (!strcasecmp(buf, "no_player_stealing")) {
931  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
933  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
935  } else {
936  LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp);
937  }
938  } else if (!strcasecmp(buf, "create_home_portals")) {
939  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
941  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
943  } else {
944  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
945  }
946  } else if (!strcasecmp(buf, "personalized_blessings")) {
947  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
949  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
951  } else {
952  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
953  }
954  } else if (!strcasecmp(buf, "pk_max_experience")) {
955  int64_t pkme = atoll(cp);
956  if (pkme < 0)
957  pkme = -1;
959  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
960  int pkmep = atoi(cp);
961  if (pkmep < 0) {
962  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
963  } else
965  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
966  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
968  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
970  } else {
971  LOG(llevError, "load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
972  }
973  } else if (!strcasecmp(buf, "allow_broken_converters")) {
974  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
976  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
978  } else {
979  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
980  }
981  } else if (!strcasecmp(buf, "log_timestamp")) {
982  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
984  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
986  } else {
987  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
988  }
989  } else if (!strcasecmp(buf, "log_timestamp_format")) {
992  } else if (!strcasecmp(buf, "starting_stat_min")) {
993  int val = atoi(cp);
994 
995  if (val < 1 || val > settings.max_stat || val > settings.starting_stat_max)
996  LOG(llevError, "load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
998  else
1000  } else if (!strcasecmp(buf, "starting_stat_max")) {
1001  int val = atoi(cp);
1002 
1003  if (val < 1 || val > settings.max_stat || val<settings.starting_stat_min)
1004  LOG(llevError, "load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
1006  else
1008  } else if (!strcasecmp(buf, "starting_stat_points")) {
1009  int val = atoi(cp);
1010 
1011  if (val < NUM_STATS * settings.starting_stat_min ||
1013  LOG(llevError, "load_settings: starting_stat_points (%d) need to be within %d-%d\n",
1015  else
1017  } else if (!strcasecmp(buf, "roll_stat_points")) {
1018  int val = atoi(cp);
1019 
1020  /* The 3 and 18 values are hard coded in because we know that
1021  * roll_stat() generates a value between 3 and 18 - if that ever
1022  * changed, this code should change also, but that code will eventually
1023  * go away.
1024  */
1025  if (val < NUM_STATS * 3 || val > NUM_STATS * 18)
1026  LOG(llevError, "load_settings: roll_stat_points need to be within %d-%d\n",
1027  NUM_STATS * 3, NUM_STATS * 18);
1028  else
1029  settings.roll_stat_points = val;
1030  } else if (!strcasecmp(buf, "special_break_map")) {
1031  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1033  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1035  } else {
1036  LOG(llevError, "load_settings: unknown value for special_break_map: %s\n", cp);
1037  }
1038  } else if (!strcasecmp(buf, "ignore_plugin_compatibility")) {
1039  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1041  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1043  } else {
1044  LOG(llevError, "load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1045  }
1046  } else if (!strcasecmp(buf, "account_block_create")) {
1047  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1049  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1051  } else {
1052  LOG(llevError, "load_settings: unknown value for account_block_create: %s\n", cp);
1053  }
1054  } else if (!strcasecmp(buf, "account_trusted_host")) {
1057  } else if (!strcasecmp(buf, "crypt_mode")) {
1058  int val = atoi(cp);
1059  if (val != 0 && val != 1) {
1060  LOG(llevError, "load_settings: crypt_mode must be 0 or 1\n");
1061  } else {
1062  settings.crypt_mode = val;
1063  }
1064  } else if (!strcasecmp(buf, "min_name")) {
1065  int val = atoi(cp);
1066 
1067  if (val < 1 || val > MAX_NAME )
1068  LOG(llevError, "load_settings: min_name (%d) need to be within %d-%d\n",
1069  val, 1, MAX_NAME);
1070  else
1071  settings.min_name = val;
1072  } else {
1073  LOG(llevError, "Unknown value in settings file: %s\n", buf);
1074  }
1075  }
1076  fclose(fp);
1077  if (settings.log_timestamp_format == NULL)
1078  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
1079 
1080  /*
1081  * The who formats are defined in config to be blank. They should have been
1082  * overridden by the settings file, if there are no entries however, it will
1083  * have stayed blank. Since this probably isn't what is wanted, we will check if
1084  * new formats have been specified, and if not we will use the old defaults.
1085  */
1086  if (!strcmp(settings.who_format, ""))
1087  strcpy(settings.who_format, "%N_%T%t%h%d%b%n<%m>");
1088  if (!strcmp(settings.who_wiz_format, ""))
1089  strcpy(settings.who_wiz_format, "%N_%T%t%h%d%b%nLevel %l <%m>(@%i)(%c)");
1090 }
1091 
1093  settings.hooks_filename[settings.hooks_count] = "/materials";
1099 }
1100 
1108 void init(int argc, char **argv) {
1109  logfile = stderr;
1110 
1111  /* First argument pass - right now it does nothing, but in the future specifying
1112  * the LibDir in this pass would be reasonable. */
1113  parse_args(argc, argv, 1);
1114 
1116  init_modules();
1117 
1118  init_library(); /* Must be called early */
1119  load_settings(); /* Load the settings file */
1120  parse_args(argc, argv, 2);
1121 
1122  LOG(llevInfo, "Crossfire %s\n", FULL_VERSION);
1123  SRANDOM(time(NULL));
1124 
1125  init_startup(); /* Check shutdown/forbid files */
1126  init_signals(); /* Sets up signal interceptions */
1127  commands_init(); /* Sort command tables */
1128  read_map_log(); /* Load up the old temp map files */
1129  init_skills();
1130  init_ob_methods();
1131  cftimer_init();
1132  hiscore_init();
1133 
1134  parse_args(argc, argv, 3);
1135 
1136  init_beforeplay();
1137  init_server();
1138  metaserver2_init();
1139  accounts_load();
1140  reset_sleep();
1141 }
1142 
1148 void free_server(void) {
1149  free_materials();
1150  free_races();
1151  free_quest();
1152  while (settings.disabled_plugins) {
1154  free((void *)settings.disabled_plugins->name);
1155  free(settings.disabled_plugins);
1157  }
1158 }
1159 
1163 static void help(void) {
1164  printf("Usage: crossfire-server [options]\n\n");
1165 
1166  printf("Options:\n");
1167  printf(" -conf Set the directory to find configuration files.\n");
1168  printf(" -d Turn on extra debugging messages.\n");
1169  printf(" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1170  printf(" -disable-module\n"
1171  " Disable specified module, by its name\n"
1172  " Can be specified multiple times. 'All' disables all modules.\n");
1173  printf(" -enable-module\n"
1174  " Enable specified module, by its name\n"
1175  " Can be specified multiple times. 'All' enables all modules.\n");
1176  printf(" -disable-plugin\n"
1177  " Disables specified plugin. Use the name without the extension.\n"
1178  " Can be specified multiple times. 'All' disables all plugins.\n");
1179  printf(" -dump-anims Dump animations.\n");
1180  printf(" -h Print this help message.\n");
1181  printf(" -ignore-assets-errors\n");
1182  printf(" Allow going on even if there are errors in assets.\n");
1183  printf(" Warning: this may lead to strange behaviour.\n");
1184  printf(" -list-modules\n"
1185  " List built-in modules and exit.\n");
1186  printf(" -local Set the local data (var/) directory.\n");
1187  printf(" -log <file> Write logging information to the given file.\n");
1188  printf(" -m List suggested experience for all monsters.\n");
1189  printf(" -m2 Dump monster abilities.\n");
1190  printf(" -m3 Dump artifact information.\n");
1191  printf(" -m4 Dump spell information.\n");
1192  printf(" -m5 Dump skill information.\n");
1193  printf(" -m6 Dump race information.\n");
1194  printf(" -m7 Dump alchemy information.\n");
1195  printf(" -m8 Dump gods information.\n");
1196  printf(" -m9 Dump more alchemy information (formula checking).\n");
1197  printf(" -maps Set the map directory.\n");
1198  printf(" -mexp Dump the experience table.\n");
1199  printf(" -mon Turn on monster debugging.\n");
1200  printf(" -mq Dump the quest list.\n");
1201  printf(" -mt <name> Dump a list of treasures for a monster.\n");
1202  printf(" -n Turn off debugging messages if on by default.\n");
1203  printf(" -p <port> Specifies the port to listen on for incoming connections.\n");
1204  printf(" -pack-assets <type> <filename>\n");
1205  printf(" Packs specified assets type to the specified filename.\n");
1206  printf(" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1207  printf(" The file format will be tar ('images') or text (everything else).\n");
1208  printf(" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1209  printf(" In this case the file will be in tar format.\n");
1210  printf(" -playerdir Set the player files directory.\n");
1211  printf(" -regions Set the region file.\n");
1212  printf(" -templatedir Set the template map directory.\n");
1213  printf(" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1214  printf(" -uniquedir Set the unique items/maps directory.\n");
1215  printf(" -v Print version information.\n");
1216  exit(EXIT_SUCCESS);
1217 }
1218 
1223 static void init_beforeplay(void) {
1224  init_archetype_pointers(); /* Setup global pointers to archetypes */
1225  finish_races(); /* overwrite race designations using entries in lib/races file */
1227  init_gods(); /* init linked list of gods from archs*/
1228  init_readable(); /* inits useful arrays for readable texts */
1229 
1230  switch (settings.dumpvalues) {
1231  case 1:
1232  print_monsters();
1233  cleanup();
1234 
1235  case 2:
1236  dump_abilities();
1237  cleanup();
1238 
1239  case 3:
1240  dump_artifacts();
1241  cleanup();
1242 
1243  case 4:
1244  dump_spells();
1245  cleanup();
1246 
1247  case 5:
1248  cleanup();
1249 
1250  case 6:
1251  dump_races();
1252  cleanup();
1253 
1254  case 7:
1255  dump_alchemy();
1256  cleanup();
1257 
1258  case 8:
1259  dump_gods();
1260  cleanup();
1261 
1262  case 9:
1264  cleanup();
1265 
1266  case 10:
1268  cleanup();
1269  }
1270 }
1271 
1277 static void init_startup(void) {
1278 #ifdef SHUTDOWN_FILE
1279  char buf[MAX_BUF];
1280  FILE *fp;
1281 
1282  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1283  if ((fp = fopen(buf, "r")) != NULL) {
1284  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1285  printf("%s", buf);
1286  fclose(fp);
1287  exit(1);
1288  }
1289 #endif
1290 
1291  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1292  LOG(llevError, "CrossFire: Playing not allowed.\n");
1293  exit(-1);
1294  }
1295 }
1296 
1300 static void signal_shutdown(int signum_unused) {
1301  (void) signum_unused; /* avoid unused warning if enambled */
1302  shutdown_flag += 1;
1303 }
1304 
1317 static void rec_sighup(int i) {
1318  (void)i;
1319  /* Don't call LOG(). It calls non-reentrant functions. The other
1320  * signal handlers shouldn't really call LOG() either. */
1321  if (logfile != stderr) {
1322  reopen_logfile = 1;
1323  }
1324 }
1325 
1329 void init_signals(void) {
1330 #ifndef WIN32 /* init_signals() remove signals */
1331  struct sigaction sa;
1332 
1333  sa.sa_sigaction = NULL;
1334  sigemptyset(&sa.sa_mask);
1335  sa.sa_flags = 0;
1336  sa.sa_handler = rec_sighup;
1337  sigaction(SIGHUP, &sa, NULL);
1338  signal(SIGINT, signal_shutdown);
1339  signal(SIGPIPE, SIG_IGN);
1340 #endif /* win32 */
1341 }
Settings::casting_time
uint8_t casting_time
Definition: global.h:265
give.next
def next
Definition: give.py:44
Settings::special_break_map
uint8_t special_break_map
Definition: global.h:320
Settings::meta_comment
char meta_comment[MAX_BUF]
Definition: global.h:284
Command_Line_Options
Definition: init.c:361
module_information::name
const char * name
Definition: init.c:46
server_pack_assets
static void server_pack_assets(const char *assets, const char *filename)
Definition: init.c:264
list_modules
static void list_modules()
Definition: init.c:94
Settings::mapdir
const char * mapdir
Definition: global.h:246
global.h
_materialtype::mod
int8_t mod[NROFATTACKS]
Definition: material.h:37
Settings::meta_server
char meta_server[MAX_BUF]
Definition: global.h:281
Settings::hooks_count
uint8_t hooks_count
Definition: global.h:327
Settings::simple_exp
uint8_t simple_exp
Definition: global.h:258
init_beforeplay
static void init_beforeplay(void)
Definition: init.c:1223
add_string
sstring add_string(const char *str)
Definition: shstr.c:124
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
set_localdir
static void set_localdir(const char *path)
Definition: init.c:205
set_disable_plugin
static void set_disable_plugin(const char *name)
Definition: init.c:290
Settings::recycle_tmp_maps
uint8_t recycle_tmp_maps
Definition: global.h:267
free_server
void free_server(void)
Definition: init.c:1148
llevError
@ llevError
Definition: logger.h:11
Settings::regions
const char * regions
Definition: global.h:247
Settings::allow_broken_converters
int allow_broken_converters
Definition: global.h:311
Settings::log_timestamp_format
char * log_timestamp_format
Definition: global.h:314
Settings::armor_speed_linear
uint8_t armor_speed_linear
Definition: global.h:304
module_information::close
void(* close)()
Definition: init.c:50
random_house_generator_init
void random_house_generator_init(Settings *settings)
Definition: random_house_generator.c:210
strdup_local
#define strdup_local
Definition: compat.h:29
_materialtype::description
const char * description
Definition: material.h:34
Settings::resurrection
uint8_t resurrection
Definition: global.h:261
init_startup
static void init_startup(void)
Definition: init.c:1277
service_handle
void service_handle()
Settings::set_title
uint8_t set_title
Definition: global.h:260
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
Definition: global.h:322
FALSE
#define FALSE
Definition: compat.h:14
Settings::not_permadeth
uint8_t not_permadeth
Definition: global.h:257
Settings::permanent_exp_ratio
uint8_t permanent_exp_ratio
Definition: global.h:253
Settings::crypt_mode
uint8_t crypt_mode
Definition: global.h:325
module_information::description
const char * description
Definition: init.c:47
Settings::dumpvalues
uint8_t dumpvalues
Definition: global.h:240
Settings::datadir
const char * datadir
Definition: global.h:243
disinfect.a
a
Definition: disinfect.py:13
set_dumpmon3
static void set_dumpmon3(void)
Definition: init.c:142
FULL_VERSION
#define FULL_VERSION
Definition: version.h:4
cleanup
void cleanup(void)
Definition: server.c:1257
set_tmpdir
static void set_tmpdir(const char *path)
Definition: init.c:253
Settings::worldmaptilesy
uint32_t worldmaptilesy
Definition: global.h:289
SHUTDOWN_FILE
#define SHUTDOWN_FILE
Definition: config.h:455
call_version
static void call_version(void)
Definition: init.c:111
Settings::min_name
uint8_t min_name
Definition: global.h:326
dump_abilities
void dump_abilities(void)
Definition: info.c:63
set_uniquedir
static void set_uniquedir(const char *path)
Definition: init.c:229
SRANDOM
#define SRANDOM(seed)
Definition: define.h:645
dump_alchemy_costs
void dump_alchemy_costs(void)
Definition: recipe.c:462
Settings::worldmapstartx
uint32_t worldmapstartx
Definition: global.h:286
init_ob_methods
void init_ob_methods(void)
Definition: ob_methods.c:35
Settings::starting_stat_min
uint8_t starting_stat_min
Definition: global.h:315
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Definition: bufferreader.c:102
read_map_log
void read_map_log(void)
Definition: swap.c:70
Settings::roll_stat_points
uint8_t roll_stat_points
Definition: global.h:318
Settings::pk_luck_penalty
int16_t pk_luck_penalty
Definition: global.h:252
Ice.tmp
int tmp
Definition: Ice.py:207
rec_sighup
static void rec_sighup(int i)
Definition: init.c:1317
llevMonster
@ llevMonster
Definition: logger.h:14
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
materialt
EXTERN materialtype_t * materialt
Definition: material.h:42
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
close_modules
void close_modules()
Definition: init.c:80
help
static void help(void)
Definition: init.c:1163
npc_dialog.filename
filename
Definition: npc_dialog.py:99
dump_gods
void dump_gods(void)
Definition: holy.cpp:371
Settings::csport
uint16_t csport
Definition: global.h:238
Settings::ignore_assets_errors
int ignore_assets_errors
Definition: global.h:330
cmdlinefunc_args2
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
Definition: init.c:353
load_races
void load_races(BufferReader *reader, const char *filename)
Definition: races.cpp:50
version.h
service_register
void service_register()
Command_Line_Options::num_args
uint8_t num_args
Definition: init.c:363
Settings::meta_host
char meta_host[MAX_BUF]
Definition: global.h:282
forbid_play
int forbid_play(void)
Definition: server.c:1363
reset_sleep
void reset_sleep(void)
Definition: time.c:132
linked_char
Definition: global.h:86
Settings::worldmaptilesx
uint32_t worldmaptilesx
Definition: global.h:288
set_templatedir
static void set_templatedir(const char *path)
Definition: init.c:237
settings
struct Settings settings
Definition: init.c:39
dump_races
void dump_races(void)
Definition: races.cpp:84
Settings::pk_max_experience
int64_t pk_max_experience
Definition: global.h:308
Command_Line_Options::cmd_option
const char * cmd_option
Definition: init.c:362
init_readable
void init_readable(void)
Definition: readable.c:903
set_dumpmon6
static void set_dumpmon6(void)
Definition: init.c:157
Settings::spell_encumbrance
uint8_t spell_encumbrance
Definition: global.h:263
_materialtype::material
int material
Definition: material.h:35
init_gods
void init_gods(void)
Definition: holy.cpp:63
dump_alchemy
void dump_alchemy(void)
Definition: recipe.c:350
module_information::init
void(* init)()
Definition: init.c:49
reopen_logfile
int reopen_logfile
Definition: logger.c:26
Settings::meta_port
uint16_t meta_port
Definition: global.h:283
Settings::balanced_stat_loss
uint8_t balanced_stat_loss
Definition: global.h:256
set_debug
static void set_debug(void)
Definition: init.c:117
set_confdir
static void set_confdir(const char *path)
Definition: init.c:197
Settings::debug
LogLevel debug
Definition: global.h:239
Settings::pk_max_experience_percent
int pk_max_experience_percent
Definition: global.h:309
set_dumpmon8
static void set_dumpmon8(void)
Definition: init.c:167
linked_char::name
const char * name
Definition: global.h:87
citylife_init
void citylife_init(Settings *settings)
Definition: citylife.cpp:430
Settings::death_penalty_ratio
uint8_t death_penalty_ratio
Definition: global.h:254
cftimer_init
void cftimer_init(void)
Definition: timers.c:157
random_house_generator_close
void random_house_generator_close()
Definition: random_house_generator.c:223
free_races
void free_races(void)
Definition: races.cpp:96
Settings::set_friendly_fire
uint16_t set_friendly_fire
Definition: global.h:270
Settings::account_block_create
uint8_t account_block_create
Definition: global.h:323
init_modules
void init_modules()
Definition: init.c:64
set_dumpmont
static void set_dumpmont(const char *name)
Definition: init.c:180
unset_debug
static void unset_debug(void)
Definition: init.c:122
Settings::logfilename
const char * logfilename
Definition: global.h:237
_materialtype::next
struct _materialtype * next
Definition: material.h:38
set_regions
static void set_regions(const char *path)
Definition: init.c:221
Settings::worldmapstarty
uint32_t worldmapstarty
Definition: global.h:287
fatal
void fatal(enum fatal_error err)
Definition: utils.c:580
free_quest
void free_quest(void)
Definition: quest.c:910
_materialtype::save
int8_t save[NROFATTACKS]
Definition: material.h:36
python_init.path
path
Definition: python_init.py:8
Settings::motd
char motd[MAX_BUF]
Definition: global.h:273
metaserver2_init
int metaserver2_init(void)
Definition: metaserver.c:171
Settings::armor_weight_reduction
int armor_weight_reduction
Definition: global.h:301
set_dumpmon1
static void set_dumpmon1(void)
Definition: init.c:132
Settings::stat_loss_on_death
uint8_t stat_loss_on_death
Definition: global.h:251
_materialtype
Definition: material.h:32
server_dump_faces
static void server_dump_faces(void)
Definition: init.c:344
set_csport
static void set_csport(const char *val)
Definition: init.c:277
linked_char::next
struct linked_char * next
Definition: global.h:88
Settings::item_power_factor
float item_power_factor
Definition: global.h:298
set_dumpmon5
static void set_dumpmon5(void)
Definition: init.c:152
MAX_NAME
#define MAX_NAME
Definition: define.h:41
service_unregister
void service_unregister()
Settings::dumparg
const char * dumparg
Definition: global.h:241
assets_finish_archetypes_for_play
void assets_finish_archetypes_for_play()
Definition: assets.cpp:550
Settings::hooks_filename
const char * hooks_filename[20]
Definition: global.h:328
set_playerdir
static void set_playerdir(const char *path)
Definition: init.c:245
init_server
void init_server(void)
Definition: init.c:263
dump_spells
void dump_spells(void)
Definition: spell_util.c:106
set_ignore_assets_errors
static void set_ignore_assets_errors()
Definition: init.c:260
Settings::confdir
const char * confdir
Definition: global.h:242
sproto.h
cmdlinefunc_args0
void(* cmdlinefunc_args0)(void)
Definition: init.c:351
logfile
EXTERN FILE * logfile
Definition: global.h:134
should_exit
static int should_exit
Definition: init.c:43
Settings::death_penalty_level
uint8_t death_penalty_level
Definition: global.h:255
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
modules.h
cfcitybell_init
void cfcitybell_init(Settings *settings)
Definition: cfcitybell.cpp:155
add_server_collect_hooks
void add_server_collect_hooks()
Definition: init.c:1092
accounts_load
void accounts_load(void)
Definition: account.c:157
MAX_BUF
#define MAX_BUF
Definition: define.h:35
set_dumpmon4
static void set_dumpmon4(void)
Definition: init.c:147
Settings::playerdir
const char * playerdir
Definition: global.h:245
dump_artifacts
void dump_artifacts(void)
Definition: artifact.c:616
init_skills
void init_skills(void)
Definition: skill_util.c:91
Settings::spell_failure_effects
uint8_t spell_failure_effects
Definition: global.h:264
Settings::starting_stat_points
uint8_t starting_stat_points
Definition: global.h:317
set_dumpmon2
static void set_dumpmon2(void)
Definition: init.c:137
Settings::meta_on
unsigned int meta_on
Definition: global.h:280
Settings::allow_denied_spells_writing
int allow_denied_spells_writing
Definition: global.h:310
set_datadir
static void set_datadir(const char *path)
Definition: init.c:189
Settings::disabled_plugins
linked_char * disabled_plugins
Definition: global.h:321
llevInfo
@ llevInfo
Definition: logger.h:12
print_monsters
void print_monsters(void)
Definition: info.c:101
hiscore_init
void hiscore_init(void)
Definition: hiscore.c:294
Settings::who_wiz_format
char who_wiz_format[MAX_BUF]
Definition: global.h:272
server_dump_animations
static void server_dump_animations(void)
Definition: init.c:336
commands_init
void commands_init(void)
Definition: commands.cpp:112
Settings::spellpoint_level_depend
uint8_t spellpoint_level_depend
Definition: global.h:269
dump_quests
void dump_quests(void)
Definition: quest.c:899
Settings::fastclock
uint8_t fastclock
Definition: global.h:292
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.c:51
get_empty_mat
static materialtype_t * get_empty_mat(void)
Definition: init.c:502
autojail.value
value
Definition: autojail.py:6
module_information
struct module_information module_information
Settings::personalized_blessings
uint8_t personalized_blessings
Definition: global.h:307
set_enable_module
static void set_enable_module(const char *name)
Definition: init.c:329
set_disable_module
static void set_disable_module(const char *name)
Definition: init.c:321
dump_animations
void dump_animations(void)
Definition: anim.c:183
dump_monster_treasure
void dump_monster_treasure(const char *name)
Definition: treasure.c:1217
set_mondebug
static void set_mondebug(void)
Definition: init.c:127
Settings::max_stat
uint8_t max_stat
Definition: global.h:319
modules
static module_information modules[]
Definition: init.c:54
options
static struct Command_Line_Options options[]
Definition: init.c:379
init
void init(int argc, char **argv)
Definition: init.c:1108
assets.h
Settings::armor_max_enchant
int armor_max_enchant
Definition: global.h:300
buf
StringBuffer * buf
Definition: readable.c:1610
cfcitybell_close
void cfcitybell_close()
Definition: cfcitybell.cpp:173
Settings::hooks
collectorHook hooks[20]
Definition: global.h:329
do_module
static void do_module(const char *name, bool enabled)
Definition: init.c:303
Settings::armor_weight_linear
uint8_t armor_weight_linear
Definition: global.h:302
load_materials
static void load_materials(BufferReader *reader, const char *filename)
Definition: init.c:523
strcasecmp
int strcasecmp(const char *s1, const char *s2)
Settings::worldmaptilesizex
uint32_t worldmaptilesizex
Definition: global.h:290
signal_shutdown
static void signal_shutdown(int signum_unused)
Definition: init.c:1300
loader.h
Settings::real_wiz
uint8_t real_wiz
Definition: global.h:266
free_materials
static void free_materials(void)
Definition: init.c:595
set_dumpmon7
static void set_dumpmon7(void)
Definition: init.c:162
Settings::templatedir
const char * templatedir
Definition: global.h:249
Settings::worldmaptilesizey
uint32_t worldmaptilesizey
Definition: global.h:291
_materialtype::name
const char * name
Definition: material.h:33
load_settings
static void load_settings(void)
Definition: init.c:611
assets_pack
void assets_pack(const char *what, const char *filename)
Definition: assets.cpp:459
dump_experience
void dump_experience(void)
Definition: exp.c:251
citylife_close
void citylife_close()
Definition: citylife.cpp:447
finish_races
void finish_races()
Definition: races.cpp:101
cmdlinefunc_args1
void(* cmdlinefunc_args1)(const char *arg1)
Definition: init.c:352
Settings::no_player_stealing
uint8_t no_player_stealing
Definition: global.h:305
Settings::account_trusted_host
char * account_trusted_host
Definition: global.h:324
Settings::search_items
uint8_t search_items
Definition: global.h:262
init_signals
void init_signals(void)
Definition: init.c:1329
module_information
Definition: init.c:45
init_library
void init_library(void)
Definition: init.c:192
server.h
Settings::tmpdir
const char * tmpdir
Definition: global.h:250
set_logfile
static void set_logfile(char *val)
Definition: init.c:106
Settings::always_show_hp
uint8_t always_show_hp
Definition: global.h:268
TRUE
#define TRUE
Definition: compat.h:11
Settings::create_home_portals
uint8_t create_home_portals
Definition: global.h:306
init_archetype_pointers
void init_archetype_pointers(void)
Definition: treasure.c:55
Command_Line_Options::pass
uint8_t pass
Definition: init.c:364
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
BufferReader
Definition: bufferreader.c:21
Settings::armor_speed_improvement
int armor_speed_improvement
Definition: global.h:303
NUM_STATS
@ NUM_STATS
Definition: living.h:18
Settings::log_timestamp
int log_timestamp
Definition: global.h:313
Settings::who_format
char who_format[MAX_BUF]
Definition: global.h:271
Command_Line_Options::func
void(* func)()
Definition: init.c:365
shutdown_flag
volatile sig_atomic_t shutdown_flag
Definition: server.c:53
module_information::enabled
bool enabled
Definition: init.c:48
set_mapdir
static void set_mapdir(const char *path)
Definition: init.c:213
dump_faces
void dump_faces(void)
Definition: image.c:162
llevDebug
@ llevDebug
Definition: logger.h:13
parse_args
static void parse_args(int argc, char *argv[], int pass)
Definition: init.c:450
give.name
name
Definition: give.py:27
set_dumpmon9
static void set_dumpmon9(void)
Definition: init.c:172
Settings::starting_stat_max
uint8_t starting_stat_max
Definition: global.h:316
Settings::uniquedir
const char * uniquedir
Definition: global.h:248
Settings::localdir
const char * localdir
Definition: global.h:244