From ac5fde61fb03059daee4b505dcaad84f21b93857 Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 30 Aug 2007 12:10:32 +0000 Subject: (svn r11002) -Codechange: unhackify the cargo packet list saving (a little). --- src/cargopacket.h | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/cargopacket.h') diff --git a/src/cargopacket.h b/src/cargopacket.h index c7948b579..2dacb7bc2 100644 --- a/src/cargopacket.h +++ b/src/cargopacket.h @@ -67,6 +67,8 @@ struct CargoPacket : PoolItem { */ #define FOR_ALL_CARGOPACKETS(cp) FOR_ALL_CARGOPACKETS_FROM(cp, 0) +extern void SaveLoad_STNS(Station *st); + /** * Simple collection class for a list of cargo packets */ @@ -93,21 +95,7 @@ private: uint days_in_transit; ///< Cache for the number of days in transit public: - /** - * Needed for an ugly hack: - * - vehicles and stations need to store cargo lists, so they use CargoList as container - * - this internals of the container should be protected, e.g. private (or protected) by C++ - * - for saving/loading we need to pass pointer to objects - * -> so *if* the pointer to the cargo list is the same as the pointer to the packet list - * encapsulated in the CargoList, we can just pass the CargoList as "offset". - * Normally we would then just add the offset of the packets variable within the cargo list - * but that is not possible because the variable is private. Furthermore we are not sure - * that this works on all platforms, we need to check whether the offset is actually 0. - * This cannot be done compile time, because the variable is private. So we need to write - * a function that does actually check the offset runtime and call it somewhere where it - * is always called but it should not be called often. - */ - static void AssertOnWrongPacketOffset(); + friend void SaveLoad_STNS(Station *st); /** Create the cargo list */ CargoList() { this->InvalidateCache(); } -- cgit v1.2.3-54-g00ecf