ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/res2pm
(Generate patch)

Comparing deliantra/Deliantra/res2pm (file contents):
Revision 1.1 by root, Wed Feb 22 20:33:05 2006 UTC vs.
Revision 1.2 by root, Wed Feb 22 21:20:19 2006 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3# usage: res2pm >Crossfire/Data.pm 3# usage: res2pm
4
5open STDOUT, ">:utf8", "Crossfire/Data.pm"
6 or die "Crossfire/Data.pm: $!";
4 7
5print <<EOF; 8print <<EOF;
6=head1 NAME 9=head1 NAME
7 10
8Crossfire::Data - various data structures useful for understanding archs and objects 11Crossfire::Data - various data structures useful for understanding archs and objects
65} 68}
66 69
67sub parse_attr { 70sub parse_attr {
68 my ($e, $sect) = @_; 71 my ($e, $sect) = @_;
69 72
70 $sect->{$e->attr ("arch") || $e->attr("arch_begin")} = { 73 my $arch = {
71 name => $e->attr ("editor"), 74 name => $e->attr ("editor"),
72 type => $e->attr ("type"), 75 type => $e->attr ("type"),
73 desc => string $e, 76 desc => string $e,
74 $e->attr("arch_begin") ? (end => $e->attr("arch_end")) : (), 77 $e->attr("arch_begin") ? (end => $e->attr("arch_end")) : (),
75 }; 78 };
79
80 if ($arch->{type} =~ s/^(bitmask)_(.*)/$1/) {
81 $arch->{values} = $BITMASK{$2} ||= {};
82 }
83
84 $sect->{$e->attr ("arch") || $e->attr("arch_begin")} = $arch;
76} 85}
77 86
78sub parse_type { 87sub parse_type {
79 my ($e, $type) = @_; 88 my ($e, $type) = @_;
80 89
112 $type 121 $type
113} 122}
114 123
115for my $e (grep ref, @{$type->root->contents}) { 124for my $e (grep ref, @{$type->root->contents}) {
116 if ($e->name eq "bitmask") { 125 if ($e->name eq "bitmask") {
117 my $bm = $bitmask{$e->attr ("name")} = {}; 126 my $bm = $bitmask{$e->attr ("name")} ||= {};
118 for my $b (grep ref, @{$e->contents}) { 127 for my $b (grep ref, @{$e->contents}) {
119 $bm->{$b->attr ("bit")} = $b->attr ("name"); 128 $bm->{$b->attr ("bit")} = $b->attr ("name");
120 } 129 }
121 } elsif ($e->name eq "list") { 130 } elsif ($e->name eq "list") {
122 my $list = $list{$e->attr ("name")} = {}; 131 my $list = $list{$e->attr ("name")} ||= {};
123 for my $b (grep ref, @{$e->contents}) { 132 for my $b (grep ref, @{$e->contents}) {
124 $list->{$b->attr ("value")} = $b->attr ("name"); 133 $list->{$b->attr ("value")} = $b->attr ("name");
125 } 134 }
126 } elsif ($e->name eq "ignore_list") { 135 } elsif ($e->name eq "ignore_list") {
127 my $list = $ignore_list{$e->attr ("name")} ||= []; 136 my $list = $ignore_list{$e->attr ("name")} ||= [];
147 $type{$_->attr ("number")}{name} = $_->attr ("name"); 156 $type{$_->attr ("number")}{name} = $_->attr ("name");
148} 157}
149 158
150dump_hash "TYPE", \%type; 159dump_hash "TYPE", \%type;
151 160
152dump_hash "LIST", \%list;
153dump_hash "BITMASK", \%bitmask;
154
155my $spell = XML::Parser->new (Style => 'grove')->parsefile ("res/spells.xml") 161my $spell = XML::Parser->new (Style => 'grove')->parsefile ("res/spells.xml")
156 or die; 162 or die;
157 163
158my %spell; 164my %spell;
159 165

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines