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

@@ -2050,9 +2050,9 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_74)) {
for (Station *st : Station::Iterate()) {
for (CargoID c = 0; c < NUM_CARGO; c++) {
st->goods[c].last_speed = 0;
if (st->goods[c].CargoAvailableCount() != 0) SetBit(st->goods[c].status, GoodsEntry::GES_RATING);
for (GoodsEntry &ge : st->goods) {
ge.last_speed = 0;
if (ge.CargoAvailableCount() != 0) SetBit(ge.status, GoodsEntry::GES_RATING);
}
}
}

View File

@@ -174,7 +174,7 @@ struct GSTRChunkHandler : ChunkHandler {
}
/* If there were no strings in the savegame, set GameStrings to nullptr */
if (_current_data->raw_strings.size() == 0) {
if (_current_data->raw_strings.empty()) {
delete _current_data;
_current_data = nullptr;
return;

View File

@@ -279,21 +279,21 @@ public:
size_t num_cargo = this->GetNumCargo();
for (size_t i = 0; i < num_cargo; i++) {
GoodsEntry *ge = &st->goods[i];
if (ge->data == nullptr) {
GoodsEntry &ge = st->goods[i];
if (ge.data == nullptr) {
if (spare_ged != nullptr) {
ge->data = std::move(spare_ged);
ge.data = std::move(spare_ged);
} else {
ge->data.reset(new GoodsEntryData());
ge.data.reset(new GoodsEntryData());
}
}
SlObject(ge, this->GetLoadDescription());
if (!IsSavegameVersionBefore(SLV_181)) ge->data->cargo.LoadSetReservedCount(_cargo_reserved_count);
SlObject(&ge, this->GetLoadDescription());
if (!IsSavegameVersionBefore(SLV_181)) ge.data->cargo.LoadSetReservedCount(_cargo_reserved_count);
if (IsSavegameVersionBefore(SLV_183)) {
SwapPackets(ge);
SwapPackets(&ge);
}
if (IsSavegameVersionBefore(SLV_68)) {
SB(ge->status, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
SB(ge.status, GoodsEntry::GES_ACCEPTANCE, 1, HasBit(_waiting_acceptance, 15));
if (GB(_waiting_acceptance, 0, 12) != 0) {
/* In old versions, enroute_from used 0xFF as INVALID_STATION */
StationID source = (IsSavegameVersionBefore(SLV_7) && _cargo_source == 0xFF) ? INVALID_STATION : _cargo_source;
@@ -306,12 +306,12 @@ public:
/* Don't construct the packet with station here, because that'll fail with old savegames */
CargoPacket *cp = new CargoPacket(GB(_waiting_acceptance, 0, 12), _cargo_periods, source, _cargo_source_xy, _cargo_feeder_share);
ge->data->cargo.Append(cp, INVALID_STATION);
SB(ge->status, GoodsEntry::GES_RATING, 1, 1);
ge.data->cargo.Append(cp, INVALID_STATION);
SB(ge.status, GoodsEntry::GES_RATING, 1, 1);
}
}
if (ge->data->MayBeRemoved()) {
spare_ged = std::move(ge->data);
if (ge.data->MayBeRemoved()) {
spare_ged = std::move(ge.data);
}
}
}
@@ -320,15 +320,16 @@ public:
{
Station *st = Station::From(bst);
uint num_cargo = IsSavegameVersionBefore(SLV_55) ? 12 : IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
for (CargoID i = 0; i < num_cargo; i++) {
GoodsEntry *ge = &st->goods[i];
size_t num_cargo = IsSavegameVersionBefore(SLV_55) ? 12 : IsSavegameVersionBefore(SLV_EXTEND_CARGOTYPES) ? 32 : NUM_CARGO;
auto end = std::next(std::begin(st->goods), std::min(num_cargo, std::size(st->goods)));
for (auto it = std::begin(st->goods); it != end; ++it) {
GoodsEntry &ge = *it;
if (IsSavegameVersionBefore(SLV_183)) {
SwapPackets(ge); // We have to swap back again to be in the format pre-183 expects.
SlObject(ge, this->GetDescription());
SwapPackets(ge);
SwapPackets(&ge); // We have to swap back again to be in the format pre-183 expects.
SlObject(&ge, this->GetDescription());
SwapPackets(&ge);
} else {
SlObject(ge, this->GetDescription());
SlObject(&ge, this->GetDescription());
}
}
}

View File

@@ -50,9 +50,9 @@ public:
void Save(Town *t) const override
{
SlSetStructListLength(NUM_CARGO);
for (CargoID i = 0; i < NUM_CARGO; i++) {
SlObject(&t->supplied[i], this->GetDescription());
SlSetStructListLength(std::size(t->supplied));
for (auto &supplied : t->supplied) {
SlObject(&supplied, this->GetDescription());
}
}
@@ -77,9 +77,9 @@ public:
void Save(Town *t) const override
{
SlSetStructListLength(NUM_TE);
for (size_t i = TE_BEGIN; i < TE_END; i++) {
SlObject(&t->received[i], this->GetDescription());
SlSetStructListLength(std::size(t->received));
for (auto &received : t->received) {
SlObject(&received, this->GetDescription());
}
}