… | |
… | |
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; |
… | |
… | |
157 | |
157 | |
158 | print "maps installed successfully.\n"; |
158 | print "maps installed successfully.\n"; |
159 | } |
159 | } |
160 | |
160 | |
161 | our %WALL_SUFFIX = ( |
161 | our %WALL_SUFFIX = ( |
162 | "0" => "⬤", |
162 | "_0" => "⬤", |
163 | "1_3" => "╸", |
163 | "_1_3" => "╸", |
164 | "1_4" => "╺", |
164 | "_1_4" => "╺", |
165 | "2_1_2" => "━", |
165 | "_2_1_2" => "━", |
166 | |
166 | |
167 | "1_2" => "╹", |
167 | "_1_2" => "╹", |
168 | "2_2_4" => "┛", |
168 | "_2_2_4" => "┛", |
169 | "2_2_1" => "┗", |
169 | "_2_2_1" => "┗", |
170 | "3_1" => "┻", |
170 | "_3_1" => "┻", |
171 | |
171 | |
172 | "1_1" => "╻", |
172 | "_1_1" => "╻", |
173 | "2_2_3" => "┓", |
173 | "_2_2_3" => "┓", |
174 | "2_2_2" => "┏", |
174 | "_2_2_2" => "┏", |
175 | "3_3" => "┳", |
175 | "_3_3" => "┳", |
176 | |
176 | |
177 | "2_1_1" => "┃", |
177 | "_2_1_1" => "┃", |
178 | "3_4" => "┫", |
178 | "_3_4" => "┫", |
179 | "3_2" => "┣", |
179 | "_3_2" => "┣", |
180 | "4" => "╋", |
180 | "_4" => "╋", |
181 | ); |
181 | ); |
182 | |
182 | |
183 | sub autoglyph { |
183 | sub autoglyph { |
184 | my ($stem, $face) = @_; |
184 | my ($stem, $face) = @_; |
185 | |
185 | |
186 | if ($stem =~ /^wall\/|Nimwall/) { |
186 | if ($stem =~ /^wall\/|Nimwall/) { |
187 | while (my ($k, $v) = each %WALL_SUFFIX) { |
187 | if ($stem =~ /((?:_[0-4])+).x11/) { |
188 | return $v if $stem =~ /_$k.x11/; |
188 | return $WALL_SUFFIX{$1} if exists $WALL_SUFFIX{$1}; |
189 | } |
189 | } |
190 | |
190 | |
191 | "+" |
191 | "+" |
192 | |
192 | |
193 | } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { |
193 | } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { |
… | |
… | |
843 | make_hash $k, $v->{data64}, $v->{hash64}; |
843 | make_hash $k, $v->{data64}, $v->{hash64}; |
844 | |
844 | |
845 | #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
845 | #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
846 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
846 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
847 | |
847 | |
848 | my $stem = delete $v->{stem}; |
|
|
849 | $v->{glyph} //= autoglyph $stem, $v; |
|
|
850 | |
|
|
851 | if (my $magicmap = $v->{magicmap}) { |
848 | if (my $magicmap = $v->{magicmap}) { |
852 | $magicmap =~ y/A-Z_\-/a-z/d; |
849 | $magicmap =~ y/A-Z_\-/a-z/d; |
853 | $v->{magicmap} = $COLOR{$magicmap}; |
850 | $v->{magicmap} = $COLOR{$magicmap}; |
854 | } |
851 | } |
|
|
852 | |
|
|
853 | my $stem = delete $v->{stem}; |
|
|
854 | $v->{glyph} //= autoglyph $stem, $v; |
|
|
855 | utf8::encode $v->{glyph}; |
|
|
856 | $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph}; |
855 | |
857 | |
856 | delete $v->{arc}; |
858 | delete $v->{arc}; |
857 | } |
859 | } |
858 | |
860 | |
859 | print "processing resources...\n" if $VERBOSE; |
861 | print "processing resources...\n" if $VERBOSE; |