/* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002 Mark Wedel & Crossfire Development Team * Copyright (©) 1992 Frank Tore Johansen * * Deliantra is free software: you can redistribute it and/or modify it under * the terms of the Affero GNU General Public License as published by the * Free Software Foundation, either version 3 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the Affero GNU General Public License * and the GNU General Public License along with this program. If not, see * . * * The authors can be reached via e-mail to */ #define EXTERN // horrible hack #include #include dynbuf_text msg_dynbuf (65536, 65536); extern const char *const attacktype_desc[NROFATTACKS] = { # define def(uc, lc, name, plus, change) # name, # include "attackinc.h" # undef def }; extern const char *const resist_plus[NROFATTACKS] = { # define def(uc, lc, name, plus, change) # plus, # include "attackinc.h" # undef def }; extern const char *const change_resist_msg[NROFATTACKS] = { # define def(uc, lc, name, plus, change) # change, # include "attackinc.h" # undef def }; int resist_table[NROFATTACKS] = { # define def(uc, lc, name, plus, change) ATNR_ ## uc, # include "attackinc.h" # undef def }; /* You unforunately need to looking in include/global.h to see what these * correspond to. */ struct Settings settings = { LOGFILE, /* Logfile */ CSPORT, /* Client/server port */ llevTrace, /* Log level */ 0, NULL, 0, /* dumpvalues, dumparg, daemonmode */ 0, /* argc */ NULL, /* argv */ CONFDIR, DATADIR, LOCALDIR, PLAYERDIR, MAPDIR, ARCHETYPES, REGIONS, TREASURES, UNIQUE_DIR, "", TMPDIR, PK_LUCK_PENALTY, STAT_LOSS_ON_DEATH, PERMANENT_EXPERIENCE_RATIO, DEATH_PENALTY_RATIO, DEATH_PENALTY_LEVEL, BALANCED_STAT_LOSS, NOT_PERMADETH, SIMPLE_EXP, SET_TITLE, RESURRECTION, SEARCH_ITEMS, SPELL_ENCUMBRANCE, SPELL_FAILURE_EFFECTS, SET_FRIENDLY_FIRE, 0, 0, EXPLORE_MODE, SPELLPOINT_LEVEL_DEPEND, 0, 1.0, /* Armor enchantment stuff */ ARMOR_MAX_ENCHANT, ARMOR_WEIGHT_REDUCTION, ARMOR_WEIGHT_LINEAR, ARMOR_SPEED_IMPROVEMENT, ARMOR_SPEED_LINEAR, }; /* perhaps not the best place for this, but needs to be * in some file in the common area so that standalone * programs, like the random map generator, can be built. */ const char *const spellpathnames[NRSPELLPATHS] = { "Protection", "Fire", "Frost", "Electricity", "Missiles", "Self", "Summoning", "Abjuration", "Restoration", "Detonation", "Mind", "Creation", "Teleportation", "Information", "Transmutation", "Transferrence", "Turning", "Wounding", "Death", "Light" }; /* init_environ initialises values from the environmental variables. * it needs to be called very early, since command line options should * overwrite these if specified. */ void init_environ () { const char *cp; if (cp = getenv ("DELIANTRA_CONFDIR" )) settings.confdir = cp; if (cp = getenv ("DELIANTRA_LIBDIR" )) settings.datadir = cp; if (cp = getenv ("DELIANTRA_LOCALDIR" )) settings.localdir = cp; if (cp = getenv ("DELIANTRA_PLAYERDIR" )) settings.playerdir = cp; if (cp = getenv ("DELIANTRA_MAPDIR" )) settings.mapdir = cp; if (cp = getenv ("DELIANTRA_ARCHETYPES" )) settings.archetypes = cp; if (cp = getenv ("DELIANTRA_TREASURES" )) settings.treasures = cp; if (cp = getenv ("DELIANTRA_UNIQUEDIR" )) settings.uniquedir = cp; if (cp = getenv ("DELIANTRA_TEMPLATEDIR")) settings.templatedir = cp; if (cp = getenv ("DELIANTRA_TMPDIR" )) settings.tmpdir = cp; if (cp = getenv ("DELIANTRA_LOGFILE" )) settings.logfilename = cp; } /* * Initialises all global variables. * Might use environment-variables as default for some of them. */ void init_globals () { if (settings.logfilename[0] == 0) log_setfd (-1); else { int logfd = open (settings.logfilename, O_CREAT|O_WRONLY|O_APPEND, 0666); if (logfd >= 0) log_setfd (logfd); else { log_setfd (-1); LOG (llevError, "Unable to open %s as the logfile - will use stderr instead", settings.logfilename); } } } void init_dynamic () { first_map_ext_path = "/start/HallsOfSelection"; first_map_path = "/HallOfSelection"; } /* * initialises the attack messages. * Called by init_library(). */ //attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS]; void init_attackmess () { object_thawer thawer (settings.datadir, "attackmess"); if (!thawer) { LOG (llevError, "Can't open %s.\n", thawer.name); return; } int msgnum = -1; int total = 0; while (thawer.kw) { if (thawer.kw != KW_type) if (!thawer.parse_error ("attackmess file")) break; thawer.get (msgnum); thawer.next (); int level = 0; while (thawer.kw == KW_hp) { // our old friend, dog-slow sscanf int hp; char buf1[1024]; char buf2[1024]; char buf3[1024]; if (4 != sscanf (thawer.value_nn, "%d %1023[^|]|%1023[^|]|%1023[^|]", &hp, buf1, buf2, buf3)) thawer.parse_error ("attackmess file"); else { if (*buf2 == '-') *buf2 = 0; // sscanf can't parse empty fields, so use "-" as marker attack_mess[msgnum][level].level = hp; attack_mess[msgnum][level].buf1 = strdup (buf1); attack_mess[msgnum][level].buf2 = strdup (buf2); attack_mess[msgnum][level].buf3 = strdup (buf3); ++level; ++total; } thawer.next (); } attack_mess[msgnum][level].level = -1; attack_mess[msgnum][level].buf1 = 0; attack_mess[msgnum][level].buf2 = 0; attack_mess[msgnum][level].buf3 = 0; } LOG (llevDebug, "got %d messages in %d categories.\n", total, msgnum + 1); }