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.21 by root, Thu Apr 5 12:34:31 2007 UTC vs.
Revision 1.24 by root, Thu Apr 12 14:18:06 2007 UTC

82 82
83 print "maps installed successfully.\n"; 83 print "maps installed successfully.\n";
84} 84}
85 85
86{ 86{
87 our %ANIMINFO;
87 our %FACEINFO; 88 our %FACEINFO;
88 our @ARC; 89 our @ARC;
89 our $TRS; 90 our $TRS;
90 our $NFILE; 91 our $NFILE;
91 our %ANIM;
92 92
93 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 93 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
94 94
95 our (@png, @trs, @arc); # files we are interested in 95 our (@png, @trs, @arc); # files we are interested in
96 96
147 # possibly enlarge 147 # possibly enlarge
148 if (0 > aio_stat "$stem.64x64.png") { 148 if (0 > aio_stat "$stem.64x64.png") {
149 my $other = "$stem.64x64.png~"; 149 my $other = "$stem.64x64.png~";
150 150
151 if (0 > aio_lstat $other or (-M _) > (-M $path)) { 151 if (0 > aio_lstat $other or (-M _) > (-M $path)) {
152 warn "rescale $other\n";#d#
153 my $wrap = 0; # for the time being 152 my $wrap = 0; # for the time being
154 fork_sub { 153 fork_sub {
155 system "convert png:\Q$path\E -depth 8 rgba:-" 154 system "convert png:\Q$path\E -depth 8 rgba:-"
156 . "| $exec_prefix/bin/cfhq2xa $w $h $wrap" 155 . "| $exec_prefix/bin/cfhq2xa $w $h $wrap"
157 . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" 156 . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~"
183 } 182 }
184 } 183 }
185 184
186 (my $face = $stem) =~ s/^.*\///; 185 (my $face = $stem) =~ s/^.*\///;
187 186
187 # split all bigfaces, but avoid smoothfaces (*_S)
188 if (($w > $T || $h > $T) && $face !~ /_S\./) { 188 if (($w > $T || $h > $T) && $face !~ /_S\./) {
189 # split 189 # split
190 my @tile; 190 my @tile;
191 for my $x (0 .. (int $w / $T) - 1) { 191 for my $x (0 .. (int $w / $T) - 1) {
192 for my $y (0 .. (int $h / $T) - 1) { 192 for my $y (0 .. (int $h / $T) - 1) {
284 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 284 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
285 285
286 my $anim = delete $o->{anim}; 286 my $anim = delete $o->{anim};
287 287
288 if ($anim) { 288 if ($anim) {
289 # possibly add $ext to the animation name to avoid
290 # the need to specify archnames for all parts
291 # of a multipart archetype.
289 $o->{animation} = "$o->{_name}"; 292 $o->{animation} = "$o->{_name}";
293 my $facings = 1;
294 my @frames;
290 295
291 for (@$anim) { 296 for (@$anim) {
292 $_ .= $ext unless /^facings\s|^blank.x11$|^empty.x11$/; 297 if (/^facings\s+(\d+)/) {
298 $facings = $1*1;
299 } elsif (/^blank.x11$|^empty.x11$/) {
300 push @frames, $_;
301 } else {
302 push @frames, "$_$ext";
303 }
293 } 304 }
294 305
295 $ANIM{"$o->{_name}$ext"} = 306 $ANIMINFO{$o->{animation}} = {
296 join "", map "$_\n", 307 facings => $facings,
297 "anim $o->{_name}", 308 frames => \@frames,
298 @$anim, 309 };
299 "mina";
300 } 310 }
301 311
302 for my $face ($o->{face} || (), @{$anim || []}) { 312 for my $face ($o->{face} || (), @{$anim || []}) {
303 next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/; 313 next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/;
304 314
307 $info->{visibility} = $visibility if defined $visibility; 317 $info->{visibility} = $visibility if defined $visibility;
308 $info->{magicmap} = $magicmap if defined $magicmap; 318 $info->{magicmap} = $magicmap if defined $magicmap;
309 } 319 }
310 320
311 if (my $smooth = delete $o->{smoothface}) { 321 if (my $smooth = delete $o->{smoothface}) {
312 my ($face, $smooth) = split /\s+/, $smooth; 322 my %kv =split /\s+/, $smooth;
313 # skip empty_S.x11, it seems to server no purpose whatsoever 323 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
314 # but increases bandwidth demands and worse. 324 while (my ($face, $smooth) = each %kv) {
315 unless ($smooth eq "empty_S.x11") {
316 $FACEINFO{$face}{smooth} = $smooth; 325 $FACEINFO{$face}{smooth} = $smooth;
326 $FACEINFO{$face}{smoothlevel} = $level;
317 } 327 }
318 } 328 }
319 } 329 }
320 } 330 }
321 } 331 }
382 (async \&process_trs), (async \&process_trs), 392 (async \&process_trs), (async \&process_trs),
383 (async \&process_arc), (async \&process_arc), 393 (async \&process_arc), (async \&process_arc),
384 ); 394 );
385 395
386 { 396 {
387 open my $fh, ">:utf8", "$DATADIR/animations~"
388 or die "$DATADIR/animations~: $!";
389 print $fh join "", map $ANIM{$_}, sort keys %ANIM
390 }
391
392 {
393 open my $fh, ">:utf8", "$DATADIR/archetypes~" 397 open my $fh, ">:utf8", "$DATADIR/archetypes~"
394 or die "$DATADIR/archetypes~: $!"; 398 or die "$DATADIR/archetypes~: $!";
395 substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; 399 substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC;
396 print $fh Crossfire::archlist_to_string \@ARC; 400 print $fh Crossfire::archlist_to_string \@ARC;
397 } 401 }
415 } 419 }
416 420
417 open my $fh, ">:perlio", "$DATADIR/facedata~" 421 open my $fh, ">:perlio", "$DATADIR/facedata~"
418 or die "$DATADIR/facedata~: $!"; 422 or die "$DATADIR/facedata~: $!";
419 423
420 $FACEINFO{""} = { version => 1};
421 print $fh Storable::nfreeze \%FACEINFO; 424 print $fh Storable::nfreeze {
425 version => 2,
426 faceinfo => \%FACEINFO,
427 animinfo => \%ANIMINFO,
422 } 428 };
429 }
423 430
424 for (qw(archetypes facedata animations treasures)) { 431 for (qw(archetypes facedata treasures)) {
425 chmod 0644, "$DATADIR/$_~"; 432 chmod 0644, "$DATADIR/$_~";
426 rename "$DATADIR/$_~", "$DATADIR/$_" 433 rename "$DATADIR/$_~", "$DATADIR/$_"
427 or die "$DATADIR/$_: $!"; 434 or die "$DATADIR/$_: $!";
428 } 435 }
429 436

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines