1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 19:13:07 +01:00

fix #3575: Construction Redirection Bug

Was probably only caused when a player did not have 'Allow unfinished tracks to be tested' enabled. The function was too embeded to work into a callback function, so a new flag is added to say whether the current game command is network sourced or not. This now means the host has to have the unfinished tracks option enabled, otherwise nothing will happen on the client machine. Unfortunately if the host has it enabled and the client doesn't, the command will run on the host game but not the client game and desync. The option, like some of the cheats is game session fixed.
This commit is contained in:
Ted John
2016-05-30 12:39:09 +01:00
parent 8226c29d6c
commit fbcc68dff1
3 changed files with 26 additions and 27 deletions

View File

@@ -66,6 +66,7 @@ int gGameSpeed = 1;
float gDayNightCycle = 0;
bool gInUpdateCode = false;
int gGameCommandNestLevel;
bool gGameCommandIsNetworked;
extern void game_command_callback_place_banner(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp);
@@ -458,6 +459,10 @@ int game_do_command_p(int command, int *eax, int *ebx, int *ecx, int *edx, int *
flags = *ebx;
gGameCommandErrorText = 0xFFFF;
if (gGameCommandNestLevel == 0) {
gGameCommandIsNetworked = (flags & GAME_COMMAND_FLAG_NETWORKED) != 0;
}
// Increment nest count
gGameCommandNestLevel++;

View File

@@ -139,6 +139,7 @@ extern int gGameSpeed;
extern float gDayNightCycle;
extern bool gInUpdateCode;
extern int gGameCommandNestLevel;
extern bool gGameCommandIsNetworked;
void game_increase_game_speed();
void game_reduce_game_speed();

View File

@@ -5097,22 +5097,15 @@ void loc_6B51C0(int rideIndex)
*
* rct2: 0x006B528A
*/
void loc_6B528A(rct_xy_element *trackElement)
void ride_scroll_to_track_error(rct_xy_element *trackElement)
{
rct_ride *ride;
rct_window *w;
ride = get_ride(trackElement->element->properties.track.ride_index);
if (RCT2_GLOBAL(0x0141F568, uint8) != RCT2_GLOBAL(0x013CA740, uint8))
return;
w = window_get_main();
if (w == NULL)
return;
window_scroll_to_location(w, trackElement->x, trackElement->y, trackElement->element->base_height * 8);
ride_modify(trackElement);
if (!gGameCommandIsNetworked && RCT2_GLOBAL(0x0141F568, uint8) == RCT2_GLOBAL(0x013CA740, uint8)) {
rct_window *w = window_get_main();
if (w != NULL) {
window_scroll_to_location(w, trackElement->x, trackElement->y, trackElement->element->base_height * 8);
ride_modify(trackElement);
}
}
}
/**
@@ -5194,7 +5187,7 @@ int ride_is_valid_for_test(int rideIndex, int goingToBeOpen, int isApplying)
if (ride_find_track_gap(&trackElement, &problematicTrackElement) && (!gConfigGeneral.test_unfinished_tracks ||
ride->mode == RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED || ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED)) {
gGameCommandErrorText = STR_TRACK_IS_NOT_A_COMPLETE_CIRCUIT;
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5204,7 +5197,7 @@ int ride_is_valid_for_test(int rideIndex, int goingToBeOpen, int isApplying)
ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED
) {
if (!ride_check_block_brakes(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5214,14 +5207,14 @@ int ride_is_valid_for_test(int rideIndex, int goingToBeOpen, int isApplying)
if (rideType->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS) {
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
if (ride_check_track_contains_inversions(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
if (rideType->flags & RIDE_ENTRY_FLAG_NO_BANKED_TRACK) {
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
if (ride_check_track_contains_banked(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5235,13 +5228,13 @@ int ride_is_valid_for_test(int rideIndex, int goingToBeOpen, int isApplying)
gGameCommandErrorText = STR_STATION_NOT_LONG_ENOUGH;
if (!ride_check_station_length(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
gGameCommandErrorText = STR_RIDE_MUST_START_AND_END_WITH_STATIONS;
if (!ride_check_start_and_end_is_station(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5325,7 +5318,7 @@ int ride_is_valid_for_open(int rideIndex, int goingToBeOpen, int isApplying)
) {
if (ride_find_track_gap(&trackElement, &problematicTrackElement)) {
gGameCommandErrorText = STR_TRACK_IS_NOT_A_COMPLETE_CIRCUIT;
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5335,7 +5328,7 @@ int ride_is_valid_for_open(int rideIndex, int goingToBeOpen, int isApplying)
ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED
) {
if (!ride_check_block_brakes(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5345,14 +5338,14 @@ int ride_is_valid_for_open(int rideIndex, int goingToBeOpen, int isApplying)
if (rideType->flags & RIDE_ENTRY_FLAG_NO_INVERSIONS) {
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
if (ride_check_track_contains_inversions(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
if (rideType->flags & RIDE_ENTRY_FLAG_NO_BANKED_TRACK) {
gGameCommandErrorText = STR_TRACK_UNSUITABLE_FOR_TYPE_OF_TRAIN;
if (ride_check_track_contains_banked(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}
@@ -5366,13 +5359,13 @@ int ride_is_valid_for_open(int rideIndex, int goingToBeOpen, int isApplying)
gGameCommandErrorText = STR_STATION_NOT_LONG_ENOUGH;
if (!ride_check_station_length(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
gGameCommandErrorText = STR_RIDE_MUST_START_AND_END_WITH_STATIONS;
if (!ride_check_start_and_end_is_station(&trackElement, &problematicTrackElement)) {
loc_6B528A(&problematicTrackElement);
ride_scroll_to_track_error(&problematicTrackElement);
return 0;
}
}