summaryrefslogtreecommitdiff
path: root/src/saveload/saveload.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-06-13 14:12:21 +0000
committerfrosch <frosch@openttd.org>2010-06-13 14:12:21 +0000
commite8248cf1136cbb82f88807f68b53473aa8eb1682 (patch)
tree5309369e961e190095bbe48170fa32076d06b019 /src/saveload/saveload.cpp
parent62ac13815438c6d502ccc665adca1db5ef473a1d (diff)
downloadopenttd-e8248cf1136cbb82f88807f68b53473aa8eb1682.tar.xz
(svn r19974) -Add: SlSkipArray() to skip arrays and sparse arrays in savegames.
Diffstat (limited to 'src/saveload/saveload.cpp')
-rw-r--r--src/saveload/saveload.cpp28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index 4f48080c2..21e6861a2 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -373,6 +373,15 @@ static inline void SlWriteUint64(uint64 x)
SlWriteUint32((uint32)x);
}
+/** Read in bytes from the file/data structure but don't do
+ * anything with them, discarding them in effect
+ * @param length The amount of bytes that is being treated this way
+ */
+static inline void SlSkipBytes(size_t length)
+{
+ for (; length != 0; length--) SlReadByte();
+}
+
/**
* Read in the header descriptor of an object or an array.
* If the highest bit is set (7), then the index is bigger than 127
@@ -489,6 +498,16 @@ int SlIterateArray()
}
/**
+ * Skip an array or sparse array
+ */
+void SlSkipArray()
+{
+ while (SlIterateArray() != -1) {
+ SlSkipBytes(_next_offs - SlGetOffs());
+ }
+}
+
+/**
* Sets the length of either a RIFF object or the number of items in an array.
* This lets us load an object or an array of arbitrary size
* @param length The length of the sought object/array
@@ -551,15 +570,6 @@ static void SlCopyBytes(void *ptr, size_t length)
}
}
-/** Read in bytes from the file/data structure but don't do
- * anything with them, discarding them in effect
- * @param length The amount of bytes that is being treated this way
- */
-static inline void SlSkipBytes(size_t length)
-{
- for (; length != 0; length--) SlReadByte();
-}
-
/* Get the length of the current object */
size_t SlGetFieldLength() {return _sl.obj_len;}