diff options
author | Sylvain Dupont | 2011-01-30 13:31:13 +0000 |
---|---|---|
committer | Sylvain Dupont | 2011-01-30 13:31:13 +0000 |
commit | 3cd1ac9ca6cd48a5ba40f8f1e225776d22fb5659 (patch) | |
tree | c48c16b403ddf2b021435ce0a2aefabe1e539932 | |
parent | f8d61c9e55c4ec569a8709313d3a6aee64469f67 (diff) | |
download | scummvm-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
-rw-r--r-- | engines/toon/toon.cpp | 8 |
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; } |