--- deliantra/server/lib/cf.pm 2008/05/03 15:17:13 1.429 +++ deliantra/server/lib/cf.pm 2008/05/04 14:12:37 1.430 @@ -2700,8 +2700,6 @@ sub prepare_random_map { my ($exit) = @_; - my $guard = cf::lock_acquire "exit_prepare:$exit"; - # all this does is basically replace the /! path by # a new random map path (?random/...) with a seed # that depends on the exit object @@ -2713,6 +2711,8 @@ $rmp->{origin_map} = $exit->map->path; $rmp->{origin_x} = $exit->x; $rmp->{origin_y} = $exit->y; + + $exit->map->touch; } $rmp->{random_seed} ||= $exit->random_seed; @@ -2726,8 +2726,12 @@ undef $fh; aio_rename "$meta~", $meta; - $exit->slaying ("?random/$md5"); - $exit->msg (undef); + my $slaying = "?random/$md5"; + + if ($exit->valid) { + $exit->slaying ("?random/$md5"); + $exit->msg (undef); + } } } @@ -2736,31 +2740,33 @@ return unless $self->type == cf::PLAYER; - if ($exit->slaying eq "/!") { - #TODO: this should de-fi-ni-te-ly not be a sync-job - # the problem is that $exit might not survive long enough - # so it needs to be done right now, right here - cf::sync_job { prepare_random_map $exit }; - } - - my $slaying = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path; - my $hp = $exit->stats->hp; - my $sp = $exit->stats->sp; - $self->enter_link; - # if exit is damned, update players death & WoR home-position - $self->contr->savebed ($slaying, $hp, $sp) - if $exit->flag (FLAG_DAMNED); - (async { - $Coro::current->{desc} = "enter_exit $slaying $hp $sp"; + $Coro::current->{desc} = "enter_exit"; - $self->deactivate_recursive; # just to be sure unless (eval { - $self->goto ($slaying, $hp, $sp); + $self->deactivate_recursive; # just to be sure + + # random map handling + { + my $guard = cf::lock_acquire "exit_prepare:$exit"; + + prepare_random_map $exit + if $exit->slaying eq "/!"; + } + + my $map = cf::map::normalise $exit->slaying, $exit->map && $exit->map->path; + my $x = $exit->stats->hp; + my $y = $exit->stats->sp; + + $self->goto ($map, $x, $y); + + # if exit is damned, update players death & WoR home-position + $self->contr->savebed ($map, $x, $y) + if $exit->flag (cf::FLAG_DAMNED); - 1; + 1 }) { $self->message ("Something went wrong deep within the crossfire server. " . "I'll try to bring you back to the map you were before. "