Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -110,7 +110,7 @@ struct GraphLegendWindow : Window {
|
||||
static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index)
|
||||
{
|
||||
NWidgetVertical *vert = new NWidgetVertical();
|
||||
uint line_height = max<uint>(GetSpriteSize(SPR_COMPANY_ICON).height, FONT_HEIGHT_NORMAL) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
uint line_height = std::max<uint>(GetSpriteSize(SPR_COMPANY_ICON).height, FONT_HEIGHT_NORMAL) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
|
||||
|
||||
for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
|
||||
NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
|
||||
@@ -213,8 +213,8 @@ protected:
|
||||
OverflowSafeInt64 datapoint = this->cost[i][j];
|
||||
|
||||
if (datapoint != INVALID_DATAPOINT) {
|
||||
current_interval.highest = max(current_interval.highest, datapoint);
|
||||
current_interval.lowest = min(current_interval.lowest, datapoint);
|
||||
current_interval.highest = std::max(current_interval.highest, datapoint);
|
||||
current_interval.lowest = std::min(current_interval.lowest, datapoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ protected:
|
||||
/* Get the required grid size for each side and use the maximum one. */
|
||||
int64 grid_size_higher = (abs_higher > 0) ? ((int64)abs_higher + num_pos_grids - 1) / num_pos_grids : 0;
|
||||
int64 grid_size_lower = (abs_lower > 0) ? ((int64)abs_lower + num_hori_lines - num_pos_grids - 1) / (num_hori_lines - num_pos_grids) : 0;
|
||||
grid_size = max(grid_size_higher, grid_size_lower);
|
||||
grid_size = std::max(grid_size_higher, grid_size_lower);
|
||||
} else {
|
||||
/* If both values are zero, show an empty graph. */
|
||||
num_pos_grids = num_hori_lines / 2;
|
||||
@@ -290,7 +290,7 @@ protected:
|
||||
|
||||
/* the colours and cost array of GraphDrawer must accommodate
|
||||
* both values for cargo and companies. So if any are higher, quit */
|
||||
assert_compile(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
|
||||
static_assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
|
||||
assert(this->num_vert_lines > 0);
|
||||
|
||||
byte grid_colour = _colour_gradient[COLOUR_GREY][4];
|
||||
@@ -326,6 +326,9 @@ protected:
|
||||
/* Where to draw the X axis. Use floating point to avoid overflowing and results of zero. */
|
||||
x_axis_offset = (int)((r.bottom - r.top) * (double)interval.highest / (double)interval_size);
|
||||
|
||||
/* Draw the background of the graph itself. */
|
||||
GfxFillRect(r.left, r.top, r.right, r.bottom, GREY_SCALE(2));
|
||||
|
||||
/* Draw the vertical grid lines. */
|
||||
|
||||
/* Don't draw the first line, as that's where the axis will be. */
|
||||
@@ -436,7 +439,7 @@ protected:
|
||||
* least significant bits are removed.
|
||||
*/
|
||||
int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint));
|
||||
int reduce_range = max(mult_range - 31, 0);
|
||||
int reduce_range = std::max(mult_range - 31, 0);
|
||||
|
||||
/* Handle negative values differently (don't shift sign) */
|
||||
if (datapoint < 0) {
|
||||
@@ -497,7 +500,7 @@ public:
|
||||
SetDParam(0, month + STR_MONTH_ABBREV_JAN);
|
||||
SetDParam(1, month + STR_MONTH_ABBREV_JAN + 2);
|
||||
SetDParam(2, year);
|
||||
x_label_width = max(x_label_width, GetStringBoundingBox(month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH).width);
|
||||
x_label_width = std::max(x_label_width, GetStringBoundingBox(month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH).width);
|
||||
|
||||
month += 3;
|
||||
if (month >= 12) {
|
||||
@@ -515,9 +518,9 @@ public:
|
||||
SetDParam(1, INT64_MAX);
|
||||
uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width;
|
||||
|
||||
size->width = max<uint>(size->width, 5 + y_label_width + this->num_on_x_axis * (x_label_width + 5) + 9);
|
||||
size->height = max<uint>(size->height, 5 + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + 4);
|
||||
size->height = max<uint>(size->height, size->width / 3);
|
||||
size->width = std::max<uint>(size->width, 5 + y_label_width + this->num_on_x_axis * (x_label_width + 5) + 9);
|
||||
size->height = std::max<uint>(size->height, 5 + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + 4);
|
||||
size->height = std::max<uint>(size->height, size->width / 3);
|
||||
}
|
||||
|
||||
void DrawWidget(const Rect &r, int widget) const override
|
||||
@@ -569,7 +572,7 @@ public:
|
||||
|
||||
byte nums = 0;
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
nums = min(this->num_vert_lines, max(nums, c->num_valid_stat_ent));
|
||||
nums = std::min(this->num_vert_lines, std::max(nums, c->num_valid_stat_ent));
|
||||
}
|
||||
|
||||
int mo = (_cur_month / 3 - nums) * 3;
|
||||
@@ -1116,7 +1119,7 @@ static const StringID _performance_titles[] = {
|
||||
|
||||
static inline StringID GetPerformanceTitleFromValue(uint value)
|
||||
{
|
||||
return _performance_titles[minu(value, 1000) >> 6];
|
||||
return _performance_titles[std::min(value, 1000u) >> 6];
|
||||
}
|
||||
|
||||
class CompanyLeagueWindow : public Window {
|
||||
@@ -1200,7 +1203,7 @@ public:
|
||||
|
||||
this->ordinal_width = 0;
|
||||
for (uint i = 0; i < MAX_COMPANIES; i++) {
|
||||
this->ordinal_width = max(this->ordinal_width, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i).width);
|
||||
this->ordinal_width = std::max(this->ordinal_width, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i).width);
|
||||
}
|
||||
this->ordinal_width += 5; // Keep some extra spacing
|
||||
|
||||
@@ -1216,14 +1219,14 @@ public:
|
||||
|
||||
Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
|
||||
this->icon_width = d.width + 2;
|
||||
this->line_height = max<int>(d.height + 2, FONT_HEIGHT_NORMAL);
|
||||
this->line_height = std::max<int>(d.height + 2, FONT_HEIGHT_NORMAL);
|
||||
this->icon_y_offset = Center(1, this->line_height, d.height);
|
||||
|
||||
for (const Company *c : Company::Iterate()) {
|
||||
SetDParam(0, c->index);
|
||||
SetDParam(1, c->index);
|
||||
SetDParam(2, _performance_titles[widest_title]);
|
||||
widest_width = max(widest_width, GetStringBoundingBox(STR_COMPANY_LEAGUE_COMPANY_NAME).width);
|
||||
widest_width = std::max(widest_width, GetStringBoundingBox(STR_COMPANY_LEAGUE_COMPANY_NAME).width);
|
||||
}
|
||||
|
||||
this->text_width = widest_width + 30; // Keep some extra spacing
|
||||
@@ -1323,7 +1326,7 @@ struct PerformanceRatingDetailWindow : Window {
|
||||
|
||||
uint score_info_width = 0;
|
||||
for (uint i = SCORE_BEGIN; i < SCORE_END; i++) {
|
||||
score_info_width = max(score_info_width, GetStringBoundingBox(STR_PERFORMANCE_DETAIL_VEHICLES + i).width);
|
||||
score_info_width = std::max(score_info_width, GetStringBoundingBox(STR_PERFORMANCE_DETAIL_VEHICLES + i).width);
|
||||
}
|
||||
SetDParamMaxValue(0, 1000);
|
||||
score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WD_FRAMERECT_LEFT;
|
||||
@@ -1529,7 +1532,7 @@ static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
|
||||
STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
|
||||
};
|
||||
|
||||
assert_compile(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
|
||||
static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
|
||||
|
||||
NWidgetVertical *vert = new NWidgetVertical(NC_EQUALSIZE);
|
||||
for (int widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) {
|
||||
|
||||
Reference in New Issue
Block a user