mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 11:03:00 +01:00
Update maze element
This commit is contained in:
@@ -547,7 +547,7 @@ static Widget _trackPlaceWidgets[] = {
|
||||
uint8_t rotation = (_currentTrackPieceDirection + GetCurrentRotation()) & 3;
|
||||
for (const auto& mazeElement : td6->mazeElements)
|
||||
{
|
||||
auto rotatedMazeCoords = origin + TileCoordsXY{ mazeElement.x, mazeElement.y }.ToCoordsXY().Rotate(rotation);
|
||||
auto rotatedMazeCoords = origin + mazeElement.location.ToCoordsXY().Rotate(rotation);
|
||||
|
||||
if (pass == 0)
|
||||
{
|
||||
|
||||
@@ -703,19 +703,20 @@ template<> struct DataSerializerTraitsT<TrackDesignMazeElement>
|
||||
{
|
||||
static void encode(OpenRCT2::IStream* stream, const TrackDesignMazeElement& val)
|
||||
{
|
||||
uint32_t temp = ByteSwapBE(val.all);
|
||||
stream->Write(&temp);
|
||||
stream->Write(&val.location);
|
||||
stream->Write(&val.mazeEntry);
|
||||
}
|
||||
static void decode(OpenRCT2::IStream* stream, TrackDesignMazeElement& val)
|
||||
{
|
||||
uint32_t temp;
|
||||
stream->Read(&temp);
|
||||
val.all = ByteSwapBE(temp);
|
||||
stream->Read(&val.location);
|
||||
stream->Read(&val.mazeEntry);
|
||||
}
|
||||
static void log(OpenRCT2::IStream* stream, const TrackDesignMazeElement& val)
|
||||
{
|
||||
char msg[128] = {};
|
||||
snprintf(msg, sizeof(msg), "TrackDesignMazeElement(all = %d)", val.all);
|
||||
snprintf(
|
||||
msg, sizeof(msg), "TrackDesignMazeElement(x = %d, y = %d, entry = %d)", val.location.x, val.location.y,
|
||||
val.mazeEntry);
|
||||
stream->Write(msg, strlen(msg));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -946,10 +946,9 @@ void ImportMazeElement(TrackDesign& td, const TD46MazeElement& td46MazeElement)
|
||||
else
|
||||
{
|
||||
TrackDesignMazeElement mazeElement{};
|
||||
mazeElement.x = td46MazeElement.x;
|
||||
mazeElement.y = td46MazeElement.y;
|
||||
mazeElement.direction = td46MazeElement.Direction;
|
||||
mazeElement.type = td46MazeElement.Type;
|
||||
mazeElement.location.x = td46MazeElement.x;
|
||||
mazeElement.location.y = td46MazeElement.y;
|
||||
mazeElement.mazeEntry = td46MazeElement.MazeEntry;
|
||||
td.mazeElements.push_back(mazeElement);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,7 +104,9 @@ namespace RCT2
|
||||
{
|
||||
for (const auto& mazeElement : _trackDesign->mazeElements)
|
||||
{
|
||||
tempStream.WriteValue<uint32_t>(mazeElement.all);
|
||||
tempStream.WriteValue<int8_t>(mazeElement.location.x);
|
||||
tempStream.WriteValue<int8_t>(mazeElement.location.y);
|
||||
tempStream.WriteValue<uint16_t>(mazeElement.mazeEntry);
|
||||
}
|
||||
|
||||
for (const auto& entranceElement : _trackDesign->entranceElements)
|
||||
|
||||
@@ -376,9 +376,9 @@ ResultWithMessage TrackDesign::CreateTrackDesignMaze(TrackDesignState& tds, cons
|
||||
|
||||
TrackDesignMazeElement maze{};
|
||||
|
||||
maze.maze_entry = tileElement->AsTrack()->GetMazeEntry();
|
||||
maze.x = (x - startLoc.x) / COORDS_XY_STEP;
|
||||
maze.y = (y - startLoc.y) / COORDS_XY_STEP;
|
||||
maze.mazeEntry = tileElement->AsTrack()->GetMazeEntry();
|
||||
maze.location.x = (x - startLoc.x) / COORDS_XY_STEP;
|
||||
maze.location.y = (y - startLoc.y) / COORDS_XY_STEP;
|
||||
_saveDirection = tileElement->GetDirection();
|
||||
mazeElements.push_back(maze);
|
||||
|
||||
@@ -906,16 +906,16 @@ static void TrackDesignMirrorMaze(TrackDesign* td6)
|
||||
{
|
||||
for (auto& maze : td6->mazeElements)
|
||||
{
|
||||
maze.y = -maze.y;
|
||||
maze.location.y = -maze.location.y;
|
||||
|
||||
uint16_t maze_entry = maze.maze_entry;
|
||||
uint16_t new_entry = 0;
|
||||
for (uint8_t position = UtilBitScanForward(maze_entry); position != 0xFF; position = UtilBitScanForward(maze_entry))
|
||||
auto mazeEntry = maze.mazeEntry;
|
||||
uint16_t newEntry = 0;
|
||||
for (uint8_t position = UtilBitScanForward(mazeEntry); position != 0xFF; position = UtilBitScanForward(mazeEntry))
|
||||
{
|
||||
maze_entry &= ~(1 << position);
|
||||
new_entry |= (1 << maze_segment_mirror_map[position]);
|
||||
mazeEntry &= ~(1 << position);
|
||||
newEntry |= (1 << maze_segment_mirror_map[position]);
|
||||
}
|
||||
maze.maze_entry = new_entry;
|
||||
maze.mazeEntry = newEntry;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1456,7 +1456,7 @@ static GameActions::Result TrackDesignPlaceMaze(
|
||||
for (const auto& maze_element : td.mazeElements)
|
||||
{
|
||||
uint8_t rotation = _currentTrackPieceDirection & 3;
|
||||
CoordsXY mazeMapPos = TileCoordsXY(maze_element.x, maze_element.y).ToCoordsXY();
|
||||
CoordsXY mazeMapPos = maze_element.location.ToCoordsXY();
|
||||
auto mapCoord = mazeMapPos.Rotate(rotation);
|
||||
mapCoord += origin;
|
||||
|
||||
@@ -1473,7 +1473,7 @@ static GameActions::Result TrackDesignPlaceMaze(
|
||||
uint8_t flags;
|
||||
money64 cost = 0;
|
||||
|
||||
uint16_t maze_entry = Numerics::rol16(maze_element.maze_entry, rotation * 4);
|
||||
uint16_t mazeEntry = Numerics::rol16(maze_element.mazeEntry, rotation * 4);
|
||||
|
||||
if (tds.PlaceOperation == PTD_OPERATION_PLACE_TRACK_PREVIEW)
|
||||
{
|
||||
@@ -1497,7 +1497,7 @@ static GameActions::Result TrackDesignPlaceMaze(
|
||||
flags |= GAME_COMMAND_FLAG_REPLAY;
|
||||
}
|
||||
|
||||
auto mazePlace = MazePlaceTrackAction({ mapCoord, origin.z }, ride.id, maze_entry);
|
||||
auto mazePlace = MazePlaceTrackAction({ mapCoord, origin.z }, ride.id, mazeEntry);
|
||||
mazePlace.SetFlags(flags);
|
||||
auto res = flags & GAME_COMMAND_FLAG_APPLY ? GameActions::ExecuteNested(&mazePlace)
|
||||
: GameActions::QueryNested(&mazePlace);
|
||||
|
||||
@@ -90,27 +90,10 @@ struct TrackDesignTrackElement
|
||||
}
|
||||
};
|
||||
|
||||
/* 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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
TileCoordsXY location{};
|
||||
uint16_t mazeEntry{};
|
||||
};
|
||||
|
||||
class DataSerialiser;
|
||||
|
||||
Reference in New Issue
Block a user