From d21f406b038f9514c4180ff2ab16f2f9db91afb4 Mon Sep 17 00:00:00 2001 From: rubidium Date: Fri, 24 Apr 2009 08:15:58 +0000 Subject: (svn r16133) -Fix (r16129): who would've thought that the saveload system couldn't handle skipping strings on load yet? --- src/saveload/saveload.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/saveload/saveload.cpp') diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp index 43b904e34..f0eb90bb1 100644 --- a/src/saveload/saveload.cpp +++ b/src/saveload/saveload.cpp @@ -145,17 +145,28 @@ static void SlReadFill() } static inline size_t SlGetOffs() {return _sl.offs_base - (_sl.bufe - _sl.bufp);} +static inline uint SlReadArrayLength(); /** Return the size in bytes of a certain type of normal/atomic variable * as it appears in memory. See VarTypes * @param conv VarType type of variable that is used for calculating the size * @return Return the size of this type in bytes */ -static inline byte SlCalcConvMemLen(VarType conv) +static inline uint SlCalcConvMemLen(VarType conv) { static const byte conv_mem_size[] = {1, 1, 1, 2, 2, 4, 4, 8, 8, 0}; byte length = GB(conv, 4, 4); - assert(length < lengthof(conv_mem_size)); - return conv_mem_size[length]; + + switch (length << 4) { + case SLE_VAR_STRB: + case SLE_VAR_STRBQ: + case SLE_VAR_STR: + case SLE_VAR_STRQ: + return SlReadArrayLength(); + + default: + assert(length < lengthof(conv_mem_size)); + return conv_mem_size[length]; + } } /** Return the size in bytes of a certain type of normal/atomic variable -- cgit v1.2.3-54-g00ecf