From af14609de77e82d5c7c2213949d921b39fb058cc Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 27 Feb 2018 15:42:22 +0100 Subject: [PATCH] - don't skip empty arrays which are themselves array elements in the ZScript serializer. --- src/scripting/types.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scripting/types.cpp b/src/scripting/types.cpp index 5059834d4..d683e62d6 100644 --- a/src/scripting/types.cpp +++ b/src/scripting/types.cpp @@ -1968,7 +1968,10 @@ void PDynArray::SetPointerArray(void *base, unsigned offset, TArray *spe void PDynArray::WriteValue(FSerializer &ar, const char *key, const void *addr) const { FArray *aray = (FArray*)addr; - if (aray->Count > 0) + // We may skip an empty array only if it gets stored under a named key. + // If no name is given, i.e. it's part of an outer array's element list, even empty arrays must be stored, + // because otherwise the array would lose its entry. + if (aray->Count > 0 || key == nullptr) { if (ar.BeginArray(key)) {