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.33 by root, Thu Apr 26 00:50:03 2007 UTC vs.
Revision 1.38 by root, Thu Jul 12 08:40:14 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 my $copyright;
398 aio_load "$dir/copyright", $copyright;
399
400 $file =~ s/\.res$//;
401 $file =~ /\.([^.]+)$/
402 or next;
403
404 my $type = $1;
405
406 substr $dir, 0, 1 + length $PATH, "";
407
408 $RESOURCE{"$dir/$file"} = {
409 type => $1,
410 copyright => $copyright,
411 data => $data,
412 chksum => Digest::MD5::md5 $data,
413 };
414 }
415 }
416
372 sub find_files; 417 sub find_files;
373 sub find_files { 418 sub find_files {
374 my ($path) = @_; 419 my ($path) = @_;
375 420
376 IO::AIO::aioreq_pri 4; 421 IO::AIO::aioreq_pri 4;
385 push @png, ["$path/$file", 0]; 430 push @png, ["$path/$file", 0];
386 } elsif ($file =~ /\.trs$/) { 431 } elsif ($file =~ /\.trs$/) {
387 push @trs, [$path, $file]; 432 push @trs, [$path, $file];
388 } elsif ($file =~ /\.arc$/) { 433 } elsif ($file =~ /\.arc$/) {
389 push @arc, [$path, $file]; 434 push @arc, [$path, $file];
435 } elsif ($file =~ /\.(ogg|res)$/) {
436 push @res, [$path, $file];
390 } else { 437 } else {
391 warn "ignoring $path/$file\n" if $VERBOSE >= 3; 438 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
392 } 439 }
393 } 440 }
394 }; 441 };
395 } 442 }
396 443
397 sub inst_arch($) { 444 sub inst_arch($) {
398 my (undef, $path) = @_; 445 my (undef, $path) = @_;
446
447 $PATH = $path;
399 448
400 print "\n", 449 print "\n",
401 "Installing '$path' to '$DATADIR'\n", 450 "Installing '$path' to '$DATADIR'\n",
402 "\n", 451 "\n",
403 "This can take a long time if you run this\n", 452 "This can take a long time if you run this\n",
418 $_->join for ( 467 $_->join for (
419 # four png crunchers work fine for my 2x smp machine 468 # four png crunchers work fine for my 2x smp machine
420 (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), 469 (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png),
421 (async \&process_trs), (async \&process_trs), 470 (async \&process_trs), (async \&process_trs),
422 (async \&process_arc), (async \&process_arc), 471 (async \&process_arc), (async \&process_arc),
472 (async \&process_res), (async \&process_res),
423 ); 473 );
424 474
425 { 475 {
426 # remove path prefix from editor_folder 476 # remove path prefix from editor_folder
427 substr $_->{editor_folder}, 0, 1 + length $path, "" 477 substr $_->{editor_folder}, 0, 1 + length $path, ""
457 507
458 last; 508 last;
459 } 509 }
460 } 510 }
461 511
512 # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit
513 @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC;
514
462 open my $fh, ">:utf8", "$DATADIR/archetypes~" 515 open my $fh, ">:utf8", "$DATADIR/archetypes~"
463 or die "$DATADIR/archetypes~: $!"; 516 or die "$DATADIR/archetypes~: $!";
464 print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; 517 print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC];
465 } 518 }
466 519
478 length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; 531 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"; 532 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n";
480 533
481 $v->{chksum32} = Digest::MD5::md5 $v->{data32}; 534 $v->{chksum32} = Digest::MD5::md5 $v->{data32};
482 $v->{chksum64} = Digest::MD5::md5 $v->{data64}; 535 $v->{chksum64} = Digest::MD5::md5 $v->{data64};
536
537 if (my $magicmap = $v->{magicmap}) {
538 $magicmap =~ y/A-Z_\-/a-z/d;
539 $v->{magicmap} = $COLOR{$magicmap};
540 }
483 } 541 }
484 542
485 open my $fh, ">:perlio", "$DATADIR/facedata~" 543 open my $fh, ">:perlio", "$DATADIR/facedata~"
486 or die "$DATADIR/facedata~: $!"; 544 or die "$DATADIR/facedata~: $!";
487 545
488 print $fh freeze { 546 print $fh freeze {
489 version => 2, 547 version => 2,
490 faceinfo => \%FACEINFO, 548 faceinfo => \%FACEINFO,
491 animinfo => \%ANIMINFO, 549 animinfo => \%ANIMINFO,
550 resource => \%RESOURCE,
492 }; 551 };
493 } 552 }
494 553
495 for (qw(archetypes facedata treasures)) { 554 for (qw(archetypes facedata treasures)) {
496 chmod 0644, "$DATADIR/$_~"; 555 chmod 0644, "$DATADIR/$_~";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines