Index: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	(revision 8855)
+++ code/trunk/src/orxonox/CMakeLists.txt	(revision 8858)
@@ -32,6 +32,4 @@
   PlayerManager.cc
   Radar.cc
-  ChatHistory.cc
-  ChatInputHandler.cc
 #  Test.cc
 
@@ -42,4 +40,5 @@
 )
 
+ADD_SUBDIRECTORY(chat)
 ADD_SUBDIRECTORY(collisionshapes)
 ADD_SUBDIRECTORY(controllers)
@@ -59,5 +58,5 @@
   FIND_HEADER_FILES
   TOLUA_FILES
-    ChatInputHandler.h
+    chat/ChatInputHandler.h
     LevelInfo.h
     LevelManager.h
Index: code/trunk/src/orxonox/ChatHistory.cc
===================================================================
--- code/trunk/src/orxonox/ChatHistory.cc	(revision 8855)
+++ 	(revision )
@@ -1,195 +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:
- *      Sandro 'smerkli' Merkli
- *   Co-authors:
- *      ...
- *
- */
-
-#include "ChatHistory.h"
-#include "util/ScopedSingletonManager.h"
-
-#ifndef CHATTEST
-namespace orxonox
-{
-  /* singleton */
-  ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
-#endif
-
-  /* constructor */
-#ifndef CHATTEST
-  //ChatHistory::ChatHistory( BaseObject* creator ) : BaseObject(creator)
-  ChatHistory::ChatHistory()
-#else
-  ChatHistory::ChatHistory()
-#endif
-  {
-    /* register the object */
-#ifndef CHATTEST
-    RegisterObject(ChatHistory);
-#endif
-
-    this->hist_log_enabled = true;
-
-    /* Read setting for logfiles */
-    if( hist_log_enabled ) /* NOTE Make this a check for the logfile setting */
-    { this->chat_hist_openlog();
-
-      /* push starting line */
-      this->chat_hist_logline( "--- Logfile opened ---" );
-    }
-
-    /* Read setting for maximum number of lines and set limit */
-    this->hist_maxlines = 200; /* NOTE to be changed, 200 is just for testing */
-  }
-
-  /* destructor */
-  ChatHistory::~ChatHistory()
-  {
-    chat_hist_closelog();
-
-    /* clear list */
-    this->hist_buffer.clear();
-  }
-
-  /* react to incoming chat */
-  void ChatHistory::incomingChat(const std::string& message,
-    unsigned int senderID)
-  {
-    /* --> a) look up the actual name of the sender */
-    std::string text;
-
-#ifndef CHATTEST
-    /* get sender ID and prepend it to the message */
-    if (senderID != NETWORK_PEER_ID_UNKNOWN)
-    {
-      /* if we can't find anything, use "unknown" as default */
-      std::string name = "unknown";
-
-      PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
-      if (player)
-        name = player->getName();
-
-      text = name + ": " + message;
-    }
-    else
-      text = message;
-#else
-    text = message;
-#endif
-
-    /* add the line to the history */
-    this->chat_hist_addline( text );
-
-    /* add the line to the log */
-    this->chat_hist_logline( text );
-  }
-
-  /* Synchronize logfile onto the hard drive */ /* MARK MARK */
-  int ChatHistory::syncLog()
-  {
-    //if( this->hist_logfile )
-      //this->hist_logfile.sync();
-    return 0;
-  }
-
-  /* add a line to this history */
-  int ChatHistory::chat_hist_addline( const std::string& toadd )
-  {
-    /* crop history at the end if it's too large */
-    while( this->hist_buffer.size() > this->hist_maxlines+1 )
-      this->hist_buffer.pop_front();
-
-    /* push to the front of the history */
-    this->hist_buffer.push_back( toadd );
-    return 0;
-  }
-
-  /* log a line to a logfile */
-  int ChatHistory::chat_hist_logline( const std::string& toadd )
-  {
-    /* output the line to the file if logging is enabled */
-    if( this->hist_log_enabled )
-      this->hist_logfile << toadd << std::endl;
-    return 0;
-  }
-
-  /* open logfile */
-  int ChatHistory::chat_hist_openlog()
-  {
-    /* TODO: find out the name of the file to log to via settings
-     *       and set the this->hist_logfile_path variable to it
-     */
-#ifndef CHATTEST
-    this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
-      "chatlog.log").c_str(),
-      std::fstream::out | std::fstream::app );
-#else
-    this->hist_logfile.open( "/tmp/chatlog.log",
-      std::fstream::out | std::fstream::app );
-#endif
-
-    /* TODO check whether this works (not sure how you'd like it?) */
-    if( !this->hist_logfile )
-    { this->hist_log_enabled = false;
-#ifndef CHATTEST
-      COUT(2) << "Warning: Could not open logfile." << std::endl;
-#endif
-    }
-
-    /* if it worked */
-    return 0;
-  }
-
-  /* close logfile */
-  void ChatHistory::chat_hist_closelog()
-  {
-    /* see if we've actually got a logfile */
-    if( this->hist_logfile )
-    {
-      /* yes, we've got one, add a line that shows we're closing it */
-      this->chat_hist_logline( "--- Logfile closed ---" );
-
-      /* actually close down the file */
-      this->hist_logfile.close();
-    }
-  }
-
-  /* output history for debugging */
-  void ChatHistory::debug_printhist()
-  {
-    /* create deque iterator */
-    std::deque<std::string>::iterator it;
-
-    /* output all the strings */
-    for( it = this->hist_buffer.begin(); it != this->hist_buffer.end();
-      ++it )
-      std::cout << *it << std::endl;
-
-    /* output size */
-    std::cout << "Size: " << hist_buffer.size() << std::endl;
-  }
-
-#ifndef CHATTEST
-}
-#endif
Index: code/trunk/src/orxonox/ChatHistory.h
===================================================================
--- code/trunk/src/orxonox/ChatHistory.h	(revision 8855)
+++ 	(revision )
@@ -1,149 +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:
- *      Sandro 'smerkli' Merkli
- *   Co-authors:
- *      ...
- *
- */
-
-#include <deque>
-#include <string>
-#include <fstream>
-#include <iostream>
-#include <cassert>
-
-/* define this if you're unit testing */
-//#define CHATTEST
-
-#ifndef CHATTEST
-#include <OrxonoxPrereqs.h>
-#include <PlayerManager.h>
-#include <infos/PlayerInfo.h>
-#include <core/BaseObject.h>
-#include <network/ChatListener.h>
-#include <core/PathConfig.h>
-#include <util/Singleton.h>
-#endif
-
-#ifndef _ChatHistory_H__
-#define _ChatHistory_H__
-
-
-/* Class to implement chat history */
-#ifndef CHATTEST
-namespace orxonox
-{
-#endif
-
-  /* constructor */
-#ifndef CHATTEST
-  class _OrxonoxExport ChatHistory : public ChatListener,
-    public Singleton<ChatHistory>
-
-#else
-  class ChatHistory
-#endif
-  {
-    public:
-      /* constructors, destructors */
-#ifndef CHATTEST
-      ChatHistory();
-      friend class Singleton<ChatHistory>;
-#else
-      ChatHistory();
-#endif
-      virtual ~ChatHistory();
-
-
-    //protected:
-      /** what to do with incoming chat
-       *
-       * \param message The incoming message
-       * \param senderID Identification number of the sender
-       */
-      virtual void incomingChat(const std::string& message,
-        unsigned int senderID);
-
-      /** Synchronize logfile onto the hard drive
-       *
-       * \return 0 for success, other for error
-       */
-      int syncLog();
-
-      /** debug-print: output the whole history to stdout */
-      void debug_printhist();
-
-    private:
-      /* FIELDS */
-      /** Vector to store the history in */
-      std::deque<std::string> hist_buffer;
-
-      /** Maximum number of lines stored in this history */
-      unsigned int hist_maxlines;
-
-      /** is logging enabled? */
-      bool hist_log_enabled;
-
-      /** path of logfile on the file system */
-      std::string hist_logfile_path;
-
-      /** Output file stream for logfile */
-      std::ofstream hist_logfile;
-
-#ifndef CHATTEST
-      static ChatHistory* singletonPtr_s;
-#endif
-
-
-
-      /* METHODS */
-      /** Append line to chat history
-       *
-       * \param toadd The line to add to the history
-       * \return 0 for success, other for error TODO: Throw exception
-       */
-      int chat_hist_addline( const std::string& toadd );
-
-      /** Append line to logfile
-       *
-       * \param toadd The line to add to the logfile
-       * \return 0 for success, other for error TODO: Throw exception
-       */
-      int chat_hist_logline( const std::string& toadd );
-
-      /** open logfile to log to
-       *
-       * \return 0 for success,s other for error
-       */
-      int chat_hist_openlog();
-
-
-      /** close logfile */
-      void chat_hist_closelog();
-  };
-
-#ifndef CHATTEST
-}
-#endif
-
-#endif /* _ChatHistory_H__ */
Index: code/trunk/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/trunk/src/orxonox/ChatInputHandler.cc	(revision 8855)
+++ 	(revision )
@@ -1,356 +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:
- *      Sandro 'smerkli' Merkli
- *   Co-authors:
- *      ...
- *
- */
-
-#include "ChatInputHandler.h"
-
-#include <cassert>
-#include <string>
-#include <CEGUIWindow.h>
-#include <CEGUIWindowManager.h>
-#include <elements/CEGUIListbox.h>
-#include <elements/CEGUIListboxItem.h>
-#include <elements/CEGUIListboxTextItem.h>
-
-#include "util/ScopedSingletonManager.h"
-#include "core/CoreIncludes.h"
-#include "core/GUIManager.h"
-#include "core/command/ConsoleCommand.h"
-#include "core/input/InputBuffer.h"
-#include "core/input/InputManager.h"
-#include "core/input/InputState.h"
-#include "network/Host.h"
-
-#include "PlayerManager.h"
-#include "infos/PlayerInfo.h"
-
-namespace orxonox
-{
-  /* singleton */
-  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
-
-  /* add commands to console */
-  SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
-  SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
-
-  /* constructor */
-  ChatInputHandler::ChatInputHandler()
-  {
-    /* register the object  */
-    RegisterObject(ChatInputHandler);
-
-    /* create necessary objects */
-    this->inpbuf = new InputBuffer();
-    this->disp_offset = 0;
-    assert( this->inpbuf != NULL );
-
-    /* generate chatbox ui and chatbox-inputonly ui */
-    GUIManager::getInstance().loadGUI( "ChatBox" );
-    GUIManager::getInstance().loadGUI( "ChatBox-inputonly" );
-
-    /* setup colors */
-    setupColors();
-
-    /* configure the input buffer */
-    configureInputBuffer();
-
-    this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
-    this->inputState->setKeyHandler(this->inpbuf);
-  }
-
-  ChatInputHandler::~ChatInputHandler()
-  {
-    /* Clean up */
-    InputManager::getInstance().destroyState("chatinput");
-    delete this->inpbuf;
-  }
-
-  /* configure input buffer, sub for the constructor */
-  void ChatInputHandler::configureInputBuffer()
-  {
-    /* INSTALL CALLBACKS */
-    /* input has changed */
-    this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
-
-    /* add a line */
-    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
-    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
-
-    /* backspace */
-    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
-    //this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
-
-    /* exit the chatinputhandler thingy (tbd) */
-    this->inpbuf->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
-
-    /* delete character */
-    this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
-
-    /* cursor movement */
-    this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
-    this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
-    this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
-    this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
-
-    /* GET WINDOW POINTERS */
-    input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
-    inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
-
-    /* get pointer to the history window */
-    CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
-
-    /* cast it to a listbox */
-    lb_history = dynamic_cast<CEGUI::Listbox*>(history);
-
-    /* assert wee */
-    assert( lb_history );
-  }
-
-  /* setup the colors, sub for the constructor */
-  void ChatInputHandler::setupColors()
-  {
-    /* auto variables */
-    float red = 1.0, green = 0.5, blue = 0.5;
-    int i = 0;
-
-    // three loops: red tones, blue tones and green tones
-    // reds
-    for( i = 0; i < NumberOfColors/3; ++i )
-    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
-      green += 0.2f, blue += 0.2f;
-    }
-
-    // greens
-    red = 0.5, green = 1, blue = 0.5;
-    for( ; i < NumberOfColors*2/3; ++i )
-    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
-      red += 0.2f, blue += 0.2f;
-    }
-
-    // blues
-    red = 0.5, green = 0.5, blue = 1;
-    for( ; i < NumberOfColors; ++i )
-    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
-      red += 0.2f, green += 0.2f;
-    }
-  }
-
-
-  /* activate, deactivate */
-  void ChatInputHandler::activate_static()
-  { ChatInputHandler::getInstance().activate( true ); }
-
-  void ChatInputHandler::activate_small_static()
-  { ChatInputHandler::getInstance().activate( false ); }
-
-  void ChatInputHandler::activate( bool full )
-  {
-    /* start listening */
-    InputManager::getInstance().enterState("chatinput");
-
-    /* MARK add spawning of chat widget stuff here.*/
-    if( full )
-      GUIManager::getInstance().showGUI( "ChatBox" );
-    else
-      GUIManager::getInstance().showGUI( "ChatBox-inputonly" );
-
-    this->fullchat = full;
-  }
-
-  void ChatInputHandler::deactivate()
-  {
-    /* stop listening */
-    InputManager::getInstance().leaveState("chatinput");
-
-    /* un-spawning of chat widget stuff */
-    GUIManager::getInstance().hideGUI( "ChatBox" );
-    GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
-  }
-
-
-  /* subs for incomingChat */
-  void ChatInputHandler::sub_setcolor( CEGUI::ListboxTextItem *tocolor,
-    std::string name )
-  {
-    /* sanity checks */
-    if( !tocolor )
-      COUT(2) << "Empty ListBoxTextItem given to "
-        "ChatInputhandler::sub_setcolor().\n";
-
-    /* "hash" the name */
-    int hash = 0;
-    for( int i = name.length(); i > 0; --i )
-      hash += name[i-1];
-    hash = hash % this->NumberOfColors;
-
-    /* set the color according to the hash */
-    tocolor->setTextColours( this->text_colors[ hash ] );
-  }
-
-  /* handle incoming chat */
-  void ChatInputHandler::incomingChat(const std::string& message,
-    unsigned int senderID)
-  {
-    /* look up the actual name of the sender */
-    std::string text, name = "unknown";
-
-    /* setup player name info */
-    if (senderID != NETWORK_PEER_ID_UNKNOWN)
-    {
-       PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
-       if (player)
-         name = player->getName();
-    }
-
-    /* assemble the text */
-    text = name + ": " + message;
-
-    /* create item */
-    CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text );
-
-    /* setup colors */
-    sub_setcolor( toadd, name );
-
-    /* now add */
-    this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
-    this->lb_history->ensureItemIsVisible(
-      dynamic_cast<CEGUI::ListboxItem*>(toadd) );
-
-    /* make sure the history handles it */
-    this->lb_history->handleUpdatedItemData();
-  }
-
-
-  /* sub for inputchanged */
-  void ChatInputHandler::sub_adjust_dispoffset( int maxlen,
-    int cursorpos,
-    int inplen )
-  {
-    /* already start offsetting 5 characters before end */
-    if( cursorpos+5 > maxlen )
-    {
-      /* always stay 5 characters ahead of end, looks better */
-      ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0;
-
-      /* enforce visibility of cursor */
-      (disp_offset > cursorpos ) ? disp_offset = 0 : 1;
-    }
-
-    /* make sure we don't die at substr */
-    if( inplen <= disp_offset ) disp_offset = 0;
-  }
-
-  /* callbacks for InputBuffer */
-  void ChatInputHandler::inputChanged()
-  {
-    /* update the cursor and the window */
-    std::string raw = this->inpbuf->get();
-    int cursorpos = this->inpbuf->getCursorPosition();
-
-    /* get string before cursor */
-    std::string left = raw.substr( 0, cursorpos );
-
-    /* see if there's a string after the cursor */
-    std::string right = "";
-    if( raw.length() >= left.length()+1 )
-      right = raw.substr( cursorpos );
-
-    /* set the text */
-    std::string assembled = "$ " + left + "|" + right;
-
-    if( this->fullchat )
-    {
-      /* adjust curser position - magic number 5 for font width */
-      sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
-        cursorpos, assembled.length() );
-      this->input->setProperty( "Text", assembled.substr( disp_offset ) );
-    }
-    else
-    {
-      /* adjust curser position - magic number 5 for font width */
-      sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
-        cursorpos, assembled.length() );
-      this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
-    }
-
-    /* reset display offset */
-    disp_offset = 0;
-  }
-
-  void ChatInputHandler::addline()
-  {
-    /* actually do send what was input */
-    /* a) get the string out of the inputbuffer */
-    std::string msgtosend = this->inpbuf->get();
-
-    if( msgtosend.length() == 0 )
-    { this->deactivate();
-      return;
-    }
-
-    /* b) clear the input buffer */
-    if (this->inpbuf->getSize() > 0)
-      this->inpbuf->clear();
-
-    /* c) send the chat via some call */
-    Host::Chat( msgtosend );
-
-    /* d) stop listening to input - only if this is not fullchat */
-    if( !this->fullchat )
-      this->deactivate();
-
-  }
-
-  void ChatInputHandler::backspace()
-  { this->inpbuf->removeBehindCursor(); }
-
-  void ChatInputHandler::deleteChar()
-  { this->inpbuf->removeAtCursor(); }
-
-  void ChatInputHandler::cursorRight()
-  { this->inpbuf->increaseCursor(); }
-
-  void ChatInputHandler::cursorLeft()
-  { this->inpbuf->decreaseCursor(); }
-
-  void ChatInputHandler::cursorEnd()
-  { this->inpbuf->setCursorToEnd(); }
-
-  void ChatInputHandler::cursorHome()
-  { this->inpbuf->setCursorToBegin(); }
-
-  void ChatInputHandler::exit()
-  {
-    /* b) clear the input buffer */
-    if (this->inpbuf->getSize() > 0)
-      this->inpbuf->clear();
-
-    /* d) stop listening to input  */
-    this->deactivate();
-  }
-
-}
Index: code/trunk/src/orxonox/ChatInputHandler.h
===================================================================
--- code/trunk/src/orxonox/ChatInputHandler.h	(revision 8855)
+++ 	(revision )
@@ -1,134 +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:
- *      Sandro 'smerkli' Merkli
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _ChatInputHandler_H__
-#define _ChatInputHandler_H__
-
-#include <OrxonoxPrereqs.h>
-
-#include <string>
-#include <CEGUIForwardRefs.h>
-#include <CEGUIcolour.h>
-
-#include "util/Singleton.h"
-#include "network/ChatListener.h"
-
-namespace orxonox // tolua_export
-{ // tolua_export
-  /* class to handle chat using an InputBuffer */
-  class _OrxonoxExport ChatInputHandler  // tolua_export
-    : public Singleton<ChatInputHandler>, public ChatListener
-  { // tolua_export
-    private:
-      /** Input buffer, to be used to catch input from the
-       * keyboard
-       */
-      InputBuffer *inpbuf;
-      int disp_offset, width;
-      bool fullchat;
-
-      /* colors for nickname coloring */
-      static const int NumberOfColors = 10;
-      CEGUI::colour text_colors[ NumberOfColors ];
-
-      /** input state */
-      InputState *inputState;
-
-      /** setup input buffer, the constructor calls this */
-      void configureInputBuffer();
-
-      /** adjust display offset depending on cursor position */
-      void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
-
-      /** singleton pointer */
-      static ChatInputHandler* singletonPtr_s;
-
-      /** cegui window handles */
-      CEGUI::Window *input, *inputonly;
-
-      /** cegui handle for the history window */
-      CEGUI::Listbox *lb_history;
-
-      /* methods to deal with colors */
-      void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
-        std::string name );
-
-      void setupColors();
-
-      /* callbacks for input handler */
-      void inputChanged();
-      void addline();
-      void backspace();
-      void deleteChar();
-      void cursorRight();
-      void cursorLeft();
-      void cursorEnd();
-      void cursorHome();
-      void exit();
-
-    public:
-      /** constructor */
-      ChatInputHandler();
-      ~ChatInputHandler();
-      friend class Singleton<ChatInputHandler>;
-
-      static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); }  // tolua_export
-
-      /** start listening */
-      static void activate_static();
-
-      /** stop listening */
-      static void activate_small_static();
-
-      /** \param message the message text
-       * \param senderID ID of the player who sent the message
-       *
-       * Deal with incoming chat (which means in our case: Add it to the
-       * history window of the full chat window)
-       */
-      void incomingChat( const std::string& message,
-        unsigned int senderID );
-
-      /** \param full true means show full chat window with history,
-            false means show only an input line
-       *
-       * Show the chat window and redirect the game's keyboard input
-       * into it.
-       */
-      void activate( bool full );
-
-      /** Deactivate the chat window, meaning: hide it. */
-      void deactivate();  // tolua_export
-
-  };  // tolua_export
-
-
-}  // tolua_export
-
-
-#endif /*_ChatInputHandler_H__*/
Index: code/trunk/src/orxonox/Level.cc
===================================================================
--- code/trunk/src/orxonox/Level.cc	(revision 8855)
+++ code/trunk/src/orxonox/Level.cc	(revision 8858)
@@ -88,5 +88,5 @@
     void Level::networkcallback_applyXMLFile()
     {
-        COUT(0) << "Loading level \"" << this->xmlfilename_ << "\"..." << std::endl;
+        orxout(user_status) << "Loading level \"" << this->xmlfilename_ << "\"..." << endl;
 
         ClassTreeMask mask;
@@ -115,5 +115,5 @@
         if (!identifier || !identifier->isA(Class(Gametype)))
         {
-            COUT(0) << "Error: \"" << gametype << "\" is not a valid gametype." << std::endl;
+            orxout(internal_error) << "\"" << gametype << "\" is not a valid gametype." << endl;
             identifier = Class(Gametype);
             this->gametype_ = "Gametype";
@@ -157,5 +157,5 @@
 //         this->lodInformation_.insert(std::make_pair(meshName,lodInformation));
         if( this->lodInformation_.find(meshName) != this->lodInformation_.end())
-          CCOUT(4) << "replacing lod information for " << meshName << endl;
+            orxout(verbose, context::lod) << "replacing lod information for " << meshName << endl;
         this->lodInformation_[meshName] = lodInformation;
     }
@@ -171,5 +171,5 @@
     void Level::playerEntered(PlayerInfo* player)
     {
-        COUT(3) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
+        orxout(internal_info) << "player entered level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
         player->setGametype(this->getGametype());
     }
@@ -177,5 +177,5 @@
     void Level::playerLeft(PlayerInfo* player)
     {
-        COUT(3) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << std::endl;
+        orxout(internal_info) << "player left level (id: " << player->getClientID() << ", name: " << player->getName() << ')' << endl;
         player->setGametype(0);
     }
Index: code/trunk/src/orxonox/LevelInfo.cc
===================================================================
--- code/trunk/src/orxonox/LevelInfo.cc	(revision 8855)
+++ code/trunk/src/orxonox/LevelInfo.cc	(revision 8858)
@@ -125,5 +125,5 @@
         if(!this->validateTag(tag))
         {
-            COUT(2) << "Bad LevelInfo tag '" << tag << "' in " << this->getXMLFilename() << ". Ignoring..." << std::endl;
+            orxout(internal_warning) << "Bad LevelInfo tag '" << tag << "' in " << this->getXMLFilename() << ". Ignoring..." << endl;
             return false;
         }
Index: code/trunk/src/orxonox/LevelManager.cc
===================================================================
--- code/trunk/src/orxonox/LevelManager.cc	(revision 8855)
+++ code/trunk/src/orxonox/LevelManager.cc	(revision 8858)
@@ -251,5 +251,5 @@
 
         // Iterate over all the found *.oxw files
-        COUT(3) << "Loading LevelInfos..." << std::endl;
+        orxout(internal_info) << "Loading LevelInfos..." << endl;
         std::set<std::string> names;
         for (Ogre::StringVector::const_iterator it = levels->begin(); it != levels->end(); ++it)
@@ -281,10 +281,10 @@
                 // Warn about levels with the same name.
                 if(!names.insert(info->getName()).second)
-                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << std::endl;
+                    orxout(internal_warning) << "Multiple levels (" << info->getXMLFilename() << ") with name '" << info->getName() << "' found!" << endl;
 
                 // Warn about multiple items so that it gets fixed quickly
                 if(availableLevels_.find(info) != availableLevels_.end())
                 {
-                    COUT(2) << "Warning: Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << std::endl;
+                    orxout(internal_warning) << "Multiple levels (" << info->getXMLFilename() << ") with same name '" << info->getName() << "' and filename found! Exluding..." << endl;
                     // Delete LevelInfoItem to avoid a dangling pointer
                     delete info;
Index: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc	(revision 8855)
+++ code/trunk/src/orxonox/Main.cc	(revision 8858)
@@ -61,8 +61,15 @@
     int main(const std::string& strCmdLine)
     {
+        orxout(internal_status) << "entering orxonox::main()" << endl;
+        orxout(internal_info) << "command line: " << strCmdLine << endl;
+
+        orxout(internal_info) << "creating Game object:" << endl;
         Game* game = new Game(strCmdLine);
+        orxout(user_status) << "Finished initialization" << endl;
 
         if (CommandLineParser::getValue("generateDoc").getString().empty())
         {
+            orxout(internal_info) << "preparing game states" << endl;
+
             /* TODO make this clear */
             game->setStateHierarchy(
@@ -98,4 +105,5 @@
             }
 
+            orxout(internal_info) << "starting game" << endl;
             game->run();
         }
Index: code/trunk/src/orxonox/MoodManager.cc
===================================================================
--- code/trunk/src/orxonox/MoodManager.cc	(revision 8855)
+++ code/trunk/src/orxonox/MoodManager.cc	(revision 8858)
@@ -54,5 +54,5 @@
         {
             // TODO: Non-fatal error handling (non-critical resource missing)
-            COUT(2) << "Mood Warning: Folder for default mood (" << MoodManager::defaultMood_ << ") does not exist!" << std::endl;
+            orxout(internal_warning) << "Mood Warning: Folder for default mood (" << MoodManager::defaultMood_ << ") does not exist!" << endl;
         }
         
@@ -82,10 +82,10 @@
         if (!Resource::exists(path))
         {
-            COUT(3) << "Mood " << mood_ << " does not exist. Will not change." << std::endl;
+            orxout(internal_warning) << "Mood " << mood_ << " does not exist. Will not change." << endl;
             this->setMood(oldMood_);
         }
         else
         {
-            COUT(3) << "Mood changed to " << mood_ << std::endl;
+            orxout(internal_info) << "Mood changed to " << mood_ << endl;
             MoodListener::changedMood(mood_);
         }
Index: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 8855)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 8858)
@@ -77,4 +77,10 @@
     class Radar;
     class Scene;
+
+    // chat
+    class ChatHistory;
+    class ChatInputHandler;
+    class ChatListener;
+    class ChatManager;
 
     // collisionshapes
Index: code/trunk/src/orxonox/PlayerManager.cc
===================================================================
--- code/trunk/src/orxonox/PlayerManager.cc	(revision 8855)
+++ code/trunk/src/orxonox/PlayerManager.cc	(revision 8858)
@@ -57,5 +57,5 @@
         {
             if (clientID != 0)
-                COUT(3) << "client connected" << std::endl;
+                orxout(internal_info) << "client connected" << endl;
 
             // create new HumanPlayer instance
@@ -77,5 +77,5 @@
         {
             if (clientID != 0)
-                COUT(3) << "client disconnected" << std::endl;
+                orxout(internal_info) << "client disconnected" << endl;
 
             // remove from clients-map
Index: code/trunk/src/orxonox/Radar.cc
===================================================================
--- code/trunk/src/orxonox/Radar.cc	(revision 8855)
+++ code/trunk/src/orxonox/Radar.cc	(revision 8858)
@@ -195,10 +195,10 @@
     void Radar::listObjects() const
     {
-        COUT(3) << "List of RadarObjects:\n";
+        orxout(debug_output) << "List of RadarObjects:" << endl;
         // iterate through all Radar Objects
         unsigned int i = 0;
         for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
         {
-            COUT(3) << i++ << ": " << (*it)->getRVWorldPosition() << std::endl;
+            orxout(debug_output) << i++ << ": " << (*it)->getRVWorldPosition() << endl;
         }
     }
Index: code/trunk/src/orxonox/Scene.cc
===================================================================
--- code/trunk/src/orxonox/Scene.cc	(revision 8855)
+++ code/trunk/src/orxonox/Scene.cc	(revision 8858)
@@ -141,11 +141,11 @@
         if (range.length() < 10.0f)
         {
-            CCOUT(2) << "Warning: Setting the negative world range to a very small value: "
-                     << multi_cast<std::string>(range) << std::endl;
-        }
-        if (this->hasPhysics())
-        {
-            CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
-                     << "This causes a complete physical reload which might take some time." << std::endl;
+            orxout(internal_warning) << "Setting the negative world range to a very small value: "
+                                     << multi_cast<std::string>(range) << endl;
+        }
+        if (this->hasPhysics())
+        {
+            orxout(internal_warning) << "Attempting to set the physical world range at run time. "
+                                     << "This causes a complete physical reload which might take some time." << endl;
             this->setPhysicalWorld(false);
             this->negativeWorldRange_ = range;
@@ -160,11 +160,11 @@
         if (range.length() < 10.0f)
         {
-            CCOUT(2) << "Warning: Setting the positive world range to a very small value: "
-                     << multi_cast<std::string>(range) << std::endl;
-        }
-        if (this->hasPhysics())
-        {
-            CCOUT(2) << "Warning: Attempting to set the physical world range at run time. "
-                     << "This causes a complete physical reload which might take some time." << std::endl;
+            orxout(internal_warning) << "Setting the positive world range to a very small value: "
+                                     << multi_cast<std::string>(range) << endl;
+        }
+        if (this->hasPhysics())
+        {
+            orxout(internal_warning) << "Attempting to set the physical world range at run time. "
+                                     << "This causes a complete physical reload which might take some time." << endl;
             this->setPhysicalWorld(false);
             this->positiveWorldRange_ = range;
Index: code/trunk/src/orxonox/Test.cc
===================================================================
--- code/trunk/src/orxonox/Test.cc	(revision 8855)
+++ code/trunk/src/orxonox/Test.cc	(revision 8858)
@@ -127,5 +127,5 @@
     //     mt2.importData( temp );
     //     assert( temp-mem == mt1.getNetworkSize() );
-    //     COUT(0) << mt2 << endl;
+    //     orxout() << mt2 << endl;
     //     if(!Core::isMaster())
     //       call2(0, "bal", "a", "n", "ce");
@@ -135,18 +135,18 @@
     void Test::printBlaBla(std::string s1, std::string s2, std::string s3, std::string s4, std::string s5)
     {
-        COUT(0) << s1 << s2 << s3 << s4 << s5 << endl;
+        orxout() << s1 << s2 << s3 << s4 << s5 << endl;
     }
 
-    void Test::checkU1(){ COUT(1) << "U1 changed: " << u1 << std::endl; }
-    void Test::checkU2(){ COUT(1) << "U2 changed: " << u2 << std::endl; }
-    void Test::checkU3(){ COUT(1) << "U3 changed: " << u3 << std::endl; }
-    void Test::checkU4(){ COUT(1) << "U4 changed: " << u4 << std::endl; }
+    void Test::checkU1(){ orxout() << "U1 changed: " << u1 << endl; }
+    void Test::checkU2(){ orxout() << "U2 changed: " << u2 << endl; }
+    void Test::checkU3(){ orxout() << "U3 changed: " << u3 << endl; }
+    void Test::checkU4(){ orxout() << "U4 changed: " << u4 << endl; }
 
-    void Test::checkS1(){ COUT(1) << "S1 changed: " << s1 << std::endl; }
-    void Test::checkS2(){ COUT(1) << "S2 changed: " << s2 << std::endl; }
-    void Test::checkS3(){ COUT(1) << "S3 changed: " << s3 << std::endl; }
-    void Test::checkS4(){ COUT(1) << "S4 changed: " << s4 << std::endl; }
+    void Test::checkS1(){ orxout() << "S1 changed: " << s1 << endl; }
+    void Test::checkS2(){ orxout() << "S2 changed: " << s2 << endl; }
+    void Test::checkS3(){ orxout() << "S3 changed: " << s3 << endl; }
+    void Test::checkS4(){ orxout() << "S4 changed: " << s4 << endl; }
 
-    void Test::printPointer(){ CCOUT(1) << "pointer: " << this->pointer_ << endl; }
+    void Test::printPointer(){ orxout() << "pointer: " << this->pointer_ << endl; }
 
 }
Index: code/trunk/src/orxonox/Test.h
===================================================================
--- code/trunk/src/orxonox/Test.h	(revision 8855)
+++ code/trunk/src/orxonox/Test.h	(revision 8858)
@@ -108,5 +108,5 @@
       
       void blub2()
-      { for( std::set<uint32_t>::iterator it=mySet_.begin(); it!=mySet_.end(); ++it ) COUT(0) << *it << endl; }
+      { for( std::set<uint32_t>::iterator it=mySet_.begin(); it!=mySet_.end(); ++it ) orxout() << *it << endl; }
   };
 }
Index: code/trunk/src/orxonox/chat/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/chat/CMakeLists.txt	(revision 8858)
+++ code/trunk/src/orxonox/chat/CMakeLists.txt	(revision 8858)
@@ -0,0 +1,5 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+  ChatHistory.cc
+  ChatInputHandler.cc
+  ChatManager.cc
+)
Index: code/trunk/src/orxonox/chat/ChatHistory.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.cc	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatHistory.cc	(revision 8858)
@@ -0,0 +1,172 @@
+/*
+ *   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:
+ *      Sandro 'smerkli' Merkli
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ChatHistory.h"
+#include "util/ScopedSingletonManager.h"
+
+#ifndef CHATTEST
+namespace orxonox
+{
+  /* singleton */
+  ManageScopedSingleton( ChatHistory, ScopeID::Root, false );
+#endif
+
+  /* constructor */
+#ifndef CHATTEST
+  //ChatHistory::ChatHistory( BaseObject* creator ) : BaseObject(creator)
+  ChatHistory::ChatHistory()
+#else
+  ChatHistory::ChatHistory()
+#endif
+  {
+    /* register the object */
+#ifndef CHATTEST
+    RegisterObject(ChatHistory);
+#endif
+
+    this->hist_log_enabled = true;
+
+    /* Read setting for logfiles */
+    if( hist_log_enabled ) /* NOTE Make this a check for the logfile setting */
+    { this->chat_hist_openlog();
+
+      /* push starting line */
+      this->chat_hist_logline( "--- Logfile opened ---" );
+    }
+
+    /* Read setting for maximum number of lines and set limit */
+    this->hist_maxlines = 200; /* NOTE to be changed, 200 is just for testing */
+  }
+
+  /* destructor */
+  ChatHistory::~ChatHistory()
+  {
+    chat_hist_closelog();
+
+    /* clear list */
+    this->hist_buffer.clear();
+  }
+
+  /* react to incoming chat */
+  void ChatHistory::incomingChat(const std::string& message, const std::string& /*name*/)
+  {
+    /* add the line to the history */
+    this->chat_hist_addline( message );
+
+    /* add the line to the log */
+    this->chat_hist_logline( message );
+  }
+
+  /* Synchronize logfile onto the hard drive */ /* MARK MARK */
+  int ChatHistory::syncLog()
+  {
+    //if( this->hist_logfile )
+      //this->hist_logfile.sync();
+    return 0;
+  }
+
+  /* add a line to this history */
+  int ChatHistory::chat_hist_addline( const std::string& toadd )
+  {
+    /* crop history at the end if it's too large */
+    while( this->hist_buffer.size() > this->hist_maxlines+1 )
+      this->hist_buffer.pop_front();
+
+    /* push to the front of the history */
+    this->hist_buffer.push_back( toadd );
+    return 0;
+  }
+
+  /* log a line to a logfile */
+  int ChatHistory::chat_hist_logline( const std::string& toadd )
+  {
+    /* output the line to the file if logging is enabled */
+    if( this->hist_log_enabled )
+      this->hist_logfile << toadd << endl;
+    return 0;
+  }
+
+  /* open logfile */
+  int ChatHistory::chat_hist_openlog()
+  {
+    /* TODO: find out the name of the file to log to via settings
+     *       and set the this->hist_logfile_path variable to it
+     */
+#ifndef CHATTEST
+    this->hist_logfile.open( (PathConfig::getInstance().getLogPathString() +
+      "chatlog.log").c_str(),
+      std::fstream::out | std::fstream::app );
+#else
+    this->hist_logfile.open( "/tmp/chatlog.log",
+      std::fstream::out | std::fstream::app );
+#endif
+
+    /* TODO check whether this works (not sure how you'd like it?) */
+    if( !this->hist_logfile )
+    { this->hist_log_enabled = false;
+#ifndef CHATTEST
+      orxout(internal_warning) << "Could not open logfile." << endl;
+#endif
+    }
+
+    /* if it worked */
+    return 0;
+  }
+
+  /* close logfile */
+  void ChatHistory::chat_hist_closelog()
+  {
+    /* see if we've actually got a logfile */
+    if( this->hist_logfile )
+    {
+      /* yes, we've got one, add a line that shows we're closing it */
+      this->chat_hist_logline( "--- Logfile closed ---" );
+
+      /* actually close down the file */
+      this->hist_logfile.close();
+    }
+  }
+
+  /* output history for debugging */
+  void ChatHistory::debug_printhist()
+  {
+    /* create deque iterator */
+    std::deque<std::string>::iterator it;
+
+    /* output all the strings */
+    for( it = this->hist_buffer.begin(); it != this->hist_buffer.end();
+      ++it )
+      orxout(debug_output) << *it << endl;
+
+    /* output size */
+    orxout(debug_output) << "Size: " << hist_buffer.size() << endl;
+  }
+
+#ifndef CHATTEST
+}
+#endif
Index: code/trunk/src/orxonox/chat/ChatHistory.h
===================================================================
--- code/trunk/src/orxonox/chat/ChatHistory.h	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatHistory.h	(revision 8858)
@@ -0,0 +1,149 @@
+/*
+ *   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:
+ *      Sandro 'smerkli' Merkli
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <deque>
+#include <string>
+#include <fstream>
+#include <iostream>
+#include <cassert>
+
+/* define this if you're unit testing */
+//#define CHATTEST
+
+#ifndef CHATTEST
+#include "OrxonoxPrereqs.h"
+
+#include "util/Singleton.h"
+#include "core/BaseObject.h"
+#include "core/PathConfig.h"
+#include "chat/ChatListener.h"
+#include "infos/PlayerInfo.h"
+#include "PlayerManager.h"
+#endif
+
+#ifndef _ChatHistory_H__
+#define _ChatHistory_H__
+
+
+/* Class to implement chat history */
+#ifndef CHATTEST
+namespace orxonox
+{
+#endif
+
+  /* constructor */
+#ifndef CHATTEST
+  class _OrxonoxExport ChatHistory : public ChatListener,
+    public Singleton<ChatHistory>
+
+#else
+  class ChatHistory
+#endif
+  {
+    public:
+      /* constructors, destructors */
+#ifndef CHATTEST
+      ChatHistory();
+      friend class Singleton<ChatHistory>;
+#else
+      ChatHistory();
+#endif
+      virtual ~ChatHistory();
+
+
+    //protected:
+      /** what to do with incoming chat
+       *
+       * \param message The incoming message
+       * \param senderID Identification number of the sender
+       */
+      virtual void incomingChat(const std::string& message, const std::string& name);
+
+      /** Synchronize logfile onto the hard drive
+       *
+       * \return 0 for success, other for error
+       */
+      int syncLog();
+
+      /** debug-print: output the whole history to stdout */
+      void debug_printhist();
+
+    private:
+      /* FIELDS */
+      /** Vector to store the history in */
+      std::deque<std::string> hist_buffer;
+
+      /** Maximum number of lines stored in this history */
+      unsigned int hist_maxlines;
+
+      /** is logging enabled? */
+      bool hist_log_enabled;
+
+      /** path of logfile on the file system */
+      std::string hist_logfile_path;
+
+      /** Output file stream for logfile */
+      std::ofstream hist_logfile;
+
+#ifndef CHATTEST
+      static ChatHistory* singletonPtr_s;
+#endif
+
+
+
+      /* METHODS */
+      /** Append line to chat history
+       *
+       * \param toadd The line to add to the history
+       * \return 0 for success, other for error TODO: Throw exception
+       */
+      int chat_hist_addline( const std::string& toadd );
+
+      /** Append line to logfile
+       *
+       * \param toadd The line to add to the logfile
+       * \return 0 for success, other for error TODO: Throw exception
+       */
+      int chat_hist_logline( const std::string& toadd );
+
+      /** open logfile to log to
+       *
+       * \return 0 for success,s other for error
+       */
+      int chat_hist_openlog();
+
+
+      /** close logfile */
+      void chat_hist_closelog();
+  };
+
+#ifndef CHATTEST
+}
+#endif
+
+#endif /* _ChatHistory_H__ */
Index: code/trunk/src/orxonox/chat/ChatInputHandler.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.cc	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.cc	(revision 8858)
@@ -0,0 +1,342 @@
+/*
+ *   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:
+ *      Sandro 'smerkli' Merkli
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ChatInputHandler.h"
+
+#include <cassert>
+#include <string>
+#include <CEGUIWindow.h>
+#include <CEGUIWindowManager.h>
+#include <elements/CEGUIListbox.h>
+#include <elements/CEGUIListboxItem.h>
+#include <elements/CEGUIListboxTextItem.h>
+
+#include "util/ScopedSingletonManager.h"
+#include "core/CoreIncludes.h"
+#include "core/GUIManager.h"
+#include "core/command/ConsoleCommand.h"
+#include "core/input/InputBuffer.h"
+#include "core/input/InputManager.h"
+#include "core/input/InputState.h"
+
+#include "chat/ChatManager.h"
+#include "PlayerManager.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+  /* singleton */
+  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
+
+  /* add commands to console */
+  SetConsoleCommand( "startchat", &ChatInputHandler::activate_static );
+  SetConsoleCommand( "startchat_small", &ChatInputHandler::activate_small_static );
+
+  /* constructor */
+  ChatInputHandler::ChatInputHandler()
+  {
+    /* register the object  */
+    RegisterObject(ChatInputHandler);
+
+    /* create necessary objects */
+    this->inpbuf = new InputBuffer();
+    this->disp_offset = 0;
+    assert( this->inpbuf != NULL );
+
+    /* generate chatbox ui and chatbox-inputonly ui */
+    GUIManager::getInstance().loadGUI( "ChatBox" );
+    GUIManager::getInstance().loadGUI( "ChatBox-inputonly" );
+
+    /* setup colors */
+    setupColors();
+
+    /* configure the input buffer */
+    configureInputBuffer();
+
+    this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
+    this->inputState->setKeyHandler(this->inpbuf);
+  }
+
+  ChatInputHandler::~ChatInputHandler()
+  {
+    /* Clean up */
+    InputManager::getInstance().destroyState("chatinput");
+    delete this->inpbuf;
+  }
+
+  /* configure input buffer, sub for the constructor */
+  void ChatInputHandler::configureInputBuffer()
+  {
+    /* INSTALL CALLBACKS */
+    /* input has changed */
+    this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
+
+    /* add a line */
+    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
+    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
+
+    /* backspace */
+    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
+    //this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
+
+    /* exit the chatinputhandler thingy (tbd) */
+    this->inpbuf->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
+
+    /* delete character */
+    this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
+
+    /* cursor movement */
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
+    this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
+
+    /* GET WINDOW POINTERS */
+    input = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/input" );
+    inputonly = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox-inputonly/input" );
+
+    /* get pointer to the history window */
+    CEGUI::Window *history = CEGUI::WindowManager::getSingleton().getWindow( "orxonox/ChatBox/history" );
+
+    /* cast it to a listbox */
+    lb_history = dynamic_cast<CEGUI::Listbox*>(history);
+
+    /* assert wee */
+    assert( lb_history );
+  }
+
+  /* setup the colors, sub for the constructor */
+  void ChatInputHandler::setupColors()
+  {
+    /* auto variables */
+    float red = 1.0, green = 0.5, blue = 0.5;
+    int i = 0;
+
+    // three loops: red tones, blue tones and green tones
+    // reds
+    for( i = 0; i < NumberOfColors/3; ++i )
+    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+      green += 0.2f, blue += 0.2f;
+    }
+
+    // greens
+    red = 0.5, green = 1, blue = 0.5;
+    for( ; i < NumberOfColors*2/3; ++i )
+    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+      red += 0.2f, blue += 0.2f;
+    }
+
+    // blues
+    red = 0.5, green = 0.5, blue = 1;
+    for( ; i < NumberOfColors; ++i )
+    { this->text_colors[ i ] = CEGUI::colour( red, green, blue );
+      red += 0.2f, green += 0.2f;
+    }
+  }
+
+
+  /* activate, deactivate */
+  void ChatInputHandler::activate_static()
+  { ChatInputHandler::getInstance().activate( true ); }
+
+  void ChatInputHandler::activate_small_static()
+  { ChatInputHandler::getInstance().activate( false ); }
+
+  void ChatInputHandler::activate( bool full )
+  {
+    /* start listening */
+    InputManager::getInstance().enterState("chatinput");
+
+    /* MARK add spawning of chat widget stuff here.*/
+    if( full )
+      GUIManager::getInstance().showGUI( "ChatBox" );
+    else
+      GUIManager::getInstance().showGUI( "ChatBox-inputonly" );
+
+    this->fullchat = full;
+  }
+
+  void ChatInputHandler::deactivate()
+  {
+    /* stop listening */
+    InputManager::getInstance().leaveState("chatinput");
+
+    /* un-spawning of chat widget stuff */
+    GUIManager::getInstance().hideGUI( "ChatBox" );
+    GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
+  }
+
+
+  /* subs for incomingChat */
+  void ChatInputHandler::sub_setcolor( CEGUI::ListboxTextItem *tocolor,
+    std::string name )
+  {
+    /* sanity checks */
+    if( !tocolor )
+      orxout(internal_warning) << "Empty ListBoxTextItem given to "
+        "ChatInputhandler::sub_setcolor()." << endl;
+
+    /* "hash" the name */
+    int hash = 0;
+    for( int i = name.length(); i > 0; --i )
+      hash += name[i-1];
+    hash = hash % this->NumberOfColors;
+
+    /* set the color according to the hash */
+    tocolor->setTextColours( this->text_colors[ hash ] );
+  }
+
+  /* handle incoming chat */
+  void ChatInputHandler::incomingChat(const std::string& message, const std::string& name)
+  {
+    /* create item */
+    CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( message );
+
+    /* setup colors */
+    if (name != "")
+      sub_setcolor( toadd, name );
+
+    /* now add */
+    this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+    this->lb_history->ensureItemIsVisible(
+      dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+
+    /* make sure the history handles it */
+    this->lb_history->handleUpdatedItemData();
+  }
+
+
+  /* sub for inputchanged */
+  void ChatInputHandler::sub_adjust_dispoffset( int maxlen,
+    int cursorpos,
+    int inplen )
+  {
+    /* already start offsetting 5 characters before end */
+    if( cursorpos+5 > maxlen )
+    {
+      /* always stay 5 characters ahead of end, looks better */
+      ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0;
+
+      /* enforce visibility of cursor */
+      (disp_offset > cursorpos ) ? disp_offset = 0 : 1;
+    }
+
+    /* make sure we don't die at substr */
+    if( inplen <= disp_offset ) disp_offset = 0;
+  }
+
+  /* callbacks for InputBuffer */
+  void ChatInputHandler::inputChanged()
+  {
+    /* update the cursor and the window */
+    std::string raw = this->inpbuf->get();
+    int cursorpos = this->inpbuf->getCursorPosition();
+
+    /* get string before cursor */
+    std::string left = raw.substr( 0, cursorpos );
+
+    /* see if there's a string after the cursor */
+    std::string right = "";
+    if( raw.length() >= left.length()+1 )
+      right = raw.substr( cursorpos );
+
+    /* set the text */
+    std::string assembled = "$ " + left + "|" + right;
+
+    if( this->fullchat )
+    {
+      /* adjust curser position - magic number 5 for font width */
+      sub_adjust_dispoffset( (int)(this->input->getUnclippedInnerRect().getWidth()/6),
+        cursorpos, assembled.length() );
+      this->input->setProperty( "Text", assembled.substr( disp_offset ) );
+    }
+    else
+    {
+      /* adjust curser position - magic number 5 for font width */
+      sub_adjust_dispoffset( (int)(this->inputonly->getUnclippedInnerRect().getWidth()/6),
+        cursorpos, assembled.length() );
+      this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
+    }
+
+    /* reset display offset */
+    disp_offset = 0;
+  }
+
+  void ChatInputHandler::addline()
+  {
+    /* actually do send what was input */
+    /* a) get the string out of the inputbuffer */
+    std::string msgtosend = this->inpbuf->get();
+
+    if( msgtosend.length() == 0 )
+    { this->deactivate();
+      return;
+    }
+
+    /* b) clear the input buffer */
+    if (this->inpbuf->getSize() > 0)
+      this->inpbuf->clear();
+
+    /* c) send the chat via some call */
+    ChatManager::chat( msgtosend );
+
+    /* d) stop listening to input - only if this is not fullchat */
+    if( !this->fullchat )
+      this->deactivate();
+
+  }
+
+  void ChatInputHandler::backspace()
+  { this->inpbuf->removeBehindCursor(); }
+
+  void ChatInputHandler::deleteChar()
+  { this->inpbuf->removeAtCursor(); }
+
+  void ChatInputHandler::cursorRight()
+  { this->inpbuf->increaseCursor(); }
+
+  void ChatInputHandler::cursorLeft()
+  { this->inpbuf->decreaseCursor(); }
+
+  void ChatInputHandler::cursorEnd()
+  { this->inpbuf->setCursorToEnd(); }
+
+  void ChatInputHandler::cursorHome()
+  { this->inpbuf->setCursorToBegin(); }
+
+  void ChatInputHandler::exit()
+  {
+    /* b) clear the input buffer */
+    if (this->inpbuf->getSize() > 0)
+      this->inpbuf->clear();
+
+    /* d) stop listening to input  */
+    this->deactivate();
+  }
+
+}
Index: code/trunk/src/orxonox/chat/ChatInputHandler.h
===================================================================
--- code/trunk/src/orxonox/chat/ChatInputHandler.h	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatInputHandler.h	(revision 8858)
@@ -0,0 +1,133 @@
+/*
+ *   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:
+ *      Sandro 'smerkli' Merkli
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ChatInputHandler_H__
+#define _ChatInputHandler_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <CEGUIForwardRefs.h>
+#include <CEGUIcolour.h>
+
+#include "util/Singleton.h"
+#include "chat/ChatListener.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+  /* class to handle chat using an InputBuffer */
+  class _OrxonoxExport ChatInputHandler  // tolua_export
+    : public Singleton<ChatInputHandler>, public ChatListener
+  { // tolua_export
+    private:
+      /** Input buffer, to be used to catch input from the
+       * keyboard
+       */
+      InputBuffer *inpbuf;
+      int disp_offset, width;
+      bool fullchat;
+
+      /* colors for nickname coloring */
+      static const int NumberOfColors = 10;
+      CEGUI::colour text_colors[ NumberOfColors ];
+
+      /** input state */
+      InputState *inputState;
+
+      /** setup input buffer, the constructor calls this */
+      void configureInputBuffer();
+
+      /** adjust display offset depending on cursor position */
+      void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
+
+      /** singleton pointer */
+      static ChatInputHandler* singletonPtr_s;
+
+      /** cegui window handles */
+      CEGUI::Window *input, *inputonly;
+
+      /** cegui handle for the history window */
+      CEGUI::Listbox *lb_history;
+
+      /* methods to deal with colors */
+      void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
+        std::string name );
+
+      void setupColors();
+
+      /* callbacks for input handler */
+      void inputChanged();
+      void addline();
+      void backspace();
+      void deleteChar();
+      void cursorRight();
+      void cursorLeft();
+      void cursorEnd();
+      void cursorHome();
+      void exit();
+
+    public:
+      /** constructor */
+      ChatInputHandler();
+      ~ChatInputHandler();
+      friend class Singleton<ChatInputHandler>;
+
+      static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); }  // tolua_export
+
+      /** start listening */
+      static void activate_static();
+
+      /** stop listening */
+      static void activate_small_static();
+
+      /** \param message the message text
+       * \param senderID ID of the player who sent the message
+       *
+       * Deal with incoming chat (which means in our case: Add it to the
+       * history window of the full chat window)
+       */
+      void incomingChat(const std::string& message, const std::string& name);
+
+      /** \param full true means show full chat window with history,
+            false means show only an input line
+       *
+       * Show the chat window and redirect the game's keyboard input
+       * into it.
+       */
+      void activate( bool full );
+
+      /** Deactivate the chat window, meaning: hide it. */
+      void deactivate();  // tolua_export
+
+  };  // tolua_export
+
+
+}  // tolua_export
+
+
+#endif /*_ChatInputHandler_H__*/
Index: code/trunk/src/orxonox/chat/ChatListener.h
===================================================================
--- code/trunk/src/orxonox/chat/ChatListener.h	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatListener.h	(revision 8858)
@@ -0,0 +1,60 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ChatListener_H__
+#define _ChatListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+        @brief Classes inheriting from this interface get a notification whenever a chat
+        message was sent through ChatManager.
+    */
+    class _OrxonoxExport ChatListener : virtual public OrxonoxClass
+    {
+        friend class ChatManager;
+
+        public:
+            ChatListener(); // implemented in ChatManager.cc
+            virtual ~ChatListener() {}
+
+        protected:
+            /**
+                @brief Gets called whenever a chat message was sent through ChatManager.
+                @param message The whole message (including name of the sender if available)
+                @param name The name of the sender (if available, otherwise "")
+            */
+            virtual void incomingChat(const std::string& message, const std::string& name) = 0;
+    };
+}
+
+#endif /* _ChatListener_H__ */
Index: code/trunk/src/orxonox/chat/ChatManager.cc
===================================================================
--- code/trunk/src/orxonox/chat/ChatManager.cc	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatManager.cc	(revision 8858)
@@ -0,0 +1,120 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "ChatManager.h"
+#include "ChatListener.h"
+
+#include "util/ScopedSingletonManager.h"
+#include "core/CoreIncludes.h"
+#include "core/command/ConsoleCommand.h"
+#include "network/Host.h"
+
+#include "PlayerManager.h"
+#include "infos/PlayerInfo.h"
+
+namespace orxonox
+{
+    ManageScopedSingleton(ChatManager, ScopeID::Root, false);
+
+    SetConsoleCommand("chat", &ChatManager::chat).defaultValue(1, NETWORK_PEER_ID_BROADCAST);
+
+    ChatManager::ChatManager()
+    {
+        RegisterObject(ChatManager);
+    }
+
+    /**
+        @brief Sends a message (usually gameplay related) without explicit sender to the chat.
+        @param message The message
+        @param targetID The client ID (network) of the receiver. Usually the broadcast ID
+    */
+    /*static*/ void ChatManager::message(const std::string& message, unsigned int targetID)
+    {
+        unsigned int sourceID = NETWORK_PEER_ID_UNKNOWN;
+
+        // only the server should send gameplay messages through the network. otherwise display the message locally
+        if (GameMode::isServer())
+            Host::sendChat(message, sourceID, targetID);
+        else
+            ChatManager::getInstance().incomingChat(message, sourceID);
+    }
+
+    /**
+        @brief Sends a chat message with the client as its sender to the chat.
+        @param message The message
+        @param targetID The client ID (network) of the receiver. Usually the broadcast ID
+    */
+    /*static*/ void ChatManager::chat(const std::string& message, unsigned int targetID)
+    {
+        unsigned int sourceID = Host::getPlayerID();
+
+        // if connected to the network, send chat messages online. otherwise display chat locally
+        if (GameMode::isServer() || GameMode::isClient())
+            Host::sendChat(message, sourceID, targetID);
+        else
+            ChatManager::getInstance().incomingChat(message, sourceID);
+    }
+
+    /**
+        @brief Inherited callback from NetworkChatListener, but gets also called directly
+        by ChatManager itself if the client is offline. Distributes an incoming chat message
+        to all ChatListeners.
+        @param message The message
+        @param sourceID The client ID (network) of the sender
+    */
+    void ChatManager::incomingChat(const std::string& message, unsigned int sourceID)
+    {
+        std::string text = message;
+        std::string name;
+
+        // get the name of the sender and prepend it to the text message
+        if (sourceID != NETWORK_PEER_ID_UNKNOWN)
+        {
+            PlayerInfo* player = PlayerManager::getInstance().getClient(sourceID);
+            if (player)
+            {
+                name = player->getName();
+                text = name + ": " + message;
+            }
+        }
+
+        // notify all listeners
+        for (ObjectList<ChatListener>::iterator it = ObjectList<ChatListener>::begin(); it != ObjectList<ChatListener>::end(); ++it)
+            it->incomingChat(text, name);
+    }
+
+
+    //////////////////////////////////////////////////////////////////////////
+    // ChatListener                                                         //
+    //////////////////////////////////////////////////////////////////////////
+
+    ChatListener::ChatListener()
+    {
+        RegisterRootObject(ChatListener);
+    }
+}
Index: code/trunk/src/orxonox/chat/ChatManager.h
===================================================================
--- code/trunk/src/orxonox/chat/ChatManager.h	(revision 8858)
+++ code/trunk/src/orxonox/chat/ChatManager.h	(revision 8858)
@@ -0,0 +1,63 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#ifndef _ChatManager_H__
+#define _ChatManager_H__
+
+#include "OrxonoxPrereqs.h"
+#include "util/Singleton.h"
+#include "network/NetworkChatListener.h"
+
+namespace orxonox
+{
+    /**
+        @brief This class collects and distributes chat messages. If the client is online,
+        all chat messages are sent and received through the network. Otherwise chat is handled
+        directly by this class.
+    */
+    class _OrxonoxExport ChatManager : public Singleton<ChatManager>, public NetworkChatListener
+    {
+        friend class Singleton<ChatManager>;
+
+        public:
+            ChatManager();
+            virtual ~ChatManager() {}
+
+            static void message(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST);
+            static void chat(const std::string& message, unsigned int targetID = NETWORK_PEER_ID_BROADCAST);
+
+        protected:
+            ChatManager(const ChatManager&);
+
+            virtual void incomingChat(const std::string& message, unsigned int sourceID);
+
+            static ChatManager* singletonPtr_s;
+    };
+}
+
+#endif /* _ChatManager_H__ */
Index: code/trunk/src/orxonox/collisionshapes/CollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CollisionShape.cc	(revision 8855)
+++ code/trunk/src/orxonox/collisionshapes/CollisionShape.cc	(revision 8858)
@@ -203,5 +203,5 @@
         if(scale_.crossProduct(scale).squaredLength() != 0.0f)
         {
-            CCOUT(2) << "Warning: Non-uniform scaling is not yet supported." << endl;
+            orxout(internal_warning) << "Non-uniform scaling is not yet supported." << endl;
             return;
         }
