Avoid integer overflow issues in measurement tooltip
For large distances Use integer instead of floating point sqrt
This commit is contained in:
@@ -6007,8 +6007,7 @@ calc_heightdiff_single_direction:;
|
|||||||
if (dx != 1 || dy != 1) {
|
if (dx != 1 || dy != 1) {
|
||||||
heightdiff = CalcHeightdiff(style, 0, t0, t1);
|
heightdiff = CalcHeightdiff(style, 0, t0, t1);
|
||||||
params[index++] = DistanceManhattan(t0, t1);
|
params[index++] = DistanceManhattan(t0, t1);
|
||||||
params[index++] = sqrtl(dx * dx + dy * dy); //DistanceSquare does not like big numbers
|
params[index++] = IntSqrt64(((uint64)dx * (uint64)dx) + ((uint64)dy * (uint64)dy)); // Avoid overflow in DistanceSquare
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
index += 2;
|
index += 2;
|
||||||
}
|
}
|
||||||
@@ -6016,7 +6015,7 @@ calc_heightdiff_single_direction:;
|
|||||||
params[index++] = DistanceFromEdge(t1);
|
params[index++] = DistanceFromEdge(t1);
|
||||||
params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP;
|
params[index++] = GetTileMaxZ(t1) * TILE_HEIGHT_STEP;
|
||||||
params[index++] = heightdiff;
|
params[index++] = heightdiff;
|
||||||
//Show always the measurement tooltip
|
/* Always show the measurement tooltip */
|
||||||
GuiShowTooltips(_thd.GetCallbackWnd(), STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_EXIT_VIEWPORT);
|
GuiShowTooltips(_thd.GetCallbackWnd(), STR_MEASURE_DIST_HEIGHTDIFF, index, params, TCC_EXIT_VIEWPORT);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user