Crossfire Server, Trunk
|
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "global.h"
#include "define.h"
Go to the source code of this file.
Data Structures | |
struct | attribute_definition |
struct | attribute_type |
struct | flag_definition |
struct | ignore_list |
struct | type_attribute |
struct | type_definition |
struct | type_name |
Variables | |
int | attribute_count = 0 |
attribute_definition ** | attributes = NULL |
static const char * | custom_attributes [] |
type_definition * | default_type = NULL |
const char * | destination_dir = "../doc/Developers" |
type_definition * | fallback_type = NULL |
const char * | field_dir = "fields" |
static const flag_definition | flags [] |
static const char * | in_living [] |
int | list_count = 0 |
ignore_list ** | lists = NULL |
int | type_count = 0 |
const char * | type_dir = "types" |
static type_name | type_names [] |
type_definition ** | types = NULL |
This small program will extract information from Gridarta's types.xml file to generate documentation about types and fields. Files are placed in developer's documentation subdirs by default.
To build:
gcc -g -pg -O0 -Wall -pedantic gridarta-types-convert.c -I../include -o gridarta-types-convert
To run:
./gridarta-types-convert ../../gridarta/src/crossfire/src/main/resources/resource/conf/types.xml
(adjust the path according to your setup)
Note that someone wishing to tweak this program should know the format of Gridarta's types.xml.
This program isn't terribly robust, there could be more conditions, and it just doesn't free memory. May be fixed someday, but since it's a "run and exit", not high priority.
This program can be modified and altered at will, as long as it's for the Crossfire project. Else don't touch it :)
Note that "attribute" is used for "field in a object/living structure".
Definition in file gridarta-types-convert.c.
void add_required_parameter | ( | type_definition * | type, |
const char * | buf | ||
) |
Add a required parameter to the specified type. buf is the line read from the file, non processed.
Definition at line 477 of file gridarta-types-convert.c.
References buf, flag_definition::code_name, fallback_type, find_flag(), give::name, guildbuy::temp, is_valid_types_gen::type, and autojail::value.
Referenced by read_type().
void add_type_to_attribute | ( | attribute_definition * | attribute, |
type_definition * | type, | ||
int | attr | ||
) |
Definition at line 724 of file gridarta-types-convert.c.
References attribute_type::count, get_description_for_attribute(), attribute_type::number, is_valid_types_gen::type, and attribute_type::type.
Referenced by main().
void copy_attributes | ( | const type_definition * | source, |
type_definition * | type | ||
) |
Definition at line 369 of file gridarta-types-convert.c.
References type_definition::attribute_count, type_definition::attributes, type_attribute::description, type_attribute::field, get_attribute_for_type(), type_attribute::name, and is_valid_types_gen::type.
Referenced by copy_default_attributes(), and read_type().
void copy_default_attributes | ( | type_definition * | type | ) |
Definition at line 385 of file gridarta-types-convert.c.
References copy_attributes(), default_type, and is_valid_types_gen::type.
Referenced by get_type_definition().
void dump_ignore_lists | ( | void | ) |
Definition at line 773 of file gridarta-types-convert.c.
References ignore_list::count, guildoracle::list, list_count, lists, and give::name.
void dump_type | ( | type_definition * | type | ) |
Definition at line 660 of file gridarta-types-convert.c.
References is_valid_types_gen::type.
Referenced by dump_types().
void dump_types | ( | void | ) |
Definition at line 671 of file gridarta-types-convert.c.
References dump_type(), Floor::t, is_valid_types_gen::type, type_count, and types.
type_attribute* duplicate_attribute | ( | type_attribute * | attr | ) |
Definition at line 324 of file gridarta-types-convert.c.
References type_attribute::description, type_attribute::field, and type_attribute::name.
const flag_definition* find_flag | ( | const char * | name | ) |
Return flag if exists, NULL else.
Definition at line 197 of file gridarta-types-convert.c.
References flag_definition::field, flags, and give::name.
Referenced by add_required_parameter(), and write_attribute_reference().
ignore_list* find_ignore_list | ( | const char * | name | ) |
Definition at line 429 of file gridarta-types-convert.c.
References guildoracle::list, list_count, lists, and give::name.
Referenced by read_type().
type_definition* find_type_definition | ( | const char * | name | ) |
Used for type import.
Definition at line 410 of file gridarta-types-convert.c.
References give::name, is_valid_types_gen::type, type_count, and types.
Referenced by read_type().
void free_attribute | ( | type_attribute * | attr | ) |
Definition at line 332 of file gridarta-types-convert.c.
References type_attribute::description, type_attribute::field, and type_attribute::name.
Referenced by ignore_attribute().
attribute_definition* get_attribute | ( | const char * | name | ) |
Get an attribute, create it if it doesn't exist yet.
Definition at line 682 of file gridarta-types-convert.c.
References attribute_count, attributes, attribute_definition::field, and give::name.
Referenced by main().
type_attribute* get_attribute_for_type | ( | type_definition * | type, |
const char * | attribute, | ||
int | clean | ||
) |
Gets the attribute for the specified type. If it doesn't exist, create it. If the attribute is already defined, return the existing one, after cleaning its fields if clean is set.
Definition at line 343 of file gridarta-types-convert.c.
References type_attribute::description, type_attribute::field, type_attribute::name, and is_valid_types_gen::type.
Referenced by copy_attributes(), and read_type().
attribute_type* get_description_for_attribute | ( | attribute_definition * | attribute, |
const char * | description | ||
) |
Gets a type description for specified attribute, create it if doesn't exist.
Definition at line 702 of file gridarta-types-convert.c.
References attribute_type::description, attribute_definition::type_count, and attribute_definition::types.
Referenced by add_type_to_attribute().
type_definition* get_type_definition | ( | void | ) |
Returns a new type_definition having the default attributes.
Definition at line 394 of file gridarta-types-convert.c.
References type_definition::attribute_count, type_definition::attributes, copy_default_attributes(), default_type, and type_definition::description.
Referenced by main().
void ignore_attribute | ( | type_definition * | type, |
const char * | attribute | ||
) |
Remove an attribute from the type.
Definition at line 447 of file gridarta-types-convert.c.
References attribute_count, free_attribute(), and is_valid_types_gen::type.
Referenced by ignore_attributes(), and read_type().
void ignore_attributes | ( | type_definition * | type, |
ignore_list * | list | ||
) |
Remove all attributes in the specified list from the type.
Definition at line 463 of file gridarta-types-convert.c.
References ignore_attribute(), guildoracle::list, and is_valid_types_gen::type.
Referenced by read_type().
int is_custom_attribute | ( | const char * | attribute | ) |
Definition at line 845 of file gridarta-types-convert.c.
References custom_attributes.
Referenced by write_attribute_file(), and write_attribute_reference().
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 1024 of file gridarta-types-convert.c.
References add_type_to_attribute(), type_definition::attribute_count, attribute_count, attributes, buf, default_type, type_definition::description, fallback_type, get_attribute(), get_type_definition(), type_definition::name, OBJECT_TYPE_MAX, read_ignore_list(), read_line(), read_type(), Ice::tmp, is_valid_types_gen::type, type_count, types, write_attribute_file(), write_attribute_index(), write_type_file(), and write_type_index().
void read_ignore_list | ( | const char * | name, |
FILE * | file | ||
) |
Read the contents of a <ignore_list>
tag.
Definition at line 736 of file gridarta-types-convert.c.
References buf, mad_mage_user::file, guildoracle::list, list_count, lists, give::name, read_line(), and Ice::tmp.
Referenced by main().
char* read_line | ( | char * | buffer, |
int | size, | ||
FILE * | file | ||
) |
Definition at line 442 of file gridarta-types-convert.c.
References mad_mage_user::file.
Referenced by main(), read_ignore_list(), and read_type().
void read_type | ( | type_definition * | type, |
FILE * | file, | ||
const char * | block_end | ||
) |
Read all lines related to a type, stop when "block_end" is found on a line.
Definition at line 512 of file gridarta-types-convert.c.
References add_required_parameter(), buf, copy_attributes(), type_attribute::description, mad_mage_user::file, find_ignore_list(), find_type_definition(), get_attribute_for_type(), ignore_attribute(), ignore_attributes(), type_attribute::name, read_line(), sort_type_attribute(), Ice::tmp, and is_valid_types_gen::type.
Referenced by main().
int sort_type_attribute | ( | const void * | a, |
const void * | b | ||
) |
To sort attributes.
Definition at line 422 of file gridarta-types-convert.c.
References disinfect::a, and Ice::b.
Referenced by read_type().
void write_attribute_file | ( | attribute_definition * | attribute | ) |
Write the description of a field.
Definition at line 976 of file gridarta-types-convert.c.
References buf, disinfect::count, attribute_type::count, attribute_type::description, destination_dir, attribute_definition::field, field_dir, mad_mage_user::file, is_custom_attribute(), attribute_type::number, is_valid_types_gen::type, attribute_definition::type_count, types, attribute_definition::types, and write_attribute_reference().
Referenced by main().
void write_attribute_index | ( | void | ) |
Write the index of all attributes.
Definition at line 953 of file gridarta-types-convert.c.
References attribute_count, attributes, buf, destination_dir, field_dir, npc_dialog::index, and write_attribute_reference().
Referenced by main().
void write_attribute_reference | ( | const char * | attribute, |
FILE * | file | ||
) |
Write the part to the right of a @ref for the specified attribute.
Definition at line 857 of file gridarta-types-convert.c.
References flag_definition::code_name, mad_mage_user::file, find_flag(), in_living, and is_custom_attribute().
Referenced by write_attribute_file(), write_attribute_index(), and write_type_file().
void write_type_file | ( | type_definition * | type | ) |
Write a type definition file.
Definition at line 887 of file gridarta-types-convert.c.
References buf, type_name::code_name, destination_dir, fallback_type, mad_mage_user::file, OBJECT_TYPE_MAX, is_valid_types_gen::type, type_dir, type_names, autojail::value, and write_attribute_reference().
Referenced by main().
void write_type_index | ( | void | ) |
Write index of all types.
Definition at line 932 of file gridarta-types-convert.c.
References buf, destination_dir, npc_dialog::index, give::name, is_valid_types_gen::type, type_count, type_dir, and types.
Referenced by main().
int attribute_count = 0 |
Definition at line 92 of file gridarta-types-convert.c.
Referenced by get_attribute(), ignore_attribute(), main(), and write_attribute_index().
attribute_definition** attributes = NULL |
Definition at line 91 of file gridarta-types-convert.c.
Referenced by get_attribute(), main(), and write_attribute_index().
|
static |
Custom attributes we know about, to point to the right page.
Definition at line 810 of file gridarta-types-convert.c.
Referenced by is_custom_attribute().
type_definition* default_type = NULL |
Definitions all types have by default.
Definition at line 61 of file gridarta-types-convert.c.
Referenced by copy_default_attributes(), get_type_definition(), and main().
const char* destination_dir = "../doc/Developers" |
Root destination dir.
Definition at line 32 of file gridarta-types-convert.c.
Referenced by adjust_dir(), write_attribute_file(), write_attribute_index(), write_type_file(), and write_type_index().
type_definition* fallback_type = NULL |
Dummy object type that non defined objects use.
Definition at line 64 of file gridarta-types-convert.c.
Referenced by add_required_parameter(), main(), and write_type_file().
const char* field_dir = "fields" |
Where the files about the fields will be stored.
Definition at line 33 of file gridarta-types-convert.c.
Referenced by write_attribute_file(), and write_attribute_index().
|
static |
Flag mapping.
Definition at line 101 of file gridarta-types-convert.c.
Referenced by add_object_to_socklist(), add_player(), cf_map_get_map(), cf_object_update(), cf_player_message(), cfapi_player_message(), Crossfire_Object_Apply(), draw_ext_info(), draw_ext_info_format(), enter_player_maplevel(), esrv_update_item(), esrv_update_spells(), esrv_update_stats(), find_flag(), fix_generated_item(), ArchetypesModel::flags(), get_rangevector(), get_rangevector_from_mapcoord(), main(), map_path(), mapfile_load(), mapfile_load_lowlevel(), mapsave_test(), object_find_by_type_without_flags(), object_free(), object_update(), put_treasure(), query_flags(), ready_map_name(), readyMap(), remove_adjacent_doors(), roll_ob(), send_query(), set_magic(), SP_level_spellpoint_cost(), and update_position().
|
static |
Fields part of the living structure.
Definition at line 786 of file gridarta-types-convert.c.
Referenced by write_attribute_reference().
int list_count = 0 |
Definition at line 74 of file gridarta-types-convert.c.
Referenced by dump_ignore_lists(), find_ignore_list(), and read_ignore_list().
ignore_list** lists = NULL |
Definition at line 73 of file gridarta-types-convert.c.
Referenced by TreasureListWrapper::drop(), TreasureWrapper::drop(), TreasurePanel::dropEvent(), dump_ignore_lists(), find_ignore_list(), MessageFile::parseFile(), and read_ignore_list().
int type_count = 0 |
Definition at line 58 of file gridarta-types-convert.c.
Referenced by dump_types(), find_type_definition(), main(), and write_type_index().
const char* type_dir = "types" |
Where the files about types will be stored.
Definition at line 34 of file gridarta-types-convert.c.
Referenced by write_type_file(), and write_type_index().
|
static |
Definition at line 211 of file gridarta-types-convert.c.
Referenced by write_type_file().
type_definition** types = NULL |
Defined types.
Definition at line 56 of file gridarta-types-convert.c.
Referenced by buildShopReport(), command_applymode(), command_bowmode(), command_petmode(), command_usekeys(), dump_types(), find_type_definition(), main(), write_attribute_file(), and write_type_index().