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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines