--- deliantra/server/utils/cfutil.in 2007/04/01 00:36:35 1.19 +++ deliantra/server/utils/cfutil.in 2007/04/13 05:08:51 1.25 @@ -22,7 +22,7 @@ use Coro::AIO; use POSIX (); use Digest::MD5; -use Storable; $Storable::canonical = 1; +use Coro::Storable; $Storable::canonical = 1; sub usage { warn < aio_lstat $other or (-M _) > (-M $path)) { - warn "rescale $other\n";#d# my $wrap = 0; # for the time being fork_sub { system "convert png:\Q$path\E -depth 8 rgba:-" @@ -178,14 +177,14 @@ }; } - warn "scaled down $path to $other\n";#d# - + #warn "scaled down $path to $other\n";#d# push @png, [$other, !$CACHE]; } } (my $face = $stem) =~ s/^.*\///; + # split all bigfaces, but avoid smoothfaces (*_S) if (($w > $T || $h > $T) && $face !~ /_S\./) { # split my @tile; @@ -287,17 +286,27 @@ my $anim = delete $o->{anim}; if ($anim) { + # possibly add $ext to the animation name to avoid + # the need to specify archnames for all parts + # of a multipart archetype. $o->{animation} = "$o->{_name}"; + my $facings = 1; + my @frames; for (@$anim) { - $_ .= $ext unless /^facings\s|^blank.x11$|^empty.x11$/; + if (/^facings\s+(\d+)/) { + $facings = $1*1; + } elsif (/^blank.x11$|^empty.x11$/) { + push @frames, $_; + } else { + push @frames, "$_$ext"; + } } - $ANIM{"$o->{_name}$ext"} = - join "", map "$_\n", - "anim $o->{_name}", - @$anim, - "mina"; + $ANIMINFO{$o->{animation}} = { + facings => $facings, + frames => \@frames, + }; } for my $face ($o->{face} || (), @{$anim || []}) { @@ -310,11 +319,11 @@ } if (my $smooth = delete $o->{smoothface}) { - my ($face, $smooth) = split /\s+/, $smooth; - # skip empty_S.x11, it seems to server no purpose whatsoever - # but increases bandwidth demands and worse. - unless ($smooth eq "empty_S.x11") { - $FACEINFO{$face}{smooth} = $smooth; + my %kv =split /\s+/, $smooth; + my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support + while (my ($face, $smooth) = each %kv) { + $FACEINFO{$face}{smooth} = $smooth; + $FACEINFO{$face}{smoothlevel} = $level; } } } @@ -385,12 +394,6 @@ ); { - open my $fh, ">:utf8", "$DATADIR/animations~" - or die "$DATADIR/animations~: $!"; - print $fh join "", map $ANIM{$_}, sort keys %ANIM - } - - { open my $fh, ">:utf8", "$DATADIR/archetypes~" or die "$DATADIR/archetypes~: $!"; substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; @@ -408,6 +411,9 @@ length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; + length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; + #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; + $v->{chksum32} = Digest::MD5::md5 $v->{data32}; $v->{chksum64} = Digest::MD5::md5 $v->{data64}; } @@ -415,11 +421,14 @@ open my $fh, ">:perlio", "$DATADIR/facedata~" or die "$DATADIR/facedata~: $!"; - $FACEINFO{""} = { version => 1}; - print $fh Storable::nfreeze \%FACEINFO; + print $fh freeze { + version => 2, + faceinfo => \%FACEINFO, + animinfo => \%ANIMINFO, + }; } - for (qw(archetypes facedata animations treasures)) { + for (qw(archetypes facedata treasures)) { chmod 0644, "$DATADIR/$_~"; rename "$DATADIR/$_~", "$DATADIR/$_" or die "$DATADIR/$_: $!";