Index: code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc
===================================================================
--- code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc	(revision 8855)
+++ code/trunk/src/orxonox/collisionshapes/CompoundCollisionShape.cc	(revision 8858)
@@ -98,5 +98,5 @@
         if (this->attachedShapes_.find(shape) != this->attachedShapes_.end())
         {
-            CCOUT(2) << "Warning: Attaching a CollisionShape twice is not yet supported." << std::endl;
+            orxout(internal_warning) << "Attaching a CollisionShape twice is not yet supported." << endl;
             return;
         }
@@ -139,5 +139,5 @@
         }
         else
-            CCOUT(2) << "Warning: Cannot detach non child collision shape" << std::endl;
+            orxout(internal_warning) << "Cannot detach non child collision shape" << endl;
     }
 
@@ -168,5 +168,5 @@
         if (it == this->attachedShapes_.end())
         {
-            CCOUT(2) << "Warning: Cannot update child shape: Instance not a child." << std::endl;
+            orxout(internal_warning) << "Cannot update child shape: Instance not a child." << endl;
             return;
         }
Index: code/trunk/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/ArtificialController.cc	(revision 8855)
+++ code/trunk/src/orxonox/controllers/ArtificialController.cc	(revision 8858)
@@ -98,5 +98,5 @@
                     if (it->myMaster_ == this)
                     {
-                        COUT(1) << "error: " << this << " is still master in " << (*it) << std::endl;
+                        orxout(internal_error) << this << " is still master in " << (*it) << endl;
                         it->myMaster_ = 0;
                     }
@@ -107,5 +107,5 @@
                         if (it2 != it->slaves_.end())
                         {
-                            COUT(1) << "error: " << this << " is still slave in " << (*it) << std::endl;
+                            orxout(internal_error) << this << " is still slave in " << (*it) << endl;
                             it->slaves_.erase(it2);
                         }
@@ -737,5 +737,5 @@
         float speedDiv = this->getControllableEntity()->getVelocity().squaredLength() - this->target_->getVelocity().squaredLength();
 
-COUT(0) << "~follow distance: " << distance << "SpeedCounter: " << this->speedCounter_ << "~speedDiv: " << speedDiv << std::endl;
+orxout() << "~follow distance: " << distance << "SpeedCounter: " << this->speedCounter_ << "~speedDiv: " << speedDiv << endl;
         if (distance < 800)
         {
Index: code/trunk/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/HumanController.cc	(revision 8855)
+++ code/trunk/src/orxonox/controllers/HumanController.cc	(revision 8858)
@@ -93,5 +93,5 @@
             Camera* camera = HumanController::localController_s->controllableEntity_->getCamera();
             if (!camera)
-                COUT(3) << "HumanController, Warning: Using a ControllableEntity without Camera" << std::endl;
+                orxout(internal_warning) << "HumanController, Warning: Using a ControllableEntity without Camera" << endl;
         }
     }
@@ -197,5 +197,5 @@
             
             this->controllableEntity_->boost(this->boosting_);
-            COUT(4) << "Start boosting" << endl;
+//            orxout() << "Start boosting" << endl;
         }
     }
@@ -211,5 +211,5 @@
 
         this->controllableEntity_->boost(this->boosting_);
-        COUT(4) << "Stop boosting" << endl;
+//        orxout() << "Stop boosting" << endl;
     }
 
@@ -257,6 +257,6 @@
             const Quaternion& orientation = HumanController::localController_s->controllableEntity_->getOrientation();
 
-            COUT(0) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" ";
-            COUT(0) << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << std::endl;
+            orxout(message) << "position=\"" << position.x << ", " << position.y << ", " << position.z << "\" "
+                            << "orientation=\"" << orientation.w << ", " << orientation.x << ", " << orientation.y << ", " << orientation.z << "\"" << endl;
         }
     }
Index: code/trunk/src/orxonox/controllers/NewHumanController.cc
===================================================================
--- code/trunk/src/orxonox/controllers/NewHumanController.cc	(revision 8855)
+++ code/trunk/src/orxonox/controllers/NewHumanController.cc	(revision 8858)
@@ -388,5 +388,5 @@
         for (itr = result.begin(); itr != result.end(); ++itr)
         {
-//             CCOUT(0) << "testing object as target" << endl;
+//             orxout() << "testing object as target" << endl;
             if (itr->movable->isInScene() && itr->movable->getMovableType() == "Entity" && itr->distance > 200)
             {
Index: code/trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.cc	(revision 8855)
+++ code/trunk/src/orxonox/gamestates/GSClient.cc	(revision 8858)
@@ -29,5 +29,4 @@
 #include "GSClient.h"
 
-#include "util/Debug.h"
 #include "util/Exception.h"
 #include "core/CommandLineParser.h"
@@ -53,4 +52,6 @@
     void GSClient::activate()
     {
+        orxout(user_status) << "Starting client" << endl;
+
         GameMode::setIsClient(true);
 
Index: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 8855)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 8858)
@@ -74,4 +74,6 @@
     void GSLevel::activate()
     {
+        orxout(user_status) << "Loading level" << endl;
+
         if (GameMode::showsGraphics())
         {
@@ -155,5 +157,4 @@
 
         // call the loader
-        COUT(0) << "Loading level..." << std::endl;
         startFile_ = new XMLFile(LevelManager::getInstance().getDefaultLevel());
         bool loaded = Loader::open(startFile_);
@@ -169,5 +170,5 @@
         delete startFile_;
 
-        COUT(3) << "Unloaded level. Remaining objects:" << std::endl;
+        orxout(internal_info) << "Remaining objects:" << endl;
         unsigned int i = 0;
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); ++it)
@@ -176,12 +177,12 @@
             if (find == this->staticObjects_.end())
             {
-                COUT(3) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << std::endl;
+                orxout(internal_info) << ++i << ": " << it->getIdentifier()->getName() << " (" << *it << "), references: " << it->getReferenceCount() << endl;
             }
         }
-        COUT(3) << i << " objects remaining.";
+        orxout(internal_info) << i << " objects remaining.";
         if (i == 0)
-            COUT(3) << " Well done!" << std::endl;
+            orxout(internal_info) << " Well done!" << endl;
         else
-            COUT(3) << " Try harder!" << std::endl;
+            orxout(internal_info) << " Try harder!" << endl;
     }
 
Index: code/trunk/src/orxonox/gamestates/GSMainMenu.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMainMenu.cc	(revision 8855)
+++ code/trunk/src/orxonox/gamestates/GSMainMenu.cc	(revision 8858)
@@ -95,4 +95,6 @@
     void GSMainMenu::activate()
     {
+        orxout(user_status) << "Loading main menu" << endl;
+
         // show main menu
         GraphicsManager::getInstance().setCamera(this->camera_);
Index: code/trunk/src/orxonox/gamestates/GSMasterServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSMasterServer.cc	(revision 8855)
+++ code/trunk/src/orxonox/gamestates/GSMasterServer.cc	(revision 8858)
@@ -30,5 +30,5 @@
 #include "GSMasterServer.h"
 
-#include "util/Debug.h"
+#include "util/Output.h"
 #include "core/Game.h"
 #include "core/GameMode.h"
@@ -50,10 +50,10 @@
   void GSMasterServer::activate()
   {
+    orxout(user_status) << "Starting masterserver" << endl;
+
     /* TODO make this work for masterserver as well */
     //GameMode::setIsServer(true);
 
     this->mserver = new MasterServer();
-    COUT(0) << "Loading masterserver mode" << std::endl;
-
     this->mserver->run();
   }
Index: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc	(revision 8855)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc	(revision 8858)
@@ -77,10 +77,10 @@
         {
             if (dynamic_cast<Synchronisable*>(*it))
-                COUT(0) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << std::endl;
+                orxout(debug_output) << "object: " << it->getIdentifier()->getName() << " id: " << dynamic_cast<Synchronisable*>(*it)->getObjectID() << endl;
             else
-                COUT(0) << "object: " << it->getIdentifier()->getName() << std::endl;
+                orxout(debug_output) << "object: " << it->getIdentifier()->getName() << endl;
             nr++;
         }
-        COUT(0) << "currently got " << nr << " objects" << std::endl;
+        orxout(debug_output) << "currently got " << nr << " objects" << endl;
     }
 
Index: code/trunk/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.cc	(revision 8855)
+++ code/trunk/src/orxonox/gamestates/GSServer.cc	(revision 8858)
@@ -29,5 +29,5 @@
 #include "GSServer.h"
 
-#include "util/Debug.h"
+#include "util/Output.h"
 #include "core/CommandLineParser.h"
 #include "core/Game.h"
