pingus-cvs
[Top][All Lists]
Advanced

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

[Pingus-CVS] CVS: Games/Pingus/src globals.hxx, 1.18, 1.18.2.1 pingus_er


From: Ingo Ruhnke
Subject: [Pingus-CVS] CVS: Games/Pingus/src globals.hxx, 1.18, 1.18.2.1 pingus_error.cxx, 1.10, 1.10.2.1 pingus_error.hxx, 1.8, 1.8.2.1 system.cxx, 1.21, 1.21.2.1 system.hxx, 1.10, 1.10.2.1
Date: Sat, 01 Nov 2003 22:19:41 +0100

Update of /var/lib/cvs/Games/Pingus/src
In directory dark:/tmp/cvs-serv24504

Modified Files:
      Tag: pingus_0_6
        globals.hxx pingus_error.cxx pingus_error.hxx system.cxx 
        system.hxx 
Log Message:
- cleaned up exceptions a bit
- fixed missing error msg at startup

Index: globals.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/globals.hxx,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -d -r1.18 -r1.18.2.1
--- globals.hxx 16 Aug 2003 20:51:28 -0000      1.18
+++ globals.hxx 1 Nov 2003 21:19:39 -0000       1.18.2.1
@@ -67,20 +67,21 @@
 extern int         min_frame_skip;
 extern int         max_frame_skip;
 
-enum { PINGUS_DEBUG_ACTIONS    = (1 << 0),
-       PINGUS_DEBUG_SOUND      = (1 << 1),
-       PINGUS_DEBUG_GAMETIME   = (1 << 2),
-       PINGUS_DEBUG_TILES      = (1 << 3),
-       PINGUS_DEBUG_LOADING    = (1 << 4),
-       PINGUS_DEBUG_EDITOR     = (1 << 5),
-       PINGUS_DEBUG_BLITTER    = (1 << 6),
-       PINGUS_DEBUG_TRANSLATOR = (1 << 7),
-       PINGUS_DEBUG_RESOURCES  = (1 << 8),
-       PINGUS_DEBUG_GUI        = (1 << 9),
-       PINGUS_DEBUG_INPUT      = (1 << 10),
-       PINGUS_DEBUG_WORLDMAP   = (1 << 11),
-       PINGUS_DEBUG_PATHMGR    = (1 << 12),
-       PINGUS_DEBUG_ALL        = (~0)
+enum { PINGUS_DEBUG_ACTIONS     = (1 << 0),
+       PINGUS_DEBUG_SOUND       = (1 << 1),
+       PINGUS_DEBUG_GAMETIME    = (1 << 2),
+       PINGUS_DEBUG_TILES       = (1 << 3),
+       PINGUS_DEBUG_LOADING     = (1 << 4),
+       PINGUS_DEBUG_EDITOR      = (1 << 5),
+       PINGUS_DEBUG_BLITTER     = (1 << 6),
+       PINGUS_DEBUG_TRANSLATOR  = (1 << 7),
+       PINGUS_DEBUG_RESOURCES   = (1 << 8),
+       PINGUS_DEBUG_GUI         = (1 << 9),
+       PINGUS_DEBUG_INPUT       = (1 << 10),
+       PINGUS_DEBUG_WORLDMAP    = (1 << 11),
+       PINGUS_DEBUG_PATHMGR     = (1 << 12),
+       PINGUS_DEBUG_DIRECTORIES = (1 << 13),
+       PINGUS_DEBUG_ALL         = (~0)
      };
 
 

Index: pingus_error.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/pingus_error.cxx,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- pingus_error.cxx    24 Apr 2003 15:18:19 -0000      1.10
+++ pingus_error.cxx    1 Nov 2003 21:19:39 -0000       1.10.2.1
@@ -20,76 +20,13 @@
 #include "pingus_error.hxx"
 #include "gettext.h"
 
-PingusException::PingusException (const std::string& mes) : message(mes)
-{
-}
-
-PingusException::~PingusException ()
-{
-}
-
-PingusException::PingusException (const PingusException& old) : 
message(old.message)
-{
-}
-
-PingusException&
-PingusException::operator= (const PingusException& old)
-{
-  if (this != &old)
-    message = old.message;
-
-  return *this;
-}
-
-
-PingusBug::PingusBug (const std::string& mes) : PingusException("PingusBug: " 
+ mes)
-{
-}
-
-PingusBug::PingusBug (const PingusBug& old) : PingusException(old)
-{
-}
-
-PingusBug&
-PingusBug::operator= (const PingusBug& old)
-{
-  if (this == &old)
-    return *this;
-
-  PingusException::operator=(old);
-
-  return *this;
-}
-
-void
-PingusBug::raise (const std::string& msg)
-{
-  throw PingusBug(msg);
-}
-
-const std::string&
-PingusBug::get_message () const
-{
-  return message;
-}
-
-PingusError::PingusError (const std::string& mes) : 
PingusException("PingusError: " + mes)
-{
-}
-
-PingusError::PingusError (const PingusError& old) : PingusException(old)
+PingusError::PingusError (const std::string& mes) 
+  : message("PingusError: " + mes)
 {
 }
 
-PingusError&
-PingusError::operator= (const PingusError& old)
+PingusError::~PingusError() throw()
 {
-  if (this == &old)
-    return *this;
-
-  PingusException::operator=(old);
-
-  return *this;
 }
 
 void
@@ -104,4 +41,10 @@
   return message;
 }
 
+const char* 
+PingusError::what() const throw()
+{
+  return message.c_str(); 
+}
+
 /* EOF */

Index: pingus_error.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/pingus_error.hxx,v
retrieving revision 1.8
retrieving revision 1.8.2.1
diff -u -d -r1.8 -r1.8.2.1
--- pingus_error.hxx    19 Apr 2003 10:23:17 -0000      1.8
+++ pingus_error.hxx    1 Nov 2003 21:19:39 -0000       1.8.2.1
@@ -22,49 +22,20 @@
 
 #include "pingus.hxx"
 #include <string>
-
-class PingusException
-{
-protected:
-  std::string message;
-public:
-  PingusException (const std::string& mes);
-  virtual ~PingusException ();
-  virtual const std::string& get_message () const =0;
-
-protected:
-  PingusException (const PingusException& old);
-  PingusException& operator= (const PingusException& old);
-};
-
-/** PingusBug gets thrown on events which are a bug in Pingus, this
-    can be unsupported object types or things that must not happen
-    when the thing is properly working. */
-class PingusBug : public PingusException
-{
-protected:
-  PingusBug (const std::string& mes);
-  PingusBug (const PingusBug& old);
-  PingusBug& operator= (const PingusBug& old);
-
-public:
-  virtual const std::string& get_message () const;
-
-  static void raise (const std::string& msg);
-};
-
+#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 PingusException
+class PingusError : public std::exception
 {
 protected:
-  PingusError (const std::string& mes);
-  PingusError (const PingusError& old);
-  PingusError& operator= (const PingusError& old);
-
+  std::string message;
 public:
-  virtual const std::string& get_message () const;
+  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);
 };

Index: system.cxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/system.cxx,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- system.cxx  13 Aug 2003 13:46:39 -0000      1.21
+++ system.cxx  1 Nov 2003 21:19:39 -0000       1.21.2.1
@@ -36,6 +36,7 @@
 
 #include <iostream>
 
+#include "pingus_error.hxx"
 #include "globals.hxx"
 #include "string_converter.hxx"
 #include "system.hxx"
@@ -182,11 +183,16 @@
 System::create_dir(std::string directory)
 {
 #ifndef WIN32
+  if (pingus_debug_flags & PINGUS_DEBUG_DIRECTORIES)
+    {
+      std::cout << "System::create_dir: " << directory << std::endl;
+    }
+
   if (!exist(directory))
     {
       if (mkdir(directory.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | 
S_IXGRP) != 0)
        {
-         throw Error(directory + ": " + strerror(errno));
+         throw PingusError("System::create_dir: " + directory + ": " + 
strerror(errno));
        }
       else
        {
@@ -262,7 +268,7 @@
     }
   else
     {
-      throw Error(_("Environment variable $HOME not set, fix that and start 
again."));
+      throw PingusError(_("Environment variable $HOME not set, fix that and 
start again."));
     }
 #endif
 }
@@ -432,7 +438,7 @@
 
       if (bytes_read == -1)
        {
-         throw Error ("System:checksum: file read error");
+         throw PingusError("System:checksum: file read error");
        }
 
       for (int i=0; i < bytes_read; ++i)

Index: system.hxx
===================================================================
RCS file: /var/lib/cvs/Games/Pingus/src/system.hxx,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- system.hxx  19 Apr 2003 10:23:17 -0000      1.10
+++ system.hxx  1 Nov 2003 21:19:39 -0000       1.10.2.1
@@ -35,13 +35,6 @@
   static std::string default_email;
   static std::string default_username;
 public:
-  struct Error {
-    std::string message;
-
-    Error (const std::string& str)
-      : message (str) {}
-  };
-
   struct DirectoryEntry
   {
     enum FileType { DE_DIRECTORY, DE_FILE } type;





reply via email to

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