mirror of https://github.com/OpenRCT2/OpenRCT2.git
Extract base CoordsRange class from MapRange
Enforce MapRange to be rectangle shaped
This commit is contained in:
parent
c472a763a6
commit
701f7f6d67
|
@ -610,12 +610,12 @@ struct TileCoordsXYZD : public TileCoordsXYZ
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a rectangular range of the map using regular coordinates (32 per tile).
|
* Represents a range of the map using regular coordinates.
|
||||||
*/
|
*/
|
||||||
struct MapRange
|
template<class T> struct CoordsRange
|
||||||
{
|
{
|
||||||
CoordsXY LeftTop;
|
T LeftTop{ 0, 0 };
|
||||||
CoordsXY RightBottom;
|
T RightBottom{ 0, 0 };
|
||||||
|
|
||||||
int32_t GetLeft() const
|
int32_t GetLeft() const
|
||||||
{
|
{
|
||||||
|
@ -634,16 +634,29 @@ struct MapRange
|
||||||
return RightBottom.y;
|
return RightBottom.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapRange()
|
CoordsRange() = default;
|
||||||
: MapRange(0, 0, 0, 0)
|
CoordsRange(int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||||
{
|
|
||||||
}
|
|
||||||
MapRange(int32_t left, int32_t top, int32_t right, int32_t bottom)
|
|
||||||
: LeftTop(left, top)
|
: LeftTop(left, top)
|
||||||
, RightBottom(right, bottom)
|
, RightBottom(right, bottom)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a rectangular range of the map using regular coordinates (32 per tile).
|
||||||
|
*/
|
||||||
|
|
||||||
|
struct MapRange : public CoordsRange<CoordsXY>
|
||||||
|
{
|
||||||
|
using CoordsRange::CoordsRange;
|
||||||
|
MapRange(int32_t left, int32_t top, int32_t right, int32_t bottom)
|
||||||
|
: CoordsRange<CoordsXY>(left, top, right, bottom)
|
||||||
|
{
|
||||||
|
// Make sure it's a rectangle
|
||||||
|
assert(std::abs(GetLeft() - GetRight()) > 0);
|
||||||
|
assert(std::abs(GetTop() - GetBottom()) > 0);
|
||||||
|
}
|
||||||
|
|
||||||
MapRange Normalise() const
|
MapRange Normalise() const
|
||||||
{
|
{
|
||||||
auto result = MapRange(
|
auto result = MapRange(
|
||||||
|
|
Loading…
Reference in New Issue