1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Fix desync caused by provisional track piece peep interaction

This commit is contained in:
zsilencer
2016-10-26 15:00:05 -06:00
parent 24bd56af02
commit 1b47bdd180
6 changed files with 90 additions and 64 deletions

View File

@@ -482,7 +482,7 @@ static void window_ride_construction_draw_track_piece(
int width, int height
);
static void window_ride_construction_update_enabled_track_pieces();
static bool sub_6CA2DF(int *trackType, int *trackDirection, int *rideIndex, int *edxRS16, int *x, int *y, int *z, int *properties);
bool sub_6CA2DF(int *trackType, int *trackDirection, int *rideIndex, int *edxRS16, int *x, int *y, int *z, int *properties);
static void sub_6CBCE2(
int rideIndex, int trackType, int trackDirection, int edx,
int originX, int originY, int originZ
@@ -2546,7 +2546,7 @@ static bool sub_6CA2DF_get_track_element(uint8 *trackElement) {
* @param[out] _properties (edirs16)
* @return (CF)
*/
static bool sub_6CA2DF(int *_trackType, int *_trackDirection, int *_rideIndex, int *_edxRS16, int *_x, int *_y, int *_z, int *_properties) {
bool sub_6CA2DF(int *_trackType, int *_trackDirection, int *_rideIndex, int *_edxRS16, int *_x, int *_y, int *_z, int *_properties) {
uint8 trackType, trackDirection, rideIndex;
uint16 z, x, y, edxRS16, properties;
@@ -2722,7 +2722,7 @@ money32 sub_6CA162(int rideIndex, int trackType, int trackDirection, int edxRS16
_unkF440C5.y = y;
_unkF440C5.z = z;
_unkF440C5.direction = trackDirection;
_currentTrackSelectionFlags |= 2;
_currentTrackSelectionFlags |= (1 << 1);
viewport_set_visibility(gTrackGroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND ? 1 : 3);
if (_currentTrackSlopeEnd != 0)
viewport_set_visibility(2);
@@ -2741,7 +2741,7 @@ money32 sub_6CA162(int rideIndex, int trackType, int trackDirection, int edxRS16
_unkF440C5.z = z;
_unkF440C5.direction = trackDirection;
_currentTrackSelectionFlags |= 2;
_currentTrackSelectionFlags |= (1 << 1);
viewport_set_visibility(gTrackGroundFlags & TRACK_ELEMENT_LOCATION_IS_UNDERGROUND ? 1 : 3);
if (_currentTrackSlopeEnd != 0)
viewport_set_visibility(2);
@@ -2760,15 +2760,15 @@ void sub_6C94D8()
// Recheck if area is fine for new track.
// Set by footpath placement
if (_currentTrackSelectionFlags & 8) {
if (_currentTrackSelectionFlags & (1 << 3)) {
sub_6C9627();
_currentTrackSelectionFlags &= ~8;
_currentTrackSelectionFlags &= ~(1 << 3);
}
switch (_rideConstructionState) {
case RIDE_CONSTRUCTION_STATE_FRONT:
case RIDE_CONSTRUCTION_STATE_BACK:
if (!(_currentTrackSelectionFlags & 2)) {
if (!(_currentTrackSelectionFlags & (1 << 1))) {
if (sub_6CA2DF(&type, &direction, &rideIndex, &edxRS16, &x, &y, &z, NULL)) {
sub_6C96C0();
} else {
@@ -2781,7 +2781,7 @@ void sub_6C94D8()
break;
_rideConstructionArrowPulseTime = 5;
_currentTrackSelectionFlags ^= 1;
_currentTrackSelectionFlags ^= (1 << 0);
x = _currentTrackBeginX;
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
@@ -2796,7 +2796,7 @@ void sub_6C94D8()
direction ^= 2;
gMapSelectArrowDirection = direction;
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
if (_currentTrackSelectionFlags & 1)
if (_currentTrackSelectionFlags & (1 << 0))
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
map_invalidate_tile_full(x, y);
break;
@@ -2806,13 +2806,13 @@ void sub_6C94D8()
break;
_rideConstructionArrowPulseTime = 5;
_currentTrackSelectionFlags ^= 1;
_currentTrackSelectionFlags ^= (1 << 0);
x = _currentTrackBeginX;
y = _currentTrackBeginY;
z = _currentTrackBeginZ;
direction = _currentTrackPieceDirection & 3;
type = _currentTrackPieceType;
if (sub_6C683D(&x, &y, &z, direction, type, 0, NULL, _currentTrackSelectionFlags & 1 ? 2 : 1)) {
if (sub_6C683D(&x, &y, &z, direction, type, 0, NULL, _currentTrackSelectionFlags & (1 << 0) ? 2 : 1)) {
sub_6C96C0();
_rideConstructionState = RIDE_CONSTRUCTION_STATE_0;
}
@@ -2825,7 +2825,7 @@ void sub_6C94D8()
break;
_rideConstructionArrowPulseTime = 5;
_currentTrackSelectionFlags ^= 1;
_currentTrackSelectionFlags ^= (1 << 0);
x = _currentTrackBeginX & 0xFFE0;
y = _currentTrackBeginY & 0xFFE0;
z = _currentTrackBeginZ + 15;
@@ -2842,7 +2842,7 @@ void sub_6C94D8()
}
}
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
if (_currentTrackSelectionFlags & 1)
if (_currentTrackSelectionFlags & (1 << 0))
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE_ARROW;
map_invalidate_tile_full(x, y);
break;
@@ -3653,7 +3653,7 @@ void ride_construction_toolupdate_construct(int screenX, int screenY)
_currentTrackBeginY = y;
_currentTrackBeginZ = z;
if (
(_currentTrackSelectionFlags & 2) &&
(_currentTrackSelectionFlags & (1 << 1)) &&
x == _previousTrackPieceX &&
y == _previousTrackPieceY &&
z == _previousTrackPieceZ