… | |
… | |
1975 | })->prio (2); |
1975 | })->prio (2); |
1976 | } |
1976 | } |
1977 | }, |
1977 | }, |
1978 | ); |
1978 | ); |
1979 | |
1979 | |
1980 | =item $player_object->goto ($path, $x, $y) |
1980 | =item $player_object->goto ($path, $x, $y[, $check->($map)]) |
|
|
1981 | |
|
|
1982 | Moves the player to the given map-path and coordinates by first freezing |
|
|
1983 | her, loading and preparing them map, calling the provided $check callback |
|
|
1984 | that has to return the map if sucecssful, and then unfreezes the player on |
|
|
1985 | the new (success) or old (failed) map position. |
1981 | |
1986 | |
1982 | =cut |
1987 | =cut |
1983 | |
1988 | |
1984 | sub cf::object::player::goto { |
1989 | sub cf::object::player::goto { |
1985 | my ($self, $path, $x, $y) = @_; |
1990 | my ($self, $path, $x, $y, $check) = @_; |
1986 | |
1991 | |
1987 | $self->enter_link; |
1992 | $self->enter_link; |
1988 | |
1993 | |
1989 | (async { |
1994 | (async { |
1990 | my $map = eval { |
1995 | my $map = eval { |
1991 | my $map = cf::map::find $path; |
1996 | my $map = cf::map::find $path; |
|
|
1997 | |
|
|
1998 | if ($map) { |
1992 | $map = $map->customise_for ($self) if $map; |
1999 | $map = $map->customise_for ($self); |
|
|
2000 | $map = $check->($map) if $check && $map; |
|
|
2001 | } else { |
|
|
2002 | $self->message ("The exit to '$path' is closed", cf::NDI_UNIQUE | cf::NDI_RED); |
|
|
2003 | } |
|
|
2004 | |
1993 | $map |
2005 | $map |
|
|
2006 | }; |
|
|
2007 | |
|
|
2008 | if ($@) { |
|
|
2009 | $self->message ("Something went wrong within the server, please report this incident!", cf::NDI_UNIQUE | cf::NDI_RED); |
|
|
2010 | LOG llevError | logBacktrace, Carp::longmess $@; |
1994 | } or |
2011 | } |
1995 | $self->message ("The exit to '$path' is closed", cf::NDI_UNIQUE | cf::NDI_RED); |
|
|
1996 | |
2012 | |
1997 | $self->leave_link ($map, $x, $y); |
2013 | $self->leave_link ($map, $x, $y); |
1998 | })->prio (1); |
2014 | })->prio (1); |
1999 | } |
2015 | } |
2000 | |
2016 | |
… | |
… | |
2848 | my $signal = new Coro::Signal; |
2864 | my $signal = new Coro::Signal; |
2849 | push @WAIT_FOR_TICK_BEGIN, $signal; |
2865 | push @WAIT_FOR_TICK_BEGIN, $signal; |
2850 | $signal->wait; |
2866 | $signal->wait; |
2851 | } |
2867 | } |
2852 | |
2868 | |
|
|
2869 | my $min = 1e6;#d# |
|
|
2870 | my $avg = 10; |
2853 | $TICK_WATCHER = Event->timer ( |
2871 | $TICK_WATCHER = Event->timer ( |
2854 | reentrant => 0, |
2872 | reentrant => 0, |
2855 | parked => 1, |
2873 | parked => 1, |
2856 | prio => 0, |
2874 | prio => 0, |
2857 | at => $NEXT_TICK || $TICK, |
2875 | at => $NEXT_TICK || $TICK, |
… | |
… | |
2864 | } |
2882 | } |
2865 | |
2883 | |
2866 | $NOW = $tick_start = Event::time; |
2884 | $NOW = $tick_start = Event::time; |
2867 | |
2885 | |
2868 | cf::server_tick; # one server iteration |
2886 | cf::server_tick; # one server iteration |
|
|
2887 | |
|
|
2888 | 0 && sync_job {#d# |
|
|
2889 | for(1..10) { |
|
|
2890 | my $t = Event::time; |
|
|
2891 | my $map = my $map = new_from_path cf::map "/tmp/x.map" |
|
|
2892 | or die; |
|
|
2893 | |
|
|
2894 | $map->width (50); |
|
|
2895 | $map->height (50); |
|
|
2896 | $map->alloc; |
|
|
2897 | $map->_load_objects ("/tmp/x.map", 1); |
|
|
2898 | my $t = Event::time - $t; |
|
|
2899 | |
|
|
2900 | #next unless $t < 0.0013;#d# |
|
|
2901 | if ($t < $min) { |
|
|
2902 | $min = $t; |
|
|
2903 | } |
|
|
2904 | $avg = $avg * 0.99 + $t * 0.01; |
|
|
2905 | } |
|
|
2906 | warn "XXXXXXXXXXXXXXXXXX min $min avg $avg\n";#d# |
|
|
2907 | exit 0; |
|
|
2908 | # 2007-05-22 02:33:04.569 min 0.00112509727478027 avg 0.0012259249572477 |
|
|
2909 | }; |
2869 | |
2910 | |
2870 | $RUNTIME += $TICK; |
2911 | $RUNTIME += $TICK; |
2871 | $NEXT_TICK += $TICK; |
2912 | $NEXT_TICK += $TICK; |
2872 | |
2913 | |
2873 | if ($NOW >= $NEXT_RUNTIME_WRITE) { |
2914 | if ($NOW >= $NEXT_RUNTIME_WRITE) { |