ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.113 by root, Sat Apr 23 04:56:58 2011 UTC vs.
Revision 1.114 by root, Sat May 14 17:13:38 2011 UTC

116 116
117# here we could try to avoid collisions and reduce chksum size further 117# here we could try to avoid collisions and reduce chksum size further
118sub make_hash($\$\$;$) { 118sub make_hash($\$\$;$) {
119 my ($id, $dataref, $hashref, $clen) = @_; 119 my ($id, $dataref, $hashref, $clen) = @_;
120 120
121 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4; 121 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 5;
122 122
123 if (exists $hash{$hash}) { 123 if (exists $hash{$hash}) {
124 # hash collision, but some files are simply identical 124 # hash collision, but some files are simply identical
125 if (${$hash{$hash}[1]} ne $$dataref) { 125 if (${$hash{$hash}[1]} ne $$dataref) {
126 warn "hash collision $hash{$hash}[0] vs. $id\n"; 126 warn "hash collision $hash{$hash}[0] vs. $id\n";
130 } 130 }
131 } 131 }
132 $hash{$hash} = [$id, $dataref, $hashref]; 132 $hash{$hash} = [$id, $dataref, $hashref];
133 133
134 $$hashref = $hash; 134 $$hashref = $hash;
135}
136
137sub optipng($) {
138 system $OPTIPNG, "-i0", "-q", $_[0];
139 die "$_[0] has zero size, aborting." unless -s $_[0];
135} 140}
136 141
137mkdir $TMPDIR, 0700 142mkdir $TMPDIR, 0700
138 or die "$TMPDIR: $!"; 143 or die "$TMPDIR: $!";
139 144
345 350
346 system "convert -depth 8 $SRC rgba:-" 351 system "convert -depth 8 $SRC rgba:-"
347 . "| $exec_prefix/bin/cfhq2xa $w $h 0" 352 . "| $exec_prefix/bin/cfhq2xa $w $h 0"
348 . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $CROP $QUANTIZE -quality 00 png32:\Q$other\E~" 353 . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $CROP $QUANTIZE -quality 00 png32:\Q$other\E~"
349 and die "convert/cfhq2xa pipeline error: status $? ($!)"; 354 and die "convert/cfhq2xa pipeline error: status $? ($!)";
350 system $OPTIPNG, "-i0", "-q", "$other~"; 355 optipng "$other~";
351 die "$other~ has zero size, aborting." unless -s "$other~";
352 rename "$other~", $other; 356 rename "$other~", $other;
353 }; 357 };
354 }; 358 };
355 359
356 push @c_png, [$other, !$CACHE]; 360 push @c_png, [$other, !$CACHE];
856 if (!-d "$path/treasures") { 860 if (!-d "$path/treasures") {
857 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; 861 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n";
858 exit 1 unless $FORCE; 862 exit 1 unless $FORCE;
859 } 863 }
860 864
861 print "start file scan, arc, any processing...\n" if $VERBOSE; 865 print "starting file scan, arc, any processing...\n" if $VERBOSE;
862 866
863 my @a_arc = map +(async \&process_arc), 1..2; 867 my @a_arc = map +(async \&process_arc), 1..2;
864 my @a_any = map +(async \&process_any), 1..4; 868 my @a_any = map +(async \&process_any), 1..4;
865 869
866 find_files $path; 870 find_files $path;
867 871
868 $c_arc->shutdown; 872 $c_arc->shutdown;
869 $c_any->shutdown; 873 $c_any->shutdown;
870 874
871 $_->join for @a_arc; # need to parse all archetypes before png processing 875 $_->join for @a_arc; # need to parse all archetypes before png processing
876 print "ended arc processing...\n" if $VERBOSE;
872 877
873 print "end arc, start png processing...\n" if $VERBOSE; 878 print "starting png processing...\n" if $VERBOSE;
874 879
875 # eight png crunchers work fine for my 4x smp machine 880 # eight png crunchers work fine for my 4x smp machine
876 my @a_png = map +(async \&process_png), 1..8; 881 my @a_png = map +(async \&process_png), 1..8;
877 882
878 print "end any processing...\n" if $VERBOSE;
879 $_->join for @a_any; 883 $_->join for @a_any;
880
881 print "end png processing...\n" if $VERBOSE; 884 print "ended any processing...\n" if $VERBOSE;
885
882 $_->join for @a_png; 886 $_->join for @a_png;
887 print "ended png processing...\n" if $VERBOSE;
883 888
884 print "scanning done, processing results...\n" if $VERBOSE; 889 print "scanning done, processing results...\n" if $VERBOSE;
885 { 890 {
886 # remove path prefix from editor_folder 891 # remove path prefix from editor_folder
887 $_->{editor_folder} =~ /^\x00/ 892 $_->{editor_folder} =~ /^\x00/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines