--- deliantra/Deliantra/res2pm 2006/02/22 20:33:05 1.1 +++ deliantra/Deliantra/res2pm 2006/02/22 21:20:19 1.2 @@ -1,6 +1,9 @@ #!/opt/bin/perl -# usage: res2pm >Crossfire/Data.pm +# usage: res2pm + +open STDOUT, ">:utf8", "Crossfire/Data.pm" + or die "Crossfire/Data.pm: $!"; print <{$e->attr ("arch") || $e->attr("arch_begin")} = { + my $arch = { name => $e->attr ("editor"), type => $e->attr ("type"), desc => string $e, $e->attr("arch_begin") ? (end => $e->attr("arch_end")) : (), }; + + if ($arch->{type} =~ s/^(bitmask)_(.*)/$1/) { + $arch->{values} = $BITMASK{$2} ||= {}; + } + + $sect->{$e->attr ("arch") || $e->attr("arch_begin")} = $arch; } sub parse_type { @@ -114,12 +123,12 @@ for my $e (grep ref, @{$type->root->contents}) { if ($e->name eq "bitmask") { - my $bm = $bitmask{$e->attr ("name")} = {}; + my $bm = $bitmask{$e->attr ("name")} ||= {}; for my $b (grep ref, @{$e->contents}) { $bm->{$b->attr ("bit")} = $b->attr ("name"); } } elsif ($e->name eq "list") { - my $list = $list{$e->attr ("name")} = {}; + my $list = $list{$e->attr ("name")} ||= {}; for my $b (grep ref, @{$e->contents}) { $list->{$b->attr ("value")} = $b->attr ("name"); } @@ -149,9 +158,6 @@ dump_hash "TYPE", \%type; -dump_hash "LIST", \%list; -dump_hash "BITMASK", \%bitmask; - my $spell = XML::Parser->new (Style => 'grove')->parsefile ("res/spells.xml") or die;