… | |
… | |
6 | my $exec_prefix = "@exec_prefix@"; |
6 | my $exec_prefix = "@exec_prefix@"; |
7 | my $datarootdir = "@datarootdir@"; |
7 | my $datarootdir = "@datarootdir@"; |
8 | my $DATADIR = "@datadir@/@PACKAGE@"; |
8 | my $DATADIR = "@datadir@/@PACKAGE@"; |
9 | |
9 | |
10 | my $CONVERT = "@CONVERT@"; |
10 | my $CONVERT = "@CONVERT@"; |
11 | my $IDENTIFY = "@IDENTIFY@"; |
11 | #my $IDENTIFY = "@IDENTIFY@"; |
12 | my $OPTIPNG = "@OPTIPNG@"; |
12 | my $OPTIPNG = "@OPTIPNG@"; |
13 | my $RSYNC = "@RSYNC@"; |
13 | my $RSYNC = "@RSYNC@"; |
|
|
14 | my $PNGNQ = "@PNGNQ@"; |
14 | |
15 | |
15 | use Getopt::Long; |
16 | use Getopt::Long; |
16 | use Coro::Event; |
17 | use Coro::Event; |
17 | use AnyEvent; |
18 | use AnyEvent; |
18 | use IO::AIO (); |
19 | use IO::AIO (); |
… | |
… | |
20 | use Crossfire; |
21 | use Crossfire; |
21 | use Coro; |
22 | use Coro; |
22 | use Coro::AIO; |
23 | use Coro::AIO; |
23 | use POSIX (); |
24 | use POSIX (); |
24 | use Digest::MD5; |
25 | use Digest::MD5; |
25 | use Storable; $Storable::canonical = 1; |
26 | use Coro::Storable; $Storable::canonical = 1; |
26 | |
27 | |
27 | sub usage { |
28 | sub usage { |
28 | warn <<EOF; |
29 | warn <<EOF; |
29 | Usage: cfutil [-v] [-q] [--force] [--cache] |
30 | Usage: cfutil [-v] [-q] [--force] [--cache] |
30 | [--install-arch path] |
31 | [--install-arch path] |
… | |
… | |
42 | my $CACHE = 0; |
43 | my $CACHE = 0; |
43 | my $FORCE; |
44 | my $FORCE; |
44 | my $TMPDIR = "/tmp/cfutil$$~"; |
45 | my $TMPDIR = "/tmp/cfutil$$~"; |
45 | my $TMPFILE = "aaaa0"; |
46 | my $TMPFILE = "aaaa0"; |
46 | |
47 | |
|
|
48 | our %COLOR = ( |
|
|
49 | black => 0, |
|
|
50 | white => 1, |
|
|
51 | navy => 2, |
|
|
52 | red => 3, |
|
|
53 | orange => 4, |
|
|
54 | blue => 5, |
|
|
55 | darkorange => 6, |
|
|
56 | green => 7, |
|
|
57 | lightgreen => 8, |
|
|
58 | grey => 9, |
|
|
59 | brown => 10, |
|
|
60 | gold => 11, |
|
|
61 | tan => 12, |
|
|
62 | ); |
|
|
63 | |
47 | END { system "rm", "-rf", $TMPDIR } |
64 | END { system "rm", "-rf", $TMPDIR } |
48 | |
65 | |
49 | Event->signal (signal => "INT", cb => sub { exit 1 }); |
66 | Event->signal (signal => "INT", cb => sub { exit 1 }); |
50 | Event->signal (signal => "TERM", cb => sub { exit 1 }); |
67 | Event->signal (signal => "TERM", cb => sub { exit 1 }); |
51 | |
68 | |
… | |
… | |
68 | } |
85 | } |
69 | |
86 | |
70 | sub inst_maps($) { |
87 | sub inst_maps($) { |
71 | my (undef, $path) = @_; |
88 | my (undef, $path) = @_; |
72 | |
89 | |
73 | print "installing '$path' to '$DATADIR/maps'\n"; |
90 | print "\nInstalling '$path' to '$DATADIR/maps'\n\n"; |
74 | |
91 | |
75 | if (!-f "$path/regions") { |
92 | if (!-f "$path/regions") { |
76 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
93 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
77 | exit 1 unless $FORCE; |
94 | exit 1 unless $FORCE; |
78 | } |
95 | } |
… | |
… | |
82 | |
99 | |
83 | print "maps installed successfully.\n"; |
100 | print "maps installed successfully.\n"; |
84 | } |
101 | } |
85 | |
102 | |
86 | { |
103 | { |
|
|
104 | our %ANIMINFO; |
87 | our %FACEINFO; |
105 | our %FACEINFO; |
|
|
106 | our %RESOURCE; |
88 | our @ARC; |
107 | our @ARC; |
|
|
108 | our %ARC; |
89 | our $TRS; |
109 | our $TRS; |
90 | our $NFILE; |
110 | our $NFILE; |
91 | our %ANIM; |
111 | our $PATH; |
92 | |
112 | |
93 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
113 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
94 | |
114 | |
95 | our (@png, @trs, @arc); # files we are interested in |
115 | our (@png, @trs, @arc, @res); # files we are interested in |
96 | |
116 | |
97 | sub commit_png($$$) { |
117 | sub commit_png($$$) { |
98 | my ($name, $data, $T) = @_; |
118 | my ($name, $data, $T) = @_; |
99 | |
119 | |
100 | $FACEINFO{$name}{"data$T"} = $data; |
120 | $FACEINFO{$name}{"data$T"} = $data; |
… | |
… | |
147 | # possibly enlarge |
167 | # possibly enlarge |
148 | if (0 > aio_stat "$stem.64x64.png") { |
168 | if (0 > aio_stat "$stem.64x64.png") { |
149 | my $other = "$stem.64x64.png~"; |
169 | my $other = "$stem.64x64.png~"; |
150 | |
170 | |
151 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
171 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
152 | warn "rescale $other\n";#d# |
|
|
153 | my $wrap = 0; # for the time being |
172 | my $wrap = 0; # for the time being |
154 | fork_sub { |
173 | fork_sub { |
155 | system "convert png:\Q$path\E -depth 8 rgba:-" |
174 | system "convert png:\Q$path\E -depth 8 rgba:-" |
156 | . "| $exec_prefix/bin/cfhq2xa $w $h $wrap" |
175 | . "| $exec_prefix/bin/cfhq2xa $w $h $wrap" |
157 | . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" |
176 | . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" |
158 | and die "convert/hq2xa pipeline error: status $? ($!)"; |
177 | and die "convert/hq2xa pipeline error: status $? ($!)"; |
159 | system $OPTIPNG, "-o5", "-i0", "-q", "$other~"; |
178 | system $OPTIPNG, "-i0", "-q", "$other~"; |
160 | die "$other~ has zero size, aborting." unless -s "$other~"; |
179 | die "$other~ has zero size, aborting." unless -s "$other~"; |
161 | rename "$other~", $other; |
180 | rename "$other~", $other; |
162 | }; |
181 | }; |
163 | } |
182 | } |
164 | |
183 | |
… | |
… | |
170 | my $other = "$stem.32x32.png~"; |
189 | my $other = "$stem.32x32.png~"; |
171 | |
190 | |
172 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
191 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
173 | fork_sub { |
192 | fork_sub { |
174 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
193 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
175 | system $OPTIPNG, "-o5", "-i0", "-q", "$other~"; |
194 | system $OPTIPNG, "-i0", "-q", "$other~"; |
|
|
195 | |
|
|
196 | # reduce smoothfaces >10000 bytes |
|
|
197 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
|
|
198 | my $ncolor = 256; |
|
|
199 | while () { |
|
|
200 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
|
|
201 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
|
|
202 | last if 10000 > -s "$other~~"; |
|
|
203 | $ncolor = int $ncolor * 0.9; |
|
|
204 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
|
|
205 | } |
|
|
206 | |
|
|
207 | printf "reduced %s from %d to %d bytes using %d colours.\n", |
|
|
208 | $other, -s "$other~", -s "$other~~", $ncolor |
|
|
209 | if $VERBOSE >= 2; |
|
|
210 | rename "$other~~", "$other~"; |
|
|
211 | } |
|
|
212 | |
176 | die "$other~ has zero size, aborting." unless -s "$other~"; |
213 | die "$other~ has zero size, aborting." unless -s "$other~"; |
177 | rename "$other~", $other; |
214 | rename "$other~", $other; |
178 | }; |
215 | }; |
179 | } |
216 | } |
180 | |
217 | |
181 | warn "scaled down $path to $other\n";#d# |
218 | #warn "scaled down $path to $other\n";#d# |
182 | |
|
|
183 | push @png, [$other, !$CACHE]; |
219 | push @png, [$other, !$CACHE]; |
184 | } |
220 | } |
185 | } |
221 | } |
186 | |
222 | |
187 | (my $face = $stem) =~ s/^.*\///; |
223 | (my $face = $stem) =~ s/^.*\///; |
188 | |
224 | |
|
|
225 | # split all bigfaces, but avoid smoothfaces (*_S) |
189 | if (($w > $T || $h > $T) && $face !~ /_S\./) { |
226 | if (($w > $T || $h > $T) && $face !~ /_S\./) { |
190 | # split |
227 | # split |
191 | my @tile; |
228 | my @tile; |
192 | for my $x (0 .. (int $w / $T) - 1) { |
229 | for my $x (0 .. (int $w / $T) - 1) { |
193 | for my $y (0 .. (int $h / $T) - 1) { |
230 | for my $y (0 .. (int $h / $T) - 1) { |
… | |
… | |
257 | aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ |
294 | aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ |
258 | |
295 | |
259 | my $arc = read_arch "$dir/$file"; |
296 | my $arc = read_arch "$dir/$file"; |
260 | for my $o (values %$arc) { |
297 | for my $o (values %$arc) { |
261 | push @ARC, $o; |
298 | push @ARC, $o; |
|
|
299 | for (my $m = $o; $m; $m = $m->{more}) { |
|
|
300 | $ARC{$m->{_name}} = $m; |
|
|
301 | } |
262 | |
302 | |
263 | $o->{editor_folder} = $dir; |
303 | $o->{editor_folder} = $dir; |
264 | |
304 | |
265 | my $visibility = delete $o->{visibility}; |
305 | my $visibility = delete $o->{visibility}; |
266 | my $magicmap = delete $o->{magicmap}; |
306 | my $magicmap = delete $o->{magicmap}; |
… | |
… | |
277 | my $x = $o->{x} - $dx; |
317 | my $x = $o->{x} - $dx; |
278 | my $y = $o->{y} - $dy; |
318 | my $y = $o->{y} - $dy; |
279 | |
319 | |
280 | my $ext = $x|$y ? "+$x+$y" : ""; |
320 | my $ext = $x|$y ? "+$x+$y" : ""; |
281 | |
321 | |
282 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/; |
322 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
283 | |
323 | |
284 | my $visibility = delete $o->{visibility} if exists $o->{visibility}; |
324 | $visibility = delete $o->{visibility} if exists $o->{visibility}; |
285 | my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
325 | $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
286 | |
326 | |
287 | my $anim = delete $o->{anim}; |
327 | my $anim = delete $o->{anim}; |
288 | |
328 | |
289 | if ($anim) { |
329 | if ($anim) { |
|
|
330 | # possibly add $ext to the animation name to avoid |
|
|
331 | # the need to specify archnames for all parts |
|
|
332 | # of a multipart archetype. |
290 | $o->{animation} = "$o->{_name}"; |
333 | $o->{animation} = "$o->{_name}"; |
|
|
334 | my $facings = 1; |
|
|
335 | my @frames; |
291 | |
336 | |
292 | for (@$anim) { |
337 | for (@$anim) { |
293 | $_ .= $ext unless /^facings\s|^blank.x11$|^empty.x11$/; |
338 | if (/^facings\s+(\d+)/) { |
|
|
339 | $facings = $1*1; |
|
|
340 | } elsif (/^blank.x11$|^empty.x11$/) { |
|
|
341 | push @frames, $_; |
|
|
342 | } else { |
|
|
343 | push @frames, "$_$ext"; |
|
|
344 | } |
294 | } |
345 | } |
295 | |
346 | |
296 | $ANIM{"$o->{_name}$ext"} = |
347 | $ANIMINFO{$o->{animation}} = { |
297 | join "", map "$_\n", |
348 | facings => $facings, |
298 | "anim $o->{_name}", |
349 | frames => \@frames, |
299 | @$anim, |
350 | }; |
300 | "mina"; |
|
|
301 | } |
351 | } |
302 | |
352 | |
303 | for my $face ($o->{face} || (), @{$anim || []}) { |
353 | for my $face ($o->{face} || (), @{$anim || []}) { |
304 | next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/; |
354 | next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/; |
305 | |
355 | |
… | |
… | |
308 | $info->{visibility} = $visibility if defined $visibility; |
358 | $info->{visibility} = $visibility if defined $visibility; |
309 | $info->{magicmap} = $magicmap if defined $magicmap; |
359 | $info->{magicmap} = $magicmap if defined $magicmap; |
310 | } |
360 | } |
311 | |
361 | |
312 | if (my $smooth = delete $o->{smoothface}) { |
362 | if (my $smooth = delete $o->{smoothface}) { |
313 | my ($face, $smooth) = split /\s+/, $smooth; |
363 | my %kv =split /\s+/, $smooth; |
314 | # skip empty_S.x11, it seems to server no purpose whatsoever |
364 | my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support |
315 | # but increases bandwidth demands and worse. |
365 | while (my ($face, $smooth) = each %kv) { |
316 | unless ($smooth eq "empty_S.x11") { |
|
|
317 | $FACEINFO{$face}{smooth} = $smooth; |
366 | $FACEINFO{$face}{smooth} = $smooth; |
|
|
367 | $FACEINFO{$face}{smoothlevel} = $level; |
318 | } |
368 | } |
319 | } |
369 | } |
320 | } |
370 | } |
321 | } |
371 | } |
322 | } |
372 | } |
… | |
… | |
332 | warn "$path: $!, skipping.\n"; |
382 | warn "$path: $!, skipping.\n"; |
333 | next; |
383 | next; |
334 | } |
384 | } |
335 | |
385 | |
336 | $TRS .= $trs; |
386 | $TRS .= $trs; |
|
|
387 | } |
|
|
388 | } |
|
|
389 | |
|
|
390 | sub process_res { |
|
|
391 | while (@res) { |
|
|
392 | my ($dir, $file) = @{pop @res}; |
|
|
393 | |
|
|
394 | my $data; |
|
|
395 | aio_load "$dir/$file", $data; |
|
|
396 | |
|
|
397 | my $copyright; |
|
|
398 | aio_load "$dir/copyright", $copyright; |
|
|
399 | |
|
|
400 | $file =~ s/\.res$//; |
|
|
401 | $file =~ /\.([^.]+)$/ |
|
|
402 | or next; |
|
|
403 | |
|
|
404 | my $type = $1; |
|
|
405 | |
|
|
406 | substr $dir, 0, 1 + length $PATH, ""; |
|
|
407 | |
|
|
408 | $RESOURCE{"$dir/$file"} = { |
|
|
409 | type => $1, |
|
|
410 | copyright => $copyright, |
|
|
411 | data => $data, |
|
|
412 | chksum => Digest::MD5::md5 $data, |
|
|
413 | }; |
337 | } |
414 | } |
338 | } |
415 | } |
339 | |
416 | |
340 | sub find_files; |
417 | sub find_files; |
341 | sub find_files { |
418 | sub find_files { |
… | |
… | |
353 | push @png, ["$path/$file", 0]; |
430 | push @png, ["$path/$file", 0]; |
354 | } elsif ($file =~ /\.trs$/) { |
431 | } elsif ($file =~ /\.trs$/) { |
355 | push @trs, [$path, $file]; |
432 | push @trs, [$path, $file]; |
356 | } elsif ($file =~ /\.arc$/) { |
433 | } elsif ($file =~ /\.arc$/) { |
357 | push @arc, [$path, $file]; |
434 | push @arc, [$path, $file]; |
|
|
435 | } elsif ($file =~ /\.(ogg|res)$/) { |
|
|
436 | push @res, [$path, $file]; |
358 | } else { |
437 | } else { |
359 | warn "ignoring $path/$file\n" if $VERBOSE >= 2; |
438 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
360 | } |
439 | } |
361 | } |
440 | } |
362 | }; |
441 | }; |
363 | } |
442 | } |
364 | |
443 | |
365 | sub inst_arch($) { |
444 | sub inst_arch($) { |
366 | my (undef, $path) = @_; |
445 | my (undef, $path) = @_; |
367 | |
446 | |
|
|
447 | $PATH = $path; |
|
|
448 | |
|
|
449 | print "\n", |
368 | print "installing '$path' to '$DATADIR'\n", |
450 | "Installing '$path' to '$DATADIR'\n", |
|
|
451 | "\n", |
369 | "(this can take a long time if you run this\n", |
452 | "This can take a long time if you run this\n", |
370 | "for the first time or do not use --cache).\n"; |
453 | "for the first time or do not use --cache.\n", |
|
|
454 | "\n", |
|
|
455 | "Unless you run verbosely, all following warning\n", |
|
|
456 | "or error messages indicate serious problems.\n", |
|
|
457 | "\n"; |
371 | |
458 | |
372 | if (!-d "$path/treasures") { |
459 | if (!-d "$path/treasures") { |
373 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
460 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
374 | exit 1 unless $FORCE; |
461 | exit 1 unless $FORCE; |
375 | } |
462 | } |
… | |
… | |
380 | $_->join for ( |
467 | $_->join for ( |
381 | # four png crunchers work fine for my 2x smp machine |
468 | # four png crunchers work fine for my 2x smp machine |
382 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
469 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
383 | (async \&process_trs), (async \&process_trs), |
470 | (async \&process_trs), (async \&process_trs), |
384 | (async \&process_arc), (async \&process_arc), |
471 | (async \&process_arc), (async \&process_arc), |
|
|
472 | (async \&process_res), (async \&process_res), |
385 | ); |
473 | ); |
386 | |
474 | |
387 | { |
475 | { |
388 | open my $fh, ">:utf8", "$DATADIR/animations~" |
476 | # remove path prefix from editor_folder |
389 | or die "$DATADIR/animations~: $!"; |
477 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
390 | print $fh join "", map $ANIM{$_}, sort keys %ANIM |
478 | for values %ARC; |
|
|
479 | |
|
|
480 | # resolve inherit |
|
|
481 | while () { |
|
|
482 | my $progress; |
|
|
483 | my $loop; |
|
|
484 | |
|
|
485 | for my $o (values %ARC) { |
|
|
486 | if (my $other = $o->{inherit}) { |
|
|
487 | if (my $s = $ARC{$other}) { |
|
|
488 | if ($s->{inherit}) { |
|
|
489 | $loop = $s; |
|
|
490 | } else { |
|
|
491 | delete $o->{inherit}; |
|
|
492 | my %s = %$s; |
|
|
493 | delete @s{qw(_name more name name_pl)}; |
|
|
494 | %$o = ( %s, %$o ); |
|
|
495 | ++$progress; |
|
|
496 | } |
|
|
497 | } else { |
|
|
498 | warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; |
|
|
499 | delete $ARC{$o->{_name}}; |
|
|
500 | } |
|
|
501 | } |
|
|
502 | } |
|
|
503 | |
|
|
504 | unless ($progress) { |
|
|
505 | die "inheritance loop detected starting at archetype '$loop->{_name}', aborting.\n" |
|
|
506 | if $loop; |
|
|
507 | |
|
|
508 | last; |
|
|
509 | } |
391 | } |
510 | } |
392 | |
511 | |
393 | { |
512 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
|
|
513 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
|
|
514 | |
394 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
515 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
395 | or die "$DATADIR/archetypes~: $!"; |
516 | or die "$DATADIR/archetypes~: $!"; |
396 | substr $_->{editor_folder}, 0, 1 + length $path, "" for @ARC; |
517 | print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
397 | print $fh Crossfire::archlist_to_string \@ARC; |
|
|
398 | } |
518 | } |
399 | |
519 | |
400 | { |
520 | { |
401 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
521 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
402 | or die "$DATADIR/treasures~: $!"; |
522 | or die "$DATADIR/treasures~: $!"; |
… | |
… | |
406 | { |
526 | { |
407 | while (my ($k, $v) = each %FACEINFO) { |
527 | while (my ($k, $v) = each %FACEINFO) { |
408 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
528 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
409 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
529 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
410 | |
530 | |
|
|
531 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
|
|
532 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
|
|
533 | |
411 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
534 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
412 | $v->{chksum64} = Digest::MD5::md5 $v->{data64}; |
535 | $v->{chksum64} = Digest::MD5::md5 $v->{data64}; |
|
|
536 | |
|
|
537 | if (my $magicmap = $v->{magicmap}) { |
|
|
538 | $magicmap =~ y/A-Z_\-/a-z/d; |
|
|
539 | $v->{magicmap} = $COLOR{$magicmap}; |
|
|
540 | } |
413 | } |
541 | } |
414 | |
542 | |
415 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
543 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
416 | or die "$DATADIR/facedata~: $!"; |
544 | or die "$DATADIR/facedata~: $!"; |
417 | |
545 | |
418 | $FACEINFO{""} = { version => 1}; |
546 | print $fh freeze { |
419 | print $fh Storable::nfreeze \%FACEINFO; |
547 | version => 2, |
|
|
548 | faceinfo => \%FACEINFO, |
|
|
549 | animinfo => \%ANIMINFO, |
|
|
550 | resource => \%RESOURCE, |
420 | } |
551 | }; |
|
|
552 | } |
421 | |
553 | |
422 | for (qw(archetypes facedata animations treasures)) { |
554 | for (qw(archetypes facedata treasures)) { |
423 | chmod 0644, "$DATADIR/$_~"; |
555 | chmod 0644, "$DATADIR/$_~"; |
424 | rename "$DATADIR/$_~", "$DATADIR/$_" |
556 | rename "$DATADIR/$_~", "$DATADIR/$_" |
425 | or die "$DATADIR/$_: $!"; |
557 | or die "$DATADIR/$_: $!"; |
426 | } |
558 | } |
427 | |
559 | |