From: Perttu Ahola Date: Sun, 10 Apr 2011 17:49:15 +0000 (+0300) Subject: added missing file X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=89eaaa3e6e44acfb9b61569437c7c8cadeeec7a0;p=zefram%2Fminetest%2Fminetest_engine.git added missing file --- diff --git a/src/staticobject.h b/src/staticobject.h new file mode 100644 index 00000000..c3369af3 --- /dev/null +++ b/src/staticobject.h @@ -0,0 +1,167 @@ +/* +Minetest-c55 +Copyright (C) 2010-2011 celeron55, Perttu Ahola + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef STATICOBJECT_HEADER +#define STATICOBJECT_HEADER + +#include "common_irrlicht.h" +#include +#include +#include "utility.h" + +struct StaticObject +{ + u8 type; + v3f pos; + std::string data; + + StaticObject(): + type(0), + pos(0,0,0) + { + } + StaticObject(u8 type_, v3f pos_, const std::string &data_): + type(type_), + pos(pos_), + data(data_) + { + } + + void serialize(std::ostream &os) + { + char buf[12]; + // type + buf[0] = type; + os.write(buf, 1); + // pos + writeV3S32((u8*)buf, v3s32(pos.X*1000,pos.Y*1000,pos.Z*1000)); + os.write(buf, 12); + // data + os<::Iterator + i = m_stored.begin(); + i != m_stored.end(); i++) + { + StaticObject &s_obj = *i; + s_obj.serialize(os); + } + for(core::map::Iterator + i = m_active.getIterator(); + i.atEnd()==false; i++) + { + StaticObject s_obj = i.getNode()->getValue(); + s_obj.serialize(os); + } + } + void deSerialize(std::istream &is) + { + char buf[12]; + // version + is.read(buf, 1); + u8 version = buf[0]; + // count + is.read(buf, 2); + u16 count = readU16((u8*)buf); + for(u16 i=0; i m_stored; + core::map m_active; + +private: +}; + +#endif +