diff --git a/src/interface/viewport.c b/src/interface/viewport.c index 943c9b83b6..cbda758778 100644 --- a/src/interface/viewport.c +++ b/src/interface/viewport.c @@ -234,6 +234,9 @@ void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation){ *y = start_y + start_x / 2 + height; height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y); + + // HACK: This is to prevent the x and y values being set to values outside + // of the map. This can happen when the height is larger than the map size. if (*x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) && *y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ *x = start_y - start_x / 2; *y = start_y + start_x / 2; @@ -246,6 +249,9 @@ void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation){ *y = start_y - start_x / 2 + height; height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y); + + // HACK: This is to prevent the x and y values being set to values outside + // of the map. This can happen when the height is larger than the map size. if (*x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) && *y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ *x = -start_y - start_x / 2; *y = start_y - start_x / 2; @@ -258,6 +264,9 @@ void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation){ *y = -start_y - start_x / 2 - height; height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y); + + // HACK: This is to prevent the x and y values being set to values outside + // of the map. This can happen when the height is larger than the map size. if (*x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) && *y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ *x = -start_y + start_x / 2; *y = -start_y - start_x / 2; @@ -270,6 +279,9 @@ void sub_689174(sint16* x, sint16* y, sint16 *z, uint8 curr_rotation){ *y = start_x / 2 - start_y - height; height = map_element_height((0xFFFF) & *x, (0xFFFF) & *y); + + // HACK: This is to prevent the x and y values being set to values outside + // of the map. This can happen when the height is larger than the map size. if (*x > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16) && *y > RCT2_GLOBAL(RCT2_ADDRESS_MAP_MAXIMUM_X_Y, sint16)){ *x = start_y + start_x / 2; *y = -start_y + start_x / 2; diff --git a/src/interface/window.c b/src/interface/window.c index 7848f35f4e..30ba02612c 100644 --- a/src/interface/window.c +++ b/src/interface/window.c @@ -1232,6 +1232,8 @@ void window_zoom_in(rct_window *w) w->saved_view_x += v->view_width >> 1; w->saved_view_y += v->view_height >> 1; + // HACK: Prevents the redraw from failing when there is + // a window on top of the viewport. window_bring_to_front(w); window_invalidate(w); } @@ -1260,6 +1262,8 @@ void window_zoom_out(rct_window *w) w->saved_view_x -= width / 2; w->saved_view_y -= height >> 1; + // HACK: Prevents the redraw from failing when there is + // a window on top of the viewport. window_bring_to_front(w); window_invalidate(w); }