… | |
… | |
614 | |
614 | |
615 | my ($hash, $x, $y, $w, $h) = @$map_info; |
615 | my ($hash, $x, $y, $w, $h) = @$map_info; |
616 | |
616 | |
617 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
617 | my $data = $MAP->get_rect ($x, $y, $w, $h); |
618 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
618 | $MAPCACHE->put ($hash => Compress::LZF::compress $data); |
619 | |
|
|
620 | warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
619 | #warn sprintf "SAVEmap[%s] length %d\n", $hash, length $data;#d# |
621 | |
|
|
622 | } |
620 | } |
623 | |
621 | |
624 | sub conn::map_clear { |
622 | sub conn::map_clear { |
625 | my ($self) = @_; |
623 | my ($self) = @_; |
626 | |
624 | |
… | |
… | |
634 | sub conn::load_map($$$) { |
632 | sub conn::load_map($$$) { |
635 | my ($self, $hash, $x, $y) = @_; |
633 | my ($self, $hash, $x, $y) = @_; |
636 | |
634 | |
637 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
635 | if (defined (my $data = $MAPCACHE->get ($hash))) { |
638 | $data = Compress::LZF::decompress $data; |
636 | $data = Compress::LZF::decompress $data; |
639 | warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
637 | #warn sprintf "LOADmap[%s,%d,%d] length %d\n", $hash, $x, $y, length $data;#d# |
640 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
638 | for my $id ($MAP->set_rect ($x, $y, $data)) { |
641 | my $data = $TILECACHE->get ($id) |
639 | my $data = $TILECACHE->get ($id) |
642 | or next; |
640 | or next; |
643 | |
641 | |
644 | $self->set_texture ($id => $data); |
642 | $self->set_texture ($id => $data); |
645 | } |
643 | } |
646 | } |
644 | } |
647 | } |
645 | } |
648 | |
646 | |
|
|
647 | # this method does a "flood fill" into every tile direction |
|
|
648 | # it assumes that tiles are arranged in a rectangular grid, |
|
|
649 | # i.e. a map is the same as the left of the right map etc. |
|
|
650 | # failure to comply are harmless and result in display errors |
|
|
651 | # at worst. |
649 | sub conn::flood_fill { |
652 | sub conn::flood_fill { |
650 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
653 | my ($self, $gx, $gy, $path, $hash, $flags) = @_; |
651 | |
654 | |
652 | # the server does not allow map paths > 6 |
655 | # the server does not allow map paths > 6 |
653 | return if 6 <= length $path; |
656 | return if 6 <= length $path; |
… | |
… | |
705 | |
708 | |
706 | my $mapmapw = 250; |
709 | my $mapmapw = 250; |
707 | my $mapmaph = 250; |
710 | my $mapmaph = 250; |
708 | |
711 | |
709 | $self->{neigh_rect} = [ |
712 | $self->{neigh_rect} = [ |
710 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
713 | $ox - $mapmapw * 0.5, $oy - $mapmapw * 0.5, |
711 | $ox + $mapmapw * 0.5, $oy + $mapmapw * 0.5, |
714 | $ox + $mapmapw * 0.5 + $w, $oy + $mapmapw * 0.5 + $h, |
712 | ]; |
715 | ]; |
713 | |
716 | |
714 | delete $self->{neigh_grid}; |
717 | delete $self->{neigh_grid}; |
715 | $self->flood_fill (0, 0, "", $hash, $flags); |
718 | $self->flood_fill (0, 0, "", $hash, $flags); |
716 | |
719 | |