 |
Crossfire Server, Trunk
1.75.0
|
Go to the documentation of this file.
38 static void help(
void);
60 { NULL, NULL,
false, NULL, NULL }
68 for (
int module = 0;
modules[module].
name != NULL; module++) {
84 for (
int module = 0;
modules[module].
name != NULL; module++) {
98 for (
int module = 0;
modules[module].
name != NULL; module++) {
280 int port = atoi(val);
281 if (port <= 0 || port > 65535) {
282 LOG(
llevError,
"%d is an invalid csport number, must be between 1 and 65535.\n", port);
304 for (
int module = 0;
modules[module].
name; module++) {
462 while (on_arg < argc) {
491 fprintf(stderr,
"Unknown option: %s\n", argv[on_arg]);
492 fprintf(stderr,
"Type '%s -h' for usage.\n", argv[0]);
531 char *
buf, *cp, *next;
542 if (!strncmp(cp,
"name", 4)) {
547 }
else if (!strncmp(cp,
"description", 11)) {
549 }
else if (sscanf(cp,
"material %d", &value)) {
551 }
else if (!strncmp(cp,
"saves", 5)) {
552 cp = strchr(cp,
' ')+1;
558 if ((next = strchr(cp,
',')) != NULL)
560 sscanf(cp,
"%d", &value);
561 mt->
save[i] = (int8_t)value;
564 }
else if (!strncmp(cp,
"mods", 4)) {
565 cp = strchr(cp,
' ')+1;
571 if ((next = strchr(cp,
',')) != NULL)
573 sscanf(cp,
"%d", &value);
574 mt->
mod[i] = (int8_t)value;
610 if ((fp = fopen(
buf,
"r")) == NULL) {
618 if ((cp = strrchr(
buf,
'\n')) != NULL)
628 if ((cp = strchr(
buf,
' ')) != NULL) {
643 LOG(
llevError,
"load_settings: Unknown value for metaserver_notification: %s\n", cp);
649 LOG(
llevError,
"load_settings: metaserver_server must have a value.\n");
655 LOG(
llevError,
"load_settings: motd must have a value.\n");
660 LOG(
llevError,
"load_settings: metaserver_host must have a value.\n");
666 if (port < 1 || port > 65535)
667 LOG(
llevError,
"load_settings: metaserver_port must be between 1 and 65535, %d is invalid\n", port);
676 LOG(
llevError,
"load_settings: worldmapstartx must be at least 0, %d is invalid\n", size);
683 LOG(
llevError,
"load_settings: worldmapstarty must be at least 0, %d is invalid\n", size);
690 LOG(
llevError,
"load_settings: worldmaptilesx must be greater than 1, %d is invalid\n", size);
697 LOG(
llevError,
"load_settings: worldmaptilesy must be greater than 1, %d is invalid\n", size);
704 LOG(
llevError,
"load_settings: worldmaptilesizex must be greater than 1, %d is invalid\n", size);
711 LOG(
llevError,
"load_settings: worldmaptilesizey must be greater than 1, %d is invalid\n", size);
718 LOG(
llevError,
"load_settings: fastclock must be at least 0, %d is invalid\n", lev);
727 LOG(
llevError,
"load_settings: Unknown value for not_permadeth: %s\n", cp);
735 LOG(
llevError,
"load_settings: Unknown value for resurrection: %s\n", cp);
743 LOG(
llevError,
"load_settings: Unknown value for set_title: %s\n", cp);
751 LOG(
llevError,
"load_settings: Unknown value for search_items: %s\n", cp);
759 LOG(
llevError,
"load_settings: Unknown value for spell_encumbrance: %s\n", cp);
767 LOG(
llevError,
"load_settings: Unknown value for spell_failure_effects: %s\n", cp);
775 LOG(
llevError,
"load_settings: Unknown value for casting_time: %s\n", cp);
783 LOG(
llevError,
"load_settings: Unknown value for real_wiz: %s\n", cp);
791 LOG(
llevError,
"load_settings: Unknown value for recycle_tmp_maps: %s\n", cp);
801 LOG(
llevError,
"load_settings: Unknown value for always_show_hp: %s\n", cp);
818 LOG(
llevError,
"load_settings: Unknown value for spellpoint_level_depend: %s\n", cp);
826 LOG(
llevError,
"load_settings: Unknown value for stat_loss_on_death: %s\n", cp);
829 LOG(
llevError,
"use_permanent_experience is deprecated, usepermenent_experience_percentage instead\n");
830 }
else if (!
strcasecmp(
buf,
"permanent_experience_percentage")) {
832 if (val < 0 || val > 100)
833 LOG(
llevError,
"load_settings: permenent_experience_percentage must be between 0 and 100, %d is invalid\n", val);
838 if (val < 0 || val > 100)
839 LOG(
llevError,
"load_settings: death_penalty_percentage must be between 0 and 100, %d is invalid\n", val);
844 if (val < 0 || val > 255)
845 LOG(
llevError,
"load_settings: death_penalty_levels can not be negative, %d is invalid\n", val);
854 LOG(
llevError,
"load_settings: Unknown value for balanced_stat_loss: %s\n", cp);
862 LOG(
llevError,
"load_settings: Unknown value for simple_exp: %s\n", cp);
865 float tmp = atof(cp);
867 LOG(
llevError,
"load_settings: item_power_factor must be a positive number (%f < 0)\n", tmp);
871 int16_t val = atoi(cp);
873 if (val < -100 || val > 100)
874 LOG(
llevError,
"load_settings: pk_luck_penalty must be between -100 and 100, %d is invalid\n", val);
880 if (val < 1 || val > 100)
881 LOG(
llevError,
"load_settings: set_friendly_fire must be between 1 an 100, %d is invalid\n", val);
885 int max_e = atoi(cp);
887 LOG(
llevError,
"load_settings: armor_max_enchant is %d\n", max_e);
893 LOG(
llevError,
"load_settings: armor_weight_reduction is %d\n", wr);
902 LOG(
llevError,
"load_settings: unknown value for armor_weight_linear: %s\n", cp);
907 LOG(
llevError,
"load_settings: armor_speed_improvement is %d\n", wr);
916 LOG(
llevError,
"load_settings: unknown value for armor_speed_linear: %s\n", cp);
924 LOG(
llevError,
"load_settings: unknown value for no_player_stealing: %s\n", cp);
928 #ifdef TRY_BROKEN_TOWN_PORTALS
931 LOG(
llevError,
"load_settings: create_home_portals is currently broken. It results in town portals that prematurely reset when the apartment is swapped.\n");
936 LOG(
llevError,
"load_settings: unknown value for create_home_portals: %s\n", cp);
944 LOG(
llevError,
"load_settings: unknown value for personalized_blessings: %s\n", cp);
947 int64_t pkme = atoll(cp);
952 int pkmep = atoi(cp);
954 LOG(
llevError,
"load_settings: pk_max_experience_percent should be positive or zero (was \"%s\")\n", cp);
957 }
else if (!
strcasecmp(
buf,
"allow_denied_spells_writing")) {
963 LOG(
llevError,
"load_settings: unknown value for allow_denied_spells_writing: %s\n", cp);
971 LOG(
llevError,
"load_settings: unknown value for allow_broken_converters: %s\n", cp);
979 LOG(
llevError,
"load_settings: unknown value for log_timestamp: %s\n", cp);
988 LOG(
llevError,
"load_settings: starting_stat_min (%d) need to be within %d-%d (%d)\n",
996 LOG(
llevError,
"load_settings: starting_stat_max (%d) need to be within %d-%d (%d)\n",
1005 LOG(
llevError,
"load_settings: starting_stat_points (%d) need to be within %d-%d\n",
1017 if (val < NUM_STATS * 3 || val >
NUM_STATS * 18)
1018 LOG(
llevError,
"load_settings: roll_stat_points need to be within %d-%d\n",
1028 LOG(
llevError,
"load_settings: unknown value for special_break_map: %s\n", cp);
1030 }
else if (!
strcasecmp(
buf,
"ignore_plugin_compatibility")) {
1036 LOG(
llevError,
"load_settings: unknown value for ignore_plugin_compatibility: %s\n", cp);
1044 LOG(
llevError,
"load_settings: unknown value for account_block_create: %s\n", cp);
1051 if (val != 0 && val != 1) {
1052 LOG(
llevError,
"load_settings: crypt_mode must be 0 or 1\n");
1060 LOG(
llevError,
"load_settings: min_name (%d) need to be within %d-%d\n",
1150 printf(
"Usage: crossfire-server [options]\n\n");
1152 printf(
"Options:\n");
1153 printf(
" -conf Set the directory to find configuration files.\n");
1154 printf(
" -d Turn on extra debugging messages.\n");
1155 printf(
" -data Set the data (share/) directory (archetypes, treasures, etc).\n");
1156 printf(
" -disable-module\n"
1157 " Disable specified module, by its name\n"
1158 " Can be specified multiple times. 'All' disables all modules.\n");
1159 printf(
" -enable-module\n"
1160 " Enable specified module, by its name\n"
1161 " Can be specified multiple times. 'All' enables all modules.\n");
1162 printf(
" -disable-plugin\n"
1163 " Disables specified plugin. Use the name without the extension.\n"
1164 " Can be specified multiple times. 'All' disables all plugins.\n");
1165 printf(
" -dump-anims Dump animations.\n");
1166 printf(
" -h Print this help message.\n");
1167 printf(
" -ignore-assets-errors\n");
1168 printf(
" Allow going on even if there are errors in assets.\n");
1169 printf(
" Warning: this may lead to strange behaviour.\n");
1170 printf(
" -list-modules\n"
1171 " List built-in modules and exit.\n");
1172 printf(
" -local Set the local data (var/) directory.\n");
1173 printf(
" -log <file> Write logging information to the given file.\n");
1174 printf(
" -m List suggested experience for all monsters.\n");
1175 printf(
" -m2 Dump monster abilities.\n");
1176 printf(
" -m3 Dump artifact information.\n");
1177 printf(
" -m4 Dump spell information.\n");
1178 printf(
" -m5 Dump skill information.\n");
1179 printf(
" -m6 Dump race information.\n");
1180 printf(
" -m7 Dump alchemy information.\n");
1181 printf(
" -m8 Dump gods information.\n");
1182 printf(
" -m9 Dump more alchemy information (formula checking).\n");
1183 printf(
" -maps Set the map directory.\n");
1184 printf(
" -mexp Dump the experience table.\n");
1185 printf(
" -mon Turn on monster debugging.\n");
1186 printf(
" -mq Dump the quest list.\n");
1187 printf(
" -mt <name> Dump a list of treasures for a monster.\n");
1188 printf(
" -n Turn off debugging messages if on by default.\n");
1189 printf(
" -p <port> Specifies the port to listen on for incoming connections.\n");
1190 printf(
" -pack-assets <type> <filename>\n");
1191 printf(
" Packs specified assets type to the specified filename.\n");
1192 printf(
" Valid assets type are: archs, treasures, faces, messages, facesets, artifacts, formulae, images, quests.\n");
1193 printf(
" The file format will be tar ('images') or text (everything else).\n");
1194 printf(
" It is possible to combine multiple assets by using '+', for instance 'faces+messages+artifacts'.\n");
1195 printf(
" In this case the file will be in tar format.\n");
1196 printf(
" -playerdir Set the player files directory.\n");
1197 printf(
" -regions Set the region file.\n");
1198 printf(
" -templatedir Set the template map directory.\n");
1199 printf(
" -tmpdir Set the directory for temporary files (mostly maps.)\n");
1200 printf(
" -uniquedir Set the unique items/maps directory.\n");
1201 printf(
" -v Print version information.\n");
1274 #ifdef SHUTDOWN_FILE
1279 if ((fp = fopen(
buf,
"r")) != NULL) {
1297 (void) signum_unused;
1327 struct sigaction sa;
1329 sa.sa_sigaction = NULL;
1330 sigemptyset(&sa.sa_mask);
1333 sigaction(SIGHUP, &sa, NULL);
1335 signal(SIGPIPE, SIG_IGN);
uint8_t casting_time
It takes awhile to cast a spell.
uint8_t special_break_map
If set, then submaps in random maps can break the walls.
char meta_comment[MAX_BUF]
Comment we send to the metaserver.
One command line option definition.
const char * mapdir
Where the map files are.
char meta_server[MAX_BUF]
Hostname/ip addr of the metaserver.
struct Settings settings
Global settings.
uint8_t simple_exp
If true, use the simple experience system.
void citylife_init(Settings *settings, ServerSettings *serverSettings)
static struct Command_Line_Options options[]
Actual valid command line options.
uint8_t recycle_tmp_maps
Re-use tmp maps.
void init(int argc, char **argv)
This is the main server initialization function.
@ llevError
Error, serious thing.
static void init_beforeplay(void)
Called before the server starts listening to connections, processes various dump-related options.
const char * regions
Name of the regions file - libdir is prepended.
void LOG(LogLevel logLevel, const char *format,...)
Logs a message to stderr, or to file.
int allow_broken_converters
If set, converters will work even if price of generated item is higher than the price of converted it...
char * log_timestamp_format
Format for timestap, if log_timestamp is set.
uint8_t armor_speed_linear
If 1, speed improvement is linear, else exponantiel.
int8_t mod[NROFATTACKS]
Modification to resistances.
uint8_t resurrection
Ressurection possible w/ permadeth on.
ServerSettings serverSettings
uint8_t set_title
Players can set thier title.
void dump_alchemy_costs(void)
Dumps to output all costs of recipes.
uint8_t ignore_plugin_compatibility
If set, don't check plugin version.
uint8_t not_permadeth
If true, death is non-permament.
uint8_t permanent_exp_ratio
How much exp should be 'permenant' and unable to be lost.
uint8_t crypt_mode
0 for legacy behavior, 1 for always Traditional
static void set_datadir(const char *path)
Command line option: set data path.
uint8_t dumpvalues
Set to dump various values/tables.
const char * datadir
Read only data files.
static void load_materials(BufferReader *reader, const char *filename)
Loads the materials.
static void set_mapdir(const char *path)
Command line option: set map path.
void cleanup(void)
Clean up everything and exit.
static void set_dumpmon7(void)
Command line option: dump alchemy.
void dump_faces(void)
Dump all faces to stderr, for debugging purposes.
uint32_t worldmaptilesy
Number of tiles high the worldmap is.
#define SHUTDOWN_FILE
If you want to take the game down while installing new versions, or for other reasons,...
static void rec_sighup(int i)
SIGHUP handler.
uint8_t min_name
Minimum characters for an account or player name.
uint32_t worldmapstartx
Starting x tile for the worldmap.
static void list_modules()
List all modules, then exit.
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
static materialtype_t * get_empty_mat(void)
Creates an empty materialtype_t structure.
static void set_dumpmont(const char *name)
Command line option: dump monster treasures.
void init_ob_methods(void)
Initializes the ob_method system.
static void set_dumpmon6(void)
Command line option: dump races.
uint8_t starting_stat_min
Minimum value of a starting stat.
void read_map_log(void)
Reads temporary maps information from disk.
uint8_t roll_stat_points
How many stat points legacy (rolled) chars start with.
int16_t pk_luck_penalty
Amount by which player luck is reduced if they PK.
#define FREE_AND_COPY_IF(sv, nv)
static void set_mondebug(void)
Command line option: monster debug flag.
@ llevMonster
Many many details.
static void server_dump_animations(void)
Dump all animations, then exit.
static void set_playerdir(const char *path)
Command line option: set player path.
void dump_gods(void)
Prints all gods to stderr.
uint16_t csport
Port for new client/server.
std::vector< materialtype_t * > materials
int ignore_assets_errors
If set then go on running even if there are errors in assets.
void load_races(BufferReader *reader, const char *filename)
Reads the races file in the lib/ directory, then overwrites old 'race' entries.
void init_server(void)
This sets up the listening socket.
static void set_dumpmon2(void)
Command line option: dump abilities.
uint8_t num_args
Number or args it takes.
char meta_host[MAX_BUF]
Hostname of this host.
static void set_dumpmon4(void)
Command line option: dump spells.
int forbid_play(void)
Checks if server should be started.
Plugin animator file specs[Config] name
uint32_t worldmaptilesx
Number of tiles wide the worldmap is.
void dump_races(void)
Dumps all race information to stderr.
int64_t pk_max_experience
Maximum experience one can get for PKing.
const char * cmd_option
How it is called on the command line.
static void server_dump_faces(void)
Dump all faces, then exit.
void init_signals(void)
Setup our signal handlers.
static void parse_args(int argc, char *argv[], int pass)
Parse command line arguments.
uint8_t spell_encumbrance
Encumbrance effects spells.
void init_gods(void)
This takes a look at all of the archetypes to find the objects which correspond to the GODS (type GOD...
std::vector< char * > disabled_plugins
List of disabled plugins, 'All' means all.
int material
What basic type(s) it is linked to.
void dump_experience(void)
Dump the experience table, then calls exit() - useful in terms of debugging to make sure the format o...
uint16_t meta_port
Port number to use for updates.
static module_information modules[]
All built modules.
uint8_t balanced_stat_loss
If true, Death stat depletion based on level etc.
LogLevel debug
Default debugging level.
static void load_settings(void)
This loads the settings file.
void init_archetype_pointers(void)
Initialize global archtype pointers:
int pk_max_experience_percent
Percentage of experience of victim the killer gets.
sstring add_refcount(sstring str)
This will increase the refcount of the string str.
uint8_t death_penalty_ratio
Hhow much exp should be lost at death.
static void set_dumpmon3(void)
Command line option: dump artifacts.
void random_house_generator_init(Settings *settings, ServerSettings *serverSettings)
Module initialisation.
void assets_add_collector_hook(const char *name, collectorHook hook)
void cftimer_init(void)
Initialize timers.
void random_house_generator_close()
Close the module.
void free_races(void)
Frees all race-related information.
uint16_t set_friendly_fire
Percent of damage done by peaceful player vs player damage.
uint8_t account_block_create
const char * motd
Name of the motd file.
const char * logfilename
Logfile to use.
uint32_t worldmapstarty
Starting y tile for the worldmap.
void cfcitybell_init(Settings *settings, ServerSettings *serverSettings)
Citybells module initialisation.
sstring add_string(const char *str)
This will add 'str' to the hash table.
void free_quest(void)
Free all quest status structures.
void init_readable(void)
Initialize linked lists utilized by message functions in tailor_readable_ob()
static void set_enable_module(const char *name)
Enable a module.
const char * name
Name of the material.
static void set_dumpmon1(void)
Command line option: dump monsters.
int metaserver2_init(void)
This initializes the metaserver2 logic - it reads the metaserver2 file, storing the values away.
spell prayer lvl t sp speed range duration short description
int armor_weight_reduction
Weight reduction per enchantment.
uint8_t stat_loss_on_death
If true, chars lose a random stat when they die.
static void signal_shutdown(int signum_unused)
Signal handler that begins a normal server shutdown.
float item_power_factor
See note in setings file.
static void set_logfile(char *val)
Command line option: set logfile name.
void service_unregister()
const char * dumparg
Additional argument for some dump functions.
void assets_finish_archetypes_for_play()
void dump_spells(void)
Dumps all the spells - now also dumps skill associated with the spell.
const char * confdir
Configuration files.
FILE * logfile
Used by server/daemon.c.
static void set_tmpdir(const char *path)
Command line option: set temporary file path.
void dump_abilities(void)
Dump to standard out the abilities of all monsters.
static void set_uniquedir(const char *path)
Command line option: set unique path.
int8_t save[NROFATTACKS]
Save chances for the attacks.
uint8_t death_penalty_level
How many levels worth of exp may be lost on one death.
void fatal(enum fatal_error err)
fatal() is meant to be called whenever a fatal signal is intercepted.
void accounts_load(void)
This loads all the account entries into memory.
static void set_dumpmon9(void)
Command line option: dump alchemy costs.
#define MAX_BUF
Used for all kinds of things.
static void set_confdir(const char *path)
Command line option: set configuration path.
void(* cmdlinefunc_args2)(const char *arg1, const char *arg2)
static void set_dumpmon8(void)
Command line option: dump gods.
const char * playerdir
Where the player files are.
void init_skills(void)
This just sets up the skill_names table above.
uint8_t spell_failure_effects
Nasty backlash to spell failures.
uint8_t starting_stat_points
How many stat points character starts with.
unsigned int meta_on
True if we should send updates.
int allow_denied_spells_writing
If set, players can write spells they can't cast.
void hiscore_init(void)
Initializes the module.
static void set_regions(const char *path)
Command line option: set regions file name.
static int should_exit
If set after command line argument parsing, then the server will exit.
void init_library(void)
It is vital that init_library() is called by any functions using this library.
char who_wiz_format[MAX_BUF]
The format that the who command should use when called by a dm.
void commands_init(void)
Init standard commands.
uint8_t spellpoint_level_depend
Spell costs go up with level.
void dump_quests(void)
Dump all of the quests, then calls exit() - useful in terms of debugging to make sure that quests are...
uint8_t fastclock
If true, clock goes warp 9.
void(* cmdlinefunc_args1)(const char *arg1)
static void free_materials(void)
Frees all memory allocated to materials.
uint8_t personalized_blessings
If 1, blessed weapons get an owner and a willpower value.
void print_monsters(void)
As dump_abilities(), but with an alternative way of output.
static void unset_debug(void)
Command line option: unset debug flag.
void dump_alchemy(void)
Dumps alchemy recipes to output.
static void help(void)
Display the command line options and exits.
uint8_t max_stat
Maximum stat value - 255 should be sufficient.
void(* cmdlinefunc_args0)(void)
Typedefs used when calling option handlers.
const char * description
Description, unused.
static void set_debug(void)
Command line option: debug flag.
void close_modules()
Clean up all modules which are not disabled.
void reset_sleep(void)
Initialise all variables used in the timing routines.
int armor_max_enchant
Maximum number of times an armor can be enchanted.
static void set_ignore_assets_errors()
Command line option: ignore assets errors.
void dump_monster_treasure(const char *name)
For debugging purposes.
void dump_animations(void)
Dump all animations to stderr, for debugging purposes.
void add_server_collect_hooks()
uint8_t armor_weight_linear
If 1, weight reduction is linear, else exponantiel.
static void set_dumpmon5(void)
Command line option: ?
int strcasecmp(const char *s1, const char *s2)
uint32_t worldmaptilesizex
Number of squares wide in a wm tile.
void init_modules()
Init all modules which are not disabled.
static void call_version(void)
Command line option: show version.
static void set_csport(const char *val)
Change the server's port.
uint8_t real_wiz
Use mud-like wizards.
static void init_startup(void)
Checks if starting the server is allowed.
const char * templatedir
Directory for the template map.
static void set_disable_plugin(const char *name)
Disable a plugin.
uint32_t worldmaptilesizey
Number of squares high in a wm tile.
static void set_localdir(const char *path)
Command line option: set local path.
void assets_pack(const char *what, const char *filename)
Pack the specified assets in a file.
static void set_disable_module(const char *name)
Disable a module.
void free_server(void)
Frees all memory allocated around here:
uint8_t no_player_stealing
If 1, can not steal from other players.
char * account_trusted_host
Block account creation for untrusted hosts.
uint8_t search_items
Search_items command.
const char * tmpdir
Directory to use for temporary files.
void dump_artifacts(void)
For debugging purposes.
uint8_t always_show_hp
'probe' spell HP bars for all living things (0, 1, or 2)
static void set_templatedir(const char *path)
Command line option: set template path.
uint8_t create_home_portals
If 1, can create portals in unique maps (apartments)
static void server_dump_bonuses()
Dump all bonuses (from the stat_bonus file) then exit.
uint8_t pass
What pass this should be processed on.
int armor_speed_improvement
Speed improvement.
@ NUM_STATS
Number of statistics.
int log_timestamp
If set, log will comport a timestamp.
char who_format[MAX_BUF]
The format that the who command should use.
static void server_pack_assets(const char *assets, const char *filename)
void(* func)()
function to call when we match this.
volatile sig_atomic_t shutdown_flag
@ llevDebug
Only for debugging purposes.
static void do_module(const char *name, bool enabled)
Change the 'enabled' flag of a module.
uint8_t starting_stat_max
Maximum value of a starting stat.
const char * uniquedir
Directory for the unique items.
char * bufferreader_next_line(BufferReader *br)
Return the next line in the buffer, as separated by a newline.
const char * localdir
Read/write data files.