X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fstaticobject.cpp;h=86e455b9f65093247d5aaf09609733657e6d1db0;hb=49728d0b01e67cbb69aec394d7af5b81e86e5ebc;hp=d656b62214950c47cb95ab59d7f233a842b77933;hpb=f0cd5da687ca216b4bdd9abe7bc8038a679d3763;p=minetest.git diff --git a/src/staticobject.cpp b/src/staticobject.cpp index d656b6221..86e455b9f 100644 --- a/src/staticobject.cpp +++ b/src/staticobject.cpp @@ -19,7 +19,14 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "staticobject.h" #include "util/serialize.h" -#include "log.h" +#include "server/serveractiveobject.h" + +StaticObject::StaticObject(const ServerActiveObject *s_obj, const v3f &pos_): + type(s_obj->getType()), + pos(pos_) +{ + s_obj->getStaticData(&data); +} void StaticObject::serialize(std::ostream &os) { @@ -28,7 +35,7 @@ void StaticObject::serialize(std::ostream &os) // pos writeV3F1000(os, pos); // data - os<::iterator - i = m_stored.begin(); - i != m_stored.end(); ++i) { - StaticObject &s_obj = *i; + for (StaticObject &s_obj : m_stored) { s_obj.serialize(os); } - for(std::map::iterator - i = m_active.begin(); - i != m_active.end(); ++i) - { - StaticObject s_obj = i->second; + + for (auto &i : m_active) { + StaticObject s_obj = i.second; s_obj.serialize(os); } } void StaticObjectList::deSerialize(std::istream &is) { + if (m_active.size()) { + errorstream << "StaticObjectList::deSerialize(): " + << "deserializing objects while " << m_active.size() + << " active objects already exist (not cleared). " + << m_stored.size() << " stored objects _were_ cleared" + << std::endl; + } + m_stored.clear(); + // version u8 version = readU8(is); // count