Index: code/branches/pickup2/src/libraries/util/CMakeLists.txt
===================================================================
--- code/branches/pickup2/src/libraries/util/CMakeLists.txt	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/CMakeLists.txt	(revision 6412)
@@ -29,5 +29,4 @@
   CRC32.cc
   ExprParser.cc
-  OutputBuffer.cc
   OutputHandler.cc
   SignalHandler.cc
Index: code/branches/pickup2/src/libraries/util/Clipboard.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Clipboard.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Clipboard.cc	(revision 6412)
@@ -78,5 +78,5 @@
         {
             COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
-            COUT(1) << "       \"" << text << "\"" << std::endl;
+            COUT(1) << "       \"" << text << '"' << std::endl;
         }
         return false;
@@ -94,5 +94,7 @@
             {
                 HANDLE hData = GetClipboardData(CF_TEXT);
-                std::string output = static_cast<char*>(GlobalLock(hData));
+                if (hData == NULL)
+                    return "";
+                std::string output(static_cast<char*>(GlobalLock(hData)));
                 GlobalUnlock(hData);
                 CloseClipboard();
@@ -117,5 +119,5 @@
 namespace orxonox
 {
-    static std::string clipboard = ""; //!< Keeps the text of our internal clipboard
+    static std::string clipboard; //!< Keeps the text of our internal clipboard
 
     /**
Index: code/branches/pickup2/src/libraries/util/Clock.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Clock.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Clock.cc	(revision 6412)
@@ -34,9 +34,7 @@
     Clock::Clock()
         : timer_(new Ogre::Timer())
-        , storedTime_(0)
         , tickTime_(0)
         , tickDt_(0)
         , tickDtFloat_(0.0f)
-        , lastTimersTime_(0)
     {
     }
@@ -46,28 +44,24 @@
         delete timer_;
     }
-    
+
+    /**
+    @remarks
+        Mind the types! Ogre::Timer::getMicroseconds() will return an unsigned
+        long, which will eventually overflow. But if you use the subtraction of
+        the current time minus the last time the timer gave us and sum these up to
+        a 64 bit integer, we get the desired result.
+        Also mind that we don't have to store the last timer's time as unsigned long
+        as well because (unsigned long)tickTime_ will do exactly that.
+    */
     void Clock::capture()
     {
-        unsigned long timersTime = timer_->getMicroseconds();
-        tickTime_ = storedTime_ + timersTime;
-        tickDt_ = timersTime - lastTimersTime_;
+        tickDt_ = timer_->getMicroseconds() - (unsigned long)tickTime_;
+        tickTime_ += tickDt_;
         tickDtFloat_ = static_cast<float>(tickDt_) / 1000000.0f;
-
-        if (timersTime > 0xFFFFFFFF/4)
-        {
-            // Ogre timer will overflow at 2^32 microseconds if unsigned long is 32 bit
-            storedTime_ += timersTime;
-            lastTimersTime_ = 0;
-            timer_->reset();
-        }
-        else
-        {
-            lastTimersTime_ = timersTime;
-        }
     }
 
     unsigned long long Clock::getRealMicroseconds() const
     {
-        return this->timer_->getMicroseconds() + this->storedTime_;
+        return tickTime_ + (timer_->getMicroseconds() - (unsigned long)tickTime_);
     }
 }
Index: code/branches/pickup2/src/libraries/util/Clock.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Clock.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Clock.h	(revision 6412)
@@ -57,9 +57,7 @@
 
         Ogre::Timer*       timer_;
-        unsigned long long storedTime_;
         unsigned long long tickTime_;
         long               tickDt_;
         float              tickDtFloat_;
-        unsigned long      lastTimersTime_;
     };
 }
Index: code/branches/pickup2/src/libraries/util/Convert.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Convert.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Convert.h	(revision 6412)
@@ -43,5 +43,4 @@
 
 #include "Debug.h"
-#include "StringUtils.h"
 #include "TemplateUtils.h"
 
@@ -336,5 +335,5 @@
         FORCEINLINE static bool convert(std::string* output, const char input)
         {
-            *output = std::string(1, input);
+            *output = input;
             return true;
         }
@@ -345,5 +344,5 @@
         FORCEINLINE static bool convert(std::string* output, const unsigned char input)
         {
-            *output = std::string(1, input);
+            *output = input;
             return true;
         }
@@ -352,7 +351,7 @@
     struct ConverterExplicit<std::string, char>
     {
-        FORCEINLINE static bool convert(char* output, const std::string input)
-        {
-            if (input != "")
+        FORCEINLINE static bool convert(char* output, const std::string& input)
+        {
+            if (!input.empty())
                 *output = input[0];
             else
@@ -364,7 +363,7 @@
     struct ConverterExplicit<std::string, unsigned char>
     {
-        FORCEINLINE static bool convert(unsigned char* output, const std::string input)
-        {
-            if (input != "")
+        FORCEINLINE static bool convert(unsigned char* output, const std::string& input)
+        {
+            if (!input.empty())
                 *output = input[0];
             else
@@ -389,4 +388,8 @@
     };
 
+    // Declarations to avoid StringUtils.h include
+    _UtilExport std::string removeTrailingWhitespaces(const std::string& str);
+    _UtilExport std::string getLowercase(const std::string& str);
+
     // std::string to bool
     template <>
@@ -395,14 +398,14 @@
         static bool convert(bool* output, const std::string& input)
         {
-            std::string stripped = getLowercase(removeTrailingWhitespaces(input));
+            const std::string& stripped = getLowercase(removeTrailingWhitespaces(input));
             if (stripped == "true" || stripped == "on" || stripped == "yes")
             {
-              *output = true;
-              return true;
+                *output = true;
+                return true;
             }
             else if (stripped == "false" || stripped == "off" || stripped == "no")
             {
-              *output = false;
-              return true;
+                *output = false;
+                return true;
             }
 
Index: code/branches/pickup2/src/libraries/util/Debug.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Debug.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Debug.h	(revision 6412)
@@ -21,13 +21,15 @@
  *
  *   Author:
- *      Benjamin Grauer
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
  *   Co-authors:
- *      Fabian 'x3n' Landau
+ *      ...
  *
  */
 
 /**
-    @file
-    @brief Handles different output-levels of errors, warnings, infos and debug information.
+@file
+@brief
+    Handles different output-levels of errors, warnings, infos and debug information.
 
     The COUT(level) macro acts like std::cout, but the output is only performed if the given
@@ -35,7 +37,7 @@
 
     There are two used values in this file:
-     - The hard debug level is used during compiletime. It describes the highest allowed output level.
+     - The hard debug level is used during compile time. It describes the highest allowed output level.
      - The soft debug level is used during runtime and is the maximum of the three configurable
-       output-levels for console, logfile and ingame shell.
+       output-levels for console, log file and in game shell.
 
     The separation between the three devices is done by the OutputHandler.
@@ -50,210 +52,63 @@
      6: Crazy debug information
 
-    @example
+@example
     COUT(0) << "Very important output" << std::endl;
     COUT(1) << "Error: Something went wrong!" << std::endl;
     COUT(2) << "Warning: There might be a problem." << std::endl;
-    COUT(3) << "Info: It's monday" << std::endl;
+    COUT(3) << "Info: It's Monday" << std::endl;
     COUT(4) << "Debug: x is 1.23456" << std::endl;
- */
+*/
 
-#ifndef _Debug_H__
-#define _Debug_H__
+#ifndef _Util_Debug_H__
+#define _Util_Debug_H__
 
 #include "UtilPrereqs.h"
-
 #include "OutputHandler.h"
 
 namespace orxonox
 {
-    /**
-        @brief Returns the soft debug level, stored in the only existing instance of the OutputHandler class, configured in the config-file.
-        @return The soft debug level
-    */
-    inline int getSoftDebugLevel()
+    // Just for convenience
+    using std::endl;
+
+    // Adjust this to discard certain output with level > hardDebugLevel at compile time already
+#ifdef ORXONOX_RELEASE
+    const int hardDebugLevel = OutputLevel::Verbose
+#elif defined(NDEBUG)
+    const int hardDebugLevel = OutputLevel::Verbose;
+#else
+    //! Maximum level for debug output that should be even processed at run time
+    const int hardDebugLevel = OutputLevel::Ultra;
+#endif
+
+    //! This function simply returns 0 and helps to suppress the "statement has no effect" compiler warning
+    inline int debugDummyFunction()
     {
-        return OutputHandler::getSoftDebugLevel();
+        return 0;
     }
-
-    using std::endl;
 }
 
-// DEFINE ERROR MODES
-#define ORX_NONE            0
-#define ORX_ERROR           1
-#define ORX_WARNING         2
-#define ORX_INFO            3
-#define ORX_DEBUG           4
-#define ORX_VERBOSE         5
-#define ORX_ULTRA           6
+/**
+@brief
+    Logs text output: use exactly like std::cout, but specify an output
+    level as argument.
+@details
+    (a > b ? 0 : c << "text") is equivalent to (a > b ? 0 : (c << "text"))
+    where (a > b ? 0 : ) stands for COUT(x). This should explain how
+    this macro magic can possibly even work ;)
+@example
+    COUT(3) << "Some info" << std::endl;
+@note
+    The ? : operator requires both possible results to have the type of
+    the first. This is achieved by the int conversion operator dummy
+    in the OutputHandler.
+*/
+#define COUT(level)                                                    \
+    /*if*/ (level > orxonox::hardDebugLevel) ?                         \
+        orxonox::debugDummyFunction()                                  \
+    /*else*/ :                                                         \
+        /*if*/ (level > orxonox::OutputHandler::getSoftDebugLevel()) ? \
+            orxonox::debugDummyFunction()                              \
+        /*else*/ :                                                     \
+            orxonox::OutputHandler::getOutStream(level)
 
-//definitions
-#define ORX_PRINT_DEBUG_OUTPUT 1
-#define ORX_HARD_DEBUG_LEVEL ORX_VERBOSE
-
-#define COUT_EXEC(x) orxonox::OutputHandler::getOutStream().setOutputLevel(x)
-
-////////////////////////////////////////////////////////
-///  COUT: just prints output as is with std::cout   ///
-////////////////////////////////////////////////////////
-#define COUTORX_NONE    COUT0
-#define COUTORX_ERROR   COUT1
-#define COUTORX_WARNING COUT2
-#define COUTORX_INFO    COUT3
-#define COUTORX_DEBUG   COUT4
-#define COUTORX_VERBOSE COUT5
-#define COUTORX_ULTRA   COUT6
-
-#ifndef COUT
- #if ORX_PRINT_DEBUG_OUTPUT
-  #define COUT(x) \
-   COUT ## x
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
-   #define COUT0 \
-   (orxonox::getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : COUT_EXEC(0)
-  #else
-   #define COUT0 \
-    false ? COUT_EXEC(0) : COUT_EXEC(0)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
-   #define COUT1 \
-    (orxonox::getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : COUT_EXEC(1)
-  #else
-   #define COUT1 \
-    false ? COUT_EXEC(1) : COUT_EXEC(1)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
-   #define COUT2 \
-    (orxonox::getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : COUT_EXEC(2)
-  #else
-   #define COUT2 \
-    false ? COUT_EXEC(2) : COUT_EXEC(2)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
-   #define COUT3 \
-    (orxonox::getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : COUT_EXEC(3)
-  #else
-   #define COUT3 \
-    false ? COUT_EXEC(3) : COUT_EXEC(3)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
-   #define COUT4 \
-    (orxonox::getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : COUT_EXEC(4)
-  #else
-   #define COUT4 \
-    false ? COUT_EXEC(4) : COUT_EXEC(4)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
-   #define COUT5 \
-    (orxonox::getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : COUT_EXEC(5)
-  #else
-   #define COUT5 \
-    false ? COUT_EXEC(5) : COUT_EXEC(5)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
-   #define COUT6 \
-    (orxonox::getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : COUT_EXEC(6)
-  #else
-   #define COUT6 \
-    false ? COUT_EXEC(6) : COUT_EXEC(6)
-  #endif
-
- #else /* if ORX_PRINT_DEBUG_OUTPUT */
-  #define COUT(x) \
-    false ? COUT_EXEC(6) : COUT_EXEC(6)
- #endif /* if ORX_PRINT_DEBUG_OUTPUT */
-
-#endif /* ifndef COUT */
-
-
-/////////////////////////////////////////////////////////////////////
-///  CCOUT: Prints output with std::cout and adds the classname   ///
-/////////////////////////////////////////////////////////////////////
-#define CCOUTORX_NONE    CCOUT0
-#define CCOUTORX_ERROR   CCOUT1
-#define CCOUTORX_WARNING CCOUT2
-#define CCOUTORX_INFO    CCOUT3
-#define CCOUTORX_DEBUG   CCOUT4
-#define CCOUTORX_VERBOSE CCOUT5
-#define CCOUTORX_ULTRA   CCOUT6
-
-#define CCOUT_EXEC(x) \
-  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
-  << this->getIdentifier()->getName() << ": "
-
-#ifndef CCOUT
- #if ORX_PRINT_DEBUG_OUTPUT
-  #define CCOUT(x) \
-   CCOUT ## x
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
-   #define CCOUT0 \
-    (orxonox::getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : CCOUT_EXEC(0)
-  #else
-   #define CCOUT0 \
-    false ? COUT_EXEC(0) : CCOUT_EXEC(0)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
-   #define CCOUT1 \
-    (orxonox::getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : CCOUT_EXEC(1)
-  #else
-   #define CCOUT1 \
-    false ? COUT_EXEC(1) : CCOUT_EXEC(1)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
-   #define CCOUT2 \
-    (orxonox::getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : CCOUT_EXEC(2)
-  #else
-   #define CCOUT2 \
-    false ? COUT_EXEC(2) : CCOUT_EXEC(2)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
-   #define CCOUT3 \
-    (orxonox::getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : CCOUT_EXEC(3)
-  #else
-   #define CCOUT3 \
-    false ? COUT_EXEC(3) : CCOUT_EXEC(3)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
-   #define CCOUT4 \
-    (orxonox::getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : CCOUT_EXEC(4)
-  #else
-   #define CCOUT4 \
-    false ? COUT_EXEC(4) : CCOUT_EXEC(4)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
-   #define CCOUT5 \
-    (orxonox::getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : CCOUT_EXEC(5)
-  #else
-   #define CCOUT5 \
-    false ? COUT_EXEC(5) : CCOUT_EXEC(5)
-  #endif
-
-  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
-   #define CCOUT6 \
-    (orxonox::getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : CCOUT_EXEC(6)
-  #else
-   #define CCOUT6 \
-    false ? COUT_EXEC(6) : CCOUT_EXEC(6)
-  #endif
-
- #else /* if ORX_PRINT_DEBUG_OUTPUT */
-  #define CCOUT(x) \
-   false ? CCOUT_EXEC(6) : CCOUT_EXEC(6)
- #endif /* if ORX_PRINT_DEBUG_OUTPUT */
-
-#endif /* ifndef CCOUT */
-
-#endif /* _Debug_H__ */
+#endif /* _Util_Debug_H__ */
Index: code/branches/pickup2/src/libraries/util/DisplayStringConversions.h
===================================================================
--- code/branches/pickup2/src/libraries/util/DisplayStringConversions.h	(revision 6412)
+++ code/branches/pickup2/src/libraries/util/DisplayStringConversions.h	(revision 6412)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   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 2
+ *   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, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ */
+
+/**
+@file
+@brief
+    std::sring to Ogre::UTFString conversion functions
+*/
+
+#ifndef _DisplayStringConversions_H__
+#define _DisplayStringConversions_H__
+
+#include "UtilPrereqs.h"
+#include <OgreOverlayElement.h>
+
+#if OGRE_UNICODE_SUPPORT
+    #include <OgreUTFString.h>
+
+    namespace orxonox
+    {
+        template <>
+        struct ConverterExplicit<std::string, Ogre::DisplayString>
+        {
+            //! Converts an std::string into an Ogre::UTFString
+            inline static bool convert(Ogre::DisplayString* output, const std::string& input)
+            {
+                Ogre::UTFString::code_point cp;
+                for (unsigned int i = 0; i < input.size(); ++i)
+                {
+                  cp = input[i];
+                  cp &= 0xFF;
+                  output->append(1, cp);
+                }
+                return true;
+            }
+        };
+    }
+#else
+    namespace orxonox
+    {
+        template <>
+        struct ConverterExplicit<std::string, Ogre::DisplayString>
+        {
+            //! Converts an std::string into an Ogre::String
+            inline static bool convert(Ogre::DisplayString* output, const std::string& input)
+            {
+                *output = input;
+                return true;
+            }
+        };
+    }
+#endif
+
+#endif /* _DisplayStringConversions_H__ */
Index: code/branches/pickup2/src/libraries/util/Exception.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Exception.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Exception.cc	(revision 6412)
@@ -49,6 +49,4 @@
         : description_(description)
         , lineNumber_(0)
-        , functionName_("")
-        , filename_("")
     { }
 
@@ -61,5 +59,5 @@
     const std::string& Exception::getFullDescription() const
     {
-        if (fullDescription_ == "")
+        if (fullDescription_.empty())
         {
             std::ostringstream fullDesc;
@@ -67,21 +65,21 @@
             fullDesc << this->getTypeName() << "Exception";
 
-            if (this->filename_ != "")
+            if (!this->filename_.empty())
             {
                 fullDesc << " in " << this->filename_;
                 if (this->lineNumber_)
-                    fullDesc << "(" << this->lineNumber_ << ")";
+                    fullDesc << '(' << this->lineNumber_ << ')';
             }
 
-            if (this->functionName_ != "")
-                fullDesc << " in function '" << this->functionName_ << "'";
+            if (!this->functionName_.empty())
+                fullDesc << " in function '" << this->functionName_ << '\'';
 
             fullDesc << ": ";
-            if (this->description_ != "")
+            if (!this->description_.empty())
                 fullDesc << this->description_;
             else
                 fullDesc << "No description available.";
 
-            this->fullDescription_ = std::string(fullDesc.str());
+            this->fullDescription_ = fullDesc.str();
         }
 
Index: code/branches/pickup2/src/libraries/util/Exception.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Exception.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Exception.h	(revision 6412)
@@ -131,4 +131,5 @@
     CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
     CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
+    CREATE_ORXONOX_EXCEPTION(InitialisationAborted);
     CREATE_ORXONOX_EXCEPTION(NotImplemented);
     CREATE_ORXONOX_EXCEPTION(GameState);
Index: code/branches/pickup2/src/libraries/util/ExprParser.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/ExprParser.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/ExprParser.cc	(revision 6412)
@@ -47,7 +47,18 @@
 namespace orxonox
 {
-    ExprParser::ExprParser(const std::string& str)
+    ExprParser::ExprParser()
     {
         this->failed_ = false;
+        this->variables_["pi"] = 3.1415926535897932;
+        this->variables_["e"] = 2.7182818284590452;
+    }
+
+    void ExprParser::setVariable(const std::string& varname, double value)
+    {
+        this->variables_[varname] = value;
+    }
+
+    void ExprParser::parse(const std::string& str)
+    {
         this->reading_stream = str.c_str();
         if (str.size() == 0 || *reading_stream == '\0')
@@ -343,10 +354,8 @@
             else
             {
-#define SWITCH word
-                CASE_1("pi")
-                    value = 3.1415926535897932;
-                CASE("e")
-                    value = 2.7182818284590452;
-                CASE_ELSE
+                std::map<std::string, double>::const_iterator it = this->variables_.find(word);
+                if (it != this->variables_.end())
+                    value = it->second;
+                else
                 {
                     this->failed_ = true;
@@ -358,5 +367,5 @@
         }
         else if (*reading_stream == 40)
-        {  // expresion in paranthesis
+        {  // expression in parenthesis
             ++reading_stream;
             value = parse_last_argument();
Index: code/branches/pickup2/src/libraries/util/ExprParser.h
===================================================================
--- code/branches/pickup2/src/libraries/util/ExprParser.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/ExprParser.h	(revision 6412)
@@ -36,4 +36,6 @@
 
 #include "UtilPrereqs.h"
+
+#include <map>
 #include <string>
 
@@ -71,8 +73,11 @@
 
 
-        ExprParser(const std::string& str);
+        ExprParser();
+        void parse(const std::string& str);
         const std::string& getRemains() { return  this->remains_; }
         double             getResult()  { return  this->result_; }
         bool               getSuccess() { return !this->failed_; }
+
+        void setVariable(const std::string& varname, double value);
 
     private:
@@ -97,5 +102,5 @@
         double result_;
         std::string remains_;
-
+        std::map<std::string, double> variables_;
     };
 
Index: code/branches/pickup2/src/libraries/util/Math.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/Math.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Math.cc	(revision 6412)
@@ -43,4 +43,5 @@
 namespace orxonox
 {
+#if OGRE_VERSION < 0x010603
     /**
         @brief Function for writing a Radian to a stream.
@@ -51,4 +52,14 @@
         return out;
     }
+
+    /**
+        @brief Function for writing a Degree to a stream.
+    */
+    std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
+    {
+        out << degree.valueDegrees();
+        return out;
+    }
+#endif
 
     /**
@@ -61,13 +72,4 @@
         radian = temp;
         return in;
-    }
-
-    /**
-        @brief Function for writing a Degree to a stream.
-    */
-    std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
-    {
-        out << degree.valueDegrees();
-        return out;
     }
 
@@ -136,8 +138,8 @@
                 return orxonox::Vector2(0, 1);
         }
-        
+
         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
         float sin_value = sqrt( 1 - cos_value*cos_value );
-        
+
         if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
             return orxonox::Vector2( sin_value, cos_value );
@@ -177,5 +179,5 @@
         }
         //float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
-        
+
         float cos_value = clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1);
         float sin_value = sqrt( 1 - cos_value*cos_value );
Index: code/branches/pickup2/src/libraries/util/Math.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Math.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Math.h	(revision 6412)
@@ -59,7 +59,9 @@
 namespace orxonox
 {
+#if OGRE_VERSION < 0x010603
     _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
+    _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
+#endif
     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
-    _UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
     _UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
 
@@ -163,5 +165,5 @@
     template <> inline bool                 zeroise<bool>()                 { return 0; }
     template <> inline void*                zeroise<void*>()                { return 0; }
-    template <> inline std::string          zeroise<std::string>()          { return ""; }
+    template <> inline std::string          zeroise<std::string>()          { return std::string(); }
     template <> inline orxonox::Radian      zeroise<orxonox::Radian>()      { return orxonox::Radian(0.0f); }
     template <> inline orxonox::Degree      zeroise<orxonox::Degree>()      { return orxonox::Degree(0.0f); }
Index: code/branches/pickup2/src/libraries/util/MathConvert.h
===================================================================
--- code/branches/pickup2/src/libraries/util/MathConvert.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/MathConvert.h	(revision 6412)
@@ -53,5 +53,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.x << "," << input.y)
+            if (ostream << input.x << ',' << input.y)
             {
                 (*output) = ostream.str();
@@ -69,5 +69,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.x << "," << input.y << "," << input.z)
+            if (ostream << input.x << ',' << input.y << ',' << input.z)
             {
                 (*output) = ostream.str();
@@ -85,5 +85,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
+            if (ostream << input.x << ',' << input.y << ',' << input.z << ',' << input.w)
             {
                 (*output) = ostream.str();
@@ -101,5 +101,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
+            if (ostream << input.w << ',' << input.x << ',' << input.y << ',' << input.z)
             {
                 (*output) = ostream.str();
@@ -117,5 +117,5 @@
         {
             std::ostringstream ostream;
-            if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
+            if (ostream << input.r << ',' << input.g << ',' << input.b << ',' << input.a)
             {
                 (*output) = ostream.str();
Index: code/branches/pickup2/src/libraries/util/MultiType.h
===================================================================
--- code/branches/pickup2/src/libraries/util/MultiType.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/MultiType.h	(revision 6412)
@@ -232,5 +232,5 @@
 
             virtual void toString(std::ostream& outstream) const = 0;
-            
+
             virtual void importData( uint8_t*& mem )=0;
             virtual void exportData( uint8_t*& mem ) const=0;
@@ -339,5 +339,5 @@
             template <typename T> inline bool isType()                    const { return false; } // Only works for specialized values - see below
             std::string                       getTypename()               const;
-            
+
             /** @brief Saves the value of the MT to a bytestream (pointed at by mem) and increases mem pointer by size of MT */
             inline void                       exportData(uint8_t*& mem) const { assert(sizeof(MT_Type::Value)<=8); *static_cast<uint8_t*>(mem) = this->getType(); mem+=sizeof(uint8_t); this->value_->exportData(mem); }
Index: code/branches/pickup2/src/libraries/util/MultiTypeValue.h
===================================================================
--- code/branches/pickup2/src/libraries/util/MultiTypeValue.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/MultiTypeValue.h	(revision 6412)
@@ -150,5 +150,5 @@
         /** @brief Puts the current value on the stream */
         inline void toString(std::ostream& outstream) const { outstream << this->value_; }
-        
+
         /** @brief loads data from the bytestream (mem) into the MT and increases the bytestream pointer by the size of the data */
         inline void importData( uint8_t*& mem )         { loadAndIncrease( /*(const T&)*/this->value_, mem ); }
@@ -160,5 +160,5 @@
         T value_; //!< The stored value
     };
-    
+
     // Import / Export specialisation
     // ColourValue
Index: code/branches/pickup2/src/libraries/util/OrxAssert.h
===================================================================
--- code/branches/pickup2/src/libraries/util/OrxAssert.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/OrxAssert.h	(revision 6412)
@@ -44,5 +44,5 @@
 #ifndef NDEBUG
 #define OrxAssert(Assertion, ErrorMessage) \
-    Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(1) << ErrorMessage << std::endl); \
+    Assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream(1) << ErrorMessage << std::endl); \
     assert(Assertion)
 #else
Index: code/branches/pickup2/src/libraries/util/OutputBuffer.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputBuffer.cc	(revision 5942)
+++ 	(revision )
@@ -1,127 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   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 2
- *   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, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Implementation of the OutputBuffer.
-*/
-
-#include "OutputBuffer.h"
-
-namespace orxonox
-{
-    /**
-        @brief Adds a new listener to the list.
-        @param listener The new listener
-    */
-    void OutputBuffer::registerListener(OutputBufferListener* listener)
-    {
-        this->listeners_.push_back(listener);
-    }
-
-    /**
-        @brief Removes a listener from the list.
-        @param listener The listener
-    */
-    void OutputBuffer::unregisterListener(OutputBufferListener* listener)
-    {
-        for (std::vector<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
-        {
-            if ((*it) == listener)
-                it = this->listeners_.erase(it);
-            else
-                ++it;
-        }
-    }
-
-    /**
-        @brief Puts a stream manipulator to the stream.
-        @param manipulator The manipulator
-    */
-    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
-    {
-        this->stream_ << manipulator;
-        this->callListeners();
-        return *this;
-    }
-
-    /**
-        @brief Puts a stream manipulator to the stream.
-        @param manipulator The manipulator
-    */
-    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
-    {
-        this->stream_ << manipulator;
-        this->callListeners();
-        return *this;
-    }
-
-    /**
-        @brief Puts a stream manipulator to the stream.
-        @param manipulator The manipulator
-    */
-    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
-    {
-        this->stream_ << manipulator;
-        this->callListeners();
-        return *this;
-    }
-
-    /**
-        @brief Removes the first line from the stream and assigns it to a given string object.
-        @param output The string object to assign the first line
-        @return True if there was at least one line in the stream and this line was successfully assigned
-
-        It's important to know the returned line will be removed from the stream. If there are more than one
-        listener, they have to cooperate to avoid conflicts.
-    */
-    bool OutputBuffer::getLine(std::string* output)
-    {
-        std::getline(this->stream_, *output);
-
-        bool eof = this->stream_.eof();
-        bool fail = this->stream_.fail();
-
-        if (eof)
-            this->stream_.flush();
-
-        if (eof || fail)
-            this->stream_.clear();
-
-        return (!eof && !fail);
-    }
-
-    /**
-        @brief Calls the outputChanged() function of all registered listeners.
-    */
-    void OutputBuffer::callListeners()
-    {
-        for (std::vector<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
-            (*it)->outputChanged();
-    }
-}
Index: code/branches/pickup2/src/libraries/util/OutputBuffer.h
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputBuffer.h	(revision 5942)
+++ 	(revision )
@@ -1,173 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   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 2
- *   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, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-    @file
-    @brief Declaration of the OutputBuffer class.
-
-    The OutputBuffer acts almost like std::ostream. You can put text and other values to the
-    OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd
-    listeners if new text gets assigned.
-    The listeners are then able to retrieve the text line by line.
-
-    It's important to know that getLine actually removes the line from the OutputBuffer, so it's
-    better to only have one "active" listener.
-*/
-
-#ifndef _OutputBuffer_H__
-#define _OutputBuffer_H__
-
-#include "UtilPrereqs.h"
-
-#include <vector>
-#include <sstream>
-
-namespace orxonox
-{
-    /**
-        @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer.
-
-        This class is pure virtual, so an inheriting class has to implement the function on it's own.
-        The function get's called, if an instance of the inheriting class registers as a listener at
-        an OutputBuffer and this buffer changes.
-    */
-    class OutputBufferListener
-    {
-        friend class OutputBuffer;
-
-        public:
-            virtual ~OutputBufferListener() {}
-
-        private:
-            virtual void outputChanged() = 0;
-    };
-
-    /**
-        @brief The OutputBuffer acts almost like std::ostream and stores the assigned text.
-
-        If text gets assigned by using the << operator or another function, the OutputBuffer
-        calls it's listeners, allowing them to retrieve the text line by line.
-
-        It's important to know that getLine actually removes the line from the OutputBuffer, so it's
-        better to only have one "active" listener.
-    */
-    class _UtilExport OutputBuffer
-    {
-        public:
-            OutputBuffer() {}
-            ~OutputBuffer() {}
-
-            /**
-                @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners.
-                @param object The object/value to assign
-            */
-            template <class T>
-            inline OutputBuffer& operator<<(T object)
-            {
-                this->stream_ << object;
-                this->callListeners();
-                return *this;
-            }
-
-            /**
-                @brief Reads the stored text of the other OutputBuffer and calls the listeners.
-                @param object The other OutputBuffer
-            */
-            template <const OutputBuffer&>
-            inline OutputBuffer& operator<<(const OutputBuffer& object)
-            {
-                this->stream_ << object.stream_.rdbuf();
-                this->callListeners();
-                return *this;
-            }
-
-            OutputBuffer& operator<<(std::ostream& (*manipulator)(std::ostream&));
-            OutputBuffer& operator<<(std::ios& (*manipulator)(std::ios&));
-            OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
-
-            /**
-                @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners.
-                @param object The object/value
-            */
-            template <class T>
-            inline void add(T object)
-            {
-                this->stream_ << object;
-                this->callListeners();
-            }
-
-            /**
-                @brief Assigns an object/value and adds std::endl.
-                @param object The object/value
-            */
-            template <class T>
-            inline void addLine(T object)
-            {
-                this->stream_ << object << std::endl;
-                this->callListeners();
-            }
-
-            /**
-                @brief Puts std::endl to the stream and calls the listeners.
-            */
-            inline void newline()
-            {
-                this->stream_ << std::endl;
-                this->callListeners();
-            }
-
-            /**
-                @brief Flushes the stored text (~empties the OutputBuffer).
-            */
-            inline void flush()
-            {
-                this->stream_.flush();
-            }
-
-            bool getLine(std::string* output);
-
-            void registerListener(OutputBufferListener* listener);
-            void unregisterListener(OutputBufferListener* listener);
-
-            /**
-                @brief Returns the internal stringstream object.
-            */
-            inline std::stringstream& getStream()
-            {
-                return this->stream_;
-            }
-
-        private:
-            void callListeners();
-
-            std::stringstream stream_;                     //!< The stringstream that stores the assigned text
-            std::vector<OutputBufferListener*> listeners_; //!< A list of all listeners
-    };
-}
-
-#endif /* _OutputBuffer_H__ */
Index: code/branches/pickup2/src/libraries/util/OutputHandler.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputHandler.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/OutputHandler.cc	(revision 6412)
@@ -23,66 +23,214 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
 
 /**
-    @file
-    @brief Implementation of the OutputHandler class.
+@file
+@brief
+    Definition of classes related to output (logging).
 */
 
 #include "OutputHandler.h"
 
+#include <algorithm>
 #include <ctime>
 #include <cstdlib>
+#include <fstream>
+#include <iostream>
+#include <sstream>
+
+#include "Debug.h"
 
 namespace orxonox
 {
+    //! How the log file shall be named on the filesystem
+    const std::string logFileBaseName_g = "orxonox.log";
+
+    /////////////////////////
+    ///// LogFileWriter /////
+    /////////////////////////
     /**
-        @brief Constructor: Opens the logfile and writes the first line.
-        @param logfilename The name of the logfile
+    @brief
+        Writes the output to the log file.
+    @note
+        As long as the correct log path is not yet known (for pre main code), the
+        LogFileWriter will write to a temporary file in /temp (Unix) or %TEMP% (Windows).
+        As soon as you set the correct path setLogPath the content of the temporary file
+        is read and put into the new file as well.
     */
+    class LogFileWriter : public OutputListener
+    {
+    public:
+        /**
+        @brief
+            Gets temporary log path and starts the log file
+        @param outputHandler
+            This is only required to avoid another call to getInstance (this c'tor was
+            called from getInstance!)
+        */
+        LogFileWriter()
+            : OutputListener(OutputHandler::logFileOutputListenerName_s)
+        {
+            // Get path for a temporary file
+#ifdef ORXONOX_PLATFORM_WINDOWS
+            char* pTempDir = getenv("TEMP");
+            this->logFilename_ = std::string(pTempDir) + '/' + logFileBaseName_g;
+#else
+            this->logFilename_ = std::string("/tmp/") + logFileBaseName_g;
+#endif
+
+            // Get current time
+            time_t rawtime;
+            struct tm* timeinfo;
+            time(&rawtime);
+            timeinfo = localtime(&rawtime);
+
+            this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
+            this->logFile_ << "Started log on " << asctime(timeinfo) << std::endl;
+            this->logFile_.flush();
+
+            this->outputStream_ = &this->logFile_;
+        }
+
+        //! Closes the log file
+        ~LogFileWriter()
+        {
+            this->logFile_ << "Closed log" << std::endl;
+            this->logFile_.close();
+        }
+
+        //! Changes the log path
+        void setLogPath(const std::string& path)
+        {
+            this->logFile_.close();
+            // Read old file into a buffer
+            std::ifstream old(this->logFilename_.c_str());
+            this->logFilename_ = path + logFileBaseName_g;
+            // Open the new file and feed it the content of the old one
+            this->logFile_.open(this->logFilename_.c_str(), std::fstream::out);
+            this->logFile_ << old.rdbuf();
+            this->logFile_.flush();
+            old.close();
+        }
+
+    private:
+        std::ofstream logFile_;     //! File handle for the log file
+        std::string   logFilename_; //! Filename of the log file
+    };
+
+
+    /////////////////////////
+    ///// ConsoleWriter /////
+    /////////////////////////
+    /**
+    @brief
+        Writes the output to std::cout.
+    @note
+        This listener will usually be disable once an actual shell with console is instantiated.
+    */
+    class ConsoleWriter : public OutputListener
+    {
+    public:
+        //! Only assigns the output stream with std::cout
+        ConsoleWriter()
+            : OutputListener("consoleLog")
+        {
+            this->outputStream_ = &std::cout;
+        }
+    };
+
+
+    ///////////////////////////
+    ///// MemoryLogWriter /////
+    ///////////////////////////
+    /**
+    @brief
+        OutputListener that writes all the output piece by piece to an array
+        associated with the corresponding output level.
+    @note
+        Only output below or equal to the current soft debug level is written
+        to minimise huge arrays for the normal run.
+    */
+    class MemoryLogWriter : public OutputListener
+    {
+    public:
+        friend class OutputHandler;
+
+        /**
+        @brief
+            Sets the right soft debug level and registers itself
+        @param outputHandler
+            This is only required to avoid another call to getInstance (this c'tor was
+            called from getInstance!)
+        */
+        MemoryLogWriter()
+            : OutputListener("memoryLog")
+        {
+            this->outputStream_ = &this->buffer_;
+        }
+
+        //! Pushed the just written output to the internal array
+        void outputChanged(int level)
+        {
+            if (!this->buffer_.str().empty())
+            {
+                // Read ostringstream and store it
+                this->output_.push_back(std::make_pair(level, this->buffer_.str()));
+                // Clear content and flags
+                this->buffer_.str(std::string());
+            }
+            this->buffer_.clear();
+        }
+
+    private:
+        std::ostringstream                        buffer_; //! Stream object used to process the output
+        std::vector<std::pair<int, std::string> > output_; //! Vector containing ALL output
+    };
+
+
+    /////////////////////////
+    ///// OutputHandler /////
+    /////////////////////////
+    const std::string OutputHandler::logFileOutputListenerName_s = "logFile";
+          int         OutputHandler::softDebugLevel_s = hardDebugLevel;
+
+    //! Creates the LogFileWriter and the MemoryLogWriter
     OutputHandler::OutputHandler()
-    {
-#ifdef ORXONOX_PLATFORM_WINDOWS
-        char* pTempDir = getenv("TEMP");
-        this->logfilename_ = std::string(pTempDir) + "/orxonox.log";
+        : outputLevel_(OutputLevel::Verbose)
+    {
+#ifdef ORXONOX_RELEASE
+        const OutputLevel::Value defaultLevelConsole = OutputLevel::Error;
+        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Info;
 #else
-        this->logfilename_ = "/tmp/orxonox.log";
+        const OutputLevel::Value defaultLevelConsole = OutputLevel::Info;
+        const OutputLevel::Value defaultLevelLogFile = OutputLevel::Debug;
 #endif
-#ifdef NDEBUG
-        this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 2;
-        this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 1;
-#else
-        this->softDebugLevel_[LD_All] = this->softDebugLevel_[LD_Logfile] = 3;
-        this->softDebugLevel_[LD_Console] = this->softDebugLevel_[LD_Shell] = 2;
-#endif
-
-        this->outputBuffer_ = &this->fallbackBuffer_;
-        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
-
-        time_t rawtime;
-        struct tm* timeinfo;
-        time(&rawtime);
-        timeinfo = localtime(&rawtime);
-
-        this->logfile_ << "Started log on " << asctime(timeinfo) << std::endl;
-        this->logfile_.flush();
-    }
-
-    /**
-        @brief Destructor: Writes the last line to the logfile and closes it.
-    */
+
+        this->logFile_ = new LogFileWriter();
+        // Use default level until we get the configValue from the Core
+        this->logFile_->softDebugLevel_ = defaultLevelLogFile;
+        this->registerOutputListener(this->logFile_);
+
+        this->consoleWriter_ = new ConsoleWriter();
+        this->consoleWriter_->softDebugLevel_ = defaultLevelConsole;
+        this->registerOutputListener(this->consoleWriter_);
+
+        this->output_ = new MemoryLogWriter();
+        // We capture as much input as the listener with the highest level
+        this->output_->softDebugLevel_ = getSoftDebugLevel();
+        this->registerOutputListener(this->output_);
+    }
+
+    //! Destroys the LogFileWriter and the MemoryLogWriter
     OutputHandler::~OutputHandler()
     {
-        this->logfile_ << "Closed log" << std::endl;
-        this->logfile_.close();
-    }
-
-    /**
-        @brief Returns a reference to the only existing instance of the OutputHandler class.
-        @return The instance
-    */
-    OutputHandler& OutputHandler::getOutStream()
+        delete this->logFile_;
+        delete this->consoleWriter_;
+        delete this->output_;
+    }
+
+    OutputHandler& OutputHandler::getInstance()
     {
         static OutputHandler orxout;
@@ -90,142 +238,71 @@
     }
 
-    /**
-        @brief Sets the soft debug level for a given output device.
-        @param device The output device
-        @param level The debug level
-    */
-    void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
-    {
-        OutputHandler::getOutStream().softDebugLevel_[static_cast<unsigned int>(device)] = level;
-    }
-
-    /**
-        @brief Returns the soft debug level for a given output device.
-        @param device The output device
-        @return The debug level
-    */
-    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
-    {
-        return OutputHandler::getOutStream().softDebugLevel_[static_cast<unsigned int>(device)];
-    }
-
-    /**
-        @brief Sets the OutputBuffer, representing the third output stream.
-        @param buffer The OutputBuffer
-    */
-    void OutputHandler::setOutputBuffer(OutputBuffer* buffer)
-    {
-        if (buffer == NULL)
-            this->outputBuffer_ = &this->fallbackBuffer_;
-        else
-        {
-            buffer->getStream() >> this->outputBuffer_->getStream().rdbuf();
-            this->outputBuffer_ = buffer;
-        }
-    }
-
-    /**
-        @brief Sets the path where to create orxonox.log
-        @param Path string with trailing slash
-    */
+    void OutputHandler::registerOutputListener(OutputListener* listener)
+    {
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->name_ == listener->name_)
+            {
+                COUT(2) << "OutputHandler, Warning: Trying to register two listeners with the same name!" << std::endl;
+                return;
+            }
+        }
+        this->listeners_.push_back(listener);
+        // Update global soft debug level
+        this->setSoftDebugLevel(listener->getOutputListenerName(), listener->getSoftDebugLevel());
+    }
+
+    void OutputHandler::unregisterOutputListener(OutputListener* listener)
+    {
+        this->listeners_.remove(listener);
+    }
+
     void OutputHandler::setLogPath(const std::string& path)
     {
-        OutputHandler::getOutStream().logfile_.close();
-        // store old content
-        std::ifstream old;
-        old.open(OutputHandler::getOutStream().logfilename_.c_str());
-        OutputHandler::getOutStream().logfilename_ = path + "orxonox.log";
-        OutputHandler::getOutStream().logfile_.open(OutputHandler::getOutStream().logfilename_.c_str(), std::fstream::out);
-        OutputHandler::getOutStream().logfile_ << old.rdbuf();
-        old.close();
-        OutputHandler::getOutStream().logfile_.flush();
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console and the logfile.
-        @param sb The streambuffer that should be shown in the console
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::streambuf* sb)
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            std::cout << sb;
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            this->logfile_ << sb;
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << sb;
-
-        return *this;
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
-        @param manipulator A function, manipulating the outstream.
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::ostream& (*manipulator)(std::ostream&))
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            manipulator(std::cout);
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            manipulator(this->logfile_);
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << manipulator;
-
-        return *this;
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
-        @param manipulator A function, manipulating the outstream.
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::ios& (*manipulator)(std::ios&))
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            manipulator(std::cout);
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            manipulator(this->logfile_);
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << manipulator;
-
-        return *this;
-    }
-
-    /**
-        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
-        @param manipulator A function, manipulating the outstream.
-        @return A reference to the OutputHandler itself
-    */
-    OutputHandler& OutputHandler::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
-    {
-        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            manipulator(std::cout);
-
-        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
-        {
-            manipulator(this->logfile_);
-            this->logfile_.flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << manipulator;
-
-        return *this;
+        this->logFile_->setLogPath(path);
+    }
+
+    void OutputHandler::disableCout()
+    {
+        this->unregisterOutputListener(this->consoleWriter_);
+    }
+
+    void OutputHandler::enableCout()
+    {
+        this->registerOutputListener(this->consoleWriter_);
+    }
+
+    OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorBegin() const
+    {
+        return this->output_->output_.begin();
+    }
+
+    OutputHandler::OutputVectorIterator OutputHandler::getOutputVectorEnd() const
+    {
+        return this->output_->output_.end();
+    }
+
+    int OutputHandler::getSoftDebugLevel(const std::string& name) const
+    {
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->name_ == name)
+                return (*it)->softDebugLevel_;
+        }
+        return -1;
+    }
+
+    void OutputHandler::setSoftDebugLevel(const std::string& name, int level)
+    {
+        int globalSoftDebugLevel = -1;
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->name_ == name)
+                (*it)->softDebugLevel_ = level;
+            if ((*it)->softDebugLevel_ > globalSoftDebugLevel)
+                globalSoftDebugLevel = (*it)->softDebugLevel_;
+        }
+        // Update global soft debug level
+        OutputHandler::softDebugLevel_s = globalSoftDebugLevel;
     }
 }
Index: code/branches/pickup2/src/libraries/util/OutputHandler.h
===================================================================
--- code/branches/pickup2/src/libraries/util/OutputHandler.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/OutputHandler.h	(revision 6412)
@@ -23,14 +23,12 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
 
 /**
-    @file
-    @brief Definition of the OutputHandler class.
-
-    The OutputHandler acts like std::cout, but output isn't only shown in the console,
-    but also written to the logfile and the ingame shell.
+@file
+@brief
+    Declaration of classes related to output (logging).
 */
 
@@ -40,166 +38,244 @@
 #include "UtilPrereqs.h"
 
-#include <iostream>
-#include <fstream>
+#include <list>
+#include <ostream>
 #include <string>
-
-#include "OutputBuffer.h"
+#include <vector>
+#include <utility>
 
 namespace orxonox
 {
-    //! The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell.
+    /**
+    @brief
+        Denotes different levels of text output (log output)
+
+        0, None   : Very important output
+        1, Error  : Errors
+        2, Warning: Warnings
+        3, Info   : Information
+        4, Debug  : Debug information
+        5, Verbose: More debug information
+        6, Ultra  : Crazy debug information
+    */
+    namespace OutputLevel
+    {
+        enum Value
+        {
+            None    = 0,
+            Error   = 1,
+            Warning = 2,
+            Info    = 3,
+            Debug   = 4,
+            Verbose = 5,
+            Ultra   = 6,
+        };
+    }
+
+    // Forward declarations for classes in the source file
+    class LogFileWriter;
+    class ConsoleWriter;
+    class MemoryLogWriter;
+
+    /**
+    @brief
+        The OutputHandler acts like std::cout, but output isn't only shown in the console.
+
+        You can register your own listener for output by inheriting from OutputListner.
+        And if you need the output previously processed, iterate over it with
+        OutputHandler::getOutputVector[Begin/End].
+        The way to output text is to first set the desired output level with
+        OutputHandler::getOutStream(level) and then use the "<<" operator like with std::cout.
+    */
     class _UtilExport OutputHandler
     {
         public:
-            enum OutputDevice
-            {
-                LD_All = 0,
-                LD_Console = 1,
-                LD_Logfile = 2,
-                LD_Shell = 3
-            };
-
-            static OutputHandler& getOutStream();
-
-            /** @brief Puts some text on the outstream. @param text The text */
+            //! Returns a reference to the only existing instance of the OutputHandler class.
+            static OutputHandler& getInstance();
+
+            //! Sets the output level and returns a stream to be used with "<<"
+            static inline OutputHandler& getOutStream(int level)
+                { return OutputHandler::getInstance().setOutputLevel(level); }
+
+            typedef std::vector<std::pair<int, std::string> >::const_iterator OutputVectorIterator;
+            //! Returns an iterator to the beginning of the all-output vector
+            OutputVectorIterator getOutputVectorBegin() const;
+            //! Returns an iterator to the end of the all-output vector
+            OutputVectorIterator getOutputVectorEnd() const;
+
+            //! Writes to all output devices
             static inline const std::string& log(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts an error on the outstream. @param text The text */
+                { OutputHandler::getOutStream(0).output(text) << std::endl; return text; }
+
+            //! Writes an error message to the output
             static inline const std::string& error(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(1); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts a warning on the outstream. @param text The text */
+                { OutputHandler::getOutStream(1).output(text) << std::endl; return text; }
+
+            //! Writes a warning message to the output
             static inline const std::string& warning(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(2); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts an info on the outstream. @param text The text */
+                { OutputHandler::getOutStream(2).output(text) << std::endl; return text; }
+
+            //! Writes an informational message to the output
             static inline const std::string& info(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(3); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Puts some debug output on the outstream. @param text The text */
+                { OutputHandler::getOutStream(3).output(text) << std::endl; return text; }
+
+            //! Writes a debug message to the output
             static inline const std::string& debug(const std::string& text)
-                { OutputHandler::getOutStream().setOutputLevel(4); OutputHandler::getOutStream().output(text + "\n"); return text; }
-
-            /** @brief Returns a reference to the logfile. @return The logfile */
-            inline std::ofstream& getLogfile()
-                { return this->logfile_; }
-
-            /** @brief Returns a pointer to the OutputBuffer. @return The OutputBuffer */
-            inline OutputBuffer* getOutputBuffer()
-                { return this->outputBuffer_; }
-
-            /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */
+                { OutputHandler::getOutStream(4).output(text) << std::endl; return text; }
+
+            //! Registers an object that receives output via a provided std::ostream
+            void registerOutputListener(OutputListener* listener);
+            //! Unregisters an object that receives output via a provided std::ostream
+            void unregisterOutputListener(OutputListener* listener);
+
+            //! Set the log path once the program has been properly initialised
+            void setLogPath(const std::string& path);
+            //! Disables the std::cout stream for output
+            void disableCout();
+            //! Enables the std::cout stream for output (startup behaviour)
+            void enableCout();
+
+            //! Sets the level of the incoming output and returns the OutputHandler
             inline OutputHandler& setOutputLevel(int level)
                 { this->outputLevel_ = level; return *this; }
 
-            /** @brief Returns the level of the incoming output. @return The level */
+            //! Returns the level of the incoming output
             inline int getOutputLevel() const
                 { return this->outputLevel_; }
 
-            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
-            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
-
-            static void setLogPath(const std::string& path);
-
-            void setOutputBuffer(OutputBuffer* buffer);
-
+            //! Returns the maximum debug level over all registered listeners (devices)
+            static int getSoftDebugLevel() { return softDebugLevel_s; }
+            //! Returns the soft debug level for a device by its name   @return The level or -1 if the listener was not found
+            int  getSoftDebugLevel(const std::string& name) const;
+            //! Sets the soft debug level for a listener by its name   @remarks Only works for registered listeners!
+            void setSoftDebugLevel(const std::string& name, int level);
+
+            /**
+            @brief
+                General template that copes with all output.
+                Required because operator << might be ambiguous.
+                @a output will be streamed into every listener with an appropriate debug level
+            @return
+                Returns a reference to the OutputHandler so you can use it again directly
+            */
             template <class T>
             OutputHandler& output(const T& output);
 
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned char val)      { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(short val)              { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned short val)     { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(int val)                { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned int val)       { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(long val)               { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned long val)      { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(long long val)          { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(unsigned long long val) { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(float val)              { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(double val)             { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(long double val)        { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(const void* val)        { return this->output(val); }
-            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            //! Overloaded << operator, redirects the output to the listeners
             inline OutputHandler& operator<<(bool val)               { return this->output(val); }
 
-            OutputHandler& operator<<(std::streambuf* sb);
-
-            OutputHandler& operator<<(std::ostream& (*manipulator)(std::ostream&));
-            OutputHandler& operator<<(std::ios& (*manipulator)(std::ios&));
-            OutputHandler& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
+            //! Overloaded << operator, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::streambuf* sb)     { return this->output(sb); }
+
+            //! Overloaded << operator, redirect the output of classes with self defined 'operator <<' to the listeners
+            template <class T>
+            inline OutputHandler& operator<<(const T& val)           { return this->output(val); }
+
+            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::ostream&  (*manip)(std::ostream&))  { return this->output(manip); }
+            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::ios&      (*manip)(std::ios&))      { return this->output(manip); }
+            //! Overloaded << operator for std manipulators like std::endl, redirects the output to the listeners
+            inline OutputHandler& operator<<(std::ios_base& (*manip)(std::ios_base&)) { return this->output(manip); }
+
+            //! Dummy operator required by Debug.h for the ternary operator
+            inline operator int() const { return 0; }
+
+            //! Name of the OutputListener that writes to the log file
+            static const std::string logFileOutputListenerName_s;
 
         private:
-            explicit OutputHandler();
-            OutputHandler(const OutputHandler& oh);
-            virtual ~OutputHandler();
-
-            std::ofstream logfile_;              //!< The logfile where the output is logged
-            std::string logfilename_;            //!< The name of the logfile
-            OutputBuffer fallbackBuffer_;        //!< The OutputBuffer that gets used if there is no other OutputBuffer
-            OutputBuffer* outputBuffer_;         //!< The OutputBuffer to put output in (usually used by the Shell)
-            int outputLevel_;                    //!< The level of the incoming output
-            int softDebugLevel_[4];              //!< The soft debug level for each OutputDevice - the configurable maximal output level
+            OutputHandler();
+            ~OutputHandler();
+            OutputHandler(const OutputHandler& rhs); //! Unused and undefined
+
+            std::list<OutputListener*> listeners_;        //!< Array with all registered output listeners
+            int                        outputLevel_;      //!< The level of the incoming output
+            LogFileWriter*             logFile_;          //!< Listener that writes to the log file
+            ConsoleWriter*             consoleWriter_;    //!< Listener for std::cout (just program beginning)
+            MemoryLogWriter*           output_;           //!< Listener that Stores ALL output below the current soft debug level
+            static int                 softDebugLevel_s;  //!< Maximum of all soft debug levels. @note This is only static for faster access
     };
 
     /**
-        @brief Redirects the output to the console and the logfile.
-        @param output The value that should be shown in the console
-        @return A reference to the OutputHandler itself
+    @brief
+        Interface for listening to output.
+    @remarks
+        Remember to register the listener (not done automatically!)
     */
+    class OutputListener
+    {
+        friend class OutputHandler;
+
+    public:
+        OutputListener(const std::string& name)
+            : outputStream_(NULL)
+            , name_(name)
+            , softDebugLevel_(OutputLevel::Info)
+        {}
+        virtual ~OutputListener() {}
+
+        //! Gets called whenever output is put into the stream
+        virtual void outputChanged(int level) {}
+        //! Returns the name of this output listener
+        const std::string& getOutputListenerName() const { return this->name_; }
+        //! Returns the soft debug level of the listener
+        int getSoftDebugLevel() const { return this->softDebugLevel_; }
+        //! Sets the soft debug level of the listener
+        void setSoftDebugLevel(int level)
+        {
+            this->softDebugLevel_ = level;
+            OutputHandler::getInstance().setSoftDebugLevel(this->name_, level);
+        }
+
+    protected:
+        std::ostream*     outputStream_;   //!< Pointer to the associated output stream, can be NULL
+
+    private:
+        const std::string name_;           //!< Name of the listener, constant and unique!
+        int               softDebugLevel_; //!< Current soft debug level that defines what kind of output is written to the stream
+    };
+
     template<class T>
-    OutputHandler& OutputHandler::output(const T& output)
-    {
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
-            std::cout << output;
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+    inline OutputHandler& OutputHandler::output(const T& output)
+    {
+        for (std::list<OutputListener*>::const_iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
         {
-            this->logfile_ << output;
-            this->logfile_.flush();
+            if (this->outputLevel_ <= (*it)->softDebugLevel_ && (*it)->outputStream_ != NULL)
+            {
+                std::ostream& stream = *((*it)->outputStream_);
+                stream << output;
+                stream.flush();
+                (*it)->outputChanged(this->outputLevel_);
+            }
         }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
-            (*this->outputBuffer_) << output;
 
         return *this;
     }
-
-    /**
-        @brief Overloading of the non-member << operator to redirect the output of classes with self defined '<< to std::ostream' operators to the console and the logfile.
-        @param out The OutputHandler itself
-        @param output The class that should be shown in the console
-        @return The OutputHandler itself
-    */
-    template<class T>
-    OutputHandler& operator<<(OutputHandler& out, const T& output)
-    {
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= out.getOutputLevel())
-            std::cout << output;
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= out.getOutputLevel())
-        {
-            out.getLogfile() << output;
-            out.getLogfile().flush();
-        }
-
-        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= out.getOutputLevel())
-            (*out.getOutputBuffer()) << output;
-
-        return out;
-    }
 }
 
Index: code/branches/pickup2/src/libraries/util/Serialise.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Serialise.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Serialise.h	(revision 6412)
@@ -37,17 +37,16 @@
 #include <cstring>
 #include "util/Math.h"
+#include "util/mbool.h"
 
 namespace orxonox{
-    
-// general template declaration
-    
+
     /** @brief returns the size of the variable in a datastream */
-    template <class T> inline uint32_t returnSize( const T& );
+    template <class T> inline uint32_t returnSize( const T& variable );
     /** @brief loads the value of a variable out of the bytestream and increases the mem pointer */
-    template <class T> inline void loadAndIncrease( const T&, uint8_t*& );
+    template <class T> inline void loadAndIncrease( const T& variable, uint8_t*& mem );
     /** @brief saves the value of a variable into the bytestream and increases the mem pointer */
-    template <class T> inline void saveAndIncrease( const T&, uint8_t*& );
+    template <class T> inline void saveAndIncrease( const T& variable, uint8_t*& mem );
     /** @brief checks whether the variable of type T is the same as in the bytestream */
-    template <class T> inline  bool checkEquality( const T&, uint8_t* );
+    template <class T> inline bool checkEquality( const T& variable, uint8_t* mem );
 
 // =================== Template specialisation stuff =============
@@ -203,5 +202,5 @@
         return sizeof(uint32_t);
     }
-    
+
     template <> inline void loadAndIncrease( const unsigned int& variable, uint8_t*& mem )
     {
@@ -376,5 +375,5 @@
         double temp;
         memcpy(&temp, mem, sizeof(uint64_t));
-        *(long double*)( &variable ) = static_cast<const long double>(temp);
+        *(long double*)( &variable ) = static_cast<long double>(temp);
         mem += returnSize( variable );
     }
@@ -471,6 +470,167 @@
         return variable==Degree(*r);
     }
-    
-    
+
+    // =========== Vector2
+
+    template <> inline uint32_t returnSize( const Vector2& variable )
+    {
+        return returnSize( variable.x )+returnSize( variable.y );
+    }
+
+    template <> inline void saveAndIncrease( const Vector2& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Vector2& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+    }
+
+    template <> inline bool checkEquality( const Vector2& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.x, mem) && checkEquality(variable.y, mem+returnSize(variable.x));
+    }
+
+    // =========== Vector3
+
+    template <> inline uint32_t returnSize( const Vector3& variable )
+    {
+        return returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+    }
+
+    template <> inline void saveAndIncrease( const Vector3& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+        saveAndIncrease( variable.z, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Vector3& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+        loadAndIncrease( variable.z, mem );
+    }
+
+    template <> inline bool checkEquality( const Vector3& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.x, mem) && checkEquality(variable.y, mem+returnSize(variable.x)) &&
+            checkEquality(variable.z, mem+returnSize(variable.x)+returnSize(variable.y));
+    }
+
+    // =========== Vector4
+
+    template <> inline uint32_t returnSize( const Vector4& variable )
+    {
+        return returnSize( variable.w )+returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+    }
+
+    template <> inline void saveAndIncrease( const Vector4& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.w, mem );
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+        saveAndIncrease( variable.z, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Vector4& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.w, mem );
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+        loadAndIncrease( variable.z, mem );
+    }
+
+    template <> inline bool checkEquality( const Vector4& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.w, mem) && checkEquality(variable.x, mem+returnSize(variable.w)) &&
+            checkEquality(variable.y, mem+returnSize(variable.w)+returnSize(variable.x)) &&
+            checkEquality(variable.z, mem+returnSize(variable.w)+returnSize(variable.x)+returnSize(variable.y));
+    }
+
+    // =========== Quaternion
+
+    template <> inline uint32_t returnSize( const Quaternion& variable )
+    {
+        return returnSize( variable.w )+returnSize( variable.x )+returnSize( variable.y )+returnSize( variable.z );
+    }
+
+    template <> inline void saveAndIncrease( const Quaternion& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.w, mem );
+        saveAndIncrease( variable.x, mem );
+        saveAndIncrease( variable.y, mem );
+        saveAndIncrease( variable.z, mem );
+    }
+
+    template <> inline void loadAndIncrease( const Quaternion& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.w, mem );
+        loadAndIncrease( variable.x, mem );
+        loadAndIncrease( variable.y, mem );
+        loadAndIncrease( variable.z, mem );
+    }
+
+    template <> inline bool checkEquality( const Quaternion& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.w, mem) && checkEquality(variable.x, mem+returnSize(variable.w)) &&
+            checkEquality(variable.y, mem+returnSize(variable.w)+returnSize(variable.x)) &&
+            checkEquality(variable.z, mem+returnSize(variable.w)+returnSize(variable.x)+returnSize(variable.y));
+    }
+
+    // =========== ColourValue
+
+    template <> inline uint32_t returnSize( const ColourValue& variable )
+    {
+        return returnSize( variable.r )+returnSize( variable.g )+returnSize( variable.b )+returnSize( variable.a );
+    }
+
+    template <> inline void saveAndIncrease( const ColourValue& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( variable.r, mem );
+        saveAndIncrease( variable.g, mem );
+        saveAndIncrease( variable.b, mem );
+        saveAndIncrease( variable.a, mem );
+    }
+
+    template <> inline void loadAndIncrease( const ColourValue& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( variable.r, mem );
+        loadAndIncrease( variable.g, mem );
+        loadAndIncrease( variable.b, mem );
+        loadAndIncrease( variable.a, mem );
+    }
+
+    template <> inline bool checkEquality( const ColourValue& variable, uint8_t* mem )
+    {
+        return checkEquality(variable.r, mem) && checkEquality(variable.g, mem+returnSize(variable.r)) &&
+            checkEquality(variable.b, mem+returnSize(variable.r)+returnSize(variable.g)) &&
+            checkEquality(variable.a, mem+returnSize(variable.r)+returnSize(variable.g)+returnSize(variable.b));
+    }
+
+    // =========== mbool
+
+    template <> inline uint32_t returnSize( const mbool& variable )
+    {
+        return returnSize( (unsigned char&)((mbool&)variable).getMemory() );
+    }
+
+    template <> inline void saveAndIncrease( const mbool& variable, uint8_t*& mem )
+    {
+        saveAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
+    }
+
+    template <> inline void loadAndIncrease( const mbool& variable, uint8_t*& mem )
+    {
+        loadAndIncrease( (unsigned char&)((mbool&)variable).getMemory(), mem );
+    }
+
+    template <> inline bool checkEquality( const mbool& variable, uint8_t* mem )
+    {
+        return checkEquality( (unsigned char&)((mbool&)variable).getMemory(), mem );
+    }
 }
 
Index: code/branches/pickup2/src/libraries/util/Singleton.h
===================================================================
--- code/branches/pickup2/src/libraries/util/Singleton.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/Singleton.h	(revision 6412)
@@ -56,7 +56,11 @@
 
         //! Update method called by ClassSingletonManager (if used)
-        void updateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->update(time); }
+        void preUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->preUpdate(time); }
         //! Empty update method for the static polymorphism
-        void update(const Clock& time) { }
+        void preUpdate(const Clock& time) { }
+        //! Update method called by ClassSingletonManager (if used)
+        void postUpdateSingleton(const Clock& time) { static_cast<T*>(T::singletonPtr_s)->postUpdate(time); }
+        //! Empty update method for the static polymorphism
+        void postUpdate(const Clock& time) { }
 
     protected:
Index: code/branches/pickup2/src/libraries/util/StringUtils.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/StringUtils.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/StringUtils.cc	(revision 6412)
@@ -40,5 +40,5 @@
 namespace orxonox
 {
-    std::string BLANKSTRING("");
+    std::string BLANKSTRING;
 
     std::string getUniqueNumberString()
@@ -54,10 +54,10 @@
     {
         size_t pos;
-        while ((pos = (*str).find(" ")) < (*str).length())
-            (*str).erase(pos, 1);
-        while ((pos = (*str).find("\t")) < (*str).length())
-            (*str).erase(pos, 1);
-        while ((pos = (*str).find("\n")) < (*str).length())
-            (*str).erase(pos, 1);
+        while ((pos = str->find(' ')) < str->length())
+            str->erase(pos, 1);
+        while ((pos = str->find('\t')) < str->length())
+            str->erase(pos, 1);
+        while ((pos = str->find('\n')) < str->length())
+            str->erase(pos, 1);
     }
 
@@ -69,5 +69,5 @@
     std::string getStripped(const std::string& str)
     {
-        std::string output = std::string(str);
+        std::string output(str);
         strip(&output);
         return output;
@@ -98,5 +98,5 @@
         size_t quote = start - 1;
 
-        while ((quote = str.find('\"', quote + 1)) != std::string::npos)
+        while ((quote = str.find('"', quote + 1)) != std::string::npos)
         {
             size_t backslash = quote;
@@ -231,5 +231,5 @@
     {
         // Strip the line, whitespaces are disturbing
-        std::string teststring = getStripped(str);
+        const std::string& teststring = getStripped(str);
 
         // There are four possible comment-symbols:
@@ -259,6 +259,5 @@
     bool isEmpty(const std::string& str)
     {
-        std::string temp = getStripped(str);
-        return ((temp == "") || (temp.size() == 0));
+        return getStripped(str).empty();
     }
 
@@ -303,5 +302,5 @@
         for (size_t pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
         for (size_t pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
-        for (size_t pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
+        for (size_t pos = 0; (pos = output.find('"' , pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
         for (size_t pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
 
@@ -319,5 +318,5 @@
             return str;
 
-        std::string output = "";
+        std::string output;
         for (size_t pos = 0; pos < str.size() - 1; )
         {
@@ -363,5 +362,5 @@
     std::string getLowercase(const std::string& str)
     {
-        std::string output = std::string(str);
+        std::string output(str);
         lowercase(&output);
         return output;
@@ -387,5 +386,5 @@
     std::string getUppercase(const std::string& str)
     {
-        std::string output = std::string(str);
+        std::string output(str);
         uppercase(&output);
         return output;
Index: code/branches/pickup2/src/libraries/util/SubString.cc
===================================================================
--- code/branches/pickup2/src/libraries/util/SubString.cc	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/SubString.cc	(revision 6412)
@@ -270,8 +270,5 @@
         }
         else
-        {
-            static std::string empty;
-            return empty;
-        }
+            return "";
     }
 
@@ -557,5 +554,5 @@
     void SubString::debug() const
     {
-        printf("Substring-information::count=%d ::", this->strings.size());
+        printf("Substring-information::count=%zd ::", this->strings.size());
         for (unsigned int i = 0; i < this->strings.size(); i++)
             printf("s%d='%s'::", i, this->strings[i].c_str());
Index: code/branches/pickup2/src/libraries/util/UTFStringConversions.h
===================================================================
--- code/branches/pickup2/src/libraries/util/UTFStringConversions.h	(revision 5942)
+++ 	(revision )
@@ -1,61 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   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 2
- *   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, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Fabian 'x3n' Landau
- *      Reto Grieder
- *   Co-authors:
- *      ...
- */
-
-/**
-@file
-@brief
-    std::sring to Ogre::UTFString conversion functions
-*/
-
-#ifndef _UTFStringConversions_H__
-#define _UTFStringConversions_H__
-
-#include "UtilPrereqs.h"
-#include <OgreUTFString.h>
-
-namespace orxonox
-{
-    template <>
-    struct ConverterExplicit<std::string, Ogre::UTFString>
-    {
-        //! Converts an std::string into an Ogre::UTFString
-        inline static bool convert(Ogre::UTFString* output, const std::string& input)
-        {
-            Ogre::UTFString::code_point cp;
-            for (unsigned int i = 0; i < input.size(); ++i)
-            {
-              cp = input[i];
-              cp &= 0xFF;
-              output->append(1, cp);
-            }
-            return true;
-        }
-    };
-}
-
-#endif /* _UTFStringConversions_H__ */
Index: code/branches/pickup2/src/libraries/util/UtilPrereqs.h
===================================================================
--- code/branches/pickup2/src/libraries/util/UtilPrereqs.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/UtilPrereqs.h	(revision 6412)
@@ -87,7 +87,6 @@
     class IntVector3;
     class MultiType;
-    class OutputBuffer;
-    class OutputBufferListener;
     class OutputHandler;
+    class OutputListener;
     template <ScopeID::Value>
     class Scope;
@@ -132,3 +131,10 @@
 }
 
+// Just so you don't have to include StringUtils.h everywhere just for this
+namespace orxonox
+{
+    extern _UtilExport std::string BLANKSTRING;
+}
+
+
 #endif /* _UtilPrereqs_H__ */
Index: code/branches/pickup2/src/libraries/util/mbool.h
===================================================================
--- code/branches/pickup2/src/libraries/util/mbool.h	(revision 5942)
+++ code/branches/pickup2/src/libraries/util/mbool.h	(revision 6412)
@@ -67,5 +67,5 @@
             inline bool operator!() const
                 { return (!this->value_.bool_); }
-            
+
             inline unsigned char& getMemory(){ return value_.memory_; }
 
