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.234 by root, Thu Apr 5 13:44:31 2007 UTC vs.
Revision 1.237 by root, Fri Apr 13 05:08:51 2007 UTC

16use Coro::Event; 16use Coro::Event;
17use Coro::Timer; 17use Coro::Timer;
18use Coro::Signal; 18use Coro::Signal;
19use Coro::Semaphore; 19use Coro::Semaphore;
20use Coro::AIO; 20use Coro::AIO;
21use Coro::Storable;
21 22
22use BDB (); 23use BDB ();
23use Data::Dumper; 24use Data::Dumper;
24use Digest::MD5; 25use Digest::MD5;
25use Fcntl; 26use Fcntl;
28use Time::HiRes; 29use Time::HiRes;
29use Compress::LZF; 30use Compress::LZF;
30 31
31# configure various modules to our taste 32# configure various modules to our taste
32# 33#
34$Storable::canonical = 1; # reduce rsync transfers
33Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator 35Coro::State::cctx_stacksize 256000; # 1-2MB stack, for deep recursions in maze generator
34Compress::LZF::sfreeze_cr { }; # prime Compress::LZF so it does not use require later 36Compress::LZF::sfreeze_cr { }; # prime Compress::LZF so it does not use require later
35 37
36$Event::Eval = 1; # no idea why this is required, but it is 38$Event::Eval = 1; # no idea why this is required, but it is
37 39
2307sub load_facedata { 2309sub load_facedata {
2308 my $path = sprintf "%s/facedata", cf::datadir; 2310 my $path = sprintf "%s/facedata", cf::datadir;
2309 2311
2310 warn "loading facedata from $path\n"; 2312 warn "loading facedata from $path\n";
2311 2313
2312 my $faces; 2314 my $facedata;
2313 0 < aio_load $path, $faces 2315 0 < aio_load $path, $facedata
2314 or die "$path: $!"; 2316 or die "$path: $!";
2315 2317
2316 Coro::cede;
2317 $faces = Storable::thaw $faces; 2318 $facedata = Coro::Storable::thaw $facedata;
2318 Coro::cede;
2319 2319
2320 my $meta = delete $faces->{""};
2321 $meta->{version} == 1 2320 $facedata->{version} == 2
2322 or cf::cleanup "$path: version mismatch, cannot proceed."; 2321 or cf::cleanup "$path: version mismatch, cannot proceed.";
2323 2322
2323 {
2324 my $faces = $facedata->{faceinfo};
2325
2324 while (my ($face, $info) = each %$faces) { 2326 while (my ($face, $info) = each %$faces) {
2325 my $idx = (cf::face::find $face) || cf::face::alloc $face; 2327 my $idx = (cf::face::find $face) || cf::face::alloc $face;
2326 cf::face::set $idx, $info->{visibility}, $info->{magicmap}; 2328 cf::face::set $idx, $info->{visibility}, $info->{magicmap};
2327 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32}; 2329 cf::face::set_data $idx, 0, $info->{data32}, $info->{chksum32};
2328 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64}; 2330 cf::face::set_data $idx, 1, $info->{data64}, $info->{chksum64};
2329 Coro::cede; 2331 Coro::cede;
2330 } 2332 }
2331 2333
2332 while (my ($face, $info) = each %$faces) { 2334 while (my ($face, $info) = each %$faces) {
2333 next unless $info->{smooth}; 2335 next unless $info->{smooth};
2334 my $idx = cf::face::find $face 2336 my $idx = cf::face::find $face
2335 or next; 2337 or next;
2336 if (my $smooth = cf::face::find $info->{smooth}) { 2338 if (my $smooth = cf::face::find $info->{smooth}) {
2337 cf::face::set_smooth $idx, $smooth; 2339 cf::face::set_smooth $idx, $smooth, $info->{smoothlevel};
2338 } else { 2340 } else {
2339 warn "smooth face '$info->{smooth}' not found for face '$face'"; 2341 warn "smooth face '$info->{smooth}' not found for face '$face'";
2340 } 2342 }
2341 Coro::cede; 2343 Coro::cede;
2344 }
2345 }
2346
2347 {
2348 my $anims = $facedata->{animinfo};
2349
2350 while (my ($anim, $info) = each %$anims) {
2351 cf::anim::set $anim, $info->{frames}, $info->{facings};
2352 Coro::cede;
2353 }
2354
2355 cf::anim::invalidate_all; # d'oh
2342 } 2356 }
2343 2357
2344 1 2358 1
2345} 2359}
2346 2360

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines