Index: /code/branches/gui/src/core/CMakeLists.txt
===================================================================
--- /code/branches/gui/src/core/CMakeLists.txt	(revision 2843)
+++ /code/branches/gui/src/core/CMakeLists.txt	(revision 2844)
@@ -24,4 +24,5 @@
   Core.cc
   Event.cc
+  Game.cc
   GameState.cc
   Language.cc
@@ -29,5 +30,4 @@
   ObjectListBase.cc
   OrxonoxClass.cc
-  RootGameState.cc
 
   # command
Index: /code/branches/gui/src/core/CorePrereqs.h
===================================================================
--- /code/branches/gui/src/core/CorePrereqs.h	(revision 2843)
+++ /code/branches/gui/src/core/CorePrereqs.h	(revision 2844)
@@ -166,6 +166,7 @@
 
   // game states
+  class Game;
   class GameState;
-  class RootGameState;
+  struct GameStateTreeNode;
 
   // input
Index: /code/branches/gui/src/core/Game.cc
===================================================================
--- /code/branches/gui/src/core/Game.cc	(revision 2844)
+++ /code/branches/gui/src/core/Game.cc	(revision 2844)
@@ -0,0 +1,408 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of the Game class.
+*/
+
+#include "Game.h"
+
+#include <exception>
+#include <cassert>
+
+#include "util/Debug.h"
+#include "util/Exception.h"
+#include "Clock.h"
+#include "CommandLine.h"
+#include "ConsoleCommand.h"
+#include "Core.h"
+#include "CoreIncludes.h"
+#include "ConfigValueIncludes.h"
+#include "GameState.h"
+
+namespace orxonox
+{
+    void stop_game()
+    {
+        Game::getInstance().stop();
+    }
+
+    struct _CoreExport GameStateTreeNode
+    {
+        GameState*                      state_;
+        GameStateTreeNode*              parent_;
+        std::vector<GameStateTreeNode*> children_;
+    };
+
+    SetCommandLineArgument(state, "gui").shortcut("s");
+    SetCommandLineSwitch(startWithConsole);
+    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
+
+    std::map<std::string, GameState*> Game::allStates_s;
+    Game* Game::singletonRef_s = 0;
+
+    /**
+    @brief
+        Non-initialising constructor.
+    */
+    Game::Game(int argc, char** argv)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->rootStateNode_ = 0;
+        this->activeStateNode_ = 0;
+
+        this->abort_ = false;
+
+        // reset statistics
+        this->statisticsStartTime_ = 0;
+        this->statisticsTickTimes_.clear();
+        this->periodTickTime_ = 0;
+        this->periodTime_ = 0;
+        this->avgFPS_ = 0.0f;
+        this->avgTickTime_ = 0.0f;
+
+        this->core_ = new orxonox::Core();
+        this->gameClock_ = this->core_->initialise(argc, argv);
+
+        RegisterRootObject(Game);
+        this->setConfigValues();
+    }
+
+    /**
+    @brief
+    */
+    Game::~Game()
+    {
+        // Destroy pretty much everyhting left
+        delete this->core_;
+
+        // Delete all GameStates created by the macros
+        for (std::map<std::string, GameState*>::const_iterator it = allStates_s.begin(); it != allStates_s.end(); ++it)
+            delete it->second;
+
+        assert(singletonRef_s);
+        singletonRef_s = 0;
+    }
+
+    void Game::setConfigValues()
+    {
+        SetConfigValue(statisticsRefreshCycle_, 250000)
+            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+        SetConfigValue(statisticsAvgLength_, 1000000)
+            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
+    }
+
+    /**
+    @brief
+        Main loop of the orxonox game.
+    @note
+        We use the Ogre::Timer to measure time since it uses the most precise
+        method an any platform (however the windows timer lacks time when under
+        heavy kernel load!).
+    */
+    void Game::run()
+    {
+        // </EXPORT THIS>
+        this->setStateHierarchy(
+        "root"
+        " graphics"
+        "  gui"
+        "  standalone"
+        "   level"
+        "  server"
+        "   level"
+        "  client"
+        "   level"
+        " dedicated"
+        "  level"
+        " ioConsole"
+        );
+        // </EXPORT THIS>
+
+
+        // Always start with the root state
+        this->requestedStateNodes_.push_back(this->rootStateNode_);
+        this->activeStateNode_ = this->rootStateNode_;
+        this->loadState(this->rootStateNode_->state_);
+
+        // <EXPORT THIS>
+        if (CommandLine::getValue("startWithConsole").getBool())
+        {
+            // Start the game in the console
+            this->requestState("ioConsole");
+        }
+        else
+        {
+            // Start in GUI main menu
+            this->requestState("graphics");
+            this->requestState("gui");
+        }
+        // </EXPORT THIS>
+
+        this->gameClock_->capture(); // first delta time should be about 0 seconds
+        while (!this->abort_ && !this->activeStates_.empty())
+        {
+            this->gameClock_->capture();
+            uint64_t currentTime = this->gameClock_->getMicroseconds();
+
+            // STATISTICS
+            statisticsTickInfo tickInfo = {currentTime, 0};
+            statisticsTickTimes_.push_back(tickInfo);
+            this->periodTime_ += this->gameClock_->getDeltaTimeMicroseconds();
+
+            // UPDATE STATE STACK
+            while (this->requestedStateNodes_.size() > 1)
+            {
+                // Note: this->requestedStateNodes_.front() is the currently active state node
+                std::vector<GameStateTreeNode*>::iterator it = this->requestedStateNodes_.begin() + 1;
+                if (*it == this->activeStateNode_->parent_)
+                    this->unloadState(this->activeStateNode_->state_);
+                else // has to be child
+                    this->loadState((*it)->state_);
+                this->activeStateNode_ = *it;
+                this->requestedStateNodes_.erase(this->requestedStateNodes_.begin());
+            }
+
+            // UPDATE, bottom to top in the stack
+            for (std::vector<GameState*>::const_iterator it = this->activeStates_.begin();
+                it != this->activeStates_.end(); ++it)
+                (*it)->update(*this->gameClock_);
+
+            // STATISTICS
+            if (this->periodTime_ > statisticsRefreshCycle_)
+            {
+                std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
+                assert(it != this->statisticsTickTimes_.end());
+                int64_t lastTime = currentTime - this->statisticsAvgLength_;
+                if ((int64_t)it->tickTime < lastTime)
+                {
+                    do
+                    {
+                        assert(this->periodTickTime_ > it->tickLength);
+                        this->periodTickTime_ -= it->tickLength;
+                        ++it;
+                        assert(it != this->statisticsTickTimes_.end());
+                    } while ((int64_t)it->tickTime < lastTime);
+                    this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
+                }
+
+                uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
+                this->avgFPS_ = (float)framesPerPeriod / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0;
+                this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0;
+
+                this->periodTime_ -= this->statisticsRefreshCycle_;
+            }
+        }
+
+        // Unload all remaining states
+        while (!this->activeStates_.empty())
+            this->unloadState(this->activeStates_.back());
+        this->activeStateNode_ = 0;
+        this->requestedStateNodes_.clear();
+    }
+
+    void Game::stop()
+    {
+        this->abort_ = true;
+    }
+
+    void Game::addTickTime(uint32_t length)
+    {
+        assert(!this->statisticsTickTimes_.empty());
+        this->statisticsTickTimes_.back().tickLength += length;
+        this->periodTickTime_+=length;
+    }
+
+
+    /***** GameState related *****/
+
+    void Game::requestState(const std::string& name)
+    {
+        GameState* state = this->getState(name);
+        if (state == NULL || this->activeStateNode_ == NULL)
+            return;
+
+        GameStateTreeNode* requestedNode = 0;
+
+        // this->requestedStateNodes_.back() is the currently active state
+        GameStateTreeNode* lastRequestedNode = this->requestedStateNodes_.back();
+
+        // Already the active node?
+        if (state == lastRequestedNode->state_)
+        {
+            COUT(2) << "Warning: Requesting the currently active state! Ignoring." << std::endl;
+            return;
+        }
+
+        // Check children first
+        for (unsigned int i = 0; i < lastRequestedNode->children_.size(); ++i)
+        {
+            if (lastRequestedNode->children_[i]->state_ == state)
+            {
+                requestedNode = lastRequestedNode->children_[i];
+                break;
+            }
+        }
+
+        // Check parent and all its grand parents
+        GameStateTreeNode* currentNode = lastRequestedNode;
+        while (requestedNode == NULL && currentNode->parent_ != NULL)
+        {
+            if (currentNode->state_ == state)
+                requestedNode = currentNode;
+            currentNode = currentNode->parent_;
+        }
+
+        if (requestedNode == NULL)
+            COUT(1) << "Error: Requested GameState transition is not allowed. Ignoring." << std::endl;
+        else
+            this->requestedStateNodes_.push_back(requestedNode);
+    }
+
+    void Game::popState()
+    {
+        if (this->activeStateNode_ != NULL && this->requestedStateNodes_.back()->parent_)
+            this->requestState(this->requestedStateNodes_.back()->parent_->state_->getName());
+        else
+            COUT(2) << "Warning: Could not pop GameState. Ignoring." << std::endl;
+    }
+
+    GameState* Game::getState(const std::string& name)
+    {
+        std::map<std::string, GameState*>::const_iterator it = allStates_s.find(name);
+        if (it != allStates_s.end())
+            return it->second;
+        else
+        {
+            COUT(1) << "Error: Could not find GameState '" << name << "'. Ignoring." << std::endl;
+            return 0;
+        }
+    }
+
+    void Game::setStateHierarchy(const std::string& str)
+    {
+        // Split string into pieces of the form whitespacesText
+        std::vector<std::pair<std::string, unsigned> > stateStrings;
+        size_t pos = 0;
+        size_t startPos = 0;
+        while (pos < str.size())
+        {
+            unsigned indentation = 0;
+            while(pos < str.size() && str[pos] == ' ')
+                ++indentation, ++pos;
+            startPos = pos;
+            while(pos < str.size() && str[pos] != ' ')
+                ++pos;
+            stateStrings.push_back(std::pair<std::string, unsigned>(
+                str.substr(startPos, pos - startPos), indentation));
+        }
+        unsigned int currentLevel = 0;
+        GameStateTreeNode* currentNode = 0;
+        for (std::vector<std::pair<std::string, unsigned> >::const_iterator it = stateStrings.begin(); it != stateStrings.end(); ++it)
+        {
+            std::string newStateName = it->first;
+            unsigned newLevel = it->second;
+            GameState* newState = this->getState(newStateName);
+            if (!newState)
+                ThrowException(GameState, std::string("GameState with name '") + newStateName + "' not found!");
+            if (newLevel == 0)
+            {
+                // root
+                if (this->rootStateNode_ != NULL)
+                    ThrowException(GameState, "No two root GameStates are allowed!");
+                GameStateTreeNode* newNode = new GameStateTreeNode;
+                newNode->state_ = newState;
+                newNode->parent_ = 0;
+                this->rootStateNode_ = newNode;
+                currentNode = this->rootStateNode_;
+            }
+            else if (currentNode)
+            {
+                GameStateTreeNode* newNode = new GameStateTreeNode;
+                newNode->state_ = newState;
+                if (newLevel < currentLevel)
+                {
+                    // Get down the hierarchy
+                    do
+                        currentNode = currentNode->parent_;
+                    while (newLevel < --currentLevel);
+                }
+                if (newLevel == currentLevel)
+                {
+                    // same level
+                    newNode->parent_ = currentNode->parent_;
+                    newNode->parent_->children_.push_back(newNode);
+                }
+                else if (newLevel == currentLevel + 1)
+                {
+                    // child
+                    newNode->parent_ = currentNode;
+                    currentNode->children_.push_back(newNode);
+                }
+                else
+                    ThrowException(GameState, "Indentation error while parsing the hierarchy.");
+                currentNode = newNode;
+                currentLevel = newLevel;
+            }
+            else
+            {
+                ThrowException(GameState, "No root GameState specified!");
+            }
+        }
+    }
+
+    /*** Internal ***/
+
+    void Game::loadState(GameState* state)
+    {
+        state->activate();
+        this->activeStates_.push_back(state);
+    }
+
+    void Game::unloadState(orxonox::GameState* state)
+    {
+        state->deactivate();
+        this->activeStates_.pop_back();
+    }
+
+    /*static*/ bool Game::addGameState(GameState* state)
+    {
+        std::map<std::string, GameState*>::const_iterator it = allStates_s.find(state->getName());
+        if (it == allStates_s.end())
+            allStates_s[state->getName()] = state;
+        else
+            ThrowException(GameState, "Cannot add two GameStates with the same name to 'Game'.");
+
+        // just a required dummy return value
+        return true;
+    }
+}
Index: /code/branches/gui/src/core/Game.h
===================================================================
--- /code/branches/gui/src/core/Game.h	(revision 2844)
+++ /code/branches/gui/src/core/Game.h	(revision 2844)
@@ -0,0 +1,117 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Declaration of Game Singleton.
+ */
+
+#ifndef _Game_H__
+#define _Game_H__
+
+#include "CorePrereqs.h"
+#include <cassert>
+#include <list>
+#include <map>
+#include <vector>
+#include "OrxonoxClass.h"
+
+#define AddGameState(classname, name, ...) \
+    static bool bGameStateDummy_##classname##__LINE__ = orxonox::Game::addGameState(new classname(name, __VA_ARGS__))
+
+namespace orxonox
+{
+    /**
+    @brief
+        Main class responsible for running the game.
+    */
+    class _CoreExport Game : public OrxonoxClass
+    {
+    public:
+        Game(int argc, char** argv);
+        ~Game();
+        void setConfigValues();
+
+        void setStateHierarchy(const std::string& str);
+        GameState* getState(const std::string& name);
+
+        void run();
+        void stop();
+
+        void requestState(const std::string& name);
+        void popState();
+
+        float getAvgTickTime() { return this->avgTickTime_; }
+        float getAvgFPS()      { return this->avgFPS_; }
+
+        void addTickTime(uint32_t length);
+
+        static bool addGameState(GameState* state);
+        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+    private:
+        struct statisticsTickInfo
+        {
+            uint64_t    tickTime;
+            uint32_t    tickLength;
+        };
+
+        Game(Game&); // don't mess with singletons
+
+        void loadState(GameState* state);
+        void unloadState(GameState* state);
+
+        std::vector<GameState*>         activeStates_;
+        GameStateTreeNode*              rootStateNode_;
+        GameStateTreeNode*              activeStateNode_;
+        std::vector<GameStateTreeNode*> requestedStateNodes_;
+
+        Core*                           core_;
+        Clock*                          gameClock_;
+
+        bool                            abort_;
+
+        // variables for time statistics
+        uint64_t                        statisticsStartTime_;
+        std::list<statisticsTickInfo>   statisticsTickTimes_;
+        uint32_t                        periodTime_;
+        uint32_t                        periodTickTime_;
+        float                           avgFPS_;
+        float                           avgTickTime_;
+
+        // config values
+        unsigned int                    statisticsRefreshCycle_;
+        unsigned int                    statisticsAvgLength_;
+
+        static std::map<std::string, GameState*> allStates_s;
+        static Game* singletonRef_s;        //!< Pointer to the Singleton
+    };
+}
+
+#endif /* _Game_H__ */
Index: /code/branches/gui/src/core/GameState.cc
===================================================================
--- /code/branches/gui/src/core/GameState.cc	(revision 2843)
+++ /code/branches/gui/src/core/GameState.cc	(revision 2844)
@@ -34,6 +34,8 @@
 
 #include "GameState.h"
