ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC/Protocol.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC/Protocol.pm (file contents):
Revision 1.114 by root, Thu Jul 12 18:28:34 2007 UTC vs.
Revision 1.118 by root, Fri Jul 13 15:44:48 2007 UTC

57 57
58 my $faces = $ev->{faces}; 58 my $faces = $ev->{faces};
59 my @songs; 59 my @songs;
60 60
61 # request music from server if appropriate 61 # request music from server if appropriate
62 my $pri = -100; 62 if (my $faces = $ev->{faces}) {
63 for my $face (@$faces) { 63 for (@$faces) {
64 if (defined (my $chksum = $ev->{chksum}{$face})) { 64 my ($face, $pri, $chksum) = @$_;
65 utf8::downgrade $chksum; 65 utf8::downgrade $chksum;
66 66
67 $chksum = unpack "H*", $chksum; 67 $chksum = unpack "H*", $chksum;
68 $self->{music_map}{$face} = $chksum; 68 $self->{music_map}{$face} = $chksum;
69 69
70 # check if already cached 70 # check if already cached
71 CFPlus::DB::get resmap => $chksum, sub { 71 CFPlus::DB::get "res-metadata" => $chksum, sub {
72 my ($meta) = @_; 72 my ($meta) = @_;
73 73
74 if (defined $meta) { 74 if (defined $meta) {
75 $self->{music_meta}{$chksum} = $self->{json_coder}->decode ($meta); 75 $self->{music_meta}{$chksum} = $self->{json_coder}->decode ($meta);
76 } else { 76 } else {
77 ::message ({ markup => "starting to download song #$face, check your output-rate setting if your connection gets laggy." }); 77 ::message ({ markup => "starting to download song #$face/$pri, check your output-rate setting if your connection gets laggy." });
78 $self->ask_face ($face, $pri, undef, sub { 78 $self->ask_face ($face, -100 - $pri, undef, sub {
79 my $num = $_[0];
80 my $len = length $_[1]; 79 my $len = length $_[1];
81 my ($meta, $data) = unpack "(w/a*)*", $_[1]; 80 my ($meta, $data) = unpack "(w/a*)*", $_[1];
82 81
83 CFPlus::DB::write_file $chksum, $data, sub { }; 82 CFPlus::DB::write_file $chksum, $data, sub { };
84 CFPlus::DB::put resmap => $chksum => $meta, sub { }; 83 CFPlus::DB::put "res-metadata" => $chksum => $meta, sub { };
85 84
86 $self->{music_meta}{$chksum} = $self->{json_coder}->decode ($meta); 85 $self->{music_meta}{$chksum} = $self->{json_coder}->decode ($meta);
87 ::message ({ markup => "downloaded song #$face, size $len octets" }); 86 ::message ({ markup => "downloaded song #$face, size $len octets" });
88 87
89 &::audio_music_set ($self->{songs}); 88 &::audio_music_set ($self->{songs});
90 }); 89 });
91 } 90 }
92 } 91 }
93 } 92 }
94
95 push @songs, $self->{music_map}{$face};
96 --$pri;
97 } 93 }
98 94
99 &::audio_music_set ($self->{songs} = \@songs); 95 if (my $play = $ev->{play}) {
96 &::audio_music_set ($self->{songs} = [map $self->{music_map}{$_}, @$play]);
97 }
100 }); 98 });
101 99
102 $self->connect_ext (event_capabilities => sub { 100 $self->connect_ext (event_capabilities => sub {
103 my ($cap) = @_; 101 my ($cap) = @_;
104 102
761} 759}
762 760
763sub set_texture { 761sub set_texture {
764 my ($self, $id, $data) = @_; 762 my ($self, $id, $data) = @_;
765 763
764 return unless $self->{map};
765
766 $self->{texture}[$id] = my $tex = 766 $self->{texture}[$id] = my $tex =
767 new_from_image CFPlus::Texture 767 new_from_image CFPlus::Texture
768 $data, minify => 1, mipmap => 1; 768 $data, minify => 1, mipmap => 1;
769 769
770 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}}); 770 $self->{map}->set_texture ($id, @$tex{qw(name w h s t)}, @{$tex->{minified}});

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines