[Scummvm-cvs-logs] scummvm master -> 37b147d9503b0614983d7072be60c2708ade0800

urukgit urukgit at users.noreply.github.com
Thu Feb 20 14:42:41 CET 2014


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
37b147d950 AVALANCHE: Repair out of bound read in Help::handleMouse().


Commit: 37b147d9503b0614983d7072be60c2708ade0800
    https://github.com/scummvm/scummvm/commit/37b147d9503b0614983d7072be60c2708ade0800
Author: uruk (koppirnyo at gmail.com)
Date: 2014-02-20T05:41:56-08:00

Commit Message:
AVALANCHE: Repair out of bound read in Help::handleMouse().

Changed paths:
    engines/avalanche/help.cpp



diff --git a/engines/avalanche/help.cpp b/engines/avalanche/help.cpp
index b667ad0..5d3247b 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);
 		}
 	}
 






More information about the Scummvm-git-logs mailing list