+#include <cassert>
 #include "util/Debug.h"
 #include "util/Exception.h"
+#include "Clock.h"
 
 namespace orxonox
@@ -46,9 +48,7 @@
         : name_(name)
         , parent_(0)
-        , activeChild_(0)
-        //, bPausegetParent()(false)
     {
-        Operations temp = {false, false, false, false, false};
-        this->operation_ = temp;
+        State temp = {false, false, false, false, false};
+        this->activity_ = temp;
     }
 
@@ -59,5 +59,5 @@
     GameState::~GameState()
     {
-        OrxAssert(this->operation_.active == false, "Deleting an active GameState is a very bad idea..");
+        OrxAssert(this->activity_.active == false, "Deleting an active GameState is a very bad idea..");
     }
 
@@ -71,37 +71,17 @@
     void GameState::addChild(GameState* state)
     {
-        if (!state)
-            return;
-        // check if the state/tree to be added has states in it that already exist in this tree.
-        for (std::map<std::string, GameState*>::const_iterator it = state->allChildren_.begin();
-            it != state->allChildren_.end(); ++it)
+        assert(state != NULL);
+
+        std::map<std::string, GameState*>::const_iterator it = this->children_.find(state->getName());
+        if (it == this->children_.end())
         {
-            if (this->getState(it->second->getName()))
-            {
-                ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
-                return;
-            }
+            this->children_[state->getName()] = state;
+            // mark us as parent
+            state->setParent(this);
         }
-        if (this->getState(state->name_))
+        else
         {
-            ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
-            return;
+            ThrowException(GameState, "Cannot add two children with the same name");
         }
-        // Make sure we don't add a tree that already has an active state.
-        if (state->getCurrentState())
-        {
-            ThrowException(GameState, "Cannot merge a tree that is already active.");
-            return;
-        }
-
-        // merge the child's children into this tree
-        for (std::map<std::string, GameState*>::const_iterator it = state->allChildren_.begin();
-            it != state->allChildren_.end(); ++it)
-            this->grandchildAdded(state, it->second);
-        // merge 'state' into this tree
-        this->grandchildAdded(state, state);
-
-        // mark us as parent
-        state->setParent(this);
     }
 
@@ -115,252 +95,39 @@
     void GameState::removeChild(GameState* state)
     {
-        std::map<GameState*, GameState*>::iterator it = this->grandchildrenToChildren_.find(state);
-        if (it != this->grandchildrenToChildren_.end())
-        {
-            if (state->isInSubtree(getCurrentState()))
-            {
-                ThrowException(GameState, "Cannot remove an active game state child '"
-                    + state->getName() + "' from '" + name_ + "'.");
-                //COUT(2) << "Warning: Cannot remove an active game state child '" << state->getName()
-                //    << "' from '" << name_ << "'." << std::endl;
-            }
-            else
-            {
-                for (std::map<GameState*, GameState*>::const_iterator it = state->grandchildrenToChildren_.begin();
-                    it != state->grandchildrenToChildren_.end(); ++it)
-                    this->grandchildRemoved(it->first);
-                this->grandchildRemoved(state);
-            }
-        }
+        assert(state != NULL);
+
+        std::map<std::string, GameState*>::iterator it = this->children_.find(state->getName());
+        if (it != this->children_.end())
+            this->children_.erase(it);
         else
         {
             ThrowException(GameState, "Game state '" + name_ + "' doesn't have a child named '"
                 + state->getName() + "'.");
-            //COUT(2) << "Warning: Game state '" << name_ << "' doesn't have a child named '"
-            //    << state->getName() << "'. Removal skipped." << std::endl;
         }
     }
 
-    /**
-    @brief
-        Removes a child by name. This splits the tree in two parts,
-        each of them functional on its own.
-    @param state
-        GameState by name
-    */
-
-    void GameState::removeChild(const std::string& name)
+    void GameState::activateInternal()
     {
-        GameState* state = getState(name);
-        if (state)
-        {
-            removeChild(state);
-        }
-        else
-        {
-            ThrowException(GameState, "GameState '" + name + "' doesn't exist.");
-            //COUT(2) << "Warning: GameState '" << name << "' doesn't exist." << std::endl;
-        }
+        this->activity_.activating = true;
+        this->activate();
+        this->activity_.activating = false;
+        this->activity_.active = true;
     }
 
-    /**
-    @brief
-        Tells a state that one of its children has added a child. This is necessary
-        to fill the internal maps correctly.
-    @param child
-        The child who notices this state.
-    @param grandchild
-        The child that has been added.
-    */
-    inline void GameState::grandchildAdded(GameState* child, GameState* grandchild)
+    void GameState::deactivateInternal()
     {
-        // fill the two maps correctly.
-        this->allChildren_[grandchild->getName()] = grandchild;
-        this->grandchildrenToChildren_[grandchild] = child;
-        if (this->getParent())
-            this->getParent()->grandchildAdded(this, grandchild);
+        this->activity_.active = false;
+        this->activity_.deactivating = true;
+        this->activate();
+        this->activity_.deactivating = false;
+        this->activity_.suspended = false;
+        this->activity_.updating = false;
     }
 
-    /**
-    @brief
-        Tells a state that one of its children has removed a child. This is necessary
-        to fill the internal maps correctly.
-    @param child
-        The child who notices this state.
-    @param grandchild
-        The child that has been removed.
-    */
-    inline void GameState::grandchildRemoved(GameState* grandchild)
+    void GameState::updateInternal(const Clock& time)
     {
-        // adjust the two maps correctly.
-        this->allChildren_.erase(grandchild->getName());
-        this->grandchildrenToChildren_.erase(grandchild);
-        if (this->getParent())
-            this->getParent()->grandchildRemoved(grandchild);
-    }
-
-    /**
-    @brief
-        Checks whether a specific game states exists in the hierarchy.
-    @remarks
-        Remember that the every node has a map with all its child nodes.
-    */
-    GameState* GameState::getState(const std::string& name)
-    {
-        if (this->getParent())
-            return this->getParent()->getState(name);
-        else
-        {
-            // The map only contains children, so check ourself first
-            if (name == this->name_)
-                return this;
-            // Search in the map. If there is no entry, we can be sure the state doesn't exist.
-            std::map<std::string, GameState*>::const_iterator it = this->allChildren_.find(name);
-            return (it!= this->allChildren_.end() ? it->second : 0);
-        }
-    }
-
-    /**
-    @brief
-        Returns the root node of the tree.
-    */
-    GameState* GameState::getRoot()
-    {
-        if (this->getParent())
-            return this->getParent()->getRoot();
-        else
-            return this;
-    }
-
-    /**
-    @brief
-        Returns the current active state.
-    @remarks
-        Remember that the current active state is the one that does not
-        have active children itself. Many states can be active at once.
-    */
-    GameState* GameState::getCurrentState()
-    {
-        if (this->operation_.active)
-        {
-            if (this->activeChild_)
-                return this->activeChild_->getCurrentState();
-            else
-                return this;
-        }
-        else
-        {
-            if (this->getParent())
-                return this->getParent()->getCurrentState();
-            else
-                return 0;
-        }
-    }
-
-    /**
-    @brief
-        Determines whether 'state' is in this subtree, including this node.
-    */
-    bool GameState::isInSubtree(GameState* state) const
-    {
-        return (grandchildrenToChildren_.find(state) != grandchildrenToChildren_.end()
-                || state == this);
-    }
-
-    /**
-    @brief
-        Makes a state transition according to the state tree. You can choose any state
-        in the tree to do the call. The function finds the current state on its own.
-    @param state
-        The state to be entered, has to exist in the tree.
-    */
-    void GameState::requestState(const std::string& name)
-    {
-        assert(getRoot());
-        getRoot()->requestState(name);
-    }
-
-    /**
-    @brief
-        Internal method that actually makes the state transition. Since it is internal,
-        the method can assume certain things to be granted (like 'this' is always active).
-    */
-    void GameState::makeTransition(GameState* source, GameState* destination)
-    {
-        if (source == this->getParent())
-        {
-            // call is from the parent
-            this->activate();
-        }
-        else if (source == 0)
-        {
-            // call was just started by root
-            // don't do anyting yet
-        }
-        else
-        {
-            // call is from a child
-            this->activeChild_ = 0;
-        }
-
-        if (destination == this)
-            return;
-
-        // Check for 'destination' in the children map first
-        std::map<GameState*, GameState*>::const_iterator it
-            = this->grandchildrenToChildren_.find(destination);
-        if (it != this->grandchildrenToChildren_.end())
-        {
-            // child state. Don't use 'state', might be a grandchild!
-            this->activeChild_ = it->second;
-            it->second->makeTransition(this, destination);
-        }
-        else
-        {
-            // parent. We can be sure of this.
-            assert(this->getParent() != 0);
-
-            this->deactivate();
-            this->getParent()->makeTransition(this, destination);
-        }
-    }
-
-    /**
-    @brief
-        Activates the state. Only sets bActive_ to true and notifies the parent.
-    */
-    void GameState::activate()
-    {
-        this->operation_.active = true;
-        this->operation_.entering = true;
-        this->enter();
-        this->operation_.entering = false;
-    }
-
-    /**
-        Activates the state. Only sets bActive_ to false and notifies the parent.
-    */
-    void GameState::deactivate()
-    {
-        this->operation_.leaving = true;
-        this->leave();
-        this->operation_.leaving = false;
-        this->operation_.active = false;
-    }
-
-    /**
-    @brief
-        Update method that calls ticked() with enclosed bRunning_ = true
-        If there was a state transition request within ticked() then this
-        method will transition in the end.
-    @param dt Delta time
-    @note
-        This method is not virtual! You cannot override it therefore.
-    */
-    void GameState::tick(const Clock& time)
-    {
-        this->operation_.running = true;
-        this->ticked(time);
-        this->operation_.running = false;
+        this->activity_.updating = true;
+        this->update(time);
+        this->activity_.updating = false;
     }
 }
