--- deliantra/server/lib/cf.pm 2007/05/22 10:50:00 1.268 +++ deliantra/server/lib/cf.pm 2007/06/03 15:32:50 1.272 @@ -397,9 +397,7 @@ # first touch the runtime file to show we are still running: # the fsync below can take a very very long time. - if (my $fh = aio_open $runtime, O_WRONLY, 0) { - utime undef, undef, $fh; - } + IO::AIO::aio_utime $runtime, undef, undef; my $guard = cf::lock_acquire "write_runtime"; @@ -418,7 +416,7 @@ and return; # touch it again to show we are up-to-date - utime undef, undef, $fh; + aio_utime $fh, undef, undef; close $fh or return; @@ -1906,7 +1904,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 +1912,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 +1945,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,14 +1954,13 @@ =cut +our $GOTOGEN; + sub cf::object::player::goto { my ($self, $path, $x, $y, $check) = @_; - #d# #TODO# - if ($check && !ref $check) { - warn Carp::longmess "goto called with non-ref check argument";#d# - undef $check; - } + # do generation counting so two concurrent goto's will be executed in-order + my $gen = $self->{_goto_generation} = ++$GOTOGEN; $self->enter_link; @@ -2016,7 +1983,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); } @@ -2511,8 +2481,6 @@ } } - - ############################################################################# # the server's init and main functions @@ -2535,6 +2503,7 @@ while (my ($face, $info) = each %$faces) { my $idx = (cf::face::find $face) || cf::face::alloc $face; + warn "$face $info->{magicmap}\n" if $face =~ /obol/;#d# cf::face::set $idx, $info->{visibility}, $info->{magicmap}; cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64};