summaryrefslogtreecommitdiff
path: root/src/tilearea_type.h
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-12-13 15:13:05 +0000
committerrubidium <rubidium@openttd.org>2010-12-13 15:13:05 +0000
commitb20e77be921acc32b5887f9f35ecae8573c588af (patch)
treeab5efe19852fb742a511f9b386f5547875dc5996 /src/tilearea_type.h
parent652e2626010c3cc1a92875ccbaeed61233b1d6fc (diff)
downloadopenttd-b20e77be921acc32b5887f9f35ecae8573c588af.tar.xz
(svn r21499) -Add: diagonal tile iterator. Based on patch by fonsinchen
Diffstat (limited to 'src/tilearea_type.h')
-rw-r--r--src/tilearea_type.h24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/tilearea_type.h b/src/tilearea_type.h
index 44a2ba3c2..23813eeb8 100644
--- a/src/tilearea_type.h
+++ b/src/tilearea_type.h
@@ -73,11 +73,12 @@ protected:
{
}
+public:
/** Some compilers really like this. */
virtual ~TileIterator()
{
}
-public:
+
/**
* Get the tile we are currently at.
* @return The tile we are at, or INVALID_TILE when we're done.
@@ -128,6 +129,27 @@ public:
}
};
+/** Iterator to iterate over a diagonal area of the map. */
+class DiagonalTileIterator : public TileIterator {
+private:
+ uint base_x, base_y; ///< The base tile x and y coordinates from where the iterating happens.
+ int a_cur, b_cur; ///< The current (rotated) x and y coordinates of the iteration.
+ int a_max, b_max; ///< The (rotated) x and y coordinates of the end of the iteration.
+
+public:
+ /**
+ * Construct the iterator.
+ * @param begin Tile from where to begin iterating.
+ * @param end Tile where to end the iterating.
+ */
+ DiagonalTileIterator(TileIndex begin, TileIndex end);
+
+ /**
+ * Move ourselves to the next tile in the rectange on the map.
+ */
+ TileIterator& operator ++();
+};
+
/**
* A loop which iterates over the tiles of a TileArea.
* @param var The name of the variable which contains the current tile.