--- deliantra/server/ext/follow.ext 2007/10/08 14:00:29 1.11 +++ deliantra/server/ext/follow.ext 2007/10/11 00:34:31 1.13 @@ -6,10 +6,14 @@ # implement a 'follow' command # don't follow on damned ground -my %follow; +our %follow; + +our $CORO = cf::async { + $Coro::current->{desc} = "follow handler"; + + while () { + cf::wait_for_tick; -my $timer = Event->timer (interval => 0.2, parked => 1, data => cf::WF_AUTOCANCEL, cb => sub { - cf::sync_job { while (my ($name, $v) = each %follow) { my ($target, $his, $mine) = @$v; my ($who, $other) = (cf::player::find_active $name, cf::player::find_active $target); @@ -17,7 +21,10 @@ if ($who && $other && $other->ob->map) { my ($map, $x, $y) = ($other->ob->map->path, $other->ob->x, $other->ob->y); - if ($map ne $his->[0] || $x != $his->[1] || $y != $his->[2]) { + if ( + ($map ne $his->[0] || $x != $his->[1] || $y != $his->[2]) + && $map !~ /^\{/ + ) { @$mine = @$his; @$his = ($map, $x, $y); } @@ -38,10 +45,10 @@ $who->ob->message ("$target is gone..."); } } - }; - $_[0]->w->stop unless keys %follow; -}); + Coro::schedule unless keys %follow; + } +}; cf::register_command follow => sub { my ($who, $args) = @_; @@ -60,7 +67,7 @@ [$other->ob->map->path, $other->ob->x, $other->ob->y], [$who->map->path, $who->x, $who->y], ]; - $timer->start; + $CORO->ready; } else { $who->message ("You must stand directly beside '$args' to follow her/him"); delete $follow{$name};