Crossfire Server, Branches 1.12  R18729
init.c File Reference
#include <global.h>
#include <object.h>
+ Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define EXTERN
 
#define INIT_C
 

Functions

void free_globals (void)
 
static void init_attackmess (void)
 
static void init_clocks (void)
 
static void init_defaults (void)
 
static void init_dynamic (void)
 
static void init_emergency_mappath (void)
 
static void init_environ (void)
 
void init_globals (void)
 
void init_library (void)
 
void init_objects (void)
 
void write_todclock (void)
 

Variables

attackmess_t attack_mess [NROFATTACKMESS][MAXATTACKMESS]
 
struct Settings settings
 
const char *const spellpathnames [NRSPELLPATHS]
 
struct Statistics statistics
 
unsigned long todtick
 

Detailed Description

Basic initialization for the common library.

Definition in file init.c.

Macro Definition Documentation

#define EXTERN

Definition at line 34 of file init.c.

#define INIT_C

Definition at line 35 of file init.c.

Function Documentation

void free_globals ( void  )

Cleans all memory allocated for global variables.

Will clear:

  • attack messages
  • emergency map settings
  • friendly list
  • experience
  • regions

Definition at line 307 of file init.c.

References attack_mess, Settings::emergency_mapname, first_friendly_object, first_region, FREE_AND_CLEAR, FREE_AND_CLEAR_STR, free_experience(), regiondef::jailmap, regiondef::longname, MAXATTACKMESS, regiondef::msg, regiondef::name, regiondef::next, oblnk::next, NROFATTACKMESS, regiondef::parent_name, and undead_name.

Referenced by cleanup().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void init_attackmess ( void  )
static

Initializes the attack messages. Called by init_library().

Memory will be cleared by free_globals().

Definition at line 473 of file init.c.

References attackmess::buf1, attackmess::buf2, attackmess::buf3, close_and_delete(), Settings::datadir, attackmess::level, llevDebug, llevError, LOG(), MAX_BUF, open_and_uncompress(), snprintf(), and strdup_local().

Referenced by init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void init_clocks ( void  )
static

Initializes the gametime and TOD counters Called by init_library().

Definition at line 441 of file init.c.

References llevDebug, llevError, Settings::localdir, LOG(), MAX_BUF, snprintf(), todtick, and write_todclock().

Referenced by init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void init_defaults ( void  )
static

Initialises global variables which can be changed by options. Called by init_library().

Definition at line 378 of file init.c.

References nroferrors.

Referenced by init_globals().

+ Here is the caller graph for this function:

static void init_dynamic ( void  )
static

Initializes first_map_path from the archetype collection.

Must be called after archetypes have been initialized.

Note
will call exit() if no MAP archetype was found.

Definition at line 390 of file init.c.

References archt::clone, delete_map(), EXIT_PATH, first_archetype, first_map_ext_path, first_map_path, llevError, LOG(), MAP, archt::next, obj::race, ready_map_name(), snprintf(), and obj::type.

Referenced by init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void init_emergency_mappath ( void  )
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.

Note
If file doesn't exist, will not do anything.

Definition at line 161 of file init.c.

References Settings::datadir, Settings::emergency_mapname, Settings::emergency_x, Settings::emergency_y, llevDebug, llevError, LOG(), Settings::mapdir, MAX_BUF, snprintf(), and strdup_local().

Referenced by init_library().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void init_environ ( void  )
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 225 of file init.c.

References Settings::archetypes, Settings::datadir, Settings::localdir, Settings::mapdir, Settings::playerdir, Settings::templatedir, Settings::tmpdir, Settings::treasures, and Settings::uniquedir.

Referenced by init_library().

+ Here is the caller graph for this function:

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 263 of file init.c.

References add_string(), amulet_arch, animations, animations_allocated, exiting, first_archetype, first_artifactlist, first_friendly_object, first_map, first_map_ext_path, first_player, first_treasurelist, init_defaults(), logfile, Settings::logfilename, nrofallowedstr, nrofartifacts, nroftreasures, num_animations, ring_arch, staff_arch, statistics, trying_emergency_save, undead_name, and warn_archetypes.

