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.33 by root, Mon Aug 21 01:51:23 2006 UTC vs.
Revision 1.34 by root, Thu Aug 24 13:13:49 2006 UTC

410 for grep %$_, all_objects $ob; 410 for grep %$_, all_objects $ob;
411}; 411};
412 412
413############################################################################# 413#############################################################################
414# core extensions - in perl 414# core extensions - in perl
415
416my $delta_timer = Event->timer (
417 parked => 1,
418 prio => Event::PRIO_HIGH,
419 cb => sub { Event::unloop (undef) },
420);
421
422sub sleep_delta($) {
423 $delta_timer->at (Event::time + $_[0]);
424 $delta_timer->start;
425 Event::loop;
426}
427 415
428=item cf::player::exists $login 416=item cf::player::exists $login
429 417
430Returns true when the given account exists. 418Returns true when the given account exists.
431 419
527 no strict 'refs'; 515 no strict 'refs';
528 *{"ext::$fun"} = $safe_hole->wrap ($cb); 516 *{"ext::$fun"} = $safe_hole->wrap ($cb);
529} 517}
530 518
531############################################################################# 519#############################################################################
520# the server's main()
521
522sub run {
523 my $tick = MAX_TIME * 1e-6;
524 my $next = Event::time;
525 my $timer = Event->timer (at => $next, cb => sub {
526 cf::server_tick; # one server iteration
527
528 $next += $tick;
529 my $NOW = Event::time;
530
531 # if we are delayd by > 0.25 second, skip ticks
532 $next = $NOW if $NOW >= $next + .25;
533
534 $_[0]->w->at ($next);
535 $_[0]->w->start;
536 });
537
538 Event::loop;
539}
540
541#############################################################################
532# initialisation 542# initialisation
533 543
534register "<global>", __PACKAGE__; 544register "<global>", __PACKAGE__;
535 545
536unshift @INC, $LIBDIR; 546unshift @INC, $LIBDIR;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines