From 3cd1ac9ca6cd48a5ba40f8f1e225776d22fb5659 Mon Sep 17 00:00:00 2001 From: Sylvain Dupont Date: Sun, 30 Jan 2011 13:31:13 +0000 Subject: 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 --- engines/toon/toon.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'engines/toon/toon.cpp') 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; } -- cgit v1.2.3