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.138 by root, Fri Jan 5 17:07:17 2007 UTC vs.
Revision 1.139 by root, Fri Jan 5 19:12:03 2007 UTC

26use Event; $Event::Eval = 1; # no idea why this is required, but it is 26use Event; $Event::Eval = 1; # no idea why this is required, but it is
27 27
28# work around bug in YAML::Syck - bad news for perl6, will it be as broken wrt. unicode? 28# work around bug in YAML::Syck - bad news for perl6, will it be as broken wrt. unicode?
29$YAML::Syck::ImplicitUnicode = 1; 29$YAML::Syck::ImplicitUnicode = 1;
30 30
31$Coro::main->prio (2); # run main coroutine ("the server") with very high priority 31$Coro::main->prio (Coro::PRIO_MAX); # run main coroutine ("the server") with very high priority
32 32
33sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload 33sub WF_AUTOCANCEL () { 1 } # automatically cancel this watcher on reload
34 34
35our %COMMAND = (); 35our %COMMAND = ();
36our %COMMAND_TIME = (); 36our %COMMAND_TIME = ();
263 warn $@ if $@; 263 warn $@ if $@;
264 undef $busy; 264 undef $busy;
265 })->prio (Coro::PRIO_MAX); 265 })->prio (Coro::PRIO_MAX);
266 266
267 while ($busy) { 267 while ($busy) {
268 Coro::cede_notself; 268 unless (Coro::cede) {
269 Event::one_event unless Coro::nready; 269 Coro::nready ? Event::one_event 0 : Event::one_event;
270 Coro::cede_notself unless Coro::cede;
271 }
270 } 272 }
271 273
272 wantarray ? @res : $res[0] 274 wantarray ? @res : $res[0]
273 } else { 275 } else {
274 # we are in another coroutine, how wonderful, everything just works 276 # we are in another coroutine, how wonderful, everything just works
1268} 1270}
1269 1271
1270sub find_sync { 1272sub find_sync {
1271 my ($path, $origin) = @_; 1273 my ($path, $origin) = @_;
1272 1274
1273 cf::sync_job { cf::map::find $path, $origin } 1275 cf::sync_job {
1276 my $map = cf::map::find $path, $origin;
1277 $map
1278 }
1274} 1279}
1275 1280
1276sub do_load_sync { 1281sub do_load_sync {
1277 my ($map) = @_; 1282 my ($map) = @_;
1278 1283
1538 my ($pl) = @_; 1543 my ($pl) = @_;
1539 1544
1540 # try to abort aborted map switching on player login :) 1545 # try to abort aborted map switching on player login :)
1541 # should happen only on crashes 1546 # should happen only on crashes
1542 if ($pl->ob->{_link_pos}) { 1547 if ($pl->ob->{_link_pos}) {
1548
1543 $pl->ob->enter_link; 1549 $pl->ob->enter_link;
1544 Coro::async_pool { 1550 (Coro::async_pool {
1545 # we need this sleep as the login has a concurrent enter_exit running 1551 # we need this sleep as the login has a concurrent enter_exit running
1546 # and this sleep increases chances of the player not ending up in scorn 1552 # and this sleep increases chances of the player not ending up in scorn
1547 Coro::Timer::sleep 1; 1553 Coro::Timer::sleep 1;
1548 $pl->ob->leave_link; 1554 $pl->ob->leave_link;
1549 }; 1555 })->prio (2);
1550 } 1556 }
1551 }, 1557 },
1552); 1558);
1553 1559
1554=item $player_object->goto ($path, $x, $y) 1560=item $player_object->goto ($path, $x, $y)
1980 local $/; 1986 local $/;
1981 *CFG = YAML::Syck::Load <$fh>; 1987 *CFG = YAML::Syck::Load <$fh>;
1982 1988
1983 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_105_115", 5, 37]; 1989 $EMERGENCY_POSITION = $CFG{emergency_position} || ["/world/world_105_115", 5, 37];
1984 1990
1991 $cf::map::MAX_RESET = $CFG{map_max_reset} if exists $CFG{map_max_reset};
1992 $cf::map::DEFAULT_RESET = $CFG{map_default_reset} if exists $CFG{map_default_reset};
1993
1985 if (exists $CFG{mlockall}) { 1994 if (exists $CFG{mlockall}) {
1986 eval { 1995 eval {
1987 $CFG{mlockall} ? &mlockall : &munlockall 1996 $CFG{mlockall} ? &mlockall : &munlockall
1988 and die "WARNING: m(un)lockall failed: $!\n"; 1997 and die "WARNING: m(un)lockall failed: $!\n";
1989 }; 1998 };
1993 2002
1994sub main { 2003sub main {
1995 # we must not ever block the main coroutine 2004 # we must not ever block the main coroutine
1996 local $Coro::idle = sub { 2005 local $Coro::idle = sub {
1997 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d# 2006 Carp::cluck "FATAL: Coro::idle was called, major BUG, use cf::sync_job!\n";#d#
1998 (Coro::unblock_sub { 2007 Coro::async_pool { Event::one_event };
1999 Event::one_event;
2000 })->();
2001 }; 2008 };
2002 2009
2003 cfg_load; 2010 cfg_load;
2004 db_load; 2011 db_load;
2005 load_extensions; 2012 load_extensions;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines