--- deliantra/server/utils/cfutil.in 2010/05/14 22:56:47 1.85 +++ deliantra/server/utils/cfutil.in 2010/10/06 03:20:19 1.99 @@ -108,7 +108,7 @@ my $hash = substr +(Digest::MD5::md5 $$dataref), 0, $clen || 4; if (exists $hash{$hash}) { - # hahs collinion, but some files are simply identical + # hash collision, but some files are simply identical if (${$hash{$hash}[1]} ne $$dataref) { warn "hash collision $hash{$hash}[0] vs. $id\n"; exit 1; @@ -158,6 +158,47 @@ print "maps installed successfully.\n"; } +our @WALL_SUFFIX = qw(⬤ ╹ ╺ ┗ ╻ ┃ ┏ ┣ ╸ ┛ ━ ┻ ┓ ┫ ┳ ╋); + +# used to create crude text glyphs for text-based clients +sub autoglyph { + my ($stem, $face) = @_; + + if ($stem =~ /^wall\/|Nimwall/) { + return $WALL_SUFFIX[hex $1] + if $stem =~ /(_[0-9A-F]).x11/; + + "█" + + } elsif ($stem =~ /^traps\//) { + "☠" + + } elsif ($stem =~ /^armour\//) { + "☗" + + } elsif ($stem =~ /^weapon\//) { + "†" + + } elsif ($stem =~ /^readable\//) { + "✉" + + } elsif ($stem =~ /^river\//) { + "~" + + } elsif ($stem =~ /^floor\/|^ground\/|Nimfloor/) { + "." + + } elsif ($stem =~ /^player\//) { + "\@" + + } elsif ($stem =~ /^(?:monster|misc|class|connect|gods|indoor|inorganic|mining|music|skills).*\/(.)/) { + $1 + + } else { + substr $stem, 0, 1 + } +} + { our %ANIMINFO; our %FACEINFO; @@ -176,9 +217,10 @@ our @c_png; - sub commit_png($$$) { - my ($name, $data, $T) = @_; + sub commit_png($$$$) { + my ($stem, $name, $data, $T) = @_; + $FACEINFO{$name}{"stem"} = substr $stem, 1 + length $PATH; $FACEINFO{$name}{"data$T"} = $data; } @@ -406,11 +448,11 @@ die "$path: unable to read tile +$x+$y, aborting.\n"; } IO::AIO::aio_unlink $file unless $CACHE; - commit_png $x|$y ? "$face+$x+$y" : $face, $tile, $T; + commit_png $stem, $x|$y ? "$face+$x+$y" : $face, $tile, $T; } } else { # use as-is (either small, use smooth) - commit_png $face, $png, $T; + commit_png $stem, $face, $png, $T; } aio_unlink $path if $delete; @@ -435,6 +477,7 @@ my $visibility = delete $o->{visibility}; my $magicmap = delete $o->{magicmap}; + my $glyph = delete $o->{glyph}; # find upper left corner :/ # omg, this is sooo broken @@ -454,6 +497,7 @@ $visibility = delete $o->{visibility} if exists $o->{visibility}; $magicmap = delete $o->{magicmap} if exists $o->{magicmap}; + $glyph = delete $o->{glyph} if exists $o->{glyph}; my $anim = delete $o->{anim}; @@ -494,6 +538,7 @@ $info->{visibility} = $visibility if defined $visibility; $info->{magicmap} = $magicmap if defined $magicmap; + $info->{glyph} = $glyph if defined $glyph; } if (my $smooth = delete $o->{smoothface}) { @@ -803,6 +848,11 @@ $v->{magicmap} = $COLOR{$magicmap}; } + my $stem = delete $v->{stem}; + $v->{glyph} //= autoglyph $stem, $v; + utf8::encode $v->{glyph}; + $v->{glyph} = (chr $v->{magicmap}) . $v->{glyph}; + delete $v->{arc}; }