aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruruk2014-02-20 14:41:42 +0100
committeruruk2014-02-20 14:41:56 +0100
commit37b147d9503b0614983d7072be60c2708ade0800 (patch)
tree77cb2961fde8f2204a21d0961a38ed077f69cac8
parentf8a956777385163b3a77cf7f4de4770b70fc89b9 (diff)
downloadscummvm-rg350-37b147d9503b0614983d7072be60c2708ade0800.tar.gz
scummvm-rg350-37b147d9503b0614983d7072be60c2708ade0800.tar.bz2
scummvm-rg350-37b147d9503b0614983d7072be60c2708ade0800.zip
AVALANCHE: Repair out of bound read in Help::handleMouse().
-rw-r--r--engines/avalanche/help.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/engines/avalanche/help.cpp b/engines/avalanche/help.cpp
index b667ad090d..5d3247ba9a 100644
--- a/engines/avalanche/help.cpp
+++ b/engines/avalanche/help.cpp
@@ -180,6 +180,7 @@ bool Help::handleMouse(const Common::Event &event) {
} else { // LBUTTONDOWN or MOUSEMOVE
int highlightIs = 0;
+ // Decide which button we are hovering the cursor over:
if ((mousePos.x > 470) && (mousePos.x <= 550) && (((mousePos.y - 13) % 27) <= 20)) { // No click, so highlight.
highlightIs = (mousePos.y - 13) / 27 - 1;
if ((highlightIs < 0) || (5 < highlightIs))
@@ -187,20 +188,21 @@ bool Help::handleMouse(const Common::Event &event) {
} else
highlightIs = 177;
- if (((highlightIs != 177) && (event.type == Common::EVENT_LBUTTONDOWN)) || _holdLeft) {
+ Color highlightColor = kColorLightblue;
+ // If we clicked on a button or we are holding down the button, we have to highlight it with cyan:
+ if (((highlightIs != 177) && ((event.type == Common::EVENT_LBUTTONDOWN)) || _holdLeft)) {
_holdLeft = true;
- highlightIs += 32;
+ highlightColor = kColorLightcyan;
}
- if (_highlightWas != highlightIs) {
+ // Erase the previous highlight only if it's needed:
+ if (_highlightWas != highlightIs)
_vm->_graphics->helpDrawHighlight(_highlightWas, kColorBlue);
+
+ // Highligt the current one with the proper color:
+ if (_buttons[highlightIs]._trigger != Common::KEYCODE_INVALID) {
_highlightWas = highlightIs;
- if (_buttons[highlightIs & 31]._trigger != Common::KEYCODE_INVALID) {
- if (highlightIs > 31)
- _vm->_graphics->helpDrawHighlight(highlightIs, kColorLightcyan);
- else
- _vm->_graphics->helpDrawHighlight(highlightIs, kColorLightblue);
- }
+ _vm->_graphics->helpDrawHighlight(highlightIs, highlightColor);
}
}