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.300 by root, Tue Jul 10 06:44:29 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
1435 s/\s+\n/\n/g; # ws line-ends 1436 s/\s+\n/\n/g; # ws line-ends
1436 s/\n\n+/\n/g; # double lines 1437 s/\n\n+/\n/g; # double lines
1437 s/^\n+//; # beginning lines 1438 s/^\n+//; # beginning lines
1438 s/\n+$//; # ending lines 1439 s/\n+$//; # ending lines
1439 1440
1440 warn $_;#d#
1441 $_ 1441 $_
1442} 1442}
1443 1443
1444sub hintmode { 1444sub hintmode {
1445 $_[0]{hintmode} = $_[1] if @_ > 1; 1445 $_[0]{hintmode} = $_[1] if @_ > 1;
2720 { 2720 {
2721 my $faces = $facedata->{faceinfo}; 2721 my $faces = $facedata->{faceinfo};
2722 2722
2723 while (my ($face, $info) = each %$faces) { 2723 while (my ($face, $info) = each %$faces) {
2724 my $idx = (cf::face::find $face) || cf::face::alloc $face; 2724 my $idx = (cf::face::find $face) || cf::face::alloc $face;
2725 cf::face::set $idx, $info->{visibility}, $info->{magicmap}; 2725 cf::face::set_visibility $idx, $info->{visibility};
2726 cf::face::set_magicmap $idx, $info->{magicmap};
2726 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; 2727 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32};
2727 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64}; 2728 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64};
2728 Coro::cede; 2729
2730 cf::cede_to_tick;
2729 } 2731 }
2730 2732
2731 while (my ($face, $info) = each %$faces) { 2733 while (my ($face, $info) = each %$faces) {
2732 next unless $info->{smooth}; 2734 next unless $info->{smooth};
2733 my $idx = cf::face::find $face 2735 my $idx = cf::face::find $face
2734 or next; 2736 or next;
2735 if (my $smooth = cf::face::find $info->{smooth}) { 2737 if (my $smooth = cf::face::find $info->{smooth}) {
2738 cf::face::set_smooth $idx, $smooth;
2736 cf::face::set_smooth $idx, $smooth, $info->{smoothlevel}; 2739 cf::face::set_smoothlevel $idx, $info->{smoothlevel};
2737 } else { 2740 } else {
2738 warn "smooth face '$info->{smooth}' not found for face '$face'"; 2741 warn "smooth face '$info->{smooth}' not found for face '$face'";
2739 } 2742 }
2740 Coro::cede; 2743
2744 cf::cede_to_tick;
2741 } 2745 }
2742 } 2746 }
2743 2747
2744 { 2748 {
2745 my $anims = $facedata->{animinfo}; 2749 my $anims = $facedata->{animinfo};
2746 2750
2747 while (my ($anim, $info) = each %$anims) { 2751 while (my ($anim, $info) = each %$anims) {
2748 cf::anim::set $anim, $info->{frames}, $info->{facings}; 2752 cf::anim::set $anim, $info->{frames}, $info->{facings};
2749 Coro::cede; 2753 cf::cede_to_tick;
2750 } 2754 }
2751 2755
2752 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 }
2753 } 2783 }
2754 2784
2755 1 2785 1
2756} 2786}
2757 2787

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines