From 40bd4c485f9ab24e667e66a047214eb7dcef73e8 Mon Sep 17 00:00:00 2001 From: Adrian Astley Date: Tue, 23 Dec 2014 00:38:44 -0600 Subject: ZVISION: Clamp the rotation velocity to never be zero Before, if we set the in-game preferences to have very low rotation speed, the velocity ends up always being 0 - 0.99 Hence, when we convert back to an int, everything gets truncated to zero. Therefore, we clamp, in order to ensure the user can always move, no matter which setting they use. --- engines/zvision/core/events.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/zvision/core') diff --git a/engines/zvision/core/events.cpp b/engines/zvision/core/events.cpp index ccd7772975..1920ffd769 100644 --- a/engines/zvision/core/events.cpp +++ b/engines/zvision/core/events.cpp @@ -299,7 +299,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(); + _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_Left); @@ -310,7 +310,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = (Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); + _mouseVelocity = MAX((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1); _cursorManager->changeCursor(CursorIndex_Right); cursorWasChanged = true; @@ -324,7 +324,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = ((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(); + _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_UpArr); cursorWasChanged = true; @@ -334,7 +334,7 @@ void ZVision::onMouseMove(const Common::Point &pos) { if (mspeed <= 0) { mspeed = 25; } - _mouseVelocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(); + _mouseVelocity = MAX((Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET)).toInt(), 1); _cursorManager->changeCursor(CursorIndex_DownArr); cursorWasChanged = true; -- cgit v1.2.3