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.87 by root, Tue Oct 5 23:25:25 2010 UTC vs.
Revision 1.105 by root, Sun Oct 17 08:00:09 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 };
106 my ($id, $dataref, $hashref, $clen) = @_; 118 my ($id, $dataref, $hashref, $clen) = @_;
107 119
108 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4; 120 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4;
109 121
110 if (exists $hash{$hash}) { 122 if (exists $hash{$hash}) {
111 # hahs collinion, but some files are simply identical 123 # hash collision, but some files are simply identical
112 if (${$hash{$hash}[1]} ne $$dataref) { 124 if (${$hash{$hash}[1]} ne $$dataref) {
113 warn "hash collision $hash{$hash}[0] vs. $id\n"; 125 warn "hash collision $hash{$hash}[0] vs. $id\n";
114 exit 1; 126 exit 1;
115 } else { 127 } else {
116 print "$hash{$hash}[0] and $id are identical (which is fine).\n" if $VERBOSE >= 3; 128 print "$hash{$hash}[0] and $id are identical (which is fine).\n" if $VERBOSE >= 3;
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
176 our @WALL_SUFFIX = qw(⬤ ╹ ╺ ┗ ╻ ┃ ┏ ┣ ╸ ┛ ━ ┻ ┓ ┫ ┳ ╋);
177
178 # used to create crude text glyphs for text-based clients
161sub autoglyph { 179 sub autoglyph {
162 my ($stem, $face) = @_; 180 my ($stem, $face) = @_;
163 181
164 if ($stem =~ /^wall\/|Nimwall/) { 182 if ($stem =~ /^wall\/|Nimwall/) {
165# warn $stem; 183 return $WALL_SUFFIX[hex $1]
184 if $stem =~ /(_[0-9A-F]).x11/;
185
186 "█"
187
188 } elsif ($stem =~ /^traps\//) {
189 "☠"
190
191 } elsif ($stem =~ /^armour\/shield/) {
192 "Ø"
193
194 } elsif ($stem =~ /^armour\//) {
166 "+" 195 "A"
196
197 } elsif ($stem =~ /^weapon\//) {
198 "†"
199
200 } elsif ($stem =~ /^readable\//) {
201 "✉"
202
203 } elsif ($stem =~ /^river\//) {
204 "~"
205
167 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { 206 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) {
207 "·"
208
209 } elsif ($stem =~ /^spells\//) {
168 "." 210 "!"
211
212 } elsif ($stem =~ /^exit\//) {
213 "⎆"
214
215 } elsif ($stem =~ /^construct\//) {
216 "⌂"
217
218 } elsif ($stem =~ /^player\//) {
219 "\@"
220
221 } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) {
222 $1
223
169 } else { 224 } else {
170 substr $stem, 0, 1 225 substr $stem, 0, 1
226 }
171 } 227 }
172} 228}
173 229
174{ 230{
175 our %ANIMINFO; 231 our %ANIMINFO;
182 our $PATH; 238 our $PATH;
183 239
184 our $QUANTIZE = "+dither -colorspace RGB -colors 256"; 240 our $QUANTIZE = "+dither -colorspace RGB -colors 256";
185 241
186 our $c_arc = new Coro::Channel; 242 our $c_arc = new Coro::Channel;
187 our $c_trs = new Coro::Channel; 243 our $c_any = new Coro::Channel;
188 our $c_res = new Coro::Channel;
189 244
190 our @c_png; 245 our @c_png;
191 246
192 sub commit_png($$$$) { 247 sub commit_png($$$$) {
193 my ($stem, $name, $data, $T) = @_; 248 my ($stem, $name, $data, $T) = @_;
429 484
430 aio_unlink $path if $delete; 485 aio_unlink $path if $delete;
431 } 486 }
432 } 487 }
433 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 $fg = "white" if $fg eq "none"; # lots of faces have no fg colour yet
505
506 (my $fgi = $COLOR{$fg})
507 // warn "WARNING: $path: $face specifies unknown foreground colour '$fg'.\n";
508 (my $bgi = $COLOR{$bg})
509 // warn "WARNING: $path: $face specifies unknown background colour '$bg'.\n";
510
511 my $fi = $FACEINFO{$face} ||= { };
512 $fi->{visibility} = $visibility * 1;
513 $fi->{magicmap} = $fgi; # foreground colour becomes magicmap
514 $fi->{glyph} = (chr $fgi) . (chr $bgi) . $glyph;
515 #$fi->{glyph} = (chr $fgi) . $glyph;#d#TOOD remove
516 # bg not used except for text clients
517 }
518 }
519
434 sub process_arc { 520 sub process_arc {
435 while (my $job = $c_arc->get) { 521 while (my ($dir, $file) = @{ $c_arc->get }) {
436 my ($dir, $file) = @$job;
437
438 my $arc; 522 my $arc;
439 aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/ 523 aio_load "$dir/$file", $arc; # simply pre-cache, as read_arch wants a file :/
440 524
441 my $arc = read_arch "$dir/$file"; 525 my $arc = read_arch "$dir/$file";
442 for my $o (values %$arc) { 526 for my $o (values %$arc) {
444 for (my $m = $o; $m; $m = $m->{more}) { 528 for (my $m = $o; $m; $m = $m->{more}) {
445 $ARC{$m->{_name}} = $m; 529 $ARC{$m->{_name}} = $m;
446 } 530 }
447 531
448 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge 532 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge
449
450 my $visibility = delete $o->{visibility};
451 my $magicmap = delete $o->{magicmap};
452 my $glyph = delete $o->{glyph};
453 533
454 # find upper left corner :/ 534 # find upper left corner :/
455 # omg, this is sooo broken 535 # omg, this is sooo broken
456 my ($dx, $dy); 536 my ($dx, $dy);
457 for (my $o = $o; $o; $o = $o->{more}) { 537 for (my $o = $o; $o; $o = $o->{more}) {
464 my $y = $o->{y} - $dy; 544 my $y = $o->{y} - $dy;
465 545
466 my $ext = $x|$y ? "+$x+$y" : ""; 546 my $ext = $x|$y ? "+$x+$y" : "";
467 547
468 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 548 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
469
470 $visibility = delete $o->{visibility} if exists $o->{visibility};
471 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
472 $glyph = delete $o->{glyph} if exists $o->{glyph};
473 549
474 my $anim = delete $o->{anim}; 550 my $anim = delete $o->{anim};
475 551
476 if ($anim) { 552 if ($anim) {
477 # possibly add $ext to the animation name to avoid 553 # possibly add $ext to the animation name to avoid
505 581
506 my $info = $FACEINFO{$face} ||= { }; 582 my $info = $FACEINFO{$face} ||= { };
507 $info->{arc} = $o; 583 $info->{arc} = $o;
508 584
509 next if $face =~ /^blank.x11$|^empty.x11$/; 585 next if $face =~ /^blank.x11$|^empty.x11$/;
510
511 $info->{visibility} = $visibility if defined $visibility;
512 $info->{magicmap} = $magicmap if defined $magicmap;
513 $info->{glyph} = $glyph if defined $glyph;
514 } 586 }
515 587
516 if (my $smooth = delete $o->{smoothface}) { 588 if (my $smooth = delete $o->{smoothface}) {
517 my %kv = split /\s+/, $smooth; 589 my %kv = split /\s+/, $smooth;
518 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support 590 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
527 } 599 }
528 } 600 }
529 } 601 }
530 602
531 sub process_trs { 603 sub process_trs {
532 while (my $job = $c_trs->get) {
533 my ($dir, $file) = @$job; 604 my ($dir, $file) = @_;
534 my $path = "$dir/$file"; 605 my $path = "$dir/$file";
535 606
536 my $trs; 607 my $trs;
537 if (0 > aio_load $path, $trs) { 608 if (0 > aio_load $path, $trs) {
538 warn "$path: $!, skipping.\n"; 609 warn "$path: $!, skipping.\n";
539 next; 610 return;
540 } 611 }
541 612
542 $TRS .= $trs; 613 $TRS .= $trs;
543 }
544 } 614 }
545 615
546 my %FILECACHE; 616 my %FILECACHE;
547 617
548 sub load_cached($;$) { 618 sub load_cached($;$) {
560 630
561 $FILECACHE{$_[0]} 631 $FILECACHE{$_[0]}
562 } 632 }
563 633
564 sub process_res { 634 sub process_res {
565 while (my $job = $c_res->get) {
566 my ($dir, $file, $type) = @$job; 635 my ($dir, $file, $type) = @_;
567 636
568 my $data; 637 my $data;
569 aio_load "$dir/$file", $data; 638 aio_load "$dir/$file", $data;
570 639
571 my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) }; 640 my $meta = load_cached "$dir/meta", sub { JSON::XS->new->utf8->relaxed->decode (shift) };
572 641
573 utf8::decode $dir; 642 utf8::decode $dir;
574 utf8::decode $file; 643 utf8::decode $file;
575 644
576 # a meta file for resources is now mandatory 645 # a meta file for resources is now mandatory
577 unless (exists $meta->{$file}) { 646 unless (exists $meta->{$file}) {
578 warn "skipping $dir/$file\n" if $VERBOSE >= 3; 647 warn "skipping $dir/$file\n" if $VERBOSE >= 3;
579 next; 648 return;
580 } 649 }
581 650
582 $meta = { 651 $meta = {
583 %{ $meta->{"" } || {} }, 652 %{ $meta->{"" } || {} },
584 %{ $meta->{$file} || {} }, 653 %{ $meta->{$file} || {} },
585 }; 654 };
586 655
587 if ($meta->{license} =~ s/^#//) { 656 if ($meta->{license} =~ s/^#//) {
588 $meta->{license} = ({ 657 $meta->{license} = ({
589 "pd" => "Public Domain", 658 "pd" => "Public Domain",
590 "gpl" => "GNU General Public License, version 3.0 or any later", 659 "gpl" => "GNU General Public License, version 3.0 or any later",
591 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", 660 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/",
592 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/", 661 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/",
593 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/", 662 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/",
594 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", 663 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/",
595 })->{$meta->{license}} 664 })->{$meta->{license}}
596 || warn "$dir/$file: license tag '$meta->{license}' not found."; 665 || warn "$dir/$file: license tag '$meta->{license}' not found.";
597 } 666 }
598 667
599 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) { 668 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) {
600 ($meta->{author} = $1) =~ s/_/ /g; 669 ($meta->{author} = $1) =~ s/_/ /g;
601 } 670 }
602 671
603 $file =~ s/\.res$//; 672 $file =~ s/\.res$//;
604 $file =~ s/\.(ogg|wav|jpg|png)$//; 673 $file =~ s/\.(ogg|wav|jpg|png)$//;
605 674
606 substr $dir, 0, 1 + length $PATH, ""; 675 substr $dir, 0, 1 + length $PATH, "";
607 676
608 if (my $filter = $meta->{cfutil_filter}) { 677 if (my $filter = $meta->{cfutil_filter}) {
609 if ($filter eq "yaml2json") { 678 if ($filter eq "yaml2json") {
610 $data = JSON::XS::encode_json YAML::XS::Load $data; 679 $data = JSON::XS::encode_json YAML::XS::Load $data;
611 } elsif ($filter eq "json2json") { 680 } elsif ($filter eq "json2json") {
612 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data); 681 $data = JSON::XS::encode_json JSON::XS->relaxed->utf8->decode ($data);
613 } elsif ($filter eq "perl2json") { 682 } elsif ($filter eq "perl2json") {
614 $data = eval $data; die if $@; 683 $data = eval $data; die if $@;
615 $data = JSON::XS::encode_json $data; 684 $data = JSON::XS::encode_json $data;
616 } else { 685 } else {
617 warn "$dir/$file: unknown filter $filter, skipping\n"; 686 warn "$dir/$file: unknown filter $filter, skipping\n";
618 } 687 }
619 } 688 }
620 689
621 $RESOURCE{"$dir/$file"} = { 690 $RESOURCE{"$dir/$file"} = {
622 type => (exists $meta->{type} ? delete $meta->{type} : $type), 691 type => (exists $meta->{type} ? delete $meta->{type} : $type),
623 data => $data, 692 data => $data,
624 %$meta ? (meta => $meta) : (), 693 %$meta ? (meta => $meta) : (),
625 }; 694 };
695 }
696
697 sub process_any {
698 while (my ($func, @args) = @{ $c_any->get }) {
699 $func->(@args);
626 } 700 }
627 } 701 }
628 702
629 sub find_files; 703 sub find_files;
630 sub find_files { 704 sub find_files {
631 my ($path) = @_; 705 my ($path) = @_;
632 706
707 my $grp = IO::AIO::aio_group;
708
709 my $scandir; $scandir = sub {
710 my ($path) = @_;
711
633 IO::AIO::aioreq_pri 4; 712 IO::AIO::aioreq_pri 4;
634 IO::AIO::aio_scandir $path, 4, sub { 713 add $grp IO::AIO::aio_scandir $path, 4, sub {
635 my ($dirs, $nondirs) = @_; 714 my ($dirs, $nondirs) = @_;
636 715
637 find_files "$path/$_" 716 $scandir->("$path/$_")
638 for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs; 717 for grep $_ !~ /^(?:CVS|dev|\..*)$/, @$dirs;
639 718
640 my $dir = $path; 719 my $dir = $path;
641 substr $dir, 0, 1 + length $PATH, ""; 720 substr $dir, 0, 1 + length $PATH, "";
642 721
643 for my $file (@$nondirs) { 722 for my $file (@$nondirs) {
644 if ($dir =~ /^music(?:\/|$)/) { 723 if ($dir =~ /^music(?:\/|$)/) {
645 $c_res->put ([$path, $file, 3]) # FT_MUSIC 724 $c_any->put ([\&process_res, $path, $file, 3]) # FT_MUSIC
646 if $file =~ /\.(ogg)$/; 725 if $file =~ /\.(ogg)$/;
647 726
648 } elsif ($dir =~ /^sound(?:\/|$)/) { 727 } elsif ($dir =~ /^sound(?:\/|$)/) {
649 $c_res->put ([$path, $file, 5]) # FT_SOUND 728 $c_any->put ([\&process_res, $path, $file, 5]) # FT_SOUND
650 if $file =~ /\.(wav|ogg)$/; 729 if $file =~ /\.(wav|ogg)$/;
651 730
652 } elsif ($dir =~ /^res(?:\/|$)/) { 731 } elsif ($dir =~ /^res(?:\/|$)/) {
653 if ($file =~ /\.(jpg|png)$/) { 732 if ($file =~ /\.(jpg|png)$/) {
654 $c_res->put ([$path, $file, 0]) # FT_FACE 733 $c_any->put ([\&process_res, $path, $file, 0]) # FT_FACE
655 } elsif ($file =~ /\.(res)$/) { 734 } elsif ($file =~ /\.(res)$/) {
735 $c_any->put ([\&process_res, $path, $file, 6]) # FT_RSRC
736 } else {
737 $c_any->put ([\&process_res, $path, $file, undef]);
738 }
739
740 } elsif ($file =~ /\.png$/) {
741 push @c_png, ["$path/$file", 0];
742
743 } elsif ($file =~ /\.faceinfo$/) {
744 $c_any->put ([\&process_faceinfo, $path, $file]);
745
746 } elsif ($file =~ /\.trs$/) {
747 $c_any->put ([\&process_trs, $path, $file]);
748
749 } elsif ($file =~ /\.arc$/) {
656 $c_res->put ([$path, $file, 6]) # FT_RSRC 750 $c_arc->put ([$path, $file]);
751
657 } else { 752 } else {
658 $c_res->put ([$path, $file, undef]); 753 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
659 } 754 }
660
661 } elsif ($file =~ /\.png$/) {
662 push @c_png, ["$path/$file", 0];
663
664 } elsif ($file =~ /\.trs$/) {
665 $c_trs->put ([$path, $file]);
666
667 } elsif ($file =~ /\.arc$/) {
668 $c_arc->put ([$path, $file]);
669
670 } else { 755 }
671 warn "ignoring $path/$file\n" if $VERBOSE >= 3;
672 }
673 } 756 };
674 }; 757 };
758
759 $scandir->($path);
760 aio_wait $grp;
675 } 761 }
676 762
677 sub generate_plurals { 763 sub generate_plurals {
678# use Lingua::EN::Inflect (); 764# use Lingua::EN::Inflect ();
679# Lingua::EN::Inflect::classical; 765# Lingua::EN::Inflect::classical;
717 if (!-d "$path/treasures") { 803 if (!-d "$path/treasures") {
718 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n"; 804 warn "'$path' does not look like an arch directory ('treasures' directory is missing).\n";
719 exit 1 unless $FORCE; 805 exit 1 unless $FORCE;
720 } 806 }
721 807
722 print "scanning files...\n" if $VERBOSE; 808 print "start file scan, arc, any processing...\n" if $VERBOSE;
809
810 my @a_arc = map +(async \&process_arc), 1..2;
811 my @a_any = map +(async \&process_any), 1..4;
723 812
724 find_files $path; 813 find_files $path;
725 814
726 my @a_arc = map +(async \&process_arc), 1..2;
727 my @a_res = map +(async \&process_res), 1..2;
728 my @a_trs = map +(async \&process_trs), 1..2;
729
730 IO::AIO::flush;
731
732 $c_res->shutdown;
733 $c_arc->shutdown; 815 $c_arc->shutdown;
734 $c_trs->shutdown; 816 $c_any->shutdown;
735
736 print "start file scan, arc, res processing...\n" if $VERBOSE;
737 817
738 $_->join for @a_arc; # need to parse all archetypes before png processing 818 $_->join for @a_arc; # need to parse all archetypes before png processing
739 819
740 print "end arc, start png processing...\n" if $VERBOSE; 820 print "end arc, start png processing...\n" if $VERBOSE;
741 821
742 # eight png crunchers work fine for my 4x smp machine 822 # eight png crunchers work fine for my 4x smp machine
743 my @a_png = map +(async \&process_png), 1..8; 823 my @a_png = map +(async \&process_png), 1..8;
744 824
745 $_->join for (@a_trs, @a_res, @a_png); 825 print "end any processing...\n" if $VERBOSE;
826 $_->join for @a_any;
827
828 print "end png processing...\n" if $VERBOSE;
829 $_->join for @a_png;
746 830
747 print "scanning done, processing results...\n" if $VERBOSE; 831 print "scanning done, processing results...\n" if $VERBOSE;
748 { 832 {
749 # remove path prefix from editor_folder 833 # remove path prefix from editor_folder
750 $_->{editor_folder} =~ /^\x00/ 834 $_->{editor_folder} =~ /^\x00/
768 delete @s{qw(_name more name name_pl)}; 852 delete @s{qw(_name more name name_pl)};
769 %$o = ( %s, %$o ); 853 %$o = ( %s, %$o );
770 ++$progress; 854 ++$progress;
771 } 855 }
772 } else { 856 } else {
773 warn "'$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n"; 857 warn "WARNING: archetype '$o->{_name}' tries to inherit from undefined archetype '$other', skipping.\n";
774 delete $ARC{$o->{_name}}; 858 delete $ARC{$o->{_name}};
775 } 859 }
776 } 860 }
777 } 861 }
778 862
785 } 869 }
786 870
787 # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit 871 # remove base classes (by naming scheme, should use something like "baseclass xxx" to inherit
788 @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC; 872 @ARC = grep $_->{_name} !~ /^(?:type|class)_/, @ARC;
789 873
874 # fix up archetypes without names, where the archanme doesn't work at all
875 for (@ARC) {
876 if (!exists $_->{name} and $_->{_name} =~ /_/) {
877 for ($_->{name} = $_->{_name}) {
878 s/(?:_\d+)+$//;
879 s/_[nesw]+$//;
880 y/_/ /;
881 }
882 }
883 }
884
790 print "generating plurals...\n" if $VERBOSE; 885 #print "generating plurals...\n" if $VERBOSE;
791 generate_plurals; 886 #generate_plurals;
792 887
793 printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE; 888 printf "writing %d archetypes...\n", scalar @ARC if $VERBOSE;
794 open my $fh, ">:utf8", "$DATADIR/archetypes~" 889 open my $fh, ">:utf8", "$DATADIR/archetypes~"
795 or die "$DATADIR/archetypes~: $!"; 890 or die "$DATADIR/archetypes~: $!";
796 print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC]; 891 print $fh Deliantra::archlist_to_string [sort { $a->{_name} cmp $b->{_name} } @ARC];
892 }
893
894 if (WRITE_FACEINFO) {
895 my @table;
896 for my $face (sort keys %FACEINFO) {
897 my $v = $FACEINFO{$face};
898 (my $xf = $face) =~ s/\+\d+\+\d+$//;
899
900 $v->{magicmap} //= $FACEINFO{$xf}{magicmap};
901 $v->{glyph} //= $FACEINFO{$xf}{glyph};
902
903 $v->{magicmap} =~ y/A-Z_\-/a-z/d;
904
905 delete $v->{glyph} if $v->{glyph} =~ /^\?./;
906
907 my $stem = $v->{stem};
908 $v->{glyph} = $v->{glyph} // ("?" . (autoglyph $stem, $v));
909
910 push @table, [$face, $v->{visibility} || 0, $v->{magicmap} || "none", "none ", $v->{glyph}];
911 }
912 use Text::Table;
913 my $tb = new Text::Table undef, { align => "num" }, undef, undef, undef;
914 $tb->load (@table);
915 open my $fh, ">:raw", "default.faceinfo"or die;
916 print $fh $tb;
917 print "default.faceinfo written, exiting.\n";
918 exit 77;
797 } 919 }
798 920
799 { 921 {
800 printf "writing treasures (%d octets)...\n", length $TRS if $VERBOSE; 922 printf "writing treasures (%d octets)...\n", length $TRS if $VERBOSE;
801 open my $fh, ">:utf8", "$DATADIR/treasures~" 923 open my $fh, ">:utf8", "$DATADIR/treasures~"
804 } 926 }
805 927
806 { 928 {
807 print "processing facedata...\n" if $VERBOSE; 929 print "processing facedata...\n" if $VERBOSE;
808 while (my ($k, $v) = each %FACEINFO) { 930 while (my ($k, $v) = each %FACEINFO) {
809 length $v->{data32} or warn "$k: face has no png32. this will not work (shoddy gcfclient will crash of course).\n"; 931 length $v->{data32} or warn "WARNING: face '$k' has no png32. this will not work (shoddy gcfclient will crash of course).\n";
810 length $v->{data64} or warn "$k: face has no png64. this will not work very well.\n"; 932 length $v->{data64} or warn "WARNING: face '$k' has no png64. this will not work very well.\n";
811 933
812 make_hash $k, $v->{data32}, $v->{hash32}; 934 make_hash $k, $v->{data32}, $v->{hash32};
813 make_hash $k, $v->{data64}, $v->{hash64}; 935 make_hash $k, $v->{data64}, $v->{hash64};
814 936
815 #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; 937 #length $v->{data32} <= 10000 or warn "WARNING: face '$k' has face32 larger than 10000 bytes, will not work with crossfire client.\n";
816 #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; 938 #length $v->{data64} <= 10000 or warn "WARNING: face '$k' has face64 larger than 10000 bytes.\n";
939
940 exists $v->{visibility}
941 or warn "WARNING: face '$k' has no visibility info, missing faceinfo entry?\n";
817 942
818 my $stem = delete $v->{stem}; 943 my $stem = delete $v->{stem};
944 $v->{glyph} // warn "WARNING: face '$k' has glyph, cannot autoglyph at the moment.";
819 $v->{glyph} //= autoglyph $stem, $v; 945 #$v->{glyph} //= autoglyph $stem, $v;
820
821 if (my $magicmap = $v->{magicmap}) {
822 $magicmap =~ y/A-Z_\-/a-z/d;
823 $v->{magicmap} = $COLOR{$magicmap};
824 }
825 946
826 delete $v->{arc}; 947 delete $v->{arc};
827 } 948 }
828 949
829 print "processing resources...\n" if $VERBOSE; 950 print "processing resources...\n" if $VERBOSE;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines