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.72 by root, Mon Oct 12 14:01:00 2009 UTC vs.
Revision 1.78 by root, Wed Nov 4 13:46:37 2009 UTC

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
3use strict; 25use strict;
4 26
5my $prefix = "@prefix@"; 27my $prefix = "@prefix@";
6my $exec_prefix = "@exec_prefix@"; 28my $exec_prefix = "@exec_prefix@";
12my $OPTIPNG = "@OPTIPNG@"; 34my $OPTIPNG = "@OPTIPNG@";
13my $RSYNC = "@RSYNC@"; 35my $RSYNC = "@RSYNC@";
14my $PNGNQ = "@PNGNQ@"; 36my $PNGNQ = "@PNGNQ@";
15 37
16use Getopt::Long; 38use Getopt::Long;
39use File::Temp;
40use POSIX ();
41use Carp;
42
17use Coro::EV; 43use Coro::EV;
18use AnyEvent; 44use AnyEvent;
19use YAML::XS (); 45use YAML::XS ();
20use JSON::XS (); 46use JSON::XS ();
21use IO::AIO (); 47use IO::AIO ();
22use File::Temp; 48
23use Deliantra;
24use Coro 5.12; 49use Coro 5.12;
25use Coro::AIO; 50use Coro::AIO;
26use Coro::Util; 51use Coro::Util;
27use POSIX ();
28use Carp;
29use Coro::Channel; 52use Coro::Channel;
30use Coro::Storable; $Storable::canonical = 1; 53use Coro::Storable; $Storable::canonical = 1;
54
55use Deliantra;
31 56
32$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 57$SIG{QUIT} = sub { Carp::cluck "QUIT" };
33 58
34sub usage { 59sub 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 :/
601 } 626 }
602 } 627 }
603 }; 628 };
604 } 629 }
605 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# }
654 }
655
606 sub inst_arch($) { 656 sub inst_arch($) {
607 my (undef, $path) = @_; 657 my (undef, $path) = @_;
608 658
609 $PATH = $path; 659 $PATH = $path;
610 660
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)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines