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

Data file writing routines. More...

#include "object.h"
#include "parser.h"

Go to the source code of this file.

Data Structures

struct  file_parser
 

Functions

errr run_parser (struct file_parser *fp)
 
errr parse_file_quit_not_found (struct parser *p, const char *filename)
 The basic file parsing function. More...
 
errr parse_file (struct parser *p, const char *filename)
 The basic file parsing function. More...
 
void cleanup_parser (struct file_parser *fp)
 
int lookup_flag (const char **flag_table, const char *flag_name)
 
errr grab_rand_value (random_value *value, const char **value_type, const char *name_and_value)
 Get the random value argument from a value expression and put it into the appropriate place in an array. More...
 
errr grab_int_value (int *value, const char **value_type, const char *name_and_value)
 Get the integer argument from a value expression and put it into the appropriate place in an array. More...
 
errr grab_index_and_int (int *value, int *index, const char **value_type, const char *prefix, const char *name_and_value)
 Get the integer argument from a value expression and the index in the value_type array of the suffix used to build the value string. More...
 
errr grab_base_and_int (int *value, char **base, const char *name_and_value)
 Get the integer argument from a slay value expression and the monster base name it is slaying. More...
 
errr grab_name (const char *from, const char *what, const char *list[], int max, int *num)
 
errr grab_flag (bitflag *flags, const size_t size, const char **flag_table, const char *flag_name)
 
errr remove_flag (bitflag *flags, const size_t size, const char **flag_table, const char *flag_name)
 
void write_flags (ang_file *fff, const char *intro_text, bitflag *flags, int flag_size, const char *names[])
 

Angband datafile writing routines

More...
 
void write_mods (ang_file *fff, const int values[])
 
void write_elements (ang_file *fff, const struct element_info *el_info)
 
void file_archive (char *fname, char *append)
 Archive a data file from ANGBAND_DIR_USER into ANGBAND_DIR_ARCHIVE. More...
 
void activate_randart_file (void)
 Prepare the randart file for the current seed to be loaded. More...
 
void deactivate_randart_file (void)
 Move the randart file to the archive directory. More...
 

Variables

const char * parser_error_str [PARSE_ERROR_MAX]
 

Detailed Description

Data file writing routines.

Copyright (c) 2017 Nick McConnell

This work is free software; you can redistribute it and/or modify it under the terms of either:

a) the GNU General Public License as published by the Free Software Foundation, version 2, or

b) the "Angband licence": 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. Other copyrights may also apply.

Function Documentation

void activate_randart_file ( void  )

Prepare the randart file for the current seed to be loaded.

References ANGBAND_DIR_ARCHIVE, ANGBAND_DIR_USER, file_move(), format(), path_build(), and seed_randart.

Referenced by rd_misc().

void cleanup_parser ( struct file_parser fp)
void deactivate_randart_file ( void  )

Move the randart file to the archive directory.

References file_archive(), seed_randart, and strnfmt().

Referenced by close_game().

void file_archive ( char *  fname,
char *  append 
)

Archive a data file from ANGBAND_DIR_USER into ANGBAND_DIR_ARCHIVE.

References ANGBAND_DIR_ARCHIVE, ANGBAND_DIR_USER, file_exists(), file_move(), format(), i, my_strcpy(), and path_build().

Referenced by deactivate_randart_file().

errr grab_base_and_int ( int value,
char **  base,
const char *  name_and_value 
)

Get the integer argument from a slay value expression and the monster base name it is slaying.

Parameters
valuethe integer value
basethe monster base name
name_and_valuethe value expression being matched
Returns
0 if successful, otherwise an error value

References find_value_arg(), my_strcpy(), NULL, and string_make().

errr grab_flag ( bitflag flags,
const size_t  size,
const char **  flag_table,
const char *  flag_name 
)
errr grab_index_and_int ( int value,
int index,
const char **  value_type,
const char *  prefix,
const char *  name_and_value 
)

Get the integer argument from a value expression and the index in the value_type array of the suffix used to build the value string.

Parameters
valuethe integer value
indexthe information on where to put it (eg array index)
value_typethe variable suffix of the possible value strings
prefixthe constant prefix of the possible value strings
name_and_valuethe value expression being matched
Returns
0 if successful, otherwise an error value

References find_value_arg(), i, my_strcat(), my_strcpy(), NULL, and streq.

Referenced by parse_artifact_values(), parse_curse_values(), parse_ego_values(), parse_object_values(), and parse_p_race_values().

errr grab_int_value ( int value,
const char **  value_type,
const char *  name_and_value 
)

Get the integer argument from a value expression and put it into the appropriate place in an array.

Parameters
valuethe target array of integers
value_typethe possible value strings
name_and_valuethe value expression being matched
Returns
0 if successful, otherwise an error value

References find_value_arg(), i, my_strcpy(), NULL, and streq.

Referenced by parse_artifact_values(), and parse_ego_min_val().

errr grab_name ( const char *  from,
const char *  what,
const char *  list[],
int  max,
int num 
)
errr grab_rand_value ( random_value value,
const char **  value_type,
const char *  name_and_value 
)

Get the random value argument from a value expression and put it into the appropriate place in an array.

Parameters
valuethe target array of values
value_typethe possible value strings
name_and_valuethe value expression being matched
Returns
0 if successful, otherwise an error value

References dice_free(), dice_new(), dice_parse_string(), dice_random_value(), find_value_arg(), i, my_strcpy(), NULL, and streq.

Referenced by parse_ego_values(), and parse_object_values().

int lookup_flag ( const char **  flag_table,
const char *  flag_name 
)
errr parse_file ( struct parser p,
const char *  filename 
)
errr parse_file_quit_not_found ( struct parser p,
const char *  filename 
)
errr remove_flag ( bitflag flags,
const size_t  size,
const char **  flag_table,
const char *  flag_name 
)

References flag, FLAG_END, flag_off(), and lookup_flag().

Referenced by parse_monster_flags_off().

errr run_parser ( struct file_parser fp)
void write_elements ( ang_file fff,
const struct element_info el_info 
)
void write_flags ( ang_file fff,
const char *  intro_text,
bitflag flags,
int  flag_size,
const char *  names[] 
)


Angband datafile writing routines

Write the flag lines for a set of flags.

References buf, file_putf(), flag, FLAG_END, flag_next(), FLAG_START, my_strcat(), and my_strcpy().

Referenced by write_lore_entries().

void write_mods ( ang_file fff,
const int  values[] 
)

Variable Documentation

const char* parser_error_str[PARSE_ERROR_MAX]

Referenced by print_error().