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.83 by root, Wed Apr 28 20:51:58 2010 UTC vs.
Revision 1.97 by root, Wed Oct 6 01:23:11 2010 UTC

20# <http://www.gnu.org/licenses/>. 20# <http://www.gnu.org/licenses/>.
21# 21#
22# The authors can be reached via e-mail to <support@deliantra.net> 22# The authors can be reached via e-mail to <support@deliantra.net>
23# 23#
24 24
25use strict; 25use common::sense;
26 26
27my $prefix = "@prefix@"; 27my $prefix = "@prefix@";
28my $exec_prefix = "@exec_prefix@"; 28my $exec_prefix = "@exec_prefix@";
29my $datarootdir = "@datarootdir@"; 29my $datarootdir = "@datarootdir@";
30my $DATADIR = "@datadir@/@PACKAGE@"; 30my $DATADIR = "@datadir@/@PACKAGE@";
106 my ($id, $dataref, $hashref, $clen) = @_; 106 my ($id, $dataref, $hashref, $clen) = @_;
107 107
108 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4; 108 my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4;
109 109
110 if (exists $hash{$hash}) { 110 if (exists $hash{$hash}) {
111 # hahs collinion, but some files are simply identical 111 # hash collision, but some files are simply identical
112 if (${$hash{$hash}[1]} ne $$dataref) { 112 if (${$hash{$hash}[1]} ne $$dataref) {
113 warn "hash collision $hash{$hash}[0] vs. $id\n"; 113 warn "hash collision $hash{$hash}[0] vs. $id\n";
114 exit 1; 114 exit 1;
115 } else { 115 } else {
116 print "$hash{$hash}[0] and $id are identical (which is fine).\n" if $VERBOSE >= 3; 116 print "$hash{$hash}[0] and $id are identical (which is fine).\n" if $VERBOSE >= 3;
156 and die "map installation failed.\n"; 156 and die "map installation failed.\n";
157 157
158 print "maps installed successfully.\n"; 158 print "maps installed successfully.\n";
159} 159}
160 160
161our @WALL_SUFFIX = qw(⬤ ╹ ╺ ┗ ╻ ┃ ┏ ┣ ╸ ┛ ━ ┻ ┓ ┫ ┳ ╋);
162
163# used to create crude text glyphs for text-based clients
164sub autoglyph {
165 my ($stem, $face) = @_;
166
167 if ($stem =~ /^wall\/|Nimwall/) {
168 return $WALL_SUFFIX[hex $1]
169 if $stem =~ /(_[0-9A-F]).x11/;
170
171 "+"
172
173 } elsif ($stem =~ /^monster.*\/(.)/) {
174 $1
175
176 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) {
177 "."
178
179 } elsif ($stem =~ /^player\//) {
180 "\@"
181
182 } else {
183 substr $stem, 0, 1
184 }
185}
186
161{ 187{
162 our %ANIMINFO; 188 our %ANIMINFO;
163 our %FACEINFO; 189 our %FACEINFO;
164 our %RESOURCE; 190 our %RESOURCE;
165 our @ARC; 191 our @ARC;
174 our $c_trs = new Coro::Channel; 200 our $c_trs = new Coro::Channel;
175 our $c_res = new Coro::Channel; 201 our $c_res = new Coro::Channel;
176 202
177 our @c_png; 203 our @c_png;
178 204
179 sub commit_png($$$) { 205 sub commit_png($$$$) {
180 my ($name, $data, $T) = @_; 206 my ($stem, $name, $data, $T) = @_;
181 207
208 $FACEINFO{$name}{"stem"} = substr $stem, 1 + length $PATH;
182 $FACEINFO{$name}{"data$T"} = $data; 209 $FACEINFO{$name}{"data$T"} = $data;
183 } 210 }
184 211
185 sub process_png { 212 sub process_png {
186 while (@c_png) { 213 while (@c_png) {
404 431
405 if (0 > aio_load $file, $tile) { 432 if (0 > aio_load $file, $tile) {
406 die "$path: unable to read tile +$x+$y, aborting.\n"; 433 die "$path: unable to read tile +$x+$y, aborting.\n";
407 } 434 }
408 IO::AIO::aio_unlink $file unless $CACHE; 435 IO::AIO::aio_unlink $file unless $CACHE;
409 commit_png $x|$y ? "$face+$x+$y" : $face, $tile, $T; 436 commit_png $stem, $x|$y ? "$face+$x+$y" : $face, $tile, $T;
410 } 437 }
411 } else { 438 } else {
412 # use as-is (either small, use smooth) 439 # use as-is (either small, use smooth)
413 commit_png $face, $png, $T; 440 commit_png $stem, $face, $png, $T;
414 } 441 }
415 442
416 aio_unlink $path if $delete; 443 aio_unlink $path if $delete;
417 } 444 }
418 } 445 }
433 460
434 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge 461 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge
435 462
436 my $visibility = delete $o->{visibility}; 463 my $visibility = delete $o->{visibility};
437 my $magicmap = delete $o->{magicmap}; 464 my $magicmap = delete $o->{magicmap};
465 my $glyph = delete $o->{glyph};
438 466
439 # find upper left corner :/ 467 # find upper left corner :/
440 # omg, this is sooo broken 468 # omg, this is sooo broken
441 my ($dx, $dy); 469 my ($dx, $dy);
442 for (my $o = $o; $o; $o = $o->{more}) { 470 for (my $o = $o; $o; $o = $o->{more}) {
452 480
453 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 481 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
454 482
455 $visibility = delete $o->{visibility} if exists $o->{visibility}; 483 $visibility = delete $o->{visibility} if exists $o->{visibility};
456 $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 484 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
485 $glyph = delete $o->{glyph} if exists $o->{glyph};
457 486
458 my $anim = delete $o->{anim}; 487 my $anim = delete $o->{anim};
459 488
460 if ($anim) { 489 if ($anim) {
461 # possibly add $ext to the animation name to avoid 490 # possibly add $ext to the animation name to avoid
492 521
493 next if $face =~ /^blank.x11$|^empty.x11$/; 522 next if $face =~ /^blank.x11$|^empty.x11$/;
494 523
495 $info->{visibility} = $visibility if defined $visibility; 524 $info->{visibility} = $visibility if defined $visibility;
496 $info->{magicmap} = $magicmap if defined $magicmap; 525 $info->{magicmap} = $magicmap if defined $magicmap;
526 $info->{glyph} = $glyph if defined $glyph;
497 } 527 }
498 528
499 if (my $smooth = delete $o->{smoothface}) { 529 if (my $smooth = delete $o->{smoothface}) {
500 my %kv = split /\s+/, $smooth; 530 my %kv = split /\s+/, $smooth;
501 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support 531 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
570 if ($meta->{license} =~ s/^#//) { 600 if ($meta->{license} =~ s/^#//) {
571 $meta->{license} = ({ 601 $meta->{license} = ({
572 "pd" => "Public Domain", 602 "pd" => "Public Domain",
573 "gpl" => "GNU General Public License, version 3.0 or any later", 603 "gpl" => "GNU General Public License, version 3.0 or any later",
574 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/", 604 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/",
605 "cc/by/2.1" => "Licensed under Creative Commons Attribution 2.1 http://creativecommons.org/licenses/by/2.1/",
575 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/", 606 "cc/by/2.5" => "Licensed under Creative Commons Attribution 2.5 http://creativecommons.org/licenses/by/2.5/",
576 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/", 607 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/",
577 })->{$meta->{license}} 608 })->{$meta->{license}}
578 || warn "$dir/$file: license tag '$meta->{license}' not found."; 609 || warn "$dir/$file: license tag '$meta->{license}' not found.";
610 }
611
612 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) {
613 ($meta->{author} = $1) =~ s/_/ /g;
579 } 614 }
580 615
581 $file =~ s/\.res$//; 616 $file =~ s/\.res$//;
582 $file =~ s/\.(ogg|wav|jpg|png)$//; 617 $file =~ s/\.(ogg|wav|jpg|png)$//;
583 618
796 if (my $magicmap = $v->{magicmap}) { 831 if (my $magicmap = $v->{magicmap}) {
797 $magicmap =~ y/A-Z_\-/a-z/d; 832 $magicmap =~ y/A-Z_\-/a-z/d;
798 $v->{magicmap} = $COLOR{$magicmap}; 833 $v->{magicmap} = $COLOR{$magicmap};
799 } 834 }
800 835
836 my $stem = delete $v->{stem};
837 $v->{glyph} //= autoglyph $stem, $v;
838 utf8::encode $v->{glyph};
839 $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph};
840
801 delete $v->{arc}; 841 delete $v->{arc};
802 } 842 }
803 843
804 print "processing resources...\n" if $VERBOSE; 844 print "processing resources...\n" if $VERBOSE;
805 my $enc = JSON::XS->new->utf8->canonical->relaxed; 845 my $enc = JSON::XS->new->utf8->canonical->relaxed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines