--- deliantra/Deliantra-Client/DC/Protocol.pm 2007/12/29 13:44:30 1.187 +++ deliantra/Deliantra-Client/DC/Protocol.pm 2008/05/20 02:49:56 1.198 @@ -29,8 +29,8 @@ $self->{map_widget}->clr_commands; my @cmd_help = map { - $_->{kw}[0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x - or die "unparseable command help: $_->{kw}[0]"; + $_->[DC::Pod::N_KW][0] =~ /^(\S+) (?:\s+ \( ([^\)]*) \) )?/x + or die "unparseable command help: $_->[DC::Pod::N_KW][0]"; my $cmd = $1; my @args = split /\|/, $2; @@ -45,7 +45,7 @@ map ["$cmd$_", $text], sort { (length $a) <=> (length $b) } @args - } sort { $a->{par} <=> $b->{par} } + } sort { $a->[DC::Pod::N_PAR] <=> $b->[DC::Pod::N_PAR] } DC::Pod::find command => "*"; $self->{json_coder} @@ -66,6 +66,11 @@ $_->destroy for values %{delete $ws->{w} || {}}; } + + delete $self->{items}; + $::INV->clear; + $::INVR_HB->clear; + $::FLOORBOX->clear; }); $self->{map_widget}->add_command (@$_) @@ -277,6 +282,7 @@ floorbox => $::FLOORBOX, help_window => $::HELP_WINDOW, message_window => $::MESSAGE_WINDOW, + message_dist => $::MESSAGE_DIST, statusbox => $::SDTATUSBOX, inv => $::INV, @@ -335,7 +341,7 @@ sub ext_channel_info { my ($self, $info) = @_; $self->{channels}->{$info->{id}} = $info; - $::MESSAGE_WINDOW->add_channel ($info); + $::MESSAGE_DIST->add_channel ($info); } ############################################################################# @@ -680,20 +686,26 @@ sub flush_map { my ($self) = @_; - my $map_info = delete $self->{map_info} - or return; + return unless $self->{map_info}; - my ($hash, $x, $y, $w, $h) = @$map_info; + for my $map_info (values %{ $self->{map_cache} || {} }) { + my ($hash, $rdata, $x, $y, $w, $h) = @$map_info; - my $data = Compress::LZF::compress $self->{map}->get_rect ($x, $y, $w, $h); - $self->{map_cache_new}{$hash} = \$data; - DC::DB::put $self->{mapcache} => $hash => $data, sub { }; + my $data = $self->{map}->get_rect ($x, $y, $w, $h); + + if ($data ne $$rdata) { + $map_info->[1] = \$data; + my $cdata = Compress::LZF::compress $data; + DC::DB::put $self->{mapcache} => $hash => $cdata, sub { }; + } + } } sub map_clear { my ($self) = @_; $self->flush_map; + delete $self->{map_info}; delete $self->{neigh_map}; $self->{map}->clear; @@ -724,36 +736,34 @@ }; } -sub load_map($$$) { - my ($self, $hash, $x, $y) = @_; +sub load_map($$$$$$) { + my ($self, $hash, $x, $y, $w, $h) = @_; - my $gen = $self->{map_change_gen}; + my $map_info = $self->{map_cache}{$hash} = [$hash, \"", $x, $y, $w, $h]; my $cb = sub { - return unless $gen == $self->{map_change_gen}; - - my ($data) = @_; + $map_info->[1] = \$_[0]; - if (defined $data) { - $self->{map_cache_new}{$hash} = \$data; - - my $data = Compress::LZF::decompress $data; - - my $inprogress = @{ $self->{bg_fetch} || [] }; - unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); - $self->bg_fetch unless $inprogress; - } + my $inprogress = @{ $self->{bg_fetch} || [] }; + unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $_[0]); + $self->bg_fetch unless $inprogress; }; - if (my $rdata = $self->{map_cache_old}{$hash}) { - $cb->($$rdata); + if (my $map_info = $self->{map_cache_old}{$hash}) { + $cb->(${ $map_info->[1] }); } else { - DC::DB::get $self->{mapcache} => $hash, $cb; + my $gen = $self->{map_change_gen}; + + DC::DB::get $self->{mapcache} => $hash, sub { + return unless $gen == $self->{map_change_gen}; + return unless defined $_[0]; + $cb->(Compress::LZF::decompress $_[0]); + }; } } # hardcode /world/world_xxx_xxx map names, the savings are enourmous, -# (server resource,s latency, bandwidth), so this hack is warranted. +# (server resources, latency, bandwidth), so this hack is warranted. # the right fix is to make real tiled maps with an overview file sub send_mapinfo { my ($self, $data, $cb) = @_; @@ -788,7 +798,7 @@ # this method does a "flood fill" into every tile direction # it assumes that tiles are arranged in a rectangular grid, # i.e. a map is the same as the left of the right map etc. -# failure to comply are harmless and result in display errors +# failure to comply is harmless and results in display errors # at worst. sub flood_fill { my ($self, $block, $gx, $gy, $path, $hash, $flags) = @_; @@ -834,7 +844,7 @@ $x += $self->{map}->ox; $y += $self->{map}->oy; - $self->load_map ($hash, $x, $y) + $self->load_map ($hash, $x, $y, $w, $h) unless $self->{neigh_map}{$hash}[5]++;#d# $neigh->[$tile] = [$flags, $x, $y, $w, $h, $hash]; @@ -852,7 +862,7 @@ $self->flush_map; ++$self->{map_change_gen}; - $self->{map_cache_old} = delete $self->{map_cache_new}; + $self->{map_cache_old} = delete $self->{map_cache}; my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); @@ -874,7 +884,7 @@ (my $map = $hash) =~ s/^.*?\/([^\/]+)$/\1/; $::STATWIDS->{map}->set_text ("Map: " . $map); - $self->load_map ($hash, $x, $y); + $self->load_map ($hash, $x, $y, $w, $h); $self->flood_fill (0, 0, 0, "", $hash, $flags); } @@ -1027,6 +1037,8 @@ s/(.*?)<\/fg>/$2<\/span>/gs; s/(.*?)<\/fg>/$2<\/span>/gs; + s/\s+$//; + $_ } @@ -1141,7 +1153,7 @@ for my $node (DC::Pod::find skill_description => "*") { my (undef, @par) = DC::Pod::section_of $node; - $skill_help{$node->{kw}[0]} = DC::Pod::as_label @par; + $skill_help{$node->[DC::Pod::N_KW][0]} = DC::Pod::as_label @par; }; for my $skill (values %{$self->{skill_info}}) { @@ -1171,7 +1183,8 @@ my @add; my $row; - for (sort { $a->{count} <=> $b->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { + for (sort { $b->{count} <=> $a->{count} } values %{ $::CONN->{container}{$::CONN->{open_container} || 0} }) { + next if $_->{tag} & 0x80000000; if ($row < 6) { local $_->{face_widget}; # hack to force recreation of widget local $_->{desc_widget}; # hack to force recreation of widget @@ -1208,7 +1221,7 @@ $conn->{open_container} = $tag; update_floorbox; - $::INVR_HB->clear (); + $::INVR_HB->clear; $::INVR_HB->add (new DC::UI::Label expand => 1, text => $name); if ($tag != 0) { # Floor isn't closable, is it? @@ -1274,10 +1287,10 @@ sub item_update { my ($self, $item) = @_; - #d# print "item_update: $item->{tag} in $item->{container} ($self->{player}{tag}) ($::CONN->{open_container})\n"; + #print "item_update: $item->{tag} in $item->{container} pt($self->{player}{tag}) oc($::CONN->{open_container}) f($item->{flags})\n"; DC::Item::update_widgets $item; - + if ($item->{tag} == $::CONN->{open_container} && not ($item->{flags} & F_OPEN)) { set_opencont ($::CONN, 0, "Floor"); @@ -1321,7 +1334,7 @@ . "editing support $yesno[!!$self->{editor_support}]\n" . "map attributes $yesno[$self->{setup}{extmap} > 0]\n" . "big image protocol support $yesno[$self->{setup}{fxix} > 0]\n" - . "cfplus support $yesno[$self->{cfplus_ext} > 0]" + . "client support $yesno[$self->{cfplus_ext} > 0]" . ($self->{cfplus_ext} > 0 ? ", version $self->{cfplus_ext}" : "") ."\n" . "map size $self->{mapw}×$self->{maph}\n" );