Close #12243: Merge pull request #16295 from GalBr/use-coords-objects-in-maze-functions

Use Coords objects in maze functions
This commit is contained in:
Michael Steenbeek authored and GitHub committed 2021-12-22 19:16:34 +01:00
commit f65e12fc78
9 files changed
+18 -22

No files matched your search

+2 -1
View File
@@ -535,7 +535,8 @@ static void WindowMazeConstructionConstruct(int32_t direction)
break;
}
money32 cost = maze_set_track(x, y, z, flags, false, direction, _currentRideIndex, mode);
money32 cost = maze_set_track(
CoordsXYZD{ x, y, z, static_cast<uint8_t>(direction) }, flags, false, _currentRideIndex, mode);
if (cost == MONEY32_UNDEFINED)
{
return;
+1 -2
View File
@@ -3772,8 +3772,7 @@ void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords)
gDisableErrorWindowSound = true;
_trackPlaceCost = maze_set_track(
_currentTrackBegin.x, _currentTrackBegin.y, _currentTrackBegin.z, GAME_COMMAND_FLAG_APPLY, true, 0,
_currentRideIndex, GC_SET_MAZE_TRACK_BUILD);
CoordsXYZD{ _currentTrackBegin, 0 }, GAME_COMMAND_FLAG_APPLY, true, _currentRideIndex, GC_SET_MAZE_TRACK_BUILD);
gDisableErrorWindowSound = false;
+2 -4
View File
@@ -118,11 +118,9 @@ void guest_set_name(uint16_t spriteIndex, const char* name)
#pragma endregion
#pragma region MazeSetTrack
money32 maze_set_track(
uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, ride_id_t rideIndex,
uint8_t mode)
money32 maze_set_track(const CoordsXYZD& loc, uint8_t flags, bool initialPlacement, ride_id_t rideIndex, uint8_t mode)
{
auto gameAction = MazeSetTrackAction({ x, y, z, direction }, initialPlacement, rideIndex, mode);
auto gameAction = MazeSetTrackAction(loc, initialPlacement, rideIndex, mode);
gameAction.SetFlags(flags);
GameActions::Result res;
+5 -5
View File
@@ -207,7 +207,7 @@ GameActions::Result MazeSetTrackAction::Execute() const
{
case GC_SET_MAZE_TRACK_BUILD:
{
uint8_t segmentOffset = MazeGetSegmentBit(_loc.x, _loc.y);
uint8_t segmentOffset = MazeGetSegmentBit(_loc);
tileElement->AsTrack()->MazeEntrySubtract(1 << segmentOffset);
@@ -259,7 +259,7 @@ GameActions::Result MazeSetTrackAction::Execute() const
return res;
}
uint32_t segmentBit = MazeGetSegmentBit(previousSegment.x, previousSegment.y);
uint32_t segmentBit = MazeGetSegmentBit(previousSegment);
tileElement->AsTrack()->MazeEntryAdd(1 << segmentBit);
segmentBit--;
@@ -302,10 +302,10 @@ GameActions::Result MazeSetTrackAction::Execute() const
return res;
}
uint8_t MazeSetTrackAction::MazeGetSegmentBit(uint16_t x, uint16_t y) const
uint8_t MazeSetTrackAction::MazeGetSegmentBit(const CoordsXY& coords) const
{
uint8_t minorX = x & 0x1F; // 0 or 16
uint8_t minorY = y & 0x1F; // 0 or 16
uint8_t minorX = coords.x & 0x1F;
uint8_t minorY = coords.y & 0x1F;
if (minorX == 0 && minorY == 0)
{
+1 -1
View File
@@ -55,5 +55,5 @@ public:
GameActions::Result Execute() const override;
private:
uint8_t MazeGetSegmentBit(uint16_t x, uint16_t y) const;
uint8_t MazeGetSegmentBit(const CoordsXY&) const;
};
+1 -1
View File
@@ -40,7 +40,7 @@
// This string specifies which version of network stream current build uses.
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "8"
#define NETWORK_STREAM_VERSION "9"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION
static Peep* _pickup_peep = nullptr;
+4 -4
View File
@@ -492,10 +492,10 @@ void ride_remove_provisional_track_piece()
{
int32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
| GAME_COMMAND_FLAG_GHOST;
maze_set_track(x, y, z, flags, false, 0, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(x, y + 16, z, flags, false, 1, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(x + 16, y + 16, z, flags, false, 2, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(x + 16, y, z, flags, false, 3, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(CoordsXYZD{ x, y, z, 0 }, flags, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(CoordsXYZD{ x, y + 16, z, 1 }, flags, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(CoordsXYZD{ x + 16, y + 16, z, 2 }, flags, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
maze_set_track(CoordsXYZD{ x + 16, y, z, 3 }, flags, false, rideIndex, GC_SET_MAZE_TRACK_FILL);
}
else
{
+1 -3
View File
@@ -577,8 +577,6 @@ roll_type_t track_get_actual_bank_3(bool useInvertedSprites, TileElement* tileEl
bool track_add_station_element(CoordsXYZD loc, ride_id_t rideIndex, int32_t flags, bool fromTrackDesign);
bool track_remove_station_element(const CoordsXYZD& loc, ride_id_t rideIndex, int32_t flags);
money32 maze_set_track(
uint16_t x, uint16_t y, uint16_t z, uint8_t flags, bool initialPlacement, uint8_t direction, ride_id_t rideIndex,
uint8_t mode);
money32 maze_set_track(const CoordsXYZD& coords, uint8_t flags, bool initialPlacement, ride_id_t rideIndex, uint8_t mode);
bool TrackTypeHasSpeedSetting(track_type_t trackType);
+1 -1
View File
@@ -57,7 +57,7 @@ money32 place_provisional_track_piece(
{
int32_t flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_NO_SPEND
| GAME_COMMAND_FLAG_GHOST; // 105
auto result = maze_set_track(trackPos.x, trackPos.y, trackPos.z, flags, true, 0, rideIndex, GC_SET_MAZE_TRACK_BUILD);
auto result = maze_set_track(CoordsXYZD{ trackPos, 0 }, flags, true, rideIndex, GC_SET_MAZE_TRACK_BUILD);
if (result == MONEY32_UNDEFINED)
return result;