Merge branch 'master' into jgrpp

# Conflicts:
#	regression/regression/result.txt
#	src/aircraft_cmd.cpp
#	src/airport_gui.cpp
#	src/articulated_vehicles.cpp
#	src/console_cmds.cpp
#	src/date_gui.cpp
#	src/engine.cpp
#	src/genworld_gui.cpp
#	src/gfx_layout_fallback.cpp
#	src/group_gui.cpp
#	src/hotkeys.cpp
#	src/network/core/tcp_connect.cpp
#	src/network/core/tcp_listen.h
#	src/newgrf.cpp
#	src/newgrf.h
#	src/newgrf_engine.cpp
#	src/newgrf_gui.cpp
#	src/newgrf_station.cpp
#	src/openttd.cpp
#	src/order_gui.cpp
#	src/os/macosx/osx_main.cpp
#	src/pathfinder/yapf/yapf_node_rail.hpp
#	src/rail_gui.cpp
#	src/saveload/afterload.cpp
#	src/saveload/cargopacket_sl.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/saveload/station_sl.cpp
#	src/script/api/script_industrytype.cpp
#	src/settings.cpp
#	src/settings_gui.cpp
#	src/settings_table.cpp
#	src/settingsgen/settingsgen.cpp
#	src/station.cpp
#	src/station_cmd.cpp
#	src/strings.cpp
#	src/timer/timer_game_calendar.cpp
#	src/timer/timer_game_calendar.h
#	src/timer/timer_manager.h
#	src/timer/timer_window.cpp
#	src/timetable_cmd.cpp
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/town_gui.cpp
#	src/train_gui.cpp
#	src/vehicle_cmd.h
#	src/vehicle_gui.cpp
#	src/viewport.cpp
#	src/widgets/dropdown.cpp
#	src/window_func.h
#	src/window_gui.h
This commit is contained in:
Jonathan G Rennison
2023-11-25 13:29:58 +00:00
175 changed files with 1086 additions and 1177 deletions

View File

@@ -1146,7 +1146,7 @@ static ChangeInfoResult RailVehicleChangeInfo(uint engine, int numinfo, int prop
break;
}
if (_cur.grffile->railtype_list.size() == 0) {
if (_cur.grffile->railtype_list.empty()) {
/* Use traction type to select between normal and electrified
* rail only when no translation list is in place. */
if (_gted[e->index].railtypelabel == RAILTYPE_RAIL_LABEL && engclass >= EC_ELECTRIC) _gted[e->index].railtypelabel = RAILTYPE_ELECTRIC_LABEL;
@@ -6040,9 +6040,9 @@ static void NewSpriteGroup(ByteReader *buf)
group->default_group = PruneTargetSpriteGroup(group->default_group);
}
group->error_group = ranges.size() > 0 ? ranges[0].group : group->default_group;
group->error_group = ranges.empty() ? group->default_group : ranges[0].group;
/* nvar == 0 is a special case -- we turn our value into a callback result */
group->calculated_result = ranges.size() == 0;
group->calculated_result = ranges.empty();
ProcessDeterministicSpriteGroupRanges(ranges, group->ranges, group->default_group);
@@ -6306,7 +6306,7 @@ static CargoID TranslateCargo(uint8 feature, uint8 ctype)
if ((feature == GSF_STATIONS || feature == GSF_ROADSTOPS) && ctype == 0xFE) return CT_DEFAULT_NA;
if (ctype == 0xFF) return CT_PURCHASE;
if (_cur.grffile->cargo_list.size() == 0) {
if (_cur.grffile->cargo_list.empty()) {
/* No cargo table, so use bitnum values */
if (ctype >= 32) {
grfmsg(1, "TranslateCargo: Cargo bitnum %d out of range (max 31), skipping.", ctype);
@@ -10492,19 +10492,18 @@ void ResetPersistentNewGRFData()
*/
static void BuildCargoTranslationMap()
{
memset(_cur.grffile->cargo_map, 0xFF, sizeof(_cur.grffile->cargo_map));
_cur.grffile->cargo_map.fill(UINT8_MAX);
for (CargoID c = 0; c < NUM_CARGO; c++) {
const CargoSpec *cs = CargoSpec::Get(c);
for (const CargoSpec *cs : CargoSpec::Iterate()) {
if (!cs->IsValid()) continue;
if (_cur.grffile->cargo_list.size() == 0) {
if (_cur.grffile->cargo_list.empty()) {
/* Default translation table, so just a straight mapping to bitnum */
_cur.grffile->cargo_map[c] = cs->bitnum;
_cur.grffile->cargo_map[cs->Index()] = cs->bitnum;
} else {
/* Check the translation table for this cargo's label */
int idx = find_index(_cur.grffile->cargo_list, {cs->label});
if (idx >= 0) _cur.grffile->cargo_map[c] = idx;
if (idx >= 0) _cur.grffile->cargo_map[cs->Index()] = idx;
}
}
}
@@ -10719,20 +10718,13 @@ static void CalculateRefitMasks()
* cargo type. Finally disable the vehicle, if there is still no cargo. */
if (ei->cargo_type == CT_INVALID && ei->refit_mask != 0) {
/* Figure out which CTT to use for the default cargo, if it is 'first refittable'. */
const uint8 *cargo_map_for_first_refittable = nullptr;
{
const GRFFile *file = _gted[engine].defaultcargo_grf;
if (file == nullptr) file = e->GetGRF();
if (file != nullptr && file->grf_version >= 8 && file->cargo_list.size() != 0) {
cargo_map_for_first_refittable = file->cargo_map;
}
}
if (cargo_map_for_first_refittable != nullptr) {
const GRFFile *file = _gted[engine].defaultcargo_grf;
if (file == nullptr) file = e->GetGRF();
if (file != nullptr && file->grf_version >= 8 && !file->cargo_list.empty()) {
/* Use first refittable cargo from cargo translation table */
byte best_local_slot = 0xFF;
byte best_local_slot = UINT8_MAX;
for (CargoID cargo_type : SetCargoBitIterator(ei->refit_mask)) {
byte local_slot = cargo_map_for_first_refittable[cargo_type];
byte local_slot = file->cargo_map[cargo_type];
if (local_slot < best_local_slot) {
best_local_slot = local_slot;
ei->cargo_type = cargo_type;
@@ -10776,12 +10768,9 @@ static void FinaliseEngineArray()
}
}
/* Do final mapping on variant engine ID and set appropriate flags on variant engine */
/* Do final mapping on variant engine ID. */
if (e->info.variant_id != INVALID_ENGINE) {
e->info.variant_id = GetNewEngineID(e->grf_prop.grffile, e->type, e->info.variant_id);
if (e->info.variant_id != INVALID_ENGINE) {
Engine::Get(e->info.variant_id)->display_flags |= EngineDisplayFlags::HasVariants | EngineDisplayFlags::IsFolded;
}
}
if (!HasBit(e->info.climates, _settings_game.game_creation.landscape)) continue;
@@ -10813,13 +10802,32 @@ static void FinaliseEngineArray()
}
}
}
/* Check engine variants don't point back on themselves (either directly or via a loop) then set appropriate flags
* on variant engine. This is performed separately as all variant engines need to have been resolved. */
for (Engine *e : Engine::Iterate()) {
EngineID parent = e->info.variant_id;
while (parent != INVALID_ENGINE) {
parent = Engine::Get(parent)->info.variant_id;
if (parent != e->index) continue;
/* Engine looped back on itself, so clear the variant. */
e->info.variant_id = INVALID_ENGINE;
grfmsg(1, "FinaliseEngineArray: Variant of engine %X in '%s' loops back on itself", _engine_mngr[e->index].internal_id, e->GetGRF()->filename.c_str());
break;
}
if (e->info.variant_id != INVALID_ENGINE) {
Engine::Get(e->info.variant_id)->display_flags |= EngineDisplayFlags::HasVariants | EngineDisplayFlags::IsFolded;
}
}
}
/** Check for invalid cargoes */
static void FinaliseCargoArray()
{
for (CargoID c = 0; c < NUM_CARGO; c++) {
CargoSpec *cs = CargoSpec::Get(c);
for (CargoSpec *cs : CargoSpec::Iterate()) {
if (!cs->IsValid()) {
cs->name = cs->name_single = cs->units_volume = STR_NEWGRF_INVALID_CARGO;
cs->quantifier = STR_NEWGRF_INVALID_CARGO_QUANTITY;