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.244 by root, Mon Apr 16 13:28:00 2007 UTC vs.
Revision 1.245 by root, Tue Apr 17 10:06:33 2007 UTC

54 54
55our $RELOAD; # number of reloads so far 55our $RELOAD; # number of reloads so far
56our @EVENT; 56our @EVENT;
57our $LIBDIR = datadir . "/ext"; 57our $LIBDIR = datadir . "/ext";
58 58
59our $TICK = MAX_TIME * 1e-6; 59our $TICK = MAX_TIME * 1e-6; # this is a CONSTANT(!)
60our $TICK_WATCHER; 60our $TICK_WATCHER;
61our $AIO_POLL_WATCHER; 61our $AIO_POLL_WATCHER;
62our $NEXT_RUNTIME_WRITE; # when should the runtime file be written 62our $NEXT_RUNTIME_WRITE; # when should the runtime file be written
63our $NEXT_TICK; 63our $NEXT_TICK;
64our $NOW; 64our $NOW;
2394sub load_treasures { 2394sub load_treasures {
2395 load_treasure_file sprintf "%s/treasures", cf::datadir 2395 load_treasure_file sprintf "%s/treasures", cf::datadir
2396} 2396}
2397 2397
2398sub reload_resources { 2398sub reload_resources {
2399 warn "reloading resource files...\n";
2400
2399 load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir 2401 load_resource_file sprintf "%s/%s/regions", cf::datadir, cf::mapdir
2400 or die "unable to load regions file\n"; 2402 or die "unable to load regions file\n";
2401 load_facedata 2403 load_facedata
2402 or die "unable to load facedata\n"; 2404 or die "unable to load facedata\n";
2403 load_archetypes 2405 load_archetypes
2404 or die "unable to load archetypes\n"; 2406 or die "unable to load archetypes\n";
2405 load_treasures 2407 load_treasures
2406 or die "unable to load treasurelists\n"; 2408 or die "unable to load treasurelists\n";
2409
2410 warn "finished reloading resource files\n";
2407} 2411}
2408 2412
2409sub init { 2413sub init {
2410 reload_resources; 2414 reload_resources;
2411} 2415}
2692 } 2696 }
2693 2697
2694 $NOW = Event::time; 2698 $NOW = Event::time;
2695 2699
2696 cf::server_tick; # one server iteration 2700 cf::server_tick; # one server iteration
2701
2697 $RUNTIME += $TICK; 2702 $RUNTIME += $TICK;
2698 $NEXT_TICK += $TICK; 2703 $NEXT_TICK += $TICK;
2699 2704
2700 if ($NOW >= $NEXT_RUNTIME_WRITE) { 2705 if ($NOW >= $NEXT_RUNTIME_WRITE) {
2701 $NEXT_RUNTIME_WRITE = $NOW + 10; 2706 $NEXT_RUNTIME_WRITE = $NOW + 10;
2703 write_runtime 2708 write_runtime
2704 or warn "ERROR: unable to write runtime file: $!"; 2709 or warn "ERROR: unable to write runtime file: $!";
2705 }; 2710 };
2706 } 2711 }
2707 2712
2713# my $AFTER = Event::time;
2714# warn $AFTER - $NOW;#d#
2715
2716 # if we are delayed by four ticks or more, skip them all
2717 $NEXT_TICK = Event::time if Event::time >= $NEXT_TICK + $TICK * 4;
2718
2719 $TICK_WATCHER->at ($NEXT_TICK);
2720 $TICK_WATCHER->start;
2721
2708 if (my $sig = shift @WAIT_FOR_TICK_BEGIN) { 2722 if (my $sig = shift @WAIT_FOR_TICK_BEGIN) {
2709 $sig->send; 2723 $sig->send;
2710 } 2724 }
2711 while (my $sig = shift @WAIT_FOR_TICK) { 2725 while (my $sig = shift @WAIT_FOR_TICK) {
2712 $sig->send; 2726 $sig->send;
2713 } 2727 }
2714 2728
2715# my $AFTER = Event::time; 2729 _post_tick;
2716# warn $AFTER - $NOW;#d#
2717
2718 # if we are delayed by four ticks or more, skip them all
2719 $NEXT_TICK = Event::time if Event::time >= $NEXT_TICK + $TICK * 4;
2720
2721 $TICK_WATCHER->at ($NEXT_TICK);
2722 $TICK_WATCHER->start;
2723 }, 2730 },
2724); 2731);
2725 2732
2726{ 2733{
2727 BDB::max_poll_time $TICK * 0.1; 2734 BDB::max_poll_time $TICK * 0.1;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines