ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/utils/cfutil.in
(Generate patch)

Comparing deliantra/server/utils/cfutil.in (file contents):
Revision 1.114 by root, Sat May 14 17:13:38 2011 UTC vs.
Revision 1.120 by root, Wed Jan 4 03:22:28 2012 UTC

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,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 6# Copyright (©) 2007,2008,2009,2010,2011,2012 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.
107 khaki => 12, 107 khaki => 12,
108); 108);
109 109
110END { system "rm", "-rf", $TMPDIR } 110END { system "rm", "-rf", $TMPDIR }
111 111
112my $s_INT = EV::signal INT => sub { exit 1 }; 112my $s_INT = AE::signal INT => sub { exit 1 };
113my $s_TERM = EV::signal TERM => sub { exit 1 }; 113my $s_TERM = AE::signal TERM => sub { exit 1 };
114 114
115our %hash; 115our %hash;
116 116
117# 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
118sub make_hash($\$\$;$) { 118sub make_hash($\$\$;$) {
121 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 5; 121 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 5;
122 122
123 if (exists $hash{$hash}) { 123 if (exists $hash{$hash}) {
124 # hash collision, but some files are simply identical 124 # hash collision, but some files are simply identical
125 if (${$hash{$hash}[1]} ne $$dataref) { 125 if (${$hash{$hash}[1]} ne $$dataref) {
126 warn "hash collision $hash{$hash}[0] vs. $id\n"; 126 warn "ERROR: hash collision $hash{$hash}[0] vs. $id (increase the default \$clen in make_hash?)\n";
127 exit 1; 127 exit 1;
128 } else { 128 } else {
129 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;
130 } 130 }
131 } 131 }
133 133
134 $$hashref = $hash; 134 $$hashref = $hash;
135} 135}
136 136
137sub optipng($) { 137sub optipng($) {
138 system $OPTIPNG, "-i0", "-q", $_[0]; 138 system $OPTIPNG, "-o5", "-i0", "-q", $_[0];
139 die "$_[0] has zero size, aborting." unless -s $_[0]; 139 die "$_[0] has zero size, aborting." unless -s $_[0];
140} 140}
141 141
142mkdir $TMPDIR, 0700 142mkdir $TMPDIR, 0700
143 or die "$TMPDIR: $!"; 143 or die "$TMPDIR: $!";
190 my (undef, $path) = @_; 190 my (undef, $path) = @_;
191 191
192 print "\nInstalling '$path' to '$DATADIR/maps'\n\n"; 192 print "\nInstalling '$path' to '$DATADIR/maps'\n\n";
193 193
194 if (!-f "$path/regions") { 194 if (!-f "$path/regions") {
195 warn "'$path' does not look like a maps directory ('regions' file is missing).\n"; 195 warn "ERROR: '$path' does not look like a maps directory ('regions' file is missing).\n";
196 exit 1 unless $FORCE; 196 exit 1 unless $FORCE;
197 } 197 }
198 198
199 system $RSYNC, "-av", "--chmod=u=rwX,go=rX", 199 system $RSYNC, "-av", "--chmod=u=rwX,go=rX",
200 "$path/.", "$DATADIR/maps/.", 200 "$path/.", "$DATADIR/maps/.",
210 our %FACEINFO; 210 our %FACEINFO;
211 our %RESOURCE; 211 our %RESOURCE;
212 our @ARC; 212 our @ARC;
213 our %ARC; 213 our %ARC;
214 our $TRS; 214 our $TRS;
215 our %PNG;
215 our $NFILE; 216 our $NFILE;
216 our $PATH; 217 our $PATH;
217 218
218 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 219 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
219 220
236 my $png; 237 my $png;
237 aio_lstat $path; 238 aio_lstat $path;
238 my ($size, $mtime) = (stat _)[7,9]; 239 my ($size, $mtime) = (stat _)[7,9];
239 240
240 if (0 > aio_load $path, $png) { 241 if (0 > aio_load $path, $png) {
241 warn "$path: $!, skipping.\n"; 242 warn "ERROR: $path: $!, skipping.\n";
242 next; 243 next;
243 } 244 }
244 245
245 my $stem = $path; 246 my $stem = $path;
246 my $T; 247 my $T;
248 if ($stem =~ s/\.32x32\.png~?$//) { 249 if ($stem =~ s/\.32x32\.png~?$//) {
249 $T = 32; 250 $T = 32;
250 } elsif ($stem =~ s/\.64x64\.png~?$//) { 251 } elsif ($stem =~ s/\.64x64\.png~?$//) {
251 $T = 64; 252 $T = 64;
252 } else { 253 } else {
253 warn "$path: weird filename, skipping.\n"; 254 warn "ERROR: $path: weird filename, skipping.\n";
254 next; 255 next;
255 } 256 }
256 257
257 # quickly extract width and height of the (necessarily PNG) image 258 # quickly extract width and height of the (necessarily PNG) image
258 unless ($png =~ /^\x89PNG\x0d\x0a\x1a\x0a....IHDR(........)/s) { 259 unless ($png =~ /^\x89PNG\x0d\x0a\x1a\x0a....IHDR(........)/s) {
259 warn "$path: not a recognized png file, skipping.\n"; 260 warn "ERROR: $path: not a recognized png file, skipping.\n";
260 next; 261 next;
261 } 262 }
262 263
263 my ($w, $h) = unpack "NN", $1; 264 my ($w, $h) = unpack "NN", $1;
264 265
265 if ($w < $T || $h < $T) { 266 if ($w < $T || $h < $T) {
266 warn "$path: too small ($w $h), skipping.\n"; 267 warn "ERROR: $path: too small ($w $h), skipping.\n";
267 next; 268 next;
268 } 269 }
269 270
270 if ($w % $T || $h % $T) { 271 if ($w % $T || $h % $T) {
271 warn "$path: weird png size ($w $h), skipping.\n"; 272 warn "ERROR: $path: weird png size ($w $h), skipping.\n";
272 next; 273 next;
273 } 274 }
274 275
275 (my $base = $stem) =~ s/^.*\///; 276 (my $base = $stem) =~ s/^.*\///;
276 277
365 my $other = "$stem.32x32.png~"; 366 my $other = "$stem.32x32.png~";
366 367
367 make_file $path, $other, sub { 368 make_file $path, $other, sub {
368 fork_exec { 369 fork_exec {
369 system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~"; 370 system "convert png:\Q$path\E -geometry 50% -filter lanczos $QUANTIZE -quality 00 png32:\Q$other\E~";
370 system $OPTIPNG, "-i0", "-q", "$other~"; 371 optipng "$other~";
371 372
372 # reduce smoothfaces >10000 bytes 373 # reduce smoothfaces >10000 bytes
373 # obsolete, no longer required 374 # obsolete, no longer required
374 if (0 && $stem =~ /_S\./ && (-s "$other~") > 10000) { 375 if (0 && $stem =~ /_S\./ && (-s "$other~") > 10000) {
375 my $ncolor = 256; 376 my $ncolor = 256;
376 while () { 377 while () {
377 system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E"; 378 system "<\Q$other~\E $PNGNQ -s1 -n$ncolor >\Q$other~~\E";
378 system $OPTIPNG, "-i0", "-q", "$other~~"; 379 optipng "$other~~";
379 last if 10000 > -s "$other~~"; 380 last if 10000 > -s "$other~~";
380 $ncolor = int $ncolor * 0.9; 381 $ncolor = int $ncolor * 0.9;
381 $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes"; 382 $ncolor > 8 or die "cannot reduce filesize to < 10000 bytes";
382 } 383 }
383 384
396 push @c_png, [$other, !$CACHE]; 397 push @c_png, [$other, !$CACHE];
397 } 398 }
398 } 399 }
399 400
400 (my $face = $stem) =~ s/^.*\///; 401 (my $face = $stem) =~ s/^.*\///;
402
403 for (@{ $fi->{derive} }) {
404 my ($dir, $type) = @$_;
405
406 my $geom = "${T}x${T}";
407 my $dpath = "$dir/$type:$face.$geom.png~";
408
409 if ($type eq "buildmaterial") {
410 my $ov = "$PATH/mapbuilding/buildmaterial.png";
411 make_file [$path, $ov], $dpath, sub {
412 fork_exec {
413 system "$CONVERT -size 64x64 xc:transparent \\( \Q$path\E -geometry 52x52+6+6 \\) -composite \Q$ov\E -composite -geometry $geom png:\Q$dpath\E~";
414 optipng "$dpath~";
415 rename "$dpath~", $dpath;
416 };
417 };
418 } elsif ($type eq "buildmaterial-box") {
419 my $ov = "$PATH/mapbuilding/buildmaterial-box.png";
420 make_file [$path, $ov], $dpath, sub {
421 fork_exec {
422 system "$CONVERT \Q$ov\E "
423 . "\\( \Q$path\E -trim -geometry 34x31\\> "
424 . "-gravity center -background transparent -extent 37x34 +gravity "
425 . "-geometry +22+6 \\) -composite "
426 . "-geometry $geom png:\Q$dpath\E~";
427 optipng "$dpath~";
428 rename "$dpath~", $dpath;
429 };
430 };
431 } elsif ($type eq "buildmaterial-sbox") {
432 my $ov = "$PATH/mapbuilding/buildmaterial-sbox.png";
433 make_file [$path, $ov], $dpath, sub {
434 fork_exec {
435 system "$CONVERT \Q$ov\E "
436 . "\\( \Q$path\E -trim -geometry 16x24\\> "
437 . "-gravity center -background transparent -extent 18x26 +gravity "
438 . "-geometry +26+16 \\) -composite "
439 . "-geometry $geom png:\Q$dpath\E~";
440 optipng "$dpath~";
441 rename "$dpath~", $dpath;
442 };
443 };
444 } else {
445 warn "ERROR: facename $type:$face contains unsupported derivation type.\n";
446 }
447
448 aio_load $dpath, my $png;
449 IO::AIO::aio_unlink $dpath unless $CACHE;
450 commit_png "$dir/$type:$face", "$type:$face", $png, $T;
451 }
401 452
402 # split all bigfaces, but avoid smoothfaces (*_S) 453 # split all bigfaces, but avoid smoothfaces (*_S)
403 if (($w > $T || $h > $T) && $face !~ /_S\./) { 454 if (($w > $T || $h > $T) && $face !~ /_S\./) {
404 # split 455 # split
405 my @tile; 456 my @tile;
410 push @tile, [$x, $y, $file, (stat _)[9]]; 461 push @tile, [$x, $y, $file, (stat _)[9]];
411 } 462 }
412 } 463 }
413 464
414 my $mtime = (lstat $path)[9]; 465 my $mtime = (lstat $path)[9];
415 my @todo = grep { $_->[3] <= $mtime } @tile; 466 my @todo = grep { $_->[3] < $mtime } @tile;
416 if (@todo) { 467 if (@todo) {
417 fork_exec { 468 fork_exec {
418 open my $convert, "|-", $CONVERT, 469 open my $convert, "|-", $CONVERT,
419 "png:-", 470 "png:-",
420 (map { 471 (map {
435 print $convert $png; 486 print $convert $png;
436 close $convert; 487 close $convert;
437 488
438 # pass 2, optimise, and rename 489 # pass 2, optimise, and rename
439 for (@todo) { 490 for (@todo) {
440 system $OPTIPNG, "-o5", "-i0", "-q", "$_->[2]~"; 491 optipng "$_->[2]~";
441 die "$_->[2]~ has zero size, aborting." unless -s "$_->[2]~";
442 rename "$_->[2]~", $_->[2]; 492 rename "$_->[2]~", $_->[2];
443 } 493 }
444 }; 494 };
445 } 495 }
446 496
457 } else { 507 } else {
458 # use as-is (either small, use smooth) 508 # use as-is (either small, use smooth)
459 commit_png $stem, $face, $png, $T; 509 commit_png $stem, $face, $png, $T;
460 } 510 }
461 511
462 aio_unlink $path if $delete; 512 IO::AIO::aio_unlink $path if $delete;
463 } 513 }
464 } 514 }
465 515
466 sub process_faceinfo { 516 sub process_faceinfo {
467 my ($dir, $file) = @_; 517 my ($dir, $file) = @_;
468 my $path = "$dir/$file"; 518 my $path = "$dir/$file";
469 519
470 my $data; 520 my $data;
471 if (0 > aio_load $path, $data) { 521 if (0 > aio_load $path, $data) {
472 warn "$path: $!, skipping.\n"; 522 warn "ERROR: $path: $!, skipping.\n";
473 return; 523 return;
474 } 524 }
475 525
476 for (split /\n/, $data) { 526 for (split /\n/, $data) {
477 chomp; 527 chomp;
483 $glyph =~ s/^"(.+)"$/$1/; # allow for ""-style quoting 533 $glyph =~ s/^"(.+)"$/$1/; # allow for ""-style quoting
484 534
485 $fg = "white" if $fg eq "none"; # lots of faces have no fg colour yet 535 $fg = "white" if $fg eq "none"; # lots of faces have no fg colour yet
486 536
487 (my $fgi = $COLOR{$fg}) 537 (my $fgi = $COLOR{$fg})
488 // warn "WARNING: $path: $face specifies unknown foreground colour '$fg'.\n"; 538 // warn "ERROR: $path: $face specifies unknown foreground colour '$fg'.\n";
489 (my $bgi = $COLOR{$bg}) 539 (my $bgi = $COLOR{$bg})
490 // warn "WARNING: $path: $face specifies unknown background colour '$bg'.\n"; 540 // warn "ERROR: $path: $face specifies unknown background colour '$bg'.\n";
491 541
492 my $fi = $FACEINFO{$face} ||= { }; 542 my $fi = $FACEINFO{$face} ||= { };
493 $fi->{visibility} = $visibility * 1; 543 $fi->{visibility} = $visibility * 1;
494 $fi->{magicmap} = $fgi; # foreground colour becomes magicmap 544 $fi->{magicmap} = $fgi; # foreground colour becomes magicmap
495 545
564 next if /^facings\s/; 614 next if /^facings\s/;
565 615
566 my $face = $_; 616 my $face = $_;
567 $face =~ s/\+\d+\+\d+$//; # remove tile offset coordinates 617 $face =~ s/\+\d+\+\d+$//; # remove tile offset coordinates
568 618
569 my $info = $FACEINFO{$face} ||= { }; 619 # handle derived faces
620 if ($face =~ /^([^:]+):(.*)/) {
621 my ($type, $base) = ($1, $2);
622 push @{ $FACEINFO{$base}{derive} }, [$dir, $type];
623 }
624
570 $info->{arc} = $o; 625 $FACEINFO{$face}{arc} = $o;
571 626
572 next if $face =~ /^blank.x11$|^empty.x11$/; 627 next if $face =~ /^blank.x11$|^empty.x11$/;
573 } 628 }
574 629
575 if (my $smooth = delete $o->{smoothface}) { 630 if (my $smooth = delete $o->{smoothface}) {
591 my ($dir, $file) = @_; 646 my ($dir, $file) = @_;
592 my $path = "$dir/$file"; 647 my $path = "$dir/$file";
593 648
594 my $trs; 649 my $trs;
595 if (0 > aio_load $path, $trs) { 650 if (0 > aio_load $path, $trs) {
596 warn "$path: $!, skipping.\n"; 651 warn "ERROR: $path: $!, skipping.\n";
597 return; 652 return;
598 } 653 }
599 654
600 $TRS .= $trs; 655 $TRS .= $trs;
601 } 656 }
606 unless (exists $FILECACHE{$_[0]}) { 661 unless (exists $FILECACHE{$_[0]}) {
607 my $data; 662 my $data;
608 if (0 < aio_load $_[0], $data) { 663 if (0 < aio_load $_[0], $data) {
609 if ($_[1]) { 664 if ($_[1]) {
610 $data = eval { $_[1]->($data) }; 665 $data = eval { $_[1]->($data) };
611 warn "$_[0]: $@" if $@; 666 warn "ERROR: $_[0]: $@" if $@;
612 } 667 }
613 } 668 }
614 669
615 $FILECACHE{$_[0]} = $data; 670 $FILECACHE{$_[0]} = $data;
616 } 671 }
706 $meta = { 761 $meta = {
707 %{ $meta->{"" } || {} }, 762 %{ $meta->{"" } || {} },
708 %{ $meta->{$file} || {} }, 763 %{ $meta->{$file} || {} },
709 }; 764 };
710 765
711 if ($meta->{license} =~ s/^#//) { 766 if (exists $meta->{license} && $meta->{license} =~ s/^#//) { # exists == avoid autovivification
712 $meta->{license} = ({ 767 $meta->{license} = ({
713 "pd" => "Public Domain", 768 "pd" => "Public Domain",
714 "gpl" => "GNU General Public License, version 3.0 or any later", 769 "gpl" => "GNU General Public License, version 3.0 or any later",
715 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", 770 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/",
716 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/", 771 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/",
717 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/", 772 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/",
718 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", 773 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/",
719 })->{$meta->{license}} 774 })->{$meta->{license}}
720 || warn "$dir/$file: license tag '$meta->{license}' not found."; 775 || warn "ERROR: $dir/$file: license tag '$meta->{license}' not found.";
721 } 776 }
722 777
723 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) { 778 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) {
724 ($meta->{author} = $1) =~ s/_/ /g; 779 ($meta->{author} = $1) =~ s/_/ /g;
725 } 780 }
727 $file =~ s/\.res$//; 782 $file =~ s/\.res$//;
728 $file =~ s/\.(ogg|wav|jpg|png)$//; 783 $file =~ s/\.(ogg|wav|jpg|png)$//;
729 784
730 if ($file =~ s/\.plt$//) { 785 if ($file =~ s/\.plt$//) {
731 $data = process_plt "$dir/$file", $data; 786 $data = process_plt "$dir/$file", $data;
732 } elsif (my $filter = $meta->{cfutil_filter}) { 787 } elsif (my $filter = delete $meta->{cfutil_filter}) {
733 if ($filter eq "yaml2json") { 788 if ($filter eq "yaml2json") {
734 $data = JSON::XS::encode_json YAML::XS::Load $data; 789 $data = JSON::XS::encode_json YAML::XS::Load $data;
735 } elsif ($filter eq "json2json") { 790 } elsif ($filter eq "json2json") {
736 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); 791 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data);
737 } elsif ($filter eq "perl2json") { 792 } elsif ($filter eq "perl2json") {
738 $data = eval $data; die if $@; 793 $data = eval $data; die if $@;
739 $data = JSON::XS::encode_json $data; 794 $data = JSON::XS::encode_json $data;
740 } else { 795 } else {
741 warn "$dir/$file: unknown filter $filter, skipping\n"; 796 warn "ERROR: $dir/$file: unknown filter $filter, skipping\n";
742 } 797 }
743 } 798 }
744 799
745 substr $dir, 0, 1 + length $PATH, ""; 800 substr $dir, 0, 1 + length $PATH, "";
746 801
789 if ($file =~ /\.(jpg|png)$/) { 844 if ($file =~ /\.(jpg|png)$/) {
790 $c_any->put ([\&process_res, $path, $file, 0]) # FT_FACE 845 $c_any->put ([\&process_res, $path, $file, 0]) # FT_FACE
791 } elsif ($file =~ /\.(res)$/) { 846 } elsif ($file =~ /\.(res)$/) {
792 $c_any->put ([\&process_res, $path, $file, 6]) # FT_RSRC 847 $c_any->put ([\&process_res, $path, $file, 6]) # FT_RSRC
793 } else { 848 } else {
794 $c_any->put ([\&process_res, $path, $file, undef]); 849 $c_any->put ([\&process_res, $path, $file, 6]); # was type undef, but now meta files are mandatory, so any mentioned file surely has a purpose
795 } 850 }
796 851
797 } elsif ($file =~ /\.png$/) { 852 } elsif ($file =~ /\.png$/) {
798 push @c_png, ["$path/$file", 0]; 853 $PNG{$file} = $path;
799 854
800 } elsif ($file =~ /\.faceinfo$/) { 855 } elsif ($file =~ /\.faceinfo$/) {
801 $c_any->put ([\&process_faceinfo, $path, $file]); 856 $c_any->put ([\&process_faceinfo, $path, $file]);
802 857
803 } elsif ($file =~ /\.trs$/) { 858 } elsif ($file =~ /\.trs$/) {
856 "Unless you run verbosely, all following warning\n", 911 "Unless you run verbosely, all following warning\n",
857 "or error messages indicate serious problems.\n", 912 "or error messages indicate serious problems.\n",
858 "\n"; 913 "\n";
859 914
860 if (!-d "$path/treasures") { 915 if (!-d "$path/treasures") {
861 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; 916 warn "FATAL: '$path' does not look like an arch directory ('treasures' directory is missing).\n";
862 exit 1 unless $FORCE; 917 exit 1 unless $FORCE;
863 } 918 }
864 919
865 print "starting file scan, arc, any processing...\n" if $VERBOSE; 920 print "starting file scan, arc, any processing...\n" if $VERBOSE;
866 921
871 926
872 $c_arc->shutdown; 927 $c_arc->shutdown;
873 $c_any->shutdown; 928 $c_any->shutdown;
874 929
875 $_->join for @a_arc; # need to parse all archetypes before png processing 930 $_->join for @a_arc; # need to parse all archetypes before png processing
876 print "ended arc processing...\n" if $VERBOSE; 931 print "finished arc processing...\n" if $VERBOSE;
932
933 # fill png queue
934 for (keys %FACEINFO) {
935 # we only expect source pngs to exist for non-derived
936 # faces, i.e. no split tiles (+x+x) and no face derivates
937 # (xxx:)
938 /^[^:]+\....$/
939 or next;
940
941 my $seen;
942
943 if (exists $PNG{"$_.32x32.png"}) {
944 push @c_png, ["$PNG{\"$_.32x32.png\"}/$_.32x32.png"];
945 $seen = 1;
946 }
947 if (exists $PNG{"$_.64x64.png"}) {
948 push @c_png, ["$PNG{\"$_.64x64.png\"}/$_.64x64.png"];
949 $seen = 1;
950 }
951
952 warn "ERROR: $_: face not found, expect problems.\n"
953 unless $seen;
954 }
877 955
878 print "starting png processing...\n" if $VERBOSE; 956 print "starting png processing...\n" if $VERBOSE;
879 957
880 # eight png crunchers work fine for my 4x smp machine 958 # eight png crunchers work fine for my 4x smp machine
881 my @a_png = map +(async \&process_png), 1..8; 959 my @a_png = map +(async \&process_png), 1..8;
882 960
883 $_->join for @a_any; 961 $_->join for @a_any;
884 print "ended any processing...\n" if $VERBOSE; 962 print "finished any processing...\n" if $VERBOSE;
885 963
886 $_->join for @a_png; 964 $_->join for @a_png;
887 print "ended png processing...\n" if $VERBOSE; 965 print "finished png processing...\n" if $VERBOSE;
888 966
889 print "scanning done, processing results...\n" if $VERBOSE; 967 print "scanning done, processing results...\n" if $VERBOSE;
890 { 968 {
891 # remove path prefix from editor_folder 969 # remove path prefix from editor_folder
892 $_->{editor_folder} =~ /^\x00/ 970 $_->{editor_folder} =~ /^\x00/
910 delete @s{qw(_name more name name_pl)}; 988 delete @s{qw(_name more name name_pl)};
911 %$o = ( %s, %$o ); 989 %$o = ( %s, %$o );
912 ++$progress; 990 ++$progress;
913 } 991 }
914 } else { 992 } else {
915 warn "WARNING: archetype '$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; 993 warn "ERROR: archetype '$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n";
916 delete $ARC{$o->{_name}}; 994 delete $ARC{$o->{_name}};
917 } 995 }
918 } 996 }
919 } 997 }
920 998
957 } 1035 }
958 1036
959 { 1037 {
960 print "processing facedata...\n" if $VERBOSE; 1038 print "processing facedata...\n" if $VERBOSE;
961 while (my ($k, $v) = each %FACEINFO) { 1039 while (my ($k, $v) = each %FACEINFO) {
962 length $v->{data32} or warn "WARNING: face '$k' has no png32. this will not work (shoddy gcfclient will crash of course).\n"; 1040 length $v->{data32} or warn "ERROR: face '$k' has no png32 - this will not work.\n";
963 length $v->{data64} or warn "WARNING: face '$k' has no png64. this will not work very well.\n"; 1041 length $v->{data64} or warn "ERROR: face '$k' has no png64 - this will not work.\n";
964 1042
965 make_hash $k, $v->{data32}, $v->{hash32}; 1043 make_hash $k, $v->{data32}, $v->{hash32};
966 make_hash $k, $v->{data64}, $v->{hash64}; 1044 make_hash $k, $v->{data64}, $v->{hash64};
967 1045
968 #length $v->{data32} <= 10000 or warn "WARNING: face '$k' has face32 larger than 10000 bytes, will not work with crossfire client.\n"; 1046 #length $v->{data32} <= 10000 or warn "WARNING: face '$k' has face32 larger than 10000 bytes, will not work with crossfire client.\n";
969 #length $v->{data64} <= 10000 or warn "WARNING: face '$k' has face64 larger than 10000 bytes.\n"; 1047 #length $v->{data64} <= 10000 or warn "WARNING: face '$k' has face64 larger than 10000 bytes.\n";
970 1048
971 $v->{glyph} // warn "WARNING: face '$k' has glyph."; 1049 $v->{glyph} // warn "ERROR: face '$k' has no glyph - missing faceinfo entry?\n";
972 $v->{visibility} // warn "WARNING: face '$k' has no visibility info, missing faceinfo entry?\n"; 1050 $v->{visibility} // warn "ERROR: face '$k' has no visibility info - missing faceinfo entry?\n";
973 $v->{magicmap} // warn "WARNING: face '$k' has foreground colour."; 1051 $v->{magicmap} // warn "ERROR: face '$k' has no foreground colour - missing faceinfo entry?\n";
974 1052
975 delete @$v{qw(arc stem)}; # not used by the server 1053 delete @$v{qw(arc stem derive)}; # not used by the server
976 } 1054 }
977 1055
978 print "processing resources...\n" if $VERBOSE; 1056 print "processing resources...\n" if $VERBOSE;
979 my $enc = JSON::XS->new->utf8->canonical->relaxed; 1057 my $enc = JSON::XS->new->utf8->canonical->relaxed;
980 while (my ($k, $v) = each %RESOURCE) { 1058 while (my ($k, $v) = each %RESOURCE) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines