summaryrefslogtreecommitdiff
path: root/src/gfx.cpp
diff options
context:
space:
mode:
authorCharles Pigott <charlespigott@googlemail.com>2021-01-08 10:16:18 +0000
committerGitHub <noreply@github.com>2021-01-08 11:16:18 +0100
commit9b800a96ed32720ff60b74e498a0e0a6351004f9 (patch)
tree3f287d339e15c4902ee415556475fd9b2918d33c /src/gfx.cpp
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/gfx.cpp')
-rw-r--r--src/gfx.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/gfx.cpp b/src/gfx.cpp
index c0a2efc31..54851d375 100644
--- a/src/gfx.cpp
+++ b/src/gfx.cpp
@@ -263,8 +263,8 @@ void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mo
std::sort(intersections.begin(), intersections.end());
for (size_t i = 1; i < intersections.size(); i += 2) {
/* Check clipping. */
- const int x1 = max(0, intersections[i - 1]);
- const int x2 = min(intersections[i], dpi->width);
+ 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 *video, int x, int y, int x2, int y2, int
/* 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 ParagraphLayouter::Line &line, int y, int left,
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, Point *offset, ZoomLevel zoom)
}
Dimension d;
- d.width = max<int>(0, UnScaleByZoom(sprite->x_offs + sprite->width, zoom));
- d.height = max<int>(0, UnScaleByZoom(sprite->y_offs + sprite->height, zoom));
+ d.width = std::max<int>(0, UnScaleByZoom(sprite->x_offs + sprite->width, zoom));
+ d.height = std::max<int>(0, UnScaleByZoom(sprite->y_offs + sprite->height, zoom));
return d;
}
@@ -1024,10 +1024,10 @@ static void GfxBlitter(const Sprite * const sprite, int x, int y, BlitterMode mo
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;