Codechange: Remove min/max functions in favour of STL variants (#8502)
This commit is contained in:
@@ -695,10 +695,10 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
|
||||
|
||||
if (_draw_bounding_boxes && (image != SPR_EMPTY_BOUNDING_BOX)) {
|
||||
/* Compute maximal extents of sprite and its bounding box */
|
||||
left = min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x);
|
||||
right = max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1);
|
||||
top = min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y);
|
||||
bottom = max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1);
|
||||
left = std::min(left , RemapCoords(x + w , y + bb_offset_y, z + bb_offset_z).x);
|
||||
right = std::max(right , RemapCoords(x + bb_offset_x, y + h , z + bb_offset_z).x + 1);
|
||||
top = std::min(top , RemapCoords(x + bb_offset_x, y + bb_offset_y, z + dz ).y);
|
||||
bottom = std::max(bottom, RemapCoords(x + w , y + h , z + bb_offset_z).y + 1);
|
||||
}
|
||||
|
||||
/* Do not add the sprite to the viewport, if it is outside */
|
||||
@@ -720,13 +720,13 @@ void AddSortableSpriteToDraw(SpriteID image, PaletteID pal, int x, int y, int w,
|
||||
ps.pal = pal;
|
||||
ps.sub = sub;
|
||||
ps.xmin = x + bb_offset_x;
|
||||
ps.xmax = x + max(bb_offset_x, w) - 1;
|
||||
ps.xmax = x + std::max(bb_offset_x, w) - 1;
|
||||
|
||||
ps.ymin = y + bb_offset_y;
|
||||
ps.ymax = y + max(bb_offset_y, h) - 1;
|
||||
ps.ymax = y + std::max(bb_offset_y, h) - 1;
|
||||
|
||||
ps.zmin = z + bb_offset_z;
|
||||
ps.zmax = z + max(bb_offset_z, dz) - 1;
|
||||
ps.zmax = z + std::max(bb_offset_z, dz) - 1;
|
||||
|
||||
ps.first_child = -1;
|
||||
|
||||
@@ -1556,7 +1556,7 @@ static void ViewportSortParentSprites(ParentSpriteToSortVector *psdv)
|
||||
* Also min coordinates can be > max so using max(xmin, xmax) + max(ymin, ymax)
|
||||
* to ensure that we iterate the current sprite as we need to remove it from the list.
|
||||
*/
|
||||
auto ssum = max(s->xmax, s->xmin) + max(s->ymax, s->ymin);
|
||||
auto ssum = std::max(s->xmax, s->xmin) + std::max(s->ymax, s->ymin);
|
||||
auto prev = sprite_list.before_begin();
|
||||
auto x = sprite_list.begin();
|
||||
while (x != sprite_list.end() && ((*x).first <= ssum)) {
|
||||
@@ -1917,11 +1917,11 @@ static void MarkViewportDirty(const Viewport *vp, int left, int top, int right,
|
||||
bottom -= vp->virtual_top;
|
||||
if (bottom <= 0) return;
|
||||
|
||||
left = max(0, left - vp->virtual_left);
|
||||
left = std::max(0, left - vp->virtual_left);
|
||||
|
||||
if (left >= vp->virtual_width) return;
|
||||
|
||||
top = max(0, top - vp->virtual_top);
|
||||
top = std::max(0, top - vp->virtual_top);
|
||||
|
||||
if (top >= vp->virtual_height) return;
|
||||
|
||||
@@ -2222,7 +2222,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeStation(StationID id)
|
||||
item.top = st->sign.top;
|
||||
|
||||
/* Assume the sign can be a candidate for drawing, so measure its width */
|
||||
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
|
||||
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -2239,7 +2239,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeWaypoint(StationID id)
|
||||
item.top = st->sign.top;
|
||||
|
||||
/* Assume the sign can be a candidate for drawing, so measure its width */
|
||||
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
|
||||
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, st->sign.width_normal);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -2256,7 +2256,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeTown(TownID id)
|
||||
item.top = town->cache.sign.top;
|
||||
|
||||
/* Assume the sign can be a candidate for drawing, so measure its width */
|
||||
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, town->cache.sign.width_normal);
|
||||
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, town->cache.sign.width_normal);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -2273,7 +2273,7 @@ ViewportSignKdtreeItem ViewportSignKdtreeItem::MakeSign(SignID id)
|
||||
item.top = sign->sign.top;
|
||||
|
||||
/* Assume the sign can be a candidate for drawing, so measure its width */
|
||||
_viewport_sign_maxwidth = max<int>(_viewport_sign_maxwidth, sign->sign.width_normal);
|
||||
_viewport_sign_maxwidth = std::max<int>(_viewport_sign_maxwidth, sign->sign.width_normal);
|
||||
|
||||
return item;
|
||||
}
|
||||
@@ -2857,7 +2857,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
|
||||
assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
|
||||
h0 = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t])));
|
||||
uint ht = TileHeight(TILE_ADD(start_tile, ToTileIndexDiff(heightdiff_line_by_dir[style_t + 1])));
|
||||
h0 = max(h0, ht);
|
||||
h0 = std::max(h0, ht);
|
||||
|
||||
/* Use lookup table for end-tile based on HighLightStyle direction
|
||||
* flip around side (lower/upper, left/right) based on distance */
|
||||
@@ -2865,7 +2865,7 @@ static int CalcHeightdiff(HighLightStyle style, uint distance, TileIndex start_t
|
||||
assert(style_t < lengthof(heightdiff_line_by_dir) - 13);
|
||||
h1 = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t])));
|
||||
ht = TileHeight(TILE_ADD(end_tile, ToTileIndexDiff(heightdiff_line_by_dir[12 + style_t + 1])));
|
||||
h1 = max(h1, ht);
|
||||
h1 = std::max(h1, ht);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user