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:
@@ -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);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user