From 232f37e186d783d79288a728798446a49b936230 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Tue, 25 Jun 2024 11:21:14 +0200 Subject: [PATCH] Fix #22161: Using arrow keys in textboxes crashes the game --- distribution/changelog.txt | 1 + src/openrct2-ui/interface/Widget.cpp | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 1ed92c6d76..701d331c87 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -38,6 +38,7 @@ - Fix: [#22012] [Plugin] Images on ImgButton widgets cannot be updated. - Fix: [#22121] Some news items in the “Recent Messages” window have the wrong text colour. - Fix: [#22152] [Plugin] Negative signed integers are truncated. +- Fix: [#22161] Using arrow keys in textboxes crashes the game. - Fix: [#22174] Cheats are reset when starting a server. - Fix: [objects#323] Incorrect wall boundaries on large WW/TT scenery objects. - Fix: [objects#331] Incorrect hover car capacity string. diff --git a/src/openrct2-ui/interface/Widget.cpp b/src/openrct2-ui/interface/Widget.cpp index 30307c3c0c..3a98d5a490 100644 --- a/src/openrct2-ui/interface/Widget.cpp +++ b/src/openrct2-ui/interface/Widget.cpp @@ -1169,7 +1169,8 @@ static void WidgetTextBoxDraw(DrawPixelInfo& dpi, WindowBase& w, WidgetIndex wid // Make a new 1 character wide string for measuring the width // of the character that the cursor is under. (NOTE: this is broken for multi byte utf8 codepoints) width = std::max( - GfxGetStringWidthNoFormatting(u8string{ textInput->Buffer[textInput->SelectionStart] }, FontStyle::Medium) - 2, 4); + GfxGetStringWidthNoFormatting(u8string{ (*textInput->Buffer)[textInput->SelectionStart] }, FontStyle::Medium) - 2, + 4); } if (OpenRCT2::Ui::Windows::TextBoxCaretIsFlashed())