1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Split off QuarterTile

This commit is contained in:
Gymnasiast
2024-10-03 22:24:18 +02:00
parent efe0c11784
commit 20173f22a1
12 changed files with 116 additions and 81 deletions

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -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"

View File

@@ -614,6 +614,7 @@
<ClInclude Include="world\MapGen.h" />
<ClInclude Include="world\MapHelpers.h" />
<ClInclude Include="world\Park.h" />
<ClInclude Include="world\QuarterTile.h" />
<ClInclude Include="world\Scenery.h" />
<ClInclude Include="world\ScenerySelection.h" />
<ClInclude Include="world\SmallScenery.h" />
@@ -1097,6 +1098,7 @@
<ClCompile Include="world\MapGen.cpp" />
<ClCompile Include="world\MapHelpers.cpp" />
<ClCompile Include="world\Park.cpp" />
<ClCompile Include="world\QuarterTile.cpp" />
<ClCompile Include="world\Scenery.cpp" />
<ClCompile Include="world\SmallScenery.cpp" />
<ClCompile Include="world\Surface.cpp" />

View File

@@ -11,6 +11,7 @@
#include "../object/Object.h"
#include "../world/Map.h"
#include "../world/QuarterTile.h"
#include "../world/TileElement.h"
#include <optional>

View File

@@ -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"

View File

@@ -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<uint8_t>(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<uint8_t>(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<uint8_t>(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;
}

View File

@@ -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 <cstdint>
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;
uint8_t GetZQuarterOccupied() const;
};
enum
{
TILE_ELEMENT_QUADRANT_SW,
TILE_ELEMENT_QUADRANT_NW,
TILE_ELEMENT_QUADRANT_NE,
TILE_ELEMENT_QUADRANT_SE
};

View File

@@ -117,46 +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<uint8_t>(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<uint8_t>(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<uint8_t>(rotVal1 | rotVal2) };
}
default:
LOG_ERROR("Tried to rotate QuarterTile invalid amount.");
return QuarterTile{ 0 };
}
}

View File

@@ -531,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),