Skip to content

Commit

Permalink
Merge pull request #10059 from tupaschoal/track-design-maze-element
Browse files Browse the repository at this point in the history
Create TrackDesignMazeElement struct
  • Loading branch information
duncanspumpkin committed Oct 9, 2019
2 parents 6be7c42 + 3f21933 commit 0a00f62
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 14 deletions.
15 changes: 10 additions & 5 deletions src/openrct2/rct1/T4Importer.cpp
Expand Up @@ -253,13 +253,18 @@ class TD4Importer final : public ITrackImporter

if (td->type == RIDE_TYPE_MAZE)
{
rct_td46_maze_element mazeElement{};
mazeElement.all = !0;
while (mazeElement.all != 0)
rct_td46_maze_element t4MazeElement{};
t4MazeElement.all = !0;
while (t4MazeElement.all != 0)
{
_stream.Read(&mazeElement, sizeof(rct_td46_maze_element));
if (mazeElement.all != 0)
_stream.Read(&t4MazeElement, sizeof(rct_td46_maze_element));
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);
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/openrct2/rct2/T6Importer.cpp
Expand Up @@ -138,13 +138,18 @@ class TD6Importer final : public ITrackImporter

if (td->type == RIDE_TYPE_MAZE)
{
rct_td46_maze_element mazeElement{};
mazeElement.all = !0;
while (mazeElement.all != 0)
rct_td46_maze_element t4MazeElement{};
t4MazeElement.all = !0;
while (t4MazeElement.all != 0)
{
_stream.Read(&mazeElement, sizeof(rct_td46_maze_element));
if (mazeElement.all != 0)
_stream.Read(&t4MazeElement, sizeof(rct_td46_maze_element));
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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2/ride/TrackDesign.cpp
Expand Up @@ -379,7 +379,7 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
if (tileElement->AsTrack()->GetRideIndex() != ride.id)
continue;

rct_td46_maze_element maze{};
TrackDesignMazeElement maze{};

maze.maze_entry = tileElement->AsTrack()->GetMazeEntry();
maze.x = (x - startLoc.x) / 32;
Expand Down Expand Up @@ -418,7 +418,7 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
// Add something that stops this from walking off the end

uint8_t entranceDirection = tileElement->GetDirection();
rct_td46_maze_element mazeEntrance{};
TrackDesignMazeElement mazeEntrance{};
mazeEntrance.direction = entranceDirection;
mazeEntrance.type = 8;
mazeEntrance.x = (int8_t)((entranceLoc.x - startLoc.x) / 32);
Expand All @@ -445,7 +445,7 @@ rct_string_id TrackDesign::CreateTrackDesignMaze(const Ride& ride)
// Add something that stops this from walking off the end

uint8_t exit_direction = tileElement->GetDirection();
rct_td46_maze_element mazeExit{};
TrackDesignMazeElement mazeExit{};
mazeExit.direction = exit_direction;
mazeExit.type = 0x80;
mazeExit.x = (int8_t)((exitLoc.x - startLoc.x) / 32);
Expand Down
25 changes: 24 additions & 1 deletion src/openrct2/ride/TrackDesign.h
Expand Up @@ -53,6 +53,29 @@ struct TrackDesignTrackElement
uint8_t flags; // 0x01
};

/* Maze Element entry size: 0x04 */
struct TrackDesignMazeElement
{
union
{
uint32_t all;
struct
{
int8_t x;
int8_t y;
union
{
uint16_t maze_entry;
struct
{
uint8_t direction;
uint8_t type;
};
};
};
};
};

struct TrackDesign
{
uint8_t type;
Expand Down Expand Up @@ -96,7 +119,7 @@ struct TrackDesign
uint8_t lift_hill_speed;
uint8_t num_circuits;

std::vector<rct_td46_maze_element> maze_elements;
std::vector<TrackDesignMazeElement> maze_elements;
std::vector<TrackDesignTrackElement> track_elements;
std::vector<TrackDesignEntranceElement> entrance_elements;
std::vector<TrackDesignSceneryElement> scenery_elements;
Expand Down

0 comments on commit 0a00f62

Please sign in to comment.