--- deliantra/Deliantra-Client/DC/Protocol.pm 2007/07/24 05:13:23 1.132 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2007/07/29 18:56:02 1.140 @@ -60,6 +60,8 @@ $self->connect_ext (capabilities => sub { my (%cap) = @_; + #$self->send ("setup sound 0"); # we use a different protocol + $self->send_exti_msg (fx_want => { 3 => !!$::CFG->{bgm_enable}, # FT_MUSIC 5 => !!$::CFG->{audio_enable}, # FT_SOUND @@ -187,6 +189,13 @@ $self->send_exti_msg (w_r => $rid, [map $w->{$_}, @$attr]); }); + # message window + $self->connect_ext (channel_info => sub { + my ($info) = @_; + $self->{channels}->{$info->{id}} = $info; + $::MESSAGE_WINDOW->add_channel ($info); + }); + # destroy widgets on logout $self->{on_stop_game_guard} = $self->{map_widget}{root}->connect (stop_game => sub { for my $ws (values %{delete $self->{widgetset} || {}}) { @@ -728,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; } } @@ -753,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->(); @@ -809,8 +826,9 @@ sub sound_play { my ($self, $x, $y, $soundnum, $type) = @_; + warn "sound play <@_>\n";#d# - $self->{sound_play}->($x, $y, $soundnum, $type); + #$self->{sound_play}->($x, $y, $soundnum, $type); } my $LAST_QUERY; # server is stupid, stupid, stupid @@ -885,13 +903,13 @@ $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 #$text =~ s/(?<=\S)\n(?=\w)/ /g; - ::message ({ fg => $fg, markup => $_ }) + ::message ({ fg => $fg, markup => $_, type => $type, extra => [@extra] }) for split /\n/, $text; $self->{statusbox}->add ($text, @@ -958,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; @@ -1157,7 +1141,6 @@ . "map size $self->{mapw}×$self->{maph}\n" ); - ::setup_build_button ($self->{editor_support}->{builder_ui}); } sub logged_in { @@ -1189,14 +1172,6 @@ $self->send_command ("pickup $::CFG->{pickup}"); } -sub buildat { - my ($self, $builditem, $x, $y) = @_; - - if ($self->{cfplus_ext}) { - $self->send_ext_msg (builder_build => dx => $x, dy => $y, (ref ($builditem) eq 'HASH') ? %$builditem : (item => $builditem)); - } -} - sub lookat { my ($self, $x, $y) = @_;