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.79 by root, Sun Nov 15 18:04:00 2009 UTC vs.
Revision 1.83 by root, Wed Apr 28 20:51:58 2010 UTC

74my $VERBOSE = 1; 74my $VERBOSE = 1;
75my $CACHE = 0; 75my $CACHE = 0;
76my $FORCE; 76my $FORCE;
77my $TMPDIR = "/tmp/cfutil$$~"; 77my $TMPDIR = "/tmp/cfutil$$~";
78my $TMPFILE = "aaaa0"; 78my $TMPFILE = "aaaa0";
79my @COMMIT;
79 80
80our %COLOR = ( 81our %COLOR = (
81 black => 0, 82 black => 0,
82 white => 1, 83 white => 1,
83 navy => 2, 84 navy => 2,
610 IO::AIO::aioreq_pri 4; 611 IO::AIO::aioreq_pri 4;
611 IO::AIO::aio_scandir $path, 4, sub { 612 IO::AIO::aio_scandir $path, 4, sub {
612 my ($dirs, $nondirs) = @_; 613 my ($dirs, $nondirs) = @_;
613 614
614 find_files "$path/$_" 615 find_files "$path/$_"
615 for grep $_ !~ /^(?:CVS|dev)$/, @$dirs; 616 for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs;
616 617
617 my $dir = $path; 618 my $dir = $path;
618 substr $dir, 0, 1 + length $PATH, ""; 619 substr $dir, 0, 1 + length $PATH, "";
619 620
620 for my $file (@$nondirs) { 621 for my $file (@$nondirs) {
733 while () { 734 while () {
734 my $progress; 735 my $progress;
735 my $loop; 736 my $loop;
736 737
737 for my $o (values %ARC) { 738 for my $o (values %ARC) {
738 if (my $other = $o->{inherit}) { 739 for my $other (split /,/, $o->{inherit}) {
739 if (my $s = $ARC{$other}) { 740 if (my $s = $ARC{$other}) {
740 if ($s->{inherit}) { 741 if ($s->{inherit}) {
741 $loop = $s; 742 $loop = $s;
742 } else { 743 } else {
743 delete $o->{inherit}; 744 delete $o->{inherit};
802 803
803 print "processing resources...\n" if $VERBOSE; 804 print "processing resources...\n" if $VERBOSE;
804 my $enc = JSON::XS->new->utf8->canonical->relaxed; 805 my $enc = JSON::XS->new->utf8->canonical->relaxed;
805 while (my ($k, $v) = each %RESOURCE) { 806 while (my ($k, $v) = each %RESOURCE) {
806 807
808 if ($v->{meta} && $v->{meta}{datadir}) {
809 delete $RESOURCE{$k};
810
811 $k =~ s/^res\/// or die "$k: datadir files must be in res/";
812
813 printf "writing $k (%d octets)...\n", length $v->{data} if $VERBOSE;
814 open my $fh, ">:raw", "$DATADIR/$k~"
815 or die "$DATADIR/$k~: $!";
816 syswrite $fh, $v->{data};
817 push @COMMIT, $k;
818
819 } else {
807 if ($v->{type} & 1) { 820 if ($v->{type} & 1) {
808 # prepend meta info 821 # prepend meta info
809 822
810 my $meta = $enc->encode ({ 823 my $meta = $enc->encode ({
811 name => $k, 824 name => $k,
812 %{ $v->{meta} || {} }, 825 %{ $v->{meta} || {} },
813 }); 826 });
814 827
815 $v->{data} = pack "(w/a*)*", $meta, $v->{data}; 828 $v->{data} = pack "(w/a*)*", $meta, $v->{data};
816 } 829 }
817 830
818 make_hash $k, $v->{data}, $v->{hash}, 6; # 6 for the benefit of existing clients 831 make_hash $k, $v->{data}, $v->{hash}, 6; # 6 for the benefit of existing clients
832 }
819 } 833 }
820 834
821 printf "writing facedata (%d faces, %d anims, %d resources)...\n", 835 printf "writing facedata (%d faces, %d anims, %d resources)...\n",
822 scalar keys %FACEINFO, 836 scalar keys %FACEINFO,
823 scalar keys %ANIMINFO, 837 scalar keys %ANIMINFO,
825 if $VERBOSE; 839 if $VERBOSE;
826 840
827 open my $fh, ">:perlio", "$DATADIR/facedata~" 841 open my $fh, ">:perlio", "$DATADIR/facedata~"
828 or die "$DATADIR/facedata~: $!"; 842 or die "$DATADIR/facedata~: $!";
829 843
830 print $fh freeze { 844 print $fh nfreeze {
831 version => 2, 845 version => 2,
832 faceinfo => \%FACEINFO, 846 faceinfo => \%FACEINFO,
833 animinfo => \%ANIMINFO, 847 animinfo => \%ANIMINFO,
834 resource => \%RESOURCE, 848 resource => \%RESOURCE,
835 }; 849 };
836 850
837 } 851 }
838 852
839 print "committing files...\n" if $VERBOSE; 853 print "committing files...\n" if $VERBOSE;
840 854
841 for (qw(archetypes facedata treasures)) { 855 for (qw(archetypes facedata treasures), @COMMIT) {
842 chmod 0644, "$DATADIR/$_~"; 856 chmod 0644, "$DATADIR/$_~";
843 rename "$DATADIR/$_~", "$DATADIR/$_" 857 rename "$DATADIR/$_~", "$DATADIR/$_"
844 or die "$DATADIR/$_: $!"; 858 or die "$DATADIR/$_: $!";
845 } 859 }
846 860

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines