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.423 by root, Sun Apr 20 00:44:13 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 $status = load_resource_file_ $_[0];
3319 get_slot 0.1, 100;
3320 cf::arch::commit_load;
3321 $status
3322}
3323
3317sub reload_regions { 3324sub reload_regions {
3318 # HACK to clear player env face cache, we need some signal framework 3325 # HACK to clear player env face cache, we need some signal framework
3319 # for this (global event?) 3326 # for this (global event?)
3320 %ext::player_env::MUSIC_FACE_CACHE = (); 3327 %ext::player_env::MUSIC_FACE_CACHE = ();
3321 3328
3334} 3341}
3335 3342
3336sub reload_archetypes { 3343sub reload_archetypes {
3337 load_resource_file "$DATADIR/archetypes" 3344 load_resource_file "$DATADIR/archetypes"
3338 or die "unable to load archetypes\n"; 3345 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} 3346}
3345 3347
3346sub reload_treasures { 3348sub reload_treasures {
3347 load_resource_file "$DATADIR/treasures" 3349 load_resource_file "$DATADIR/treasures"
3348 or die "unable to load treasurelists\n"; 3350 or die "unable to load treasurelists\n";
3349} 3351}
3350 3352
3351sub reload_resources { 3353sub reload_resources {
3352 warn "reloading resource files...\n"; 3354 warn "reloading resource files...\n";
3353 3355
3356 reload_facedata;
3357 reload_archetypes;
3354 reload_regions; 3358 reload_regions;
3355 reload_facedata;
3356 #reload_archetypes;#d#
3357 reload_archetypes;
3358 reload_treasures; 3359 reload_treasures;
3359 3360
3360 warn "finished reloading resource files\n"; 3361 warn "finished reloading resource files\n";
3361} 3362}
3362 3363
3363sub init { 3364sub init {
3365 my $guard = freeze_mainloop;
3366
3364 reload_resources; 3367 reload_resources;
3365} 3368}
3366 3369
3367sub reload_config { 3370sub reload_config {
3368 open my $fh, "<:utf8", "$CONFDIR/config" 3371 open my $fh, "<:utf8", "$CONFDIR/config"
3393 $Coro::current->{desc} = "IDLE BUG HANDLER"; 3396 $Coro::current->{desc} = "IDLE BUG HANDLER";
3394 EV::loop EV::LOOP_ONESHOT; 3397 EV::loop EV::LOOP_ONESHOT;
3395 })->prio (Coro::PRIO_MAX); 3398 })->prio (Coro::PRIO_MAX);
3396 }; 3399 };
3397 3400
3401 {
3402 my $guard = freeze_mainloop;
3398 reload_config; 3403 reload_config;
3399 db_init; 3404 db_init;
3400 load_extensions; 3405 load_extensions;
3401 3406
3402 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority 3407 $Coro::current->prio (Coro::PRIO_MAX); # give the main loop max. priority
3403 evthread_start IO::AIO::poll_fileno; 3408 evthread_start IO::AIO::poll_fileno;
3409 }
3410
3404 EV::loop; 3411 EV::loop;
3405} 3412}
3406 3413
3407############################################################################# 3414#############################################################################
3408# initialisation and cleanup 3415# initialisation and cleanup
3690 3697
3691our @WAIT_FOR_TICK; 3698our @WAIT_FOR_TICK;
3692our @WAIT_FOR_TICK_BEGIN; 3699our @WAIT_FOR_TICK_BEGIN;
3693 3700
3694sub wait_for_tick { 3701sub wait_for_tick {
3695 return if tick_inhibit;
3696 return if $Coro::current == $Coro::main; 3702 return if tick_inhibit || $Coro::current == $Coro::main;
3697 3703
3698 my $signal = new Coro::Signal; 3704 my $signal = new Coro::Signal;
3699 push @WAIT_FOR_TICK, $signal; 3705 push @WAIT_FOR_TICK, $signal;
3700 $signal->wait; 3706 $signal->wait;
3701} 3707}
3702 3708
3703sub wait_for_tick_begin { 3709sub wait_for_tick_begin {
3704 return if tick_inhibit;
3705 return if $Coro::current == $Coro::main; 3710 return if tick_inhibit || $Coro::current == $Coro::main;
3706 3711
3707 my $signal = new Coro::Signal; 3712 my $signal = new Coro::Signal;
3708 push @WAIT_FOR_TICK_BEGIN, $signal; 3713 push @WAIT_FOR_TICK_BEGIN, $signal;
3709 $signal->wait; 3714 $signal->wait;
3710} 3715}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines