ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/Deliantra/Map.pm
(Generate patch)

Comparing deliantra/Deliantra/Deliantra/Map.pm (file contents):
Revision 1.4 by root, Sat Feb 11 16:17:14 2006 UTC vs.
Revision 1.5 by root, Sun Feb 12 04:50:24 2006 UTC

73 # overall placement coords 73 # overall placement coords
74 my $x = 0; 74 my $x = 0;
75 my $y = 0; 75 my $y = 0;
76 76
77 my ($maxh, $maxw) = (0, 0); # maximum sizes, to set map width/height later 77 my ($maxh, $maxw) = (0, 0); # maximum sizes, to set map width/height later
78 my $drawn_archs = 1; # line-break counter
79 my $max_line_height = 1; 78 my $max_line_height = 1;
80 79
81 for (my $i = 0; $i < $num; $i++) { 80 for (my $i = 0; $i < $num; $i++) {
82 defined ${$archs->[$i]}->{face} or next; 81 defined ${$archs->[$i]}->{face} or next;
83 82
84 # check whether this tile was already written (see below at (b)) 83 # check whether this tile was already written (see below at (b))
85 unless (defined $map->{map}[$x][$y]) { 84 unless (defined $map->{map}[$x][$y]) {
86 my ($xoffs, $yoffs, $arch_w, $arch_h) = arch_extends (${$archs->[$i]}); 85 my ($x1, $y1, $x2, $y2) = arch_extents ${$archs->[$i]};
87 86
88 if ($x + $arch_w > $width) { 87 if ($x + $x2 - $x1 + 1 > $width) {
89 $y += $max_line_height; 88 $y += $max_line_height;
90 $max_line_height = 1; 89 $max_line_height = 1;
91 $x = 0; 90 $x = 0;
92 } 91 }
93 92
94 # these are special placement coords, for chained faces which 93 $map->{map}[$x - $x1][$y - $y1] = [${$archs->[$i]}];
95 # have a special placement offset
96 my ($place_x, $place_y) = ($x, $y);
97 $xoffs < 0 and
98 $place_x += -$xoffs;
99 $yoffs < 0 and
100 $place_y += -$yoffs;
101 94
102 # iterate over the tiles this arch takes 95 $x += $x2 - $x1 + 1;
103 # NOTE: Chained archs are maybe not a rectangle, but i don't care
104 # much for that on pickmaps
105 96
106 for (my $xi = 0; $xi < $arch_w; $xi++) { 97 $max_line_height = List::Util::max $max_line_height, $y2 - $y1 + 1;
107 for (my $yi = 0; $yi < $arch_h; $yi++) {
108
109 my ($lx, $ly) = ($x + $xi, $y + $yi);
110
111 if ($lx == $place_x and $ly == $place_y) {
112 push @{$map->{map}[$place_x][$place_y]}, my $a = ${$archs->[$i]};
113
114 } else {
115
116 # (b): here we set occupied tiles, but without the arch
117 $map->{map}[$lx][$ly] = [];
118 }
119 }
120 }
121 $drawn_archs++;
122
123 $x += $arch_w;
124
125 $max_line_height < $arch_h
126 and $max_line_height = $arch_h;
127 98
128 } else { 99 } else {
129 $i--; 100 $i--;
130 } 101 }
131 102

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines