]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/object_properties.cpp
Prevent world creation if the world already exists
[dragonfireclient.git] / src / object_properties.cpp
index edd50c30a08e4b081b79620f4acbff873eb6d503..e67b78b520974667bb26c0de836e93e93b144132 100644 (file)
@@ -3,22 +3,23 @@ Minetest-c55
 Copyright (C) 2012 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 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
+it under the terms of the GNU Lesser General Public License as published by
+the Free Software Foundation; either version 2.1 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.
+GNU Lesser General Public License for more details.
 
-You should have received a copy of the GNU General Public License along
+You should have received a copy of the GNU Lesser 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.
 */
 
 #include "object_properties.h"
-#include "utility.h"
+#include "util/serialize.h"
+#include <sstream>
 
 #define PP(x) "("<<(x).X<<","<<(x).Y<<","<<(x).Z<<")"
 #define PP2(x) "("<<(x).X<<","<<(x).Y<<")"
@@ -33,7 +34,8 @@ ObjectProperties::ObjectProperties():
        spritediv(1,1),
        initial_sprite_basepos(0,0),
        is_visible(true),
-       makes_footstep_sound(false)
+       makes_footstep_sound(false),
+       automatic_rotate(0)
 {
        textures.push_back("unknown_object.png");
 }
@@ -54,12 +56,13 @@ std::string ObjectProperties::dump()
        os<<"]";
        os<<", spritediv="<<PP2(spritediv);
        os<<", initial_sprite_basepos="<<PP2(initial_sprite_basepos);
-       os<<", is_visible"<<is_visible;
+       os<<", is_visible="<<is_visible;
        os<<", makes_footstep_sound="<<makes_footstep_sound;
+       os<<", automatic_rotate="<<automatic_rotate;
        return os.str();
 }
 
-void ObjectProperties::serialize(std::ostream &os)
+void ObjectProperties::serialize(std::ostream &os) const
 {
        writeU8(os, 1); // version
        writeS16(os, hp_max);
@@ -77,6 +80,7 @@ void ObjectProperties::serialize(std::ostream &os)
        writeV2S16(os, initial_sprite_basepos);
        writeU8(os, is_visible);
        writeU8(os, makes_footstep_sound);
+       writeF1000(os, automatic_rotate);
 }
 
 void ObjectProperties::deSerialize(std::istream &is)
@@ -100,6 +104,9 @@ void ObjectProperties::deSerialize(std::istream &is)
        initial_sprite_basepos = readV2S16(is);
        is_visible = readU8(is);
        makes_footstep_sound = readU8(is);
+       try{
+               automatic_rotate = readF1000(is);
+       }catch(SerializationError &e){}
 }