ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.299 by root, Sun Jul 8 14:56:05 2007 UTC vs.
Revision 1.304 by root, Wed Jul 11 16:55:18 2007 UTC

29use Fcntl; 29use Fcntl;
30use YAML::Syck (); 30use YAML::Syck ();
31use IO::AIO 2.32 (); 31use IO::AIO 2.32 ();
32use Time::HiRes; 32use Time::HiRes;
33use Compress::LZF; 33use Compress::LZF;
34use Digest::MD5 ();
34 35
35# configure various modules to our taste 36# configure various modules to our taste
36# 37#
37$Storable::canonical = 1; # reduce rsync transfers 38$Storable::canonical = 1; # reduce rsync transfers
38Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator 39Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator
1488 my ($path) = @_; 1489 my ($path) = @_;
1489 1490
1490 my ($match, $specificity); 1491 my ($match, $specificity);
1491 1492
1492 for my $region (list) { 1493 for my $region (list) {
1493 if ($region->match && $path =~ $region->match) { 1494 if ($region->{match} && $path =~ $region->{match}) {
1494 ($match, $specificity) = ($region, $region->specificity) 1495 ($match, $specificity) = ($region, $region->specificity)
1495 if $region->specificity > $specificity; 1496 if $region->specificity > $specificity;
1496 } 1497 }
1497 } 1498 }
1498 1499
2719 { 2720 {
2720 my $faces = $facedata->{faceinfo}; 2721 my $faces = $facedata->{faceinfo};
2721 2722
2722 while (my ($face, $info) = each %$faces) { 2723 while (my ($face, $info) = each %$faces) {
2723 my $idx = (cf::face::find $face) || cf::face::alloc $face; 2724 my $idx = (cf::face::find $face) || cf::face::alloc $face;
2724 cf::face::set $idx, $info->{visibility}, $info->{magicmap}; 2725 cf::face::set_visibility $idx, $info->{visibility};
2726 cf::face::set_magicmap $idx, $info->{magicmap};
2725 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; 2727 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32};
2726 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64}; 2728 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64};
2727 Coro::cede; 2729
2730 cf::cede_to_tick;
2728 } 2731 }
2729 2732
2730 while (my ($face, $info) = each %$faces) { 2733 while (my ($face, $info) = each %$faces) {
2731 next unless $info->{smooth}; 2734 next unless $info->{smooth};
2732 my $idx = cf::face::find $face 2735 my $idx = cf::face::find $face
2733 or next; 2736 or next;
2734 if (my $smooth = cf::face::find $info->{smooth}) { 2737 if (my $smooth = cf::face::find $info->{smooth}) {
2738 cf::face::set_smooth $idx, $smooth;
2735 cf::face::set_smooth $idx, $smooth, $info->{smoothlevel}; 2739 cf::face::set_smoothlevel $idx, $info->{smoothlevel};
2736 } else { 2740 } else {
2737 warn "smooth face '$info->{smooth}' not found for face '$face'"; 2741 warn "smooth face '$info->{smooth}' not found for face '$face'";
2738 } 2742 }
2739 Coro::cede; 2743
2744 cf::cede_to_tick;
2740 } 2745 }
2741 } 2746 }
2742 2747
2743 { 2748 {
2744 my $anims = $facedata->{animinfo}; 2749 my $anims = $facedata->{animinfo};
2745 2750
2746 while (my ($anim, $info) = each %$anims) { 2751 while (my ($anim, $info) = each %$anims) {
2747 cf::anim::set $anim, $info->{frames}, $info->{facings}; 2752 cf::anim::set $anim, $info->{frames}, $info->{facings};
2748 Coro::cede; 2753 cf::cede_to_tick;
2749 } 2754 }
2750 2755
2751 cf::anim::invalidate_all; # d'oh 2756 cf::anim::invalidate_all; # d'oh
2757 }
2758
2759 {
2760 # TODO: for gcfclient pleasure, we should give resources
2761 # that gcfclient doesn't grok a >10000 face index.
2762 my $res = $facedata->{resource};
2763 my $enc = JSON::XS->new->utf8->canonical;
2764
2765 while (my ($name, $info) = each %$res) {
2766 my $meta = $enc->encode ({
2767 name => $name,
2768 type => $info->{type},
2769 copyright => $info->{copyright}, #TODO#
2770 });
2771 my $data = pack "(w/a*)*", $meta, $info->{data};
2772 my $chk = Digest::MD5::md5 "$info->{chksum},$meta"; # mangle data checksum and metadata
2773
2774 my $idx = (cf::face::find $name) || cf::face::alloc $name;
2775 cf::face::set_type $idx, 1;
2776 cf::face::set_data $idx, 0, $data, $chk;
2777
2778 cf::cede_to_tick;
2779 }
2752 } 2780 }
2753 2781
2754 1 2782 1
2755} 2783}
2756 2784
2757sub reload_regions { 2785sub reload_regions {
2758 load_resource_file "$MAPDIR/regions" 2786 load_resource_file "$MAPDIR/regions"
2759 or die "unable to load regions file\n"; 2787 or die "unable to load regions file\n";
2788
2789 for (cf::region::list) {
2790 $_->{match} = qr/$_->{match}/
2791 if exists $_->{match};
2792 }
2760} 2793}
2761 2794
2762sub reload_facedata { 2795sub reload_facedata {
2763 load_facedata "$DATADIR/facedata" 2796 load_facedata "$DATADIR/facedata"
2764 or die "unable to load facedata\n"; 2797 or die "unable to load facedata\n";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines