aboutsummaryrefslogtreecommitdiff
path: root/engines/sherlock
diff options
context:
space:
mode:
authorPaul Gilbert2016-09-07 22:35:10 -0400
committerPaul Gilbert2016-09-07 22:35:10 -0400
commit307cd0db4a75b57a0fc61f8af25ae175c5255181 (patch)
tree05e598dffe0ea8fc98b504ec67fedeb97167aef6 /engines/sherlock
parent2e643276df90339f76a34897d4f9aeaf549ffb8d (diff)
downloadscummvm-rg350-307cd0db4a75b57a0fc61f8af25ae175c5255181.tar.gz
scummvm-rg350-307cd0db4a75b57a0fc61f8af25ae175c5255181.tar.bz2
scummvm-rg350-307cd0db4a75b57a0fc61f8af25ae175c5255181.zip
SHERLOCK: RT: Fix crash using invalid number keys in conversations
Diffstat (limited to 'engines/sherlock')
-rw-r--r--engines/sherlock/tattoo/widget_talk.cpp17
1 files changed, 8 insertions, 9 deletions
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.