Changeset - r17001:81ef59232a25
[Not reviewed]
master
0 1 0
rubidium - 13 years ago 2011-01-09 14:55:22
rubidium@openttd.org
(svn r21747) -Fix [FS#4395]: the diagonal iterator would iterate twice over some tiles (fonsinchen)
1 file changed with 11 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/tilearea.cpp
Show inline comments
 
@@ -139,15 +139,22 @@ TileIterator &DiagonalTileIterator::oper
 
{
 
	assert(this->tile != INVALID_TILE);
 

	
 
	bool new_line = false;
 
	do {
 
		/* Iterate using the rotated coordinates. */
 
		if (this->a_max > 0) {
 
			++this->a_cur;
 
			this->a_cur += 2;
 
			new_line = this->a_cur >= this->a_max;
 
		} else {
 
			--this->a_cur;
 
			this->a_cur -= 2;
 
			new_line = this->a_cur <= this->a_max;
 
		}
 
		if (this->a_cur == this->a_max) {
 
			this->a_cur = 0;
 
		if (new_line) {
 
			/* offset of initial a_cur: one tile in the same direction as a_max
 
			 * every second line.
 
			 */
 
			this->a_cur = abs(this->a_cur) % 2 ? 0 : (this->a_max > 0 ? 1 : -1);
 

	
 
			if (this->b_max > 0) {
 
				++this->b_cur;
 
			} else {
0 comments (0 inline, 0 general)