… | |
… | |
20 | use Crossfire; |
20 | use Crossfire; |
21 | use Coro; |
21 | use Coro; |
22 | use Coro::AIO; |
22 | use Coro::AIO; |
23 | use POSIX (); |
23 | use POSIX (); |
24 | use Digest::MD5; |
24 | use Digest::MD5; |
|
|
25 | use Storable; $Storable::canonical = 1; |
25 | |
26 | |
26 | sub usage { |
27 | sub usage { |
27 | warn <<EOF; |
28 | warn <<EOF; |
28 | Usage: cfutil [-v] [-q] [--force] [--cache] |
29 | Usage: cfutil [-v] [-q] [--force] [--cache] |
29 | [--install-arch path] |
30 | [--install-arch path] |
… | |
… | |
75 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
76 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
76 | exit 1 unless $FORCE; |
77 | exit 1 unless $FORCE; |
77 | } |
78 | } |
78 | |
79 | |
79 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
80 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
80 | or die "map installation failed.\n"; |
81 | and die "map installation failed.\n"; |
81 | |
82 | |
82 | print "maps installed successfully.\n"; |
83 | print "maps installed successfully.\n"; |
83 | } |
84 | } |
84 | |
85 | |
85 | { |
86 | { |
… | |
… | |
87 | our %FACEINFO; |
88 | our %FACEINFO; |
88 | our @ARC; |
89 | our @ARC; |
89 | our $TRS; |
90 | our $TRS; |
90 | our $NFILE; |
91 | our $NFILE; |
91 | our %ANIM; |
92 | our %ANIM; |
92 | our $SMOOTH; |
|
|
93 | |
93 | |
94 | our (@png, @trs, @arc); # files we are interested in |
94 | our (@png, @trs, @arc); # files we are interested in |
95 | |
95 | |
96 | sub commit_png { |
96 | sub commit_png { |
97 | my ($name, $data) = @_; |
97 | my ($name, $data) = @_; |
… | |
… | |
122 | my ($w, $h) = unpack "NN", $1; |
122 | my ($w, $h) = unpack "NN", $1; |
123 | |
123 | |
124 | (my $face = $path) =~ s/^.*\///; |
124 | (my $face = $path) =~ s/^.*\///; |
125 | my $T = 32; |
125 | my $T = 32; |
126 | |
126 | |
127 | unless ($face =~ s/\.base\.(...)\.png$/.$1/) { |
127 | unless ($face =~ s/\.32x32\.png$//) { |
128 | warn "$path: weird filename, skipping.\n"; |
128 | warn "$path: weird filename, skipping.\n"; |
129 | next; |
129 | next; |
130 | } |
130 | } |
131 | |
131 | |
132 | if ($w < $T || $h < $T) { |
132 | if ($w < $T || $h < $T) { |
… | |
… | |
257 | $info->{visibility} = $visibility if defined $visibility; |
257 | $info->{visibility} = $visibility if defined $visibility; |
258 | $info->{magicmap} = $magicmap if defined $magicmap; |
258 | $info->{magicmap} = $magicmap if defined $magicmap; |
259 | } |
259 | } |
260 | |
260 | |
261 | if (my $smooth = delete $o->{smoothface}) { |
261 | if (my $smooth = delete $o->{smoothface}) { |
262 | $SMOOTH .= "$smooth\n"; |
262 | my ($face, $smooth) = split /\s+/, $smooth; |
|
|
263 | # skip empty_S.x11, it seems to server no purpose whatsoever |
|
|
264 | # but increases bandwidth demands and worse. |
|
|
265 | unless ($smooth eq "empty_S.x11") { |
|
|
266 | $FACEINFO{$face}{smooth} = $smooth; |
|
|
267 | } |
263 | } |
268 | } |
264 | } |
269 | } |
265 | } |
270 | } |
266 | } |
271 | } |
267 | } |
272 | } |
… | |
… | |
337 | substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; |
342 | substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; |
338 | print $fh Crossfire::archlist_to_string \@ARC; |
343 | print $fh Crossfire::archlist_to_string \@ARC; |
339 | } |
344 | } |
340 | |
345 | |
341 | { |
346 | { |
342 | open my $fh, ">:utf8", "$DATADIR/smooth~" |
|
|
343 | or die "$DATADIR/smooth~: $!"; |
|
|
344 | print $fh $SMOOTH; |
|
|
345 | } |
|
|
346 | |
|
|
347 | { |
|
|
348 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
347 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
349 | or die "$DATADIR/treasures~: $!"; |
348 | or die "$DATADIR/treasures~: $!"; |
350 | print $fh $TRS; |
349 | print $fh $TRS; |
351 | } |
350 | } |
352 | |
351 | |
… | |
… | |
362 | } |
361 | } |
363 | |
362 | |
364 | open my $fh, ">:perlio", "$DATADIR/faces~" |
363 | open my $fh, ">:perlio", "$DATADIR/faces~" |
365 | or die "$DATADIR/faces~: $!"; |
364 | or die "$DATADIR/faces~: $!"; |
366 | |
365 | |
|
|
366 | $FACEINFO{""} = { version => 1}; |
367 | print $fh Storable::nfreeze \%FACEINFO; |
367 | print $fh Storable::nfreeze \%FACEINFO; |
368 | } |
368 | } |
369 | |
369 | |
370 | for (qw(archetypes faces animations treasures smooth)) { |
370 | for (qw(archetypes faces animations treasures)) { |
371 | chmod 0644, "$DATADIR/$_~"; |
371 | chmod 0644, "$DATADIR/$_~"; |
372 | rename "$DATADIR/$_~", "$DATADIR/$_" |
372 | rename "$DATADIR/$_~", "$DATADIR/$_" |
373 | or die "$DATADIR/$_: $!"; |
373 | or die "$DATADIR/$_: $!"; |
374 | } |
374 | } |
375 | |
375 | |