… | |
… | |
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 | |
|
|
161 | our @WALL_SUFFIX = qw(⬤ ╹ ╺ ┗ ╻ ┃ ┏ ┣ ╸ ┛ ━ ┻ ┓ ┫ ┳ ╋); |
|
|
162 | |
|
|
163 | # used to create crude text glyphs for text-based clients |
|
|
164 | sub 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\//) { |
|
|
177 | "☗" |
|
|
178 | |
|
|
179 | } elsif ($stem =~ /^weapon\//) { |
|
|
180 | "†" |
|
|
181 | |
|
|
182 | } elsif ($stem =~ /^readable\//) { |
|
|
183 | "✉" |
|
|
184 | |
|
|
185 | } elsif ($stem =~ /^river\//) { |
|
|
186 | "⌇" |
|
|
187 | |
|
|
188 | } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { |
|
|
189 | "." |
|
|
190 | |
|
|
191 | } elsif ($stem =~ /^player\//) { |
|
|
192 | "\@" |
|
|
193 | |
|
|
194 | } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) { |
|
|
195 | $1 |
|
|
196 | |
|
|
197 | } else { |
|
|
198 | substr $stem, 0, 1 |
|
|
199 | } |
|
|
200 | } |
|
|
201 | |
161 | { |
202 | { |
162 | our %ANIMINFO; |
203 | our %ANIMINFO; |
163 | our %FACEINFO; |
204 | our %FACEINFO; |
164 | our %RESOURCE; |
205 | our %RESOURCE; |
165 | our @ARC; |
206 | our @ARC; |
… | |
… | |
174 | our $c_trs = new Coro::Channel; |
215 | our $c_trs = new Coro::Channel; |
175 | our $c_res = new Coro::Channel; |
216 | our $c_res = new Coro::Channel; |
176 | |
217 | |
177 | our @c_png; |
218 | our @c_png; |
178 | |
219 | |
179 | sub commit_png($$$) { |
220 | sub commit_png($$$$) { |
180 | my ($name, $data, $T) = @_; |
221 | my ($stem, $name, $data, $T) = @_; |
181 | |
222 | |
|
|
223 | $FACEINFO{$name}{"stem"} = substr $stem, 1 + length $PATH; |
182 | $FACEINFO{$name}{"data$T"} = $data; |
224 | $FACEINFO{$name}{"data$T"} = $data; |
183 | } |
225 | } |
184 | |
226 | |
185 | sub process_png { |
227 | sub process_png { |
186 | while (@c_png) { |
228 | while (@c_png) { |
… | |
… | |
404 | |
446 | |
405 | if (0 > aio_load $file, $tile) { |
447 | if (0 > aio_load $file, $tile) { |
406 | die "$path: unable to read tile +$x+$y, aborting.\n"; |
448 | die "$path: unable to read tile +$x+$y, aborting.\n"; |
407 | } |
449 | } |
408 | IO::AIO::aio_unlink $file unless $CACHE; |
450 | IO::AIO::aio_unlink $file unless $CACHE; |
409 | commit_png $x|$y ? "$face+$x+$y" : $face, $tile, $T; |
451 | commit_png $stem, $x|$y ? "$face+$x+$y" : $face, $tile, $T; |
410 | } |
452 | } |
411 | } else { |
453 | } else { |
412 | # use as-is (either small, use smooth) |
454 | # use as-is (either small, use smooth) |
413 | commit_png $face, $png, $T; |
455 | commit_png $stem, $face, $png, $T; |
414 | } |
456 | } |
415 | |
457 | |
416 | aio_unlink $path if $delete; |
458 | aio_unlink $path if $delete; |
417 | } |
459 | } |
418 | } |
460 | } |
… | |
… | |
433 | |
475 | |
434 | $o->{editor_folder} ||= "\x00$dir"; # horrible kludge |
476 | $o->{editor_folder} ||= "\x00$dir"; # horrible kludge |
435 | |
477 | |
436 | my $visibility = delete $o->{visibility}; |
478 | my $visibility = delete $o->{visibility}; |
437 | my $magicmap = delete $o->{magicmap}; |
479 | my $magicmap = delete $o->{magicmap}; |
|
|
480 | my $glyph = delete $o->{glyph}; |
438 | |
481 | |
439 | # find upper left corner :/ |
482 | # find upper left corner :/ |
440 | # omg, this is sooo broken |
483 | # omg, this is sooo broken |
441 | my ($dx, $dy); |
484 | my ($dx, $dy); |
442 | for (my $o = $o; $o; $o = $o->{more}) { |
485 | for (my $o = $o; $o; $o = $o->{more}) { |
… | |
… | |
452 | |
495 | |
453 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
496 | $o->{face} .= $ext unless /^blank.x11$|^empty.x11$/ || !$o->{face}; |
454 | |
497 | |
455 | $visibility = delete $o->{visibility} if exists $o->{visibility}; |
498 | $visibility = delete $o->{visibility} if exists $o->{visibility}; |
456 | $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
499 | $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; |
|
|
500 | $glyph = delete $o->{glyph} if exists $o->{glyph}; |
457 | |
501 | |
458 | my $anim = delete $o->{anim}; |
502 | my $anim = delete $o->{anim}; |
459 | |
503 | |
460 | if ($anim) { |
504 | if ($anim) { |
461 | # possibly add $ext to the animation name to avoid |
505 | # possibly add $ext to the animation name to avoid |
… | |
… | |
492 | |
536 | |
493 | next if $face =~ /^blank.x11$|^empty.x11$/; |
537 | next if $face =~ /^blank.x11$|^empty.x11$/; |
494 | |
538 | |
495 | $info->{visibility} = $visibility if defined $visibility; |
539 | $info->{visibility} = $visibility if defined $visibility; |
496 | $info->{magicmap} = $magicmap if defined $magicmap; |
540 | $info->{magicmap} = $magicmap if defined $magicmap; |
|
|
541 | $info->{glyph} = $glyph if defined $glyph; |
497 | } |
542 | } |
498 | |
543 | |
499 | if (my $smooth = delete $o->{smoothface}) { |
544 | if (my $smooth = delete $o->{smoothface}) { |
500 | my %kv = split /\s+/, $smooth; |
545 | my %kv = split /\s+/, $smooth; |
501 | my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support |
546 | my $level = $o->{smoothlevel}; #TODO: delete from $o if !gcfclient-support |
… | |
… | |
801 | if (my $magicmap = $v->{magicmap}) { |
846 | if (my $magicmap = $v->{magicmap}) { |
802 | $magicmap =~ y/A-Z_\-/a-z/d; |
847 | $magicmap =~ y/A-Z_\-/a-z/d; |
803 | $v->{magicmap} = $COLOR{$magicmap}; |
848 | $v->{magicmap} = $COLOR{$magicmap}; |
804 | } |
849 | } |
805 | |
850 | |
|
|
851 | my $stem = delete $v->{stem}; |
|
|
852 | $v->{glyph} //= autoglyph $stem, $v; |
|
|
853 | utf8::encode $v->{glyph}; |
|
|
854 | $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph}; |
|
|
855 | |
806 | delete $v->{arc}; |
856 | delete $v->{arc}; |
807 | } |
857 | } |
808 | |
858 | |
809 | print "processing resources...\n" if $VERBOSE; |
859 | print "processing resources...\n" if $VERBOSE; |
810 | my $enc = JSON::XS->new->utf8->canonical->relaxed; |
860 | my $enc = JSON::XS->new->utf8->canonical->relaxed; |