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  char buf[MAX_BUF], *cp, dummy[1];
588  int has_val;
589  FILE *fp;
590 
591  dummy[0] = '\0';
592  snprintf(buf, sizeof(buf), "%s/settings", settings.confdir);
593 
594  /* We don't require a settings file at current time, but down the road,
595  * there will probably be so many values that not having a settings file
596  * will not be a good thing.
597  */
598  if ((fp = fopen(buf, "r")) == NULL) {
599  LOG(llevError, "Warning: No settings file found\n");
600  return;
601  }
602  while (fgets(buf, MAX_BUF-1, fp) != NULL) {
603  if (buf[0] == '#')
604  continue;
605  /* eliminate newline */
606  if ((cp = strrchr(buf, '\n')) != NULL)
607  *cp = '\0';
608 
609  /* Skip over empty lines */
610  if (buf[0] == 0)
611  continue;
612 
613  /* Skip all the spaces and set them to nulls. If not space,
614  * set cp to "" to make strcpy's and the like easier down below.
615  */
616  if ((cp = strchr(buf, ' ')) != NULL) {
617  while (*cp == ' ')
618  *cp++ = 0;
619  has_val = 1;
620  } else {
621  cp = dummy;
622  has_val = 0;
623  }
624 
625  if (!strcasecmp(buf, "metaserver_notification")) {
626  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
628  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
630  } else {
631  LOG(llevError, "load_settings: Unknown value for metaserver_notification: %s\n", cp);
632  }
633  } else if (!strcasecmp(buf, "metaserver_server")) {
634  if (has_val)
636  else
637  LOG(llevError, "load_settings: metaserver_server must have a value.\n");
638  } else if (!strcasecmp(buf, "motd")) {
639  if (has_val)
640  safe_strncpy(settings.motd, cp, sizeof(settings.motd));
641  else
642  LOG(llevError, "load_settings: motd must have a value.\n");
643  } else if (!strcasecmp(buf, "metaserver_host")) {
644  if (has_val)
646  else
647  LOG(llevError, "load_settings: metaserver_host must have a value.\n");
648  } else if (!strcasecmp(buf, "port")) {
649  set_csport(cp);
650  } else if (!strcasecmp(buf, "metaserver_port")) {
651  int port = atoi(cp);
652 
653  if (port < 1 || port > 65535)
654  LOG(llevError, "load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
655  else
656  settings.meta_port = port;
657  } else if (!strcasecmp(buf, "metaserver_comment")) {
659  } else if (!strcasecmp(buf, "worldmapstartx")) {
660  int size = atoi(cp);
661 
662  if (size < 0)
663  LOG(llevError, "load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
664  else
665  settings.worldmapstartx = size;
666  } else if (!strcasecmp(buf, "worldmapstarty")) {
667  int size = atoi(cp);
668 
669  if (size < 0)
670  LOG(llevError, "load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
671  else
672  settings.worldmapstarty = size;
673  } else if (!strcasecmp(buf, "worldmaptilesx")) {
674  int size = atoi(cp);
675 
676  if (size < 1)
677  LOG(llevError, "load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
678  else
679  settings.worldmaptilesx = size;
680  } else if (!strcasecmp(buf, "worldmaptilesy")) {
681  int size = atoi(cp);
682 
683  if (size < 1)
684  LOG(llevError, "load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
685  else
686  settings.worldmaptilesy = size;
687  } else if (!strcasecmp(buf, "worldmaptilesizex")) {
688  int size = atoi(cp);
689 
690  if (size < 1)
691  LOG(llevError, "load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
692  else
694  } else if (!strcasecmp(buf, "worldmaptilesizey")) {
695  int size = atoi(cp);
696 
697  if (size < 1)
698  LOG(llevError, "load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
699  else
701  } else if (!strcasecmp(buf, "fastclock")) {
702  int lev = atoi(cp);
703 
704  if (lev < 0)
705  LOG(llevError, "load_settings: fastclock must be at least 0, %d is invalid\n", lev);
706  else
707  settings.fastclock = lev;
708  } else if (!strcasecmp(buf, "not_permadeth")) {
709  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
711  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
713  } else {
714  LOG(llevError, "load_settings: Unknown value for not_permadeth: %s\n", cp);
715  }
716  } else if (!strcasecmp(buf, "resurrection")) {
717  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
719  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
721  } else {
722  LOG(llevError, "load_settings: Unknown value for resurrection: %s\n", cp);
723  }
724  } else if (!strcasecmp(buf, "set_title")) {
725  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
727  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
729  } else {
730  LOG(llevError, "load_settings: Unknown value for set_title: %s\n", cp);
731  }
732  } else if (!strcasecmp(buf, "search_items")) {
733  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
735  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
737  } else {
738  LOG(llevError, "load_settings: Unknown value for search_items: %s\n", cp);
739  }
740  } else if (!strcasecmp(buf, "spell_encumbrance")) {
741  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
743  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
745  } else {
746  LOG(llevError, "load_settings: Unknown value for spell_encumbrance: %s\n", cp);
747  }
748  } else if (!strcasecmp(buf, "spell_failure_effects")) {
749  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
751  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
753  } else {
754  LOG(llevError, "load_settings: Unknown value for spell_failure_effects: %s\n", cp);
755  }
756  } else if (!strcasecmp(buf, "casting_time")) {
757  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
759  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
761  } else {
762  LOG(llevError, "load_settings: Unknown value for casting_time: %s\n", cp);
763  }
764  } else if (!strcasecmp(buf, "real_wiz")) {
765  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
767  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
769  } else {
770  LOG(llevError, "load_settings: Unknown value for real_wiz: %s\n", cp);
771  }
772  } else if (!strcasecmp(buf, "recycle_tmp_maps")) {
773  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
775  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
777  } else {
778  LOG(llevError, "load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
779  }
780  } else if (!strcasecmp(buf, "always_show_hp")) {
781  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
783  } else if (!strcasecmp(cp, "damaged")) {
785  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
787  } else {
788  LOG(llevError, "load_settings: Unknown value for always_show_hp: %s\n", cp);
789  }
790  } else if (!strcasecmp(buf, "who_format")) {
791  if (has_val)
793  sizeof(settings.who_format));
794  } else if (!strcasecmp(buf, "who_wiz_format")) {
795  if (has_val) {
797  sizeof(settings.who_wiz_format));
798  }
799  } else if (!strcasecmp(buf, "spellpoint_level_depend")) {
800  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
802  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
804  } else {
805  LOG(llevError, "load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
806  }
807  } else if (!strcasecmp(buf, "stat_loss_on_death")) {
808  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
810  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
812  } else {
813  LOG(llevError, "load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
814  }
815  } else if (!strcasecmp(buf, "use_permanent_experience")) {
816  LOG(llevError, "use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
817  } else if (!strcasecmp(buf, "permanent_experience_percentage")) {
818  int val = atoi(cp);
819  if (val < 0 || val > 100)
820  LOG(llevError, "load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
821  else
823  } else if (!strcasecmp(buf, "death_penalty_percentage")) {
824  int val = atoi(cp);
825  if (val < 0 || val > 100)
826  LOG(llevError, "load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
827  else
829  } else if (!strcasecmp(buf, "death_penalty_levels")) {
830  int val = atoi(cp);
831  if (val < 0 || val > 255)
832  LOG(llevError, "load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
833  else
835  } else if (!strcasecmp(buf, "balanced_stat_loss")) {
836  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
838  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
840  } else {
841  LOG(llevError, "load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
842  }
843  } else if (!strcasecmp(buf, "simple_exp")) {
844  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
846  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
848  } else {
849  LOG(llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
850  }
851  } else if (!strcasecmp(buf, "item_power_factor")) {
852  float tmp = atof(cp);
853  if (tmp < 0)
854  LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
855  else
857  } else if (!strcasecmp(buf, "pk_luck_penalty")) {
858  int16_t val = atoi(cp);
859 
860  if (val < -100 || val > 100)
861  LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
862  else
864  } else if (!strcasecmp(buf, "set_friendly_fire")) {
865  int val = atoi(cp);
866 
867  if (val < 1 || val > 100)
868  LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
869  else
871  } else if (!strcasecmp(buf, "armor_max_enchant")) {
872  int max_e = atoi(cp);
873  if (max_e <= 0)
874  LOG(llevError, "load_settings: armor_max_enchant is %d\n", max_e);
875  else
876  settings.armor_max_enchant = max_e;
877  } else if (!strcasecmp(buf, "armor_weight_reduction")) {
878  int wr = atoi(cp);
879  if (wr < 0)
880  LOG(llevError, "load_settings: armor_weight_reduction is %d\n", wr);
881  else
883  } else if (!strcasecmp(buf, "armor_weight_linear")) {
884  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
886  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
888  } else {
889  LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
890  }
891  } else if (!strcasecmp(buf, "armor_speed_improvement")) {
892  int wr = atoi(cp);
893  if (wr < 0)
894  LOG(llevError, "load_settings: armor_speed_improvement is %d\n", wr);
895  else
897  } else if (!strcasecmp(buf, "armor_speed_linear")) {
898  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
900  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
902  } else {
903  LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
904  }
905  } else if (!strcasecmp(buf, "no_player_stealing")) {
906  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
908  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
910  } else {
911  LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp);
912  }
913  } else if (!strcasecmp(buf, "create_home_portals")) {
914  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
916  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
918  } else {
919  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
920  }
921  } else if (!strcasecmp(buf, "personalized_blessings")) {
922  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
924  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
926  } else {
927  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
928  }
929  } else if (!strcasecmp(buf, "pk_max_experience")) {
930  int64_t pkme = atoll(cp);
931  if (pkme < 0)
932  pkme = -1;
934  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
935  int pkmep = atoi(cp);
936  if (pkmep < 0) {
937  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
938  } else
940  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
941  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
943  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
945  } else {
946  LOG(llevError, "load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
947  }
948  } else if (!strcasecmp(buf, "allow_broken_converters")) {
949  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
951  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
953  } else {
954  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
955  }
956  } else if (!strcasecmp(buf, "log_timestamp")) {
957  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
959  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
961  } else {
962  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
963  }
964  } else if (!strcasecmp(buf, "log_timestamp_format")) {
967  } else if (!strcasecmp(buf, "starting_stat_min")) {
968  int val = atoi(cp);
969 
970  if (val < 1 || val > settings.max_stat || val > settings.starting_stat_max)
971  LOG(llevError, "load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
973  else
975  } else if (!strcasecmp(buf, "starting_stat_max")) {
976  int val = atoi(cp);
977 
978  if (val < 1 || val > settings.max_stat || val<settings.starting_stat_min)
979  LOG(llevError, "load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
981  else
983  } else if (!strcasecmp(buf, "starting_stat_points")) {
984  int val = atoi(cp);
985 
986  if (val < NUM_STATS * settings.starting_stat_min ||
988  LOG(llevError, "load_settings: starting_stat_points (%d) need to be within %d-%d\n",
990  else
992  } else if (!strcasecmp(buf, "roll_stat_points")) {
993  int val = atoi(cp);
994 
995  /* The 3 and 18 values are hard coded in because we know that
996  * roll_stat() generates a value between 3 and 18 - if that ever
997  * changed, this code should change also, but that code will eventually
998  * go away.
999  */
1000  if (val < NUM_STATS * 3 || val > NUM_STATS * 18)
1001  LOG(llevError, "load_settings: roll_stat_points need to be within %d-%d\n",
1002  NUM_STATS * 3, NUM_STATS * 18);
1003  else
1004  settings.roll_stat_points = val;
1005  } else if (!strcasecmp(buf, "special_break_map")) {
1006  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1008  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1010  } else {
1011  LOG(llevError, "load_settings: unknown value for special_break_map: %s\n", cp);
1012  }
1013  } else if (!strcasecmp(buf, "ignore_plugin_compatibility")) {
1014  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1016  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1018  } else {
1019  LOG(llevError, "load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1020  }
1021  } else if (!strcasecmp(buf, "account_block_create")) {
1022  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1024  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1026  } else {
1027  LOG(llevError, "load_settings: unknown value for account_block_create: %s\n", cp);
1028  }
1029  } else if (!strcasecmp(buf, "account_trusted_host")) {
1032  } else if (!strcasecmp(buf, "crypt_mode")) {
1033  int val = atoi(cp);
1034  if (val != 0 && val != 1) {
1035  LOG(llevError, "load_settings: crypt_mode must be 0 or 1\n");
1036  } else {
1037  settings.crypt_mode = val;
1038  }
1039  } else if (!strcasecmp(buf, "min_name")) {
1040  int val = atoi(cp);
1041 
1042  if (val < 1 || val > MAX_NAME )
1043  LOG(llevError, "load_settings: min_name (%d) need to be within %d-%d\n",
1044  val, 1, MAX_NAME);
1045  else
1046  settings.min_name = val;
1047  } else {
1048  LOG(llevError, "Unknown value in settings file: %s\n", buf);
1049  }
1050  }
1051  fclose(fp);
1052  if (settings.log_timestamp_format == NULL)
1053  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
1054 
1055  /*
1056  * The who formats are defined in config to be blank. They should have been
1057  * overridden by the settings file, if there are no entries however, it will
1058  * have stayed blank. Since this probably isn't what is wanted, we will check if
1059  * new formats have been specified, and if not we will use the old defaults.
1060  */
1061  if (!strcmp(settings.who_format, ""))
1062  strcpy(settings.who_format, "%N_%t%h%d%b%n<%M>");
1063  if (!strcmp(settings.who_wiz_format, ""))
1064  strcpy(settings.who_wiz_format, "%N_%t%h%d%b%nLevel %l <%M>(@%i)(%c)");
1065 }
1066 
1068  settings.add_hook("/materials", load_materials);
1069  settings.add_hook("/races", load_races);
1070 }
1071 
1079 void init(int argc, char **argv) {
1080  logfile = stderr;
1081 
1082  /* First argument pass - right now it does nothing, but in the future specifying
1083  * the LibDir in this pass would be reasonable. */
1084  parse_args(argc, argv, 1);
1085 
1087  init_modules();
1088 
1089  init_library(); /* Must be called early */
1090  load_settings(); /* Load the settings file */
1091  parse_args(argc, argv, 2);
1092 
1093  LOG(llevInfo, "Crossfire %s\n", FULL_VERSION);
1094  SRANDOM(time(NULL));
1095 
1096  init_startup(); /* Check shutdown/forbid files */
1097  init_signals(); /* Sets up signal interceptions */
1098  commands_init(); /* Sort command tables */
1099  read_map_log(); /* Load up the old temp map files */
1100  init_skills();
1101  init_ob_methods();
1102  cftimer_init();
1103  hiscore_init();
1104 
1105  parse_args(argc, argv, 3);
1106 
1107  init_beforeplay();
1108  init_server();
1109  metaserver2_init();
1110  accounts_load();
1111  reset_sleep();
1112 }
1113 
1119 void free_server(void) {
1120  free_materials();
1121  free_races();
1122  free_quest();
1123  std::for_each(settings.disabled_plugins.begin(), settings.disabled_plugins.end(), [] (char *item) { free(item); });
1124  settings.disabled_plugins.clear();
1125 }
1126 
1130 static void help(void) {
1131  printf("Usage: crossfire-server [options]\n\n");
1132 
1133  printf("Options:\n");
1134  printf(" -conf Set the directory to find configuration files.\n");
1135  printf(" -d Turn on extra debugging messages.\n");
1136  printf(" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1137  printf(" -disable-module\n"
1138  " Disable specified module, by its name\n"
1139  " Can be specified multiple times. 'All' disables all modules.\n");
1140  printf(" -enable-module\n"
1141  " Enable specified module, by its name\n"
1142  " Can be specified multiple times. 'All' enables all modules.\n");
1143  printf(" -disable-plugin\n"
1144  " Disables specified plugin. Use the name without the extension.\n"
1145  " Can be specified multiple times. 'All' disables all plugins.\n");
1146  printf(" -dump-anims Dump animations.\n");
1147  printf(" -h Print this help message.\n");
1148  printf(" -ignore-assets-errors\n");
1149  printf(" Allow going on even if there are errors in assets.\n");
1150  printf(" Warning: this may lead to strange behaviour.\n");
1151  printf(" -list-modules\n"
1152  " List built-in modules and exit.\n");
1153  printf(" -local Set the local data (var/) directory.\n");
1154  printf(" -log <file> Write logging information to the given file.\n");
1155  printf(" -m List suggested experience for all monsters.\n");
1156  printf(" -m2 Dump monster abilities.\n");
1157  printf(" -m3 Dump artifact information.\n");
1158  printf(" -m4 Dump spell information.\n");
1159  printf(" -m5 Dump skill information.\n");
1160  printf(" -m6 Dump race information.\n");
1161  printf(" -m7 Dump alchemy information.\n");
1162  printf(" -m8 Dump gods information.\n");
1163  printf(" -m9 Dump more alchemy information (formula checking).\n");
1164  printf(" -maps Set the map directory.\n");
1165  printf(" -mexp Dump the experience table.\n");
1166  printf(" -mon Turn on monster debugging.\n");
1167  printf(" -mq Dump the quest list.\n");
1168  printf(" -mt <name> Dump a list of treasures for a monster.\n");
1169  printf(" -n Turn off debugging messages if on by default.\n");
1170  printf(" -p <port> Specifies the port to listen on for incoming connections.\n");
1171  printf(" -pack-assets <type> <filename>\n");
1172  printf(" Packs specified assets type to the specified filename.\n");
1173  printf(" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1174  printf(" The file format will be tar ('images') or text (everything else).\n");
1175  printf(" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1176  printf(" In this case the file will be in tar format.\n");
1177  printf(" -playerdir Set the player files directory.\n");
1178  printf(" -regions Set the region file.\n");
1179  printf(" -templatedir Set the template map directory.\n");
1180  printf(" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1181  printf(" -uniquedir Set the unique items/maps directory.\n");
1182  printf(" -v Print version information.\n");
1183  exit(EXIT_SUCCESS);
1184 }
1185 
1190 static void init_beforeplay(void) {
1191  init_archetype_pointers(); /* Setup global pointers to archetypes */
1192  finish_races(); /* overwrite race designations using entries in lib/races file */
1194  init_gods(); /* init linked list of gods from archs*/
1195  init_readable(); /* inits useful arrays for readable texts */
1196 
1197  switch (settings.dumpvalues) {
1198  case 1:
1199  print_monsters();
1200  cleanup();
1201 
1202  case 2:
1203  dump_abilities();
1204  cleanup();
1205 
1206  case 3:
1207  dump_artifacts();
1208  cleanup();
1209 
1210  case 4:
1211  dump_spells();
1212  cleanup();
1213 
1214  case 5:
1215  cleanup();
1216 
1217  case 6:
1218  dump_races();
1219  cleanup();
1220 
1221  case 7:
1222  dump_alchemy();
1223  cleanup();
1224 
1225  case 8:
1226  dump_gods();
1227  cleanup();
1228 
1229  case 9:
1231  cleanup();
1232 
1233  case 10:
1235  cleanup();
1236  }
1237 }
1238 
1244 static void init_startup(void) {
1245 #ifdef SHUTDOWN_FILE
1246  char buf[MAX_BUF];
1247  FILE *fp;
1248 
1249  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1250  if ((fp = fopen(buf, "r")) != NULL) {
1251  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1252  printf("%s", buf);
1253  fclose(fp);
1254  exit(1);
1255  }
1256 #endif
1257 
1258  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1259  LOG(llevError, "CrossFire: Playing not allowed.\n");
1260  exit(-1);
1261  }
1262 }
1263 
1267 static void signal_shutdown(int signum_unused) {
1268  (void) signum_unused; /* avoid unused warning if enambled */
1269  shutdown_flag += 1;
1270 }
1271 
1284 static void rec_sighup(int i) {
1285  (void)i;
1286  /* Don't call LOG(). It calls non-reentrant functions. The other
1287  * signal handlers shouldn't really call LOG() either. */
1288  if (logfile != stderr) {
1289  reopen_logfile = 1;
1290  }
1291 }
1292 
1296 void init_signals(void) {
1297 #ifndef WIN32 /* init_signals() remove signals */
1298  struct sigaction sa;
1299 
1300  sa.sa_sigaction = NULL;
1301  sigemptyset(&sa.sa_mask);
1302  sa.sa_flags = 0;
1303  sa.sa_handler = rec_sighup;
1304  sigaction(SIGHUP, &sa, NULL);
1305  signal(SIGINT, signal_shutdown);
1306  signal(SIGPIPE, SIG_IGN);
1307 #endif /* win32 */
1308 }
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:138
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:1079
llevError
@ llevError
Definition: logger.h:11
init_beforeplay
static void init_beforeplay(void)
Definition: init.cpp:1190
Settings::regions
const char * regions
Definition: global.h:252
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
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:590
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:1257
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:1284
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:70
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
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:1551
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:1363
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:1296
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:339
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::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:894
python_init.path
path
Definition: python_init.py:8
Settings::motd
char motd[MAX_BUF]
Definition: global.h:278
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:149
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:1267
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:510
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:570
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:26
init_skills
void init_skills(void)
Definition: skill_util.cpp:91
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:322
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:352
help
static void help(void)
Definition: init.cpp:1130
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:132
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:1244
dump_animations
void dump_animations(void)
Definition: anim.cpp:180
add_server_collect_hooks
void add_server_collect_hooks()
Definition: init.cpp:1067
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:1244
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:419
set_disable_module
static void set_disable_module(const char *name)
Definition: init.cpp:318
free_server
void free_server(void)
Definition: init.cpp:1119
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