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.84 by root, Tue May 4 22:49:21 2010 UTC vs.
Revision 1.101 by root, Wed Oct 6 18:22:47 2010 UTC

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 =~ /^traps\//) {
174 "☠"
175
176 } elsif ($stem =~ /^armour\/shield/) {
177 "Ø"
178
179 } elsif ($stem =~ /^armour\//) {
180 "A"
181
182 } elsif ($stem =~ /^weapon\//) {
183 "†"
184
185 } elsif ($stem =~ /^readable\//) {
186 "✉"
187
188 } elsif ($stem =~ /^river\//) {
189 "~"
190
191 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) {
192 "·"
193
194 } elsif ($stem =~ /^spells\//) {
195 "!"
196
197 } elsif ($stem =~ /^player\//) {
198 "\@"
199
200 } elsif ($stem =~ /^construct\//) {
201 "⌂"
202
203 } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) {
204 $1
205
206 } else {
207 substr $stem, 0, 1
208 }
209}
210
161{ 211{
162 our %ANIMINFO; 212 our %ANIMINFO;
163 our %FACEINFO; 213 our %FACEINFO;
164 our %RESOURCE; 214 our %RESOURCE;
165 our @ARC; 215 our @ARC;
174 our $c_trs = new Coro::Channel; 224 our $c_trs = new Coro::Channel;
175 our $c_res = new Coro::Channel; 225 our $c_res = new Coro::Channel;
176 226
177 our @c_png; 227 our @c_png;
178 228
179 sub commit_png($$$) { 229 sub commit_png($$$$) {
180 my ($name, $data, $T) = @_; 230 my ($stem, $name, $data, $T) = @_;
181 231
232 $FACEINFO{$name}{"stem"} = substr $stem, 1 + length $PATH;
182 $FACEINFO{$name}{"data$T"} = $data; 233 $FACEINFO{$name}{"data$T"} = $data;
183 } 234 }
184 235
185 sub process_png { 236 sub process_png {
186 while (@c_png) { 237 while (@c_png) {
404 455
405 if (0 > aio_load $file, $tile) { 456 if (0 > aio_load $file, $tile) {
406 die "$path: unable to read tile +$x+$y, aborting.\n"; 457 die "$path: unable to read tile +$x+$y, aborting.\n";
407 } 458 }
408 IO::AIO::aio_unlink $file unless $CACHE; 459 IO::AIO::aio_unlink $file unless $CACHE;
409 commit_png $x|$y ? "$face+$x+$y" : $face, $tile, $T; 460 commit_png $stem, $x|$y ? "$face+$x+$y" : $face, $tile, $T;
410 } 461 }
411 } else { 462 } else {
412 # use as-is (either small, use smooth) 463 # use as-is (either small, use smooth)
413 commit_png $face, $png, $T; 464 commit_png $stem, $face, $png, $T;
414 } 465 }
415 466
416 aio_unlink $path if $delete; 467 aio_unlink $path if $delete;
417 } 468 }
418 } 469 }
433 484
434 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge 485 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge
435 486
436 my $visibility = delete $o->{visibility}; 487 my $visibility = delete $o->{visibility};
437 my $magicmap = delete $o->{magicmap}; 488 my $magicmap = delete $o->{magicmap};
489 my $glyph = delete $o->{glyph};
438 490
439 # find upper left corner :/ 491 # find upper left corner :/
440 # omg, this is sooo broken 492 # omg, this is sooo broken
441 my ($dx, $dy); 493 my ($dx, $dy);
442 for (my $o = $o; $o; $o = $o->{more}) { 494 for (my $o = $o; $o; $o = $o->{more}) {
452 504
453 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 505 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
454 506
455 $visibility = delete $o->{visibility} if exists $o->{visibility}; 507 $visibility = delete $o->{visibility} if exists $o->{visibility};
456 $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 508 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
509 $glyph = delete $o->{glyph} if exists $o->{glyph};
457 510
458 my $anim = delete $o->{anim}; 511 my $anim = delete $o->{anim};
459 512
460 if ($anim) { 513 if ($anim) {
461 # possibly add $ext to the animation name to avoid 514 # possibly add $ext to the animation name to avoid
492 545
493 next if $face =~ /^blank.x11$|^empty.x11$/; 546 next if $face =~ /^blank.x11$|^empty.x11$/;
494 547
495 $info->{visibility} = $visibility if defined $visibility; 548 $info->{visibility} = $visibility if defined $visibility;
496 $info->{magicmap} = $magicmap if defined $magicmap; 549 $info->{magicmap} = $magicmap if defined $magicmap;
550 $info->{glyph} = $glyph if defined $glyph;
497 } 551 }
498 552
499 if (my $smooth = delete $o->{smoothface}) { 553 if (my $smooth = delete $o->{smoothface}) {
500 my %kv = split /\s+/, $smooth; 554 my %kv = split /\s+/, $smooth;
501 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support 555 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
570 if ($meta->{license} =~ s/^#//) { 624 if ($meta->{license} =~ s/^#//) {
571 $meta->{license} = ({ 625 $meta->{license} = ({
572 "pd" => "Public Domain", 626 "pd" => "Public Domain",
573 "gpl" => "GNU General Public License, version 3.0 or any later", 627 "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/", 628 "cc/by/2.0" => "Licensed under Creative Commons Attribution 2.0 http://creativecommons.org/licenses/by/2.0/",
629 "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/", 630 "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/", 631 "cc/by/3.0" => "Licensed under Creative Commons Attribution 3.0 http://creativecommons.org/licenses/by/3.0/",
577 })->{$meta->{license}} 632 })->{$meta->{license}}
578 || warn "$dir/$file: license tag '$meta->{license}' not found."; 633 || warn "$dir/$file: license tag '$meta->{license}' not found.";
634 }
635
636 if (!exists $meta->{author} && $meta->{source} =~ m%^http://www.jamendo.com/en/artist/(.*)$%) {
637 ($meta->{author} = $1) =~ s/_/ /g;
579 } 638 }
580 639
581 $file =~ s/\.res$//; 640 $file =~ s/\.res$//;
582 $file =~ s/\.(ogg|wav|jpg|png)$//; 641 $file =~ s/\.(ogg|wav|jpg|png)$//;
583 642
796 if (my $magicmap = $v->{magicmap}) { 855 if (my $magicmap = $v->{magicmap}) {
797 $magicmap =~ y/A-Z_\-/a-z/d; 856 $magicmap =~ y/A-Z_\-/a-z/d;
798 $v->{magicmap} = $COLOR{$magicmap}; 857 $v->{magicmap} = $COLOR{$magicmap};
799 } 858 }
800 859
860 my $stem = delete $v->{stem};
861 $v->{glyph} //= autoglyph $stem, $v;
862 utf8::encode $v->{glyph};
863 $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph};
864
801 delete $v->{arc}; 865 delete $v->{arc};
802 } 866 }
803 867
804 print "processing resources...\n" if $VERBOSE; 868 print "processing resources...\n" if $VERBOSE;
805 my $enc = JSON::XS->new->utf8->canonical->relaxed; 869 my $enc = JSON::XS->new->utf8->canonical->relaxed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines