Iterator to iterate over all tiles belonging to a bitmaptilearea. */
| 104 | |
| 105 | /** Iterator to iterate over all tiles belonging to a bitmaptilearea. */ |
| 106 | class BitmapTileIterator : public OrthogonalTileIterator { |
| 107 | protected: |
| 108 | const BitmapTileArea *bitmap; |
| 109 | public: |
| 110 | /** |
| 111 | * Construct the iterator. |
| 112 | * @param bitmap BitmapTileArea to iterate. |
| 113 | */ |
| 114 | BitmapTileIterator(const BitmapTileArea &bitmap) : OrthogonalTileIterator(bitmap), bitmap(&bitmap) |
| 115 | { |
| 116 | if (!this->bitmap->HasTile(TileIndex(this->tile))) ++(*this); |
| 117 | } |
| 118 | |
| 119 | inline TileIterator& operator ++() override |
| 120 | { |
| 121 | this->OrthogonalTileIterator::operator++(); |
| 122 | while (this->tile != INVALID_TILE && !this->bitmap->HasTile(TileIndex(this->tile))) { |
| 123 | this->OrthogonalTileIterator::operator++(); |
| 124 | } |
| 125 | return *this; |
| 126 | } |
| 127 | |
| 128 | std::unique_ptr<TileIterator> Clone() const override |
| 129 | { |
| 130 | return std::make_unique<BitmapTileIterator>(*this); |
| 131 | } |
| 132 | }; |
| 133 | |
| 134 | #endif /* BITMAP_TYPE_HPP */ |