diff --git a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp b/src/openrct2/actions/FootpathLayoutPlaceAction.cpp
index 01f4173a28..982c5cc262 100644
--- a/src/openrct2/actions/FootpathLayoutPlaceAction.cpp
+++ b/src/openrct2/actions/FootpathLayoutPlaceAction.cpp
@@ -21,6 +21,7 @@
#include "../world/Footpath.h"
#include "../world/Location.hpp"
#include "../world/Park.h"
+#include "../world/QuarterTile.h"
#include "../world/Surface.h"
#include "../world/Wall.h"
#include "../world/tile_element/EntranceElement.h"
diff --git a/src/openrct2/actions/FootpathPlaceAction.cpp b/src/openrct2/actions/FootpathPlaceAction.cpp
index 4529e7a491..14a19f47cf 100644
--- a/src/openrct2/actions/FootpathPlaceAction.cpp
+++ b/src/openrct2/actions/FootpathPlaceAction.cpp
@@ -25,6 +25,7 @@
#include "../world/Footpath.h"
#include "../world/Location.hpp"
#include "../world/Park.h"
+#include "../world/QuarterTile.h"
#include "../world/Scenery.h"
#include "../world/Surface.h"
#include "../world/TileElementsView.h"
diff --git a/src/openrct2/actions/LargeSceneryPlaceAction.cpp b/src/openrct2/actions/LargeSceneryPlaceAction.cpp
index e4958df2ea..86967f1b03 100644
--- a/src/openrct2/actions/LargeSceneryPlaceAction.cpp
+++ b/src/openrct2/actions/LargeSceneryPlaceAction.cpp
@@ -21,6 +21,7 @@
#include "../world/Banner.h"
#include "../world/ConstructionClearance.h"
#include "../world/MapAnimation.h"
+#include "../world/QuarterTile.h"
#include "../world/Surface.h"
#include "../world/tile_element/Slope.h"
diff --git a/src/openrct2/actions/SmallSceneryPlaceAction.cpp b/src/openrct2/actions/SmallSceneryPlaceAction.cpp
index eef9547df4..876f04bb09 100644
--- a/src/openrct2/actions/SmallSceneryPlaceAction.cpp
+++ b/src/openrct2/actions/SmallSceneryPlaceAction.cpp
@@ -24,6 +24,7 @@
#include "../world/ConstructionClearance.h"
#include "../world/MapAnimation.h"
#include "../world/Park.h"
+#include "../world/QuarterTile.h"
#include "../world/Scenery.h"
#include "../world/Surface.h"
#include "../world/TileElement.h"
diff --git a/src/openrct2/actions/TrackPlaceAction.cpp b/src/openrct2/actions/TrackPlaceAction.cpp
index 0e2cd1e04b..277670afe4 100644
--- a/src/openrct2/actions/TrackPlaceAction.cpp
+++ b/src/openrct2/actions/TrackPlaceAction.cpp
@@ -20,6 +20,7 @@
#include "../util/Math.hpp"
#include "../world/ConstructionClearance.h"
#include "../world/MapAnimation.h"
+#include "../world/QuarterTile.h"
#include "../world/Surface.h"
#include "../world/tile_element/Slope.h"
#include "RideSetSettingAction.h"
diff --git a/src/openrct2/libopenrct2.vcxproj b/src/openrct2/libopenrct2.vcxproj
index f1878287a4..1765cdb9ed 100644
--- a/src/openrct2/libopenrct2.vcxproj
+++ b/src/openrct2/libopenrct2.vcxproj
@@ -614,6 +614,7 @@
+
@@ -1085,6 +1086,7 @@
+
@@ -1096,12 +1098,12 @@
+
-
diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h
index 068741ac28..6a891e51dd 100644
--- a/src/openrct2/ride/Track.h
+++ b/src/openrct2/ride/Track.h
@@ -11,6 +11,7 @@
#include "../object/Object.h"
#include "../world/Map.h"
+#include "../world/QuarterTile.h"
#include "../world/TileElement.h"
#include
diff --git a/src/openrct2/world/ConstructionClearance.cpp b/src/openrct2/world/ConstructionClearance.cpp
index 39f1ab7113..7335bda579 100644
--- a/src/openrct2/world/ConstructionClearance.cpp
+++ b/src/openrct2/world/ConstructionClearance.cpp
@@ -19,6 +19,7 @@
#include "../ride/Ride.h"
#include "../ride/RideData.h"
#include "Park.h"
+#include "QuarterTile.h"
#include "Scenery.h"
#include "Surface.h"
#include "tile_element/EntranceElement.h"
diff --git a/src/openrct2/world/QuarterTile.cpp b/src/openrct2/world/QuarterTile.cpp
new file mode 100644
index 0000000000..ff30d51b68
--- /dev/null
+++ b/src/openrct2/world/QuarterTile.cpp
@@ -0,0 +1,65 @@
+/*****************************************************************************
+ * Copyright (c) 2014-2024 OpenRCT2 developers
+ *
+ * For a complete list of all authors, please refer to contributors.md
+ * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
+ *
+ * OpenRCT2 is licensed under the GNU General Public License version 3.
+ *****************************************************************************/
+
+#include "QuarterTile.h"
+
+#include "../Diagnostic.h"
+
+// Rotate both of the values amount
+const QuarterTile QuarterTile::Rotate(uint8_t amount) const
+{
+ switch (amount)
+ {
+ case 0:
+ return QuarterTile{ *this };
+ case 1:
+ {
+ auto rotVal1 = _val << 1;
+ auto rotVal2 = rotVal1 >> 4;
+ // Clear the bit from the tileQuarter
+ rotVal1 &= 0b11101110;
+ // Clear the bit from the zQuarter
+ rotVal2 &= 0b00010001;
+ return QuarterTile{ static_cast(rotVal1 | rotVal2) };
+ }
+ case 2:
+ {
+ auto rotVal1 = _val << 2;
+ auto rotVal2 = rotVal1 >> 4;
+ // Clear the bit from the tileQuarter
+ rotVal1 &= 0b11001100;
+ // Clear the bit from the zQuarter
+ rotVal2 &= 0b00110011;
+ return QuarterTile{ static_cast(rotVal1 | rotVal2) };
+ }
+ case 3:
+ {
+ auto rotVal1 = _val << 3;
+ auto rotVal2 = rotVal1 >> 4;
+ // Clear the bit from the tileQuarter
+ rotVal1 &= 0b10001000;
+ // Clear the bit from the zQuarter
+ rotVal2 &= 0b01110111;
+ return QuarterTile{ static_cast(rotVal1 | rotVal2) };
+ }
+ default:
+ LOG_ERROR("Tried to rotate QuarterTile invalid amount.");
+ return QuarterTile{ 0 };
+ }
+}
+
+uint8_t QuarterTile::GetBaseQuarterOccupied() const
+{
+ return _val & 0xF;
+}
+
+uint8_t QuarterTile::GetZQuarterOccupied() const
+{
+ return (_val >> 4) & 0xF;
+}
diff --git a/src/openrct2/world/QuarterTile.h b/src/openrct2/world/QuarterTile.h
new file mode 100644
index 0000000000..11cf0e8fae
--- /dev/null
+++ b/src/openrct2/world/QuarterTile.h
@@ -0,0 +1,42 @@
+/*****************************************************************************
+ * Copyright (c) 2014-2024 OpenRCT2 developers
+ *
+ * For a complete list of all authors, please refer to contributors.md
+ * Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
+ *
+ * OpenRCT2 is licensed under the GNU General Public License version 3.
+ *****************************************************************************/
+
+#pragma once
+
+#include
+
+class QuarterTile
+{
+private:
+ uint8_t _val{ 0 };
+
+public:
+ constexpr QuarterTile(uint8_t tileQuarter, uint8_t zQuarter)
+ : _val(tileQuarter | (zQuarter << 4))
+ {
+ }
+
+ constexpr QuarterTile(uint8_t tileAndZQuarter)
+ : _val(tileAndZQuarter)
+ {
+ }
+
+ // Rotate both of the values amount. Returns new RValue QuarterTile
+ const QuarterTile Rotate(uint8_t amount) const;
+ uint8_t GetBaseQuarterOccupied() const;
+ uint8_t GetZQuarterOccupied() const;
+};
+
+enum
+{
+ TILE_ELEMENT_QUADRANT_SW,
+ TILE_ELEMENT_QUADRANT_NW,
+ TILE_ELEMENT_QUADRANT_NE,
+ TILE_ELEMENT_QUADRANT_SE
+};
diff --git a/src/openrct2/world/TileElement.cpp b/src/openrct2/world/TileElement.cpp
index e2cba7d7f3..bc298b743b 100644
--- a/src/openrct2/world/TileElement.cpp
+++ b/src/openrct2/world/TileElement.cpp
@@ -117,56 +117,3 @@ void TileElement::ClearAs(TileElementType newType)
std::fill_n(Pad05, sizeof(Pad05), 0x00);
std::fill_n(Pad08, sizeof(Pad08), 0x00);
}
-
-// Rotate both of the values amount
-const QuarterTile QuarterTile::Rotate(uint8_t amount) const
-{
- switch (amount)
- {
- case 0:
- return QuarterTile{ *this };
- case 1:
- {
- auto rotVal1 = _val << 1;
- auto rotVal2 = rotVal1 >> 4;
- // Clear the bit from the tileQuarter
- rotVal1 &= 0b11101110;
- // Clear the bit from the zQuarter
- rotVal2 &= 0b00010001;
- return QuarterTile{ static_cast(rotVal1 | rotVal2) };
- }
- case 2:
- {
- auto rotVal1 = _val << 2;
- auto rotVal2 = rotVal1 >> 4;
- // Clear the bit from the tileQuarter
- rotVal1 &= 0b11001100;
- // Clear the bit from the zQuarter
- rotVal2 &= 0b00110011;
- return QuarterTile{ static_cast(rotVal1 | rotVal2) };
- }
- case 3:
- {
- auto rotVal1 = _val << 3;
- auto rotVal2 = rotVal1 >> 4;
- // Clear the bit from the tileQuarter
- rotVal1 &= 0b10001000;
- // Clear the bit from the zQuarter
- rotVal2 &= 0b01110111;
- return QuarterTile{ static_cast(rotVal1 | rotVal2) };
- }
- default:
- LOG_ERROR("Tried to rotate QuarterTile invalid amount.");
- return QuarterTile{ 0 };
- }
-}
-
-const EntranceElement* TileElementBase::AsEntrance() const
-{
- return as();
-}
-
-EntranceElement* TileElementBase::AsEntrance()
-{
- return as();
-}
diff --git a/src/openrct2/world/TileElement.h b/src/openrct2/world/TileElement.h
index acce7757b0..da3545cb0c 100644
--- a/src/openrct2/world/TileElement.h
+++ b/src/openrct2/world/TileElement.h
@@ -101,64 +101,22 @@ struct TileElementBase
return GetType() == TType::ElementType ? reinterpret_cast(this) : nullptr;
}
- const SurfaceElement* AsSurface() const
- {
- return as();
- }
- SurfaceElement* AsSurface()
- {
- return as();
- }
- const PathElement* AsPath() const
- {
- return as();
- }
- PathElement* AsPath()
- {
- return as();
- }
- const TrackElement* AsTrack() const
- {
- return as();
- }
- TrackElement* AsTrack()
- {
- return as();
- }
- const SmallSceneryElement* AsSmallScenery() const
- {
- return as();
- }
- SmallSceneryElement* AsSmallScenery()
- {
- return as();
- }
- const LargeSceneryElement* AsLargeScenery() const
- {
- return as();
- }
- LargeSceneryElement* AsLargeScenery()
- {
- return as();
- }
- const WallElement* AsWall() const
- {
- return as();
- }
- WallElement* AsWall()
- {
- return as();
- }
+ const SurfaceElement* AsSurface() const;
+ SurfaceElement* AsSurface();
+ const PathElement* AsPath() const;
+ PathElement* AsPath();
+ const TrackElement* AsTrack() const;
+ TrackElement* AsTrack();
+ const SmallSceneryElement* AsSmallScenery() const;
+ SmallSceneryElement* AsSmallScenery();
+ const LargeSceneryElement* AsLargeScenery() const;
+ LargeSceneryElement* AsLargeScenery();
+ const WallElement* AsWall() const;
+ WallElement* AsWall();
const EntranceElement* AsEntrance() const;
EntranceElement* AsEntrance();
- const BannerElement* AsBanner() const
- {
- return as();
- }
- BannerElement* AsBanner()
- {
- return as();
- }
+ const BannerElement* AsBanner() const;
+ BannerElement* AsBanner();
};
/**
@@ -573,44 +531,6 @@ static_assert(sizeof(BannerElement) == 16);
#pragma pack(pop)
-class QuarterTile
-{
-private:
- uint8_t _val{ 0 };
-
-public:
- constexpr QuarterTile(uint8_t tileQuarter, uint8_t zQuarter)
- : _val(tileQuarter | (zQuarter << 4))
- {
- }
-
- QuarterTile(uint8_t tileAndZQuarter)
- : _val(tileAndZQuarter)
- {
- }
-
- // Rotate both of the values amount. Returns new RValue QuarterTile
- const QuarterTile Rotate(uint8_t amount) const;
-
- uint8_t GetBaseQuarterOccupied() const
- {
- return _val & 0xF;
- }
-
- uint8_t GetZQuarterOccupied() const
- {
- return (_val >> 4) & 0xF;
- }
-};
-
-enum
-{
- TILE_ELEMENT_QUADRANT_SW,
- TILE_ELEMENT_QUADRANT_NW,
- TILE_ELEMENT_QUADRANT_NE,
- TILE_ELEMENT_QUADRANT_SE
-};
-
enum
{
SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER = (1 << 6),
diff --git a/src/openrct2/world/TileElementBase.cpp b/src/openrct2/world/tile_element/TileElementBase.cpp
similarity index 66%
rename from src/openrct2/world/TileElementBase.cpp
rename to src/openrct2/world/tile_element/TileElementBase.cpp
index 5a3ce735bb..3541e6c02e 100644
--- a/src/openrct2/world/TileElementBase.cpp
+++ b/src/openrct2/world/tile_element/TileElementBase.cpp
@@ -7,8 +7,9 @@
* OpenRCT2 is licensed under the GNU General Public License version 3.
*****************************************************************************/
-#include "Map.h"
-#include "TileElement.h"
+#include "../Map.h"
+#include "../TileElement.h"
+#include "EntranceElement.h"
TileElementType TileElementBase::GetType() const
{
@@ -126,3 +127,71 @@ void TileElementBase::SetOwner(uint8_t newOwner)
Owner &= ~OWNER_MASK;
Owner |= (newOwner & OWNER_MASK);
}
+
+const SurfaceElement* TileElementBase::AsSurface() const
+{
+ return as();
+}
+SurfaceElement* TileElementBase::AsSurface()
+{
+ return as();
+}
+const PathElement* TileElementBase::AsPath() const
+{
+ return as();
+}
+PathElement* TileElementBase::AsPath()
+{
+ return as();
+}
+const TrackElement* TileElementBase::AsTrack() const
+{
+ return as();
+}
+TrackElement* TileElementBase::AsTrack()
+{
+ return as();
+}
+const SmallSceneryElement* TileElementBase::AsSmallScenery() const
+{
+ return as();
+}
+SmallSceneryElement* TileElementBase::AsSmallScenery()
+{
+ return as();
+}
+const LargeSceneryElement* TileElementBase::AsLargeScenery() const
+{
+ return as();
+}
+LargeSceneryElement* TileElementBase::AsLargeScenery()
+{
+ return as();
+}
+const WallElement* TileElementBase::AsWall() const
+{
+ return as();
+}
+WallElement* TileElementBase::AsWall()
+{
+ return as();
+}
+
+const EntranceElement* TileElementBase::AsEntrance() const
+{
+ return as();
+}
+
+EntranceElement* TileElementBase::AsEntrance()
+{
+ return as();
+}
+
+const BannerElement* TileElementBase::AsBanner() const
+{
+ return as();
+}
+BannerElement* TileElementBase::AsBanner()
+{
+ return as();
+}