Go to the documentation of this file.
102 {
"alive",
"FLAG_ALIVE" },
103 {
"wiz",
"FLAG_WIZ" },
104 {
"was_wiz",
"FLAG_WAS_WIZ" },
105 {
"applied",
"FLAG_APPLIED" },
106 {
"unpaid",
"FLAG_UNPAID" },
107 {
"can_use_shield",
"FLAG_USE_SHIELD" },
108 {
"no_pick",
"FLAG_NO_PICK" },
109 {
"client_anim_sync",
"FLAG_CLIENT_ANIM_SYNC" },
110 {
"client_anim_random",
"FLAG_CLIENT_ANIM_RANDOM" },
111 {
"is_animated",
"FLAG_ANIMATE" },
112 {
"monster",
"FLAG_MONSTER" },
113 {
"friendly",
"FLAG_FRIENDLY" },
114 {
"generator",
"FLAG_GENERATOR" },
115 {
"is_thrown",
"FLAG_IS_THROWN" },
116 {
"auto_apply",
"FLAG_AUTO_APPLY" },
117 {
"treasure",
"FLAG_TREASURE" },
118 {
"player sold",
"FLAG_PLAYER_SOLD" },
119 {
"see_invisible",
"FLAG_SEE_INVISIBLE" },
120 {
"can_roll",
"FLAG_CAN_ROLL" },
121 {
"overlay_floor",
"FLAG_OVERLAY_FLOOR" },
122 {
"is_turnable",
"FLAG_IS_TURNABLE" },
123 {
"is_used_up",
"FLAG_IS_USED_UP" },
124 {
"identified",
"FLAG_IDENTIFIED" },
125 {
"reflecting",
"FLAG_REFLECTING" },
126 {
"changing",
"FLAG_CHANGING" },
127 {
"splitting",
"FLAG_SPLITTING" },
128 {
"hitback",
"FLAG_HITBACK" },
129 {
"startequip",
"FLAG_STARTEQUIP" },
130 {
"blocksview",
"FLAG_BLOCKSVIEW" },
131 {
"undead",
"FLAG_UNDEAD" },
132 {
"scared",
"FLAG_SCARED" },
133 {
"unaggressive",
"FLAG_UNAGGRESSIVE" },
134 {
"reflect_missile",
"FLAG_REFL_MISSILE" },
135 {
"reflect_spell",
"FLAG_REFL_SPELL" },
136 {
"no_magic",
"FLAG_NO_MAGIC" },
137 {
"no_fix_player",
"FLAG_NO_FIX_PLAYER" },
138 {
"is_lightable",
"FLAG_IS_LIGHTABLE" },
139 {
"tear_down",
"FLAG_TEAR_DOWN" },
140 {
"run_away",
"FLAG_RUN_AWAY" },
141 {
"unique",
"FLAG_UNIQUE" },
142 {
"no_drop",
"FLAG_NO_DROP" },
143 {
"can_cast_spell",
"FLAG_CAST_SPELL" },
144 {
"can_use_scroll",
"FLAG_USE_SCROLL" },
145 {
"can_use_range",
"FLAG_USE_RANGE" },
146 {
"can_use_bow",
"FLAG_USE_BOW" },
147 {
"can_use_armour",
"FLAG_USE_ARMOUR" },
148 {
"can_use_weapon",
"FLAG_USE_WEAPON" },
149 {
"can_use_ring",
"FLAG_USE_RING" },
150 {
"has_ready_range",
"FLAG_READY_RANGE" },
151 {
"has_ready_bow",
"FLAG_READY_BOW" },
152 {
"xrays",
"FLAG_XRAYS" },
153 {
"is_floor",
"FLAG_IS_FLOOR" },
154 {
"lifesave",
"FLAG_LIFESAVE" },
155 {
"no_strength",
"FLAG_NO_STRENGTH" },
156 {
"sleep",
"FLAG_SLEEP" },
157 {
"stand_still",
"FLAG_STAND_STILL" },
158 {
"random_movement",
"FLAG_RANDOM_MOVE" },
159 {
"only_attack",
"FLAG_ONLY_ATTACK" },
160 {
"confused",
"FLAG_CONFUSED" },
161 {
"stealth",
"FLAG_STEALTH" },
162 {
"cursed",
"FLAG_CURSED" },
163 {
"damned",
"FLAG_DAMNED" },
164 {
"see_anywhere",
"FLAG_SEE_ANYWHERE" },
165 {
"known_magical",
"FLAG_KNOWN_MAGICAL" },
166 {
"known_cursed",
"FLAG_KNOWN_CURSED" },
167 {
"can_use_skill",
"FLAG_CAN_USE_SKILL" },
168 {
"been_applied",
"FLAG_BEEN_APPLIED" },
169 {
"has_ready_scroll",
"FLAG_READY_SCROLL" },
170 {
"make_invisible",
"FLAG_MAKE_INVIS" },
171 {
"inv_locked",
"FLAG_INV_LOCKED" },
172 {
"is_wooded",
"FLAG_IS_WOODED" },
173 {
"is_hilly",
"FLAG_IS_HILLY" },
174 {
"has_ready_skill",
"FLAG_READY_SKILL" },
175 {
"has_ready_weapon",
"FLAG_READY_WEAPON" },
176 {
"no_skill_ident",
"FLAG_NO_SKILL_IDENT" },
177 {
"is_blind",
"FLAG_BLIND" },
178 {
"can_see_in_dark",
"FLAG_SEE_IN_DARK" },
179 {
"is_cauldron",
"FLAG_IS_CAULDRON" },
180 {
"no_steal",
"FLAG_NO_STEAL" },
181 {
"one_hit",
"FLAG_ONE_HIT" },
182 {
"berserk",
"FLAG_BERSERK" },
183 {
"neutral",
"FLAG_NEUTRAL" },
184 {
"no_attack",
"FLAG_NO_ATTACK" },
185 {
"no_damage",
"FLAG_NO_DAMAGE" },
186 {
"activate_on_push",
"FLAG_ACTIVATE_ON_PUSH" },
187 {
"activate_on_release",
"FLAG_ACTIVATE_ON_RELEASE" },
188 {
"is_water",
"FLAG_IS_WATER" },
189 {
"use_content_on_gen",
"FLAG_CONTENT_ON_GEN" },
190 {
"is_buildable",
"FLAG_IS_BUILDABLE" },
191 {
"blessed",
"FLAG_BLESSED" },
192 {
"known_blessed",
"FLAG_KNOWN_BLESSED" },
347 for (test = 0; test <
type->attribute_count; test++) {
348 if (!strcmp(
type->attributes[test]->field, attribute)) {
349 ret =
type->attributes[test];
360 ret->
field = strdup(attribute);
362 type->attribute_count++;
364 type->attributes[
type->attribute_count-1] = ret;
417 printf(
"type not found: %s\n",
name);
426 return strcmp((*la)->name, (*lb)->name);
443 return fgets(buffer, 200,
file);
450 for (find = 0; find <
type->attribute_count; find++) {
451 if (!strcmp(attribute,
type->attributes[find]->field)) {
455 type->attributes[find] =
type->attributes[
type->attribute_count-1];
456 type->attribute_count--;
467 printf(
"empty ignore list?\n");
471 for (attr = 0; attr <
list->count; attr++) {
478 char *sn, *en, *sv, *ev;
486 sn = strstr(
buf,
"arch");
489 sn = strchr(sn,
'"');
490 en = strchr(sn+1,
'"');
491 sv = strstr(
buf,
"value");
492 sv = strchr(sv,
'"');
493 ev = strchr(sv+1,
'"');
495 name[en-sn-1] =
'\0';
496 strncpy(
name, sn+1, en-sn-1);
497 value[ev-sv-1] =
'\0';
498 strncpy(
value, sv+1, ev-sv-1);
500 type->require_count++;
501 type->required = realloc(
type->required,
type->require_count*
sizeof(
char *));
505 snprintf(
temp, 200,
"@ref %s %s", flag->
code_name, strcmp(
value,
"0") ?
"set" :
"unset");
518 if (strstr(
buf, block_end) != NULL) {
519 if (
type->attribute_count)
523 if (strstr(
buf,
"<description>") != NULL) {
525 if (strstr(
buf,
"</description>") != NULL)
528 if (
type->description) {
529 type->description = realloc(
type->description, strlen(
type->description)+strlen(
buf)+1);
530 strcat(
type->description,
buf);
533 type->description = strdup(
buf);
535 find = strstr(
type->description,
"]]>");
537 type->description[find-
type->description] =
'\0';
538 while (
type->description[strlen(
type->description)-1] ==
'\n')
539 type->description[strlen(
type->description)-1] =
'\0';
543 if (strstr(
buf,
"<ignore_list") != NULL) {
544 find = strstr(
buf,
"name=");
547 find = strchr(find+1,
'"');
550 end = strchr(find+1,
'"');
553 tmp[end-find-1] =
'\0';
554 strncpy(
tmp, find+1, end-find-1);
558 if (strstr(
buf,
"<ignore>") != NULL) {
560 if (strstr(
buf,
"</ignore>") != NULL)
562 find = strstr(
buf,
"arch=");
565 find = strchr(find+1,
'"');
568 end = strchr(find+1,
'"');
571 tmp[end-find-1] =
'\0';
572 strncpy(
tmp, find+1, end-find-1);
577 if (strstr(
buf,
"<required>") != NULL) {
579 if (strstr(
buf,
"</required>") != NULL)
585 if (strstr(
buf,
"<import_type") != NULL) {
588 find = strstr(
buf,
"name=");
591 find = strchr(find+1,
'"');
594 end = strchr(find+1,
'"');
597 tmp[end-find-1] =
'\0';
598 strncpy(
tmp, find+1, end-find-1);
605 printf(
"%s: import %s not found\n",
type->name,
tmp);
608 if (strstr(
buf,
"<attribute") != NULL) {
609 find = strstr(
buf,
"arch");
612 find = strchr(find,
'"');
613 end = strchr(find+1,
'"');
618 tmp[end-find-1] =
'\0';
619 strncpy(
tmp, find+1, end-find-1);
622 find = strstr(
buf,
"editor");
627 find = strchr(find,
'"');
628 end = strchr(find+1,
'"');
629 tmp[end-find-1] =
'\0';
630 strncpy(
tmp, find+1, end-find-1);
634 if (strstr(
buf,
"</attribute>") == NULL && strstr(
buf,
"/>") == NULL) {
636 if (strstr(
buf,
"<![CDATA[<html>") != NULL)
639 if (strstr(
buf,
"]]>") != NULL)
642 if (strstr(
buf,
"</attribute>") != NULL)
663 printf(
"type: %s [%d]\n",
type->name,
type->number);
664 printf(
" attributes:\n");
665 for (attr = 0; attr <
type->attribute_count; attr++) {
666 printf(
" %30s: %s\n",
type->attributes[attr]->field,
type->attributes[attr]->name);
667 printf(
" %s\n",
type->attributes[attr]->description);
706 for (desc = 0; desc < attribute->
type_count; desc++) {
708 return attribute->
types[desc];
710 return attribute->
types[desc];
729 att->
type = realloc(att->
type, att->
count*
sizeof(
const char *));
749 if (strstr(
buf,
"</ignore_list>") != NULL) {
753 start = strstr(
buf,
"arch=");
756 start = strchr(start+1,
'"');
759 end = strchr(start+1,
'"');
763 tmp[end-start-1] =
'\0';
764 strncpy(
tmp, start+1, end-start-1);
768 list->fields = realloc(
list->fields,
list->count*
sizeof(
char *));
776 printf(
"ignore lists:\n");
780 printf(
" %s",
lists[
list]->fields[field]);
812 "weight_speed_ratio",
830 "price_adjustment_buy",
831 "price_adjustment_sell",
832 "casting_requirements",
834 "identified_name_pl",
836 "identified_animation",
837 "identified_anim_speed",
838 "identified_anim_random",
865 for (val = 0;
in_living[val] != NULL; val++) {
866 if (!strcmp(
in_living[val], attribute)) {
867 fprintf(
file,
"liv::%s", attribute);
872 fprintf(
file,
"page_custom_attribute_%s \"%s\"", attribute, attribute);
875 if (strstr(attribute,
"resist_")) {
876 fprintf(
file,
"obj::resist");
879 if (!strcmp(attribute,
"connected")) {
880 fprintf(
file,
"page_connected \"connection value\"");
883 fprintf(
file,
"obj::%s", attribute);
895 fprintf(
file,
"/**\n");
898 if (
type->number > 0) {
901 fprintf(
file,
"@var %s\nSee @ref page_type_%d\n*/\n\n/**\n",
type_names[req].code_name,
type->number);
907 fprintf(
file,
"@page page_type_%d %s\n\n",
type->number,
type->name);
908 fprintf(
file,
"\n@section sec_desc_%d Description\n",
type->number);
909 fprintf(
file,
"%s\n\n",
type->description);
911 fprintf(
file,
"\n\nType defined by:\n");
913 fprintf(
file,
"- @ref object::type = %d\n",
type->number);
914 for (req = 0; req <
type->require_count; req++)
915 fprintf(
file,
"- %s\n",
type->required[req]);
918 fprintf(
file,
"\n\n@section sec_attr_%d Attributes\n\n",
type->number);
919 fprintf(
file,
"<table>\n\t<tr>\n\t\t<th>Attribute</th>\n\t\t<th>Field</th>\n\t\t<th>Description</th>\n\t</tr>\n");
920 for (attr = 0; attr <
type->attribute_count; attr++) {
921 fprintf(
file,
"\t<tr>\n\t\t<td>%s</td>\n\t\t<td>@ref ",
type->attributes[attr]->name);
923 fprintf(
file,
"</td>\n\t\t<td>%s\n\t\t</td>\n\t</tr>\n",
type->attributes[attr]->description ?
type->attributes[attr]->description :
"(no description)");
926 fprintf(
file,
"</table>\n*/\n");
939 fprintf(
index,
"/**\n@page type_index Type index\n");
941 fprintf(
index,
"Types not listed here have the attributes defined in @ref page_type_0 \"this page\".\n\n");
947 fprintf(
index,
"*/\n");
960 fprintf(
index,
"/**\n@page field_index Field index\n");
962 fprintf(
index,
"This page lists all attributes.\n\n");
965 fprintf(
index,
"- @ref ");
967 fprintf(
index,
"\n");
970 fprintf(
index,
"*/\n");
986 fprintf(
file,
"/**\n@page page_custom_attribute_%s %s", attribute->
field, attribute->
field);
987 fprintf(
file,
"\nThis is a @ref page_custom_attributes \"custom attribute\".\n");
989 if (strcmp(attribute->
field,
"connected") == 0)
990 fprintf(
file,
"/**\n@page ");
992 fprintf(
file,
"/**\n@fn ");
997 if (strstr(attribute->
field,
"resist_"))
998 fprintf(
file,
"\n@section %s %s resistance\n", attribute->
field, attribute->
field+7);
1000 fprintf(
file,
"\n@section sec_%s Use\n", attribute->
field);
1002 fprintf(
file,
"<table>\n\t<tr>\n\t\t<th>Type(s)</th>\n\t\t<th>Description</th>\n\t</tr>");
1004 for (desc = 0; desc < attribute->
type_count; desc++) {
1007 fprintf(
file,
"\t<tr>\n\t\t<td>\n");
1019 fprintf(
file,
"\n*/\n");
1026 int number, attr, dummy;
1032 printf(
"Syntax: %s /path/to/Gridarta/types.xml\n", argv[0]);
1039 xml = fopen(argv[1],
"r");
1042 printf(
"Could not find file %s\n", argv[1]);
1049 if (strstr(
buf,
"<default_type>")) {
1056 if (strstr(
buf,
"<ignore_list") != NULL) {
1057 start = strstr(
buf,
"name=");
1058 start = strchr(start+1,
'"');
1059 end = strchr(start+1,
'"');
1060 tmp[end-start-1] =
'\0';
1061 strncpy(
tmp, start+1, end-start-1);
1066 start = strstr(
buf,
"<type number");
1068 start = strchr(start,
'"');
1071 end = strchr(start+1,
'"');
1074 tmp[end-start-1] =
'\0';
1075 strncpy(
tmp, start+1, end-start-1);
1079 start = strstr(end,
"name=");
1080 start = strchr(start,
'"');
1081 end = strchr(start+1,
'"');
1082 tmp[end-start-1] =
'\0';
1083 strncpy(
tmp, start+1, end-start-1);
1085 if (!strcmp(
tmp,
"Misc")) {
1101 while (
read_line(
buf, 200, xml) != NULL && strstr(
buf,
"</type>") == NULL)
1108 type->number = number;
1120 for (number = 0; number <
type_count; number++) {
1130 for (number = 0; number <
type_count; number++)
attribute_type * get_description_for_attribute(attribute_definition *attribute, const char *description)
void add_type_to_attribute(attribute_definition *attribute, type_definition *type, int attr)
attribute_definition * get_attribute(const char *name)
int is_custom_attribute(const char *attribute)
void dump_type(type_definition *type)
char * read_line(char *buffer, int size, FILE *file)
static const flag_definition flags[]
type_attribute * get_attribute_for_type(type_definition *type, const char *attribute, int clean)
static type_name type_names[]
void read_type(type_definition *type, FILE *file, const char *block_end)
void write_type_file(type_definition *type)
attribute_definition ** attributes
void add_required_parameter(type_definition *type, const char *buf)
type_attribute ** attributes
int sort_type_attribute(const void *a, const void *b)
void copy_attributes(const type_definition *source, type_definition *type)
void read_ignore_list(const char *name, FILE *file)
const flag_definition * find_flag(const char *name)
ignore_list * find_ignore_list(const char *name)
static const char * in_living[]
void free_attribute(type_attribute *attr)
void write_attribute_reference(const char *attribute, FILE *file)
type_definition * get_type_definition(void)
void ignore_attributes(type_definition *type, ignore_list *list)
void write_attribute_file(attribute_definition *attribute)
static const char * custom_attributes[]
type_definition * default_type
type_definition * fallback_type
void dump_ignore_lists(void)
const char * destination_dir
void write_type_index(void)
void copy_default_attributes(type_definition *type)
type_definition * find_type_definition(const char *name)
void write_attribute_index(void)
void ignore_attribute(type_definition *type, const char *attribute)
int main(int argc, char **argv)
type_attribute * duplicate_attribute(type_attribute *attr)