Angband
Data Structures | Functions | Variables
init.h File Reference

initialization More...

#include "h-basic.h"
#include "z-bitflag.h"
#include "z-file.h"
#include "z-rand.h"
#include "parser.h"

Go to the source code of this file.

Data Structures

struct  angband_constants
 Information about maximal indices of certain arrays. More...
struct  init_module

Functions

struct parserinit_parse_artifact (void)
struct parserinit_parse_class (void)
struct parserinit_parse_ego (void)
struct parserinit_parse_feat (void)
struct parserinit_parse_history (void)
struct parserinit_parse_object (void)
struct parserinit_parse_object_base (void)
struct parserinit_parse_pain (void)
struct parserinit_parse_p_race (void)
struct parserinit_parse_pit (void)
struct parserinit_parse_monster (void)
struct parserinit_parse_v (void)
struct parserinit_parse_constants (void)
struct parserinit_parse_flavor (void)
struct parserinit_parse_names (void)
struct parserinit_parse_hints (void)
struct parserinit_parse_trap (void)
struct parserinit_parse_quest (void)
void init_file_paths (const char *config, const char *lib, const char *data)
 Find the default paths to all of our important sub-directories.
void init_game_constants (void)
 Initialise game constants.
void init_arrays (void)
 Initialise just the internal arrays.
void create_needed_dirs (void)
 Create any missing directories.
bool init_angband (void)
 Initialise Angband's data stores and allocate memory for structures, etc, so that the game can get started.
void cleanup_angband (void)
 Free all the stuff initialised in init_angband()

Variables

struct angband_constantsz_info
const char * ANGBAND_SYS
char * ANGBAND_DIR_APEX
char * ANGBAND_DIR_EDIT
char * ANGBAND_DIR_FILE
char * ANGBAND_DIR_HELP
char * ANGBAND_DIR_INFO
char * ANGBAND_DIR_SAVE
char * ANGBAND_DIR_PREF
char * ANGBAND_DIR_USER
char * ANGBAND_DIR_XTRA
char * ANGBAND_DIR_XTRA_FONT
char * ANGBAND_DIR_XTRA_GRAF
char * ANGBAND_DIR_XTRA_SOUND
char * ANGBAND_DIR_XTRA_ICON

Detailed Description

initialization

Copyright (c) 2000 Robert Ruehlmann

This software may be copied and distributed for educational, research, and not for profit purposes provided that this copyright and statement are included in all such copies.

Function Documentation

void cleanup_angband ( void  )
void create_needed_dirs ( void  )

Create any missing directories.

We create only those dirs which may be empty (user/, save/, apex/, info/, help/). The others are assumed to contain required files and therefore must exist at startup (edit/, pref/, file/, xtra/).

ToDo: Only create the directories when actually writing files.

References ANGBAND_DIR_APEX, ANGBAND_DIR_HELP, ANGBAND_DIR_INFO, ANGBAND_DIR_SAVE, ANGBAND_DIR_USER, dir_create(), path_build(), and quit_fmt().

Referenced by main().

bool init_angband ( void  )

Initialise Angband's data stores and allocate memory for structures, etc, so that the game can get started.

The only input/output in this file should be via event_signal_string(). We cannot rely on any particular UI as this part should be UI-agnostic. We also cannot rely on anything else having being initialised into any particlar state. Which is why you'd be calling this function in the first place.

Old comment, not sure if still accurate: Note that the "graf-xxx.prf" file must be loaded separately, if needed, in the first (?) pass through "TERM_XTRA_REACT".

References EVENT_ENTER_INIT, EVENT_INITSTATUS, event_signal(), event_signal_message(), i, init_module::init, init_game_constants(), monster_list_init(), object_list_init(), Rand_init(), and TRUE.

Referenced by main(), and setup_tests().

void init_arrays ( void  )

Initialise just the internal arrays.

This should be callable by the test suite, without relying on input, or anything to do with a user or savefiles.

Assumption: Paths are set up correctly before calling this function.

References EVENT_INITSTATUS, event_signal_message(), format(), i, N_ELEMENTS, pl, quit_fmt(), and run_parser().

