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.34 by root, Mon May 7 06:01:48 2007 UTC vs.
Revision 1.37 by root, Tue Jul 10 16:24:00 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
85} 101}
86 102
87{ 103{
88 our %ANIMINFO; 104 our %ANIMINFO;
89 our %FACEINFO; 105 our %FACEINFO;
106 our %RESOURCE;
90 our @ARC; 107 our @ARC;
91 our %ARC; 108 our %ARC;
92 our $TRS; 109 our $TRS;
93 our $NFILE; 110 our $NFILE;
111 our $PATH;
94 112
95 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 113 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
96 114
97 our (@png, @trs, @arc); # files we are interested in 115 our (@png, @trs, @arc, @res); # files we are interested in
98 116
99 sub commit_png($$$) { 117 sub commit_png($$$) {
100 my ($name, $data, $T) = @_; 118 my ($name, $data, $T) = @_;
101 119
102 $FACEINFO{$name}{"data$T"} = $data; 120 $FACEINFO{$name}{"data$T"} = $data;
301 319
302 my $ext = $x|$y ? "+$x+$y" : ""; 320 my $ext = $x|$y ? "+$x+$y" : "";
303 321
304 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 322 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
305 323
306 my $visibility = delete $o->{visibility} if exists $o->{visibility}; 324 $visibility = delete $o->{visibility} if exists $o->{visibility};
307 my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 325 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
308 326
309 my $anim = delete $o->{anim}; 327 my $anim = delete $o->{anim};
310 328
311 if ($anim) { 329 if ($anim) {
312 # possibly add $ext to the animation name to avoid 330 # possibly add $ext to the animation name to avoid
367 385
368 $TRS .= $trs; 386 $TRS .= $trs;
369 } 387 }
370 } 388 }
371 389
390 sub process_res {
391 while (@res) {
392 my ($dir, $file) = @{pop @res};
393
394 my $data;
395 aio_load "$dir/$file", $data;
396
397 $file =~ s/\.res$//;
398 $file =~ /\.([^.]+)$/
399 or next;
400
401 my $type = $1;
402
403 substr $dir, 0, 1 + length $PATH, "";
404
405 $RESOURCE{"$dir/$file"} = {
406 type => $1,
407 copyright => "", # TODO
408 data => $data,
409 chksum => Digest::MD5::md5 $data,
410 };
411 }
412 }
413
372 sub find_files; 414 sub find_files;
373 sub find_files { 415 sub find_files {
374 my ($path) = @_; 416 my ($path) = @_;
375 417
376 IO::AIO::aioreq_pri 4; 418 IO::AIO::aioreq_pri 4;
385 push @png, ["$path/$file", 0]; 427 push @png, ["$path/$file", 0];
386 } elsif ($file =~ /\.trs$/) { 428 } elsif ($file =~ /\.trs$/) {
387 push @trs, [$path, $file]; 429 push @trs, [$path, $file];
388 } elsif ($file =~ /\.arc$/) { 430 } elsif ($file =~ /\.arc$/) {
389 push @arc, [$path, $file]; 431 push @arc, [$path, $file];
432 } elsif ($file =~ /\.(ogg|res)$/) {
433 push @res, [$path, $file];
390 } else { 434 } else {
391 warn "ignoring $path/$file\n" if $VERBOSE >= 3; 435 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
392 } 436 }
393 } 437 }
394 }; 438 };
395 } 439 }
396 440
397 sub inst_arch($) { 441 sub inst_arch($) {
398 my (undef, $path) = @_; 442 my (undef, $path) = @_;
443
444 $PATH = $path;
399 445
400 print "\n", 446 print "\n",
401 "Installing '$path' to '$DATADIR'\n", 447 "Installing '$path' to '$DATADIR'\n",
402 "\n", 448 "\n",
403 "This can take a long time if you run this\n", 449 "This can take a long time if you run this\n",
418 $_->join for ( 464 $_->join for (
419 # four png crunchers work fine for my 2x smp machine 465 # four png crunchers work fine for my 2x smp machine
420 (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), 466 (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png),
421 (async \&process_trs), (async \&process_trs), 467 (async \&process_trs), (async \&process_trs),
422 (async \&process_arc), (async \&process_arc), 468 (async \&process_arc), (async \&process_arc),
469 (async \&process_res), (async \&process_res),
423 ); 470 );
424 471
425 { 472 {
426 # remove path prefix from editor_folder 473 # remove path prefix from editor_folder
427 substr $_->{editor_folder}, 0, 1 + length $path, "" 474 substr $_->{editor_folder}, 0, 1 + length $path, ""
481 length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; 528 length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n";
482 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; 529 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n";
483 530
484 $v->{chksum32} = Digest::MD5::md5 $v->{data32}; 531 $v->{chksum32} = Digest::MD5::md5 $v->{data32};
485 $v->{chksum64} = Digest::MD5::md5 $v->{data64}; 532 $v->{chksum64} = Digest::MD5::md5 $v->{data64};
533
534 if (my $magicmap = $v->{magicmap}) {
535 $magicmap =~ y/A-Z_\-/a-z/d;
536 $v->{magicmap} = $COLOR{$magicmap};
537 }
486 } 538 }
487 539
488 open my $fh, ">:perlio", "$DATADIR/facedata~" 540 open my $fh, ">:perlio", "$DATADIR/facedata~"
489 or die "$DATADIR/facedata~: $!"; 541 or die "$DATADIR/facedata~: $!";
490 542
491 print $fh freeze { 543 print $fh freeze {
492 version => 2, 544 version => 2,
493 faceinfo => \%FACEINFO, 545 faceinfo => \%FACEINFO,
494 animinfo => \%ANIMINFO, 546 animinfo => \%ANIMINFO,
547 resource => \%RESOURCE,
495 }; 548 };
496 } 549 }
497 550
498 for (qw(archetypes facedata treasures)) { 551 for (qw(archetypes facedata treasures)) {
499 chmod 0644, "$DATADIR/$_~"; 552 chmod 0644, "$DATADIR/$_~";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines