--- deliantra/Deliantra/Deliantra.pm 2006/02/07 14:30:08 1.11 +++ deliantra/Deliantra/Deliantra.pm 2006/02/09 19:59:29 1.12 @@ -17,8 +17,8 @@ #XXX: The map_* procedures scream for a map-object our @EXPORT = - qw(read_pak read_arch arch2map $ARCH TILESIZE editor_archs - arch2pickmap arch_extends + qw(read_pak read_arch $ARCH TILESIZE editor_archs + arch_extends map_get_tile_stack map_push_tile_stack map_pop_tile_stack ); @@ -221,125 +221,6 @@ } } -# arch2pickmap forms a list of archs to a pickmap -sub arch2pickmap { - my ($archs, $w) = @_; - - # sort archs alphabetiacally - my $archs = [ sort { ${$a}->{_name} cmp ${$b}->{_name} } @$archs ]; - - $w ||= 10; # default width - my $num = @$archs; - my $map = { }; - # overall placement coords - my $x = 0; - my $y = 0; - - my ($maxh, $maxw) = (0, 0); # maximum sizes, to set map width/height later - my $drawn_archs = 1; # line-break counter - my $max_line_height = 1; - - for (my $i = 0; $i < $num; $i++) { - - defined ${$archs->[$i]}->{face} or next; - - # check whether this tile was already written (see below at (b)) - unless (defined $map->{map}[$x][$y]) { - - my ($xoffs, $yoffs, $arch_w, $arch_h) = arch_extends (${$archs->[$i]}); - - # these are special placement coords, for chained faces which - # have a special placement offset - my ($place_x, $place_y) = ($x, $y); - $xoffs < 0 and - $place_x += -$xoffs; - $yoffs < 0 and - $place_y += -$yoffs; - - # iterate over the tiles this arch takes - # NOTE: Chained archs are maybe not a rectangle, but i don't care - # much for that on pickmaps - - for (my $xi = 0; $xi < $arch_w; $xi++) { - for (my $yi = 0; $yi < $arch_h; $yi++) { - - my ($lx, $ly) = ($x + $xi, $y + $yi); - - if ($lx == $place_x and $ly == $place_y) { - push @{$map->{map}[$place_x][$place_y]}, my $a = ${$archs->[$i]}; - - } else { - - # (b): here we set occupied tiles, but without the arch - $map->{map}[$lx][$ly] = []; - } - } - } - $drawn_archs++; - - $x += $arch_w - 1; - $max_line_height < $arch_h - and $max_line_height = $arch_h; - - } else { - $i--; - } - - - $x++; - - if ($x > $w) { - - $y += $max_line_height; - $max_line_height = 1; - $x = 0; - } - - $maxw < ($x + 1) and $maxw = $x + 1; - $maxh < ($y + 1) and $maxh = $y + 1; - } - - $map->{height} = $maxh; - $map->{width} = $maxw; - - return $map; -} - -sub arch2map($;$) { - my ($mapa) = @_; - - my %meta; - - my ($mapx, $mapy); - - my $map; - - for (@{ $mapa->{arch} }) { - my ($x, $y) = (delete $_->{x}, delete $_->{y}); - - if ($_->{_name} eq "map") { - $meta{info} = $_; - - $mapx = $_->{width} || $x; - $mapy = $_->{height} || $y; - } else { - push @{ $map->[$x][$y] }, $_; - - # arch map is unreliable w.r.t. width and height - $mapx = $x + 1 if $mapx <= $x; - $mapy = $y + 1 if $mapy <= $y; - #$mapx = $a->{x} + 1, warn "$mapname: arch '$a->{_name}' outside map width at ($a->{x}|$a->{y})\n" if $mapx <= $a->{x}; - #$mapy = $a->{y} + 1, warn "$mapname: arch '$a->{_name}' outside map height at ($a->{x}|$a->{y})\n" if $mapy <= $a->{y}; - } - } - - $meta{width} = $mapx; - $meta{height} = $mapy; - $meta{map} = $map; - - \%meta -} - sub init($) { my ($cachedir) = @_;