101 {
"alive",
"FLAG_ALIVE" },
102 {
"wiz",
"FLAG_WIZ" },
103 {
"was_wiz",
"FLAG_WAS_WIZ" },
104 {
"applied",
"FLAG_APPLIED" },
105 {
"unpaid",
"FLAG_UNPAID" },
106 {
"can_use_shield",
"FLAG_USE_SHIELD" },
107 {
"no_pick",
"FLAG_NO_PICK" },
108 {
"client_anim_sync",
"FLAG_CLIENT_ANIM_SYNC" },
109 {
"client_anim_random",
"FLAG_CLIENT_ANIM_RANDOM" },
110 {
"is_animated",
"FLAG_ANIMATE" },
111 {
"monster",
"FLAG_MONSTER" },
112 {
"friendly",
"FLAG_FRIENDLY" },
113 {
"generator",
"FLAG_GENERATOR" },
114 {
"is_thrown",
"FLAG_IS_THROWN" },
115 {
"auto_apply",
"FLAG_AUTO_APPLY" },
116 {
"treasure",
"FLAG_TREASURE" },
117 {
"player sold",
"FLAG_PLAYER_SOLD" },
118 {
"see_invisible",
"FLAG_SEE_INVISIBLE" },
119 {
"can_roll",
"FLAG_CAN_ROLL" },
120 {
"overlay_floor",
"FLAG_OVERLAY_FLOOR" },
121 {
"is_turnable",
"FLAG_IS_TURNABLE" },
122 {
"is_used_up",
"FLAG_IS_USED_UP" },
123 {
"identified",
"FLAG_IDENTIFIED" },
124 {
"reflecting",
"FLAG_REFLECTING" },
125 {
"changing",
"FLAG_CHANGING" },
126 {
"splitting",
"FLAG_SPLITTING" },
127 {
"hitback",
"FLAG_HITBACK" },
128 {
"startequip",
"FLAG_STARTEQUIP" },
129 {
"blocksview",
"FLAG_BLOCKSVIEW" },
130 {
"undead",
"FLAG_UNDEAD" },
131 {
"scared",
"FLAG_SCARED" },
132 {
"unaggressive",
"FLAG_UNAGGRESSIVE" },
133 {
"reflect_missile",
"FLAG_REFL_MISSILE" },
134 {
"reflect_spell",
"FLAG_REFL_SPELL" },
135 {
"no_magic",
"FLAG_NO_MAGIC" },
136 {
"no_fix_player",
"FLAG_NO_FIX_PLAYER" },
137 {
"is_lightable",
"FLAG_IS_LIGHTABLE" },
138 {
"tear_down",
"FLAG_TEAR_DOWN" },
139 {
"run_away",
"FLAG_RUN_AWAY" },
140 {
"unique",
"FLAG_UNIQUE" },
141 {
"no_drop",
"FLAG_NO_DROP" },
142 {
"can_cast_spell",
"FLAG_CAST_SPELL" },
143 {
"can_use_scroll",
"FLAG_USE_SCROLL" },
144 {
"can_use_range",
"FLAG_USE_RANGE" },
145 {
"can_use_bow",
"FLAG_USE_BOW" },
146 {
"can_use_armour",
"FLAG_USE_ARMOUR" },
147 {
"can_use_weapon",
"FLAG_USE_WEAPON" },
148 {
"can_use_ring",
"FLAG_USE_RING" },
149 {
"has_ready_range",
"FLAG_READY_RANGE" },
150 {
"has_ready_bow",
"FLAG_READY_BOW" },
151 {
"xrays",
"FLAG_XRAYS" },
152 {
"is_floor",
"FLAG_IS_FLOOR" },
153 {
"lifesave",
"FLAG_LIFESAVE" },
154 {
"no_strength",
"FLAG_NO_STRENGTH" },
155 {
"sleep",
"FLAG_SLEEP" },
156 {
"stand_still",
"FLAG_STAND_STILL" },
157 {
"random_movement",
"FLAG_RANDOM_MOVE" },
158 {
"only_attack",
"FLAG_ONLY_ATTACK" },
159 {
"confused",
"FLAG_CONFUSED" },
160 {
"stealth",
"FLAG_STEALTH" },
161 {
"cursed",
"FLAG_CURSED" },
162 {
"damned",
"FLAG_DAMNED" },
163 {
"see_anywhere",
"FLAG_SEE_ANYWHERE" },
164 {
"known_magical",
"FLAG_KNOWN_MAGICAL" },
165 {
"known_cursed",
"FLAG_KNOWN_CURSED" },
166 {
"can_use_skill",
"FLAG_CAN_USE_SKILL" },
167 {
"been_applied",
"FLAG_BEEN_APPLIED" },
168 {
"has_ready_scroll",
"FLAG_READY_SCROLL" },
169 {
"can_use_rod",
"FLAG_USE_ROD" },
170 {
"can_use_horn",
"FLAG_USE_HORN" },
171 {
"make_invisible",
"FLAG_MAKE_INVIS" },
172 {
"inv_locked",
"FLAG_INV_LOCKED" },
173 {
"is_wooded",
"FLAG_IS_WOODED" },
174 {
"is_hilly",
"FLAG_IS_HILLY" },
175 {
"has_ready_skill",
"FLAG_READY_SKILL" },
176 {
"has_ready_weapon",
"FLAG_READY_WEAPON" },
177 {
"no_skill_ident",
"FLAG_NO_SKILL_IDENT" },
178 {
"is_blind",
"FLAG_BLIND" },
179 {
"can_see_in_dark",
"FLAG_SEE_IN_DARK" },
180 {
"is_cauldron",
"FLAG_IS_CAULDRON" },
181 {
"no_steal",
"FLAG_NO_STEAL" },
182 {
"one_hit",
"FLAG_ONE_HIT" },
183 {
"berserk",
"FLAG_BERSERK" },
184 {
"neutral",
"FLAG_NEUTRAL" },
185 {
"no_attack",
"FLAG_NO_ATTACK" },
186 {
"no_damage",
"FLAG_NO_DAMAGE" },
187 {
"activate_on_push",
"FLAG_ACTIVATE_ON_PUSH" },
188 {
"activate_on_release",
"FLAG_ACTIVATE_ON_RELEASE" },
189 {
"is_water",
"FLAG_IS_WATER" },
190 {
"use_content_on_gen",
"FLAG_CONTENT_ON_GEN" },
191 {
"is_buildable",
"FLAG_IS_BUILDABLE" },
192 {
"blessed",
"FLAG_BLESSED" },
193 {
"known_blessed",
"FLAG_KNOWN_BLESSED" },
201 for (flag = 0; flags[flag].
field; flag++)
202 if (!strcmp(flags[flag].field, name))
363 ret->
field = strdup(attribute);
417 if (!strcmp(types[type]->name, name))
420 printf(
"type not found: %s\n", name);
429 return strcmp((*la)->name, (*lb)->name);
436 if (strcmp(lists[list]->name, name) == 0)
446 return fgets(buffer, 200, file);
470 printf(
"empty ignore list?\n");
474 for (attr = 0; attr < list->
count; attr++) {
481 char *sn, *en, *sv, *ev;
482 char value[200], name[200], temp[200];
485 if (type == fallback_type)
489 sn = strstr(buf,
"arch");
492 sn = strchr(sn,
'"');
493 en = strchr(sn+1,
'"');
494 sv = strstr(buf,
"value");
495 sv = strchr(sv,
'"');
496 ev = strchr(sv+1,
'"');
498 name[en-sn-1] =
'\0';
499 strncpy(name, sn+1, en-sn-1);
500 value[ev-sv-1] =
'\0';
501 strncpy(value, sv+1, ev-sv-1);
508 snprintf(temp, 200,
"@ref %s %s", flag->
code_name, strcmp(value,
"0") ?
"set" :
"unset");
510 snprintf(temp, 200,
"@ref object::%s = %s", name, value);
516 char buf[200], tmp[200];
521 if (strstr(buf, block_end) != NULL) {
526 if (strstr(buf,
"<description>") != NULL) {
528 if (strstr(buf,
"</description>") != NULL)
546 if (strstr(buf,
"<ignore_list") != NULL) {
547 find = strstr(buf,
"name=");
550 find = strchr(find+1,
'"');
553 end = strchr(find+1,
'"');
556 tmp[end-find-1] =
'\0';
557 strncpy(tmp, find+1, end-find-1);
561 if (strstr(buf,
"<ignore>") != NULL) {
563 if (strstr(buf,
"</ignore>") != NULL)
565 find = strstr(buf,
"arch=");
568 find = strchr(find+1,
'"');
571 end = strchr(find+1,
'"');
574 tmp[end-find-1] =
'\0';
575 strncpy(tmp, find+1, end-find-1);
580 if (strstr(buf,
"<required>") != NULL) {
582 if (strstr(buf,
"</required>") != NULL)
588 if (strstr(buf,
"<import_type") != NULL) {
591 find = strstr(buf,
"name=");
594 find = strchr(find+1,
'"');
597 end = strchr(find+1,
'"');
600 tmp[end-find-1] =
'\0';
601 strncpy(tmp, find+1, end-find-1);
608 printf(
"%s: import %s not found\n", type->
name, tmp);
611 if (strstr(buf,
"<attribute") != NULL) {
612 if (strstr(buf,
"/>") != NULL)
614 find = strstr(buf,
"arch");
617 find = strchr(find,
'"');
618 end = strchr(find+1,
'"');
623 tmp[end-find-1] =
'\0';
624 strncpy(tmp, find+1, end-find-1);
629 find = strstr(buf,
"editor");
630 find = strchr(find,
'"');
631 end = strchr(find+1,
'"');
632 tmp[end-find-1] =
'\0';
633 strncpy(tmp, find+1, end-find-1);
634 attr->
name = strdup(tmp);
637 if (strstr(buf,
"</attribute>") != NULL)
657 printf(
"type: %s [%d]\n", type->
name, type->
number);
658 printf(
" attributes:\n");
681 if (!strcmp(attributes[attr]->field, name))
682 return attributes[attr];
688 attributes[attribute_count-1] = ret;
690 ret->
field = strdup(name);
700 for (desc = 0; desc < attribute->
type_count; desc++) {
702 return attribute->
types[desc];
704 return attribute->
types[desc];
723 att->
type = realloc(att->
type, att->
count*
sizeof(
const char *));
731 char buf[200], tmp[200];
740 list->
name = strdup(name);
743 if (strstr(buf,
"</ignore_list>") != NULL) {
747 start = strstr(buf,
"arch=");
750 start = strchr(start+1,
'"');
753 end = strchr(start+1,
'"');
757 tmp[end-start-1] =
'\0';
758 strncpy(tmp, start+1, end-start-1);
770 printf(
"ignore lists:\n");
772 printf(
" %s:", lists[list]->name);
773 for (field = 0; field < lists[list]->
count; field++)
774 printf(
" %s", lists[list]->fields[field]);
806 "weight_speed_ratio",
834 for (val = 0;
in_living[val] != NULL; val++) {
835 if (!strcmp(
in_living[val], attribute)) {
836 fprintf(file,
"liv::%s", attribute);
841 fprintf(file,
"page_custom_attributes \"%s\"", attribute);
844 if (strstr(attribute,
"resist_")) {
845 fprintf(file,
"obj::resist");
848 if (!strcmp(attribute,
"connected")) {
849 fprintf(file,
"page_connected \"connection value\"");
852 fprintf(file,
"obj::%s", attribute);
862 file = fopen(buf,
"w+");
864 fprintf(file,
"/**\n");
868 for (req = 0; type_names[req].
code_name != NULL; req++) {
869 if (type_names[req].value == type->
number) {
870 fprintf(file,
"@var %s\nSee @ref page_type_%d\n*/\n\n/**\n", type_names[req].qcode_name, type->
number);
876 fprintf(file,
"@page page_type_%d %s\n\n", type->
number, type->
name);
877 fprintf(file,
"\n@section Description\n");
879 if (type != fallback_type) {
880 fprintf(file,
"\n\nType defined by:\n");
882 fprintf(file,
"- @ref object::type = %d\n", type->
number);
884 fprintf(file,
"- %s\n", type->
required[req]);
887 fprintf(file,
"\n\n@section Attributes\n\n");
888 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");
890 fprintf(file,
"\t<tr>\n\t\t<td>%s</td>\n\t\t<td>@ref ", type->
attributes[attr]->
name);
895 fprintf(file,
"</table>\n*/\n");
907 index = fopen(buf,
"w+");
908 fprintf(index,
"/**\n@page type_index Type index\n");
910 fprintf(index,
"Types not listed here have the attributes defined in @ref page_type_0 \"this page\".\n\n");
913 fprintf(index,
"-@ref page_type_%d \"%s\"\n", types[type]->number, types[type]->name);
916 fprintf(index,
"*/\n");
929 file = fopen(buf,
"w+");
931 fprintf(file,
"/**\n@fn ");
935 if (strstr(attribute->
field,
"resist_"))
936 fprintf(file,
"\n@section %s %s resistance\n", attribute->
field, attribute->
field+7);
938 fprintf(file,
"\n@section Use\n");
940 fprintf(file,
"<table>\n\t<tr>\n\t\t<th>Type(s)</th>\n\t\t<th>Description</th>\n\t</tr>");
942 for (desc = 0; desc < attribute->
type_count; desc++) {
945 fprintf(file,
"\t<tr>\n\t\t<td>\n");
947 for (type = 0; type < attribute->
types[desc]->
count; type++) {
948 if (type < attribute->types[desc]->count-1)
952 fprintf(file,
"@ref page_type_%d%s", attribute->
types[desc]->
number[type], end);
957 fprintf(file,
"\n*/\n");
962 int main(
int argc,
char **argv) {
964 int number, attr, dummy;
965 char buf[200], tmp[200];
970 printf(
"Syntax: %s /path/to/Gridarta/types.xml\n", argv[0]);
977 xml = fopen(argv[1],
"r");
978 while (
read_line(buf, 200, xml) != NULL) {
981 if (strstr(buf,
"<default_type>")) {
983 default_type->
name = strdup(
"(default type)");
984 read_type(default_type, xml,
"</default_type>");
988 if (strstr(buf,
"<ignore_list") != NULL) {
989 start = strstr(buf,
"name=");
990 start = strchr(start+1,
'"');
991 end = strchr(start+1,
'"');
992 tmp[end-start-1] =
'\0';
993 strncpy(tmp, start+1, end-start-1);
998 start = strstr(buf,
"<type number");
1000 start = strchr(start,
'"');
1003 end = strchr(start+1,
'"');
1006 tmp[end-start-1] =
'\0';
1007 strncpy(tmp, start+1, end-start-1);
1011 start = strstr(end,
"name=");
1012 start = strchr(start,
'"');
1013 end = strchr(start+1,
'"');
1014 tmp[end-start-1] =
'\0';
1015 strncpy(tmp, start+1, end-start-1);
1017 if (!strcmp(tmp,
"Misc")) {
1033 while (
read_line(buf, 200, xml) != NULL && strstr(buf,
"</type>") == NULL)
1043 type->
name = strdup(tmp);
1051 fallback_type->
description = strdup(
"This type regroups all types who don't have a specific definition.");
1053 for (number = 0; number <
type_count; number++) {
1063 for (number = 0; number <
type_count; number++)
int is_custom_attribute(const char *attribute)
void free_attribute(type_attribute *attr)
void copy_attributes(const type_definition *source, type_definition *type)
type_attribute * get_attribute_for_type(type_definition *type, const char *attribute, int clean)
void read_type(type_definition *type, FILE *file, const char *block_end)
ignore_list * find_ignore_list(const char *name)
void write_attribute_reference(const char *attribute, FILE *file)
attribute_definition * get_attribute(const char *name)
type_attribute * duplicate_attribute(type_attribute *attr)
const flag_definition * find_flag(const char *name)
type_definition * default_type
void read_ignore_list(const char *name, FILE *file)
void add_required_parameter(type_definition *type, const char *buf)
const char * destination_dir
void write_type_index(void)
char * read_line(char *buffer, int size, FILE *file)
int main(int argc, char **argv)
void write_attribute_file(attribute_definition *attribute)
type_attribute ** attributes
void write_type_file(type_definition *type)
static type_name type_names[]
static const char * in_living[]
void ignore_attributes(type_definition *type, ignore_list *list)
static const flag_definition flags[]
void ignore_attribute(type_definition *type, const char *attribute)
int sort_type_attribute(const void *a, const void *b)
int snprintf(char *dest, int max, const char *format,...)
attribute_definition ** attributes
type_definition * get_type_definition(void)
void add_type_to_attribute(attribute_definition *attribute, type_definition *type, int attr)
type_definition * fallback_type
void dump_type(type_definition *type)
void dump_ignore_lists(void)
static const char * custom_attributes[]
type_definition * find_type_definition(const char *name)
attribute_type * get_description_for_attribute(attribute_definition *attribute, const char *description)
void copy_default_attributes(type_definition *type)