(svn r21768) -Fix [FS#4396]: Diagonal tile iterator needed a special case for A * 0 selections.

This commit is contained in:
frosch 2011-01-11 16:45:45 +00:00
parent 7e6ccf3a0a
commit 12b4fa7dba
1 changed files with 27 additions and 15 deletions

View File

@ -139,9 +139,20 @@ TileIterator &DiagonalTileIterator::operator++()
{
assert(this->tile != INVALID_TILE);
/* Determine the next tile, while clipping at map borders */
bool new_line = false;
do {
/* Iterate using the rotated coordinates. */
if (this->a_max == 1 || this->a_max == -1) {
/* Special case: Every second column has zero length, skip them completely */
this->a_cur = 0;
if (this->b_max > 0) {
this->b_cur = min(this->b_cur + 2, this->b_max);
} else {
this->b_cur = max(this->b_cur - 2, this->b_max);
}
} else {
/* Every column has at least one tile to process */
if (this->a_max > 0) {
this->a_cur += 2;
new_line = this->a_cur >= this->a_max;
@ -161,6 +172,7 @@ TileIterator &DiagonalTileIterator::operator++()
--this->b_cur;
}
}
}
/* And convert the coordinates back once we've gone to the next tile. */
uint x = this->base_x + (this->a_cur - this->b_cur) / 2;