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.151 by root, Sun Aug 12 09:39:49 2007 UTC vs.
Revision 1.152 by root, Mon Aug 13 14:15:09 2007 UTC

596sub load_map($$$) { 596sub load_map($$$) {
597 my ($self, $hash, $x, $y) = @_; 597 my ($self, $hash, $x, $y) = @_;
598 598
599 my $gen = $self->{map_change_gen}; 599 my $gen = $self->{map_change_gen};
600 600
601 CFPlus::DB::get $self->{mapcache} => $hash, sub { 601 my $cb = sub {
602 return unless $gen == $self->{map_change_gen}; 602 return unless $gen == $self->{map_change_gen};
603 603
604 my ($data) = @_; 604 my ($data) = @_;
605 605
606 if (defined $data) { 606 if (defined $data) {
607 $self->{map_cache_new}{$hash} = \$data;
608
607 $data = Compress::LZF::decompress $data; 609 my $data = Compress::LZF::decompress $data;
608 #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d#
609 610
610 my $inprogress = @{ $self->{bg_fetch} || [] }; 611 my $inprogress = @{ $self->{bg_fetch} || [] };
611 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data); 612 unshift @{ $self->{bg_fetch} }, $self->{map}->set_rect ($x, $y, $data);
612 $self->bg_fetch unless $inprogress; 613 $self->bg_fetch unless $inprogress;
613 } 614 }
614 }; 615 };
616
617 if (my $rdata = $self->{map_cache_old}{$hash}) {
618 $cb->($$rdata);
619 } else {
620 CFPlus::DB::get $self->{mapcache} => $hash, $cb;
621 }
615} 622}
616 623
617# hardcode /world/world_xxx_xxx map names, the savings are enourmous, 624# hardcode /world/world_xxx_xxx map names, the savings are enourmous,
618# (server resource,s latency, bandwidth), so this hack is warranted. 625# (server resource,s latency, bandwidth), so this hack is warranted.
619# the right fix is to make real tiled maps with an overview file 626# the right fix is to make real tiled maps with an overview file
712 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_; 719 my ($self, $mode, $flags, $x, $y, $w, $h, $hash) = @_;
713 720
714 $self->flush_map; 721 $self->flush_map;
715 722
716 ++$self->{map_change_gen}; 723 ++$self->{map_change_gen};
724 $self->{map_cache_old} = delete $self->{map_cache_new};
717 725
718 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy); 726 my ($ox, $oy) = ($::MAP->ox, $::MAP->oy);
719 727
720 my $mapmapw = $self->{mapmap}->{w}; 728 my $mapmapw = $self->{mapmap}->{w};
721 my $mapmaph = $self->{mapmap}->{h}; 729 my $mapmaph = $self->{mapmap}->{h};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines