![]() |
Crossfire Server, Trunk
1.75.0
|
#include "global.h"
#include <stdlib.h>
#include <string.h>
#include "object.h"
#include "output_file.h"
#include "assets.h"
#include "AssetsManager.h"
Go to the source code of this file.
Functions | |
void | free_globals (void) |
Cleans all memory allocated for global variables. More... | |
void | init_attackmess (BufferReader *reader, const char *filename) |
Initializes the attack messages. More... | |
static void | init_clocks (void) |
Initializes the gametime and TOD counters Called by init_library(). More... | |
static void | init_defaults (void) |
Initialises global variables which can be changed by options. More... | |
static void | init_dynamic (void) |
Initializes first_map_path from the archetype collection, and check that some required archetype actually exist. More... | |
static void | init_emergency_mappath (void) |
This loads the emergency map information from a .emergency file in the map directory. More... | |
static void | init_environ (void) |
Initializes values from the environmental variables. More... | |
void | init_globals (void) |
Initialises all global variables. More... | |
void | init_library (void) |
It is vital that init_library() is called by any functions using this library. More... | |
void | write_todclock (void) |
Write out the current time to the file so time does not reset every time the server reboots. More... | |
Variables | |
std::vector< region * > | all_regions |
attackmess_t | attack_mess [NROFATTACKMESS][MAXATTACKMESS] |
Chaos_Attacks | ATTACKS [22] |
Some local definitions for shuffle_attack(). More... | |
const char *const | attacktype_desc [NROFATTACKS] |
Short description of names of the attacktypes. More... | |
sstring | blocks_prayer |
For update_position() mostly. More... | |
const char *const | change_resist_msg [NROFATTACKS] |
These are the descriptions of the resistances displayed when a player puts on/takes off an item. More... | |
archetype * | empty_archetype |
Nice to have fast access to it. More... | |
int | exiting |
True if the game is about to exit. More... | |
artifactlist * | first_artifactlist |
First artifact. More... | |
mapstruct * | first_map |
First map. More... | |
char | first_map_ext_path [MAX_BUF] |
Path used for per-race start maps. More... | |
char | first_map_path [MAX_BUF] |
The start-level. More... | |
player * | first_player |
First player. More... | |
FILE * | logfile |
Used by server/daemon.c. More... | |
std::vector< materialtype_t * > | materials |
long | nrofallowedstr |
Only used in malloc_info(). More... | |
long | nrofartifacts |
Only used in malloc_info(). More... | |
long | nroferrors |
If it exceeds MAX_ERRORS, call fatal() More... | |
long | ob_count |
const char *const | resist_color [NROFATTACKS] |
Colors to add to the resistances for media tags. More... | |
const char *const | resist_plus [NROFATTACKS] |
Attack types to show to the player. More... | |
const char *const | resist_save [NROFATTACKS] |
Attack types. More... | |
struct Settings | settings |
Global settings. More... | |
const char *const | spellpathnames [NRSPELLPATHS] |
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. More... | |
struct Statistics | statistics |
Merged spell statistics. More... | |
long | trying_emergency_save |
True when emergency_save() is reached. More... | |
const char * | undead_name |
Basic initialization for the common library.
Definition in file init.cpp.
void free_globals | ( | void | ) |
Cleans all memory allocated for global variables.
Will clear:
Definition at line 431 of file init.cpp.
References all_regions, assets_free(), attack_mess, blocks_prayer, clear_friendly_list(), Settings::emergency_mapname, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, free_experience(), region::jailmap, region::longname, MAXATTACKMESS, region::msg, region::name, NROFATTACKMESS, settings, and undead_name.
Referenced by cleanup().
void init_attackmess | ( | BufferReader * | reader, |
const char * | filename | ||
) |
Initializes the attack messages.
Called by init_library().
Memory will be cleared by free_globals().
Definition at line 563 of file init.cpp.
References attack_mess, buf, attackmess_t::buf1, attackmess_t::buf2, attackmess_t::buf3, bufferreader_next_line(), attackmess_t::level, level, llevDebug, LOG(), and strdup_local.
Referenced by assets_collect().
|
static |
Initializes the gametime and TOD counters Called by init_library().
Definition at line 527 of file init.cpp.
References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, settings, todtick, and write_todclock().
Referenced by init_library().
|
static |
Initialises global variables which can be changed by options.
Called by init_library().
Definition at line 464 of file init.cpp.
References nroferrors.
Referenced by init_globals().
|
static |
Initializes first_map_path from the archetype collection, and check that some required archetype actually exist.
Must be called after archetypes have been initialized.
Definition at line 477 of file init.cpp.
References archetype::clone, delete_map(), EXIT_PATH, fatal(), first_map_path, get_archetype_by_type_subtype(), llevError, LOG(), MAP, MAP_TYPE_DEFAULT, MAP_TYPE_LEGACY, ready_map_name(), SEE_LAST_ERROR, and strlcpy().
Referenced by init_library().
|
static |
This loads the emergency map information from a .emergency file in the map directory.
Doing this makes it easier to switch between map distributions (don't need to recompile. Note that there is no reason I see that this could not be re-loaded during play, but it seems like there should be little reason to do that.
Definition at line 271 of file init.cpp.
References Settings::datadir, Settings::emergency_mapname, EMERGENCY_MAPPATH, Settings::emergency_x, Settings::emergency_y, llevDebug, llevError, LOG(), Settings::mapdir, MAX_BUF, settings, and strdup_local.
Referenced by init_library().
|
static |
Initializes values from the environmental variables.
it needs to be called very early, since command line options should overwrite these if specified.
Definition at line 355 of file init.cpp.
References Settings::datadir, Settings::localdir, Settings::mapdir, Settings::playerdir, settings, Settings::templatedir, Settings::tmpdir, and Settings::uniquedir.
Referenced by init_library().
void init_globals | ( | void | ) |
Initialises all global variables.
Might use environment-variables as default for some of them.
Setups logfile, and such variables.
Definition at line 387 of file init.cpp.
References add_string(), blocks_prayer, exiting, first_artifactlist, first_map, first_map_ext_path, first_player, init_defaults(), llevError, LOG(), logfile, Settings::logfilename, nrofallowedstr, nrofartifacts, settings, statistics, trying_emergency_save, and undead_name.
Referenced by generate_map(), init_library(), and main().
void init_library | ( | void | ) |
It is vital that init_library() is called by any functions using this library.
If you want to lessen the size of the program using the library, you can replace the call to init_library() with init_globals(). Good idea to also call init_hash_table if you are doing any object loading.
Definition at line 315 of file init.cpp.
References assets_init(), attack_mess, attackmess_t::buf1, attackmess_t::buf2, attackmess_t::buf3, fatal(), getManager(), i18n_init(), Settings::ignore_assets_errors, init_block(), init_clocks(), init_dynamic(), init_emergency_mappath(), init_environ(), init_experience(), init_globals(), init_hash_table(), init_objects(), init_stats(), attackmess_t::level, level, llevError, load_assets(), LOG(), MAXATTACKMESS, SEE_LAST_ERROR, and settings.
Referenced by generate_map(), init(), and main().
void write_todclock | ( | void | ) |
Write out the current time to the file so time does not reset every time the server reboots.
Definition at line 510 of file init.cpp.
References Settings::localdir, MAX_BUF, of_close(), of_open(), settings, and todtick.
Referenced by clean_tmp_files(), init_clocks(), and tick_the_clock().
std::vector<region *> all_regions |
Definition at line 108 of file init.cpp.
Referenced by cfapi_system_get_region_vector(), cfcitybell_close(), command_whereabouts(), free_globals(), get_name_of_region_for_map(), get_region_by_name(), get_region_from_string(), init_regions(), and main().
attackmess_t attack_mess[NROFATTACKMESS][MAXATTACKMESS] |
Definition at line 78 of file init.cpp.
Referenced by free_globals(), get_attack_message_for_attack_type(), init_attackmess(), and init_library().
Chaos_Attacks ATTACKS[22] |
Some local definitions for shuffle_attack().
Definition at line 81 of file init.cpp.
Referenced by hit_player(), and shuffle_attack().
const char* const attacktype_desc[NROFATTACKS] |
Short description of names of the attacktypes.
Definition at line 40 of file init.cpp.
Referenced by command_resistances(), describe_god(), and print_monsters().
sstring blocks_prayer |
For update_position() mostly.
Definition at line 126 of file init.cpp.
Referenced by free_globals(), init_globals(), and update_position().
const char* const change_resist_msg[NROFATTACKS] |
These are the descriptions of the resistances displayed when a player puts on/takes off an item.
See change_abil() in living.c.
Definition at line 70 of file init.cpp.
Referenced by change_abil(), command_resistances(), describe_item(), dragon_eat_flesh(), dragon_level_gain(), perceive_self(), and potion_type_apply().
archetype* empty_archetype |
Nice to have fast access to it.
Definition at line 119 of file init.cpp.
Referenced by Archetypes::Archetypes(), create_singularity(), doWrite(), object_dump(), save_object_in_sb(), and ArtifactWriter::write().
int exiting |
True if the game is about to exit.
Definition at line 115 of file init.cpp.
Referenced by init_globals(), and LOG().
artifactlist* first_artifactlist |
First artifact.
Definition at line 109 of file init.cpp.
Referenced by AssetsManager::archetypeUpdated(), dump_artifacts(), find_artifactlist(), free_all_artifacts(), init_globals(), ArtifactLoader::load(), malloc_info(), and pack_artifacts().
mapstruct* first_map |
First map.
Definition at line 107 of file init.cpp.
Referenced by cfapi_map_get_map_property(), cfapi_system_get_map_vector(), check_active_maps(), clean_tmp_files(), dawn_to_dusk(), delete_map(), dump_all_maps(), flush_old_maps(), free_all_maps(), get_linked_map(), has_been_loaded(), init_globals(), key_confirm_quit(), load_style_map(), malloc_info(), map_can_reset(), map_info(), and write_map_log().
char first_map_ext_path[MAX_BUF] |
Path used for per-race start maps.
Definition at line 121 of file init.cpp.
Referenced by init_globals(), and key_change_class().
char first_map_path[MAX_BUF] |
The start-level.
Definition at line 120 of file init.cpp.
Referenced by check_login(), emergency_save(), get_player(), init_dynamic(), main(), and set_first_map().
player* first_player |
First player.
Definition at line 106 of file init.cpp.
Referenced by account_play_cmd(), cfapi_object_get_property(), cfapi_object_set_property(), cfapi_party_get_property(), cfapi_system_get_object_vector(), check_all_fds(), check_login(), command_abil(), command_addexp(), command_kick2(), command_recollect(), command_reset(), command_whereabouts(), count_players(), create_player_cmd(), do_server(), draw_ext_info(), emergency_save(), ext_info_map(), ext_info_map_except(), ext_info_map_except2(), find_player_options(), find_player_socket(), fix_luck(), fix_weight(), free_player(), get_nearest_criminal(), get_nearest_player(), get_other_player_from_name(), get_player(), init_globals(), is_legal_2ways_exit(), knowledge_process_incremental(), list_players(), make_sure_not_seen(), make_sure_seen(), malloc_info(), object_decrease_nrof(), object_increase_nrof(), party_remove(), party_send_message(), play_sound_map(), players_on_map(), process_players1(), process_players2(), remove_if_unused(), ring_bell(), save_and_kick_all_players(), send_changed_object(), share_exp(), swap_map(), update_all_los(), update_all_map_los(), update_players(), and verify_player().
FILE* logfile |
Used by server/daemon.c.
Definition at line 114 of file init.cpp.
Referenced by draw_ext_info(), draw_ext_info_format(), dump_alchemy_costs(), dump_artifacts(), dump_experience(), dump_monster_treasure(), dump_monster_treasure_rec(), ext_info_map(), fatal(), forbid_play(), init(), init_globals(), LOG(), output_quests(), and rec_sighup().
std::vector<materialtype_t *> materials |
Definition at line 128 of file init.cpp.
Referenced by free_materials(), load_materials(), name_to_material(), object_get_materialtype(), and set_materialname().
long nrofallowedstr |
Only used in malloc_info().
Definition at line 117 of file init.cpp.
Referenced by init_globals(), ArtifactLoader::load(), and malloc_info().
long nrofartifacts |
Only used in malloc_info().
Definition at line 116 of file init.cpp.
Referenced by init_globals(), ArtifactLoader::load(), and malloc_info().
long nroferrors |
If it exceeds MAX_ERRORS, call fatal()
Definition at line 112 of file init.cpp.
Referenced by init_defaults(), LOG(), and server_main().
long ob_count |
Definition at line 123 of file init.cpp.
Referenced by object_new().
const char* const resist_color[NROFATTACKS] |
Colors to add to the resistances for media tags.
Definition at line 61 of file init.cpp.
Referenced by describe_resistance().
const char* const resist_plus[NROFATTACKS] |
Attack types to show to the player.
Definition at line 49 of file init.cpp.
Referenced by describe_resistance(), and print_monsters().
const char* const resist_save[NROFATTACKS] |
Attack types.
Definition at line 31 of file init.cpp.
Referenced by get_ob_diff().
struct Settings settings |
Global settings.
Definition at line 139 of file init.cpp.
Referenced by account_block_create(), account_char_load_from_file(), account_char_save(), account_new_cmd(), accounts_load(), accounts_save(), add_me_cmd(), add_player_exp(), apply_check_item_power(), apply_check_personalized_blessings(), apply_death_exp_penalty(), apply_race_and_class(), assets_collect(), attack_ob_simple(), attempt_steal(), calc_perm_exp(), calc_skill_exp(), cast_create_town_portal(), cast_spell(), cfapi_system_directory(), change_abil(), check_exp_loss(), check_login(), check_pick(), check_probe(), check_race_and_class(), checkbanned(), checkdm(), clean_tmp_files(), command_abil(), command_addexp(), command_banish(), command_create(), command_debug(), command_help(), command_loadtest(), command_nowiz(), command_patch(), command_players(), command_purge_quest_definitions(), command_search_items(), command_settings(), command_title(), compute_price_variation_with_bargaining(), create_items_path(), create_overlay_pathname(), create_pathname(), create_player_cmd(), create_template_pathname(), crypt_string(), dead_player(), delete_character(), display_motd(), do_item_conversion(), do_symptoms(), do_throw(), dragon_eat_flesh(), dump_experience(), dump_stat_bonuses(), enter_player_maplevel(), enter_player_savebed(), exp_level(), fatal(), find_help_file_in(), find_maps(), find_spot_for_submap(), find_style(), fix_object(), fix_player(), forbid_play(), free_globals(), get_cha_bonus(), get_cleric_chance(), get_con_bonus(), get_dam_bonus(), get_dex_bonus(), get_fear_bonus(), get_grace_bonus(), get_learn_spell(), get_sp_bonus(), get_speed_bonus(), get_thaco_bonus(), get_turn_bonus(), get_weight_limit(), god_enchants_weapon(), help_topics(), hiscore_init(), hit_player(), i18n_init(), improve_armour(), improve_weapon(), init_beforeplay(), init_book_archive(), init_clocks(), init_emergency_mappath(), init_environ(), init_experience(), init_globals(), init_library(), init_modules(), init_server(), init_startup(), init_stats(), key_change_class(), key_confirm_quit(), kill_object(), kill_player(), kill_player_not_permadeath(), kill_player_permadeath(), knowledge_read_player_data(), knowledge_write_player_data(), level_exp(), list_players(), load_assets(), load_settings(), load_table(), LOG(), main(), map_path(), map_remove_unique_files(), metaserver2_init(), object_clear(), pay_for_item(), pick_up_object(), player_lvl_adj(), plugins_init_plugin(), process_events(), process_players1(), quest_read_player_data(), quest_write_player_data(), random_house_generator_init(), rangetostring(), read_map_log(), ready_map_name(), resurrect_player(), roll_stats(), save_map(), save_player(), scroll_failure(), scroll_type_apply(), send_exp_table(), send_file(), send_new_char_info(), send_news(), send_rules(), set_abs_magic(), set_confdir(), set_csport(), set_datadir(), set_debug(), set_dumpmon1(), set_dumpmon2(), set_dumpmon3(), set_dumpmon4(), set_dumpmon5(), set_dumpmon6(), set_dumpmon7(), set_dumpmon8(), set_dumpmon9(), set_dumpmont(), set_ignore_assets_errors(), set_localdir(), set_logfile(), set_mapdir(), set_mondebug(), set_playerdir(), set_regions(), set_templatedir(), set_tmpdir(), set_uniquedir(), show_skills(), SP_level_spellpoint_cost(), spell_failure(), spellbook_type_apply(), swap_map(), unset_debug(), verify_player(), while(), write_book_archive(), write_map_log(), write_scroll(), and write_todclock().
const char* const spellpathnames[NRSPELLPATHS] |
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.
Definition at line 236 of file init.cpp.
Referenced by describe_spellpath_attenuation(), dragon_ability_gain(), send_spell_paths(), and spellpath_msg().
struct Statistics statistics |
Merged spell statistics.
Definition at line 229 of file init.cpp.
Referenced by init_globals(), object_merge_spell(), and ok_to_put_more().
long trying_emergency_save |
True when emergency_save() is reached.
Definition at line 111 of file init.cpp.
Referenced by emergency_save(), init_globals(), and LOG().
const char* undead_name |
Definition at line 125 of file init.cpp.
Referenced by deathstrike_living(), free_globals(), hit_player(), hit_with_one_attacktype(), init_globals(), and is_susceptible_to_disease().