Fix #7443: Construction arrows pulse at irregular intervals.

This commit is contained in:
Simon Jarrett 2020-10-03 18:41:56 +01:00 committed by Simon Jarrett
parent 26720eb345
commit 25ce8b3f6e
6 changed files with 36 additions and 44 deletions

View File

@ -12,6 +12,7 @@
- Fix: [#5178] Lighting effects cannot be disabled in software mode
- Fix: [#5904] Empty errors on tile inspector base height change.
- Fix: [#6086] Cannot install existing track design with another name.
- Fix: [#7443] Construction arrows pulse at irregular intervals.
- Fix: [#7748] Tooltips would not timeout for normal UI elements.
- Fix: [#8015] RCT2 files are not found when put into the OpenRCT2 folder.
- Fix: [#8957] Error title missing when building with insufficient funds

View File

@ -19,6 +19,7 @@
#include <openrct2/audio/audio.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/object/ObjectLimits.h>
#include <openrct2/platform/platform.h>
#include <openrct2/sprites.h>
#include <openrct2/world/Footpath.h>
#include <openrct2/world/Park.h>
@ -27,6 +28,7 @@
static constexpr const rct_string_id WINDOW_TITLE = STR_FOOTPATHS;
static constexpr const int32_t WH = 381;
static constexpr const int32_t WW = 106;
static constexpr const uint16_t ARROW_PULSE_DURATION = 200;
// clang-format off
enum
@ -129,7 +131,7 @@ static rct_window_event_list window_footpath_events([](auto& events)
// clang-format on
static money32 _window_footpath_cost;
static int8_t _window_footpath_provisional_path_arrow_timer;
static uint32_t _footpathConstructionNextArrowPulse = 0;
static uint8_t _lastUpdatedCameraRotation = UINT8_MAX;
static bool _footpathErrorOccured;
@ -473,10 +475,13 @@ static void window_footpath_update_provisional_path_for_bridge_mode(rct_window*
widget_invalidate(w, WIDX_CONSTRUCT);
}
auto curTime = platform_get_ticks();
// Update little directional arrow on provisional bridge mode path
if (--_window_footpath_provisional_path_arrow_timer < 0)
if (_footpathConstructionNextArrowPulse < curTime)
{
_window_footpath_provisional_path_arrow_timer = 5;
_footpathConstructionNextArrowPulse = curTime + ARROW_PULSE_DURATION;
gFootpathProvisionalFlags ^= PROVISIONAL_PATH_FLAG_SHOW_ARROW;
CoordsXYZ footpathLoc;
footpath_get_next_path_info(&type, footpathLoc, &slope);
@ -932,7 +937,6 @@ static void window_footpath_start_bridge_at_point(const ScreenCoordsXY& screenCo
gFootpathConstructFromPosition = { mapCoords, z };
gFootpathConstructDirection = direction;
gFootpathProvisionalFlags = 0;
_window_footpath_provisional_path_arrow_timer = 0;
gFootpathConstructSlope = 0;
gFootpathConstructionMode = PATH_CONSTRUCTION_MODE_BRIDGE_OR_TUNNEL;
gFootpathConstructValidDirections = INVALID_DIRECTION;

View File

@ -25,6 +25,7 @@
#include <openrct2/config/Config.h>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/network/network.h>
#include <openrct2/platform/platform.h>
#include <openrct2/ride/Ride.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/Track.h>
@ -38,6 +39,7 @@
static constexpr const rct_string_id WINDOW_TITLE = STR_RIDE_CONSTRUCTION_WINDOW_TITLE;
static constexpr const int32_t WH = 394;
static constexpr const int32_t WW = 166;
static constexpr const uint16_t ARROW_PULSE_DURATION = 200;
#pragma region Widgets
@ -441,6 +443,7 @@ static uint8_t _currentlyShowingBrakeOrBoosterSpeed;
static bool _boosterTrackSelected;
static uint32_t _currentDisabledSpecialTrackPieces;
static uint32_t _rideConstructionNextArrowPulse = 0;
static void window_ride_construction_construct(rct_window* w);
static void window_ride_construction_mouseup_demolish(rct_window* w);
@ -562,7 +565,6 @@ rct_window* window_ride_construction_open()
_currentTrackPieceDirection = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_PLACE;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_autoOpeningShop = false;
_autoRotatingShop = true;
_trackPlaceCtrlState = false;
@ -1708,7 +1710,6 @@ static void RideConstructPlacedForwardGameActionCallback(const GameAction* ga, c
_currentTrackPieceDirection = next_track.element->GetDirection();
_currentTrackPieceType = next_track.element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
ride_select_next_section();
}
@ -1752,7 +1753,6 @@ static void RideConstructPlacedBackwardGameActionCallback(const GameAction* ga,
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_SELECTED;
ride_select_previous_section();
}
@ -2550,6 +2550,7 @@ void sub_6C94D8()
{
case RIDE_CONSTRUCTION_STATE_FRONT:
case RIDE_CONSTRUCTION_STATE_BACK:
{
if (!(_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_TRACK))
{
if (window_ride_construction_update_state(
@ -2564,11 +2565,12 @@ void sub_6C94D8()
window_ride_construction_update_active_elements();
}
}
_rideConstructionArrowPulseTime--;
if (_rideConstructionArrowPulseTime >= 0)
break;
_rideConstructionArrowPulseTime = 5;
auto curTime = platform_get_ticks();
if (_rideConstructionNextArrowPulse >= curTime)
break;
_rideConstructionNextArrowPulse = curTime + ARROW_PULSE_DURATION;
_currentTrackSelectionFlags ^= TRACK_SELECTION_FLAG_ARROW;
trackPos = _currentTrackBegin;
direction = _currentTrackPieceDirection;
@ -2584,13 +2586,14 @@ void sub_6C94D8()
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
map_invalidate_tile_full(trackPos);
break;
}
case RIDE_CONSTRUCTION_STATE_SELECTED:
{
_rideConstructionArrowPulseTime--;
if (_rideConstructionArrowPulseTime >= 0)
auto curTime = platform_get_ticks();
if (_rideConstructionNextArrowPulse >= curTime)
break;
_rideConstructionNextArrowPulse = curTime + ARROW_PULSE_DURATION;
_rideConstructionArrowPulseTime = 5;
_currentTrackSelectionFlags ^= TRACK_SELECTION_FLAG_ARROW;
direction = _currentTrackPieceDirection & 3;
type = _currentTrackPieceType;
@ -2604,14 +2607,15 @@ void sub_6C94D8()
}
break;
}
case 6:
case 7:
case 8:
_rideConstructionArrowPulseTime--;
if (_rideConstructionArrowPulseTime >= 0)
case RIDE_CONSTRUCTION_STATE_MAZE_BUILD:
case RIDE_CONSTRUCTION_STATE_MAZE_MOVE:
case RIDE_CONSTRUCTION_STATE_MAZE_FILL:
{
auto curTime = platform_get_ticks();
if (_rideConstructionNextArrowPulse >= curTime)
break;
_rideConstructionNextArrowPulse = curTime + ARROW_PULSE_DURATION;
_rideConstructionArrowPulseTime = 5;
_currentTrackSelectionFlags ^= TRACK_SELECTION_FLAG_ARROW;
trackPos = CoordsXYZ{ _currentTrackBegin.x & 0xFFE0, _currentTrackBegin.y & 0xFFE0, _currentTrackBegin.z + 15 };
gMapSelectArrowPosition = trackPos;
@ -2631,6 +2635,7 @@ void sub_6C94D8()
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
map_invalidate_tile_full(trackPos);
break;
}
}
}
@ -3755,7 +3760,6 @@ void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords)
_currentTrackBegin.y = mapCoords.y;
_currentTrackBegin.z = z;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
auto intent = Intent(INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION);
context_broadcast_intent(&intent);
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
@ -3812,7 +3816,6 @@ void ride_construction_tooldown_construct(const ScreenCoordsXY& screenCoords)
_currentTrackBegin.y = mapCoords.y;
_currentTrackBegin.z = z;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
window_ride_construction_update_active_elements();
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
if (w == nullptr)

View File

@ -101,7 +101,6 @@ CoordsXYZ _currentTrackBegin;
uint8_t _currentTrackPieceDirection;
track_type_t _currentTrackPieceType;
uint8_t _currentTrackSelectionFlags;
int8_t _rideConstructionArrowPulseTime;
uint8_t _currentTrackSlopeEnd;
uint8_t _currentTrackBankEnd;
uint8_t _currentTrackLiftHill;
@ -1611,6 +1610,12 @@ void ride_select_next_section()
// Set next element's height.
virtual_floor_set_height(tileElement->GetBaseZ());
}
_currentTrackBegin = *newCoords;
_currentTrackPieceDirection = tileElement->GetDirection();
_currentTrackPieceType = tileElement->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
window_ride_construction_update_active_elements();
}
else
{
@ -1619,18 +1624,9 @@ void ride_select_next_section()
_currentTrackPieceDirection = direction;
_currentTrackPieceType = tileElement->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
ride_construction_set_default_next_piece();
window_ride_construction_update_active_elements();
return;
}
_currentTrackBegin = *newCoords;
_currentTrackPieceDirection = tileElement->GetDirection();
_currentTrackPieceType = tileElement->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
window_ride_construction_update_active_elements();
}
else if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_BACK)
{
@ -1673,7 +1669,6 @@ void ride_select_previous_section()
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
if (!scenery_tool_is_active())
{
// Set previous element's height.
@ -1690,7 +1685,6 @@ void ride_select_previous_section()
_currentTrackPieceDirection = trackBeginEnd.end_direction;
_currentTrackPieceType = tileElement->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
ride_construction_set_default_next_piece();
window_ride_construction_update_active_elements();
}
@ -1799,7 +1793,6 @@ static bool ride_modify_maze(const CoordsXYE& tileElement)
_currentTrackBegin.y = tileElement.y;
_currentTrackBegin.z = trackElement->GetBaseZ();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
auto intent = Intent(INTENT_ACTION_UPDATE_MAZE_CONSTRUCTION);
context_broadcast_intent(&intent);
@ -1880,7 +1873,6 @@ bool ride_modify(CoordsXYE* input)
_currentTrackPieceDirection = direction;
_currentTrackPieceType = type;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
if (ride_type_has_flag(ride->type, RIDE_TYPE_FLAG_HAS_NO_TRACK))
{
@ -1900,7 +1892,6 @@ bool ride_modify(CoordsXYE* input)
_currentTrackPieceDirection = direction;
_currentTrackPieceType = type;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
ride_select_previous_section();
@ -1911,7 +1902,6 @@ bool ride_modify(CoordsXYE* input)
_currentTrackPieceDirection = direction;
_currentTrackPieceType = type;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
}
window_ride_construction_update_active_elements();
@ -1958,7 +1948,6 @@ int32_t ride_initialise_construction_window(Ride* ride)
_currentTrackPieceDirection = 0;
_rideConstructionState = RIDE_CONSTRUCTION_STATE_PLACE;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
window_ride_construction_update_active_elements();
return 1;
@ -6260,7 +6249,6 @@ bool ride_select_backwards_from_front()
_currentTrackPieceDirection = trackBeginEnd.begin_direction;
_currentTrackPieceType = trackBeginEnd.begin_element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
return true;
}
}
@ -6286,7 +6274,6 @@ bool ride_select_forwards_from_back()
_currentTrackPieceDirection = next_track.element->GetDirection();
_currentTrackPieceType = next_track.element->AsTrack()->GetTrackType();
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
return true;
}
}

View File

@ -1061,7 +1061,6 @@ extern CoordsXYZ _currentTrackBegin;
extern uint8_t _currentTrackPieceDirection;
extern track_type_t _currentTrackPieceType;
extern uint8_t _currentTrackSelectionFlags;
extern int8_t _rideConstructionArrowPulseTime;
extern uint8_t _currentTrackSlopeEnd;
extern uint8_t _currentTrackBankEnd;
extern uint8_t _currentTrackLiftHill;

View File

@ -434,7 +434,6 @@ void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piec
_currentTrackBegin.z = floor2(piecePos.z, COORDS_Z_STEP);
_rideConstructionState = RIDE_CONSTRUCTION_STATE_FRONT;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
_currentTrackPieceDirection = piecePos.direction & 3;
int32_t savedCurrentTrackCurve = _currentTrackCurve;
int32_t savedPreviousTrackSlopeEnd = _previousTrackSlopeEnd;
@ -489,7 +488,6 @@ void window_ride_construction_mouseup_demolish_next_piece(const CoordsXYZD& piec
_currentTrackPieceDirection = piecePos.direction;
_currentTrackPieceType = type;
_currentTrackSelectionFlags = 0;
_rideConstructionArrowPulseTime = 0;
if (_rideConstructionState2 == RIDE_CONSTRUCTION_STATE_FRONT)
{
ride_select_next_section();