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.366 by root, Tue Sep 11 16:05:35 2007 UTC vs.
Revision 1.370 by root, Thu Sep 13 10:59:41 2007 UTC

2463 # *tag paths override both path and x|y 2463 # *tag paths override both path and x|y
2464 if ($path =~ /^\*(.*)$/) { 2464 if ($path =~ /^\*(.*)$/) {
2465 if (my @obs = grep $_->map, ext::map_tags::find $1) { 2465 if (my @obs = grep $_->map, ext::map_tags::find $1) {
2466 my $ob = $obs[rand @obs]; 2466 my $ob = $obs[rand @obs];
2467 2467
2468 # todo: use ob_blocked to check all tiles of the destination "object" 2468 # see if we actually can go there
2469 # for suitability. 2469 if (@obs = grep !$self->blocked ($_->map, $_->x, $_->y), $ob, $ob->tail) {
2470 $ob = $obs[rand @obs];
2471 } else {
2472 $self->message ("Wow, it's pretty crowded in there.", cf::NDI_UNIQUE | cf::NDI_RED);
2473 }
2474 # else put us there anyways for now #d#
2470 2475
2471 ($path, $x, $y) = ($ob->map, $ob->x, $ob->y); 2476 ($path, $x, $y) = ($ob->map, $ob->x, $ob->y);
2477 } else {
2478 ($path, $x, $y) = (undef, undef, undef);
2472 } 2479 }
2473 } 2480 }
2474 2481
2475 my $map = eval { 2482 my $map = eval {
2476 my $map = cf::map::find $path; 2483 my $map = defined $path ? cf::map::find $path : undef;
2477 2484
2478 if ($map) { 2485 if ($map) {
2479 $map = $map->customise_for ($self); 2486 $map = $map->customise_for ($self);
2480 $map = $check->($map) if $check && $map; 2487 $map = $check->($map) if $check && $map;
2481 } else { 2488 } else {
2482 $self->message ("The exit to '$path' is closed", cf::NDI_UNIQUE | cf::NDI_RED); 2489 $self->message ("The exit to '$path' is closed.", cf::NDI_UNIQUE | cf::NDI_RED);
2483 } 2490 }
2484 2491
2485 $map 2492 $map
2486 }; 2493 };
2487 2494
3457 my $signal = new Coro::Signal; 3464 my $signal = new Coro::Signal;
3458 push @WAIT_FOR_TICK_BEGIN, $signal; 3465 push @WAIT_FOR_TICK_BEGIN, $signal;
3459 $signal->wait; 3466 $signal->wait;
3460} 3467}
3461 3468
3462our $stat_fh;
3463sysopen $stat_fh, "/tmp/cfstats", Fcntl::O_APPEND | Fcntl::O_CREAT | Fcntl::O_WRONLY, 0600;#d#
3464
3465$TICK_WATCHER = Event->timer ( 3469$TICK_WATCHER = Event->timer (
3466 reentrant => 0, 3470 reentrant => 0,
3467 parked => 1, 3471 parked => 1,
3468 prio => 0, 3472 prio => 0,
3469 at => $NEXT_TICK || $TICK, 3473 at => $NEXT_TICK || $TICK,
3473 Carp::cluck "major BUG: server tick called outside of main coro, skipping it" 3477 Carp::cluck "major BUG: server tick called outside of main coro, skipping it"
3474 unless ++$bug_warning > 10; 3478 unless ++$bug_warning > 10;
3475 return; 3479 return;
3476 } 3480 }
3477 3481
3478 my @pl = cf::player::list; my $stats = sprintf "%.2f %d %d %d", $RUNTIME, (scalar @pl), cf::object::actives_size, cf::object::objects_size; #d#
3479
3480 $NOW = $tick_start = Event::time; 3482 $NOW = $tick_start = Event::time;
3481 3483
3482 cf::server_tick; # one server iteration 3484 cf::server_tick; # one server iteration
3483 3485
3484 $RUNTIME += $TICK; 3486 $RUNTIME += $TICK;
3490 write_runtime 3492 write_runtime
3491 or warn "ERROR: unable to write runtime file: $!"; 3493 or warn "ERROR: unable to write runtime file: $!";
3492 }; 3494 };
3493 } 3495 }
3494 3496
3495# my $AFTER = Event::time;
3496# warn $AFTER - $NOW;#d#
3497
3498 if (my $sig = shift @WAIT_FOR_TICK_BEGIN) { 3497 if (my $sig = shift @WAIT_FOR_TICK_BEGIN) {
3499 $sig->send; 3498 $sig->send;
3500 } 3499 }
3501 while (my $sig = shift @WAIT_FOR_TICK) { 3500 while (my $sig = shift @WAIT_FOR_TICK) {
3502 $sig->send; 3501 $sig->send;
3512 3511
3513 $LOAD = ($NOW - $tick_start) / $TICK; 3512 $LOAD = ($NOW - $tick_start) / $TICK;
3514 $LOADAVG = $LOADAVG * 0.75 + $LOAD * 0.25; 3513 $LOADAVG = $LOADAVG * 0.75 + $LOAD * 0.25;
3515 3514
3516 _post_tick; 3515 _post_tick;
3517
3518 # gather some statistics#d#
3519 $stats .= sprintf " %d\n", 10000 * ($NOW - $tick_start);#d#
3520 IO::AIO::aio_write $stat_fh, undef, undef, $stats, 0;#d#
3521 }, 3516 },
3522); 3517);
3523 3518
3524{ 3519{
3525 BDB::min_parallel 8; 3520 BDB::min_parallel 8;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines