… | |
… | |
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 |
161 | sub autoglyph { |
164 | sub autoglyph { |
162 | my ($stem, $face) = @_; |
165 | my ($stem, $face) = @_; |
163 | |
166 | |
164 | if ($stem =~ /^wall\/|Nimwall/) { |
167 | if ($stem =~ /^wall\/|Nimwall/) { |
165 | # warn $stem; |
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\//) { |
166 | "+" |
186 | "~" |
|
|
187 | |
167 | } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { |
188 | } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { |
168 | "." |
189 | "." |
|
|
190 | |
|
|
191 | } elsif ($stem =~ /^player\//) { |
|
|
192 | "\@" |
|
|
193 | |
|
|
194 | } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) { |
|
|
195 | $1 |
|
|
196 | |
169 | } else { |
197 | } else { |
170 | substr $stem, 0, 1 |
198 | substr $stem, 0, 1 |
171 | } |
199 | } |
172 | } |
200 | } |
173 | |
201 | |
… | |
… | |
813 | make_hash $k, $v->{data64}, $v->{hash64}; |
841 | make_hash $k, $v->{data64}, $v->{hash64}; |
814 | |
842 | |
815 | #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
843 | #length $v->{data32} <= 10000 or warn "$k: face32 larger than 10000 bytes, will not work with crossfire client.\n"; |
816 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
844 | #length $v->{data64} <= 10000 or warn "$k: face64 larger than 10000 bytes.\n"; |
817 | |
845 | |
818 | my $stem = delete $v->{stem}; |
|
|
819 | $v->{glyph} //= autoglyph $stem, $v; |
|
|
820 | |
|
|
821 | if (my $magicmap = $v->{magicmap}) { |
846 | if (my $magicmap = $v->{magicmap}) { |
822 | $magicmap =~ y/A-Z_\-/a-z/d; |
847 | $magicmap =~ y/A-Z_\-/a-z/d; |
823 | $v->{magicmap} = $COLOR{$magicmap}; |
848 | $v->{magicmap} = $COLOR{$magicmap}; |
824 | } |
849 | } |
|
|
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}; |
825 | |
855 | |
826 | delete $v->{arc}; |
856 | delete $v->{arc}; |
827 | } |
857 | } |
828 | |
858 | |
829 | print "processing resources...\n" if $VERBOSE; |
859 | print "processing resources...\n" if $VERBOSE; |