From 16fd91f7864c6b3c6f5d88f522f79c0c29dddcbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 13 May 2016 12:09:06 +0200 Subject: [PATCH 1/3] Don't copy the error message to fixed-size buffer --- src/object.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/object.c b/src/object.c index 6ac3db84e8..ac7ead90d1 100644 --- a/src/object.c +++ b/src/object.c @@ -97,9 +97,7 @@ int object_load_file(int groupIndex, const rct_object_entry *entry, int* chunkSi // Calculate and check checksum if (calculatedChecksum != openedEntry.checksum && !gConfigGeneral.allow_loading_with_incorrect_checksum) { - char buffer[100]; - sprintf(buffer, "Object Load failed due to checksum failure: calculated checksum %d, object says %d.", calculatedChecksum, (int)openedEntry.checksum); - log_error(buffer); + log_error("Object Load failed due to checksum failure: calculated checksum %d, object says %d.", calculatedChecksum, (int)openedEntry.checksum); RCT2_GLOBAL(0x00F42BD9, uint8) = 2; free(chunk); return 0; From 070f29887809df3d0062075873db3550291609c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 13 May 2016 13:23:37 +0200 Subject: [PATCH 2/3] Make sure variables don't end up uninitialised --- src/platform/linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform/linux.c b/src/platform/linux.c index 8920d97d07..c83ea304e7 100644 --- a/src/platform/linux.c +++ b/src/platform/linux.c @@ -220,8 +220,8 @@ bool platform_open_common_file_dialog(utf8 *outFilename, file_dialog_desc *desc) char result[MAX_PATH]; size_t size; dialog_type dtype; - char *action; - char *flags; + char *action = NULL; + char *flags = NULL; char filter[MAX_PATH] = { 0 }; char filterPatternRegex[64]; char *allFilesPatternDescription; From 4d05c939cf957858215df3a105219af99acebc99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 13 May 2016 13:24:30 +0200 Subject: [PATCH 3/3] Cache accesses to get_current_rotation() --- src/interface/viewport.c | 2 +- src/paint/map_element/surface.c | 85 ++++++++++---------- src/paint/supports.c | 13 ++-- src/ride/coaster/virginia_reel.c | 7 +- src/ride/gentle/maze.c | 53 ++++++------- src/ride/ride.c | 3 +- src/ride/thrill/launched_freefall.c | 13 ++-- src/ride/thrill/roto_drop.c | 7 +- src/ride/thrill/top_spin.c | 115 +++++++++++++++------------- src/ride/vehicle_paint.c | 5 +- src/ride/water/river_rapids.c | 13 ++-- src/world/map.c | 9 ++- 12 files changed, 174 insertions(+), 151 deletions(-) diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 19fbb254ad..cd9f2540cc 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -197,6 +197,7 @@ void sub_689174(sint16* x, sint16* y, sint16 *z) sint16 start_y = *y; sint16 height = 0; + uint32 rotation = get_current_rotation(); rct_xy16 pos; for (int i = 0; i < 6; i++) { pos = viewport_coord_to_map_coord(start_x, start_y, height); @@ -208,7 +209,6 @@ void sub_689174(sint16* x, sint16* y, sint16 *z) if (pos.x > max && pos.y > max) { int x_corr[] = { -1, 1, 1, -1 }; int y_corr[] = { -1, -1, 1, 1 }; - uint32 rotation = get_current_rotation(); pos.x += x_corr[rotation] * height; pos.y += y_corr[rotation] * height; } diff --git a/src/paint/map_element/surface.c b/src/paint/map_element/surface.c index 25d940ec0d..cca5ea0ad9 100644 --- a/src/paint/map_element/surface.c +++ b/src/paint/map_element/surface.c @@ -536,6 +536,7 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter uint32 base_image_id = stru_97B5C0[terrain][1] + (edge == EDGE_TOPLEFT ? 5 : 0); // var_04 + const uint8 rotation = get_current_rotation(); uint8 cur_height = min(regs.ch, regs.ah); if (regs.ch != regs.ah) { // neightbour tile corners aren't level @@ -546,7 +547,7 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter if (cur_height != regs.al && cur_height != regs.cl) { uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, rotation); cur_height++; } } @@ -554,7 +555,7 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter regs.ah = regs.cl; while (cur_height < regs.al && cur_height < regs.ah) { - sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); + sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, rotation); cur_height++; } @@ -568,7 +569,7 @@ void viewport_surface_draw_land_side_top(enum edge edge, uint8 height, uint8 ter } uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, rotation); } /** @@ -637,6 +638,7 @@ void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 base_image_id += 5; } + const uint8 rotation = get_current_rotation(); uint8 curHeight = min(regs.ah, regs.ch); if (regs.ch != regs.ah) { // If bottom part of edge isn't straight, add a filler @@ -648,7 +650,7 @@ void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 if (curHeight != regs.al && curHeight != regs.cl) { uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation); curHeight++; } } @@ -667,7 +669,7 @@ void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation); return; } @@ -680,7 +682,7 @@ void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 } } - sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation); curHeight++; continue; @@ -706,7 +708,7 @@ void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 uint32 image_id = stru_97B640[edgeStyle][tunnelType] + (edge == EDGE_BOTTOMRIGHT ? 2 : 0); - sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, zOffset, 0, 0, boundBoxOffsetZ, get_current_rotation()); + sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, zOffset, 0, 0, boundBoxOffsetZ, rotation); boundBoxOffsetZ = curHeight * 16; @@ -718,7 +720,7 @@ void viewport_surface_draw_land_side_bottom(enum edge edge, uint8 height, uint8 } image_id = stru_97B640[edgeStyle][tunnelType] + (edge == EDGE_BOTTOMRIGHT ? 2 : 0) + 1; - sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, curHeight * 16, tunnelTopBoundBoxOffset.x, tunnelTopBoundBoxOffset.y, boundBoxOffsetZ, get_current_rotation()); + sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, curHeight * 16, tunnelTopBoundBoxOffset.x, tunnelTopBoundBoxOffset.y, boundBoxOffsetZ, rotation); curHeight += stru_97B570[tunnelType][0]; @@ -794,6 +796,7 @@ void viewport_surface_draw_water_side_top(enum edge edge, uint8 height, uint8 te base_image_id += (edge == EDGE_TOPLEFT ? 5 : 0); + const uint8 rotation = get_current_rotation(); uint8 cur_height = min(regs.ch, regs.ah); if (regs.ch != regs.ah) { // neightbour tile corners aren't level @@ -804,7 +807,7 @@ void viewport_surface_draw_water_side_top(enum edge edge, uint8 height, uint8 te if (cur_height != regs.al && cur_height != regs.cl) { uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, rotation); cur_height++; } } @@ -812,7 +815,7 @@ void viewport_surface_draw_water_side_top(enum edge edge, uint8 height, uint8 te regs.ah = regs.cl; while (cur_height < regs.al && cur_height < regs.ah) { - sub_98196C(base_image_id, 0, 0, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); + sub_98196C(base_image_id, 0, 0, bounds.x, bounds.y, 15, cur_height * 16, rotation); cur_height++; } @@ -826,7 +829,7 @@ void viewport_surface_draw_water_side_top(enum edge edge, uint8 height, uint8 te } uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, cur_height * 16, rotation); } /** @@ -905,6 +908,7 @@ void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height, uint8 base_image_id += 5; } + const uint8 rotation = get_current_rotation(); uint8 curHeight = min(regs.ah, regs.ch); if (regs.ch != regs.ah) { // If bottom part of edge isn't straight, add a filler @@ -916,7 +920,7 @@ void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height, uint8 if (curHeight != regs.al && curHeight != regs.cl) { uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation); curHeight++; } } @@ -935,7 +939,7 @@ void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height, uint8 uint32 image_id = base_image_id + image_offset; - sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + sub_98196C(image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation); return; } @@ -948,7 +952,7 @@ void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height, uint8 } } - sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, get_current_rotation()); + sub_98196C(base_image_id, offset.x, offset.y, bounds.x, bounds.y, 15, curHeight * 16, rotation); curHeight++; continue; @@ -974,7 +978,7 @@ void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height, uint8 uint32 image_id = stru_97B640[edgeStyle][tunnelType] + (edge == EDGE_BOTTOMRIGHT ? 2 : 0); - sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, zOffset, 0, 0, boundBoxOffsetZ, get_current_rotation()); + sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, zOffset, 0, 0, boundBoxOffsetZ, rotation); boundBoxOffsetZ = curHeight * 16; @@ -986,7 +990,7 @@ void viewport_surface_draw_water_side_bottom(enum edge edge, uint8 height, uint8 } image_id = stru_97B640[edgeStyle][tunnelType] + (edge == EDGE_BOTTOMRIGHT ? 2 : 0) + 1; - sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, curHeight * 16, tunnelTopBoundBoxOffset.x, tunnelTopBoundBoxOffset.y, boundBoxOffsetZ, get_current_rotation()); + sub_98197C(image_id, offset.x, offset.y, tunnelBounds.x, tunnelBounds.y, boundBoxLength - 1, curHeight * 16, tunnelTopBoundBoxOffset.x, tunnelTopBoundBoxOffset.y, boundBoxOffsetZ, rotation); curHeight += stru_97B570[tunnelType][0]; @@ -1012,8 +1016,9 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) uint16 zoomLevel = dpi->zoom_level; + const uint8 rotation = get_current_rotation(); uint32 terrain_type = ((mapElement->type & MAP_ELEMENT_DIRECTION_MASK) << 3) | (mapElement->properties.surface.terrain >> 5); - uint32 surfaceShape = viewport_surface_paint_setup_get_relative_slope(mapElement, get_current_rotation()); + uint32 surfaceShape = viewport_surface_paint_setup_get_relative_slope(mapElement, rotation); rct_xy16 base = { .x = RCT2_GLOBAL(0x9DE568, sint16), @@ -1037,7 +1042,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) tileDescriptors[0] = selfDescriptor; for (int i = 0; i < 4; i++) { - rct_xy16 offset = viewport_surface_paint_data[i][get_current_rotation()]; + rct_xy16 offset = viewport_surface_paint_data[i][rotation]; rct_xy16 position = {.x = base.x + offset.x, .y = base.y + offset.y}; tileDescriptors[i + 1].map_element = NULL; @@ -1052,7 +1057,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) tileDescriptors[i + 1].map_element = surfaceElement; tileDescriptors[i + 1].terrain = ((surfaceElement->type & MAP_ELEMENT_DIRECTION_MASK) << 3) | (surfaceElement->properties.surface.terrain >> 5); - uint32 ebx = viewport_surface_paint_setup_get_relative_slope(surfaceElement, get_current_rotation()); + uint32 ebx = viewport_surface_paint_setup_get_relative_slope(surfaceElement, rotation); tileDescriptors[i + 1].slope = ebx; uint8 baseHeight = surfaceElement->base_height / 2; @@ -1074,17 +1079,17 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) image_id += get_height_marker_offset(); image_id -= RCT2_GLOBAL(0x01359208, uint16); - sub_98196C(image_id, 16, 16, 1, 1, 0, height, get_current_rotation()); + sub_98196C(image_id, 16, 16, 1, 1, 0, height, rotation); } bool has_surface = false; if (RCT2_GLOBAL(0x9E323C, uint8) * 16 == height) { // Vertical tunnels - sub_98197C(1575, 0, 0, 1, 30, 39, height, -2, 1, height - 40, get_current_rotation()); - sub_98197C(1576, 0, 0, 30, 1, 0, height, 1, 31, height, get_current_rotation()); - sub_98197C(1577, 0, 0, 1, 30, 0, height, 31, 1, height, get_current_rotation()); - sub_98197C(1578, 0, 0, 30, 1, 39, height, 1, -2, height - 40, get_current_rotation()); + sub_98197C(1575, 0, 0, 1, 30, 39, height, -2, 1, height - 40, rotation); + sub_98197C(1576, 0, 0, 30, 1, 0, height, 1, 31, height, rotation); + sub_98197C(1577, 0, 0, 1, 30, 0, height, 31, 1, height, rotation); + sub_98197C(1578, 0, 0, 30, 1, 39, height, 1, -2, height - 40, rotation); } else { bool showGridlines = (gCurrentViewportFlags & VIEWPORT_FLAG_GRIDLINES); @@ -1106,7 +1111,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) switch (branch) { case 0: // loc_660C90 - image_id = dword_97B898[get_current_rotation()][showGridlines ? 1 : 0] + image_offset; + image_id = dword_97B898[rotation][showGridlines ? 1 : 0] + image_offset; break; case 1: @@ -1114,7 +1119,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) case 3: default: // loc_660C9F - if (get_current_rotation() & 1) { + if (rotation & 1) { assert(ebp < countof(byte_97B84A)); ebp = byte_97B84A[ebp]; } @@ -1152,7 +1157,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } - sub_98196C(image_id, 0, 0, 32, 32, 255, height, get_current_rotation()); + sub_98196C(image_id, 0, 0, 32, 32, 255, height, rotation); has_surface = true; } @@ -1199,11 +1204,11 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) if ((spawn->x & 0xFFE0) == pos.x && (spawn->y & 0xFFE0) == pos.y) { // TODO: SPR_TERRAIN_SELECTION_SQUARE_SIMPLE ??? (no variations) - sub_98196C(2624, 0, 0, 32, 32, 16, spawn->z * 16, get_current_rotation()); + sub_98196C(2624, 0, 0, 32, 32, 16, spawn->z * 16, rotation); - int offset = ((spawn->direction ^ 2) + get_current_rotation()) & 3; + int offset = ((spawn->direction ^ 2) + rotation) & 3; uint32 image_id = 3111 + offset | 0x20380000; - sub_98196C(image_id, 0, 0, 32, 32, 19, spawn->z * 16, get_current_rotation()); + sub_98196C(image_id, 0, 0, 32, 32, 19, spawn->z * 16, rotation); } } } @@ -1218,7 +1223,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; paint_struct * backup = RCT2_GLOBAL(0xF1AD28, paint_struct*); int height = (map_element_height(pos.x + 16, pos.y + 16) & 0xFFFF) + 3; - sub_98196C(22955, 16, 16, 1, 1, 0, height, get_current_rotation()); + sub_98196C(22955, 16, 16, 1, 1, 0, height, rotation); RCT2_GLOBAL(0xF1AD28, paint_struct*) = backup; } } @@ -1233,7 +1238,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) paint_struct * backup = RCT2_GLOBAL(0xF1AD28, paint_struct*); rct_xy16 pos = {RCT2_GLOBAL(0x009DE56A, sint16), RCT2_GLOBAL(0x009DE56E, sint16)}; int height = map_element_height(pos.x + 16, pos.y + 16) & 0xFFFF; - sub_98196C(22956, 16, 16, 1, 1, 0, height + 3, get_current_rotation()); + sub_98196C(22956, 16, 16, 1, 1, 0, height + 3, rotation); RCT2_GLOBAL(0xF1AD28, paint_struct*) = backup; } } @@ -1254,20 +1259,20 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) if (mapSelectionType >= 0xA) { // Walls // loc_661089: - uint32 eax = ((((mapSelectionType - 9) + get_current_rotation()) & 3) + 0x21) << 19; + uint32 eax = ((((mapSelectionType - 9) + rotation) & 3) + 0x21) << 19; uint32 image_id = (SPR_TERRAIN_SELECTION_EDGE + byte_97B444[surfaceShape]) | eax | 0x20000000; paint_attach_to_previous_ps(image_id, 0, 0); } else if (mapSelectionType >= 6) { // loc_661051:(no jump) // Selection split into four quarter segments - uint32 eax = ((((mapSelectionType - 6) + get_current_rotation()) & 3) + 0x27) << 19; + uint32 eax = ((((mapSelectionType - 6) + rotation) & 3) + 0x27) << 19; uint32 image_id = (SPR_TERRAIN_SELECTION_QUARTER + byte_97B444[surfaceShape]) | eax | 0x20000000; paint_attach_to_previous_ps(image_id, 0, 0); } else if (mapSelectionType <= 4) { // Corners uint32 eax = mapSelectionType; if (mapSelectionType != 4) { - eax = (mapSelectionType + get_current_rotation()) & 3; + eax = (mapSelectionType + rotation) & 3; } eax = (eax + 0x21) << 19; @@ -1299,7 +1304,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) int image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[local_surfaceShape]) | 0x21300000; paint_struct * backup = RCT2_GLOBAL(0xF1AD28, paint_struct*); - sub_98196C(image_id, 0, 0, 32, 32, 1, local_height, get_current_rotation()); + sub_98196C(image_id, 0, 0, 32, 32, 1, local_height, rotation); RCT2_GLOBAL(0xF1AD28, paint_struct*) = backup; } } @@ -1343,7 +1348,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) uint8 image_offset = byte_97B444[surfaceShape]; uint32 base_image = terrain_type; - if (get_current_rotation() & 1) { + if (rotation & 1) { base_image = byte_97B84A[terrain_type]; } uint32 image_id = dword_97B7C8[base_image] + image_offset; @@ -1390,7 +1395,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } int image_id = (SPR_WATER_MASK + image_offset) | 0x61000000; - sub_98196C(image_id, 0, 0, 32, 32, -1, waterHeight, get_current_rotation()); + sub_98196C(image_id, 0, 0, 32, 32, -1, waterHeight, rotation); paint_attach_to_previous_ps(SPR_WATER_OVERLAY + image_offset, 0, 0); @@ -1421,7 +1426,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) registers regs = { 0 }; regs.al = mapElement->properties.surface.ownership & 0x0F; - regs.ax = regs.ax << get_current_rotation(); + regs.ax = regs.ax << rotation; regs.ah = regs.al >> 4; uint8 al = regs.al | regs.ah; @@ -1532,7 +1537,7 @@ void surface_paint(uint8 direction, uint16 height, rct_map_element * mapElement) } } - sub_98197C(image_id, offset.x, offset.y, box_size.x, box_size.y, 9, local_height, box_offset.x, box_offset.y, local_height + 1, get_current_rotation()); + sub_98197C(image_id, offset.x, offset.y, box_size.x, box_size.y, 9, local_height, box_offset.x, box_offset.y, local_height + 1, rotation); } } diff --git a/src/paint/supports.c b/src/paint/supports.c index 89967f8481..c857f606a2 100644 --- a/src/paint/supports.c +++ b/src/paint/supports.c @@ -339,6 +339,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int sint16 originalHeight = height; + const uint8 rotation = get_current_rotation(); RCT2_GLOBAL(0x009E3294, sint16) = -1; if (height < RCT2_ADDRESS(0x0141E9B4, uint16)[segment * 2]){ RCT2_GLOBAL(0x009E3294, sint16) = height; @@ -347,7 +348,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int if (height < 0) return false; - uint8* esi = &(RCT2_ADDRESS(0x0097AF32, uint8)[get_current_rotation() * 2]); + uint8* esi = &(RCT2_ADDRESS(0x0097AF32, uint8)[rotation * 2]); uint8 newSegment = esi[segment * 8]; if (height <= RCT2_ADDRESS(0x0141E9B4, uint16)[newSegment * 2]) { @@ -380,7 +381,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int uint32 image_id = RCT2_ADDRESS(0x0097B072, uint16)[supportType * 8 + ebp]; image_id |= imageColourFlags; - sub_98196C(image_id, xOffset, yOffset, boundBoxLengthX, boundBoxLengthY, 1, height, get_current_rotation()); + sub_98196C(image_id, xOffset, yOffset, boundBoxLengthX, boundBoxLengthY, 1, height, rotation); segment = newSegment; } @@ -399,7 +400,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int image_id += RCT2_ADDRESS(0x0097B404, sint16)[RCT2_ADDRESS(0x00141E9B4 + 2, sint16)[segment * 2] & 0x1F]; image_id |= imageColourFlags; - sub_98196C(image_id, xOffset, yOffset, 0, 0, 5, RCT2_ADDRESS(0x0141E9B4, uint16)[segment * 2], get_current_rotation()); + sub_98196C(image_id, xOffset, yOffset, 0, 0, 5, RCT2_ADDRESS(0x0141E9B4, uint16)[segment * 2], rotation); height = RCT2_ADDRESS(0x0141E9B4, uint16)[segment * 2] + 6; } @@ -423,7 +424,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int image_id |= imageColourFlags; - sub_98196C(image_id, xOffset, yOffset, 0, 0, heightDiff - 1, height, get_current_rotation()); + sub_98196C(image_id, xOffset, yOffset, 0, 0, heightDiff - 1, height, rotation); } height += heightDiff; @@ -452,7 +453,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int if (count == 3 && z == 0x10) image_id++; - sub_98196C(image_id, xOffset, yOffset, 0, 0, z - 1, height, get_current_rotation()); + sub_98196C(image_id, xOffset, yOffset, 0, 0, z - 1, height, rotation); height += z; } @@ -492,7 +493,7 @@ bool metal_a_supports_paint_setup(int supportType, int segment, int special, int image_id |= imageColourFlags; - sub_98197C(image_id, xOffset, yOffset, 0, 0, z - 1, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98197C(image_id, xOffset, yOffset, 0, 0, z - 1, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); height += z; } diff --git a/src/ride/coaster/virginia_reel.c b/src/ride/coaster/virginia_reel.c index 1616731c1d..e7d5f2de76 100644 --- a/src/ride/coaster/virginia_reel.c +++ b/src/ride/coaster/virginia_reel.c @@ -42,7 +42,8 @@ void vehicle_visual_virginia_reel(int x, int imageDirection, int y, int z, rct_v { int image_id; int baseImage_id = imageDirection; - int ecx = ((vehicle->var_BA / 8) + (get_current_rotation() * 8)) & 31; + const uint8 rotation = get_current_rotation(); + int ecx = ((vehicle->var_BA / 8) + (rotation * 8)) & 31; int j = 0; if (vehicle->vehicle_sprite_type == 0) { baseImage_id = ecx & 7; @@ -72,7 +73,7 @@ void vehicle_visual_virginia_reel(int x, int imageDirection, int y, int z, rct_v const vehicle_boundbox *bb = &_virginiaReelBoundbox[j]; image_id = baseImage_id | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0xA0000000; - sub_98197C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98197C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); if (RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*)->zoom_level < 2 && vehicle->num_peeps > 0) { uint8 riding_peep_sprites[4] = {0xFF, 0xFF, 0xFF, 0xFF}; @@ -83,7 +84,7 @@ void vehicle_visual_virginia_reel(int x, int imageDirection, int y, int z, rct_v for (int i = 0; i < countof(draw_order); i++) { if (riding_peep_sprites[draw_order[i]] != 0xFF) { image_id = (baseImage_id + ((draw_order[i] + 1) * 72)) | (riding_peep_sprites[draw_order[i]] << 19) | 0x20000000; - sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); } } } diff --git a/src/ride/gentle/maze.c b/src/ride/gentle/maze.c index 3de2e7153a..68048b226a 100644 --- a/src/ride/gentle/maze.c +++ b/src/ride/gentle/maze.c @@ -52,9 +52,10 @@ static void maze_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi uint16 maze_entry = mapElement->properties.track.maze_entry; maze_entry = rol16(maze_entry, direction * 4); + uint32 rotation = get_current_rotation(); // draw ground int image_id = 2485 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98196C(image_id, 0, 0, 32, 32, 0, height, get_current_rotation()); + sub_98196C(image_id, 0, 0, 32, 32, 0, height, rotation); wooden_a_supports_paint_setup(direction & 1, 0, height, RCT2_GLOBAL(0x00F441A4, uint32), NULL); @@ -80,98 +81,98 @@ static void maze_paint_setup(uint8 rideIndex, uint8 trackSequence, uint8 directi image_id = base_image_id + SPR_MAZE_OFFSET_WALL_CENTER; if (maze_entry & (1 << 3)) - sub_98197C(image_id, 2, 2, 10, 10, 9, height, 3, 3, height + 2, get_current_rotation()); + sub_98197C(image_id, 2, 2, 10, 10, 9, height, 3, 3, height + 2, rotation); if (maze_entry & (1 << 7)) - sub_98197C(image_id, 2, 18, 10, 10, 9, height, 3, 19, height + 2, get_current_rotation()); + sub_98197C(image_id, 2, 18, 10, 10, 9, height, 3, 19, height + 2, rotation); if (maze_entry & (1 << 11)) - sub_98197C(image_id, 18, 18, 10, 10, 9, height, 19, 19, height + 2, get_current_rotation()); + sub_98197C(image_id, 18, 18, 10, 10, 9, height, 19, 19, height + 2, rotation); if (maze_entry & (1 << 15)) - sub_98197C(image_id, 18, 2, 10, 10, 9, height, 19, 3, height + 2, get_current_rotation()); + sub_98197C(image_id, 18, 2, 10, 10, 9, height, 19, 3, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_TOP_LEFT; if (maze_entry & (1 << 0)) - sub_98197C(image_id, 2, 0, 10, 1, 9, height, 3, 1, height + 2, get_current_rotation()); + sub_98197C(image_id, 2, 0, 10, 1, 9, height, 3, 1, height + 2, rotation); if (maze_entry & (1 << 13)) - sub_98197C(image_id, 18, 0, 10, 1, 9, height, 19, 1, height + 2, get_current_rotation()); + sub_98197C(image_id, 18, 0, 10, 1, 9, height, 19, 1, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_BOTTOM_RIGHT; if (maze_entry & (1 << 5)) - sub_98197C(image_id, 2, 30, 10, 1, 9, height, 3, 30, height + 2, get_current_rotation()); + sub_98197C(image_id, 2, 30, 10, 1, 9, height, 3, 30, height + 2, rotation); if (maze_entry & (1 << 8)) - sub_98197C(image_id, 18, 30, 10, 1, 9, height, 19, 30, height + 2, get_current_rotation()); + sub_98197C(image_id, 18, 30, 10, 1, 9, height, 19, 30, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_TOP_RIGHT; if (maze_entry & (1 << 1)) - sub_98197C(image_id, 0, 2, 1, 10, 9, height, 1, 3, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 2, 1, 10, 9, height, 1, 3, height + 2, rotation); if (maze_entry & (1 << 4)) - sub_98197C(image_id, 0, 18, 1, 10, 9, height, 1, 19, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 18, 1, 10, 9, height, 1, 19, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_BOTTOM_LEFT; if (maze_entry & (1 << 12)) - sub_98197C(image_id, 30, 2, 1, 10, 9, height, 30, 3, height + 2, get_current_rotation()); + sub_98197C(image_id, 30, 2, 1, 10, 9, height, 30, 3, height + 2, rotation); if (maze_entry & (1 << 9)) - sub_98197C(image_id, 30, 18, 1, 10, 9, height, 30, 19, height + 2, get_current_rotation()); + sub_98197C(image_id, 30, 18, 1, 10, 9, height, 30, 19, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_INNER_NE_SW; if (maze_entry & (1 << 2)) - sub_98197C(image_id, 2, 14, 10, 4, 9, height, 3, 14, height + 2, get_current_rotation()); + sub_98197C(image_id, 2, 14, 10, 4, 9, height, 3, 14, height + 2, rotation); if (maze_entry & (1 << 10)) - sub_98197C(image_id, 18, 14, 10, 4, 9, height, 19, 14, height + 2, get_current_rotation()); + sub_98197C(image_id, 18, 14, 10, 4, 9, height, 19, 14, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_WALL_INNER_NW_SE; if (maze_entry & (1 << 14)) - sub_98197C(image_id, 14, 2, 4, 10, 9, height, 14, 3, height + 2, get_current_rotation()); + sub_98197C(image_id, 14, 2, 4, 10, 9, height, 14, 3, height + 2, rotation); if (maze_entry & (1 << 6)) - sub_98197C(image_id, 14, 18, 4, 10, 9, height, 14, 19, height + 2, get_current_rotation()); + sub_98197C(image_id, 14, 18, 4, 10, 9, height, 14, 19, height + 2, rotation); image_id = base_image_id + SPR_MAZE_OFFSET_COLUMN_CORNER; if (maze_entry & (1 << 0 | 1 << 1)) - sub_98197C(image_id, 0, 0, 1, 1, 9, height, 1, 1, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 0, 1, 1, 9, height, 1, 1, height + 2, rotation); if (maze_entry & (1 << 4 | 1 << 5)) - sub_98197C(image_id, 0, 30, 1, 1, 9, height, 1, 30, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 30, 1, 1, 9, height, 1, 30, height + 2, rotation); if (maze_entry & (1 << 8 | 1 << 9)) - sub_98197C(image_id, 30, 30, 1, 1, 9, height, 30, 30, height + 2, get_current_rotation()); + sub_98197C(image_id, 30, 30, 1, 1, 9, height, 30, 30, height + 2, rotation); if (maze_entry & (1 << 12 | 1 << 13)) - sub_98197C(image_id, 30, 0, 1, 1, 9, height, 30, 1, height + 2, get_current_rotation()); + sub_98197C(image_id, 30, 0, 1, 1, 9, height, 30, 1, height + 2, rotation); if (maze_entry & (1 << 0 | 1 << 13 | 1 << 14)) - sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_LEFT, 14, 0, 2, 1, 9, height, 15, 1, height + 2, get_current_rotation()); + sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_LEFT, 14, 0, 2, 1, 9, height, 15, 1, height + 2, rotation); if (maze_entry & (1 << 5 | 1 << 6 | 1 << 8)) - sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_RIGHT, 14, 30, 2, 1, 9, height, 15, 30, height + 2, get_current_rotation()); + sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_RIGHT, 14, 30, 2, 1, 9, height, 15, 30, height + 2, rotation); if (maze_entry & (1 << 1 | 1 << 2 | 1 << 4)) - sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_RIGHT, 0, 14, 1, 2, 9, height, 1, 15, height + 2, get_current_rotation()); + sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_TOP_RIGHT, 0, 14, 1, 2, 9, height, 1, 15, height + 2, rotation); if (maze_entry & (1 << 9 | 1 << 10 | 1 << 12)) - sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_LEFT, 30, 14, 1, 2, 9, height, 30, 15, height + 2, get_current_rotation()); + sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_BOTTOM_LEFT, 30, 14, 1, 2, 9, height, 30, 15, height + 2, rotation); if (maze_entry & (1 << 2 | 1 << 6 | 1 << 10 | 1 << 14)) { - sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_CENTER, 14, 14, 2, 2, 8, height, 15, 15, height + 2, get_current_rotation()); + sub_98197C(base_image_id + SPR_MAZE_OFFSET_COLUMN_CENTER, 14, 14, 2, 2, 8, height, 15, 15, height + 2, rotation); RCT2_GLOBAL(0x141E9C4, uint16) = height + 12; RCT2_GLOBAL(0x141E9C6, uint8) = 0x20; diff --git a/src/ride/ride.c b/src/ride/ride.c index 61c3861afb..4f7549bef1 100644 --- a/src/ride/ride.c +++ b/src/ride/ride.c @@ -2063,6 +2063,7 @@ static void ride_spiral_slide_update(rct_ride *ride) peep->destination_x++; } + const uint8 current_rotation = get_current_rotation(); // Invalidate something related to station start for (i = 0; i < 4; i++) { if (ride->station_starts[i] == 0xFFFF) @@ -2073,7 +2074,7 @@ static void ride_spiral_slide_update(rct_ride *ride) z = ride->station_heights[i]; mapElement = ride_get_station_start_track_element(ride, i); - int rotation = ((mapElement->type & 3) << 2) | get_current_rotation(); + int rotation = ((mapElement->type & 3) << 2) | current_rotation; x *= 32; y *= 32; x += RCT2_GLOBAL(0x0098DDB8 + (rotation * 4), sint16); diff --git a/src/ride/thrill/launched_freefall.c b/src/ride/thrill/launched_freefall.c index dccfadc6cb..ee8020aba5 100644 --- a/src/ride/thrill/launched_freefall.c +++ b/src/ride/thrill/launched_freefall.c @@ -29,13 +29,14 @@ void vehicle_visual_launched_freefall(int x, int imageDirection, int y, int z, r int image_id; int baseImage_id = vehicleEntry->base_image_id + ((vehicle->restraints_position / 64) * 2); + const uint8 rotation = get_current_rotation(); // Draw back: image_id = (baseImage_id + 2) | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0xA0000000; - sub_98197C(image_id, 0, 0, 2, 2, 41, z, -11, -11, z + 1, get_current_rotation()); + sub_98197C(image_id, 0, 0, 2, 2, 41, z, -11, -11, z + 1, rotation); // Draw front: image_id = (baseImage_id + 1) | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0xA0000000; - sub_98197C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98197C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); // Draw peeps: if (RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*)->zoom_level < 2) { @@ -45,18 +46,18 @@ void vehicle_visual_launched_freefall(int x, int imageDirection, int y, int z, r baseImage_id += 2; // Draw peeps sitting without transparent area between them for restraints } image_id = (baseImage_id + ((((imageDirection / 8) + 0) & 3) * 3)) | (vehicle->peep_tshirt_colours[0] << 19) | (vehicle->peep_tshirt_colours[1] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); if (vehicle->num_peeps > 2) { image_id = (baseImage_id + ((((imageDirection / 8) + 1) & 3) * 3)) | (vehicle->peep_tshirt_colours[2] << 19) | (vehicle->peep_tshirt_colours[3] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); } if (vehicle->num_peeps > 4) { image_id = (baseImage_id + ((((imageDirection / 8) + 2) & 3) * 3)) | (vehicle->peep_tshirt_colours[4] << 19) | (vehicle->peep_tshirt_colours[5] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); } if (vehicle->num_peeps > 6) { image_id = (baseImage_id + ((((imageDirection / 8) + 3) & 3) * 3)) | (vehicle->peep_tshirt_colours[6] << 19) | (vehicle->peep_tshirt_colours[7] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); } } } diff --git a/src/ride/thrill/roto_drop.c b/src/ride/thrill/roto_drop.c index c990f50f99..66cbec28c2 100644 --- a/src/ride/thrill/roto_drop.c +++ b/src/ride/thrill/roto_drop.c @@ -33,13 +33,14 @@ void vehicle_visual_roto_drop(int x, int imageDirection, int y, int z, rct_vehic baseImage_id += (vehicle->restraints_position / 64); } + const uint8 rotation = get_current_rotation(); // Draw back: image_id = baseImage_id | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0xA0000000; - sub_98197C(image_id, 0, 0, 2, 2, 41, z, -11, -11, z + 1, get_current_rotation()); + sub_98197C(image_id, 0, 0, 2, 2, 41, z, -11, -11, z + 1, rotation); // Draw front: image_id = (baseImage_id + 4) | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0xA0000000; - sub_98197C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98197C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); uint8 riding_peep_sprites[64]; memset(riding_peep_sprites, 0xFF, sizeof(riding_peep_sprites)); @@ -62,7 +63,7 @@ void vehicle_visual_roto_drop(int x, int imageDirection, int y, int z, rct_vehic baseImage_id += vehicle->restraints_position / 64; } image_id = baseImage_id | (riding_peep_sprites[i] << 19) | 0x20000000; - sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, get_current_rotation()); + sub_98199C(image_id, 0, 0, 16, 16, 41, z, -5, -5, z + 1, rotation); } }; diff --git a/src/ride/thrill/top_spin.c b/src/ride/thrill/top_spin.c index 1e753d000e..e035f856e6 100644 --- a/src/ride/thrill/top_spin.c +++ b/src/ride/thrill/top_spin.c @@ -130,11 +130,12 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di (ride->track_colour_supports[0] << 24); } + const uint8 rotation = get_current_rotation(); image_id += (direction & 1) << 1; image_id += rideEntry->vehicles[0].base_image_id; // Left back bottom support image_id += 572; - sub_98197C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98197C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); image_id = RCT2_GLOBAL(0x00F441A0, uint32); if (image_id == 0x20000000) { @@ -156,7 +157,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di // Left hand arm image_id += 380; - sub_98199C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); uint32 seatImageId; @@ -212,7 +213,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di RCT2_GLOBAL(0x014280B9, sint8) = (sint8)seatCoords.y; RCT2_GLOBAL(0x014280BA, sint16) = seatCoords.z; - sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); rct_drawpixelinfo* dpi = RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*); if (dpi->zoom_level < 2 && vehicle != NULL && vehicle->num_peeps != 0) { @@ -223,7 +224,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di image_id += 0xA0000000; image_id += 76; - sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); if (vehicle->num_peeps > 2) { image_id = @@ -233,7 +234,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di image_id += 0xA0000000; image_id += 152; - sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); } if (vehicle->num_peeps > 4) { @@ -244,7 +245,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di image_id += 0xA0000000; image_id += 228; - sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); } if (vehicle->num_peeps > 6) { @@ -255,7 +256,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di image_id += 0xA0000000; image_id += 304; - sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, (sint8) seatCoords.x, (sint8) seatCoords.y, lengthX, lengthY, 90, seatCoords.z, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); } } @@ -273,7 +274,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di // Right hand arm image_id += 476; - sub_98199C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); image_id = RCT2_GLOBAL(0x00F441A0, uint32); if (image_id == 0x20000000) { @@ -288,7 +289,7 @@ static void top_spin_paint_vehicle(sint8 al, sint8 cl, uint8 rideIndex, uint8 di // Right back bottom support image_id += 573; - sub_98199C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, get_current_rotation()); + sub_98199C(image_id, al, cl, lengthX, lengthY, 90, height, boundBoxOffsetX, boundBoxOffsetY, boundBoxOffsetZ, rotation); RCT2_GLOBAL(0x009DE578, rct_map_element*) = curMapElement; RCT2_GLOBAL(RCT2_ADDRESS_PAINT_SETUP_CURRENT_TYPE, uint8) = VIEWPORT_INTERACTION_ITEM_RIDE; @@ -302,29 +303,30 @@ static void top_spin_paint_tile_1(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[get_current_rotation()].x) | - (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); + ((x / 32) + loc_7667AE[rotation].x) | + (((y / 32) + loc_7667AE[rotation].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, rotation); } entranceLoc = - ((x / 32) + loc_7667AC[get_current_rotation()].x) | - (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); + ((x / 32) + loc_7667AC[rotation].x) | + (((y / 32) + loc_7667AC[rotation].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0, 2, height + 2, get_current_rotation()); + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 0, 2, height + 2, rotation); } top_spin_paint_vehicle(32, 32, rideIndex, direction, height, mapElement); @@ -357,20 +359,21 @@ static void top_spin_paint_tile_2(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AC[get_current_rotation()].x) | - (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); + ((x / 32) + loc_7667AC[rotation].x) | + (((y / 32) + loc_7667AC[rotation].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, rotation); } RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; @@ -398,20 +401,21 @@ static void top_spin_paint_tile_4(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22137 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[get_current_rotation()].x) | - (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); + ((x / 32) + loc_7667AE[rotation].x) | + (((y / 32) + loc_7667AE[rotation].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, rotation); } RCT2_GLOBAL(0x141E9B4, uint16) = 0xFFFF; @@ -439,30 +443,31 @@ static void top_spin_paint_tile_3(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22136 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AC[get_current_rotation()].x) | - (((y / 32) + loc_7667AC[get_current_rotation()].y) << 8); + ((x / 32) + loc_7667AC[rotation].x) | + (((y / 32) + loc_7667AC[rotation].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22138 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, get_current_rotation()); + sub_98199C(image_id, 0, 0, 1, 32, 7, height, 2, 0, height + 2, rotation); } entranceLoc = - ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | - (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(rotation + 3) & 3].x) | + (((y / 32) + loc_7667AC[(rotation + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, rotation); } top_spin_paint_vehicle(32, -32, rideIndex, direction, height, mapElement); @@ -495,20 +500,21 @@ static void top_spin_paint_tile_5(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22136 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | - (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(rotation + 3) & 3].x) | + (((y / 32) + loc_7667AC[(rotation + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 1, 7, height, 0, 30, height + 2, rotation); } top_spin_paint_vehicle(0, -32, rideIndex, direction, height, mapElement); @@ -538,30 +544,31 @@ static void top_spin_paint_tile_6(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22135 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint16 entranceLoc = - ((x / 32) + loc_7667AE[get_current_rotation()].x) | - (((y / 32) + loc_7667AE[get_current_rotation()].y) << 8); + ((x / 32) + loc_7667AE[rotation].x) | + (((y / 32) + loc_7667AE[rotation].y) << 8); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22141 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, get_current_rotation()); + sub_98199C(image_id, 0, 0, 32, 1, 7, height, 0, 2, height + 2, rotation); } entranceLoc = - ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | - (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(rotation + 1) & 3].x) | + (((y / 32) + loc_7667AE[(rotation + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 2, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 2, height + 2, rotation); } top_spin_paint_vehicle(-32, 32, rideIndex, direction, height, mapElement); @@ -594,31 +601,32 @@ static void top_spin_paint_tile_7(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22134 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | - (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(rotation + 1) & 3].x) | + (((y / 32) + loc_7667AE[(rotation + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 1, 28, 7, height, 29, 0, height + 3, get_current_rotation()); + sub_98197C(image_id, 0, 0, 1, 28, 7, height, 29, 0, height + 3, rotation); } entranceLoc = - ((x / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].x) | - (((y / 32) + loc_7667AC[(get_current_rotation() + 3) & 3].y) << 8); + ((x / 32) + loc_7667AC[(rotation + 3) & 3].x) | + (((y / 32) + loc_7667AC[(rotation + 3) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22139 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 28, 1, 7, height, 0, 29, height + 3, get_current_rotation()); + sub_98197C(image_id, 0, 0, 28, 1, 7, height, 0, 29, height + 3, rotation); } top_spin_paint_vehicle(-32, -32, rideIndex, direction, height, mapElement); @@ -651,21 +659,22 @@ static void top_spin_paint_tile_8(uint8 rideIndex, uint8 trackSequence, uint8 di uint32 image_id = RCT2_GLOBAL(0x00F441A0, uint32); wooden_a_supports_paint_setup(direction & 1, 0, height, image_id, NULL); + const uint8 rotation = get_current_rotation(); image_id = 22135 | RCT2_GLOBAL(0x00F44198, uint32); - sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, get_current_rotation()); + sub_98197C(image_id, 0, 0, 32, 32, 1, height, 0, 0, height, rotation); sint16 x = RCT2_GLOBAL(0x009DE56A, sint16), y = RCT2_GLOBAL(0x009DE56E, sint16); uint8 entranceId = (mapElement->properties.track.sequence & 0x70) >> 4; rct_ride* ride = get_ride(rideIndex); uint16 entranceLoc = - ((x / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].x) | - (((y / 32) + loc_7667AE[(get_current_rotation() + 1) & 3].y) << 8); + ((x / 32) + loc_7667AE[(rotation + 1) & 3].x) | + (((y / 32) + loc_7667AE[(rotation + 1) & 3].y) << 8); if (ride->entrances[entranceId] != entranceLoc && ride->exits[entranceId] != entranceLoc) { image_id = 22140 | RCT2_GLOBAL(0x00F441A0, uint32); - sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, get_current_rotation()); + sub_98197C(image_id, 0, 0, 1, 32, 7, height, 30, 0, height + 2, rotation); } top_spin_paint_vehicle(-32, 0, rideIndex, direction, height, mapElement); diff --git a/src/ride/vehicle_paint.c b/src/ride/vehicle_paint.c index 1fe49eee2c..341826feb3 100644 --- a/src/ride/vehicle_paint.c +++ b/src/ride/vehicle_paint.c @@ -899,8 +899,9 @@ void vehicle_sprite_paint(rct_vehicle *vehicle, int ebx, int ecx, int z, const r if (vehicleEntry->flags_b & 0x80) { baseImage_id += vehicle->var_C5; } + uint32 rotation = get_current_rotation(); int image_id = baseImage_id | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0x80000000; - paint_struct* ps = sub_98197C(image_id, 0, 0, bb.length_x, bb.length_y, bb.length_z, z, bb.offset_x, bb.offset_y, bb.offset_z + z, get_current_rotation()); + paint_struct* ps = sub_98197C(image_id, 0, 0, bb.length_x, bb.length_y, bb.length_z, z, bb.offset_x, bb.offset_y, bb.offset_z + z, rotation); if (ps != NULL) { ps->tertiary_colour = vehicle->colours_extended; } @@ -913,7 +914,7 @@ void vehicle_sprite_paint(rct_vehicle *vehicle, int ebx, int ecx, int z, const r if (i == 0 && vehicleEntry->flags_b & 0x100) { image_id += (vehicleEntry->no_vehicle_images * vehicle->var_C5); } - sub_98199C(image_id, 0, 0, bb.length_x, bb.length_y, bb.length_z, z, bb.offset_x, bb.offset_y, bb.offset_z + z, get_current_rotation()); + sub_98199C(image_id, 0, 0, bb.length_x, bb.length_y, bb.length_z, z, bb.offset_x, bb.offset_y, bb.offset_z + z, rotation); baseImage_id += vehicleEntry->no_vehicle_images; } } diff --git a/src/ride/water/river_rapids.c b/src/ride/water/river_rapids.c index 7fdd6e9a75..a78994d826 100644 --- a/src/ride/water/river_rapids.c +++ b/src/ride/water/river_rapids.c @@ -43,7 +43,8 @@ void vehicle_visual_river_rapids(int x, int imageDirection, int y, int z, rct_ve { int image_id; int baseImage_id = imageDirection; - int ecx = ((vehicle->var_BA / 8) + (get_current_rotation() * 8)) & 31; + uint32 rotation = get_current_rotation(); + int ecx = ((vehicle->var_BA / 8) + (rotation * 8)) & 31; int j = 0; if (vehicle->vehicle_sprite_type == 0) { baseImage_id = ecx & 7; @@ -73,27 +74,27 @@ void vehicle_visual_river_rapids(int x, int imageDirection, int y, int z, rct_ve const vehicle_boundbox *bb = &_riverRapidsBoundbox[j]; image_id = baseImage_id | (vehicle->colours.body_colour << 19) | (vehicle->colours.trim_colour << 24) | 0xA0000000; - sub_98197C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98197C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); if (RCT2_GLOBAL(0x140E9A8, rct_drawpixelinfo*)->zoom_level < 2 && vehicle->num_peeps > 0) { // Draw peeps: (this particular vehicle doesn't sort them back to front like others so the back ones sometimes clip, but thats how the original does it...) int peeps = ((ecx / 8) + 0) & 3; image_id = (baseImage_id + ((peeps + 1) * 72)) | (vehicle->peep_tshirt_colours[0] << 19) | (vehicle->peep_tshirt_colours[1] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); if (vehicle->num_peeps > 2) { peeps = ((ecx / 8) + 2) & 3; image_id = (baseImage_id + ((peeps + 1) * 72)) | (vehicle->peep_tshirt_colours[2] << 19) | (vehicle->peep_tshirt_colours[3] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); } if (vehicle->num_peeps > 4) { peeps = ((ecx / 8) + 1) & 3; image_id = (baseImage_id + ((peeps + 1) * 72)) | (vehicle->peep_tshirt_colours[4] << 19) | (vehicle->peep_tshirt_colours[5] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); } if (vehicle->num_peeps > 6) { peeps = ((ecx / 8) + 3) & 3; image_id = (baseImage_id + ((peeps + 1) * 72)) | (vehicle->peep_tshirt_colours[6] << 19) | (vehicle->peep_tshirt_colours[7] << 24) | 0xA0000000; - sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, get_current_rotation()); + sub_98199C(image_id, 0, 0, bb->length_x, bb->length_y, bb->length_z, z, bb->offset_x, bb->offset_y, bb->offset_z + z, rotation); } } diff --git a/src/world/map.c b/src/world/map.c index 25f7fe3ff3..6535f0ff94 100644 --- a/src/world/map.c +++ b/src/world/map.c @@ -3840,28 +3840,29 @@ void map_get_bounding_box(int ax, int ay, int bx, int by, int *left, int *top, i int x, y; x = ax; y = ay; - translate_3d_to_2d(get_current_rotation(), &x, &y); + uint32 rotation = get_current_rotation(); + translate_3d_to_2d(rotation, &x, &y); *left = x; *right = x; *top = y; *bottom = y; x = bx; y = ay; - translate_3d_to_2d(get_current_rotation(), &x, &y); + translate_3d_to_2d(rotation, &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; if (y < *top) *top = y; x = bx; y = by; - translate_3d_to_2d(get_current_rotation(), &x, &y); + translate_3d_to_2d(rotation, &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y; if (y < *top) *top = y; x = ax; y = by; - translate_3d_to_2d(get_current_rotation(), &x, &y); + translate_3d_to_2d(rotation, &x, &y); if (x < *left) *left = x; if (x > *right) *right = x; if (y > *bottom) *bottom = y;