… | |
… | |
21 | use Crossfire; |
21 | use Crossfire; |
22 | use Coro; |
22 | use Coro; |
23 | use Coro::AIO; |
23 | use Coro::AIO; |
24 | use POSIX (); |
24 | use POSIX (); |
25 | use Digest::MD5; |
25 | use Digest::MD5; |
|
|
26 | use Carp; |
26 | use Coro::Storable; $Storable::canonical = 1; |
27 | use Coro::Storable; $Storable::canonical = 1; |
|
|
28 | |
|
|
29 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
27 | |
30 | |
28 | sub usage { |
31 | sub usage { |
29 | warn <<EOF; |
32 | warn <<EOF; |
30 | Usage: cfutil [-v] [-q] [--force] [--cache] |
33 | Usage: cfutil [-v] [-q] [--force] [--cache] |
31 | [--install-arch path] |
34 | [--install-arch path] |
… | |
… | |
92 | if (!-f "$path/regions") { |
95 | if (!-f "$path/regions") { |
93 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
96 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
94 | exit 1 unless $FORCE; |
97 | exit 1 unless $FORCE; |
95 | } |
98 | } |
96 | |
99 | |
97 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
100 | system $RSYNC, "-a", "--chmod=u=rwX,go=rX", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
98 | and die "map installation failed.\n"; |
101 | and die "map installation failed.\n"; |
99 | |
102 | |
100 | print "maps installed successfully.\n"; |
103 | print "maps installed successfully.\n"; |
101 | } |
104 | } |
102 | |
105 | |
… | |
… | |
392 | my ($dir, $file) = @{pop @res}; |
395 | my ($dir, $file) = @{pop @res}; |
393 | |
396 | |
394 | my $data; |
397 | my $data; |
395 | aio_load "$dir/$file", $data; |
398 | aio_load "$dir/$file", $data; |
396 | |
399 | |
|
|
400 | my $copyright; |
|
|
401 | aio_load "$dir/copyright", $copyright; |
|
|
402 | |
397 | $file =~ s/\.res$//; |
403 | $file =~ s/\.res$//; |
398 | $file =~ /\.([^.]+)$/ |
404 | $file =~ /\.([^.]+)$/ |
399 | or next; |
405 | or next; |
400 | |
406 | |
401 | my $type = $1; |
407 | my $type = $1; |
402 | |
408 | |
403 | substr $dir, 0, 1 + length $PATH, ""; |
409 | substr $dir, 0, 1 + length $PATH, ""; |
404 | |
410 | |
405 | $RESOURCE{"$dir/$file"} = { |
411 | $RESOURCE{"$dir/$file"} = { |
406 | type => $1, |
412 | type => $1, |
407 | copyright => "", # TODO |
413 | copyright => $copyright, |
408 | data => $data, |
414 | data => $data, |
409 | chksum => Digest::MD5::md5 $data, |
415 | chksum => Digest::MD5::md5 $data, |
410 | }; |
416 | }; |
411 | } |
417 | } |
412 | } |
418 | } |
… | |
… | |
427 | push @png, ["$path/$file", 0]; |
433 | push @png, ["$path/$file", 0]; |
428 | } elsif ($file =~ /\.trs$/) { |
434 | } elsif ($file =~ /\.trs$/) { |
429 | push @trs, [$path, $file]; |
435 | push @trs, [$path, $file]; |
430 | } elsif ($file =~ /\.arc$/) { |
436 | } elsif ($file =~ /\.arc$/) { |
431 | push @arc, [$path, $file]; |
437 | push @arc, [$path, $file]; |
432 | } elsif ($file =~ /\.(ogg|res)$/) { |
438 | } elsif ($file =~ /\.(ogg|jpg|res)$/) { |
433 | push @res, [$path, $file]; |
439 | push @res, [$path, $file]; |
434 | } else { |
440 | } else { |
435 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
441 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
436 | } |
442 | } |
437 | } |
443 | } |