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.494 by root, Mon Oct 26 05:18:00 2009 UTC vs.
Revision 1.498 by elmex, Tue Jan 5 16:16:37 2010 UTC

53use Coro::Util (); 53use Coro::Util ();
54 54
55use JSON::XS 2.01 (); 55use JSON::XS 2.01 ();
56use BDB (); 56use BDB ();
57use Data::Dumper; 57use Data::Dumper;
58use Digest::MD5;
59use Fcntl; 58use Fcntl;
60use YAML::XS (); 59use YAML::XS ();
61use IO::AIO (); 60use IO::AIO ();
62use Time::HiRes; 61use Time::HiRes;
63use Compress::LZF; 62use Compress::LZF;
3142our $safe_hole = new Safe::Hole; 3141our $safe_hole = new Safe::Hole;
3143 3142
3144$SIG{FPE} = 'IGNORE'; 3143$SIG{FPE} = 'IGNORE';
3145 3144
3146$safe->permit_only (Opcode::opset qw( 3145$safe->permit_only (Opcode::opset qw(
3147 :base_core :base_mem :base_orig :base_math 3146 :base_core :base_mem :base_orig :base_math :base_loop
3148 grepstart grepwhile mapstart mapwhile 3147 grepstart grepwhile mapstart mapwhile
3149 sort time 3148 sort time
3150)); 3149));
3151 3150
3152# here we export the classes and methods available to script code 3151# here we export the classes and methods available to script code
3292 while (my ($face, $info) = each %$faces) { 3291 while (my ($face, $info) = each %$faces) {
3293 my $idx = (cf::face::find $face) || cf::face::alloc $face; 3292 my $idx = (cf::face::find $face) || cf::face::alloc $face;
3294 3293
3295 cf::face::set_visibility $idx, $info->{visibility}; 3294 cf::face::set_visibility $idx, $info->{visibility};
3296 cf::face::set_magicmap $idx, $info->{magicmap}; 3295 cf::face::set_magicmap $idx, $info->{magicmap};
3297 cf::face::set_data $idx, 0, $info->{data32}, Digest::MD5::md5 $info->{data32}; 3296 cf::face::set_data $idx, 0, $info->{data32}, $info->{hash32};
3298 cf::face::set_data $idx, 1, $info->{data64}, Digest::MD5::md5 $info->{data64}; 3297 cf::face::set_data $idx, 1, $info->{data64}, $info->{hash64};
3299 3298
3300 cf::cede_to_tick; 3299 cf::cede_to_tick;
3301 } 3300 }
3302 3301
3303 while (my ($face, $info) = each %$faces) { 3302 while (my ($face, $info) = each %$faces) {
3327 3326
3328 cf::anim::invalidate_all; # d'oh 3327 cf::anim::invalidate_all; # d'oh
3329 } 3328 }
3330 3329
3331 { 3330 {
3332 # TODO: for gcfclient pleasure, we should give resources
3333 # that gcfclient doesn't grok a >10000 face index.
3334 my $res = $facedata->{resource}; 3331 my $res = $facedata->{resource};
3335 3332
3336 while (my ($name, $info) = each %$res) { 3333 while (my ($name, $info) = each %$res) {
3337 if (defined $info->{type}) { 3334 if (defined $info->{type}) {
3338 my $idx = (cf::face::find $name) || cf::face::alloc $name; 3335 my $idx = (cf::face::find $name) || cf::face::alloc $name;
3339 my $data;
3340 3336
3341 if ($info->{type} & 1) { 3337 cf::face::set_data $idx, 0, $info->{data}, $info->{hash};
3342 # prepend meta info
3343
3344 my $meta = $enc->encode ({
3345 name => $name,
3346 %{ $info->{meta} || {} },
3347 });
3348
3349 $data = pack "(w/a*)*", $meta, $info->{data};
3350 } else {
3351 $data = $info->{data};
3352 }
3353
3354 cf::face::set_data $idx, 0, $data, Digest::MD5::md5 $data;
3355 cf::face::set_type $idx, $info->{type}; 3338 cf::face::set_type $idx, $info->{type};
3356 } else { 3339 } else {
3357 $RESOURCE{$name} = $info; 3340 $RESOURCE{$name} = $info;
3358 } 3341 }
3359 3342
3522 }; 3505 };
3523 3506
3524 evthread_start IO::AIO::poll_fileno; 3507 evthread_start IO::AIO::poll_fileno;
3525 3508
3526 cf::sync_job { 3509 cf::sync_job {
3510 cf::load_settings;
3511 cf::load_materials;
3512
3527 reload_resources; 3513 reload_resources;
3528 reload_config; 3514 reload_config;
3529 db_init; 3515 db_init;
3530 3516
3531 cf::load_settings;
3532 cf::load_materials;
3533 cf::init_uuid; 3517 cf::init_uuid;
3534 cf::init_signals; 3518 cf::init_signals;
3535 cf::init_commands; 3519 cf::init_commands;
3536 cf::init_skills; 3520 cf::init_skills;
3537 3521
3896 3880
3897our @WAIT_FOR_TICK; 3881our @WAIT_FOR_TICK;
3898our @WAIT_FOR_TICK_BEGIN; 3882our @WAIT_FOR_TICK_BEGIN;
3899 3883
3900sub wait_for_tick { 3884sub wait_for_tick {
3901 return if tick_inhibit || $Coro::current == $Coro::main; 3885 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main;
3902 3886
3903 my $signal = new Coro::Signal; 3887 my $signal = new Coro::Signal;
3904 push @WAIT_FOR_TICK, $signal; 3888 push @WAIT_FOR_TICK, $signal;
3905 $signal->wait; 3889 $signal->wait;
3906} 3890}
3907 3891
3908sub wait_for_tick_begin { 3892sub wait_for_tick_begin {
3909 return if tick_inhibit || $Coro::current == $Coro::main; 3893 return Coro::cede if tick_inhibit || $Coro::current == $Coro::main;
3910 3894
3911 my $signal = new Coro::Signal; 3895 my $signal = new Coro::Signal;
3912 push @WAIT_FOR_TICK_BEGIN, $signal; 3896 push @WAIT_FOR_TICK_BEGIN, $signal;
3913 $signal->wait; 3897 $signal->wait;
3914} 3898}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines