Merge branch 'master' into jgrpp
# Conflicts: # cmake/CompileFlags.cmake # src/aircraft_cmd.cpp # src/blitter/32bpp_anim.cpp # src/cargopacket.cpp # src/cheat_gui.cpp # src/company_cmd.cpp # src/company_gui.cpp # src/core/pool_func.hpp # src/date.cpp # src/economy.cpp # src/error_gui.cpp # src/ground_vehicle.cpp # src/ground_vehicle.hpp # src/group_gui.cpp # src/industry_cmd.cpp # src/lang/dutch.txt # src/lang/french.txt # src/lang/german.txt # src/linkgraph/linkgraph_gui.cpp # src/linkgraph/mcf.cpp # src/network/network_content.cpp # src/network/network_server.cpp # src/network/network_udp.cpp # src/newgrf_engine.cpp # src/newgrf_station.cpp # src/order_cmd.cpp # src/order_gui.cpp # src/pathfinder/follow_track.hpp # src/pathfinder/yapf/yapf_common.hpp # src/saveload/saveload.cpp # src/settings_gui.cpp # src/station_cmd.cpp # src/station_kdtree.h # src/string_func.h # src/table/settings.ini # src/tgp.cpp # src/timetable_cmd.cpp # src/timetable_gui.cpp # src/toolbar_gui.cpp # src/town_cmd.cpp # src/train_cmd.cpp # src/train_gui.cpp # src/tree_gui.cpp # src/tunnelbridge_cmd.cpp # src/vehicle.cpp # src/vehicle_gui.cpp # src/video/sdl2_v.cpp # src/video/sdl_v.cpp # src/video/win32_v.cpp # src/viewport.cpp # src/viewport_sprite_sorter_sse4.cpp # src/window.cpp
This commit is contained in:
@@ -142,7 +142,7 @@ Money CalculateCompanyValue(const Company *c, bool including_loan)
|
||||
if (including_loan) value -= c->current_loan;
|
||||
value += c->money;
|
||||
|
||||
return max(value, (Money)1);
|
||||
return std::max<Money>(value, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,15 +201,15 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
|
||||
|
||||
/* Generate statistics depending on recent income statistics */
|
||||
{
|
||||
int numec = min(c->num_valid_stat_ent, 12);
|
||||
int numec = std::min<uint>(c->num_valid_stat_ent, 12u);
|
||||
if (numec != 0) {
|
||||
const CompanyEconomyEntry *cee = c->old_economy;
|
||||
Money min_income = cee->income + cee->expenses;
|
||||
Money max_income = cee->income + cee->expenses;
|
||||
|
||||
do {
|
||||
min_income = min(min_income, cee->income + cee->expenses);
|
||||
max_income = max(max_income, cee->income + cee->expenses);
|
||||
min_income = std::min(min_income, cee->income + cee->expenses);
|
||||
max_income = std::max(max_income, cee->income + cee->expenses);
|
||||
} while (++cee, --numec);
|
||||
|
||||
if (min_income > 0) {
|
||||
@@ -222,7 +222,7 @@ int UpdateCompanyRatingAndValue(Company *c, bool update)
|
||||
|
||||
/* Generate score depending on amount of transported cargo */
|
||||
{
|
||||
int numec = min(c->num_valid_stat_ent, 4);
|
||||
int numec = std::min<uint>(c->num_valid_stat_ent, 4u);
|
||||
if (numec != 0) {
|
||||
const CompanyEconomyEntry *cee = c->old_economy;
|
||||
OverflowSafeInt64 total_delivered = 0;
|
||||
@@ -370,7 +370,7 @@ void ChangeOwnershipOfCompanyItems(Owner old_owner, Owner new_owner)
|
||||
if (HasBit(t->have_ratings, old_owner)) {
|
||||
if (HasBit(t->have_ratings, new_owner)) {
|
||||
/* use max of the two ratings. */
|
||||
t->ratings[new_owner] = max(t->ratings[new_owner], t->ratings[old_owner]);
|
||||
t->ratings[new_owner] = std::max(t->ratings[new_owner], t->ratings[old_owner]);
|
||||
} else {
|
||||
SetBit(t->have_ratings, new_owner);
|
||||
t->ratings[new_owner] = t->ratings[old_owner];
|
||||
@@ -961,12 +961,12 @@ void StartupEconomy()
|
||||
{
|
||||
_economy.interest_rate = _settings_game.difficulty.initial_interest;
|
||||
_economy.infl_amount = _settings_game.difficulty.initial_interest;
|
||||
_economy.infl_amount_pr = max(0, _settings_game.difficulty.initial_interest - 1);
|
||||
_economy.infl_amount_pr = std::max(0, _settings_game.difficulty.initial_interest - 1);
|
||||
_economy.fluct = GB(Random(), 0, 8) + 168;
|
||||
|
||||
if (_settings_game.economy.inflation && _settings_game.economy.inflation_fixed_dates) {
|
||||
/* Apply inflation that happened before our game start year. */
|
||||
int months = (min(_cur_year, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR) * 12;
|
||||
int months = (std::min(_cur_year, ORIGINAL_MAX_YEAR) - ORIGINAL_BASE_YEAR) * 12;
|
||||
for (int i = 0; i < months; i++) {
|
||||
AddInflation(false);
|
||||
}
|
||||
@@ -1023,7 +1023,7 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, C
|
||||
|
||||
/* Use callback to calculate cargo profit, if available */
|
||||
if (HasBit(cs->callback_mask, CBM_CARGO_PROFIT_CALC)) {
|
||||
uint32 var18 = min(dist, 0xFFFF) | (min(num_pieces, 0xFF) << 16) | (transit_days << 24);
|
||||
uint32 var18 = std::min(dist, 0xFFFFu) | (std::min(num_pieces, 0xFFu) << 16) | (transit_days << 24);
|
||||
uint16 callback = GetCargoCallback(CBID_CARGO_PROFIT_CALC, 0, var18, cs);
|
||||
if (callback != CALLBACK_FAILED) {
|
||||
int result = GB(callback, 0, 14);
|
||||
@@ -1043,8 +1043,8 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, C
|
||||
|
||||
const int days1 = cs->transit_days[0];
|
||||
const int days2 = cs->transit_days[1];
|
||||
const int days_over_days1 = max( transit_days - days1, 0);
|
||||
const int days_over_days2 = max(days_over_days1 - days2, 0);
|
||||
const int days_over_days1 = std::max( transit_days - days1, 0);
|
||||
const int days_over_days2 = std::max(days_over_days1 - days2, 0);
|
||||
|
||||
/*
|
||||
* The time factor is calculated based on the time it took
|
||||
@@ -1056,7 +1056,7 @@ Money GetTransportedGoodsIncome(uint num_pieces, uint dist, byte transit_days, C
|
||||
* - linear decreasing with time with a slope of -2 for slow transports
|
||||
*
|
||||
*/
|
||||
const int time_factor = max(MAX_TIME_FACTOR - days_over_days1 - days_over_days2, MIN_TIME_FACTOR);
|
||||
const int time_factor = std::max(MAX_TIME_FACTOR - days_over_days1 - days_over_days2, MIN_TIME_FACTOR);
|
||||
|
||||
return BigMulS(dist * time_factor * num_pieces, cs->current_payment, 21);
|
||||
}
|
||||
@@ -1105,7 +1105,7 @@ static uint DeliverGoodsToIndustry(const Station *st, CargoID cargo_type, uint n
|
||||
/* Insert the industry into _cargo_delivery_destinations, if not yet contained */
|
||||
include(_cargo_delivery_destinations, ind);
|
||||
|
||||
uint amount = min(num_pieces, 0xFFFFU - ind->incoming_cargo_waiting[cargo_index]);
|
||||
uint amount = std::min(num_pieces, 0xFFFFu - ind->incoming_cargo_waiting[cargo_index]);
|
||||
ind->incoming_cargo_waiting[cargo_index] += amount;
|
||||
ind->last_cargo_accepted_at[cargo_index] = _date;
|
||||
num_pieces -= amount;
|
||||
@@ -1200,7 +1200,7 @@ static void TriggerIndustryProduction(Industry *i)
|
||||
if (cargo_waiting == 0) continue;
|
||||
|
||||
for (uint ci_out = 0; ci_out < lengthof(i->produced_cargo_waiting); ci_out++) {
|
||||
i->produced_cargo_waiting[ci_out] = min(i->produced_cargo_waiting[ci_out] + (cargo_waiting * indspec->input_cargo_multiplier[ci_in][ci_out] / 256), 0xFFFF);
|
||||
i->produced_cargo_waiting[ci_out] = std::min(i->produced_cargo_waiting[ci_out] + (cargo_waiting * indspec->input_cargo_multiplier[ci_in][ci_out] / 256), 0xFFFFu);
|
||||
}
|
||||
|
||||
i->incoming_cargo_waiting[ci_in] = 0;
|
||||
@@ -1402,7 +1402,7 @@ static uint GetLoadAmount(Vehicle *v)
|
||||
if (HasBit(e->info.misc_flags, EF_NO_DEFAULT_CARGO_MULTIPLIER) && !air_mail) load_amount = CeilDiv(load_amount * CargoSpec::Get(v->cargo_type)->multiplier, 0x100);
|
||||
|
||||
/* Zero load amount breaks a lot of things. */
|
||||
return max(1u, load_amount);
|
||||
return std::max(1u, load_amount);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1726,7 +1726,7 @@ static void UpdateLoadUnloadTicks(Vehicle *front, const Station *st, int ticks,
|
||||
}
|
||||
}
|
||||
/* Always wait at least 1, otherwise we'll wait 'infinitively' long. */
|
||||
front->load_unload_ticks = max(1, ticks);
|
||||
front->load_unload_ticks = std::max(1, ticks);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1873,7 +1873,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
|
||||
if (HasBit(v->vehicle_flags, VF_CARGO_UNLOADING) && (GetUnloadType(v) & OUFB_NO_UNLOAD) == 0) {
|
||||
uint cargo_count = v->cargo.UnloadCount();
|
||||
uint amount_unloaded = _settings_game.order.gradual_loading ? min(cargo_count, GetLoadAmount(v)) : cargo_count;
|
||||
uint amount_unloaded = _settings_game.order.gradual_loading ? std::min(cargo_count, GetLoadAmount(v)) : cargo_count;
|
||||
bool remaining = false; // Are there cargo entities in this vehicle that can still be unloaded here?
|
||||
|
||||
assert(payment != nullptr);
|
||||
@@ -1976,8 +1976,8 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
}
|
||||
|
||||
/* if last speed is 0, we treat that as if no vehicle has ever visited the station. */
|
||||
ge->last_speed = min(t, 255);
|
||||
ge->last_age = min(_cur_year - front->build_year, 255);
|
||||
ge->last_speed = std::min(t, 255);
|
||||
ge->last_age = std::min(_cur_year - front->build_year, 255);
|
||||
|
||||
assert(v->cargo_cap >= v->cargo.StoredCount());
|
||||
/* Capacity available for loading more cargo. */
|
||||
@@ -1991,7 +1991,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
* has capacity for it, load it on the vehicle. */
|
||||
if ((v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0 || ge->cargo.AvailableCount() > 0) && MayLoadUnderExclusiveRights(st, v)) {
|
||||
if (v->cargo.StoredCount() == 0) TriggerVehicle(v, VEHICLE_TRIGGER_NEW_CARGO);
|
||||
if (_settings_game.order.gradual_loading) cap_left = min(cap_left, GetLoadAmount(v));
|
||||
if (_settings_game.order.gradual_loading) cap_left = std::min(cap_left, GetLoadAmount(v));
|
||||
|
||||
uint loaded = ge->cargo.Load(cap_left, &v->cargo, st->xy, next_station.Get(v->cargo_type));
|
||||
if (v->cargo.ActionCount(VehicleCargoList::MTA_LOAD) > 0) {
|
||||
@@ -2095,7 +2095,7 @@ static void LoadUnloadVehicle(Vehicle *front)
|
||||
/* We loaded less cargo than possible for all cargo types and it's not full
|
||||
* load and we're not supposed to wait any longer: stop loading. */
|
||||
if (!anything_unloaded && full_load_amount == 0 && reservation_left == 0 && full_load_cargo_mask == 0 &&
|
||||
(front->current_order_time >= (uint)max<int>(front->current_order.GetTimetabledWait() - front->lateness_counter, 0) ||
|
||||
(front->current_order_time >= (uint)std::max<int>(front->current_order.GetTimetabledWait() - front->lateness_counter, 0) ||
|
||||
may_leave_early())) {
|
||||
SetBit(front->vehicle_flags, VF_STOP_LOADING);
|
||||
if (may_leave_early()) {
|
||||
|
Reference in New Issue
Block a user