--- deliantra/server/utils/cfutil.in 2007/03/07 20:30:18 1.4 +++ deliantra/server/utils/cfutil.in 2007/03/08 15:19:08 1.5 @@ -82,12 +82,15 @@ our @PNG; our @ARC; our $NFILE; + our @FACE; + our $ANIM; our (@png, @trs, @arc); # files we are interested in sub commit_png { my ($name, $data) = @_; - #warn "$name: commited\n"; + + push @PNG, [$name => $data]; } sub process_png { @@ -100,13 +103,13 @@ if (0 > aio_load $path, $png) { warn "$path: $!, skipping.\n"; - return; + next; } # quickly extratc width and height of the (necessarily PNG) image unless ($png =~ /^\x89PNG\x0d\x0a\x1a\x0a....IHDR(........)/s) { warn "$path: not a recongized png file, skipping.\n"; - return; + next; } my ($w, $h) = unpack "NN", $1; @@ -116,17 +119,17 @@ unless ($face =~ s/\.base\.(...)\.png$/.$1/) { warn "$path: weird filename, skipping.\n"; - return; + next; } if ($w < $T || $h < $T) { warn "$path: too small ($w $h), skipping.\n"; - return; + next; } if ($w % $T || $h % $T) { warn "$path: weird png size ($w $h), skipping.\n"; - return; + next; } if (($w > $T || $h > $T) && $face !~ /_S\./) { @@ -146,6 +149,7 @@ fork_sub { open my $convert, "|-", $CONVERT, "png:-", + -negate,#d# (map { ( "(", @@ -210,6 +214,13 @@ $_ .= "+$x+$y" for $o->{face}, @{$o->{anim} || []}; } } + if (my $anim = delete $o->{anim}) { + $o->{animation} = $o->{_name}; + $ANIM .= join "", map "$_\n", + "anim $o->{_name}", + @$anim, + "mina"; + } } } } @@ -264,11 +275,30 @@ (async \&process_arc), (async \&process_arc), ); - open my $archetypes, ">:utf8", "$DATADIR/archetypes~" - or die "$DATADIR/archetypes~: $!"; - print $archetypes Crossfire::archlist_to_string \@ARC; - close $archetypes; - rename "$DATADIR/archetypes~", "$DATADIR/archetypes"; + { + open my $fh, ">:utf8", "$DATADIR/animations~" + or die "$DATADIR/animations~: $!"; + print $fh $ANIM; + } + + { + open my $fh, ">:utf8", "$DATADIR/archetypes~" + or die "$DATADIR/archetypes~: $!"; + print $fh Crossfire::archlist_to_string \@ARC; + } + + @PNG = sort { $a->[0] cmp $b->[0] } @PNG; + + { + open my $fh, ">:perlio", "$DATADIR/crossfire.0~" + or die "$DATADIR/crossfire.0~: $!"; + printf $fh "IMAGE %d %d %s\x0a%s", $_, (length $PNG[$_][1]), $PNG[$_][0], $PNG[$_][1] + for 0.. $#PNG; + } + + rename "$DATADIR/archetypes~" , "$DATADIR/archetypes"; + rename "$DATADIR/crossfire.0~", "$DATADIR/crossfire.0"; + rename "$DATADIR/animations~" , "$DATADIR/animations"; die "--install-arch not fully implemented\n"; }