Fix empty legacy meta being persisted
authorrubenwardy <rubenwardy@gmail.com>
Sat, 19 Aug 2017 18:43:02 +0000 (19:43 +0100)
committerparamat <mat.gregory@virginmedia.com>
Sun, 10 Sep 2017 00:30:42 +0000 (01:30 +0100)
src/itemstackmetadata.cpp

index 02c548abb6ae88b18519eec027f480381f385f0d..f63671425d390222397a35df81aa0a0dbbe68b10 100644 (file)
@@ -14,8 +14,9 @@ void ItemStackMetadata::serialize(std::ostream &os) const
        std::ostringstream os2;
        os2 << DESERIALIZE_START;
        for (const auto &stringvar : m_stringvars) {
-               os2 << stringvar.first << DESERIALIZE_KV_DELIM
-                   << stringvar.second << DESERIALIZE_PAIR_DELIM;
+               if (!stringvar.first.empty() || !stringvar.second.empty())
+                       os2 << stringvar.first << DESERIALIZE_KV_DELIM
+                               << stringvar.second << DESERIALIZE_PAIR_DELIM;
        }
        os << serializeJsonStringIfNeeded(os2.str());
 }