… | |
… | |
413 | my $data; |
413 | my $data; |
414 | aio_load "$dir/$file", $data; |
414 | aio_load "$dir/$file", $data; |
415 | |
415 | |
416 | my $meta = load_cached "$dir/meta", sub { JSON::XS::from_json shift }; |
416 | my $meta = load_cached "$dir/meta", sub { JSON::XS::from_json shift }; |
417 | |
417 | |
418 | $file =~ s/\.res$//; |
|
|
419 | $file =~ s/\.(ogg|wav|jpg|png)$//; |
|
|
420 | |
|
|
421 | substr $dir, 0, 1 + length $PATH, ""; |
|
|
422 | |
|
|
423 | $meta = { |
418 | $meta = { |
424 | %{ $meta->{"" } || {} }, |
419 | %{ $meta->{"" } || {} }, |
425 | %{ $meta->{$file} || {} }, |
420 | %{ $meta->{$file} || {} }, |
426 | }; |
421 | }; |
|
|
422 | |
|
|
423 | $file =~ s/\.res$//; |
|
|
424 | $file =~ s/\.(ogg|wav|jpg|png)$//; |
|
|
425 | |
|
|
426 | substr $dir, 0, 1 + length $PATH, ""; |
427 | |
427 | |
428 | $RESOURCE{"$dir/$file"} = { |
428 | $RESOURCE{"$dir/$file"} = { |
429 | type => (delete $meta->{type}) || $type, |
429 | type => (delete $meta->{type}) || $type, |
430 | data => $data, |
430 | data => $data, |
431 | chksum => (Digest::MD5::md5 $data), |
431 | chksum => (Digest::MD5::md5 $data), |
… | |
… | |
451 | for my $file (@$nondirs) { |
451 | for my $file (@$nondirs) { |
452 | if ($dir =~ /^music(?:\/|$)/) { |
452 | if ($dir =~ /^music(?:\/|$)/) { |
453 | push @res, [$path, $file, 3] # FT_MUSIC |
453 | push @res, [$path, $file, 3] # FT_MUSIC |
454 | if $file =~ /\.(ogg)$/; |
454 | if $file =~ /\.(ogg)$/; |
455 | |
455 | |
456 | } elsif ($dir =~ /^sounds(?:\/|$)/) { |
456 | } elsif ($dir =~ /^sound(?:\/|$)/) { |
457 | push @res, [$path, $file, 5] # FT_SOUND |
457 | push @res, [$path, $file, 5] # FT_SOUND |
458 | if $file =~ /\.(wav|ogg)$/; |
458 | if $file =~ /\.(wav|ogg)$/; |
459 | |
459 | |
460 | } elsif ($dir =~ /^res(?:\/|$)/) { |
460 | } elsif ($dir =~ /^res(?:\/|$)/) { |
461 | push @res, [$path, $file, 0] # FT_FACE |
461 | push @res, [$path, $file, 0] # FT_FACE |