diff options
-rw-r--r-- | src/StringUtils.cpp | 26 | ||||
-rw-r--r-- | src/WorldStorage/NBTChunkSerializer.cpp | 10 |
2 files changed, 12 insertions, 24 deletions
diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index decce8065..0e30e8ebb 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -198,14 +198,7 @@ AString TrimString(const AString & str) AString & StrToUpper(AString & s) { - AString::iterator i = s.begin(); - AString::iterator end = s.end(); - - while (i != end) - { - *i = (char)toupper(*i); - ++i; - } + std::transform(s.begin(), s.end(), s.begin(), ::toupper); return s; } @@ -215,14 +208,7 @@ AString & StrToUpper(AString & s) AString & StrToLower(AString & s) { - AString::iterator i = s.begin(); - AString::iterator end = s.end(); - - while (i != end) - { - *i = (char)tolower(*i); - ++i; - } + std::transform(s.begin(), s.end(), s.begin(), ::tolower); return s; } @@ -232,12 +218,8 @@ AString & StrToLower(AString & s) AString StrToLower(const AString & s) { - AString res; - res.resize(s.size()); - for (AString::iterator itr = res.begin(), end = res.end(); itr != end; ++itr) - { - *itr = (char)tolower(*itr); - } + AString res(s); + std::transform(res.begin(), res.end(), res.begin(), ::tolower); return res; } diff --git a/src/WorldStorage/NBTChunkSerializer.cpp b/src/WorldStorage/NBTChunkSerializer.cpp index ecda9b8fd..e435a1b1f 100644 --- a/src/WorldStorage/NBTChunkSerializer.cpp +++ b/src/WorldStorage/NBTChunkSerializer.cpp @@ -570,8 +570,14 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster) case cMonster::mtWolf: { const cWolf & Wolf = *((cWolf *)a_Monster); - m_Writer.AddString("Owner", Wolf.GetOwnerName()); - m_Writer.AddString("OwnerUUID", Wolf.GetOwnerUUID()); + if (!Wolf.GetOwnerName().empty()) + { + m_Writer.AddString("Owner", Wolf.GetOwnerName()); + } + if (!Wolf.GetOwnerUUID().empty()) + { + m_Writer.AddString("OwnerUUID", Wolf.GetOwnerUUID()); + } m_Writer.AddByte("Sitting", Wolf.IsSitting() ? 1 : 0); m_Writer.AddByte("Angry", Wolf.IsAngry() ? 1 : 0); m_Writer.AddInt("CollarColor", Wolf.GetCollarColor()); |