1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-15 20:03:15 +02:00

fix division by zero edge case

This commit is contained in:
Michael
2023-08-27 00:53:09 +02:00
committed by GitHub
parent bbd69fd430
commit 4137a66f2a

View File

@@ -148,8 +148,11 @@ void MapView::postSwipe(uint32_t msPassed) {
uint32_t timediff = swipeHistory.rbegin()->first - firstAccepted.first;
postSwipeAngle = diff.angle();
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
if(diff.length() > 0 && timediff > 0)
{
postSwipeAngle = diff.angle();
postSwipeSpeed = static_cast<double>(diff.length()) / static_cast<double>(timediff); // unit: pixel/millisecond
}
}
swipeHistory.clear();
} else
@@ -205,4 +208,4 @@ PuzzleMapView::PuzzleMapView(const Point & offset, const Point & dimensions, con
controller->activatePuzzleMapContext(tileToCenter);
controller->setViewCenter(tileToCenter);
}
}