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.566 by root, Sun May 1 16:58:16 2011 UTC vs.
Revision 1.567 by root, Mon May 2 16:16:00 2011 UTC

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
1960 1959
1961 $path =~ s/$PATH_SEP/\//go; 1960 $path =~ s/$PATH_SEP/\//go;
1962 1961
1963 # treat it as relative path if it starts with 1962 # treat it as relative path if it starts with
1964 # something that looks reasonable 1963 # something that looks reasonable
1965 if ($path =~ m{^(?:\./|\.\./|\w)}) { 1964 if ($path =~ m{^(?:\./|\.\./|\w)}) {
1966 $base or Carp::carp "normalise called with relative path and no base: '$path'"; 1965 $base or Carp::carp "normalise called with relative path and no base: '$path'";
1967 1966
1968 $base =~ s{[^/]+/?$}{}; 1967 $base =~ s{[^/]+/?$}{};
1969 $path = "$base/$path"; 1968 $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;
1984 } 1969 }
1985 1970
1986 for ($path) { 1971 for ($path) {
1987 redo if s{/\.?/}{/}; 1972 redo if s{/\.?/}{/};
1988 redo if s{/[^/]+/\.\./}{/}; 1973 redo if s{/[^/]+/\.\./}{/};
2934 $Coro::current->{desc} = "enter_exit"; 2919 $Coro::current->{desc} = "enter_exit";
2935 2920
2936 unless (eval { 2921 unless (eval {
2937 $self->deactivate_recursive; # just to be sure 2922 $self->deactivate_recursive; # just to be sure
2938 2923
2939 # random map handling
2940 {
2941 my $guard = cf::lock_acquire "exit_prepare:$exit";
2942
2943 prepare_random_map $exit
2944 if $exit->slaying eq "/!";
2945 }
2946
2947 my $map = cf::map::normalise $exit->slaying, $exit->map; 2924 my $map = cf::map::normalise $exit->slaying, $exit->map;
2948 my $x = $exit->stats->hp; 2925 my $x = $exit->stats->hp;
2949 my $y = $exit->stats->sp; 2926 my $y = $exit->stats->sp;
2927
2928 # special map handling
2929 my $slaying = $exit->slaying;
2930
2931 # special map handling
2932 if ($slaying eq "/!") {
2933 my $guard = cf::lock_acquire "exit_prepare:$exit";
2934
2935 prepare_random_map $exit
2936 if $slaying eq "/!"; # need to re-check after getting the lock
2937
2938 } elsif ($slaying eq '!up') {
2939 $map = $exit->map->tile_path (cf::TILE_UP);
2940 $x = $exit->x;
2941 $y = $exit->y;
2942
2943 } elsif ($slaying eq '!down') {
2944 $map = $exit->map->tile_path (cf::TILE_DOWN);
2945 $x = $exit->x;
2946 $y = $exit->y;
2947 }
2950 2948
2951 $self->goto ($map, $x, $y); 2949 $self->goto ($map, $x, $y);
2952 2950
2953 # if exit is damned, update players death & WoR home-position 2951 # if exit is damned, update players death & WoR home-position
2954 $self->contr->savebed ($map, $x, $y) 2952 $self->contr->savebed ($map, $x, $y)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines