Crossfire Server, Trunk
init.cpp
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 
46  const char *name;
47  char const *description;
48  bool enabled;
49  void (*init)(Settings *);
50  void (*close)();
51 };
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();
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  settings.disabled_plugins.push_back(strdup(name));
292 }
293 
300 static void do_module(const char *name, bool enabled) {
301  bool one = false;
302  for (int module = 0; modules[module].name; module++) {
303  if (strcmp("All", name) == 0 || strcmp(modules[module].name, name) == 0) {
304  modules[module].enabled = enabled;
305  one = true;
306  }
307  }
308  if (!one) {
309  LOG(llevError, "Invalid module name %s\n", name);
311  }
312 }
313 
318 static void set_disable_module(const char *name) {
319  do_module(name, false);
320 }
321 
326 static void set_enable_module(const char *name) {
327  do_module(name, true);
328 }
329 
333 static void server_dump_animations(void) {
334  dump_animations();
335  cleanup();
336 }
337 
341 static void server_dump_faces(void) {
342  dump_faces();
343  cleanup();
344 }
345 
349 typedef void (*cmdlinefunc_args1)(const char* arg1);
350 typedef void (*cmdlinefunc_args2)(const char* arg1, const char* arg2);
359  const char *cmd_option;
360  uint8_t num_args;
361  uint8_t pass;
362  void (*func)();
366 };
367 
376 static struct Command_Line_Options options[] = {
380  { "-conf", 1, 1, (cmdlinefunc_args0)set_confdir },
381  { "-d", 0, 1, (cmdlinefunc_args0)set_debug },
382  { "-data", 1, 1, (cmdlinefunc_args0)set_datadir },
383  { "-disable-plugin", 1, 1, (cmdlinefunc_args0)set_disable_plugin },
384  { "-disable-module", 1, 1, (cmdlinefunc_args0)set_disable_module },
385  { "-enable-module", 1, 1, (cmdlinefunc_args0)set_enable_module },
386  { "-list-modules", 0, 1, (cmdlinefunc_args0)list_modules },
387  { "-h", 0, 1, (cmdlinefunc_args0)help },
388  { "-ignore-assets-errors", 0, 1, (cmdlinefunc_args0)set_ignore_assets_errors },
389  { "-local", 1, 1, (cmdlinefunc_args0)set_localdir },
390  { "-log", 1, 1, (cmdlinefunc_args0)set_logfile },
391  { "-maps", 1, 1, (cmdlinefunc_args0)set_mapdir },
392  { "-mon", 0, 1, (cmdlinefunc_args0)set_mondebug },
393  { "-n", 0, 1, (cmdlinefunc_args0)unset_debug },
394  { "-playerdir", 1, 1, (cmdlinefunc_args0)set_playerdir },
395  { "-regions", 1, 1, (cmdlinefunc_args0)set_regions },
396  { "-templatedir", 1, 1, (cmdlinefunc_args0)set_templatedir },
397  { "-tmpdir", 1, 1, (cmdlinefunc_args0)set_tmpdir },
398  { "-uniquedir", 1, 1, (cmdlinefunc_args0)set_uniquedir },
399  { "-v", 0, 1, (cmdlinefunc_args0)call_version },
400 
401 #ifdef WIN32
402  /* Windows service stuff */
403  { "-regsrv", 0, 1, service_register },
404  { "-unregsrv", 0, 1, service_unregister },
405  { "-srv", 0, 1, service_handle },
406 #endif
407 
411  { "-p", 1, 2, (cmdlinefunc_args0)set_csport },
412 
416  { "-m", 0, 3, (cmdlinefunc_args0)set_dumpmon1 },
417  { "-m2", 0, 3, (cmdlinefunc_args0)set_dumpmon2 },
418  { "-m3", 0, 3, (cmdlinefunc_args0)set_dumpmon3 },
419  { "-m4", 0, 3, (cmdlinefunc_args0)set_dumpmon4 },
420  { "-m5", 0, 3, (cmdlinefunc_args0)set_dumpmon5 },
421  { "-m6", 0, 3, (cmdlinefunc_args0)set_dumpmon6 },
422  { "-m7", 0, 3, (cmdlinefunc_args0)set_dumpmon7 },
423  { "-m8", 0, 3, (cmdlinefunc_args0)set_dumpmon8 },
424  { "-m9", 0, 3, (cmdlinefunc_args0)set_dumpmon9 },
425  { "-mt", 1, 3, (cmdlinefunc_args0)set_dumpmont },
426  { "-mexp", 0, 3, (cmdlinefunc_args0)dump_experience },
427  { "-mq", 0, 3, (cmdlinefunc_args0)dump_quests },
428  { "-dump-anims", 0, 3, (cmdlinefunc_args0)server_dump_animations },
429  { "-dump-faces", 0, 3, (cmdlinefunc_args0)server_dump_faces },
430  { "-pack-assets", 2, 3, (cmdlinefunc_args0)server_pack_assets },
431 };
432 
447 static void parse_args(int argc, char *argv[], int pass) {
448  size_t i;
449  int on_arg = 1;
450 
451  while (on_arg < argc) {
452  for (i = 0; i < sizeof(options)/sizeof(struct Command_Line_Options); i++) {
453  if (!strcmp(options[i].cmd_option, argv[on_arg])) {
454  /* Found a matching option, but should not be processed on
455  * this pass. Just skip over it
456  */
457  if (options[i].pass != pass) {
458  on_arg += options[i].num_args+1;
459  break;
460  }
461  if (options[i].num_args) {
462  if ((on_arg+options[i].num_args) >= argc) {
463  fprintf(stderr, "%s requires an argument.\n", options[i].cmd_option);
464  exit(1);
465  }
466 
467  if (options[i].num_args == 1)
468  ((cmdlinefunc_args1)options[i].func)(argv[on_arg+1]);
469  if (options[i].num_args == 2)
470  ((cmdlinefunc_args2)options[i].func)(argv[on_arg+1], argv[on_arg+2]);
471  on_arg += options[i].num_args+1;
472  } else { /* takes no args */
474  on_arg++;
475  }
476  break;
477  }
478  }
479  if (i == sizeof(options)/sizeof(struct Command_Line_Options)) {
480  fprintf(stderr, "Unknown option: %s\n", argv[on_arg]);
481  fprintf(stderr, "Type '%s -h' for usage.\n", argv[0]);
482  exit(1);
483  }
484  }
485 
486  if (should_exit) {
487  cleanup();
488  }
489 }
490 
500  materialtype_t *mt;
501  int i;
502 
503  mt = (materialtype_t *)malloc(sizeof(materialtype_t));
504  if (mt == NULL)
506  mt->name = NULL;
507  mt->description = NULL;
508  for (i = 0; i < NROFATTACKS; i++) {
509  mt->save[i] = 0;
510  mt->mod[i] = 0;
511  }
512  return mt;
513 }
514 
519 static void load_materials(BufferReader *reader, const char *filename) {
520  char *buf, *cp, *next;
521  materialtype_t *mt;
522  int i, value;
523  (void)filename;
524 
525  while ((buf = bufferreader_next_line(reader)) != NULL) {
526  if (*buf == '#')
527  continue;
528  cp = buf;
529  while (*cp == ' ') /* Skip blanks */
530  cp++;
531  if (!strncmp(cp, "name", 4)) {
532  mt = get_empty_mat();
533  materials.push_back(mt);
534  mt->name = add_string(strchr(cp, ' ')+1);
535  mt->description = add_refcount(mt->name);
536  } else if (!strncmp(cp, "description", 11)) {
537  FREE_AND_COPY_IF(mt->description, strchr(cp, ' ')+1);
538  } else if (sscanf(cp, "material %d", &value)) {
539  mt->material = value;
540  } else if (!strncmp(cp, "saves", 5)) {
541  cp = strchr(cp, ' ')+1;
542  for (i = 0; i < NROFATTACKS; i++) {
543  if (cp == NULL) {
544  mt->save[i] = 0;
545  continue;
546  }
547  if ((next = strchr(cp, ',')) != NULL)
548  *(next++) = '\0';
549  sscanf(cp, "%d", &value);
550  mt->save[i] = (int8_t)value;
551  cp = next;
552  }
553  } else if (!strncmp(cp, "mods", 4)) {
554  cp = strchr(cp, ' ')+1;
555  for (i = 0; i < NROFATTACKS; i++) {
556  if (cp == NULL) {
557  mt->save[i] = 0;
558  continue;
559  }
560  if ((next = strchr(cp, ',')) != NULL)
561  *(next++) = '\0';
562  sscanf(cp, "%d", &value);
563  mt->mod[i] = (int8_t)value;
564  cp = next;
565  }
566  }
567  }
568  LOG(llevDebug, "loaded %d material type data\n", static_cast<int>(materials.size()));
569 }
570 
574 static void free_materials(void) {
575  for (auto material : materials) {
576  free(material);
577  }
578  materials.clear();
579 }
580 
586 static void load_settings(void) {
587  static char motd[MAX_BUF] = { 0 };
588  char buf[MAX_BUF], *cp, dummy[1];
589  int has_val;
590  FILE *fp;
591 
592  dummy[0] = '\0';
593  snprintf(buf, sizeof(buf), "%s/settings", settings.confdir);
594 
595  /* We don't require a settings file at current time, but down the road,
596  * there will probably be so many values that not having a settings file
597  * will not be a good thing.
598  */
599  if ((fp = fopen(buf, "r")) == NULL) {
600  LOG(llevError, "Warning: No settings file found\n");
601  return;
602  }
603  while (fgets(buf, MAX_BUF-1, fp) != NULL) {
604  if (buf[0] == '#')
605  continue;
606  /* eliminate newline */
607  if ((cp = strrchr(buf, '\n')) != NULL)
608  *cp = '\0';
609 
610  /* Skip over empty lines */
611  if (buf[0] == 0)
612  continue;
613 
614  /* Skip all the spaces and set them to nulls. If not space,
615  * set cp to "" to make strcpy's and the like easier down below.
616  */
617  if ((cp = strchr(buf, ' ')) != NULL) {
618  while (*cp == ' ')
619  *cp++ = 0;
620  has_val = 1;
621  } else {
622  cp = dummy;
623  has_val = 0;
624  }
625 
626  if (!strcasecmp(buf, "metaserver_notification")) {
627  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
629  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
631  } else {
632  LOG(llevError, "load_settings: Unknown value for metaserver_notification: %s\n", cp);
633  }
634  } else if (!strcasecmp(buf, "metaserver_server")) {
635  if (has_val)
637  else
638  LOG(llevError, "load_settings: metaserver_server must have a value.\n");
639  } else if (!strcasecmp(buf, "motd")) {
640  if (has_val) {
641  safe_strncpy(motd, cp, sizeof(motd));
642  settings.motd = motd;
643  } else
644  LOG(llevError, "load_settings: motd must have a value.\n");
645  } else if (!strcasecmp(buf, "metaserver_host")) {
646  if (has_val)
648  else
649  LOG(llevError, "load_settings: metaserver_host must have a value.\n");
650  } else if (!strcasecmp(buf, "port")) {
651  set_csport(cp);
652  } else if (!strcasecmp(buf, "metaserver_port")) {
653  int port = atoi(cp);
654 
655  if (port < 1 || port > 65535)
656  LOG(llevError, "load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
657  else
658  settings.meta_port = port;
659  } else if (!strcasecmp(buf, "metaserver_comment")) {
661  } else if (!strcasecmp(buf, "worldmapstartx")) {
662  int size = atoi(cp);
663 
664  if (size < 0)
665  LOG(llevError, "load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
666  else
667  settings.worldmapstartx = size;
668  } else if (!strcasecmp(buf, "worldmapstarty")) {
669  int size = atoi(cp);
670 
671  if (size < 0)
672  LOG(llevError, "load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
673  else
674  settings.worldmapstarty = size;
675  } else if (!strcasecmp(buf, "worldmaptilesx")) {
676  int size = atoi(cp);
677 
678  if (size < 1)
679  LOG(llevError, "load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
680  else
681  settings.worldmaptilesx = size;
682  } else if (!strcasecmp(buf, "worldmaptilesy")) {
683  int size = atoi(cp);
684 
685  if (size < 1)
686  LOG(llevError, "load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
687  else
688  settings.worldmaptilesy = size;
689  } else if (!strcasecmp(buf, "worldmaptilesizex")) {
690  int size = atoi(cp);
691 
692  if (size < 1)
693  LOG(llevError, "load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
694  else
696  } else if (!strcasecmp(buf, "worldmaptilesizey")) {
697  int size = atoi(cp);
698 
699  if (size < 1)
700  LOG(llevError, "load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
701  else
703  } else if (!strcasecmp(buf, "fastclock")) {
704  int lev = atoi(cp);
705 
706  if (lev < 0)
707  LOG(llevError, "load_settings: fastclock must be at least 0, %d is invalid\n", lev);
708  else
709  settings.fastclock = lev;
710  } else if (!strcasecmp(buf, "not_permadeth")) {
711  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
713  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
715  } else {
716  LOG(llevError, "load_settings: Unknown value for not_permadeth: %s\n", cp);
717  }
718  } else if (!strcasecmp(buf, "resurrection")) {
719  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
721  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
723  } else {
724  LOG(llevError, "load_settings: Unknown value for resurrection: %s\n", cp);
725  }
726  } else if (!strcasecmp(buf, "set_title")) {
727  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
729  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
731  } else {
732  LOG(llevError, "load_settings: Unknown value for set_title: %s\n", cp);
733  }
734  } else if (!strcasecmp(buf, "search_items")) {
735  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
737  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
739  } else {
740  LOG(llevError, "load_settings: Unknown value for search_items: %s\n", cp);
741  }
742  } else if (!strcasecmp(buf, "spell_encumbrance")) {
743  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
745  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
747  } else {
748  LOG(llevError, "load_settings: Unknown value for spell_encumbrance: %s\n", cp);
749  }
750  } else if (!strcasecmp(buf, "spell_failure_effects")) {
751  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
753  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
755  } else {
756  LOG(llevError, "load_settings: Unknown value for spell_failure_effects: %s\n", cp);
757  }
758  } else if (!strcasecmp(buf, "casting_time")) {
759  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
761  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
763  } else {
764  LOG(llevError, "load_settings: Unknown value for casting_time: %s\n", cp);
765  }
766  } else if (!strcasecmp(buf, "real_wiz")) {
767  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
769  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
771  } else {
772  LOG(llevError, "load_settings: Unknown value for real_wiz: %s\n", cp);
773  }
774  } else if (!strcasecmp(buf, "recycle_tmp_maps")) {
775  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
777  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
779  } else {
780  LOG(llevError, "load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
781  }
782  } else if (!strcasecmp(buf, "always_show_hp")) {
783  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
785  } else if (!strcasecmp(cp, "damaged")) {
787  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
789  } else {
790  LOG(llevError, "load_settings: Unknown value for always_show_hp: %s\n", cp);
791  }
792  } else if (!strcasecmp(buf, "who_format")) {
793  if (has_val)
795  sizeof(settings.who_format));
796  } else if (!strcasecmp(buf, "who_wiz_format")) {
797  if (has_val) {
799  sizeof(settings.who_wiz_format));
800  }
801  } else if (!strcasecmp(buf, "spellpoint_level_depend")) {
802  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
804  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
806  } else {
807  LOG(llevError, "load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
808  }
809  } else if (!strcasecmp(buf, "stat_loss_on_death")) {
810  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
812  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
814  } else {
815  LOG(llevError, "load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
816  }
817  } else if (!strcasecmp(buf, "use_permanent_experience")) {
818  LOG(llevError, "use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
819  } else if (!strcasecmp(buf, "permanent_experience_percentage")) {
820  int val = atoi(cp);
821  if (val < 0 || val > 100)
822  LOG(llevError, "load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
823  else
825  } else if (!strcasecmp(buf, "death_penalty_percentage")) {
826  int val = atoi(cp);
827  if (val < 0 || val > 100)
828  LOG(llevError, "load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
829  else
831  } else if (!strcasecmp(buf, "death_penalty_levels")) {
832  int val = atoi(cp);
833  if (val < 0 || val > 255)
834  LOG(llevError, "load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
835  else
837  } else if (!strcasecmp(buf, "balanced_stat_loss")) {
838  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
840  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
842  } else {
843  LOG(llevError, "load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
844  }
845  } else if (!strcasecmp(buf, "simple_exp")) {
846  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
848  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
850  } else {
851  LOG(llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
852  }
853  } else if (!strcasecmp(buf, "item_power_factor")) {
854  float tmp = atof(cp);
855  if (tmp < 0)
856  LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
857  else
859  } else if (!strcasecmp(buf, "pk_luck_penalty")) {
860  int16_t val = atoi(cp);
861 
862  if (val < -100 || val > 100)
863  LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
864  else
866  } else if (!strcasecmp(buf, "set_friendly_fire")) {
867  int val = atoi(cp);
868 
869  if (val < 1 || val > 100)
870  LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
871  else
873  } else if (!strcasecmp(buf, "armor_max_enchant")) {
874  int max_e = atoi(cp);
875  if (max_e <= 0)
876  LOG(llevError, "load_settings: armor_max_enchant is %d\n", max_e);
877  else
878  settings.armor_max_enchant = max_e;
879  } else if (!strcasecmp(buf, "armor_weight_reduction")) {
880  int wr = atoi(cp);
881  if (wr < 0)
882  LOG(llevError, "load_settings: armor_weight_reduction is %d\n", wr);
883  else
885  } else if (!strcasecmp(buf, "armor_weight_linear")) {
886  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
888  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
890  } else {
891  LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
892  }
893  } else if (!strcasecmp(buf, "armor_speed_improvement")) {
894  int wr = atoi(cp);
895  if (wr < 0)
896  LOG(llevError, "load_settings: armor_speed_improvement is %d\n", wr);
897  else
899  } else if (!strcasecmp(buf, "armor_speed_linear")) {
900  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
902  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
904  } else {
905  LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
906  }
907  } else if (!strcasecmp(buf, "no_player_stealing")) {
908  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
910  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
912  } else {
913  LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp);
914  }
915  } else if (!strcasecmp(buf, "create_home_portals")) {
916  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
917 #ifdef TRY_BROKEN_TOWN_PORTALS
919 #else
920  LOG(llevError, "load_settings: create_home_portals is currently broken. It results in town portals that prematurely reset when the apartment is swapped.\n");
921 #endif
922  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
924  } else {
925  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
926  }
927  } else if (!strcasecmp(buf, "personalized_blessings")) {
928  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
930  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
932  } else {
933  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
934  }
935  } else if (!strcasecmp(buf, "pk_max_experience")) {
936  int64_t pkme = atoll(cp);
937  if (pkme < 0)
938  pkme = -1;
940  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
941  int pkmep = atoi(cp);
942  if (pkmep < 0) {
943  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
944  } else
946  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
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 allow_denied_spells_writing: %s\n", cp);
953  }
954  } else if (!strcasecmp(buf, "allow_broken_converters")) {
955  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
957  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
959  } else {
960  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
961  }
962  } else if (!strcasecmp(buf, "log_timestamp")) {
963  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
965  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
967  } else {
968  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
969  }
970  } else if (!strcasecmp(buf, "log_timestamp_format")) {
973  } else if (!strcasecmp(buf, "starting_stat_min")) {
974  int val = atoi(cp);
975 
976  if (val < 1 || val > settings.max_stat || val > settings.starting_stat_max)
977  LOG(llevError, "load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
979  else
981  } else if (!strcasecmp(buf, "starting_stat_max")) {
982  int val = atoi(cp);
983 
984  if (val < 1 || val > settings.max_stat || val<settings.starting_stat_min)
985  LOG(llevError, "load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
987  else
989  } else if (!strcasecmp(buf, "starting_stat_points")) {
990  int val = atoi(cp);
991 
992  if (val < NUM_STATS * settings.starting_stat_min ||
994  LOG(llevError, "load_settings: starting_stat_points (%d) need to be within %d-%d\n",
996  else
998  } else if (!strcasecmp(buf, "roll_stat_points")) {
999  int val = atoi(cp);
1000 
1001  /* The 3 and 18 values are hard coded in because we know that
1002  * roll_stat() generates a value between 3 and 18 - if that ever
1003  * changed, this code should change also, but that code will eventually
1004  * go away.
1005  */
1006  if (val < NUM_STATS * 3 || val > NUM_STATS * 18)
1007  LOG(llevError, "load_settings: roll_stat_points need to be within %d-%d\n",
1008  NUM_STATS * 3, NUM_STATS * 18);
1009  else
1010  settings.roll_stat_points = val;
1011  } else if (!strcasecmp(buf, "special_break_map")) {
1012  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1014  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1016  } else {
1017  LOG(llevError, "load_settings: unknown value for special_break_map: %s\n", cp);
1018  }
1019  } else if (!strcasecmp(buf, "ignore_plugin_compatibility")) {
1020  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1022  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1024  } else {
1025  LOG(llevError, "load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1026  }
1027  } else if (!strcasecmp(buf, "account_block_create")) {
1028  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1030  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1032  } else {
1033  LOG(llevError, "load_settings: unknown value for account_block_create: %s\n", cp);
1034  }
1035  } else if (!strcasecmp(buf, "account_trusted_host")) {
1038  } else if (!strcasecmp(buf, "crypt_mode")) {
1039  int val = atoi(cp);
1040  if (val != 0 && val != 1) {
1041  LOG(llevError, "load_settings: crypt_mode must be 0 or 1\n");
1042  } else {
1043  settings.crypt_mode = val;
1044  }
1045  } else if (!strcasecmp(buf, "min_name")) {
1046  int val = atoi(cp);
1047 
1048  if (val < 1 || val > MAX_NAME )
1049  LOG(llevError, "load_settings: min_name (%d) need to be within %d-%d\n",
1050  val, 1, MAX_NAME);
1051  else
1052  settings.min_name = val;
1053  } else if (!strcasecmp(buf, "stat_file")) {
1055  } else {
1056  LOG(llevError, "Unknown value in settings file: %s\n", buf);
1057  }
1058  }
1059  fclose(fp);
1060  if (settings.log_timestamp_format == NULL)
1061  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
1062 
1063  /*
1064  * The who formats are defined in config to be blank. They should have been
1065  * overridden by the settings file, if there are no entries however, it will
1066  * have stayed blank. Since this probably isn't what is wanted, we will check if
1067  * new formats have been specified, and if not we will use the old defaults.
1068  */
1069  if (!strcmp(settings.who_format, ""))
1070  strcpy(settings.who_format, "%N_%t%h%d%b%n<%M>");
1071  if (!strcmp(settings.who_wiz_format, ""))
1072  strcpy(settings.who_wiz_format, "%N_%t%h%d%b%nLevel %l <%M>(@%i)(%c)");
1073 }
1074 
1076  settings.add_hook("/materials", load_materials);
1077  settings.add_hook("/races", load_races);
1078 }
1079 
1087 void init(int argc, char **argv) {
1088  logfile = stderr;
1089 
1090  /* First argument pass - right now it does nothing, but in the future specifying
1091  * the LibDir in this pass would be reasonable. */
1092  parse_args(argc, argv, 1);
1093 
1095  init_modules();
1096 
1097  init_library(); /* Must be called early */
1098  load_settings(); /* Load the settings file */
1099  parse_args(argc, argv, 2);
1100 
1101  LOG(llevInfo, "Crossfire %s\n", FULL_VERSION);
1102  SRANDOM(time(NULL));
1103 
1104  init_startup(); /* Check shutdown/forbid files */
1105  init_signals(); /* Sets up signal interceptions */
1106  commands_init(); /* Sort command tables */
1107  read_map_log(); /* Load up the old temp map files */
1108  init_skills();
1109  init_ob_methods();
1110  cftimer_init();
1111  hiscore_init();
1112 
1113  parse_args(argc, argv, 3);
1114 
1115  init_beforeplay();
1116  init_server();
1117  metaserver2_init();
1118  accounts_load();
1119  reset_sleep();
1120 }
1121 
1127 void free_server(void) {
1128  free_materials();
1129  free_races();
1130  free_quest();
1131  std::for_each(settings.disabled_plugins.begin(), settings.disabled_plugins.end(), [] (char *item) { free(item); });
1132  settings.disabled_plugins.clear();
1133 }
1134 
1138 static void help(void) {
1139  printf("Usage: crossfire-server [options]\n\n");
1140 
1141  printf("Options:\n");
1142  printf(" -conf Set the directory to find configuration files.\n");
1143  printf(" -d Turn on extra debugging messages.\n");
1144  printf(" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1145  printf(" -disable-module\n"
1146  " Disable specified module, by its name\n"
1147  " Can be specified multiple times. 'All' disables all modules.\n");
1148  printf(" -enable-module\n"
1149  " Enable specified module, by its name\n"
1150  " Can be specified multiple times. 'All' enables all modules.\n");
1151  printf(" -disable-plugin\n"
1152  " Disables specified plugin. Use the name without the extension.\n"
1153  " Can be specified multiple times. 'All' disables all plugins.\n");
1154  printf(" -dump-anims Dump animations.\n");
1155  printf(" -h Print this help message.\n");
1156  printf(" -ignore-assets-errors\n");
1157  printf(" Allow going on even if there are errors in assets.\n");
1158  printf(" Warning: this may lead to strange behaviour.\n");
1159  printf(" -list-modules\n"
1160  " List built-in modules and exit.\n");
1161  printf(" -local Set the local data (var/) directory.\n");
1162  printf(" -log <file> Write logging information to the given file.\n");
1163  printf(" -m List suggested experience for all monsters.\n");
1164  printf(" -m2 Dump monster abilities.\n");
1165  printf(" -m3 Dump artifact information.\n");
1166  printf(" -m4 Dump spell information.\n");
1167  printf(" -m5 Dump skill information.\n");
1168  printf(" -m6 Dump race information.\n");
1169  printf(" -m7 Dump alchemy information.\n");
1170  printf(" -m8 Dump gods information.\n");
1171  printf(" -m9 Dump more alchemy information (formula checking).\n");
1172  printf(" -maps Set the map directory.\n");
1173  printf(" -mexp Dump the experience table.\n");
1174  printf(" -mon Turn on monster debugging.\n");
1175  printf(" -mq Dump the quest list.\n");
1176  printf(" -mt <name> Dump a list of treasures for a monster.\n");
1177  printf(" -n Turn off debugging messages if on by default.\n");
1178  printf(" -p <port> Specifies the port to listen on for incoming connections.\n");
1179  printf(" -pack-assets <type> <filename>\n");
1180  printf(" Packs specified assets type to the specified filename.\n");
1181  printf(" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1182  printf(" The file format will be tar ('images') or text (everything else).\n");
1183  printf(" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1184  printf(" In this case the file will be in tar format.\n");
1185  printf(" -playerdir Set the player files directory.\n");
1186  printf(" -regions Set the region file.\n");
1187  printf(" -templatedir Set the template map directory.\n");
1188  printf(" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1189  printf(" -uniquedir Set the unique items/maps directory.\n");
1190  printf(" -v Print version information.\n");
1191  exit(EXIT_SUCCESS);
1192 }
1193 
1198 static void init_beforeplay(void) {
1199  init_archetype_pointers(); /* Setup global pointers to archetypes */
1200  finish_races(); /* overwrite race designations using entries in lib/races file */
1202  init_gods(); /* init linked list of gods from archs*/
1203  init_readable(); /* inits useful arrays for readable texts */
1204 
1205  switch (settings.dumpvalues) {
1206  case 1:
1207  print_monsters();
1208  cleanup();
1209  break;
1210 
1211  case 2:
1212  dump_abilities();
1213  cleanup();
1214  break;
1215 
1216  case 3:
1217  dump_artifacts();
1218  cleanup();
1219  break;
1220 
1221  case 4:
1222  dump_spells();
1223  cleanup();
1224  break;
1225 
1226  case 5:
1227  cleanup();
1228  break;
1229 
1230  case 6:
1231  dump_races();
1232  cleanup();
1233  break;
1234 
1235  case 7:
1236  dump_alchemy();
1237  cleanup();
1238  break;
1239 
1240  case 8:
1241  dump_gods();
1242  cleanup();
1243  break;
1244 
1245  case 9:
1247  cleanup();
1248  break;
1249 
1250  case 10:
1252  cleanup();
1253  break;
1254  }
1255 }
1256 
1262 static void init_startup(void) {
1263 #ifdef SHUTDOWN_FILE
1264  char buf[MAX_BUF];
1265  FILE *fp;
1266 
1267  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1268  if ((fp = fopen(buf, "r")) != NULL) {
1269  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1270  printf("%s", buf);
1271  fclose(fp);
1272  exit(1);
1273  }
1274 #endif
1275 
1276  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1277  LOG(llevError, "CrossFire: Playing not allowed.\n");
1278  exit(-1);
1279  }
1280 }
1281 
1285 static void signal_shutdown(int signum_unused) {
1286  (void) signum_unused; /* avoid unused warning if enambled */
1287  shutdown_flag += 1;
1288 }
1289 
1302 static void rec_sighup(int i) {
1303  (void)i;
1304  /* Don't call LOG(). It calls non-reentrant functions. The other
1305  * signal handlers shouldn't really call LOG() either. */
1306  if (logfile != stderr) {
1307  reopen_logfile = 1;
1308  }
1309 }
1310 
1314 void init_signals(void) {
1315 #ifndef WIN32 /* init_signals() remove signals */
1316  struct sigaction sa;
1317 
1318  sa.sa_sigaction = NULL;
1319  sigemptyset(&sa.sa_mask);
1320  sa.sa_flags = 0;
1321  sa.sa_handler = rec_sighup;
1322  sigaction(SIGHUP, &sa, NULL);
1323  signal(SIGINT, signal_shutdown);
1324  signal(SIGPIPE, SIG_IGN);
1325 #endif /* win32 */
1326 }
Settings::casting_time
uint8_t casting_time
Definition: global.h:270
give.next
def next
Definition: give.py:44
Settings::special_break_map
uint8_t special_break_map
Definition: global.h:325
Settings::meta_comment
char meta_comment[MAX_BUF]
Definition: global.h:289
Command_Line_Options
Definition: init.cpp:358
module_information::name
const char * name
Definition: init.cpp:46
Settings::mapdir
const char * mapdir
Definition: global.h:251
global.h
Settings::meta_server
char meta_server[MAX_BUF]
Definition: global.h:286
settings
struct Settings settings
Definition: init.cpp:139
Settings::simple_exp
uint8_t simple_exp
Definition: global.h:263
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
options
static struct Command_Line_Options options[]
Definition: init.cpp:376
Settings::recycle_tmp_maps
uint8_t recycle_tmp_maps
Definition: global.h:272
init
void init(int argc, char **argv)
Definition: init.cpp:1087
llevError
@ llevError
Definition: logger.h:11
init_beforeplay
static void init_beforeplay(void)
Definition: init.cpp:1198
Settings::regions
const char * regions
Definition: global.h:252
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:58
Settings::allow_broken_converters
int allow_broken_converters
Definition: global.h:316
Settings::log_timestamp_format
char * log_timestamp_format
Definition: global.h:319
Settings::armor_speed_linear
uint8_t armor_speed_linear
Definition: global.h:309
module_information::close
void(* close)()
Definition: init.cpp:50
random_house_generator_init
void random_house_generator_init(Settings *settings)
Definition: random_house_generator.cpp:210
strdup_local
#define strdup_local
Definition: compat.h:29
materialtype_t::mod
int8_t mod[NROFATTACKS]
Definition: material.h:37
Settings::resurrection
uint8_t resurrection
Definition: global.h:266
service_handle
void service_handle()
Settings::set_title
uint8_t set_title
Definition: global.h:265
dump_alchemy_costs
void dump_alchemy_costs(void)
Definition: recipe.cpp:588
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
Definition: global.h:327
FALSE
#define FALSE
Definition: compat.h:14
Settings::not_permadeth
uint8_t not_permadeth
Definition: global.h:262
Settings::permanent_exp_ratio
uint8_t permanent_exp_ratio
Definition: global.h:258
Settings::crypt_mode
uint8_t crypt_mode
Definition: global.h:330
set_datadir
static void set_datadir(const char *path)
Definition: init.cpp:189
module_information::description
const char * description
Definition: init.cpp:47
Settings::dumpvalues
uint8_t dumpvalues
Definition: global.h:245
Settings::datadir
const char * datadir
Definition: global.h:248
load_materials
static void load_materials(BufferReader *reader, const char *filename)
Definition: init.cpp:519
FULL_VERSION
#define FULL_VERSION
Definition: version.h:4
set_mapdir
static void set_mapdir(const char *path)
Definition: init.cpp:213
cleanup
void cleanup(void)
Definition: server.cpp:1252
set_dumpmon7
static void set_dumpmon7(void)
Definition: init.cpp:162
dump_faces
void dump_faces(void)
Definition: image.cpp:159
Settings::worldmaptilesy
uint32_t worldmaptilesy
Definition: global.h:294
SHUTDOWN_FILE
#define SHUTDOWN_FILE
Definition: config.h:463
rec_sighup
static void rec_sighup(int i)
Definition: init.cpp:1302
Settings::min_name
uint8_t min_name
Definition: global.h:331
SRANDOM
#define SRANDOM(seed)
Definition: define.h:645
Settings::worldmapstartx
uint32_t worldmapstartx
Definition: global.h:291
list_modules
static void list_modules()
Definition: init.cpp:94
get_empty_mat
static materialtype_t * get_empty_mat(void)
Definition: init.cpp:499
set_dumpmont
static void set_dumpmont(const char *name)
Definition: init.cpp:180
init_ob_methods
void init_ob_methods(void)
Definition: ob_methods.cpp:35
module_information::init
void(* init)(Settings *)
Definition: init.cpp:49
set_dumpmon6
static void set_dumpmon6(void)
Definition: init.cpp:157
Settings::starting_stat_min
uint8_t starting_stat_min
Definition: global.h:320
read_map_log
void read_map_log(void)
Definition: swap.cpp:71
Settings::roll_stat_points
uint8_t roll_stat_points
Definition: global.h:323
Settings::pk_luck_penalty
int16_t pk_luck_penalty
Definition: global.h:257
Ice.tmp
int tmp
Definition: Ice.py:207
FREE_AND_COPY_IF
#define FREE_AND_COPY_IF(sv, nv)
Definition: global.h:206
Settings::stat_file
char * stat_file
Definition: global.h:338
set_mondebug
static void set_mondebug(void)
Definition: init.cpp:127
llevMonster
@ llevMonster
Definition: logger.h:14
server_dump_animations
static void server_dump_animations(void)
Definition: init.cpp:333
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
set_playerdir
static void set_playerdir(const char *path)
Definition: init.cpp:245
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
npc_dialog.filename
filename
Definition: npc_dialog.py:99
dump_gods
void dump_gods(void)
Definition: holy.cpp:367
Settings::csport
uint16_t csport
Definition: global.h:242
materials
std::vector< materialtype_t * > materials
Definition: init.cpp:128
Settings::ignore_assets_errors
int ignore_assets_errors
Definition: global.h:335
load_races
void load_races(BufferReader *reader, const char *filename)
Definition: races.cpp:49
buf
StringBuffer * buf
Definition: readable.cpp:1565
init_server
void init_server(void)
Definition: init.cpp:283
version.h
service_register
void service_register()
set_dumpmon2
static void set_dumpmon2(void)
Definition: init.cpp:137
Command_Line_Options::num_args
uint8_t num_args
Definition: init.cpp:360
Settings::meta_host
char meta_host[MAX_BUF]
Definition: global.h:287
set_dumpmon4
static void set_dumpmon4(void)
Definition: init.cpp:147
forbid_play
int forbid_play(void)
Definition: server.cpp:1359
Settings::worldmaptilesx
uint32_t worldmaptilesx
Definition: global.h:293
dump_races
void dump_races(void)
Definition: races.cpp:83
Settings::pk_max_experience
int64_t pk_max_experience
Definition: global.h:313
Command_Line_Options::cmd_option
const char * cmd_option
Definition: init.cpp:359
server_dump_faces
static void server_dump_faces(void)
Definition: init.cpp:341
init_signals
void init_signals(void)
Definition: init.cpp:1314
parse_args
static void parse_args(int argc, char *argv[], int pass)
Definition: init.cpp:447
Settings::spell_encumbrance
uint8_t spell_encumbrance
Definition: global.h:268
init_gods
void init_gods(void)
Definition: holy.cpp:59
materialtype_t::material
int material
Definition: material.h:35
dump_experience
void dump_experience(void)
Definition: exp.cpp:251
Settings::add_hook
void add_hook(const char *name, collectorHook hook)
Definition: global.h:340
Settings::meta_port
uint16_t meta_port
Definition: global.h:288
modules
static module_information modules[]
Definition: init.cpp:54
Settings::balanced_stat_loss
uint8_t balanced_stat_loss
Definition: global.h:261
Settings::debug
LogLevel debug
Definition: global.h:243
load_settings
static void load_settings(void)
Definition: init.cpp:586
init_archetype_pointers
void init_archetype_pointers(void)
Definition: treasure.cpp:62
Settings::pk_max_experience_percent
int pk_max_experience_percent
Definition: global.h:314
add_refcount
sstring add_refcount(sstring str)
Definition: shstr.cpp:210
citylife_init
void citylife_init(Settings *settings)
Definition: citylife.cpp:427
Settings::death_penalty_ratio
uint8_t death_penalty_ratio
Definition: global.h:259
set_dumpmon3
static void set_dumpmon3(void)
Definition: init.cpp:142
cftimer_init
void cftimer_init(void)
Definition: timers.cpp:157
random_house_generator_close
void random_house_generator_close()
Definition: random_house_generator.cpp:220
free_races
void free_races(void)
Definition: races.cpp:95
Settings::set_friendly_fire
uint16_t set_friendly_fire
Definition: global.h:275
Settings::account_block_create
uint8_t account_block_create
Definition: global.h:328
Settings::motd
const char * motd
Definition: global.h:278
Settings::logfilename
const char * logfilename
Definition: global.h:241
Settings::worldmapstarty
uint32_t worldmapstarty
Definition: global.h:292
add_string
sstring add_string(const char *str)
Definition: shstr.cpp:124
free_quest
void free_quest(void)
Definition: quest.cpp:891
init_readable
void init_readable(void)
Definition: readable.cpp:904
python_init.path
path
Definition: python_init.py:8
set_enable_module
static void set_enable_module(const char *name)
Definition: init.cpp:326
materialtype_t::name
const char * name
Definition: material.h:33
set_dumpmon1
static void set_dumpmon1(void)
Definition: init.cpp:132
metaserver2_init
int metaserver2_init(void)
Definition: metaserver.cpp:332
Settings::armor_weight_reduction
int armor_weight_reduction
Definition: global.h:306
Settings::stat_loss_on_death
uint8_t stat_loss_on_death
Definition: global.h:256
Settings::disabled_plugins
std::vector< char * > disabled_plugins
Definition: global.h:326
signal_shutdown
static void signal_shutdown(int signum_unused)
Definition: init.cpp:1285
Settings::item_power_factor
float item_power_factor
Definition: global.h:303
MAX_NAME
#define MAX_NAME
Definition: define.h:41
set_logfile
static void set_logfile(char *val)
Definition: init.cpp:106
service_unregister
void service_unregister()
Settings::dumparg
const char * dumparg
Definition: global.h:246
assets_finish_archetypes_for_play
void assets_finish_archetypes_for_play()
Definition: assets.cpp:509
dump_spells
void dump_spells(void)
Definition: spell_util.cpp:108
Settings::confdir
const char * confdir
Definition: global.h:247
sproto.h
logfile
FILE * logfile
Definition: init.cpp:114
set_tmpdir
static void set_tmpdir(const char *path)
Definition: init.cpp:253
dump_abilities
void dump_abilities(void)
Definition: info.cpp:65
set_uniquedir
static void set_uniquedir(const char *path)
Definition: init.cpp:229
materialtype_t::save
int8_t save[NROFATTACKS]
Definition: material.h:36
Settings::death_penalty_level
uint8_t death_penalty_level
Definition: global.h:260
nlohmann::detail::void
j template void())
Definition: json.hpp:4099
modules.h
cfcitybell_init
void cfcitybell_init(Settings *settings)
Definition: cfcitybell.cpp:152
fatal
void fatal(enum fatal_error err)
Definition: utils.cpp:590
accounts_load
void accounts_load(void)
Definition: account.cpp:162
set_dumpmon9
static void set_dumpmon9(void)
Definition: init.cpp:172
MAX_BUF
#define MAX_BUF
Definition: define.h:35
set_confdir
static void set_confdir(const char *path)
Definition: init.cpp:197
cmdlinefunc_args2
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
Definition: init.cpp:350
set_dumpmon8
static void set_dumpmon8(void)
Definition: init.cpp:167
Settings::playerdir
const char * playerdir
Definition: global.h:250
reopen_logfile
int reopen_logfile
Definition: logger.cpp:27
init_skills
void init_skills(void)
Definition: skill_util.cpp:99
Settings::spell_failure_effects
uint8_t spell_failure_effects
Definition: global.h:269
Settings::starting_stat_points
uint8_t starting_stat_points
Definition: global.h:322
Settings
Definition: global.h:240
Settings::meta_on
unsigned int meta_on
Definition: global.h:285
Settings::allow_denied_spells_writing
int allow_denied_spells_writing
Definition: global.h:315
llevInfo
@ llevInfo
Definition: logger.h:12
hiscore_init
void hiscore_init(void)
Definition: hiscore.cpp:296
set_regions
static void set_regions(const char *path)
Definition: init.cpp:221
should_exit
static int should_exit
Definition: init.cpp:43
init_library
void init_library(void)
Definition: init.cpp:324
Settings::who_wiz_format
char who_wiz_format[MAX_BUF]
Definition: global.h:277
commands_init
void commands_init(void)
Definition: commands.cpp:109
Settings::spellpoint_level_depend
uint8_t spellpoint_level_depend
Definition: global.h:274
dump_quests
void dump_quests(void)
Definition: quest.cpp:880
Settings::fastclock
uint8_t fastclock
Definition: global.h:297
cmdlinefunc_args1
void(* cmdlinefunc_args1)(const char *arg1)
Definition: init.cpp:349
item
Definition: item.py:1
free_materials
static void free_materials(void)
Definition: init.cpp:574
autojail.value
value
Definition: autojail.py:6
Settings::personalized_blessings
uint8_t personalized_blessings
Definition: global.h:312
print_monsters
void print_monsters(void)
Definition: info.cpp:100
unset_debug
static void unset_debug(void)
Definition: init.cpp:122
dump_alchemy
void dump_alchemy(void)
Definition: recipe.cpp:350
help
static void help(void)
Definition: init.cpp:1138
Settings::max_stat
uint8_t max_stat
Definition: global.h:324
cmdlinefunc_args0
void(* cmdlinefunc_args0)(void)
Definition: init.cpp:348
materialtype_t::description
const char * description
Definition: material.h:34
set_debug
static void set_debug(void)
Definition: init.cpp:117
close_modules
void close_modules()
Definition: init.cpp:80
reset_sleep
void reset_sleep(void)
Definition: time.cpp:134
assets.h
Settings::armor_max_enchant
int armor_max_enchant
Definition: global.h:305
cfcitybell_close
void cfcitybell_close()
Definition: cfcitybell.cpp:164
set_ignore_assets_errors
static void set_ignore_assets_errors()
Definition: init.cpp:260
dump_monster_treasure
void dump_monster_treasure(const char *name)
Definition: treasure.cpp:1250
dump_animations
void dump_animations(void)
Definition: anim.cpp:180
add_server_collect_hooks
void add_server_collect_hooks()
Definition: init.cpp:1075
Settings::armor_weight_linear
uint8_t armor_weight_linear
Definition: global.h:307
set_dumpmon5
static void set_dumpmon5(void)
Definition: init.cpp:152
strcasecmp
int strcasecmp(const char *s1, const char *s2)
Settings::worldmaptilesizex
uint32_t worldmaptilesizex
Definition: global.h:295
init_modules
void init_modules()
Definition: init.cpp:64
call_version
static void call_version(void)
Definition: init.cpp:111
set_csport
static void set_csport(const char *val)
Definition: init.cpp:277
loader.h
Settings::real_wiz
uint8_t real_wiz
Definition: global.h:271
init_startup
static void init_startup(void)
Definition: init.cpp:1262
Settings::templatedir
const char * templatedir
Definition: global.h:254
set_disable_plugin
static void set_disable_plugin(const char *name)
Definition: init.cpp:290
Settings::worldmaptilesizey
uint32_t worldmaptilesizey
Definition: global.h:296
set_localdir
static void set_localdir(const char *path)
Definition: init.cpp:205
assets_pack
void assets_pack(const char *what, const char *filename)
Definition: assets.cpp:418
set_disable_module
static void set_disable_module(const char *name)
Definition: init.cpp:318
free_server
void free_server(void)
Definition: init.cpp:1127
citylife_close
void citylife_close()
Definition: citylife.cpp:438
finish_races
void finish_races()
Definition: races.cpp:100
materialtype_t
Definition: material.h:32
Settings::no_player_stealing
uint8_t no_player_stealing
Definition: global.h:310
Settings::account_trusted_host
char * account_trusted_host
Definition: global.h:329
Settings::search_items
uint8_t search_items
Definition: global.h:267
module_information
Definition: init.cpp:45
server.h
Settings::tmpdir
const char * tmpdir
Definition: global.h:255
dump_artifacts
void dump_artifacts(void)
Definition: artifact.cpp:614
Settings::always_show_hp
uint8_t always_show_hp
Definition: global.h:273
TRUE
#define TRUE
Definition: compat.h:11
set_templatedir
static void set_templatedir(const char *path)
Definition: init.cpp:237
Settings::create_home_portals
uint8_t create_home_portals
Definition: global.h:311
Command_Line_Options::pass
uint8_t pass
Definition: init.cpp:361
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
BufferReader
Definition: bufferreader.cpp:21
Settings::armor_speed_improvement
int armor_speed_improvement
Definition: global.h:308
NUM_STATS
@ NUM_STATS
Definition: living.h:18
Settings::log_timestamp
int log_timestamp
Definition: global.h:318
Settings::who_format
char who_format[MAX_BUF]
Definition: global.h:276
server_pack_assets
static void server_pack_assets(const char *assets, const char *filename)
Definition: init.cpp:264
Command_Line_Options::func
void(* func)()
Definition: init.cpp:362
shutdown_flag
volatile sig_atomic_t shutdown_flag
Definition: server.cpp:53
module_information::enabled
bool enabled
Definition: init.cpp:48
llevDebug
@ llevDebug
Definition: logger.h:13
do_module
static void do_module(const char *name, bool enabled)
Definition: init.cpp:300
give.name
name
Definition: give.py:27
Settings::starting_stat_max
uint8_t starting_stat_max
Definition: global.h:321
Settings::uniquedir
const char * uniquedir
Definition: global.h:253
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Definition: bufferreader.cpp:102
Settings::localdir
const char * localdir
Definition: global.h:249