1 | #!@PERL@ |
1 | #!@PERL@ |
|
|
2 | |
|
|
3 | # |
|
|
4 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
|
|
5 | # |
|
|
6 | # Copyright (©) 2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
|
|
7 | # |
|
|
8 | # Deliantra is free software: you can redistribute it and/or modify it under |
|
|
9 | # the terms of the Affero GNU General Public License as published by the |
|
|
10 | # Free Software Foundation, either version 3 of the License, or (at your |
|
|
11 | # option) any later version. |
|
|
12 | # |
|
|
13 | # This program is distributed in the hope that it will be useful, |
|
|
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
16 | # GNU General Public License for more details. |
|
|
17 | # |
|
|
18 | # You should have received a copy of the Affero GNU General Public License |
|
|
19 | # and the GNU General Public License along with this program. If not, see |
|
|
20 | # <http://www.gnu.org/licenses/>. |
|
|
21 | # |
|
|
22 | # The authors can be reached via e-mail to <support@deliantra.net> |
|
|
23 | # |
2 | |
24 | |
3 | use strict; |
25 | use strict; |
4 | |
26 | |
5 | my $prefix = "@prefix@"; |
27 | my $prefix = "@prefix@"; |
6 | my $exec_prefix = "@exec_prefix@"; |
28 | my $exec_prefix = "@exec_prefix@"; |
… | |
… | |
12 | my $OPTIPNG = "@OPTIPNG@"; |
34 | my $OPTIPNG = "@OPTIPNG@"; |
13 | my $RSYNC = "@RSYNC@"; |
35 | my $RSYNC = "@RSYNC@"; |
14 | my $PNGNQ = "@PNGNQ@"; |
36 | my $PNGNQ = "@PNGNQ@"; |
15 | |
37 | |
16 | use Getopt::Long; |
38 | use Getopt::Long; |
|
|
39 | use File::Temp; |
|
|
40 | use POSIX (); |
|
|
41 | use Carp; |
|
|
42 | |
17 | use Coro::EV; |
43 | use Coro::EV; |
18 | use AnyEvent; |
44 | use AnyEvent; |
19 | use YAML (); |
45 | use YAML::XS (); |
20 | use JSON::XS (); |
46 | use JSON::XS (); |
21 | use IO::AIO (); |
47 | use IO::AIO (); |
22 | use File::Temp; |
48 | |
23 | use Deliantra; |
|
|
24 | use Coro 5.12; |
49 | use Coro 5.12; |
25 | use Coro::AIO; |
50 | use Coro::AIO; |
26 | use Coro::Util; |
51 | use Coro::Util; |
27 | use POSIX (); |
|
|
28 | use Carp; |
|
|
29 | use Coro::Channel; |
52 | use Coro::Channel; |
30 | use Coro::Storable; $Storable::canonical = 1; |
53 | use Coro::Storable; $Storable::canonical = 1; |
|
|
54 | |
|
|
55 | use Deliantra; |
31 | |
56 | |
32 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
57 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
33 | |
58 | |
34 | sub usage { |
59 | sub usage { |
35 | warn <<EOF; |
60 | warn <<EOF; |
… | |
… | |
380 | push @ARC, $o; |
405 | push @ARC, $o; |
381 | for (my $m = $o; $m; $m = $m->{more}) { |
406 | for (my $m = $o; $m; $m = $m->{more}) { |
382 | $ARC{$m->{_name}} = $m; |
407 | $ARC{$m->{_name}} = $m; |
383 | } |
408 | } |
384 | |
409 | |
385 | $o->{editor_folder} = $dir; |
410 | $o->{editor_folder} ||= "\x00$dir"; # horrible kludge |
386 | |
411 | |
387 | my $visibility = delete $o->{visibility}; |
412 | my $visibility = delete $o->{visibility}; |
388 | my $magicmap = delete $o->{magicmap}; |
413 | my $magicmap = delete $o->{magicmap}; |
389 | |
414 | |
390 | # find upper left corner :/ |
415 | # find upper left corner :/ |
… | |
… | |
534 | |
559 | |
535 | substr $dir, 0, 1 + length $PATH, ""; |
560 | substr $dir, 0, 1 + length $PATH, ""; |
536 | |
561 | |
537 | if (my $filter = $meta->{cfutil_filter}) { |
562 | if (my $filter = $meta->{cfutil_filter}) { |
538 | if ($filter eq "yaml2json") { |
563 | if ($filter eq "yaml2json") { |
539 | $data = JSON::XS::encode_json YAML::Load $data; |
564 | $data = JSON::XS::encode_json YAML::XS::Load $data; |
540 | } elsif ($filter eq "json2json") { |
565 | } elsif ($filter eq "json2json") { |
541 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
566 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
542 | } elsif ($filter eq "perl2json") { |
567 | } elsif ($filter eq "perl2json") { |
543 | $data = eval $data; die if $@; |
568 | $data = eval $data; die if $@; |
544 | $data = JSON::XS::encode_json $data; |
569 | $data = JSON::XS::encode_json $data; |
… | |
… | |
599 | } else { |
624 | } else { |
600 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
625 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
601 | } |
626 | } |
602 | } |
627 | } |
603 | }; |
628 | }; |
|
|
629 | } |
|
|
630 | |
|
|
631 | sub generate_plurals { |
|
|
632 | # use Lingua::EN::Inflect (); |
|
|
633 | # Lingua::EN::Inflect::classical; |
|
|
634 | # Lingua::EN::Inflect::def_noun '(.*)staff' => '$1staves'; # policy |
|
|
635 | # Lingua::EN::Inflect::def_noun '(.*)boots' => '$1boots'; # hack |
|
|
636 | # |
|
|
637 | # for my $a (@ARC) { |
|
|
638 | # my $name = $a->{name} || $a->{_name}; |
|
|
639 | # |
|
|
640 | # next unless $a->{name_pl}; |
|
|
641 | # next if $a->{invisible}; |
|
|
642 | # next if $a->{is_floor}; |
|
|
643 | # next if $a->{no_pick}; |
|
|
644 | # |
|
|
645 | # my $test = Lingua::EN::Inflect::PL_N_eq $name, Lingua::EN::Inflect::PL $name; |
|
|
646 | # my $pl = $test =~ /^(?:eq|p:.)$/ |
|
|
647 | # ? $name |
|
|
648 | # : Lingua::EN::Inflect::PL $name; |
|
|
649 | # |
|
|
650 | # if ($pl ne $a->{name_pl}) { |
|
|
651 | # warn "$a->{_name}: plural differs, $pl vs $a->{name_pl}\n"; |
|
|
652 | # } |
|
|
653 | # } |
604 | } |
654 | } |
605 | |
655 | |
606 | sub inst_arch($) { |
656 | sub inst_arch($) { |
607 | my (undef, $path) = @_; |
657 | my (undef, $path) = @_; |
608 | |
658 | |
… | |
… | |
649 | $_->join for (@a_trs, @a_res, @a_png); |
699 | $_->join for (@a_trs, @a_res, @a_png); |
650 | |
700 | |
651 | print "scanning done, processing results...\n" if $VERBOSE; |
701 | print "scanning done, processing results...\n" if $VERBOSE; |
652 | { |
702 | { |
653 | # remove path prefix from editor_folder |
703 | # remove path prefix from editor_folder |
|
|
704 | $_->{editor_folder} =~ /^\x00/ |
654 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
705 | and substr $_->{editor_folder}, 0, 2 + length $path, "" |
655 | for values %ARC; |
706 | for values %ARC; |
656 | |
707 | |
657 | print "resolving inheritance tree...\n" if $VERBOSE; |
708 | print "resolving inheritance tree...\n" if $VERBOSE; |
658 | # resolve inherit |
709 | # resolve inherit |
659 | while () { |
710 | while () { |
660 | my $progress; |
711 | my $progress; |
… | |
… | |
688 | } |
739 | } |
689 | |
740 | |
690 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
741 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
691 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
742 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
692 | |
743 | |
|
|
744 | print "generating plurals...\n" if $VERBOSE; |
|
|
745 | generate_plurals; |
|
|
746 | |
693 | print "writing archetypes...\n" if $VERBOSE; |
747 | printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE; |
694 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
748 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
695 | or die "$DATADIR/archetypes~: $!"; |
749 | or die "$DATADIR/archetypes~: $!"; |
696 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
750 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
697 | } |
751 | } |
698 | |
752 | |
699 | { |
753 | { |
700 | print "writing treasures...\n" if $VERBOSE; |
754 | printf "writing treasures (%d octets)...\n", length $TRS if $VERBOSE; |
701 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
755 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
702 | or die "$DATADIR/treasures~: $!"; |
756 | or die "$DATADIR/treasures~: $!"; |
703 | print $fh $TRS; |
757 | print $fh $TRS; |
704 | } |
758 | } |
705 | |
759 | |
… | |
… | |
718 | } |
772 | } |
719 | |
773 | |
720 | delete $v->{arc}; |
774 | delete $v->{arc}; |
721 | } |
775 | } |
722 | |
776 | |
723 | print "writing facedata...\n" if $VERBOSE; |
777 | printf "writing facedata (%d faces, %d anims, %d resources)...\n", |
|
|
778 | scalar keys %FACEINFO, |
|
|
779 | scalar keys %ANIMINFO, |
|
|
780 | scalar keys %RESOURCE |
|
|
781 | if $VERBOSE; |
|
|
782 | |
724 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
783 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
725 | or die "$DATADIR/facedata~: $!"; |
784 | or die "$DATADIR/facedata~: $!"; |
726 | |
785 | |
727 | print $fh freeze { |
786 | print $fh freeze { |
728 | version => 2, |
787 | version => 2, |
729 | faceinfo => \%FACEINFO, |
788 | faceinfo => \%FACEINFO, |
730 | animinfo => \%ANIMINFO, |
789 | animinfo => \%ANIMINFO, |
731 | resource => \%RESOURCE, |
790 | resource => \%RESOURCE, |
732 | }; |
791 | }; |
|
|
792 | |
733 | } |
793 | } |
734 | |
794 | |
735 | print "committing files...\n" if $VERBOSE; |
795 | print "committing files...\n" if $VERBOSE; |
736 | |
796 | |
737 | for (qw(archetypes facedata treasures)) { |
797 | for (qw(archetypes facedata treasures)) { |