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:
@@ -94,7 +94,7 @@ static uint32 GetClosestIndustry(TileIndex tile, IndustryType type, const Indust
|
||||
for (const Industry *i : Industry::Iterate()) {
|
||||
if (i->type != type || i == current) continue;
|
||||
|
||||
best_dist = min(best_dist, DistanceManhattan(tile, i->location.tile));
|
||||
best_dist = std::min(best_dist, DistanceManhattan(tile, i->location.tile));
|
||||
}
|
||||
|
||||
return best_dist;
|
||||
@@ -140,13 +140,13 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
/* If the filter is 0, it could be because none was specified as well as being really a 0.
|
||||
* In either case, just do the regular var67 */
|
||||
closest_dist = GetClosestIndustry(current->location.tile, ind_index, current);
|
||||
count = min(Industry::GetIndustryTypeCount(ind_index), UINT8_MAX); // clamp to 8 bit
|
||||
count = std::min<uint>(Industry::GetIndustryTypeCount(ind_index), UINT8_MAX); // clamp to 8 bit
|
||||
} else {
|
||||
/* Count only those who match the same industry type and layout filter
|
||||
* Unfortunately, we have to do it manually */
|
||||
for (const Industry *i : Industry::Iterate()) {
|
||||
if (i->type == ind_index && i != current && (i->selected_layout == layout_filter || layout_filter == 0) && (!town_filter || i->town == current->town)) {
|
||||
closest_dist = min(closest_dist, DistanceManhattan(current->location.tile, i->location.tile));
|
||||
closest_dist = std::min(closest_dist, DistanceManhattan(current->location.tile, i->location.tile));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@@ -180,7 +180,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
case 0x88: return GetTownRadiusGroup(this->industry->town, this->tile);
|
||||
|
||||
/* Manhattan distance of the closest town */
|
||||
case 0x89: return min(DistanceManhattan(this->industry->town->xy, this->tile), 255);
|
||||
case 0x89: return std::min(DistanceManhattan(this->industry->town->xy, this->tile), 255u);
|
||||
|
||||
/* Lowest height of the tile */
|
||||
case 0x8A: return Clamp(GetTileZ(this->tile) * (this->ro.grffile->grf_version >= 8 ? 1 : TILE_HEIGHT), 0, 0xFF);
|
||||
@@ -189,7 +189,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
case 0x8B: return GetClosestWaterDistance(this->tile, (GetIndustrySpec(this->industry->type)->behaviour & INDUSTRYBEH_BUILT_ONWATER) == 0);
|
||||
|
||||
/* Square of Euclidian distance from town */
|
||||
case 0x8D: return min(DistanceSquare(this->industry->town->xy, this->tile), 65535);
|
||||
case 0x8D: return std::min(DistanceSquare(this->industry->town->xy, this->tile), 65535u);
|
||||
|
||||
/* 32 random bits */
|
||||
case 0x8F: return this->random_bits;
|
||||
@@ -213,9 +213,9 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
if (HasBit(callback, CBM_IND_PRODUCTION_CARGO_ARRIVAL) || HasBit(callback, CBM_IND_PRODUCTION_256_TICKS)) {
|
||||
if ((indspec->behaviour & INDUSTRYBEH_PROD_MULTI_HNDLING) != 0) {
|
||||
if (this->industry->prod_level == 0) return 0;
|
||||
return min(this->industry->incoming_cargo_waiting[variable - 0x40] / this->industry->prod_level, (uint16)0xFFFF);
|
||||
return std::min<uint16>(this->industry->incoming_cargo_waiting[variable - 0x40] / this->industry->prod_level, 0xFFFFu);
|
||||
} else {
|
||||
return min(this->industry->incoming_cargo_waiting[variable - 0x40], (uint16)0xFFFF);
|
||||
return std::min<uint16>(this->industry->incoming_cargo_waiting[variable - 0x40], 0xFFFFu);
|
||||
}
|
||||
} else {
|
||||
return 0;
|
||||
@@ -283,11 +283,11 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
/* Get town zone and Manhattan distance of closest town */
|
||||
case 0x65:
|
||||
if (this->tile == INVALID_TILE) break;
|
||||
return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | min(DistanceManhattan(this->tile, this->industry->town->xy), 0xFFFF);
|
||||
return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | std::min(DistanceManhattan(this->tile, this->industry->town->xy), 0xFFFFu);
|
||||
/* Get square of Euclidian distance of closes town */
|
||||
case 0x66:
|
||||
if (this->tile == INVALID_TILE) break;
|
||||
return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | min(DistanceSquare(this->tile, this->industry->town->xy), 0xFFFF);
|
||||
return GetTownRadiusGroup(this->industry->town, this->tile) << 16 | std::min(DistanceSquare(this->tile, this->industry->town->xy), 0xFFFFu);
|
||||
|
||||
/* Count of industry, distance of closest instance
|
||||
* 68 is the same as 67, but with a filtering on selected layout */
|
||||
@@ -311,6 +311,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
case 0x70:
|
||||
case 0x71: {
|
||||
CargoID cargo = GetCargoTranslation(parameter, this->ro.grffile);
|
||||
if (cargo == CT_INVALID) return 0;
|
||||
int index = this->industry->GetCargoProducedIndex(cargo);
|
||||
if (index < 0) return 0; // invalid cargo
|
||||
switch (variable) {
|
||||
@@ -329,6 +330,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
|
||||
case 0x6E:
|
||||
case 0x6F: {
|
||||
CargoID cargo = GetCargoTranslation(parameter, this->ro.grffile);
|
||||
if (cargo == CT_INVALID) return 0;
|
||||
int index = this->industry->GetCargoAcceptedIndex(cargo);
|
||||
if (index < 0) return 0; // invalid cargo
|
||||
if (variable == 0x6E) return this->industry->last_cargo_accepted_at[index];
|
||||
@@ -639,7 +641,7 @@ void IndustryProductionCallback(Industry *ind, int reason)
|
||||
ind->incoming_cargo_waiting[i] = Clamp(ind->incoming_cargo_waiting[i] - DerefIndProd(group->subtract_input[i], deref) * multiplier, 0, 0xFFFF);
|
||||
}
|
||||
for (uint i = 0; i < group->num_output; i++) {
|
||||
ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF);
|
||||
ind->produced_cargo_waiting[i] = Clamp(ind->produced_cargo_waiting[i] + std::max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF);
|
||||
}
|
||||
} else {
|
||||
/* Callback receives list of cargos to apply for, which need to have their cargo slots in industry looked up */
|
||||
@@ -651,7 +653,7 @@ void IndustryProductionCallback(Industry *ind, int reason)
|
||||
for (uint i = 0; i < group->num_output; i++) {
|
||||
int cargo_index = ind->GetCargoProducedIndex(group->cargo_output[i]);
|
||||
if (cargo_index < 0) continue;
|
||||
ind->produced_cargo_waiting[cargo_index] = Clamp(ind->produced_cargo_waiting[cargo_index] + max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF);
|
||||
ind->produced_cargo_waiting[cargo_index] = Clamp(ind->produced_cargo_waiting[cargo_index] + std::max(DerefIndProd(group->add_output[i], deref), 0) * multiplier, 0, 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user