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.85 by root, Fri May 14 22:56:47 2010 UTC vs.
Revision 1.95 by root, Wed Oct 6 00:19:32 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
163sub autoglyph {
164 my ($stem, $face) = @_;
165
166 if ($stem =~ /^wall\/|Nimwall/) {
167 return $WALL_SUFFIX[hex $1]
168 if $stem =~ /(_[0-9A-F]).x11/;
169
170 "+"
171
172 } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) {
173 "."
174
175 } elsif ($stem =~ /^player\//) {
176 "\@"
177
178 } else {
179 substr $stem, 0, 1
180 }
181}
182
161{ 183{
162 our %ANIMINFO; 184 our %ANIMINFO;
163 our %FACEINFO; 185 our %FACEINFO;
164 our %RESOURCE; 186 our %RESOURCE;
165 our @ARC; 187 our @ARC;
174 our $c_trs = new Coro::Channel; 196 our $c_trs = new Coro::Channel;
175 our $c_res = new Coro::Channel; 197 our $c_res = new Coro::Channel;
176 198
177 our @c_png; 199 our @c_png;
178 200
179 sub commit_png($$$) { 201 sub commit_png($$$$) {
180 my ($name, $data, $T) = @_; 202 my ($stem, $name, $data, $T) = @_;
181 203
204 $FACEINFO{$name}{"stem"} = substr $stem, 1 + length $PATH;
182 $FACEINFO{$name}{"data$T"} = $data; 205 $FACEINFO{$name}{"data$T"} = $data;
183 } 206 }
184 207
185 sub process_png { 208 sub process_png {
186 while (@c_png) { 209 while (@c_png) {
404 427
405 if (0 > aio_load $file, $tile) { 428 if (0 > aio_load $file, $tile) {
406 die "$path: unable to read tile +$x+$y, aborting.\n"; 429 die "$path: unable to read tile +$x+$y, aborting.\n";
407 } 430 }
408 IO::AIO::aio_unlink $file unless $CACHE; 431 IO::AIO::aio_unlink $file unless $CACHE;
409 commit_png $x|$y ? "$face+$x+$y" : $face, $tile, $T; 432 commit_png $stem, $x|$y ? "$face+$x+$y" : $face, $tile, $T;
410 } 433 }
411 } else { 434 } else {
412 # use as-is (either small, use smooth) 435 # use as-is (either small, use smooth)
413 commit_png $face, $png, $T; 436 commit_png $stem, $face, $png, $T;
414 } 437 }
415 438
416 aio_unlink $path if $delete; 439 aio_unlink $path if $delete;
417 } 440 }
418 } 441 }
433 456
434 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge 457 $o->{editor_folder} ||= "\x00$dir"; # horrible kludge
435 458
436 my $visibility = delete $o->{visibility}; 459 my $visibility = delete $o->{visibility};
437 my $magicmap = delete $o->{magicmap}; 460 my $magicmap = delete $o->{magicmap};
461 my $glyph = delete $o->{glyph};
438 462
439 # find upper left corner :/ 463 # find upper left corner :/
440 # omg, this is sooo broken 464 # omg, this is sooo broken
441 my ($dx, $dy); 465 my ($dx, $dy);
442 for (my $o = $o; $o; $o = $o->{more}) { 466 for (my $o = $o; $o; $o = $o->{more}) {
452 476
453 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; 477 $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face};
454 478
455 $visibility = delete $o->{visibility} if exists $o->{visibility}; 479 $visibility = delete $o->{visibility} if exists $o->{visibility};
456 $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; 480 $magicmap = delete $o->{magicmap} if exists $o->{magicmap};
481 $glyph = delete $o->{glyph} if exists $o->{glyph};
457 482
458 my $anim = delete $o->{anim}; 483 my $anim = delete $o->{anim};
459 484
460 if ($anim) { 485 if ($anim) {
461 # possibly add $ext to the animation name to avoid 486 # possibly add $ext to the animation name to avoid
492 517
493 next if $face =~ /^blank.x11$|^empty.x11$/; 518 next if $face =~ /^blank.x11$|^empty.x11$/;
494 519
495 $info->{visibility} = $visibility if defined $visibility; 520 $info->{visibility} = $visibility if defined $visibility;
496 $info->{magicmap} = $magicmap if defined $magicmap; 521 $info->{magicmap} = $magicmap if defined $magicmap;
522 $info->{glyph} = $glyph if defined $glyph;
497 } 523 }
498 524
499 if (my $smooth = delete $o->{smoothface}) { 525 if (my $smooth = delete $o->{smoothface}) {
500 my %kv = split /\s+/, $smooth; 526 my %kv = split /\s+/, $smooth;
501 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support 527 my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support
801 if (my $magicmap = $v->{magicmap}) { 827 if (my $magicmap = $v->{magicmap}) {
802 $magicmap =~ y/A-Z_\-/a-z/d; 828 $magicmap =~ y/A-Z_\-/a-z/d;
803 $v->{magicmap} = $COLOR{$magicmap}; 829 $v->{magicmap} = $COLOR{$magicmap};
804 } 830 }
805 831
832 my $stem = delete $v->{stem};
833 $v->{glyph} //= autoglyph $stem, $v;
834 utf8::encode $v->{glyph};
835 $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph};
836
806 delete $v->{arc}; 837 delete $v->{arc};
807 } 838 }
808 839
809 print "processing resources...\n" if $VERBOSE; 840 print "processing resources...\n" if $VERBOSE;
810 my $enc = JSON::XS->new->utf8->canonical->relaxed; 841 my $enc = JSON::XS->new->utf8->canonical->relaxed;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines