diff --git a/src/openrct2-ui/input/InputManager.cpp b/src/openrct2-ui/input/InputManager.cpp index 2bf671a1d4..ccc6d25f10 100644 --- a/src/openrct2-ui/input/InputManager.cpp +++ b/src/openrct2-ui/input/InputManager.cpp @@ -115,7 +115,7 @@ void InputManager::HandleViewScrolling() auto mainWindow = window_get_main(); if (mainWindow != nullptr && (_viewScroll.x != 0 || _viewScroll.y != 0)) { - window_unfollow_sprite(mainWindow); + window_unfollow_sprite(*mainWindow); } InputScrollViewport(_viewScroll); diff --git a/src/openrct2-ui/input/MouseInput.cpp b/src/openrct2-ui/input/MouseInput.cpp index 5220802ee5..f340f6ea30 100644 --- a/src/openrct2-ui/input/MouseInput.cpp +++ b/src/openrct2-ui/input/MouseInput.cpp @@ -297,7 +297,7 @@ static void GameHandleInputMouse(const ScreenCoordsXY& screenCoords, MouseState if (w != nullptr) { - w = window_bring_to_front(w); + w = window_bring_to_front(*w); } if (widgetIndex != -1) @@ -530,7 +530,7 @@ static void InputViewportDragBegin(rct_window& w) gInputDragLast = cursorPosition; context_hide_cursor(); - window_unfollow_sprite(&w); + window_unfollow_sprite(w); // gInputFlags |= INPUT_FLAG_5; } @@ -1012,7 +1012,7 @@ static void InputWidgetLeft(const ScreenCoordsXY& screenCoords, rct_window* w, r if (w == nullptr) return; - w = window_bring_to_front(w); + w = window_bring_to_front(*w); if (widgetIndex == -1) return; diff --git a/src/openrct2-ui/scripting/CustomWindow.cpp b/src/openrct2-ui/scripting/CustomWindow.cpp index d534aed7ef..685235f37f 100644 --- a/src/openrct2-ui/scripting/CustomWindow.cpp +++ b/src/openrct2-ui/scripting/CustomWindow.cpp @@ -666,7 +666,7 @@ namespace OpenRCT2::Ui::Windows else if (widgetDesc->Type == "textbox") { auto* text = const_cast(widgetDesc->Text.c_str()); - window_start_textbox(this, widgetIndex, STR_STRING, text, widgetDesc->MaxLength + 1); + window_start_textbox(*this, widgetIndex, STR_STRING, text, widgetDesc->MaxLength + 1); } } } diff --git a/src/openrct2-ui/scripting/ScWindow.hpp b/src/openrct2-ui/scripting/ScWindow.hpp index 7868886b67..b79a861d26 100644 --- a/src/openrct2-ui/scripting/ScWindow.hpp +++ b/src/openrct2-ui/scripting/ScWindow.hpp @@ -307,7 +307,7 @@ namespace OpenRCT2::Scripting auto w = GetWindow(); if (w != nullptr) { - window_bring_to_front(w); + window_bring_to_front(*w); w->flags |= WF_WHITE_BORDER_MASK; } } diff --git a/src/openrct2-ui/windows/EditorObjectSelection.cpp b/src/openrct2-ui/windows/EditorObjectSelection.cpp index 9b36d52c90..7a411d5750 100644 --- a/src/openrct2-ui/windows/EditorObjectSelection.cpp +++ b/src/openrct2-ui/windows/EditorObjectSelection.cpp @@ -416,7 +416,7 @@ public: break; } case WIDX_FILTER_TEXT_BOX: - window_start_textbox(this, widgetIndex, STR_STRING, _filter_string, sizeof(_filter_string)); + window_start_textbox(*this, widgetIndex, STR_STRING, _filter_string, sizeof(_filter_string)); break; case WIDX_FILTER_CLEAR_BUTTON: std::fill_n(_filter_string, sizeof(_filter_string), 0x00); diff --git a/src/openrct2-ui/windows/Guest.cpp b/src/openrct2-ui/windows/Guest.cpp index 2c00c2823e..d5302f1440 100644 --- a/src/openrct2-ui/windows/Guest.cpp +++ b/src/openrct2-ui/windows/Guest.cpp @@ -697,7 +697,7 @@ private: void GuestFollow() { rct_window* main = window_get_main(); - window_follow_sprite(main, EntityId::FromUnderlying(number)); + window_follow_sprite(*main, EntityId::FromUnderlying(number)); } void OnViewportRotateOverview() diff --git a/src/openrct2-ui/windows/Ride.cpp b/src/openrct2-ui/windows/Ride.cpp index 321c811e38..6f1c1c0e95 100644 --- a/src/openrct2-ui/windows/Ride.cpp +++ b/src/openrct2-ui/windows/Ride.cpp @@ -1983,7 +1983,7 @@ static void WindowRideMainFollowRide(rct_window* w) { auto headVehicleSpriteIndex = vehicle->sprite_index; rct_window* w_main = window_get_main(); - window_follow_sprite(w_main, headVehicleSpriteIndex); + window_follow_sprite(*w_main, headVehicleSpriteIndex); } } } diff --git a/src/openrct2-ui/windows/ServerList.cpp b/src/openrct2-ui/windows/ServerList.cpp index 6881d54319..893b1f5c9e 100644 --- a/src/openrct2-ui/windows/ServerList.cpp +++ b/src/openrct2-ui/windows/ServerList.cpp @@ -167,7 +167,7 @@ static void WindowServerListMouseup(rct_window* w, rct_widgetindex widgetIndex) window_close(*w); break; case WIDX_PLAYER_NAME_INPUT: - window_start_textbox(w, widgetIndex, STR_STRING, _playerName, 63); + window_start_textbox(*w, widgetIndex, STR_STRING, _playerName, 63); break; case WIDX_LIST: { diff --git a/src/openrct2-ui/windows/ServerStart.cpp b/src/openrct2-ui/windows/ServerStart.cpp index 1a7dc0e0e6..822a733f3c 100644 --- a/src/openrct2-ui/windows/ServerStart.cpp +++ b/src/openrct2-ui/windows/ServerStart.cpp @@ -97,19 +97,19 @@ public: Close(); break; case WIDX_PORT_INPUT: - window_start_textbox(this, widgetIndex, STR_STRING, _port, 6); + window_start_textbox(*this, widgetIndex, STR_STRING, _port, 6); break; case WIDX_NAME_INPUT: - window_start_textbox(this, widgetIndex, STR_STRING, _name, 64); + window_start_textbox(*this, widgetIndex, STR_STRING, _name, 64); break; case WIDX_DESCRIPTION_INPUT: - window_start_textbox(this, widgetIndex, STR_STRING, _description, MAX_SERVER_DESCRIPTION_LENGTH); + window_start_textbox(*this, widgetIndex, STR_STRING, _description, MAX_SERVER_DESCRIPTION_LENGTH); break; case WIDX_GREETING_INPUT: - window_start_textbox(this, widgetIndex, STR_STRING, _greeting, CHAT_INPUT_SIZE); + window_start_textbox(*this, widgetIndex, STR_STRING, _greeting, CHAT_INPUT_SIZE); break; case WIDX_PASSWORD_INPUT: - window_start_textbox(this, widgetIndex, STR_STRING, _password, 32); + window_start_textbox(*this, widgetIndex, STR_STRING, _password, 32); break; case WIDX_MAXPLAYERS_INCREASE: if (gConfigNetwork.maxplayers < 255) diff --git a/src/openrct2-ui/windows/Staff.cpp b/src/openrct2-ui/windows/Staff.cpp index b65bcad1e9..53e57d1f0d 100644 --- a/src/openrct2-ui/windows/Staff.cpp +++ b/src/openrct2-ui/windows/Staff.cpp @@ -1200,7 +1200,7 @@ private: void FollowPeep() { rct_window* main = window_get_main(); - window_follow_sprite(main, EntityId::FromUnderlying(number)); + window_follow_sprite(*main, EntityId::FromUnderlying(number)); } void DrawTabImages(rct_drawpixelinfo* dpi) diff --git a/src/openrct2-ui/windows/TitleMenu.cpp b/src/openrct2-ui/windows/TitleMenu.cpp index 76e7d7fc80..aa48d62bc2 100644 --- a/src/openrct2-ui/windows/TitleMenu.cpp +++ b/src/openrct2-ui/windows/TitleMenu.cpp @@ -133,7 +133,7 @@ static void WindowTitleMenuMouseup(rct_window* w, rct_widgetindex widgetIndex) windowToOpen = window_find_by_class(WC_SCENARIO_SELECT); if (windowToOpen != nullptr) { - window_bring_to_front(windowToOpen); + window_bring_to_front(*windowToOpen); } else { @@ -146,7 +146,7 @@ static void WindowTitleMenuMouseup(rct_window* w, rct_widgetindex widgetIndex) windowToOpen = window_find_by_class(WC_LOADSAVE); if (windowToOpen != nullptr) { - window_bring_to_front(windowToOpen); + window_bring_to_front(*windowToOpen); } else { @@ -160,7 +160,7 @@ static void WindowTitleMenuMouseup(rct_window* w, rct_widgetindex widgetIndex) windowToOpen = window_find_by_class(WC_SERVER_LIST); if (windowToOpen != nullptr) { - window_bring_to_front(windowToOpen); + window_bring_to_front(*windowToOpen); } else { diff --git a/src/openrct2-ui/windows/TrackList.cpp b/src/openrct2-ui/windows/TrackList.cpp index 981a79c816..935045691d 100644 --- a/src/openrct2-ui/windows/TrackList.cpp +++ b/src/openrct2-ui/windows/TrackList.cpp @@ -279,7 +279,7 @@ public: } break; case WIDX_FILTER_STRING: - window_start_textbox(this, widgetIndex, STR_STRING, _filterString, sizeof(_filterString)); // TODO check this + window_start_textbox(*this, widgetIndex, STR_STRING, _filterString, sizeof(_filterString)); // TODO check this // out break; case WIDX_FILTER_CLEAR: diff --git a/src/openrct2/Game.cpp b/src/openrct2/Game.cpp index 4d6b2461a4..6cd56f0336 100644 --- a/src/openrct2/Game.cpp +++ b/src/openrct2/Game.cpp @@ -468,7 +468,7 @@ void game_load_init() else { auto* mainWindow = window_get_main(); - window_unfollow_sprite(mainWindow); + window_unfollow_sprite(*mainWindow); } auto windowManager = GetContext()->GetUiContext()->GetWindowManager(); diff --git a/src/openrct2/interface/Viewport.cpp b/src/openrct2/interface/Viewport.cpp index c3e1acf335..569510befe 100644 --- a/src/openrct2/interface/Viewport.cpp +++ b/src/openrct2/interface/Viewport.cpp @@ -1919,7 +1919,7 @@ void viewport_invalidate(const rct_viewport* viewport, const ScreenRect& screenR if (owner != nullptr && owner->classification != WC_MAIN_WINDOW) { // note, window_is_visible will update viewport->visibility, so this should have a low hit count - if (!window_is_visible(owner)) + if (!window_is_visible(*owner)) { return; } diff --git a/src/openrct2/interface/Window.cpp b/src/openrct2/interface/Window.cpp index cca2a1e953..96480a1826 100644 --- a/src/openrct2/interface/Window.cpp +++ b/src/openrct2/interface/Window.cpp @@ -83,8 +83,8 @@ namespace WindowCloseFlags static constexpr uint32_t CloseSingle = (1 << 1); } // namespace WindowCloseFlags -static void window_draw_core(rct_drawpixelinfo* dpi, rct_window* w, int32_t left, int32_t top, int32_t right, int32_t bottom); -static void window_draw_single(rct_drawpixelinfo* dpi, rct_window* w, int32_t left, int32_t top, int32_t right, int32_t bottom); +static void window_draw_core(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t top, int32_t right, int32_t bottom); +static void window_draw_single(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t top, int32_t right, int32_t bottom); std::list>::iterator window_get_iterator(const rct_window* w) { @@ -115,7 +115,7 @@ void window_dispatch_update_all() void window_update_all_viewports() { window_visit_each([&](rct_window* w) { - if (w->viewport != nullptr && window_is_visible(w)) + if (w->viewport != nullptr && window_is_visible(*w)) { viewport_update_position(w); } @@ -649,11 +649,11 @@ int32_t window_get_scroll_data_index(rct_window& w, rct_widgetindex widget_index * * rct2: 0x006ECDA4 */ -rct_window* window_bring_to_front(rct_window* w) +rct_window* window_bring_to_front(rct_window& w) { - if (!(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) + if (!(w.flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT))) { - auto itSourcePos = window_get_iterator(w); + auto itSourcePos = window_get_iterator(&w); if (itSourcePos != g_window_list.end()) { // Insert in front of the first non-stick-to-front window @@ -669,31 +669,29 @@ rct_window* window_bring_to_front(rct_window* w) } g_window_list.splice(itDestPos, g_window_list, itSourcePos); - w->Invalidate(); + w.Invalidate(); - if (w->windowPos.x + w->width < 20) + if (w.windowPos.x + w.width < 20) { - int32_t i = 20 - w->windowPos.x; - w->windowPos.x += i; - if (w->viewport != nullptr) - w->viewport->pos.x += i; - w->Invalidate(); + int32_t i = 20 - w.windowPos.x; + w.windowPos.x += i; + if (w.viewport != nullptr) + w.viewport->pos.x += i; + w.Invalidate(); } } } - return w; + return &w; } rct_window* window_bring_to_front_by_class_with_flags(rct_windowclass cls, uint16_t flags) { - rct_window* w; - - w = window_find_by_class(cls); + rct_window* w = window_find_by_class(cls); if (w != nullptr) { w->flags |= flags; w->Invalidate(); - w = window_bring_to_front(w); + w = window_bring_to_front(*w); } return w; @@ -719,7 +717,7 @@ rct_window* window_bring_to_front_by_number(rct_windowclass cls, rct_windownumbe { w->flags |= WF_WHITE_BORDER_MASK; w->Invalidate(); - w = window_bring_to_front(w); + w = window_bring_to_front(*w); } return w; @@ -820,7 +818,7 @@ rct_window* window_get_main() */ void window_scroll_to_location(rct_window& w, const CoordsXYZ& coords) { - window_unfollow_sprite(&w); + window_unfollow_sprite(w); if (w.viewport != nullptr) { int16_t height = tile_element_height(coords); @@ -1071,7 +1069,7 @@ void window_zoom_set(rct_window& w, ZoomLevel zoomLevel, bool atCursor) // HACK: Prevents the redraw from failing when there is // a window on top of the viewport. - window_bring_to_front(&w); + window_bring_to_front(w); w.Invalidate(); } @@ -1120,7 +1118,7 @@ void main_window_zoom(bool zoomIn, bool atCursor) */ void window_draw(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t top, int32_t right, int32_t bottom) { - if (!window_is_visible(&w)) + if (!window_is_visible(w)) return; // Divide the draws up for only the visible regions of the window recursively @@ -1140,26 +1138,26 @@ void window_draw(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t to if (topwindow->windowPos.x > left) { // Split draw at topwindow.left - window_draw_core(dpi, &w, left, top, topwindow->windowPos.x, bottom); - window_draw_core(dpi, &w, topwindow->windowPos.x, top, right, bottom); + window_draw_core(dpi, w, left, top, topwindow->windowPos.x, bottom); + window_draw_core(dpi, w, topwindow->windowPos.x, top, right, bottom); } else if (topwindow->windowPos.x + topwindow->width < right) { // Split draw at topwindow.right - window_draw_core(dpi, &w, left, top, topwindow->windowPos.x + topwindow->width, bottom); - window_draw_core(dpi, &w, topwindow->windowPos.x + topwindow->width, top, right, bottom); + window_draw_core(dpi, w, left, top, topwindow->windowPos.x + topwindow->width, bottom); + window_draw_core(dpi, w, topwindow->windowPos.x + topwindow->width, top, right, bottom); } else if (topwindow->windowPos.y > top) { // Split draw at topwindow.top - window_draw_core(dpi, &w, left, top, right, topwindow->windowPos.y); - window_draw_core(dpi, &w, left, topwindow->windowPos.y, right, bottom); + window_draw_core(dpi, w, left, top, right, topwindow->windowPos.y); + window_draw_core(dpi, w, left, topwindow->windowPos.y, right, bottom); } else if (topwindow->windowPos.y + topwindow->height < bottom) { // Split draw at topwindow.bottom - window_draw_core(dpi, &w, left, top, right, topwindow->windowPos.y + topwindow->height); - window_draw_core(dpi, &w, left, topwindow->windowPos.y + topwindow->height, right, bottom); + window_draw_core(dpi, w, left, top, right, topwindow->windowPos.y + topwindow->height); + window_draw_core(dpi, w, left, topwindow->windowPos.y + topwindow->height, right, bottom); } // Drawing for this region should be done now, exit @@ -1167,36 +1165,36 @@ void window_draw(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t to } // No windows overlap - window_draw_core(dpi, &w, left, top, right, bottom); + window_draw_core(dpi, w, left, top, right, bottom); } /** * Draws the given window and any other overlapping transparent windows. */ -static void window_draw_core(rct_drawpixelinfo* dpi, rct_window* w, int32_t left, int32_t top, int32_t right, int32_t bottom) +static void window_draw_core(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t top, int32_t right, int32_t bottom) { // Clamp region - left = std::max(left, w->windowPos.x); - top = std::max(top, w->windowPos.y); - right = std::min(right, w->windowPos.x + w->width); - bottom = std::min(bottom, w->windowPos.y + w->height); + left = std::max(left, w.windowPos.x); + top = std::max(top, w.windowPos.y); + right = std::min(right, w.windowPos.x + w.width); + bottom = std::min(bottom, w.windowPos.y + w.height); if (left >= right) return; if (top >= bottom) return; // Draw the window and any other overlapping transparent windows - for (auto it = window_get_iterator(w); it != g_window_list.end(); it++) + for (auto it = window_get_iterator(&w); it != g_window_list.end(); it++) { - auto v = (*it).get(); - if ((w == v || (v->flags & WF_TRANSPARENT)) && window_is_visible(v)) + auto* v = (*it).get(); + if ((&w == v || (v->flags & WF_TRANSPARENT)) && window_is_visible(*v)) { - window_draw_single(dpi, v, left, top, right, bottom); + window_draw_single(dpi, *v, left, top, right, bottom); } } } -static void window_draw_single(rct_drawpixelinfo* dpi, rct_window* w, int32_t left, int32_t top, int32_t right, int32_t bottom) +static void window_draw_single(rct_drawpixelinfo* dpi, rct_window& w, int32_t left, int32_t top, int32_t right, int32_t bottom) { // Copy dpi so we can crop it rct_drawpixelinfo copy = *dpi; @@ -1246,15 +1244,15 @@ static void window_draw_single(rct_drawpixelinfo* dpi, rct_window* w, int32_t le // Invalidate modifies the window colours so first get the correct // colour before setting the global variables for the string painting - window_event_invalidate_call(w); + window_event_invalidate_call(&w); // Text colouring - gCurrentWindowColours[0] = NOT_TRANSLUCENT(w->colours[0]); - gCurrentWindowColours[1] = NOT_TRANSLUCENT(w->colours[1]); - gCurrentWindowColours[2] = NOT_TRANSLUCENT(w->colours[2]); - gCurrentWindowColours[3] = NOT_TRANSLUCENT(w->colours[3]); + gCurrentWindowColours[0] = NOT_TRANSLUCENT(w.colours[0]); + gCurrentWindowColours[1] = NOT_TRANSLUCENT(w.colours[1]); + gCurrentWindowColours[2] = NOT_TRANSLUCENT(w.colours[2]); + gCurrentWindowColours[3] = NOT_TRANSLUCENT(w.colours[3]); - window_event_paint_call(w, dpi); + window_event_paint_call(&w, dpi); } /** @@ -1970,14 +1968,14 @@ void textinput_cancel() } void window_start_textbox( - rct_window* call_w, rct_widgetindex call_widget, rct_string_id existing_text, char* existing_args, int32_t maxLength) + rct_window& call_w, rct_widgetindex call_widget, rct_string_id existing_text, char* existing_args, int32_t maxLength) { if (gUsingWidgetTextBox) window_cancel_textbox(); gUsingWidgetTextBox = true; - gCurrentTextBox.window.classification = call_w->classification; - gCurrentTextBox.window.number = call_w->number; + gCurrentTextBox.window.classification = call_w.classification; + gCurrentTextBox.window.number = call_w.number; gCurrentTextBox.widget_index = call_widget; gTextBoxFrameNo = 0; @@ -2039,45 +2037,43 @@ void window_update_textbox() } } -bool window_is_visible(rct_window* w) +bool window_is_visible(rct_window& w) { // w->visibility is used to prevent repeat calculations within an iteration by caching the result - if (w == nullptr) - return false; - if (w->visibility == VisibilityCache::Visible) + if (w.visibility == VisibilityCache::Visible) return true; - if (w->visibility == VisibilityCache::Covered) + if (w.visibility == VisibilityCache::Covered) return false; // only consider viewports, consider the main window always visible - if (w->viewport == nullptr || w->classification == WC_MAIN_WINDOW) + if (w.viewport == nullptr || w.classification == WC_MAIN_WINDOW) { // default to previous behaviour - w->visibility = VisibilityCache::Visible; + w.visibility = VisibilityCache::Visible; return true; } // start from the window above the current - auto itPos = window_get_iterator(w); + auto itPos = window_get_iterator(&w); for (auto it = std::next(itPos); it != g_window_list.end(); it++) { auto& w_other = *(*it); // if covered by a higher window, no rendering needed - if (w_other.windowPos.x <= w->windowPos.x && w_other.windowPos.y <= w->windowPos.y - && w_other.windowPos.x + w_other.width >= w->windowPos.x + w->width - && w_other.windowPos.y + w_other.height >= w->windowPos.y + w->height) + if (w_other.windowPos.x <= w.windowPos.x && w_other.windowPos.y <= w.windowPos.y + && w_other.windowPos.x + w_other.width >= w.windowPos.x + w.width + && w_other.windowPos.y + w_other.height >= w.windowPos.y + w.height) { - w->visibility = VisibilityCache::Covered; - w->viewport->visibility = VisibilityCache::Covered; + w.visibility = VisibilityCache::Covered; + w.viewport->visibility = VisibilityCache::Covered; return false; } } // default to previous behaviour - w->visibility = VisibilityCache::Visible; - w->viewport->visibility = VisibilityCache::Visible; + w.visibility = VisibilityCache::Visible; + w.viewport->visibility = VisibilityCache::Visible; return true; } @@ -2141,18 +2137,18 @@ void window_init_all() window_close_all_except_flags(0); } -void window_follow_sprite(rct_window* w, EntityId spriteIndex) +void window_follow_sprite(rct_window& w, EntityId spriteIndex) { if (spriteIndex.ToUnderlying() < MAX_ENTITIES || spriteIndex.IsNull()) { - w->viewport_smart_follow_sprite = spriteIndex; + w.viewport_smart_follow_sprite = spriteIndex; } } -void window_unfollow_sprite(rct_window* w) +void window_unfollow_sprite(rct_window& w) { - w->viewport_smart_follow_sprite = EntityId::GetNull(); - w->viewport_target_sprite = EntityId::GetNull(); + w.viewport_smart_follow_sprite = EntityId::GetNull(); + w.viewport_target_sprite = EntityId::GetNull(); } rct_viewport* window_get_viewport(rct_window* w) @@ -2182,9 +2178,9 @@ rct_window* window_get_listening() return nullptr; } -rct_windowclass window_get_classification(rct_window* window) +rct_windowclass window_get_classification(rct_window& window) { - return window->classification; + return window.classification; } /** diff --git a/src/openrct2/interface/Window.h b/src/openrct2/interface/Window.h index a248221632..64a5939b9b 100644 --- a/src/openrct2/interface/Window.h +++ b/src/openrct2/interface/Window.h @@ -645,7 +645,7 @@ void window_update_all(); void window_set_window_limit(int32_t value); -rct_window* window_bring_to_front(rct_window* w); +rct_window* window_bring_to_front(rct_window& w); rct_window* window_bring_to_front_by_class(rct_windowclass cls); rct_window* window_bring_to_front_by_class_with_flags(rct_windowclass cls, uint16_t flags); rct_window* window_bring_to_front_by_number(rct_windowclass cls, rct_windownumber number); @@ -799,12 +799,12 @@ void window_move_and_snap(rct_window& w, ScreenCoordsXY newWindowCoords, int32_t int32_t window_can_resize(rct_window& w); void window_start_textbox( - rct_window* call_w, rct_widgetindex call_widget, rct_string_id existing_text, char* existing_args, int32_t maxLength); + rct_window& call_w, rct_widgetindex call_widget, rct_string_id existing_text, char* existing_args, int32_t maxLength); void window_cancel_textbox(); void window_update_textbox_caret(); void window_update_textbox(); -bool window_is_visible(rct_window* w); +bool window_is_visible(rct_window& w); bool scenery_tool_is_active(); @@ -835,8 +835,8 @@ void window_footpath_keyboard_shortcut_slope_up(); void window_footpath_keyboard_shortcut_build_current(); void window_footpath_keyboard_shortcut_demolish_current(); -void window_follow_sprite(rct_window* w, EntityId spriteIndex); -void window_unfollow_sprite(rct_window* w); +void window_follow_sprite(rct_window& w, EntityId spriteIndex); +void window_unfollow_sprite(rct_window& w); bool window_ride_construction_update_state( int32_t* trackType, int32_t* trackDirection, RideId* rideIndex, int32_t* _liftHillAndAlternativeState, CoordsXYZ* trackPos, @@ -848,4 +848,4 @@ money32 place_provisional_track_piece( extern RideConstructionState _rideConstructionState2; rct_window* window_get_listening(); -rct_windowclass window_get_classification(rct_window* window); +rct_windowclass window_get_classification(rct_window& window); diff --git a/src/openrct2/ride/Vehicle.cpp b/src/openrct2/ride/Vehicle.cpp index 1fd4102991..e53acf5728 100644 --- a/src/openrct2/ride/Vehicle.cpp +++ b/src/openrct2/ride/Vehicle.cpp @@ -804,7 +804,7 @@ bool Vehicle::SoundCanPlay() const auto left = g_music_tracking_viewport->viewPos.x; auto bottom = g_music_tracking_viewport->viewPos.y; - if (window_get_classification(gWindowAudioExclusive) == WC_MAIN_WINDOW) + if (window_get_classification(*gWindowAudioExclusive) == WC_MAIN_WINDOW) { left -= quarter_w; bottom -= quarter_h; @@ -816,7 +816,7 @@ bool Vehicle::SoundCanPlay() const auto right = g_music_tracking_viewport->view_width + left; auto top = g_music_tracking_viewport->view_height + bottom; - if (window_get_classification(gWindowAudioExclusive) == WC_MAIN_WINDOW) + if (window_get_classification(*gWindowAudioExclusive) == WC_MAIN_WINDOW) { right += quarter_w + quarter_w; top += quarter_h + quarter_h; diff --git a/src/openrct2/title/Command/FollowEntity.cpp b/src/openrct2/title/Command/FollowEntity.cpp index 83d4625bca..28bd530a3f 100644 --- a/src/openrct2/title/Command/FollowEntity.cpp +++ b/src/openrct2/title/Command/FollowEntity.cpp @@ -18,7 +18,7 @@ namespace OpenRCT2::Title auto* w = window_get_main(); if (w != nullptr) { - window_follow_sprite(w, Follow.SpriteIndex); + window_follow_sprite(*w, Follow.SpriteIndex); } return 0; diff --git a/src/openrct2/title/TitleScreen.cpp b/src/openrct2/title/TitleScreen.cpp index 5051a23271..9840b33d7e 100644 --- a/src/openrct2/title/TitleScreen.cpp +++ b/src/openrct2/title/TitleScreen.cpp @@ -89,7 +89,7 @@ void TitleScreen::StopPreviewingSequence() rct_window* mainWindow = window_get_main(); if (mainWindow != nullptr) { - window_unfollow_sprite(mainWindow); + window_unfollow_sprite(*mainWindow); } _previewingSequence = false; _currentSequence = title_get_config_sequence();