Merge branch 'master' into jgrpp

# Conflicts:
#	config.lib
#	projects/openttd_vs140.vcxproj
#	projects/openttd_vs140.vcxproj.filters
#	projects/openttd_vs141.vcxproj
#	projects/openttd_vs141.vcxproj.filters
#	projects/openttd_vs142.vcxproj
#	projects/openttd_vs142.vcxproj.filters
#	src/aircraft_cmd.cpp
#	src/base_station_base.h
#	src/core/pool_type.hpp
#	src/disaster_vehicle.cpp
#	src/economy.cpp
#	src/engine.cpp
#	src/group.h
#	src/group_cmd.cpp
#	src/group_gui.cpp
#	src/lang/english.txt
#	src/lang/german.txt
#	src/linkgraph/linkgraph_gui.cpp
#	src/network/network_command.cpp
#	src/network/network_server.cpp
#	src/openttd.cpp
#	src/order_cmd.cpp
#	src/road_cmd.cpp
#	src/saveload/afterload.cpp
#	src/saveload/cargopacket_sl.cpp
#	src/saveload/linkgraph_sl.cpp
#	src/saveload/order_sl.cpp
#	src/saveload/station_sl.cpp
#	src/saveload/town_sl.cpp
#	src/saveload/vehicle_sl.cpp
#	src/screenshot.cpp
#	src/screenshot.h
#	src/settings_gui.cpp
#	src/settings_type.h
#	src/smallmap_gui.cpp
#	src/station.cpp
#	src/station_cmd.cpp
#	src/table/settings.ini
#	src/toolbar_gui.cpp
#	src/town_cmd.cpp
#	src/train.h
#	src/train_cmd.cpp
#	src/train_gui.cpp
#	src/vehicle.cpp
#	src/vehicle_base.h
#	src/vehiclelist.cpp
#	src/window_type.h
This commit is contained in:
Jonathan G Rennison
2020-01-06 18:45:51 +00:00
281 changed files with 2714 additions and 2467 deletions

View File

@@ -25,14 +25,13 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
/* static */ void CargoPacket::AfterLoad()
{
if (IsSavegameVersionBefore(SLV_44)) {
Vehicle *v;
/* If we remove a station while cargo from it is still en route, payment calculation will assume
* 0, 0 to be the source of the cargo, resulting in very high payments usually. v->source_xy
* stores the coordinates, preserving them even if the station is removed. However, if a game is loaded
* where this situation exists, the cargo-source information is lost. in this case, we set the source
* to the current tile of the vehicle to prevent excessive profits
*/
FOR_ALL_VEHICLES(v) {
for (const Vehicle *v : Vehicle::Iterate()) {
const CargoPacketList *packets = v->cargo.Packets();
for (VehicleCargoList::ConstIterator it(packets->begin()); it != packets->end(); it++) {
CargoPacket *cp = *it;
@@ -46,8 +45,7 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
* station where the goods came from is already removed, the source
* information is lost. In that case we set it to the position of this
* station */
Station *st;
FOR_ALL_STATIONS(st) {
for (Station *st : Station::Iterate()) {
for (CargoID c = 0; c < NUM_CARGO; c++) {
GoodsEntry *ge = &st->goods[c];
@@ -63,8 +61,7 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
if (IsSavegameVersionBefore(SLV_120)) {
/* CargoPacket's source should be either INVALID_STATION or a valid station */
CargoPacket *cp;
FOR_ALL_CARGOPACKETS(cp) {
for (CargoPacket *cp : CargoPacket::Iterate()) {
if (!Station::IsValidID(cp->source)) cp->source = INVALID_STATION;
}
}
@@ -73,18 +70,15 @@ extern btree::btree_map<uint64, Money> _cargo_packet_deferred_payments;
/* Only since version 68 we have cargo packets. Savegames from before used
* 'new CargoPacket' + cargolist.Append so their caches are already
* correct and do not need rebuilding. */
Vehicle *v;
FOR_ALL_VEHICLES(v) v->cargo.InvalidateCache();
for (Vehicle *v : Vehicle::Iterate()) v->cargo.InvalidateCache();
Station *st;
FOR_ALL_STATIONS(st) {
for (Station *st : Station::Iterate()) {
for (CargoID c = 0; c < NUM_CARGO; c++) st->goods[c].cargo.InvalidateCache();
}
}
if (IsSavegameVersionBefore(SLV_181)) {
Vehicle *v;
FOR_ALL_VEHICLES(v) v->cargo.KeepAll();
for (Vehicle *v : Vehicle::Iterate()) v->cargo.KeepAll();
}
}
@@ -140,8 +134,7 @@ const SaveLoad *GetCargoPacketDesc()
static void Save_CAPA()
{
std::vector<SaveLoad> filtered_packet_desc = SlFilterObject(GetCargoPacketDesc());
CargoPacket *cp;
FOR_ALL_CARGOPACKETS(cp) {
for (CargoPacket *cp : CargoPacket::Iterate()) {
SlSetArrayIndex(cp->index);
SlObjectSaveFiltered(cp, filtered_packet_desc.data());
}