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<<")"
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");
}
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);
writeV2S16(os, initial_sprite_basepos);
writeU8(os, is_visible);
writeU8(os, makes_footstep_sound);
+ writeF1000(os, automatic_rotate);
}
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){}
}