Skip to content

Commit

Permalink
Fix for empty key/value when reading item string with wear but no met…
Browse files Browse the repository at this point in the history
…adata (#6058)
  • Loading branch information
nybble41 authored and nerzhul committed Jun 27, 2017
1 parent d7343b6 commit 85d7b18
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/itemstackmetadata.cpp
Expand Up @@ -28,16 +28,18 @@ void ItemStackMetadata::deSerialize(std::istream &is)

m_stringvars.clear();

if (!in.empty() && in[0] == DESERIALIZE_START) {
Strfnd fnd(in);
fnd.to(1);
while (!fnd.at_end()) {
std::string name = fnd.next(DESERIALIZE_KV_DELIM_STR);
std::string var = fnd.next(DESERIALIZE_PAIR_DELIM_STR);
m_stringvars[name] = var;
if (!in.empty()) {
if (in[0] == DESERIALIZE_START) {
Strfnd fnd(in);
fnd.to(1);
while (!fnd.at_end()) {
std::string name = fnd.next(DESERIALIZE_KV_DELIM_STR);
std::string var = fnd.next(DESERIALIZE_PAIR_DELIM_STR);
m_stringvars[name] = var;
}
} else {
// BACKWARDS COMPATIBILITY
m_stringvars[""] = in;
}
} else {
// BACKWARDS COMPATIBILITY
m_stringvars[""] = in;
}
}

0 comments on commit 85d7b18

Please sign in to comment.