diff --git a/src/openrct2-ui/windows/MazeConstruction.cpp b/src/openrct2-ui/windows/MazeConstruction.cpp index 2f434c96f5..e3d02f6483 100644 --- a/src/openrct2-ui/windows/MazeConstruction.cpp +++ b/src/openrct2-ui/windows/MazeConstruction.cpp @@ -509,7 +509,7 @@ static void window_maze_construction_construct(sint32 direction) break; } - money32 cost = maze_set_track(x, y, z, flags, direction, _currentRideIndex, mode); + money32 cost = maze_set_track(x, y, z, flags, false, direction, _currentRideIndex, mode); if (cost == MONEY32_UNDEFINED) { return; } diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 71e5a6900e..e5f184773f 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3560,7 +3560,8 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY) _currentTrackBeginY, _currentTrackBeginZ, GAME_COMMAND_FLAG_APPLY, - 4, + true, + 0, _currentRideIndex, GC_SET_MAZE_TRACK_BUILD); diff --git a/src/openrct2/actions/GameActionCompat.cpp b/src/openrct2/actions/GameActionCompat.cpp index f5664552e8..3a953506d2 100644 --- a/src/openrct2/actions/GameActionCompat.cpp +++ b/src/openrct2/actions/GameActionCompat.cpp @@ -253,9 +253,9 @@ #pragma endregion #pragma region MazeSetTrack - money32 maze_set_track(uint16 x, uint16 y, uint16 z, uint8 flags, uint8 direction, uint8 rideIndex, uint8 mode) + money32 maze_set_track(uint16 x, uint16 y, uint16 z, uint8 flags, bool initialPlacement, uint8 direction, uint8 rideIndex, uint8 mode) { - auto gameAction = MazeSetTrackAction(x, y, z, direction, rideIndex, mode); + auto gameAction = MazeSetTrackAction(x, y, z, initialPlacement, direction, rideIndex, mode); gameAction.SetFlags(flags); GameActionResult::Ptr res; diff --git a/src/openrct2/actions/MazeSetTrackAction.hpp b/src/openrct2/actions/MazeSetTrackAction.hpp index 3e46a3f2e8..98c61ec78b 100644 --- a/src/openrct2/actions/MazeSetTrackAction.hpp +++ b/src/openrct2/actions/MazeSetTrackAction.hpp @@ -56,16 +56,18 @@ private: uint16 _x; uint16 _y; uint16 _z; + bool _initialPlacement; uint8 _direction; uint8 _rideIndex; uint8 _mode; public: MazeSetTrackAction() {} - MazeSetTrackAction(uint16 x, uint16 y, uint16 z, uint8 direction, uint8 rideIndex, uint8 mode) + MazeSetTrackAction(uint16 x, uint16 y, uint16 z, bool initialPlacement, uint8 direction, uint8 rideIndex, uint8 mode) : _x(x), _y(y), _z(z), + _initialPlacement(initialPlacement), _direction(direction), _rideIndex(rideIndex), _mode(mode) @@ -81,7 +83,7 @@ public: { GameAction::Serialise(stream); - stream << _x << _y << _z << _direction << _rideIndex << _mode; + stream << _x << _y << _z << _initialPlacement << _direction << _rideIndex << _mode; } GameActionResult::Ptr Query() const override @@ -247,13 +249,10 @@ public: ride->station_heights[0] = tileElement->base_height; ride->station_starts[0].xy = 0; - if (_direction == 4) + if (_initialPlacement && !(flags & GAME_COMMAND_FLAG_GHOST)) { - if (!(flags & GAME_COMMAND_FLAG_GHOST)) - { - ride->overall_view.x = flooredX / 32; - ride->overall_view.y = flooredY / 32; - } + ride->overall_view.x = flooredX / 32; + ride->overall_view.y = flooredY / 32; } } @@ -265,7 +264,7 @@ public: tileElement->properties.track.maze_entry &= ~(1 << segmentOffset); - if (_direction != 4) + if (!_initialPlacement) { segmentOffset = byte_993CE9[(_direction + segmentOffset)]; tileElement->properties.track.maze_entry &= ~(1 << segmentOffset); @@ -301,7 +300,7 @@ public: break; case GC_SET_MAZE_TRACK_FILL: - if (_direction != 4) + if (!_initialPlacement) { uint16 previousSegmentX = _x - TileDirectionDelta[_direction].x / 2; uint16 previousSegmentY = _y - TileDirectionDelta[_direction].y / 2; diff --git a/src/openrct2/actions/RideDemolishAction.hpp b/src/openrct2/actions/RideDemolishAction.hpp index 7fb5de0f2e..5948fbd4d3 100644 --- a/src/openrct2/actions/RideDemolishAction.hpp +++ b/src/openrct2/actions/RideDemolishAction.hpp @@ -114,7 +114,7 @@ public: { peep->current_ride = MAX_RIDES; if (peep->time_to_stand >= 50) - { + { // make peep stop watching the ride peep->time_to_stand = 50; } @@ -223,7 +223,7 @@ private: money32 MazeRemoveTrack(uint16 x, uint16 y, uint16 z, uint8 direction) const { - auto setMazeTrack = MazeSetTrackAction(x, y, z, direction, _rideIndex, GC_SET_MAZE_TRACK_FILL); + auto setMazeTrack = MazeSetTrackAction(x, y, z, false, direction, _rideIndex, GC_SET_MAZE_TRACK_FILL); setMazeTrack.SetFlags(GetFlags()); auto queryRes = setMazeTrack.Query(); @@ -236,7 +236,7 @@ private: } } - return MONEY16_UNDEFINED; + return MONEY32_UNDEFINED; } money32 DemolishTracks() const @@ -249,7 +249,7 @@ private: tile_element_iterator it; tile_element_iterator_begin(&it); - while (tile_element_iterator_next(&it)) + while (tile_element_iterator_next(&it)) { if (tile_element_get_type(it.element) != TILE_ELEMENT_TYPE_TRACK) continue; @@ -263,7 +263,7 @@ private: uint8 rotation = tile_element_get_direction(it.element); uint8 type = track_element_get_type(it.element); - if (type != TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP) + if (type != TRACK_ELEM_INVERTED_90_DEG_UP_TO_FLAT_QUARTER_LOOP) { money32 removePrice = game_do_command( x, @@ -274,9 +274,9 @@ private: z, 0); - if (removePrice == MONEY32_UNDEFINED) + if (removePrice == MONEY32_UNDEFINED) tile_element_remove(it.element); - else + else refundPrice += removePrice; tile_element_iterator_restart_for_tile(&it); diff --git a/src/openrct2/ride/Ride.cpp b/src/openrct2/ride/Ride.cpp index d6e9790349..70750d8814 100644 --- a/src/openrct2/ride/Ride.cpp +++ b/src/openrct2/ride/Ride.cpp @@ -1382,10 +1382,10 @@ void ride_remove_provisional_track_piece() if (ride->type == RIDE_TYPE_MAZE) { sint32 flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST; - maze_set_track(x, y, z, flags, 0, rideIndex, GC_SET_MAZE_TRACK_FILL); - maze_set_track(x, y + 16, z, flags, 1, rideIndex, GC_SET_MAZE_TRACK_FILL); - maze_set_track(x + 16, y + 16, z, flags, 2, rideIndex, GC_SET_MAZE_TRACK_FILL); - maze_set_track(x + 16, y, z, flags, 3, rideIndex, GC_SET_MAZE_TRACK_FILL); + 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); } else { diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index 728e227f87..031b6fc321 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -557,7 +557,7 @@ void game_command_place_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * void game_command_remove_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); void game_command_set_maze_track(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); -money32 maze_set_track(uint16 x, uint16 y, uint16 z, uint8 flags, uint8 direction, uint8 rideIndex, uint8 mode); +money32 maze_set_track(uint16 x, uint16 y, uint16 z, uint8 flags, bool initialPlacement, uint8 direction, uint8 rideIndex, uint8 mode); void game_command_set_brakes_speed(sint32 * eax, sint32 * ebx, sint32 * ecx, sint32 * edx, sint32 * esi, sint32 * edi, sint32 * ebp); bool track_element_is_booster(uint8 rideType, uint8 trackType); diff --git a/src/openrct2/windows/_legacy.cpp b/src/openrct2/windows/_legacy.cpp index e51cb92f69..eac0ff3735 100644 --- a/src/openrct2/windows/_legacy.cpp +++ b/src/openrct2/windows/_legacy.cpp @@ -139,7 +139,7 @@ money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 if (ride->type == RIDE_TYPE_MAZE) { sint32 flags = GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST; // 105 - result = maze_set_track(x, y, z, flags, 4, rideIndex, GC_SET_MAZE_TRACK_BUILD); + result = maze_set_track(x, y, z, flags, true, 0, rideIndex, GC_SET_MAZE_TRACK_BUILD); if (result == MONEY32_UNDEFINED) return result; @@ -163,7 +163,7 @@ money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 return result; } - else + else { result = game_do_command(x, 105 | (trackDirection << 8), y, rideIndex | (trackType << 8) | (liftHillAndAlternativeState << 16), GAME_COMMAND_PLACE_TRACK, z, 0); if (result == MONEY32_UNDEFINED)