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