1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-24 00:03:11 +01:00

Make generic version of 98197C rotations. Refactor.

I've added a new function coordinate 3d to 2d. There are still quite a few different versions of this same code throughout the project that should be changed to use this function.
This commit is contained in:
Duncan Frost
2015-06-21 16:22:09 +01:00
parent 2c6312a86d
commit d5c19437ac
4 changed files with 150 additions and 191 deletions

View File

@@ -1270,6 +1270,12 @@ void window_scroll_to_viewport(rct_window *w)
*/
void window_scroll_to_location(rct_window *w, int x, int y, int z)
{
rct_xyz16 location_3d = {
.x = x,
.y = y,
.z = z
};
if (w->viewport) {
sint16 height = map_element_height(x, y);
if (z < height - 16) {
@@ -1283,26 +1289,9 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z)
window_invalidate(w);
}
}
sint16 sx;
sint16 sy;
switch (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8)) {
case 0:
sx = y - x;
sy = ((x + y) / 2) - z;
break;
case 1:
sx = -y - x;
sy = ((-x + y) / 2) - z;
break;
case 2:
sx = -y + x;
sy = ((-x - y) / 2) - z;
break;
case 3:
sx = y + x;
sy = ((x - y) / 2) - z;
break;
}
rct_xy16 map_coordinate = coordinate_3d_to_2d(&location_3d, RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_ROTATION, uint8));
int i = 0;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)) {
int found = 0;
@@ -1336,8 +1325,8 @@ void window_scroll_to_location(rct_window *w, int x, int y, int z)
// rct2: 0x006E7C76
if (w->viewport_target_sprite == -1) {
if (!(w->flags & WF_2)) {
w->saved_view_x = sx - (sint16)(w->viewport->view_width * window_scroll_locations[i][0]);
w->saved_view_y = sy - (sint16)(w->viewport->view_height * window_scroll_locations[i][1]);
w->saved_view_x = map_coordinate.x - (sint16)(w->viewport->view_width * window_scroll_locations[i][0]);
w->saved_view_y = map_coordinate.y - (sint16)(w->viewport->view_height * window_scroll_locations[i][1]);
w->flags |= WF_SCROLLING_TO_LOCATION;
}
}