44 static void help(
void);
45 static void usage(
void);
238 {
"-h", 0, 1,
help },
240 {
"-help", 0, 1,
help },
308 while (on_arg < argc) {
310 if (!strcmp(options[i].
cmd_option, argv[on_arg])) {
314 if (options[i].pass != pass) {
319 if ((on_arg+options[i].num_args) >= argc) {
320 fprintf(stderr,
"%s requires an argument.\n", options[i].cmd_option);
323 if (options[i].num_args == 1)
325 if (options[i].num_args == 2)
337 fprintf(stderr,
"Unknown option: %s\n", argv[on_arg]);
392 LOG(
llevDebug,
"Reading material type data from %s...\n", filename);
393 if ((fp = fopen(filename,
"r")) == NULL) {
394 LOG(
llevError,
"Cannot open %s for reading\n", filename);
402 while (fgets(buf,
MAX_BUF, fp) != NULL) {
405 if ((cp = strchr(buf,
'\n')) != NULL)
410 if (!strncmp(cp,
"name", 4)) {
412 if (mt->
next != NULL) {
419 }
else if (!strncmp(cp,
"description", 11)) {
421 }
else if (sscanf(cp,
"material %d", &value)) {
423 }
else if (!strncmp(cp,
"saves", 5)) {
424 cp = strchr(cp,
' ')+1;
430 if ((next = strchr(cp,
',')) != NULL)
432 sscanf(cp,
"%d", &value);
436 }
else if (!strncmp(cp,
"mods", 4)) {
437 cp = strchr(cp,
' ')+1;
443 if ((next = strchr(cp,
',')) != NULL)
445 sscanf(cp,
"%d", &value);
449 }
else if (sscanf(cp,
"chance %d\n", &value)) {
451 }
else if (sscanf(cp,
"diff %d\n", &value)) {
453 }
else if (sscanf(cp,
"magic %d\n", &value)) {
455 }
else if (sscanf(cp,
"damage %d\n", &value)) {
457 }
else if (sscanf(cp,
"wc %d\n", &value)) {
459 }
else if (sscanf(cp,
"ac %d\n", &value)) {
461 }
else if (sscanf(cp,
"sp %d\n", &value)) {
463 }
else if (sscanf(cp,
"weight %d\n", &value)) {
465 }
else if (sscanf(cp,
"value %d\n", &value)) {
485 next = materialt->
next;
512 while (fgets(buf,
MAX_BUF-1, fp) != NULL) {
516 if ((cp = strrchr(buf,
'\n')) != NULL)
526 if ((cp = strchr(buf,
' ')) != NULL) {
535 if (!
strcasecmp(buf,
"metaserver_notification")) {
541 LOG(
llevError,
"load_settings: Unknown value for metaserver_notification: %s\n", cp);
543 }
else if (!
strcasecmp(buf,
"metaserver_server")) {
547 LOG(
llevError,
"load_settings: metaserver_server must have a value.\n");
552 LOG(
llevError,
"load_settings: motd must have a value.\n");
557 LOG(
llevError,
"load_settings: dm_mail must have a value.\n");
558 }
else if (!
strcasecmp(buf,
"metaserver_host")) {
562 LOG(
llevError,
"load_settings: metaserver_host must have a value.\n");
565 }
else if (!
strcasecmp(buf,
"metaserver_port")) {
568 if (port < 1 || port > 65535)
569 LOG(
llevError,
"load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
572 }
else if (!
strcasecmp(buf,
"metaserver_comment")) {
574 }
else if (!
strcasecmp(buf,
"worldmapstartx")) {
578 LOG(
llevError,
"load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
581 }
else if (!
strcasecmp(buf,
"worldmapstarty")) {
585 LOG(
llevError,
"load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
588 }
else if (!
strcasecmp(buf,
"worldmaptilesx")) {
592 LOG(
llevError,
"load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
595 }
else if (!
strcasecmp(buf,
"worldmaptilesy")) {
599 LOG(
llevError,
"load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
602 }
else if (!
strcasecmp(buf,
"worldmaptilesizex")) {
606 LOG(
llevError,
"load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
609 }
else if (!
strcasecmp(buf,
"worldmaptilesizey")) {
613 LOG(
llevError,
"load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
620 LOG(
llevError,
"load_settings: fastclock must be at least 0, %d is invalid\n", lev);
623 }
else if (!
strcasecmp(buf,
"not_permadeth")) {
629 LOG(
llevError,
"load_settings: Unknown value for not_permadeth: %s\n", cp);
631 }
else if (!
strcasecmp(buf,
"resurrection")) {
637 LOG(
llevError,
"load_settings: Unknown value for resurrection: %s\n", cp);
645 LOG(
llevError,
"load_settings: Unknown value for set_title: %s\n", cp);
647 }
else if (!
strcasecmp(buf,
"search_items")) {
653 LOG(
llevError,
"load_settings: Unknown value for search_items: %s\n", cp);
655 }
else if (!
strcasecmp(buf,
"spell_encumbrance")) {
661 LOG(
llevError,
"load_settings: Unknown value for spell_encumbrance: %s\n", cp);
663 }
else if (!
strcasecmp(buf,
"spell_failure_effects")) {
669 LOG(
llevError,
"load_settings: Unknown value for spell_failure_effects: %s\n", cp);
671 }
else if (!
strcasecmp(buf,
"casting_time")) {
677 LOG(
llevError,
"load_settings: Unknown value for casting_time: %s\n", cp);
685 LOG(
llevError,
"load_settings: Unknown value for real_wiz: %s\n", cp);
687 }
else if (!
strcasecmp(buf,
"recycle_tmp_maps")) {
693 LOG(
llevError,
"load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
695 }
else if (!
strcasecmp(buf,
"explore_mode")) {
701 LOG(
llevError,
"load_settings: Unknown value for explore_mode: %s\n", cp);
706 }
else if (!
strcasecmp(buf,
"who_wiz_format")) {
709 }
else if (!
strcasecmp(buf,
"spellpoint_level_depend")) {
715 LOG(
llevError,
"load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
717 }
else if (!
strcasecmp(buf,
"stat_loss_on_death")) {
723 LOG(
llevError,
"load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
725 }
else if (!
strcasecmp(buf,
"use_permanent_experience")) {
726 LOG(
llevError,
"use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
727 }
else if (!
strcasecmp(buf,
"permanent_experience_percentage")) {
729 if (val < 0 || val > 100)
730 LOG(
llevError,
"load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
733 }
else if (!
strcasecmp(buf,
"death_penalty_percentage")) {
735 if (val < 0 || val > 100)
736 LOG(
llevError,
"load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
739 }
else if (!
strcasecmp(buf,
"death_penalty_levels")) {
741 if (val < 0 || val > 255)
742 LOG(
llevError,
"load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
745 }
else if (!
strcasecmp(buf,
"balanced_stat_loss")) {
751 LOG(
llevError,
"load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
759 LOG(
llevError,
"load_settings: Unknown value for simple_exp: %s\n", cp);
761 }
else if (!
strcasecmp(buf,
"item_power_factor")) {
762 float tmp = atof(cp);
764 LOG(
llevError,
"load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
767 }
else if (!
strcasecmp(buf,
"pk_luck_penalty")) {
770 if (val < -100 || val > 100)
771 LOG(
llevError,
"load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
774 }
else if (!
strcasecmp(buf,
"set_friendly_fire")) {
777 if (val < 1 || val > 100)
778 LOG(
llevError,
"load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
781 }
else if (!
strcasecmp(buf,
"armor_max_enchant")) {
782 int max_e = atoi(cp);
784 LOG(
llevError,
"load_settings: armor_max_enchant is %d\n", max_e);
787 }
else if (!
strcasecmp(buf,
"armor_weight_reduction")) {
790 LOG(
llevError,
"load_settings: armor_weight_reduction is %d\n", wr);
793 }
else if (!
strcasecmp(buf,
"armor_weight_linear")) {
799 LOG(
llevError,
"load_settings: unknown value for armor_weight_linear: %s\n", cp);
802 }
else if (!
strcasecmp(buf,
"armor_speed_improvement")) {
805 LOG(
llevError,
"load_settings: armor_speed_improvement is %d\n", wr);
808 }
else if (!
strcasecmp(buf,
"armor_speed_linear")) {
814 LOG(
llevError,
"load_settings: unknown value for armor_speed_linear: %s\n", cp);
817 }
else if (!
strcasecmp(buf,
"no_player_stealing")) {
823 LOG(
llevError,
"load_settings: unknown value for no_player_stealing: %s\n", cp);
826 }
else if (!
strcasecmp(buf,
"create_home_portals")) {
832 LOG(
llevError,
"load_settings: unknown value for create_home_portals: %s\n", cp);
834 }
else if (!
strcasecmp(buf,
"personalized_blessings")) {
840 LOG(
llevError,
"load_settings: unknown value for personalized_blessings: %s\n", cp);
842 }
else if (!
strcasecmp(buf,
"pk_max_experience")) {
843 sint64 pkme = atoll(cp);
847 }
else if (!
strcasecmp(buf,
"pk_max_experience_percent")) {
848 int pkmep = atoi(cp);
850 LOG(
llevError,
"load_settings: pk_max_experience_percent should be positive or zero\n", cp);
853 }
else if (!
strcasecmp(buf,
"allow_denied_spells_writing")) {
859 LOG(
llevError,
"load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
861 }
else if (!
strcasecmp(buf,
"allow_broken_converters")) {
867 LOG(
llevError,
"load_settings: unknown value for allow_broken_converters: %s\n", cp);
869 }
else if (!
strcasecmp(buf,
"log_timestamp")) {
875 LOG(
llevError,
"load_settings: unknown value for log_timestamp: %s\n", cp);
877 }
else if (!
strcasecmp(buf,
"log_timestamp_format")) {
881 LOG(
llevError,
"Unknown value in settings file: %s\n", buf);
905 void init(
int argc,
char **argv) {
918 fprintf(
logfile,
"Copyright (C) 1994 Mark Wedel.\n");
919 fprintf(
logfile,
"Copyright (C) 1992 Frank Tore Johansen.\n");
923 fprintf(
logfile,
"Questions and bugs should be mailed to above address.\n");
961 (void)fprintf(
logfile,
"Usage: crossfire [-h] [-<flags>]...\n");
968 printf(
" -csport <port> Specifies the port to use for the new client/server code.\n");
969 printf(
" -d Turns on some debugging.\n");
970 printf(
" +d Turns off debugging (useful if server compiled with debugging\n");
971 printf(
" as default).\n");
972 printf(
" -detach The server will go in the background, closing all\n");
973 printf(
" connections to the tty.\n");
974 printf(
" -h Display this information.\n");
975 printf(
" -log <file> Specifies which file to send output to.\n");
976 printf(
" Only has meaning if -detach is specified.\n");
977 printf(
" -mon Turns on monster debugging.\n");
978 printf(
" -o Prints out info on what was defined at compile time.\n");
979 printf(
" -s Display the high-score list.\n");
980 printf(
" -score <name or class> Displays all high scores with matching name/class.\n");
981 printf(
" -v Print version and contributors.\n");
982 printf(
" -conf Sets the configuration dir (settings, motd, etc.)\n");
983 printf(
" -data Sets the lib dir (archetypes, treasures, etc.)\n");
984 printf(
" -local Read/write local data (hiscore, unique items, etc.)\n");
985 printf(
" -maps Sets the directory for maps.\n");
986 printf(
" -arch Sets the archetype file to use.\n");
987 printf(
" -regions Sets the regions file to use.\n");
988 printf(
" -playerdir Sets the directory for the player files.\n");
989 printf(
" -templatedir Sets the directory for template generate maps.\n");
990 printf(
" -treasures Sets the treasures file to use.\n");
991 printf(
" -uniquedir Sets the unique items/maps directory.\n");
992 printf(
" -tmpdir Sets the directory for temporary files (mostly maps.)\n");
993 printf(
" -m Lists out suggested experience for all monsters.\n");
994 printf(
" -m2 Dumps out abilities.\n");
995 printf(
" -m3 Dumps out artifact information.\n");
996 printf(
" -m4 Dumps out spell information.\n");
997 printf(
" -m5 Dumps out skill information.\n");
998 printf(
" -m6 Dumps out race information.\n");
999 printf(
" -m7 Dumps out alchemy information.\n");
1000 printf(
" -m8 Dumps out gods information.\n");
1001 printf(
" -m9 Dumps out more alchemy information (formula checking).\n");
1002 printf(
" -mt <name> Dumps out list of treasures for a monster.\n");
1069 #ifdef SHUTDOWN_FILE
1072 while (fgets(buf,
MAX_BUF-1, fp) != NULL)
1095 printf(
"Non-standard include files:\n");
1096 #if !defined(__STRICT_ANSI__) || defined(__sun__)
1098 printf(
"<stdlib.h>\n");
1101 #if !defined(MACH) && !defined(sony)
1102 printf(
"<malloc.h>\n");
1106 #ifndef __STRICT_ANSI__
1108 printf(
"<memory.h\n");
1113 printf(
"<sys/timeb.h>\n");
1121 printf(
"Perm file:\t<ETC>/%s\n",
PERM_FILE);
1123 #ifdef SHUTDOWN_FILE
1126 printf(
"Save player:\t<true>\n");
1127 printf(
"Save mode:\t%4.4o\n",
SAVE_MODE);
1134 printf(
"Use_calloc:\t<true>\n");
1136 printf(
"Use_calloc:\t<false>\n");
1139 printf(
"Max_time:\t%d\n",
MAX_TIME);
1145 execl(
"/bin/uname",
"uname",
"-a", NULL);
1218 LOG(
llevError,
"\nSIGPIPE--------------\n------------\n--------\n---\n");
1219 #if 1 && !defined(WIN32)
1220 LOG(
llevInfo,
"\nReceived SIGPIPE, ignoring...\n");
1223 LOG(
llevError,
"\nSIGPIPE received, not ignoring...\n");
1273 struct sigaction sa;
1275 sa.sa_sigaction = NULL;
1276 sigemptyset(&sa.sa_mask);
1279 sigaction(SIGHUP, &sa, NULL);
1284 LOG(
llevInfo,
"\n---------registering SIGPIPE\n");
1313 if (!(file = fopen(fname,
"r"))) {
1318 while (fgets(buf,
MAX_BUF, file) != NULL) {
1319 int set_race = 1, set_list = 1;
1322 if ((cp = strchr(buf,
'\n')) != NULL)
1325 while (*cp ==
' ' || *cp ==
'!' || *cp ==
'@') {
1332 if (sscanf(cp,
"RACE %s", variable)) {
1333 strcpy(race, variable);
1338 for (cp1 = cp; *cp1 ==
' '; cp1++)
1341 for (cp1 = cp+strlen(cp)-1; *cp1 ==
'\n' || *cp1 ==
' '; cp1--) {
1347 if (cp[strlen(cp)-1] ==
'\n')
1348 cp[strlen(cp)-1] =
'\0';
1351 LOG(
llevError,
"Creature %s in race file lacks archetype\n", cp);
1378 fprintf(stderr,
"\nRACE %s:\t", list->
name);
1379 for (tmp = list->
member; tmp; tmp = tmp->
next)
1382 fprintf(stderr,
"\n");
1417 if (!op || !race_name)
1473 if (!test->
name || !strcmp(name, test->
name))
static void set_dumpmon2(void)
void clean_tmp_files(void)
archetype * find_archetype(const char *name)
static void set_dumpmon8(void)
static void rec_sigpipe(int i)
static void free_materials(void)
static void set_dumpmon7(void)
static void rec_sigsegv(int i)
static void set_mondebug(void)
void dump_artifacts(void)
static struct Command_Line_Options options[]
void print_monsters(void)
uint8 death_penalty_ratio
char who_wiz_format[MAX_BUF]
static void set_dumpmon1(void)
static void set_csport(const char *val)
void free_string(sstring str)
static void unset_debug(void)
static void rec_sigbus(int i)
void(* cmdlinefunc_args1)(const char *arg1)
int allow_broken_converters
void init_archetypes(void)
static void fatal_signal(int make_core)
uint8 spellpoint_level_depend
static void parse_args(int argc, char *argv[], int pass)
void close_and_delete(FILE *fp, int compressed)
objectlink * get_objectlink(void)
void dump_experience(void)
static void set_playerdir(const char *path)
void(* cmdlinefunc_args0)(void)
char meta_server[MAX_BUF]
static void set_datadir(const char *path)
racelink * find_racelink(const char *name)
void dump_alchemy_costs(void)
static void set_localdir(const char *path)
char meta_comment[MAX_BUF]
static void set_mapdir(const char *path)
static void rec_sigterm(int i)
static void add_to_racelist(const char *race_name, object *op)
materialtype_t * materialt
static void set_dumpmon4(void)
char * log_timestamp_format
int armor_speed_improvement
void init(int argc, char **argv)
uint8 spell_failure_effects
uint8 create_home_portals
static void init_signals(void)
void service_unregister()
static void rec_sigquit(int i)
static void init_startup(void)
static void load_settings(void)
static void set_dumpmon3(void)
static void load_materials(void)
static void set_tmpdir(const char *path)
EXTERN racelink * first_race
static void showscores(void)
static void set_templatedir(const char *path)
static void set_archetypes(const char *path)
static void compile_info(void)
static void set_treasures(const char *path)
#define QUERY_FLAG(xyz, p)
char * strdup_local(const char *str)
void emergency_save(int flag)
static void showscoresparm(const char *data)
static void set_logfile(char *val)
static void set_confdir(const char *path)
static char default_daemon_log[]
static void dump_races(void)
static void set_dumpmont(const char *name)
static void set_regions(const char *path)
int snprintf(char *dest, int max, const char *format,...)
int armor_weight_reduction
void dump_abilities(void)
static void set_debug(void)
static void set_dumpmon9(void)
uint8 armor_weight_linear
uint8 death_penalty_level
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
void dump_monster_treasure(const char *name)
static void init_beforeplay(void)
sstring add_string(const char *str)
static void call_version(void)
int strcasecmp(const char *s1, const char *s2)
static void init_races(void)
uint8 personalized_blessings
uint8 permanent_exp_ratio
static void free_races(void)
void display_high_score(object *op, int max, const char *match)
void LOG(LogLevel logLevel, const char *format,...)
static void set_daemon(void)
static void set_dumpmon5(void)
void metaserver_init(void)
struct _materialtype * next
static void rec_sighup(int i)
int metaserver2_init(void)
static void rec_sigint(int i)
int allow_denied_spells_writing
char * strerror_local(int errnum, char *buf, size_t size)
static void set_uniquedir(const char *path)
int pk_max_experience_percent
void init_archetype_pointers(void)
FILE * open_and_uncompress(const char *name, int flag, int *compressed)
void init_ob_methods(void)
static void set_dumpmon6(void)
void init_artifacts(void)
static materialtype_t * get_empty_mat(void)
static racelink * get_racelist(void)