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.301 by root, Tue Jul 10 07:01:51 2007 UTC vs.
Revision 1.302 by root, Tue Jul 10 16:23:59 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
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},
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 use Data::Dumper; warn Dumper substr $data, 0, 100;#d#
2775
2776 my $idx = (cf::face::find $name) || cf::face::alloc $name;
2777 cf::face::set_type $idx, 1;
2778 cf::face::set_data $idx, 0, $data, $chk;
2779
2780 # TODO
2781 cf::cede_to_tick;
2782 }
2752 } 2783 }
2753 2784
2754 1 2785 1
2755} 2786}
2756 2787

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines