aboutsummaryrefslogtreecommitdiff
path: root/engines/lab
diff options
context:
space:
mode:
authorStrangerke2015-12-15 16:20:08 +0100
committerWillem Jan Palenstijn2015-12-23 21:34:05 +0100
commitf791d690b2f97d5a1c49f28ef53ecf1a508b8ff6 (patch)
tree2bb86ff9d5741e36bd5ec98f3b0cab7c5d187917 /engines/lab
parente71f28d0ba319bca35056b7e88d8ebfe0ea92017 (diff)
downloadscummvm-rg350-f791d690b2f97d5a1c49f28ef53ecf1a508b8ff6.tar.gz
scummvm-rg350-f791d690b2f97d5a1c49f28ef53ecf1a508b8ff6.tar.bz2
scummvm-rg350-f791d690b2f97d5a1c49f28ef53ecf1a508b8ff6.zip
LAB: Use Common::Rect in a couple of position checks to make it a bit more readable
Diffstat (limited to 'engines/lab')
-rw-r--r--engines/lab/processroom.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/engines/lab/processroom.cpp b/engines/lab/processroom.cpp
index dc1b149592..8c52d75c15 100644
--- a/engines/lab/processroom.cpp
+++ b/engines/lab/processroom.cpp
@@ -94,9 +94,10 @@ CloseData *LabEngine::getObject(Common::Point pos, CloseDataPtr closePtr) {
else
wrkClosePtr = closePtr->_subCloseUps;
+ Common::Rect objRect;
while (wrkClosePtr) {
- if ((pos.x >= _utils->scaleX(wrkClosePtr->_x1)) && (pos.y >= _utils->scaleY(wrkClosePtr->_y1)) &&
- (pos.x <= _utils->scaleX(wrkClosePtr->_x2)) && (pos.y <= _utils->scaleY(wrkClosePtr->_y2)))
+ objRect = Common::Rect(_utils->scaleX(wrkClosePtr->_x1), _utils->scaleX(wrkClosePtr->_y1), _utils->scaleX(wrkClosePtr->_x2), _utils->scaleX(wrkClosePtr->_y2));
+ if (objRect.contains(pos))
return wrkClosePtr;
wrkClosePtr = wrkClosePtr->_nextCloseUp;
@@ -250,10 +251,11 @@ bool LabEngine::takeItem(uint16 x, uint16 y, CloseDataPtr *closePtrList) {
} else
closePtr = (*closePtrList)->_subCloseUps;
+ Common::Point pos = Common::Point(x, y);
+ Common::Rect objRect;
while (closePtr) {
- if ((x >= _utils->scaleX(closePtr->_x1)) && (y >= _utils->scaleY(closePtr->_y1)) &&
- (x <= _utils->scaleX(closePtr->_x2)) && (y <= _utils->scaleY(closePtr->_y2)) &&
- (closePtr->_closeUpType < 0)) {
+ objRect = Common::Rect(_utils->scaleX(closePtr->_x1), _utils->scaleX(closePtr->_y1), _utils->scaleX(closePtr->_x2), _utils->scaleX(closePtr->_y2));
+ if (objRect.contains(pos) && (closePtr->_closeUpType < 0)) {
_conditions->inclElement(abs(closePtr->_closeUpType));
return true;
}