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 
45 static int should_exit = 0;
46 
48  const char *name;
49  char const *description;
50  bool enabled;
51  void (*init)(Settings *, ServerSettings *);
52  void (*close)();
53 };
54 
57  { "citybell", "Ring bells every hour for defined temples", true, cfcitybell_init, cfcitybell_close },
58  { "citylife", "Add NPCs in towns", true, citylife_init, citylife_close },
59  { "rhg", "Add random maps to exits in towns", false, random_house_generator_init, random_house_generator_close },
60  { NULL, NULL, false, NULL, NULL }
61 };
62 
66 void init_modules() {
67  LOG(llevInfo, "Initializing modules\n");
68  for (int module = 0; modules[module].name != NULL; module++) {
69  module_information *mod = &modules[module];
70  if (!mod->enabled) {
71  LOG(llevInfo, " %s (%s): disabled\n", mod->name, mod->description);
72  } else {
73  mod->init(&settings, &serverSettings);
74  LOG(llevInfo, " %s (%s): activated\n", mod->name, mod->description);
75  }
76  }
77 }
78 
82 void close_modules() {
83  LOG(llevInfo, "Cleaning modules\n");
84  for (int module = 0; modules[module].name != NULL; module++) {
85  module_information *mod = &modules[module];
86  if (mod->enabled) {
87  mod->close();
88  LOG(llevInfo, " %s (%s): closed\n", mod->name, mod->description);
89  }
90  }
91 }
92 
96 static void list_modules() {
97  LOG(llevInfo, "Built-in modules:\n");
98  for (int module = 0; modules[module].name != NULL; module++) {
99  LOG(llevInfo, " %s: %s -> %s\n", modules[module].name, modules[module].description, modules[module].enabled ? "enabled" : "disabled");
100  }
101  should_exit = 1;
102 }
103 
108 static void set_logfile(char *val) {
109  settings.logfilename = val;
110 }
111 
113 static void call_version(void) {
114  puts(FULL_VERSION);
115  exit(EXIT_SUCCESS);
116 }
117 
119 static void set_debug(void) {
121 }
122 
124 static void unset_debug(void) {
126 }
127 
129 static void set_mondebug(void) {
131 }
132 
134 static void set_dumpmon1(void) {
135  settings.dumpvalues = 1;
136 }
137 
139 static void set_dumpmon2(void) {
140  settings.dumpvalues = 2;
141 }
142 
144 static void set_dumpmon3(void) {
145  settings.dumpvalues = 3;
146 }
147 
149 static void set_dumpmon4(void) {
150  settings.dumpvalues = 4;
151 }
152 
154 static void set_dumpmon5(void) {
155  settings.dumpvalues = 5;
156 }
157 
159 static void set_dumpmon6(void) {
160  settings.dumpvalues = 6;
161 }
162 
164 static void set_dumpmon7(void) {
165  settings.dumpvalues = 7;
166 }
167 
169 static void set_dumpmon8(void) {
170  settings.dumpvalues = 8;
171 }
172 
174 static void set_dumpmon9(void) {
175  settings.dumpvalues = 9;
176 }
177 
182 static void set_dumpmont(const char *name) {
183  settings.dumpvalues = 10;
185 }
186 
191 static void set_datadir(const char *path) {
192  settings.datadir = path;
193 }
194 
199 static void set_confdir(const char *path) {
200  settings.confdir = path;
201 }
202 
207 static void set_localdir(const char *path) {
208  settings.localdir = path;
209 }
210 
215 static void set_mapdir(const char *path) {
216  settings.mapdir = path;
217 }
218 
223 static void set_regions(const char *path) {
224  settings.regions = path;
225 }
226 
231 static void set_uniquedir(const char *path) {
232  settings.uniquedir = path;
233 }
234 
239 static void set_templatedir(const char *path) {
240  settings.templatedir = path;
241 }
242 
247 static void set_playerdir(const char *path) {
248  settings.playerdir = path;
249 }
250 
255 static void set_tmpdir(const char *path) {
256  settings.tmpdir = path;
257 }
258 
264 }
265 
266 static void server_pack_assets(const char *assets, const char *filename) {
267  assets_pack(assets, filename);
268  should_exit = 1;
269 }
270 
271 static void free_materials(void);
272 
279 static void set_csport(const char *val) {
280  int port = atoi(val);
281  if (port <= 0 || port > 65535) {
282  LOG(llevError, "%d is an invalid csport number, must be between 1 and 65535.\n", port);
283  exit(1);
284  }
285  settings.csport = port;
286 }
287 
292 static void set_disable_plugin(const char *name) {
293  serverSettings.disabled_plugins.push_back(strdup(name));
294 }
295 
302 static void do_module(const char *name, bool enabled) {
303  bool one = false;
304  for (int module = 0; modules[module].name; module++) {
305  if (strcmp("All", name) == 0 || strcmp(modules[module].name, name) == 0) {
306  modules[module].enabled = enabled;
307  one = true;
308  }
309  }
310  if (!one) {
311  LOG(llevError, "Invalid module name %s\n", name);
313  }
314 }
315 
320 static void set_disable_module(const char *name) {
321  do_module(name, false);
322 }
323 
328 static void set_enable_module(const char *name) {
329  do_module(name, true);
330 }
331 
335 static void server_dump_animations(void) {
336  dump_animations();
337  cleanup();
338 }
339 
343 static void server_dump_faces(void) {
344  dump_faces();
345  cleanup();
346 }
347 
351 static void server_dump_bonuses() {
353  cleanup();
354 }
355 
358 typedef void (*cmdlinefunc_args0)(void);
359 typedef void (*cmdlinefunc_args1)(const char* arg1);
360 typedef void (*cmdlinefunc_args2)(const char* arg1, const char* arg2);
369  const char *cmd_option;
370  uint8_t num_args;
371  uint8_t pass;
372  void (*func)();
376 };
377 
386 static struct Command_Line_Options options[] = {
390  { "-conf", 1, 1, (cmdlinefunc_args0)set_confdir },
391  { "-d", 0, 1, (cmdlinefunc_args0)set_debug },
392  { "-data", 1, 1, (cmdlinefunc_args0)set_datadir },
393  { "-disable-plugin", 1, 1, (cmdlinefunc_args0)set_disable_plugin },
394  { "-disable-module", 1, 1, (cmdlinefunc_args0)set_disable_module },
395  { "-enable-module", 1, 1, (cmdlinefunc_args0)set_enable_module },
396  { "-list-modules", 0, 1, (cmdlinefunc_args0)list_modules },
397  { "-h", 0, 1, (cmdlinefunc_args0)help },
398  { "-ignore-assets-errors", 0, 1, (cmdlinefunc_args0)set_ignore_assets_errors },
399  { "-local", 1, 1, (cmdlinefunc_args0)set_localdir },
400  { "-log", 1, 1, (cmdlinefunc_args0)set_logfile },
401  { "-maps", 1, 1, (cmdlinefunc_args0)set_mapdir },
402  { "-mon", 0, 1, (cmdlinefunc_args0)set_mondebug },
403  { "-n", 0, 1, (cmdlinefunc_args0)unset_debug },
404  { "-playerdir", 1, 1, (cmdlinefunc_args0)set_playerdir },
405  { "-regions", 1, 1, (cmdlinefunc_args0)set_regions },
406  { "-templatedir", 1, 1, (cmdlinefunc_args0)set_templatedir },
407  { "-tmpdir", 1, 1, (cmdlinefunc_args0)set_tmpdir },
408  { "-uniquedir", 1, 1, (cmdlinefunc_args0)set_uniquedir },
409  { "-v", 0, 1, (cmdlinefunc_args0)call_version },
410 
411 #ifdef WIN32
412  /* Windows service stuff */
413  { "-regsrv", 0, 1, service_register },
414  { "-unregsrv", 0, 1, service_unregister },
415  { "-srv", 0, 1, service_handle },
416 #endif
417 
421  { "-p", 1, 2, (cmdlinefunc_args0)set_csport },
422 
426  { "-m", 0, 3, (cmdlinefunc_args0)set_dumpmon1 },
427  { "-m2", 0, 3, (cmdlinefunc_args0)set_dumpmon2 },
428  { "-m3", 0, 3, (cmdlinefunc_args0)set_dumpmon3 },
429  { "-m4", 0, 3, (cmdlinefunc_args0)set_dumpmon4 },
430  { "-m5", 0, 3, (cmdlinefunc_args0)set_dumpmon5 },
431  { "-m6", 0, 3, (cmdlinefunc_args0)set_dumpmon6 },
432  { "-m7", 0, 3, (cmdlinefunc_args0)set_dumpmon7 },
433  { "-m8", 0, 3, (cmdlinefunc_args0)set_dumpmon8 },
434  { "-m9", 0, 3, (cmdlinefunc_args0)set_dumpmon9 },
435  { "-mt", 1, 3, (cmdlinefunc_args0)set_dumpmont },
436  { "-mexp", 0, 3, (cmdlinefunc_args0)dump_experience },
437  { "-mq", 0, 3, (cmdlinefunc_args0)dump_quests },
438  { "-dump-anims", 0, 3, (cmdlinefunc_args0)server_dump_animations },
439  { "-dump-faces", 0, 3, (cmdlinefunc_args0)server_dump_faces },
440  { "-pack-assets", 2, 3, (cmdlinefunc_args0)server_pack_assets },
441  { "-dump-stat-bonuses", 0, 3, (cmdlinefunc_args0)server_dump_bonuses },
442 };
443 
458 static void parse_args(int argc, char *argv[], int pass) {
459  size_t i;
460  int on_arg = 1;
461 
462  while (on_arg < argc) {
463  for (i = 0; i < sizeof(options)/sizeof(struct Command_Line_Options); i++) {
464  if (!strcmp(options[i].cmd_option, argv[on_arg])) {
465  /* Found a matching option, but should not be processed on
466  * this pass. Just skip over it
467  */
468  if (options[i].pass != pass) {
469  on_arg += options[i].num_args+1;
470  break;
471  }
472  if (options[i].num_args) {
473  if ((on_arg+options[i].num_args) >= argc) {
474  fprintf(stderr, "%s requires an argument.\n", options[i].cmd_option);
475  exit(1);
476  }
477 
478  if (options[i].num_args == 1)
479  ((cmdlinefunc_args1)options[i].func)(argv[on_arg+1]);
480  if (options[i].num_args == 2)
481  ((cmdlinefunc_args2)options[i].func)(argv[on_arg+1], argv[on_arg+2]);
482  on_arg += options[i].num_args+1;
483  } else { /* takes no args */
485  on_arg++;
486  }
487  break;
488  }
489  }
490  if (i == sizeof(options)/sizeof(struct Command_Line_Options)) {
491  fprintf(stderr, "Unknown option: %s\n", argv[on_arg]);
492  fprintf(stderr, "Type '%s -h' for usage.\n", argv[0]);
493  exit(1);
494  }
495  }
496 
497  if (should_exit) {
498  cleanup();
499  }
500 }
501 
511  materialtype_t *mt;
512  int i;
513 
514  mt = (materialtype_t *)malloc(sizeof(materialtype_t));
515  if (mt == NULL)
517  mt->name = NULL;
518  mt->description = NULL;
519  for (i = 0; i < NROFATTACKS; i++) {
520  mt->save[i] = 0;
521  mt->mod[i] = 0;
522  }
523  return mt;
524 }
525 
530 static void load_materials(BufferReader *reader, const char *filename) {
531  char *buf, *cp, *next;
532  materialtype_t *mt;
533  int i, value;
534  (void)filename;
535 
536  while ((buf = bufferreader_next_line(reader)) != NULL) {
537  if (*buf == '#')
538  continue;
539  cp = buf;
540  while (*cp == ' ') /* Skip blanks */
541  cp++;
542  if (!strncmp(cp, "name", 4)) {
543  mt = get_empty_mat();
544  materials.push_back(mt);
545  mt->name = add_string(strchr(cp, ' ')+1);
546  mt->description = add_refcount(mt->name);
547  } else if (!strncmp(cp, "description", 11)) {
548  FREE_AND_COPY_IF(mt->description, strchr(cp, ' ')+1);
549  } else if (sscanf(cp, "material %d", &value)) {
550  mt->material = value;
551  } else if (!strncmp(cp, "saves", 5)) {
552  cp = strchr(cp, ' ')+1;
553  for (i = 0; i < NROFATTACKS; i++) {
554  if (cp == NULL) {
555  mt->save[i] = 0;
556  continue;
557  }
558  if ((next = strchr(cp, ',')) != NULL)
559  *(next++) = '\0';
560  sscanf(cp, "%d", &value);
561  mt->save[i] = (int8_t)value;
562  cp = next;
563  }
564  } else if (!strncmp(cp, "mods", 4)) {
565  cp = strchr(cp, ' ')+1;
566  for (i = 0; i < NROFATTACKS; i++) {
567  if (cp == NULL) {
568  mt->save[i] = 0;
569  continue;
570  }
571  if ((next = strchr(cp, ',')) != NULL)
572  *(next++) = '\0';
573  sscanf(cp, "%d", &value);
574  mt->mod[i] = (int8_t)value;
575  cp = next;
576  }
577  }
578  }
579  LOG(llevDebug, "loaded %d material type data\n", static_cast<int>(materials.size()));
580 }
581 
585 static void free_materials(void) {
586  for (auto material : materials) {
587  free(material);
588  }
589  materials.clear();
590 }
591 
597 static void load_settings(void) {
598  static char motd[MAX_BUF] = { 0 };
599  char buf[MAX_BUF], *cp, dummy[1];
600  int has_val;
601  FILE *fp;
602 
603  dummy[0] = '\0';
604  snprintf(buf, sizeof(buf), "%s/settings", settings.confdir);
605 
606  /* We don't require a settings file at current time, but down the road,
607  * there will probably be so many values that not having a settings file
608  * will not be a good thing.
609  */
610  if ((fp = fopen(buf, "r")) == NULL) {
611  LOG(llevError, "Warning: No settings file found\n");
612  return;
613  }
614  while (fgets(buf, MAX_BUF-1, fp) != NULL) {
615  if (buf[0] == '#')
616  continue;
617  /* eliminate newline */
618  if ((cp = strrchr(buf, '\n')) != NULL)
619  *cp = '\0';
620 
621  /* Skip over empty lines */
622  if (buf[0] == 0)
623  continue;
624 
625  /* Skip all the spaces and set them to nulls. If not space,
626  * set cp to "" to make strcpy's and the like easier down below.
627  */
628  if ((cp = strchr(buf, ' ')) != NULL) {
629  while (*cp == ' ')
630  *cp++ = 0;
631  has_val = 1;
632  } else {
633  cp = dummy;
634  has_val = 0;
635  }
636 
637  if (!strcasecmp(buf, "metaserver_notification")) {
638  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
640  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
642  } else {
643  LOG(llevError, "load_settings: Unknown value for metaserver_notification: %s\n", cp);
644  }
645  } else if (!strcasecmp(buf, "metaserver_server")) {
646  if (has_val)
648  else
649  LOG(llevError, "load_settings: metaserver_server must have a value.\n");
650  } else if (!strcasecmp(buf, "motd")) {
651  if (has_val) {
652  safe_strncpy(motd, cp, sizeof(motd));
653  settings.motd = motd;
654  } else
655  LOG(llevError, "load_settings: motd must have a value.\n");
656  } else if (!strcasecmp(buf, "metaserver_host")) {
657  if (has_val)
659  else
660  LOG(llevError, "load_settings: metaserver_host must have a value.\n");
661  } else if (!strcasecmp(buf, "port")) {
662  set_csport(cp);
663  } else if (!strcasecmp(buf, "metaserver_port")) {
664  int port = atoi(cp);
665 
666  if (port < 1 || port > 65535)
667  LOG(llevError, "load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
668  else
669  settings.meta_port = port;
670  } else if (!strcasecmp(buf, "metaserver_comment")) {
672  } else if (!strcasecmp(buf, "worldmapstartx")) {
673  int size = atoi(cp);
674 
675  if (size < 0)
676  LOG(llevError, "load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
677  else
678  settings.worldmapstartx = size;
679  } else if (!strcasecmp(buf, "worldmapstarty")) {
680  int size = atoi(cp);
681 
682  if (size < 0)
683  LOG(llevError, "load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
684  else
685  settings.worldmapstarty = size;
686  } else if (!strcasecmp(buf, "worldmaptilesx")) {
687  int size = atoi(cp);
688 
689  if (size < 1)
690  LOG(llevError, "load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
691  else
692  settings.worldmaptilesx = size;
693  } else if (!strcasecmp(buf, "worldmaptilesy")) {
694  int size = atoi(cp);
695 
696  if (size < 1)
697  LOG(llevError, "load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
698  else
699  settings.worldmaptilesy = size;
700  } else if (!strcasecmp(buf, "worldmaptilesizex")) {
701  int size = atoi(cp);
702 
703  if (size < 1)
704  LOG(llevError, "load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
705  else
707  } else if (!strcasecmp(buf, "worldmaptilesizey")) {
708  int size = atoi(cp);
709 
710  if (size < 1)
711  LOG(llevError, "load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
712  else
714  } else if (!strcasecmp(buf, "fastclock")) {
715  int lev = atoi(cp);
716 
717  if (lev < 0)
718  LOG(llevError, "load_settings: fastclock must be at least 0, %d is invalid\n", lev);
719  else
720  settings.fastclock = lev;
721  } else if (!strcasecmp(buf, "not_permadeth")) {
722  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
724  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
726  } else {
727  LOG(llevError, "load_settings: Unknown value for not_permadeth: %s\n", cp);
728  }
729  } else if (!strcasecmp(buf, "resurrection")) {
730  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
732  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
734  } else {
735  LOG(llevError, "load_settings: Unknown value for resurrection: %s\n", cp);
736  }
737  } else if (!strcasecmp(buf, "set_title")) {
738  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
740  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
742  } else {
743  LOG(llevError, "load_settings: Unknown value for set_title: %s\n", cp);
744  }
745  } else if (!strcasecmp(buf, "search_items")) {
746  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
748  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
750  } else {
751  LOG(llevError, "load_settings: Unknown value for search_items: %s\n", cp);
752  }
753  } else if (!strcasecmp(buf, "spell_encumbrance")) {
754  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
756  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
758  } else {
759  LOG(llevError, "load_settings: Unknown value for spell_encumbrance: %s\n", cp);
760  }
761  } else if (!strcasecmp(buf, "spell_failure_effects")) {
762  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
764  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
766  } else {
767  LOG(llevError, "load_settings: Unknown value for spell_failure_effects: %s\n", cp);
768  }
769  } else if (!strcasecmp(buf, "casting_time")) {
770  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
772  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
774  } else {
775  LOG(llevError, "load_settings: Unknown value for casting_time: %s\n", cp);
776  }
777  } else if (!strcasecmp(buf, "real_wiz")) {
778  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
780  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
782  } else {
783  LOG(llevError, "load_settings: Unknown value for real_wiz: %s\n", cp);
784  }
785  } else if (!strcasecmp(buf, "recycle_tmp_maps")) {
786  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
788  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
790  } else {
791  LOG(llevError, "load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
792  }
793  } else if (!strcasecmp(buf, "always_show_hp")) {
794  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
796  } else if (!strcasecmp(cp, "damaged")) {
798  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
800  } else {
801  LOG(llevError, "load_settings: Unknown value for always_show_hp: %s\n", cp);
802  }
803  } else if (!strcasecmp(buf, "who_format")) {
804  if (has_val)
806  sizeof(settings.who_format));
807  } else if (!strcasecmp(buf, "who_wiz_format")) {
808  if (has_val) {
810  sizeof(settings.who_wiz_format));
811  }
812  } else if (!strcasecmp(buf, "spellpoint_level_depend")) {
813  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
815  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
817  } else {
818  LOG(llevError, "load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
819  }
820  } else if (!strcasecmp(buf, "stat_loss_on_death")) {
821  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
823  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
825  } else {
826  LOG(llevError, "load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
827  }
828  } else if (!strcasecmp(buf, "use_permanent_experience")) {
829  LOG(llevError, "use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
830  } else if (!strcasecmp(buf, "permanent_experience_percentage")) {
831  int val = atoi(cp);
832  if (val < 0 || val > 100)
833  LOG(llevError, "load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
834  else
836  } else if (!strcasecmp(buf, "death_penalty_percentage")) {
837  int val = atoi(cp);
838  if (val < 0 || val > 100)
839  LOG(llevError, "load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
840  else
842  } else if (!strcasecmp(buf, "death_penalty_levels")) {
843  int val = atoi(cp);
844  if (val < 0 || val > 255)
845  LOG(llevError, "load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
846  else
848  } else if (!strcasecmp(buf, "balanced_stat_loss")) {
849  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
851  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
853  } else {
854  LOG(llevError, "load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
855  }
856  } else if (!strcasecmp(buf, "simple_exp")) {
857  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
859  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
861  } else {
862  LOG(llevError, "load_settings: Unknown value for simple_exp: %s\n", cp);
863  }
864  } else if (!strcasecmp(buf, "item_power_factor")) {
865  float tmp = atof(cp);
866  if (tmp < 0)
867  LOG(llevError, "load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
868  else
870  } else if (!strcasecmp(buf, "pk_luck_penalty")) {
871  int16_t val = atoi(cp);
872 
873  if (val < -100 || val > 100)
874  LOG(llevError, "load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
875  else
877  } else if (!strcasecmp(buf, "set_friendly_fire")) {
878  int val = atoi(cp);
879 
880  if (val < 1 || val > 100)
881  LOG(llevError, "load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
882  else
884  } else if (!strcasecmp(buf, "armor_max_enchant")) {
885  int max_e = atoi(cp);
886  if (max_e <= 0)
887  LOG(llevError, "load_settings: armor_max_enchant is %d\n", max_e);
888  else
889  settings.armor_max_enchant = max_e;
890  } else if (!strcasecmp(buf, "armor_weight_reduction")) {
891  int wr = atoi(cp);
892  if (wr < 0)
893  LOG(llevError, "load_settings: armor_weight_reduction is %d\n", wr);
894  else
896  } else if (!strcasecmp(buf, "armor_weight_linear")) {
897  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
899  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
901  } else {
902  LOG(llevError, "load_settings: unknown value for armor_weight_linear: %s\n", cp);
903  }
904  } else if (!strcasecmp(buf, "armor_speed_improvement")) {
905  int wr = atoi(cp);
906  if (wr < 0)
907  LOG(llevError, "load_settings: armor_speed_improvement is %d\n", wr);
908  else
910  } else if (!strcasecmp(buf, "armor_speed_linear")) {
911  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
913  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
915  } else {
916  LOG(llevError, "load_settings: unknown value for armor_speed_linear: %s\n", cp);
917  }
918  } else if (!strcasecmp(buf, "no_player_stealing")) {
919  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
921  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
923  } else {
924  LOG(llevError, "load_settings: unknown value for no_player_stealing: %s\n", cp);
925  }
926  } else if (!strcasecmp(buf, "create_home_portals")) {
927  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
928 #ifdef TRY_BROKEN_TOWN_PORTALS
930 #else
931  LOG(llevError, "load_settings: create_home_portals is currently broken. It results in town portals that prematurely reset when the apartment is swapped.\n");
932 #endif
933  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
935  } else {
936  LOG(llevError, "load_settings: unknown value for create_home_portals: %s\n", cp);
937  }
938  } else if (!strcasecmp(buf, "personalized_blessings")) {
939  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
941  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
943  } else {
944  LOG(llevError, "load_settings: unknown value for personalized_blessings: %s\n", cp);
945  }
946  } else if (!strcasecmp(buf, "pk_max_experience")) {
947  int64_t pkme = atoll(cp);
948  if (pkme < 0)
949  pkme = -1;
951  } else if (!strcasecmp(buf, "pk_max_experience_percent")) {
952  int pkmep = atoi(cp);
953  if (pkmep < 0) {
954  LOG(llevError, "load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
955  } else
957  } else if (!strcasecmp(buf, "allow_denied_spells_writing")) {
958  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
960  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
962  } else {
963  LOG(llevError, "load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
964  }
965  } else if (!strcasecmp(buf, "allow_broken_converters")) {
966  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
968  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
970  } else {
971  LOG(llevError, "load_settings: unknown value for allow_broken_converters: %s\n", cp);
972  }
973  } else if (!strcasecmp(buf, "log_timestamp")) {
974  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
976  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
978  } else {
979  LOG(llevError, "load_settings: unknown value for log_timestamp: %s\n", cp);
980  }
981  } else if (!strcasecmp(buf, "log_timestamp_format")) {
984  } else if (!strcasecmp(buf, "starting_stat_min")) {
985  int val = atoi(cp);
986 
987  if (val < 1 || val > settings.max_stat || val > settings.starting_stat_max)
988  LOG(llevError, "load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
990  else
992  } else if (!strcasecmp(buf, "starting_stat_max")) {
993  int val = atoi(cp);
994 
995  if (val < 1 || val > settings.max_stat || val<settings.starting_stat_min)
996  LOG(llevError, "load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
998  else
1000  } else if (!strcasecmp(buf, "starting_stat_points")) {
1001  int val = atoi(cp);
1002 
1003  if (val < NUM_STATS * settings.starting_stat_min ||
1005  LOG(llevError, "load_settings: starting_stat_points (%d) need to be within %d-%d\n",
1007  else
1009  } else if (!strcasecmp(buf, "roll_stat_points")) {
1010  int val = atoi(cp);
1011 
1012  /* The 3 and 18 values are hard coded in because we know that
1013  * roll_stat() generates a value between 3 and 18 - if that ever
1014  * changed, this code should change also, but that code will eventually
1015  * go away.
1016  */
1017  if (val < NUM_STATS * 3 || val > NUM_STATS * 18)
1018  LOG(llevError, "load_settings: roll_stat_points need to be within %d-%d\n",
1019  NUM_STATS * 3, NUM_STATS * 18);
1020  else
1021  settings.roll_stat_points = val;
1022  } else if (!strcasecmp(buf, "special_break_map")) {
1023  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1025  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1027  } else {
1028  LOG(llevError, "load_settings: unknown value for special_break_map: %s\n", cp);
1029  }
1030  } else if (!strcasecmp(buf, "ignore_plugin_compatibility")) {
1031  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1033  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1035  } else {
1036  LOG(llevError, "load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1037  }
1038  } else if (!strcasecmp(buf, "account_block_create")) {
1039  if (!strcasecmp(cp, "on") || !strcasecmp(cp, "true")) {
1041  } else if (!strcasecmp(cp, "off") || !strcasecmp(cp, "false")) {
1043  } else {
1044  LOG(llevError, "load_settings: unknown value for account_block_create: %s\n", cp);
1045  }
1046  } else if (!strcasecmp(buf, "account_trusted_host")) {
1049  } else if (!strcasecmp(buf, "crypt_mode")) {
1050  int val = atoi(cp);
1051  if (val != 0 && val != 1) {
1052  LOG(llevError, "load_settings: crypt_mode must be 0 or 1\n");
1053  } else {
1054  settings.crypt_mode = val;
1055  }
1056  } else if (!strcasecmp(buf, "min_name")) {
1057  int val = atoi(cp);
1058 
1059  if (val < 1 || val > MAX_NAME )
1060  LOG(llevError, "load_settings: min_name (%d) need to be within %d-%d\n",
1061  val, 1, MAX_NAME);
1062  else
1063  settings.min_name = val;
1064  } else if (!strcasecmp(buf, "stat_file")) {
1066  } else {
1067  LOG(llevError, "Unknown value in settings file: %s\n", buf);
1068  }
1069  }
1070  fclose(fp);
1071  if (settings.log_timestamp_format == NULL)
1072  settings.log_timestamp_format = strdup_local("%y/%m/%d %H:%M:%S");
1073 
1074  /*
1075  * The who formats are defined in config to be blank. They should have been
1076  * overridden by the settings file, if there are no entries however, it will
1077  * have stayed blank. Since this probably isn't what is wanted, we will check if
1078  * new formats have been specified, and if not we will use the old defaults.
1079  */
1080  if (!strcmp(settings.who_format, ""))
1081  strcpy(settings.who_format, "%N_%t%h%d%b%n<%M>");
1082  if (!strcmp(settings.who_wiz_format, ""))
1083  strcpy(settings.who_wiz_format, "%N_%t%h%d%b%nLevel %l <%M>(@%i)(%c)");
1084 }
1085 
1089 }
1090 
1098 void init(int argc, char **argv) {
1099  logfile = stderr;
1100 
1101  /* First argument pass - right now it does nothing, but in the future specifying
1102  * the LibDir in this pass would be reasonable. */
1103  parse_args(argc, argv, 1);
1104 
1106  init_modules();
1107 
1108  init_library(); /* Must be called early */
1109  load_settings(); /* Load the settings file */
1110  parse_args(argc, argv, 2);
1111 
1112  LOG(llevInfo, "Crossfire %s\n", FULL_VERSION);
1113  SRANDOM(time(NULL));
1114 
1115  init_startup(); /* Check shutdown/forbid files */
1116  init_signals(); /* Sets up signal interceptions */
1117  commands_init(); /* Sort command tables */
1118  read_map_log(); /* Load up the old temp map files */
1119  init_skills();
1120  init_ob_methods();
1121  cftimer_init();
1122  hiscore_init();
1123 
1124  parse_args(argc, argv, 3);
1125 
1126  init_beforeplay();
1127  init_server();
1128  metaserver2_init();
1129  accounts_load();
1130  reset_sleep();
1131 }
1132 
1138 void free_server(void) {
1139  free_materials();
1140  free_races();
1141  free_quest();
1142  std::for_each(serverSettings.disabled_plugins.begin(), serverSettings.disabled_plugins.end(), [] (char *item) { free(item); });
1144 }
1145 
1149 static void help(void) {
1150  printf("Usage: crossfire-server [options]\n\n");
1151 
1152  printf("Options:\n");
1153  printf(" -conf Set the directory to find configuration files.\n");
1154  printf(" -d Turn on extra debugging messages.\n");
1155  printf(" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1156  printf(" -disable-module\n"
1157  " Disable specified module, by its name\n"
1158  " Can be specified multiple times. 'All' disables all modules.\n");
1159  printf(" -enable-module\n"
1160  " Enable specified module, by its name\n"
1161  " Can be specified multiple times. 'All' enables all modules.\n");
1162  printf(" -disable-plugin\n"
1163  " Disables specified plugin. Use the name without the extension.\n"
1164  " Can be specified multiple times. 'All' disables all plugins.\n");
1165  printf(" -dump-anims Dump animations.\n");
1166  printf(" -h Print this help message.\n");
1167  printf(" -ignore-assets-errors\n");
1168  printf(" Allow going on even if there are errors in assets.\n");
1169  printf(" Warning: this may lead to strange behaviour.\n");
1170  printf(" -list-modules\n"
1171  " List built-in modules and exit.\n");
1172  printf(" -local Set the local data (var/) directory.\n");
1173  printf(" -log <file> Write logging information to the given file.\n");
1174  printf(" -m List suggested experience for all monsters.\n");
1175  printf(" -m2 Dump monster abilities.\n");
1176  printf(" -m3 Dump artifact information.\n");
1177  printf(" -m4 Dump spell information.\n");
1178  printf(" -m5 Dump skill information.\n");
1179  printf(" -m6 Dump race information.\n");
1180  printf(" -m7 Dump alchemy information.\n");
1181  printf(" -m8 Dump gods information.\n");
1182  printf(" -m9 Dump more alchemy information (formula checking).\n");
1183  printf(" -maps Set the map directory.\n");
1184  printf(" -mexp Dump the experience table.\n");
1185  printf(" -mon Turn on monster debugging.\n");
1186  printf(" -mq Dump the quest list.\n");
1187  printf(" -mt <name> Dump a list of treasures for a monster.\n");
1188  printf(" -n Turn off debugging messages if on by default.\n");
1189  printf(" -p <port> Specifies the port to listen on for incoming connections.\n");
1190  printf(" -pack-assets <type> <filename>\n");
1191  printf(" Packs specified assets type to the specified filename.\n");
1192  printf(" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1193  printf(" The file format will be tar ('images') or text (everything else).\n");
1194  printf(" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1195  printf(" In this case the file will be in tar format.\n");
1196  printf(" -playerdir Set the player files directory.\n");
1197  printf(" -regions Set the region file.\n");
1198  printf(" -templatedir Set the template map directory.\n");
1199  printf(" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1200  printf(" -uniquedir Set the unique items/maps directory.\n");
1201  printf(" -v Print version information.\n");
1202  exit(EXIT_SUCCESS);
1203 }
1204 
1209 static void init_beforeplay(void) {
1210  init_archetype_pointers(); /* Setup global pointers to archetypes */
1211  finish_races(); /* overwrite race designations using entries in lib/races file */
1213  init_gods(); /* init linked list of gods from archs*/
1214  init_readable(); /* inits useful arrays for readable texts */
1215 
1216  switch (settings.dumpvalues) {
1217  case 1:
1218  print_monsters();
1219  cleanup();
1220  break;
1221 
1222  case 2:
1223  dump_abilities();
1224  cleanup();
1225  break;
1226 
1227  case 3:
1228  dump_artifacts();
1229  cleanup();
1230  break;
1231 
1232  case 4:
1233  dump_spells();
1234  cleanup();
1235  break;
1236 
1237  case 5:
1238  cleanup();
1239  break;
1240 
1241  case 6:
1242  dump_races();
1243  cleanup();
1244  break;
1245 
1246  case 7:
1247  dump_alchemy();
1248  cleanup();
1249  break;
1250 
1251  case 8:
1252  dump_gods();
1253  cleanup();
1254  break;
1255 
1256  case 9:
1258  cleanup();
1259  break;
1260 
1261  case 10:
1263  cleanup();
1264  break;
1265  }
1266 }
1267 
1273 static void init_startup(void) {
1274 #ifdef SHUTDOWN_FILE
1275  char buf[MAX_BUF];
1276  FILE *fp;
1277 
1278  snprintf(buf, sizeof(buf), "%s/%s", settings.confdir, SHUTDOWN_FILE);
1279  if ((fp = fopen(buf, "r")) != NULL) {
1280  while (fgets(buf, MAX_BUF-1, fp) != NULL)
1281  printf("%s", buf);
1282  fclose(fp);
1283  exit(1);
1284  }
1285 #endif
1286 
1287  if (forbid_play()) { /* Maybe showing highscore should be allowed? */
1288  LOG(llevError, "CrossFire: Playing not allowed.\n");
1289  exit(-1);
1290  }
1291 }
1292 
1296 static void signal_shutdown(int signum_unused) {
1297  (void) signum_unused; /* avoid unused warning if enambled */
1298  shutdown_flag += 1;
1299 }
1300 
1313 static void rec_sighup(int i) {
1314  (void)i;
1315  /* Don't call LOG(). It calls non-reentrant functions. The other
1316  * signal handlers shouldn't really call LOG() either. */
1317  if (logfile != stderr) {
1318  reopen_logfile = 1;
1319  }
1320 }
1321 
1325 void init_signals(void) {
1326 #ifndef WIN32 /* init_signals() remove signals */
1327  struct sigaction sa;
1328 
1329  sa.sa_sigaction = NULL;
1330  sigemptyset(&sa.sa_mask);
1331  sa.sa_flags = 0;
1332  sa.sa_handler = rec_sighup;
1333  sigaction(SIGHUP, &sa, NULL);
1334  signal(SIGINT, signal_shutdown);
1335  signal(SIGPIPE, SIG_IGN);
1336 #endif /* win32 */
1337 }
Settings::casting_time
uint8_t casting_time
It takes awhile to cast a spell.
Definition: global.h:271
Settings::special_break_map
uint8_t special_break_map
If set, then submaps in random maps can break the walls.
Definition: global.h:326
Settings::meta_comment
char meta_comment[MAX_BUF]
Comment we send to the metaserver.
Definition: global.h:290
Command_Line_Options
One command line option definition.
Definition: init.cpp:368
module_information::name
const char * name
Module name, without space.
Definition: init.cpp:48
Settings::mapdir
const char * mapdir
Where the map files are.
Definition: global.h:252
global.h
Settings::meta_server
char meta_server[MAX_BUF]
Hostname/ip addr of the metaserver.
Definition: global.h:287
settings
struct Settings settings
Global settings.
Definition: init.cpp:139
Settings::simple_exp
uint8_t simple_exp
If true, use the simple experience system.
Definition: global.h:264
citylife_init
void citylife_init(Settings *settings, ServerSettings *serverSettings)
Definition: citylife.cpp:426
safe_strncpy
#define safe_strncpy
Definition: compat.h:27
options
static struct Command_Line_Options options[]
Actual valid command line options.
Definition: init.cpp:386
Settings::recycle_tmp_maps
uint8_t recycle_tmp_maps
Re-use tmp maps.
Definition: global.h:273
init
void init(int argc, char **argv)
This is the main server initialization function.
Definition: init.cpp:1098
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:1209
Settings::regions
const char * regions
Name of the regions file - libdir is prepended.
Definition: global.h:253
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:317
Settings::log_timestamp_format
char * log_timestamp_format
Format for timestap, if log_timestamp is set.
Definition: global.h:320
Settings::armor_speed_linear
uint8_t armor_speed_linear
If 1, speed improvement is linear, else exponantiel.
Definition: global.h:310
module_information::close
void(* close)()
Cleanup function.
Definition: init.cpp:52
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:267
serverSettings
ServerSettings serverSettings
Definition: init.cpp:42
service_handle
void service_handle()
Settings::set_title
uint8_t set_title
Players can set thier title.
Definition: global.h:266
dump_alchemy_costs
void dump_alchemy_costs(void)
Dumps to output all costs of recipes.
Definition: recipe.cpp:591
Settings::ignore_plugin_compatibility
uint8_t ignore_plugin_compatibility
If set, don't check plugin version.
Definition: global.h:327
FALSE
#define FALSE
Definition: compat.h:14
Settings::not_permadeth
uint8_t not_permadeth
If true, death is non-permament.
Definition: global.h:263
Settings::permanent_exp_ratio
uint8_t permanent_exp_ratio
How much exp should be 'permenant' and unable to be lost.
Definition: global.h:259
Settings::crypt_mode
uint8_t crypt_mode
0 for legacy behavior, 1 for always Traditional
Definition: global.h:330
set_datadir
static void set_datadir(const char *path)
Command line option: set data path.
Definition: init.cpp:191
module_information::description
const char * description
Module long description.
Definition: init.cpp:49
Settings::dumpvalues
uint8_t dumpvalues
Set to dump various values/tables.
Definition: global.h:246
Settings::datadir
const char * datadir
Read only data files.
Definition: global.h:249
load_materials
static void load_materials(BufferReader *reader, const char *filename)
Loads the materials.
Definition: init.cpp:530
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:215
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:164
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:295
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:1313
Settings::min_name
uint8_t min_name
Minimum characters for an account or player name.
Definition: global.h:331
SRANDOM
#define SRANDOM(seed)
Definition: define.h:639
Settings::worldmapstartx
uint32_t worldmapstartx
Starting x tile for the worldmap.
Definition: global.h:292
list_modules
static void list_modules()
List all modules, then exit.
Definition: init.cpp:96
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:510
set_dumpmont
static void set_dumpmont(const char *name)
Command line option: dump monster treasures.
Definition: init.cpp:182
init_ob_methods
void init_ob_methods(void)
Initializes the ob_method system.
Definition: ob_methods.cpp:35
set_dumpmon6
static void set_dumpmon6(void)
Command line option: dump races.
Definition: init.cpp:159
Settings::starting_stat_min
uint8_t starting_stat_min
Minimum value of a starting stat.
Definition: global.h:321
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:324
Settings::pk_luck_penalty
int16_t pk_luck_penalty
Amount by which player luck is reduced if they PK.
Definition: global.h:258
FREE_AND_COPY_IF
#define FREE_AND_COPY_IF(sv, nv)
Definition: global.h:208
Settings::stat_file
char * stat_file
Definition: global.h:335
set_mondebug
static void set_mondebug(void)
Command line option: monster debug flag.
Definition: init.cpp:129
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:335
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:247
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:243
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:332
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:139
Command_Line_Options::num_args
uint8_t num_args
Number or args it takes.
Definition: init.cpp:370
Settings::meta_host
char meta_host[MAX_BUF]
Hostname of this host.
Definition: global.h:288
set_dumpmon4
static void set_dumpmon4(void)
Command line option: dump spells.
Definition: init.cpp:149
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:294
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:314
Command_Line_Options::cmd_option
const char * cmd_option
How it is called on the command line.
Definition: init.cpp:369
server_dump_faces
static void server_dump_faces(void)
Dump all faces, then exit.
Definition: init.cpp:343
init_signals
void init_signals(void)
Setup our signal handlers.
Definition: init.cpp:1325
parse_args
static void parse_args(int argc, char *argv[], int pass)
Parse command line arguments.
Definition: init.cpp:458
Settings::spell_encumbrance
uint8_t spell_encumbrance
Encumbrance effects spells.
Definition: global.h:269
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
ServerSettings::disabled_plugins
std::vector< char * > disabled_plugins
List of disabled plugins, 'All' means all.
Definition: server.h:16
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::meta_port
uint16_t meta_port
Port number to use for updates.
Definition: global.h:289
modules
static module_information modules[]
All built modules.
Definition: init.cpp:56
Settings::balanced_stat_loss
uint8_t balanced_stat_loss
If true, Death stat depletion based on level etc.
Definition: global.h:262
dump_stat_bonuses
void dump_stat_bonuses()
Definition: living.cpp:2651
Settings::debug
LogLevel debug
Default debugging level.
Definition: global.h:244
load_settings
static void load_settings(void)
This loads the settings file.
Definition: init.cpp:597
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:315
add_refcount
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
Definition: shstr.cpp:210
Settings::death_penalty_ratio
uint8_t death_penalty_ratio
Hhow much exp should be lost at death.
Definition: global.h:260
set_dumpmon3
static void set_dumpmon3(void)
Command line option: dump artifacts.
Definition: init.cpp:144
random_house_generator_init
void random_house_generator_init(Settings *settings, ServerSettings *serverSettings)
Module initialisation.
Definition: random_house_generator.cpp:211
assets_add_collector_hook
void assets_add_collector_hook(const char *name, collectorHook hook)
Definition: assets.cpp:552
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:221
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:276
Settings::account_block_create
uint8_t account_block_create
Definition: global.h:328
Settings::motd
const char * motd
Name of the motd file.
Definition: global.h:279
Settings::logfilename
const char * logfilename
Logfile to use.
Definition: global.h:242
Settings::worldmapstarty
uint32_t worldmapstarty
Starting y tile for the worldmap.
Definition: global.h:293
cfcitybell_init
void cfcitybell_init(Settings *settings, ServerSettings *serverSettings)
Citybells module initialisation.
Definition: cfcitybell.cpp:153
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:328
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:134
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:307
Settings::stat_loss_on_death
uint8_t stat_loss_on_death
If true, chars lose a random stat when they die.
Definition: global.h:257
signal_shutdown
static void signal_shutdown(int signum_unused)
Signal handler that begins a normal server shutdown.
Definition: init.cpp:1296
Settings::item_power_factor
float item_power_factor
See note in setings file.
Definition: global.h:304
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:108
service_unregister
void service_unregister()
Settings::dumparg
const char * dumparg
Additional argument for some dump functions.
Definition: global.h:247
assets_finish_archetypes_for_play
void assets_finish_archetypes_for_play()
Definition: assets.cpp:509
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:248
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:255
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:231
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:261
modules.h
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:174
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:199
cmdlinefunc_args2
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
Definition: init.cpp:360
set_dumpmon8
static void set_dumpmon8(void)
Command line option: dump gods.
Definition: init.cpp:169
Settings::playerdir
const char * playerdir
Where the player files are.
Definition: global.h:251
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:270
Settings::starting_stat_points
uint8_t starting_stat_points
How many stat points character starts with.
Definition: global.h:323
Settings
Server settings.
Definition: global.h:241
module_information::init
void(* init)(Settings *, ServerSettings *)
Initialisation function.
Definition: init.cpp:51
Settings::meta_on
unsigned int meta_on
True if we should send updates.
Definition: global.h:286
Settings::allow_denied_spells_writing
int allow_denied_spells_writing
If set, players can write spells they can't cast.
Definition: global.h:316
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:223
should_exit
static int should_exit
If set after command line argument parsing, then the server will exit.
Definition: init.cpp:45
init_library
void init_library(void)
It is vital that init_library() is called by any functions using this library.
Definition: init.cpp:315
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:278
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:275
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:298
cmdlinefunc_args1
void(* cmdlinefunc_args1)(const char *arg1)
Definition: init.cpp:359
ServerSettings
Definition: server.h:15
free_materials
static void free_materials(void)
Frees all memory allocated to materials.
Definition: init.cpp:585
Settings::personalized_blessings
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
Definition: global.h:313
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:124
dump_alchemy
void dump_alchemy(void)
Dumps alchemy recipes to output.
Definition: recipe.cpp:352
help
static void help(void)
Display the command line options and exits.
Definition: init.cpp:1149
Settings::max_stat
uint8_t max_stat
Maximum stat value - 255 should be sufficient.
Definition: global.h:325
cmdlinefunc_args0
void(* cmdlinefunc_args0)(void)
Typedefs used when calling option handlers.
Definition: init.cpp:358
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:119
close_modules
void close_modules()
Clean up all modules which are not disabled.
Definition: init.cpp:82
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:306
cfcitybell_close
void cfcitybell_close()
Definition: cfcitybell.cpp:165
set_ignore_assets_errors
static void set_ignore_assets_errors()
Command line option: ignore assets errors.
Definition: init.cpp:262
dump_monster_treasure
void dump_monster_treasure(const char *name)
For debugging purposes.
Definition: treasure.cpp:1284
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:1086
Settings::armor_weight_linear
uint8_t armor_weight_linear
If 1, weight reduction is linear, else exponantiel.
Definition: global.h:308
set_dumpmon5
static void set_dumpmon5(void)
Command line option: ?
Definition: init.cpp:154
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:296
init_modules
void init_modules()
Init all modules which are not disabled.
Definition: init.cpp:66
call_version
static void call_version(void)
Command line option: show version.
Definition: init.cpp:113
set_csport
static void set_csport(const char *val)
Change the server's port.
Definition: init.cpp:279
loader.h
Settings::real_wiz
uint8_t real_wiz
Use mud-like wizards.
Definition: global.h:272
init_startup
static void init_startup(void)
Checks if starting the server is allowed.
Definition: init.cpp:1273
Settings::templatedir
const char * templatedir
Directory for the template map.
Definition: global.h:255
set_disable_plugin
static void set_disable_plugin(const char *name)
Disable a plugin.
Definition: init.cpp:292
Settings::worldmaptilesizey
uint32_t worldmaptilesizey
Number of squares high in a wm tile.
Definition: global.h:297
set_localdir
static void set_localdir(const char *path)
Command line option: set local path.
Definition: init.cpp:207
assets_pack
void assets_pack(const char *what, const char *filename)
Pack the specified assets in a file.
Definition: assets.cpp:418
set_disable_module
static void set_disable_module(const char *name)
Disable a module.
Definition: init.cpp:320
free_server
void free_server(void)
Frees all memory allocated around here:
Definition: init.cpp:1138
citylife_close
void citylife_close()
Definition: citylife.cpp:437
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:311
Settings::account_trusted_host
char * account_trusted_host
Block account creation for untrusted hosts.
Definition: global.h:329
Settings::search_items
uint8_t search_items
Search_items command.
Definition: global.h:268
module_information
Definition: init.cpp:47
server.h
Settings::tmpdir
const char * tmpdir
Directory to use for temporary files.
Definition: global.h:256
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:274
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:239
Settings::create_home_portals
uint8_t create_home_portals
If 1, can create portals in unique maps (apartments)
Definition: global.h:312
server_dump_bonuses
static void server_dump_bonuses()
Dump all bonuses (from the stat_bonus file) then exit.
Definition: init.cpp:351
Command_Line_Options::pass
uint8_t pass
What pass this should be processed on.
Definition: init.cpp:371
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:309
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:319
Settings::who_format
char who_format[MAX_BUF]
The format that the who command should use.
Definition: global.h:277
server_pack_assets
static void server_pack_assets(const char *assets, const char *filename)
Definition: init.cpp:266
Command_Line_Options::func
void(* func)()
function to call when we match this.
Definition: init.cpp:372
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:50
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:302
Settings::starting_stat_max
uint8_t starting_stat_max
Maximum value of a starting stat.
Definition: global.h:322
Settings::uniquedir
const char * uniquedir
Directory for the unique items.
Definition: global.h:254
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:250