--- deliantra/server/lib/cf.pm 2007/05/22 21:35:26 1.269 +++ deliantra/server/lib/cf.pm 2007/05/26 15:44:06 1.270 @@ -1906,7 +1906,7 @@ return if UNIVERSAL::isa $self->map, "ext::map_link"; $self->{_link_pos} ||= [$self->map->{path}, $self->x, $self->y] - if $self->map; + if $self->map && $self->map->{path} ne "{link}"; $self->enter_map ($LINK_MAP || link_map, 10, 10); } @@ -1914,6 +1914,8 @@ sub cf::object::player::leave_link { my ($self, $map, $x, $y) = @_; + return unless $self->contr->active; + my $link_pos = delete $self->{_link_pos}; unless ($map) { @@ -1945,38 +1947,6 @@ $self->enter_map ($map, $x, $y); } -cf::player->attach ( - on_logout => sub { - my ($pl) = @_; - - # abort map switching before logout - if ($pl->ob->{_link_pos}) { - cf::sync_job { - $pl->ob->leave_link - }; - } - }, - on_login => sub { - my ($pl) = @_; - - # try to abort aborted map switching on player login :) - # should happen only on crashes - if ($pl->ob->{_link_pos}) { - $pl->ob->enter_link; - (async { - $pl->ob->reply (undef, - "There was an internal problem at your last logout, " - . "the server will try to bring you to your intended destination in a second.", - cf::NDI_RED); - # we need this sleep as the login has a concurrent enter_exit running - # and this sleep increases chances of the player not ending up in scorn - Coro::Timer::sleep 1; - $pl->ob->leave_link; - })->prio (2); - } - }, -); - =item $player_object->goto ($path, $x, $y[, $check->($map)]) Moves the player to the given map-path and coordinates by first freezing @@ -1986,9 +1956,14 @@ =cut +our $GOTOGEN; + sub cf::object::player::goto { my ($self, $path, $x, $y, $check) = @_; + # do generation counting so two concurrent goto's will be executed in-order + my $gen = $self->{_goto_generation} = ++$GOTOGEN; + $self->enter_link; (async { @@ -2010,7 +1985,10 @@ LOG llevError | logBacktrace, Carp::longmess $@; } - $self->leave_link ($map, $x, $y); + if ($gen == $self->{_goto_generation}) { + delete $self->{_goto_generation}; + $self->leave_link ($map, $x, $y); + } })->prio (1); }