… | |
… | |
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 (); |
19 | use File::Temp; |
20 | use File::Temp; |
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 (); |
|
|
25 | use Digest::MD5; |
|
|
26 | use Coro::Storable; $Storable::canonical = 1; |
24 | |
27 | |
25 | sub usage { |
28 | sub usage { |
26 | warn <<EOF; |
29 | warn <<EOF; |
27 | Usage: cfutil [-v] [-q] [--force] [--cache] |
30 | Usage: cfutil [-v] [-q] [--force] [--cache] |
28 | [--install-arch path] |
31 | [--install-arch path] |
… | |
… | |
66 | } |
69 | } |
67 | |
70 | |
68 | sub inst_maps($) { |
71 | sub inst_maps($) { |
69 | my (undef, $path) = @_; |
72 | my (undef, $path) = @_; |
70 | |
73 | |
71 | print "installing '$path' to '$DATADIR/maps'\n\n"; |
74 | print "\nInstalling '$path' to '$DATADIR/maps'\n\n"; |
72 | |
75 | |
73 | if (!-f "$path/regions") { |
76 | if (!-f "$path/regions") { |
74 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
77 | warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; |
75 | exit 1 unless $FORCE; |
78 | exit 1 unless $FORCE; |
76 | } |
79 | } |
77 | |
80 | |
78 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded"; |
81 | system $RSYNC, "-av", "$path/.", "$DATADIR/maps/.", "--delete", "--exclude", "CVS", "--delete-excluded" |
|
|
82 | and die "map installation failed.\n"; |
|
|
83 | |
|
|
84 | print "maps installed successfully.\n"; |
79 | } |
85 | } |
80 | |
86 | |
81 | { |
87 | { |
82 | our @PNG; |
88 | our %ANIMINFO; |
|
|
89 | our %FACEINFO; |
83 | our @ARC; |
90 | our @ARC; |
|
|
91 | our %ARC; |
|
|
92 | our $TRS; |
84 | our $NFILE; |
93 | our $NFILE; |
85 | |
94 | |
|
|
95 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
|
|
96 | |
86 | our (@png, @trs, @arc); # files we are interested in |
97 | our (@png, @trs, @arc); # files we are interested in |
87 | |
98 | |
88 | sub commit_png { |
99 | sub commit_png($$$) { |
89 | my ($name, $data) = @_; |
100 | my ($name, $data, $T) = @_; |
90 | #warn "$name: commited\n"; |
101 | |
|
|
102 | $FACEINFO{$name}{"data$T"} = $data; |
91 | } |
103 | } |
92 | |
104 | |
93 | sub process_png { |
105 | sub process_png { |
94 | while (@png) { |
106 | while (@png) { |
95 | my $path = pop @png; |
107 | my ($path, $delete) = @{pop @png}; |
96 | |
108 | |
97 | my $png; |
109 | my $png; |
98 | aio_lstat $path; |
110 | aio_lstat $path; |
99 | my ($size, $mtime) = (stat _)[7,9]; |
111 | my ($size, $mtime) = (stat _)[7,9]; |
100 | |
112 | |
101 | if (0 > aio_load $path, $png) { |
113 | if (0 > aio_load $path, $png) { |
102 | warn "$path: $!, skipping.\n"; |
114 | warn "$path: $!, skipping.\n"; |
103 | return; |
115 | next; |
104 | } |
116 | } |
105 | |
117 | |
|
|
118 | my $stem = $path; |
|
|
119 | my $T; |
|
|
120 | |
|
|
121 | if ($stem =~ s/\.32x32\.png~?$//) { |
|
|
122 | $T = 32; |
|
|
123 | } elsif ($stem =~ s/\.64x64\.png~?$//) { |
|
|
124 | $T = 64; |
|
|
125 | } else { |
|
|
126 | warn "$path: weird filename, skipping.\n"; |
|
|
127 | next; |
|
|
128 | } |
|
|
129 | |
106 | # quickly extratc width and height of the (necessarily PNG) image |
130 | # quickly extract width and height of the (necessarily PNG) image |
107 | unless ($png =~ /^\x89PNG\x0d\x0a\x1a\x0a....IHDR(........)/s) { |
131 | unless ($png =~ /^\x89PNG\x0d\x0a\x1a\x0a....IHDR(........)/s) { |
108 | warn "$path: not a recongized png file, skipping.\n"; |
132 | warn "$path: not a recognized png file, skipping.\n"; |
109 | return; |
133 | next; |
110 | } |
134 | } |
111 | |
135 | |
112 | my ($w, $h) = unpack "NN", $1; |
136 | my ($w, $h) = unpack "NN", $1; |
113 | |
|
|
114 | (my $face = $path) =~ s/^.*\///; |
|
|
115 | my $T = 32; |
|
|
116 | |
|
|
117 | unless ($face =~ s/\.base\.(...)\.png$/.$1/) { |
|
|
118 | warn "$path: weird filename, skipping.\n"; |
|
|
119 | return; |
|
|
120 | } |
|
|
121 | |
137 | |
122 | if ($w < $T || $h < $T) { |
138 | if ($w < $T || $h < $T) { |
123 | warn "$path: too small ($w $h), skipping.\n"; |
139 | warn "$path: too small ($w $h), skipping.\n"; |
124 | return; |
140 | next; |
125 | } |
141 | } |
126 | |
142 | |
127 | if ($w % $T || $h % $T) { |
143 | if ($w % $T || $h % $T) { |
128 | warn "$path: weird png size ($w $h), skipping.\n"; |
144 | warn "$path: weird png size ($w $h), skipping.\n"; |
129 | return; |
145 | next; |
|
|
146 | } |
|
|
147 | |
|
|
148 | unless ($path =~ /~$/) { |
|
|
149 | # possibly enlarge |
|
|
150 | if (0 > aio_stat "$stem.64x64.png") { |
|
|
151 | my $other = "$stem.64x64.png~"; |
|
|
152 | |
|
|
153 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
|
|
154 | my $wrap = 0; # for the time being |
|
|
155 | fork_sub { |
|
|
156 | system "convert png:\Q$path\E -depth 8 rgba:-" |
|
|
157 | . "| $exec_prefix/bin/cfhq2xa $w $h $wrap" |
|
|
158 | . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $QUANTIZE -quality 00 png32:\Q$other\E~" |
|
|
159 | and die "convert/hq2xa pipeline error: status $? ($!)"; |
|
|
160 | system $OPTIPNG, "-i0", "-q", "$other~"; |
|
|
161 | die "$other~ has zero size, aborting." unless -s "$other~"; |
|
|
162 | rename "$other~", $other; |
|
|
163 | }; |
|
|
164 | } |
|
|
165 | |
|
|
166 | push @png, [$other, !$CACHE]; |
130 | } |
167 | } |
131 | |
168 | |
|
|
169 | # possibly scale down |
|
|
170 | if (0 > aio_stat "$stem.32x32.png") { |
|
|
171 | my $other = "$stem.32x32.png~"; |
|
|
172 | |
|
|
173 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
|
|
174 | fork_sub { |
|
|
175 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
|
|
176 | system $OPTIPNG, "-i0", "-q", "$other~"; |
|
|
177 | |
|
|
178 | # reduce smoothfaces >10000 bytes |
|
|
179 | if ($stem =~ /_S\./ && (-s "$other~") > 10000) { |
|
|
180 | my $ncolor = 256; |
|
|
181 | while () { |
|
|
182 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
|
|
183 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
|
|
184 | last if 10000 > -s "$other~~"; |
|
|
185 | $ncolor = int $ncolor * 0.9; |
|
|
186 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
|
|
187 | } |
|
|
188 | |
|
|
189 | printf "reduced %s from %d to %d bytes using %d colours.\n", |
|
|
190 | $other, -s "$other~", -s "$other~~", $ncolor |
|
|
191 | if $VERBOSE >= 2; |
|
|
192 | rename "$other~~", "$other~"; |
|
|
193 | } |
|
|
194 | |
|
|
195 | die "$other~ has zero size, aborting." unless -s "$other~"; |
|
|
196 | rename "$other~", $other; |
|
|
197 | }; |
|
|
198 | } |
|
|
199 | |
|
|
200 | #warn "scaled down $path to $other\n";#d# |
|
|
201 | push @png, [$other, !$CACHE]; |
|
|
202 | } |
|
|
203 | } |
|
|
204 | |
|
|
205 | (my $face = $stem) =~ s/^.*\///; |
|
|
206 | |
|
|
207 | # split all bigfaces, but avoid smoothfaces (*_S) |
132 | if (($w > $T || $h > $T) && $face !~ /_S\./) { |
208 | if (($w > $T || $h > $T) && $face !~ /_S\./) { |
133 | # split |
209 | # split |
134 | my @tile; |
210 | my @tile; |
135 | for my $x (0 .. (int $w / $T) - 1) { |
211 | for my $x (0 .. (int $w / $T) - 1) { |
136 | for my $y (0 .. (int $h / $T) - 1) { |
212 | for my $y (0 .. (int $h / $T) - 1) { |
… | |
… | |
149 | (map { |
225 | (map { |
150 | ( |
226 | ( |
151 | "(", |
227 | "(", |
152 | "+clone", |
228 | "+clone", |
153 | -crop => (sprintf "%dx%d+%d+%d", $T, $T, $_->[0] * $T, $_->[1] * $T), |
229 | -crop => (sprintf "%dx%d+%d+%d", $T, $T, $_->[0] * $T, $_->[1] * $T), |
|
|
230 | "+repage", |
|
|
231 | -quality => "00", |
154 | -write => "png:$_->[2]~", |
232 | -write => "png32:$_->[2]~", |
155 | "+delete", |
233 | "+delete", |
156 | ")", |
234 | ")", |
157 | ) |
235 | ) |
158 | } @todo), |
236 | } @todo), |
159 | "null:"; |
237 | "null:"; |
… | |
… | |
163 | close $convert; |
241 | close $convert; |
164 | |
242 | |
165 | # pass 2, optimise, and rename |
243 | # pass 2, optimise, and rename |
166 | for (@todo) { |
244 | for (@todo) { |
167 | system $OPTIPNG, "-o5", "-i0", "-q", "$_->[2]~"; |
245 | system $OPTIPNG, "-o5", "-i0", "-q", "$_->[2]~"; |
|
|
246 | die "$_->[2]~ has zero size, aborting." unless -s "$_->[2]~"; |
168 | rename "$_->[2]~", $_->[2]; |
247 | rename "$_->[2]~", $_->[2]; |
169 | } |
248 | } |
170 | }; |
249 | }; |
171 | } |
250 | } |
172 | |
251 | |
… | |
… | |
176 | |
255 | |
177 | if (0 > aio_load $file, $tile) { |
256 | if (0 > aio_load $file, $tile) { |
178 | die "$path: unable to read tile +$x+$y, aborting.\n"; |
257 | die "$path: unable to read tile +$x+$y, aborting.\n"; |
179 | } |
258 | } |
180 | IO::AIO::aio_unlink $file unless $CACHE; |
259 | IO::AIO::aio_unlink $file unless $CACHE; |
181 | commit_png $x|$y ? "$face+$x+$y" : $face, $tile; |
260 | commit_png $x|$y ? "$face+$x+$y" : $face, $tile, $T; |
182 | } |
261 | } |
183 | } else { |
262 | } else { |
184 | # use as-is (either small, use smooth) |
263 | # use as-is (either small, use smooth) |
185 | commit_png $face, $png; |
264 | commit_png $face, $png, $T; |
186 | } |
265 | } |
|
|
266 | |
|
|
267 | aio_unlink $path if $delete; |
187 | } |
268 | } |
188 | } |
269 | } |
189 | |
270 | |
190 | sub process_arc { |
271 | sub process_arc { |
191 | while (@arc) { |
272 | while (@arc) { |
192 | my ($dir, $file) = @{pop @arc}; |
273 | my ($dir, $file) = @{pop @arc}; |
193 | |
274 | |
194 | my $arc; |
275 | my $arc; |
195 | aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ |
276 | aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ |
|
|
277 | |
196 | my $arc = read_arch "$dir/$file"; |
278 | my $arc = read_arch "$dir/$file"; |
|
|
279 | for my $o (values %$arc) { |
|
|
280 | push @ARC, $o; |
|
|
281 | for (my $m = $o; $m; $m = $m->{more}) { |
|
|
282 | $ARC{$m->{_name}} = $m; |
|
|
283 | } |
|
|
284 | |
|
|
285 | $o->{editor_folder} = $dir; |
|
|
286 | |
|
|
287 | my $visibility = delete $o->{visibility}; |
|
|
288 | my $magicmap = delete $o->{magicmap}; |
|
|
289 | |
|
|
290 | # find upper left corner :/ |
|
|
291 | # omg, this is sooo broken |
|
|
292 | my ($dx, $dy); |
|
|
293 | for (my $o = $o; $o; $o = $o->{more}) { |
|
|
294 | $dx = $o->{x} if $o->{x} < $dx; |
|
|
295 | $dy = $o->{y} if $o->{y} < $dy; |
|
|
296 | } |
|
|
297 | |
|
|
298 | for (my $o = $o; $o; $o = $o->{more}) { |
|
|
299 | my $x = $o->{x} - $dx; |
|
|
300 | my $y = $o->{y} - $dy; |
|
|
301 | |
|
|
302 | my $ext = $x|$y ? "+$x+$y" : ""; |
|
|
303 | |
|
|
304 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
|
|
305 | |
|
|
306 | my $visibility = delete $o->{visibility} if exists $o->{visibility}; |
|
|
307 | my $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
|
|
308 | |
|
|
309 | my $anim = delete $o->{anim}; |
|
|
310 | |
|
|
311 | if ($anim) { |
|
|
312 | # possibly add $ext to the animation name to avoid |
|
|
313 | # the need to specify archnames for all parts |
|
|
314 | # of a multipart archetype. |
|
|
315 | $o->{animation} = "$o->{_name}"; |
|
|
316 | my $facings = 1; |
|
|
317 | my @frames; |
|
|
318 | |
|
|
319 | for (@$anim) { |
|
|
320 | if (/^facings\s+(\d+)/) { |
|
|
321 | $facings = $1*1; |
|
|
322 | } elsif (/^blank.x11$|^empty.x11$/) { |
|
|
323 | push @frames, $_; |
|
|
324 | } else { |
|
|
325 | push @frames, "$_$ext"; |
|
|
326 | } |
|
|
327 | } |
|
|
328 | |
|
|
329 | $ANIMINFO{$o->{animation}} = { |
|
|
330 | facings => $facings, |
|
|
331 | frames => \@frames, |
|
|
332 | }; |
|
|
333 | } |
|
|
334 | |
|
|
335 | for my $face ($o->{face} || (), @{$anim || []}) { |
|
|
336 | next if $face =~ /^facings\s|^blank.x11$|^empty.x11$/; |
|
|
337 | |
|
|
338 | my $info = $FACEINFO{$face} ||= {}; |
|
|
339 | |
|
|
340 | $info->{visibility} = $visibility if defined $visibility; |
|
|
341 | $info->{magicmap} = $magicmap if defined $magicmap; |
|
|
342 | } |
|
|
343 | |
|
|
344 | if (my $smooth = delete $o->{smoothface}) { |
|
|
345 | my %kv =split /\s+/, $smooth; |
|
|
346 | my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support |
|
|
347 | while (my ($face, $smooth) = each %kv) { |
|
|
348 | $FACEINFO{$face}{smooth} = $smooth; |
|
|
349 | $FACEINFO{$face}{smoothlevel} = $level; |
|
|
350 | } |
|
|
351 | } |
|
|
352 | } |
|
|
353 | } |
197 | } |
354 | } |
198 | } |
355 | } |
199 | |
356 | |
200 | sub process_trs { |
357 | sub process_trs { |
201 | while (@trs) { |
358 | while (@trs) { |
202 | my ($dir, $file) = @{pop @trs}; |
359 | my ($dir, $file) = @{pop @trs}; |
|
|
360 | my $path = "$dir/$file"; |
|
|
361 | |
|
|
362 | my $trs; |
|
|
363 | if (0 > aio_load $path, $trs) { |
|
|
364 | warn "$path: $!, skipping.\n"; |
|
|
365 | next; |
|
|
366 | } |
|
|
367 | |
|
|
368 | $TRS .= $trs; |
203 | } |
369 | } |
204 | } |
370 | } |
205 | |
371 | |
206 | sub find_files; |
372 | sub find_files; |
207 | sub find_files { |
373 | sub find_files { |
… | |
… | |
214 | find_files "$path/$_" |
380 | find_files "$path/$_" |
215 | for grep $_ !~ /^(?:CVS|dev)$/, @$dirs; |
381 | for grep $_ !~ /^(?:CVS|dev)$/, @$dirs; |
216 | |
382 | |
217 | for my $file (@$nondirs) { |
383 | for my $file (@$nondirs) { |
218 | if ($file =~ /\.png$/) { |
384 | if ($file =~ /\.png$/) { |
219 | push @png, "$path/$file"; |
385 | push @png, ["$path/$file", 0]; |
220 | } elsif ($file =~ /\.trs$/) { |
386 | } elsif ($file =~ /\.trs$/) { |
221 | push @trs, [$path, $file]; |
387 | push @trs, [$path, $file]; |
222 | } elsif ($file =~ /\.arc$/) { |
388 | } elsif ($file =~ /\.arc$/) { |
223 | push @arc, [$path, $file]; |
389 | push @arc, [$path, $file]; |
224 | } else { |
390 | } else { |
225 | warn "ignoring $path/$file\n" if $VERBOSE >= 2; |
391 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
226 | } |
392 | } |
227 | } |
393 | } |
228 | }; |
394 | }; |
229 | } |
395 | } |
230 | |
396 | |
231 | sub inst_arch($) { |
397 | sub inst_arch($) { |
232 | my (undef, $path) = @_; |
398 | my (undef, $path) = @_; |
233 | |
399 | |
|
|
400 | print "\n", |
234 | print "installing '$path' to '$DATADIR'\n\n"; |
401 | "Installing '$path' to '$DATADIR'\n", |
|
|
402 | "\n", |
|
|
403 | "This can take a long time if you run this\n", |
|
|
404 | "for the first time or do not use --cache.\n", |
|
|
405 | "\n", |
|
|
406 | "Unless you run verbosely, all following warning\n", |
|
|
407 | "or error messages indicate serious problems.\n", |
|
|
408 | "\n"; |
235 | |
409 | |
236 | if (!-d "$path/treasures") { |
410 | if (!-d "$path/treasures") { |
237 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
411 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
238 | exit 1 unless $FORCE; |
412 | exit 1 unless $FORCE; |
239 | } |
413 | } |
240 | |
414 | |
241 | find_files $path; |
415 | find_files $path; |
242 | IO::AIO::flush; |
416 | IO::AIO::flush; |
243 | |
417 | |
244 | $_->join for ( |
418 | $_->join for ( |
245 | (async \&process_png), (async \&process_png), |
419 | # four png crunchers work fine for my 2x smp machine |
|
|
420 | (async \&process_png), (async \&process_png), (async \&process_png), (async \&process_png), |
246 | (async \&process_trs), (async \&process_trs), |
421 | (async \&process_trs), (async \&process_trs), |
247 | (async \&process_arc), (async \&process_arc), |
422 | (async \&process_arc), (async \&process_arc), |
248 | ); |
423 | ); |
249 | |
424 | |
250 | die "--install-arch not yet implemented\n"; |
425 | { |
|
|
426 | # remove path prefix from editor_folder |
|
|
427 | substr $_->{editor_folder}, 0, 1 + length $path, "" |
|
|
428 | for values %ARC; |
|
|
429 | |
|
|
430 | # resolve inherit |
|
|
431 | while () { |
|
|
432 | my $progress; |
|
|
433 | my $loop; |
|
|
434 | |
|
|
435 | for my $o (values %ARC) { |
|
|
436 | if (my $other = $o->{inherit}) { |
|
|
437 | if (my $s = $ARC{$other}) { |
|
|
438 | if ($s->{inherit}) { |
|
|
439 | $loop = $s; |
|
|
440 | } else { |
|
|
441 | delete $o->{inherit}; |
|
|
442 | my %s = %$s; |
|
|
443 | delete @s{qw(_name more name name_pl)}; |
|
|
444 | %$o = ( %s, %$o ); |
|
|
445 | ++$progress; |
|
|
446 | } |
|
|
447 | } else { |
|
|
448 | warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; |
|
|
449 | delete $ARC{$o->{_name}}; |
|
|
450 | } |
|
|
451 | } |
|
|
452 | } |
|
|
453 | |
|
|
454 | unless ($progress) { |
|
|
455 | die "inheritance loop detected starting at archetype '$loop->{_name}', aborting.\n" |
|
|
456 | if $loop; |
|
|
457 | |
|
|
458 | last; |
|
|
459 | } |
|
|
460 | } |
|
|
461 | |
|
|
462 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
|
|
463 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
|
|
464 | |
|
|
465 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
|
|
466 | or die "$DATADIR/archetypes~: $!"; |
|
|
467 | print $fh Crossfire::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
|
|
468 | } |
|
|
469 | |
|
|
470 | { |
|
|
471 | open my $fh, ">:utf8", "$DATADIR/treasures~" |
|
|
472 | or die "$DATADIR/treasures~: $!"; |
|
|
473 | print $fh $TRS; |
|
|
474 | } |
|
|
475 | |
|
|
476 | { |
|
|
477 | while (my ($k, $v) = each %FACEINFO) { |
|
|
478 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
|
|
479 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
|
|
480 | |
|
|
481 | length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
|
|
482 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
|
|
483 | |
|
|
484 | $v->{chksum32} = Digest::MD5::md5 $v->{data32}; |
|
|
485 | $v->{chksum64} = Digest::MD5::md5 $v->{data64}; |
|
|
486 | } |
|
|
487 | |
|
|
488 | open my $fh, ">:perlio", "$DATADIR/facedata~" |
|
|
489 | or die "$DATADIR/facedata~: $!"; |
|
|
490 | |
|
|
491 | print $fh freeze { |
|
|
492 | version => 2, |
|
|
493 | faceinfo => \%FACEINFO, |
|
|
494 | animinfo => \%ANIMINFO, |
|
|
495 | }; |
|
|
496 | } |
|
|
497 | |
|
|
498 | for (qw(archetypes facedata treasures)) { |
|
|
499 | chmod 0644, "$DATADIR/$_~"; |
|
|
500 | rename "$DATADIR/$_~", "$DATADIR/$_" |
|
|
501 | or die "$DATADIR/$_: $!"; |
|
|
502 | } |
|
|
503 | |
|
|
504 | print "archetype data installed successfully.\n"; |
251 | } |
505 | } |
252 | } |
506 | } |
253 | |
507 | |
254 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
508 | Getopt::Long::Configure ("bundling", "no_ignore_case"); |
255 | GetOptions ( |
509 | GetOptions ( |