Index: /code/branches/gui/src/core/GameState.h
===================================================================
--- /code/branches/gui/src/core/GameState.h	(revision 2843)
+++ /code/branches/gui/src/core/GameState.h	(revision 2844)
@@ -39,8 +39,6 @@
 
 #include <string>
-#include <vector>
 #include <map>
-#include <cassert>
-#include "Clock.h"
+#include "CorePrereqs.h"
 
 namespace orxonox
@@ -62,6 +60,4 @@
     class _CoreExport GameState
     {
-        friend class RootGameState;
-        // Hack
         friend class Game;
 
@@ -71,11 +67,11 @@
             Gives information about what the GameState is currently doing
         */
-        struct Operations
+        struct State
         {
-            unsigned active    : 1;
-            unsigned entering  : 1;
-            unsigned leaving   : 1;
-            unsigned running   : 1;
-            unsigned suspended : 1;
+            unsigned active       : 1;
+            unsigned activating   : 1;
+            unsigned deactivating : 1;
+            unsigned updating     : 1;
+            unsigned suspended    : 1;
         };
 
@@ -85,48 +81,26 @@
 
         const std::string& getName() const { return name_; }
-        const Operations getOperation() const { return this->operation_; }
-        bool isInSubtree(GameState* state) const;
-
-        GameState* getState(const std::string& name);
-        GameState* getRoot();
-        //! Returns the currently active game state
-        virtual GameState* getCurrentState();
-
-        virtual void requestState(const std::string& name);
+        const State getActivity() const    { return this->activity_; }
+        GameState* getParent() const       { return this->parent_; }
 
         void addChild(GameState* state);
         void removeChild(GameState* state);
-        void removeChild(const std::string& name);
 
     protected:
-        virtual void enter() = 0;
-        virtual void leave() = 0;
-        virtual void ticked(const Clock& time) = 0;
-
-        GameState* getActiveChild() { return this->activeChild_; }
-
-        void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
-
-        GameState* getParent() const     { return this->parent_; }
-        void setParent(GameState* state) { this->parent_ = state; }
+        virtual void activate() = 0;
+        virtual void deactivate() = 0;
+        virtual void update(const Clock& time) = 0;
 
     private:
-        //! Performs a transition to 'destination'
-        virtual void makeTransition(GameState* source, GameState* destination);
-
-        void grandchildAdded(GameState* child, GameState* grandchild);
-        void grandchildRemoved(GameState* grandchild);
-
-        void tick(const Clock& time);
-        void activate();
-        void deactivate();
+        void setParent(GameState* state) { this->parent_ = state; }
+        void setActivity(State activity);
+        void activateInternal();
+        void deactivateInternal();
+        void updateInternal(const Clock& time);
 
         const std::string                        name_;
-        Operations                               operation_;
+        State                                    activity_;
         GameState*                               parent_;
-        GameState*                               activeChild_;
-        //bool                                     bPauseParent_;
-        std::map<std::string, GameState*>        allChildren_;
-        std::map<GameState*, GameState*>         grandchildrenToChildren_;
+        std::map<std::string, GameState*>        children_;
     };
 }
Index: de/branches/gui/src/core/RootGameState.cc
===================================================================
--- /code/branches/gui/src/core/RootGameState.cc	(revision 2843)
+++ 	(revision )
@@ -1,118 +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:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#include "RootGameState.h"
-
-#include "util/Debug.h"
-#include "util/Exception.h"
-#include "Clock.h"
-
-namespace orxonox
-{
-    RootGameState::RootGameState(const std::string& name)
-        : GameState(name)
-        , stateRequest_("")
-    {
-    }
-
-    RootGameState::~RootGameState()
-    {
-    }
-
-    /**
-    @brief
-        Internal method that actually makes the state transition. Since it is internal,
-        the method can assume certain things to be granted (like 'this' is always active).
-    */
-    void RootGameState::makeTransition(GameState* source, GameState* destination)
-    {
-        if (source != 0)
-        {
-            // transition was not initiated by root itself
-            this->activeChild_ = 0;
-        }
-
-        if (destination == this)
-        {
-            // this marks the end of the game.
-            return;
-        }
-
-        // Check for 'destination' in the children map first
-        std::map<GameState*, GameState*>::const_iterator it
-            = this->grandchildrenToChildren_.find(destination);
-        if (it != this->grandchildrenToChildren_.end())
-        {
-            OrxAssert(static_cast<GameState*>(it->second) != 0,
-                "There was a mix with RootGameState and GameState, could not cast.");
-            GameState* child = static_cast<GameState*>(it->second);
-            // child state. Don't use 'state', might be a grandchild!
-            this->activeChild_ = child;
-            child->makeTransition(this, destination);
-        }
-        else
-        {
-            // root doesn't have a parent..
-            OrxAssert(false, "GameState '" + destination->getName() + "' not found in children list of Root.");
-        }
-    }
-
-    void RootGameState::gotoState(const std::string& name)
-    {
-        GameState* request = getState(name);
-        if (request)
-        {
-            GameState* current = getCurrentState();
-            if (current)
-            {
-                current->makeTransition(0, request);
-            }
-            else
-            {
-                // Root is not yet active. This is a violation.
-                ThrowException(GameState, "Activate Root before requesting a state.");
-            }
-        }
-        else
-        {
-            COUT(2) << "Warning: GameState '" << name << "' doesn't exist." << std::endl;
-        }
-    }
-
-    /**
-    @brief
-        Makes a state transition according to the state tree. You can choose any state
-        in the tree to do the call. The function finds the current state on its own.
-    @param state
-        The state to be entered, has to exist in the tree.
-    */
-    void RootGameState::requestState(const std::string& name)
-    {
-        this->stateRequest_ = name;
-    }
-}
Index: de/branches/gui/src/core/RootGameState.h
===================================================================
--- /code/branches/gui/src/core/RootGameState.h	(revision 2843)
+++ 	(revision )
@@ -1,56 +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:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _RootGameState_H__
-#define _RootGameState_H__
-
-#include "CorePrereqs.h"
-#include "GameState.h"
-
-namespace orxonox
-{
-    class _CoreExport RootGameState : public GameState
-    {
-        // Hack!
-        friend class Game;
-
-    public:
-        RootGameState(const std::string& name);
-        ~RootGameState();
-
-        void requestState(const std::string& name);
-
-    private:
-        void makeTransition(GameState* source, GameState* destination);
-        void gotoState(const std::string& name);
-
-        std::string stateRequest_;
-    };
-}
-
-#endif /* _RootGameState_H__ */
Index: /code/branches/gui/src/network/Server.h
===================================================================
--- /code/branches/gui/src/network/Server.h	(revision 2843)
+++ /code/branches/gui/src/network/Server.h	(revision 2844)
@@ -53,5 +53,5 @@
   const int CLIENTID_SERVER = 0;
   const unsigned int NETWORK_FREQUENCY = 25;
