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.422 by root, Tue Apr 15 20:46:55 2008 UTC vs.
Revision 1.424 by root, Sun Apr 20 05:24:55 2008 UTC

427 } 427 }
428 } 428 }
429}; 429};
430 430
431sub get_slot($;$$) { 431sub get_slot($;$$) {
432 return if tick_inhibit; 432 return if tick_inhibit || $Coro::current == $Coro::main;
433 433
434 my ($time, $pri, $name) = @_; 434 my ($time, $pri, $name) = @_;
435 435
436 $time = $TICK * .6 if $time > $TICK * .6; 436 $time = $TICK * .6 if $time > $TICK * .6;
437 my $sig = new Coro::Signal; 437 my $sig = new Coro::Signal;
3312 while (my ($k, $v) = each %$want) { 3312 while (my ($k, $v) = each %$want) {
3313 $ns->fx_want ($k, $v); 3313 $ns->fx_want ($k, $v);
3314 } 3314 }
3315}; 3315};
3316 3316
3317sub load_resource_file($) {
3318 my $guard = lock_acquire "load_resource_file";
3319
3320 my $status = load_resource_file_ $_[0];
3321 get_slot 0.1, 100;
3322 cf::arch::commit_load;
3323
3324 $status
3325}
3326
3317sub reload_regions { 3327sub reload_regions {
3318 # HACK to clear player env face cache, we need some signal framework 3328 # HACK to clear player env face cache, we need some signal framework
3319 # for this (global event?) 3329 # for this (global event?)
3320 %ext::player_env::MUSIC_FACE_CACHE = (); 3330 %ext::player_env::MUSIC_FACE_CACHE = ();
3321 3331
3334} 3344}
3335 3345
3336sub reload_archetypes { 3346sub reload_archetypes {
3337 load_resource_file "$DATADIR/archetypes" 3347 load_resource_file "$DATADIR/archetypes"
3338 or die "unable to load archetypes\n"; 3348 or die "unable to load archetypes\n";
3339 #d# NEED to laod twice to resolve forward references
3340 # this really needs to be done in an extra post-pass
3341 # (which needs to be synchronous, so solve it differently)
3342 load_resource_file "$DATADIR/archetypes"
3343 or die "unable to load archetypes\n";
3344} 3349}
3345 3350
3346sub reload_treasures { 3351sub reload_treasures {
3347 load_resource_file "$DATADIR/treasures" 3352 load_resource_file "$DATADIR/treasures"
3348 or die "unable to load treasurelists\n"; 3353 or die "unable to load treasurelists\n";
3349} 3354}
3350 3355
3351sub reload_resources { 3356sub reload_resources {
3352 warn "reloading resource files...\n"; 3357 warn "reloading resource files...\n";
3353 3358
3359 reload_facedata;
3360 reload_archetypes;
3354 reload_regions; 3361 reload_regions;
3355 reload_facedata;
3356 #reload_archetypes;#d#
3357 reload_archetypes;
3358 reload_treasures; 3362 reload_treasures;
3359 3363
3360 warn "finished reloading resource files\n"; 3364 warn "finished reloading resource files\n";
3361} 3365}
3362 3366
3363sub init { 3367sub init {
3368 my $guard = freeze_mainloop;
3369
3364 reload_resources; 3370 reload_resources;
3365} 3371}
3366 3372
3367sub reload_config { 3373sub reload_config {
3368 open my $fh, "<:utf8", "$CONFDIR/config" 3374 open my $fh, "<:utf8", "$CONFDIR/config"
3393 $Coro::current->{desc} = "IDLE BUG HANDLER"; 3399 $Coro::current->{desc} = "IDLE BUG HANDLER";
3394 EV::loop EV::LOOP_ONESHOT; 3400 EV::loop EV::LOOP_ONESHOT;
3395 })->prio (Coro::PRIO_MAX); 3401 })->prio (Coro::PRIO_MAX);
3396 }; 3402 };
3397 3403
3404 {
3405 my $guard = freeze_mainloop;
3398 reload_config; 3406 reload_config;
3399 db_init; 3407 db_init;
3400 load_extensions; 3408 load_extensions;
3401 3409
3402 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority 3410 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority
3403 evthread_start IO::AIO::poll_fileno; 3411 evthread_start IO::AIO::poll_fileno;
3412 }
3413
3404 EV::loop; 3414 EV::loop;
3405} 3415}
3406 3416
3407############################################################################# 3417#############################################################################
3408# initialisation and cleanup 3418# initialisation and cleanup
3690 3700
3691our @WAIT_FOR_TICK; 3701our @WAIT_FOR_TICK;
3692our @WAIT_FOR_TICK_BEGIN; 3702our @WAIT_FOR_TICK_BEGIN;
3693 3703
3694sub wait_for_tick { 3704sub wait_for_tick {
3695 return if tick_inhibit;
3696 return if $Coro::current == $Coro::main; 3705 return if tick_inhibit || $Coro::current == $Coro::main;
3697 3706
3698 my $signal = new Coro::Signal; 3707 my $signal = new Coro::Signal;
3699 push @WAIT_FOR_TICK, $signal; 3708 push @WAIT_FOR_TICK, $signal;
3700 $signal->wait; 3709 $signal->wait;
3701} 3710}
3702 3711
3703sub wait_for_tick_begin { 3712sub wait_for_tick_begin {
3704 return if tick_inhibit;
3705 return if $Coro::current == $Coro::main; 3713 return if tick_inhibit || $Coro::current == $Coro::main;
3706 3714
3707 my $signal = new Coro::Signal; 3715 my $signal = new Coro::Signal;
3708 push @WAIT_FOR_TICK_BEGIN, $signal; 3716 push @WAIT_FOR_TICK_BEGIN, $signal;
3709 $signal->wait; 3717 $signal->wait;
3710} 3718}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines