1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-27 08:45:00 +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

@@ -218,6 +218,8 @@ static void ride_set_vehicle_colours_to_random_preset(rct_ride *ride, uint8 pres
static void maze_entrance_hedge_removal(int x, int y, rct_map_element *mapElement);
void loc_6DDF9C(rct_ride *ride, rct_map_element *mapElement);
static void maze_entrance_hedge_replacement(int x, int y, rct_map_element *mapElement);
bool sub_6CA2DF(int *trackType, int *trackDirection, int *rideIndex, int *edxRS16, int *x, int *y, int *z, int *properties);
money32 sub_6CA162(int rideIndex, int trackType, int trackDirection, int edxRS16, int x, int y, int z);
rct_ride *get_ride(int index)
{
@@ -1347,7 +1349,7 @@ int sub_6C683D(int* x, int* y, int* z, int direction, int type, uint16 extra_par
void ride_restore_provisional_entrance_or_exit()
{
if (_currentTrackSelectionFlags & (1 << 2)) {
money32 result = game_do_command(
game_do_command(
_unkF440BF.x,
(GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_ALLOW_DURING_PAUSED | GAME_COMMAND_FLAG_5 | GAME_COMMAND_FLAG_GHOST) | (_unkF440BF.direction << 8),
_unkF440BF.y,
@@ -1374,54 +1376,75 @@ void ride_remove_provisional_entrance_or_exit()
}
}
void ride_restore_provisional_track_piece()
{
if (_currentTrackSelectionFlags & (1 << 1)) {
int x, y, z, direction, type, rideIndex, edxRS16;
if (sub_6CA2DF(&type, &direction, &rideIndex, &edxRS16, &x, &y, &z, NULL)) {
sub_6C96C0();
} else {
_currentTrackPrice = sub_6CA162(rideIndex, type, direction, edxRS16, x, y, z);
sub_6C84CE();
}
}
}
void ride_remove_provisional_track_piece()
{
if (!(_currentTrackSelectionFlags & (1 << 1))) {
return;
}
rct_ride *ride;
int rideIndex, x, y, z, direction;
rideIndex = _currentRideIndex;
x = _unkF440C5.x;
y = _unkF440C5.y;
z = _unkF440C5.z;
ride = get_ride(rideIndex);
if (ride->type == RIDE_TYPE_MAZE) {
game_do_command(x , 41 | (0 << 8), y , rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
game_do_command(x , 41 | (1 << 8), y + 16, rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
game_do_command(x + 16, 41 | (2 << 8), y + 16, rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
game_do_command(x + 16, 41 | (3 << 8), y , rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
} else {
direction = _unkF440C5.direction;
if (!(direction & 4)) {
x -= TileDirectionDelta[direction].x;
y -= TileDirectionDelta[direction].y;
}
rct_xy_element next_track;
if (track_block_get_next_from_zero(x, y, z, rideIndex, direction, &next_track, &z, &direction)) {
game_do_command(
next_track.x,
105 | ((direction & 3) << 8),
next_track.y,
next_track.element->properties.track.type | ((next_track.element->properties.track.sequence & 0x0F) << 8),
GAME_COMMAND_REMOVE_TRACK,
z,
0
);
}
}
}
/**
*
* rct2: 0x006C96C0
*/
void sub_6C96C0()
{
rct_ride *ride;
int rideIndex, x, y, z, direction;
if (_currentTrackSelectionFlags & (1 << 2)) {
ride_remove_provisional_entrance_or_exit();
_currentTrackSelectionFlags &= ~(1 << 2);
}
if (_currentTrackSelectionFlags & 2) {
_currentTrackSelectionFlags &= ~2;
rideIndex = _currentRideIndex;
x = _unkF440C5.x;
y = _unkF440C5.y;
z = _unkF440C5.z;
ride = get_ride(rideIndex);
if (ride->type == RIDE_TYPE_MAZE) {
game_do_command(x , 41 | (0 << 8), y , rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
game_do_command(x , 41 | (1 << 8), y + 16, rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
game_do_command(x + 16, 41 | (2 << 8), y + 16, rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
game_do_command(x + 16, 41 | (3 << 8), y , rideIndex | (2 << 8), GAME_COMMAND_SET_MAZE_TRACK, z, 0);
} else {
direction = _unkF440C5.direction;
if (!(direction & 4)) {
x -= TileDirectionDelta[direction].x;
y -= TileDirectionDelta[direction].y;
}
rct_xy_element next_track;
if (track_block_get_next_from_zero(x, y, z, rideIndex, direction, &next_track, &z, &direction)) {
game_do_command(
next_track.x,
105 | ((direction & 3) << 8),
next_track.y,
next_track.element->properties.track.type | ((next_track.element->properties.track.sequence & 0x0F) << 8),
GAME_COMMAND_REMOVE_TRACK,
z,
0
);
}
}
if (_currentTrackSelectionFlags & (1 << 1)) {
ride_remove_provisional_track_piece();
_currentTrackSelectionFlags &= ~(1 << 1);
}
}
@@ -1448,7 +1471,7 @@ void sub_6C9627()
case RIDE_CONSTRUCTION_STATE_MAZE_BUILD:
case RIDE_CONSTRUCTION_STATE_MAZE_MOVE:
case RIDE_CONSTRUCTION_STATE_MAZE_FILL:
if (_currentTrackSelectionFlags & 1) {
if (_currentTrackSelectionFlags & (1 << 0)) {
map_invalidate_tile_full(
_currentTrackBeginX & 0xFFE0,
_currentTrackBeginY & 0xFFE0
@@ -1457,8 +1480,8 @@ void sub_6C9627()
}
break;
default:
if (_currentTrackSelectionFlags & 1) {
_currentTrackSelectionFlags &= ~1;
if (_currentTrackSelectionFlags & (1 << 0)) {
_currentTrackSelectionFlags &= ~(1 << 0);
gMapSelectFlags &= ~MAP_SELECT_FLAG_ENABLE_ARROW;
map_invalidate_tile_full(_currentTrackBeginX, _currentTrackBeginY);
}

View File

@@ -1060,6 +1060,8 @@ money32 ride_create_command(int type, int subType, int flags, uint8 *outRideInde
void ride_clear_for_construction(int rideIndex);
void ride_restore_provisional_entrance_or_exit();
void ride_remove_provisional_entrance_or_exit();
void ride_restore_provisional_track_piece();
void ride_remove_provisional_track_piece();
void set_vehicle_type_image_max_sizes(rct_ride_entry_vehicle* vehicle_type, int num_images);
void invalidate_test_results(int rideIndex);