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:
Jonathan G Rennison
2021-02-01 17:07:34 +00:00
290 changed files with 2135 additions and 1577 deletions

View File

@@ -47,7 +47,7 @@ public:
*/
inline void SetDemandPerNode(uint num_demands)
{
this->demand_per_node = max(this->supply_sum / num_demands, 1U);
this->demand_per_node = std::max(this->supply_sum / num_demands, 1U);
}
/**
@@ -59,7 +59,7 @@ public:
*/
inline uint EffectiveSupply(const Node &from, const Node &to)
{
return max(from.Supply() * max(1U, to.Supply()) * this->mod_size / 100 / this->demand_per_node, 1U);
return std::max(from.Supply() * std::max(1U, to.Supply()) * this->mod_size / 100 / this->demand_per_node, 1U);
}
/**
@@ -161,7 +161,7 @@ public:
*/
inline void AdjustDemandNodes(LinkGraphJob &job, const std::vector<NodeID> &demands)
{
const uint count = min<uint>(demands.size(), this->missing_supply);
const uint count = std::min<uint>(demands.size(), this->missing_supply);
this->missing_supply = 0;
for (uint i = 0; i < count; i++) {
job[demands[i]].ReceiveDemand(1);
@@ -177,7 +177,7 @@ public:
*/
inline uint EffectiveSupply(const Node &from, const Node &to)
{
return max<int>(min<int>(from.Supply(), ((int) this->demand_per_node) - ((int) to.ReceivedDemand())), 1);
return std::max<int>(std::min<int>(from.Supply(), ((int) this->demand_per_node) - ((int) to.ReceivedDemand())), 1);
}
/**
@@ -213,7 +213,7 @@ void SymmetricScaler::SetDemands(LinkGraphJob &job, NodeID from_id, NodeID to_id
uint undelivered = job[to_id].UndeliveredSupply();
if (demand_back > undelivered) {
demand_back = undelivered;
demand_forw = max(1U, demand_back * 100 / this->mod_size);
demand_forw = std::max(1U, demand_back * 100 / this->mod_size);
}
this->Scaler::SetDemands(job, to_id, from_id, demand_back);
}
@@ -325,7 +325,7 @@ void DemandCalculator::CalcDemand(LinkGraphJob &job, const std::vector<bool> &re
demand_forw = 1;
}
demand_forw = min(demand_forw, job[from_id].UndeliveredSupply());
demand_forw = std::min(demand_forw, job[from_id].UndeliveredSupply());
scaler.SetDemands(job, from_id, to_id, demand_forw);
@@ -380,7 +380,7 @@ void DemandCalculator::CalcMinimisedDistanceDemand(LinkGraphJob &job, const std:
uint distance;
};
std::vector<EdgeCandidate> candidates;
candidates.reserve(supplies.size() * demands.size() - min(supplies.size(), demands.size()));
candidates.reserve(supplies.size() * demands.size() - std::min(supplies.size(), demands.size()));
for (NodeID from_id : supplies) {
for (NodeID to_id : demands) {
if (from_id != to_id) {
@@ -395,7 +395,7 @@ void DemandCalculator::CalcMinimisedDistanceDemand(LinkGraphJob &job, const std:
if (job[candidate.from_id].UndeliveredSupply() == 0) continue;
if (!scaler.HasDemandLeft(job[candidate.to_id])) continue;
scaler.SetDemands(job, candidate.from_id, candidate.to_id, min(job[candidate.from_id].UndeliveredSupply(), scaler.EffectiveSupply(job[candidate.from_id], job[candidate.to_id])));
scaler.SetDemands(job, candidate.from_id, candidate.to_id, std::min(job[candidate.from_id].UndeliveredSupply(), scaler.EffectiveSupply(job[candidate.from_id], job[candidate.to_id])));
}
}

View File

@@ -71,7 +71,7 @@ void LinkGraph::Compress()
for (NodeID node2 = 0; node2 < this->Size(); ++node2) {
BaseEdge &edge = this->edges[node1][node2];
if (edge.capacity > 0) {
edge.capacity = max(1U, edge.capacity / 2);
edge.capacity = std::max(1U, edge.capacity / 2);
edge.usage /= 2;
}
}
@@ -163,8 +163,7 @@ NodeID LinkGraph::AddNode(const Station *st)
this->nodes.emplace_back();
/* Avoid reducing the height of the matrix as that is expensive and we
* most likely will increase it again later which is again expensive. */
this->edges.Resize(new_node + 1U,
max(new_node + 1U, this->edges.Height()));
this->edges.Resize(new_node + 1U, std::max(new_node + 1U, this->edges.Height()));
this->nodes[new_node].Init(st->xy, st->index,
HasBit(good.status, GoodsEntry::GES_ACCEPTANCE));
@@ -266,8 +265,8 @@ void LinkGraph::Edge::Update(uint capacity, uint usage, EdgeUpdateMode mode)
this->edge.capacity += capacity;
this->edge.usage += usage;
} else if (mode & EUM_REFRESH) {
this->edge.capacity = max(this->edge.capacity, capacity);
this->edge.usage = max(this->edge.usage, usage);
this->edge.capacity = std::max(this->edge.capacity, capacity);
this->edge.usage = std::max(this->edge.usage, usage);
}
if (mode & EUM_UNRESTRICTED) this->edge.last_unrestricted_update = _date;
if (mode & EUM_RESTRICTED) this->edge.last_restricted_update = _date;

View File

@@ -114,7 +114,7 @@ public:
* Get the date of the last update to any part of the edge's capacity.
* @return Last update.
*/
Date LastUpdate() const { return max(this->edge.last_unrestricted_update, this->edge.last_restricted_update); }
Date LastUpdate() const { return std::max(this->edge.last_unrestricted_update, this->edge.last_restricted_update); }
};
/**
@@ -454,7 +454,7 @@ public:
*/
inline static uint Scale(uint val, uint target_age, uint orig_age)
{
return val > 0 ? max(1U, val * target_age / orig_age) : 0;
return val > 0 ? std::max(1U, val * target_age / orig_age) : 0;
}
/** Bare constructor, only for save/load. */

View File

@@ -350,7 +350,7 @@ inline bool LinkGraphOverlay::IsLinkVisible(Point pta, Point ptb, const DrawPixe
{
/* multiply the numbers by 32 in order to avoid comparing to 0 too often. */
if (cargo.capacity == 0 ||
max(cargo.usage, cargo.planned) * 32 / (cargo.capacity + 1) < max(new_usg, new_plan) * 32 / (new_cap + 1)) {
std::max(cargo.usage, cargo.planned) * 32 / (cargo.capacity + 1) < std::max(new_usg, new_plan) * 32 / (new_cap + 1)) {
cargo.capacity = new_cap;
cargo.usage = new_usg;
cargo.planned = new_plan;
@@ -417,7 +417,7 @@ void LinkGraphOverlay::DrawLinks(const DrawPixelInfo *dpi) const
*/
void LinkGraphOverlay::DrawContent(Point pta, Point ptb, const LinkProperties &cargo) const
{
uint usage_or_plan = min(cargo.capacity * 2 + 1, max(cargo.usage, cargo.planned));
uint usage_or_plan = std::min(cargo.capacity * 2 + 1, std::max(cargo.usage, cargo.planned));
int colour = LinkGraphOverlay::LINK_COLOURS[_settings_client.gui.linkgraph_colours][usage_or_plan * lengthof(LinkGraphOverlay::LINK_COLOURS[0]) / (cargo.capacity * 2 + 2)];
int dash = cargo.shared ? this->scale * 4 : 0;
@@ -448,7 +448,7 @@ void LinkGraphOverlay::DrawStationDots(const DrawPixelInfo *dpi) const
const Station *st = Station::GetIfValid(i->id);
if (st == nullptr) continue;
uint r = this->scale * 2 + this->scale * 2 * min(200, i->quantity) / 200;
uint r = this->scale * 2 + this->scale * 2 * std::min<uint>(200, i->quantity) / 200;
LinkGraphOverlay::DrawVertex(pt.x, pt.y, r,
_colour_gradient[st->owner != OWNER_NONE ?

View File

@@ -230,8 +230,8 @@ void LinkGraphJob::NodeAnnotation::Init(uint supply)
*/
void Path::Fork(Path *base, uint cap, int free_cap, uint dist)
{
this->capacity = min(base->capacity, cap);
this->free_capacity = min(base->free_capacity, free_cap);
this->capacity = std::min(base->capacity, cap);
this->free_capacity = std::min(base->free_capacity, free_cap);
this->distance = base->distance + dist;
assert(this->distance > 0);
if (this->GetParent() != base) {
@@ -257,7 +257,7 @@ uint Path::AddFlow(uint new_flow, LinkGraphJob &job, uint max_saturation)
if (max_saturation != UINT_MAX) {
uint usable_cap = edge.Capacity() * max_saturation / 100;
if (usable_cap > edge.Flow()) {
new_flow = min(new_flow, usable_cap - edge.Flow());
new_flow = std::min(new_flow, usable_cap - edge.Flow());
} else {
return 0;
}

View File

@@ -424,7 +424,7 @@ public:
*/
inline static int GetCapacityRatio(int free, uint total)
{
return Clamp(free, PATH_CAP_MIN_FREE, PATH_CAP_MAX_FREE) * PATH_CAP_MULTIPLIER / max(total, 1U);
return Clamp(free, PATH_CAP_MIN_FREE, PATH_CAP_MAX_FREE) * PATH_CAP_MULTIPLIER / std::max(total, 1U);
}
/**

View File

@@ -67,7 +67,7 @@ void LinkGraphSchedule::SpawnNext()
for (auto &it : this->running) {
total_cost += it->Graph().CalculateCostEstimate();
}
uint64 clamped_total_cost = min<uint64>(total_cost, 1 << 25);
uint64 clamped_total_cost = std::min<uint64>(total_cost, 1 << 25);
uint log2_clamped_total_cost = FindLastBit(clamped_total_cost);
uint scaling = log2_clamped_total_cost > 13 ? log2_clamped_total_cost - 12 : 1;
uint64 cost_budget = clamped_total_cost / scaling;
@@ -326,7 +326,7 @@ void StateGameLoop_LinkGraphPauseControl()
if (_date % _settings_game.linkgraph.recalc_interval != _settings_game.linkgraph.recalc_interval / 2) return;
} else {
int date_ticks = ((_date * DAY_TICKS) + _date_fract - (LinkGraphSchedule::SPAWN_JOIN_TICK - 2));
int interval = max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / _settings_game.economy.day_length_factor));
int interval = std::max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / _settings_game.economy.day_length_factor));
if (date_ticks % interval != interval / 2) return;
}
@@ -362,7 +362,7 @@ void OnTick_LinkGraph()
interval = _settings_game.linkgraph.recalc_interval;
offset = _date % interval;
} else {
interval = max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / _settings_game.economy.day_length_factor));
interval = std::max<int>(2, (_settings_game.linkgraph.recalc_interval * DAY_TICKS / _settings_game.economy.day_length_factor));
offset = ((_date * DAY_TICKS) + _date_fract - LinkGraphSchedule::SPAWN_JOIN_TICK) % interval;
}
if (offset == 0) {

View File

@@ -253,7 +253,7 @@ bool DistanceAnnotation::IsBetter(const DistanceAnnotation *base, uint cap,
bool CapacityAnnotation::IsBetter(const CapacityAnnotation *base, uint cap,
int free_cap, uint dist) const
{
int min_cap = Path::GetCapacityRatio(min(base->free_capacity, free_cap), min(base->capacity, cap));
int min_cap = Path::GetCapacityRatio(std::min(base->free_capacity, free_cap), std::min(base->capacity, cap));
int this_cap = this->GetAnnotation();
if (min_cap == this_cap) {
/* If the capacities are the same and the other path isn't disconnected
@@ -379,7 +379,7 @@ uint MCF1stPass::FindCycleFlow(const PathVector &path, const Path *cycle_begin)
uint flow = UINT_MAX;
const Path *cycle_end = cycle_begin;
do {
flow = min(flow, cycle_begin->GetFlow());
flow = std::min(flow, cycle_begin->GetFlow());
cycle_begin = path[cycle_begin->GetNode()];
} while (cycle_begin != cycle_end);
return flow;

View File

@@ -209,7 +209,7 @@ const Order *LinkRefresher::PredictNextOrder(const Order *cur, const Order *next
const Order *skip_to = this->vehicle->orders.list->GetNextDecisionNode(
this->vehicle->orders.list->GetOrderAt(next->GetConditionSkipToOrder()), num_hops, this_cargo_mask);
assert(this_cargo_mask == this->cargo_mask);
if (skip_to != nullptr && num_hops < min<uint>(64, this->vehicle->orders.list->GetNumOrders()) && skip_to != next) {
if (skip_to != nullptr && num_hops < std::min<uint>(64, this->vehicle->orders.list->GetNumOrders()) && skip_to != next) {
/* Make copies of capacity tracking lists. There is potential
* for optimization here: If the vehicle never refits we don't
* need to copy anything. Also, if we've seen the branched link