From b1adf15f899062ba9ef6e7a134b5a0460be15764 Mon Sep 17 00:00:00 2001 From: karutoh Date: Sat, 17 Feb 2024 00:48:14 -0800 Subject: [PATCH] Added param for Serializer::WriteStr. --- include/ehs/Serializer.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/include/ehs/Serializer.h b/include/ehs/Serializer.h index 5234a41..594500a 100644 --- a/include/ehs/Serializer.h +++ b/include/ehs/Serializer.h @@ -396,7 +396,7 @@ namespace ehs } template - void WriteStr(const T* str, N inSize = 0) + void WriteStr(const T* str, const bool sizeKnown, N inSize = 0) { if (!inSize) while (str[inSize]) @@ -424,7 +424,8 @@ namespace ehs { Util::Copy(&data[offset], &str[0], bSize); - *(T*)&data[offset + inSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + inSize] = 0; } else { @@ -432,7 +433,8 @@ namespace ehs for (N b = 0; b < sizeof(T); ++b) data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; - *(T*)&data[offset + bSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + bSize] = 0; } } else @@ -443,13 +445,15 @@ namespace ehs for (N b = 0; b < sizeof(T); ++b) data[offset + sizeof(T) * i + b] = ((Byte*)&str[i])[sizeof(T) - i - 1]; - *(T*)&data[offset + bSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + bSize] = 0; } else { Util::Copy(&data[offset], &str[0], bSize); - *(T*)&data[offset + bSize] = 0; + if (!sizeKnown) + *(T*)&data[offset + bSize] = 0; } }