mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r21747) -Fix [FS#4395]: the diagonal iterator would iterate twice over some tiles (fonsinchen)
This commit is contained in:
parent
814a46aa38
commit
debc98e4ac
@ -139,15 +139,22 @@ TileIterator &DiagonalTileIterator::operator++()
|
|||||||
{
|
{
|
||||||
assert(this->tile != INVALID_TILE);
|
assert(this->tile != INVALID_TILE);
|
||||||
|
|
||||||
|
bool new_line = false;
|
||||||
do {
|
do {
|
||||||
/* Iterate using the rotated coordinates. */
|
/* Iterate using the rotated coordinates. */
|
||||||
if (this->a_max > 0) {
|
if (this->a_max > 0) {
|
||||||
++this->a_cur;
|
this->a_cur += 2;
|
||||||
|
new_line = this->a_cur >= this->a_max;
|
||||||
} else {
|
} else {
|
||||||
--this->a_cur;
|
this->a_cur -= 2;
|
||||||
|
new_line = this->a_cur <= this->a_max;
|
||||||
}
|
}
|
||||||
if (this->a_cur == this->a_max) {
|
if (new_line) {
|
||||||
this->a_cur = 0;
|
/* 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) {
|
if (this->b_max > 0) {
|
||||||
++this->b_cur;
|
++this->b_cur;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user