1 | #!@PERL@ |
1 | #!@PERL@ |
2 | |
2 | |
3 | # |
3 | # |
4 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
4 | # This file is part of Deliantra, the Roguelike Realtime MMORPG. |
5 | # |
5 | # |
6 | # Copyright (©) 2007,2008,2009 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
6 | # Copyright (©) 2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
7 | # |
7 | # |
8 | # Deliantra is free software: you can redistribute it and/or modify it under |
8 | # Deliantra is free software: you can redistribute it and/or modify it under |
9 | # the terms of the Affero GNU General Public License as published by the |
9 | # the terms of the Affero GNU General Public License as published by the |
10 | # Free Software Foundation, either version 3 of the License, or (at your |
10 | # Free Software Foundation, either version 3 of the License, or (at your |
11 | # option) any later version. |
11 | # option) any later version. |
… | |
… | |
28 | my $exec_prefix = "@exec_prefix@"; |
28 | my $exec_prefix = "@exec_prefix@"; |
29 | my $datarootdir = "@datarootdir@"; |
29 | my $datarootdir = "@datarootdir@"; |
30 | my $DATADIR = "@datadir@/@PACKAGE@"; |
30 | my $DATADIR = "@datadir@/@PACKAGE@"; |
31 | |
31 | |
32 | my $CONVERT = "@CONVERT@"; |
32 | my $CONVERT = "@CONVERT@"; |
33 | #my $IDENTIFY = "@IDENTIFY@"; |
33 | my $IDENTIFY = "@IDENTIFY@"; |
34 | my $OPTIPNG = "@OPTIPNG@"; |
34 | my $OPTIPNG = "@OPTIPNG@"; |
35 | my $RSYNC = "@RSYNC@"; |
35 | my $RSYNC = "@RSYNC@"; |
36 | my $PNGNQ = "@PNGNQ@"; |
36 | my $PNGNQ = "@PNGNQ@"; |
37 | |
37 | |
38 | use Getopt::Long; |
38 | use Getopt::Long; |
39 | use File::Temp; |
39 | use File::Temp; |
40 | use POSIX (); |
40 | use POSIX (); |
41 | use Carp; |
41 | use Carp; |
42 | |
42 | |
43 | use Coro::EV; |
|
|
44 | use AnyEvent; |
|
|
45 | use YAML::XS (); |
43 | use YAML::XS (); |
|
|
44 | use Digest::MD5 (); |
|
|
45 | use Storable (); |
46 | use JSON::XS (); |
46 | use JSON::XS (); |
47 | use IO::AIO (); |
47 | use IO::AIO (); |
48 | use Digest::MD5 (); |
48 | use Compress::LZF (); |
49 | |
49 | |
|
|
50 | use AnyEvent; |
50 | use Coro 5.12; |
51 | use Coro 5.12; |
|
|
52 | use Coro::EV; |
51 | use Coro::AIO; |
53 | use Coro::AIO; |
52 | use Coro::Util; |
54 | use Coro::Util; |
53 | use Coro::Channel; |
55 | use Coro::Channel; |
|
|
56 | use Coro::AnyEvent; |
54 | use Coro::Storable; $Storable::canonical = 1; |
57 | use Coro::Storable; $Storable::canonical = 1; |
55 | |
58 | |
56 | use Deliantra; |
59 | use Deliantra; |
57 | |
60 | |
58 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
61 | $SIG{QUIT} = sub { Carp::cluck "QUIT" }; |
… | |
… | |
77 | my $TMPDIR = "/tmp/cfutil$$~"; |
80 | my $TMPDIR = "/tmp/cfutil$$~"; |
78 | my $TMPFILE = "aaaa0"; |
81 | my $TMPFILE = "aaaa0"; |
79 | my @COMMIT; |
82 | my @COMMIT; |
80 | |
83 | |
81 | our %COLOR = ( |
84 | our %COLOR = ( |
|
|
85 | # original cf colours |
82 | black => 0, |
86 | black => 0, |
83 | white => 1, |
87 | white => 1, |
84 | navy => 2, |
88 | navy => 2, # "dark blue" |
85 | red => 3, |
89 | red => 3, |
86 | orange => 4, |
90 | orange => 4, |
87 | blue => 5, |
91 | blue => 5, # "light blue" |
88 | darkorange => 6, |
92 | darkorange => 6, |
89 | green => 7, |
93 | green => 7, |
90 | lightgreen => 8, |
94 | lightgreen => 8, |
91 | grey => 9, |
95 | grey => 9, |
|
|
96 | brown => 10, # "yellow" |
|
|
97 | gold => 11, # "light yellow" |
|
|
98 | tan => 12, # yellowish gray |
|
|
99 | |
|
|
100 | # new for deliantra |
92 | brown => 10, |
101 | none => 13, |
|
|
102 | |
|
|
103 | # compatibility to existing archetypes |
|
|
104 | lightblue => 5, |
93 | gold => 11, |
105 | gray => 9, |
|
|
106 | yellow => 11, |
94 | tan => 12, |
107 | khaki => 12, |
95 | ); |
108 | ); |
96 | |
109 | |
97 | END { system "rm", "-rf", $TMPDIR } |
110 | END { system "rm", "-rf", $TMPDIR } |
98 | |
111 | |
99 | my $s_INT = EV::signal INT => sub { exit 1 }; |
112 | my $s_INT = EV::signal INT => sub { exit 1 }; |
… | |
… | |
103 | |
116 | |
104 | # here we could try to avoid collisions and reduce chksum size further |
117 | # here we could try to avoid collisions and reduce chksum size further |
105 | sub make_hash($\$\$;$) { |
118 | sub make_hash($\$\$;$) { |
106 | my ($id, $dataref, $hashref, $clen) = @_; |
119 | my ($id, $dataref, $hashref, $clen) = @_; |
107 | |
120 | |
108 | my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4; |
121 | my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 5; |
109 | |
122 | |
110 | if (exists $hash{$hash}) { |
123 | if (exists $hash{$hash}) { |
111 | # hash collision, but some files are simply identical |
124 | # hash collision, but some files are simply identical |
112 | if (${$hash{$hash}[1]} ne $$dataref) { |
125 | if (${$hash{$hash}[1]} ne $$dataref) { |
113 | warn "hash collision $hash{$hash}[0] vs. $id\n"; |
126 | warn "hash collision $hash{$hash}[0] vs. $id (increase the default \$clen in make_hash?)\n"; |
114 | exit 1; |
127 | exit 1; |
115 | } else { |
128 | } else { |
116 | print "$hash{$hash}[0] and $id are identical (which is fine).\n" if $VERBOSE >= 3; |
129 | print "$hash{$hash}[0] and $id are identical (which is fine).\n" if $VERBOSE >= 3; |
117 | } |
130 | } |
118 | } |
131 | } |
119 | $hash{$hash} = [$id, $dataref, $hashref]; |
132 | $hash{$hash} = [$id, $dataref, $hashref]; |
120 | |
133 | |
121 | $$hashref = $hash; |
134 | $$hashref = $hash; |
122 | } |
135 | } |
123 | |
136 | |
|
|
137 | sub optipng($) { |
|
|
138 | system $OPTIPNG, "-o5", "-i0", "-q", $_[0]; |
|
|
139 | die "$_[0] has zero size, aborting." unless -s $_[0]; |
|
|
140 | } |
|
|
141 | |
124 | mkdir $TMPDIR, 0700 |
142 | mkdir $TMPDIR, 0700 |
125 | or die "$TMPDIR: $!"; |
143 | or die "$TMPDIR: $!"; |
126 | |
144 | |
127 | sub fork_sub(&) { |
145 | sub fork_exec(&) { |
128 | my ($cb) = @_; |
146 | my ($cb) = @_; |
129 | |
147 | |
130 | if (my $pid = fork) { |
148 | if (my $pid = fork) { |
131 | my $current = $Coro::current; |
149 | my $current = $Coro::current; |
132 | my $w = AnyEvent->child (pid => $pid, cb => sub { $current->ready }); |
150 | my $w = AnyEvent->child (pid => $pid, cb => sub { $current->ready }); |
… | |
… | |
137 | warn $@; |
155 | warn $@; |
138 | POSIX::_exit 1; |
156 | POSIX::_exit 1; |
139 | } |
157 | } |
140 | } |
158 | } |
141 | |
159 | |
|
|
160 | sub imgsize($) { |
|
|
161 | open my $fh, "-|", $IDENTIFY, qw(-ping -format %w,%h --), $_[0] |
|
|
162 | or die "$IDENTIFY: $!"; |
|
|
163 | |
|
|
164 | Coro::AnyEvent::readable $fh; |
|
|
165 | |
|
|
166 | my ($w, $h) = split /,/, <$fh>; |
|
|
167 | |
|
|
168 | ($w+0, $h+0) |
|
|
169 | } |
|
|
170 | |
|
|
171 | # make $dst from $src, if not uptodate, by calling $how |
|
|
172 | sub make_file($$$) { |
|
|
173 | my ($src, $dst, $how) = @_; |
|
|
174 | |
|
|
175 | my $t = (aio_stat $dst) ? -1 : (stat _)[9]; |
|
|
176 | |
|
|
177 | for (ref $src ? @$src : $src) { |
|
|
178 | aio_stat $_ |
|
|
179 | and die "$_: $!"; |
|
|
180 | |
|
|
181 | if ((stat _)[9] > $t) { |
|
|
182 | # outdated, redo |
|
|
183 | $how->(); |
|
|
184 | last; |
|
|
185 | } |
|
|
186 | } |
|
|
187 | } |
|
|
188 | |
142 | sub inst_maps($) { |
189 | sub inst_maps($) { |
143 | my (undef, $path) = @_; |
190 | my (undef, $path) = @_; |
144 | |
191 | |
145 | print "\nInstalling '$path' to '$DATADIR/maps'\n\n"; |
192 | print "\nInstalling '$path' to '$DATADIR/maps'\n\n"; |
146 | |
193 | |
… | |
… | |
154 | "--exclude", "CVS", "--exclude", "/world-precomposed", |
201 | "--exclude", "CVS", "--exclude", "/world-precomposed", |
155 | "--delete", "--delete-excluded" |
202 | "--delete", "--delete-excluded" |
156 | and die "map installation failed.\n"; |
203 | and die "map installation failed.\n"; |
157 | |
204 | |
158 | print "maps installed successfully.\n"; |
205 | print "maps installed successfully.\n"; |
159 | } |
|
|
160 | |
|
|
161 | our %WALL_SUFFIX = ( |
|
|
162 | "_0" => "⬤", |
|
|
163 | "_1_3" => "╸", |
|
|
164 | "_1_4" => "╺", |
|
|
165 | "_2_1_2" => "━", |
|
|
166 | |
|
|
167 | "_1_2" => "╹", |
|
|
168 | "_2_2_4" => "┛", |
|
|
169 | "_2_2_1" => "┗", |
|
|
170 | "_3_1" => "┻", |
|
|
171 | |
|
|
172 | "_1_1" => "╻", |
|
|
173 | "_2_2_3" => "┓", |
|
|
174 | "_2_2_2" => "┏", |
|
|
175 | "_3_3" => "┳", |
|
|
176 | |
|
|
177 | "_2_1_1" => "┃", |
|
|
178 | "_3_4" => "┫", |
|
|
179 | "_3_2" => "┣", |
|
|
180 | "_4" => "╋", |
|
|
181 | ); |
|
|
182 | |
|
|
183 | sub autoglyph { |
|
|
184 | my ($stem, $face) = @_; |
|
|
185 | |
|
|
186 | if ($stem =~ /^wall\/|Nimwall/) { |
|
|
187 | if ($stem =~ /((?:_[0-4])+).x11/) { |
|
|
188 | return $WALL_SUFFIX{$1} if exists $WALL_SUFFIX{$1}; |
|
|
189 | } |
|
|
190 | |
|
|
191 | "+" |
|
|
192 | |
|
|
193 | } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { |
|
|
194 | "." |
|
|
195 | |
|
|
196 | } elsif ($stem =~ /^player\//) { |
|
|
197 | "\@" |
|
|
198 | |
|
|
199 | } else { |
|
|
200 | substr $stem, 0, 1 |
|
|
201 | } |
|
|
202 | } |
206 | } |
203 | |
207 | |
204 | { |
208 | { |
205 | our %ANIMINFO; |
209 | our %ANIMINFO; |
206 | our %FACEINFO; |
210 | our %FACEINFO; |
… | |
… | |
212 | our $PATH; |
216 | our $PATH; |
213 | |
217 | |
214 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
218 | our $QUANTIZE = "+dither -colorspace RGB -colors 256"; |
215 | |
219 | |
216 | our $c_arc = new Coro::Channel; |
220 | our $c_arc = new Coro::Channel; |
217 | our $c_trs = new Coro::Channel; |
221 | our $c_any = new Coro::Channel; |
218 | our $c_res = new Coro::Channel; |
|
|
219 | |
222 | |
220 | our @c_png; |
223 | our @c_png; |
221 | |
224 | |
222 | sub commit_png($$$$) { |
225 | sub commit_png($$$$) { |
223 | my ($stem, $name, $data, $T) = @_; |
226 | my ($stem, $name, $data, $T) = @_; |
… | |
… | |
282 | unless ($path =~ /~$/) { |
285 | unless ($path =~ /~$/) { |
283 | # possibly enlarge |
286 | # possibly enlarge |
284 | if (0 > aio_stat "$stem.64x64.png") { |
287 | if (0 > aio_stat "$stem.64x64.png") { |
285 | my $other = "$stem.64x64.png~"; |
288 | my $other = "$stem.64x64.png~"; |
286 | |
289 | |
287 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
290 | make_file $path, $other, sub { |
288 | fork_sub { |
291 | fork_exec { |
289 | my $CROP; |
292 | my $CROP; |
290 | my $SRC = "png:\Q$path\E"; |
293 | my $SRC = "png:\Q$path\E"; |
291 | |
294 | |
292 | my $is_floor = $arc->{is_floor}; |
295 | my $is_floor = $arc->{is_floor}; |
293 | my $is_wall = 0; |
296 | my $is_wall = 0; |
… | |
… | |
347 | |
350 | |
348 | system "convert -depth 8 $SRC rgba:-" |
351 | system "convert -depth 8 $SRC rgba:-" |
349 | . "| $exec_prefix/bin/cfhq2xa $w $h 0" |
352 | . "| $exec_prefix/bin/cfhq2xa $w $h 0" |
350 | . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $CROP $QUANTIZE -quality 00 png32:\Q$other\E~" |
353 | . "| convert -depth 8 -size ".($w * 2)."x".($h * 2)." rgba:- $CROP $QUANTIZE -quality 00 png32:\Q$other\E~" |
351 | and die "convert/cfhq2xa pipeline error: status $? ($!)"; |
354 | and die "convert/cfhq2xa pipeline error: status $? ($!)"; |
352 | system $OPTIPNG, "-i0", "-q", "$other~"; |
355 | optipng "$other~"; |
353 | die "$other~ has zero size, aborting." unless -s "$other~"; |
|
|
354 | rename "$other~", $other; |
356 | rename "$other~", $other; |
355 | }; |
357 | }; |
356 | } |
358 | }; |
357 | |
359 | |
358 | push @c_png, [$other, !$CACHE]; |
360 | push @c_png, [$other, !$CACHE]; |
359 | } |
361 | } |
360 | |
362 | |
361 | # possibly scale down |
363 | # possibly scale down |
362 | if (0 > aio_stat "$stem.32x32.png") { |
364 | if (0 > aio_stat "$stem.32x32.png") { |
363 | my $other = "$stem.32x32.png~"; |
365 | my $other = "$stem.32x32.png~"; |
364 | |
366 | |
365 | if (0 > aio_lstat $other or (-M _) > (-M $path)) { |
367 | make_file $path, $other, sub { |
366 | fork_sub { |
368 | fork_exec { |
367 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
369 | system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; |
368 | system $OPTIPNG, "-i0", "-q", "$other~"; |
370 | optipng "$other~"; |
369 | |
371 | |
370 | # reduce smoothfaces >10000 bytes |
372 | # reduce smoothfaces >10000 bytes |
371 | # obsolete, no longer required |
373 | # obsolete, no longer required |
372 | if (0 && $stem =~ /_S\./ && (-s "$other~") > 10000) { |
374 | if (0 && $stem =~ /_S\./ && (-s "$other~") > 10000) { |
373 | my $ncolor = 256; |
375 | my $ncolor = 256; |
374 | while () { |
376 | while () { |
375 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
377 | system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; |
376 | system $OPTIPNG, "-i0", "-q", "$other~~"; |
378 | optipng "$other~~"; |
377 | last if 10000 > -s "$other~~"; |
379 | last if 10000 > -s "$other~~"; |
378 | $ncolor = int $ncolor * 0.9; |
380 | $ncolor = int $ncolor * 0.9; |
379 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
381 | $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; |
380 | } |
382 | } |
381 | |
383 | |
… | |
… | |
386 | } |
388 | } |
387 | |
389 | |
388 | die "$other~ has zero size, aborting." unless -s "$other~"; |
390 | die "$other~ has zero size, aborting." unless -s "$other~"; |
389 | rename "$other~", $other; |
391 | rename "$other~", $other; |
390 | }; |
392 | }; |
391 | } |
393 | }; |
392 | |
394 | |
393 | #warn "scaled down $path to $other\n";#d# |
395 | #warn "scaled down $path to $other\n";#d# |
394 | push @c_png, [$other, !$CACHE]; |
396 | push @c_png, [$other, !$CACHE]; |
395 | } |
397 | } |
396 | } |
398 | } |
… | |
… | |
410 | } |
412 | } |
411 | |
413 | |
412 | my $mtime = (lstat $path)[9]; |
414 | my $mtime = (lstat $path)[9]; |
413 | my @todo = grep { $_->[3] <= $mtime } @tile; |
415 | my @todo = grep { $_->[3] <= $mtime } @tile; |
414 | if (@todo) { |
416 | if (@todo) { |
415 | fork_sub { |
417 | fork_exec { |
416 | open my $convert, "|-", $CONVERT, |
418 | open my $convert, "|-", $CONVERT, |
417 | "png:-", |
419 | "png:-", |
418 | (map { |
420 | (map { |
419 | ( |
421 | ( |
420 | "(", |
422 | "(", |
… | |
… | |
433 | print $convert $png; |
435 | print $convert $png; |
434 | close $convert; |
436 | close $convert; |
435 | |
437 | |
436 | # pass 2, optimise, and rename |
438 | # pass 2, optimise, and rename |
437 | for (@todo) { |
439 | for (@todo) { |
438 | system $OPTIPNG, "-o5", "-i0", "-q", "$_->[2]~"; |
440 | optipng "$_->[2]~"; |
439 | die "$_->[2]~ has zero size, aborting." unless -s "$_->[2]~"; |
|
|
440 | rename "$_->[2]~", $_->[2]; |
441 | rename "$_->[2]~", $_->[2]; |
441 | } |
442 | } |
442 | }; |
443 | }; |
443 | } |
444 | } |
444 | |
445 | |
… | |
… | |
459 | |
460 | |
460 | aio_unlink $path if $delete; |
461 | aio_unlink $path if $delete; |
461 | } |
462 | } |
462 | } |
463 | } |
463 | |
464 | |
|
|
465 | sub process_faceinfo { |
|
|
466 | my ($dir, $file) = @_; |
|
|
467 | my $path = "$dir/$file"; |
|
|
468 | |
|
|
469 | my $data; |
|
|
470 | if (0 > aio_load $path, $data) { |
|
|
471 | warn "$path: $!, skipping.\n"; |
|
|
472 | return; |
|
|
473 | } |
|
|
474 | |
|
|
475 | for (split /\n/, $data) { |
|
|
476 | chomp; |
|
|
477 | my ($face, $visibility, $fg, $bg, $glyph) = split /\s+/, $_, 5; |
|
|
478 | # bg not used except for text clients |
|
|
479 | |
|
|
480 | utf8::decode $glyph; |
|
|
481 | $glyph =~ s/^\?(?=.)//; # remove "autoglyph" flag |
|
|
482 | $glyph =~ s/^"(.+)"$/$1/; # allow for ""-style quoting |
|
|
483 | |
|
|
484 | $fg = "white" if $fg eq "none"; # lots of faces have no fg colour yet |
|
|
485 | |
|
|
486 | (my $fgi = $COLOR{$fg}) |
|
|
487 | // warn "WARNING: $path: $face specifies unknown foreground colour '$fg'.\n"; |
|
|
488 | (my $bgi = $COLOR{$bg}) |
|
|
489 | // warn "WARNING: $path: $face specifies unknown background colour '$bg'.\n"; |
|
|
490 | |
|
|
491 | my $fi = $FACEINFO{$face} ||= { }; |
|
|
492 | $fi->{visibility} = $visibility * 1; |
|
|
493 | $fi->{magicmap} = $fgi; # foreground colour becomes magicmap |
|
|
494 | |
|
|
495 | $glyph .= " " if 2 > length $glyph; # TODO kanji |
|
|
496 | die "glyph $face too long" if 2 < length $glyph; |
|
|
497 | |
|
|
498 | $fi->{glyph} = ""; |
|
|
499 | for (split //, $glyph) { |
|
|
500 | utf8::encode $_; |
|
|
501 | $fi->{glyph} .= (chr $fgi) . (chr $bgi) . $_; |
|
|
502 | } |
|
|
503 | } |
|
|
504 | } |
|
|
505 | |
464 | sub process_arc { |
506 | sub process_arc { |
465 | while (my $job = $c_arc->get) { |
507 | while (my ($dir, $file) = @{ $c_arc->get }) { |
466 | my ($dir, $file) = @$job; |
|
|
467 | |
|
|
468 | my $arc; |
508 | my $arc; |
469 | aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ |
509 | aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ |
470 | |
510 | |
471 | my $arc = read_arch "$dir/$file"; |
511 | my $arc = read_arch "$dir/$file"; |
472 | for my $o (values %$arc) { |
512 | for my $o (values %$arc) { |
… | |
… | |
474 | for (my $m = $o; $m; $m = $m->{more}) { |
514 | for (my $m = $o; $m; $m = $m->{more}) { |
475 | $ARC{$m->{_name}} = $m; |
515 | $ARC{$m->{_name}} = $m; |
476 | } |
516 | } |
477 | |
517 | |
478 | $o->{editor_folder} ||= "\x00$dir"; # horrible kludge |
518 | $o->{editor_folder} ||= "\x00$dir"; # horrible kludge |
479 | |
|
|
480 | my $visibility = delete $o->{visibility}; |
|
|
481 | my $magicmap = delete $o->{magicmap}; |
|
|
482 | my $glyph = delete $o->{glyph}; |
|
|
483 | |
519 | |
484 | # find upper left corner :/ |
520 | # find upper left corner :/ |
485 | # omg, this is sooo broken |
521 | # omg, this is sooo broken |
486 | my ($dx, $dy); |
522 | my ($dx, $dy); |
487 | for (my $o = $o; $o; $o = $o->{more}) { |
523 | for (my $o = $o; $o; $o = $o->{more}) { |
… | |
… | |
494 | my $y = $o->{y} - $dy; |
530 | my $y = $o->{y} - $dy; |
495 | |
531 | |
496 | my $ext = $x|$y ? "+$x+$y" : ""; |
532 | my $ext = $x|$y ? "+$x+$y" : ""; |
497 | |
533 | |
498 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
534 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
499 | |
|
|
500 | $visibility = delete $o->{visibility} if exists $o->{visibility}; |
|
|
501 | $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
|
|
502 | $glyph = delete $o->{glyph} if exists $o->{glyph}; |
|
|
503 | |
535 | |
504 | my $anim = delete $o->{anim}; |
536 | my $anim = delete $o->{anim}; |
505 | |
537 | |
506 | if ($anim) { |
538 | if ($anim) { |
507 | # possibly add $ext to the animation name to avoid |
539 | # possibly add $ext to the animation name to avoid |
… | |
… | |
535 | |
567 | |
536 | my $info = $FACEINFO{$face} ||= { }; |
568 | my $info = $FACEINFO{$face} ||= { }; |
537 | $info->{arc} = $o; |
569 | $info->{arc} = $o; |
538 | |
570 | |
539 | next if $face =~ /^blank.x11$|^empty.x11$/; |
571 | next if $face =~ /^blank.x11$|^empty.x11$/; |
540 | |
|
|
541 | $info->{visibility} = $visibility if defined $visibility; |
|
|
542 | $info->{magicmap} = $magicmap if defined $magicmap; |
|
|
543 | $info->{glyph} = $glyph if defined $glyph; |
|
|
544 | } |
572 | } |
545 | |
573 | |
546 | if (my $smooth = delete $o->{smoothface}) { |
574 | if (my $smooth = delete $o->{smoothface}) { |
547 | my %kv = split /\s+/, $smooth; |
575 | my %kv = split /\s+/, $smooth; |
548 | my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support |
576 | my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support |
… | |
… | |
557 | } |
585 | } |
558 | } |
586 | } |
559 | } |
587 | } |
560 | |
588 | |
561 | sub process_trs { |
589 | sub process_trs { |
562 | while (my $job = $c_trs->get) { |
|
|
563 | my ($dir, $file) = @$job; |
590 | my ($dir, $file) = @_; |
564 | my $path = "$dir/$file"; |
591 | my $path = "$dir/$file"; |
565 | |
592 | |
566 | my $trs; |
593 | my $trs; |
567 | if (0 > aio_load $path, $trs) { |
594 | if (0 > aio_load $path, $trs) { |
568 | warn "$path: $!, skipping.\n"; |
595 | warn "$path: $!, skipping.\n"; |
569 | next; |
596 | return; |
570 | } |
597 | } |
571 | |
598 | |
572 | $TRS .= $trs; |
599 | $TRS .= $trs; |
573 | } |
|
|
574 | } |
600 | } |
575 | |
601 | |
576 | my %FILECACHE; |
602 | my %FILECACHE; |
577 | |
603 | |
578 | sub load_cached($;$) { |
604 | sub load_cached($;$) { |
… | |
… | |
589 | } |
615 | } |
590 | |
616 | |
591 | $FILECACHE{$_[0]} |
617 | $FILECACHE{$_[0]} |
592 | } |
618 | } |
593 | |
619 | |
|
|
620 | # convert an image and a palette to some indexed 2d-matrix structure |
|
|
621 | sub process_plt { |
|
|
622 | my ($base, $plt) = @_; |
|
|
623 | |
|
|
624 | my ($w, $h) = imgsize "$base.png"; |
|
|
625 | |
|
|
626 | $w * $h |
|
|
627 | or die "$base.png: unable to identify correct size\n"; |
|
|
628 | |
|
|
629 | my @plt; |
|
|
630 | my %map; |
|
|
631 | |
|
|
632 | for (split /\n/, $plt) { |
|
|
633 | next unless /\S/; |
|
|
634 | next if /^\s*#/; |
|
|
635 | |
|
|
636 | /^([0-9a-fA-F]{3,6})\s*(.*?)\s*$/ |
|
|
637 | or die "unparseable palette entry for $base.plt: $_"; |
|
|
638 | |
|
|
639 | my ($rgb, $name) = ($1, $2); |
|
|
640 | |
|
|
641 | $rgb =~ s/^(.)(.)(.)$/$1$1$2$2$3$3/; |
|
|
642 | |
|
|
643 | $map{pack "H*", $rgb} = chr @plt; |
|
|
644 | push @plt, $name; |
|
|
645 | } |
|
|
646 | |
|
|
647 | make_file ["$base.plt", "$base.png"], "$base.tbl~", sub { |
|
|
648 | warn "building $base\n" if $VERBOSE >= 3; |
|
|
649 | |
|
|
650 | fork_exec { |
|
|
651 | open my $png, "-|", $CONVERT, qw(-depth 8 --), "$base.png", "rgb:" |
|
|
652 | or die "$base.png: $!"; |
|
|
653 | |
|
|
654 | local $/; |
|
|
655 | $png = <$png>; |
|
|
656 | |
|
|
657 | $w * $h * 3 == length $png |
|
|
658 | or die "$base.png: failed to read enough data from file\n"; |
|
|
659 | |
|
|
660 | $png =~ s/(...)/$map{$1}/ge; |
|
|
661 | |
|
|
662 | $w * $h == length $png |
|
|
663 | or die "$base.png: failed to map all data - wrong palette?\n"; |
|
|
664 | |
|
|
665 | { |
|
|
666 | open my $fh, ">:raw", "$base.tbl~~" |
|
|
667 | or die "$base.tbl~~: $!"; |
|
|
668 | syswrite $fh, $png; |
|
|
669 | } |
|
|
670 | |
|
|
671 | rename "$base.tbl~~", "$base.tbl~"; |
|
|
672 | }; |
|
|
673 | }; |
|
|
674 | |
|
|
675 | 0 <= aio_load "$base.tbl~", my $tbl |
|
|
676 | or die "$base.tbl~: $!"; |
|
|
677 | |
|
|
678 | IO::AIO::aio_unlink "$base.tbl~" unless $CACHE; |
|
|
679 | |
|
|
680 | Compress::LZF::compress nfreeze { |
|
|
681 | w => $w, |
|
|
682 | h => $h, |
|
|
683 | plt => \@plt, |
|
|
684 | tbl => $tbl, |
|
|
685 | } |
|
|
686 | } |
|
|
687 | |
594 | sub process_res { |
688 | sub process_res { |
595 | while (my $job = $c_res->get) { |
|
|
596 | my ($dir, $file, $type) = @$job; |
689 | my ($dir, $file, $type) = @_; |
597 | |
690 | |
598 | my $data; |
|
|
599 | aio_load "$dir/$file", $data; |
691 | 0 <= aio_load "$dir/$file", my $data |
|
|
692 | or die "$dir/$file: $!"; |
600 | |
693 | |
601 | my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; |
694 | my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; |
602 | |
695 | |
603 | utf8::decode $dir; |
696 | utf8::decode $dir; |
604 | utf8::decode $file; |
697 | utf8::decode $file; |
605 | |
698 | |
606 | # a meta file for resources is now mandatory |
699 | # a meta file for resources is now mandatory |
607 | unless (exists $meta->{$file}) { |
700 | unless (exists $meta->{$file}) { |
608 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
701 | warn "skipping $dir/$file\n" if $VERBOSE >= 3; |
609 | next; |
702 | return; |
610 | } |
703 | } |
611 | |
704 | |
612 | $meta = { |
705 | $meta = { |
613 | %{ $meta->{"" } || {} }, |
706 | %{ $meta->{"" } || {} }, |
614 | %{ $meta->{$file} || {} }, |
707 | %{ $meta->{$file} || {} }, |
615 | }; |
708 | }; |
616 | |
709 | |
617 | if ($meta->{license} =~ s/^#//) { |
710 | if ($meta->{license} =~ s/^#//) { |
618 | $meta->{license} = ({ |
711 | $meta->{license} = ({ |
619 | "pd" => "Public Domain", |
712 | "pd" => "Public Domain", |
620 | "gpl" => "GNU General Public License, version 3.0 or any later", |
713 | "gpl" => "GNU General Public License, version 3.0 or any later", |
621 | "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", |
714 | "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", |
622 | "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/", |
715 | "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/", |
623 | "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/", |
716 | "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/", |
624 | "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", |
717 | "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", |
625 | })->{$meta->{license}} |
718 | })->{$meta->{license}} |
626 | || warn "$dir/$file: license tag '$meta->{license}' not found."; |
719 | || warn "$dir/$file: license tag '$meta->{license}' not found."; |
627 | } |
720 | } |
628 | |
721 | |
629 | if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) { |
722 | if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) { |
630 | ($meta->{author} = $1) =~ s/_/ /g; |
723 | ($meta->{author} = $1) =~ s/_/ /g; |
631 | } |
724 | } |
632 | |
725 | |
633 | $file =~ s/\.res$//; |
726 | $file =~ s/\.res$//; |
634 | $file =~ s/\.(ogg|wav|jpg|png)$//; |
727 | $file =~ s/\.(ogg|wav|jpg|png)$//; |
635 | |
728 | |
636 | substr $dir, 0, 1 + length $PATH, ""; |
729 | if ($file =~ s/\.plt$//) { |
637 | |
730 | $data = process_plt "$dir/$file", $data; |
638 | if (my $filter = $meta->{cfutil_filter}) { |
731 | } elsif (my $filter = $meta->{cfutil_filter}) { |
639 | if ($filter eq "yaml2json") { |
732 | if ($filter eq "yaml2json") { |
640 | $data = JSON::XS::encode_json YAML::XS::Load $data; |
733 | $data = JSON::XS::encode_json YAML::XS::Load $data; |
641 | } elsif ($filter eq "json2json") { |
734 | } elsif ($filter eq "json2json") { |
642 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
735 | $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); |
643 | } elsif ($filter eq "perl2json") { |
736 | } elsif ($filter eq "perl2json") { |
644 | $data = eval $data; die if $@; |
737 | $data = eval $data; die if $@; |
645 | $data = JSON::XS::encode_json $data; |
738 | $data = JSON::XS::encode_json $data; |
646 | } else { |
739 | } else { |
647 | warn "$dir/$file: unknown filter $filter, skipping\n"; |
740 | warn "$dir/$file: unknown filter $filter, skipping\n"; |
648 | } |
741 | } |
649 | } |
742 | } |
650 | |
743 | |
|
|
744 | substr $dir, 0, 1 + length $PATH, ""; |
|
|
745 | |
651 | $RESOURCE{"$dir/$file"} = { |
746 | $RESOURCE{"$dir/$file"} = { |
652 | type => (exists $meta->{type} ? delete $meta->{type} : $type), |
747 | type => (exists $meta->{type} ? delete $meta->{type} : $type), |
653 | data => $data, |
748 | data => $data, |
654 | %$meta ? (meta => $meta) : (), |
749 | %$meta ? (meta => $meta) : (), |
655 | }; |
750 | }; |
|
|
751 | } |
|
|
752 | |
|
|
753 | sub process_any { |
|
|
754 | while (my ($func, @args) = @{ $c_any->get }) { |
|
|
755 | $func->(@args); |
656 | } |
756 | } |
657 | } |
757 | } |
658 | |
758 | |
659 | sub find_files; |
759 | sub find_files; |
660 | sub find_files { |
760 | sub find_files { |
661 | my ($path) = @_; |
761 | my ($path) = @_; |
662 | |
762 | |
|
|
763 | my $grp = IO::AIO::aio_group; |
|
|
764 | |
|
|
765 | my $scandir; $scandir = sub { |
|
|
766 | my ($path) = @_; |
|
|
767 | |
663 | IO::AIO::aioreq_pri 4; |
768 | IO::AIO::aioreq_pri 4; |
664 | IO::AIO::aio_scandir $path, 4, sub { |
769 | add $grp IO::AIO::aio_scandir $path, 4, sub { |
665 | my ($dirs, $nondirs) = @_; |
770 | my ($dirs, $nondirs) = @_; |
666 | |
771 | |
667 | find_files "$path/$_" |
772 | $scandir->("$path/$_") |
668 | for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs; |
773 | for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs; |
669 | |
774 | |
670 | my $dir = $path; |
775 | my $dir = $path; |
671 | substr $dir, 0, 1 + length $PATH, ""; |
776 | substr $dir, 0, 1 + length $PATH, ""; |
672 | |
777 | |
673 | for my $file (@$nondirs) { |
778 | for my $file (@$nondirs) { |
674 | if ($dir =~ /^music(?:\/|$)/) { |
779 | if ($dir =~ /^music(?:\/|$)/) { |
675 | $c_res->put ([$path, $file, 3]) # FT_MUSIC |
780 | $c_any->put ([\&process_res, $path, $file, 3]) # FT_MUSIC |
676 | if $file =~ /\.(ogg)$/; |
781 | if $file =~ /\.(ogg)$/; |
677 | |
782 | |
678 | } elsif ($dir =~ /^sound(?:\/|$)/) { |
783 | } elsif ($dir =~ /^sound(?:\/|$)/) { |
679 | $c_res->put ([$path, $file, 5]) # FT_SOUND |
784 | $c_any->put ([\&process_res, $path, $file, 5]) # FT_SOUND |
680 | if $file =~ /\.(wav|ogg)$/; |
785 | if $file =~ /\.(wav|ogg)$/; |
681 | |
786 | |
682 | } elsif ($dir =~ /^res(?:\/|$)/) { |
787 | } elsif ($dir =~ /^res(?:\/|$)/) { |
683 | if ($file =~ /\.(jpg|png)$/) { |
788 | if ($file =~ /\.(jpg|png)$/) { |
684 | $c_res->put ([$path, $file, 0]) # FT_FACE |
789 | $c_any->put ([\&process_res, $path, $file, 0]) # FT_FACE |
685 | } elsif ($file =~ /\.(res)$/) { |
790 | } elsif ($file =~ /\.(res)$/) { |
|
|
791 | $c_any->put ([\&process_res, $path, $file, 6]) # FT_RSRC |
|
|
792 | } else { |
|
|
793 | $c_any->put ([\&process_res, $path, $file, undef]); |
|
|
794 | } |
|
|
795 | |
|
|
796 | } elsif ($file =~ /\.png$/) { |
|
|
797 | push @c_png, ["$path/$file", 0]; |
|
|
798 | |
|
|
799 | } elsif ($file =~ /\.faceinfo$/) { |
|
|
800 | $c_any->put ([\&process_faceinfo, $path, $file]); |
|
|
801 | |
|
|
802 | } elsif ($file =~ /\.trs$/) { |
|
|
803 | $c_any->put ([\&process_trs, $path, $file]); |
|
|
804 | |
|
|
805 | } elsif ($file =~ /\.arc$/) { |
686 | $c_res->put ([$path, $file, 6]) # FT_RSRC |
806 | $c_arc->put ([$path, $file]); |
|
|
807 | |
687 | } else { |
808 | } else { |
688 | $c_res->put ([$path, $file, undef]); |
809 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
689 | } |
810 | } |
690 | |
|
|
691 | } elsif ($file =~ /\.png$/) { |
|
|
692 | push @c_png, ["$path/$file", 0]; |
|
|
693 | |
|
|
694 | } elsif ($file =~ /\.trs$/) { |
|
|
695 | $c_trs->put ([$path, $file]); |
|
|
696 | |
|
|
697 | } elsif ($file =~ /\.arc$/) { |
|
|
698 | $c_arc->put ([$path, $file]); |
|
|
699 | |
|
|
700 | } else { |
811 | } |
701 | warn "ignoring $path/$file\n" if $VERBOSE >= 3; |
|
|
702 | } |
|
|
703 | } |
812 | }; |
704 | }; |
813 | }; |
|
|
814 | |
|
|
815 | $scandir->($path); |
|
|
816 | aio_wait $grp; |
705 | } |
817 | } |
706 | |
818 | |
707 | sub generate_plurals { |
819 | sub generate_plurals { |
708 | # use Lingua::EN::Inflect (); |
820 | # use Lingua::EN::Inflect (); |
709 | # Lingua::EN::Inflect::classical; |
821 | # Lingua::EN::Inflect::classical; |
… | |
… | |
747 | if (!-d "$path/treasures") { |
859 | if (!-d "$path/treasures") { |
748 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
860 | warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; |
749 | exit 1 unless $FORCE; |
861 | exit 1 unless $FORCE; |
750 | } |
862 | } |
751 | |
863 | |
752 | print "scanning files...\n" if $VERBOSE; |
864 | print "starting file scan, arc, any processing...\n" if $VERBOSE; |
|
|
865 | |
|
|
866 | my @a_arc = map +(async \&process_arc), 1..2; |
|
|
867 | my @a_any = map +(async \&process_any), 1..4; |
753 | |
868 | |
754 | find_files $path; |
869 | find_files $path; |
755 | |
870 | |
756 | my @a_arc = map +(async \&process_arc), 1..2; |
|
|
757 | my @a_res = map +(async \&process_res), 1..2; |
|
|
758 | my @a_trs = map +(async \&process_trs), 1..2; |
|
|
759 | |
|
|
760 | IO::AIO::flush; |
|
|
761 | |
|
|
762 | $c_res->shutdown; |
|
|
763 | $c_arc->shutdown; |
871 | $c_arc->shutdown; |
764 | $c_trs->shutdown; |
872 | $c_any->shutdown; |
765 | |
|
|
766 | print "start file scan, arc, res processing...\n" if $VERBOSE; |
|
|
767 | |
873 | |
768 | $_->join for @a_arc; # need to parse all archetypes before png processing |
874 | $_->join for @a_arc; # need to parse all archetypes before png processing |
|
|
875 | print "ended arc processing...\n" if $VERBOSE; |
769 | |
876 | |
770 | print "end arc, start png processing...\n" if $VERBOSE; |
877 | print "starting png processing...\n" if $VERBOSE; |
771 | |
878 | |
772 | # eight png crunchers work fine for my 4x smp machine |
879 | # eight png crunchers work fine for my 4x smp machine |
773 | my @a_png = map +(async \&process_png), 1..8; |
880 | my @a_png = map +(async \&process_png), 1..8; |
774 | |
881 | |
775 | $_->join for (@a_trs, @a_res, @a_png); |
882 | $_->join for @a_any; |
|
|
883 | print "ended any processing...\n" if $VERBOSE; |
|
|
884 | |
|
|
885 | $_->join for @a_png; |
|
|
886 | print "ended png processing...\n" if $VERBOSE; |
776 | |
887 | |
777 | print "scanning done, processing results...\n" if $VERBOSE; |
888 | print "scanning done, processing results...\n" if $VERBOSE; |
778 | { |
889 | { |
779 | # remove path prefix from editor_folder |
890 | # remove path prefix from editor_folder |
780 | $_->{editor_folder} =~ /^\x00/ |
891 | $_->{editor_folder} =~ /^\x00/ |
… | |
… | |
798 | delete @s{qw(_name more name name_pl)}; |
909 | delete @s{qw(_name more name name_pl)}; |
799 | %$o = ( %s, %$o ); |
910 | %$o = ( %s, %$o ); |
800 | ++$progress; |
911 | ++$progress; |
801 | } |
912 | } |
802 | } else { |
913 | } else { |
803 | warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; |
914 | warn "WARNING: archetype '$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; |
804 | delete $ARC{$o->{_name}}; |
915 | delete $ARC{$o->{_name}}; |
805 | } |
916 | } |
806 | } |
917 | } |
807 | } |
918 | } |
808 | |
919 | |
… | |
… | |
815 | } |
926 | } |
816 | |
927 | |
817 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
928 | # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit |
818 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
929 | @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; |
819 | |
930 | |
|
|
931 | # fix up archetypes without names, where the archanme doesn't work at all |
|
|
932 | for (@ARC) { |
|
|
933 | if (!exists $_->{name} and $_->{_name} =~ /_/) { |
|
|
934 | for ($_->{name} = $_->{_name}) { |
|
|
935 | s/(?:_\d+)+$//; |
|
|
936 | s/_[nesw]+$//; |
|
|
937 | y/_/ /; |
|
|
938 | } |
|
|
939 | } |
|
|
940 | } |
|
|
941 | |
820 | print "generating plurals...\n" if $VERBOSE; |
942 | #print "generating plurals...\n" if $VERBOSE; |
821 | generate_plurals; |
943 | #generate_plurals; |
822 | |
944 | |
823 | printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE; |
945 | printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE; |
824 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
946 | open my $fh, ">:utf8", "$DATADIR/archetypes~" |
825 | or die "$DATADIR/archetypes~: $!"; |
947 | or die "$DATADIR/archetypes~: $!"; |
826 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
948 | print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; |
… | |
… | |
834 | } |
956 | } |
835 | |
957 | |
836 | { |
958 | { |
837 | print "processing facedata...\n" if $VERBOSE; |
959 | print "processing facedata...\n" if $VERBOSE; |
838 | while (my ($k, $v) = each %FACEINFO) { |
960 | while (my ($k, $v) = each %FACEINFO) { |
839 | length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
961 | length $v->{data32} or warn "WARNING: face '$k' has no png32. this will not work (shoddy gcfclient will crash of course).\n"; |
840 | length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; |
962 | length $v->{data64} or warn "WARNING: face '$k' has no png64. this will not work very well.\n"; |
841 | |
963 | |
842 | make_hash $k, $v->{data32}, $v->{hash32}; |
964 | make_hash $k, $v->{data32}, $v->{hash32}; |
843 | make_hash $k, $v->{data64}, $v->{hash64}; |
965 | make_hash $k, $v->{data64}, $v->{hash64}; |
844 | |
966 | |
845 | #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
967 | #length $v->{data32} <= 10000 or warn "WARNING: face '$k' has face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
846 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
968 | #length $v->{data64} <= 10000 or warn "WARNING: face '$k' has face64 larger than 10000 bytes.\n"; |
847 | |
969 | |
848 | if (my $magicmap = $v->{magicmap}) { |
970 | $v->{glyph} // warn "WARNING: face '$k' has glyph."; |
849 | $magicmap =~ y/A-Z_\-/a-z/d; |
971 | $v->{visibility} // warn "WARNING: face '$k' has no visibility info, missing faceinfo entry?\n"; |
850 | $v->{magicmap} = $COLOR{$magicmap}; |
972 | $v->{magicmap} // warn "WARNING: face '$k' has foreground colour."; |
851 | } |
|
|
852 | |
973 | |
853 | my $stem = delete $v->{stem}; |
974 | delete @$v{qw(arc stem)}; # not used by the server |
854 | $v->{glyph} //= autoglyph $stem, $v; |
|
|
855 | utf8::encode $v->{glyph}; |
|
|
856 | $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph}; |
|
|
857 | |
|
|
858 | delete $v->{arc}; |
|
|
859 | } |
975 | } |
860 | |
976 | |
861 | print "processing resources...\n" if $VERBOSE; |
977 | print "processing resources...\n" if $VERBOSE; |
862 | my $enc = JSON::XS->new->utf8->canonical->relaxed; |
978 | my $enc = JSON::XS->new->utf8->canonical->relaxed; |
863 | while (my ($k, $v) = each %RESOURCE) { |
979 | while (my ($k, $v) = each %RESOURCE) { |
… | |
… | |
902 | version => 2, |
1018 | version => 2, |
903 | faceinfo => \%FACEINFO, |
1019 | faceinfo => \%FACEINFO, |
904 | animinfo => \%ANIMINFO, |
1020 | animinfo => \%ANIMINFO, |
905 | resource => \%RESOURCE, |
1021 | resource => \%RESOURCE, |
906 | }; |
1022 | }; |
907 | |
|
|
908 | } |
1023 | } |
909 | |
1024 | |
910 | print "committing files...\n" if $VERBOSE; |
1025 | print "committing files...\n" if $VERBOSE; |
911 | |
1026 | |
912 | for (qw(archetypes facedata treasures), @COMMIT) { |
1027 | for (qw(archetypes facedata treasures), @COMMIT) { |