Referenced by read_edit_files().

void init_file_paths ( const char *  configpath,
const char *  libpath,
const char *  datapath 
)

Find the default paths to all of our important sub-directories.

All of the sub-directories should, by default, be located inside the main directory, whose location is very system dependant and is set by the ANGBAND_PATH environment variable, if it exists. (On multi- user systems such as Linux this is not the default - see config.h for more info.)

This function takes a writable buffers, initially containing the "path" to the "config", "lib" and "data" directories, for example, "/etc/angband/", "/usr/share/angband" and "/var/games/angband" - or a system dependant string, for example, ":lib:". The buffer must be large enough to contain at least 32 more characters.

Various command line options may allow some of the important directories to be changed to user-specified directories, most importantly, the "apex" and "user" and "save" directories, but this is done after this function, see "main.c".

In general, the initial path should end in the appropriate "PATH_SEP" string. All of the "sub-directory" paths (created below or supplied by the user) will NOT end in the "PATH_SEP" string, see the special "path_build()" function in "util.c" for more information.

Hack – first we free all the strings, since this is known to succeed even if the strings have not been allocated yet, as long as the variables start out as "NULL". This allows this function to be called multiple times, for example, to try several base "path" values until a good one is found.

References ANGBAND_DIR_APEX, ANGBAND_DIR_EDIT, ANGBAND_DIR_FILE, ANGBAND_DIR_HELP, ANGBAND_DIR_INFO, ANGBAND_DIR_PREF, ANGBAND_DIR_SAVE, ANGBAND_DIR_USER, ANGBAND_DIR_XTRA, ANGBAND_DIR_XTRA_FONT, ANGBAND_DIR_XTRA_GRAF, ANGBAND_DIR_XTRA_ICON, ANGBAND_DIR_XTRA_SOUND, ANGBAND_SYS, buf, format(), path_build(), PATH_SEP, string_free(), string_make(), and VERSION_NAME.

Referenced by init_stuff(), and set_file_paths().

void init_game_constants ( void  )

Initialise game constants.

Assumption: Paths are set up correctly before calling this function.

References EVENT_INITSTATUS, event_signal_message(), quit_fmt(), and run_parser().

Referenced by init_angband(), and read_edit_files().

struct parser* init_parse_artifact ( void  )
read
struct parser* init_parse_class ( void  )
read
struct parser* init_parse_constants ( void  )
read
struct parser* init_parse_ego ( void  )
read
struct parser* init_parse_feat ( void  )
read
struct parser* init_parse_flavor ( void  )
read
struct parser* init_parse_hints ( void  )
read
struct parser* init_parse_history ( void  )
read
struct parser* init_parse_monster ( void  )
read
struct parser* init_parse_names ( void  )
read
struct parser* init_parse_object ( void  )
read
struct parser* init_parse_object_base ( void  )
read
struct parser* init_parse_p_race ( void  )
read
struct parser* init_parse_pain ( void  )
read
struct parser* init_parse_pit ( void  )
read
struct parser* init_parse_quest ( void  )
read
struct parser* init_parse_trap ( void  )
read
struct parser* init_parse_v ( void  )
read

Variable Documentation

char* ANGBAND_DIR_APEX
char* ANGBAND_DIR_EDIT
char* ANGBAND_DIR_FILE
char* ANGBAND_DIR_HELP
char* ANGBAND_DIR_INFO
char* ANGBAND_DIR_PREF
char* ANGBAND_DIR_SAVE
char* ANGBAND_DIR_USER
char* ANGBAND_DIR_XTRA

Referenced by cleanup_angband(), and init_file_paths().

char* ANGBAND_DIR_XTRA_FONT

Referenced by cleanup_angband(), and init_file_paths().

char* ANGBAND_DIR_XTRA_GRAF
char* ANGBAND_DIR_XTRA_ICON

Referenced by cleanup_angband(), and init_file_paths().

char* ANGBAND_DIR_XTRA_SOUND

Referenced by cleanup_angband(), and init_file_paths().

const char* ANGBAND_SYS
struct angband_constants* z_info