Fixing SuperTux crashes when compiled on Mac OS X 10.9
[supertux.git] / src / object / scripted_object.cpp
index b1a572a..e17de28 100644 (file)
 #include "scripting/squirrel_util.hpp"
 #include "sprite/sprite.hpp"
 #include "supertux/object_factory.hpp"
+#include "util/reader.hpp"
 
 ScriptedObject::ScriptedObject(const Reader& lisp) :
   MovingSprite(lisp, LAYER_OBJECTS, COLGROUP_MOVING_STATIC),
+  physic(),
+  name(),
   solid(true), 
   physic_enabled(true), 
   visible(true), 
-  new_vel_set(false)
+  new_vel_set(false),
+  new_vel()
 {
   lisp.get("name", name);
   if(name == "")
@@ -43,7 +47,7 @@ ScriptedObject::ScriptedObject(const Reader& lisp) :
   lisp.get("solid", solid);
   lisp.get("physic-enabled", physic_enabled);
   lisp.get("visible", visible);
-  lisp.get("z-pos", layer);
+  layer = reader_get_layer (lisp, /* default = */ LAYER_OBJECTS);
   if( solid ){
     set_group( COLGROUP_MOVING_STATIC );
   } else {
@@ -55,14 +59,14 @@ void
 ScriptedObject::expose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name.empty()) return;
-  expose_object(vm, table_idx, dynamic_cast<Scripting::ScriptedObject *>(this), name, false);
+  expose_object(vm, table_idx, dynamic_cast<scripting::ScriptedObject *>(this), name, false);
 }
 
 void
 ScriptedObject::unexpose(HSQUIRRELVM vm, SQInteger table_idx)
 {
   if (name.empty()) return;
-  Scripting::unexpose_object(vm, table_idx, name);
+  scripting::unexpose_object(vm, table_idx, name);
 }
 
 void
@@ -139,6 +143,18 @@ ScriptedObject::is_solid()
   return solid;
 }
 
+bool
+ScriptedObject::gravity_enabled() const
+{
+       return physic.gravity_enabled();
+}
+
+void
+ScriptedObject::enable_gravity(bool f)
+{
+       physic.enable_gravity(f);
+}
+
 void
 ScriptedObject::set_action(const std::string& animation)
 {
@@ -203,6 +219,4 @@ ScriptedObject::collision(GameObject& , const CollisionHit& )
   return FORCE_MOVE;
 }
 
-IMPLEMENT_FACTORY(ScriptedObject, "scriptedobject");
-
 /* EOF */