Update Squirrel to 2.2.2 (although README says 2.2.1)
[supertux.git] / src / object_factory.cpp
index 5335140..667a12f 100644 (file)
 #include "object_factory.hpp"
 #include "math/vector.hpp"
 
-Factories* object_factories = 0;
-
 GameObject* create_object(const std::string& name, const lisp::Lisp& reader)
 {
-  Factories::iterator i = object_factories->find(name);
-  if(i == object_factories->end()) {
+  Factory::Factories::iterator i = Factory::get_factories().find(name);
+  if(i == Factory::get_factories().end()) {
     std::stringstream msg;
     msg << "No factory for object '" << name << "' found.";
     throw std::runtime_error(msg.str());
@@ -44,13 +42,27 @@ GameObject* create_object(const std::string& name, const lisp::Lisp& reader)
 GameObject* create_object(const std::string& name, const Vector& pos)
 {
   std::stringstream lisptext;
-  lisptext << "(" << name
-           << " (x " << pos.x << ")"
+  lisptext << "((x " << pos.x << ")"
            << " (y " << pos.y << "))";
 
   lisp::Parser parser;
   const lisp::Lisp* lisp = parser.parse(lisptext, "create_object");
-  GameObject* object = create_object(name, *lisp);
+  GameObject* object = create_object(name, *(lisp->get_car()));
 
   return object;
 }
+
+GameObject* create_badguy_object(const std::string& name, const Vector& pos, const Direction dir)
+{
+  std::stringstream lisptext;
+  lisptext << "((x " << pos.x << ")"
+           << " (y " << pos.y << ")"
+           << " (direction " << dir << "))";
+
+  lisp::Parser parser;
+  const lisp::Lisp* lisp = parser.parse(lisptext, "create_object");
+  GameObject* object = create_object(name, *(lisp->get_car()));
+
+  return object;
+}
+