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")) {
918  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
920  } else {
921  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
922  }
923  } else if (!strcasecmp(buf, "personalized_blessings")) {
924  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
926  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
928  } else {
929  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
930  }
931  } else if (!strcasecmp(buf, "pk_max_experience")) {
932  int64_t pkme = atoll(cp);
933  if (pkme < 0)
934  pkme = -1;
936  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
937  int pkmep = atoi(cp);
938  if (pkmep < 0) {
939  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
940  } else
942  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
943  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
945  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
947  } else {
948  LOG(llevError, "load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
949  }
950  } else if (!strcasecmp(buf, "allow_broken_converters")) {
951  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
953  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
955  } else {
956  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
957  }
958  } else if (!strcasecmp(buf, "log_timestamp")) {
959  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
961  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
963  } else {
964  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
965  }
966  } else if (!strcasecmp(buf, "log_timestamp_format")) {
969  } else if (!strcasecmp(buf, "starting_stat_min")) {
970  int val = atoi(cp);
971 
972  if (val < 1 || val > settings.max_stat || val > settings.starting_stat_max)
973  LOG(llevError, "load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
975  else
977  } else if (!strcasecmp(buf, "starting_stat_max")) {
978  int val = atoi(cp);
979 
980  if (val < 1 || val > settings.max_stat || val<settings.starting_stat_min)
981  LOG(llevError, "load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
983  else
985  } else if (!strcasecmp(buf, "starting_stat_points")) {
986  int val = atoi(cp);
987 
988  if (val < NUM_STATS * settings.starting_stat_min ||
990  LOG(llevError, "load_settings: starting_stat_points (%d) need to be within %d-%d\n",
992  else
994  } else if (!strcasecmp(buf, "roll_stat_points")) {
995  int val = atoi(cp);
996 
997  /* The 3 and 18 values are hard coded in because we know that
998  * roll_stat() generates a value between 3 and 18 - if that ever
999  * changed, this code should change also, but that code will eventually
1000  * go away.
1001  */
1002  if (val < NUM_STATS * 3 || val > NUM_STATS * 18)
1003  LOG(llevError, "load_settings: roll_stat_points need to be within %d-%d\n",
1004  NUM_STATS * 3, NUM_STATS * 18);
1005  else
1006  settings.roll_stat_points = val;
1007  } else if (!strcasecmp(buf, "special_break_map")) {
1008  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1010  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1012  } else {
1013  LOG(llevError, "load_settings: unknown value for special_break_map: %s\n", cp);
1014  }
1015  } else if (!strcasecmp(buf, "ignore_plugin_compatibility")) {
1016  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1018  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1020  } else {
1021  LOG(llevError, "load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1022  }
1023  } else if (!strcasecmp(buf, "account_block_create")) {
1024  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1026  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1028  } else {
1029  LOG(llevError, "load_settings: unknown value for account_block_create: %s\n", cp);
1030  }
1031  } else if (!strcasecmp(buf, "account_trusted_host")) {
1034  } else if (!strcasecmp(buf, "crypt_mode")) {
1035  int val = atoi(cp);
1036  if (val != 0 && val != 1) {
1037  LOG(llevError, "load_settings: crypt_mode must be 0 or 1\n");
1038  } else {
1039  settings.crypt_mode = val;
1040  }
1041  } else if (!strcasecmp(buf, "min_name")) {
1042  int val = atoi(cp);
1043 
1044  if (val < 1 || val > MAX_NAME )
1045  LOG(llevError, "load_settings: min_name (%d) need to be within %d-%d\n",
1046  val, 1, MAX_NAME);
1047  else
1048  settings.min_name = val;
1049  } else if (!strcasecmp(buf, "stat_file")) {
1051  } else {
1052  LOG(llevError, "Unknown value in settings file: %s\n", buf);
1053  }
1054  }
1055  fclose(fp);
1056  if (settings.log_timestamp_format == NULL)
1057  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
1058 
1059  /*
1060  * The who formats are defined in config to be blank. They should have been
1061  * overridden by the settings file, if there are no entries however, it will
1062  * have stayed blank. Since this probably isn't what is wanted, we will check if
1063  * new formats have been specified, and if not we will use the old defaults.
1064  */
1065  if (!strcmp(settings.who_format, ""))
1066  strcpy(settings.who_format, "%N_%t%h%d%b%n<%M>");
1067  if (!strcmp(settings.who_wiz_format, ""))
1068  strcpy(settings.who_wiz_format, "%N_%t%h%d%b%nLevel %l <%M>(@%i)(%c)");
1069 }
1070 
1072  settings.add_hook("/materials", load_materials);
1073  settings.add_hook("/races", load_races);
1074 }
1075 
1083 void init(int argc, char **argv) {
1084  logfile = stderr;
1085 
1086  /* First argument pass - right now it does nothing, but in the future specifying
1087  * the LibDir in this pass would be reasonable. */
1088  parse_args(argc, argv, 1);
1089 
1091  init_modules();
1092 
1093  init_library(); /* Must be called early */
1094  load_settings(); /* Load the settings file */
1095  parse_args(argc, argv, 2);
1096 
1097  LOG(llevInfo, "Crossfire %s\n", FULL_VERSION);
1098  SRANDOM(time(NULL));
1099 
1100  init_startup(); /* Check shutdown/forbid files */
1101  init_signals(); /* Sets up signal interceptions */
1102  commands_init(); /* Sort command tables */
1103  read_map_log(); /* Load up the old temp map files */
1104  init_skills();
1105  init_ob_methods();
1106  cftimer_init();
1107  hiscore_init();
1108 
1109  parse_args(argc, argv, 3);
1110 
1111  init_beforeplay();
1112  init_server();
1113  metaserver2_init();
1114  accounts_load();
1115  reset_sleep();
1116 }
1117 
1123 void free_server(void) {
1124  free_materials();
1125  free_races();
1126  free_quest();
1127  std::for_each(settings.disabled_plugins.begin(), settings.disabled_plugins.end(), [] (char *item) { free(item); });
1128  settings.disabled_plugins.clear();
1129 }
1130 
1134 static void help(void) {
1135  printf("Usage: crossfire-server [options]\n\n");
1136 
1137  printf("Options:\n");
1138  printf(" -conf Set the directory to find configuration files.\n");
1139  printf(" -d Turn on extra debugging messages.\n");
1140  printf(" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1141  printf(" -disable-module\n"
1142  " Disable specified module, by its name\n"
1143  " Can be specified multiple times. 'All' disables all modules.\n");
1144  printf(" -enable-module\n"
1145  " Enable specified module, by its name\n"
1146  " Can be specified multiple times. 'All' enables all modules.\n");
1147  printf(" -disable-plugin\n"
1148  " Disables specified plugin. Use the name without the extension.\n"
1149  " Can be specified multiple times. 'All' disables all plugins.\n");
1150  printf(" -dump-anims Dump animations.\n");
1151  printf(" -h Print this help message.\n");
1152  printf(" -ignore-assets-errors\n");
1153  printf(" Allow going on even if there are errors in assets.\n");
1154  printf(" Warning: this may lead to strange behaviour.\n");
1155  printf(" -list-modules\n"
1156  " List built-in modules and exit.\n");
1157  printf(" -local Set the local data (var/) directory.\n");
1158  printf(" -log <file> Write logging information to the given file.\n");
1159  printf(" -m List suggested experience for all monsters.\n");
1160  printf(" -m2 Dump monster abilities.\n");
1161  printf(" -m3 Dump artifact information.\n");
1162  printf(" -m4 Dump spell information.\n");
1163  printf(" -m5 Dump skill information.\n");
1164  printf(" -m6 Dump race information.\n");
1165  printf(" -m7 Dump alchemy information.\n");
1166  printf(" -m8 Dump gods information.\n");
1167  printf(" -m9 Dump more alchemy information (formula checking).\n");
1168  printf(" -maps Set the map directory.\n");
1169  printf(" -mexp Dump the experience table.\n");
1170  printf(" -mon Turn on monster debugging.\n");
1171  printf(" -mq Dump the quest list.\n");
1172  printf(" -mt <name> Dump a list of treasures for a monster.\n");
1173  printf(" -n Turn off debugging messages if on by default.\n");
1174  printf(" -p <port> Specifies the port to listen on for incoming connections.\n");
1175  printf(" -pack-assets <type> <filename>\n");
1176  printf(" Packs specified assets type to the specified filename.\n");
1177  printf(" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1178  printf(" The file format will be tar ('images') or text (everything else).\n");
1179  printf(" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1180  printf(" In this case the file will be in tar format.\n");
1181  printf(" -playerdir Set the player files directory.\n");
1182  printf(" -regions Set the region file.\n");
1183  printf(" -templatedir Set the template map directory.\n");
1184  printf(" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1185  printf(" -uniquedir Set the unique items/maps directory.\n");
1186  printf(" -v Print version information.\n");
1187  exit(EXIT_SUCCESS);
1188 }
1189 
1194 static void init_beforeplay(void) {
1195  init_archetype_pointers(); /* Setup global pointers to archetypes */
1196  finish_races(); /* overwrite race designations using entries in lib/races file */
1198  init_gods(); /* init linked list of gods from archs*/
1199  init_readable(); /* inits useful arrays for readable texts */
1200 
1201  switch (settings.dumpvalues) {
1202  case 1:
1203  print_monsters();
1204  cleanup();
1205  break;
1206 
1207  case 2:
1208  dump_abilities();
1209  cleanup();
1210  break;
1211 
1212  case 3:
1213  dump_artifacts();
1214  cleanup();
1215  break;
1216 
1217  case 4:
1218  dump_spells();
1219  cleanup();
1220  break;
1221 
1222  case 5:
1223  cleanup();
1224  break;
1225 
1226  case 6:
1227  dump_races();
1228  cleanup();
1229  break;
1230 
1231  case 7:
1232  dump_alchemy();
1233  cleanup();
1234  break;
1235 
1236  case 8:
1237  dump_gods();
1238  cleanup();
1239  break;
1240 
1241  case 9:
1243  cleanup();
1244  break;
1245 
1246  case 10:
1248  cleanup();
1249  break;
1250  }
1251 }
1252 
1258 static void init_startup(void) {
1259 #ifdef SHUTDOWN_FILE
1260  char buf[MAX_BUF];
1261  FILE *fp;
1262 
1263  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1264  if ((fp = fopen(buf, "r")) != NULL) {
1265  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1266  printf("%s", buf);
1267  fclose(fp);
1268  exit(1);
1269  }
1270 #endif
1271 
1272  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1273  LOG(llevError, "CrossFire: Playing not allowed.\n");
1274  exit(-1);
1275  }
1276 }
1277 
1281 static void signal_shutdown(int signum_unused) {
1282  (void) signum_unused; /* avoid unused warning if enambled */
1283  shutdown_flag += 1;
1284 }
1285 
1298 static void rec_sighup(int i) {
1299  (void)i;
1300  /* Don't call LOG(). It calls non-reentrant functions. The other
1301  * signal handlers shouldn't really call LOG() either. */
1302  if (logfile != stderr) {
1303  reopen_logfile = 1;
1304  }
1305 }
1306 
1310 void init_signals(void) {
1311 #ifndef WIN32 /* init_signals() remove signals */
1312  struct sigaction sa;
1313 
1314  sa.sa_sigaction = NULL;
1315  sigemptyset(&sa.sa_mask);
1316  sa.sa_flags = 0;
1317  sa.sa_handler = rec_sighup;
1318  sigaction(SIGHUP, &sa, NULL);
1319  signal(SIGINT, signal_shutdown);
1320  signal(SIGPIPE, SIG_IGN);
1321 #endif /* win32 */
1322 }
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:1083
llevError
@ llevError
Definition: logger.h:11
init_beforeplay
static void init_beforeplay(void)
Definition: init.cpp:1194
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:1263
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:1298
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:272
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:1370
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:1310
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:1281
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:1134
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:1071
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:1258
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:1123
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