forked from rosebudai/OpenRCT2-Web
Create enum class for EntranceSequence
This commit is contained in:
20 files changed
+62
-50
No files matched your search
@@ -672,12 +672,14 @@ namespace OpenRCT2::Ui
|
||||
int32_t rotation = entranceElement.getDirectionWithOffset(1);
|
||||
switch (entranceElement.getSequenceIndex())
|
||||
{
|
||||
case 1:
|
||||
case ParkEntranceSequence::left:
|
||||
mapCoords += CoordsDirectionDelta[rotation];
|
||||
break;
|
||||
case 2:
|
||||
case ParkEntranceSequence::right:
|
||||
mapCoords -= CoordsDirectionDelta[rotation];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction(
|
||||
{ mapCoords.x, mapCoords.y, entranceElement.getBaseZ() });
|
||||
|
||||
@@ -1423,7 +1423,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
// Entrance part
|
||||
ft = Formatter();
|
||||
ft.Add<StringId>(kParkEntrancePartStringIds[entranceEl.getSequenceIndex()]);
|
||||
ft.Add<StringId>(kParkEntrancePartStringIds[EnumValue(entranceEl.getSequenceIndex())]);
|
||||
drawText(rt, screenCoords + ScreenCoordsXY{ 0, 22 }, STR_TILE_INSPECTOR_ENTRANCE_PART, ft, { colours[1] });
|
||||
}
|
||||
else
|
||||
|
||||
@@ -138,8 +138,7 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == 0)
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == ParkEntranceSequence::centre)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
@@ -207,8 +206,7 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == 0)
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == ParkEntranceSequence::centre)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
|
||||
@@ -300,8 +300,7 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == 0)
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == ParkEntranceSequence::centre)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
@@ -368,8 +367,7 @@ namespace OpenRCT2::GameActions
|
||||
}
|
||||
|
||||
auto entranceElement = MapGetParkEntranceElementAt(_loc, false);
|
||||
// Make sure the entrance part is the middle
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == 0)
|
||||
if (entranceElement != nullptr && (entranceElement->getSequenceIndex()) == ParkEntranceSequence::centre)
|
||||
{
|
||||
entrancePath = true;
|
||||
// Make the price the same as replacing a path
|
||||
|
||||
@@ -132,14 +132,21 @@ namespace OpenRCT2::GameActions
|
||||
auto zLow = _loc.z;
|
||||
auto zHigh = zLow + ParkEntranceHeight;
|
||||
CoordsXY entranceLoc = { _loc.x, _loc.y };
|
||||
for (uint8_t index = 0; index < 3; index++)
|
||||
|
||||
constexpr auto kEntranceSequences = std::to_array(
|
||||
{
|
||||
ParkEntranceSequence::centre,
|
||||
ParkEntranceSequence::left,
|
||||
ParkEntranceSequence::right,
|
||||
});
|
||||
for (const auto index : kEntranceSequences)
|
||||
{
|
||||
if (index == 1)
|
||||
if (index == ParkEntranceSequence::left)
|
||||
{
|
||||
entranceLoc.x += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].x;
|
||||
entranceLoc.y += CoordsDirectionDelta[(_loc.direction - 1) & 0x3].y;
|
||||
}
|
||||
else if (index == 2)
|
||||
else if (index == ParkEntranceSequence::right)
|
||||
{
|
||||
entranceLoc.x += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].x * 2;
|
||||
entranceLoc.y += CoordsDirectionDelta[(_loc.direction + 1) & 0x3].y * 2;
|
||||
@@ -185,7 +192,7 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
MapInvalidateTile({ entranceLoc, entranceElement->getBaseZ(), entranceElement->getClearanceZ() });
|
||||
|
||||
if (index == 0)
|
||||
if (index == ParkEntranceSequence::centre)
|
||||
{
|
||||
MapAnimations::MarkTileForInvalidation(TileCoordsXY(entranceLoc));
|
||||
}
|
||||
|
||||
@@ -1744,8 +1744,7 @@ namespace OpenRCT2
|
||||
return true;
|
||||
}
|
||||
|
||||
// If not the centre of the entrance arch
|
||||
if (tile_element->asEntrance()->getSequenceIndex() != 0)
|
||||
if (tile_element->asEntrance()->getSequenceIndex() != ParkEntranceSequence::centre)
|
||||
{
|
||||
PeepReturnToCentreOfTile(guest);
|
||||
return true;
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "../core/Json.hpp"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../localisation/Language.h"
|
||||
#include "../world/tile_element/EntranceElement.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
@@ -66,11 +67,11 @@ namespace OpenRCT2
|
||||
PopulateTablesFromJson(context, root);
|
||||
}
|
||||
|
||||
ImageIndex EntranceObject::GetImage(uint8_t sequence, Direction direction) const
|
||||
ImageIndex EntranceObject::GetImage(ParkEntranceSequence sequence, Direction direction) const
|
||||
{
|
||||
if (sequence > 2)
|
||||
if (EnumValue(sequence) > 2)
|
||||
return kImageIndexUndefined;
|
||||
return _legacyType.image_id + ((direction & 3) * 3) + sequence;
|
||||
return _legacyType.image_id + ((direction & 3) * 3) + EnumValue(sequence);
|
||||
}
|
||||
|
||||
uint8_t EntranceObject::GetScrollingMode() const
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum class ParkEntranceSequence : uint8_t;
|
||||
|
||||
class EntranceObject final : public Object
|
||||
{
|
||||
private:
|
||||
@@ -35,7 +37,7 @@ namespace OpenRCT2
|
||||
|
||||
void DrawPreview(Drawing::RenderTarget& rt, int32_t width, int32_t height) const override;
|
||||
|
||||
ImageIndex GetImage(uint8_t sequence, Direction direction) const;
|
||||
ImageIndex GetImage(ParkEntranceSequence sequence, Direction direction) const;
|
||||
uint8_t GetScrollingMode() const;
|
||||
uint8_t GetTextHeight() const;
|
||||
};
|
||||
|
||||
@@ -271,7 +271,7 @@ static void PaintParkEntrance(PaintSession& session, uint8_t direction, int32_t
|
||||
auto sequence = entranceEl.getSequenceIndex();
|
||||
switch (sequence)
|
||||
{
|
||||
case EntranceSequence::Centre:
|
||||
case ParkEntranceSequence::centre:
|
||||
{
|
||||
// Footpath
|
||||
auto surfaceDescriptor = entranceEl.getPathSurfaceDescriptor();
|
||||
@@ -294,8 +294,8 @@ static void PaintParkEntrance(PaintSession& session, uint8_t direction, int32_t
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EntranceSequence::Left:
|
||||
case EntranceSequence::Right:
|
||||
case ParkEntranceSequence::left:
|
||||
case ParkEntranceSequence::right:
|
||||
if (entrance != nullptr)
|
||||
{
|
||||
auto imageIndex = entrance->GetImage(sequence, direction);
|
||||
|
||||
@@ -2539,7 +2539,7 @@ namespace OpenRCT2::RCT1
|
||||
continue;
|
||||
if (element->asEntrance()->getEntranceType() != EntranceType::parkEntrance)
|
||||
continue;
|
||||
if ((element->asEntrance()->getSequenceIndex()) != 0)
|
||||
if ((element->asEntrance()->getSequenceIndex()) != ParkEntranceSequence::centre)
|
||||
continue;
|
||||
|
||||
CoordsXYZD entrance = { TileCoordsXY(it.x, it.y).ToCoordsXY(), element->getBaseZ(), element->getDirection() };
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "../ride/ted/TrackElemType.h"
|
||||
#include "../scenario/Scenario.h"
|
||||
#include "../world/Wall.h"
|
||||
#include "../world/tile_element/EntranceElement.h"
|
||||
#include "../world/tile_element/PathElement.h"
|
||||
#include "../world/tile_element/Slope.h"
|
||||
#include "../world/tile_element/SmallSceneryElement.h"
|
||||
@@ -446,9 +447,9 @@ uint8_t RCT12EntranceElement::GetStationIndex() const
|
||||
return (Index & RCT12_TRACK_ELEMENT_SEQUENCE_STATION_INDEX_MASK) >> 4;
|
||||
}
|
||||
|
||||
uint8_t RCT12EntranceElement::GetSequenceIndex() const
|
||||
OpenRCT2::ParkEntranceSequence RCT12EntranceElement::GetSequenceIndex() const
|
||||
{
|
||||
return Index & 0xF;
|
||||
return static_cast<OpenRCT2::ParkEntranceSequence>(Index & 0xF);
|
||||
}
|
||||
|
||||
uint8_t RCT12EntranceElement::GetPathType() const
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class ObjectList;
|
||||
enum class ParkEntranceSequence : uint8_t;
|
||||
enum class EntranceType : uint8_t;
|
||||
enum class TrackElemType : uint16_t;
|
||||
} // namespace OpenRCT2
|
||||
@@ -871,7 +872,7 @@ public:
|
||||
OpenRCT2::EntranceType GetEntranceType() const;
|
||||
uint8_t GetRideIndex() const;
|
||||
uint8_t GetStationIndex() const;
|
||||
uint8_t GetSequenceIndex() const;
|
||||
OpenRCT2::ParkEntranceSequence GetSequenceIndex() const;
|
||||
uint8_t GetPathType() const;
|
||||
};
|
||||
static_assert(sizeof(RCT12EntranceElement) == 8);
|
||||
|
||||
@@ -1469,7 +1469,7 @@ namespace OpenRCT2::RCT2
|
||||
dst2->setStationIndex(StationIndex::FromUnderlying(src2->GetStationIndex()));
|
||||
dst2->setSequenceIndex(src2->GetSequenceIndex());
|
||||
|
||||
if (src2->GetSequenceIndex() == 0)
|
||||
if (src2->GetSequenceIndex() == ParkEntranceSequence::centre)
|
||||
{
|
||||
auto pathEntryIndex = src2->GetPathType();
|
||||
auto surfaceEntry = _pathToSurfaceMap[pathEntryIndex];
|
||||
|
||||
@@ -399,8 +399,7 @@ namespace OpenRCT2::Editor
|
||||
type = iter.element->asEntrance()->getEntryIndex();
|
||||
Editor::SetSelectedObject(ObjectType::parkEntrance, type, ObjectSelectionFlags::InUse);
|
||||
|
||||
// Skip if not the middle part
|
||||
if (parkEntranceEl->getSequenceIndex() != 0)
|
||||
if (parkEntranceEl->getSequenceIndex() != ParkEntranceSequence::centre)
|
||||
break;
|
||||
|
||||
auto legacyPathEntryIndex = parkEntranceEl->getLegacyPathEntryIndex();
|
||||
|
||||
@@ -560,7 +560,7 @@ namespace OpenRCT2::Scripting
|
||||
case TileElementType::entrance:
|
||||
{
|
||||
auto* el = element->asEntrance();
|
||||
return JS_NewUint32(ctx, el->getSequenceIndex());
|
||||
return JS_NewUint32(ctx, EnumValue(el->getSequenceIndex()));
|
||||
}
|
||||
default:
|
||||
{
|
||||
@@ -613,7 +613,7 @@ namespace OpenRCT2::Scripting
|
||||
case TileElementType::entrance:
|
||||
{
|
||||
auto* el = element->asEntrance();
|
||||
el->setSequenceIndex(value);
|
||||
el->setSequenceIndex(static_cast<ParkEntranceSequence>(std::clamp<uint8_t>(value, 0, 2)));
|
||||
Invalidate(data);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ void ParkEntranceUpdateLocations()
|
||||
{
|
||||
auto entranceElement = it.element->asEntrance();
|
||||
if (entranceElement != nullptr && entranceElement->getEntranceType() == EntranceType::parkEntrance
|
||||
&& entranceElement->getSequenceIndex() == 0 && !entranceElement->isGhost())
|
||||
&& entranceElement->getSequenceIndex() == ParkEntranceSequence::centre && !entranceElement->isGhost())
|
||||
{
|
||||
auto entrance = TileCoordsXYZD(it.x, it.y, it.element->baseHeight, it.element->getDirection()).ToCoordsXYZD();
|
||||
park.entrances.push_back(entrance);
|
||||
|
||||
@@ -1406,12 +1406,14 @@ namespace OpenRCT2
|
||||
auto seqLoc = loc;
|
||||
switch (element->asEntrance()->getSequenceIndex())
|
||||
{
|
||||
case 1:
|
||||
case ParkEntranceSequence::left:
|
||||
seqLoc += CoordsDirectionDelta[rotation];
|
||||
break;
|
||||
case 2:
|
||||
case ParkEntranceSequence::right:
|
||||
seqLoc -= CoordsDirectionDelta[rotation];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
auto parkEntranceRemoveAction = GameActions::ParkEntranceRemoveAction(CoordsXYZ{ seqLoc, element->getBaseZ() });
|
||||
auto result = GameActions::ExecuteNested(&parkEntranceRemoveAction, gameState);
|
||||
|
||||
@@ -108,7 +108,8 @@ static bool UpdateEntranceAnimation(
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (entrance.getEntranceType() == EntranceType::parkEntrance && entrance.getSequenceIndex() == 0)
|
||||
else if (
|
||||
entrance.getEntranceType() == EntranceType::parkEntrance && entrance.getSequenceIndex() == ParkEntranceSequence::centre)
|
||||
{
|
||||
if constexpr (invalidate)
|
||||
{
|
||||
@@ -559,7 +560,8 @@ static std::optional<UpdateType> IsElementAnimated(const TileElementBase& elemen
|
||||
case TileElementType::entrance:
|
||||
{
|
||||
const auto* const entrance = element.asEntrance();
|
||||
if (entrance->getEntranceType() == EntranceType::parkEntrance && entrance->getSequenceIndex() == 0)
|
||||
if (entrance->getEntranceType() == EntranceType::parkEntrance
|
||||
&& entrance->getSequenceIndex() == ParkEntranceSequence::centre)
|
||||
{
|
||||
return std::optional(UpdateType::invalidate);
|
||||
}
|
||||
|
||||
@@ -53,15 +53,15 @@ namespace OpenRCT2
|
||||
stationIndex = newStationIndex;
|
||||
}
|
||||
|
||||
uint8_t EntranceElement::getSequenceIndex() const
|
||||
ParkEntranceSequence EntranceElement::getSequenceIndex() const
|
||||
{
|
||||
return sequenceIndex & 0xF;
|
||||
return static_cast<ParkEntranceSequence>(sequenceIndex & 0xF);
|
||||
}
|
||||
|
||||
void EntranceElement::setSequenceIndex(uint8_t newSequenceIndex)
|
||||
void EntranceElement::setSequenceIndex(ParkEntranceSequence newSequenceIndex)
|
||||
{
|
||||
sequenceIndex &= ~0xF;
|
||||
sequenceIndex |= (newSequenceIndex & 0xF);
|
||||
sequenceIndex |= (EnumValue(newSequenceIndex) & 0xF);
|
||||
}
|
||||
|
||||
bool EntranceElement::hasLegacyPathEntry() const
|
||||
@@ -129,7 +129,7 @@ namespace OpenRCT2
|
||||
|
||||
int32_t EntranceElement::getDirections() const
|
||||
{
|
||||
return kEntranceDirections[EnumValue(getEntranceType())][getSequenceIndex()];
|
||||
return kEntranceDirections[EnumValue(getEntranceType())][EnumValue(getSequenceIndex())];
|
||||
}
|
||||
|
||||
ObjectEntryIndex EntranceElement::getEntryIndex() const
|
||||
|
||||
@@ -33,12 +33,12 @@ namespace OpenRCT2
|
||||
ENTRANCE_ELEMENT_FLAGS2_LEGACY_PATH_ENTRY = (1 << 0),
|
||||
};
|
||||
|
||||
namespace EntranceSequence
|
||||
enum class ParkEntranceSequence : uint8_t
|
||||
{
|
||||
constexpr uint8_t Centre = 0;
|
||||
constexpr uint8_t Left = 1;
|
||||
constexpr uint8_t Right = 2;
|
||||
} // namespace EntranceSequence
|
||||
centre = 0,
|
||||
left = 1,
|
||||
right = 2,
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
@@ -69,8 +69,8 @@ namespace OpenRCT2
|
||||
StationIndex getStationIndex() const;
|
||||
void setStationIndex(StationIndex newStationIndex);
|
||||
|
||||
uint8_t getSequenceIndex() const;
|
||||
void setSequenceIndex(uint8_t newSequenceIndex);
|
||||
ParkEntranceSequence getSequenceIndex() const;
|
||||
void setSequenceIndex(ParkEntranceSequence newSequenceIndex);
|
||||
|
||||
bool hasLegacyPathEntry() const;
|
||||
|
||||
|
||||
Reference in new issue
Block a user