ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.44 by root, Tue Jul 24 04:55:35 2007 UTC vs.
Revision 1.48 by root, Tue Jul 31 02:24:43 2007 UTC

388 388
389 $TRS .= $trs; 389 $TRS .= $trs;
390 } 390 }
391 } 391 }
392 392
393 my %FILECACHE;
394
395 sub load_cached($;$) {
396 unless (exists $FILECACHE{$_[0]}) {
397 my $data;
398 if (0 < aio_load $_[0], $data) {
399 $data = $_[1]->($data)
400 if $_[1];
401 }
402
403 $FILECACHE{$_[0]} = $data;
404 }
405
406 $FILECACHE{$_[0]}
407 }
408
393 sub process_res { 409 sub process_res {
394 while (@res) { 410 while (@res) {
395 my ($dir, $file, $type) = @{pop @res}; 411 my ($dir, $file, $type) = @{pop @res};
396 412
397 my $data; 413 my $data;
398 aio_load "$dir/$file", $data; 414 aio_load "$dir/$file", $data;
399 415
400 my $copyright; 416 my $meta = load_cached "$dir/meta", sub { JSON::XS::from_json shift };
401 aio_load "$dir/copyright", $copyright; 417
418 $meta = {
419 %{ $meta->{"" } || {} },
420 %{ $meta->{$file} || {} },
421 };
402 422
403 $file =~ s/\.res$//; 423 $file =~ s/\.res$//;
404 $file =~ /\.([^.]+)$/ 424 $file =~ s/\.(ogg|wav|jpg|png)$//;
405 or next;
406 425
407 substr $dir, 0, 1 + length $PATH, ""; 426 substr $dir, 0, 1 + length $PATH, "";
408 427
409 $RESOURCE{"$dir/$file"} = { 428 $RESOURCE{"$dir/$file"} = {
410 type => $type, 429 type => (delete $meta->{type}) || $type,
411 copyright => $copyright,
412 data => $data, 430 data => $data,
413 chksum => Digest::MD5::md5 $data, 431 chksum => (Digest::MD5::md5 $data),
432 %$meta ? (meta => $meta) : (),
414 }; 433 };
415 } 434 }
416 } 435 }
417 436
418 sub find_files; 437 sub find_files;
432 for my $file (@$nondirs) { 451 for my $file (@$nondirs) {
433 if ($dir =~ /^music(?:\/|$)/) { 452 if ($dir =~ /^music(?:\/|$)/) {
434 push @res, [$path, $file, 3] # FT_MUSIC 453 push @res, [$path, $file, 3] # FT_MUSIC
435 if $file =~ /\.(ogg)$/; 454 if $file =~ /\.(ogg)$/;
436 455
437 } elsif ($dir =~ /^sounds(?:\/|$)/) { 456 } elsif ($dir =~ /^sound(?:\/|$)/) {
438 push @res, [$path, $file, 5] # FT_SOUND 457 push @res, [$path, $file, 5] # FT_SOUND
439 if $file =~ /\.(wav|ogg)$/; 458 if $file =~ /\.(wav|ogg)$/;
440 459
441 } elsif ($dir =~ /^res(?:\/|$)/) { 460 } elsif ($dir =~ /^res(?:\/|$)/) {
442 push @res, [$path, $file, 0] # FT_FACE 461 push @res, [$path, $file, 0] # FT_FACE

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines