Crossfire Server, Branches 1.12
R18729
|
#include <global.h>
#include <loader.h>
#include <version.h>
#include <sproto.h>
#include <strings.h>
Go to the source code of this file.
Data Structures | |
struct | Command_Line_Options |
Typedefs | |
typedef void(* | cmdlinefunc_args0 )(void) |
typedef void(* | cmdlinefunc_args1 )(const char *arg1) |
typedef void(* | cmdlinefunc_args2 )(const char *arg1, const char *arg2) |
Functions | |
static void | add_to_racelist (const char *race_name, object *op) |
static void | call_version (void) |
static void | compile_info (void) |
static void | dump_races (void) |
static void | fatal_signal (int make_core) |
racelink * | find_racelink (const char *name) |
static void | free_materials (void) |
static void | free_races (void) |
void | free_server (void) |
static materialtype_t * | get_empty_mat (void) |
static racelink * | get_racelist (void) |
static void | help (void) |
void | init (int argc, char **argv) |
static void | init_beforeplay (void) |
static void | init_races (void) |
static void | init_signals (void) |
static void | init_startup (void) |
static void | load_materials (void) |
static void | load_settings (void) |
static void | parse_args (int argc, char *argv[], int pass) |
static void | rec_sigbus (int i) |
static void | rec_sighup (int i) |
static void | rec_sigint (int i) |
static void | rec_sigpipe (int i) |
static void | rec_sigquit (int i) |
static void | rec_sigsegv (int i) |
static void | rec_sigterm (int i) |
static void | set_archetypes (const char *path) |
static void | set_confdir (const char *path) |
static void | set_csport (const char *val) |
static void | set_daemon (void) |
static void | set_datadir (const char *path) |
static void | set_debug (void) |
static void | set_dumpmon1 (void) |
static void | set_dumpmon2 (void) |
static void | set_dumpmon3 (void) |
static void | set_dumpmon4 (void) |
static void | set_dumpmon5 (void) |
static void | set_dumpmon6 (void) |
static void | set_dumpmon7 (void) |
static void | set_dumpmon8 (void) |
static void | set_dumpmon9 (void) |
static void | set_dumpmont (const char *name) |
static void | set_localdir (const char *path) |
static void | set_logfile (char *val) |
static void | set_mapdir (const char *path) |
static void | set_mondebug (void) |
static void | set_playerdir (const char *path) |
static void | set_regions (const char *path) |
static void | set_templatedir (const char *path) |
static void | set_tmpdir (const char *path) |
static void | set_treasures (const char *path) |
static void | set_uniquedir (const char *path) |
static void | showscores (void) |
static void | showscoresparm (const char *data) |
static void | unset_debug (void) |
static void | usage (void) |
Variables | |
static char | default_daemon_log [] = "logfile" |
materialtype_t * | materialt |
static struct Command_Line_Options | options [] |
Server initialisation, settings loading, command-line handling and such.
Definition in file init.c.
typedef void(* cmdlinefunc_args0)(void) |
typedef void(* cmdlinefunc_args2)(const char *arg1, const char *arg2) |
|
static |
Add an object to the racelist.
race_name | race name. |
op | what object to add to the race. |
Definition at line 1414 of file init.c.
References add_string(), find_racelink(), first_race, get_objectlink(), get_racelist(), ralnk::member, ralnk::name, ralnk::next, oblnk::next, ralnk::nrof, and oblnk::ob.
Referenced by init_races().
|
static |
|
static |
Dump compilation information, activated with the -o flag.
It writes out information on how Imakefile and config.h was configured at compile time.
Definition at line 1091 of file init.c.
References Settings::datadir, llevError, Settings::localdir, LOG(), Settings::logfilename, MAP_MAXTIMEOUT, MAX_BUF, MAX_OBJECTS, MAX_TIME, PERM_FILE, Settings::playerdir, SAVE_MODE, settings, SHUTDOWN_FILE, strerror_local(), Settings::tmpdir, and Settings::uniquedir.
|
static |
Dumps all race information to stderr.
Definition at line 1373 of file init.c.
References obj::arch, first_race, obj::level, ralnk::member, ralnk::name, archt::name, ralnk::next, oblnk::next, and oblnk::ob.
Referenced by init_beforeplay().
|
static |
General signal handling. Will exit() in any case.
make_core | if set abort() instead of exit() to generate a core dump. |
Definition at line 1258 of file init.c.
References clean_tmp_files(), emergency_save(), and init_done.
Referenced by rec_sigbus(), rec_sigint(), rec_sigpipe(), rec_sigquit(), rec_sigsegv(), and rec_sigterm().
racelink* find_racelink | ( | const char * | name | ) |
Find the race information for the specified name.
name | race to search for. |
Definition at line 1468 of file init.c.
References first_race, ralnk::name, and ralnk::next.
Referenced by add_to_racelist(), and choose_cult_monster().
|
static |
Frees all memory allocated to materials.
Definition at line 481 of file init.c.
References _materialtype::next.
Referenced by free_server().
|
static |
Frees all race-related information.
Definition at line 1388 of file init.c.
References first_race, free_string(), llevDebug, LOG(), ralnk::member, ralnk::name, ralnk::next, and oblnk::next.
Referenced by free_server().
void free_server | ( | void | ) |
Frees all memory allocated around here:
Definition at line 955 of file init.c.
References free_materials(), and free_races().
Referenced by cleanup().
|
static |
Creates an empty materialtype_t structure.
Definition at line 355 of file init.c.
References _materialtype::ac, _materialtype::chance, _materialtype::damage, _materialtype::description, _materialtype::difficulty, fatal(), _materialtype::magic, _materialtype::mod, _materialtype::name, _materialtype::next, NROFATTACKS, OUT_OF_MEMORY, _materialtype::save, _materialtype::sp, _materialtype::value, _materialtype::wc, and _materialtype::weight.
Referenced by load_materials().
|
static |
Create a new racelink structure.
Definition at line 1446 of file init.c.
References fatal(), get_objectlink(), ralnk::member, ralnk::name, ralnk::next, ralnk::nrof, and OUT_OF_MEMORY.
Referenced by add_to_racelist().
void init | ( | int | argc, |
char ** | argv | ||
) |
This is the main server initialisation function.
Called only once, when starting the program.
Definition at line 905 of file init.c.
References become_daemon(), cftimer_init(), Settings::daemonmode, Settings::dm_mail, FULL_VERSION, init_beforeplay(), init_commands(), init_done, init_library(), init_ob_methods(), init_server(), init_signals(), init_skills(), init_startup(), load_materials(), load_settings(), logfile, metaserver2_init(), metaserver_init(), parse_args(), read_map_log(), reset_sleep(), and settings.
Referenced by main(), and server_main().
|
static |
Definition at line 1006 of file init.c.
References check_spells(), cleanup(), dump_abilities(), dump_alchemy(), dump_alchemy_costs(), dump_artifacts(), dump_gods(), dump_monster_treasure(), dump_races(), dump_spells(), Settings::dumparg, Settings::dumpvalues, init_archetype_pointers(), init_archetypes(), init_artifacts(), init_formulae(), init_gods(), init_races(), init_readable(), init_regions(), print_monsters(), and settings.
Referenced by init().
|
static |
Reads the races file in the lib/ directory, then overwrites old 'race' entries. This routine allow us to quickly re-configure the 'alignment' of monsters, objects. Useful for putting together lists of creatures, etc that belong to gods.
Definition at line 1300 of file init.c.
References add_string(), add_to_racelist(), archt::clone, Settings::datadir, find_archetype(), first_race, FLAG_MONSTER, free_string(), init_done, llevDebug, llevError, LOG(), MAX_BUF, mon, archt::name, QUERY_FLAG, obj::race, settings, snprintf(), and strerror_local().
Referenced by init_beforeplay().
|
static |
Setup our signal handlers.
Definition at line 1271 of file init.c.
References llevInfo, LOG(), rec_sigbus(), rec_sighup(), rec_sigint(), rec_sigpipe(), rec_sigquit(), rec_sigsegv(), and rec_sigterm().
Referenced by init().
|
static |
Checks if starting the server is allowed.
Definition at line 1064 of file init.c.
References close_and_delete(), Settings::confdir, forbid_play(), llevError, LOG(), MAX_BUF, open_and_uncompress(), settings, SHUTDOWN_FILE, and snprintf().
Referenced by init().
|
static |
Loads the materials.
Definition at line 385 of file init.c.
References _materialtype::ac, add_string(), _materialtype::chance, _materialtype::damage, Settings::datadir, _materialtype::description, _materialtype::difficulty, get_empty_mat(), llevDebug, llevError, LOG(), _materialtype::magic, _materialtype::material, MAX_BUF, _materialtype::mod, _materialtype::name, _materialtype::next, NROFATTACKS, _materialtype::save, settings, snprintf(), _materialtype::sp, _materialtype::value, _materialtype::wc, and _materialtype::weight.
Referenced by init().
|
static |
This loads the settings file. There could be debate whether this should be here or in the common directory - but since only the server needs this information, having it here probably makes more sense.
Definition at line 497 of file init.c.
References Settings::allow_broken_converters, Settings::allow_denied_spells_writing, Settings::armor_max_enchant, Settings::armor_speed_improvement, Settings::armor_speed_linear, Settings::armor_weight_linear, Settings::armor_weight_reduction, Settings::balanced_stat_loss, Settings::casting_time, close_and_delete(), Settings::confdir, Settings::create_home_portals, Settings::death_penalty_level, Settings::death_penalty_ratio, Settings::dm_mail, Settings::explore_mode, FALSE, Settings::fastclock, Settings::item_power_factor, llevError, LOG(), Settings::log_timestamp, Settings::log_timestamp_format, MAX_BUF, Settings::meta_comment, Settings::meta_host, Settings::meta_on, Settings::meta_port, Settings::meta_server, Settings::motd, Settings::no_player_stealing, Settings::not_permadeth, open_and_uncompress(), Settings::permanent_exp_ratio, Settings::personalized_blessings, Settings::pk_luck_penalty, Settings::pk_max_experience, Settings::pk_max_experience_percent, Settings::real_wiz, Settings::recycle_tmp_maps, Settings::resurrection, Settings::search_items, set_csport(), Settings::set_friendly_fire, Settings::set_title, settings, Settings::simple_exp, snprintf(), Settings::spell_encumbrance, Settings::spell_failure_effects, Settings::spellpoint_level_depend, Settings::stat_loss_on_death, strcasecmp(), strdup_local(), TRUE, Settings::who_format, Settings::who_wiz_format, Settings::worldmapstartx, Settings::worldmapstarty, Settings::worldmaptilesizex, Settings::worldmaptilesizey, Settings::worldmaptilesx, and Settings::worldmaptilesy.
Referenced by init().
|
static |
Parse command line arguments.
Note since this may be called before the library has been set up, we don't use any of crossfires built in logging functions.
argc | length of argv. |
argv | arguments. |
pass | initialization pass arguments to use. |
Definition at line 304 of file init.c.
References Command_Line_Options::cmd_option, Command_Line_Options::func, Command_Line_Options::num_args, options, and usage().
Referenced by init().
|
static |
SIGBUS handler.
i | unused. |
Definition at line 1234 of file init.c.
References fatal_signal(), llevError, and LOG().
Referenced by init_signals().
|
static |
SIGHUP handler. SIGHUP handlers on daemons typically make them reread the config files and reinitialize itself. This behaviour is better left for an explicit shutdown and restart with Crossfire, as there is just too much persistent runtime state. However, another function of SIGHUP handlers is to reopen the log file for logrotate's benefit. We can do that here.
i | unused. |
Definition at line 1185 of file init.c.
References logfile, and reopen_logfile.
Referenced by init_signals().
|
static |
SIGINT handler.
i | unused. |
Definition at line 1168 of file init.c.
References fatal_signal(), llevInfo, and LOG().
Referenced by init_signals().
|
static |
SIGPIPE handler.
Keep running if we receive a sigpipe. Crossfire should really be able to handle this signal (at least at some point in the future if not right now). By causing a dump right when it is received, it is not doing much good. However, if it core dumps later on, at least it can be looked at later on, and maybe fix the problem that caused it to dump core. There is no reason that SIGPIPES should be fatal
i | unused. |
Definition at line 1217 of file init.c.
References fatal_signal(), llevError, llevInfo, and LOG().
Referenced by init_signals().
|
static |
SIGQUIT handler.
i | unused. |
Definition at line 1199 of file init.c.
References fatal_signal(), llevInfo, and LOG().
Referenced by init_signals().
|
static |
SIGSERV handler.
i | unused. |
Definition at line 1158 of file init.c.
References fatal_signal(), llevError, and LOG().
Referenced by init_signals().
|
static |
SIGTERM handler.
i | unused. |
Definition at line 1247 of file init.c.
References fatal_signal(), llevInfo, and LOG().
Referenced by init_signals().
|
static |
Definition at line 149 of file init.c.
References Settings::archetypes, and settings.
|
static |
Definition at line 137 of file init.c.
References Settings::confdir, and settings.
|
static |
Change the server's port. Will exit() if invalid value.
val | port to use. Must be a valid one, between 1 and 32765 inclusive. |
Definition at line 192 of file init.c.
References Settings::csport, llevError, LOG(), and settings.
Referenced by load_settings().
|
static |
Definition at line 126 of file init.c.
References Settings::daemonmode, default_daemon_log, Settings::logfilename, and settings.
|
static |
Definition at line 133 of file init.c.
References Settings::datadir, and settings.
|
static |
Definition at line 73 of file init.c.
References Settings::debug, llevDebug, and settings.
|
static |
Definition at line 85 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 89 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 93 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 97 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 101 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 105 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 109 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 113 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 117 of file init.c.
References Settings::dumpvalues, and settings.
|
static |
Definition at line 121 of file init.c.
References Settings::dumparg, Settings::dumpvalues, and settings.
|
static |
Definition at line 141 of file init.c.
References Settings::localdir, and settings.
|
static |
Definition at line 59 of file init.c.
References Settings::logfilename, and settings.
|
static |
Definition at line 145 of file init.c.
References Settings::mapdir, and settings.
|
static |
Definition at line 81 of file init.c.
References Settings::debug, llevMonster, and settings.
|
static |
Definition at line 169 of file init.c.
References Settings::playerdir, and settings.
|
static |
Definition at line 153 of file init.c.
References Settings::regions, and settings.
|
static |
Definition at line 165 of file init.c.
References settings, and Settings::templatedir.
|
static |
Definition at line 173 of file init.c.
References settings, and Settings::tmpdir.
|
static |
Definition at line 157 of file init.c.
References settings, and Settings::treasures.
|
static |
Definition at line 161 of file init.c.
References settings, and Settings::uniquedir.
|
static |
Definition at line 68 of file init.c.
References display_high_score().
|
static |
Definition at line 181 of file init.c.
References display_high_score().
|
static |
Definition at line 77 of file init.c.
References Settings::debug, llevInfo, and settings.
|
static |
Definition at line 960 of file init.c.
References logfile.
Referenced by parse_args().
|
static |
materialtype_t* materialt |
|
static |
Actual valid command line options. The way this system works is pretty simple - parse_args takes the options passed to the program and a pass number. If an option matches both in name and in pass (and we have enough options), we call the associated function. This makes writing a multi pass system very easy, and it is very easy to add in new options.
Definition at line 234 of file init.c.
Referenced by parse_args().