qmax patch to fix bug #0000389 - colors in infoblocks
[supertux.git] / src / sprite / sprite_manager.cpp
index 71e9d3f..f1de683 100644 (file)
@@ -1,7 +1,7 @@
 //  $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
@@ -16,6 +16,7 @@
 //  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>
@@ -29,7 +30,9 @@
 #include "lisp/parser.hpp"
 #include "lisp/list_iterator.hpp"
 #include "file_system.hpp"
-#include "msg.hpp"
+#include "log.hpp"
+
+SpriteManager* sprite_manager = NULL;
 
 SpriteManager::SpriteManager()
 {
@@ -58,7 +61,7 @@ SpriteManager::create(const std::string& name)
   } else {
     data = i->second;
   }
-  
+
   return new Sprite(*data);
 }
 
@@ -66,7 +69,16 @@ SpriteData*
 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) {
@@ -78,7 +90,6 @@ SpriteManager::load(const std::string& filename)
   std::auto_ptr<SpriteData> data (
       new SpriteData(sprite, FileSystem::dirname(filename)) );
   sprites[filename] = data.release();
-  
+
   return sprites[filename];
 }
-