mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-13 02:52:37 +00:00
(svn r23466) -Fix [FS#4871, FS#4874]: assertion triggered when resizing a window during ReInit by an amount that's not a multiple of the resize interval
This commit is contained in:
parent
dcba6c25ea
commit
6153dc57f5
@ -329,6 +329,17 @@ static FORCEINLINE uint CeilDiv(uint a, uint b)
|
||||
return (a + b - 1) / b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes ceil(a / b) * b for non-negative a and b.
|
||||
* @param a Numerator
|
||||
* @param b Denominator
|
||||
* @return a rounded up to the nearest multiple of b.
|
||||
*/
|
||||
static FORCEINLINE uint Ceil(uint a, uint b)
|
||||
{
|
||||
return CeilDiv(a, b) * b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes round(a / b) for signed a and unsigned b.
|
||||
* @param a Numerator
|
||||
|
@ -1675,8 +1675,8 @@ void ResizeWindow(Window *w, int delta_x, int delta_y)
|
||||
* the resolution clamp it in such a manner that it stays within the bounts. */
|
||||
int new_right = w->left + w->width + delta_x;
|
||||
int new_bottom = w->top + w->height + delta_y;
|
||||
if (new_right >= (int)_cur_resolution.width) delta_x -= new_right - _cur_resolution.width;
|
||||
if (new_bottom >= (int)_cur_resolution.height) delta_y -= new_bottom - _cur_resolution.height;
|
||||
if (new_right >= (int)_cur_resolution.width) delta_x -= Ceil(new_right - _cur_resolution.width, max(1U, w->nested_root->resize_x));
|
||||
if (new_bottom >= (int)_cur_resolution.height) delta_y -= Ceil(new_bottom - _cur_resolution.height, max(1U, w->nested_root->resize_y));
|
||||
|
||||
w->SetDirty();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user