Fix link graph tooltips with very long links when zoomed in

This commit is contained in:
Jonathan G Rennison
2023-07-15 19:14:01 +01:00
parent a157fa9e3d
commit 669215cf41

View File

@@ -505,8 +505,8 @@ bool LinkGraphOverlay::ShowTooltip(Point pt, TooltipCloseCondition close_cond)
/* Check the distance from the cursor to the line defined by the two stations. */ /* Check the distance from the cursor to the line defined by the two stations. */
auto check_distance = [&]() -> bool { auto check_distance = [&]() -> bool {
int64 a = ((ptb.x - pta.x) * (pta.y - pt.y) - (pta.x - pt.x) * (ptb.y - pta.y)); int64 a = ((int64)(ptb.x - pta.x) * (int64)(pta.y - pt.y) - (int64)(pta.x - pt.x) * (int64)(ptb.y - pta.y));
int64 b = ((ptb.x - pta.x) * (ptb.x - pta.x) + (ptb.y - pta.y) * (ptb.y - pta.y)); int64 b = ((int64)(ptb.x - pta.x) * (int64)(ptb.x - pta.x) + (int64)(ptb.y - pta.y) * (int64)(ptb.y - pta.y));
if (b == 0) return false; if (b == 0) return false;
return ((a * a) / b) <= 16; return ((a * a) / b) <= 16;
}; };