pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] r4056 - in trunk/pingus: . src/engine/display src/engine/in


From: grumbel at BerliOS
Subject: [Pingus-CVS] r4056 - in trunk/pingus: . src/engine/display src/engine/input src/engine/input_old src/engine/input_old/axes src/engine/input_old/buttons src/pingus src/pingus/worldmap src/util
Date: Fri, 6 Nov 2009 16:44:20 +0100

Author: grumbel
Date: 2009-11-06 16:44:11 +0100 (Fri, 06 Nov 2009)
New Revision: 4056

Removed:
   trunk/pingus/src/pingus/pingus_error.cpp
   trunk/pingus/src/pingus/pingus_error.hpp
Modified:
   trunk/pingus/TODO
   trunk/pingus/src/engine/display/blitter.cpp
   trunk/pingus/src/engine/display/font_description.cpp
   trunk/pingus/src/engine/input/manager.cpp
   trunk/pingus/src/engine/input_old/axes/joystick_axis.cpp
   trunk/pingus/src/engine/input_old/axis_factory.cpp
   trunk/pingus/src/engine/input_old/button_factory.cpp
   trunk/pingus/src/engine/input_old/buttons/joystick_button.cpp
   trunk/pingus/src/engine/input_old/controller.cpp
   trunk/pingus/src/engine/input_old/pointer_factory.cpp
   trunk/pingus/src/engine/input_old/scroller_factory.cpp
   trunk/pingus/src/pingus/collision_map.cpp
   trunk/pingus/src/pingus/ground_map.cpp
   trunk/pingus/src/pingus/levelset.cpp
   trunk/pingus/src/pingus/pingus_demo.cpp
   trunk/pingus/src/pingus/pingus_level.cpp
   trunk/pingus/src/pingus/pingus_main.cpp
   trunk/pingus/src/pingus/res_descriptor.cpp
   trunk/pingus/src/pingus/savegame_manager.cpp
   trunk/pingus/src/pingus/server_event.cpp
   trunk/pingus/src/pingus/stat_manager.cpp
   trunk/pingus/src/pingus/state_sprite.cpp
   trunk/pingus/src/pingus/worldmap/dot_factory.cpp
   trunk/pingus/src/pingus/worldmap/drawable.hpp
   trunk/pingus/src/pingus/worldmap/drawable_factory.cpp
   trunk/pingus/src/pingus/worldmap/path_graph.cpp
   trunk/pingus/src/pingus/worldmap/pingus_worldmap.cpp
   trunk/pingus/src/pingus/worldmap/worldmap.cpp
   trunk/pingus/src/pingus/worldmap/worldmap_story.cpp
   trunk/pingus/src/pingus/worldobj_factory.cpp
   trunk/pingus/src/util/system.cpp
Log:
Replaced PingusError with std::runtime_error


Modified: trunk/pingus/TODO
===================================================================
--- trunk/pingus/TODO   2009-11-06 14:04:47 UTC (rev 4055)
+++ trunk/pingus/TODO   2009-11-06 15:44:11 UTC (rev 4056)
@@ -37,15 +37,15 @@
 
 * banish Vector3f from the source code, along with float
 
-* replace PingusError with std::runtime_error()
-
 * reduce global variables
 
 * get rid of "pingus/pingus.cpp"
 
 * make pingu.hpp use int not float
 
+* data/prefab/ completly obsolete? if so remove
 
+
 OLPC Issues
 ===========
 
@@ -53,9 +53,9 @@
   drawing or collision detection (likely to many rectangles -> go
   Microtile array or make RectMerger suck in rects that are close together)
 
-* music doesn't makes things very slow and then just stops working
+* music does make things very slow and then just stops working
 
-* cursor and icons are to small, fonts maybe too
+* cursor and icons are to small
 
 * maybe bigger font
 
@@ -212,6 +212,9 @@
 
 * keep highscores for levels (number saved and stuff like that)
 
+* add clickable WorldObjs, that can be triggered by the user, not by a
+  Pingu
+
 Wishlist:
 =========
 

Modified: trunk/pingus/src/engine/display/blitter.cpp
===================================================================
--- trunk/pingus/src/engine/display/blitter.cpp 2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/engine/display/blitter.cpp 2009-11-06 15:44:11 UTC (rev 
4056)
@@ -22,7 +22,6 @@
 #include "SDL.h"
 
 #include "util/string_util.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/globals.hpp"
 #include "math/math.hpp"
 #include "pingus/debug.hpp"

Modified: trunk/pingus/src/engine/display/font_description.cpp
===================================================================
--- trunk/pingus/src/engine/display/font_description.cpp        2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/engine/display/font_description.cpp        2009-11-06 
15:44:11 UTC (rev 4056)
@@ -16,7 +16,8 @@
 
 #include "engine/display/font_description.hpp"
 
-#include "pingus/pingus_error.hpp"
+#include <stdexcept>
+
 #include "util/file_reader.hpp"
 
 GlyphDescription::GlyphDescription() :
@@ -57,7 +58,7 @@
 
   if (reader.get_name() != "pingus-font")
     {
-      PingusError::raise("FontDescription: not a pingus-font file");
+      throw std::runtime_error("FontDescription: not a pingus-font file");
     }
   else
     {

Modified: trunk/pingus/src/engine/input/manager.cpp
===================================================================
--- trunk/pingus/src/engine/input/manager.cpp   2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/engine/input/manager.cpp   2009-11-06 15:44:11 UTC (rev 
4056)
@@ -16,10 +16,10 @@
 
 #include "engine/input/manager.hpp"
 
+#include <stdexcept>
+
 #include "config.h"
-
 #include "util/string_util.hpp"
-#include "pingus/pingus_error.hpp"
 #include "util/pathname.hpp"
 #include "pingus/path_manager.hpp"
 #include "engine/input/sdl_driver.hpp"
@@ -103,7 +103,7 @@
 
   if (reader.get_name() != "pingus-controller")
   {
-    PingusError::raise("Controller: invalid config file '" + filename.str() + 
"'");
+    throw std::runtime_error("Controller: invalid config file '" + 
filename.str() + "'");
   }
   else
   {
@@ -185,7 +185,7 @@
       }
       else
       {
-        PingusError::raise(std::string("Manager: Unkown Element in Controller 
Config: ") 
+        throw std::runtime_error(std::string("Manager: Unkown Element in 
Controller Config: ") 
                            + i->get_name());
       }
     }

Modified: trunk/pingus/src/engine/input_old/axes/joystick_axis.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/axes/joystick_axis.cpp    2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/engine/input_old/axes/joystick_axis.cpp    2009-11-06 
15:44:11 UTC (rev 4056)
@@ -26,10 +26,10 @@
 {
 #if 0
   if (id >= CL_Joystick::get_device_count())
-    PingusError::raise("JoystickAxis: Invalid joystick id");
+    throw std::runtime_error("JoystickAxis: Invalid joystick id");
 
   if (axis > CL_Joystick::get_device(id).get_axis_count())
-    PingusError::raise("JoystickAxis: Invalid joystick axis id");
+    throw std::runtime_error("JoystickAxis: Invalid joystick axis id");
 #endif
 
   if (angle < 0)

Modified: trunk/pingus/src/engine/input_old/axis_factory.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/axis_factory.cpp  2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/engine/input_old/axis_factory.cpp  2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -43,7 +43,7 @@
     return multiple_axis(reader);
 
   else
-    PingusError::raise(std::string("Unknown axis type: ") + reader.get_name());
+    throw std::runtime_error(std::string("Unknown axis type: ") + 
reader.get_name());
 
   return 0; // never reached
 }
@@ -52,12 +52,12 @@
 {
   float angle;
   if (!reader.read_float("angle", angle))
-    PingusError::raise("ButtonAxis without angle parameter");
+    throw std::runtime_error("ButtonAxis without angle parameter");
 
   const std::vector<FileReader>& sections = reader.get_sections();
   
   if (sections.size() != 3)
-    PingusError::raise("ButtonAxis isn't <angle><button><button>");
+    throw std::runtime_error("ButtonAxis isn't <angle><button><button>");
 
   Button* button1 = ButtonFactory::create(sections[1]);
   Button* button2 = ButtonFactory::create(sections[2]);
@@ -74,15 +74,15 @@
 {
   float angle;
   if (!reader.read_float("angle", angle))
-    PingusError::raise("JoystickAxis without angle parameter");
+    throw std::runtime_error("JoystickAxis without angle parameter");
 
   int id;
   if (!reader.read_int("id", id))
-    PingusError::raise("JoystickAxis without id parameter");
+    throw std::runtime_error("JoystickAxis without id parameter");
 
   int axis;
   if (!reader.read_int("axis", axis))
-    PingusError::raise("JoystickAxis without axis parameter");
+    throw std::runtime_error("JoystickAxis without axis parameter");
 
   return new JoystickAxis(id, axis, angle);
 }
@@ -97,7 +97,7 @@
     axes.push_back(create(*i));
 
   if (!axes.size())
-    PingusError::raise("MultipleAxis without any axis");
+    throw std::runtime_error("MultipleAxis without any axis");
 
   return new MultipleAxis(axes);
 }

Modified: trunk/pingus/src/engine/input_old/button_factory.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/button_factory.cpp        2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/engine/input_old/button_factory.cpp        2009-11-06 
15:44:11 UTC (rev 4056)
@@ -50,7 +50,7 @@
     return triple_button(reader);
 
   else
-    PingusError::raise(std::string("Unknown button type: ") + 
reader.get_name());
+    throw std::runtime_error(std::string("Unknown button type: ") + 
reader.get_name());
 
   return 0; // never reached
 }
@@ -60,7 +60,7 @@
   const std::vector<FileReader>& sections = reader.get_sections();
   
   if (sections.size() != 2)
-    PingusError::raise("DoubleButton isn't <angle><button><button>");
+    throw std::runtime_error("DoubleButton isn't <angle><button><button>");
 
   Button *button1, *button2;
 
@@ -74,11 +74,11 @@
 {
   int id;
   if (!reader.read_int("id", id))
-    PingusError::raise("JoystickButton without id parameter");
+    throw std::runtime_error("JoystickButton without id parameter");
 
   int button;
   if (!reader.read_int("button", button))
-    PingusError::raise("JoystickButton without button parameter");
+    throw std::runtime_error("JoystickButton without button parameter");
 
   return new JoystickButton(id, button);
 }
@@ -87,7 +87,7 @@
 {
   std::string key;
   if (!reader.read_string("key", key))
-    PingusError::raise("KeyButton without key parameter");
+    throw std::runtime_error("KeyButton without key parameter");
 
   return new KeyButton(KeyButton::string_to_keyid(key));
 }
@@ -96,7 +96,7 @@
 {
   int button;
   if (!reader.read_int("button", button))
-    PingusError::raise("MouseButton without button parameter");
+    throw std::runtime_error("MouseButton without button parameter");
 
   return new MouseButton(button);
 }
@@ -119,7 +119,7 @@
   const std::vector<FileReader>& sections = reader.get_sections();
   
   if (sections.size() != 3)
-    PingusError::raise("DoubleButton isn't <angle><button><button>");
+    throw std::runtime_error("DoubleButton isn't <angle><button><button>");
 
   Button *button1, *button2, *button3;
 

Modified: trunk/pingus/src/engine/input_old/buttons/joystick_button.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/buttons/joystick_button.cpp       
2009-11-06 14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/engine/input_old/buttons/joystick_button.cpp       
2009-11-06 15:44:11 UTC (rev 4056)
@@ -25,10 +25,10 @@
 {
 #if 0
   if (id >= CL_Joystick::get_device_count())
-    PingusError::raise("JoystickButton: Invalid joystick id: " + 
CL_String::to(id));
+    throw std::runtime_error("JoystickButton: Invalid joystick id: " + 
CL_String::to(id));
 
   if (button > CL_Joystick::get_device(id).get_button_count())
-    PingusError::raise("JoystickButton: Invalid joystick button id: " + 
CL_String::to(button));
+    throw std::runtime_error("JoystickButton: Invalid joystick button id: " + 
CL_String::to(button));
 #endif
 }
 

Modified: trunk/pingus/src/engine/input_old/controller.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/controller.cpp    2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/engine/input_old/controller.cpp    2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -54,7 +54,7 @@
   FileReader reader = FileReader::parse(path_manager.complete(configfile));
   if (reader.get_name() != "pingus-controller")
     {
-      PingusError::raise("Controller: invalid config file <" + configfile + 
">");
+      throw std::runtime_error("Controller: invalid config file <" + 
configfile + ">");
     }
   else
     {
@@ -108,7 +108,7 @@
             }
           else
             {
-              PingusError::raise(std::string("Unkown Element in Controller 
Config: ") 
+              throw std::runtime_error(std::string("Unkown Element in 
Controller Config: ") 
                                  + i->get_name());
             }
         }
@@ -215,7 +215,7 @@
       }
       else
       {
-        PingusError::raise(std::string("Wrong Element in Controller Config 
(action-buttons): ") 
+        throw std::runtime_error(std::string("Wrong Element in Controller 
Config (action-buttons): ") 
                            + i->get_name());
       }
       count++;

Modified: trunk/pingus/src/engine/input_old/pointer_factory.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/pointer_factory.cpp       2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/engine/input_old/pointer_factory.cpp       2009-11-06 
15:44:11 UTC (rev 4056)
@@ -38,7 +38,7 @@
     return multiple_pointer(reader);
 
   else
-    PingusError::raise(std::string("Unknown pointer type: ") + 
reader.get_name());
+    throw std::runtime_error(std::string("Unknown pointer type: ") + 
reader.get_name());
 
   return 0; // never reached
 }
@@ -47,7 +47,7 @@
 {
   float speed;
   if (!reader.read_float("speed", speed))
-    PingusError::raise("AxisPointer without speed parameter");
+    throw std::runtime_error("AxisPointer without speed parameter");
 
   std::vector<Axis*> axes;
   

Modified: trunk/pingus/src/engine/input_old/scroller_factory.cpp
===================================================================
--- trunk/pingus/src/engine/input_old/scroller_factory.cpp      2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/engine/input_old/scroller_factory.cpp      2009-11-06 
15:44:11 UTC (rev 4056)
@@ -56,7 +56,7 @@
     return pointer_scroller(reader);
 
   else
-    PingusError::raise(std::string("Unknown scroller type: ") + 
reader.get_name());
+    throw std::runtime_error(std::string("Unknown scroller type: ") + 
reader.get_name());
 
   return 0; // never reached
 }
@@ -66,7 +66,7 @@
 {
   float speed;
   if (!reader.read_float("speed", speed))
-    PingusError::raise("AxisScroller without speed parameter");
+    throw std::runtime_error("AxisScroller without speed parameter");
 
   std::vector<Axis*> axes;
   const std::vector<FileReader>& sections = reader.get_sections();
@@ -82,11 +82,11 @@
 {
   bool invert_x;
   if (!reader.read_bool("invert-x", invert_x))
-    PingusError::raise("InvertedScroller without invert X parameter");
+    throw std::runtime_error("InvertedScroller without invert X parameter");
 
   bool invert_y;
   if (!reader.read_bool("invert-y", invert_y))
-    PingusError::raise("InvertedScroller without invert Y parameter");
+    throw std::runtime_error("InvertedScroller without invert Y parameter");
 
   Scroller* scroller;
   scroller = create(reader);
@@ -99,11 +99,11 @@
 {
   int id;
   if (!reader.read_int("id", id))
-    PingusError::raise("JoystickScroller without id parameter");
+    throw std::runtime_error("JoystickScroller without id parameter");
 
   float speed;
   if (!reader.read_float("speed", speed))
-    PingusError::raise("JoystickScroller without speed parameter");
+    throw std::runtime_error("JoystickScroller without speed parameter");
 
   return new JoystickScroller(id, speed);
 }
@@ -140,7 +140,7 @@
   const std::vector<FileReader>& sections = reader.get_sections();
   
   if (sections.size() != 2)
-    PingusError::raise("ScrollerFactory isn't <pointer><button>");
+    throw std::runtime_error("ScrollerFactory isn't <pointer><button>");
 
   pointer = PointerFactory::create(sections[0]);
   button  = ButtonFactory::create(sections[1]);

Modified: trunk/pingus/src/pingus/collision_map.cpp
===================================================================
--- trunk/pingus/src/pingus/collision_map.cpp   2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/collision_map.cpp   2009-11-06 15:44:11 UTC (rev 
4056)
@@ -17,11 +17,11 @@
 #include "pingus/collision_map.hpp"
 
 #include <iostream>
-#include "SDL.h"
+#include <SDL.h>
+
 #include "engine/display/drawing_context.hpp"
 #include "pingus/globals.hpp"
 #include "pingus/collision_mask.hpp"
-#include "pingus/pingus_error.hpp"
 #include "math/math.hpp"
 #include "pingus/gettext.h"
 #include "engine/display/sprite.hpp"

Modified: trunk/pingus/src/pingus/ground_map.cpp
===================================================================
--- trunk/pingus/src/pingus/ground_map.cpp      2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/ground_map.cpp      2009-11-06 15:44:11 UTC (rev 
4056)
@@ -18,14 +18,15 @@
 
 #include <stdio.h>
 #include <iostream>
+#include <stdexcept>
+#include <SDL.h>
+
+#include "engine/display/blitter.hpp"
 #include "engine/display/scene_context.hpp"
-#include "pingus/pingus_error.hpp"
-#include "engine/display/blitter.hpp"
-#include "pingus/pingus_level.hpp"
 #include "gettext.h"
+#include "math/math.hpp"
 #include "pingus/collision_map.hpp"
-#include "math/math.hpp"
-#include "SDL.h"
+#include "pingus/pingus_level.hpp"
 
 class MapTile
 {
@@ -207,7 +208,7 @@
 {
   if (sprovider.get_surface()->format->BitsPerPixel != 8)
     {
-      PingusError::raise(std::string("SpotMap::put_alpha_surface: Image has 
wrong color depth: " 
+      throw std::runtime_error(std::string("SpotMap::put_alpha_surface: Image 
has wrong color depth: " 
                                      + 
sprovider.get_surface()->format->BitsPerPixel));
     }
 

Modified: trunk/pingus/src/pingus/levelset.cpp
===================================================================
--- trunk/pingus/src/pingus/levelset.cpp        2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/levelset.cpp        2009-11-06 15:44:11 UTC (rev 
4056)
@@ -17,12 +17,13 @@
 #include "pingus/levelset.hpp"
 
 #include <iostream>
-#include "pingus/pingus_error.hpp"
-#include "util/file_reader.hpp"
+#include <stdexcept>
+
+#include "math/math.hpp"
 #include "pingus/plf_res_mgr.hpp"
+#include "pingus/resource.hpp"
 #include "pingus/savegame_manager.hpp"
-#include "pingus/resource.hpp"
-#include "math/math.hpp"
+#include "util/file_reader.hpp"
 
 Levelset::Levelset(const Pathname& pathname) :
   title(),
@@ -34,7 +35,7 @@
   FileReader reader = FileReader::parse(pathname);
   if (reader.get_name() != "pingus-levelset")
   {
-    PingusError::raise("Error: " + pathname.str() + ": not a 'pingus-levelset' 
file");
+    throw std::runtime_error("Error: " + pathname.str() + ": not a 
'pingus-levelset' file");
   }
   else
   {

Modified: trunk/pingus/src/pingus/pingus_demo.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_demo.cpp     2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/pingus_demo.cpp     2009-11-06 15:44:11 UTC (rev 
4056)
@@ -19,11 +19,10 @@
 #include <stdexcept>
 #include <fstream>
 
-#include "util/pathname.hpp"
-#include "util/file_reader.hpp"
-#include "pingus/server_event.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/pingu_enums.hpp"
+#include "pingus/server_event.hpp"
+#include "util/file_reader.hpp"
+#include "util/pathname.hpp"
 
 PingusDemo::PingusDemo(const Pathname& pathname) :
   levelname(),
@@ -34,7 +33,7 @@
 
   if (lines.empty())
     {
-      PingusError::raise("'" + pathname.str() + "', demo file is empty");
+      throw std::runtime_error("'" + pathname.str() + "', demo file is empty");
     }
   else
     {
@@ -42,7 +41,7 @@
         {
           if (!lines.front().read_string("name", levelname))
             {
-              PingusError::raise("(level (name ...)) entry missing in demo 
file '" + pathname.str() + "'");
+              throw std::runtime_error("(level (name ...)) entry missing in 
demo file '" + pathname.str() + "'");
             }
 
           lines.front().read_string("checksum", checksum);

Deleted: trunk/pingus/src/pingus/pingus_error.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_error.cpp    2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/pingus_error.cpp    2009-11-06 15:44:11 UTC (rev 
4056)
@@ -1,50 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#include "pingus/pingus_error.hpp"
-
-#include "gettext.h"
-
-
-PingusError::PingusError (const std::string& mes) 
-  : message("PingusError: " + mes)
-{
-}
-
-PingusError::~PingusError() throw()
-{
-}
-
-void
-PingusError::raise (const std::string& msg)
-{
-  throw PingusError(msg);
-}
-
-const std::string&
-PingusError::get_message () const
-{
-  return message;
-}
-
-const char* 
-PingusError::what() const throw()
-{
-  return message.c_str(); 
-}
-
-
-/* EOF */

Deleted: trunk/pingus/src/pingus/pingus_error.hpp
===================================================================
--- trunk/pingus/src/pingus/pingus_error.hpp    2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/pingus_error.hpp    2009-11-06 15:44:11 UTC (rev 
4056)
@@ -1,44 +0,0 @@
-//  Pingus - A free Lemmings clone
-//  Copyright (C) 1999 Ingo Ruhnke <address@hidden>
-//
-//  This program is free software: you can redistribute it and/or modify
-//  it under the terms of the GNU General Public License as published by
-//  the Free Software Foundation, either version 3 of the License, or
-//  (at your option) any later version.
-//  
-//  This program is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//  GNU General Public License for more details.
-//  
-//  You should have received a copy of the GNU General Public License
-//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-#ifndef HEADER_PINGUS_PINGUS_PINGUS_ERROR_HPP
-#define HEADER_PINGUS_PINGUS_PINGUS_ERROR_HPP
-
-#include "pingus/pingus.hpp"
-#include <string>
-#include <exception>
-
-
-/** A PingusError is thrown in situation where an error occured due to
-    invalid user input, file not found events or similar stuff. */
-class PingusError : public std::exception
-{
-protected:
-  std::string message;
-public:
-  PingusError(const std::string& mes);
-  ~PingusError() throw();
-
-  const std::string& get_message () const;
-  const char* what() const throw();
-
-  static void raise (const std::string& msg);
-};
-
-
-#endif
-
-/* EOF */

Modified: trunk/pingus/src/pingus/pingus_level.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_level.cpp    2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/pingus_level.cpp    2009-11-06 15:44:11 UTC (rev 
4056)
@@ -17,9 +17,9 @@
 #include "pingus/pingus_level.hpp"
 
 #include <iostream>
+#include <stdexcept>
 
 #include "util/file_reader.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/pingus_level_impl.hpp"
 #include "pingus/globals.hpp"
 #include "util/pathname.hpp"
@@ -52,7 +52,7 @@
 
   if (reader.get_name() != "pingus-level")
     {
-      PingusError::raise("Error: " + pathname.str() + ": not a 'pingus-level' 
file");
+      throw std::runtime_error("Error: " + pathname.str() + ": not a 
'pingus-level' file");
     }
   else
     {
@@ -65,7 +65,7 @@
       FileReader head;
       if (!reader.read_section("head", head))
         {
-          PingusError::raise("Error: (head) section not found in '" + 
pathname.str() + "'");
+          throw std::runtime_error("Error: (head) section not found in '" + 
pathname.str() + "'");
         }
       else
         {
@@ -97,7 +97,7 @@
             }
           else
             {
-              PingusError::raise("Error: (pingus-level head actions) not found 
in '" + pathname.str() + "'"); 
+              throw std::runtime_error("Error: (pingus-level head actions) not 
found in '" + pathname.str() + "'"); 
             }
         }
       

Modified: trunk/pingus/src/pingus/pingus_main.cpp
===================================================================
--- trunk/pingus/src/pingus/pingus_main.cpp     2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/pingus_main.cpp     2009-11-06 15:44:11 UTC (rev 
4056)
@@ -63,7 +63,6 @@
 #include "pingus/path_manager.hpp"
 #include "pingus/globals.hpp"
 #include "util/system.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/fps_counter.hpp"
 #include "pingus/plf_res_mgr.hpp"
 #include "pingus/screens/game_session.hpp"
@@ -716,26 +715,22 @@
   perr.add(std::cout);
 
   try
-    {
-      parse_args(argc, argv);
-      init_path_finder();
-      read_rc_file();
-      apply_args();
-
-      print_greeting_message();
-
-      init_sdl();
-      init_pingus();
-
-      // start and run the actual game
-      start_game();
-    }
-
-  catch (const PingusError& err) {
-    std::cout << _("Error caught from Pingus: ") << err.get_message () << 
std::endl;
+  {
+    parse_args(argc, argv);
+    init_path_finder();
+    read_rc_file();
+    apply_args();
+    
+    print_greeting_message();
+    
+    init_sdl();
+    init_pingus();
+    
+    // start and run the actual game
+    start_game();
   }
-
-  catch (const std::bad_alloc&) {
+  catch (const std::bad_alloc&) 
+  {
     std::cout << _("Pingus: Out of memory!") << std::endl;
   }
 

Modified: trunk/pingus/src/pingus/res_descriptor.cpp
===================================================================
--- trunk/pingus/src/pingus/res_descriptor.cpp  2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/res_descriptor.cpp  2009-11-06 15:44:11 UTC (rev 
4056)
@@ -18,9 +18,7 @@
 
 #include <assert.h>
 #include <iostream>
-#include "pingus/pingus_error.hpp"
 
-
 /*
    uri -> file:///home/ingo/.pingus/images/...
    uri -> resource://core/result/ok

Modified: trunk/pingus/src/pingus/savegame_manager.cpp
===================================================================
--- trunk/pingus/src/pingus/savegame_manager.cpp        2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/savegame_manager.cpp        2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -20,7 +20,6 @@
 #include <fstream>
 
 #include "util/system.hpp"
-#include "pingus/pingus_error.hpp"
 #include "util/sexpr_file_reader.hpp"
 #include "util/sexpr_file_writer.hpp"
 #include "lisp/lisp.hpp"

Modified: trunk/pingus/src/pingus/server_event.cpp
===================================================================
--- trunk/pingus/src/pingus/server_event.cpp    2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/server_event.cpp    2009-11-06 15:44:11 UTC (rev 
4056)
@@ -21,7 +21,6 @@
 #include <boost/format.hpp>
 
 #include "math/math.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/server.hpp"
 #include "pingus/world.hpp"
 #include "pingus/pingu_holder.hpp"
@@ -80,7 +79,7 @@
     }
   else
     {
-      PingusError::raise(std::string("ServerEvent: Parse error: Unknown event: 
")
+      throw std::runtime_error(std::string("ServerEvent: Parse error: Unknown 
event: ")
                         + reader.get_name());
     }
 }

Modified: trunk/pingus/src/pingus/stat_manager.cpp
===================================================================
--- trunk/pingus/src/pingus/stat_manager.cpp    2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/stat_manager.cpp    2009-11-06 15:44:11 UTC (rev 
4056)
@@ -21,7 +21,6 @@
 
 #include "lisp/lisp.hpp"
 #include "lisp/parser.hpp"
-#include "pingus/pingus_error.hpp"
 #include "util/sexpr_file_reader.hpp"
 #include "util/sexpr_file_writer.hpp"
 #include "util/string_util.hpp"

Modified: trunk/pingus/src/pingus/state_sprite.cpp
===================================================================
--- trunk/pingus/src/pingus/state_sprite.cpp    2009-11-06 14:04:47 UTC (rev 
4055)
+++ trunk/pingus/src/pingus/state_sprite.cpp    2009-11-06 15:44:11 UTC (rev 
4056)
@@ -16,10 +16,10 @@
 
 #include "pingus/state_sprite.hpp"
 
+#include <stdexcept>
+
 #include "pingus/resource.hpp"
-#include "pingus/pingus_error.hpp"
 
-
 StateSprite::StateSprite() :
   sprites()
 {
@@ -60,9 +60,8 @@
     }
   else
     {
-      throw PingusError("StateSprite error");
+      throw std::runtime_error("StateSprite error");
     }
 }
 
-
 /* EOF */

Modified: trunk/pingus/src/pingus/worldmap/dot_factory.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/dot_factory.cpp    2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/worldmap/dot_factory.cpp    2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -16,7 +16,8 @@
 
 #include "pingus/worldmap/dot_factory.hpp"
 
-#include "pingus/pingus_error.hpp"
+#include <stdexcept>
+
 #include "pingus/worldmap/level_dot.hpp"
 
 namespace WorldmapNS {
@@ -30,7 +31,7 @@
     }
   else if (reader.get_name() == "tubedot")
     {
-      PingusError::raise("DotFactory: unknown tag: ");
+      throw std::runtime_error("DotFactory: unknown tag: ");
     }
   return 0;
 }

Modified: trunk/pingus/src/pingus/worldmap/drawable.hpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/drawable.hpp       2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/worldmap/drawable.hpp       2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -17,7 +17,6 @@
 #ifndef HEADER_PINGUS_PINGUS_WORLDMAP_DRAWABLE_HPP
 #define HEADER_PINGUS_PINGUS_WORLDMAP_DRAWABLE_HPP
 
-#include "pingus/pingus_error.hpp"
 #include "util/file_reader.hpp"
 
 class DrawingContext;

Modified: trunk/pingus/src/pingus/worldmap/drawable_factory.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/drawable_factory.cpp       2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/pingus/worldmap/drawable_factory.cpp       2009-11-06 
15:44:11 UTC (rev 4056)
@@ -17,6 +17,7 @@
 #include "pingus/worldmap/drawable_factory.hpp"
 
 #include <iostream>
+
 #include "pingus/worldmap/sprite_drawable.hpp"
 #include "pingus/worldmap/sprite_drawable.hpp"
 

Modified: trunk/pingus/src/pingus/worldmap/path_graph.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/path_graph.cpp     2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/worldmap/path_graph.cpp     2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -17,10 +17,10 @@
 #include "pingus/worldmap/path_graph.hpp"
 
 #include <iostream>
+#include <stdexcept>
 
 #include "math/math.hpp"
 #include "util/file_reader.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/worldmap/dot.hpp"
 #include "pingus/worldmap/dot_factory.hpp"
 #include "pingus/worldmap/worldmap.hpp"
@@ -156,7 +156,7 @@
     }
     else
     {
-      PingusError::raise("PathGraph: unhandled: ");
+      throw std::runtime_error("PathGraph: unhandled: ");
     }
   }
 }

Modified: trunk/pingus/src/pingus/worldmap/pingus_worldmap.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/pingus_worldmap.cpp        2009-11-06 
14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/pingus/worldmap/pingus_worldmap.cpp        2009-11-06 
15:44:11 UTC (rev 4056)
@@ -17,7 +17,8 @@
 #include "pingus/worldmap/pingus_worldmap.hpp"
 
 #include <string>
-#include "pingus/pingus_error.hpp"
+#include <stdexcept>
+
 #include "util/file_reader.hpp"
 #include "pingus/worldmap/drawable_factory.hpp"
 
@@ -83,7 +84,7 @@
     {
       if (!reader.read_section("graph", impl->path_graph))
         {
-          PingusError::raise("Worldmap: " + impl->filename + " is missed 
'graph' section");
+          throw std::runtime_error("Worldmap: " + impl->filename + " is missed 
'graph' section");
         }
 
       impl->objects = reader.read_section("objects").get_sections();
@@ -95,7 +96,7 @@
     }
   else
     {
-      PingusError::raise("Worldmap:" + impl->filename + ": not a Worldmap 
file");
+      throw std::runtime_error("Worldmap:" + impl->filename + ": not a 
Worldmap file");
     }
 }
 

Modified: trunk/pingus/src/pingus/worldmap/worldmap.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/worldmap.cpp       2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/worldmap/worldmap.cpp       2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -27,7 +27,6 @@
 #include "pingus/resource.hpp"
 #include "pingus/globals.hpp"
 #include "engine/sound/sound.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/gettext.h"
 #include "pingus/globals.hpp"
 #include "util/sexpr_file_reader.hpp"

Modified: trunk/pingus/src/pingus/worldmap/worldmap_story.cpp
===================================================================
--- trunk/pingus/src/pingus/worldmap/worldmap_story.cpp 2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/worldmap/worldmap_story.cpp 2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -18,13 +18,14 @@
 
 #include <algorithm>
 #include <vector>
+#include <stdexcept>
+
+#include "pingus/fonts.hpp"
+#include "pingus/gettext.h"
+#include "pingus/res_descriptor.hpp"
 #include "pingus/screens/story_screen.hpp"
+#include "pingus/string_format.hpp"
 #include "util/file_reader.hpp"
-#include "pingus/res_descriptor.hpp"
-#include "pingus/pingus_error.hpp"
-#include "pingus/string_format.hpp"
-#include "pingus/fonts.hpp"
-#include "pingus/gettext.h"
 
 namespace WorldmapNS {
 
@@ -58,7 +59,7 @@
   std::reverse(pages.begin(), pages.end());
 
   if (pages.empty())
-    PingusError::raise("WorldmapStory: Worldmap does not include a valid 
story");
+    throw std::runtime_error("WorldmapStory: Worldmap does not include a valid 
story");
 }
 
 } // namespace WorldmapNS

Modified: trunk/pingus/src/pingus/worldobj_factory.cpp
===================================================================
--- trunk/pingus/src/pingus/worldobj_factory.cpp        2009-11-06 14:04:47 UTC 
(rev 4055)
+++ trunk/pingus/src/pingus/worldobj_factory.cpp        2009-11-06 15:44:11 UTC 
(rev 4056)
@@ -17,7 +17,7 @@
 #include "pingus/worldobj_factory.hpp"
 
 #include <iostream>
-#include "pingus/pingus_error.hpp"
+#include <stdexcept>
 
 #include "pingus/worldobjs/conveyor_belt.hpp"
 #include "pingus/worldobjs/entrance.hpp"
@@ -153,7 +153,7 @@
   std::map<std::string, WorldObjAbstractFactory*>::iterator it = 
factories.find(reader.get_name());
 
   if (it == factories.end())
-    PingusError::raise("WorldObjFactory: Invalid id: '" + reader.get_name() + 
"'");
+    throw std::runtime_error("WorldObjFactory: Invalid id: '" + 
reader.get_name() + "'");
   else
     return it->second->create(reader);
 

Modified: trunk/pingus/src/util/system.cpp
===================================================================
--- trunk/pingus/src/util/system.cpp    2009-11-06 14:04:47 UTC (rev 4055)
+++ trunk/pingus/src/util/system.cpp    2009-11-06 15:44:11 UTC (rev 4056)
@@ -16,9 +16,13 @@
 
 #include "util/system.hpp"
 
+#include <config.h>
+#include <iostream>
+#include <locale.h>
+#include <sstream>
+#include <stdexcept>
 #include <stdio.h>
 #include <stdlib.h>
-#include <locale.h>
 
 #ifndef WIN32
 #  include <dirent.h>
@@ -40,12 +44,7 @@
 #define F_OK   0
 #endif
 
-#include <config.h>
-#include <iostream>
-#include <sstream>
-
 #include "util/pathname.hpp"
-#include "pingus/pingus_error.hpp"
 #include "pingus/globals.hpp"
 #include "util/string_util.hpp"
 #include "pingus/gettext.h"
@@ -181,7 +180,7 @@
     {
       if (mkdir(directory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | 
S_IXGRP) != 0)
        {
-         throw PingusError("System::create_dir: " + directory + ": " + 
strerror(errno));
+         throw std::runtime_error("System::create_dir: " + directory + ": " + 
strerror(errno));
        }
       else
        {
@@ -197,12 +196,12 @@
         }
       else if (dwError == ERROR_PATH_NOT_FOUND)
         {
-          throw PingusError("CreateDirectory: " + directory +
+          throw std::runtime_error("CreateDirectory: " + directory +
             ": One or more intermediate directories do not exist; this 
function will only create the final directory in the path.");
         }
       else
         {
-          throw PingusError("CreateDirectory: " + directory + ": failed with 
error " + StringUtil::to_string(dwError));
+          throw std::runtime_error("CreateDirectory: " + directory + ": failed 
with error " + StringUtil::to_string(dwError));
         }
     }
   else
@@ -240,7 +239,7 @@
     }
   else
     {
-      throw PingusError("Environment variable $HOME not set, fix that and 
start again.");
+      throw std::runtime_error("Environment variable $HOME not set, fix that 
and start again.");
     }
 #endif
 }
@@ -387,7 +386,7 @@
 
       if (bytes_read != 4096 && !feof(in))
        {
-         throw PingusError("System:checksum: file read error");
+         throw std::runtime_error("System:checksum: file read error");
        }
 
       for (size_t i=0; i < bytes_read; ++i)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]