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.567 by root, Mon May 2 16:16:00 2011 UTC

2069 $self->{load_path} = $path; 2069 $self->{load_path} = $path;
2070 2070
2071 1 2071 1
2072} 2072}
2073 2073
2074# used to laod the header of an original map
2074sub load_header_orig { 2075sub load_header_orig {
2075 my ($self) = @_; 2076 my ($self) = @_;
2076 2077
2077 $self->load_header_from ($self->load_path) 2078 $self->load_header_from ($self->load_path)
2078} 2079}
2079 2080
2081# used to laod the header of an instantiated map
2080sub load_header_temp { 2082sub load_header_temp {
2081 my ($self) = @_; 2083 my ($self) = @_;
2082 2084
2083 $self->load_header_from ($self->save_path) 2085 $self->load_header_from ($self->save_path)
2084} 2086}
2085 2087
2088# called after loading the header from an instantiated map
2086sub prepare_temp { 2089sub prepare_temp {
2087 my ($self) = @_; 2090 my ($self) = @_;
2088 2091
2089 $self->last_access ((delete $self->{last_access}) 2092 $self->last_access ((delete $self->{last_access})
2090 || $cf::RUNTIME); #d# 2093 || $cf::RUNTIME); #d#
2091 # safety 2094 # safety
2092 $self->{instantiate_time} = $cf::RUNTIME 2095 $self->{instantiate_time} = $cf::RUNTIME
2093 if $self->{instantiate_time} > $cf::RUNTIME; 2096 if $self->{instantiate_time} > $cf::RUNTIME;
2094} 2097}
2095 2098
2099# called after loading the header from an original map
2096sub prepare_orig { 2100sub prepare_orig {
2097 my ($self) = @_; 2101 my ($self) = @_;
2098 2102
2099 $self->{load_original} = 1; 2103 $self->{load_original} = 1;
2100 $self->{instantiate_time} = $cf::RUNTIME; 2104 $self->{instantiate_time} = $cf::RUNTIME;
2126sub find { 2130sub find {
2127 my ($path, $origin) = @_; 2131 my ($path, $origin) = @_;
2128 2132
2129 cf::cede_to_tick; 2133 cf::cede_to_tick;
2130 2134
2131 $path = normalise $path, $origin && $origin->path; 2135 $path = normalise $path, $origin;
2132 2136
2133 my $guard1 = cf::lock_acquire "map_data:$path";#d#remove 2137 my $guard1 = cf::lock_acquire "map_data:$path";#d#remove
2134 my $guard2 = cf::lock_acquire "map_find:$path"; 2138 my $guard2 = cf::lock_acquire "map_find:$path";
2135 2139
2136 $cf::MAP{$path} || do { 2140 $cf::MAP{$path} || do {
2197 } 2201 }
2198 } 2202 }
2199 } 2203 }
2200 2204
2201 $f->resolve_delayed_derefs; 2205 $f->resolve_delayed_derefs;
2206 } else {
2207 $self->post_load_original
2208 if delete $self->{load_original};
2202 } 2209 }
2203 2210
2204 cf::cede_to_tick; 2211 cf::cede_to_tick;
2205 # now do the right thing for maps 2212 # now do the right thing for maps
2206 $self->link_multipart_objects; 2213 $self->link_multipart_objects;
2291our $MAP_PREFETCHER = undef; 2298our $MAP_PREFETCHER = undef;
2292 2299
2293sub find_async { 2300sub find_async {
2294 my ($path, $origin, $load) = @_; 2301 my ($path, $origin, $load) = @_;
2295 2302
2296 $path = normalise $path, $origin && $origin->{path}; 2303 $path = normalise $path, $origin;
2297 2304
2298 if (my $map = $cf::MAP{$path}) { 2305 if (my $map = $cf::MAP{$path}) {
2299 return $map if !$load || $map->in_memory == cf::MAP_ACTIVE; 2306 return $map if !$load || $map->in_memory == cf::MAP_ACTIVE;
2300 } 2307 }
2301 2308
2812 ($path, $x, $y) = (undef, undef, undef); 2819 ($path, $x, $y) = (undef, undef, undef);
2813 } 2820 }
2814 } 2821 }
2815 2822
2816 my $map = eval { 2823 my $map = eval {
2817 my $map = defined $path ? cf::map::find $path : undef; 2824 my $map = defined $path ? cf::map::find $path, $self->map : undef;
2818 2825
2819 if ($map) { 2826 if ($map) {
2820 $map = $map->customise_for ($self); 2827 $map = $map->customise_for ($self);
2821 $map = $check->($map, $x, $y, $self) if $check && $map; 2828 $map = $check->($map, $x, $y, $self) if $check && $map;
2822 } else { 2829 } else {
2912 $Coro::current->{desc} = "enter_exit"; 2919 $Coro::current->{desc} = "enter_exit";
2913 2920
2914 unless (eval { 2921 unless (eval {
2915 $self->deactivate_recursive; # just to be sure 2922 $self->deactivate_recursive; # just to be sure
2916 2923
2917 # random map handling
2918 {
2919 my $guard = cf::lock_acquire "exit_prepare:$exit";
2920
2921 prepare_random_map $exit
2922 if $exit->slaying eq "/!";
2923 }
2924
2925 my $map = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path; 2924 my $map = cf::map::normalise $exit->slaying, $exit->map;
2926 my $x = $exit->stats->hp; 2925 my $x = $exit->stats->hp;
2927 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 }
2928 2948
2929 $self->goto ($map, $x, $y); 2949 $self->goto ($map, $x, $y);
2930 2950
2931 # if exit is damned, update players death & WoR home-position 2951 # if exit is damned, update players death & WoR home-position
2932 $self->contr->savebed ($map, $x, $y) 2952 $self->contr->savebed ($map, $x, $y)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines