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:
@@ -534,7 +534,7 @@ static bool TransportIndustryGoods(TileIndex tile)
|
||||
bool moved_cargo = false;
|
||||
|
||||
for (uint j = 0; j < lengthof(i->produced_cargo_waiting); j++) {
|
||||
uint cw = min(i->produced_cargo_waiting[j], 255);
|
||||
uint cw = std::min<uint>(i->produced_cargo_waiting[j], 255u);
|
||||
if (cw > indspec->minimal_cargo && i->produced_cargo[j] != CT_INVALID) {
|
||||
i->produced_cargo_waiting[j] -= cw;
|
||||
|
||||
@@ -1076,7 +1076,7 @@ static void PlantFarmField(TileIndex tile, IndustryID industry)
|
||||
uint size_x = GB(r, 0, 8);
|
||||
uint size_y = GB(r, 8, 8);
|
||||
|
||||
TileArea ta(tile - TileDiffXY(min(TileX(tile), size_x / 2), min(TileY(tile), size_y / 2)), size_x, size_y);
|
||||
TileArea ta(tile - TileDiffXY(std::min(TileX(tile), size_x / 2), std::min(TileY(tile), size_y / 2)), size_x, size_y);
|
||||
ta.ClampToMap();
|
||||
|
||||
if (ta.w == 0 || ta.h == 0) return;
|
||||
@@ -1165,7 +1165,7 @@ static void ChopLumberMillTrees(Industry *i)
|
||||
|
||||
TileIndex tile = i->location.tile;
|
||||
if (CircularTileSearch(&tile, 40, SearchLumberMillTrees, nullptr)) { // 40x40 tiles to search.
|
||||
i->produced_cargo_waiting[0] = min(0xffff, i->produced_cargo_waiting[0] + 45); // Found a tree, add according value to waiting cargo.
|
||||
i->produced_cargo_waiting[0] = std::min(0xffff, i->produced_cargo_waiting[0] + 45); // Found a tree, add according value to waiting cargo.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,7 +1176,7 @@ static void ProduceIndustryGoodsFromRate(Industry *i, bool scale)
|
||||
if (amount != 0 && scale) {
|
||||
amount = ScaleQuantity(amount, _settings_game.economy.industry_cargo_scale_factor);
|
||||
}
|
||||
i->produced_cargo_waiting[j] = min(0xffff, i->produced_cargo_waiting[j] + amount);
|
||||
i->produced_cargo_waiting[j] = std::min<uint>(0xffff, i->produced_cargo_waiting[j] + amount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1815,7 +1815,7 @@ static void DoCreateNewIndustry(Industry *i, TileIndex tile, IndustryType type,
|
||||
/* Randomize inital production if non-original economy is used and there are no production related callbacks. */
|
||||
if (!indspec->UsesOriginalEconomy()) {
|
||||
for (size_t ci = 0; ci < lengthof(i->production_rate); ci++) {
|
||||
i->production_rate[ci] = min((RandomRange(256) + 128) * i->production_rate[ci] >> 8, 255);
|
||||
i->production_rate[ci] = std::min((RandomRange(256) + 128) * i->production_rate[ci] >> 8, 255u);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2281,7 +2281,7 @@ static uint GetNumberOfIndustries()
|
||||
|
||||
assert(lengthof(numof_industry_table) == ID_END);
|
||||
uint difficulty = (_game_mode != GM_EDITOR) ? _settings_game.difficulty.industry_density : (uint)ID_VERY_LOW;
|
||||
return min(IndustryPool::MAX_SIZE, ScaleByMapSize(numof_industry_table[difficulty]));
|
||||
return std::min<uint>(IndustryPool::MAX_SIZE, ScaleByMapSize(numof_industry_table[difficulty]));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2357,7 +2357,7 @@ void IndustryBuildData::MonthlyLoop()
|
||||
|
||||
/* To prevent running out of unused industries for the player to connect,
|
||||
* add a fraction of new industries each month, but only if the manager can keep up. */
|
||||
uint max_behind = 1 + min(99u, ScaleByMapSize(3)); // At most 2 industries for small maps, and 100 at the biggest map (about 6 months industry build attempts).
|
||||
uint max_behind = 1 + std::min(99u, ScaleByMapSize(3)); // At most 2 industries for small maps, and 100 at the biggest map (about 6 months industry build attempts).
|
||||
if (GetCurrentTotalNumberOfIndustries() + max_behind >= (this->wanted_inds >> 16)) {
|
||||
this->wanted_inds += ScaleByMapSize(NEWINDS_PER_MONTH);
|
||||
}
|
||||
@@ -2425,7 +2425,7 @@ static void UpdateIndustryStatistics(Industry *i)
|
||||
byte pct = 0;
|
||||
if (i->this_month_production[j] != 0) {
|
||||
i->last_prod_year = _cur_year;
|
||||
pct = min(i->this_month_transported[j] * 256 / i->this_month_production[j], 255);
|
||||
pct = std::min(i->this_month_transported[j] * 256 / i->this_month_production[j], 255);
|
||||
}
|
||||
i->last_month_pct_transported[j] = pct;
|
||||
|
||||
@@ -2449,7 +2449,7 @@ void Industry::RecomputeProductionMultipliers()
|
||||
|
||||
/* Rates are rounded up, so e.g. oilrig always produces some passengers */
|
||||
for (size_t i = 0; i < lengthof(this->production_rate); i++) {
|
||||
this->production_rate[i] = min(CeilDiv(indspec->production_rate[i] * this->prod_level, PRODLEVEL_DEFAULT), 0xFF);
|
||||
this->production_rate[i] = std::min(CeilDiv(indspec->production_rate[i] * this->prod_level, PRODLEVEL_DEFAULT), 0xFFu);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2582,10 +2582,10 @@ void IndustryBuildData::TryBuildNewIndustry()
|
||||
const Industry *ind = PlaceIndustry(it, IACT_RANDOMCREATION, false);
|
||||
if (ind == nullptr) {
|
||||
this->builddata[it].wait_count = this->builddata[it].max_wait + 1; // Compensate for decrementing below.
|
||||
this->builddata[it].max_wait = min(1000, this->builddata[it].max_wait + 2);
|
||||
this->builddata[it].max_wait = std::min(1000, this->builddata[it].max_wait + 2);
|
||||
} else {
|
||||
AdvertiseIndustryOpening(ind);
|
||||
this->builddata[it].max_wait = max(this->builddata[it].max_wait / 2, 1); // Reduce waiting time of the industry type.
|
||||
this->builddata[it].max_wait = std::max(this->builddata[it].max_wait / 2, 1); // Reduce waiting time of the industry type.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2822,7 +2822,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||
/* 4.5% chance for 3-23% (or 1 unit for very low productions) production change,
|
||||
* determined by mult value. If mult = 1 prod. increases, else (-1) it decreases. */
|
||||
if (Chance16I(1, 22, r >> 16)) {
|
||||
new_prod += mult * (max(((RandomRange(50) + 10) * old_prod) >> 8, 1U));
|
||||
new_prod += mult * (std::max(((RandomRange(50) + 10) * old_prod) >> 8, 1U));
|
||||
}
|
||||
|
||||
/* Prevent production to overflow or Oil Rig passengers to be over-"produced" */
|
||||
@@ -2867,7 +2867,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||
|
||||
/* Increase if needed */
|
||||
while (mul-- != 0 && i->prod_level < PRODLEVEL_MAXIMUM) {
|
||||
i->prod_level = min(i->prod_level * 2, PRODLEVEL_MAXIMUM);
|
||||
i->prod_level = std::min<int>(i->prod_level * 2, PRODLEVEL_MAXIMUM);
|
||||
recalculate_multipliers = true;
|
||||
if (str == STR_NULL) str = indspec->production_up_text;
|
||||
}
|
||||
@@ -2878,7 +2878,7 @@ static void ChangeIndustryProduction(Industry *i, bool monthly)
|
||||
closeit = true;
|
||||
break;
|
||||
} else {
|
||||
i->prod_level = max(i->prod_level / 2, (int)PRODLEVEL_MINIMUM); // typecast to int required to please MSVC
|
||||
i->prod_level = std::max<int>(i->prod_level / 2, PRODLEVEL_MINIMUM);
|
||||
recalculate_multipliers = true;
|
||||
if (str == STR_NULL) str = indspec->production_down_text;
|
||||
}
|
||||
@@ -2970,7 +2970,7 @@ void IndustryDailyLoop()
|
||||
|
||||
uint perc = 3; // Between 3% and 9% chance of creating a new industry.
|
||||
if ((_industry_builder.wanted_inds >> 16) > GetCurrentTotalNumberOfIndustries()) {
|
||||
perc = min(9u, perc + (_industry_builder.wanted_inds >> 16) - GetCurrentTotalNumberOfIndustries());
|
||||
perc = std::min(9u, perc + (_industry_builder.wanted_inds >> 16) - GetCurrentTotalNumberOfIndustries());
|
||||
}
|
||||
for (uint16 j = 0; j < change_loop; j++) {
|
||||
if (Chance16(perc, 100)) {
|
||||
|
Reference in New Issue
Block a user