--- deliantra/server/utils/cfutil.in 2007/07/26 21:44:43 1.47 +++ deliantra/server/utils/cfutil.in 2007/08/18 20:39:14 1.51 @@ -21,6 +21,7 @@ use Crossfire; use Coro; use Coro::AIO; +use Coro::Util; use POSIX (); use Digest::MD5; use Carp; @@ -172,10 +173,9 @@ my $other = "$stem.64x64.png~"; if (0 > aio_lstat $other or (-M _) > (-M $path)) { - my $wrap = 0; # for the time being fork_sub { - system "convert png:\Q$path\E -depth 8 rgba:-" - . "| $exec_prefix/bin/cfhq2xa $w $h $wrap" + system "convert -depth 8 png:\Q$path\E rgba:-" + . "| $exec_prefix/bin/cfhq2xa $w $h 0" . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" and die "convert/hq2xa pipeline error: status $? ($!)"; system $OPTIPNG, "-i0", "-q", "$other~"; @@ -396,8 +396,10 @@ unless (exists $FILECACHE{$_[0]}) { my $data; if (0 < aio_load $_[0], $data) { - $data = $_[1]->($data) - if $_[1]; + if ($_[1]) { + $data = eval { $_[1]->($data) }; + warn "$_[0]: $@" if $@; + } } $FILECACHE{$_[0]} = $data; @@ -415,16 +417,29 @@ my $meta = load_cached "$dir/meta", sub { JSON::XS::from_json shift }; - $file =~ s/\.res$//; - $file =~ s/\.(ogg|wav|jpg|png)$//; - - substr $dir, 0, 1 + length $PATH, ""; + next if $meta && !exists $meta->{$file}; $meta = { %{ $meta->{"" } || {} }, %{ $meta->{$file} || {} }, }; + if ($meta->{license} =~ s/^#//) { + $meta->{license} = ({ + "pd" => "Public Domain", + "gpl" => "GNU General Public License, version 3.0 or any later", + "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", + "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.5/", + "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", + })->{$meta->{license}} + || warn "$dir/$file: license tag '$meta->{license}' not found."; + } + + $file =~ s/\.res$//; + $file =~ s/\.(ogg|wav|jpg|png)$//; + + substr $dir, 0, 1 + length $PATH, ""; + $RESOURCE{"$dir/$file"} = { type => (delete $meta->{type}) || $type, data => $data,