summaryrefslogtreecommitdiff
path: root/src/spritecache.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/spritecache.cpp
parentc1fddb9a6ae5c3af6865461a7295788a341011a2 (diff)
downloadopenttd-9b800a96ed32720ff60b74e498a0e0a6351004f9.tar.xz
Codechange: Remove min/max functions in favour of STL variants (#8502)
Diffstat (limited to 'src/spritecache.cpp')
-rw-r--r--src/spritecache.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/spritecache.cpp b/src/spritecache.cpp
index 3eceb38de..3029a0253 100644
--- a/src/spritecache.cpp
+++ b/src/spritecache.cpp
@@ -302,8 +302,8 @@ static bool PadSprites(SpriteLoader::Sprite *sprite, uint8 sprite_avail)
int min_yoffs = INT32_MAX;
for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
if (HasBit(sprite_avail, zoom)) {
- min_xoffs = min(min_xoffs, ScaleByZoom(sprite[zoom].x_offs, zoom));
- min_yoffs = min(min_yoffs, ScaleByZoom(sprite[zoom].y_offs, zoom));
+ min_xoffs = std::min(min_xoffs, ScaleByZoom(sprite[zoom].x_offs, zoom));
+ min_yoffs = std::min(min_yoffs, ScaleByZoom(sprite[zoom].y_offs, zoom));
}
}
@@ -312,8 +312,8 @@ static bool PadSprites(SpriteLoader::Sprite *sprite, uint8 sprite_avail)
int max_height = INT32_MIN;
for (ZoomLevel zoom = ZOOM_LVL_BEGIN; zoom != ZOOM_LVL_END; zoom++) {
if (HasBit(sprite_avail, zoom)) {
- max_width = max(max_width, ScaleByZoom(sprite[zoom].width + sprite[zoom].x_offs - UnScaleByZoom(min_xoffs, zoom), zoom));
- max_height = max(max_height, ScaleByZoom(sprite[zoom].height + sprite[zoom].y_offs - UnScaleByZoom(min_yoffs, zoom), zoom));
+ max_width = std::max(max_width, ScaleByZoom(sprite[zoom].width + sprite[zoom].x_offs - UnScaleByZoom(min_xoffs, zoom), zoom));
+ max_height = std::max(max_height, ScaleByZoom(sprite[zoom].height + sprite[zoom].y_offs - UnScaleByZoom(min_yoffs, zoom), zoom));
}
}
@@ -322,10 +322,10 @@ static bool PadSprites(SpriteLoader::Sprite *sprite, uint8 sprite_avail)
if (HasBit(sprite_avail, zoom)) {
/* Scaling the sprite dimensions in the blitter is done with rounding up,
* so a negative padding here is not an error. */
- int pad_left = max(0, sprite[zoom].x_offs - UnScaleByZoom(min_xoffs, zoom));
- int pad_top = max(0, sprite[zoom].y_offs - UnScaleByZoom(min_yoffs, zoom));
- int pad_right = max(0, UnScaleByZoom(max_width, zoom) - sprite[zoom].width - pad_left);
- int pad_bottom = max(0, UnScaleByZoom(max_height, zoom) - sprite[zoom].height - pad_top);
+ int pad_left = std::max(0, sprite[zoom].x_offs - UnScaleByZoom(min_xoffs, zoom));
+ int pad_top = std::max(0, sprite[zoom].y_offs - UnScaleByZoom(min_yoffs, zoom));
+ int pad_right = std::max(0, UnScaleByZoom(max_width, zoom) - sprite[zoom].width - pad_left);
+ int pad_bottom = std::max(0, UnScaleByZoom(max_height, zoom) - sprite[zoom].height - pad_top);
if (pad_left > 0 || pad_right > 0 || pad_top > 0 || pad_bottom > 0) {
if (!PadSingleSprite(&sprite[zoom], zoom, pad_left, pad_top, pad_right, pad_bottom)) return false;
@@ -378,10 +378,10 @@ static void *ReadRecolourSprite(uint16 file_slot, uint num)
* GRFs which are the same as 257 byte recolour sprites, but with the last
* 240 bytes zeroed. */
static const uint RECOLOUR_SPRITE_SIZE = 257;
- byte *dest = (byte *)AllocSprite(max(RECOLOUR_SPRITE_SIZE, num));
+ byte *dest = (byte *)AllocSprite(std::max(RECOLOUR_SPRITE_SIZE, num));
if (_palette_remap_grf[file_slot]) {
- byte *dest_tmp = AllocaM(byte, max(RECOLOUR_SPRITE_SIZE, num));
+ byte *dest_tmp = AllocaM(byte, std::max(RECOLOUR_SPRITE_SIZE, num));
/* Only a few recolour sprites are less than 257 bytes */
if (num < RECOLOUR_SPRITE_SIZE) memset(dest_tmp, 0, RECOLOUR_SPRITE_SIZE);