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.31 by root, Thu Apr 26 00:39:18 2007 UTC vs.
Revision 1.36 by root, Sun Jun 10 02:51:46 2007 UTC

6my $exec_prefix = "@exec_prefix@"; 6my $exec_prefix = "@exec_prefix@";
7my $datarootdir = "@datarootdir@"; 7my $datarootdir = "@datarootdir@";
8my $DATADIR = "@datadir@/@PACKAGE@"; 8my $DATADIR = "@datadir@/@PACKAGE@";
9 9
10my $CONVERT = "@CONVERT@"; 10my $CONVERT = "@CONVERT@";
11my $IDENTIFY = "@IDENTIFY@"; 11#my $IDENTIFY = "@IDENTIFY@";
12my $OPTIPNG = "@OPTIPNG@"; 12my $OPTIPNG = "@OPTIPNG@";
13my $RSYNC = "@RSYNC@"; 13my $RSYNC = "@RSYNC@";
14my $PNGNQ = "@PNGNQ@"; 14my $PNGNQ = "@PNGNQ@";
15 15
16use Getopt::Long; 16use Getopt::Long;
43my $CACHE = 0; 43my $CACHE = 0;
44my $FORCE; 44my $FORCE;
45my $TMPDIR = "/tmp/cfutil$$~"; 45my $TMPDIR = "/tmp/cfutil$$~";
46my $TMPFILE = "aaaa0"; 46my $TMPFILE = "aaaa0";
47 47
48our %COLOR = (
49 black => 0,
50 white => 1,
51 navy => 2,
52 red => 3,
53 orange => 4,
54 blue => 5,
55 darkorange => 6,
56 green => 7,
57 lightgreen => 8,
58 grey => 9,
59 brown => 10,
60 gold => 11,
61 tan => 12,
62);
63
48END { system "rm", "-rf", $TMPDIR } 64END { system "rm", "-rf", $TMPDIR }
49 65
50Event->signal (signal => "INT", cb => sub { exit 1 }); 66Event->signal (signal => "INT", cb => sub { exit 1 });
51Event->signal (signal => "TERM", cb => sub { exit 1 }); 67Event->signal (signal => "TERM", cb => sub { exit 1 });
52 68
177 193
178 # reduce smoothfaces >10000 bytes 194 # reduce smoothfaces >10000 bytes
179 if ($stem =~ /_S\./ && (-s "$other~") > 10000) { 195 if ($stem =~ /_S\./ && (-s "$other~") > 10000) {
180 my $ncolor = 256; 196 my $ncolor = 256;
181 while () { 197 while () {
182 system "<\Q$other~\E $PNGNQ -n$ncolor >\Q$other~~\E"; 198 system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E";
183 system $OPTIPNG, "-i0", "-q", "$other~~"; 199 system $OPTIPNG, "-i0", "-q", "$other~~";
184 last if 10000 > -s "$other~~"; 200 last if 10000 > -s "$other~~";
185 $ncolor = int $ncolor * 0.9; 201 $ncolor = int $ncolor * 0.9;
186 $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; 202 $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes";
187 } 203 }
188 204
189 printf "reduced %s from %d to %d bytes using %d colours.\n", 205 printf "reduced %s from %d to %d bytes using %d colours.\n",
190 $other, -s "$other~", -s "$other~~", $ncolor 206 $other, -s "$other~", -s "$other~~", $ncolor
191 if $VERBOSE > 0; 207 if $VERBOSE >= 2;
192 rename "$other~~", "$other~"; 208 rename "$other~~", "$other~";
193 } 209 }
194 210
195 die "$other~ has zero size, aborting." unless -s "$other~"; 211 die "$other~ has zero size, aborting." unless -s "$other~";
196 rename "$other~", $other; 212 rename "$other~", $other;
301 317
302 my $ext = $x|$y ? "+$x+$y" : ""; 318 my $ext = $x|$y ? "+$x+$y" : "";
303 319
304 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 320 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
305 321
306 my $visibility = delete $o->{visibility} if exists $o->{visibility}; 322 $visibility = delete $o->{visibility} if exists $o->{visibility};
307 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 323 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
308 324
309 my $anim = delete $o->{anim}; 325 my $anim = delete $o->{anim};
310 326
311 if ($anim) { 327 if ($anim) {
312 # possibly add $ext to the animation name to avoid 328 # possibly add $ext to the animation name to avoid
386 } elsif ($file =~ /\.trs$/) { 402 } elsif ($file =~ /\.trs$/) {
387 push @trs, [$path, $file]; 403 push @trs, [$path, $file];
388 } elsif ($file =~ /\.arc$/) { 404 } elsif ($file =~ /\.arc$/) {
389 push @arc, [$path, $file]; 405 push @arc, [$path, $file];
390 } else { 406 } else {
391 warn "ignoring $path/$file\n" if $VERBOSE >= 2; 407 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
392 } 408 }
393 } 409 }
394 }; 410 };
395 } 411 }
396 412
457 473
458 last; 474 last;
459 } 475 }
460 } 476 }
461 477
478 # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit
479 @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC;
480
462 open my $fh, ">:utf8", "$DATADIR/archetypes~" 481 open my $fh, ">:utf8", "$DATADIR/archetypes~"
463 or die "$DATADIR/archetypes~: $!"; 482 or die "$DATADIR/archetypes~: $!";
464 print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; 483 print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC];
465 } 484 }
466 485
478 length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; 497 length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n";
479 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; 498 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n";
480 499
481 $v->{chksum32} = Digest::MD5::md5 $v->{data32}; 500 $v->{chksum32} = Digest::MD5::md5 $v->{data32};
482 $v->{chksum64} = Digest::MD5::md5 $v->{data64}; 501 $v->{chksum64} = Digest::MD5::md5 $v->{data64};
502
503 if (my $magicmap = $v->{magicmap}) {
504 $magicmap =~ y/A-Z_\-/a-z/d;
505 $v->{magicmap} = $COLOR{$magicmap};
506 }
483 } 507 }
484 508
485 open my $fh, ">:perlio", "$DATADIR/facedata~" 509 open my $fh, ">:perlio", "$DATADIR/facedata~"
486 or die "$DATADIR/facedata~: $!"; 510 or die "$DATADIR/facedata~: $!";
487 511

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines