// $Id$
//
-// SuperTux - A Jump'n Run
+// SuperTux
// Copyright (C) 2004 Ricardo Cruz <rick2@aeiou.pt>
+// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
#include "lisp/lisp.hpp"
#include "lisp/parser.hpp"
#include "object_factory.hpp"
-
-Factories* object_factories = 0;
+#include "math/vector.hpp"
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());
return i->second->create_object(reader);
}
-GameObject* create_object(const std::string& name, const Vector& pos)
+GameObject* create_object(const std::string& name, const Vector& pos, const Direction dir)
{
std::stringstream lisptext;
- lisptext << "(" << name
- << " (x " << pos.x << ")"
- << " (y " << pos.y << "))";
-
+ lisptext << "((x " << pos.x << ")"
+ << " (y " << pos.y << ")";
+ if(dir != AUTO)
+ lisptext << " (direction " << dir << "))";
+
lisp::Parser parser;
- std::auto_ptr<lisp::Lisp> lisp (parser.parse(lisptext));
- return create_object(name, *lisp);
+ const lisp::Lisp* lisp = parser.parse(lisptext, "create_object");
+ GameObject* object = create_object(name, *(lisp->get_car()));
+
+ return object;
}
+