Codechange: Remove min/max functions in favour of STL variants (#8502)
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user