summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatric Stout <truebrain@openttd.org>2021-06-15 12:00:48 +0200
committerPatric Stout <github@truebrain.nl>2021-06-15 16:45:04 +0200
commitf67af5cbe5cb754c3b64553b9cc03b5c18ca7e79 (patch)
tree58eda00de38ea476852ee2d738ced7b85623bbc4
parentd5cda58158726b80ff619d0ba691420469f18e90 (diff)
downloadopenttd-f67af5cbe5cb754c3b64553b9cc03b5c18ca7e79.tar.xz
Codechange: make it more obvious SlArray supports SLE_VAR_NULL
In the end, the code was already doing the right thing, but a few functions deep, and not really obvious. When validating what objects can handle SLE_VAR_NULL, it is nicer to just have this obvious.
-rw-r--r--src/saveload/saveload.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/saveload/saveload.cpp b/src/saveload/saveload.cpp
index c07330cab..d4ca1b308 100644
--- a/src/saveload/saveload.cpp
+++ b/src/saveload/saveload.cpp
@@ -1069,6 +1069,12 @@ void SlArray(void *array, size_t length, VarType conv)
if (_sl.need_length == NL_CALCLENGTH) return;
}
+ if (GetVarMemType(conv) == SLE_VAR_NULL) {
+ assert(_sl.action != SLA_SAVE); // Use SL_NULL if you want to write null-bytes
+ SlSkipBytes(SlCalcArrayLen(length, conv));
+ return;
+ }
+
/* NOTICE - handle some buggy stuff, in really old versions everything was saved
* as a byte-type. So detect this, and adjust array size accordingly */
if (_sl.action != SLA_SAVE && _sl_version == 0) {