… | |
… | |
1916 | |
1916 | |
1917 | $self |
1917 | $self |
1918 | } |
1918 | } |
1919 | |
1919 | |
1920 | # find and load all maps in the 3x3 area around a map |
1920 | # find and load all maps in the 3x3 area around a map |
1921 | sub load_diag { |
1921 | sub load_neighbours { |
1922 | my ($map) = @_; |
1922 | my ($map) = @_; |
1923 | |
1923 | |
1924 | my @diag; # diagonal neighbours |
1924 | my @neigh; # diagonal neighbours |
1925 | |
1925 | |
1926 | for (0 .. 3) { |
1926 | for (0 .. 3) { |
1927 | my $neigh = $map->tile_path ($_) |
1927 | my $neigh = $map->tile_path ($_) |
1928 | or next; |
1928 | or next; |
1929 | $neigh = find $neigh, $map |
1929 | $neigh = find $neigh, $map |
1930 | or next; |
1930 | or next; |
1931 | $neigh->load; |
1931 | $neigh->load; |
1932 | |
1932 | |
|
|
1933 | push @neigh, |
1933 | push @diag, [$neigh->tile_path (($_ + 3) % 4), $neigh], |
1934 | [$neigh->tile_path (($_ + 3) % 4), $neigh], |
1934 | [$neigh->tile_path (($_ + 1) % 4), $neigh]; |
1935 | [$neigh->tile_path (($_ + 1) % 4), $neigh]; |
1935 | } |
1936 | } |
1936 | |
1937 | |
1937 | for (@diag) { |
1938 | for (grep defined $_->[0], @neigh) { |
|
|
1939 | my ($path, $origin) = @$_; |
1938 | my $neigh = find @$_ |
1940 | my $neigh = find $path, $origin |
1939 | or next; |
1941 | or next; |
1940 | $neigh->load; |
1942 | $neigh->load; |
1941 | } |
1943 | } |
1942 | } |
1944 | } |
1943 | |
1945 | |
… | |
… | |
2312 | # use -1 or undef as default coordinates, not 0, 0 |
2314 | # use -1 or undef as default coordinates, not 0, 0 |
2313 | ($x, $y) = ($map->enter_x, $map->enter_y) |
2315 | ($x, $y) = ($map->enter_x, $map->enter_y) |
2314 | if $x <=0 && $y <= 0; |
2316 | if $x <=0 && $y <= 0; |
2315 | |
2317 | |
2316 | $map->load; |
2318 | $map->load; |
2317 | $map->load_diag; |
2319 | $map->load_neighbours; |
2318 | |
2320 | |
2319 | return unless $self->contr->active; |
2321 | return unless $self->contr->active; |
2320 | $self->activate_recursive; |
2322 | $self->activate_recursive; |
2321 | |
2323 | |
2322 | local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext |
2324 | local $self->{_prev_pos} = $link_pos; # ugly hack for rent.ext |