diff --git a/src/gfx.cpp b/src/gfx.cpp --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -263,8 +263,8 @@ void GfxFillPolygon(const std::vectorwidth); + const int x1 = std::max(0, intersections[i - 1]); + const int x2 = std::min(intersections[i], dpi->width); if (x2 < 0) continue; if (x1 >= dpi->width) continue; @@ -327,7 +327,7 @@ static inline void GfxDoDrawLine(void *v /* prevent integer overflows. */ int margin = 1; - while (INT_MAX / abs(grade_y) < max(abs(clip.left - x), abs(clip.right - x))) { + while (INT_MAX / abs(grade_y) < std::max(abs(clip.left - x), abs(clip.right - x))) { grade_y /= 2; grade_x /= 2; margin *= 2; // account for rounding errors @@ -636,7 +636,7 @@ static int DrawLayoutLine(const Paragrap int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize) { /* The string may contain control chars to change the font, just use the biggest font for clipping. */ - int max_height = max(max(FONT_HEIGHT_SMALL, FONT_HEIGHT_NORMAL), max(FONT_HEIGHT_LARGE, FONT_HEIGHT_MONO)); + int max_height = std::max({FONT_HEIGHT_SMALL, FONT_HEIGHT_NORMAL, FONT_HEIGHT_LARGE, FONT_HEIGHT_MONO}); /* Funny glyphs may extent outside the usual bounds, so relax the clipping somewhat. */ int extra = max_height / 2; @@ -916,8 +916,8 @@ Dimension GetSpriteSize(SpriteID sprid, } Dimension d; - d.width = max(0, UnScaleByZoom(sprite->x_offs + sprite->width, zoom)); - d.height = max(0, UnScaleByZoom(sprite->y_offs + sprite->height, zoom)); + d.width = std::max(0, UnScaleByZoom(sprite->x_offs + sprite->width, zoom)); + d.height = std::max(0, UnScaleByZoom(sprite->y_offs + sprite->height, zoom)); return d; } @@ -1024,10 +1024,10 @@ static void GfxBlitter(const Sprite * co bp.height = UnScaleByZoom(sprite->height, zoom); } else { /* Amount of pixels to clip from the source sprite */ - int clip_left = max(0, -sprite->x_offs + sub->left * ZOOM_BASE ); - int clip_top = max(0, -sprite->y_offs + sub->top * ZOOM_BASE ); - int clip_right = max(0, sprite->width - (-sprite->x_offs + (sub->right + 1) * ZOOM_BASE)); - int clip_bottom = max(0, sprite->height - (-sprite->y_offs + (sub->bottom + 1) * ZOOM_BASE)); + int clip_left = std::max(0, -sprite->x_offs + sub->left * ZOOM_BASE ); + int clip_top = std::max(0, -sprite->y_offs + sub->top * ZOOM_BASE ); + int clip_right = std::max(0, sprite->width - (-sprite->x_offs + (sub->right + 1) * ZOOM_BASE)); + int clip_bottom = std::max(0, sprite->height - (-sprite->y_offs + (sub->bottom + 1) * ZOOM_BASE)); if (clip_left + clip_right >= sprite->width) return; if (clip_top + clip_bottom >= sprite->height) return; @@ -1305,7 +1305,7 @@ byte GetDigitWidth(FontSize size) { byte width = 0; for (char c = '0'; c <= '9'; c++) { - width = max(GetCharacterWidth(size, c), width); + width = std::max(GetCharacterWidth(size, c), width); } return width; } @@ -1695,8 +1695,8 @@ void UpdateCursorSize() _cursor.total_offs = offs; _cursor.total_size = size; } else { - int right = max(_cursor.total_offs.x + _cursor.total_size.x, offs.x + size.x); - int bottom = max(_cursor.total_offs.y + _cursor.total_size.y, offs.y + size.y); + int right = std::max(_cursor.total_offs.x + _cursor.total_size.x, offs.x + size.x); + int bottom = std::max(_cursor.total_offs.y + _cursor.total_size.y, offs.y + size.y); if (offs.x < _cursor.total_offs.x) _cursor.total_offs.x = offs.x; if (offs.y < _cursor.total_offs.y) _cursor.total_offs.y = offs.y; _cursor.total_size.x = right - _cursor.total_offs.x;