Fix signed integer overflow in viewport draw area chunking

This caused drawing areas larger than 2097151 pixels at 8x zoom to
not be subdivided into smaller chunks as required.
This resulted in pathological performance issues in the sprite sorter.
This commit is contained in:
Jonathan G Rennison
2020-02-01 18:49:30 +00:00
parent 81a1094cc8
commit 6f6bac5212

View File

@@ -2748,7 +2748,7 @@ void ViewportDoDraw(const ViewPort *vp, int left, int top, int right, int bottom
*/
static void ViewportDrawChk(const ViewPort *vp, int left, int top, int right, int bottom)
{
if ((vp->zoom < ZOOM_LVL_DRAW_MAP) && (ScaleByZoom(bottom - top, vp->zoom) * ScaleByZoom(right - left, vp->zoom) > (int)(180000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE))) {
if ((vp->zoom < ZOOM_LVL_DRAW_MAP) && ((int64)ScaleByZoom(bottom - top, vp->zoom) * (int64)ScaleByZoom(right - left, vp->zoom) > (int64)(180000 * ZOOM_LVL_BASE * ZOOM_LVL_BASE))) {
if ((bottom - top) > (right - left)) {
int t = (top + bottom) >> 1;
ViewportDrawChk(vp, left, top, right, t);