summaryrefslogtreecommitdiff
path: root/src/saveload.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-06-22 11:58:59 +0000
committerrubidium <rubidium@openttd.org>2007-06-22 11:58:59 +0000
commite5c352818d7edfdc5219e4c82f7d5b2083b2b72d (patch)
treefd6fbc96b8d23bef18ed7267fa8174e1689c8e78 /src/saveload.cpp
parent6159f58948763ed39a457e6ff825a735eea06b23 (diff)
downloadopenttd-e5c352818d7edfdc5219e4c82f7d5b2083b2b72d.tar.xz
(svn r10266) -Codechange: keep track of the origin, time of travel and accumulated feeder share (transfers) of individual pieces of cargo. This means that cargo isn't thrown on a big pile when it's put in a station or unloaded at a station, however the GUI does not reflect these changes yet so you will not actually see it.
Diffstat (limited to 'src/saveload.cpp')
-rw-r--r--src/saveload.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/saveload.cpp b/src/saveload.cpp
index 36be798ee..f8af5dc9b 100644
--- a/src/saveload.cpp
+++ b/src/saveload.cpp
@@ -29,7 +29,7 @@
#include <setjmp.h>
#include <list>
-extern const uint16 SAVEGAME_VERSION = 67;
+extern const uint16 SAVEGAME_VERSION = 68;
uint16 _sl_version; ///< the major savegame version identifier
byte _sl_minor_version; ///< the minor savegame version, DO NOT USE!
@@ -820,7 +820,7 @@ void SlObject(void *object, const SaveLoad *sld)
}
for (; sld->cmd != SL_END; sld++) {
- void *ptr = GetVariableAddress(object, sld);
+ void *ptr = sld->global ? sld->address : GetVariableAddress(object, sld);
SlObjectMember(ptr, sld);
}
}
@@ -831,14 +831,7 @@ void SlObject(void *object, const SaveLoad *sld)
*/
void SlGlobList(const SaveLoadGlobVarList *sldg)
{
- if (_sl.need_length != NL_NONE) {
- SlSetLength(SlCalcObjLength(NULL, (const SaveLoad*)sldg));
- if (_sl.need_length == NL_CALCLENGTH) return;
- }
-
- for (; sldg->cmd != SL_END; sldg++) {
- SlObjectMember(sldg->address, (const SaveLoad*)sldg);
- }
+ SlObject(NULL, (const SaveLoad*)sldg);
}
/**
@@ -1258,6 +1251,7 @@ extern const ChunkHandler _economy_chunk_handlers[];
extern const ChunkHandler _animated_tile_chunk_handlers[];
extern const ChunkHandler _newgrf_chunk_handlers[];
extern const ChunkHandler _group_chunk_handlers[];
+extern const ChunkHandler _cargopacket_chunk_handlers[];
static const ChunkHandler * const _chunk_handlers[] = {
_misc_chunk_handlers,
@@ -1276,6 +1270,7 @@ static const ChunkHandler * const _chunk_handlers[] = {
_animated_tile_chunk_handlers,
_newgrf_chunk_handlers,
_group_chunk_handlers,
+ _cargopacket_chunk_handlers,
NULL,
};
@@ -1307,6 +1302,7 @@ static uint ReferenceToInt(const void *obj, SLRefType rt)
case REF_ORDER: return ((const Order*)obj)->index + 1;
case REF_ROADSTOPS: return ((const RoadStop*)obj)->index + 1;
case REF_ENGINE_RENEWS: return ((const EngineRenew*)obj)->index + 1;
+ case REF_CARGO_PACKET: return ((const CargoPacket*)obj)->index + 1;
default: NOT_REACHED();
}
@@ -1367,6 +1363,11 @@ static void *IntToReference(uint index, SLRefType rt)
error("EngineRenews: failed loading savegame: too many EngineRenews");
return GetEngineRenew(index);
}
+ case REF_CARGO_PACKET: {
+ if (!AddBlockIfNeeded(&_CargoPacket_pool, index))
+ error("CargoPackets: failed loading savegame: too many Cargo packets");
+ return GetCargoPacket(index);
+ }
case REF_VEHICLE_OLD: {
/* Old vehicles were saved differently: