diff options
author | rubenwardy <rubenwardy@gmail.com> | 2017-08-19 19:43:02 +0100 |
---|---|---|
committer | SmallJoker <mk939@ymail.com> | 2018-06-03 17:31:59 +0200 |
commit | e9087d1be7e24557a268e77b3005052058d89adb (patch) | |
tree | 8b2f326d75bd370039790aaecf0bc0c9b0a86e50 | |
parent | bb4ef529548d2d27fbea0617347d49eb7ba70b85 (diff) | |
download | minetest-e9087d1be7e24557a268e77b3005052058d89adb.tar.gz minetest-e9087d1be7e24557a268e77b3005052058d89adb.tar.bz2 minetest-e9087d1be7e24557a268e77b3005052058d89adb.zip |
Fix empty legacy meta being persisted
-rw-r--r-- | src/itemstackmetadata.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/itemstackmetadata.cpp b/src/itemstackmetadata.cpp index 65829fd68..f63671425 100644 --- a/src/itemstackmetadata.cpp +++ b/src/itemstackmetadata.cpp @@ -13,11 +13,10 @@ void ItemStackMetadata::serialize(std::ostream &os) const { std::ostringstream os2; os2 << DESERIALIZE_START; - for (StringMap::const_iterator - it = m_stringvars.begin(); - it != m_stringvars.end(); ++it) { - os2 << it->first << DESERIALIZE_KV_DELIM - << it->second << DESERIALIZE_PAIR_DELIM; + for (const auto &stringvar : m_stringvars) { + if (!stringvar.first.empty() || !stringvar.second.empty()) + os2 << stringvar.first << DESERIALIZE_KV_DELIM + << stringvar.second << DESERIALIZE_PAIR_DELIM; } os << serializeJsonStringIfNeeded(os2.str()); } |