… | |
… | |
21 | res/typenumbers.xml |
21 | res/typenumbers.xml |
22 | |
22 | |
23 | See F<res/README> for more info. |
23 | See F<res/README> for more info. |
24 | |
24 | |
25 | =cut |
25 | =cut |
|
|
26 | |
|
|
27 | package Crossfire::Data; |
26 | |
28 | |
27 | EOF |
29 | EOF |
28 | |
30 | |
29 | use Data::Dumper; |
31 | use Data::Dumper; |
30 | use XML::Parser::Grove; |
32 | use XML::Parser::Grove; |
… | |
… | |
97 | |
99 | |
98 | if ($arch->{type} =~ s/^(bitmask)_(.*)/$1/) { |
100 | if ($arch->{type} =~ s/^(bitmask)_(.*)/$1/) { |
99 | $arch->{value} = $bitmask{$2} ||= {}; |
101 | $arch->{value} = $bitmask{$2} ||= {}; |
100 | } elsif ($arch->{type} =~ s/^(list)_(.*)/$1/) { |
102 | } elsif ($arch->{type} =~ s/^(list)_(.*)/$1/) { |
101 | $arch->{value} = $list{$2} ||= {}; |
103 | $arch->{value} = $list{$2} ||= {}; |
|
|
104 | } elsif ($arch->{type} eq "fixed") { |
|
|
105 | $arch->{value} = $e->attr ("value"); |
102 | } elsif ($arch->{type} =~ s/^bool_special$/bool/) { |
106 | } elsif ($arch->{type} =~ s/^bool_special$/bool/) { |
103 | $arch->{value} = [$e->attr ("false"), $e->attr ("true")]; |
107 | $arch->{value} = [$e->attr ("false"), $e->attr ("true")]; |
104 | } |
108 | } |
105 | |
109 | |
106 | $sect->{$e->attr ("arch") || $e->attr("arch_begin")} = $arch; |
110 | push @$sect, [$e->attr ("arch") || $e->attr("arch_begin"), $arch]; |
107 | } |
111 | } |
108 | |
112 | |
109 | sub parse_type { |
113 | sub parse_type { |
110 | my ($e, $type) = @_; |
114 | my ($e, $type) = @_; |
111 | |
115 | |
|
|
116 | my %main; |
|
|
117 | |
112 | for my $e (grep ref, @{$e->contents}) { |
118 | for my $e (grep ref, @{$e->contents}) { |
113 | if ($e->name eq "required") { |
119 | if ($e->name eq "required") { |
|
|
120 | # not used |
114 | for my $i (grep ref, @{$e->contents}) { |
121 | #for my $i (grep ref, @{$e->contents}) { |
115 | $type->{required}{$i->attr ("arch")} = $i->attr ("value"); |
122 | # $type->{required}{$i->attr ("arch")} = $i->attr ("value"); |
116 | } |
123 | #} |
117 | } elsif ($e->name eq "attribute") { |
124 | } elsif ($e->name eq "attribute") { |
118 | parse_attr $e, $type->{attr}{Main} ||= {}; |
125 | parse_attr $e, $type->{attr} ||= []; |
119 | } elsif ($e->name eq "ignore") { |
126 | } elsif ($e->name eq "ignore") { |
120 | for my $i (grep ref, @{$e->contents}) { |
127 | for my $i (grep ref, @{$e->contents}) { |
121 | if ($i->name eq "ignore_list") { |
128 | if ($i->name eq "ignore_list") { |
122 | push @{$type->{ignore}}, $ignore_list{$i->attr ("name")} ||= []; |
129 | push @{$type->{ignore}}, $ignore_list{$i->attr ("name")} ||= []; |
123 | } elsif ($i->name eq "attribute") { |
130 | } elsif ($i->name eq "attribute") { |
… | |
… | |
129 | } elsif ($e->name eq "use") { |
136 | } elsif ($e->name eq "use") { |
130 | $type->{use} = string $e; |
137 | $type->{use} = string $e; |
131 | } elsif ($e->name eq "description") { |
138 | } elsif ($e->name eq "description") { |
132 | $type->{desc} = string $e; |
139 | $type->{desc} = string $e; |
133 | } elsif ($e->name eq "section") { |
140 | } elsif ($e->name eq "section") { |
|
|
141 | my @attr; |
134 | for my $i (grep ref, @{$e->contents}) { |
142 | for my $i (grep ref, @{$e->contents}) { |
135 | parse_attr $i, $type->{attr}{$e->attr ("name")} ||= {}; |
143 | parse_attr $i, \@attr; |
136 | } |
144 | } |
|
|
145 | push @{ $type->{section} }, [$e->attr ("name") => \@attr]; |
137 | } else { |
146 | } else { |
138 | warn "unknown types subelement ", $e->name; |
147 | warn "unknown types subelement ", $e->name; |
139 | } |
148 | } |
140 | } |
149 | } |
141 | |
150 | |
… | |
… | |
160 | } |
169 | } |
161 | } elsif ($e->name eq "default_type") { |
170 | } elsif ($e->name eq "default_type") { |
162 | parse_type $e, \%default_attr; |
171 | parse_type $e, \%default_attr; |
163 | } elsif ($e->name eq "type") { |
172 | } elsif ($e->name eq "type") { |
164 | my $type = $type{$e->attr ("name")} ||= {}; |
173 | my $type = $type{$e->attr ("name")} ||= {}; |
|
|
174 | |
|
|
175 | $type->{name} = $e->attr ("name"); |
|
|
176 | |
165 | parse_type $e, $type; |
177 | parse_type $e, $type; |
166 | #unshift @{$type->{import}}, \%default_attr; |
|
|
167 | |
178 | |
168 | if ($e->attr ("number") > 0) { |
179 | if ($e->attr ("number") > 0) { |
169 | $attr{$e->attr ("number")} = $type; |
180 | $attr{$e->attr ("number")} = $type; |
170 | } elsif ($e->attr ("name") eq "Misc") { |
181 | } elsif ($e->attr ("name") eq "Misc") { |
171 | delete $type->{required}; |
182 | delete $type->{required}; |
… | |
… | |
189 | |
200 | |
190 | for (grep ref, @{$spell->root->contents}) { |
201 | for (grep ref, @{$spell->root->contents}) { |
191 | $spell{$_->attr ("id")} = $_->attr ("name"); |
202 | $spell{$_->attr ("id")} = $_->attr ("name"); |
192 | } |
203 | } |
193 | |
204 | |
194 | dump_hash ["BITMASK", "LIST", "IGNORE_LIST", "DEFAULT_ATTR", "TYPE", "ATTR0", "ATTR", "TYPENAME", "SPELL"], |
205 | dump_hash ["BITMASK", "LIST", "IGNORE_LIST", "DEFAULT_ATTR", "TYPE", "ATTR", "TYPENAME", "SPELL"], |
195 | [\%bitmask, \%list, \%ignore_list, \%default_attr, \%type, \@attr0, \%attr, \%typename, \%spell]; |
206 | [\%bitmask, \%list, \%ignore_list, \%default_attr, \%type, \%attr, \%typename, \%spell]; |
196 | |
207 | |
197 | print <<EOF; |
208 | print <<EOF; |
198 | |
209 | |
199 | =head1 AUTHOR |
210 | =head1 AUTHOR |
200 | |
211 | |