Crossfire Server, Trunk  1.75.0
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 static void server_dump_bonuses() {
351  cleanup();
352 }
353 
356 typedef void (*cmdlinefunc_args0)(void);
357 typedef void (*cmdlinefunc_args1)(const char* arg1);
358 typedef void (*cmdlinefunc_args2)(const char* arg1, const char* arg2);
367  const char *cmd_option;
368  uint8_t num_args;
369  uint8_t pass;
370  void (*func)();
374 };
375 
384 static struct Command_Line_Options options[] = {
388  { "-conf", 1, 1, (cmdlinefunc_args0)set_confdir },
389  { "-d", 0, 1, (cmdlinefunc_args0)set_debug },
390  { "-data", 1, 1, (cmdlinefunc_args0)set_datadir },
391  { "-disable-plugin", 1, 1, (cmdlinefunc_args0)set_disable_plugin },
392  { "-disable-module", 1, 1, (cmdlinefunc_args0)set_disable_module },
393  { "-enable-module", 1, 1, (cmdlinefunc_args0)set_enable_module },
394  { "-list-modules", 0, 1, (cmdlinefunc_args0)list_modules },
395  { "-h", 0, 1, (cmdlinefunc_args0)help },
396  { "-ignore-assets-errors", 0, 1, (cmdlinefunc_args0)set_ignore_assets_errors },
397  { "-local", 1, 1, (cmdlinefunc_args0)set_localdir },
398  { "-log", 1, 1, (cmdlinefunc_args0)set_logfile },
399  { "-maps", 1, 1, (cmdlinefunc_args0)set_mapdir },
400  { "-mon", 0, 1, (cmdlinefunc_args0)set_mondebug },
401  { "-n", 0, 1, (cmdlinefunc_args0)unset_debug },
402  { "-playerdir", 1, 1, (cmdlinefunc_args0)set_playerdir },
403  { "-regions", 1, 1, (cmdlinefunc_args0)set_regions },
404  { "-templatedir", 1, 1, (cmdlinefunc_args0)set_templatedir },
405  { "-tmpdir", 1, 1, (cmdlinefunc_args0)set_tmpdir },
406  { "-uniquedir", 1, 1, (cmdlinefunc_args0)set_uniquedir },
407  { "-v", 0, 1, (cmdlinefunc_args0)call_version },
408 
409 #ifdef WIN32
410  /* Windows service stuff */
411  { "-regsrv", 0, 1, service_register },
412  { "-unregsrv", 0, 1, service_unregister },
413  { "-srv", 0, 1, service_handle },
414 #endif
415 
419  { "-p", 1, 2, (cmdlinefunc_args0)set_csport },
420 
424  { "-m", 0, 3, (cmdlinefunc_args0)set_dumpmon1 },
425  { "-m2", 0, 3, (cmdlinefunc_args0)set_dumpmon2 },
426  { "-m3", 0, 3, (cmdlinefunc_args0)set_dumpmon3 },
427  { "-m4", 0, 3, (cmdlinefunc_args0)set_dumpmon4 },
428  { "-m5", 0, 3, (cmdlinefunc_args0)set_dumpmon5 },
429  { "-m6", 0, 3, (cmdlinefunc_args0)set_dumpmon6 },
430  { "-m7", 0, 3, (cmdlinefunc_args0)set_dumpmon7 },
431  { "-m8", 0, 3, (cmdlinefunc_args0)set_dumpmon8 },
432  { "-m9", 0, 3, (cmdlinefunc_args0)set_dumpmon9 },
433  { "-mt", 1, 3, (cmdlinefunc_args0)set_dumpmont },
434  { "-mexp", 0, 3, (cmdlinefunc_args0)dump_experience },
435  { "-mq", 0, 3, (cmdlinefunc_args0)dump_quests },
436  { "-dump-anims", 0, 3, (cmdlinefunc_args0)server_dump_animations },
437  { "-dump-faces", 0, 3, (cmdlinefunc_args0)server_dump_faces },
438  { "-pack-assets", 2, 3, (cmdlinefunc_args0)server_pack_assets },
439  { "-dump-stat-bonuses", 0, 3, (cmdlinefunc_args0)server_dump_bonuses },
440 };
441 
456 static void parse_args(int argc, char *argv[], int pass) {
457  size_t i;
458  int on_arg = 1;
459 
460  while (on_arg < argc) {
461  for (i = 0; i < sizeof(options)/sizeof(struct Command_Line_Options); i++) {
462  if (!strcmp(options[i].cmd_option, argv[on_arg])) {
463  /* Found a matching option, but should not be processed on
464  * this pass. Just skip over it
465  */
466  if (options[i].pass != pass) {
467  on_arg += options[i].num_args+1;
468  break;
469  }
470  if (options[i].num_args) {
471  if ((on_arg+options[i].num_args) >= argc) {
472  fprintf(stderr, "%s requires an argument.\n", options[i].cmd_option);
473  exit(1);
474  }
475 
476  if (options[i].num_args == 1)
477  ((cmdlinefunc_args1)options[i].func)(argv[on_arg+1]);
478  if (options[i].num_args == 2)
479  ((cmdlinefunc_args2)options[i].func)(argv[on_arg+1], argv[on_arg+2]);
480  on_arg += options[i].num_args+1;
481  } else { /* takes no args */
483  on_arg++;
484  }
485  break;
486  }
487  }
488  if (i == sizeof(options)/sizeof(struct Command_Line_Options)) {
489  fprintf(stderr, "Unknown option: %s\n", argv[on_arg]);
490  fprintf(stderr, "Type '%s -h' for usage.\n", argv[0]);
491  exit(1);
492  }
493  }
494 
495  if (should_exit) {
496  cleanup();
497  }
498 }
499 
509  materialtype_t *mt;
510  int i;
511 
512  mt = (materialtype_t *)malloc(sizeof(materialtype_t));
513  if (mt == NULL)
515  mt->name = NULL;
516  mt->description = NULL;
517  for (i = 0; i < NROFATTACKS; i++) {
518  mt->save[i] = 0;
519  mt->mod[i] = 0;
520  }
521  return mt;
522 }
523 
528 static void load_materials(BufferReader *reader, const char *filename) {
529  char *buf, *cp, *next;
530  materialtype_t *mt;
531  int i, value;
532  (void)filename;
533 
534  while ((buf = bufferreader_next_line(reader)) != NULL) {
535  if (*buf == '#')
536  continue;
537  cp = buf;
538  while (*cp == ' ') /* Skip blanks */
539  cp++;
540  if (!strncmp(cp, "name", 4)) {
541  mt = get_empty_mat();
542  materials.push_back(mt);
543  mt->name = add_string(strchr(cp, ' ')+1);
544  mt->description = add_refcount(mt->name);
545  } else if (!strncmp(cp, "description", 11)) {
546  FREE_AND_COPY_IF(mt->description, strchr(cp, ' ')+1);
547  } else if (sscanf(cp, "material %d", &value)) {
548  mt->material = value;
549  } else if (!strncmp(cp, "saves", 5)) {
550  cp = strchr(cp, ' ')+1;
551  for (i = 0; i < NROFATTACKS; i++) {
552  if (cp == NULL) {
553  mt->save[i] = 0;
554  continue;
555  }
556  if ((next = strchr(cp, ',')) != NULL)
557  *(next++) = '\0';
558  sscanf(cp, "%d", &value);
559  mt->save[i] = (int8_t)value;
560  cp = next;
561  }
562  } else if (!strncmp(cp, "mods", 4)) {
563  cp = strchr(cp, ' ')+1;
564  for (i = 0; i < NROFATTACKS; i++) {
565  if (cp == NULL) {
566  mt->save[i] = 0;
567  continue;
568  }
569  if ((next = strchr(cp, ',')) != NULL)
570  *(next++) = '\0';
571  sscanf(cp, "%d", &value);
572  mt->mod[i] = (int8_t)value;
573  cp = next;
574  }
575  }
576  }
577  LOG(llevDebug, "loaded %d material type data\n", static_cast<int>(materials.size()));
578 }
579 
583 static void free_materials(void) {
584  for (auto material : materials) {
585  free(material);
586  }
587  materials.clear();
588 }
589 
595 static void load_settings(void) {
596  static char motd[MAX_BUF] = { 0 };
597  char buf[MAX_BUF], *cp, dummy[1];
598  int has_val;
599  FILE *fp;
600 
601  dummy[0] = '\0';
602  snprintf(buf, sizeof(buf), "%s/settings", settings.confdir);
603 
604  /* We don't require a settings file at current time, but down the road,
605  * there will probably be so many values that not having a settings file
606  * will not be a good thing.
607  */
608  if ((fp = fopen(buf, "r")) == NULL) {
609  LOG(llevError, "Warning: No settings file found\n");
610  return;
611  }
612  while (fgets(buf, MAX_BUF-1, fp) != NULL) {
613  if (buf[0] == '#')
614  continue;
615  /* eliminate newline */
616  if ((cp = strrchr(buf, '\n')) != NULL)
617  *cp = '\0';
618 
619  /* Skip over empty lines */
620  if (buf[0] == 0)
621  continue;
622 
623  /* Skip all the spaces and set them to nulls. If not space,
624  * set cp to "" to make strcpy's and the like easier down below.
625  */
626  if ((cp = strchr(buf, ' ')) != NULL) {
627  while (*cp == ' ')
628  *cp++ = 0;
629  has_val = 1;
630  } else {
631  cp = dummy;
632  has_val = 0;
633  }
634 
635  if (!strcasecmp(buf, "metaserver_notification")) {
636  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
638  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
640  } else {
641  LOG(llevError, "load_settings: Unknown value for metaserver_notification: %s\n", cp);
642  }
643  } else if (!strcasecmp(buf, "metaserver_server")) {
644  if (has_val)
646  else
647  LOG(llevError, "load_settings: metaserver_server must have a value.\n");
648  } else if (!strcasecmp(buf, "motd")) {
649  if (has_val) {
650  safe_strncpy(motd, cp, sizeof(motd));
651  settings.motd = motd;
652  } else
653  LOG(llevError, "load_settings: motd must have a value.\n");
654  } else if (!strcasecmp(buf, "metaserver_host")) {
655  if (has_val)
657  else
658  LOG(llevError, "load_settings: metaserver_host must have a value.\n");
659  } else if (!strcasecmp(buf, "port")) {
660  set_csport(cp);
661  } else if (!strcasecmp(buf, "metaserver_port")) {
662  int port = atoi(cp);
663 
664  if (port < 1 || port > 65535)
665  LOG(llevError, "load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
666  else
667  settings.meta_port = port;
668  } else if (!strcasecmp(buf, "metaserver_comment")) {
670  } else if (!strcasecmp(buf, "worldmapstartx")) {
671  int size = atoi(cp);
672 
673  if (size < 0)
674  LOG(llevError, "load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
675  else
676  settings.worldmapstartx = size;
677  } else if (!strcasecmp(buf, "worldmapstarty")) {
678  int size = atoi(cp);
679 
680  if (size < 0)
681  LOG(llevError, "load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
682  else
683  settings.worldmapstarty = size;
684  } else if (!strcasecmp(buf, "worldmaptilesx")) {
685  int size = atoi(cp);
686 
687  if (size < 1)
688  LOG(llevError, "load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
689  else
690  settings.worldmaptilesx = size;
691  } else if (!strcasecmp(buf, "worldmaptilesy")) {
692  int size = atoi(cp);
693 
694  if (size < 1)
695  LOG(llevError, "load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
696  else
697  settings.worldmaptilesy = size;
698  } else if (!strcasecmp(buf, "worldmaptilesizex")) {
699  int size = atoi(cp);
700 
701  if (size < 1)
702  LOG(llevError, "load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
703  else
705  } else if (!strcasecmp(buf, "worldmaptilesizey")) {
706  int size = atoi(cp);
707 
708  if (size < 1)
709  LOG(llevError, "load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
710  else
712  } else if (!strcasecmp(buf, "fastclock")) {
713  int lev = atoi(cp);
714 
715  if (lev < 0)
716  LOG(llevError, "load_settings: fastclock must be at least 0, %d is invalid\n", lev);
717  else
718  settings.fastclock = lev;
719  } else if (!strcasecmp(buf, "not_permadeth")) {
720  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
722  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
724  } else {
725  LOG(llevError, "load_settings: Unknown value for not_permadeth: %s\n", cp);
726  }
727  } else if (!strcasecmp(buf, "resurrection")) {
728  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
730  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
732  } else {
733  LOG(llevError, "load_settings: Unknown value for resurrection: %s\n", cp);
734  }
735  } else if (!strcasecmp(buf, "set_title")) {
736  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
738  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
740  } else {
741  LOG(llevError, "load_settings: Unknown value for set_title: %s\n", cp);
742  }
743  } else if (!strcasecmp(buf, "search_items")) {
744  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
746  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
748  } else {
749  LOG(llevError, "load_settings: Unknown value for search_items: %s\n", cp);
750  }
751  } else if (!strcasecmp(buf, "spell_encumbrance")) {
752  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
754  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
756  } else {
757  LOG(llevError, "load_settings: Unknown value for spell_encumbrance: %s\n", cp);
758  }
759  } else if (!strcasecmp(buf, "spell_failure_effects")) {
760  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
762  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
764  } else {
765  LOG(llevError, "load_settings: Unknown value for spell_failure_effects: %s\n", cp);
766  }
767  } else if (!strcasecmp(buf, "casting_time")) {
768  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
770  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
772  } else {
773  LOG(llevError, "load_settings: Unknown value for casting_time: %s\n", cp);
774  }
775  } else if (!strcasecmp(buf, "real_wiz")) {
776  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
778  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
780  } else {
781  LOG(llevError, "load_settings: Unknown value for real_wiz: %s\n", cp);
782  }
783  } else if (!strcasecmp(buf, "recycle_tmp_maps")) {
784  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
786  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
788  } else {
789  LOG(llevError, "load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
790  }
791  } else if (!strcasecmp(buf, "always_show_hp")) {
792  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
794  } else if (!strcasecmp(cp, "damaged")) {
796  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
798  } else {
799  LOG(llevError, "load_settings: Unknown value for always_show_hp: %s\n", cp);
800  }
801  } else if (!strcasecmp(buf, "who_format")) {
802  if (has_val)
804  sizeof(settings.who_format));
805  } else if (!strcasecmp(buf, "who_wiz_format")) {
806  if (has_val) {
808  sizeof(settings.who_wiz_format));
809  }
810  } else if (!strcasecmp(buf, "spellpoint_level_depend")) {
811  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
813  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
815  } else {
816  LOG(llevError, "load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
817  }
818  } else if (!strcasecmp(buf, "stat_loss_on_death")) {
819  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
821  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
823  } else {
824  LOG(llevError, "load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
825  }
826  } else if (!strcasecmp(buf, "use_permanent_experience")) {
827  LOG(llevError, "use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
828  } else if (!strcasecmp(buf, "permanent_experience_percentage")) {
829  int val = atoi(cp);
830  if (val < 0 || val > 100)
831  LOG(llevError, "load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
832  else
834  } else if (!strcasecmp(buf, "death_penalty_percentage")) {
835  int val = atoi(cp);
836  if (val < 0 || val > 100)
837  LOG(llevError, "load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
838  else
840  } else if (!strcasecmp(buf, "death_penalty_levels")) {
841  int val = atoi(cp);
842  if (val < 0 || val > 255)
843  LOG(llevError, "load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
844  else
846  } else if (!strcasecmp(buf, "balanced_stat_loss")) {
847  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
849  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
851  } else {
852  LOG(llevError, "load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
853  }
854  } else if (!strcasecmp(buf, "simple_exp")) {
855  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
857  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
859  } else {
860  LOG(llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
861  }
862  } else if (!strcasecmp(buf, "item_power_factor")) {
863  float tmp = atof(cp);
864  if (tmp < 0)
865  LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
866  else
868  } else if (!strcasecmp(buf, "pk_luck_penalty")) {
869  int16_t val = atoi(cp);
870 
871  if (val < -100 || val > 100)
872  LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
873  else
875  } else if (!strcasecmp(buf, "set_friendly_fire")) {
876  int val = atoi(cp);
877 
878  if (val < 1 || val > 100)
879  LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
880  else
882  } else if (!strcasecmp(buf, "armor_max_enchant")) {
883  int max_e = atoi(cp);
884  if (max_e <= 0)
885  LOG(llevError, "load_settings: armor_max_enchant is %d\n", max_e);
886  else
887  settings.armor_max_enchant = max_e;
888  } else if (!strcasecmp(buf, "armor_weight_reduction")) {
889  int wr = atoi(cp);
890  if (wr < 0)
891  LOG(llevError, "load_settings: armor_weight_reduction is %d\n", wr);
892  else
894  } else if (!strcasecmp(buf, "armor_weight_linear")) {
895  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
897  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
899  } else {
900  LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
901  }
902  } else if (!strcasecmp(buf, "armor_speed_improvement")) {
903  int wr = atoi(cp);
904  if (wr < 0)
905  LOG(llevError, "load_settings: armor_speed_improvement is %d\n", wr);
906  else
908  } else if (!strcasecmp(buf, "armor_speed_linear")) {
909  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
911  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
913  } else {
914  LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
915  }
916  } else if (!strcasecmp(buf, "no_player_stealing")) {
917  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
919  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
921  } else {
922  LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp);
923  }
924  } else if (!strcasecmp(buf, "create_home_portals")) {
925  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
926 #ifdef TRY_BROKEN_TOWN_PORTALS
928 #else
929  LOG(llevError, "load_settings: create_home_portals is currently broken. It results in town portals that prematurely reset when the apartment is swapped.\n");
930 #endif
931  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
933  } else {
934  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
935  }
936  } else if (!strcasecmp(buf, "personalized_blessings")) {
937  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
939  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
941  } else {
942  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
943  }
944  } else if (!strcasecmp(buf, "pk_max_experience")) {
945  int64_t pkme = atoll(cp);
946  if (pkme < 0)
947  pkme = -1;
949  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
950  int pkmep = atoi(cp);
951  if (pkmep < 0) {
952  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
953  } else
955  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
956  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
958  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
960  } else {
961  LOG(llevError, "load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
962  }
963  } else if (!strcasecmp(buf, "allow_broken_converters")) {
964  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
966  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
968  } else {
969  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
970  }
971  } else if (!strcasecmp(buf, "log_timestamp")) {
972  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
974  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
976  } else {
977  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
978  }
979  } else if (!strcasecmp(buf, "log_timestamp_format")) {
982  } else if (!strcasecmp(buf, "starting_stat_min")) {
983  int val = atoi(cp);
984 
985  if (val < 1 || val > settings.max_stat || val > settings.starting_stat_max)
986  LOG(llevError, "load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
988  else
990  } else if (!strcasecmp(buf, "starting_stat_max")) {
991  int val = atoi(cp);
992 
993  if (val < 1 || val > settings.max_stat || val<settings.starting_stat_min)
994  LOG(llevError, "load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
996  else
998  } else if (!strcasecmp(buf, "starting_stat_points")) {
999  int val = atoi(cp);
1000 
1001  if (val < NUM_STATS * settings.starting_stat_min ||
1003  LOG(llevError, "load_settings: starting_stat_points (%d) need to be within %d-%d\n",
1005  else
1007  } else if (!strcasecmp(buf, "roll_stat_points")) {
1008  int val = atoi(cp);
1009 
1010  /* The 3 and 18 values are hard coded in because we know that
1011  * roll_stat() generates a value between 3 and 18 - if that ever
1012  * changed, this code should change also, but that code will eventually
1013  * go away.
1014  */
1015  if (val < NUM_STATS * 3 || val > NUM_STATS * 18)
1016  LOG(llevError, "load_settings: roll_stat_points need to be within %d-%d\n",
1017  NUM_STATS * 3, NUM_STATS * 18);
1018  else
1019  settings.roll_stat_points = val;
1020  } else if (!strcasecmp(buf, "special_break_map")) {
1021  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1023  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1025  } else {
1026  LOG(llevError, "load_settings: unknown value for special_break_map: %s\n", cp);
1027  }
1028  } else if (!strcasecmp(buf, "ignore_plugin_compatibility")) {
1029  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1031  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1033  } else {
1034  LOG(llevError, "load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1035  }
1036  } else if (!strcasecmp(buf, "account_block_create")) {
1037  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1039  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1041  } else {
1042  LOG(llevError, "load_settings: unknown value for account_block_create: %s\n", cp);
1043  }
1044  } else if (!strcasecmp(buf, "account_trusted_host")) {
1047  } else if (!strcasecmp(buf, "crypt_mode")) {
1048  int val = atoi(cp);
1049  if (val != 0 && val != 1) {
1050  LOG(llevError, "load_settings: crypt_mode must be 0 or 1\n");
1051  } else {
1052  settings.crypt_mode = val;
1053  }
1054  } else if (!strcasecmp(buf, "min_name")) {
1055  int val = atoi(cp);
1056 
1057  if (val < 1 || val > MAX_NAME )
1058  LOG(llevError, "load_settings: min_name (%d) need to be within %d-%d\n",
1059  val, 1, MAX_NAME);
1060  else
1061  settings.min_name = val;
1062  } else if (!strcasecmp(buf, "stat_file")) {
1064  } else {
1065  LOG(llevError, "Unknown value in settings file: %s\n", buf);
1066  }
1067  }
1068  fclose(fp);
1069  if (settings.log_timestamp_format == NULL)
1070  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
1071 
1072  /*
1073  * The who formats are defined in config to be blank. They should have been
1074  * overridden by the settings file, if there are no entries however, it will
1075  * have stayed blank. Since this probably isn't what is wanted, we will check if
1076  * new formats have been specified, and if not we will use the old defaults.
1077  */
1078  if (!strcmp(settings.who_format, ""))
1079  strcpy(settings.who_format, "%N_%t%h%d%b%n<%M>");
1080  if (!strcmp(settings.who_wiz_format, ""))
1081  strcpy(settings.who_wiz_format, "%N_%t%h%d%b%nLevel %l <%M>(@%i)(%c)");
1082 }
1083 
1085  settings.add_hook("/materials", load_materials);
1086  settings.add_hook("/races", load_races);
1087 }
1088 
1096 void init(int argc, char **argv) {
1097  logfile = stderr;
1098 
1099  /* First argument pass - right now it does nothing, but in the future specifying
1100  * the LibDir in this pass would be reasonable. */
1101  parse_args(argc, argv, 1);
1102 
1104  init_modules();
1105 
1106  init_library(); /* Must be called early */
1107  load_settings(); /* Load the settings file */
1108  parse_args(argc, argv, 2);
1109 
1110  LOG(llevInfo, "Crossfire %s\n", FULL_VERSION);
1111  SRANDOM(time(NULL));
1112 
1113  init_startup(); /* Check shutdown/forbid files */
1114  init_signals(); /* Sets up signal interceptions */
1115  commands_init(); /* Sort command tables */
1116  read_map_log(); /* Load up the old temp map files */
1117  init_skills();
1118  init_ob_methods();
1119  cftimer_init();
1120  hiscore_init();
1121 
1122  parse_args(argc, argv, 3);
1123 
1124  init_beforeplay();
1125  init_server();
1126  metaserver2_init();
1127  accounts_load();
1128  reset_sleep();
1129 }
1130 
1136 void free_server(void) {
1137  free_materials();
1138  free_races();
1139  free_quest();
1140  std::for_each(settings.disabled_plugins.begin(), settings.disabled_plugins.end(), [] (char *item) { free(item); });
1141  settings.disabled_plugins.clear();
1142 }
1143 
1147 static void help(void) {
1148  printf("Usage: crossfire-server [options]\n\n");
1149 
1150  printf("Options:\n");
1151  printf(" -conf Set the directory to find configuration files.\n");
1152  printf(" -d Turn on extra debugging messages.\n");
1153  printf(" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1154  printf(" -disable-module\n"
1155  " Disable specified module, by its name\n"
1156  " Can be specified multiple times. 'All' disables all modules.\n");
1157  printf(" -enable-module\n"
1158  " Enable specified module, by its name\n"
1159  " Can be specified multiple times. 'All' enables all modules.\n");
1160  printf(" -disable-plugin\n"
1161  " Disables specified plugin. Use the name without the extension.\n"
1162  " Can be specified multiple times. 'All' disables all plugins.\n");
1163  printf(" -dump-anims Dump animations.\n");
1164  printf(" -h Print this help message.\n");
1165  printf(" -ignore-assets-errors\n");
1166  printf(" Allow going on even if there are errors in assets.\n");
1167  printf(" Warning: this may lead to strange behaviour.\n");
1168  printf(" -list-modules\n"
1169  " List built-in modules and exit.\n");
1170  printf(" -local Set the local data (var/) directory.\n");
1171  printf(" -log <file> Write logging information to the given file.\n");
1172  printf(" -m List suggested experience for all monsters.\n");
1173  printf(" -m2 Dump monster abilities.\n");
1174  printf(" -m3 Dump artifact information.\n");
1175  printf(" -m4 Dump spell information.\n");
1176  printf(" -m5 Dump skill information.\n");
1177  printf(" -m6 Dump race information.\n");
1178  printf(" -m7 Dump alchemy information.\n");
1179  printf(" -m8 Dump gods information.\n");
1180  printf(" -m9 Dump more alchemy information (formula checking).\n");
1181  printf(" -maps Set the map directory.\n");
1182  printf(" -mexp Dump the experience table.\n");
1183  printf(" -mon Turn on monster debugging.\n");
1184  printf(" -mq Dump the quest list.\n");
1185  printf(" -mt <name> Dump a list of treasures for a monster.\n");
1186  printf(" -n Turn off debugging messages if on by default.\n");
1187  printf(" -p <port> Specifies the port to listen on for incoming connections.\n");
1188  printf(" -pack-assets <type> <filename>\n");
1189  printf(" Packs specified assets type to the specified filename.\n");
1190  printf(" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1191  printf(" The file format will be tar ('images') or text (everything else).\n");
1192  printf(" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1193  printf(" In this case the file will be in tar format.\n");
1194  printf(" -playerdir Set the player files directory.\n");
1195  printf(" -regions Set the region file.\n");
1196  printf(" -templatedir Set the template map directory.\n");
1197  printf(" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1198  printf(" -uniquedir Set the unique items/maps directory.\n");
1199  printf(" -v Print version information.\n");
1200  exit(EXIT_SUCCESS);
1201 }
1202 
1207 static void init_beforeplay(void) {
1208  init_archetype_pointers(); /* Setup global pointers to archetypes */
1209  finish_races(); /* overwrite race designations using entries in lib/races file */
1211  init_gods(); /* init linked list of gods from archs*/
1212  init_readable(); /* inits useful arrays for readable texts */
1213 
1214  switch (settings.dumpvalues) {
1215  case 1:
1216  print_monsters();
1217  cleanup();
1218  break;
1219 
1220  case 2:
1221  dump_abilities();
1222  cleanup();
1223  break;
1224 
1225  case 3:
1226  dump_artifacts();
1227  cleanup();
1228  break;
1229 
1230  case 4:
1231  dump_spells();
1232  cleanup();
1233  break;
1234 
1235  case 5:
1236  cleanup();
1237  break;
1238 
1239  case 6:
1240  dump_races();
1241  cleanup();
1242  break;
1243 
1244  case 7:
1245  dump_alchemy();
1246  cleanup();
1247  break;
1248 
1249  case 8:
1250  dump_gods();
1251  cleanup();
1252  break;
1253 
1254  case 9:
1256  cleanup();
1257  break;
1258 
1259  case 10:
1261  cleanup();
1262  break;
1263  }
1264 }
1265 
1271 static void init_startup(void) {
1272 #ifdef SHUTDOWN_FILE
1273  char buf[MAX_BUF];
1274  FILE *fp;
1275 
1276  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1277  if ((fp = fopen(buf, "r")) != NULL) {
1278  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1279  printf("%s", buf);
1280  fclose(fp);
1281  exit(1);
1282  }
1283 #endif
1284 
1285  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1286  LOG(llevError, "CrossFire: Playing not allowed.\n");
1287  exit(-1);
1288  }
1289 }
1290 
1294 static void signal_shutdown(int signum_unused) {
1295  (void) signum_unused; /* avoid unused warning if enambled */
1296  shutdown_flag += 1;
1297 }
1298 
1311 static void rec_sighup(int i) {
1312  (void)i;
1313  /* Don't call LOG(). It calls non-reentrant functions. The other
1314  * signal handlers shouldn't really call LOG() either. */
1315  if (logfile != stderr) {
1316  reopen_logfile = 1;
1317  }
1318 }
1319 
1323 void init_signals(void) {
1324 #ifndef WIN32 /* init_signals() remove signals */
1325  struct sigaction sa;
1326 
1327  sa.sa_sigaction = NULL;
1328  sigemptyset(&sa.sa_mask);
1329  sa.sa_flags = 0;
1330  sa.sa_handler = rec_sighup;
1331  sigaction(SIGHUP, &sa, NULL);
1332  signal(SIGINT, signal_shutdown);
1333  signal(SIGPIPE, SIG_IGN);
1334 #endif /* win32 */
1335 }
Settings::casting_time
uint8_t casting_time
It takes awhile to cast a spell.
Definition: global.h:272
Settings::special_break_map
uint8_t special_break_map
If set, then submaps in random maps can break the walls.
Definition: global.h:327
Settings::meta_comment
char meta_comment[MAX_BUF]
Comment we send to the metaserver.
Definition: global.h:291
Command_Line_Options
One command line option definition.
Definition: init.cpp:366
module_information::name
const char * name
Module name, without space.
Definition: init.cpp:46
Settings::mapdir
const char * mapdir
Where the map files are.
Definition: global.h:253
global.h
Settings::meta_server
char meta_server[MAX_BUF]
Hostname/ip addr of the metaserver.
Definition: global.h:288
settings
struct Settings settings
Server settings.
Definition: init.cpp:139
Settings::simple_exp
uint8_t simple_exp
If true, use the simple experience system.
Definition: global.h:265
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
options
static struct Command_Line_Options options[]
Actual valid command line options.
Definition: init.cpp:384
Settings::recycle_tmp_maps
uint8_t recycle_tmp_maps
Re-use tmp maps.
Definition: global.h:274
init
void init(int argc, char **argv)
This is the main server initialization function.
Definition: init.cpp:1096
llevError
@ llevError
Error, serious thing.
Definition: logger.h:11
init_beforeplay
static void init_beforeplay(void)
Called before the server starts listening to connections, processes various dump-related options.
Definition: init.cpp:1207
Settings::regions
const char * regions
Name of the regions file - libdir is prepended.
Definition: global.h:254
LOG
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
Definition: logger.cpp:58
Settings::allow_broken_converters
int allow_broken_converters
If set, converters will work even if price of generated item is higher than the price of converted it...
Definition: global.h:318
Settings::log_timestamp_format
char * log_timestamp_format
Format for timestap, if log_timestamp is set.
Definition: global.h:321
Settings::armor_speed_linear
uint8_t armor_speed_linear
If 1, speed improvement is linear, else exponantiel.
Definition: global.h:311
module_information::close
void(* close)()
Cleanup function.
Definition: init.cpp:50
random_house_generator_init
void random_house_generator_init(Settings *settings)
Module initialisation.
Definition: random_house_generator.cpp:210
strdup_local
#define strdup_local
Definition: compat.h:29
materialtype_t::mod
int8_t mod[NROFATTACKS]
Modification to resistances.
Definition: material.h:37
Settings::resurrection
uint8_t resurrection
Ressurection possible w/ permadeth on.
Definition: global.h:268
service_handle
void service_handle()
Settings::set_title
uint8_t set_title
Players can set thier title.
Definition: global.h:267
dump_alchemy_costs
void dump_alchemy_costs(void)
Dumps to output all costs of recipes.
Definition: recipe.cpp:588
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
If set, don't check plugin version.
Definition: global.h:329
FALSE
#define FALSE
Definition: compat.h:14
Settings::not_permadeth
uint8_t not_permadeth
If true, death is non-permament.
Definition: global.h:264
Settings::permanent_exp_ratio
uint8_t permanent_exp_ratio
How much exp should be 'permenant' and unable to be lost.
Definition: global.h:260
Settings::crypt_mode
uint8_t crypt_mode
0 for legacy behavior, 1 for always Traditional
Definition: global.h:332
set_datadir
static void set_datadir(const char *path)
Command line option: set data path.
Definition: init.cpp:189
module_information::description
const char * description
Module long description.
Definition: init.cpp:47
Settings::dumpvalues
uint8_t dumpvalues
Set to dump various values/tables.
Definition: global.h:247
Settings::datadir
const char * datadir
Read only data files.
Definition: global.h:250
load_materials
static void load_materials(BufferReader *reader, const char *filename)
Loads the materials.
Definition: init.cpp:528
FULL_VERSION
#define FULL_VERSION
Definition: version.h:4
set_mapdir
static void set_mapdir(const char *path)
Command line option: set map path.
Definition: init.cpp:213
cleanup
void cleanup(void)
Clean up everything and exit.
Definition: server.cpp:1257
set_dumpmon7
static void set_dumpmon7(void)
Command line option: dump alchemy.
Definition: init.cpp:162
dump_faces
void dump_faces(void)
Dump all faces to stderr, for debugging purposes.
Definition: image.cpp:159
Settings::worldmaptilesy
uint32_t worldmaptilesy
Number of tiles high the worldmap is.
Definition: global.h:296
SHUTDOWN_FILE
#define SHUTDOWN_FILE
If you want to take the game down while installing new versions, or for other reasons,...
Definition: config.h:463
rec_sighup
static void rec_sighup(int i)
SIGHUP handler.
Definition: init.cpp:1311
Settings::min_name
uint8_t min_name
Minimum characters for an account or player name.
Definition: global.h:333
SRANDOM
#define SRANDOM(seed)
Definition: define.h:639
Settings::worldmapstartx
uint32_t worldmapstartx
Starting x tile for the worldmap.
Definition: global.h:293
list_modules
static void list_modules()
List all modules, then exit.
Definition: init.cpp:94
time
non standard information is not specified or uptime this means how long since the executable has been started A particular host may have been running a server for quite a long time
Definition: arch-handbook.txt:206
get_empty_mat
static materialtype_t * get_empty_mat(void)
Creates an empty materialtype_t structure.
Definition: init.cpp:508
set_dumpmont
static void set_dumpmont(const char *name)
Command line option: dump monster treasures.
Definition: init.cpp:180
init_ob_methods
void init_ob_methods(void)
Initializes the ob_method system.
Definition: ob_methods.cpp:35
module_information::init
void(* init)(Settings *)
Initialisation function.
Definition: init.cpp:49
set_dumpmon6
static void set_dumpmon6(void)
Command line option: dump races.
Definition: init.cpp:157
Settings::starting_stat_min
uint8_t starting_stat_min
Minimum value of a starting stat.
Definition: global.h:322
read_map_log
void read_map_log(void)
Reads temporary maps information from disk.
Definition: swap.cpp:71
Settings::roll_stat_points
uint8_t roll_stat_points
How many stat points legacy (rolled) chars start with.
Definition: global.h:325
Settings::pk_luck_penalty
int16_t pk_luck_penalty
Amount by which player luck is reduced if they PK.
Definition: global.h:259
FREE_AND_COPY_IF
#define FREE_AND_COPY_IF(sv, nv)
Definition: global.h:208
Settings::stat_file
char * stat_file
Definition: global.h:338
set_mondebug
static void set_mondebug(void)
Command line option: monster debug flag.
Definition: init.cpp:127
llevMonster
@ llevMonster
Many many details.
Definition: logger.h:14
server_dump_animations
static void server_dump_animations(void)
Dump all animations, then exit.
Definition: init.cpp:333
SEE_LAST_ERROR
@ SEE_LAST_ERROR
Definition: define.h:52
set_playerdir
static void set_playerdir(const char *path)
Command line option: set player path.
Definition: init.cpp:245
NROFATTACKS
#define NROFATTACKS
Definition: attack.h:17
motd
**Media tags please refer to the protocol file in doc Developers protocol Quick for your pleasure an example[/b][i] This is an old full of dirt and partially destroyed[hand] My dear as you two years i had to leave quickly Words have come to me of powerful magic scrolls discovered in an old temple by my uncle I have moved to study them I not forgot your knowledge in ancient languages I need your help for[print][b] Some parts of document are to damaged to be readable[/b][arcane] Arghis[color=Red] k h[color=dark slate blue] ark[color=#004000] fido[/color][hand] please come as fast as possible my friend[print][b] The bottom of letter seems deliberatly shredded What is but not limited book signs motd
Definition: media-tags.txt:31
dump_gods
void dump_gods(void)
Prints all gods to stderr.
Definition: holy.cpp:367
Settings::csport
uint16_t csport
Port for new client/server.
Definition: global.h:244
materials
std::vector< materialtype_t * > materials
Definition: init.cpp:128
Settings::ignore_assets_errors
int ignore_assets_errors
If set then go on running even if there are errors in assets.
Definition: global.h:335
load_races
void load_races(BufferReader *reader, const char *filename)
Reads the races file in the lib/ directory, then overwrites old 'race' entries.
Definition: races.cpp:47
buf
StringBuffer * buf
Definition: readable.cpp:1565
init_server
void init_server(void)
This sets up the listening socket.
Definition: init.cpp:283
version.h
service_register
void service_register()
set_dumpmon2
static void set_dumpmon2(void)
Command line option: dump abilities.
Definition: init.cpp:137
Command_Line_Options::num_args
uint8_t num_args
Number or args it takes.
Definition: init.cpp:368
Settings::meta_host
char meta_host[MAX_BUF]
Hostname of this host.
Definition: global.h:289
set_dumpmon4
static void set_dumpmon4(void)
Command line option: dump spells.
Definition: init.cpp:147
forbid_play
int forbid_play(void)
Checks if server should be started.
Definition: server.cpp:1364
name
Plugin animator file specs[Config] name
Definition: animfiles.txt:4
Settings::worldmaptilesx
uint32_t worldmaptilesx
Number of tiles wide the worldmap is.
Definition: global.h:295
dump_races
void dump_races(void)
Dumps all race information to stderr.
Definition: races.cpp:81
Settings::pk_max_experience
int64_t pk_max_experience
Maximum experience one can get for PKing.
Definition: global.h:315
Command_Line_Options::cmd_option
const char * cmd_option
How it is called on the command line.
Definition: init.cpp:367
server_dump_faces
static void server_dump_faces(void)
Dump all faces, then exit.
Definition: init.cpp:341
init_signals
void init_signals(void)
Setup our signal handlers.
Definition: init.cpp:1323
parse_args
static void parse_args(int argc, char *argv[], int pass)
Parse command line arguments.
Definition: init.cpp:456
Settings::spell_encumbrance
uint8_t spell_encumbrance
Encumbrance effects spells.
Definition: global.h:270
init_gods
void init_gods(void)
This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD...
Definition: holy.cpp:59
materialtype_t::material
int material
What basic type(s) it is linked to.
Definition: material.h:35
dump_experience
void dump_experience(void)
Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format o...
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
Port number to use for updates.
Definition: global.h:290
modules
static module_information modules[]
All built modules.
Definition: init.cpp:54
Settings::balanced_stat_loss
uint8_t balanced_stat_loss
If true, Death stat depletion based on level etc.
Definition: global.h:263
dump_stat_bonuses
void dump_stat_bonuses()
Definition: living.cpp:2651
Settings::debug
LogLevel debug
Default debugging level.
Definition: global.h:245
load_settings
static void load_settings(void)
This loads the settings file.
Definition: init.cpp:595
init_archetype_pointers
void init_archetype_pointers(void)
Initialize global archtype pointers:
Definition: treasure.cpp:62
Settings::pk_max_experience_percent
int pk_max_experience_percent
Percentage of experience of victim the killer gets.
Definition: global.h:316
add_refcount
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
Definition: shstr.cpp:210
citylife_init
void citylife_init(Settings *settings)
Definition: citylife.cpp:424
Settings::death_penalty_ratio
uint8_t death_penalty_ratio
Hhow much exp should be lost at death.
Definition: global.h:261
set_dumpmon3
static void set_dumpmon3(void)
Command line option: dump artifacts.
Definition: init.cpp:142
cftimer_init
void cftimer_init(void)
Initialize timers.
Definition: timers.cpp:157
random_house_generator_close
void random_house_generator_close()
Close the module.
Definition: random_house_generator.cpp:220
free_races
void free_races(void)
Frees all race-related information.
Definition: races.cpp:93
Settings::set_friendly_fire
uint16_t set_friendly_fire
Percent of damage done by peaceful player vs player damage.
Definition: global.h:277
Settings::account_block_create
uint8_t account_block_create
Definition: global.h:330
Settings::motd
const char * motd
Name of the motd file.
Definition: global.h:280
Settings::logfilename
const char * logfilename
Logfile to use.
Definition: global.h:243
Settings::worldmapstarty
uint32_t worldmapstarty
Starting y tile for the worldmap.
Definition: global.h:294
add_string
sstring add_string(const char *str)
This will add 'str' to the hash table.
Definition: shstr.cpp:124
free_quest
void free_quest(void)
Free all quest status structures.
Definition: quest.cpp:891
init_readable
void init_readable(void)
Initialize linked lists utilized by message functions in tailor_readable_ob()
Definition: readable.cpp:904
set_enable_module
static void set_enable_module(const char *name)
Enable a module.
Definition: init.cpp:326
materialtype_t::name
const char * name
Name of the material.
Definition: material.h:33
set_dumpmon1
static void set_dumpmon1(void)
Command line option: dump monsters.
Definition: init.cpp:132
metaserver2_init
int metaserver2_init(void)
This initializes the metaserver2 logic - it reads the metaserver2 file, storing the values away.
Definition: metaserver.cpp:331
description
spell prayer lvl t sp speed range duration short description
Definition: spell-summary.txt:2
Settings::armor_weight_reduction
int armor_weight_reduction
Weight reduction per enchantment.
Definition: global.h:308
Settings::stat_loss_on_death
uint8_t stat_loss_on_death
If true, chars lose a random stat when they die.
Definition: global.h:258
Settings::disabled_plugins
std::vector< char * > disabled_plugins
List of disabled plugins, 'All' means all.
Definition: global.h:328
signal_shutdown
static void signal_shutdown(int signum_unused)
Signal handler that begins a normal server shutdown.
Definition: init.cpp:1294
Settings::item_power_factor
float item_power_factor
See note in setings file.
Definition: global.h:305
MAX_NAME
#define MAX_NAME
Definition: define.h:41
set_logfile
static void set_logfile(char *val)
Command line option: set logfile name.
Definition: init.cpp:106
service_unregister
void service_unregister()
Settings::dumparg
const char * dumparg
Additional argument for some dump functions.
Definition: global.h:248
assets_finish_archetypes_for_play
void assets_finish_archetypes_for_play()
Definition: assets.cpp:508
dump_spells
void dump_spells(void)
Dumps all the spells - now also dumps skill associated with the spell.
Definition: spell_util.cpp:108
Settings::confdir
const char * confdir
Configuration files.
Definition: global.h:249
sproto.h
logfile
FILE * logfile
Used by server/daemon.c.
Definition: init.cpp:114
set_tmpdir
static void set_tmpdir(const char *path)
Command line option: set temporary file path.
Definition: init.cpp:253
dump_abilities
void dump_abilities(void)
Dump to standard out the abilities of all monsters.
Definition: info.cpp:52
set_uniquedir
static void set_uniquedir(const char *path)
Command line option: set unique path.
Definition: init.cpp:229
materialtype_t::save
int8_t save[NROFATTACKS]
Save chances for the attacks.
Definition: material.h:36
Settings::death_penalty_level
uint8_t death_penalty_level
How many levels worth of exp may be lost on one death.
Definition: global.h:262
modules.h
cfcitybell_init
void cfcitybell_init(Settings *settings)
Citybells module initialisation.
Definition: cfcitybell.cpp:151
fatal
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
Definition: utils.cpp:590
accounts_load
void accounts_load(void)
This loads all the account entries into memory.
Definition: account.cpp:161
set_dumpmon9
static void set_dumpmon9(void)
Command line option: dump alchemy costs.
Definition: init.cpp:172
MAX_BUF
#define MAX_BUF
Used for all kinds of things.
Definition: define.h:35
set_confdir
static void set_confdir(const char *path)
Command line option: set configuration path.
Definition: init.cpp:197
path
pluglist shows those as well as a short text describing each the list will simply appear empty The keyword for the Python plugin is Python plugout< keyword > Unloads a given identified by its _keyword_ So if you want to unload the Python you need to do plugout Python plugin< libname > Loads a given whose _filename_ is libname So in the case of you d have to do a plugin cfpython so Note that all filenames are relative to the default plugin path(SHARE/plugins). Console messages. ----------------- When Crossfire starts
cmdlinefunc_args2
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
Definition: init.cpp:358
set_dumpmon8
static void set_dumpmon8(void)
Command line option: dump gods.
Definition: init.cpp:167
Settings::playerdir
const char * playerdir
Where the player files are.
Definition: global.h:252
reopen_logfile
int reopen_logfile
Definition: logger.cpp:27
init_skills
void init_skills(void)
This just sets up the skill_names table above.
Definition: skill_util.cpp:99
Settings::spell_failure_effects
uint8_t spell_failure_effects
Nasty backlash to spell failures.
Definition: global.h:271
Settings::starting_stat_points
uint8_t starting_stat_points
How many stat points character starts with.
Definition: global.h:324
Settings
Server settings.
Definition: global.h:242
Settings::meta_on
unsigned int meta_on
True if we should send updates.
Definition: global.h:287
Settings::allow_denied_spells_writing
int allow_denied_spells_writing
If set, players can write spells they can't cast.
Definition: global.h:317
llevInfo
@ llevInfo
Information.
Definition: logger.h:12
hiscore_init
void hiscore_init(void)
Initializes the module.
Definition: hiscore.cpp:296
set_regions
static void set_regions(const char *path)
Command line option: set regions file name.
Definition: init.cpp:221
should_exit
static int should_exit
If set after command line argument parsing, then the server will exit.
Definition: init.cpp:43
init_library
void init_library(void)
It is vital that init_library() is called by any functions using this library.
Definition: init.cpp:322
Settings::who_wiz_format
char who_wiz_format[MAX_BUF]
The format that the who command should use when called by a dm.
Definition: global.h:279
commands_init
void commands_init(void)
Init standard commands.
Definition: commands.cpp:108
Settings::spellpoint_level_depend
uint8_t spellpoint_level_depend
Spell costs go up with level.
Definition: global.h:276
dump_quests
void dump_quests(void)
Dump all of the quests, then calls exit() - useful in terms of debugging to make sure that quests are...
Definition: quest.cpp:880
Settings::fastclock
uint8_t fastclock
If true, clock goes warp 9.
Definition: global.h:299
cmdlinefunc_args1
void(* cmdlinefunc_args1)(const char *arg1)
Definition: init.cpp:357
free_materials
static void free_materials(void)
Frees all memory allocated to materials.
Definition: init.cpp:583
Settings::personalized_blessings
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
Definition: global.h:314
print_monsters
void print_monsters(void)
As dump_abilities(), but with an alternative way of output.
Definition: info.cpp:87
unset_debug
static void unset_debug(void)
Command line option: unset debug flag.
Definition: init.cpp:122
dump_alchemy
void dump_alchemy(void)
Dumps alchemy recipes to output.
Definition: recipe.cpp:350
help
static void help(void)
Display the command line options and exits.
Definition: init.cpp:1147
Settings::max_stat
uint8_t max_stat
Maximum stat value - 255 should be sufficient.
Definition: global.h:326
cmdlinefunc_args0
void(* cmdlinefunc_args0)(void)
Typedefs used when calling option handlers.
Definition: init.cpp:356
materialtype_t::description
const char * description
Description, unused.
Definition: material.h:34
set_debug
static void set_debug(void)
Command line option: debug flag.
Definition: init.cpp:117
close_modules
void close_modules()
Clean up all modules which are not disabled.
Definition: init.cpp:80
reset_sleep
void reset_sleep(void)
Initialise all variables used in the timing routines.
Definition: time.cpp:134
assets.h
Settings::armor_max_enchant
int armor_max_enchant
Maximum number of times an armor can be enchanted.
Definition: global.h:307
cfcitybell_close
void cfcitybell_close()
Definition: cfcitybell.cpp:163
set_ignore_assets_errors
static void set_ignore_assets_errors()
Command line option: ignore assets errors.
Definition: init.cpp:260
dump_monster_treasure
void dump_monster_treasure(const char *name)
For debugging purposes.
Definition: treasure.cpp:1244
dump_animations
void dump_animations(void)
Dump all animations to stderr, for debugging purposes.
Definition: anim.cpp:180
add_server_collect_hooks
void add_server_collect_hooks()
Definition: init.cpp:1084
Settings::armor_weight_linear
uint8_t armor_weight_linear
If 1, weight reduction is linear, else exponantiel.
Definition: global.h:309
set_dumpmon5
static void set_dumpmon5(void)
Command line option: ?
Definition: init.cpp:152
strcasecmp
int strcasecmp(const char *s1, const char *s2)
Settings::worldmaptilesizex
uint32_t worldmaptilesizex
Number of squares wide in a wm tile.
Definition: global.h:297
init_modules
void init_modules()
Init all modules which are not disabled.
Definition: init.cpp:64
call_version
static void call_version(void)
Command line option: show version.
Definition: init.cpp:111
set_csport
static void set_csport(const char *val)
Change the server's port.
Definition: init.cpp:277
loader.h
Settings::real_wiz
uint8_t real_wiz
Use mud-like wizards.
Definition: global.h:273
init_startup
static void init_startup(void)
Checks if starting the server is allowed.
Definition: init.cpp:1271
Settings::templatedir
const char * templatedir
Directory for the template map.
Definition: global.h:256
set_disable_plugin
static void set_disable_plugin(const char *name)
Disable a plugin.
Definition: init.cpp:290
Settings::worldmaptilesizey
uint32_t worldmaptilesizey
Number of squares high in a wm tile.
Definition: global.h:298
set_localdir
static void set_localdir(const char *path)
Command line option: set local path.
Definition: init.cpp:205
assets_pack
void assets_pack(const char *what, const char *filename)
Pack the specified assets in a file.
Definition: assets.cpp:417
set_disable_module
static void set_disable_module(const char *name)
Disable a module.
Definition: init.cpp:318
free_server
void free_server(void)
Frees all memory allocated around here:
Definition: init.cpp:1136
citylife_close
void citylife_close()
Definition: citylife.cpp:435
finish_races
void finish_races()
Definition: races.cpp:98
materialtype_t
One material type.
Definition: material.h:32
Settings::no_player_stealing
uint8_t no_player_stealing
If 1, can not steal from other players.
Definition: global.h:312
Settings::account_trusted_host
char * account_trusted_host
Block account creation for untrusted hosts.
Definition: global.h:331
Settings::search_items
uint8_t search_items
Search_items command.
Definition: global.h:269
module_information
Definition: init.cpp:45
server.h
Settings::tmpdir
const char * tmpdir
Directory to use for temporary files.
Definition: global.h:257
dump_artifacts
void dump_artifacts(void)
For debugging purposes.
Definition: artifact.cpp:614
Settings::always_show_hp
uint8_t always_show_hp
'probe' spell HP bars for all living things (0, 1, or 2)
Definition: global.h:275
TRUE
#define TRUE
Definition: compat.h:11
set_templatedir
static void set_templatedir(const char *path)
Command line option: set template path.
Definition: init.cpp:237
Settings::create_home_portals
uint8_t create_home_portals
If 1, can create portals in unique maps (apartments)
Definition: global.h:313
server_dump_bonuses
static void server_dump_bonuses()
Dump all bonuses (from the stat_bonus file) then exit.
Definition: init.cpp:349
Command_Line_Options::pass
uint8_t pass
What pass this should be processed on.
Definition: init.cpp:369
OUT_OF_MEMORY
@ OUT_OF_MEMORY
Definition: define.h:48
BufferReader
Definition: bufferreader.cpp:21
Settings::armor_speed_improvement
int armor_speed_improvement
Speed improvement.
Definition: global.h:310
NUM_STATS
@ NUM_STATS
Number of statistics.
Definition: living.h:18
Settings::log_timestamp
int log_timestamp
If set, log will comport a timestamp.
Definition: global.h:320
Settings::who_format
char who_format[MAX_BUF]
The format that the who command should use.
Definition: global.h:278
server_pack_assets
static void server_pack_assets(const char *assets, const char *filename)
Definition: init.cpp:264
Command_Line_Options::func
void(* func)()
function to call when we match this.
Definition: init.cpp:370
shutdown_flag
volatile sig_atomic_t shutdown_flag
Definition: server.cpp:53
module_information::enabled
bool enabled
Whether the module is enabled or not.
Definition: init.cpp:48
llevDebug
@ llevDebug
Only for debugging purposes.
Definition: logger.h:13
do_module
static void do_module(const char *name, bool enabled)
Change the 'enabled' flag of a module.
Definition: init.cpp:300
Settings::starting_stat_max
uint8_t starting_stat_max
Maximum value of a starting stat.
Definition: global.h:323
Settings::uniquedir
const char * uniquedir
Directory for the unique items.
Definition: global.h:255
bufferreader_next_line
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
Definition: bufferreader.cpp:102
Settings::localdir
const char * localdir
Read/write data files.
Definition: global.h:251