-  const float NETWORK_PERIOD = 1./NETWORK_FREQUENCY;
+  const float NETWORK_PERIOD = 1.f/NETWORK_FREQUENCY;
 
   /**
Index: /code/branches/gui/src/orxonox/CMakeLists.txt
===================================================================
--- /code/branches/gui/src/orxonox/CMakeLists.txt	(revision 2843)
+++ /code/branches/gui/src/orxonox/CMakeLists.txt	(revision 2844)
@@ -20,7 +20,7 @@
 SET_SOURCE_FILES(ORXONOX_SRC_FILES
   CameraManager.cc
-  Game.cc
   GraphicsManager.cc
   LevelManager.cc
+  Main.cc
   PawnManager.cc
   PlayerManager.cc
Index: de/branches/gui/src/orxonox/Game.cc
===================================================================
--- /code/branches/gui/src/orxonox/Game.cc	(revision 2843)
+++ 	(revision )
@@ -1,228 +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:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-@file
-@brief
-    Implementation of the Game class.
-*/
-
-#include "OrxonoxStableHeaders.h"
-#include "Game.h"
-
-#include <exception>
-#include <cassert>
-
-#include "util/Debug.h"
-#include "util/Exception.h"
-#include "core/CommandLine.h"
-#include "core/ConsoleCommand.h"
-#include "core/Core.h"
-#include "core/Identifier.h"
-#include "core/CoreIncludes.h"
-#include "core/ConfigValueIncludes.h"
-
-#include "gamestates/GSRoot.h"
-#include "gamestates/GSGraphics.h"
-#include "gamestates/GSStandalone.h"
-#include "gamestates/GSServer.h"
-#include "gamestates/GSClient.h"
-#include "gamestates/GSDedicated.h"
-#include "gamestates/GSGUI.h"
-#include "gamestates/GSIOConsole.h"
-
-/*
-@brief
-    Main method. Game starts here (except for static initialisations).
-*/
-int main(int argc, char** argv)
-{
-    {
-        orxonox::Game orxonox(argc, argv);
-        orxonox.run();
-        // objects gets destroyed here!
-    }
-
-    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
-    // Needs to be done after Game destructor because of ~OrxonoxClass
-    orxonox::Identifier::destroyAllIdentifiers();
-
-    return 0;
-}
-
-namespace orxonox
-{
-    void stop_game()
-    {
-        Game::getInstance().stop();
-    }
-
-    SetCommandLineArgument(state, "gui").shortcut("s");
-    SetConsoleCommandShortcutExternAlias(stop_game, "exit");
-
-    Game* Game::singletonRef_s = 0;
-
-    /**
-    @brief
-        Non-initialising constructor.
-    */
-    Game::Game(int argc, char** argv)
-    {
-        assert(singletonRef_s == 0);
-        singletonRef_s = this;
-
-        this->abort_ = false;
-
-        // reset statistics
-        this->statisticsStartTime_ = 0;
-        this->statisticsTickTimes_.clear();
-        this->periodTickTime_ = 0;
-        this->periodTime_ = 0;
-        this->avgFPS_ = 0.0f;
-        this->avgTickTime_ = 0.0f;
-
-        this->core_ = new orxonox::Core();
-        this->gameClock_ = this->core_->initialise(argc, argv);
-
-        RegisterRootObject(Game);
-        this->setConfigValues();
-    }
-
-    /**
-    @brief
-    */
-    Game::~Game()
-    {
-        // Destroy pretty much everyhting left
-        delete this->core_;
-
-        assert(singletonRef_s);
-        singletonRef_s = 0;
-    }
-
-    void Game::setConfigValues()
-    {
-        SetConfigValue(statisticsRefreshCycle_, 250000)
-            .description("Sets the time in microseconds interval at which average fps, etc. get updated.");
-        SetConfigValue(statisticsAvgLength_, 1000000)
-            .description("Sets the time in microseconds interval at which average fps, etc. gets calculated.");
-    }
-
-    /**
-    @brief
-        Main loop of the orxonox game.
-    @note
-        We use the Ogre::Timer to measure time since it uses the most precise
-        method an any platform (however the windows timer lacks time when under
-        heavy kernel load!).
-    */
-    void Game::run()
-    {
-        // create the gamestates
-        GSRoot root;
-        GSGraphics graphics;
-        GSStandalone standalone;
-        GSServer server;
-        GSClient client;
-        GSDedicated dedicated;
-        GSGUI gui;
-        GSIOConsole ioConsole;
-
-        // make the hierarchy
-        root.addChild(&graphics);
-        graphics.addChild(&standalone);
-        graphics.addChild(&server);
-        graphics.addChild(&client);
-        graphics.addChild(&gui);
-        root.addChild(&ioConsole);
-        root.addChild(&dedicated);
-
-        root.activate();
-
-        // get initial state from command line
-        root.gotoState(CommandLine::getValue("state"));
-
-        this->gameClock_->capture(); // first delta time should be about 0 seconds
-        while (!this->abort_)
-        {
-            this->gameClock_->capture();
-            uint64_t currentTime = this->gameClock_->getMicroseconds();
-
-            // STATISTICS
-            statisticsTickInfo tickInfo = {currentTime, 0};
-            statisticsTickTimes_.push_back(tickInfo);
-            this->periodTime_ += this->gameClock_->getDeltaTimeMicroseconds();
-
-            // UPDATE
-            root.tick(*this->gameClock_);
-
-            // STATISTICS
-            if (this->periodTime_ > statisticsRefreshCycle_)
-            {
-                std::list<statisticsTickInfo>::iterator it = this->statisticsTickTimes_.begin();
-                assert(it != this->statisticsTickTimes_.end());
-                int64_t lastTime = currentTime - this->statisticsAvgLength_;
-                if ((int64_t)it->tickTime < lastTime)
-                {
-                    do
-                    {
-                        assert(this->periodTickTime_ > it->tickLength);
-                        this->periodTickTime_ -= it->tickLength;
-                        ++it;
-                        assert(it != this->statisticsTickTimes_.end());
-                    } while ((int64_t)it->tickTime < lastTime);
-                    this->statisticsTickTimes_.erase(this->statisticsTickTimes_.begin(), it);
-                }
-
-                uint32_t framesPerPeriod = this->statisticsTickTimes_.size();
-                this->avgFPS_ = (float)framesPerPeriod / (currentTime - this->statisticsTickTimes_.front().tickTime) * 1000000.0;
-                this->avgTickTime_ = (float)this->periodTickTime_ / framesPerPeriod / 1000.0;
-
-                this->periodTime_ -= this->statisticsRefreshCycle_;
-            }
-
-            if (root.stateRequest_ != "")
-                root.gotoState(root.stateRequest_);
-        }
-
-        root.gotoState("root");
-        root.deactivate();
-    }
-
-    void Game::stop()
-    {
-        this->abort_ = true;
-    }
-
-    void Game::addTickTime(uint32_t length)
-    {
-        assert(!this->statisticsTickTimes_.empty());
-        this->statisticsTickTimes_.back().tickLength += length;
-        this->periodTickTime_+=length;
-    }
-}
Index: de/branches/gui/src/orxonox/Game.h
===================================================================
--- /code/branches/gui/src/orxonox/Game.h	(revision 2843)
+++ 	(revision )
@@ -1,97 +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:
- *      Reto Grieder
- *   Co-authors:
- *      ...
- *
- */
-
-/**
-@file
-@brief
-    Declaration of Game Singleton.
- */
-
-#ifndef _Game_H__
-#define _Game_H__
-
-#include "OrxonoxPrereqs.h"
-#include <cassert>
-#include <list>
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
-    /**
-    @brief
-        Main class responsible for running the game.
-    */
-    class _OrxonoxExport Game : public OrxonoxClass
-    {
-    public:
-        Game(int argc, char** argv);
-        ~Game();
-        void setConfigValues();
-
-        void run();
-        void stop();
-
-        float getAvgTickTime() { return this->avgTickTime_; }
-        float getAvgFPS()      { return this->avgFPS_; }
-
-        void addTickTime(uint32_t length);
-
-        static Game& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
-
-    private:
-        struct statisticsTickInfo
-        {
-            uint64_t    tickTime;
-            uint32_t    tickLength;
-        };
-
-        Game(Game&); // don't mess with singletons
-
-        Core* core_;
-        Clock* gameClock_;
-
-        bool abort_;
-
-        // variables for time statistics
-        uint64_t              statisticsStartTime_;
-        std::list<statisticsTickInfo>
-                              statisticsTickTimes_;
-        uint32_t              periodTime_;
-        uint32_t              periodTickTime_;
-        float                 avgFPS_;
-        float                 avgTickTime_;
-
-        // config values
-        unsigned int          statisticsRefreshCycle_;
-        unsigned int          statisticsAvgLength_;
-
-        static Game* singletonRef_s;        //!< Pointer to the Singleton
-    };
-}
-
-#endif /* _Game_H__ */
Index: /code/branches/gui/src/orxonox/Main.cc
===================================================================
--- /code/branches/gui/src/orxonox/Main.cc	(revision 2844)
+++ /code/branches/gui/src/orxonox/Main.cc	(revision 2844)
@@ -0,0 +1,58 @@
+/*
+ *   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:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+ /**
+ @file
+ @brief Entry point of the program.
+  */
+
+#include "OrxonoxStableHeaders.h"
+#include "OrxonoxConfig.h"
+
+#include "util/Debug.h"
+#include "core/Identifier.h"
+#include "core/Game.h"
+
+/*
+@brief
+    Main method. Game starts here (except for static initialisations).
+*/
+int main(int argc, char** argv)
+{
+    {
+        orxonox::Game orxonox(argc, argv);
+        orxonox.run();
+    } // orxonox gets destroyed right here!
+
+    // Clean up class hierarchy stuff (identifiers, xmlport, configvalue, consolecommand)
+    // Needs to be done after Game destructor because of ~OrxonoxClass
+    orxonox::Identifier::destroyAllIdentifiers();
+
+    return 0;
+}
Index: /code/branches/gui/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/gui/src/orxonox/OrxonoxPrereqs.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/OrxonoxPrereqs.h	(revision 2844)
@@ -77,7 +77,4 @@
     namespace MunitionType
     {
-
-
-
         enum Enum
         { laserGunMunition };
@@ -238,15 +235,4 @@
     //gui
     class GUIManager;
-
-    // game states
-    class GSRoot;
-    class GSGraphics;
-    class GSIO;
-    class GSIOConsole;
-    class GSLevel;
-    class GSStandalone;
-    class GSServer;
-    class GSClient;
-    class GSGUI;
 }
 
