ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/lib/cf.pm
(Generate patch)

Comparing deliantra/server/lib/cf.pm (file contents):
Revision 1.267 by root, Sat May 19 00:08:11 2007 UTC vs.
Revision 1.268 by root, Tue May 22 10:50:00 2007 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines