changeset 15333:72de7debf8ce draft

(svn r19974) -Add: SlSkipArray() to skip arrays and sparse arrays in savegames.
author frosch <frosch@openttd.org>
date Sun, 13 Jun 2010 14:12:21 +0000
parents e2d08cace39d
children 09680603c66b
files src/saveload/saveload.cpp
diffstat 1 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -373,6 +373,15 @@
 	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 @@
 }
 
 /**
+ * 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 @@
 	}
 }
 
-/** 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;}