X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fnameidmapping.cpp;h=05cfae0691722f3c86023a59f3328606a1db08bd;hb=391eec9ee78fc9dfdc476ad2a8ed7755009e4a2f;hp=2a436f735af9b0895f655b316bbf3b407af4e596;hpb=d0ea6f9920d30f46d1f5d44e8823a8d932f9f29d;p=minetest.git diff --git a/src/nameidmapping.cpp b/src/nameidmapping.cpp index 2a436f735..05cfae069 100644 --- a/src/nameidmapping.cpp +++ b/src/nameidmapping.cpp @@ -1,6 +1,6 @@ /* -Minetest-c55 -Copyright (C) 2011 celeron55, Perttu Ahola +Minetest +Copyright (C) 2013 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by @@ -18,33 +18,31 @@ with this program; if not, write to the Free Software Foundation, Inc., */ #include "nameidmapping.h" +#include "exceptions.h" #include "util/serialize.h" void NameIdMapping::serialize(std::ostream &os) const { writeU8(os, 0); // version writeU16(os, m_id_to_name.size()); - for(std::map::const_iterator - i = m_id_to_name.begin(); - i != m_id_to_name.end(); i++){ - writeU16(os, i->first); - os<second); + for (const auto &i : m_id_to_name) { + writeU16(os, i.first); + os << serializeString16(i.second); } } void NameIdMapping::deSerialize(std::istream &is) { int version = readU8(is); - if(version != 0) + if (version != 0) throw SerializationError("unsupported NameIdMapping version"); u32 count = readU16(is); m_id_to_name.clear(); m_name_to_id.clear(); - for(u32 i=0; i