1
0
mirror of https://github.com/OpenTTD/OpenTTD synced 2026-01-30 15:44:31 +01:00

Fix 6e90b828c6: Off-by-one in Rect::CentreTo. (#14643)

* Rect right/bottom are inclusive so -1 must be taken from width/height.
* Misnamed variable, `new_right` is actually `new_top`.
This commit is contained in:
Peter Nelson
2025-09-21 13:41:23 +01:00
committed by GitHub
parent 69697a62d3
commit 13ab9c1adc

View File

@@ -261,8 +261,8 @@ struct Rect {
[[nodiscard]] inline Rect CentreTo(int width, int height) const
{
int new_left = CentreBounds(this->left, this->right, width);
int new_right = CentreBounds(this->top, this->bottom, height);
return {new_left, new_right, new_left + width, new_right + height};
int new_top = CentreBounds(this->top, this->bottom, height);
return {new_left, new_top, new_left + width - 1, new_top + height - 1};
}
};