Referenced by cctk_init_std_archetypes(), init_library(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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() and init_function_pointers(). Good idea to also call init_vars and init_hash_table if you are doing any object loading.

Definition at line 201 of file init.c.

References i18n_init(), init_anim(), init_archetypes(), init_attackmess(), init_block(), init_clocks(), init_dynamic(), init_emergency_mappath(), init_environ(), init_experience(), init_globals(), init_hash_table(), init_objects(), init_vars(), read_bmap_names(), and read_smooth().

Referenced by init(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void init_objects ( void  )

Sets up and initialises the linked list of free and used objects. Allocates a certain chunk of objects and puts them on the free list. Called by init_library();

Definition at line 347 of file init.c.

References active_objects, FLAG_FREED, FLAG_REMOVED, free_objects, obj::next, objarray, objects, obj::prev, SET_FLAG, and STARTMAX.

Referenced by cctk_init_std_archetypes(), and init_library().

+ Here is the caller graph for this function:

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 424 of file init.c.

References llevError, Settings::localdir, LOG(), MAX_BUF, snprintf(), and todtick.

Referenced by clean_tmp_files(), init_clocks(), and tick_the_clock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

Attack messages the player gets when hitting/getting hit.

Definition at line 465 of file init.c.

Referenced by attack_message(), and free_globals().

struct Settings settings

You unforunately need to looking in include/global.h to see what these correspond to.

Definition at line 48 of file init.c.

Referenced by add_me_cmd(), add_player_exp(), add_score(), apply_death_exp_penalty(), apply_special(), attack_ob_simple(), attempt_steal(), block_until_new_connection(), calc_perm_exp(), calc_skill_exp(), cast_create_town_portal(), cast_spell(), cctk_init_std_archetypes(), cctk_setdatadir(), cctk_setlog(), cfapi_system_directory(), check_exp_loss(), check_login(), check_pick(), checkbanned(), checkdm(), clean_tmp_files(), clear_object(), command_abil(), command_addexp(), command_banish(), command_create(), command_debug(), command_explore(), command_help(), command_loadtest(), command_nowiz(), command_patch(), command_players(), command_search_items(), command_title(), compile_info(), convert_item(), create_items_path(), create_overlay_pathname(), create_pathname(), create_template_pathname(), dead_player(), delete_character(), display_high_score(), display_motd(), dragon_eat_flesh(), dump_experience(), enter_exit(), enter_player_savebed(), enter_unique_map(), find_maps(), find_style(), fix_object(), forbid_play(), god_enchants_weapon(), help_topics(), hit_player(), i18n_init(), improve_armour(), improve_weapon(), init(), init_anim(), init_artifacts(), init_beforeplay(), init_book_archive(), init_experience(), init_formulae(), init_msgfile(), init_races(), init_regions(), init_server(), init_startup(), is_legal_2ways_exit(), key_change_class(), key_confirm_quit(), kill_object(), kill_player(), level_exp(), list_players(), load_archetypes(), load_materials(), load_settings(), load_treasures(), LOG(), main(), metaserver2_init(), metaserver_init(), metaserver_update(), pay_for_item(), pick_up_object(), player_lvl_adj(), process_events(), process_players1(), query_cost(), rangetostring(), read_bmap_names(), read_client_images(), read_face_data(), read_map_log(), read_smooth(), resurrect_player(), save_map(), save_player(), scroll_failure(), scroll_type_apply(), send_exp_table(), send_news(), send_rules(), server_main(), set_archetypes(), set_confdir(), set_csport(), set_daemon(), 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_localdir(), set_logfile(), set_mapdir(), set_mondebug(), set_playerdir(), set_regions(), set_templatedir(), set_tmpdir(), set_treasures(), set_uniquedir(), show_skills(), SP_level_spellpoint_cost(), spell_failure(), spellbook_type_apply(), swap_map(), unset_debug(), verify_player(), write_book_archive(), write_map_log(), and write_scroll().

const char* const spellpathnames[NRSPELLPATHS]
Initial value:
= {
"Protection",
"Fire",
"Frost",
"Electricity",
"Missiles",
"Self",
"Summoning",
"Abjuration",
"Restoration",
"Detonation",
"Mind",
"Creation",
"Teleportation",
"Information",
"Transmutation",
"Transferrence",
"Turning",
"Wounding",
"Death",
"Light"
}

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 126 of file init.c.

Referenced by dragon_ability_gain(), send_spell_paths(), and spellpath_msg().

struct Statistics statistics

Definition at line 119 of file init.c.

Referenced by init_globals(), main(), merge_spell(), and ok_to_put_more().

unsigned long todtick

Ingame time

Definition at line 418 of file init.c.

Referenced by get_tod(), init_clocks(), tick_the_clock(), and write_todclock().