aboutsummaryrefslogtreecommitdiff
path: root/engines/toon/toon.cpp
diff options
context:
space:
mode:
authorSylvain Dupont2011-01-30 13:31:13 +0000
committerSylvain Dupont2011-01-30 13:31:13 +0000
commit3cd1ac9ca6cd48a5ba40f8f1e225776d22fb5659 (patch)
treec48c16b403ddf2b021435ce0a2aefabe1e539932 /engines/toon/toon.cpp
parentf8d61c9e55c4ec569a8709313d3a6aee64469f67 (diff)
downloadscummvm-rg350-3cd1ac9ca6cd48a5ba40f8f1e225776d22fb5659.tar.gz
scummvm-rg350-3cd1ac9ca6cd48a5ba40f8f1e225776d22fb5659.tar.bz2
scummvm-rg350-3cd1ac9ca6cd48a5ba40f8f1e225776d22fb5659.zip
TOON: Add coordinates clamping for safety
In some rare cases, Drew position is outside the valid area. Made sure it does not crash in these cases. svn-id: r55655
Diffstat (limited to 'engines/toon/toon.cpp')
-rw-r--r--engines/toon/toon.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp
index 61b558ca6c..54a261fedc 100644
--- a/engines/toon/toon.cpp
+++ b/engines/toon/toon.cpp
@@ -1820,6 +1820,10 @@ int32 ToonEngine::getScaleAtPoint(int32 x, int32 y) {
if (!_currentMask)
return 1024;
+ // clamp values
+ x = MIN(1279, MAX(0, x));
+ y = MIN(399, MAX(0, y));
+
int32 maskData = _currentMask->getData(x, y) & 0x1f;
return _roomScaleData[maskData+2] * 1024 / 100;
}
@@ -1828,6 +1832,10 @@ int32 ToonEngine::getLayerAtPoint(int32 x, int32 y) {
if (!_currentMask)
return 0;
+ // clamp values
+ x = MIN(1279, MAX(0, x));
+ y = MIN(399, MAX(0, y));
+
int32 maskData = _currentMask->getData(x, y) & 0x1f;
return _roomScaleData[maskData+130] << 5;
}