@@ -54,8 +54,10 @@
     void GSServer::activate()
     {
+        orxout(user_status) << "Starting server" << endl;
+
         GameMode::setIsServer(true);
 
         this->server_ = new Server(CommandLineParser::getValue("port"));
-        COUT(0) << "Loading scene in server mode" << std::endl;
+        orxout(user_status) << "Loading scene in server mode" << endl;
 
         server_->open();
Index: code/trunk/src/orxonox/gametypes/Asteroids.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Asteroids.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/Asteroids.cc	(revision 8858)
@@ -30,5 +30,5 @@
 
 #include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
 #include "worldentities/pawns/Pawn.h"
 
@@ -74,6 +74,5 @@
 
         std::string message("The match has started! Reach the first chekpoint within 15 seconds! But be aware, there may be pirates around...");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
 
     }
@@ -84,6 +83,5 @@
 
         std::string message("The match has ended.");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
     }
 }
Index: code/trunk/src/orxonox/gametypes/Deathmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Deathmatch.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/Deathmatch.cc	(revision 8858)
@@ -30,5 +30,5 @@
 
 #include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
 #include "infos/PlayerInfo.h"
 #include "worldentities/pawns/Pawn.h"
@@ -48,6 +48,5 @@
 
         std::string message("The match has started!");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
     }
 
@@ -57,6 +56,5 @@
 
         std::string message("The match has ended.");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
     }
 
@@ -66,6 +64,5 @@
 
         const std::string& message = player->getName() + " entered the game";
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
     }
 
@@ -77,6 +74,5 @@
         {
             const std::string& message = player->getName() + " left the game";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
 
@@ -91,6 +87,5 @@
         {
             const std::string& message = player->getOldName() + " changed name to " + player->getName();
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
 
@@ -113,6 +108,5 @@
                 message = victim->getPlayer()->getName() + " died";
 
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
 
@@ -127,6 +121,5 @@
         {
             const std::string& message = player->getName() + " scores!";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
     }
Index: code/trunk/src/orxonox/gametypes/Dynamicmatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Dynamicmatch.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/Dynamicmatch.cc	(revision 8858)
@@ -49,5 +49,5 @@
 #include "core/CoreIncludes.h"
 #include "core/command/Executor.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
 #include "infos/PlayerInfo.h"
 #include "worldentities/pawns/Pawn.h"
@@ -342,7 +342,6 @@
         numberOf[chaser]++;
         Gametype::playerEntered(player);
-        const std::string& message6 = player->getName() + " entered the game";
-        COUT(0) << message6 << std::endl;
-        Host::Broadcast(message6);
+        const std::string& message = player->getName() + " entered the game";
+        ChatManager::message(message);
     }
 
@@ -359,6 +358,5 @@
             }
             const std::string& message = player->getName() + " left the game";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
             //remove player from map
             playerParty_.erase (player);
@@ -617,6 +615,5 @@
         {
             const std::string& message = player->getOldName() + " changed name to " + player->getName();
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
 
@@ -630,6 +627,5 @@
         {
             std::string message("Dynamicmatch started!");
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
         else if(tutorial) // Announce selectionphase
@@ -647,6 +643,5 @@
     {
         std::string message("Earn points:\n\n\n\tIf you're red: Chase the blue player!\n\n\tIf you're blue shoot at a red player or hide.\n\n\tIf you're green: You've got the licence to kill red players!");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
         callInstructions_.setTimer(10, false, createExecutor(createFunctor(&Dynamicmatch::furtherInstructions, this)));
     }
@@ -655,6 +650,5 @@
     {
         std::string message("After 3 Minutes the game is over.");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
     }*/
     void Dynamicmatch::end()
@@ -663,6 +657,5 @@
 
         std::string message("Time out. Press F2 to see the points you scored.");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
     }
     SpawnPoint* Dynamicmatch::getBestSpawnPoint(PlayerInfo* player) const
Index: code/trunk/src/orxonox/gametypes/Gametype.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/Gametype.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/Gametype.cc	(revision 8858)
@@ -297,5 +297,5 @@
             }
             else
-                COUT(2) << "Warning: Killed Pawn was not in the playerlist" << std::endl;
+                orxout(internal_warning) << "Killed Pawn was not in the playerlist" << endl;
         }
     }
@@ -344,5 +344,5 @@
             }
 
-            COUT(2) << "Warning: Fallback SpawnPoint was used, because there were no active SpawnPoints." << endl;
+            orxout(internal_warning) << "Fallback SpawnPoint was used because there were no active SpawnPoints." << endl;
             return fallbackSpawnPoint;
         }
@@ -444,5 +444,5 @@
         else
         {
-            COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+            orxout(user_error) << "No SpawnPoints in current Gametype" << endl;
             abort();
         }
@@ -461,5 +461,5 @@
         else
         {
-            COUT(1) << "Error: No SpawnPoints in current Gametype" << std::endl;
+            orxout(user_error) << "No SpawnPoints in current Gametype" << endl;
             abort();
         }
Index: code/trunk/src/orxonox/gametypes/LastManStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastManStanding.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/LastManStanding.cc	(revision 8858)
@@ -30,5 +30,5 @@
 
 #include "core/CoreIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
 #include "infos/PlayerInfo.h"
 #include "worldentities/pawns/Pawn.h"
@@ -90,5 +90,5 @@
                 const std::string& message = ""; // resets Camper-Warning-message
                 this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
-            }    
+            }
         }
         return true;
@@ -105,6 +105,5 @@
             this->playersAlive--;
             const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
 
@@ -128,5 +127,5 @@
     {
         Gametype::end();
-        
+
         for (std::map<PlayerInfo*, int>::iterator it = this->playerLives_.begin(); it != this->playerLives_.end(); ++it)
         {
@@ -148,5 +147,5 @@
             return 0;
     }
-    
+
     int LastManStanding::getNumPlayersAlive() const
     {
@@ -190,5 +189,5 @@
         this->timeToAct_[player]=timeRemaining+3.0f+respawnDelay;//reset timer
         this->playerDelayTime_[player]=respawnDelay;
-        
+
         std::map<PlayerInfo*, Player>::iterator it = this->players_.find(player);
         if (it != this->players_.end())
@@ -198,5 +197,5 @@
             const std::string& message = ""; // resets Camper-Warning-message
             this->gtinfo_->sendFadingMessage(message,it->first->getClientID());
-        }  
+        }
     }
 
@@ -239,9 +238,9 @@
             }
             for (std::map<PlayerInfo*, float>::iterator it = this->timeToAct_.begin(); it != this->timeToAct_.end(); ++it)
-            {   
+            {
                 if (playerGetLives(it->first)<=0)//Players without lives shouldn't be affected by time.
-                    continue;     
+                    continue;
                 it->second-=dt;//Decreases punishment time.
-                if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up. 
+                if (!inGame_[it->first])//Manages respawn delay - player is forced to respawn after the delaytime is used up.
                 {
                     playerDelayTime_[it->first]-=dt;
Index: code/trunk/src/orxonox/gametypes/LastTeamStanding.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/LastTeamStanding.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/LastTeamStanding.cc	(revision 8858)
@@ -30,6 +30,5 @@
 
 #include "core/CoreIncludes.h"
-#include "network/NetworkPrereqs.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
 #include "infos/PlayerInfo.h"
 #include "worldentities/pawns/Pawn.h"
@@ -119,6 +118,5 @@
                 this->teamsAlive--;
             const std::string& message = victim->getPlayer()->getName() + " has lost all lives";
-            COUT(0) << message << std::endl;
-            Host::Broadcast(message);
+            ChatManager::message(message);
         }
         return allow;
Index: code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/TeamBaseMatch.cc	(revision 8858)
@@ -141,7 +141,7 @@
             return;
 
-        COUT(0) << "Points standing:" << std::endl << "Team 1: "<< pointsTeam1_ << std::endl << "Team 2: " << pointsTeam2_ << std::endl;
-        if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) COUT(0) << "Team 1 is near victory!" << std::endl;
-        if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) COUT(0) << "Team 2 is near victory!" << std::endl;
+        orxout(message) << "Points standing:" << '\n' << "Team 1: "<< pointsTeam1_ << '\n' << "Team 2: " << pointsTeam2_ << endl;
+        if(pointsTeam1_ >=1700 && pointsTeam1_ < 2000) orxout(message) << "Team 1 is near victory!" << endl;
+        if(pointsTeam2_ >=1700 && pointsTeam2_ < 2000) orxout(message) << "Team 2 is near victory!" << endl;
     }
 
@@ -179,10 +179,10 @@
             if (this->pointsTeam1_ > this->pointsTeam2_)
             {
-                COUT(0) << "Team 1 has won the match" << std::endl;
+                orxout(message) << "Team 1 has won the match" << endl;
                 winningteam = 0;
             }
             else
             {
-                COUT(0) << "Team 2 has won the match" << std::endl;
+                orxout(message) << "Team 2 has won the match" << endl;
                 winningteam = 1;
             }
Index: code/trunk/src/orxonox/gametypes/UnderAttack.cc
===================================================================
--- code/trunk/src/orxonox/gametypes/UnderAttack.cc	(revision 8855)
+++ code/trunk/src/orxonox/gametypes/UnderAttack.cc	(revision 8858)
@@ -32,5 +32,5 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
-#include "network/Host.h"
+#include "chat/ChatManager.h"
 #include "worldentities/pawns/Destroyer.h"
 #include "infos/PlayerInfo.h"
@@ -70,6 +70,5 @@
         this->end(); //end gametype
         std::string message("Ship destroyed! Team 0 has won!");
-        COUT(0) << message << std::endl;
-        Host::Broadcast(message);
+        ChatManager::message(message);
         this->gameEnded_ = true;
 
@@ -153,6 +152,5 @@
                 this->end();
                 std::string message("Time is up! Team 1 has won!");
-                COUT(0) << message << std::endl;
-                Host::Broadcast(message);
+                ChatManager::message(message);
 
                 for (std::map<PlayerInfo*, int>::iterator it = this->teamnumbers_.begin(); it != this->teamnumbers_.end(); ++it)
@@ -173,6 +171,5 @@
                 const std::string& message = multi_cast<std::string>(timesequence_) + " seconds left!";
 /*
-                COUT(0) << message << std::endl;
-                Host::Broadcast(message);
+                ChatManager::message(message);
 */
                 this->gtinfo_->sendAnnounceMessage(message);
Index: code/trunk/src/orxonox/graphics/AnimatedModel.cc
===================================================================
--- code/trunk/src/orxonox/graphics/AnimatedModel.cc	(revision 8855)
+++ code/trunk/src/orxonox/graphics/AnimatedModel.cc	(revision 8858)
@@ -22,5 +22,6 @@
  *   Author:
  *      Benjamin de Capitani
- *
+ *   Co-authors:
+ *      ...
  *
  */
Index: code/trunk/src/orxonox/graphics/AnimatedModel.h
===================================================================
--- code/trunk/src/orxonox/graphics/AnimatedModel.h	(revision 8855)
+++ code/trunk/src/orxonox/graphics/AnimatedModel.h	(revision 8858)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Fabian 'x3n' Landau
+ *      Benjamin de Capitani
  *   Co-authors:
  *      ...
Index: code/trunk/src/orxonox/graphics/CEGuiSample.cc
===================================================================
--- code/trunk/src/orxonox/graphics/CEGuiSample.cc	(revision 8855)
+++ 	(revision )
@@ -1,304 +1,0 @@
-/***********************************************************************
-    filename:   CEGuiSample.cpp
-    created:    24/9/2004
-    author:     Paul D Turner
-*************************************************************************/
-/***************************************************************************
- *   Copyright (C) 2004 - 2008 Paul D Turner & The CEGUI Development Team
- *
- *   Permission is hereby granted, free of charge, to any person obtaining
- *   a copy of this software and associated documentation files (the
- *   "Software"), to deal in the Software without restriction, including
- *   without limitation the rights to use, copy, modify, merge, publish,
- *   distribute, sublicense, and/or sell copies of the Software, and to
- *   permit persons to whom the Software is furnished to do so, subject to
- *   the following conditions:
- *
- *   The above copyright notice and this permission notice shall be
- *   included in all copies or substantial portions of the Software.
- *
- *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- *   OTHER DEALINGS IN THE SOFTWARE.
- ***************************************************************************/
-#include "CEGuiSample.h"
-
-#ifdef HAVE_CONFIG_H
-#   include "config.h"
-#endif
-#include "CEGUISamplesConfig.h"
-
-// includes for renderer selector classes
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#   include "Win32CEGuiRendererSelector.h"
-#elif defined(__linux__)
-#   ifdef CEGUI_SAMPLES_USE_GTK2
-#       include "GTK2CEGuiRendererSelector.h"
-#   else
-#       include "CLICEGuiRendererSelector.h"
-#   endif
-#elif defined(__APPLE__)
-#   include "MacCEGuiRendererSelector.h"
-#endif
-
-// includes for application types
-#ifdef CEGUI_SAMPLES_USE_OGRE
-#   include "CEGuiOgreBaseApplication.h"
-#endif
-#ifdef CEGUI_SAMPLES_USE_OPENGL
-#   include "CEGuiOpenGLBaseApplication.h"
-#endif
-#ifdef CEGUI_SAMPLES_USE_IRRLICHT
-#   include "CEGuiIrrlichtBaseApplication.h"
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTFB
-#   include "CEGuiDirectFBBaseApplication.h"
-#endif
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#   ifdef CEGUI_SAMPLES_USE_DIRECTX_8
-#       include "CEGuiD3D81BaseApplication.h"
-#   endif
-#   ifdef CEGUI_SAMPLES_USE_DIRECTX_9
-#       include "CEGuiD3D9BaseApplication.h"
-#   endif
-#   ifdef CEGUI_SAMPLES_USE_DIRECTX_10
-#       include "CEGuiD3D10BaseApplication.h"
-#   endif
-#endif
-// now we include the base CEGuiBaseApplication just in case someone has managed to
-// get this far without any of the renderers.  This ensures the framework will build,
-// although there will be no renderers available for selection in the samples.
-#include "CEGuiBaseApplication.h"
-
-#include "CEGUI.h"
-
-#ifdef CEGUI_WITH_XERCES
-#   include "CEGUIXercesParser.h"
-#endif
-
-// Include iostream if not on windows.
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#else
-#    include <iostream>
-#endif
-
-
-/*************************************************************************
-    Constructor
-*************************************************************************/
-CEGuiSample::CEGuiSample() :
-        d_rendererSelector(0),
-        d_sampleApp(0)
-{}
-
-
-/*************************************************************************
-    Destructor
-*************************************************************************/
-CEGuiSample::~CEGuiSample()
-{
-    if (d_sampleApp)
-    {
-        d_sampleApp->cleanup();
-        delete d_sampleApp;
-    }
-
-    if (d_rendererSelector)
-    {
-        delete d_rendererSelector;
-    }
-
-}
-
-
-/*************************************************************************
-    Application entry point
-*************************************************************************/
-int CEGuiSample::run()
-{
-    try
-    {
-        if (initialise())
-            cleanup();
-    }
-    catch (CEGUI::Exception& exc)
-    {
-        outputExceptionMessage(exc.getMessage().c_str());
-    }
-    catch (std::exception& exc)
-    {
-        outputExceptionMessage(exc.what());
-    }
-    catch(...)
-    {
-        outputExceptionMessage("Unknown exception was caught!");
-    }
-
-    return 0;
-}
-
-
-/*************************************************************************
-    Initialise the sample application
-*************************************************************************/
-bool CEGuiSample::initialise()
-{
-    // Setup renderer selection dialog for Win32
-#if defined( __WIN32__ ) || defined( _WIN32 )
-    d_rendererSelector = new Win32CEGuiRendererSelector;
-
-    // enable renderer types supported for Win32
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_8
-    d_rendererSelector->setRendererAvailability(Direct3D81GuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_9
-    d_rendererSelector->setRendererAvailability(Direct3D9GuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_10
-    d_rendererSelector->setRendererAvailability(Direct3D10GuiRendererType);
-#endif
-
-#elif defined(__linux__)
-    // decide which method to use for renderer selection
-#   ifdef CEGUI_SAMPLES_USE_GTK2
-        d_rendererSelector = new GTK2CEGuiRendererSelector();
-#   else
-        d_rendererSelector = new CLICEGuiRendererSelector();
-#   endif
-
-#elif defined(__APPLE__)
-     d_rendererSelector = new MacCEGuiRendererSelector();
-#endif
-
-    // enable available renderer types
-#ifdef CEGUI_SAMPLES_USE_OGRE
-    d_rendererSelector->setRendererAvailability(OgreGuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_OPENGL
-    d_rendererSelector->setRendererAvailability(OpenGLGuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_IRRLICHT
-    d_rendererSelector->setRendererAvailability(IrrlichtGuiRendererType);
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTFB
-    d_rendererSelector->setRendererAvailability(DirectFBGuiRendererType);
-#endif
-
-    // get selection from user
-    if (d_rendererSelector->invokeDialog())
-    {
-        // create appropriate application type based upon users selection
-        switch(d_rendererSelector->getSelectedRendererType())
-        {
-#ifdef CEGUI_SAMPLES_USE_OGRE
-        case OgreGuiRendererType:
-            d_sampleApp = new CEGuiOgreBaseApplication();
-            break;
-#endif
-#if defined( __WIN32__ ) || defined( _WIN32 )
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_8
-        case Direct3D81GuiRendererType:
-            d_sampleApp = new CEGuiD3D81BaseApplication();
-            break;
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_9
-        case Direct3D9GuiRendererType:
-            d_sampleApp = new CEGuiD3D9BaseApplication();
-            break;
-#endif // DX9
-#ifdef CEGUI_SAMPLES_USE_DIRECTX_10
-        case Direct3D10GuiRendererType:
-            d_sampleApp = new CEGuiD3D10BaseApplication();
-            break;
-#endif // DX10
-#endif // Win32
-#ifdef CEGUI_SAMPLES_USE_OPENGL
-        case OpenGLGuiRendererType:
-            d_sampleApp = new CEGuiOpenGLBaseApplication();
-            break;
-#endif
-#ifdef CEGUI_SAMPLES_USE_IRRLICHT
-        case IrrlichtGuiRendererType:
-            d_sampleApp = new CEGuiIrrlichtBaseApplication();
-            break;
-#endif
-#ifdef CEGUI_SAMPLES_USE_DIRECTFB
-        case DirectFBGuiRendererType:
-            d_sampleApp = new CEGuiDirectFBBaseApplication();
-            break;
-#endif
-
-        default:
-            throw CEGUI::GenericException("No renderer was selected!");
-            break;
-        }
-
-        // set the default resource groups to be used
-        CEGUI::Imageset::setDefaultResourceGroup("imagesets");
-        CEGUI::Font::setDefaultResourceGroup("fonts");
-        CEGUI::Scheme::setDefaultResourceGroup("schemes");
-        CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
-        CEGUI::WindowManager::setDefaultResourceGroup("layouts");
-        CEGUI::ScriptModule::setDefaultResourceGroup("lua_scripts");
-#ifdef CEGUI_WITH_XERCES
-        CEGUI::XercesParser::setSchemaDefaultResourceGroup("schemas");
-#endif
-
-        // execute the base application (which sets up the demo via 'this' and runs it.
-        if (d_sampleApp->execute(this))
-        {
-            // signal that app initialised and ran
-            return true;
-        }
-
-        // sample app did not initialise, delete the object.
-        delete d_sampleApp;
-        d_sampleApp = 0;
-    }
-
-    // delete renderer selector object
-    delete d_rendererSelector;
-    d_rendererSelector = 0;
-
-    // signal app did not initialise and run.
-    return false;
-}
-
-
-/*************************************************************************
-    Cleanup the sample application.
-*************************************************************************/
-void CEGuiSample::cleanup()
-{
-    if (d_sampleApp)
-    {
-        d_sampleApp->cleanup();
-        delete d_sampleApp;
-        d_sampleApp = 0;
-    }
-
-    if (d_rendererSelector)
-    {
-        delete d_rendererSelector;
-        d_rendererSelector = 0;
-    }
-
-}
-
-
-/*************************************************************************
-    Output a message to the user in some OS independant way.
-*************************************************************************/
-void CEGuiSample::outputExceptionMessage(const char* message) const
-{
-#if defined(__WIN32__) || defined(_WIN32)
-    MessageBoxA(0, message, "CEGUI - Exception", MB_OK|MB_ICONERROR);
-#else
-    std::cout << "An exception was thrown within the sample framework:" << std::endl;
-    std::cout << message << std::endl;
-#endif
-}
Index: code/trunk/src/orxonox/graphics/CEGuiSample.h
===================================================================
--- code/trunk/src/orxonox/graphics/CEGuiSample.h	(revision 8855)
+++ 	(revision )
@@ -1,130 +1,0 @@
-/***********************************************************************
-    filename:   CEGuiSample.h
-    created:    24/9/2004
-    author:     Paul D Turner
-*************************************************************************/
-/***************************************************************************
- *   Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
- *
- *   Permission is hereby granted, free of charge, to any person obtaining
- *   a copy of this software and associated documentation files (the
- *   "Software"), to deal in the Software without restriction, including
- *   without limitation the rights to use, copy, modify, merge, publish,
- *   distribute, sublicense, and/or sell copies of the Software, and to
- *   permit persons to whom the Software is furnished to do so, subject to
- *   the following conditions:
- *
- *   The above copyright notice and this permission notice shall be
- *   included in all copies or substantial portions of the Software.
- *
- *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- *   OTHER DEALINGS IN THE SOFTWARE.
- ***************************************************************************/
-#ifndef _CEGuiSample_h_
-#define _CEGuiSample_h_
-
-#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined (CEGUI_STATIC)
-#   ifdef CEGUISAMPLE_EXPORTS
-#       define CEGUISAMPLE_API __declspec(dllexport)
-#   else
-#       define CEGUISAMPLE_API __declspec(dllimport)
-#   endif
-#else
-#       define CEGUISAMPLE_API
-#endif
-
-
-// forward declarations
-class CEGuiBaseApplication;
-class CEGuiRendererSelector;
-
-
-/*!
-\brief
-    This is a base class that is intended to be used for all sample applications.
-    Here we take care of common things such the renderer selection and application
-    startup.
-*/
-class CEGUISAMPLE_API CEGuiSample
-{
-public:
-    /*!
-    \brief
-        Constructor.
-    */
-    CEGuiSample();
-
-
-    /*!
-    \brief
-        Destructor.
-    */
-    virtual ~CEGuiSample();
-
-
-    /*!
-    \brief
-        Application entry point.
-
-    \return
-        code to be returned by the application.
-    */
-    int run();
-
-
-    /*!
-    \brief
-        Sample specific initialisation goes here.  This method is called by the application base object created
-        as part of the initialise call.
-
-    \return
-        false if something went wrong.
-    */
-    virtual bool initialiseSample()  = 0;
-
-
-    /*!
-    \brief
-        Cleans up resources allocated in the initialiseSample call.
-    */
-    virtual void cleanupSample() = 0;
-
-
-protected:
-    /*!
-    \brief
-        Initialises the sample system, this includes asking the user for a render to use and
-        the subsequent creation of the required systems to support that renderer.
-
-    \return
-        false if anything went wrong.
-    */
-    virtual bool initialise();
-
-
-    /*!
-    \brief
-        Cleans up all resources allocated by the initialise call.
-    */
-    virtual void cleanup();
-
-
-    /*!
-    \brief
-        Output a message to the user in some OS independant way.
-    */
-    void outputExceptionMessage(const char* message) const;
-
-    /*************************************************************************
-        Data fields
-    *************************************************************************/
-    CEGuiRendererSelector*  d_rendererSelector;     //!< Points to the renderer selector object.
-    CEGuiBaseApplication*   d_sampleApp;            //!< Pointer to the base application object.
-};
-
-#endif  // end of guard _CEGuiSample_h_
Index: code/trunk/src/orxonox/graphics/Model.cc
===================================================================
--- code/trunk/src/orxonox/graphics/Model.cc	(revision 8855)
+++ code/trunk/src/orxonox/graphics/Model.cc	(revision 8858)
@@ -142,5 +142,5 @@
             if( this->numLodLevels_>10 )
             {
-                CCOUT(2) << "More than 10 LoD levels requested. Creating only 10." << endl;
+                orxout(internal_warning, context::lod) << "More than 10 LoD levels requested. Creating only 10." << endl;
                 this->numLodLevels_ = 10;
             }
@@ -158,7 +158,7 @@
                     creatorPtr = creatorPtr->getCreator();
                 }
-                COUT(0) << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;
+                orxout() << "name: " << this->meshSrc_ << "scaleFactor: " << scaleFactor << ", volume: " << volume << endl;
 */
-                COUT(4) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << std::endl;
+                orxout(verbose, context::lod) << "Setting lodLevel for " << this->meshSrc_<< " with lodLevel_: " << this->lodLevel_ <<" and volume: "<< volume << ":" << endl;
 
 #if OGRE_VERSION >= 0x010700
@@ -173,5 +173,5 @@
                     float factor = pow(volume, 2.0f / 3.0f) * 15.0f / lodLevel_;
 
-                    COUT(4) << "LodLevel set with factor: " << factor << endl;
+                    orxout(verbose, context::lod) << "LodLevel set with factor: " << factor << endl;
 
                     distList.push_back(70.0f*factor);
@@ -200,9 +200,9 @@
                         what = "<0";
 
-                    COUT(4)<<"LodLevel not set because lodLevel("<<lodLevel_<<") was "<<what<<"." << endl;
+                    orxout(verbose, context::lod) << "LodLevel not set because lodLevel(" << lodLevel_ << ") was " << what << "." << endl;
                 }
             }
             else
-                COUT(4) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl;
+                orxout(verbose, context::lod) << "LodLevel for " << this->meshSrc_ << " not set because is disabled." << endl;
         }
     }
Index: code/trunk/src/orxonox/graphics/ParticleEmitter.cc
===================================================================
--- code/trunk/src/orxonox/graphics/ParticleEmitter.cc	(revision 8855)
+++ code/trunk/src/orxonox/graphics/ParticleEmitter.cc	(revision 8858)
@@ -116,6 +116,6 @@
             catch (const std::exception& ex)
             {
-                COUT(1) << "Error: Couln't load particle effect \"" << this->source_ << "\" because:" << std::endl
-                        << ex.what() << std::endl;
+                orxout(internal_error) << "Couldn't load particle effect \"" << this->source_ << "\" because:" << endl
+                                       << ex.what() << endl;
             }
         }
Index: code/trunk/src/orxonox/infos/GametypeInfo.cc
===================================================================
--- code/trunk/src/orxonox/infos/GametypeInfo.cc	(revision 8855)
+++ code/trunk/src/orxonox/infos/GametypeInfo.cc	(revision 8858)
@@ -196,5 +196,5 @@
         this->startCountdown_ = countdown;
         // Set the counter to the ceiling of the current countdown.
-        this->counter_ = std::ceil(countdown);
+        this->counter_ = static_cast<unsigned int>(std::ceil(countdown));
         this->changedCountdownCounter();
     }
Index: code/trunk/src/orxonox/interfaces/PickupCarrier.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/PickupCarrier.cc	(revision 8855)
+++ code/trunk/src/orxonox/interfaces/PickupCarrier.cc	(revision 8858)
@@ -75,5 +75,5 @@
             if(it != this->pickups_.end() && temp == *it) // Infinite loop avoidance, in case the pickup wasn't removed from the carrier somewhere in the carrierDestroy() procedure.
             {
-                COUT(2) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << temp << ") didn't unregister itself as it should have." << std::endl;;
+                orxout(internal_warning, context::pickups) << "Oops. In a PickupCarrier, while cleaning up, a Pickupable (&" << temp << ") didn't unregister itself as it should have." << endl;;
                 it++;
             }
@@ -158,5 +158,5 @@
     bool PickupCarrier::addPickup(Pickupable* pickup)
     {
-        COUT(4) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << std::endl;
+        orxout(verbose, context::pickups) << "Adding Pickupable (&" << pickup << ") to PickupCarrier (&" << this << ")" << endl;
         return this->pickups_.insert(pickup).second;
     }
@@ -172,5 +172,5 @@
     bool PickupCarrier::removePickup(Pickupable* pickup)
     {
-        COUT(4) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << std::endl;
+        orxout(verbose, context::pickups) << "Removing Pickupable (&" << pickup << ") from PickupCarrier (&" << this << ")" << endl;
         return this->pickups_.erase(pickup) == 1;
     }
Index: code/trunk/src/orxonox/interfaces/Pickupable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/Pickupable.cc	(revision 8855)
+++ code/trunk/src/orxonox/interfaces/Pickupable.cc	(revision 8858)
@@ -71,5 +71,5 @@
         if(this->pickupIdentifier_ != NULL)
         {
-            COUT(4) << "Pickupable (&" << this << ") destroyed." << std::endl;
+            orxout(verbose, context::pickups) << "Pickupable (&" << this << ") destroyed." << endl;
             this->pickupIdentifier_->destroy();
         }
@@ -107,5 +107,5 @@
             this->OrxonoxClass::destroy();
         else
-            COUT(2) << this->getIdentifier()->getName() << " may be unsafe. " << std::endl;
+            orxout(internal_warning, context::pickups) << this->getIdentifier()->getName() << " may be unsafe. " << endl;
     }
 
@@ -126,5 +126,5 @@
             return false;
 
-        COUT(4) << "Pickupable (&" << this << ") set to used " << used << "." << std::endl;
+        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") set to used " << used << "." << endl;
 
         this->used_ = used;
@@ -201,5 +201,5 @@
             return false;
 
-        COUT(4) << "Target " << target->getName() << " added to Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ")." << std::endl;
+        orxout(verbose, context::pickups) << "Target " << target->getName() << " added to Pickupable (" << this->getIdentifier()->getName() << ") (&" << this << ")." << endl;
         this->targets_.push_back(target);
         return true;
@@ -221,10 +221,10 @@
         if(!this->setCarrier(carrier))
         {
-            COUT(3) << "A Pickupable (&" << this << ") was trying to be added to a PickupCarrier, but was already present." << std::endl;
+            orxout(internal_warning, context::pickups) << "A Pickupable (&" << this << ") was trying to be added to a PickupCarrier, but was already present." << endl;
             return false;
         }
 
         this->setPickedUp(true);
-        COUT(4) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << std::endl;
+        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") got picked up by a PickupCarrier (&" << carrier << ")." << endl;
         return true;
     }
@@ -245,7 +245,7 @@
         assert(this->getCarrier()); // The Carrier cannot be NULL at this point.
         if(!this->getCarrier()->removePickup(this)) //TODO Shouldn't this be a little later?
-            COUT(2) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << std::endl;
-
-        COUT(4) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << std::endl;
+            orxout(internal_warning, context::pickups) << "Pickupable (&" << this << ", " << this->getIdentifier()->getName() << ") is being dropped, but it was not present in the PickupCarriers list of pickups." << endl;
+
+        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") got dropped up by a PickupCarrier (&" << this->getCarrier() << ")." << endl;
         this->setUsed(false);
         this->setPickedUp(false);
@@ -276,5 +276,5 @@
             return false;
 
-        COUT(4) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << std::endl;
+        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") set to pickedUp " << pickedUp << "." << endl;
 
         this->pickedUp_ = pickedUp;
@@ -305,5 +305,5 @@
             return false;
 
-        COUT(4) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << std::endl;
+        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") changed Carrier (& " << carrier << ")." << endl;
 
         if(carrier != NULL && tell)
@@ -340,5 +340,5 @@
         Pickupable* pickup = dynamic_cast<Pickupable*>(item);
 
-        COUT(4) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << std::endl;
+        orxout(verbose, context::pickups) << "Pickupable (&" << this << ") cloned. Clone is new Pickupable (&" << pickup << ")." << endl;
         return pickup;
     }
Index: code/trunk/src/orxonox/interfaces/RadarViewable.cc
===================================================================
--- code/trunk/src/orxonox/interfaces/RadarViewable.cc	(revision 8855)
+++ code/trunk/src/orxonox/interfaces/RadarViewable.cc	(revision 8858)
@@ -83,5 +83,5 @@
 //         else
 //         {
-//             CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
+//             orxout(internal_warning) << "Attempting to access the radar, but the radar is non existent." << endl;
 //         }
 //         this->radarObjectDescription_ = str;
@@ -106,5 +106,5 @@
         if (!object)
         {
-            COUT(1) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl;
+            orxout(user_error) << "Assertion: Every RadarViewable has to be assigned a WorldEntity pointer!" << endl;
             assert(0);
         }
Index: code/trunk/src/orxonox/items/Engine.cc
===================================================================
--- code/trunk/src/orxonox/items/Engine.cc	(revision 8855)
+++ code/trunk/src/orxonox/items/Engine.cc	(revision 8858)
@@ -261,5 +261,5 @@
         if(!this->engineTemplate_.empty())
         {
-            COUT(4)<<"Loading an engine template: "<<this->engineTemplate_<<"\n";
+            orxout(verbose, context::templates) << "Loading an engine template: " << this->engineTemplate_ << endl;
             Template *temp = Template::getTemplate(this->engineTemplate_);
             if(temp)
Index: code/trunk/src/orxonox/overlays/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.cc	(revision 8855)
+++ code/trunk/src/orxonox/overlays/InGameConsole.cc	(revision 8858)
@@ -46,4 +46,5 @@
 #include "util/DisplayStringConversions.h"
 #include "util/ScopedSingletonManager.h"
+#include "util/output/MemoryWriter.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -58,5 +59,5 @@
 {
     const int LINES = 30;
-    const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
+    const float CHAR_WIDTH = 8.0f; // fix this please - determine the char-width dynamically
 
     SetConsoleCommand("InGameConsole", "openConsole", &InGameConsole::openConsole);
@@ -94,5 +95,5 @@
         // Output buffering is not anymore needed. Not the best solution to do
         // this here, but there isn't much of another way.
-        OutputHandler::getInstance().disableMemoryLog();
+        MemoryWriter::getInstance().disable();
     }
 
@@ -262,5 +263,5 @@
         this->consoleOverlayContainer_->setTop(-1.3f * this->relativeHeight);
 
-        COUT(4) << "Info: InGameConsole initialized" << std::endl;
+        orxout(internal_info) << "InGameConsole initialized" << endl;
     }
 
@@ -288,5 +289,5 @@
 
         for (int i = LINES - 1; i > max; --i)
-            this->print("", Shell::None, i, true);
+            this->print("", Shell::DebugOutput, i, true);
 
         for (int i = max; i >= 1; --i)
@@ -298,20 +299,12 @@
 
     /**
-        @brief Called if only the last output-line has changed.
-    */
-    void InGameConsole::onlyLastLineChanged()
-    {
+        @brief Called if a new output-line was added.
+    */
+    void InGameConsole::lineAdded()
+    {
+        this->numLinesShifted_ = 0;
+        this->shiftLines();
         if (LINES > 1)
             this->print(this->shell_->getNewestLineIterator()->first, this->shell_->getNewestLineIterator()->second, 1);
-    }
-
-    /**
-        @brief Called if a new output-line was added.
-    */
-    void InGameConsole::lineAdded()
-    {
-        this->numLinesShifted_ = 0;
-        this->shiftLines();
-        this->onlyLastLineChanged();
     }
 
@@ -346,5 +339,5 @@
     void InGameConsole::executed()
     {
-        this->shell_->addOutput(this->shell_->getInput() + '\n', Shell::Command);
+        this->shell_->addOutput(this->shell_->getInput(), Shell::Command);
     }
 
@@ -437,5 +430,5 @@
 
         // now adjust the text lines...
-        this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 12;
+        this->desiredTextWidth_ = static_cast<int>(this->windowW_ * this->relativeWidth) - 24;
 
         if (LINES > 0)
@@ -566,34 +559,29 @@
         switch (type)
         {
-        case Shell::Error:   colourTop = ColourValue(0.95f, 0.25f, 0.25f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.50f, 0.50f, 1.00f); break;
-
-        case Shell::Warning: colourTop = ColourValue(0.95f, 0.50f, 0.20f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.70f, 0.50f, 1.00f); break;
-
-        case Shell::Info:    colourTop = ColourValue(0.50f, 0.50f, 0.95f, 1.00f);
-                          colourBottom = ColourValue(0.80f, 0.80f, 1.00f, 1.00f); break;
-
-        case Shell::Debug:   colourTop = ColourValue(0.65f, 0.48f, 0.44f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.90f, 0.90f, 1.00f); break;
-
-        case Shell::Verbose: colourTop = ColourValue(0.40f, 0.20f, 0.40f, 1.00f);
-                          colourBottom = ColourValue(0.80f, 0.60f, 0.80f, 1.00f); break;
-
-        case Shell::Ultra:   colourTop = ColourValue(0.21f, 0.69f, 0.21f, 1.00f);
-                          colourBottom = ColourValue(0.80f, 1.00f, 0.80f, 1.00f); break;
-
-        case Shell::Command: colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
-                          colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 0.90f); break;
-
-        case Shell::Hint:    colourTop = ColourValue(0.80f, 0.80f, 0.80f, 1.00f);
-                          colourBottom = ColourValue(0.90f, 0.90f, 0.90f, 1.00f); break;
-
-        case Shell::TDebug:  colourTop = ColourValue(0.90f, 0.00f, 0.90f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 0.00f, 1.00f, 1.00f); break;
-
-        default:             colourTop = ColourValue(0.90f, 0.90f, 0.90f, 1.00f);
-                          colourBottom = ColourValue(1.00f, 1.00f, 1.00f, 1.00f); break;
-        }
+            case Shell::Message:
+            case Shell::DebugOutput:     colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
+
+            case Shell::UserError:       colourTop = ColourValue(0.9f, 0.0f, 0.0f); break;
+            case Shell::UserWarning:     colourTop = ColourValue(0.9f, 0.5f, 0.0f); break;
+            case Shell::UserStatus:      colourTop = ColourValue(0.0f, 0.9f, 0.0f); break;
+            case Shell::UserInfo:        colourTop = ColourValue(0.0f, 0.8f, 0.8f); break;
+
+            case Shell::InternalError:   colourTop = ColourValue(0.5f, 0.0f, 0.0f); break;
+            case Shell::InternalWarning: colourTop = ColourValue(0.5f, 0.2f, 0.0f); break;
+            case Shell::InternalStatus:  colourTop = ColourValue(0.0f, 0.5f, 0.0f); break;
+            case Shell::InternalInfo:    colourTop = ColourValue(0.0f, 0.4f, 0.4f); break;
+
+            case Shell::Verbose:         colourTop = ColourValue(0.3f, 0.3f, 0.9f); break;
+            case Shell::VerboseMore:     colourTop = ColourValue(0.2f, 0.2f, 0.7f); break;
+            case Shell::VerboseUltra:    colourTop = ColourValue(0.1f, 0.1f, 0.5f); break;
+
+            case Shell::Command:         colourTop = ColourValue(0.8f, 0.2f, 0.8f); break;
+            case Shell::Hint:            colourTop = ColourValue(0.4f, 0.0f, 0.4f); break;
+            case Shell::Input:           colourTop = ColourValue(0.9f, 0.9f, 0.9f); break;
+
+            default:                     colourTop = ColourValue(0.5f, 0.5f, 0.5f); break;
+        }
+
+        colourBottom = ColourValue(sqrt(colourTop.r), sqrt(colourTop.g), sqrt(colourTop.b));
 
         this->consoleOverlayTextAreas_[index]->setColourTop   (colourTop);
Index: code/trunk/src/orxonox/overlays/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/overlays/InGameConsole.h	(revision 8855)
+++ code/trunk/src/orxonox/overlays/InGameConsole.h	(revision 8858)
@@ -64,5 +64,4 @@
 
         void linesChanged();
-        void onlyLastLineChanged();
         void lineAdded();
         void inputChanged();
Index: code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 8855)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 8858)
@@ -147,5 +147,5 @@
 
         if (OrxonoxOverlay::overlays_s.find(this->getName()) != OrxonoxOverlay::overlays_s.end())
-            COUT(1) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << std::endl;
+            orxout(internal_warning) << "Overlay names should be unique or you cannnot access them via console. Name: \"" << this->getName() << '"' << endl;
 
         OrxonoxOverlay::overlays_s[this->getName()] = this;
@@ -362,10 +362,10 @@
             {
                 overlay->hide();
-                COUT(4) << "HIDE " << name << std::endl;
+                orxout(verbose, context::misc::overlays) << "HIDE " << name << endl;
             }
             else
             {
                 overlay->show();
-                COUT(4) << "SHOW " << name << std::endl;
+                orxout(verbose, context::misc::overlays) << "SHOW " << name << endl;
             }
         }
Index: code/trunk/src/orxonox/pickup/PickupIdentifier.cc
===================================================================
--- code/trunk/src/orxonox/pickup/PickupIdentifier.cc	(revision 8855)
+++ code/trunk/src/orxonox/pickup/PickupIdentifier.cc	(revision 8858)
@@ -51,5 +51,5 @@
 
         if(pickup == NULL)
-            COUT(1) << "Error, PickupIdentifier was created without a valid Pickupable." << std::endl;
+            orxout(internal_error, context::pickups) << "PickupIdentifier was created without a valid Pickupable." << endl;
 
         this->pickup_ = pickup;
@@ -83,5 +83,5 @@
         if(!(this->parameters_.size() == identifier->parameters_.size()))
         {
-            COUT(1) << "Something went wrong in PickupIdentifier!" << std::endl;
+            orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
             return this->parameters_.size()-identifier->parameters_.size();
         }
@@ -93,5 +93,5 @@
             if(identifier->parameters_.find(it->first) == identifier->parameters_.end())
             {
-                COUT(1) << "Something went wrong in PickupIdentifier!" << std::endl;
+                orxout(internal_error, context::pickups) << "Something went wrong in PickupIdentifier!" << endl;
                 return -1;
             }
@@ -115,9 +115,9 @@
     bool PickupIdentifier::addParameter(std::string & name, std::string & value)
     {
-        COUT(4) << "PickupIdentifier " << name << ", " << value << std::endl;
+        orxout(verbose, context::pickups) << "PickupIdentifier " << name << ", " << value << endl;
 
         if(!(this->parameters_.find(name) == this->parameters_.end()))
         {
-            COUT(4) << "Request for adding a parameter that already exists for the PickupIdentififer was denied. name: '" << name << "', value: '" << value << "'."<<  std::endl;
+            orxout(verbose, context::pickups) << "Request for adding a parameter that already exists for the PickupIdentififer was denied. name: '" << name << "', value: '" << value << "'."<<  endl;
             return false;
         }
Index: code/trunk/src/orxonox/sound/AmbientSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/AmbientSound.cc	(revision 8855)
+++ code/trunk/src/orxonox/sound/AmbientSound.cc	(revision 8858)
@@ -94,5 +94,5 @@
                 this->setSource(path);
             else
-                COUT(3) << "Sound: " << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << std::endl;
+                orxout(internal_warning, context::sound) << this->ambientSource_ << ": Not a valid name! Ambient sound will not change." << endl;
         }
     }
Index: code/trunk/src/orxonox/sound/BaseSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/BaseSound.cc	(revision 8855)
+++ code/trunk/src/orxonox/sound/BaseSound.cc	(revision 8858)
@@ -94,5 +94,5 @@
             alSourcePlay(this->audioSource_);
             if (int error = alGetError())
-                COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
+                orxout(internal_error, context::sound) << "Error playing sound: " << SoundManager::getALErrorString(error) << endl;
         }
     }
@@ -147,10 +147,10 @@
         alSource3f(this->audioSource_, AL_DIRECTION, 0, 0, 0);
         if (ALint error = alGetError())
-            COUT(2) << "Sound Warning: Setting source parameters to 0 failed: "
-                    << SoundManager::getALErrorString(error) << std::endl;
+            orxout(internal_warning, context::sound) << "Setting source parameters to 0 failed: "
+                                                     << SoundManager::getALErrorString(error) << endl;
         assert(this->soundBuffer_ != NULL);
         alSourcei(this->audioSource_, AL_BUFFER, this->soundBuffer_->getBuffer());
         if (ALuint error = alGetError())
-            COUT(1) << "Sound Error: Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << std::endl;
+            orxout(internal_error, context::sound) << "Could not set buffer \"" << this->source_ << "\": " << SoundManager::getALErrorString(error) << endl;
     }
 
@@ -159,5 +159,5 @@
         this->volume_ = clamp(vol, 0.0f, 1.0f);
         if (this->volume_ != vol)
-            COUT(2) << "Sound warning: volume out of range, clamping value." << std::endl;
+            orxout(internal_warning, context::sound) << "Volume out of range, clamping value." << endl;
         this->updateVolume();
     }
@@ -170,6 +170,6 @@
             alSourcef(this->audioSource_, AL_GAIN, volume);
             if (int error = alGetError())
-                COUT(2) << "Sound: Error setting volume to " << volume
-                        << ": " << SoundManager::getALErrorString(error) << std::endl;
+                orxout(internal_error, context::sound) << "Error setting volume to " << volume
+                                                       << ": " << SoundManager::getALErrorString(error) << endl;
         }
     }
@@ -186,5 +186,5 @@
         if (pitch > 2 || pitch < 0.5f)
         {
-            COUT(2) << "Sound warning: pitch out of range, cropping value." << std::endl;
+            orxout(internal_warning, context::sound) << "Pitch out of range, cropping value." << endl;
             pitch = pitch > 2.0f ? 2.0f : pitch;
             pitch = pitch < 0.5f ? 0.5f : pitch;
@@ -195,5 +195,5 @@
             alSourcef(this->audioSource_, AL_PITCH, pitch);
             if (int error = alGetError())
-                COUT(2) << "Sound: Error setting pitch: " << SoundManager::getALErrorString(error) << std::endl;
+                orxout(internal_error, context::sound) << "Error setting pitch: " << SoundManager::getALErrorString(error) << endl;
         }
     }
@@ -240,5 +240,5 @@
             if (ALuint error = alGetError())
             {
-                COUT(1) << "Sound Error: Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << std::endl;
+                orxout(internal_error, context::sound) << "Could not set buffer \"" << source << "\": " << SoundManager::getALErrorString(error) << endl;
                 return;
             }
@@ -248,5 +248,5 @@
             alSourcePlay(this->audioSource_);
             if (int error = alGetError())
-                COUT(2) << "Sound: Error playing sound: " << SoundManager::getALErrorString(error) << std::endl;
+                orxout(internal_error, context::sound) << "Error playing sound: " << SoundManager::getALErrorString(error) << endl;
             if (this->isPaused())
                 alSourcePause(this->audioSource_);
Index: code/trunk/src/orxonox/sound/SoundBuffer.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundBuffer.cc	(revision 8855)
+++ code/trunk/src/orxonox/sound/SoundBuffer.cc	(revision 8858)
@@ -51,5 +51,5 @@
         if (fileInfo == NULL)
         {
-            COUT(2) << "Sound: Warning: Sound file '" << filename << "' not found" << std::endl;
+            orxout(internal_error, context::sound) << "Sound file '" << filename << "' not found" << endl;
             return;
         }
@@ -144,5 +144,5 @@
         if (ret < 0)
         {
-            COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
+            orxout(internal_error, context::sound) << "libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << endl;
             ov_clear(&vf);
             ThrowException(General, "Sound Error: Ogg file loader failed when opening the bitstream");
@@ -160,5 +160,5 @@
             else if (ret < 0)
             {
-                COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+                orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
                 ov_clear(&vf);
                 ThrowException(General, "Sound Error: Ogg file loader failed when decoding the file");
Index: code/trunk/src/orxonox/sound/SoundManager.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundManager.cc	(revision 8855)
+++ code/trunk/src/orxonox/sound/SoundManager.cc	(revision 8858)
@@ -71,4 +71,6 @@
         RegisterRootObject(SoundManager);
 
+        orxout(user_status) << "Loading sound" << endl;
+
         this->bDestructorCalled_ = false;
          
@@ -89,17 +91,17 @@
         std::string renderDevice;
         SetConfigValue(renderDevice, std::string(device)).description("Sound device used for rendering");
-        COUT(4) << "Sound: Available devices: ";
+        orxout(verbose, context::sound) << "Sound: Available devices: ";
         while (true)
         {
             this->deviceNames_.push_back(devices);
-            COUT(4) << '"' << devices << "\", ";
+            orxout(verbose, context::sound) << '"' << devices << "\", ";
             devices += strlen(devices) + 1;
             if (*devices == '\0')
                 break;
         }
-        COUT(4) << std::endl;
+        orxout(verbose, context::sound) << endl;
 
         // Open the selected device
-        COUT(3) << "Sound: Opening device \"" << renderDevice << '\' << std::endl;
+        orxout(internal_info, context::sound) << "Sound: Opening device \"" << renderDevice << '\' << endl;
         this->device_ = alcOpenDevice(renderDevice.c_str());
 */
@@ -122,11 +124,11 @@
         // Get some information about the sound
         if (const char* version = alGetString(AL_VERSION))
-            COUT(4) << "Sound: --- OpenAL Version: " << version << std::endl;
+            orxout(internal_info, context::sound) << "Sound: --- OpenAL Version: " << version << endl;
         if (const char* vendor = alGetString(AL_VENDOR))
-            COUT(4) << "Sound: --- OpenAL Vendor : " << vendor << std::endl;
+            orxout(internal_info, context::sound) << "Sound: --- OpenAL Vendor : " << vendor << endl;
         if (const char* types = alutGetMIMETypes(ALUT_LOADER_BUFFER))
-            COUT(4) << "Sound: --- Supported MIME Types: " << types << std::endl;
+            orxout(internal_info, context::sound) << "Sound: --- Supported MIME Types: " << types << endl;
         else
-            COUT(2) << "Sound Warning: MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << std::endl;
+            orxout(internal_warning, context::sound) << "MIME Type retrieval failed: " << alutGetErrorString(alutGetError()) << endl;
 
         this->mute_[SoundType::All]     = 1.0f;
@@ -152,5 +154,5 @@
         resetPlaysSoundGuard.Dismiss();
 
-        COUT(4) << "Sound: Initialisation complete" << std::endl;
+        orxout(internal_status, context::sound) << "Sound: Initialisation complete" << endl;
     }
 
@@ -164,5 +166,5 @@
         // If there are still used buffers around, well, that's just very bad...
         if (this->soundBuffers_.size() != this->effectsPool_.size())
-            COUT(1) << "Sound Error: Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+            orxout(internal_error, context::sound) << "Some sound buffers are still in use but OpenAL is about to shut down. Fix this!" << endl;
         // Empty buffer pool and buffer list
         this->effectsPool_.clear();
@@ -171,5 +173,5 @@
         // There should not be any sources in use anymore
         if (!this->usedSoundSources_.empty())
-            COUT(1) << "Sound Error: Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << std::endl;
+            orxout(internal_error, context::sound) << "Some sound sources are still in use but OpenAL is about to shut down. Fix this!" << endl;
         while (!this->availableSoundSources_.empty())
         {
@@ -182,21 +184,21 @@
         // Relieve context to destroy it
         if (!alcMakeContextCurrent(NULL))
-            COUT(1) << "Sound Error: Could not unset ALC context" << std::endl;
+            orxout(internal_error, context::sound) << "Could not unset ALC context" << endl;
         alcDestroyContext(this->context_);
         if (ALCenum error = alcGetError(this->device_))
         {
             if (error == AL_INVALID_OPERATION)
-                COUT(1) << "Sound Error: Could not destroy ALC context because it is the current one" << std::endl;
+                orxout(internal_error, context::sound) << "Could not destroy ALC context because it is the current one" << endl;
             else
-                COUT(1) << "Sound Error: Could not destroy ALC context because it is invalid" << std::endl;
+                orxout(internal_error, context::sound) << "Could not destroy ALC context because it is invalid" << endl;
         }
 #ifdef AL_VERSION_1_1
         if (!alcCloseDevice(this->device_))
-            COUT(1) << "Sound Error: Could not destroy ALC device. This might be because there are still buffers in use!" << std::endl;
+            orxout(internal_error, context::sound) << "Could not destroy ALC device. This might be because there are still buffers in use!" << endl;
 #else
         alcCloseDevice(this->device_);
 #endif
         if (!alutExit())
-            COUT(1) << "Sound Error: Closing ALUT failed: " << alutGetErrorString(alutGetError()) << std::endl;
+            orxout(internal_error, context::sound) << "Closing ALUT failed: " << alutGetErrorString(alutGetError()) << endl;
     }
 
@@ -244,5 +246,5 @@
         if (crossFadeStep_ <= 0.0 || crossFadeStep_ >= 1.0 )
         {
-            COUT(2) << "Sound warning: fade step out of range, ignoring change." << std::endl;
+            orxout(internal_warning, context::sound) << "Fade step out of range, ignoring change." << endl;
             ResetConfigValue(crossFadeStep_);
         }
@@ -253,5 +255,5 @@
         float clampedVolume = clamp(this->volume_[type], 0.0f, 1.0f);
         if (clampedVolume != this->volume_[type])
-            COUT(2) << "Sound warning: Volume setting (" << type << ") out of range, clamping." << std::endl;
+            orxout(internal_warning, context::sound) << "Volume setting (" << type << ") out of range, clamping." << endl;
         this->updateVolume(type);
     }
@@ -321,5 +323,5 @@
         if (error == AL_INVALID_VALUE)
             // @TODO: Follow this constantly appearing, nerve-racking warning
-            COUT(2) << "Sound: OpenAL: Invalid listener position" << std::endl;
+            orxout(internal_error, context::sound) << "OpenAL: Invalid listener position" << endl;
     }
 
@@ -335,5 +337,5 @@
         ALenum error = alGetError();
         if (error == AL_INVALID_VALUE)
-            COUT(2) << "Sound: OpenAL: Invalid listener orientation" << std::endl;
+            orxout(internal_error, context::sound) << "OpenAL: Invalid listener orientation" << endl;
     }
 
@@ -346,5 +348,5 @@
                 if (it->first == newAmbient)
                 {
-                    COUT(2) << "Sound warning: Will not play an AmbientSound twice." << std::endl;
+                    orxout(internal_warning, context::sound) << "Will not play an AmbientSound twice." << endl;
                     return;
                 }
@@ -520,5 +522,5 @@
             catch (const std::exception& ex)
             {
-                COUT(1) << ex.what() << std::endl;
+                orxout(internal_error, context::sound) << ex.what() << endl;
                 return buffer;
             }
@@ -614,5 +616,5 @@
             alDeleteSources(1, &this->availableSoundSources_.back());
             if (alGetError())
-                COUT(1) << "Sound Error: Failed to delete a source --> lost forever" << std::endl;
+                orxout(internal_error, context::sound) << "Failed to delete a source --> lost forever" << endl;
             this->availableSoundSources_.pop_back();
         }
Index: code/trunk/src/orxonox/sound/SoundStreamer.cc
===================================================================
--- code/trunk/src/orxonox/sound/SoundStreamer.cc	(revision 8855)
+++ code/trunk/src/orxonox/sound/SoundStreamer.cc	(revision 8858)
@@ -51,5 +51,5 @@
         if (ret < 0)
         {
-            COUT(2) << "Sound: libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << std::endl;
+            orxout(internal_error, context::sound) << "libvorbisfile: File does not seem to be an Ogg Vorbis bitstream" << endl;
             ov_clear(&vf);
             return;
@@ -77,5 +77,5 @@
             else if (ret < 0)
             {
-                COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+                orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
                 ov_clear(&vf);
                 return;
@@ -91,6 +91,6 @@
             alGetSourcei(audioSource, AL_BUFFERS_PROCESSED, &processed);
             if (ALint error = alGetError())
-            COUT(2) << "Sound Warning: Couldn't get number of processed buffers: "
-                    << SoundManager::getALErrorString(error) << std::endl;
+            orxout(internal_warning, context::sound) << "Couldn't get number of processed buffers: "
+                                                     << SoundManager::getALErrorString(error) << endl;
 
             if(processed > 0)
@@ -99,6 +99,6 @@
                 alSourceUnqueueBuffers(audioSource, processed, buffers);
                 if (ALint error = alGetError())
-                    COUT(2) << "Sound Warning: Couldn't unqueue buffers: "
-                    << SoundManager::getALErrorString(error) << std::endl;
+                    orxout(internal_warning, context::sound) << "Couldn't unqueue buffers: "
+                                                             << SoundManager::getALErrorString(error) << endl;
 
                 for(int i = 0; i < processed; i++)
@@ -111,5 +111,5 @@
                     else if (ret < 0)
                     {
-                        COUT(2) << "Sound: libvorbisfile: error reading the file" << std::endl;
+                        orxout(internal_error, context::sound) << "libvorbisfile: error reading the file" << endl;
                         ov_clear(&vf);
                         return;
@@ -121,6 +121,6 @@
                 alSourceQueueBuffers(audioSource, processed, buffers);
                 if (ALint error = alGetError())
-                    COUT(2) << "Sound Warning: Couldn't queue buffers: "
-                    << SoundManager::getALErrorString(error) << std::endl;
+                    orxout(internal_warning, context::sound) << "Couldn't queue buffers: "
+                                                             << SoundManager::getALErrorString(error) << endl;
             }
         }
Index: code/trunk/src/orxonox/sound/WorldSound.cc
===================================================================
--- code/trunk/src/orxonox/sound/WorldSound.cc	(revision 8855)
+++ code/trunk/src/orxonox/sound/WorldSound.cc	(revision 8858)
@@ -94,5 +94,5 @@
             ALenum error = alGetError();
             if (error == AL_INVALID_VALUE)
-                COUT(2) << "Sound: OpenAL: Invalid sound position" << std::endl;
+                orxout(internal_error, context::sound) << "OpenAL: Invalid sound position" << endl;
 
             const Vector3& vel = this->getVelocity();
@@ -100,5 +100,5 @@
             error = alGetError();
             if (error == AL_INVALID_VALUE)
-                COUT(2) << "Sound: OpenAL: Invalid sound velocity" << std::endl;
+                orxout(internal_error, context::sound) << "OpenAL: Invalid sound velocity" << endl;
 
             const Vector3& direction = -this->getWorldOrientation().zAxis();
@@ -106,5 +106,5 @@
             error = alGetError();
             if (error == AL_INVALID_VALUE)
-                COUT(2) << "Sound: OpenAL: Invalid sound direction" << std::endl;
+                orxout(internal_error, context::sound) << "OpenAL: Invalid sound direction" << endl;
         }
     }
Index: code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.cc	(revision 8855)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.cc	(revision 8858)
@@ -188,5 +188,5 @@
             this->munitiontype_ = identifier;
         else
-            COUT(2) << "Warning: No munition class defined in WeaponMode " << this->getName() << std::endl;
+            orxout(internal_warning) << "No munition class defined in WeaponMode " << this->getName() << endl;
         this->updateMunition();
     }
@@ -249,5 +249,4 @@
             Vector3 muzzleDirection;
             muzzleDirection = target - this->muzzlePosition_;
-//             COUT(0) << "muzzleDirection " << muzzleDirection << endl;
             this->muzzleOrientation_ = (this->weapon_->getWorldOrientation() * WorldEntity::FRONT).getRotationTo(muzzleDirection) * this->weapon_->getWorldOrientation();
         }
Index: code/trunk/src/orxonox/worldentities/BigExplosion.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/BigExplosion.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/BigExplosion.cc	(revision 8858)
@@ -61,5 +61,5 @@
             catch (const std::exception& ex)
             {
-                COUT(1) << "Error: Couln't load particle effect in BigExplosion: " << ex.what() << std::endl;
+                orxout(internal_error) << "Couldn't load particle effect in BigExplosion: " << ex.what() << endl;
                 this->initZero();
             }
Index: code/trunk/src/orxonox/worldentities/ControllableEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ControllableEntity.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/ControllableEntity.cc	(revision 8858)
@@ -457,5 +457,5 @@
         }
         else
-            COUT(2) << "Warning: ControllableEntity \"" << this->getName() << "\" already has a Controller." << std::endl;
+            orxout(internal_warning) << "ControllableEntity \"" << this->getName() << "\" already has a Controller." << endl;
     }
 
Index: code/trunk/src/orxonox/worldentities/ExplosionChunk.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/ExplosionChunk.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/ExplosionChunk.cc	(revision 8858)
@@ -61,5 +61,5 @@
             catch (const std::exception& ex)
             {
-                COUT(1) << "Error: Couln't load particle effect in ExplosionChunk: " << ex.what() << std::endl;
+                orxout(internal_error) << "Couldn't load particle effect in ExplosionChunk: " << ex.what() << endl;
                 this->fire_ = 0;
                 this->smoke_ = 0;
Index: code/trunk/src/orxonox/worldentities/MobileEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/MobileEntity.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/MobileEntity.cc	(revision 8858)
@@ -189,5 +189,5 @@
         if (type == WorldEntity::Static)
         {
-            CCOUT(1) << "Error: Cannot tell a MobileEntity to have static collision type! Ignoring." << std::endl;
+            orxout(internal_warning) << "Cannot tell a MobileEntity to have static collision type! Ignoring." << endl;
             assert(false); // Only in debug mode
             return false;
Index: code/trunk/src/orxonox/worldentities/SpawnPoint.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/SpawnPoint.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/SpawnPoint.cc	(revision 8858)
@@ -48,5 +48,5 @@
             this->getGametype()->registerSpawnPoint(this);
         else
-            COUT(1) << "Error: SpawnPoint has no Gametype" << std::endl;
+            orxout(internal_error) << "SpawnPoint has no Gametype" << endl;
 
         this->setSyncMode(ObjectDirection::None);
Index: code/trunk/src/orxonox/worldentities/StaticEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/StaticEntity.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/StaticEntity.cc	(revision 8858)
@@ -63,5 +63,5 @@
         if (this->addedToPhysicalWorld())
         {
-            CCOUT(2) << "Warning: Attempting to change the position of a StaticEntity at physics run time. Ignoring change." << std::endl;
+            orxout(internal_warning) << "Attempting to change the position of a StaticEntity at physics run time. Ignoring change." << endl;
             return;
         }
@@ -80,5 +80,5 @@
         if (this->addedToPhysicalWorld())
         {
-            CCOUT(2) << "Warning: Attempting to change the orientation of a StaticEntity at physics run time. Ignoring change." << std::endl;
+            orxout(internal_warning) << "Attempting to change the orientation of a StaticEntity at physics run time. Ignoring change." << endl;
             return;
         }
@@ -97,5 +97,5 @@
         if (type == WorldEntity::Kinematic || type == WorldEntity::Dynamic)
         {
-            CCOUT(1) << "Error: Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << std::endl;
+            orxout(internal_warning) << "Cannot tell a StaticEntity to have kinematic or dynamic collision type! Ignoring." << endl;
             assert(false); // Only in debug mode
             return false;
Index: code/trunk/src/orxonox/worldentities/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/WorldEntity.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/WorldEntity.cc	(revision 8858)
@@ -95,5 +95,5 @@
         this->collisionType_             = None;
         this->collisionTypeSynchronised_ = None;
-        this->mass_           = 0;
+        this->mass_           = 1.0f;
         this->childrenMass_   = 0;
         // Using bullet default values
@@ -311,10 +311,10 @@
             this->collisionTypeSynchronised_ != None)
         {
-            CCOUT(1) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << std::endl;
+            orxout(internal_error) << "Error when collsion Type was received over network. Unknown enum value:" << this->collisionTypeSynchronised_ << endl;
         }
         else if (this->collisionTypeSynchronised_ != collisionType_)
         {
             if (this->parent_)
-                CCOUT(2) << "Warning: Network connection tried to set the collision type of an attached WE. Ignoring." << std::endl;
+                orxout(internal_warning) << "Network connection tried to set the collision type of an attached WE. Ignoring." << endl;
             else
                 this->setCollisionType(this->collisionTypeSynchronised_);
@@ -373,5 +373,5 @@
         if (object == this)
         {
-            COUT(2) << "Warning: Can't attach a WorldEntity to itself." << std::endl;
+            orxout(internal_warning) << "Can't attach a WorldEntity to itself." << endl;
             return;
         }
@@ -406,20 +406,20 @@
             if (!newParent->hasPhysics())
             {
-                COUT(2) << "Warning: Cannot attach a physical object to a non physical one." << std::endl;
+                orxout(internal_warning) << " Cannot attach a physical object to a non physical one." << endl;
                 return false;
             }
             else if (this->isDynamic())
             {
-                COUT(2) << "Warning: Cannot attach a dynamic object to a WorldEntity." << std::endl;
+                orxout(internal_warning) << "Cannot attach a dynamic object to a WorldEntity." << endl;
                 return false;
             }
             else if (this->isKinematic() && newParent->isDynamic())
             {
-                COUT(2) << "Warning: Cannot attach a kinematic object to a dynamic one." << std::endl;
+                orxout(internal_warning) << "Cannot attach a kinematic object to a dynamic one." << endl;
                 return false;
             }
             else if (this->isKinematic())
             {
-                COUT(2) << "Warning: Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << std::endl;
+                orxout(internal_warning) << "Cannot attach a kinematic object to a static or kinematic one: Not yet implemented." << endl;
                 return false;
             }
@@ -455,5 +455,5 @@
         if (it == this->children_.end())
         {
-            CCOUT(2) << "Warning: Cannot detach an object that is not a child." << std::endl;
+            orxout(internal_warning) << "Cannot detach an object that is not a child." << endl;
             return;
         }
@@ -799,5 +799,5 @@
         if (this->parent_)
         {
-            CCOUT(2) << "Warning: Cannot set the collision type of a WorldEntity with a parent." << std::endl;
+            orxout(internal_warning) << "Cannot set the collision type of a WorldEntity with a parent." << endl;
             return;
         }
@@ -822,5 +822,5 @@
             if (!this->node_->getScale().positionEquals(Vector3(1, 1, 1), 0.001))
             {
-                CCOUT(2) << "Warning: Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << std::endl;
+                orxout(internal_warning) << "Cannot create a physical body if there is scaling applied to the node: Not yet implemented." << endl;
                 return;
             }
@@ -968,8 +968,8 @@
                 this->physicalBody_->setMassProps(0.0f, btVector3(0, 0, 0));
             }
-            else if ((this->mass_ + this->childrenMass_) == 0.0f)
+            else if (totalMass == 0.0f)
             {
                 // Use default values to avoid very large or very small values
-                CCOUT(4) << "Warning: Setting the internal physical mass to 1.0 because mass_ is 0.0" << std::endl;
+                orxout(internal_warning) << "Setting the internal physical mass to 1.0 because mass_ is 0.0" << endl;
                 btVector3 inertia(0, 0, 0);
                 this->collisionShape_->calculateLocalInertia(1.0f, inertia);
Index: code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/pawns/FpsPlayer.cc	(revision 8858)
@@ -132,5 +132,5 @@
         if (type != WorldEntity::Dynamic)
         {
-            CCOUT(1) << "Error: Cannot tell a FpsPlayer not to be dynamic! Ignoring." << std::endl;
+            orxout(internal_warning) << "Cannot tell a FpsPlayer not to be dynamic! Ignoring." << endl;
             assert(false); // Only in debug mode
             return false;
Index: code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc	(revision 8855)
+++ code/trunk/src/orxonox/worldentities/pawns/SpaceShip.cc	(revision 8858)
@@ -145,5 +145,5 @@
         if (type != WorldEntity::Dynamic)
         {
-            CCOUT(1) << "Error: Cannot tell a SpaceShip not to be dynamic! Ignoring." << std::endl;
+            orxout(internal_warning) << "Cannot tell a SpaceShip not to be dynamic! Ignoring." << endl;
             assert(false); // Only in debug mode
             return false;
@@ -507,5 +507,5 @@
         if (camera == 0)
         {
-            COUT(2) << "Failed to reset camera!";
+            orxout(internal_warning) << "Failed to reset camera!" << endl;
             return;
         }