Index: /code/branches/gui/src/orxonox/gamestates/GSClient.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSClient.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSClient.cc	(revision 2844)
@@ -35,11 +35,14 @@
 #include "core/Core.h"
 #include "network/Client.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
+    AddGameState(GSClient, "client");
+
     SetCommandLineArgument(ip, "127.0.0.1").information("#.#.#.#");
 
-    GSClient::GSClient()
-        : GameState("client")
+    GSClient::GSClient(const std::string& name)
+        : GameState(name)
         , client_(0)
     {
@@ -50,5 +53,5 @@
     }
 
-    void GSClient::enter()
+    void GSClient::activate()
     {
         Core::setIsClient(true);
@@ -59,13 +62,9 @@
             ThrowException(InitialisationFailed, "Could not establish connection with server.");
 
-        GSLevel::enter();
-
         client_->update(Core::getGameClock());
     }
 
-    void GSClient::leave()
+    void GSClient::deactivate()
     {
-        GSLevel::leave();
-
         client_->closeConnection();
 
@@ -76,10 +75,7 @@
     }
 
-    void GSClient::ticked(const Clock& time)
+    void GSClient::update(const Clock& time)
     {
-        GSLevel::ticked(time);
         client_->update(time);
-
-        this->tickChild(time);
     }
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSClient.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSClient.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSClient.h	(revision 2844)
@@ -33,20 +33,18 @@
 #include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
-#include "GSLevel.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSClient : public GameState, public GSLevel
+    class _OrxonoxExport GSClient : public GameState
     {
     public:
-        GSClient();
+        GSClient(const std::string& name);
         ~GSClient();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
 
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
         Client* client_;
     };
Index: /code/branches/gui/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSDedicated.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSDedicated.cc	(revision 2844)
@@ -37,9 +37,12 @@
 #include "objects/Tickable.h"
 #include "util/Sleep.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
-    GSDedicated::GSDedicated()
-        : GameState("dedicated")
+    AddGameState(GSDedicated, "dedicated");
+
+    GSDedicated::GSDedicated(const std::string& name)
+        : GameState(name)
         , server_(0)
         , timeSinceLastUpdate_(0)
@@ -51,5 +54,5 @@
     }
 
-    void GSDedicated::enter()
+    void GSDedicated::activate()
     {
         Core::setHasServer(true);
@@ -58,13 +61,9 @@
         COUT(0) << "Loading scene in server mode" << std::endl;
 
-        GSLevel::enter();
-
         server_->open();
     }
 
-    void GSDedicated::leave()
+    void GSDedicated::deactivate()
     {
-        GSLevel::leave();
-
         this->server_->close();
         delete this->server_;
@@ -73,5 +72,5 @@
     }
 
-    void GSDedicated::ticked(const Clock& time)
+    void GSDedicated::update(const Clock& time)
     {
 //        static float startTime = time.getSecondsPrecise();
@@ -83,7 +82,5 @@
 //            COUT(0) << "estimated ticks/sec: " << nrOfTicks/(time.getSecondsPrecise()-startTime) << endl;
             timeSinceLastUpdate_ -= static_cast<unsigned int>(timeSinceLastUpdate_ / NETWORK_PERIOD) * NETWORK_PERIOD;
-            GSLevel::ticked(time);
             server_->update(time);
-            this->tickChild(time);
         }
         else
Index: /code/branches/gui/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSDedicated.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSDedicated.h	(revision 2844)
@@ -33,21 +33,20 @@
 #include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
-#include "GSLevel.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSDedicated : public GameState, public GSLevel
+    class _OrxonoxExport GSDedicated : public GameState
     {
     public:
-        GSDedicated();
+        GSDedicated(const std::string& name);
         ~GSDedicated();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
-        Server*      server_;
-        float        timeSinceLastUpdate_;
+        Server* server_;
+        float   timeSinceLastUpdate_;
     };
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSGUI.cc	(revision 2844)
@@ -32,13 +32,17 @@
 #include <OgreViewport.h>
 #include "core/Clock.h"
+#include "core/ConsoleCommand.h"
 #include "core/input/InputManager.h"
 #include "core/input/SimpleInputState.h"
 #include "gui/GUIManager.h"
 #include "GraphicsManager.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
-    GSGUI::GSGUI()
-        : GameState("gui")
+    AddGameState(GSGUI, "gui");
+
+    GSGUI::GSGUI(const std::string& name)
+        : GameState(name)
     {
     }
@@ -48,5 +52,5 @@
     }
 
-    void GSGUI::enter()
+    void GSGUI::activate()
     {
         guiManager_ = GUIManager::getInstancePtr();
@@ -56,17 +60,37 @@
         guiManager_->showGUI("MainMenu", 0);
         GraphicsManager::getInstance().getViewport()->setCamera(guiManager_->getCamera());
+
+        {
+            // time factor console command
+            FunctorMember<GSGUI>* functor = createFunctor(&GSGUI::startGame);
+            functor->setObject(this);
+            this->ccStartGame_ = createConsoleCommand(functor, "startGame");
+            CommandExecutor::addConsoleCommandShortcut(this->ccStartGame_);
+        }
     }
 
-    void GSGUI::leave()
+    void GSGUI::deactivate()
     {
+        if (this->ccStartGame_)
+        {
+            delete this->ccStartGame_;
+            this->ccStartGame_ = 0;
+        }
+
         guiManager_->hideGUI();
     }
 
-    void GSGUI::ticked(const Clock& time)
+    void GSGUI::update(const Clock& time)
     {
         // tick CEGUI
         guiManager_->update(time);
+    }
 
-        this->tickChild(time);
+    void GSGUI::startGame()
+    {
+        // HACK - HACK
+        Game::getInstance().popState();
+        Game::getInstance().requestState("standalone");
+        Game::getInstance().requestState("level");
     }
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSGUI.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGUI.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSGUI.h	(revision 2844)
@@ -38,13 +38,18 @@
     {
     public:
-        GSGUI();
+        GSGUI(const std::string& name);
         ~GSGUI();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
+        void startGame();
+
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
+        GUIManager* guiManager_;
 
-        GUIManager* guiManager_;
+        // console commands
+        ConsoleCommand* ccStartGame_;
     };
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSGraphics.cc	(revision 2844)
@@ -45,10 +45,12 @@
 #include "gui/GUIManager.h"
 #include "GraphicsManager.h"
-#include "Game.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
-    GSGraphics::GSGraphics()
-        : GameState("graphics")
+    AddGameState(GSGraphics, "graphics");
+
+    GSGraphics::GSGraphics(const std::string& name)
+        : GameState(name)
         , inputManager_(0)
         , console_(0)
@@ -60,5 +62,4 @@
     {
         RegisterRootObject(GSGraphics);
-        setConfigValues();
     }
 
@@ -71,6 +72,8 @@
     }
 
-    void GSGraphics::enter()
+    void GSGraphics::activate()
     {
+        setConfigValues();
+
         Core::setShowsGraphics(true);
 
@@ -108,5 +111,5 @@
     }
 
-    void GSGraphics::leave()
+    void GSGraphics::deactivate()
     {
         if (Core::showsGraphics())
@@ -146,5 +149,5 @@
         need the time. So we shouldn't run into problems.
     */
-    void GSGraphics::ticked(const Clock& time)
+    void GSGraphics::update(const Clock& time)
     {
         uint64_t timeBeforeTick = time.getRealMicroseconds();
@@ -152,5 +155,4 @@
         this->inputManager_->update(time);        // tick console
         this->console_->update(time);
-        this->tickChild(time);
 
         uint64_t timeAfterTick = time.getRealMicroseconds();
Index: /code/branches/gui/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSGraphics.h	(revision 2844)
@@ -32,5 +32,4 @@
 #include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
-#include "core/OrxonoxClass.h"
 #include "tools/WindowEventListener.h"
 
@@ -39,22 +38,18 @@
     class _OrxonoxExport GSGraphics : public GameState, public WindowEventListener
     {
-        friend class ClassIdentifier<GSGraphics>;
-
     public:
-        GSGraphics();
+        GSGraphics(const std::string& name);
         ~GSGraphics();
-
-    private: // functions
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
         void setConfigValues();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
+    private:
         // Window events from WindowEventListener
         void windowResized(unsigned int newWidth, unsigned int newHeight);
         void windowFocusChanged();
 
-    private:
         // managed singletons
         InputManager*         inputManager_;
Index: /code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSIOConsole.cc	(revision 2844)
@@ -36,9 +36,12 @@
 
 #include "core/ConsoleCommand.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
-    GSIOConsole::GSIOConsole()
-        : GameState("ioConsole")
+    AddGameState(GSIOConsole, "ioConsole");
+
+    GSIOConsole::GSIOConsole(const std::string& name)
+        : GameState(name)
     {
     }
@@ -48,19 +51,17 @@
     }
 
-    void GSIOConsole::enter()
+    void GSIOConsole::activate()
     {
     }
 
-    void GSIOConsole::leave()
+    void GSIOConsole::deactivate()
     {
     }
 
-    void GSIOConsole::ticked(const Clock& time)
+    void GSIOConsole::update(const Clock& time)
     {
         std::string command;
         std::getline(std::cin, command);
         CommandExecutor::execute(command, true);
-        
-        tickChild(time);
     }
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSIOConsole.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSIOConsole.h	(revision 2844)
@@ -31,5 +31,4 @@
 
 #include "OrxonoxPrereqs.h"
-#include <OgrePrerequisites.h>
 #include "core/GameState.h"
 
@@ -39,11 +38,13 @@
     {
     public:
-        GSIOConsole();
+        GSIOConsole(const std::string& name);
         ~GSIOConsole();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
+
     };
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSLevel.cc	(revision 2844)
@@ -47,12 +47,15 @@
 #include "LevelManager.h"
 #include "PlayerManager.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
+    AddGameState(GSLevel, "level");
+
     SetCommandLineArgument(level, "presentation.oxw").shortcut("l");
 
-    GSLevel::GSLevel()
-//        : GameState(name)
-        : keyBinder_(0)
+    GSLevel::GSLevel(const std::string& name)
+        : GameState(name)
+        , keyBinder_(0)
         , inputState_(0)
         , radar_(0)
@@ -65,19 +68,19 @@
         this->ccKeybind_ = 0;
         this->ccTkeybind_ = 0;
-
+    }
+
+    GSLevel::~GSLevel()
+    {
+    }
+
+    void GSLevel::setConfigValues()
+    {
+        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
+    }
+
+    void GSLevel::activate()
+    {
         setConfigValues();
-    }
-
-    GSLevel::~GSLevel()
-    {
-    }
-
-    void GSLevel::setConfigValues()
-    {
-        SetConfigValue(keyDetectorCallbackCode_, "KeybindBindingStringKeyName=");
-    }
-
-    void GSLevel::enter()
-    {
+
         if (Core::showsGraphics())
         {
@@ -126,5 +129,5 @@
     }
 
-    void GSLevel::leave()
+    void GSLevel::deactivate()
     {
         // destroy console commands
@@ -188,7 +191,7 @@
     }
 
-    void GSLevel::ticked(const Clock& time)
-    {
-        // Commented by 1337: Temporarily moved to GSGraphics.
+    void GSLevel::update(const Clock& time)
+    {
+        // Note: Temporarily moved to GSGraphics.
         //// Call the scene objects
         //for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
@@ -233,5 +236,5 @@
         Command string that can be executed by the CommandExecutor
         OR: Internal string "KeybindBindingStringKeyName=" used for the second call to identify
-        the key/button/axis that has been activated. This is configured above in enter().
+        the key/button/axis that has been activated. This is configured above in activate().
     */
     void GSLevel::keybindInternal(const std::string& command, bool bTemporary)
Index: /code/branches/gui/src/orxonox/gamestates/GSLevel.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSLevel.h	(revision 2844)
@@ -31,24 +31,21 @@
 
 #include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
 #include "core/GameState.h"
-#include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSLevel : public OrxonoxClass
+    class _OrxonoxExport GSLevel : public GameState, public OrxonoxClass
     {
-        friend class ClassIdentifier<GSLevel>;
     public:
-        GSLevel();
+        GSLevel(const std::string& name);
         ~GSLevel();
-
-        // was private before (is public now because of console command in GSStandalone)
         void setConfigValues();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
     protected:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
         void loadLevel();
         void unloadLevel();
Index: /code/branches/gui/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSRoot.cc	(revision 2844)
@@ -32,16 +32,18 @@
 #include "util/Exception.h"
 #include "util/Debug.h"
+#include "core/Clock.h"
 #include "core/Core.h"
-#include "core/CoreIncludes.h"
 #include "core/ConsoleCommand.h"
 #include "tools/TimeFactorListener.h"
 #include "tools/Timer.h"
 #include "objects/Tickable.h"
-#include "Game.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
-    GSRoot::GSRoot()
-        : RootGameState("root")
+    AddGameState(GSRoot, "root");
+
+    GSRoot::GSRoot(const std::string& name)
+        : GameState(name)
         , timeFactor_(1.0f)
         , bPaused_(false)
@@ -56,16 +58,8 @@
     }
 
-    void GSRoot::enter()
+    void GSRoot::activate()
     {
         // reset game speed to normal
         timeFactor_ = 1.0f;
-
-        {
-            // add console commands
-            FunctorMember01<GameState, const std::string&>* functor = createFunctor(&GameState::requestState);
-            functor->setObject(this);
-            this->ccSelectGameState_ = createConsoleCommand(functor, "selectGameState");
-            CommandExecutor::addConsoleCommandShortcut(this->ccSelectGameState_);
-        }
 
         {
@@ -86,9 +80,6 @@
     }
 
-    void GSRoot::leave()
+    void GSRoot::deactivate()
     {
-        // destroy console commands
-        delete this->ccSelectGameState_;
-
         if (this->ccSetTimeFactor_)
         {
@@ -104,5 +95,5 @@
     }
 
-    void GSRoot::ticked(const Clock& time)
+    void GSRoot::update(const Clock& time)
     {
         uint64_t timeBeforeTick = time.getRealMicroseconds();
@@ -129,6 +120,4 @@
         // Also add our tick time to the list in GSRoot
         Game::getInstance().addTickTime(timeAfterTick - timeBeforeTick);
-
-        this->tickChild(time);
     }
 
Index: /code/branches/gui/src/orxonox/gamestates/GSRoot.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSRoot.h	(revision 2844)
@@ -31,20 +31,18 @@
 
 #include "OrxonoxPrereqs.h"
-
-#include <list>
-#include "core/RootGameState.h"
+#include "core/GameState.h"
 #include "core/OrxonoxClass.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSRoot : public RootGameState
+    class _OrxonoxExport GSRoot : public GameState
     {
-        friend class ClassIdentifier<GSRoot>;
+    public:
+        GSRoot(const std::string& name);
+        ~GSRoot();
 
-    public:
-    
-    public:
-        GSRoot();
-        ~GSRoot();
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
 
         // this has to be public because proteced triggers a bug in msvc
@@ -55,8 +53,4 @@
 
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
         float                 timeFactor_;       //!< A factor that sets the gamespeed. 1 is normal.
         bool                  bPaused_;
@@ -64,5 +58,4 @@
 
         // console commands
-        ConsoleCommand*       ccSelectGameState_;
         ConsoleCommand*       ccSetTimeFactor_;
         ConsoleCommand*       ccPause_;
Index: /code/branches/gui/src/orxonox/gamestates/GSServer.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSServer.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSServer.cc	(revision 2844)
@@ -33,11 +33,14 @@
 #include "core/Core.h"
 #include "network/Server.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
+    AddGameState(GSServer, "server");
+
     SetCommandLineArgument(port, 55556).shortcut("p").information("0-65535");
 
-    GSServer::GSServer()
-        : GameState("server")
+    GSServer::GSServer(const std::string& name)
+        : GameState(name)
         , server_(0)
     {
@@ -48,5 +51,5 @@
     }
 
-    void GSServer::enter()
+    void GSServer::activate()
     {
         Core::setHasServer(true);
@@ -55,13 +58,9 @@
         COUT(0) << "Loading scene in server mode" << std::endl;
 
-        GSLevel::enter();
-
         server_->open();
     }
 
-    void GSServer::leave()
+    void GSServer::deactivate()
     {
-        GSLevel::leave();
-
         this->server_->close();
         delete this->server_;
@@ -70,9 +69,7 @@
     }
 
-    void GSServer::ticked(const Clock& time)
+    void GSServer::update(const Clock& time)
     {
-        GSLevel::ticked(time);
         server_->update(time);
-        this->tickChild(time);
     }
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSServer.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSServer.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSServer.h	(revision 2844)
@@ -33,20 +33,19 @@
 #include "core/GameState.h"
 #include "network/NetworkPrereqs.h"
-#include "GSLevel.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSServer : public GameState, public GSLevel
+    class _OrxonoxExport GSServer : public GameState
     {
     public:
-        GSServer();
+        GSServer(const std::string& name);
         ~GSServer();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
-        Server*      server_;
+        Server* server_;
     };
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSStandalone.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSStandalone.cc	(revision 2844)
@@ -36,9 +36,12 @@
 #include "gui/GUIManager.h"
 #include "GraphicsManager.h"
+#include "core/Game.h"
 
 namespace orxonox
 {
-    GSStandalone::GSStandalone()
-        : GameState("standalone")
+    AddGameState(GSStandalone, "standalone");
+
+    GSStandalone::GSStandalone(const std::string& name)
+        : GameState(name)
     {
     }
@@ -49,9 +52,7 @@
 
 
-    void GSStandalone::enter()
+    void GSStandalone::activate()
     {
         Core::setIsStandalone(true);
-
-        GSLevel::enter();
 
         guiManager_ = GUIManager::getInstancePtr();
@@ -60,12 +61,10 @@
     }
 
-    void GSStandalone::leave()
+    void GSStandalone::deactivate()
     {
-        GSLevel::leave();
-
         Core::setIsStandalone(false);
     }
 
-    void GSStandalone::ticked(const Clock& time)
+    void GSStandalone::update(const Clock& time)
     {
         //Ogre::Viewport* viewport = GraphicsManager::getInstance().getViewport();
@@ -77,7 +76,4 @@
         // tick CEGUI
         guiManager_->update(time);
-
-        GSLevel::ticked(time);
-        this->tickChild(time);
     }
 }
Index: /code/branches/gui/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- /code/branches/gui/src/orxonox/gamestates/GSStandalone.h	(revision 2843)
+++ /code/branches/gui/src/orxonox/gamestates/GSStandalone.h	(revision 2844)
@@ -32,20 +32,19 @@
 #include "OrxonoxPrereqs.h"
 #include "core/GameState.h"
-#include "GSLevel.h"
 
 namespace orxonox
 {
-    class _OrxonoxExport GSStandalone : public GameState, public GSLevel
+    class _OrxonoxExport GSStandalone : public GameState
     {
     public:
-        GSStandalone();
+        GSStandalone(const std::string& name);
         ~GSStandalone();
 
+        void activate();
+        void deactivate();
+        void update(const Clock& time);
+
     private:
-        void enter();
-        void leave();
-        void ticked(const Clock& time);
-
-        GUIManager*     guiManager_;
+        GUIManager* guiManager_;
     };
 }
Index: /code/branches/gui/src/orxonox/overlays/debug/DebugFPSText.cc
===================================================================
--- /code/branches/gui/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 2844)
@@ -32,5 +32,5 @@
 #include "util/Convert.h"
 #include "core/CoreIncludes.h"
-#include "Game.h"
+#include "core/Game.h"
 
 namespace orxonox
Index: /code/branches/gui/src/orxonox/overlays/debug/DebugRTRText.cc
===================================================================
--- /code/branches/gui/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 2843)
+++ /code/branches/gui/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 2844)
@@ -32,5 +32,5 @@
 #include "core/CoreIncludes.h"
 #include "util/Convert.h"
-#include "Game.h"
+#include "core/Game.h"
 
 namespace orxonox
