@ -112,11 +112,11 @@ struct ExpensesList {
ExpensesType et = this - > et [ i ] ;
if ( et = = INVALID_EXPENSES ) {
if ( ! invalid_expenses_measured ) {
width = max( width , GetStringBoundingBox ( STR_FINANCES_TOTAL_CAPTION ) . width ) ;
width = std: : max( width , GetStringBoundingBox ( STR_FINANCES_TOTAL_CAPTION ) . width ) ;
invalid_expenses_measured = true ;
}
} else {
width = max( width , GetStringBoundingBox ( STR_FINANCES_SECTION_CONSTRUCTION + et ) . width ) ;
width = std: : max( width , GetStringBoundingBox ( STR_FINANCES_SECTION_CONSTRUCTION + et ) . width ) ;
}
}
return width ;
@ -322,7 +322,7 @@ struct CompanyFinancesWindow : Window {
case WID_CF_LOAN_VALUE :
case WID_CF_TOTAL_VALUE :
SetDParamMaxValue ( 0 , CompanyFinancesWindow : : max_money ) ;
size - > width = max( GetStringBoundingBox ( STR_FINANCES_NEGATIVE_INCOME ) . width , GetStringBoundingBox ( STR_FINANCES_POSITIVE_INCOME ) . width ) + padding . width ;
size - > width = std: : max( GetStringBoundingBox ( STR_FINANCES_NEGATIVE_INCOME ) . width , GetStringBoundingBox ( STR_FINANCES_POSITIVE_INCOME ) . width ) + padding . width ;
break ;
case WID_CF_MAXLOAN_GAP :
@ -342,7 +342,7 @@ struct CompanyFinancesWindow : Window {
case WID_CF_EXPS_PRICE2 :
case WID_CF_EXPS_PRICE3 : {
const Company * c = Company : : Get ( ( CompanyID ) this - > window_number ) ;
int age = min( _cur_year - c - > inaugurated_year , 2 ) ;
int age = std: : min( _cur_year - c - > inaugurated_year , 2 ) ;
int wid_offset = widget - WID_CF_EXPS_PRICE1 ;
if ( wid_offset < = age ) {
DrawYearColumn ( r , _cur_year - ( age - wid_offset ) , c - > yearly_expenses + ( age - wid_offset ) ) ;
@ -455,7 +455,7 @@ struct CompanyFinancesWindow : Window {
{
const Company * c = Company : : Get ( ( CompanyID ) this - > window_number ) ;
if ( c - > money > CompanyFinancesWindow : : max_money ) {
CompanyFinancesWindow : : max_money = max( c - > money * 2 , CompanyFinancesWindow : : max_money * 4 ) ;
CompanyFinancesWindow : : max_money = std: : max( c - > money * 2 , CompanyFinancesWindow : : max_money * 4 ) ;
this - > SetupWidgets ( ) ;
this - > ReInit ( ) ;
}
@ -526,7 +526,7 @@ public:
uint Height ( uint width ) const override
{
return max( FONT_HEIGHT_NORMAL , ScaleGUITrad ( 12 ) + 2 ) ;
return std : : max( FONT_HEIGHT_NORMAL , ScaleGUITrad ( 12 ) + 2 ) ;
}
bool Selectable ( ) const override
@ -731,7 +731,7 @@ public:
/* Position scrollbar to selected group */
for ( uint i = 0 ; i < this - > rows ; i + + ) {
if ( this - > groups [ i ] - > index = = sel ) {
this - > vscroll - > SetPosition ( Clamp ( i - this - > vscroll - > GetCapacity ( ) / 2 , 0 , max( this - > vscroll - > GetCount ( ) - this - > vscroll - > GetCapacity ( ) , 0 ) ) ) ;
this - > vscroll - > SetPosition ( Clamp ( i - this - > vscroll - > GetCapacity ( ) / 2 , 0 , std: : max( this - > vscroll - > GetCount ( ) - this - > vscroll - > GetCapacity ( ) , 0 ) ) ) ;
break ;
}
}
@ -755,14 +755,14 @@ public:
}
}
size - > width = max( size - > width , 5 + d . width + WD_FRAMERECT_RIGHT ) ;
size - > width = std: : max( size - > width , 5 + d . width + WD_FRAMERECT_RIGHT ) ;
break ;
}
case WID_SCL_MATRIX : {
/* 11 items in the default rail class */
this - > square = GetSpriteSize ( SPR_SQUARE ) ;
this - > line_height = max( this - > square . height , ( uint ) FONT_HEIGHT_NORMAL ) + 4 ;
this - > line_height = std: : max( this - > square . height , ( uint ) FONT_HEIGHT_NORMAL ) + 4 ;
size - > height = 11 * this - > line_height ;
resize - > width = 1 ;
@ -781,9 +781,9 @@ public:
this - > square = GetSpriteSize ( SPR_SQUARE ) ;
int padding = this - > square . width + NWidgetScrollbar : : GetVerticalDimension ( ) . width + 10 ;
for ( const StringID * id = _colour_dropdown ; id ! = endof ( _colour_dropdown ) ; id + + ) {
size - > width = max( size - > width , GetStringBoundingBox ( * id ) . width + padding ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( * id ) . width + padding ) ;
}
size - > width = max( size - > width , GetStringBoundingBox ( STR_COLOUR_DEFAULT ) . width + padding ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COLOUR_DEFAULT ) . width + padding ) ;
break ;
}
}
@ -898,7 +898,7 @@ public:
}
}
} else {
uint max = min ( this - > vscroll - > GetPosition ( ) + this - > vscroll - > GetCapacity ( ) , ( uint ) this - > groups . size ( ) ) ;
uint max = static_cast < uint > ( std : : min < size_t > ( this - > vscroll - > GetPosition ( ) + this - > vscroll - > GetCapacity ( ) , this - > groups . size ( ) ) ) ;
for ( uint i = this - > vscroll - > GetPosition ( ) ; i < max ; + + i ) {
const Group * g = this - > groups [ i ] ;
SetDParam ( 0 , g - > index ) ;
@ -1380,7 +1380,7 @@ public:
number_dim . width + = WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + arrows_width ;
number_dim . height + = WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM ;
/* Compute width of both buttons. */
yesno_dim . width = max( yesno_dim . width , number_dim . width ) ;
yesno_dim . width = std: : max( yesno_dim . width , number_dim . width ) ;
number_dim . width = yesno_dim . width - arrows_width ;
this - > yesno_dim = yesno_dim ;
@ -1392,8 +1392,8 @@ public:
switch ( widget ) {
case WID_SCMF_FACE : {
Dimension face_size = GetSpriteSize ( SPR_GRADIENT ) ;
size - > width = max( size - > width , face_size . width ) ;
size - > height = max( size - > height , face_size . height ) ;
size - > width = std: : max( size - > width , face_size . width ) ;
size - > height = std: : max( size - > height , face_size . height ) ;
break ;
}
@ -1885,22 +1885,22 @@ struct CompanyInfrastructureWindow : Window
case WID_CI_RAIL_DESC : {
uint lines = 1 ; // Starts at 1 because a line is also required for the section title
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_RAIL_SECT ) . width ) ;
RailType rt ;
FOR_ALL_SORTED_RAILTYPES ( rt ) {
if ( HasBit ( this - > railtypes , rt ) ) {
lines + + ;
SetDParam ( 0 , GetRailTypeInfo ( rt ) - > strings . name ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_WHITE_STRING ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_WHITE_STRING ) . width + WD_FRAMERECT_LEFT ) ;
}
}
if ( this - > railtypes ! = RAILTYPES_NONE ) {
lines + + ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_SIGNALS ) . width + WD_FRAMERECT_LEFT ) ;
}
size - > height = max( size - > height , lines * FONT_HEIGHT_NORMAL ) ;
size - > height = std: : max( size - > height , lines * FONT_HEIGHT_NORMAL ) ;
break ;
}
@ -1908,30 +1908,30 @@ struct CompanyInfrastructureWindow : Window
case WID_CI_TRAM_DESC : {
uint lines = 1 ; // Starts at 1 because a line is also required for the section title
size - > width = max( size - > width , GetStringBoundingBox ( widget = = WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( widget = = WID_CI_ROAD_DESC ? STR_COMPANY_INFRASTRUCTURE_VIEW_ROAD_SECT : STR_COMPANY_INFRASTRUCTURE_VIEW_TRAM_SECT ) . width ) ;
RoadType rt ;
FOR_ALL_SORTED_ROADTYPES ( rt ) {
if ( HasBit ( this - > roadtypes , rt ) & & RoadTypeIsRoad ( rt ) = = ( widget = = WID_CI_ROAD_DESC ) ) {
lines + + ;
SetDParam ( 0 , GetRoadTypeInfo ( rt ) - > strings . name ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_WHITE_STRING ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_WHITE_STRING ) . width + WD_FRAMERECT_LEFT ) ;
}
}
size - > height = max( size - > height , lines * FONT_HEIGHT_NORMAL ) ;
size - > height = std: : max( size - > height , lines * FONT_HEIGHT_NORMAL ) ;
break ;
}
case WID_CI_WATER_DESC :
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_WATER_SECT ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_CANALS ) . width + WD_FRAMERECT_LEFT ) ;
break ;
case WID_CI_STATION_DESC :
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_STATION_SECT ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_STATIONS ) . width + WD_FRAMERECT_LEFT ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_AIRPORTS ) . width + WD_FRAMERECT_LEFT ) ;
break ;
case WID_CI_RAIL_COUNT :
@ -1945,24 +1945,24 @@ struct CompanyInfrastructureWindow : Window
Money max_cost = 10000 ; // Some random number to reserve enough space.
uint32 rail_total = c - > infrastructure . GetRailTotal ( ) ;
for ( RailType rt = RAILTYPE_BEGIN ; rt < RAILTYPE_END ; rt + + ) {
max_val = max( max_val , c - > infrastructure . rail [ rt ] ) ;
max_cost = max( max_cost , RailMaintenanceCost ( rt , c - > infrastructure . rail [ rt ] , rail_total ) ) ;
max_val = std: : max( max_val , c - > infrastructure . rail [ rt ] ) ;
max_cost = std: : max( max_cost , RailMaintenanceCost ( rt , c - > infrastructure . rail [ rt ] , rail_total ) ) ;
}
max_val = max( max_val , c - > infrastructure . signal ) ;
max_cost = max( max_cost , SignalMaintenanceCost ( c - > infrastructure . signal ) ) ;
max_val = std: : max( max_val , c - > infrastructure . signal ) ;
max_cost = std: : max( max_cost , SignalMaintenanceCost ( c - > infrastructure . signal ) ) ;
uint32 road_total = c - > infrastructure . GetRoadTotal ( ) ;
uint32 tram_total = c - > infrastructure . GetTramTotal ( ) ;
for ( RoadType rt = ROADTYPE_BEGIN ; rt < ROADTYPE_END ; rt + + ) {
max_val = max( max_val , c - > infrastructure . road [ rt ] ) ;
max_cost = max( max_cost , RoadMaintenanceCost ( rt , c - > infrastructure . road [ rt ] , RoadTypeIsRoad ( rt ) ? road_total : tram_total ) ) ;
max_val = std: : max( max_val , c - > infrastructure . road [ rt ] ) ;
max_cost = std: : max( max_cost , RoadMaintenanceCost ( rt , c - > infrastructure . road [ rt ] , RoadTypeIsRoad ( rt ) ? road_total : tram_total ) ) ;
}
max_val = max( max_val , c - > infrastructure . water ) ;
max_cost = max( max_cost , CanalMaintenanceCost ( c - > infrastructure . water ) ) ;
max_val = max( max_val , c - > infrastructure . station ) ;
max_cost = max( max_cost , StationMaintenanceCost ( c - > infrastructure . station ) ) ;
max_val = max( max_val , c - > infrastructure . airport ) ;
max_cost = max( max_cost , AirportMaintenanceCost ( c - > index ) ) ;
max_val = std: : max( max_val , c - > infrastructure . water ) ;
max_cost = std: : max( max_cost , CanalMaintenanceCost ( c - > infrastructure . water ) ) ;
max_val = std: : max( max_val , c - > infrastructure . station ) ;
max_cost = std: : max( max_cost , StationMaintenanceCost ( c - > infrastructure . station ) ) ;
max_val = std: : max( max_val , c - > infrastructure . airport ) ;
max_cost = std: : max( max_cost , AirportMaintenanceCost ( c - > index ) ) ;
SetDParamMaxValue ( 0 , max_val ) ;
uint count_width = GetStringBoundingBox ( STR_WHITE_COMMA ) . width + 20 ; // Reserve some wiggle room
@ -1970,17 +1970,17 @@ struct CompanyInfrastructureWindow : Window
if ( _settings_game . economy . infrastructure_maintenance ) {
SetDParamMaxValue ( 0 , this - > GetTotalMaintenanceCost ( ) * 12 ) ; // Convert to per year
this - > total_width = GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL ) . width + 20 ;
size - > width = max( size - > width , this - > total_width ) ;
size - > width = std: : max( size - > width , this - > total_width ) ;
SetDParamMaxValue ( 0 , max_cost * 12 ) ; // Convert to per year
count_width + = max( this - > total_width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL ) . width ) ;
count_width + = std: : max( this - > total_width , GetStringBoundingBox ( STR_COMPANY_INFRASTRUCTURE_VIEW_TOTAL ) . width ) ;
}
size - > width = max( size - > width , count_width ) ;
size - > width = std: : max( size - > width , count_width ) ;
/* Set height of the total line. */
if ( widget = = WID_CI_TOTAL ) {
size - > height = _settings_game . economy . infrastructure_maintenance ? max( size - > height , EXP_LINESPACE + FONT_HEIGHT_NORMAL ) : 0 ;
size - > height = _settings_game . economy . infrastructure_maintenance ? std: : max( size - > height , EXP_LINESPACE + FONT_HEIGHT_NORMAL ) : 0 ;
}
break ;
}
@ -2367,8 +2367,8 @@ struct CompanyWindow : Window
switch ( widget ) {
case WID_C_FACE : {
Dimension face_size = GetSpriteSize ( SPR_GRADIENT ) ;
size - > width = max( size - > width , face_size . width ) ;
size - > height = max( size - > height , face_size . height ) ;
size - > width = std: : max( size - > width , face_size . width ) ;
size - > height = std: : max( size - > height , face_size . height ) ;
break ;
}
@ -2389,18 +2389,18 @@ struct CompanyWindow : Window
case WID_C_DESC_VEHICLE_COUNTS :
SetDParamMaxValue ( 0 , 5000 ) ; // Maximum number of vehicles
for ( uint i = 0 ; i < lengthof ( _company_view_vehicle_count_strings ) ; i + + ) {
size - > width = max( size - > width , GetStringBoundingBox ( _company_view_vehicle_count_strings [ i ] ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( _company_view_vehicle_count_strings [ i ] ) . width ) ;
}
break ;
case WID_C_DESC_INFRASTRUCTURE_COUNTS :
SetDParamMaxValue ( 0 , UINT_MAX ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_WATER ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_STATION ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_NONE ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_RAIL ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_ROAD ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_WATER ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_STATION ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_AIRPORT ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_NONE ) . width ) ;
break ;
case WID_C_DESC_OWNERS : {
@ -2408,7 +2408,7 @@ struct CompanyWindow : Window
SetDParamMaxValue ( 0 , 75 ) ;
SetDParam ( 1 , c2 - > index ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_SHARES_OWNED_BY ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_SHARES_OWNED_BY ) . width ) ;
}
break ;
}
@ -2420,13 +2420,13 @@ struct CompanyWindow : Window
case WID_C_GIVE_MONEY :
case WID_C_COMPANY_PASSWORD :
case WID_C_COMPANY_JOIN :
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_VIEW_HQ_BUTTON ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_BUILD_HQ_BUTTON ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_RELOCATE_HQ ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_GIVE_MONEY_BUTTON ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_PASSWORD ) . width ) ;
size - > width = max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_JOIN ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_VIEW_HQ_BUTTON ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_BUILD_HQ_BUTTON ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_RELOCATE_HQ ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_INFRASTRUCTURE_BUTTON ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_GIVE_MONEY_BUTTON ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_PASSWORD ) . width ) ;
size - > width = std: : max( size - > width , GetStringBoundingBox ( STR_COMPANY_VIEW_JOIN ) . width ) ;
break ;
case WID_C_HAS_PASSWORD :