Import combined Enhanced viewport: zoom out, overlays & tooltips (r53_27127) patch
https://www.tt-forums.net/viewtopic.php?f=33&t=53394
This commit is contained in:

committed by
Jonathan G Rennison

parent
fd3388467f
commit
536a95dfd0
@@ -12,6 +12,8 @@
|
||||
#ifndef TILEAREA_TYPE_H
|
||||
#define TILEAREA_TYPE_H
|
||||
|
||||
#include "stdafx.h"
|
||||
#include INCLUDE_FOR_PREFETCH_NTA
|
||||
#include "map_func.h"
|
||||
|
||||
/** Represents the covered area of e.g. a rail station */
|
||||
@@ -184,6 +186,65 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/** Iterator to iterate over a tile area (rectangle) of the map.
|
||||
* It prefetches tiles once per row.
|
||||
*/
|
||||
class OrthogonalPrefetchTileIterator {
|
||||
private:
|
||||
TileIndex tile; ///< The current tile we are at.
|
||||
int w; ///< The width of the iterated area.
|
||||
int x; ///< The current 'x' position in the rectangle.
|
||||
int y; ///< The current 'y' position in the rectangle.
|
||||
|
||||
public:
|
||||
/**
|
||||
* Construct the iterator.
|
||||
* @param ta Area, i.e. begin point and width/height of to-be-iterated area.
|
||||
*/
|
||||
OrthogonalPrefetchTileIterator(const TileArea &ta) : tile(ta.w == 0 || ta.h == 0 ? INVALID_TILE : ta.tile), w(ta.w), x(ta.w), y(ta.h)
|
||||
{
|
||||
PREFETCH_NTA(&_m[ta.tile]);
|
||||
}
|
||||
|
||||
/** Some compilers really like this. */
|
||||
virtual ~OrthogonalPrefetchTileIterator()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile we are currently at.
|
||||
* @return The tile we are at, or INVALID_TILE when we're done.
|
||||
*/
|
||||
inline operator TileIndex () const
|
||||
{
|
||||
return this->tile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move ourselves to the next tile in the rectangle on the map.
|
||||
*/
|
||||
inline OrthogonalPrefetchTileIterator& operator ++()
|
||||
{
|
||||
assert(this->tile != INVALID_TILE);
|
||||
|
||||
if (--this->x > 0) {
|
||||
this->tile++;
|
||||
} else if (--this->y > 0) {
|
||||
this->x = this->w;
|
||||
this->tile += TileDiffXY(1, 1) - this->w;
|
||||
PREFETCH_NTA(&_m[tile]);
|
||||
} else {
|
||||
this->tile = INVALID_TILE;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual OrthogonalPrefetchTileIterator *Clone() const
|
||||
{
|
||||
return new OrthogonalPrefetchTileIterator(*this);
|
||||
}
|
||||
};
|
||||
|
||||
/** Iterator to iterate over a diagonal area of the map. */
|
||||
class DiagonalTileIterator : public TileIterator {
|
||||
private:
|
||||
@@ -230,5 +291,6 @@ public:
|
||||
* @param ta The tile area to search over.
|
||||
*/
|
||||
#define TILE_AREA_LOOP(var, ta) for (OrthogonalTileIterator var(ta); var != INVALID_TILE; ++var)
|
||||
#define TILE_AREA_LOOP_WITH_PREFETCH(var, ta) for (OrthogonalPrefetchTileIterator var(ta); var != INVALID_TILE; ++var)
|
||||
|
||||
#endif /* TILEAREA_TYPE_H */
|
||||
|
Reference in New Issue
Block a user