ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.563 by root, Sat Apr 23 04:56:51 2011 UTC vs.
Revision 1.564 by elmex, Thu Apr 28 14:58:08 2011 UTC

1816 for (@$files) { 1816 for (@$files) {
1817 utf8::decode $_; 1817 utf8::decode $_;
1818 next if /\.(?:pl|pst)$/; 1818 next if /\.(?:pl|pst)$/;
1819 next unless /^$PATH_SEP/o; 1819 next unless /^$PATH_SEP/o;
1820 1820
1821 push @paths, cf::map::normalise "~$pl/$_"; 1821 push @paths, cf::map::normalise "~$pl/$_", $pl->map;
1822 } 1822 }
1823 1823
1824 \@paths 1824 \@paths
1825} 1825}
1826 1826
1954 # {... are special paths that are not being touched 1954 # {... are special paths that are not being touched
1955 # ?xxx/... are special absolute paths 1955 # ?xxx/... are special absolute paths
1956 # ?random/... random maps 1956 # ?random/... random maps
1957 # /... normal maps 1957 # /... normal maps
1958 # ~user/... per-player map of a specific user 1958 # ~user/... per-player map of a specific user
1959 # !up !down for quad maps, or other maps with up/down layers
1959 1960
1960 $path =~ s/$PATH_SEP/\//go; 1961 $path =~ s/$PATH_SEP/\//go;
1961 1962
1962 # treat it as relative path if it starts with 1963 # treat it as relative path if it starts with
1963 # something that looks reasonable 1964 # something that looks reasonable
1964 if ($path =~ m{^(?:\./|\.\./|\w)}) { 1965 if ($path =~ m{^(?:\./|\.\./|\w)}) {
1965 $base or Carp::carp "normalise called with relative path and no base: '$path'"; 1966 $base or Carp::carp "normalise called with relative path and no base: '$path'";
1966 1967
1967 $base =~ s{[^/]+/?$}{}; 1968 $base =~ s{[^/]+/?$}{};
1968 $path = "$base/$path"; 1969 $path = "$base/$path";
1970
1971 } elsif ($path eq '!up') {
1972 $base && ref $base
1973 or Carp::carp "normalise called with relative tile path and no base: '$path'";
1974
1975 my $uppth = $base->tile_path (cf::TILE_UP);
1976 $path = $uppth if $uppth;
1977
1978 } elsif ($path eq '!down') {
1979 $base && ref $base
1980 or Carp::carp "normalise called with relative tile path and no base: '$path'";
1981
1982 my $dpth = $base->tile_path (cf::TILE_DOWN);
1983 $path = $dpth if $dpth;
1969 } 1984 }
1970 1985
1971 for ($path) { 1986 for ($path) {
1972 redo if s{/\.?/}{/}; 1987 redo if s{/\.?/}{/};
1973 redo if s{/[^/]+/\.\./}{/}; 1988 redo if s{/[^/]+/\.\./}{/};
2126sub find { 2141sub find {
2127 my ($path, $origin) = @_; 2142 my ($path, $origin) = @_;
2128 2143
2129 cf::cede_to_tick; 2144 cf::cede_to_tick;
2130 2145
2131 $path = normalise $path, $origin && $origin->path; 2146 $path = normalise $path, $origin;
2132 2147
2133 my $guard1 = cf::lock_acquire "map_data:$path";#d#remove 2148 my $guard1 = cf::lock_acquire "map_data:$path";#d#remove
2134 my $guard2 = cf::lock_acquire "map_find:$path"; 2149 my $guard2 = cf::lock_acquire "map_find:$path";
2135 2150
2136 $cf::MAP{$path} || do { 2151 $cf::MAP{$path} || do {
2291our $MAP_PREFETCHER = undef; 2306our $MAP_PREFETCHER = undef;
2292 2307
2293sub find_async { 2308sub find_async {
2294 my ($path, $origin, $load) = @_; 2309 my ($path, $origin, $load) = @_;
2295 2310
2296 $path = normalise $path, $origin && $origin->{path}; 2311 $path = normalise $path, $origin;
2297 2312
2298 if (my $map = $cf::MAP{$path}) { 2313 if (my $map = $cf::MAP{$path}) {
2299 return $map if !$load || $map->in_memory == cf::MAP_ACTIVE; 2314 return $map if !$load || $map->in_memory == cf::MAP_ACTIVE;
2300 } 2315 }
2301 2316
2812 ($path, $x, $y) = (undef, undef, undef); 2827 ($path, $x, $y) = (undef, undef, undef);
2813 } 2828 }
2814 } 2829 }
2815 2830
2816 my $map = eval { 2831 my $map = eval {
2817 my $map = defined $path ? cf::map::find $path : undef; 2832 my $map = defined $path ? cf::map::find $path, $self->map : undef;
2818 2833
2819 if ($map) { 2834 if ($map) {
2820 $map = $map->customise_for ($self); 2835 $map = $map->customise_for ($self);
2821 $map = $check->($map, $x, $y, $self) if $check && $map; 2836 $map = $check->($map, $x, $y, $self) if $check && $map;
2822 } else { 2837 } else {
2920 2935
2921 prepare_random_map $exit 2936 prepare_random_map $exit
2922 if $exit->slaying eq "/!"; 2937 if $exit->slaying eq "/!";
2923 } 2938 }
2924 2939
2925 my $map = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path; 2940 my $map = cf::map::normalise $exit->slaying, $exit->map;
2926 my $x = $exit->stats->hp; 2941 my $x = $exit->stats->hp;
2927 my $y = $exit->stats->sp; 2942 my $y = $exit->stats->sp;
2928 2943
2929 $self->goto ($map, $x, $y); 2944 $self->goto ($map, $x, $y);
2930 2945

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines