mirror of
https://github.com/OpenRCT2/OpenRCT2.git
synced 2025-01-24 11:22:02 -05:00
Reduce desyncs by removing teh track before updating peep logic
This commit is contained in:
parent
cfb4bba721
commit
d97bb88c41
5 changed files with 58 additions and 0 deletions
|
@ -440,6 +440,13 @@ public:
|
|||
window_invalidate_by_class(WC_FINANCES);
|
||||
window_invalidate_by_class(WC_RESEARCH);
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_TRACK_DESIGN_REMOVE_PROVISIONAL:
|
||||
TrackPlaceClearProvisionalTemporarily();
|
||||
break;
|
||||
case INTENT_ACTION_TRACK_DESIGN_RESTORE_PROVISIONAL:
|
||||
TrackPlaceRestoreProvisional();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -436,6 +436,38 @@ static void window_track_place_clear_provisional()
|
|||
}
|
||||
}
|
||||
|
||||
void TrackPlaceClearProvisionalTemporarily()
|
||||
{
|
||||
if (_window_track_place_last_was_valid)
|
||||
{
|
||||
auto ride = get_ride(_window_track_place_ride_index);
|
||||
if (ride != nullptr)
|
||||
{
|
||||
place_virtual_track(
|
||||
_trackDesign.get(), PTD_OPERATION_REMOVE_GHOST, true, ride, _window_track_place_last_valid_x,
|
||||
_window_track_place_last_valid_y, _window_track_place_last_valid_z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackPlaceRestoreProvisional()
|
||||
{
|
||||
if (_window_track_place_last_was_valid)
|
||||
{
|
||||
money32 cost;
|
||||
ride_id_t rideIndex;
|
||||
window_track_place_attempt_placement(
|
||||
_trackDesign.get(), _window_track_place_last_valid_x, _window_track_place_last_valid_y,
|
||||
_window_track_place_last_valid_z, GAME_COMMAND_FLAG_APPLY | GAME_COMMAND_FLAG_NO_SPEND | GAME_COMMAND_FLAG_GHOST,
|
||||
&cost, &rideIndex);
|
||||
if (cost == MONEY32_UNDEFINED)
|
||||
{
|
||||
_window_track_place_last_was_valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006D17C6
|
||||
|
|
|
@ -95,6 +95,9 @@ rct_window* window_loadsave_open(int32_t type, const char* defaultName, loadsave
|
|||
rct_window* window_track_place_open(const struct track_design_file_ref* tdFileRef);
|
||||
rct_window* window_track_manage_open(struct track_design_file_ref* tdFileRef);
|
||||
|
||||
void TrackPlaceClearProvisionalTemporarily();
|
||||
void TrackPlaceRestoreProvisional();
|
||||
|
||||
rct_window* window_map_open();
|
||||
void window_map_reset();
|
||||
|
||||
|
|
|
@ -102,4 +102,6 @@ enum
|
|||
INTENT_ACTION_UPDATE_CASH,
|
||||
INTENT_ACTION_UPDATE_BANNER,
|
||||
INTENT_ACTION_UPDATE_RESEARCH,
|
||||
INTENT_ACTION_TRACK_DESIGN_REMOVE_PROVISIONAL,
|
||||
INTENT_ACTION_TRACK_DESIGN_RESTORE_PROVISIONAL,
|
||||
};
|
||||
|
|
|
@ -1498,6 +1498,13 @@ void map_remove_provisional_elements()
|
|||
ride_remove_provisional_track_piece();
|
||||
ride_entrance_exit_remove_ghost();
|
||||
}
|
||||
// This is in non performant so only make network games suffer for it
|
||||
// non networked games do not need this as its to prevent desyncs.
|
||||
if ((network_get_mode() != NETWORK_MODE_NONE) && window_find_by_class(WC_TRACK_DESIGN_PLACE) != nullptr)
|
||||
{
|
||||
auto intent = Intent(INTENT_ACTION_TRACK_DESIGN_REMOVE_PROVISIONAL);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
void map_restore_provisional_elements()
|
||||
|
@ -1514,6 +1521,13 @@ void map_restore_provisional_elements()
|
|||
ride_restore_provisional_track_piece();
|
||||
ride_entrance_exit_place_provisional_ghost();
|
||||
}
|
||||
// This is in non performant so only make network games suffer for it
|
||||
// non networked games do not need this as its to prevent desyncs.
|
||||
if ((network_get_mode() != NETWORK_MODE_NONE) && window_find_by_class(WC_TRACK_DESIGN_PLACE) != nullptr)
|
||||
{
|
||||
auto intent = Intent(INTENT_ACTION_TRACK_DESIGN_RESTORE_PROVISIONAL);
|
||||
context_broadcast_intent(&intent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue