From 7eb3a90cea91025e10862a1e0f54ba0d7c114b16 Mon Sep 17 00:00:00 2001 From: janisozaur Date: Thu, 21 Apr 2016 00:57:54 +0200 Subject: [PATCH] Fixes for values being shifted (#3362) --- src/ride/ride.c | 4 ++-- src/ride/track.c | 2 +- src/windows/new_ride.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ride/ride.c b/src/ride/ride.c index bbb1da8d6e..32a2ccc96c 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -3370,7 +3370,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint view_y2 < rotatedCoords.y) { goto label58; } - int x2 = RCT2_GLOBAL(0x00F438A4, rct_viewport*)->x + ((rotatedCoords.x - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_x) >> RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom); + uint32 x2 = RCT2_GLOBAL(0x00F438A4, rct_viewport*)->x + ((rotatedCoords.x - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_x) >> RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom); x2 <<= 16; uint16 screenwidth = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, uint16); if (screenwidth < 64) { @@ -3378,7 +3378,7 @@ int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint } int pan_x = ((x2 / screenwidth) - 0x8000) >> 4; - int y2 = RCT2_GLOBAL(0x00F438A4, rct_viewport*)->y + ((rotatedCoords.y - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_y) >> RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom); + uint32 y2 = RCT2_GLOBAL(0x00F438A4, rct_viewport*)->y + ((rotatedCoords.y - RCT2_GLOBAL(0x00F438A4, rct_viewport*)->view_y) >> RCT2_GLOBAL(0x00F438A4, rct_viewport*)->zoom); y2 <<= 16; uint16 screenheight = RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_HEIGHT, uint16); if (screenheight < 64) { diff --git a/src/ride/track.c b/src/ride/track.c index dedeb45bdf..8fa3602930 100644 --- a/src/ride/track.c +++ b/src/ride/track.c @@ -1660,7 +1660,7 @@ int track_place_ride(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint8** trac int temp_z = z; temp_z -= track_coordinates->z_begin; uint32 edi = ((track->flags & 0xF) << 17) | - ((track->flags & 0xF) << 28) | + ((uint32)(track->flags & 0xF) << 28) | (((track->flags >> 4) & 0x3) << 24) | (temp_z & 0xFFFF); diff --git a/src/windows/new_ride.c b/src/windows/new_ride.c index ef9f0a59e2..4410bad6cf 100644 --- a/src/windows/new_ride.c +++ b/src/windows/new_ride.c @@ -309,7 +309,7 @@ static void window_new_ride_populate_list() quadIndex = rideType >> 5; bitIndex = rideType & 0x1F; - if (RCT2_ADDRESS(0x01357404, uint32)[quadIndex] & (1 << bitIndex)) { + if (RCT2_ADDRESS(0x01357404, uint32)[quadIndex] & (1u << bitIndex)) { int dh = 0; uint8 *rideEntryIndexPtr = get_ride_entry_indices_for_ride_type(rideType); @@ -323,7 +323,7 @@ static void window_new_ride_populate_list() quadIndex = rideEntryIndex >> 5; bitIndex = rideEntryIndex & 0x1F; // Skip if vehicle type is not invented yet - if (!(RCT2_ADDRESS(0x01357424, uint32)[quadIndex] & (1 << bitIndex))) + if (!(RCT2_ADDRESS(0x01357424, uint32)[quadIndex] & (1u << bitIndex))) continue; // Ride entries