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.70 by root, Fri Dec 5 00:52:44 2008 UTC vs.
Revision 1.76 by root, Tue Nov 3 14:49:39 2009 UTC

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;
17use File::Temp;
18use POSIX ();
19use Carp;
20
17use Coro::EV; 21use Coro::EV;
18use AnyEvent; 22use AnyEvent;
19use YAML (); 23use YAML::XS ();
20use JSON::XS (); 24use JSON::XS ();
21use IO::AIO (); 25use IO::AIO ();
22use File::Temp; 26
23use Deliantra;
24use Coro 5.12; 27use Coro 5.12;
25use Coro::AIO; 28use Coro::AIO;
26use Coro::Util; 29use Coro::Util;
27use POSIX ();
28use Carp;
29use Coro::Channel; 30use Coro::Channel;
30use Coro::Storable; $Storable::canonical = 1; 31use Coro::Storable; $Storable::canonical = 1;
32
33use Deliantra;
31 34
32$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 35$SIG{QUIT} = sub { Carp::cluck "QUIT" };
33 36
34sub usage { 37sub usage {
35 warn <<EOF; 38 warn <<EOF;
273 fork_sub { 276 fork_sub {
274 system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; 277 system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~";
275 system $OPTIPNG, "-i0", "-q", "$other~"; 278 system $OPTIPNG, "-i0", "-q", "$other~";
276 279
277 # reduce smoothfaces >10000 bytes 280 # reduce smoothfaces >10000 bytes
281 # obsolete, no longer required
278 if ($stem =~ /_S\./ && (-s "$other~") > 10000) { 282 if (0 && $stem =~ /_S\./ && (-s "$other~") > 10000) {
279 my $ncolor = 256; 283 my $ncolor = 256;
280 while () { 284 while () {
281 system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; 285 system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E";
282 system $OPTIPNG, "-i0", "-q", "$other~~"; 286 system $OPTIPNG, "-i0", "-q", "$other~~";
283 last if 10000 > -s "$other~~"; 287 last if 10000 > -s "$other~~";
379 push @ARC, $o; 383 push @ARC, $o;
380 for (my $m = $o; $m; $m = $m->{more}) { 384 for (my $m = $o; $m; $m = $m->{more}) {
381 $ARC{$m->{_name}} = $m; 385 $ARC{$m->{_name}} = $m;
382 } 386 }
383 387
384 $o->{editor_folder} = $dir; 388 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge
385 389
386 my $visibility = delete $o->{visibility}; 390 my $visibility = delete $o->{visibility};
387 my $magicmap = delete $o->{magicmap}; 391 my $magicmap = delete $o->{magicmap};
388 392
389 # find upper left corner :/ 393 # find upper left corner :/
533 537
534 substr $dir, 0, 1 + length $PATH, ""; 538 substr $dir, 0, 1 + length $PATH, "";
535 539
536 if (my $filter = $meta->{cfutil_filter}) { 540 if (my $filter = $meta->{cfutil_filter}) {
537 if ($filter eq "yaml2json") { 541 if ($filter eq "yaml2json") {
538 $data = JSON::XS::encode_json YAML::Load $data; 542 $data = JSON::XS::encode_json YAML::XS::Load $data;
539 } elsif ($filter eq "json2json") { 543 } elsif ($filter eq "json2json") {
540 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); 544 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data);
541 } elsif ($filter eq "perl2json") { 545 } elsif ($filter eq "perl2json") {
542 $data = eval $data; die if $@; 546 $data = eval $data; die if $@;
543 $data = JSON::XS::encode_json $data; 547 $data = JSON::XS::encode_json $data;
598 } else { 602 } else {
599 warn "ignoring $path/$file\n" if $VERBOSE >= 3; 603 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
600 } 604 }
601 } 605 }
602 }; 606 };
607 }
608
609 sub generate_plurals {
610# use Lingua::EN::Inflect ();
611# Lingua::EN::Inflect::classical;
612# Lingua::EN::Inflect::def_noun '(.*)staff' => '$1staves'; # policy
613# Lingua::EN::Inflect::def_noun '(.*)boots' => '$1boots'; # hack
614#
615# for my $a (@ARC) {
616# my $name = $a->{name} || $a->{_name};
617#
618# next unless $a->{name_pl};
619# next if $a->{invisible};
620# next if $a->{is_floor};
621# next if $a->{no_pick};
622#
623# my $test = Lingua::EN::Inflect::PL_N_eq $name, Lingua::EN::Inflect::PL $name;
624# my $pl = $test =~ /^(?:eq|p:.)$/
625# ? $name
626# : Lingua::EN::Inflect::PL $name;
627#
628# if ($pl ne $a->{name_pl}) {
629# warn "$a->{_name}: plural differs, $pl vs $a->{name_pl}\n";
630# }
631# }
603 } 632 }
604 633
605 sub inst_arch($) { 634 sub inst_arch($) {
606 my (undef, $path) = @_; 635 my (undef, $path) = @_;
607 636
648 $_->join for (@a_trs, @a_res, @a_png); 677 $_->join for (@a_trs, @a_res, @a_png);
649 678
650 print "scanning done, processing results...\n" if $VERBOSE; 679 print "scanning done, processing results...\n" if $VERBOSE;
651 { 680 {
652 # remove path prefix from editor_folder 681 # remove path prefix from editor_folder
682 $_->{editor_folder} =~ /^\x00/
653 substr $_->{editor_folder}, 0, 1 + length $path, "" 683 and substr $_->{editor_folder}, 0, 2 + length $path, ""
654 for values %ARC; 684 for values %ARC;
655 685
656 print "resolving inheritance tree...\n" if $VERBOSE; 686 print "resolving inheritance tree...\n" if $VERBOSE;
657 # resolve inherit 687 # resolve inherit
658 while () { 688 while () {
659 my $progress; 689 my $progress;
687 } 717 }
688 718
689 # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit 719 # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit
690 @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; 720 @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC;
691 721
722 print "generating plurals...\n" if $VERBOSE;
723 generate_plurals;
724
692 print "writing archetypes...\n" if $VERBOSE; 725 print "writing archetypes...\n" if $VERBOSE;
693 open my $fh, ">:utf8", "$DATADIR/archetypes~" 726 open my $fh, ">:utf8", "$DATADIR/archetypes~"
694 or die "$DATADIR/archetypes~: $!"; 727 or die "$DATADIR/archetypes~: $!";
695 print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; 728 print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC];
696 } 729 }
706 print "processing facedata...\n" if $VERBOSE; 739 print "processing facedata...\n" if $VERBOSE;
707 while (my ($k, $v) = each %FACEINFO) { 740 while (my ($k, $v) = each %FACEINFO) {
708 length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; 741 length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n";
709 length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; 742 length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n";
710 743
711 length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; 744 #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n";
712 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; 745 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n";
713 746
714 if (my $magicmap = $v->{magicmap}) { 747 if (my $magicmap = $v->{magicmap}) {
715 $magicmap =~ y/A-Z_\-/a-z/d; 748 $magicmap =~ y/A-Z_\-/a-z/d;
716 $v->{magicmap} = $COLOR{$magicmap}; 749 $v->{magicmap} = $COLOR{$magicmap};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines