You've already forked OpenRCT2-Unity
mirror of
https://github.com/izzy2lost/OpenRCT2-Unity.git
synced 2026-03-10 12:38:22 -07:00
Merge pull request #21164 from Gymnasiast/refactor/td-entrance-elements
Import maze entrances in the same way as regular ones
This commit is contained in:
@@ -433,7 +433,40 @@ private:
|
||||
_trackDesign.get(), RideGetTemporaryForPreview(), { loc, z, _currentTrackPieceDirection });
|
||||
}
|
||||
|
||||
void DrawMiniPreviewTrack(TrackDesign* td6, int32_t pass, const CoordsXY& origin, CoordsXY min, CoordsXY max)
|
||||
void DrawMiniPreviewEntrances(
|
||||
const TrackDesign& td6, int32_t pass, const CoordsXY& origin, CoordsXY& min, CoordsXY& max, Direction rotation)
|
||||
{
|
||||
for (const auto& entrance : td6.entrance_elements)
|
||||
{
|
||||
auto rotatedAndOffsetEntrance = origin + entrance.Location.ToCoordsXY().Rotate(rotation);
|
||||
|
||||
if (pass == 0)
|
||||
{
|
||||
min.x = std::min(min.x, rotatedAndOffsetEntrance.x);
|
||||
max.x = std::max(max.x, rotatedAndOffsetEntrance.x);
|
||||
min.y = std::min(min.y, rotatedAndOffsetEntrance.y);
|
||||
max.y = std::max(max.y, rotatedAndOffsetEntrance.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pixelPosition = DrawMiniPreviewGetPixelPosition(rotatedAndOffsetEntrance);
|
||||
if (DrawMiniPreviewIsPixelInBounds(pixelPosition))
|
||||
{
|
||||
uint8_t* pixel = DrawMiniPreviewGetPixelPtr(pixelPosition);
|
||||
uint8_t colour = entrance.IsExit ? _PaletteIndexColourExit : _PaletteIndexColourEntrance;
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
{
|
||||
pixel[338 + i] = colour; // x + 2, y + 2
|
||||
pixel[168 + i] = colour; // y + 1
|
||||
pixel[2 + i] = colour; // x + 2
|
||||
pixel[172 + i] = colour; // x + 4, y + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawMiniPreviewTrack(TrackDesign* td6, int32_t pass, const CoordsXY& origin, CoordsXY& min, CoordsXY& max)
|
||||
{
|
||||
const uint8_t rotation = (_currentTrackPieceDirection + GetCurrentRotation()) & 3;
|
||||
|
||||
@@ -503,38 +536,10 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
// Draw entrance and exit preview.
|
||||
for (const auto& entrance : td6->entrance_elements)
|
||||
{
|
||||
auto rotatedAndOffsetEntrance = origin + entrance.Location.ToCoordsXY().Rotate(rotation);
|
||||
|
||||
if (pass == 0)
|
||||
{
|
||||
min.x = std::min(min.x, rotatedAndOffsetEntrance.x);
|
||||
max.x = std::max(max.x, rotatedAndOffsetEntrance.x);
|
||||
min.y = std::min(min.y, rotatedAndOffsetEntrance.y);
|
||||
max.y = std::max(max.y, rotatedAndOffsetEntrance.y);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto pixelPosition = DrawMiniPreviewGetPixelPosition(rotatedAndOffsetEntrance);
|
||||
if (DrawMiniPreviewIsPixelInBounds(pixelPosition))
|
||||
{
|
||||
uint8_t* pixel = DrawMiniPreviewGetPixelPtr(pixelPosition);
|
||||
uint8_t colour = entrance.IsExit ? _PaletteIndexColourExit : _PaletteIndexColourEntrance;
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
{
|
||||
pixel[338 + i] = colour; // x + 2, y + 2
|
||||
pixel[168 + i] = colour; // y + 1
|
||||
pixel[2 + i] = colour; // x + 2
|
||||
pixel[172 + i] = colour; // x + 4, y + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DrawMiniPreviewEntrances(*td6, pass, origin, min, max, rotation);
|
||||
}
|
||||
|
||||
void DrawMiniPreviewMaze(TrackDesign* td6, int32_t pass, const CoordsXY& origin, CoordsXY min, CoordsXY max)
|
||||
void DrawMiniPreviewMaze(TrackDesign* td6, int32_t pass, const CoordsXY& origin, CoordsXY& min, CoordsXY& max)
|
||||
{
|
||||
uint8_t rotation = (_currentTrackPieceDirection + GetCurrentRotation()) & 3;
|
||||
for (const auto& mazeElement : td6->maze_elements)
|
||||
@@ -556,13 +561,6 @@ private:
|
||||
uint8_t* pixel = DrawMiniPreviewGetPixelPtr(pixelPosition);
|
||||
|
||||
uint8_t colour = _PaletteIndexColourTrack;
|
||||
|
||||
// Draw entrance and exit with different colours.
|
||||
if (mazeElement.type == MAZE_ELEMENT_TYPE_ENTRANCE)
|
||||
colour = _PaletteIndexColourEntrance;
|
||||
else if (mazeElement.type == MAZE_ELEMENT_TYPE_EXIT)
|
||||
colour = _PaletteIndexColourExit;
|
||||
|
||||
for (int32_t i = 0; i < 4; i++)
|
||||
{
|
||||
pixel[338 + i] = colour; // x + 2, y + 2
|
||||
@@ -573,6 +571,8 @@ private:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DrawMiniPreviewEntrances(*td6, pass, origin, min, max, rotation);
|
||||
}
|
||||
|
||||
ScreenCoordsXY DrawMiniPreviewGetPixelPosition(const CoordsXY& location)
|
||||
|
||||
@@ -250,12 +250,7 @@ namespace RCT1
|
||||
_stream.Read(&t4MazeElement, sizeof(TD46MazeElement));
|
||||
if (t4MazeElement.All != 0)
|
||||
{
|
||||
TrackDesignMazeElement mazeElement{};
|
||||
mazeElement.x = t4MazeElement.x;
|
||||
mazeElement.y = t4MazeElement.y;
|
||||
mazeElement.direction = t4MazeElement.Direction;
|
||||
mazeElement.type = t4MazeElement.Type;
|
||||
td->maze_elements.push_back(mazeElement);
|
||||
ImportMazeElement(*td, t4MazeElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -925,6 +925,26 @@ uint8_t ConvertToTD46Flags(const TrackDesignTrackElement& source)
|
||||
return trackFlags;
|
||||
}
|
||||
|
||||
void ImportMazeElement(TrackDesign& td, const TD46MazeElement& td46MazeElement)
|
||||
{
|
||||
if (td46MazeElement.IsEntrance() || td46MazeElement.IsExit())
|
||||
{
|
||||
TrackDesignEntranceElement element{};
|
||||
element.Location = TileCoordsXYZD(td46MazeElement.x, td46MazeElement.y, 0, td46MazeElement.Direction);
|
||||
element.IsExit = td46MazeElement.IsExit();
|
||||
td.entrance_elements.push_back(element);
|
||||
}
|
||||
else
|
||||
{
|
||||
TrackDesignMazeElement mazeElement{};
|
||||
mazeElement.x = td46MazeElement.x;
|
||||
mazeElement.y = td46MazeElement.y;
|
||||
mazeElement.direction = td46MazeElement.Direction;
|
||||
mazeElement.type = td46MazeElement.Type;
|
||||
td.maze_elements.push_back(mazeElement);
|
||||
}
|
||||
}
|
||||
|
||||
namespace RCT12
|
||||
{
|
||||
size_t GetRCTStringBufferLen(const char* buffer, size_t maxBufferLen)
|
||||
|
||||
@@ -74,6 +74,7 @@ constexpr uint8_t RCT12PeepThoughtItemNone = std::numeric_limits<uint8_t>::max()
|
||||
constexpr uint8_t RCT12GuestsInParkHistoryFactor = 20;
|
||||
constexpr uint8_t RCT12ParkHistoryUndefined = std::numeric_limits<uint8_t>::max();
|
||||
|
||||
struct TrackDesign;
|
||||
struct TrackDesignTrackElement;
|
||||
|
||||
enum class RCT12TrackDesignVersion : uint8_t
|
||||
@@ -169,6 +170,25 @@ enum
|
||||
RCT12_ENTITY_FLAGS_IS_CRASHED_VEHICLE_ENTITY = 1 << 7,
|
||||
};
|
||||
|
||||
// Only written to in RCT2, not used in OpenRCT2. All of these are elements that had to be invented in RCT1.
|
||||
enum : uint32_t
|
||||
{
|
||||
TRACK_FLAGS_CONTAINS_VERTICAL_LOOP = (1 << 7),
|
||||
TRACK_FLAGS_CONTAINS_INLINE_TWIST = (1 << 17),
|
||||
TRACK_FLAGS_CONTAINS_HALF_LOOP = (1 << 18),
|
||||
TRACK_FLAGS_CONTAINS_CORKSCREW = (1 << 19),
|
||||
TRACK_FLAGS_CONTAINS_WATER_SPLASH = (1 << 27),
|
||||
TRACK_FLAGS_CONTAINS_BARREL_ROLL = (1 << 29),
|
||||
TRACK_FLAGS_CONTAINS_POWERED_LIFT = (1 << 30),
|
||||
TRACK_FLAGS_CONTAINS_LARGE_HALF_LOOP = (1u << 31),
|
||||
};
|
||||
|
||||
enum : uint32_t
|
||||
{
|
||||
TRACK_FLAGS2_CONTAINS_LOG_FLUME_REVERSER = (1 << 1),
|
||||
TRACK_FLAGS2_SIX_FLAGS_RIDE_DEPRECATED = (1u << 31) // Not used anymore.
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct RCT12xy8
|
||||
@@ -194,6 +214,12 @@ struct RCT12xy8
|
||||
};
|
||||
assert_struct_size(RCT12xy8, 2);
|
||||
|
||||
enum class TD46MazeElementType : uint8_t
|
||||
{
|
||||
Entrance = (1 << 3),
|
||||
Exit = (1 << 7)
|
||||
};
|
||||
|
||||
/* Maze Element entry size: 0x04 */
|
||||
struct TD46MazeElement
|
||||
{
|
||||
@@ -215,6 +241,16 @@ struct TD46MazeElement
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
constexpr bool IsEntrance() const
|
||||
{
|
||||
return Type == EnumValue(TD46MazeElementType::Entrance);
|
||||
}
|
||||
|
||||
constexpr bool IsExit() const
|
||||
{
|
||||
return Type == EnumValue(TD46MazeElementType::Exit);
|
||||
}
|
||||
};
|
||||
assert_struct_size(TD46MazeElement, 0x04);
|
||||
|
||||
@@ -914,6 +950,7 @@ enum class TD46Flags : uint8_t
|
||||
|
||||
void ConvertFromTD46Flags(TrackDesignTrackElement& target, uint8_t flags);
|
||||
uint8_t ConvertToTD46Flags(const TrackDesignTrackElement& source);
|
||||
void ImportMazeElement(TrackDesign& td, const TD46MazeElement& td46MazeElement);
|
||||
|
||||
namespace RCT12
|
||||
{
|
||||
|
||||
@@ -107,6 +107,15 @@ namespace RCT2
|
||||
tempStream.WriteValue<uint32_t>(mazeElement.all);
|
||||
}
|
||||
|
||||
for (const auto& entranceElement : _trackDesign->entrance_elements)
|
||||
{
|
||||
tempStream.WriteValue<int8_t>(entranceElement.Location.x);
|
||||
tempStream.WriteValue<int8_t>(entranceElement.Location.y);
|
||||
tempStream.WriteValue<int8_t>(entranceElement.Location.direction);
|
||||
tempStream.WriteValue<int8_t>(
|
||||
EnumValue(entranceElement.IsExit ? TD46MazeElementType::Exit : TD46MazeElementType::Entrance));
|
||||
}
|
||||
|
||||
tempStream.WriteValue<uint32_t>(0);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -148,12 +148,7 @@ namespace RCT2
|
||||
_stream.Read(&t6MazeElement, sizeof(TD46MazeElement));
|
||||
if (t6MazeElement.All != 0)
|
||||
{
|
||||
TrackDesignMazeElement mazeElement{};
|
||||
mazeElement.x = t6MazeElement.x;
|
||||
mazeElement.y = t6MazeElement.y;
|
||||
mazeElement.direction = t6MazeElement.Direction;
|
||||
mazeElement.type = t6MazeElement.Type;
|
||||
td->maze_elements.push_back(mazeElement);
|
||||
ImportMazeElement(*td, t6MazeElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -177,25 +177,6 @@ private:
|
||||
CoordsXYE MazeGetFirstElement(const Ride& ride);
|
||||
};
|
||||
|
||||
// Only written to in RCT2, not used in OpenRCT2. All of these are elements that had to be invented in RCT1.
|
||||
enum : uint32_t
|
||||
{
|
||||
TRACK_FLAGS_CONTAINS_VERTICAL_LOOP = (1 << 7),
|
||||
TRACK_FLAGS_CONTAINS_INLINE_TWIST = (1 << 17),
|
||||
TRACK_FLAGS_CONTAINS_HALF_LOOP = (1 << 18),
|
||||
TRACK_FLAGS_CONTAINS_CORKSCREW = (1 << 19),
|
||||
TRACK_FLAGS_CONTAINS_WATER_SPLASH = (1 << 27),
|
||||
TRACK_FLAGS_CONTAINS_BARREL_ROLL = (1 << 29),
|
||||
TRACK_FLAGS_CONTAINS_POWERED_LIFT = (1 << 30),
|
||||
TRACK_FLAGS_CONTAINS_LARGE_HALF_LOOP = (1u << 31),
|
||||
};
|
||||
|
||||
enum : uint32_t
|
||||
{
|
||||
TRACK_FLAGS2_CONTAINS_LOG_FLUME_REVERSER = (1 << 1),
|
||||
TRACK_FLAGS2_SIX_FLAGS_RIDE_DEPRECATED = (1u << 31) // Not used anymore.
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
TDPF_PLACE_SCENERY = 1 << 0,
|
||||
@@ -221,13 +202,6 @@ enum
|
||||
|
||||
static constexpr uint8_t PTD_OPERATION_FLAG_IS_REPLAY = (1 << 7);
|
||||
|
||||
enum
|
||||
{
|
||||
MAZE_ELEMENT_TYPE_MAZE_TRACK = 0,
|
||||
MAZE_ELEMENT_TYPE_ENTRANCE = (1 << 3),
|
||||
MAZE_ELEMENT_TYPE_EXIT = (1 << 7)
|
||||
};
|
||||
|
||||
extern bool gTrackDesignSceneryToggle;
|
||||
|
||||
extern bool _trackDesignDrawingPreview;
|
||||
|
||||
Reference in New Issue
Block a user