From 307cd0db4a75b57a0fc61f8af25ae175c5255181 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 7 Sep 2016 22:35:10 -0400 Subject: SHERLOCK: RT: Fix crash using invalid number keys in conversations --- engines/sherlock/tattoo/widget_talk.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'engines/sherlock/tattoo/widget_talk.cpp') diff --git a/engines/sherlock/tattoo/widget_talk.cpp b/engines/sherlock/tattoo/widget_talk.cpp index b673f32d31..aec664561e 100644 --- a/engines/sherlock/tattoo/widget_talk.cpp +++ b/engines/sherlock/tattoo/widget_talk.cpp @@ -196,22 +196,21 @@ void WidgetTalk::handleEvents() { // Handle selecting a talk entry if a numeric key has been pressed if (keycode >= Common::KEYCODE_1 && keycode <= Common::KEYCODE_9) { - int x = 0, t = 0, y = 0; + int x = 0, y = 0, t; + + for (t = 0; t < (int)_statementLines.size(); ++t) { + if (t > 0 && _statementLines[x]._num != _statementLines[t]._num) { + x = t; + ++y; + } - do { if (y == (keycode - Common::KEYCODE_1)) { _selector = _statementLines[t]._num; _outsideMenu = false; hotkey = true; break; } - - ++t; - if (_statementLines[x]._num != _statementLines[t]._num) { - x = t; - ++y; - } - } while (t < (int)_statementLines.size()); + } } // Display the selected statement highlighted and reset the last statement. -- cgit v1.2.3