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.102 by root, Wed Oct 6 18:23:52 2010 UTC vs.
Revision 1.103 by root, Sat Oct 16 09:20:58 2010 UTC

55 55
56use Deliantra; 56use Deliantra;
57 57
58$SIG{QUIT} = sub { Carp::cluck "QUIT" }; 58$SIG{QUIT} = sub { Carp::cluck "QUIT" };
59 59
60sub WRITE_FACEINFO() { 0 }
61
60sub usage { 62sub usage {
61 warn <<EOF; 63 warn <<EOF;
62Usage: cfutil [-v] [-q] [--force] [--cache] 64Usage: cfutil [-v] [-q] [--force] [--cache]
63 [--install-arch path] 65 [--install-arch path]
64 [--install-maps maps] 66 [--install-maps maps]
77my $TMPDIR = "/tmp/cfutil$$~"; 79my $TMPDIR = "/tmp/cfutil$$~";
78my $TMPFILE = "aaaa0"; 80my $TMPFILE = "aaaa0";
79my @COMMIT; 81my @COMMIT;
80 82
81our %COLOR = ( 83our %COLOR = (
84 # original cf colours
82 black => 0, 85 black => 0,
83 white => 1, 86 white => 1,
84 navy => 2, 87 navy => 2, # "dark blue"
85 red => 3, 88 red => 3,
86 orange => 4, 89 orange => 4,
87 blue => 5, 90 blue => 5, # "light blue"
88 darkorange => 6, 91 darkorange => 6,
89 green => 7, 92 green => 7,
90 lightgreen => 8, 93 lightgreen => 8,
91 grey => 9, 94 grey => 9,
95 brown => 10, # "yellow"
96 gold => 11, # "light yellow"
97 tan => 12, # yellowish gray
98
99 # new for deliantra
92 brown => 10, 100 none => 13,
101
102 # compatibility to existing archetypes
103 lightblue => 5,
93 gold => 11, 104 gray => 9,
105 yellow => 11,
94 tan => 12, 106 khaki => 12,
95); 107);
96 108
97END { system "rm", "-rf", $TMPDIR } 109END { system "rm", "-rf", $TMPDIR }
98 110
99my $s_INT = EV::signal INT => sub { exit 1 }; 111my $s_INT = EV::signal INT => sub { exit 1 };
156 and die "map installation failed.\n"; 168 and die "map installation failed.\n";
157 169
158 print "maps installed successfully.\n"; 170 print "maps installed successfully.\n";
159} 171}
160 172
173{
174 no utf8; # == values are utf-8 encoded
175
161our @WALL_SUFFIX = qw(⬤ ╹ ╺ ┗ ╻ ┃ ┏ ┣ ╸ ┛ ━ ┻ ┓ ┫ ┳ ╋); 176 our @WALL_SUFFIX = qw(⬤ ╹ ╺ ┗ ╻ ┃ ┏ ┣ ╸ ┛ ━ ┻ ┓ ┫ ┳ ╋);
162 177
163# used to create crude text glyphs for text-based clients 178 # used to create crude text glyphs for text-based clients
164sub autoglyph { 179 sub autoglyph {
165 my ($stem, $face) = @_; 180 my ($stem, $face) = @_;
166 181
167 if ($stem =~ /^wall\/|Nimwall/) { 182 if ($stem =~ /^wall\/|Nimwall/) {
168 return $WALL_SUFFIX[hex $1] 183 return $WALL_SUFFIX[hex $1]
169 if $stem =~ /(_[0-9A-F]).x11/; 184 if $stem =~ /(_[0-9A-F]).x11/;
170 185
171 "█" 186 "█"
172 187
173 } elsif ($stem =~ /^traps\//) { 188 } elsif ($stem =~ /^traps\//) {
174 "☠" 189 "☠"
175 190
176 } elsif ($stem =~ /^armour\/shield/) { 191 } elsif ($stem =~ /^armour\/shield/) {
177 "Ø" 192 "Ø"
178 193
179 } elsif ($stem =~ /^armour\//) { 194 } elsif ($stem =~ /^armour\//) {
180 "A" 195 "A"
181 196
182 } elsif ($stem =~ /^weapon\//) { 197 } elsif ($stem =~ /^weapon\//) {
183 "†" 198 "†"
184 199
185 } elsif ($stem =~ /^readable\//) { 200 } elsif ($stem =~ /^readable\//) {
186 "✉" 201 "✉"
187 202
188 } elsif ($stem =~ /^river\//) { 203 } elsif ($stem =~ /^river\//) {
189 "~" 204 "~"
190 205
191 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { 206 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) {
192 "·" 207 "·"
193 208
194 } elsif ($stem =~ /^spells\//) { 209 } elsif ($stem =~ /^spells\//) {
195 "!" 210 "!"
196 211
197 } elsif ($stem =~ /^exit\//) { 212 } elsif ($stem =~ /^exit\//) {
198 "⎆" 213 "⎆"
199 214
200 } elsif ($stem =~ /^construct\//) { 215 } elsif ($stem =~ /^construct\//) {
201 "⌂" 216 "⌂"
202 217
203 } elsif ($stem =~ /^player\//) { 218 } elsif ($stem =~ /^player\//) {
204 "\@" 219 "\@"
205 220
206 } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) { 221 } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) {
207 $1 222 $1
208 223
209 } else { 224 } else {
210 substr $stem, 0, 1 225 substr $stem, 0, 1
226 }
211 } 227 }
212} 228}
213 229
214{ 230{
215 our %ANIMINFO; 231 our %ANIMINFO;
222 our $PATH; 238 our $PATH;
223 239
224 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 240 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
225 241
226 our $c_arc = new Coro::Channel; 242 our $c_arc = new Coro::Channel;
227 our $c_trs = new Coro::Channel; 243 our $c_any = new Coro::Channel;
228 our $c_res = new Coro::Channel;
229 244
230 our @c_png; 245 our @c_png;
231 246
232 sub commit_png($$$$) { 247 sub commit_png($$$$) {
233 my ($stem, $name, $data, $T) = @_; 248 my ($stem, $name, $data, $T) = @_;
469 484
470 aio_unlink $path if $delete; 485 aio_unlink $path if $delete;
471 } 486 }
472 } 487 }
473 488
489 sub process_faceinfo {
490 my ($dir, $file) = @_;
491 my $path = "$dir/$file";
492
493 my $data;
494 if (0 > aio_load $path, $data) {
495 warn "$path: $!, skipping.\n";
496 return;
497 }
498
499 for (split /\n/, $data) {
500 my ($face, $visibility, $fg, $bg, $glyph) = split /\s+/;
501
502 $glyph =~ s/^?(?=.)//; # remove "autoglyph" flag
503
504 (my $fgi = $COLOR{$fg})
505 // warn "WARNING: $path: $face specifies unknown foreground colour '$fg'.\n";
506 (my $bgi = $COLOR{$bg})
507 // warn "WARNING: $path: $face specifies unknown background colour '$bg'.\n";
508
509 my $fi = $FACEINFO{$face} ||= { };
510 $fi->{visibility} = $visibility * 1;
511 $fi->{magicmap} = $fgi; # foreground colour becomes magicmap
512 $fi->{glyph} = (chr $fgi) . (chr $bgi) . $glyph;
513 # bg not used except for text clients
514 }
515 }
516
474 sub process_arc { 517 sub process_arc {
475 while (my $job = $c_arc->get) { 518 while (my ($dir, $file) = @{ $c_arc->get }) {
476 my ($dir, $file) = @$job;
477
478 my $arc; 519 my $arc;
479 aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ 520 aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/
480 521
481 my $arc = read_arch "$dir/$file"; 522 my $arc = read_arch "$dir/$file";
482 for my $o (values %$arc) { 523 for my $o (values %$arc) {
484 for (my $m = $o; $m; $m = $m->{more}) { 525 for (my $m = $o; $m; $m = $m->{more}) {
485 $ARC{$m->{_name}} = $m; 526 $ARC{$m->{_name}} = $m;
486 } 527 }
487 528
488 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge 529 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge
489
490 my $visibility = delete $o->{visibility};
491 my $magicmap = delete $o->{magicmap};
492 my $glyph = delete $o->{glyph};
493 530
494 # find upper left corner :/ 531 # find upper left corner :/
495 # omg, this is sooo broken 532 # omg, this is sooo broken
496 my ($dx, $dy); 533 my ($dx, $dy);
497 for (my $o = $o; $o; $o = $o->{more}) { 534 for (my $o = $o; $o; $o = $o->{more}) {
504 my $y = $o->{y} - $dy; 541 my $y = $o->{y} - $dy;
505 542
506 my $ext = $x|$y ? "+$x+$y" : ""; 543 my $ext = $x|$y ? "+$x+$y" : "";
507 544
508 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 545 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
509
510 $visibility = delete $o->{visibility} if exists $o->{visibility};
511 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
512 $glyph = delete $o->{glyph} if exists $o->{glyph};
513 546
514 my $anim = delete $o->{anim}; 547 my $anim = delete $o->{anim};
515 548
516 if ($anim) { 549 if ($anim) {
517 # possibly add $ext to the animation name to avoid 550 # possibly add $ext to the animation name to avoid
545 578
546 my $info = $FACEINFO{$face} ||= { }; 579 my $info = $FACEINFO{$face} ||= { };
547 $info->{arc} = $o; 580 $info->{arc} = $o;
548 581
549 next if $face =~ /^blank.x11$|^empty.x11$/; 582 next if $face =~ /^blank.x11$|^empty.x11$/;
550
551 $info->{visibility} = $visibility if defined $visibility;
552 $info->{magicmap} = $magicmap if defined $magicmap;
553 $info->{glyph} = $glyph if defined $glyph;
554 } 583 }
555 584
556 if (my $smooth = delete $o->{smoothface}) { 585 if (my $smooth = delete $o->{smoothface}) {
557 my %kv = split /\s+/, $smooth; 586 my %kv = split /\s+/, $smooth;
558 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support 587 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
567 } 596 }
568 } 597 }
569 } 598 }
570 599
571 sub process_trs { 600 sub process_trs {
572 while (my $job = $c_trs->get) {
573 my ($dir, $file) = @$job; 601 my ($dir, $file) = @_;
574 my $path = "$dir/$file"; 602 my $path = "$dir/$file";
575 603
576 my $trs; 604 my $trs;
577 if (0 > aio_load $path, $trs) { 605 if (0 > aio_load $path, $trs) {
578 warn "$path: $!, skipping.\n"; 606 warn "$path: $!, skipping.\n";
579 next; 607 return;
580 } 608 }
581 609
582 $TRS .= $trs; 610 $TRS .= $trs;
583 }
584 } 611 }
585 612
586 my %FILECACHE; 613 my %FILECACHE;
587 614
588 sub load_cached($;$) { 615 sub load_cached($;$) {
600 627
601 $FILECACHE{$_[0]} 628 $FILECACHE{$_[0]}
602 } 629 }
603 630
604 sub process_res { 631 sub process_res {
605 while (my $job = $c_res->get) {
606 my ($dir, $file, $type) = @$job; 632 my ($dir, $file, $type) = @_;
607 633
608 my $data; 634 my $data;
609 aio_load "$dir/$file", $data; 635 aio_load "$dir/$file", $data;
610 636
611 my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; 637 my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) };
612 638
613 utf8::decode $dir; 639 utf8::decode $dir;
614 utf8::decode $file; 640 utf8::decode $file;
615 641
616 # a meta file for resources is now mandatory 642 # a meta file for resources is now mandatory
617 unless (exists $meta->{$file}) { 643 unless (exists $meta->{$file}) {
618 warn "skipping $dir/$file\n" if $VERBOSE >= 3; 644 warn "skipping $dir/$file\n" if $VERBOSE >= 3;
619 next; 645 return;
620 } 646 }
621 647
622 $meta = { 648 $meta = {
623 %{ $meta->{"" } || {} }, 649 %{ $meta->{"" } || {} },
624 %{ $meta->{$file} || {} }, 650 %{ $meta->{$file} || {} },
625 }; 651 };
626 652
627 if ($meta->{license} =~ s/^#//) { 653 if ($meta->{license} =~ s/^#//) {
628 $meta->{license} = ({ 654 $meta->{license} = ({
629 "pd" => "Public Domain", 655 "pd" => "Public Domain",
630 "gpl" => "GNU General Public License, version 3.0 or any later", 656 "gpl" => "GNU General Public License, version 3.0 or any later",
631 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", 657 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/",
632 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/", 658 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/",
633 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/", 659 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/",
634 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", 660 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/",
635 })->{$meta->{license}} 661 })->{$meta->{license}}
636 || warn "$dir/$file: license tag '$meta->{license}' not found."; 662 || warn "$dir/$file: license tag '$meta->{license}' not found.";
637 } 663 }
638 664
639 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) { 665 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) {
640 ($meta->{author} = $1) =~ s/_/ /g; 666 ($meta->{author} = $1) =~ s/_/ /g;
641 } 667 }
642 668
643 $file =~ s/\.res$//; 669 $file =~ s/\.res$//;
644 $file =~ s/\.(ogg|wav|jpg|png)$//; 670 $file =~ s/\.(ogg|wav|jpg|png)$//;
645 671
646 substr $dir, 0, 1 + length $PATH, ""; 672 substr $dir, 0, 1 + length $PATH, "";
647 673
648 if (my $filter = $meta->{cfutil_filter}) { 674 if (my $filter = $meta->{cfutil_filter}) {
649 if ($filter eq "yaml2json") { 675 if ($filter eq "yaml2json") {
650 $data = JSON::XS::encode_json YAML::XS::Load $data; 676 $data = JSON::XS::encode_json YAML::XS::Load $data;
651 } elsif ($filter eq "json2json") { 677 } elsif ($filter eq "json2json") {
652 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); 678 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data);
653 } elsif ($filter eq "perl2json") { 679 } elsif ($filter eq "perl2json") {
654 $data = eval $data; die if $@; 680 $data = eval $data; die if $@;
655 $data = JSON::XS::encode_json $data; 681 $data = JSON::XS::encode_json $data;
656 } else { 682 } else {
657 warn "$dir/$file: unknown filter $filter, skipping\n"; 683 warn "$dir/$file: unknown filter $filter, skipping\n";
658 } 684 }
659 } 685 }
660 686
661 $RESOURCE{"$dir/$file"} = { 687 $RESOURCE{"$dir/$file"} = {
662 type => (exists $meta->{type} ? delete $meta->{type} : $type), 688 type => (exists $meta->{type} ? delete $meta->{type} : $type),
663 data => $data, 689 data => $data,
664 %$meta ? (meta => $meta) : (), 690 %$meta ? (meta => $meta) : (),
665 }; 691 };
692 }
693
694 sub process_any {
695 while (my ($func, @args) = @{ $c_any->get }) {
696 $func->(@args);
666 } 697 }
667 } 698 }
668 699
669 sub find_files; 700 sub find_files;
670 sub find_files { 701 sub find_files {
671 my ($path) = @_; 702 my ($path) = @_;
672 703
704 my $grp = IO::AIO::aio_group;
705
706 my $scandir; $scandir = sub {
707 my ($path) = @_;
708
673 IO::AIO::aioreq_pri 4; 709 IO::AIO::aioreq_pri 4;
674 IO::AIO::aio_scandir $path, 4, sub { 710 add $grp IO::AIO::aio_scandir $path, 4, sub {
675 my ($dirs, $nondirs) = @_; 711 my ($dirs, $nondirs) = @_;
676 712
677 find_files "$path/$_" 713 $scandir->("$path/$_")
678 for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs; 714 for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs;
679 715
680 my $dir = $path; 716 my $dir = $path;
681 substr $dir, 0, 1 + length $PATH, ""; 717 substr $dir, 0, 1 + length $PATH, "";
682 718
683 for my $file (@$nondirs) { 719 for my $file (@$nondirs) {
684 if ($dir =~ /^music(?:\/|$)/) { 720 if ($dir =~ /^music(?:\/|$)/) {
685 $c_res->put ([$path, $file, 3]) # FT_MUSIC 721 $c_any->put ([\&process_res, $path, $file, 3]) # FT_MUSIC
686 if $file =~ /\.(ogg)$/; 722 if $file =~ /\.(ogg)$/;
687 723
688 } elsif ($dir =~ /^sound(?:\/|$)/) { 724 } elsif ($dir =~ /^sound(?:\/|$)/) {
689 $c_res->put ([$path, $file, 5]) # FT_SOUND 725 $c_any->put ([\&process_res, $path, $file, 5]) # FT_SOUND
690 if $file =~ /\.(wav|ogg)$/; 726 if $file =~ /\.(wav|ogg)$/;
691 727
692 } elsif ($dir =~ /^res(?:\/|$)/) { 728 } elsif ($dir =~ /^res(?:\/|$)/) {
693 if ($file =~ /\.(jpg|png)$/) { 729 if ($file =~ /\.(jpg|png)$/) {
694 $c_res->put ([$path, $file, 0]) # FT_FACE 730 $c_any->put ([\&process_res, $path, $file, 0]) # FT_FACE
695 } elsif ($file =~ /\.(res)$/) { 731 } elsif ($file =~ /\.(res)$/) {
732 $c_any->put ([\&process_res, $path, $file, 6]) # FT_RSRC
733 } else {
734 $c_any->put ([\&process_res, $path, $file, undef]);
735 }
736
737 } elsif ($file =~ /\.png$/) {
738 push @c_png, ["$path/$file", 0];
739
740 } elsif ($file =~ /\.faceinfo$/) {
741 $c_any->put ([\&process_faceinfo, $path, $file]);
742
743 } elsif ($file =~ /\.trs$/) {
744 $c_any->put ([\&process_trs, $path, $file]);
745
746 } elsif ($file =~ /\.arc$/) {
696 $c_res->put ([$path, $file, 6]) # FT_RSRC 747 $c_arc->put ([$path, $file]);
748
697 } else { 749 } else {
698 $c_res->put ([$path, $file, undef]); 750 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
699 } 751 }
700
701 } elsif ($file =~ /\.png$/) {
702 push @c_png, ["$path/$file", 0];
703
704 } elsif ($file =~ /\.trs$/) {
705 $c_trs->put ([$path, $file]);
706
707 } elsif ($file =~ /\.arc$/) {
708 $c_arc->put ([$path, $file]);
709
710 } else { 752 }
711 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
712 }
713 } 753 };
714 }; 754 };
755
756 $scandir->($path);
757 aio_wait $grp;
715 } 758 }
716 759
717 sub generate_plurals { 760 sub generate_plurals {
718# use Lingua::EN::Inflect (); 761# use Lingua::EN::Inflect ();
719# Lingua::EN::Inflect::classical; 762# Lingua::EN::Inflect::classical;
757 if (!-d "$path/treasures") { 800 if (!-d "$path/treasures") {
758 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; 801 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n";
759 exit 1 unless $FORCE; 802 exit 1 unless $FORCE;
760 } 803 }
761 804
762 print "scanning files...\n" if $VERBOSE; 805 print "start file scan, arc, any processing...\n" if $VERBOSE;
806
807 my @a_arc = map +(async \&process_arc), 1..2;
808 my @a_any = map +(async \&process_any), 1..4;
763 809
764 find_files $path; 810 find_files $path;
765 811
766 my @a_arc = map +(async \&process_arc), 1..2;
767 my @a_res = map +(async \&process_res), 1..2;
768 my @a_trs = map +(async \&process_trs), 1..2;
769
770 IO::AIO::flush;
771
772 $c_res->shutdown;
773 $c_arc->shutdown; 812 $c_arc->shutdown;
774 $c_trs->shutdown; 813 $c_any->shutdown;
775
776 print "start file scan, arc, res processing...\n" if $VERBOSE;
777 814
778 $_->join for @a_arc; # need to parse all archetypes before png processing 815 $_->join for @a_arc; # need to parse all archetypes before png processing
779 816
780 print "end arc, start png processing...\n" if $VERBOSE; 817 print "end arc, start png processing...\n" if $VERBOSE;
781 818
782 # eight png crunchers work fine for my 4x smp machine 819 # eight png crunchers work fine for my 4x smp machine
783 my @a_png = map +(async \&process_png), 1..8; 820 my @a_png = map +(async \&process_png), 1..8;
784 821
785 $_->join for (@a_trs, @a_res, @a_png); 822 print "end any processing...\n" if $VERBOSE;
823 $_->join for @a_any;
824
825 print "end png processing...\n" if $VERBOSE;
826 $_->join for @a_png;
786 827
787 print "scanning done, processing results...\n" if $VERBOSE; 828 print "scanning done, processing results...\n" if $VERBOSE;
788 { 829 {
789 # remove path prefix from editor_folder 830 # remove path prefix from editor_folder
790 $_->{editor_folder} =~ /^\x00/ 831 $_->{editor_folder} =~ /^\x00/
808 delete @s{qw(_name more name name_pl)}; 849 delete @s{qw(_name more name name_pl)};
809 %$o = ( %s, %$o ); 850 %$o = ( %s, %$o );
810 ++$progress; 851 ++$progress;
811 } 852 }
812 } else { 853 } else {
813 warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; 854 warn "WARNING: archetype '$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n";
814 delete $ARC{$o->{_name}}; 855 delete $ARC{$o->{_name}};
815 } 856 }
816 } 857 }
817 } 858 }
818 859
832 873
833 printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE; 874 printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE;
834 open my $fh, ">:utf8", "$DATADIR/archetypes~" 875 open my $fh, ">:utf8", "$DATADIR/archetypes~"
835 or die "$DATADIR/archetypes~: $!"; 876 or die "$DATADIR/archetypes~: $!";
836 print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; 877 print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC];
878 }
879
880 if (WRITE_FACEINFO) {
881 my @table;
882 for my $face (sort keys %FACEINFO) {
883 my $v = $FACEINFO{$face};
884 (my $xf = $face) =~ s/\+\d+\+\d+$//;
885
886 $v->{magicmap} //= $FACEINFO{$xf}{magicmap};
887 $v->{glyph} //= $FACEINFO{$xf}{glyph};
888
889 $v->{magicmap} =~ y/A-Z_\-/a-z/d;
890
891 delete $v->{glyph} if $v->{glyph} =~ /^\?./;
892
893 my $stem = $v->{stem};
894 $v->{glyph} = $v->{glyph} // ("?" . (autoglyph $stem, $v));
895
896 push @table, [$face, $v->{visibility} || 0, $v->{magicmap} || "none", "none ", $v->{glyph}];
897 }
898 use Text::Table;
899 my $tb = new Text::Table undef, { align => "num" }, undef, undef, undef;
900 $tb->load (@table);
901 open my $fh, ">:raw", "default.faceinfo"or die;
902 print $fh $tb;
903 print "default.faceinfo written, exiting.\n";
904 exit 77;
837 } 905 }
838 906
839 { 907 {
840 printf "writing treasures (%d octets)...\n", length $TRS if $VERBOSE; 908 printf "writing treasures (%d octets)...\n", length $TRS if $VERBOSE;
841 open my $fh, ">:utf8", "$DATADIR/treasures~" 909 open my $fh, ">:utf8", "$DATADIR/treasures~"
844 } 912 }
845 913
846 { 914 {
847 print "processing facedata...\n" if $VERBOSE; 915 print "processing facedata...\n" if $VERBOSE;
848 while (my ($k, $v) = each %FACEINFO) { 916 while (my ($k, $v) = each %FACEINFO) {
849 length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; 917 length $v->{data32} or warn "WARNING: face '$k' has no png32. this will not work (shoddy gcfclient will crash of course).\n";
850 length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; 918 length $v->{data64} or warn "WARNING: face '$k' has no png64. this will not work very well.\n";
851 919
852 make_hash $k, $v->{data32}, $v->{hash32}; 920 make_hash $k, $v->{data32}, $v->{hash32};
853 make_hash $k, $v->{data64}, $v->{hash64}; 921 make_hash $k, $v->{data64}, $v->{hash64};
854 922
855 #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; 923 #length $v->{data32} <= 10000 or warn "WARNING: face '$k' has face32 larger than 10000 bytes, will not work with crossfire client.\n";
856 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; 924 #length $v->{data64} <= 10000 or warn "WARNING: face '$k' has face64 larger than 10000 bytes.\n";
857 925
858 if (my $magicmap = $v->{magicmap}) { 926 exists $v->{visibility}
859 $magicmap =~ y/A-Z_\-/a-z/d; 927 or warn "WARNING: face '$k' has no visibility info, missing faceinfo entry?\n";
860 $v->{magicmap} = $COLOR{$magicmap};
861 }
862 928
863 my $stem = delete $v->{stem}; 929 my $stem = delete $v->{stem};
930 $v->{glyph} // warn "WARNING: face '$k' has glyph, cannot autoglyph at the moment.";
864 $v->{glyph} //= autoglyph $stem, $v; 931 #$v->{glyph} //= autoglyph $stem, $v;
865 utf8::encode $v->{glyph};
866 $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph};
867 932
868 delete $v->{arc}; 933 delete $v->{arc};
869 } 934 }
870 935
871 print "processing resources...\n" if $VERBOSE; 936 print "processing resources...\n" if $VERBOSE;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines