// $Id$
//
// SuperTux
-// Copyright (C) 2004 Ingo Ruhnke <grumbel@gmx.de>
+// 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
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
#include <config.h>
#include <iostream>
#include "file_system.hpp"
#include "log.hpp"
+SpriteManager* sprite_manager = NULL;
+
SpriteManager::SpriteManager()
{
}
} else {
data = i->second;
}
-
+
return new Sprite(*data);
}
SpriteManager::load(const std::string& filename)
{
lisp::Parser parser;
- std::auto_ptr<lisp::Lisp> root (parser.parse(filename));
+ const lisp::Lisp* root;
+
+ try {
+ root = parser.parse(filename);
+ } catch(const std::exception& e) {
+ std::ostringstream msg;
+ msg << "Parse error when trying to load sprite '" << filename
+ << "': " << e.what() << "\n";
+ throw std::runtime_error(msg.str());
+ }
const lisp::Lisp* sprite = root->get_lisp("supertux-sprite");
if(!sprite) {
std::auto_ptr<SpriteData> data (
new SpriteData(sprite, FileSystem::dirname(filename)) );
sprites[filename] = data.release();
-
+
return sprites[filename];
}
-