From 9f33f2b3df22a26314dbb74173f49bc930c7a1f9 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Wed, 19 Jul 2017 21:13:47 -0500 Subject: SCI32: Don't warp the mouse when it doesn't need to be warped --- engines/sci/graphics/cursor32.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/engines/sci/graphics/cursor32.cpp b/engines/sci/graphics/cursor32.cpp index fc853bbfd6..c626487970 100644 --- a/engines/sci/graphics/cursor32.cpp +++ b/engines/sci/graphics/cursor32.cpp @@ -151,20 +151,28 @@ void GfxCursor32::setRestrictedArea(const Common::Rect &rect) { mulru(_restrictedArea, Ratio(screenWidth, scriptWidth), Ratio(screenHeight, scriptHeight), 0); + bool restricted = false; + if (_position.x < rect.left) { _position.x = rect.left; + restricted = true; } if (_position.x >= rect.right) { _position.x = rect.right - 1; + restricted = true; } if (_position.y < rect.top) { _position.y = rect.top; + restricted = true; } if (_position.y >= rect.bottom) { _position.y = rect.bottom - 1; + restricted = true; } - g_system->warpMouse(_position.x, _position.y); + if (restricted) { + g_system->warpMouse(_position.x, _position.y); + } } void GfxCursor32::clearRestrictedArea() { @@ -367,22 +375,31 @@ void GfxCursor32::donePainting() { } void GfxCursor32::deviceMoved(Common::Point &position) { + bool restricted = false; + if (position.x < _restrictedArea.left) { position.x = _restrictedArea.left; + restricted = true; } if (position.x >= _restrictedArea.right) { position.x = _restrictedArea.right - 1; + restricted = true; } if (position.y < _restrictedArea.top) { position.y = _restrictedArea.top; + restricted = true; } if (position.y >= _restrictedArea.bottom) { position.y = _restrictedArea.bottom - 1; + restricted = true; } _position = position; - g_system->warpMouse(position.x, position.y); + if (restricted) { + g_system->warpMouse(position.x, position.y); + } + move(); } -- cgit v1.2.3