--- deliantra/server/utils/cfutil.in 2007/12/17 08:03:22 1.63 +++ deliantra/server/utils/cfutil.in 2008/12/05 00:52:44 1.70 @@ -14,14 +14,14 @@ my $PNGNQ = "@PNGNQ@"; use Getopt::Long; -use Coro::Event; +use Coro::EV; use AnyEvent; -use YAML::Syck (); +use YAML (); use JSON::XS (); use IO::AIO (); use File::Temp; -use Crossfire; -use Coro; +use Deliantra; +use Coro 5.12; use Coro::AIO; use Coro::Util; use POSIX (); @@ -69,8 +69,8 @@ END { system "rm", "-rf", $TMPDIR } -Event->signal (signal => "INT", cb => sub { exit 1 }); -Event->signal (signal => "TERM", cb => sub { exit 1 }); +my $s_INT = EV::signal INT => sub { exit 1 }; +my $s_TERM = EV::signal TERM => sub { exit 1 }; mkdir $TMPDIR, 0700 or die "$TMPDIR: $!"; @@ -509,6 +509,7 @@ # a meta file for resources is now mandatory unless (exists $meta->{$file}) { warn "skipping $dir/$file\n" if $VERBOSE >= 3; + next; } $meta = { @@ -534,7 +535,12 @@ if (my $filter = $meta->{cfutil_filter}) { if ($filter eq "yaml2json") { - $data = JSON::XS::encode_json YAML::Syck::Load $data; + $data = JSON::XS::encode_json YAML::Load $data; + } elsif ($filter eq "json2json") { + $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); + } elsif ($filter eq "perl2json") { + $data = eval $data; die if $@; + $data = JSON::XS::encode_json $data; } else { warn "$dir/$file: unknown filter $filter, skipping\n"; } @@ -575,7 +581,7 @@ if ($file =~ /\.(jpg|png)$/) { $c_res->put ([$path, $file, 0]) # FT_FACE } elsif ($file =~ /\.(res)$/) { - $c_res->put ([$path, $file, 7]) # FT_RSRC + $c_res->put ([$path, $file, 6]) # FT_RSRC } else { $c_res->put ([$path, $file, undef]); } @@ -626,9 +632,9 @@ IO::AIO::flush; - $c_res->put (undef) for @a_res; - $c_arc->put (undef) for @a_arc; - $c_trs->put (undef) for @a_trs; + $c_res->shutdown; + $c_arc->shutdown; + $c_trs->shutdown; print "start file scan, arc, res processing...\n" if $VERBOSE; @@ -636,8 +642,8 @@ print "end arc, start png processing...\n" if $VERBOSE; - # four png crunchers work fine for my 2x smp machine - my @a_png = map +(async \&process_png), 1..4; + # eight png crunchers work fine for my 4x smp machine + my @a_png = map +(async \&process_png), 1..8; $_->join for (@a_trs, @a_res, @a_png); @@ -686,7 +692,7 @@ print "writing archetypes...\n" if $VERBOSE; open my $fh, ">:utf8", "$DATADIR/archetypes~" or die "$DATADIR/archetypes~: $!"; - print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; + print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; } {