--- deliantra/Deliantra-Client/DC/Protocol.pm 2007/07/28 00:45:28 1.137 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2007/07/29 18:56:02 1.140 @@ -737,7 +737,7 @@ } elsif ($face->{type} & 1) { # with metadata #::message ({ markup => "starting to download song #$face/$pri, check your output-rate setting if your connection gets laggy." }); - CFPlus::DB::get "res-metadata" => $face->{name}, $cb; + CFPlus::DB::get res_meta => $face->{name}, $cb; } } @@ -762,20 +762,28 @@ &::audio_music_set ($self->{songs}); }; + } elsif ($face->{type} == 5) { # FT_SOUND + $cb = sub { + $self->{sound_meta}{$facenum} = $face; + + use Data::Dumper; warn Dumper $face;#d# + ::message ({ markup => "downloaded sound #$facenum" }) + if $changed; + }; } + if ($changed) { # new data my ($meta_json, $data) = unpack "(w/a*)*", delete $face->{data}; - my $path = CFPlus::DB::path_of_res $face->{name}; - CFPlus::DB::write_file $path, $data, sub { - CFPlus::DB::put "res-metadata" => $face->{name} => $meta_json, sub { + CFPlus::DB::put res_data => $face->{name} => $data, sub { + CFPlus::DB::put res_meta => $face->{name} => $meta_json, sub { $face->{meta} = $self->{json_coder}->decode ($meta_json); - $face->{path} = $path; $cb->(); }; }; + } else { $face->{meta} = $self->{json_coder}->decode (delete $face->{data}); $cb->(); @@ -895,7 +903,7 @@ $self->logprint ("msg: ", $text); return if $color < 0; # negative color == ignore if not understood - my $fg = $CF_COLOR[$color % @CF_COLOR]; + my $fg = $CF_COLOR[$color & 0x1f] || [1, 0, 0]; ## try to create single paragraphs of multiple lines sent by the server # no longer neecssary with TRT servers @@ -968,40 +976,6 @@ ::stop_game (); } -sub image_info { - my ($self, $numfaces) = @_; - - $self->{num_faces} = $numfaces; - $self->{face_prefetch} = [1 .. $numfaces]; - $self->face_prefetch; -} - -sub face_prefetch { - my ($self) = @_; - - return unless $::CFG->{face_prefetch}; - - if ($self->{num_faces}) { - return if @{ $self->{send_queue} || [] }; - my $todo = @{ $self->{face_prefetch} } - or return; - - my ($face) = splice @{ $self->{face_prefetch} }, + rand @{ $self->{face_prefetch} }, 1, (); - - $self->send ("requestinfo image_sums $face $face"); - - $self->{statusbox}->add (CFPlus::asxml "prefetching $todo", - group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]); - } elsif (!exists $self->{num_faces}) { - $self->send ("requestinfo image_info"); - - $self->{num_faces} = 0; - - $self->{statusbox}->add (CFPlus::asxml "starting to prefetch", - group => "prefetch", timeout => 3, fg => [1, 1, 0, 0.5]); - } -} - sub update_floorbox { $CFPlus::UI::ROOT->on_refresh ($::FLOORBOX => sub { return unless $::CONN;