Changeset - r27893:8c85dc228529
[Not reviewed]
master
0 2 0
Patric Stout - 9 months ago 2023-09-10 20:35:03
truebrain@openttd.org
Fix b0e73277: save/load next_station for CargoPacket again
2 files changed with 3 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/saveload/cargopacket_sl.cpp
Show inline comments
 
@@ -67,48 +67,50 @@
 
		 * 'new CargoPacket' + cargolist.Append so their caches are already
 
		 * correct and do not need rebuilding. */
 
		for (Vehicle *v : Vehicle::Iterate()) v->cargo.InvalidateCache();
 

	
 
		for (Station *st : Station::Iterate()) {
 
			for (CargoID c = 0; c < NUM_CARGO; c++) st->goods[c].cargo.InvalidateCache();
 
		}
 
	}
 

	
 
	if (IsSavegameVersionBefore(SLV_181)) {
 
		for (Vehicle *v : Vehicle::Iterate()) v->cargo.KeepAll();
 
	}
 
}
 

	
 
/**
 
 * Wrapper function to get the CargoPacket's internal structure while
 
 * some of the variables itself are private.
 
 * @return the saveload description for CargoPackets.
 
 */
 
SaveLoadTable GetCargoPacketDesc()
 
{
 
	static const SaveLoad _cargopacket_desc[] = {
 
		SLE_VARNAME(CargoPacket, first_station, "source", SLE_UINT16),
 
		SLE_VAR(CargoPacket, source_xy,       SLE_UINT32),
 
		SLE_CONDVARNAME(CargoPacket, next_hop, "loaded_at_xy", SLE_FILE_U32 | SLE_VAR_U16, SL_MIN_VERSION, SLV_REMOVE_LOADED_AT_XY),
 
		SLE_CONDVARNAME(CargoPacket, next_hop, "loaded_at_xy", SLE_UINT16, SLV_REMOVE_LOADED_AT_XY, SL_MAX_VERSION),
 
		SLE_VAR(CargoPacket, count,           SLE_UINT16),
 
		SLE_CONDVARNAME(CargoPacket, periods_in_transit, "days_in_transit", SLE_FILE_U8 | SLE_VAR_U16, SL_MIN_VERSION, SLV_MORE_CARGO_AGE),
 
		SLE_CONDVARNAME(CargoPacket, periods_in_transit, "days_in_transit", SLE_UINT16, SLV_MORE_CARGO_AGE, SLV_PERIODS_IN_TRANSIT_RENAME),
 
		SLE_CONDVAR(CargoPacket, periods_in_transit, SLE_UINT16, SLV_PERIODS_IN_TRANSIT_RENAME, SL_MAX_VERSION),
 
		SLE_VAR(CargoPacket, feeder_share,    SLE_INT64),
 
		SLE_CONDVAR(CargoPacket, source_type,     SLE_UINT8,  SLV_125, SL_MAX_VERSION),
 
		SLE_CONDVAR(CargoPacket, source_id,       SLE_UINT16, SLV_125, SL_MAX_VERSION),
 
	};
 
	return _cargopacket_desc;
 
}
 

	
 
struct CAPAChunkHandler : ChunkHandler {
 
	CAPAChunkHandler() : ChunkHandler('CAPA', CH_TABLE) {}
 

	
 
	void Save() const override
 
	{
 
		SlTableHeader(GetCargoPacketDesc());
 

	
 
		for (CargoPacket *cp : CargoPacket::Iterate()) {
 
			SlSetArrayIndex(cp->index);
 
			SlObject(cp, GetCargoPacketDesc());
 
		}
 
	}
 

	
src/saveload/compat/cargopacket_sl_compat.h
Show inline comments
 
/*
 
 * This file is part of OpenTTD.
 
 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
 
 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
 
 */
 

	
 
/** @file cargopacket_sl_compat.h Loading for cargopacket chunks before table headers were added. */
 

	
 
#ifndef SAVELOAD_COMPAT_CARGOPACKET_H
 
#define SAVELOAD_COMPAT_CARGOPACKET_H
 

	
 
#include "../saveload.h"
 

	
 
/** Original field order for _cargopacket_desc. */
 
const SaveLoadCompat _cargopacket_sl_compat[] = {
 
	SLC_VAR("source"),
 
	SLC_VAR("source_xy"),
 
	SLC_NULL(4, SL_MIN_VERSION, SLV_REMOVE_LOADED_AT_XY),
 
	SLC_VAR("loaded_at_xy"),
 
	SLC_VAR("count"),
 
	SLC_VAR("days_in_transit"),
 
	SLC_VAR("feeder_share"),
 
	SLC_VAR("source_type"),
 
	SLC_VAR("source_id"),
 
	SLC_NULL(1, SL_MIN_VERSION, SLV_121),
 
};
 

	
 
#endif /* SAVELOAD_COMPAT_CARGOPACKET_H */
0 comments (0 inline, 0 general)