--- deliantra/server/utils/cfutil.in 2007/05/07 06:01:48 1.34 +++ deliantra/server/utils/cfutil.in 2007/07/16 19:43:33 1.40 @@ -8,7 +8,7 @@ my $DATADIR = "@datadir@/@PACKAGE@"; my $CONVERT = "@CONVERT@"; -my $IDENTIFY = "@IDENTIFY@"; +#my $IDENTIFY = "@IDENTIFY@"; my $OPTIPNG = "@OPTIPNG@"; my $RSYNC = "@RSYNC@"; my $PNGNQ = "@PNGNQ@"; @@ -45,6 +45,22 @@ my $TMPDIR = "/tmp/cfutil$$~"; my $TMPFILE = "aaaa0"; +our %COLOR = ( + black => 0, + white => 1, + navy => 2, + red => 3, + orange => 4, + blue => 5, + darkorange => 6, + green => 7, + lightgreen => 8, + grey => 9, + brown => 10, + gold => 11, + tan => 12, +); + END { system "rm", "-rf", $TMPDIR } Event->signal (signal => "INT", cb => sub { exit 1 }); @@ -78,7 +94,7 @@ exit 1 unless $FORCE; } - system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" + system $RSYNC, "-av", "--chmod=u=rwX,go=rX", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" and die "map installation failed.\n"; print "maps installed successfully.\n"; @@ -87,14 +103,16 @@ { our %ANIMINFO; our %FACEINFO; + our %RESOURCE; our @ARC; our %ARC; our $TRS; our $NFILE; + our $PATH; our $QUANTIZE = "+dither -colorspace RGB -colors 256"; - our (@png, @trs, @arc); # files we are interested in + our (@png, @trs, @arc, @res); # files we are interested in sub commit_png($$$) { my ($name, $data, $T) = @_; @@ -303,8 +321,8 @@ $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; - my $visibility = delete $o->{visibility} if exists $o->{visibility}; - my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; + $visibility = delete $o->{visibility} if exists $o->{visibility}; + $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; my $anim = delete $o->{anim}; @@ -369,6 +387,33 @@ } } + sub process_res { + while (@res) { + my ($dir, $file) = @{pop @res}; + + my $data; + aio_load "$dir/$file", $data; + + my $copyright; + aio_load "$dir/copyright", $copyright; + + $file =~ s/\.res$//; + $file =~ /\.([^.]+)$/ + or next; + + my $type = $1; + + substr $dir, 0, 1 + length $PATH, ""; + + $RESOURCE{"$dir/$file"} = { + type => $1, + copyright => $copyright, + data => $data, + chksum => Digest::MD5::md5 $data, + }; + } + } + sub find_files; sub find_files { my ($path) = @_; @@ -387,6 +432,8 @@ push @trs, [$path, $file]; } elsif ($file =~ /\.arc$/) { push @arc, [$path, $file]; + } elsif ($file =~ /\.(ogg|jpg|res)$/) { + push @res, [$path, $file]; } else { warn "ignoring $path/$file\n" if $VERBOSE >= 3; } @@ -397,6 +444,8 @@ sub inst_arch($) { my (undef, $path) = @_; + $PATH = $path; + print "\n", "Installing '$path' to '$DATADIR'\n", "\n", @@ -420,6 +469,7 @@ (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_trs), (async \&process_trs), (async \&process_arc), (async \&process_arc), + (async \&process_res), (async \&process_res), ); { @@ -483,6 +533,11 @@ $v->{chksum32} = Digest::MD5::md5 $v->{data32}; $v->{chksum64} = Digest::MD5::md5 $v->{data64}; + + if (my $magicmap = $v->{magicmap}) { + $magicmap =~ y/A-Z_\-/a-z/d; + $v->{magicmap} = $COLOR{$magicmap}; + } } open my $fh, ">:perlio", "$DATADIR/facedata~" @@ -492,6 +547,7 @@ version => 2, faceinfo => \%FACEINFO, animinfo => \%ANIMINFO, + resource => \%RESOURCE, }; }