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.34 by root, Thu Aug 24 13:13:49 2006 UTC vs.
Revision 1.35 by root, Thu Aug 24 13:35:48 2006 UTC

16our %COMMAND; 16our %COMMAND;
17our @EVENT; 17our @EVENT;
18our %PROP_TYPE; 18our %PROP_TYPE;
19our %PROP_IDX; 19our %PROP_IDX;
20our $LIBDIR = maps_directory "perl"; 20our $LIBDIR = maps_directory "perl";
21
22our $TICK = MAX_TIME * 1e-6;
23our $TICK_WATCHER;
24our $NEXT_TICK;
21 25
22BEGIN { 26BEGIN {
23 @EVENT = map lc, @EVENT; 27 @EVENT = map lc, @EVENT;
24 28
25 *CORE::GLOBAL::warn = sub { 29 *CORE::GLOBAL::warn = sub {
518 522
519############################################################################# 523#############################################################################
520# the server's main() 524# the server's main()
521 525
522sub run { 526sub run {
523 my $tick = MAX_TIME * 1e-6; 527 Event::loop;
524 my $next = Event::time; 528}
525 my $timer = Event->timer (at => $next, cb => sub { 529
530#############################################################################
531# initialisation
532
533register "<global>", __PACKAGE__;
534
535unshift @INC, $LIBDIR;
536
537load_extensions;
538
539$TICK_WATCHER = Event->timer (
540 prio => 1,
541 at => $NEXT_TICK || 1,
542 cb => sub {
526 cf::server_tick; # one server iteration 543 cf::server_tick; # one server iteration
527 544
528 $next += $tick;
529 my $NOW = Event::time; 545 my $NOW = Event::time;
546 $NEXT_TICK += $TICK;
530 547
531 # if we are delayd by > 0.25 second, skip ticks 548 # if we are delayed by > 0.25 second, skip ticks
532 $next = $NOW if $NOW >= $next + .25; 549 $NEXT_TICK = $NOW if $NOW >= $NEXT_TICK + .25;
533 550
534 $_[0]->w->at ($next); 551 $TICK_WATCHER->at ($NEXT_TICK);
535 $_[0]->w->start; 552 $TICK_WATCHER->start;
536 }); 553 },
537 554);
538 Event::loop;
539}
540
541#############################################################################
542# initialisation
543
544register "<global>", __PACKAGE__;
545
546unshift @INC, $LIBDIR;
547
548load_extensions;
549 555
5501 5561
551 557

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines