From 800e80aeb3394e22b9585ca34b37762cf95650a2 Mon Sep 17 00:00:00 2001 From: IntelOrca Date: Tue, 3 Nov 2015 22:58:30 +0000 Subject: [PATCH] fix demolish track piece as client on multiplayer --- src/network/network.cpp | 2 ++ src/ride/ride.c | 20 ++++++++++++-------- src/ride/ride.h | 7 ++++++- src/windows/ride_construction.c | 14 +++++++++++--- 4 files changed, 31 insertions(+), 12 deletions(-) diff --git a/src/network/network.cpp b/src/network/network.cpp index 6a23a8c0bc..faf75bc010 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -871,10 +871,12 @@ bool Network::ProcessConnection(NetworkConnection& connection) break; } } while (packetStatus == NETWORK_READPACKET_MORE_DATA || packetStatus == NETWORK_READPACKET_SUCCESS); +#if !DEBUG if (!connection.ReceivedPacketRecently()) { connection.last_disconnect_reason = "No Data"; return false; } +#endif return true; } diff --git a/src/ride/ride.c b/src/ride/ride.c index 9f522dfaf9..f0878fe592 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -129,6 +129,11 @@ static const int RideInspectionInterval[] = { rct_ride_type **gRideTypeList = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_ENTRIES, rct_ride_type*); rct_ride* g_ride_list = RCT2_ADDRESS(RCT2_ADDRESS_RIDE_LIST, rct_ride); bool gGotoStartPlacementMode = false; +int gRideRemoveTrackPieceCallbackX; +int gRideRemoveTrackPieceCallbackY; +int gRideRemoveTrackPieceCallbackZ; +int gRideRemoveTrackPieceCallbackDirection; +int gRideRemoveTrackPieceCallbackType; // Static function declarations rct_peep *find_closest_mechanic(int x, int y, int forInspection); @@ -5548,15 +5553,14 @@ void game_command_callback_ride_construct_placed_front(int eax, int ebx, int ecx void game_command_callback_ride_remove_track_piece(int eax, int ebx, int ecx, int edx, int esi, int edi, int ebp) { int x, y, z, direction, type; - rct_xy_element outputElement; - x = _currentTrackBeginX; - y = _currentTrackBeginY; - z = _currentTrackBeginZ; - direction = _currentTrackPieceDirection; - type = _currentTrackPieceType; - - window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type, outputElement); + x = gRideRemoveTrackPieceCallbackX; + y = gRideRemoveTrackPieceCallbackY; + z = gRideRemoveTrackPieceCallbackZ; + direction = gRideRemoveTrackPieceCallbackDirection; + type = gRideRemoveTrackPieceCallbackType; + + window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type); } /** diff --git a/src/ride/ride.h b/src/ride/ride.h index 5a1e38b154..a94d6f74ad 100644 --- a/src/ride/ride.h +++ b/src/ride/ride.h @@ -877,6 +877,11 @@ extern const uint8 gRideClassifications[255]; #define _currentSeatRotationAngle RCT2_GLOBAL(0x00F440CF, uint8) extern bool gGotoStartPlacementMode; +extern int gRideRemoveTrackPieceCallbackX; +extern int gRideRemoveTrackPieceCallbackY; +extern int gRideRemoveTrackPieceCallbackZ; +extern int gRideRemoveTrackPieceCallbackDirection; +extern int gRideRemoveTrackPieceCallbackType; int ride_get_count(); int ride_get_total_queue_length(rct_ride *ride); @@ -1012,6 +1017,6 @@ bool shop_item_is_souvenir(int shopItem); void ride_reset_all_names(); const uint8* ride_seek_available_modes(rct_ride *ride); -void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, int direction, int type, rct_xy_element outputElement); +void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, int direction, int type); #endif diff --git a/src/windows/ride_construction.c b/src/windows/ride_construction.c index ac19ef73b6..e028ae3778 100644 --- a/src/windows/ride_construction.c +++ b/src/windows/ride_construction.c @@ -1753,10 +1753,18 @@ static void window_ride_construction_mouseup_demolish(rct_window* w) return; } - window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type, outputElement); + if (network_get_mode() == NETWORK_MODE_CLIENT) { + gRideRemoveTrackPieceCallbackX = x; + gRideRemoveTrackPieceCallbackY = y; + gRideRemoveTrackPieceCallbackZ = z; + gRideRemoveTrackPieceCallbackDirection = direction; + gRideRemoveTrackPieceCallbackType = type; + } else { + window_ride_construction_mouseup_demolish_next_piece(x, y, z, direction, type); + } } -void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, int direction, int type, rct_xy_element outputElement) +void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, int direction, int type) { int slope, slopeEnd, b2, bankEnd, bankStart, b5, b4; if (gGotoStartPlacementMode) { @@ -1775,7 +1783,7 @@ void window_ride_construction_mouseup_demolish_next_piece(int x, int y, int z, i b4 = _currentTrackLiftHill; ride_construction_set_default_next_piece(); sub_6C84CE(); - if (!sub_6CAF80(_currentRideIndex, &outputElement)) { + if (!sub_6CAF80(_currentRideIndex, NULL)) { sub_6CC3FB(_currentRideIndex); _currentTrackPieceDirection = direction; if (!(slope & 0x100)) {