mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-02-01 11:15:13 +01:00
Split off QuarterTile
This commit is contained in:
65
src/openrct2/world/QuarterTile.cpp
Normal file
65
src/openrct2/world/QuarterTile.cpp
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user