Mercurial > hg > openttd
changeset 17011:559fd62df6d2 draft
(svn r21747) -Fix [FS#4395]: the diagonal iterator would iterate twice over some tiles (fonsinchen)
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sun, 09 Jan 2011 14:55:22 +0000 |
parents | df13cc59e779 |
children | 2ec77aad1b52 |
files | src/tilearea.cpp |
diffstat | 1 files changed, 11 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tilearea.cpp +++ b/src/tilearea.cpp @@ -139,15 +139,22 @@ { 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 {