Index: code/trunk/CMakeLists.txt
===================================================================
--- code/trunk/CMakeLists.txt	(revision 1754)
+++ code/trunk/CMakeLists.txt	(revision 1755)
@@ -63,5 +63,5 @@
 #Performs the search and sets the variables
 FIND_PACKAGE(OGRE)
-# FIND_PACKAGE(CEGUI)
+FIND_PACKAGE(CEGUI)
 # FIND_PACKAGE(CEGUI_OGRE)
 FIND_PACKAGE(ENet)
@@ -78,5 +78,5 @@
 LINK_DIRECTORIES(
   ${OGRE_LIB_DIR}
-#  ${CEGUI_LIB_DIR} ${CEGUI_OGRE_LIB_DIR}
+  ${CEGUI_LIB_DIR} # ${CEGUI_OGRE_LIB_DIR}
   ${ENet_LIBRARY}
   ${Boost_LIBRARY_DIRS}
@@ -88,5 +88,5 @@
 INCLUDE_DIRECTORIES(
   ${OGRE_INCLUDE_DIR}
-#  ${CEGUI_INCLUDE_DIR} ${CEGUI_OGRE_INCLUDE_DIR}
+  ${CEGUI_INCLUDE_DIR} # ${CEGUI_OGRE_INCLUDE_DIR}
   ${ENet_INCLUDE_DIR}
   ${Boost_INCLUDE_DIRS}
Index: code/trunk/cmake/FindCEGUI.cmake
===================================================================
--- code/trunk/cmake/FindCEGUI.cmake	(revision 1754)
+++ code/trunk/cmake/FindCEGUI.cmake	(revision 1755)
@@ -39,4 +39,5 @@
 SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIR} CACHE PATH "")
 SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
+SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule" CACHE STRING "")
 SET(CEGUI_LIB_DIR ${CEGUI_LIB_DIR} CACHE PATH "")
 
Index: code/trunk/cmake/FindLua.cmake
===================================================================
--- code/trunk/cmake/FindLua.cmake	(revision 1754)
+++ code/trunk/cmake/FindLua.cmake	(revision 1755)
@@ -48,5 +48,5 @@
     # Found newer lua 5.1 libs
     SET(Lua_FOUND TRUE)
-    SET(Lua_VERSION 5.1 CACHE STRING "")
+    SET(Lua_VERSION "5.1" CACHE STRING "")
     SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_51} CACHE PATH "")
     SET(Lua_LIBRARIES ${Lua_LIBRARY_51} CACHE FILEPATH "")
@@ -56,5 +56,5 @@
     # Found older lua 5.0 libs
     SET(Lua_FOUND TRUE)
-    SET(Lua_VERSION 5.0 CACHE STRING "")
+    SET(Lua_VERSION "5.0" CACHE STRING "")
     SET(Lua_INCLUDE_DIR ${Lua_INCLUDE_DIR_50} CACHE PATH "")
     SET(Lua_LIBRARIES ${Lua_LIBRARY_1_50} ${Lua_LIBRARY_2_50} CACHE FILEPATH "")
Index: code/trunk/src/core/CMakeLists.txt
===================================================================
--- code/trunk/src/core/CMakeLists.txt	(revision 1754)
+++ code/trunk/src/core/CMakeLists.txt	(revision 1755)
@@ -1,9 +1,13 @@
 SET(CORE_SRC_FILES
+  Clock.cc
   ConfigFileManager.cc
   ConfigValueContainer.cc
   Core.cc
+  Exception.cc
+  GameState.cc
   Language.cc
   ObjectListBase.cc
   OrxonoxClass.cc
+  RootGameState.cc
   Script.cc
 
@@ -12,4 +16,5 @@
   CommandEvaluation.cc
   CommandExecutor.cc
+  CommandLine.cc
   ConsoleCommand.cc
   ConsoleCommandCompilation.cc
@@ -38,4 +43,5 @@
   input/Button.cc
   input/CalibratorCallback.cc
+  input/ExtendedInputState.cc
   input/HalfAxis.cc
   input/InputBuffer.cc
@@ -44,4 +50,5 @@
   input/KeyBinder.cc
   input/KeyDetector.cc
+  input/SimpleInputState.cc
 
   tolua/tolua_bind.cc
@@ -51,5 +58,5 @@
 ADD_CUSTOM_COMMAND(
   OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc
-  COMMAND ${TOLUA_EXE} -n core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg
+  COMMAND ${TOLUA_EXE} -n Core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg
   DEPENDS tolua
   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
Index: code/trunk/src/core/ClassTreeMask.h
===================================================================
--- code/trunk/src/core/ClassTreeMask.h	(revision 1754)
+++ code/trunk/src/core/ClassTreeMask.h	(revision 1755)
@@ -60,5 +60,5 @@
     step back, and so on.
 
-    Example: A and B are childs of BaseObject, A1 and A2 are childs of A, B1 and B2 are childs of B.
+    Example: A and B are children of BaseObject, A1 and A2 are children of A, B1 and B2 are children of B.
     The ClassTreeMaskIterator would move trough the tree in the following order:
     BaseObject, A, A1, A2, B, B1, B2.
Index: code/trunk/src/core/Clock.cc
===================================================================
--- code/trunk/src/core/Clock.cc	(revision 1755)
+++ code/trunk/src/core/Clock.cc	(revision 1755)
@@ -0,0 +1,78 @@
+/*
+ *   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
+*/
+
+#include "Clock.h"
+#include <OgreTimer.h>
+
+namespace orxonox
+{
+    Clock::Clock()
+        : timer_(new Ogre::Timer())
+        , storedTime_(0)
+        , tickTime_(0)
+        , tickDt_(0)
+        , tickDtFloat_(0.0f)
+        , lastTimersTime_(0)
+    {
+    }
+
+    Clock::~Clock()
+    {
+        delete timer_;
+    }
+    
+    void Clock::capture()
+    {
+        unsigned long timersTime = timer_->getMicroseconds();
+        tickTime_ = storedTime_ + timersTime;
+        tickDt_ = timersTime - lastTimersTime_;
+        tickDtFloat_ = (float)tickDt_ / 1000000.0f;
+
+        if (timersTime > 0x7FFFFFF0)
+        {
+            // Ogre timer will overflow at 2^32 microseconds if unsigned long is 32 bit
+            storedTime_ += timersTime;
+            lastTimersTime_ = 0;
+            timer_->reset();
+        }
+        else
+        {
+            lastTimersTime_ = timersTime;
+        }
+    }
+
+    unsigned long long Clock::getRealMicroseconds() const
+    {
+        return this->timer_->getMicroseconds();
+    }
+}
Index: code/trunk/src/core/Clock.h
===================================================================
--- code/trunk/src/core/Clock.h	(revision 1755)
+++ code/trunk/src/core/Clock.h	(revision 1755)
@@ -0,0 +1,76 @@
+/*
+ *   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:
+ *      Reto Grieder
+ *
+ */
+
+/**
+    @file Core.h
+    @brief Declaration of the Core class.
+
+    The Core class is a singleton, only used to configure some variables
+    in the core through the config-file.
+*/
+
+#ifndef _Clock_H__
+#define _Clock_H__
+
+#include "CorePrereqs.h"
+#include <OgrePrerequisites.h>
+
+namespace orxonox
+{
+    class _CoreExport Clock
+    {
+        friend class RootGameState;
+
+    public:
+        Clock();
+        ~Clock();
+
+        unsigned long long getMicroseconds()   const { return tickTime_; }
+        unsigned long long getMilliseconds()   const { return tickTime_ / 1000; }
+        int                getSeconds()        const { return tickTime_ / 1000000; }
+        float              getSecondsPrecise() const { return (float)tickTime_ / 1000000.0f; }
+
+        float              getDeltaTime()      const { return tickDtFloat_; }
+        int                getDeltaTimeMicroseconds() const { return tickDt_; }
+
+        unsigned long long getRealMicroseconds() const;
+
+    private:
+        Clock(const Clock& instance);
+        void capture();
+
+        Ogre::Timer*       timer_;
+        unsigned long long storedTime_;
+        unsigned long long tickTime_;
+        int                tickDt_;
+        float              tickDtFloat_;
+        unsigned long      lastTimersTime_;
+    };
+}
+
+#endif /* _Clock_H__ */
Index: code/trunk/src/core/CommandExecutor.h
===================================================================
--- code/trunk/src/core/CommandExecutor.h	(revision 1754)
+++ code/trunk/src/core/CommandExecutor.h	(revision 1755)
@@ -36,10 +36,13 @@
 #include "CommandEvaluation.h"
 
-namespace orxonox
-{
+namespace orxonox // tolua_export
+{ // tolua_export
     class _CoreExport CommandExecutor
+    /*
+    class CommandExecutor { // tolua_export
+    */
     {
         public:
-            static bool execute(const std::string& command, bool useTcl = true);
+            static bool execute(const std::string& command, bool useTcl = true); // tolua_export
             static std::string complete(const std::string& command);
             static std::string hint(const std::string& command);
@@ -98,6 +101,6 @@
             std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
             std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
-    };
-}
+    }; // tolua_export
+} // tolua_export
 
 #endif /* _CommandExecutor_H__ */
Index: code/trunk/src/core/CommandLine.cc
===================================================================
--- code/trunk/src/core/CommandLine.cc	(revision 1755)
+++ code/trunk/src/core/CommandLine.cc	(revision 1755)
@@ -0,0 +1,216 @@
+/*
+ *   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 "CommandLine.h"
+
+#include "util/String.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Destructor destroys all CommandLineArguments with it.
+    */
+    CommandLine::~CommandLine()
+    {
+        for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+            it != cmdLineArgs_.end(); ++it)
+        {
+            delete it->second;
+        }
+    }
+
+    /**
+    @brief
+        Returns a unique instance (Meyers Singleton).
+    */
+    CommandLine& CommandLine::_getInstance()
+    {
+        static CommandLine instance;
+        return instance;
+    }
+
+    /**
+    @brief
+        Reads the command line parses the values of each argument.
+        It is then stored in the corresponding CommandLineArgument.
+    @note
+        The reason that you have to provide the string to be parsed as
+        space separted list is because of argc and argv. If you only have
+        a whole string, simply use getAllStrings() of SubString.
+    @param arguments
+        Vector of space separated strings.
+    */
+    void CommandLine::_parse(const std::vector<std::string>& arguments)
+    {
+        // why this? See bFirstTimeParse_ declaration.
+        if (bFirstTimeParse_)
+        {
+            // first shove all the shortcuts in a map
+            for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.begin();
+                it != cmdLineArgs_.end(); ++it)
+            {
+                OrxAssert(cmdLineArgsShortcut_.find(it->second->getShortcut()) == cmdLineArgsShortcut_.end(),
+                    "Cannot have two command line shortcut with the same name.");
+                if (it->second->getShortcut() != "")
+                    cmdLineArgsShortcut_[it->second->getShortcut()] = it->second;
+            }
+            bFirstTimeParse_ = false;
+        }
+
+        std::string name;
+        std::string shortcut;
+        std::string value;
+        for (unsigned int i = 0; i < arguments.size(); ++i)
+        {
+            if (arguments[i].size() != 0)
+            {
+                // sure not ""
+                if (arguments[i][0] == '-')
+                {
+                    // start with "-"
+                    if (arguments[i].size() == 1)
+                    {
+                        // argument[i] is "-", probably a minus sign
+                        value += "- ";
+                    }
+                    else if (arguments[i][1] <= 57 && arguments[i][1] >= 48)
+                    {
+                        // negative number as a value
+                        value += arguments[i] + " ";
+                    }
+                    else
+                    {
+                        // can be shortcut or full name argument
+
+                        // save old data first
+                        value = removeTrailingWhitespaces(value);
+                        if (name != "")
+                        {
+                            checkFullArgument(name, value);
+                            name = "";
+                            assert(shortcut == "");
+                        }
+                        else if (shortcut != "")
+                        {
+                            checkShortcut(shortcut, value);
+                            shortcut = "";
+                            assert(name == "");
+                        }
+
+                        if (arguments[i][1] == '-')
+                        {
+                            // full name argument with "--name"
+                            name = arguments[i].substr(2);
+                        }
+                        else
+                        {
+                            // shortcut with "-s"
+                            shortcut = arguments[i].substr(1);
+                        }
+
+                        // reset value string
+                        value = "";
+                    }
+                }
+                else
+                {
+                    // value string
+
+                    if (name == "" && shortcut == "")
+                    {
+                        ThrowException(Argument, "Expected \"-\" or \"-\" in command line arguments.\n");
+                    }
+
+                    // Concatenate strings as long as there's no new argument by "-" or "--"
+                    value += arguments[i] + ' ';
+                }
+            }
+        }
+
+        // parse last argument
+        value = removeTrailingWhitespaces(value);
+        if (name != "")
+        {
+            checkFullArgument(name, value);
+            assert(shortcut == "");
+        }
+        else if (shortcut != "")
+        {
+            checkShortcut(shortcut, value);
+            assert(name == "");
+        }
+    }
+
+    /**
+    @brief
+        Parses an argument based on its full name.
+    @param name
+        Full name of the argument
+    @param value
+        String containing the value
+    */
+    void CommandLine::checkFullArgument(const std::string& name, const std::string& value)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgs_.find(name);
+        if (it == cmdLineArgs_.end())
+            ThrowException(Argument, "Command line argument '" + name + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    /**
+    @brief
+        Parses an argument based on its shortcut.
+    @param shortcut
+        Shotcut to the argument
+    @param value
+        String containing the value
+    */
+    void CommandLine::checkShortcut(const std::string& shortcut, const std::string& value)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = cmdLineArgsShortcut_.find(shortcut);
+        if (it == cmdLineArgsShortcut_.end())
+            ThrowException(Argument, "Command line shortcut '" + shortcut + "' does not exist.");
+
+        it->second->parse(value);
+    }
+
+    std::string CommandLine::getUsageInformation()
+    {
+        CommandLine* inst = &_getInstance();
+        std::string infoStr;
+        for (std::map<std::string, BaseCommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin();
+            it != inst->cmdLineArgs_.end(); ++it)
+        {
+            infoStr += "[--" + it->second->getName() + " " + it->second->getInformation() + "] ";
+        }
+        return infoStr;
+    }
+
+}
Index: code/trunk/src/core/CommandLine.h
===================================================================
--- code/trunk/src/core/CommandLine.h	(revision 1755)
+++ code/trunk/src/core/CommandLine.h	(revision 1755)
@@ -0,0 +1,333 @@
+/*
+ *   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 _CommandLine_H__
+#define _CommandLine_H__
+
+#include "CorePrereqs.h"
+#include <map>
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "Exception.h"
+
+#define SetCommandLineArgument(name, defaultValue) \
+    BaseCommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLine::addArgument(#name, defaultValue)
+#define SetCommandLineSwitch(name) \
+    BaseCommandLineArgument& CmdArgumentDummyBoolVar##name \
+    = orxonox::CommandLine::addArgument(#name, false)
+
+
+namespace orxonox
+{
+    /**
+    @brief
+        Template struct which creates a distinct type for every integer constant.
+    @note
+        This allows to select a different function depending on a boolean value
+        when creating a new CommandLineArgument.
+        From 'Modern C++ Design' (Alexandrescu 2001).
+    */
+    template <int v>
+    struct Int2Type
+    {
+        enum { value = v };
+    };
+
+    /**
+    @brief
+        Base class for CommandLineArguments.
+    */
+    class _CoreExport BaseCommandLineArgument
+    {
+        friend class CommandLine;
+
+    public:
+        //! Tells whether the value has been changed by the command line.
+        bool hasDefaultValue() const { return bHasDefaultValue_; }
+        //! Returns the name of the argument.
+        const std::string& getName() const { return name_; }
+
+        //! Returns the shortcut (example: "-p 22" for "--port 22") of the argument.
+        //! Evaluates to "" if none there is none.
+        const std::string& getShortcut() const { return shortcut_; }
+        //! Sets the shortcut for the argument
+        BaseCommandLineArgument& setShortcut(const std::string& shortcut)
+        { this->shortcut_ = shortcut; return *this; }
+
+        //! Returns the usage information
+        const std::string& getInformation() const { return this->usageInformation_; }
+        //! Sets the option information when displaying orxonox usage.
+        BaseCommandLineArgument& setInformation(const std::string& usage)
+        { this->usageInformation_ = usage; return *this; }
+
+    protected:
+        BaseCommandLineArgument(const std::string& name)
+            : bHasDefaultValue_(true)
+            , name_(name)
+        { }
+
+        //! Undefined copy constructor
+        BaseCommandLineArgument(const BaseCommandLineArgument& instance);
+        virtual ~BaseCommandLineArgument() { }
+
+        //! Parses the value string of a command line argument.
+        virtual void parse(const std::string& value) = 0;
+
+        //! Tells whether the value has been changed by the command line.
+        bool bHasDefaultValue_;
+
+    private:
+        std::string name_;             //!< Name of the argument
+        std::string shortcut_;         //!< Shortcut of the argument. @see getShortcut().
+        std::string usageInformation_; //!< Tells about the usage of this parameter
+    };
+
+
+    /**
+    @brief
+        Container class for a command line argument of type T.
+        
+        Whenever you want to have an option specified by a command line switch,
+        you need to first define it with SetCommandLineArgument(name, defaultValue).
+        It is then added to a map and possibly changed when the command line is being parsed.
+        If the option was not given, you can detect this by asking hasDefaultValue().
+        
+        There is a possibility to define a short cut so you can write "-p 20" instead of "--port 20".
+        Note the difference between "-" and "--"!
+        Also, there is no restriction to the number of strings you add after --name.
+        So "--startVector (2, 4, 5)" is perfectly legal.
+
+        Retrieving an argument is possible with the getCommandLineArgument function of the
+        CommandLine class. It is a Singleton, but the public interface is static.
+    */
+    template <class T>
+    class CommandLineArgument : public BaseCommandLineArgument
+    {
+        // Only let CommandLine change the value.
+        friend class CommandLine;
+
+    public:
+        //! Returns the actual value of the argument. Can be equal to default value.
+        T getValue() const { return value_; }
+        //! Returns the given default value as type T.
+        T getDefaultValue() const { return defaultValue_; }
+
+    private:
+        //! Constructor initialises both value_ and defaultValue_ with defaultValue.
+        CommandLineArgument(const std::string& name, const T& defaultValue)
+            : BaseCommandLineArgument(name)
+            , value_(defaultValue)
+            , defaultValue_(defaultValue)
+        { }
+
+        virtual void parse(const std::string& value);
+
+        T value_;            //!< The actual value
+        T defaultValue_;     //!< Default value. Should not be changed.
+    };
+
+    /**
+    @brief
+        Parses a value string for a command line argument.
+        It simply uses convertValue(Output, Input) to do that.
+    */
+    template <class T>
+    void CommandLineArgument<T>::parse(const std::string& value)
+    {
+        if (convertValue(&this->value_, value))
+        {
+            this->bHasDefaultValue_ = false;
+        }
+        else
+        {
+            ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+        }
+    }
+
+    /**
+    @brief
+        Parses a value string for a command line argument.
+        It simply uses convertValue(Output, Input) to do that.
+        This is a template specialisation for bool type. That is necessary
+        so that you can have simple command line switches.
+    */
+    template <>
+    inline void CommandLineArgument<bool>::parse(const std::string& value)
+    {
+        if (convertValue(&this->value_, value))
+        {
+            this->bHasDefaultValue_ = false;
+        }
+        else if (value == "")
+        {
+            this->bHasDefaultValue_ = false;
+            this->value_ = true;
+        }
+        else
+        {
+            ThrowException(Argument, "Could not read command line argument '" + getName() + "'.");
+        }
+    }
+
+
+    /**
+    @brief
+        Global interface to command line options.
+        Allows to add and retrieve command line arguments. Also does the parsing.
+    @note
+        Internally it is a Singleton, but the public interface is static.
+    @see
+        CommandLineArgument
+    */
+    class _CoreExport CommandLine
+    {
+    public:
+
+        //! Parse redirection to internal member method.
+        static void parse(const std::vector<std::string>& arguments) { _getInstance()._parse(arguments); }
+
+        static std::string getUsageInformation();
+
+        template <class T>
+        static const CommandLineArgument<T>* getArgument(const std::string& name);
+        //! Writes the argument value in the given parameter.
+        template <class T>
+        static void getValue(const std::string& name, T* value)
+        { *value = getArgument<T>(name)->getValue(); }
+        template <class T>
+        static BaseCommandLineArgument& addArgument(const std::string& name, T defaultValue);
+
+    private:
+        //! Constructor initialises bFirstTimeParse_ with true.
+        CommandLine() : bFirstTimeParse_(true) { }
+        //! Undefined copy constructor
+        CommandLine(const CommandLine& instance);
+        ~CommandLine();
+
+        static CommandLine& _getInstance();
+
+        void _parse(const std::vector<std::string>& arguments);
+        void checkFullArgument(const std::string& name, const std::string& value);
+        void checkShortcut(const std::string& shortcut, const std::string& value);
+
+        template <class T>
+        BaseCommandLineArgument* createArg(const std::string& name, T defaultValue, Int2Type<0> isString);
+        template <class T>
+        BaseCommandLineArgument* createArg(const std::string& name, T defaultValue, Int2Type<1> isString);
+
+        /**
+            Tells whether we parse the first expression. The CommmandLineArguments are added before main().
+            So when we call parse() the first time, we need to create a map with all shortcuts since these
+            get added after addCommandLineArgument().
+        */
+        bool bFirstTimeParse_;
+
+        //! Holds all pointers to the arguments and serves as a search map by name.
+        std::map<std::string, BaseCommandLineArgument*> cmdLineArgs_;
+        //! Search map by chortcut for the arguments.
+        std::map<std::string, BaseCommandLineArgument*> cmdLineArgsShortcut_;
+    };
+
+
+    /**
+    @brief
+        Retrieves a CommandLineArgument.
+        The method throws an exception if 'name' was not found or the value could not be converted.
+    @note
+        You shold of course not call this method before the command line has been parsed.
+    */
+    template <class T>
+    const CommandLineArgument<T>* CommandLine::getArgument(const std::string& name)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        if (it == _getInstance().cmdLineArgs_.end())
+        {
+            ThrowException(Argument, "Could find command line argument '" + name + "'.");
+        }
+        else
+        {
+            CommandLineArgument<T>* arg = dynamic_cast<CommandLineArgument<T>* >(it->second);
+            if (arg == 0)
+            {
+                ThrowException(Argument, "Could not convert command line argument value to requested type. " \
+                    "You should use exactly the same type as predefined.");
+            }
+            else
+            {
+                return arg;
+            }
+        }
+    }
+
+    /**
+    @brief
+        Adds a new CommandLineArgument to the internal map.
+        Note that only such arguments are actually valid.
+    @param name
+        Name of the argument. Shortcut can be added later.
+    @param defaultValue
+        Default value that is used when argument was not given.
+    @note
+        In order to store char* strings as std::string too, there's
+        little bit of template programming involved:
+        StaticConversions::exists determines whether T converts to std::string.
+        Int2Type<int> is then used to call the right function. One returns
+        a CommandLineArgument<T> and the other CommandLineArgument<std::string>.
+    */
+    template <class T>
+    BaseCommandLineArgument& CommandLine::addArgument(const std::string& name, T defaultValue)
+    {
+        std::map<std::string, BaseCommandLineArgument*>::const_iterator it = _getInstance().cmdLineArgs_.find(name);
+        OrxAssert(it == _getInstance().cmdLineArgs_.end(),
+            "Cannot add a command line argument with name '" + name + "' twice.");
+
+        return *(_getInstance().cmdLineArgs_[name] = 
+            _getInstance().createArg(name, defaultValue, Int2Type<StaticConversion<T, std::string>::exists>()));
+    }
+
+    /**
+        Returns a new CommandLineArgument<T>.
+    */
+    template <class T>
+    BaseCommandLineArgument* CommandLine::createArg(const std::string& name, T defaultValue, Int2Type<0> isPrime)
+    {
+        return new CommandLineArgument<T>(name, defaultValue);
+    }
+
+    /**
+        Returns a new CommandLineArgument<std::string>.
+    */
+    template <class T>
+    BaseCommandLineArgument* CommandLine::createArg(const std::string& name, T defaultValue, Int2Type<1> isPrime)
+    {
+        return new CommandLineArgument<std::string>(name, defaultValue);
+    }
+}
+
+#endif /* _CommandLine_H__ */
Index: code/trunk/src/core/ConsoleCommand.cc
===================================================================
--- code/trunk/src/core/ConsoleCommand.cc	(revision 1754)
+++ code/trunk/src/core/ConsoleCommand.cc	(revision 1755)
@@ -31,5 +31,5 @@
 namespace orxonox
 {
-    ConsoleCommand::ConsoleCommand(FunctorStatic* functor, const std::string& name) : ExecutorStatic(functor, name)
+    ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name)
     {
         this->accessLevel_ = AccessLevel::None;
Index: code/trunk/src/core/ConsoleCommand.h
===================================================================
--- code/trunk/src/core/ConsoleCommand.h	(revision 1754)
+++ code/trunk/src/core/ConsoleCommand.h	(revision 1755)
@@ -82,27 +82,27 @@
     }
 
-    class _CoreExport ConsoleCommand : public ExecutorStatic
+    class _CoreExport ConsoleCommand : public Executor
     {
         public:
-            ConsoleCommand(FunctorStatic* functor, const std::string& name = "");
+            ConsoleCommand(Functor* functor, const std::string& name = "");
 
             inline ConsoleCommand& description(const std::string& description)
-                { this->ExecutorStatic::setDescription(description); return (*this); }
+                { this->Executor::setDescription(description); return (*this); }
             inline ConsoleCommand& descriptionParam(int param, const std::string& description)
-                { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); }
+                { this->Executor::setDescriptionParam(param, description); return (*this); }
             inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
-                { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); }
+                { this->Executor::setDescriptionReturnvalue(description); return (*this); }
             inline ConsoleCommand& defaultValues(const MultiType& param1)
-                { this->ExecutorStatic::setDefaultValues(param1); return (*this); }
+                { this->Executor::setDefaultValues(param1); return (*this); }
             inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2)
-                { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); }
+                { this->Executor::setDefaultValues(param1, param2); return (*this); }
             inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
-                { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); }
+                { this->Executor::setDefaultValues(param1, param2, param3); return (*this); }
             inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
-                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); }
+                { this->Executor::setDefaultValues(param1, param2, param3, param4); return (*this); }
             inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
-                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
+                { this->Executor::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
             inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
-                { this->ExecutorStatic::setDefaultValue(index, param); return (*this); }
+                { this->Executor::setDefaultValue(index, param); return (*this); }
 
             inline ConsoleCommand& accessLevel(AccessLevel::Level level)
@@ -147,5 +147,5 @@
     };
 
-    inline ConsoleCommand* createConsoleCommand(FunctorStatic* functor, const std::string& name = "")
+    inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "")
     {
         return new ConsoleCommand(functor, name);
Index: code/trunk/src/core/Core.cc
===================================================================
--- code/trunk/src/core/Core.cc	(revision 1754)
+++ code/trunk/src/core/Core.cc	(revision 1755)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -36,6 +36,6 @@
 #include "CoreIncludes.h"
 #include "ConfigValueIncludes.h"
-#include "input/InputManager.h"
-#include "TclThreadManager.h"
+//#include "input/InputManager.h"
+//#include "TclThreadManager.h"
 
 namespace orxonox
@@ -201,13 +201,13 @@
     }
 
-    /**
-        @brief Ticks every core class in a specified sequence. Has to be called
-               every Orxonox tick!
-        @param dt Delta Time
-    */
-    void Core::tick(float dt)
-    {
-        TclThreadManager::getInstance().tick(dt);
-        InputManager::tick(dt);
-    }
+    ///**
+    //    @brief Ticks every core class in a specified sequence. Has to be called
+    //           every Orxonox tick!
+    //    @param dt Delta Time
+    //*/
+    //void Core::tick(float dt)
+    //{
+    //    TclThreadManager::getInstance().tick(dt);
+    //    InputManager::getInstance().tick(dt);
+    //}
 }
Index: code/trunk/src/core/Core.h
===================================================================
--- code/trunk/src/core/Core.h	(revision 1754)
+++ code/trunk/src/core/Core.h	(revision 1755)
@@ -23,5 +23,5 @@
  *      Fabian 'x3n' Landau
  *   Co-authors:
- *      ...
+ *      Reto Grieder
  *
  */
@@ -29,5 +29,5 @@
 /**
     @file Core.h
-    @brief Definition of the Core class.
+    @brief Declaration of the Core class.
 
     The Core class is a singleton, only used to configure some variables
@@ -60,5 +60,5 @@
             static void resetLanguage();
 
-            static void tick(float dt);
+            //static void tick(float dt);
 
         private:
Index: code/trunk/src/core/CoreIncludes.h
===================================================================
--- code/trunk/src/core/CoreIncludes.h	(revision 1754)
+++ code/trunk/src/core/CoreIncludes.h	(revision 1755)
@@ -111,5 +111,5 @@
     @param StringOrInt The name or the network ID of the class
 */
-#define ID(StringOrInt) \
+#define GetIdentifier(StringOrInt) \
     orxonox::Factory::getIdentifier(StringOrInt)
 
Index: code/trunk/src/core/CorePrereqs.h
===================================================================
--- code/trunk/src/core/CorePrereqs.h	(revision 1754)
+++ code/trunk/src/core/CorePrereqs.h	(revision 1755)
@@ -98,6 +98,11 @@
   class ClassTreeMaskIterator;
   class ClassTreeMaskNode;
+  class Clock;
   class CommandEvaluation;
   class CommandExecutor;
+  class CommandLine;
+  class BaseCommandLineArgument;
+  template <class T>
+  class CommandLineArgument;
   class ConfigFile;
   class ConfigFileEntry;
@@ -155,13 +160,20 @@
   class XMLPortParamContainer;
 
+  // game states
+  class GameStateBase;
+  template <class ParentType>
+  class GameState;
+  class RootGameState;
+
   // input
-  //class GUIInputHandler;
   class BaseCommand;
   class BufferedParamCommand;
   class Button;
   class CalibratorCallback;
+  class ExtendedInputState;
   class HalfAxis;
   class InputBuffer;
   class InputManager;
+  class InputState;
   class JoyStickHandler;
   class MouseHandler;
@@ -171,4 +183,5 @@
   class ParamCommand;
   class SimpleCommand;
+  class SimpleInputState;
 }
 
Index: code/trunk/src/core/Exception.cc
===================================================================
--- code/trunk/src/core/Exception.cc	(revision 1755)
+++ code/trunk/src/core/Exception.cc	(revision 1755)
@@ -0,0 +1,85 @@
+/*
+ *   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 Exception class.
+*/
+
+#include "Exception.h"
+
+namespace orxonox
+{
+    Exception::Exception(const std::string& description, int lineNumber,
+                         const char* fileName, const char* functionName)
+        : description_(description)
+        , lineNumber_(lineNumber)
+        , functionName_(functionName)
+        , fileName_(fileName)
+    { }
+
+    Exception::Exception(const std::string& description)
+        : description_(description)
+        , lineNumber_(0)
+        , functionName_("")
+        , fileName_("")
+    { }
+
+    const std::string& Exception::getFullDescription() const
+    {
+        if (fullDescription_ == "")
+        {
+            std::ostringstream fullDesc;
+
+            fullDesc << this->getTypeName() << "_EXCEPTION";
+
+            if (this->fileName_ != "")
+            {
+                fullDesc << " in " << this->fileName_;
+                if (this->lineNumber_)
+                    fullDesc << "(" << this->lineNumber_ << ")";
+            }
+
+            if (this->functionName_ != "")
+                fullDesc << " in function '" << this->functionName_ << "'";
+
+            fullDesc << ": ";
+            if (this->description_ != "")
+                fullDesc << this->description_;
+            else
+                fullDesc << "No description available.";
+
+            this->fullDescription_ = std::string(fullDesc.str());
+        }
+
+        return fullDescription_;
+    }
+
+
+}
Index: code/trunk/src/core/Exception.h
===================================================================
--- code/trunk/src/core/Exception.h	(revision 1755)
+++ code/trunk/src/core/Exception.h	(revision 1755)
@@ -0,0 +1,158 @@
+/*
+ *   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 the Exception class.
+*/
+
+#ifndef _Exception_H__
+#define _Exception_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <exception>
+#include <cassert>
+#include "util/Debug.h"
+
+// Define some ugly macros to make things more clear
+#define CREATE_ORXONOX_EXCEPTION(name) typedef SpecificException<Exception::name> name##Exception;
+#define RETURN_EXCEPTION_CODE(name) \
+    case Exception::name:           \
+        return #name;
+
+
+namespace orxonox
+{
+    class _CoreExport Exception : public std::exception
+    {
+    public:
+        enum ExceptionType
+        {
+            General,
+            FileNotFound,
+            Argument,
+            PluginsNotFound,
+            InitialisationFailed,
+            NotImplemented,
+            GameState
+        };
+
+        Exception(const std::string& description, int lineNumber,
+                  const char* fileName, const char* functionName);
+        Exception(const std::string& description);
+
+        /// Needed for  compatibility with std::exception (from Ogre::Exception)
+        virtual ~Exception() throw() { }
+
+        virtual const std::string& getFullDescription() const;
+        virtual ExceptionType      getType()            const = 0;
+        virtual std::string        getTypeName()        const = 0;
+        virtual const std::string& getDescription()     const { return this->description_; }
+        virtual const int          getLineNumber()      const { return this->lineNumber_; }
+        virtual const std::string& getFunctionName()    const { return this->functionName_; }
+
+        /// Override std::exception::what (from Ogre::Exception)
+        const char* what() const throw() { return getFullDescription().c_str(); }
+
+    protected:
+        std::string description_;
+        int lineNumber_;
+        std::string functionName_;
+        std::string fileName_;
+        // mutable because "what()" is a const method
+        mutable std::string fullDescription_;
+    };
+
+
+    template <Exception::ExceptionType Type>
+    class SpecificException : public Exception
+    {
+    public:
+        SpecificException(const std::string& description, int lineNumber,
+                  const char* fileName, const char* functionName)
+                  : Exception(description, lineNumber, fileName, functionName)
+        {
+            // let the catcher decide whether to display the message below level 4
+            COUT(4) << this->getFullDescription() << std::endl;
+        }
+
+        SpecificException(const std::string& description)
+            : Exception(description)
+        {
+            // let the catcher decide whether to display the message below level 4
+            COUT(4) << this->getFullDescription() << std::endl;
+        }
+
+        ~SpecificException() throw() { }
+
+        ExceptionType getType() const { return Type; }
+        std::string getTypeName() const
+        {
+            // note: break is not necessary due to the return in the macros.
+            switch (Type)
+            {
+            RETURN_EXCEPTION_CODE(General)
+            RETURN_EXCEPTION_CODE(FileNotFound);
+            RETURN_EXCEPTION_CODE(Argument);
+            RETURN_EXCEPTION_CODE(PluginsNotFound);
+            RETURN_EXCEPTION_CODE(InitialisationFailed);
+            RETURN_EXCEPTION_CODE(NotImplemented);
+            RETURN_EXCEPTION_CODE(GameState);
+            default:
+                return "";
+            }
+        }
+    };
+
+    // define the template spcialisations
+    CREATE_ORXONOX_EXCEPTION(General);
+    CREATE_ORXONOX_EXCEPTION(FileNotFound);
+    CREATE_ORXONOX_EXCEPTION(Argument);
+    CREATE_ORXONOX_EXCEPTION(PluginsNotFound);
+    CREATE_ORXONOX_EXCEPTION(InitialisationFailed);
+    CREATE_ORXONOX_EXCEPTION(NotImplemented);
+    CREATE_ORXONOX_EXCEPTION(GameState);
+
+#define ThrowException(type, description) \
+    throw SpecificException<Exception::type>(description, __LINE__, __FILE__, __FUNCTIONNAME__)
+
+    // define an assert macro that can display a message
+#ifndef NDEBUG
+#define OrxAssert(assertion, errorMessage) \
+    assertion ? ((void)0) : (void)(orxonox::OutputHandler::getOutStream().setOutputLevel(ORX_ERROR) << errorMessage << std::endl); \
+    assert(assertion)
+#else
+#define OrxAssert(condition, errorMessage)  ((void)0)
+#endif
+
+}
+
+#endif /* _Exception_H__ */
Index: code/trunk/src/core/GameState.cc
===================================================================
--- code/trunk/src/core/GameState.cc	(revision 1755)
+++ code/trunk/src/core/GameState.cc	(revision 1755)
@@ -0,0 +1,366 @@
+/*
+ *   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 GameStateBase class.
+*/
+
+#include "GameState.h"
+#include "util/Debug.h"
+#include "Exception.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Constructor only initialises variables and sets the name permanently.
+    */
+    GameStateBase::GameStateBase(const std::string& name)
+        : name_(name)
+        //, parent_(0)
+        , activeChild_(0)
+        //, bPausegetParent()(false)
+    {
+        Operations temp = {false, false, false, false, false};
+        this->operation_ = temp;
+    }
+
+    /**
+    @brief
+        Destructor only checks that we don't delete an active state.
+    */
+    GameStateBase::~GameStateBase()
+    {
+        OrxAssert(this->operation_.active == false, "Deleting an active GameState is a very bad idea..");
+    }
+
+    /**
+    @brief
+        Adds a child to the current tree. The Child can contain children of its own.
+        But you cannot a state tree that already has an active state.
+    @param state
+        The state to be added.
+    */
+    void GameStateBase::addChild(GameStateBase* 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, GameStateBase*>::const_iterator it = state->allChildren_.begin();
+            it != state->allChildren_.end(); ++it)
+        {
+            if (this->getState(it->second->getName()))
+            {
+                ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
+                return;
+            }
+        }
+        if (this->getState(state->name_))
+        {
+            ThrowException(GameState, "Cannot add a GameState to the hierarchy twice.");
+            return;
+        }
+        // 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, GameStateBase*>::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);
+    }
+
+    /**
+    @brief
+        Removes a child by instance. This splits the tree in two parts,
+        each of them functional on its own.
+    @param state
+        GameState by instance pointer
+    */
+    void GameStateBase::removeChild(GameStateBase* state)
+    {
+        std::map<GameStateBase*, GameStateBase*>::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<GameStateBase*, GameStateBase*>::const_iterator it = state->grandchildrenToChildren_.begin();
+                    it != state->grandchildrenToChildren_.end(); ++it)
+                    this->grandchildRemoved(it->first);
+                this->grandchildRemoved(state);
+            }
+        }
+        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 GameStateBase::removeChild(const std::string& name)
+    {
+        GameStateBase* 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;
+        }
+    }
+
+    /**
+    @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 GameStateBase::grandchildAdded(GameStateBase* child, GameStateBase* grandchild)
+    {
+        // fill the two maps correctly.
+        this->allChildren_[grandchild->getName()] = grandchild;
+        this->grandchildrenToChildren_[grandchild] = child;
+        if (this->getParent())
+            this->getParent()->grandchildAdded(this, grandchild);
+    }
+
+    /**
+    @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 GameStateBase::grandchildRemoved(GameStateBase* grandchild)
+    {
+        // 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.
+    */
+    GameStateBase* GameStateBase::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, GameStateBase*>::const_iterator it = this->allChildren_.find(name);
+            return (it!= this->allChildren_.end() ? it->second : 0);
+        }
+    }
+
+    /**
+    @brief
+        Returns the root node of the tree.
+    */
+    GameStateBase* GameStateBase::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.
+    */
+    GameStateBase* GameStateBase::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 GameStateBase::isInSubtree(GameStateBase* 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 GameStateBase::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 GameStateBase::makeTransition(GameStateBase* source, GameStateBase* 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<GameStateBase*, GameStateBase*>::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 GameStateBase::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 GameStateBase::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 GameStateBase::tick(const Clock& time)
+    {
+        this->operation_.running = true;
+        this->ticked(time);
+        this->operation_.running = false;
+    }
+}
Index: code/trunk/src/core/GameState.h
===================================================================
--- code/trunk/src/core/GameState.h	(revision 1755)
+++ code/trunk/src/core/GameState.h	(revision 1755)
@@ -0,0 +1,161 @@
+/*
+ *   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
+    Definition of GameState class.
+*/
+
+#ifndef _GameState_H__
+#define _GameState_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include <map>
+#include <cassert>
+#include "Clock.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        An implementation of a tree to manage game states.
+        This leads to a certain hierarchy that is created at runtime.
+        To actually use the structure, you will have to derive from it and
+        implement 'enter', 'leave' and 'tick'. The latter corresponds to an
+        update function.
+
+        Internally the tree is managed by two maps per node: One stores all its
+        children, grandchildren, etc. by name of the state. The other maps these
+        children states to the actual child of the node.
+        An example: Foo is a grandchildren of Bar and Foofoo is the Foo's parent.
+        Then Bar stores Foo in map by its name. The other one then maps Foo to Foofoo.
+    */
+    class _CoreExport GameStateBase
+    {
+        friend class RootGameState;
+        template <class ParentType>
+        friend class GameState;
+
+    public:
+        /**
+        @brief
+            Gives information about what the GameState is currently doing
+        */
+        struct Operations
+        {
+            unsigned active    : 1;
+            unsigned entering  : 1;
+            unsigned leaving   : 1;
+            unsigned running   : 1;
+            unsigned suspended : 1;
+        };
+
+    public:
+        virtual ~GameStateBase();
+
+        const std::string& getName() const { return name_; }
+        const Operations getOperation() const { return this->operation_; }
+        bool isInSubtree(GameStateBase* state) const;
+
+        GameStateBase* getState(const std::string& name);
+        GameStateBase* getRoot();
+        //! Returns the currently active game state
+        virtual GameStateBase* getCurrentState();
+
+        virtual void requestState(const std::string& name);
+
+        void addChild(GameStateBase* state);
+        void removeChild(GameStateBase* state);
+        void removeChild(const std::string& name);
+
+    protected:
+        virtual void enter() = 0;
+        virtual void leave() = 0;
+        virtual void ticked(const Clock& time) = 0;
+
+        GameStateBase* getActiveChild() { return this->activeChild_; }
+
+        void tickChild(const Clock& time) { if (this->getActiveChild()) this->getActiveChild()->tick(time); }
+
+        virtual GameStateBase* getParent() const = 0;
+        virtual void setParent(GameStateBase* state) = 0;
+
+    private:
+        // Making the constructor private ensures that game states
+        // are always derivates of GameState<T>. Note the friend declaration above.
+        GameStateBase(const std::string& name);
+
+        //! Performs a transition to 'destination'
+        virtual void makeTransition(GameStateBase* source, GameStateBase* destination);
+
+        void grandchildAdded(GameStateBase* child, GameStateBase* grandchild);
+        void grandchildRemoved(GameStateBase* grandchild);
+
+        void tick(const Clock& time);
+        void activate();
+        void deactivate();
+
+        const std::string                        name_;
+        Operations                               operation_;
+        GameStateBase*                           activeChild_;
+        //bool                                     bPauseParent_;
+        std::map<std::string, GameStateBase*>    allChildren_;
+        std::map<GameStateBase*, GameStateBase*> grandchildrenToChildren_;
+    };
+
+
+    template <class ParentType>
+    class GameState : public GameStateBase
+    {
+    public:
+        GameState(const std::string& name)
+            : GameStateBase(name)
+            , parent_(0)
+        { }
+        virtual ~GameState() { }
+
+        ParentType* getParent() const
+            { return parent_; }
+
+    protected:
+        void setParent(GameStateBase* state)
+        {
+            assert(dynamic_cast<ParentType*>(state) != 0);
+            this->parent_ = dynamic_cast<ParentType*>(state);
+        }
+
+    private:
+        ParentType* parent_;
+    };
+}
+
+#endif /* _GameState_H__ */
Index: code/trunk/src/core/Identifier.h
===================================================================
--- code/trunk/src/core/Identifier.h	(revision 1754)
+++ code/trunk/src/core/Identifier.h	(revision 1755)
@@ -78,5 +78,5 @@
          - the name
          - a list with all objects
-         - parents and childs
+         - parents and children
          - the factory (if available)
          - the networkID that can be synchronised with the server
Index: code/trunk/src/core/Loader.cc
===================================================================
--- code/trunk/src/core/Loader.cc	(revision 1754)
+++ code/trunk/src/core/Loader.cc	(revision 1755)
@@ -65,4 +65,6 @@
     void Loader::add(const Level* level, const ClassTreeMask& mask)
     {
+        if (!level)
+            return;
         Loader::levels_s.insert(Loader::levels_s.end(), std::pair<const Level*, ClassTreeMask>(level, mask));
     }
@@ -70,4 +72,6 @@
     void Loader::remove(const Level* level)
     {
+        if (!level)
+            return;
         for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)
         {
@@ -109,4 +113,7 @@
     bool Loader::load(const Level* level, const ClassTreeMask& mask)
     {
+        if (!level)
+            return false;
+
         Loader::currentMask_s = level->getMask() * mask;
 
@@ -166,4 +173,6 @@
     void Loader::unload(const Level* level, const ClassTreeMask& mask)
     {
+        if (!level)
+            return;
         for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; )
         {
Index: code/trunk/src/core/OrxonoxClass.h
===================================================================
--- code/trunk/src/core/OrxonoxClass.h	(revision 1754)
+++ code/trunk/src/core/OrxonoxClass.h	(revision 1755)
@@ -29,5 +29,5 @@
 /**
     @file OrxonoxClass.h
-    @brief Definition of the OrxonoxClass Class.
+    @brief Declaration of the OrxonoxClass Class.
 
     All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass.
Index: code/trunk/src/core/RootGameState.cc
===================================================================
--- code/trunk/src/core/RootGameState.cc	(revision 1755)
+++ code/trunk/src/core/RootGameState.cc	(revision 1755)
@@ -0,0 +1,214 @@
+/*
+ *   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/String.h"
+#include "util/SubString.h"
+#include "util/Debug.h"
+#include "Core.h"
+#include "Clock.h"
+#include "Exception.h"
+#include "CommandLine.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(state, "gui").setShortcut("s");
+
+    RootGameState::RootGameState(const std::string& name)
+        : GameState<GameStateBase>(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(GameStateBase* source, GameStateBase* 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<GameStateBase*, GameStateBase*>::const_iterator it
+            = this->grandchildrenToChildren_.find(destination);
+        if (it != this->grandchildrenToChildren_.end())
+        {
+            OrxAssert(dynamic_cast<GameStateBase*>(it->second) != 0,
+                "There was a mix with RootGameState and GameState, could not cast.");
+            GameStateBase* child = static_cast<GameStateBase*>(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)
+    {
+        GameStateBase* request = getState(name);
+        if (request)
+        {
+            GameStateBase* 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;
+    }
+
+    /**
+    @brief
+        Starts the game. The little 'while' denotes the main loop.
+        Whenever the root state is selected, the game ends.
+    @param name
+        State to start with (usually main menu or specified by command line)
+    */
+    void RootGameState::start(int argc, char** argv)
+    {
+        // start global orxonox time
+        Clock clock;
+
+        parseArguments(argc, argv);
+
+        this->activate();
+
+        // get initial state from command line
+        std::string initialState;
+        CommandLine::getValue<std::string>("state", &initialState);
+        gotoState(initialState);
+
+        while (this->activeChild_)
+        {
+            clock.capture();
+
+            this->tick(clock);
+
+            if (this->stateRequest_ != "")
+                gotoState(stateRequest_);
+        }
+
+        this->deactivate();
+    }
+
+    /**
+    @brief
+        Parses both command line and start.ini for CommandLineArguments.
+    */
+    void RootGameState::parseArguments(int argc, char** argv)
+    {
+        // parse command line first
+        std::vector<std::string> args;
+        for (int i = 1; i < argc; ++i)
+            args.push_back(argv[i]);
+
+        try
+        {
+            orxonox::CommandLine::parse(args);
+        }
+        catch (orxonox::ArgumentException& ex)
+        {
+            COUT(1) << ex.what() << std::endl;
+            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
+        }
+
+        // look for additional arguments in start.ini
+        std::ifstream file;
+        file.open("start.ini");
+        args.clear();
+        if (file)
+        {
+            while (!file.eof())
+            {
+                std::string line;
+                std::getline(file, line);
+                line = removeTrailingWhitespaces(line);
+                //if (!(line[0] == '#' || line[0] == '%'))
+                //{
+                SubString tokens(line, " ", " ", false, 92, false, 34, false, 40, 41, false, '#');
+                for (unsigned i = 0; i < tokens.size(); ++i)
+                    if (tokens[i][0] != '#')
+                        args.push_back(tokens[i]);
+                //args.insert(args.end(), tokens.getAllStrings().begin(), tokens.getAllStrings().end());
+                //}
+            }
+            file.close();
+        }
+
+        try
+        {
+            orxonox::CommandLine::parse(args);
+        }
+        catch (orxonox::ArgumentException& ex)
+        {
+            COUT(1) << "An Exception occured while parsing start.ini" << std::endl;
+            COUT(1) << ex.what() << std::endl;
+            COUT(0) << "Usage:" << std::endl << "orxonox " << CommandLine::getUsageInformation() << std::endl;
+        }
+    }
+}
Index: code/trunk/src/core/RootGameState.h
===================================================================
--- code/trunk/src/core/RootGameState.h	(revision 1755)
+++ code/trunk/src/core/RootGameState.h	(revision 1755)
@@ -0,0 +1,56 @@
+/*
+ *   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<GameStateBase>
+    {
+    public:
+        RootGameState(const std::string& name);
+        ~RootGameState();
+
+        void requestState(const std::string& name);
+        void start(int argc, char** argv);
+
+    private:
+        void makeTransition(GameStateBase* source, GameStateBase* destination);
+        void gotoState(const std::string& name);
+
+        void parseArguments(int argc, char** argv);
+
+        std::string           stateRequest_;
+    };
+}
+
+#endif /* _RootGameState_H__ */
Index: code/trunk/src/core/Script.cc
===================================================================
--- code/trunk/src/core/Script.cc	(revision 1754)
+++ code/trunk/src/core/Script.cc	(revision 1755)
@@ -60,5 +60,5 @@
     luaopen_debug(luaState_);
 #endif
-    tolua_core_open(luaState_);
+    tolua_Core_open(luaState_);
     output_ = "";
   }
@@ -198,5 +198,5 @@
       for (std::map<unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
       {
-        if ((*it).second == expectedValue)
+        if (it->second == expectedValue)
           expectedValue = !expectedValue;
         else
Index: code/trunk/src/core/Script.h
===================================================================
--- code/trunk/src/core/Script.h	(revision 1754)
+++ code/trunk/src/core/Script.h	(revision 1755)
@@ -28,5 +28,5 @@
 
 /**
- @file  script.h
+ @file
  @brief Representation of an interface to lua
  @author Benjamin Knecht <beni_at_orxonox.net>
@@ -47,7 +47,9 @@
 namespace orxonox // tolua_export
 { // tolua_export
-
-  class _CoreExport Script // tolua_export
-  { // tolua_export
+  class _CoreExport Script
+  /*
+  class Script { // tolua_export
+  */
+  {
     struct LoadS {
       const char *s;
Index: code/trunk/src/core/Script_clean.h
===================================================================
--- code/trunk/src/core/Script_clean.h	(revision 1754)
+++ 	(revision )
@@ -1,83 +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:
- *      Benjamin Knecht
- *   Co-authors:
- *      ...
- *
- */
-
-/**
- @file  script.h
- @brief Representation of an interface to lua
- @author Benjamin Knecht <beni_at_orxonox.net>
- */
-
-#ifndef _Script_H__
-#define _Script_H__
-
-#include "CorePrereqs.h"
-
-extern "C" {
-#include <lua.h>
-}
-
-#include <list>
-#include <string>
-
-namespace orxonox // tolua_export
-{ // tolua_export
-
-  class  Script // tolua_export
-  { // tolua_export
-    public:
-      inline static Script* getInstance() { if (!Script::singletonRef) Script::singletonRef = new Script(); return Script::singletonRef; } // tolua_export
-      inline ~Script() { Script::singletonRef = NULL; };
-
-    void loadFile(std::string filename, bool luaTags);
-    //void init(lua_State *state_);
-    //void xmlToLua();
-    void run();
-    void luaPrint(std::string str); // tolua_export
-
-#if LUA_VERSION_NUM != 501
-    inline static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size) { return NULL;};
-#endif
-
-    inline lua_State* getLuaState() { return luaState_; };
-    inline std::string getLuaOutput() { return output_; };
-    //inline std::string* getFileString() { return &fileString_; };
-
-    unsigned int getNextQuote(const std::string& text, unsigned int start);
-    std::string replaceLuaTags(const std::string& text);
-
-    private:
-      Script();
-      static Script* singletonRef;
-
-      std::string luaSource_;
-      std::string output_;
-      lua_State* luaState_;
-
-  }; // tolua_export
-} // tolua_export
-#endif /* _Script_H__ */
Index: code/trunk/src/core/Shell.cc
===================================================================
--- code/trunk/src/core/Shell.cc	(revision 1754)
+++ code/trunk/src/core/Shell.cc	(revision 1755)
@@ -33,5 +33,4 @@
 #include "Core.h"
 #include "ConsoleCommand.h"
-#include "input/InputInterfaces.h"
 #include "util/OutputHandler.h"
 
@@ -64,6 +63,6 @@
         this->clearLines();
 
-        this->inputBuffer_ = 0;
-        this->setInputBuffer(new InputBuffer());
+        this->inputBuffer_ = new InputBuffer();
+        this->configureInputBuffer();
 
         this->outputBuffer_.registerListener(this);
@@ -71,4 +70,10 @@
 
         this->setConfigValues();
+    }
+
+    Shell::~Shell()
+    {
+        if (this->inputBuffer_)
+            delete this->inputBuffer_;
     }
 
@@ -113,14 +118,6 @@
     }
 
-    void Shell::setInputBuffer(InputBuffer* buffer)
-    {
-        if (this->inputBuffer_)
-        {
-            this->inputBuffer_->unregisterListener(this);
-            // TODO: may be very dangerous. InputManager already deletes InputBuffer instance!!!
-            delete this->inputBuffer_;
-        }
-
-        this->inputBuffer_ = buffer;
+    void Shell::configureInputBuffer()
+    {
         this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
         this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false);
Index: code/trunk/src/core/Shell.h
===================================================================
--- code/trunk/src/core/Shell.h	(revision 1754)
+++ code/trunk/src/core/Shell.h	(revision 1755)
@@ -73,7 +73,6 @@
             void unregisterListener(ShellListener* listener);
 
-            void setInputBuffer(InputBuffer* buffer);
-            inline InputBuffer& getInputBuffer()
-                { return (*this->inputBuffer_); }
+            inline InputBuffer* getInputBuffer()
+                { return this->inputBuffer_; }
             inline OutputBuffer& getOutputBuffer()
                 { return this->outputBuffer_; }
@@ -107,5 +106,7 @@
             Shell();
             Shell(const Shell& other);
-            virtual ~Shell() {}
+            virtual ~Shell();
+
+            void configureInputBuffer();
 
             void addToHistory(const std::string& command);
Index: code/trunk/src/core/XMLPort.h
===================================================================
--- code/trunk/src/core/XMLPort.h	(revision 1754)
+++ code/trunk/src/core/XMLPort.h	(revision 1755)
@@ -298,5 +298,5 @@
                             for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
                             {
-                                Identifier* identifier = ID(child->Value());
+                                Identifier* identifier = GetIdentifier(child->Value());
                                 if (identifier)
                                 {
Index: code/trunk/src/core/input/Button.cc
===================================================================
--- code/trunk/src/core/input/Button.cc	(revision 1754)
+++ code/trunk/src/core/input/Button.cc	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Implementation of the different input handlers.
- */
+@file
+@brief
+    Implementation of the different input handlers.
+*/
 
 #include "Button.h"
@@ -44,172 +45,187 @@
 namespace orxonox
 {
-  void Button::clear()
-  {
-    for (unsigned int j = 0; j < 3; j++)
-    {
-      if (nCommands_[j])
-      {
-        // delete all commands and the command pointer array
-        for (unsigned int i = 0; i < nCommands_[j]; i++)
-          delete commands_[j][i];
-        delete[] commands_[j];
-        commands_[j] = 0;
-        nCommands_[j] = 0;
-      }
-      else
-      {
-        commands_[j] = 0;
-      }
-    }
-  }
-
-  void Button::parse(std::vector<BufferedParamCommand*>& paramCommandBuffer)
-  {
-    if (isEmpty(bindingString_))
-    {
-      clear();
-      return;
-    }
-
-    // use std::vector for a temporary dynamic array
-    std::vector<BaseCommand*> commands[3];
-
-
-    // separate the commands
-    SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
-        '\\', false, '"', false, '(', ')', false, '\0');
-
-    for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
-    {
-      if (commandStrings[iCommand] != "")
-      {
-        SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
+    void Button::clear()
+    {
+        for (unsigned int j = 0; j < 3; j++)
+        {
+            if (nCommands_[j])
+            {
+                // delete all commands and the command pointer array
+                for (unsigned int i = 0; i < nCommands_[j]; i++)
+                    delete commands_[j][i];
+                delete[] commands_[j];
+                commands_[j] = 0;
+                nCommands_[j] = 0;
+            }
+            else
+            {
+                commands_[j] = 0;
+            }
+        }
+    }
+
+    void Button::parse(std::vector<BufferedParamCommand*>& paramCommandBuffer)
+    {
+        if (isEmpty(bindingString_))
+        {
+            clear();
+            return;
+        }
+
+        // use std::vector for a temporary dynamic array
+        std::vector<BaseCommand*> commands[3];
+
+
+        // separate the commands
+        SubString commandStrings(bindingString_, "|", SubString::WhiteSpaces, false,
             '\\', false, '"', false, '(', ')', false, '\0');
 
-        unsigned int iToken = 0;
-
-        // for real axes, we can feed a ButtonThreshold argument as entire command
-        if (getLowercase(tokens[0]) == "buttonthreshold")
-        {
-          if (tokens.size() == 1)
-            continue;
-          // may fail, but doesn't matter
-          convertValue(&buttonThreshold_, tokens[1]);
-          continue;
-        }
-
-        // first argument can be OnPress, OnHold OnRelease or nothing
-        KeybindMode::Enum mode = KeybindMode::None;
-        if (getLowercase(tokens[iToken]) == "onpress")
-          mode = KeybindMode::OnPress,   iToken++;
-        if (getLowercase(tokens[iToken]) == "onrelease")
-          mode = KeybindMode::OnRelease, iToken++;
-        if (getLowercase(tokens[iToken]) == "onhold")
-          mode = KeybindMode::OnHold,    iToken++;
-
-        if (iToken == tokens.size())
-          continue;
-
-        // second argument can be the amplitude for the case it as an axis command
-        // default amplitude is 1.0f
-        float paramModifier = 1.0f;
-        if (getLowercase(tokens[iToken]) == "scale")
-        {
-          iToken++;
-          if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
-          {
-            COUT(2) << "Error while parsing key binding " << name_
-                << ". Numeric expression expected afer 'AxisAmp', switching to default value" << std::endl;
-            if (iToken == tokens.size())
-              continue;
-          }
-          iToken++;
-        }
-
-        // no more arguments expected except for the actual command
-        if (iToken == tokens.size())
-          continue;
-
-        std::string commandStr;
-        while (iToken != tokens.size())
-          commandStr += tokens[iToken++] + " ";
-
-        // evaluate the command
-        CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
-        if (!eval.isValid())
-          continue;
-
-        // check for param command
-        int paramIndex = eval.getConsoleCommand()->getAxisParamIndex();
-        if (paramIndex >= 0)
-        {
-          // parameter supported command
-          ParamCommand* cmd = new ParamCommand();
-          cmd->paramModifier_ = paramModifier;
-          cmd->bRelative_ = eval.getConsoleCommand()->getIsAxisRelative();
-
-          // add command to the buffer if not yet existing
-          for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer.size(); iParamCmd++)
-          {
-            if (getLowercase(paramCommandBuffer[iParamCmd]->evaluation_.getOriginalCommand())
-                == getLowercase(commandStr))
-            {
-              // already in list
-              cmd->paramCommand_ = paramCommandBuffer[iParamCmd];
-              break;
-            }
-          }
-          if (cmd->paramCommand_ == 0)
-          {
-            cmd->paramCommand_ = new BufferedParamCommand();
-            paramCommandBuffer.push_back(cmd->paramCommand_);
-            cmd->paramCommand_->evaluation_ = eval;
-            cmd->paramCommand_->paramIndex_ = paramIndex;
-          }
-
-
-          // we don't know whether this is an actual axis or just a button
-          if (mode == KeybindMode::None)
-          {
-            if (!addParamCommand(cmd))
-            {
-              mode = eval.getConsoleCommand()->getKeybindMode();
-              commands[mode].push_back(cmd);
-            }
-          }
+        for (unsigned int iCommand = 0; iCommand < commandStrings.size(); iCommand++)
+        {
+            if (commandStrings[iCommand] != "")
+            {
+                SubString tokens(commandStrings[iCommand], " ", SubString::WhiteSpaces, false,
+                    '\\', false, '"', false, '(', ')', false, '\0');
+
+                KeybindMode::Enum mode = KeybindMode::None;
+                float paramModifier = 1.0f;
+                std::string commandStr = "";
+
+                for (unsigned int iToken = 0; iToken < tokens.size(); ++iToken)
+                {
+                    std::string token = getLowercase(tokens[iToken]);
+
+                    if (token == "onpress")
+                        mode = KeybindMode::OnPress;
+                    else if (token == "onrelease")
+                        mode = KeybindMode::OnRelease;
+                    else if (token == "onhold")
+                        mode = KeybindMode::OnHold;
+                    else if (token == "buttonthreshold")
+                    {
+                        // for real axes, we can feed a ButtonThreshold argument
+                        ++iToken;
+                        if (iToken == tokens.size())
+                            continue;
+                        // may fail, but doesn't matter (default value already set)
+                        if (!convertValue(&buttonThreshold_, tokens[iToken + 1]))
+                            parseError("Could not parse 'ButtonThreshold' argument. \
+                                Switching to default value.", true);
+                    }
+                    else if (token == "scale")
+                    {
+                        ++iToken;
+                        if (iToken == tokens.size() || !convertValue(&paramModifier, tokens[iToken]))
+                            parseError("Could not parse 'scale' argument. Switching to default value.", true);
+                    }
+                    else
+                    {
+                        // no input related argument
+                        // we interpret everything from here as a command string
+                        while (iToken != tokens.size())
+                            commandStr += tokens[iToken++] + " ";
+                    }
+                }
+
+                if (commandStr == "")
+                {
+                    parseError("No command string given.", false);
+                    continue;
+                }
+
+                // evaluate the command
+                CommandEvaluation eval = CommandExecutor::evaluate(commandStr);
+                if (!eval.isValid())
+                {
+                    parseError("Command evaluation failed.", true);
+                    continue;
+                }
+
+                // check for param command
+                int paramIndex = eval.getConsoleCommand()->getAxisParamIndex();
+                if (paramIndex >= 0)
+                {
+                    // parameter supported command
+                    ParamCommand* cmd = new ParamCommand();
+                    cmd->paramModifier_ = paramModifier;
+                    cmd->bRelative_ = eval.getConsoleCommand()->getIsAxisRelative();
+
+                    // add command to the buffer if not yet existing
+                    for (unsigned int iParamCmd = 0; iParamCmd < paramCommandBuffer.size(); iParamCmd++)
+                    {
+                        if (getLowercase(paramCommandBuffer[iParamCmd]->evaluation_.getOriginalCommand())
+                            == getLowercase(commandStr))
+                        {
+                            // already in list
+                            cmd->paramCommand_ = paramCommandBuffer[iParamCmd];
+                            break;
+                        }
+                    }
+                    if (cmd->paramCommand_ == 0)
+                    {
+                        cmd->paramCommand_ = new BufferedParamCommand();
+                        paramCommandBuffer.push_back(cmd->paramCommand_);
+                        cmd->paramCommand_->evaluation_ = eval;
+                        cmd->paramCommand_->paramIndex_ = paramIndex;
+                    }
+
+
+                    // we don't know whether this is an actual axis or just a button
+                    if (mode == KeybindMode::None)
+                    {
+                        if (!addParamCommand(cmd))
+                        {
+                            mode = eval.getConsoleCommand()->getKeybindMode();
+                            commands[mode].push_back(cmd);
+                        }
+                    }
+                }
+                else
+                {
+                    SimpleCommand* cmd = new SimpleCommand();
+                    cmd->evaluation_ = eval;
+
+                    if (mode == KeybindMode::None)
+                        mode = eval.getConsoleCommand()->getKeybindMode();
+
+                    commands[mode].push_back(cmd);
+                }
+            }
+        }
+
+        for (unsigned int j = 0; j < 3; j++)
+        {
+            nCommands_[j] = commands[j].size();
+            if (nCommands_[j])
+            {
+                commands_[j] = new BaseCommand*[nCommands_[j]];
+                for (unsigned int i = 0; i < commands[j].size(); i++)
+                    commands_[j][i] = commands[j][i];
+            }
+            else
+                commands_[j] = 0;
+        }
+    }
+
+    bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
+    {
+        // execute all the parsed commands in the string
+        for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
+            commands_[mode][iCommand]->execute(abs, rel);
+        return true;
+    }
+
+    inline void Button::parseError(std::string message, bool serious)
+    {
+        if (serious)
+        {
+            COUT(2) << "Error while parsing binding for button/axis" << this->name_ << ". "
+                << message << std::endl;
         }
         else
         {
-          SimpleCommand* cmd = new SimpleCommand();
-          cmd->evaluation_ = eval;
-
-          if (mode == KeybindMode::None)
-            mode = eval.getConsoleCommand()->getKeybindMode();
-
-          commands[mode].push_back(cmd);
-        }
-      }
-    }
-
-    for (unsigned int j = 0; j < 3; j++)
-    {
-      nCommands_[j] = commands[j].size();
-      if (nCommands_[j])
-      {
-        commands_[j] = new BaseCommand*[nCommands_[j]];
-        for (unsigned int i = 0; i < commands[j].size(); i++)
-          commands_[j][i] = commands[j][i];
-      }
-      else
-        commands_[j] = 0;
-    }
-  }
-
-  bool Button::execute(KeybindMode::Enum mode, float abs, float rel)
-  {
-    // execute all the parsed commands in the string
-    for (unsigned int iCommand = 0; iCommand < nCommands_[mode]; iCommand++)
-      commands_[mode][iCommand]->execute(abs, rel);
-    return true;
-  }
+            COUT(3) << "Warning while parsing binding for button/axis" << this->name_ << ". "
+                << message << std::endl;
+        }
+    }
 }
Index: code/trunk/src/core/input/Button.h
===================================================================
--- code/trunk/src/core/input/Button.h	(revision 1754)
+++ code/trunk/src/core/input/Button.h	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Different definitions of input processing.
- */
+@file
+@brief
+    Different definitions of input processing.
+*/
 
 #ifndef _Button_H__
@@ -42,26 +43,29 @@
 namespace orxonox
 {
-  class _CoreExport Button
-  {
-  public:
-    Button() { nCommands_[0]=0; nCommands_[1]=0; nCommands_[2]=0; clear(); }
-    virtual ~Button() { clear(); }
-    virtual void clear();
-    virtual bool addParamCommand(ParamCommand* command) { return false; }
-    void parse(std::vector<BufferedParamCommand*>& paramCommandBuffer);
-    bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
+    class _CoreExport Button
+    {
+    public:
+        Button() { nCommands_[0]=0; nCommands_[1]=0; nCommands_[2]=0; clear(); }
+        virtual ~Button() { clear(); }
+        virtual void clear();
+        virtual bool addParamCommand(ParamCommand* command) { return false; }
+        void parse(std::vector<BufferedParamCommand*>& paramCommandBuffer);
+        bool execute(KeybindMode::Enum mode, float abs = 1.0f, float rel = 1.0f);
 
-    //! The configured string value
-    std::string bindingString_;
-    //! Name of the trigger as strings
-    std::string name_;
-    //! Basic commands for OnPress, OnHold and OnRelease
-    BaseCommand** commands_[3];
-    //! Number of basic commands
-    unsigned int nCommands_[3];
-    //! Says how much it takes for an analog axis to trigger a button
-    //! Note: This variable is here to have only one parse() function.
-    float buttonThreshold_;
-  };
+        //! The configured string value
+        std::string bindingString_;
+        //! Name of the trigger as strings
+        std::string name_;
+        //! Basic commands for OnPress, OnHold and OnRelease
+        BaseCommand** commands_[3];
+        //! Number of basic commands
+        unsigned int nCommands_[3];
+        //! Says how much it takes for an analog axis to trigger a button
+        //! Note: This variable is here to have only one parse() function.
+        float buttonThreshold_;
+
+    private:
+        void parseError(std::string message, bool serious);
+    };
 }
 
Index: code/trunk/src/core/input/CalibratorCallback.cc
===================================================================
--- code/trunk/src/core/input/CalibratorCallback.cc	(revision 1754)
+++ code/trunk/src/core/input/CalibratorCallback.cc	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Implementation of the different input handlers.
- */
+@file
+@brief
+    Implementation of the different input handlers.
+*/
 
 #include "CalibratorCallback.h"
@@ -37,10 +38,10 @@
 namespace orxonox
 {
-  void CalibratorCallback::keyPressed(const orxonox::KeyEvent &evt)
-  {
-    if (evt.key == KeyCode::Return)
+    void CalibratorCallback::keyPressed(const orxonox::KeyEvent &evt)
     {
-      InputManager::setInputState(InputManager::IS_NOCALIBRATE);
+        if (evt.key == KeyCode::Return)
+        {
+            //InputManager::setInputState(InputManager::IS_NOCALIBRATE);
+        }
     }
-  }
 }
Index: code/trunk/src/core/input/CalibratorCallback.h
===================================================================
--- code/trunk/src/core/input/CalibratorCallback.h	(revision 1754)
+++ code/trunk/src/core/input/CalibratorCallback.h	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Different definitions of input processing.
- */
+@file
+@brief
+    Different definitions of input processing.
+*/
 
 #ifndef _CalibratorCallback_H__
@@ -36,22 +37,21 @@
 
 #include "core/CorePrereqs.h"
-
 #include "InputInterfaces.h"
 
 namespace orxonox
 {
-  class _CoreExport CalibratorCallback : public KeyHandler
-  {
-  public:
-    CalibratorCallback() {}
-    ~CalibratorCallback() {}
+    class _CoreExport CalibratorCallback : public KeyHandler
+    {
+    public:
+        CalibratorCallback()  { }
+        ~CalibratorCallback() { }
 
-  private:
-    void keyPressed (const KeyEvent& evt);
-    void keyReleased(const KeyEvent& evt) {}
-    void keyHeld    (const KeyEvent& evt) {}
+    private:
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt) { }
+        void keyHeld    (const KeyEvent& evt) { }
 
-    void tickInput(float dt, const HandlerState &state) { }
-  };
+        void tickInput(float dt) { }
+    };
 }
 
Index: code/trunk/src/core/input/ExtendedInputState.cc
===================================================================
--- code/trunk/src/core/input/ExtendedInputState.cc	(revision 1755)
+++ code/trunk/src/core/input/ExtendedInputState.cc	(revision 1755)
@@ -0,0 +1,472 @@
+/*
+ *   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 ExtendedInputState class.
+*/
+
+#include "ExtendedInputState.h"
+
+#include <assert.h>
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    using namespace InputDevice;
+
+    void ExtendedInputState::numberOfJoySticksChanged(unsigned int n)
+    {
+        unsigned int oldSize = joyStickHandlers_.size();
+        joyStickHandlers_.resize(n);
+
+        if (oldSize > n)
+        {
+            // we have to add all the handlers in joyStickHandlersAll_ to the joyStickHandlers_[>n]
+            for (unsigned int j = 0; j < joyStickHandlersAll_.size(); ++j)
+            {
+                for (unsigned int i = oldSize; i < n; ++i)
+                {
+                    joyStickHandlers_[i].push_back(joyStickHandlersAll_[j]);
+                }
+            }
+        }
+        update();
+    }
+
+    void ExtendedInputState::keyPressed(const KeyEvent& evt)
+    {
+        for (unsigned int i = 0; i < keyHandlers_.size(); i++)
+            keyHandlers_[i]->keyPressed(evt);
+    }
+
+    void ExtendedInputState::keyReleased(const KeyEvent& evt)
+    {
+        for (unsigned int i = 0; i < keyHandlers_.size(); i++)
+            keyHandlers_[i]->keyReleased(evt);
+    }
+
+    void ExtendedInputState::keyHeld(const KeyEvent& evt)
+    {
+        for (unsigned int i = 0; i < keyHandlers_.size(); i++)
+            keyHandlers_[i]->keyHeld(evt);
+    }
+
+
+    void ExtendedInputState::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseMoved(abs, rel, clippingSize);
+    }
+
+    void ExtendedInputState::mouseScrolled(int abs, int rel)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseScrolled(abs, rel);
+    }
+
+    void ExtendedInputState::mouseButtonPressed(MouseButton::Enum id)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseButtonPressed(id);
+    }
+
+    void ExtendedInputState::mouseButtonReleased(MouseButton::Enum id)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseButtonReleased(id);
+    }
+
+    void ExtendedInputState::mouseButtonHeld(MouseButton::Enum id)
+    {
+        for (unsigned int i = 0; i < mouseHandlers_.size(); i++)
+            mouseHandlers_[i]->mouseButtonHeld(id);
+    }
+
+
+    void ExtendedInputState::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickAxisMoved(joyStickID, axis, value);
+    }
+
+    void ExtendedInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButton::Enum id)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickButtonPressed(joyStickID, id);
+    }
+
+    void ExtendedInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickButtonReleased(joyStickID, id);
+    }
+
+    void ExtendedInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButton::Enum id)
+    {
+        assert(joyStickID < joyStickHandlers_.size());
+        for (unsigned int i = 0; i < joyStickHandlers_[joyStickID].size(); i++)
+            joyStickHandlers_[joyStickID][i]->joyStickButtonHeld(joyStickID, id);
+    }
+
+
+    /**
+    @brief
+        Adds a key handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addKeyHandler(KeyHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        // see whether the handler already is in the list
+        for (std::vector<KeyHandler*>::iterator it = keyHandlers_.begin(); it != keyHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        keyHandlers_.push_back(handler);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a Key handler from the state.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeKeyHandler(KeyHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        for (std::vector<KeyHandler*>::iterator it = keyHandlers_.begin(); it != keyHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                keyHandlers_.erase(it);
+                update();
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+    @brief
+        Adds a mouse handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addMouseHandler(MouseHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        // see whether the handler already is in the list
+        for (std::vector<MouseHandler*>::iterator it = mouseHandlers_.begin(); it != mouseHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        mouseHandlers_.push_back(handler);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a mouse handler from the state.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeMouseHandler(MouseHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        for (std::vector<MouseHandler*>::iterator it = mouseHandlers_.begin(); it != mouseHandlers_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                mouseHandlers_.erase(it);
+                update();
+                return true;
+            }
+        }
+        return false;
+    }
+
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @param joyStickID
+        ID of the joy stick
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID)
+    {
+        if (!handler || joyStickID >= joyStickHandlers_.size())
+            return false;
+
+        // see whether the handler already is in the list
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlers_[joyStickID].begin();
+            it != joyStickHandlers_[joyStickID].end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        joyStickHandlers_[joyStickID].push_back(handler);
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a joy stick handler from the state.
+    @param handler
+        Pointer to the handler.
+    @param joyStickID
+        ID of the joy stick
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID)
+    {
+        if (!handler || joyStickID >= joyStickHandlers_.size())
+            return false;
+
+        // remove it from the list of all-joystick handlers if present
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlersAll_.begin();
+            it != joyStickHandlersAll_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                joyStickHandlersAll_.erase(it);
+            }
+        }
+
+        // remove handler from the list of seperate lists of handlers
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlers_[joyStickID].begin();
+            it != joyStickHandlers_[joyStickID].end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                joyStickHandlers_[joyStickID].erase(it);
+                update();
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addJoyStickHandler(JoyStickHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        // see whether the handler already is in the big list
+        for (std::vector<JoyStickHandler*>::iterator it = joyStickHandlersAll_.begin();
+            it != joyStickHandlersAll_.end(); it++)
+        {
+            if ((*it) == handler)
+            {
+                return false;
+            }
+        }
+        joyStickHandlersAll_.push_back(handler);
+        update();
+
+        // now, we have to add it to all the separate lists
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); ++iJoyStick)
+            addJoyStickHandler(handler, iJoyStick);
+        return true;
+    }
+
+    /**
+    @brief
+        Removes a joy stick handler from the state.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeJoyStickHandler(JoyStickHandler* handler)
+    {
+        if (!handler)
+            return false;
+
+        bool success = false;
+        // remove from all lists in a loop (also removes it from the big list)
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); ++iJoyStick)
+            success |= removeJoyStickHandler(handler, iJoyStick);
+
+        return success;
+    }
+
+    void ExtendedInputState::removeAndDestroyAllHandlers()
+    {
+        for (std::vector<InputTickable*>::iterator it = allHandlers_.begin();
+            it != allHandlers_.end(); ++it)
+            delete *it;
+
+        allHandlers_.clear();
+        keyHandlers_.clear();
+        mouseHandlers_.clear();
+        joyStickHandlersAll_.clear();
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); ++iJoyStick)
+            joyStickHandlers_[iJoyStick].clear();
+        update();
+    }
+
+    /**
+    @brief
+        Adds a handler of any kind. dynamic_cast determines to which list it is added.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool ExtendedInputState::addHandler(InputTickable* handler)
+    {
+        bool success = false;
+
+        success |= addKeyHandler(dynamic_cast<KeyHandler*>(handler));
+        success |= addMouseHandler(dynamic_cast<MouseHandler*>(handler));
+        success |= addJoyStickHandler(dynamic_cast<JoyStickHandler*>(handler));
+
+        return success;
+    }
+
+    /**
+    @brief
+        Removes a handler from all lists.
+    @param handler
+        Pointer to the handler.
+    @return
+        True if removal was successful, false if handler was not found.
+    */
+    bool ExtendedInputState::removeHandler(InputTickable* handler)
+    {
+        bool success = false;
+
+        success |= removeKeyHandler(dynamic_cast<KeyHandler*>(handler));
+        success |= removeMouseHandler(dynamic_cast<MouseHandler*>(handler));
+        success |= removeJoyStickHandler(dynamic_cast<JoyStickHandler*>(handler));
+
+        return success;
+    }
+
+    void ExtendedInputState::tickInput(float dt)
+    {
+        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
+        {
+            allHandlers_[i]->tickInput(dt);
+        }
+    }
+
+    void ExtendedInputState::tickInput(float dt, unsigned int device)
+    {
+        switch (device)
+        {
+        case Keyboard:
+            for (unsigned int i = 0; i < keyHandlers_.size(); ++i)
+                keyHandlers_[i]->tickKey(dt);
+            break;
+
+        case Mouse:
+            for (unsigned int i = 0; i < mouseHandlers_.size(); ++i)
+                mouseHandlers_[i]->tickMouse(dt);
+            break;
+
+        default: // joy sticks
+            for (unsigned int i = 0; i < joyStickHandlers_[device - 2].size(); ++i)
+                joyStickHandlers_[device - 2][i]->tickJoyStick(dt, device - 2);
+            break;
+        }
+    }
+
+    void ExtendedInputState::update()
+    {
+        // we can use a set to have a list of unique pointers (an object can implement all 3 handlers)
+        std::set<InputTickable*> tempSet;
+        for (unsigned int iHandler = 0; iHandler < keyHandlers_.size(); iHandler++)
+            tempSet.insert(keyHandlers_[iHandler]);
+        for (unsigned int iHandler = 0; iHandler < mouseHandlers_.size(); iHandler++)
+            tempSet.insert(mouseHandlers_[iHandler]);
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandlers_.size(); iJoyStick++)
+            for (unsigned int iHandler = 0; iHandler < joyStickHandlers_[iJoyStick].size(); iHandler++)
+                tempSet.insert(joyStickHandlers_[iJoyStick][iHandler]);
+
+        // copy the content of the map back to the actual vector
+        allHandlers_.clear();
+        for (std::set<InputTickable*>::const_iterator itHandler = tempSet.begin();
+            itHandler != tempSet.end(); itHandler++)
+            allHandlers_.push_back(*itHandler);
+
+        // update the deviceEnabled options
+        setInputDeviceEnabled(Keyboard, (keyHandlers_.size() != 0));
+        setInputDeviceEnabled(Mouse, (mouseHandlers_.size() != 0));
+        for (unsigned int i = 0; i < joyStickHandlers_.size(); ++i)
+            setInputDeviceEnabled(2 + i, (joyStickHandlers_[i].size() != 0));
+    }
+}
Index: code/trunk/src/core/input/ExtendedInputState.h
===================================================================
--- code/trunk/src/core/input/ExtendedInputState.h	(revision 1755)
+++ code/trunk/src/core/input/ExtendedInputState.h	(revision 1755)
@@ -0,0 +1,102 @@
+/*
+ *   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 
+*/
+
+#ifndef _ExtendedInputState_H__
+#define _ExtendedInputState_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+
+#include "InputInterfaces.h"
+#include "InputState.h"
+
+namespace orxonox
+{
+
+    class _CoreExport ExtendedInputState : public InputState
+    {
+        friend class InputManager;
+
+    public:
+        bool addKeyHandler        (KeyHandler* handler);
+        bool removeKeyHandler     (KeyHandler* handler);
+
+        bool addMouseHandler      (MouseHandler* handler);
+        bool removeMouseHandler   (MouseHandler* handler);
+
+        bool addJoyStickHandler   (JoyStickHandler* handler, unsigned int joyStickID);
+        bool removeJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID);
+        bool addJoyStickHandler   (JoyStickHandler* handler);
+        bool removeJoyStickHandler(JoyStickHandler* handler);
+
+        bool addHandler(InputTickable* handler);
+        bool removeHandler(InputTickable* handler);
+
+        void removeAndDestroyAllHandlers();
+
+    private:
+        ExtendedInputState() { }
+        ~ExtendedInputState() { }
+
+        void tickInput(float dt);
+        void tickInput(float dt, unsigned int device);
+
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt);
+        void keyHeld    (const KeyEvent& evt);
+
+        void mouseButtonPressed (MouseButton::Enum id);
+        void mouseButtonReleased(MouseButton::Enum id);
+        void mouseButtonHeld    (MouseButton::Enum id);
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+        void mouseScrolled      (int abs, int rel);
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);        void updateTickables();
+
+        void numberOfJoySticksChanged(unsigned int n);
+        void update();
+
+        std::vector<KeyHandler*>                    keyHandlers_;
+        std::vector<MouseHandler*>                  mouseHandlers_;
+        std::vector<std::vector<JoyStickHandler*> > joyStickHandlers_;
+        std::vector<JoyStickHandler*>               joyStickHandlersAll_;
+
+        std::vector<InputTickable*> allHandlers_;
+    };
+}
+
+#endif /* _ExtendedInputState_H__ */
Index: code/trunk/src/core/input/HalfAxis.cc
===================================================================
--- code/trunk/src/core/input/HalfAxis.cc	(revision 1754)
+++ code/trunk/src/core/input/HalfAxis.cc	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Implementation of the different input handlers.
- */
+@file
+@brief
+    Implementation of the different input handlers.
+*/
 
 #include "HalfAxis.h"
@@ -38,40 +39,40 @@
 namespace orxonox
 {
-  void HalfAxis::clear()
-  {
-    Button::clear();
-    if (nParamCommands_)
+    void HalfAxis::clear()
     {
-      // delete all commands and the command pointer array
-      for (unsigned int i = 0; i < nParamCommands_; i++)
-        delete paramCommands_[i];
-      delete[] paramCommands_;
-      nParamCommands_ = 0;
+        Button::clear();
+        if (nParamCommands_)
+        {
+            // delete all commands and the command pointer array
+            for (unsigned int i = 0; i < nParamCommands_; i++)
+                delete paramCommands_[i];
+            delete[] paramCommands_;
+            nParamCommands_ = 0;
+        }
+        else
+        {
+            nParamCommands_ = 0; nParamCommands_ = 0;
+        }
     }
-    else
+
+    bool HalfAxis::addParamCommand(ParamCommand* command)
     {
-      nParamCommands_ = 0; nParamCommands_ = 0;
+        ParamCommand** cmds = paramCommands_;
+        paramCommands_ = new ParamCommand*[++nParamCommands_];
+        unsigned int i;
+        for (i = 0; i < nParamCommands_ - 1; i++)
+            paramCommands_[i] = cmds[i];
+        paramCommands_[i] = command;
+        if (nParamCommands_ > 1)
+            delete[] cmds;
+        return true;
     }
-  }
 
-  bool HalfAxis::addParamCommand(ParamCommand* command)
-  {
-    ParamCommand** cmds = paramCommands_;
-    paramCommands_ = new ParamCommand*[++nParamCommands_];
-    unsigned int i;
-    for (i = 0; i < nParamCommands_ - 1; i++)
-      paramCommands_[i] = cmds[i];
-    paramCommands_[i] = command;
-    if (nParamCommands_ > 1)
-      delete[] cmds;
-    return true;
-  }
-
-  bool HalfAxis::execute()
-  {
-    bool success = true;
-    for (unsigned int i = 0; i < nParamCommands_; i++)
-      success = success && paramCommands_[i]->execute(absVal_, relVal_);
-    return success;
-  }
+    bool HalfAxis::execute()
+    {
+        bool success = true;
+        for (unsigned int i = 0; i < nParamCommands_; i++)
+            success = success && paramCommands_[i]->execute(absVal_, relVal_);
+        return success;
+    }
 }
Index: code/trunk/src/core/input/HalfAxis.h
===================================================================
--- code/trunk/src/core/input/HalfAxis.h	(revision 1754)
+++ code/trunk/src/core/input/HalfAxis.h	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Different definitions of input processing.
- */
+@file
+@brief
+    Different definitions of input processing.
+*/
 
 #ifndef _HalfAxis_H__
@@ -40,24 +41,30 @@
 namespace orxonox
 {
-  class _CoreExport HalfAxis : public Button
-  {
-  public:
-    HalfAxis() : relVal_(0.0f), absVal_(0.0f), paramCommands_(0), nParamCommands_(0),
-                 wasDown_(false), hasChanged_(false) { }
-    using Button::execute;
-    bool execute();
-    bool addParamCommand(ParamCommand* command);
-    void clear();
+    class _CoreExport HalfAxis : public Button
+    {
+    public:
+        HalfAxis()
+            : relVal_(0.0f)
+            , absVal_(0.0f)
+            , paramCommands_(0)
+            , nParamCommands_(0)
+            , wasDown_(false)
+            , hasChanged_(false)
+        { }
+        using Button::execute;
+        bool execute();
+        bool addParamCommand(ParamCommand* command);
+        void clear();
 
-    // axis related
-    float relVal_;
-    float absVal_;
-    ParamCommand** paramCommands_;
-    unsigned int nParamCommands_;
+        // axis related
+        float relVal_;
+        float absVal_;
+        ParamCommand** paramCommands_;
+        unsigned int nParamCommands_;
 
-    // button related
-    bool wasDown_;
-    bool hasChanged_;
-  };
+        // button related
+        bool wasDown_;
+        bool hasChanged_;
+    };
 }
 
Index: code/trunk/src/core/input/InputBuffer.cc
===================================================================
--- code/trunk/src/core/input/InputBuffer.cc	(revision 1754)
+++ code/trunk/src/core/input/InputBuffer.cc	(revision 1755)
@@ -220,5 +220,5 @@
         @param dt Delta time
     */
-    void InputBuffer::tickInput(float dt, const HandlerState& state)
+    void InputBuffer::tickInput(float dt)
     {
         timeSinceKeyPressed_ += dt;
Index: code/trunk/src/core/input/InputBuffer.h
===================================================================
--- code/trunk/src/core/input/InputBuffer.h	(revision 1754)
+++ code/trunk/src/core/input/InputBuffer.h	(revision 1755)
@@ -170,5 +170,6 @@
             void processKey (const KeyEvent &e);
 
-            void tickInput(float dt, const HandlerState& state);
+            void tickInput(float dt);
+            void tickKey(float dt) { }
 
             std::string buffer_;
Index: code/trunk/src/core/input/InputCommands.cc
===================================================================
--- code/trunk/src/core/input/InputCommands.cc	(revision 1754)
+++ code/trunk/src/core/input/InputCommands.cc	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Implementation of the different input handlers.
- */
+@file
+@brief
+    Implementation of the different input handlers.
+*/
 
 #include "InputCommands.h"
@@ -37,91 +38,97 @@
 namespace orxonox
 {
-  // ###############################
-  // ###  BufferedParamCommand   ###
-  // ###############################
+    // ###############################
+    // ###  BufferedParamCommand   ###
+    // ###############################
 
-  /**
-  * Executes a buffered command. This is used for commands with additional
-  * parameters.
-  * @return True if command execution was successful or value was zero.
-  */
-  bool BufferedParamCommand::execute()
-  {
-    if (nValuesAdded_)
+    /**
+    @brief
+        Executes a buffered command. This is used for commands with additional
+        parameters.
+    @return
+        True if command execution was successful or value was zero.
+    */
+    bool BufferedParamCommand::execute()
     {
-      BufferedParamCommand& cmd = *this;
-      cmd.evaluation_.setEvaluatedParameter(cmd.paramIndex_, cmd.value_);
-      // reset
-      cmd.nValuesAdded_ = 0;
-      cmd.value_ = 0;
-      return cmd.evaluation_.execute();
+        if (nValuesAdded_)
+        {
+            BufferedParamCommand& cmd = *this;
+            cmd.evaluation_.setEvaluatedParameter(cmd.paramIndex_, cmd.value_);
+            // reset
+            cmd.nValuesAdded_ = 0;
+            cmd.value_ = 0;
+            return cmd.evaluation_.execute();
+        }
+        else
+            return true;
     }
-    else
-      return true;
-  }
 
-  // ###############################
-  // #####    SimpleCommand    #####
-  // ###############################
+    // ###############################
+    // #####    SimpleCommand    #####
+    // ###############################
 
-  /**
-  * Executes a simple command with no additional paramters.
-  * @return True if command execution was successful, false otherwise.
-  */
-  bool SimpleCommand::execute(float abs, float rel)
-  {
-    return evaluation_.execute();
-  }
+    /**
+    @brief
+        Executes a simple command with no additional paramters.
+    @return 
+        True if command execution was successful, false otherwise.
+    */
+    bool SimpleCommand::execute(float abs, float rel)
+    {
+        return evaluation_.execute();
+    }
 
-  // ###############################
-  // #####    ParamCommand     #####
-  // ###############################
+    // ###############################
+    // #####    ParamCommand     #####
+    // ###############################
 
-  /**
-  * Executes a parameter command. The commmand string is not directly executed,
-  * but instead stored in a buffer list so that values can be combined.
-  * @return Always true.
-  */
-  bool ParamCommand::execute(float abs, float rel)
-  {
-    BufferedParamCommand& cmd = *paramCommand_;
-    // command has an additional parameter
-    if (bRelative_)
+    /**
+    @brief
+        Executes a parameter command. The commmand string is not directly executed,
+        but instead stored in a buffer list so that values can be combined.
+    @return
+        Always true.
+    */
+    bool ParamCommand::execute(float abs, float rel)
     {
-      if (rel != 0.0f)
-      {
-        // we have to calculate a relative movement.
-        // paramModifier_ says how much one keystroke is
-        cmd.value_ += paramModifier_ * rel;
-      }
+        BufferedParamCommand& cmd = *paramCommand_;
+        // command has an additional parameter
+        if (bRelative_)
+        {
+            if (rel != 0.0f)
+            {
+                // we have to calculate a relative movement.
+                // paramModifier_ says how much one keystroke is
+                cmd.value_ += paramModifier_ * rel;
+            }
+        }
+        else if (abs != 0.0f)
+        {
+            // Usually, joy sticks create 'noise' (they return values if they're in 0 position)
+            // and normally this is caught in tickInput(), but that threshold cannot be to high
+            // in order to preserve accuracy. Instead, we have to catch the problem here. An example:
+            // Someone only uses buttons with an active joystick. The joy stick value could then
+            // be 0.05 for instance and the the key value 1. Without handling the problem, the final
+            // value would be computed to (1+0.05)/2=0.5025 which is not what the user expects.
+            float absQ = abs * abs;
+            float valueQ = cmd.value_ * cmd.value_;
+            if (absQ > 50.0f * valueQ) // ease up comparison by using quadratics
+            {
+                cmd.value_ = abs * paramModifier_;
+                cmd.nValuesAdded_ = 1;
+            }
+            else if (absQ * 50.0f < valueQ)
+            {
+                // abs is too small, we just don't do anything
+            }
+            else
+            {
+                // we have to calculate the absolute position of the axis.
+                // Since there might be another axis that is affected, we have to wait and
+                // store the result in a temporary place
+                cmd.value_ = (cmd.value_ * cmd.nValuesAdded_ + paramModifier_ * abs) / ++cmd.nValuesAdded_;
+            }
+        }
+        return true;
     }
-    else if (abs != 0.0f)
-    {
-      // Usually, joy sticks create 'noise' (they return values if they're in 0 position)
-      // and normally this is caught in tickInput(), but that threshold cannot be to high
-      // in order to preserve accuracy. Instead, we have to catch the problem here. An example:
-      // Someone only uses buttons with an active joystick. The joy stick value could then
-      // be 0.05 for instance and the the key value 1. Without handling the problem, the final
-      // value would be computed to (1+0.05)/2=0.5025 which is not what the user expects.
-      float absQ = abs * abs;
-      float valueQ = cmd.value_ * cmd.value_;
-      if (absQ > 50.0f * valueQ) // ease up comparison by using quadratics
-      {
-        cmd.value_ = abs * paramModifier_;
-        cmd.nValuesAdded_ = 1;
-      }
-      else if (absQ * 50.0f < valueQ)
-      {
-        // abs is too small, we just don't do anything
-      }
-      else
-      {
-        // we have to calculate the absolute position of the axis.
-        // Since there might be another axis that is affected, we have to wait and
-        // store the result in a temporary place
-        cmd.value_ = (cmd.value_ * cmd.nValuesAdded_ + paramModifier_ * abs) / ++cmd.nValuesAdded_;
-      }
-    }
-    return true;
-  }
 }
Index: code/trunk/src/core/input/InputCommands.h
===================================================================
--- code/trunk/src/core/input/InputCommands.h	(revision 1754)
+++ code/trunk/src/core/input/InputCommands.h	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Different definitions of input processing.
- */
+@file
+@brief
+    Different definitions of input processing.
+*/
 
 #ifndef _InputCommands_H__
@@ -40,41 +41,41 @@
 namespace orxonox
 {
-  class _CoreExport BufferedParamCommand
-  {
-  public:
-    BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
-    bool execute();
+    class _CoreExport BufferedParamCommand
+    {
+    public:
+        BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
+        bool execute();
 
-    float value_;
-    unsigned int nValuesAdded_;
-    int paramIndex_;
-    CommandEvaluation evaluation_;
-  };
+        float value_;
+        unsigned int nValuesAdded_;
+        int paramIndex_;
+        CommandEvaluation evaluation_;
+    };
 
-  class _CoreExport BaseCommand
-  {
-  public:
-    virtual ~BaseCommand() { }
-    virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;
-  };
+    class _CoreExport BaseCommand
+    {
+    public:
+        virtual ~BaseCommand() { }
+        virtual bool execute(float abs = 1.0f, float rel = 1.0f) = 0;
+    };
 
-  class _CoreExport SimpleCommand : public BaseCommand
-  {
-  public:
-    bool execute(float abs = 1.0f, float rel = 1.0f);
+    class _CoreExport SimpleCommand : public BaseCommand
+    {
+    public:
+        bool execute(float abs = 1.0f, float rel = 1.0f);
 
-    CommandEvaluation evaluation_;
-  };
+        CommandEvaluation evaluation_;
+    };
 
-  class _CoreExport ParamCommand : public BaseCommand
-  {
-  public:
-    ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }
-    bool execute(float abs = 1.0f, float rel = 1.0f);
+    class _CoreExport ParamCommand : public BaseCommand
+    {
+    public:
+        ParamCommand() : bRelative_(false), paramModifier_(1.0f), paramCommand_(0) { }
+        bool execute(float abs = 1.0f, float rel = 1.0f);
 
-    bool bRelative_;
-    float paramModifier_;
-    BufferedParamCommand* paramCommand_;
-  };
+        bool bRelative_;
+        float paramModifier_;
+        BufferedParamCommand* paramCommand_;
+    };
 }
 
Index: code/trunk/src/core/input/InputInterfaces.h
===================================================================
--- code/trunk/src/core/input/InputInterfaces.h	(revision 1754)
+++ code/trunk/src/core/input/InputInterfaces.h	(revision 1755)
@@ -28,6 +28,7 @@
 
 /**
- @file
- @brief Declarations of various interface classes for the input management.
+@file
+@brief
+    Declarations of various interface classes for the input management.
 */
 
@@ -37,286 +38,329 @@
 #include "core/CorePrereqs.h"
 
-#include "src/ois/OISKeyboard.h"
-#include "src/ois/OISMouse.h"
-#include "src/ois/OISJoyStick.h"
+#include "ois/OISKeyboard.h"
+#include "ois/OISMouse.h"
+#include "ois/OISJoyStick.h"
 #include "util/Math.h"
 
 namespace orxonox
 {
-  namespace KeyCode
-  {
-    // note: KeyCode comments were directly taken from OISKeyboard.h
-    enum Enum
-    {
-      Unassigned    = OIS::KC_UNASSIGNED,
-      Escape        = OIS::KC_ESCAPE,
-      NumRow1       = OIS::KC_1,
-      NumRow2       = OIS::KC_2,
-      NumRow3       = OIS::KC_3,
-      NumRow4       = OIS::KC_4,
-      NumRow5       = OIS::KC_5,
-      NumRow6       = OIS::KC_6,
-      NumRow7       = OIS::KC_7,
-      NumRow8       = OIS::KC_8,
-      NumRow9       = OIS::KC_9,
-      NumRow0       = OIS::KC_0,
-      Minus         = OIS::KC_MINUS,           // - on main keyboard
-      Equals        = OIS::KC_EQUALS,
-      Back          = OIS::KC_BACK,            // backspace
-      Tab           = OIS::KC_TAB,
-      Q             = OIS::KC_Q,
-      W             = OIS::KC_W,
-      E             = OIS::KC_E,
-      R             = OIS::KC_R,
-      T             = OIS::KC_T,
-      Y             = OIS::KC_Y,
-      U             = OIS::KC_U,
-      I             = OIS::KC_I,
-      O             = OIS::KC_O,
-      P             = OIS::KC_P,
-      LeftBracket   = OIS::KC_LBRACKET,
-      RightBracket  = OIS::KC_RBRACKET,
-      Return        = OIS::KC_RETURN,          // Enter on main keyboard
-      LeftControl   = OIS::KC_LCONTROL,
-      A             = OIS::KC_A,
-      S             = OIS::KC_S,
-      D             = OIS::KC_D,
-      F             = OIS::KC_F,
-      G             = OIS::KC_G,
-      H             = OIS::KC_H,
-      J             = OIS::KC_J,
-      K             = OIS::KC_K,
-      L             = OIS::KC_L,
-      Semicolon     = OIS::KC_SEMICOLON,
-      Apostrophe    = OIS::KC_APOSTROPHE,
-      Grave         = OIS::KC_GRAVE,           // accent
-      LeftShift     = OIS::KC_LSHIFT,
-      Backslash     = OIS::KC_BACKSLASH,
-      Z             = OIS::KC_Z,
-      X             = OIS::KC_X,
-      C             = OIS::KC_C,
-      V             = OIS::KC_V,
-      B             = OIS::KC_B,
-      N             = OIS::KC_N,
-      M             = OIS::KC_M,
-      Comma         = OIS::KC_COMMA,
-      Period        = OIS::KC_PERIOD,          // . on main keyboard
-      Slash         = OIS::KC_SLASH,           // / on main keyboard
-      RightShift    = OIS::KC_RSHIFT,
-      Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
-      LeftAlt       = OIS::KC_LMENU,           // left Alt
-      Space         = OIS::KC_SPACE,
-      CapsLock      = OIS::KC_CAPITAL,
-      F1            = OIS::KC_F1,
-      F2            = OIS::KC_F2,
-      F3            = OIS::KC_F3,
-      F4            = OIS::KC_F4,
-      F5            = OIS::KC_F5,
-      F6            = OIS::KC_F6,
-      F7            = OIS::KC_F7,
-      F8            = OIS::KC_F8,
-      F9            = OIS::KC_F9,
-      F10           = OIS::KC_F10,
-      Numlock       = OIS::KC_NUMLOCK,
-      Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
-      Numpad7       = OIS::KC_NUMPAD7,
-      Numpad8       = OIS::KC_NUMPAD8,
-      Numpad9       = OIS::KC_NUMPAD9,
-      NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
-      Numpad4       = OIS::KC_NUMPAD4,
-      Numpad5       = OIS::KC_NUMPAD5,
-      Numpad6       = OIS::KC_NUMPAD6,
-      NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
-      Numpad1       = OIS::KC_NUMPAD1,
-      Numpad2       = OIS::KC_NUMPAD2,
-      Numpad3       = OIS::KC_NUMPAD3,
-      Numpad0       = OIS::KC_NUMPAD0,
-      NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
-      LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
-      F11           = OIS::KC_F11,
-      F12           = OIS::KC_F12,
-      F13           = OIS::KC_F13,             //                     (NEC PC98)
-      F14           = OIS::KC_F14,             //                     (NEC PC98)
-      F15           = OIS::KC_F15,             //                     (NEC PC98)
-      Kana          = OIS::KC_KANA,            // (Japanese keyboard)
-      ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
-      Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
-      NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
-      Yen           = OIS::KC_YEN,             // (Japanese keyboard)
-      ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
-      NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
-      PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
-      AT            = OIS::KC_AT,              //                     (NEC PC98)
-      Colon         = OIS::KC_COLON,           //                     (NEC PC98)
-      Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
-      Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
-      Stop          = OIS::KC_STOP,            //                     (NEC PC98)
-      AX            = OIS::KC_AX,              //                     (Japan AX)
-      Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
-      NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
-      NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
-      RightControl  = OIS::KC_RCONTROL,
-      Mute          = OIS::KC_MUTE,            // Mute
-      Calculator    = OIS::KC_CALCULATOR,      // Calculator
-      PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
-      MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
-      VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
-      VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
-      WebHome       = OIS::KC_WEBHOME,         // Web home
-      NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
-      Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
-      SYSRQ         = OIS::KC_SYSRQ,
-      RightAlt      = OIS::KC_RMENU,           // right Alt
-      Pause         = OIS::KC_PAUSE,           // Pause
-      Home          = OIS::KC_HOME,            // Home on arrow keypad
-      Up            = OIS::KC_UP,              // UpArrow on arrow keypad
-      PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
-      Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
-      Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
-      End           = OIS::KC_END,             // End on arrow keypad
-      Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
-      PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
-      Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
-      Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
-      LeftWindows   = OIS::KC_LWIN,            // Left Windows key
-      RightWindows  = OIS::KC_RWIN,            // Right Windows key
-      Apps          = OIS::KC_APPS,            // AppMenu key
-      Power         = OIS::KC_POWER,           // System Power
-      Sleep         = OIS::KC_SLEEP,           // System Sleep
-      Wake          = OIS::KC_WAKE,            // System Wake
-      WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
-      WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
-      WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
-      WebStop       = OIS::KC_WEBSTOP,         // Web Stop
-      WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
-      WebBack       = OIS::KC_WEBBACK,         // Web Back
-      MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
-      Mail          = OIS::KC_MAIL,            // Mail
-      MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
-    };
-  }
-
-  namespace MouseButton
-  {
-    enum Enum
-    {
-      Left    = OIS::MB_Left,
-      Right   = OIS::MB_Right,
-      Middle  = OIS::MB_Middle,
-      Button3 = OIS::MB_Button3,
-      Button4 = OIS::MB_Button4,
-      Button5 = OIS::MB_Button5,
-      Button6 = OIS::MB_Button6,
-      Button7 = OIS::MB_Button7
-    };
-  }
-
-  namespace KeyboardModifier
-  {
-    enum Enum
-    {
-      Shift = 0x0000001,
-      Ctrl  = 0x0000010,
-      Alt   = 0x0000100
-    };
-  }
-
-  struct _CoreExport Key
-  {
-    Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
-    KeyCode::Enum key;
-    unsigned int text;
-  };
-
-  class _CoreExport KeyEvent
-  {
-  public:
-    KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
-    KeyEvent(const OIS::KeyEvent& evt, unsigned int mod) : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
-    KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
-    bool isModifierDown(KeyboardModifier::Enum modifier) const { return (KeyboardModifier::Enum)modifier&modifiers; }
-
-    const KeyCode::Enum key;
-    unsigned int text;
-    unsigned int modifiers;
-  };
-
-  //typedef OIS::MouseState MouseState;
-
-  /*class _CoreExport JoyStickState
-  {
-  public:
-    JoyStickState(const OIS::JoyStickState& state, int ID) : OIS::JoyStickState(state), mJoyStickID(ID) { }
-    JoyStickState() { clear(); }
-    int mJoyStickID;
-		JoyStickState() { clear(); }
-
-		std::vector<bool> mButtons;
-		int axes[16];
-		std::vector<Vector3> mVectors;
-  };*/
-
-  /**
-  * Helper struct to determine which handlers of an object (can implement
-  * multiple handlers) are active.
-  */
-  struct HandlerState
-  {
-    HandlerState() : key(false), mouse(false), joyStick(false) { }
-    bool key;
-    bool mouse;
-    bool joyStick;
-  };
-
-  class _CoreExport InputTickable
-  {
-  public:
-    virtual ~InputTickable() { }
-    virtual void tickInput(float dt, const HandlerState& state) = 0;
-  };
-
-  /**
-    @brief Interface class used for key input listeners.
-  */
-  class _CoreExport KeyHandler : virtual public InputTickable
-  {
-  public:
-    virtual ~KeyHandler() { }
-    virtual void keyPressed (const KeyEvent& evt) = 0;
-    virtual void keyReleased(const KeyEvent& evt) = 0;
-    virtual void keyHeld    (const KeyEvent& evt) = 0;
-    //virtual void tickKey    (float dt) { }
-  };
-
-  /**
-    @brief Interface class used for mouse input listeners.
-  */
-  class _CoreExport MouseHandler : virtual public InputTickable
-  {
-  public:
-    virtual ~MouseHandler() { }
-    virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
-    virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
-    virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
-    virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
-    virtual void mouseScrolled      (int abs, int rel)     = 0;
-    //virtual void tickMouse          (float dt) { }
-  };
-
-
-  /**
-    @brief Interface class used for joy stick input listeners.
-  */
-  class _CoreExport JoyStickHandler : virtual public InputTickable
-  {
-  public:
-    virtual ~JoyStickHandler() { }
-    virtual void joyStickButtonPressed (int joyStickID, int button) = 0;
-    virtual void joyStickButtonReleased(int joyStickID, int button) = 0;
-    virtual void joyStickButtonHeld    (int joyStickID, int button) = 0;
-    virtual void joyStickAxisMoved     (int joyStickID, int axis, float value) = 0;
-    //virtual bool joyStickVector3Moved  (int joyStickID, int index /*, fill list*/) {return true;}
-    //virtual void tickJoyStick          (float dt) { }
-  };
+    namespace KeyCode
+    {
+        // note: KeyCode comments were directly copied from OISKeyboard.h
+        enum Enum
+        {
+            Unassigned    = OIS::KC_UNASSIGNED,
+            Escape        = OIS::KC_ESCAPE,
+            NumRow1       = OIS::KC_1,
+            NumRow2       = OIS::KC_2,
+            NumRow3       = OIS::KC_3,
+            NumRow4       = OIS::KC_4,
+            NumRow5       = OIS::KC_5,
+            NumRow6       = OIS::KC_6,
+            NumRow7       = OIS::KC_7,
+            NumRow8       = OIS::KC_8,
+            NumRow9       = OIS::KC_9,
+            NumRow0       = OIS::KC_0,
+            Minus         = OIS::KC_MINUS,           // - on main keyboard
+            Equals        = OIS::KC_EQUALS,
+            Back          = OIS::KC_BACK,            // backspace
+            Tab           = OIS::KC_TAB,
+            Q             = OIS::KC_Q,
+            W             = OIS::KC_W,
+            E             = OIS::KC_E,
+            R             = OIS::KC_R,
+            T             = OIS::KC_T,
+            Y             = OIS::KC_Y,
+            U             = OIS::KC_U,
+            I             = OIS::KC_I,
+            O             = OIS::KC_O,
+            P             = OIS::KC_P,
+            LeftBracket   = OIS::KC_LBRACKET,
+            RightBracket  = OIS::KC_RBRACKET,
+            Return        = OIS::KC_RETURN,          // Enter on main keyboard
+            LeftControl   = OIS::KC_LCONTROL,
+            A             = OIS::KC_A,
+            S             = OIS::KC_S,
+            D             = OIS::KC_D,
+            F             = OIS::KC_F,
+            G             = OIS::KC_G,
+            H             = OIS::KC_H,
+            J             = OIS::KC_J,
+            K             = OIS::KC_K,
+            L             = OIS::KC_L,
+            Semicolon     = OIS::KC_SEMICOLON,
+            Apostrophe    = OIS::KC_APOSTROPHE,
+            Grave         = OIS::KC_GRAVE,           // accent
+            LeftShift     = OIS::KC_LSHIFT,
+            Backslash     = OIS::KC_BACKSLASH,
+            Z             = OIS::KC_Z,
+            X             = OIS::KC_X,
+            C             = OIS::KC_C,
+            V             = OIS::KC_V,
+            B             = OIS::KC_B,
+            N             = OIS::KC_N,
+            M             = OIS::KC_M,
+            Comma         = OIS::KC_COMMA,
+            Period        = OIS::KC_PERIOD,          // . on main keyboard
+            Slash         = OIS::KC_SLASH,           // / on main keyboard
+            RightShift    = OIS::KC_RSHIFT,
+            Multiply      = OIS::KC_MULTIPLY,        // * on numeric keypad
+            LeftAlt       = OIS::KC_LMENU,           // left Alt
+            Space         = OIS::KC_SPACE,
+            CapsLock      = OIS::KC_CAPITAL,
+            F1            = OIS::KC_F1,
+            F2            = OIS::KC_F2,
+            F3            = OIS::KC_F3,
+            F4            = OIS::KC_F4,
+            F5            = OIS::KC_F5,
+            F6            = OIS::KC_F6,
+            F7            = OIS::KC_F7,
+            F8            = OIS::KC_F8,
+            F9            = OIS::KC_F9,
+            F10           = OIS::KC_F10,
+            Numlock       = OIS::KC_NUMLOCK,
+            Scrolllock    = OIS::KC_SCROLL,          // Scroll Lock
+            Numpad7       = OIS::KC_NUMPAD7,
+            Numpad8       = OIS::KC_NUMPAD8,
+            Numpad9       = OIS::KC_NUMPAD9,
+            NumpadSubtract= OIS::KC_SUBTRACT,        // - on numeric keypad
+            Numpad4       = OIS::KC_NUMPAD4,
+            Numpad5       = OIS::KC_NUMPAD5,
+            Numpad6       = OIS::KC_NUMPAD6,
+            NumpadAdd     = OIS::KC_ADD,             // + on numeric keypad
+            Numpad1       = OIS::KC_NUMPAD1,
+            Numpad2       = OIS::KC_NUMPAD2,
+            Numpad3       = OIS::KC_NUMPAD3,
+            Numpad0       = OIS::KC_NUMPAD0,
+            NumpadPeriod  = OIS::KC_DECIMAL,         // . on numeric keypad
+            LessThan      = OIS::KC_OEM_102,         // < > | on UK/Germany keyboards
+            F11           = OIS::KC_F11,
+            F12           = OIS::KC_F12,
+            F13           = OIS::KC_F13,             //                     (NEC PC98)
+            F14           = OIS::KC_F14,             //                     (NEC PC98)
+            F15           = OIS::KC_F15,             //                     (NEC PC98)
+            Kana          = OIS::KC_KANA,            // (Japanese keyboard)
+            ABNT_C1       = OIS::KC_ABNT_C1,         // / ? on Portugese (Brazilian) keyboards
+            Convert       = OIS::KC_CONVERT,         // (Japanese keyboard)
+            NoConvert     = OIS::KC_NOCONVERT,       // (Japanese keyboard)
+            Yen           = OIS::KC_YEN,             // (Japanese keyboard)
+            ABNT_C2       = OIS::KC_ABNT_C2,         // Numpad . on Portugese (Brazilian) keyboards
+            NumpadEquals  = OIS::KC_NUMPADEQUALS,    // = on numeric keypad (NEC PC98)
+            PreviousTrack = OIS::KC_PREVTRACK,       // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+            AT            = OIS::KC_AT,              //                     (NEC PC98)
+            Colon         = OIS::KC_COLON,           //                     (NEC PC98)
+            Underline     = OIS::KC_UNDERLINE,       //                     (NEC PC98)
+            Kanji         = OIS::KC_KANJI,           // (Japanese keyboard)
+            Stop          = OIS::KC_STOP,            //                     (NEC PC98)
+            AX            = OIS::KC_AX,              //                     (Japan AX)
+            Unlabeled     = OIS::KC_UNLABELED,       //                        (J3100)
+            NextTrack     = OIS::KC_NEXTTRACK,       // Next Track
+            NumpadEnter   = OIS::KC_NUMPADENTER,     // Enter on numeric keypad
+            RightControl  = OIS::KC_RCONTROL,
+            Mute          = OIS::KC_MUTE,            // Mute
+            Calculator    = OIS::KC_CALCULATOR,      // Calculator
+            PlayPause     = OIS::KC_PLAYPAUSE,       // Play / Pause
+            MediaStop     = OIS::KC_MEDIASTOP,       // Media Stop
+            VolumeDown    = OIS::KC_VOLUMEDOWN,      // Volume -
+            VolumeUp      = OIS::KC_VOLUMEUP,        // Volume +
+            WebHome       = OIS::KC_WEBHOME,         // Web home
+            NumpadComma   = OIS::KC_NUMPADCOMMA,     // , on numeric keypad (NEC PC98)
+            Divide        = OIS::KC_DIVIDE,          // / on numeric keypad
+            SYSRQ         = OIS::KC_SYSRQ,
+            RightAlt      = OIS::KC_RMENU,           // right Alt
+            Pause         = OIS::KC_PAUSE,           // Pause
+            Home          = OIS::KC_HOME,            // Home on arrow keypad
+            Up            = OIS::KC_UP,              // UpArrow on arrow keypad
+            PageUp        = OIS::KC_PGUP,            // PgUp on arrow keypad
+            Left          = OIS::KC_LEFT,            // LeftArrow on arrow keypad
+            Right         = OIS::KC_RIGHT,           // RightArrow on arrow keypad
+            End           = OIS::KC_END,             // End on arrow keypad
+            Down          = OIS::KC_DOWN,            // DownArrow on arrow keypad
+            PageDown      = OIS::KC_PGDOWN,          // PgDn on arrow keypad
+            Insert        = OIS::KC_INSERT,          // Insert on arrow keypad
+            Delete        = OIS::KC_DELETE,          // Delete on arrow keypad
+            LeftWindows   = OIS::KC_LWIN,            // Left Windows key
+            RightWindows  = OIS::KC_RWIN,            // Right Windows key
+            Apps          = OIS::KC_APPS,            // AppMenu key
+            Power         = OIS::KC_POWER,           // System Power
+            Sleep         = OIS::KC_SLEEP,           // System Sleep
+            Wake          = OIS::KC_WAKE,            // System Wake
+            WebSearch     = OIS::KC_WEBSEARCH,       // Web Search
+            WebFavorites  = OIS::KC_WEBFAVORITES,    // Web Favorites
+            WebRefresh    = OIS::KC_WEBREFRESH,      // Web Refresh
+            WebStop       = OIS::KC_WEBSTOP,         // Web Stop
+            WebForward    = OIS::KC_WEBFORWARD,      // Web Forward
+            WebBack       = OIS::KC_WEBBACK,         // Web Back
+            MyComputer    = OIS::KC_MYCOMPUTER,      // My Computer
+            Mail          = OIS::KC_MAIL,            // Mail
+            MediaSelect   = OIS::KC_MEDIASELECT      // Media Select
+        };
+    }
+
+    namespace MouseButton
+    {
+        enum Enum
+        {
+            Left    = OIS::MB_Left,
+            Right   = OIS::MB_Right,
+            Middle  = OIS::MB_Middle,
+            Button3 = OIS::MB_Button3,
+            Button4 = OIS::MB_Button4,
+            Button5 = OIS::MB_Button5,
+            Button6 = OIS::MB_Button6,
+            Button7 = OIS::MB_Button7
+        };
+    }
+
+    namespace JoyStickButton
+    {
+        enum Enum
+        {
+            Button0       =  0, Button1       =  1, Button2       =  2, Button3       =  3,
+            Button4       =  4, Button5       =  5, Button6       =  6, Button7       =  7,
+            Button8       =  8, Button9       =  9, Button10      = 10, Button11      = 11,
+            Button12      = 12, Button13      = 13, Button14      = 14, Button15      = 15,
+            Button16      = 16, Button17      = 17, Button18      = 18, Button19      = 19,
+            Button20      = 20, Button21      = 21, Button22      = 22, Button23      = 23,
+            Button24      = 24, Button25      = 25, Button26      = 26, Button27      = 27,
+            Button28      = 28, Button29      = 29, Button30      = 30, Button31      = 31,
+
+            POV0North     = 32, POV0South     = 33, POV0East      = 34, POV0West      = 35,
+            POV0NorthEast = 36, POV0SouthEast = 37, POV0NorthWest = 38, POV0SouthWest = 39,
+
+            POV1North     = 40, POV1South     = 41, POV1East      = 42, POV1West      = 43,
+            POV1NorthEast = 44, POV1SouthEast = 45, POV1NorthWest = 46, POV1SouthWest = 47,
+
+            POV2North     = 48, POV2South     = 49, POV2East      = 50, POV2West      = 51,
+            POV2NorthEast = 52, POV2SouthEast = 53, POV2NorthWest = 54, POV2SouthWest = 55,
+
+            POV3North     = 56, POV3South     = 57, POV3East      = 58, POV3West      = 59,
+            POV3NorthEast = 60, POV3SouthEast = 61, POV3NorthWest = 62, POV3SouthWest = 63,
+        };
+    }
+
+    namespace KeyboardModifier
+    {
+        enum Enum
+        {
+            Shift = 0x0000001,
+            Ctrl  = 0x0000010,
+            Alt   = 0x0000100
+        };
+    }
+    
+    namespace InputDevice
+    {
+        enum Enum
+        {
+            Keyboard,
+            Mouse,
+            JoyStick0,
+            JoyStick1,
+            JoyStick2,
+            JoyStick3,
+            // note: No problem if there are more joy sticks. This enum is just for convenience.
+        };
+    }
+
+    struct _CoreExport Key
+    {
+        Key(const OIS::KeyEvent& evt) : key((KeyCode::Enum)evt.key), text(evt.text) { }
+        KeyCode::Enum key;
+        unsigned int text;
+    };
+
+    class _CoreExport KeyEvent
+    {
+    public:
+        KeyEvent(KeyCode::Enum key, unsigned int text) : key(key), text(text) { }
+        KeyEvent(const OIS::KeyEvent& evt, unsigned int mod)
+            : key((KeyCode::Enum)evt.key), text(evt.text), modifiers(mod) { }
+        KeyEvent(const Key& key, unsigned int mod) : key(key.key), text(key.text), modifiers(mod) { }
+        bool isModifierDown(KeyboardModifier::Enum modifier) const
+            { return (KeyboardModifier::Enum)modifier&modifiers; }
+
+        const KeyCode::Enum key;
+        unsigned int text;
+        unsigned int modifiers;
+    };
+
+
+    class _CoreExport InputTickable
+    {
+    public:
+        virtual ~InputTickable() { }
+        virtual void tickInput(float dt) = 0;
+    };
+
+    /**
+    @brief
+        Interface class used for key input listeners.
+    */
+    class _CoreExport KeyHandler : virtual public InputTickable
+    {
+    public:
+        virtual ~KeyHandler() { }
+        virtual void keyPressed (const KeyEvent& evt) = 0;
+        virtual void keyReleased(const KeyEvent& evt) = 0;
+        virtual void keyHeld    (const KeyEvent& evt) = 0;
+        virtual void tickKey    (float dt) = 0;
+    };
+
+    /**
+    @brief
+        Interface class used for mouse input listeners.
+    */
+    class _CoreExport MouseHandler : virtual public InputTickable
+    {
+    public:
+        virtual ~MouseHandler() { }
+        virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
+        virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
+        virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
+        virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
+        virtual void mouseScrolled      (int abs, int rel)     = 0;
+        virtual void tickMouse          (float dt) = 0;
+    };
+
+
+    /**
+    @brief
+        Interface class used for joy stick input listeners.
+    */
+    class _CoreExport JoyStickHandler : virtual public InputTickable
+    {
+    public:
+        virtual ~JoyStickHandler() { }
+        virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) = 0;
+        virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) = 0;
+        virtual void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id) = 0;
+        virtual void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) = 0;
+        virtual void tickJoyStick          (float dt, unsigned int joyStick) = 0;
+    };
+
+    class _CoreExport EmptyHandler : public KeyHandler, public MouseHandler, public JoyStickHandler
+    {
+    private:
+        void tickInput(float dt) { }
+        void tickJoyStick(float dt, unsigned int joyStick) { }
+        void tickMouse(float dt) { }
+        void tickKey(float dt) { }
+
+        void keyPressed (const KeyEvent& evt) { }
+        void keyReleased(const KeyEvent& evt) { }
+        void keyHeld    (const KeyEvent& evt) { }
+
+        void mouseButtonPressed (MouseButton::Enum id) { }
+        void mouseButtonReleased(MouseButton::Enum id) { }
+        void mouseButtonHeld    (MouseButton::Enum id) { }
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) { }
+        void mouseScrolled      (int abs, int rel) { }
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) { }
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) { }
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id) { }
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) { }
+    };
 
 }
Index: code/trunk/src/core/input/InputManager.cc
===================================================================
--- code/trunk/src/core/input/InputManager.cc	(revision 1754)
+++ code/trunk/src/core/input/InputManager.cc	(revision 1755)
@@ -28,18 +28,23 @@
 
 /**
-  @file
-  @brief Implementation of the InputManager that captures all the input from OIS
-         and redirects it to handlers.
+@file
+@brief
+    Implementation of the InputManager that captures all the input from OIS
+    and redirects it to handlers.
  */
 
 #include "InputManager.h"
 
-#include <limits.h>
+#include <climits>
+#include <cassert>
+
+#include "ois/OISException.h"
+#include "ois/OISInputManager.h"
 
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/Exception.h"
 #include "core/CommandExecutor.h"
 #include "core/ConsoleCommand.h"
-#include "core/Shell.h"               // hack!
 #include "util/Debug.h"
 
@@ -48,1512 +53,1283 @@
 #include "KeyDetector.h"
 #include "CalibratorCallback.h"
-
-#include "src/ois/OISException.h"
-#include "src/ois/OISInputManager.h"
+#include "InputState.h"
+#include "SimpleInputState.h"
+#include "ExtendedInputState.h"
 
 namespace orxonox
 {
-  SetConsoleCommandShortcut(InputManager, keyBind);
-  SetConsoleCommandShortcut(InputManager, storeKeyStroke);
-  SetConsoleCommandShortcut(InputManager, calibrate);
-
-  // ###############################
-  // ###    Internal Methods     ###
-  // ###############################
-  // ###############################
-
-  /**
-    @brief Constructor only sets member fields to initial zero values
-           and registers the class in the class hierarchy.
-  */
-  InputManager::InputManager() :
-      inputSystem_(0), keyboard_(0), mouse_(0),
-      joySticksSize_(0),
-      keyBinder_(0), keyDetector_(0), buffer_(0), calibratorCallback_(0),
-      state_(IS_UNINIT), stateRequest_(IS_UNINIT), savedState_(IS_UNINIT),
-      keyboardModifiers_(0)
-  {
-    RegisterRootObject(InputManager);
-  }
-
-  /**
-    @brief The one instance of the InputManager is stored in this function.
-    @return A reference to the only instance of the InputManager
-  */
-  InputManager& InputManager::_getSingleton()
-  {
-    static InputManager theOnlyInstance;
-    return theOnlyInstance;
-  }
-
-  /**
-    @brief Destructor only called at the end of the program, after main.
-  */
-  InputManager::~InputManager()
-  {
-    _destroy();
-  }
-
-  /**
-    @brief Creates the OIS::InputMananger, the keyboard, the mouse and
-           the joysticks and assigns the key bindings.
-    @param windowHnd The window handle of the render window
-    @param windowWidth The width of the render window
-    @param windowHeight The height of the render window
-  */
-  bool InputManager::_initialise(const size_t windowHnd, int windowWidth, int windowHeight,
-        bool createKeyboard, bool createMouse, bool createJoySticks)
-  {
-    if (state_ == IS_UNINIT)
-    {
-      CCOUT(3) << "Initialising Input System..." << std::endl;
-      CCOUT(ORX_DEBUG) << "Initialising OIS components..." << std::endl;
-
-      OIS::ParamList paramList;
-      std::ostringstream windowHndStr;
-
-      // Fill parameter list
-      windowHndStr << (unsigned int)windowHnd;
-      paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
-      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
-      //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
+    SetConsoleCommand(InputManager, keyBind, true);
+    SetConsoleCommand(InputManager, storeKeyStroke, true);
+    SetConsoleCommand(InputManager, calibrate, true);
+    SetConsoleCommand(InputManager, reload, false);
+
+    std::string InputManager::bindingCommmandString_s = "";
+    InputManager* InputManager::singletonRef_s = 0;
+
+    using namespace InputDevice;
+
+    /**
+    @brief
+        Defines the |= operator for easier use.
+    */
+    inline InputManager::InputManagerState operator|=(InputManager::InputManagerState& lval,
+                                                      InputManager::InputManagerState rval)
+    {
+        return (lval = (InputManager::InputManagerState)(lval | rval));
+    }
+
+    /**
+    @brief
+        Defines the &= operator for easier use.
+    */
+    inline InputManager::InputManagerState operator&=(InputManager::InputManagerState& lval, int rval)
+    {
+        return (lval = (InputManager::InputManagerState)(lval & rval));
+    }
+
+    // ############################################################
+    // #####                  Initialisation                  #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Constructor only sets member fields to initial zero values
+        and registers the class in the class hierarchy.
+    */
+    InputManager::InputManager()
+        : inputSystem_(0)
+        , keyboard_(0)
+        , mouse_(0)
+        , joySticksSize_(0)
+        , devicesNum_(0)
+        , windowHnd_(0)
+        , internalState_(Uninitialised)
+        , stateDetector_(0)
+        , stateCalibrator_(0)
+        , stateEmpty_(0)
+        , bCalibrating_(false)
+        , keyboardModifiers_(0)
+    {
+        RegisterRootObject(InputManager);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+    }
+
+    /**
+    @brief
+        Creates the OIS::InputMananger, the keyboard, the mouse and
+        the joysticks and assigns the key bindings.
+    @param windowHnd
+        The window handle of the render window
+    @param windowWidth
+        The width of the render window
+    @param windowHeight
+        The height of the render window
+    @param joyStickSupport
+        Whether or not to load the joy sticks as well
+    */
+    void InputManager::initialise(size_t windowHnd, int windowWidth, int windowHeight, bool joyStickSupport)
+    {
+        CCOUT(3) << "Initialising Input System..." << std::endl;
+
+        if (!(internalState_ & OISReady))
+        {
+            CCOUT(4) << "Initialising OIS components..." << std::endl;
+
+            // store handle internally so we can reload OIS
+            windowHnd_ = windowHnd;
+
+            OIS::ParamList paramList;
+            std::ostringstream windowHndStr;
+
+            // Fill parameter list
+            windowHndStr << (unsigned int)windowHnd_;
+            paramList.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
+            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
+            //paramList.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
 #if defined OIS_LINUX_PLATFORM
-      paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
+            paramList.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
 #endif
 
-      try
-      {
-        inputSystem_ = OIS::InputManager::createInputSystem(paramList);
-        CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
-      }
-      catch (OIS::Exception ex)
-      {
-        CCOUT(ORX_ERROR) << "Error: Failed creating an OIS input system."
-            << "OIS message: \"" << ex.eText << "\"" << std::endl;
-        inputSystem_ = 0;
+            inputSystem_ = OIS::InputManager::createInputSystem(paramList);
+            CCOUT(ORX_DEBUG) << "Created OIS input system" << std::endl;
+
+            _initialiseKeyboard();
+
+            _initialiseMouse();
+
+            if (joyStickSupport)
+                _initialiseJoySticks();
+
+            // Set mouse/joystick region
+            if (mouse_)
+                setWindowExtents(windowWidth, windowHeight);
+
+            // clear all buffers
+            _clearBuffers();
+
+            // load joy stick calibration
+            setConfigValues();
+
+            internalState_ |= OISReady;
+
+            CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
+        }
+        else
+        {
+            CCOUT(2) << "Warning: OIS compoments already initialised, skipping" << std::endl;
+        }
+
+        if (!(internalState_ & InternalsReady))
+        {
+            CCOUT(4) << "Initialising InputStates components..." << std::endl;
+
+            stateEmpty_ = createInputState<SimpleInputState>("empty", -1);
+            stateEmpty_->setHandler(new EmptyHandler());
+            activeStates_[stateEmpty_->getPriority()] = stateEmpty_;
+
+            stateDetector_ = createInputState<SimpleInputState>("detector", 101);
+            KeyDetector* temp = new KeyDetector();
+            temp->loadBindings("storeKeyStroke");
+            stateDetector_->setHandler(temp);
+
+            stateCalibrator_ = createInputState<SimpleInputState>("calibrator", 100);
+            stateCalibrator_->setHandler(new EmptyHandler());
+            InputBuffer* buffer = new InputBuffer();
+            buffer->registerListener(this, &InputManager::_completeCalibration, '\r', true);
+            stateCalibrator_->setKeyHandler(buffer);
+
+            internalState_ |= InternalsReady;
+
+            CCOUT(4) << "Initialising InputStates complete." << std::endl;
+        }
+
+        _updateActiveStates();
+
+        CCOUT(3) << "Initialising complete." << std::endl;
+    }
+
+    /**
+    @brief
+        Creates a keyboard and sets the event handler.
+    @return
+        False if keyboard stays uninitialised, true otherwise.
+    */
+    void InputManager::_initialiseKeyboard()
+    {
+        if (keyboard_ != 0)
+        {
+            CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
+            return;
+        }
+        if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
+        {
+            keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
+            // register our listener in OIS.
+            keyboard_->setEventCallback(this);
+            // note: OIS will not detect keys that have already been down when the keyboard was created.
+            CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
+        }
+        else
+        {
+            ThrowException(InitialisationFailed, "No keyboard found!");
+        }
+    }
+
+    /**
+    @brief
+        Creates a mouse and sets the event handler.
+    @return
+        False if mouse stays uninitialised, true otherwise.
+    */
+    void InputManager::_initialiseMouse()
+    {
+        if (mouse_ != 0)
+        {
+            CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
+            return;
+        }
+        try
+        {
+            if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
+            {
+                mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
+                // register our listener in OIS.
+                mouse_->setEventCallback(this);
+                CCOUT(ORX_DEBUG) << "Created OIS mouse" << std::endl;
+            }
+            else
+            {
+                CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
+            }
+        }
+        catch (OIS::Exception ex)
+        {
+            CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
+                << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+            mouse_ = 0;
+        }
+    }
+
+    /**
+    @brief
+        Creates all joy sticks and sets the event handler.
+    @return
+        False joy stick stay uninitialised, true otherwise.
+    */
+    void InputManager::_initialiseJoySticks()
+    {
+        if (joySticksSize_ > 0)
+        {
+            CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
+            return;
+        }
+        if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
+        {
+            for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
+            {
+                try
+                {
+                    OIS::JoyStick* stig = static_cast<OIS::JoyStick*>
+                        (inputSystem_->createInputObject(OIS::OISJoyStick, true));
+                    CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
+                    joySticks_.push_back(stig);
+                    // register our listener in OIS.
+                    stig->setEventCallback(this);
+                }
+                catch (OIS::Exception ex)
+                {
+                    CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
+                        << "OIS error message: \"" << ex.eText << "\"" << std::endl;
+                }
+            }
+        }
+        else
+        {
+            //CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
+        }
+        _redimensionLists();
+    }
+
+    /**
+    @brief
+        Sets the size of all the different lists that are dependent on the number
+        of joy stick devices created.
+    @remarks
+        No matter whether there are a mouse and/or keyboard, they will always
+        occupy 2 places in the device number dependent lists.
+    */
+    void InputManager::_redimensionLists()
+    {
+        joySticksSize_ = joySticks_.size();
+        devicesNum_ = 2 + joySticksSize_;
+        joyStickButtonsDown_ .resize(joySticksSize_);
+        povStates_           .resize(joySticksSize_);
+        sliderStates_        .resize(joySticksSize_);
+        joySticksCalibration_.resize(joySticksSize_);
+
+        for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
+        {
+            // reset the calibration with default values
+            for (unsigned int i = 0; i < 24; i++)
+            {
+                joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
+                joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
+                joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
+            }
+        }
+
+        // state management
+        activeStatesTop_.resize(devicesNum_);
+
+        // inform all states
+        for (std::map<int, InputState*>::const_iterator it = inputStatesByPriority_.begin();
+            it != inputStatesByPriority_.end(); ++it)
+            it->second->setNumOfJoySticks(joySticksSize_);
+    }
+
+    /**
+    @brief
+        Sets the configurable values.
+        This mainly concerns joy stick calibrations.
+    */
+    void InputManager::setConfigValues()
+    {
+        if (joySticksSize_ > 0)
+        {
+            std::vector<double> coeffPos;
+            std::vector<double> coeffNeg;
+            std::vector<int> zero;
+            coeffPos.resize(24);
+            coeffNeg.resize(24);
+            zero.resize(24);
+            for (unsigned int i = 0; i < 24; i++)
+            {
+                coeffPos[i] =  1.0f/32767.0f;
+                coeffNeg[i] =  1.0f/32768.0f;
+                zero[i]     =  0;
+            }
+
+            ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+            if (!cont)
+            {
+                cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), "CoeffPos", coeffPos);
+                getIdentifier()->addConfigValueContainer("CoeffPos", cont);
+            }
+            cont->getValue(&coeffPos, this);
+
+            cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+            if (!cont)
+            {
+                cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), "CoeffNeg", coeffNeg);
+                getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
+            }
+            cont->getValue(&coeffNeg, this);
+
+            cont = getIdentifier()->getConfigValueContainer("Zero");
+            if (!cont)
+            {
+                cont = new ConfigValueContainer(CFT_Settings, getIdentifier(), "Zero", zero);
+                getIdentifier()->addConfigValueContainer("Zero", cont);
+            }
+            cont->getValue(&zero, this);
+
+            // copy values to our own variables
+            for (unsigned int i = 0; i < 24; i++)
+            {
+                joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
+                joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
+                joySticksCalibration_[0].zeroStates[i]    = zero[i];
+            }
+        }
+    }
+
+
+    // ############################################################
+    // #####                    Destruction                   #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Destroys all the created input devices and states.
+    */
+    InputManager::~InputManager()
+    {
+        if (internalState_ != Uninitialised)
+        {
+            try
+            {
+                CCOUT(3) << "Destroying ..." << std::endl;
+
+                // clear our own states
+                stateEmpty_->removeAndDestroyAllHandlers();
+                stateCalibrator_->removeAndDestroyAllHandlers();
+                stateDetector_->removeAndDestroyAllHandlers();
+
+                // kick all active states 'nicely'
+                for (std::map<int, InputState*>::reverse_iterator rit = activeStates_.rbegin();
+                    rit != activeStates_.rend(); ++rit)
+                {
+                    (*rit).second->onLeave();
+                }
+
+                // destroy all input states
+                while (inputStatesByPriority_.size() > 0)
+                    _destroyState((*inputStatesByPriority_.rbegin()).second);
+
+                // destroy the devices
+                _destroyKeyboard();
+                _destroyMouse();
+                _destroyJoySticks();
+
+                OIS::InputManager::destroyInputSystem(inputSystem_);
+
+                CCOUT(3) << "Destroying done." << std::endl;
+            }
+            catch (OIS::Exception& ex)
+            {
+                CCOUT(1) << "An exception has occured while destroying:\n" << ex.what()
+                         << "This could lead to a possible memory/resource leak!" << std::endl;
+            }
+        }
+    }
+
+    /**
+    @brief
+        Destroys the keyboard and sets it to 0.
+    */
+    void InputManager::_destroyKeyboard()
+    {
+        assert(inputSystem_);
+        if (keyboard_)
+            inputSystem_->destroyInputObject(keyboard_);
+        keyboard_ = 0;
+        CCOUT(4) << "Keyboard destroyed." << std::endl;
+    }
+
+    /**
+    @brief
+        Destroys the mouse and sets it to 0.
+    */
+    void InputManager::_destroyMouse()
+    {
+        assert(inputSystem_);
+        if (mouse_)
+            inputSystem_->destroyInputObject(mouse_);
+        mouse_ = 0;
+        CCOUT(4) << "Mouse destroyed." << std::endl;
+    }
+
+    /**
+    @brief
+        Destroys all the joy sticks and resizes the lists to 0.
+    */
+    void InputManager::_destroyJoySticks()
+    {
+        if (joySticksSize_ > 0)
+        {
+            assert(inputSystem_);
+            for (unsigned int i = 0; i < joySticksSize_; i++)
+                if (joySticks_[i] != 0)
+                    inputSystem_->destroyInputObject(joySticks_[i]);
+
+            joySticks_.clear();
+            // don't use _redimensionLists(), might mess with registered handler if
+            // downgrading from 2 to 1 joystick
+            //_redimensionLists();
+            joySticksSize_ = 0;
+        }
+        CCOUT(4) << "Joy sticks destroyed." << std::endl;
+    }
+
+    /**
+    @brief
+        Removes and destroys an InputState.
+    @return
+        True if state was removed immediately, false if postponed.
+    */
+    void InputManager::_destroyState(InputState* state)
+    {
+        assert(state && !(this->internalState_ & Ticking));
+        std::map<int, InputState*>::iterator it = this->activeStates_.find(state->getPriority());
+        if (it != this->activeStates_.end())
+        {
+            this->activeStates_.erase(it);
+            _updateActiveStates();
+        }
+        inputStatesByPriority_.erase(state->getPriority());
+        inputStatesByName_.erase(state->getName());
+        delete state;
+    }
+
+    void InputManager::_clearBuffers()
+    {
+        keysDown_.clear();
+        keyboardModifiers_ = 0;
+        mouseButtonsDown_.clear();
+        for (unsigned int i = 0; i < joySticksSize_; ++i)
+        {
+            joyStickButtonsDown_[i].clear();
+            for (int j = 0; j < 4; ++j)
+            {
+                sliderStates_[i].sliderStates[j].x = 0;
+                sliderStates_[i].sliderStates[j].y = 0;
+                povStates_[i][j] = 0;
+            }
+        }
+    }
+
+
+    // ############################################################
+    // #####                     Reloading                    #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Public interface. Only reloads immediately if the call stack doesn't
+        include the tick() method.
+    @param joyStickSupport
+        Whether or not to initialise joy sticks as well.
+    */
+    void InputManager::reloadInputSystem(bool joyStickSupport)
+    {
+        if (internalState_ & Ticking)
+        {
+            // We cannot destroy OIS right now, because reload was probably
+            // caused by a user clicking on a GUI item. The backtrace would then
+            // include an OIS method. So it would be a very bad thing to destroy it..
+            internalState_ |= ReloadRequest;
+            // Misuse of internalState_: We can easily store the joyStickSupport bool.
+            // use Uninitialised as 0 value in order to make use of the overloaded |= operator
+            internalState_ |= joyStickSupport ? JoyStickSupport : Uninitialised;
+        }
+        else if (internalState_ & OISReady)
+        {
+            _reload(joyStickSupport);
+        }
+        else
+        {
+            CCOUT(2) << "Warning: Cannot reload OIS. May not yet be initialised or"
+                     << "joy sticks are currently calibrating." << std::endl;
+        }
+    }
+
+    /**
+    @brief
+        Internal reload method. Destroys the OIS devices and loads them again.
+    */
+    void InputManager::_reload(bool joyStickSupport)
+    {
+        try
+        {
+            CCOUT(3) << "Reloading ..." << std::endl;
+
+            // Save mouse clipping size
+            int mouseWidth  = mouse_->getMouseState().width;
+            int mouseHeight = mouse_->getMouseState().height;
+
+            internalState_ &= ~OISReady;
+
+            // destroy the devices
+            _destroyKeyboard();
+            _destroyMouse();
+            _destroyJoySticks();
+
+            OIS::InputManager::destroyInputSystem(inputSystem_);
+            inputSystem_ = 0;
+
+            // clear all buffers containing input information
+            _clearBuffers();
+
+            initialise(windowHnd_, mouseWidth, mouseHeight, joyStickSupport);
+
+            CCOUT(3) << "Reloading done." << std::endl;
+        }
+        catch (OIS::Exception& ex)
+        {
+            CCOUT(1) << "An exception has occured while reloading:\n" << ex.what() << std::endl;
+        }
+    }
+
+    // ############################################################
+    // #####                  Runtime Methods                 #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Updates the InputManager. Tick is called by the Core class.
+    @param dt
+        Delta time
+    */
+    void InputManager::tick(float dt)
+    {
+        if (internalState_ == Uninitialised)
+            return;
+        else if (internalState_ & ReloadRequest)
+        {
+            _reload(internalState_ & JoyStickSupport);
+            internalState_ &= ~ReloadRequest;
+            internalState_ &= ~JoyStickSupport;
+        }
+
+        // check for states to leave
+        for (std::set<InputState*>::reverse_iterator rit = stateLeaveRequests_.rbegin();
+            rit != stateLeaveRequests_.rend(); ++rit)
+        {
+            (*rit)->onLeave();
+            // just to be sure that the state actually is registered
+            assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
+
+            activeStates_.erase((*rit)->getPriority());
+            _updateActiveStates();
+        }
+        stateLeaveRequests_.clear();
+
+        // check for states to enter
+        for (std::set<InputState*>::reverse_iterator rit = stateEnterRequests_.rbegin();
+            rit != stateEnterRequests_.rend(); ++rit)
+        {
+            // just to be sure that the state actually is registered
+            assert(inputStatesByName_.find((*rit)->getName()) != inputStatesByName_.end());
+
+            activeStates_[(*rit)->getPriority()] = (*rit);
+            _updateActiveStates();
+            (*rit)->onEnter();
+        }
+        stateEnterRequests_.clear();
+
+        // check for states to destroy
+        for (std::set<InputState*>::reverse_iterator rit = stateDestroyRequests_.rbegin();
+            rit != stateDestroyRequests_.rend(); ++rit)
+        {
+            _destroyState((*rit));
+        }
+        stateDestroyRequests_.clear();
+
+        // mark that we capture and distribute input
+        internalState_ |= Ticking;
+
+        // Capture all the input. This calls the event handlers in InputManager.
+        if (keyboard_)
+            keyboard_->capture();
+        if (mouse_)
+            mouse_->capture();
+        for (unsigned  int i = 0; i < joySticksSize_; i++)
+            joySticks_[i]->capture();
+
+        if (!bCalibrating_)
+        {
+            // call all the handlers for the held key events
+            for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+                activeStatesTop_[Keyboard]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
+
+            // call all the handlers for the held mouse button events
+            for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+                activeStatesTop_[Mouse]->mouseButtonHeld(mouseButtonsDown_[iButton]);
+
+            // call all the handlers for the held joy stick button events
+            for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
+                for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
+                    activeStatesTop_[JoyStick0 + iJoyStick]
+                        ->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
+
+            // tick the handlers for each active handler
+            for (unsigned int i = 0; i < devicesNum_; ++i)
+                activeStatesTop_[i]->tickInput(dt, i);
+
+            // tick the handler with a general tick afterwards
+            for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
+                activeStatesTicked_[i]->tickInput(dt);
+        }
+
+        internalState_ &= ~Ticking;
+    }
+
+    /**
+    @brief
+        Updates the currently active states (according to activeStates_) for each device.
+        Also, a list of all active states (no duplicates!) is compiled for the general tick.
+    */
+    void InputManager::_updateActiveStates()
+    {
+        for (std::map<int, InputState*>::const_iterator it = activeStates_.begin(); it != activeStates_.end(); ++it)
+            for (unsigned int i = 0; i < devicesNum_; ++i)
+                if (it->second->isInputDeviceEnabled(i))
+                    activeStatesTop_[i] = it->second;
+
+        // update tickables (every state will only appear once)
+        // Using a std::set to avoid duplicates
+        std::set<InputState*> tempSet;
+        for (unsigned int i = 0; i < devicesNum_; ++i)
+            tempSet.insert(activeStatesTop_[i]);
+
+        // copy the content of the set back to the actual vector
+        activeStatesTicked_.clear();
+        for (std::set<InputState*>::const_iterator it = tempSet.begin();it != tempSet.end(); ++it)
+            activeStatesTicked_.push_back(*it);
+
+        this->mouseButtonsDown_.clear();
+    }
+
+    /**
+    @brief
+        Processes the accumultated data for the joy stick calibration.
+    */
+    void InputManager::_completeCalibration()
+    {
+        for (unsigned int i = 0; i < 24; i++)
+        {
+            // positive coefficient
+            if (marginalsMax_[i] == INT_MIN)
+                marginalsMax_[i] =  32767;
+            // coefficients
+            if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
+            {
+                joySticksCalibration_[0].positiveCoeff[i]
+                    = 1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
+            }
+            else
+                joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
+
+            // config value
+            ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
+            assert(cont);
+            cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
+
+            // negative coefficient
+            if (marginalsMin_[i] == INT_MAX)
+                marginalsMin_[i] = -32768;
+            // coefficients
+            if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
+            {
+                joySticksCalibration_[0].negativeCoeff[i] = -1.0f
+                    / (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
+            }
+            else
+                joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
+            // config value
+            cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
+            assert(cont);
+            cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
+
+            // zero states
+            if (i < 8)
+            {
+                if (!(i & 1))
+                    joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
+                else
+                    joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
+            }
+            else
+            {
+                if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
+                    joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
+                else
+                    joySticksCalibration_[0].zeroStates[i] = 0;
+            }
+            // config value
+            cont = getIdentifier()->getConfigValueContainer("Zero");
+            assert(cont);
+            cont->set(i, joySticksCalibration_[0].zeroStates[i]);
+        }
+
+        // restore old input state
+        requestLeaveState("calibrator");
+        bCalibrating_ = false;
+    }
+
+
+    // ############################################################
+    // #####                    OIS events                    #####
+    // ##########                                        ##########
+    // ############################################################
+
+    // ###### Key Events ######
+
+    /**
+    @brief
+        Event handler for the keyPressed Event.
+    @param e
+        Event information
+    */
+    bool InputManager::keyPressed(const OIS::KeyEvent &e)
+    {
+        // check whether the key already is in the list (can happen when focus was lost)
+        unsigned int iKey = 0;
+        while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
+            iKey++;
+        if (iKey == keysDown_.size())
+            keysDown_.push_back(Key(e));
+        else
+            return true;
+
+        // update modifiers
+        if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+            keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
+        if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+            keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
+        if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+            keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
+
+        activeStatesTop_[Keyboard]->keyPressed(KeyEvent(e, keyboardModifiers_));
+
+        return true;
+    }
+
+    /**
+    @brief
+        Event handler for the keyReleased Event.
+    @param e
+        Event information
+    */
+    bool InputManager::keyReleased(const OIS::KeyEvent &e)
+    {
+        // remove the key from the keysDown_ list
+        for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
+        {
+            if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
+            {
+                keysDown_.erase(keysDown_.begin() + iKey);
+                break;
+            }
+        }
+
+        // update modifiers
+        if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
+            keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
+        if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
+            keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
+        if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
+            keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
+
+        activeStatesTop_[Keyboard]->keyReleased(KeyEvent(e, keyboardModifiers_));
+
+        return true;
+    }
+
+
+    // ###### Mouse Events ######
+
+    /**
+    @brief
+        Event handler for the mouseMoved Event.
+    @param e
+        Event information
+    */
+    bool InputManager::mouseMoved(const OIS::MouseEvent &e)
+    {
+        // check for actual moved event
+        if (e.state.X.rel != 0 || e.state.Y.rel != 0)
+        {
+            activeStatesTop_[Mouse]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
+                    IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
+        }
+
+        // check for mouse scrolled event
+        if (e.state.Z.rel != 0)
+        {
+            activeStatesTop_[Mouse]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+        }
+
+        return true;
+    }
+
+    /**
+    @brief
+        Event handler for the mousePressed Event.
+    @param e
+        Event information
+    @param id
+        The ID of the mouse button
+    */
+    bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+    {
+        // check whether the button already is in the list (can happen when focus was lost)
+        unsigned int iButton = 0;
+        while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
+            iButton++;
+        if (iButton == mouseButtonsDown_.size())
+            mouseButtonsDown_.push_back((MouseButton::Enum)id);
+
+        activeStatesTop_[Mouse]->mouseButtonPressed((MouseButton::Enum)id);
+
+        return true;
+    }
+
+    /**
+    @brief
+        Event handler for the mouseReleased Event.
+    @param e
+        Event information
+    @param id
+        The ID of the mouse button
+    */
+    bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
+    {
+        // remove the button from the keysDown_ list
+        for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+        {
+            if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
+            {
+                mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
+                break;
+            }
+        }
+
+        activeStatesTop_[Mouse]->mouseButtonReleased((MouseButton::Enum)id);
+
+        return true;
+    }
+
+
+    // ###### Joy Stick Events ######
+
+    /**
+    @brief
+        Returns the joy stick ID (orxonox) according to a OIS::JoyStickEvent
+    */
+    inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg)
+    {
+        // use the device to identify which one called the method
+        OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
+        unsigned int iJoyStick = 0;
+        while (joySticks_[iJoyStick] != joyStick)
+            iJoyStick++;
+        // assert: Unknown joystick fired an event.
+        assert(iJoyStick != joySticksSize_);
+        return iJoyStick;
+    }
+
+    bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // check whether the button already is in the list (can happen when focus was lost)
+        std::vector<JoyStickButton::Enum>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+        unsigned int iButton = 0;
+        while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
+            iButton++;
+        if (iButton == buttonsDown.size())
+            buttonsDown.push_back((JoyStickButton::Enum)button);
+
+        activeStatesTop_[2 + iJoyStick]->joyStickButtonPressed(iJoyStick, (JoyStickButton::Enum)button);
+
+        return true;
+    }
+
+    bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // remove the button from the joyStickButtonsDown_ list
+        std::vector<JoyStickButton::Enum>& buttonsDown = joyStickButtonsDown_[iJoyStick];
+        for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
+        {
+            if (buttonsDown[iButton] == button)
+            {
+                buttonsDown.erase(buttonsDown.begin() + iButton);
+                break;
+            }
+        }
+
+        activeStatesTop_[2 + iJoyStick]->joyStickButtonReleased(iJoyStick, (JoyStickButton::Enum)button);
+
+        return true;
+    }
+
+    /**
+    @brief
+        Calls the states for a particular axis with our enumeration.
+        Used by OIS sliders and OIS axes.
+    */
+    void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
+    {
+        if (bCalibrating_)
+        {
+            if (value > marginalsMax_[axis])
+                marginalsMax_[axis] = value;
+            if (value < marginalsMin_[axis])
+                marginalsMin_[axis] = value;
+        }
+        else
+        {
+            float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
+            if (fValue > 0.0f)
+                fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
+            else
+                fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
+
+            activeStatesTop_[2 + iJoyStick]->joyStickAxisMoved(iJoyStick, axis, fValue);
+        }
+    }
+
+    bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // keep in mind that the first 8 axes are reserved for the sliders
+        _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
+
+        return true;
+    }
+
+    bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
+            _fireAxis(iJoyStick, id * 2, arg.state.mSliders[id].abX);
+        else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
+            _fireAxis(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
+
+        return true;
+    }
+
+    bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
+    {
+        unsigned int iJoyStick = _getJoystick(arg);
+
+        // translate the POV into 8 simple buttons
+
+        int lastState = povStates_[iJoyStick][id];
+        if (lastState & OIS::Pov::North)
+            buttonReleased(arg, 32 + id * 4 + 0);
+        if (lastState & OIS::Pov::South)
+            buttonReleased(arg, 32 + id * 4 + 1);
+        if (lastState & OIS::Pov::East)
+            buttonReleased(arg, 32 + id * 4 + 2);
+        if (lastState & OIS::Pov::West)
+            buttonReleased(arg, 32 + id * 4 + 3);
+
+        povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
+
+        int currentState = povStates_[iJoyStick][id];
+        if (currentState & OIS::Pov::North)
+            buttonPressed(arg, 32 + id * 4 + 0);
+        if (currentState & OIS::Pov::South)
+            buttonPressed(arg, 32 + id * 4 + 1);
+        if (currentState & OIS::Pov::East)
+            buttonPressed(arg, 32 + id * 4 + 2);
+        if (currentState & OIS::Pov::West)
+            buttonPressed(arg, 32 + id * 4 + 3);
+
+        return true;
+    }
+
+
+    // ############################################################
+    // #####         Other Public Interface Methods           #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Adjusts the mouse window metrics.
+        This method has to be called every time the size of the window changes.
+    @param width
+        The new width of the render window
+    @param^height
+        The new height of the render window
+    */
+    void InputManager::setWindowExtents(const int width, const int height)
+    {
+        if (mouse_)
+        {
+            // Set mouse region (if window resizes, we should alter this to reflect as well)
+            mouse_->getMouseState().width  = width;
+            mouse_->getMouseState().height = height;
+        }
+    }
+
+
+    // ###### InputStates ######
+
+    /**
+    @brief
+        Adds a new key handler.
+    @param handler
+        Pointer to the handler object.
+    @param name
+        Unique name of the handler.
+    @param priority
+        Unique integer number. Higher means more prioritised.
+    @return
+        True if added, false if name or priority already existed.
+    */
+    bool InputManager::_configureInputState(InputState* state, const std::string& name, int priority)
+    {
+        if (name == "")
+            return false;
+        if (!state)
+            return false;
+        if (inputStatesByName_.find(name) == inputStatesByName_.end())
+        {
+            if (inputStatesByPriority_.find(priority)
+                == inputStatesByPriority_.end())
+            {
+                inputStatesByName_[name] = state;
+                inputStatesByPriority_[priority] = state;
+                state->setNumOfJoySticks(numberOfJoySticks());
+                state->setName(name);
+                state->setPriority(priority);
+                return true;
+            }
+            else
+            {
+                COUT(2) << "Warning: Could not add an InputState with the same priority '"
+                    << priority << "'." << std::endl;
+                return false;
+            }
+        }
+        else
+        {
+            COUT(2) << "Warning: Could not add an InputState with the same name '" << name << "'." << std::endl;
+            return false;
+        }
+    }
+
+    /**
+    @brief
+        Removes and destroys an input state internally.
+    @param name
+        Name of the handler.
+    @return
+        True if removal was successful, false if name was not found.
+    @remarks
+        You can't remove the internal states "empty", "calibrator" and "detector".
+        The removal process is being postponed if InputManager::tick() is currently running.
+    */
+    bool InputManager::requestDestroyState(const std::string& name)
+    {
+        if (name == "empty" || name == "calibrator" || name == "detector")
+        {
+            COUT(2) << "InputManager: Removing the '" << name << "' state is not allowed!" << std::endl;
+            return false;
+        }
+        std::map<std::string, InputState*>::iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+        {
+            if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
+            {
+                // The state is still active. We have to postpone
+                stateLeaveRequests_.insert(it->second);
+                stateDestroyRequests_.insert(it->second);
+            }
+            else if (this->internalState_ & Ticking)
+            {
+                // cannot remove state while ticking
+                stateDestroyRequests_.insert(it->second);
+            }
+            else
+                _destroyState(it->second);
+
+            return true;
+        }
         return false;
-      }
-
-      if (createKeyboard)
-        _initialiseKeyboard();
-
-      if (createMouse)
-        _initialiseMouse();
-
-      if (createJoySticks)
-        _initialiseJoySticks();
-
-      // Set mouse/joystick region
-      if (mouse_)
-      {
-        setWindowExtents(windowWidth, windowHeight);
-      }
-
-      state_ = IS_NONE;
-      CCOUT(ORX_DEBUG) << "Initialising OIS components done." << std::endl;
-
-      // InputManager holds the input buffer --> create one and add it.
-      buffer_ = new InputBuffer();
-      addKeyHandler(buffer_, "buffer");
-      Shell::getInstance().setInputBuffer(buffer_);
-
-      keyBinder_ = new KeyBinder();
-      keyBinder_->loadBindings();
-      addKeyHandler(keyBinder_, "keybinder");
-      addMouseHandler(keyBinder_, "keybinder");
-      addJoyStickHandler(keyBinder_, "keybinder");
-
-      keyDetector_ = new KeyDetector();
-      keyDetector_->loadBindings();
-      addKeyHandler(keyDetector_, "keydetector");
-      addMouseHandler(keyDetector_, "keydetector");
-      addJoyStickHandler(keyDetector_, "keydetector");
-
-      calibratorCallback_ = new CalibratorCallback();
-      addKeyHandler(calibratorCallback_, "calibratorcallback");
-
-      setConfigValues();
-
-      CCOUT(ORX_DEBUG) << "Initialising complete." << std::endl;
-    }
-    else
-    {
-      CCOUT(ORX_WARNING) << "Warning: OIS compoments already initialised, skipping" << std::endl;
-    }
-    return true;
-  }
-
-  /**
-    @brief Creates a keyboard and sets the event handler.
-    @return False if keyboard stays uninitialised, true otherwise.
-  */
-  bool InputManager::_initialiseKeyboard()
-  {
-    if (keyboard_ != 0)
-    {
-      CCOUT(2) << "Warning: Keyboard already initialised, skipping." << std::endl;
-      return true;
-    }
-    try
-    {
-      if (inputSystem_->getNumberOfDevices(OIS::OISKeyboard) > 0)
-      {
-        keyboard_ = (OIS::Keyboard*)inputSystem_->createInputObject(OIS::OISKeyboard, true);
-        // register our listener in OIS.
-        keyboard_->setEventCallback(this);
-        // note: OIS will not detect keys that have already been down when the keyboard was created.
-        CCOUT(ORX_DEBUG) << "Created OIS keyboard" << std::endl;
-        return true;
-      }
-      else
-      {
-        CCOUT(ORX_WARNING) << "Warning: No keyboard found!" << std::endl;
+    }
+
+    /**
+    @brief
+        Returns the pointer to the requested InputState.
+    @param name
+        Unique name of the state.
+    @return
+        Pointer to the instance, 0 if name was not found.
+    */
+    InputState* InputManager::getState(const std::string& name)
+    {
+        std::map<std::string, InputState*>::iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+            return it->second;
+        else
+            return 0;
+    }
+
+    /**
+    @brief
+        Returns the current input state (there might be others active too!)
+    @return
+        The current highest prioritised active input state.
+    */
+    InputState* InputManager::getCurrentState()
+    {
+        return (*activeStates_.rbegin()).second;
+    }
+
+    /**
+    @brief
+        Activates a specific input state.
+        It might not be really activated if the priority is too low!
+    @param name
+        Unique name of the state.
+    @return
+        False if name was not found, true otherwise.
+    */
+    bool InputManager::requestEnterState(const std::string& name)
+    {
+        // get pointer from the map with all stored handlers
+        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+        {
+            // exists
+            if (activeStates_.find(it->second->getPriority()) == activeStates_.end())
+            {
+                // not active
+                if (stateDestroyRequests_.find(it->second) == stateDestroyRequests_.end())
+                {
+                    // not scheduled for destruction
+                    // set prevents a state being added multiple times
+                    stateEnterRequests_.insert(it->second);
+                    return true;
+                }
+            }
+        }
         return false;
-      }
-    }
-    catch (OIS::Exception ex)
-    {
-      // TODO: Test this output regarding formatting
-      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS keyboard\n"
-          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-      keyboard_ = 0;
-      return false;
-    }
-  }
-
-  /**
-    @brief Creates a mouse and sets the event handler.
-    @return False if mouse stays uninitialised, true otherwise.
-  */
-  bool InputManager::_initialiseMouse()
-  {
-    if (mouse_ != 0)
-    {
-      CCOUT(2) << "Warning: Mouse already initialised, skipping." << std::endl;
-      return true;
-    }
-    try
-    {
-      if (inputSystem_->getNumberOfDevices(OIS::OISMouse) > 0)
-      {
-        mouse_ = static_cast<OIS::Mouse*>(inputSystem_->createInputObject(OIS::OISMouse, true));
-        // register our listener in OIS.
-        mouse_->setEventCallback(this);
-        CCOUT(ORX_DEBUG) << "Created OIS mouse" << std::endl;
-        return true;
-      }
-      else
-      {
-        CCOUT(ORX_WARNING) << "Warning: No mouse found!" << std::endl;
+    }
+
+    /**
+    @brief
+        Deactivates a specific input state.
+    @param name
+        Unique name of the state.
+    @return
+        False if name was not found, true otherwise.
+    */
+    bool InputManager::requestLeaveState(const std::string& name)
+    {
+        // get pointer from the map with all stored handlers
+        std::map<std::string, InputState*>::const_iterator it = inputStatesByName_.find(name);
+        if (it != inputStatesByName_.end())
+        {
+            // exists
+            if (activeStates_.find(it->second->getPriority()) != activeStates_.end())
+            {
+                // active
+                stateLeaveRequests_.insert(it->second);
+                return true;
+            }
+        }
         return false;
-      }
-    }
-    catch (OIS::Exception ex)
-    {
-      CCOUT(ORX_WARNING) << "Warning: Failed to create an OIS mouse\n"
-          << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-      mouse_ = 0;
-      return false;
-    }
-  }
-
-  /**
-    @brief Creates all joy sticks and sets the event handler.
-    @return False joy stick stay uninitialised, true otherwise.
-  */
-  bool InputManager::_initialiseJoySticks()
-  {
-    if (joySticksSize_ > 0)
-    {
-      CCOUT(2) << "Warning: Joy sticks already initialised, skipping." << std::endl;
-      return true;
-    }
-    bool success = false;
-    if (inputSystem_->getNumberOfDevices(OIS::OISJoyStick) > 0)
-    {
-      for (int i = 0; i < inputSystem_->getNumberOfDevices(OIS::OISJoyStick); i++)
-      {
-        try
-        {
-          OIS::JoyStick* stig = static_cast<OIS::JoyStick*>(inputSystem_->createInputObject(OIS::OISJoyStick, true));
-          joySticks_.push_back(stig);
-          // register our listener in OIS.
-          stig->setEventCallback(this);
-          CCOUT(ORX_DEBUG) << "Created OIS joy stick with ID " << stig->getID() << std::endl;
-          success = true;
-        }
-        catch (OIS::Exception ex)
-        {
-          CCOUT(ORX_WARNING) << "Warning: Failed to create OIS joy number" << i << "\n"
-              << "OIS error message: \"" << ex.eText << "\"" << std::endl;
-        }
-      }
-    }
-    else
-    {
-      CCOUT(ORX_WARNING) << "Warning: Joy stick support requested, but no joy stick was found" << std::endl;
-      return false;
-    }
-    joySticksSize_ = joySticks_.size();
-    activeJoyStickHandlers_.resize(joySticksSize_);
-    joyStickButtonsDown_.resize(joySticksSize_);
-    povStates_.resize(joySticksSize_);
-    sliderStates_.resize(joySticksSize_);
-    joySticksCalibration_.resize(joySticksSize_);
-    for (unsigned int iJoyStick = 0; iJoyStick < joySticksSize_; iJoyStick++)
-    {
-      // reset the calibration with default values
-      for (unsigned int i = 0; i < 24; i++)
-      {
-        joySticksCalibration_[iJoyStick].negativeCoeff[i] = 1.0f/32767.0f;
-        joySticksCalibration_[iJoyStick].positiveCoeff[i] = 1.0f/32768.0f;
-        joySticksCalibration_[iJoyStick].zeroStates[i] = 0;
-      }
-    }
-    return success;
-  }
-
-  /**
-    @brief Sets the configurable values. Use keybindings.ini as file..
-  */
-  void InputManager::setConfigValues()
-  {
-    if (joySticksSize_)
-    {
-      std::vector<double> coeffPos;
-      std::vector<double> coeffNeg;
-      std::vector<int> zero;
-      coeffPos.resize(24);
-      coeffNeg.resize(24);
-      zero.resize(24);
-      for (unsigned int i = 0; i < 24; i++)
-      {
-        coeffPos[i] =  1.0f/32767.0f;
-        coeffNeg[i] =  1.0f/32768.0f;
-        zero[i]     =  0;
-      }
-
-      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
-      if (!cont)
-      {
-          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffPos", coeffPos);
-          getIdentifier()->addConfigValueContainer("CoeffPos", cont);
-      }
-      cont->getValue(&coeffPos, this);
-
-      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
-      if (!cont)
-      {
-          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "CoeffNeg", coeffNeg);
-          getIdentifier()->addConfigValueContainer("CoeffNeg", cont);
-      }
-      cont->getValue(&coeffNeg, this);
-
-      cont = getIdentifier()->getConfigValueContainer("Zero");
-      if (!cont)
-      {
-          cont = new ConfigValueContainer(CFT_Keybindings, getIdentifier(), "Zero", zero);
-          getIdentifier()->addConfigValueContainer("Zero", cont);
-      }
-      cont->getValue(&zero, this);
-
-      // copy values to our own variables
-      for (unsigned int i = 0; i < 24; i++)
-      {
-        joySticksCalibration_[0].positiveCoeff[i] = coeffPos[i];
-        joySticksCalibration_[0].negativeCoeff[i] = coeffNeg[i];
-        joySticksCalibration_[0].zeroStates[i]    = zero[i];
-      }
-    }
-  }
-
-  /**
-    @brief Destroys all the created input devices and sets the InputManager to construction state.
-  */
-  void InputManager::_destroy()
-  {
-    if (state_ != IS_UNINIT)
-    {
-      CCOUT(ORX_DEBUG) << "Destroying ..." << std::endl;
-
-      if (buffer_)
-        delete buffer_;
-
-      if (keyBinder_)
-        delete keyBinder_;
-
-      if (keyDetector_)
-        delete keyDetector_;
-
-      if (calibratorCallback_)
-        delete calibratorCallback_;
-
-      keyHandlers_.clear();
-      mouseHandlers_.clear();
-      joyStickHandlers_.clear();
-
-      _destroyKeyboard();
-      _destroyMouse();
-      _destroyJoySticks();
-
-      activeHandlers_.clear();
-
-      // inputSystem_ can never be 0, or else the code is mistaken
-      OIS::InputManager::destroyInputSystem(inputSystem_);
-      inputSystem_ = 0;
-
-      state_ = IS_UNINIT;
-      CCOUT(ORX_DEBUG) << "Destroying done." << std::endl;
-    }
-  }
-
-  /**
-    @brief Destroys the keyboard and sets it to 0.
-  */
-  void InputManager::_destroyKeyboard()
-  {
-    if (keyboard_)
-      // inputSystem_ can never be 0, or else the code is mistaken
-      inputSystem_->destroyInputObject(keyboard_);
-    keyboard_ = 0;
-    activeKeyHandlers_.clear();
-    keysDown_.clear();
-    CCOUT(ORX_DEBUG) << "Keyboard destroyed." << std::endl;
-  }
-
-  /**
-    @brief Destroys the mouse and sets it to 0.
-  */
-  void InputManager::_destroyMouse()
-  {
-    if (mouse_)
-      // inputSystem_ can never be 0, or else the code is mistaken
-      inputSystem_->destroyInputObject(mouse_);
-    mouse_ = 0;
-    activeMouseHandlers_.clear();
-    mouseButtonsDown_.clear();
-    CCOUT(ORX_DEBUG) << "Mouse destroyed." << std::endl;
-  }
-
-  /**
-    @brief Destroys all the joy sticks and resizes the lists to 0.
-  */
-  void InputManager::_destroyJoySticks()
-  {
-    if (joySticksSize_ > 0)
-    {
-      // note: inputSystem_ can never be 0, or else the code is mistaken
-      for (unsigned int i = 0; i < joySticksSize_; i++)
-        if (joySticks_[i] != 0)
-          inputSystem_->destroyInputObject(joySticks_[i]);
-
-      joySticks_.clear();
-      joySticksSize_ = 0;
-      activeJoyStickHandlers_.clear();
-      joyStickButtonsDown_.clear();
-      povStates_.clear();
-      sliderStates_.clear();
-      joySticksCalibration_.clear();
-    }
-    CCOUT(ORX_DEBUG) << "Joy sticks destroyed." << std::endl;
-  }
-
-  void InputManager::_saveState()
-  {
-    savedHandlers_.activeHandlers_ = activeHandlers_;
-    savedHandlers_.activeJoyStickHandlers_ = activeJoyStickHandlers_;
-    savedHandlers_.activeKeyHandlers_ = activeKeyHandlers_;
-    savedHandlers_.activeMouseHandlers_ = activeMouseHandlers_;
-  }
-
-  void InputManager::_restoreState()
-  {
-    activeHandlers_ = savedHandlers_.activeHandlers_;
-    activeJoyStickHandlers_ = savedHandlers_.activeJoyStickHandlers_;
-    activeKeyHandlers_ = savedHandlers_.activeKeyHandlers_;
-    activeMouseHandlers_ = savedHandlers_.activeMouseHandlers_;
-  }
-
-  void InputManager::_updateTickables()
-  {
-    // we can use a map to have a list of unique pointers (an object can implement all 3 handlers)
-    std::map<InputTickable*, HandlerState> tempSet;
-    for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
-      tempSet[activeKeyHandlers_[iHandler]].joyStick = true;
-    for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
-      tempSet[activeMouseHandlers_[iHandler]].mouse = true;
-    for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
-      for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-        tempSet[activeJoyStickHandlers_[iJoyStick][iHandler]].joyStick = true;
-
-    // copy the content of the map back to the actual vector
-    activeHandlers_.clear();
-    for (std::map<InputTickable*, HandlerState>::const_iterator itHandler = tempSet.begin();
-        itHandler != tempSet.end(); itHandler++)
-      activeHandlers_.push_back(std::pair<InputTickable*, HandlerState>((*itHandler).first, (*itHandler).second));
-  }
-
-
-  // #################################
-  // ### Private Interface Methods ###
-  // #################################
-  // #################################
-
-  /**
-    @brief Updates the InputManager. Tick is called by Orxonox.
-    @param dt Delta time
-  */
-  void InputManager::_tick(float dt)
-  {
-    if (state_ == IS_UNINIT)
-      return;
-
-    if (state_ != stateRequest_)
-    {
-      InputState sr = stateRequest_;
-      switch (sr)
-      {
-      case IS_NORMAL:
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-
-        // normal play mode
-        // note: we assume that the handlers exist since otherwise, something's wrong anyway.
-        enableKeyHandler("keybinder");
-        enableMouseHandler("keybinder");
-        enableJoyStickHandler("keybinder", 0);
-        stateRequest_ = IS_NORMAL;
-        state_ = IS_NORMAL;
-        break;
-
-      case IS_GUI:
-        state_ = IS_GUI;
-        break;
-
-      case IS_CONSOLE:
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-
-        enableMouseHandler("keybinder");
-        enableJoyStickHandler("keybinder", 0);
-        enableKeyHandler("buffer");
-        stateRequest_ = IS_CONSOLE;
-        state_ = IS_CONSOLE;
-        break;
-
-      case IS_DETECT:
-        savedState_ = state_;
-        _saveState();
-
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-
-        enableKeyHandler("keydetector");
-        enableMouseHandler("keydetector");
-        enableJoyStickHandler("keydetector", 0);
-
-        stateRequest_ = IS_DETECT;
-        state_ = IS_DETECT;
-        break;
-
-      case IS_NODETECT:
-        _restoreState();
-        keysDown_.clear();
-        mouseButtonsDown_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          joyStickButtonsDown_[i].clear();
-        state_ = IS_NODETECT;
-        stateRequest_ = savedState_;
-        break;
-
-      case IS_CALIBRATE:
-        if (joySticksSize_)
-        {
-          savedState_ = _getSingleton().state_;
-          for (unsigned int i = 0; i < 24; i++)
-          {
-            marginalsMax_[i] = INT_MIN;
-            marginalsMin_[i] = INT_MAX;
-          }
-          COUT(0) << "Move all joy stick axes in all directions a few times. "
-            << "Then put all axes in zero state and hit enter." << std::endl;
-
-          savedState_ = state_;
-          _saveState();
-
-          activeKeyHandlers_.clear();
-          activeMouseHandlers_.clear();
-          for (unsigned int i = 0; i < joySticksSize_; i++)
-            activeJoyStickHandlers_[i].clear();
-
-          enableKeyHandler("calibratorcallback");
-          stateRequest_ = IS_CALIBRATE;
-          state_ = IS_CALIBRATE;
-        }
-        else
-        {
-          COUT(3) << "Connot calibrate, no joy stick found!" << std::endl;
-          stateRequest_ = state_;
-        }
-        break;
-
-      case IS_NOCALIBRATE:
-        _completeCalibration();
-        _restoreState();
-        keyBinder_->resetJoyStickAxes();
-        state_ = IS_NOCALIBRATE;
-        stateRequest_ = savedState_;
-        break;
-
-      case IS_NONE:
-        activeKeyHandlers_.clear();
-        activeMouseHandlers_.clear();
-        for (unsigned int i = 0; i < joySticksSize_; i++)
-          activeJoyStickHandlers_[i].clear();
-        state_ = IS_NONE;
-
-      default:
-        break;
-      }
-    }
-
-    // Capture all the input. This calls the event handlers in InputManager.
-    if (mouse_)
-      mouse_->capture();
-    if (keyboard_)
-      keyboard_->capture();
-    for (unsigned  int i = 0; i < joySticksSize_; i++)
-      joySticks_[i]->capture();
-
-    if (state_ != IS_CALIBRATE)
-    {
-      // call all the handlers for the held key events
-      for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
-        for (unsigned int iHandler = 0; iHandler < activeKeyHandlers_.size(); iHandler++)
-          activeKeyHandlers_[iHandler]->keyHeld(KeyEvent(keysDown_[iKey], keyboardModifiers_));
-
-      // call all the handlers for the held mouse button events
-      for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
-        for (unsigned int iHandler = 0; iHandler < activeMouseHandlers_.size(); iHandler++)
-          activeMouseHandlers_[iHandler]->mouseButtonHeld(mouseButtonsDown_[iButton]);
-
-      // call all the handlers for the held joy stick button events
-      for (unsigned int iJoyStick  = 0; iJoyStick < joySticksSize_; iJoyStick++)
-        for (unsigned int iButton   = 0; iButton   < joyStickButtonsDown_[iJoyStick].size(); iButton++)
-          for (unsigned int iHandler = 0; iHandler  < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-            activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonHeld(iJoyStick, joyStickButtonsDown_[iJoyStick][iButton]);
-    }
-
-    // call the ticks for the handlers (need to be treated specially)
-    for (unsigned int iHandler = 0; iHandler < activeHandlers_.size(); iHandler++)
-      activeHandlers_[iHandler].first->tickInput(dt, activeHandlers_[iHandler].second);
-  }
-
-  void InputManager::_completeCalibration()
-  {
-    for (unsigned int i = 0; i < 24; i++)
-    {
-      // positive coefficient
-      if (marginalsMax_[i] == INT_MIN)
-        marginalsMax_[i] =  32767;
-      // coefficients
-      if (marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i])
-        joySticksCalibration_[0].positiveCoeff[i] =  1.0f/(marginalsMax_[i] - joySticksCalibration_[0].zeroStates[i]);
-      else
-        joySticksCalibration_[0].positiveCoeff[i] =  1.0f;
-
-      // config value
-      ConfigValueContainer* cont = getIdentifier()->getConfigValueContainer("CoeffPos");
-      assert(cont);
-      cont->set(i, joySticksCalibration_[0].positiveCoeff[i]);
-
-      // negative coefficient
-      if (marginalsMin_[i] == INT_MAX)
-        marginalsMin_[i] = -32768;
-      // coefficients
-      if (marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i])
-        joySticksCalibration_[0].negativeCoeff[i] = -1.0f/(marginalsMin_[i] - joySticksCalibration_[0].zeroStates[i]);
-      else
-        joySticksCalibration_[0].negativeCoeff[i] =  1.0f;
-      // config value
-      cont = getIdentifier()->getConfigValueContainer("CoeffNeg");
-      assert(cont);
-      cont->set(i, joySticksCalibration_[0].negativeCoeff[i]);
-
-      // zero states
-      if (i < 8)
-      {
-        if (!(i & 1))
-          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abX;
-        else
-          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mSliders[i/2].abY;
-      }
-      else
-      {
-        if (i - 8 < joySticks_[0]->getJoyStickState().mAxes.size())
-          joySticksCalibration_[0].zeroStates[i] = joySticks_[0]->getJoyStickState().mAxes[i - 8].abs;
-        else
-          joySticksCalibration_[0].zeroStates[i] = 0;
-      }
-      // config value
-      cont = getIdentifier()->getConfigValueContainer("Zero");
-      assert(cont);
-      cont->set(i, joySticksCalibration_[0].zeroStates[i]);
-    }
-  }
-
-  // ###### Key Events ######
-
-  /**
-    @brief Event handler for the keyPressed Event.
-    @param e Event information
-  */
-  bool InputManager::keyPressed(const OIS::KeyEvent &e)
-  {
-    // check whether the key already is in the list (can happen when focus was lost)
-    unsigned int iKey = 0;
-    while (iKey < keysDown_.size() && keysDown_[iKey].key != (KeyCode::Enum)e.key)
-      iKey++;
-    if (iKey == keysDown_.size())
-      keysDown_.push_back(Key(e));
-    else
-      return true;
-
-    // update modifiers
-    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
-      keyboardModifiers_ |= KeyboardModifier::Alt;   // alt key
-    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
-      keyboardModifiers_ |= KeyboardModifier::Ctrl;  // ctrl key
-    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
-      keyboardModifiers_ |= KeyboardModifier::Shift; // shift key
-
-    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-      activeKeyHandlers_[i]->keyPressed(KeyEvent(e, keyboardModifiers_));
-
-    return true;
-  }
-
-  /**
-    @brief Event handler for the keyReleased Event.
-    @param e Event information
-  */
-  bool InputManager::keyReleased(const OIS::KeyEvent &e)
-  {
-    // remove the key from the keysDown_ list
-    for (unsigned int iKey = 0; iKey < keysDown_.size(); iKey++)
-    {
-      if (keysDown_[iKey].key == (KeyCode::Enum)e.key)
-      {
-        keysDown_.erase(keysDown_.begin() + iKey);
-        break;
-      }
-    }
-
-    // update modifiers
-    if(e.key == OIS::KC_RMENU    || e.key == OIS::KC_LMENU)
-      keyboardModifiers_ &= ~KeyboardModifier::Alt;   // alt key
-    if(e.key == OIS::KC_RCONTROL || e.key == OIS::KC_LCONTROL)
-      keyboardModifiers_ &= ~KeyboardModifier::Ctrl;  // ctrl key
-    if(e.key == OIS::KC_RSHIFT   || e.key == OIS::KC_LSHIFT)
-      keyboardModifiers_ &= ~KeyboardModifier::Shift; // shift key
-
-    for (unsigned int i = 0; i < activeKeyHandlers_.size(); i++)
-      activeKeyHandlers_[i]->keyReleased(KeyEvent(e, keyboardModifiers_));
-
-    return true;
-  }
-
-
-  // ###### Mouse Events ######
-
-  /**
-    @brief Event handler for the mouseMoved Event.
-    @param e Event information
-  */
-  bool InputManager::mouseMoved(const OIS::MouseEvent &e)
-  {
-    // check for actual moved event
-    if (e.state.X.rel != 0 || e.state.Y.rel != 0)
-    {
-      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-        activeMouseHandlers_[i]->mouseMoved(IntVector2(e.state.X.abs, e.state.Y.abs),
-            IntVector2(e.state.X.rel, e.state.Y.rel), IntVector2(e.state.width, e.state.height));
-    }
-
-    // check for mouse scrolled event
-    if (e.state.Z.rel != 0)
-    {
-      for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-        activeMouseHandlers_[i]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
-    }
-
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mousePressed Event.
-    @param e Event information
-    @param id The ID of the mouse button
-  */
-  bool InputManager::mousePressed(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // check whether the button already is in the list (can happen when focus was lost)
-    unsigned int iButton = 0;
-    while (iButton < mouseButtonsDown_.size() && mouseButtonsDown_[iButton] != (MouseButton::Enum)id)
-      iButton++;
-    if (iButton == mouseButtonsDown_.size())
-      mouseButtonsDown_.push_back((MouseButton::Enum)id);
-
-    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mouseButtonPressed((MouseButton::Enum)id);
-
-    return true;
-  }
-
-  /**
-    @brief Event handler for the mouseReleased Event.
-    @param e Event information
-    @param id The ID of the mouse button
-  */
-  bool InputManager::mouseReleased(const OIS::MouseEvent &e, OIS::MouseButtonID id)
-  {
-    // remove the button from the keysDown_ list
-    for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
-    {
-      if (mouseButtonsDown_[iButton] == (MouseButton::Enum)id)
-      {
-        mouseButtonsDown_.erase(mouseButtonsDown_.begin() + iButton);
-        break;
-      }
-    }
-
-    for (unsigned int i = 0; i < activeMouseHandlers_.size(); i++)
-      activeMouseHandlers_[i]->mouseButtonReleased((MouseButton::Enum)id);
-
-    return true;
-  }
-
-
-  // ###### Joy Stick Events ######
-
-  inline unsigned int InputManager::_getJoystick(const OIS::JoyStickEvent& arg)
-  {
-    // use the device to identify which one called the method
-    OIS::JoyStick* joyStick = (OIS::JoyStick*)arg.device;
-    unsigned int iJoyStick = 0;
-    while (joySticks_[iJoyStick] != joyStick)
-    {
-      iJoyStick++;
-      if (iJoyStick == joySticksSize_)
-      {
-        CCOUT(3) << "Unknown joystick fired an event. This means there is a bug somewhere! Aborting." << std::endl;
-        abort();
-      }
-    }
-    return iJoyStick;
-  }
-
-  bool InputManager::buttonPressed(const OIS::JoyStickEvent &arg, int button)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // check whether the button already is in the list (can happen when focus was lost)
-    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
-    unsigned int iButton = 0;
-    while (iButton < buttonsDown.size() && buttonsDown[iButton] != button)
-      iButton++;
-    if (iButton == buttonsDown.size())
-      buttonsDown.push_back(button);
-
-    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonPressed(iJoyStick, button);
-
-    return true;
-  }
-
-  bool InputManager::buttonReleased(const OIS::JoyStickEvent &arg, int button)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // remove the button from the joyStickButtonsDown_ list
-    std::vector<int>& buttonsDown = joyStickButtonsDown_[iJoyStick];
-    for (unsigned int iButton = 0; iButton < buttonsDown.size(); iButton++)
-    {
-      if (buttonsDown[iButton] == button)
-      {
-        buttonsDown.erase(buttonsDown.begin() + iButton);
-        break;
-      }
-    }
-
-    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickButtonReleased(iJoyStick, button);
-
-    return true;
-  }
-
-  void InputManager::_fireAxis(unsigned int iJoyStick, int axis, int value)
-  {
-    if (state_ == IS_CALIBRATE)
-    {
-      if (value > marginalsMax_[axis])
-        marginalsMax_[axis] = value;
-      if (value < marginalsMin_[axis])
-        marginalsMin_[axis] = value;
-    }
-    else
-    {
-      float fValue = value - joySticksCalibration_[iJoyStick].zeroStates[axis];
-      if (fValue > 0.0f)
-        fValue *= joySticksCalibration_[iJoyStick].positiveCoeff[axis];
-      else
-        fValue *= joySticksCalibration_[iJoyStick].negativeCoeff[axis];
-
-      for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-        activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickAxisMoved(iJoyStick, axis, fValue);
-    }
-  }
-
-  bool InputManager::axisMoved(const OIS::JoyStickEvent &arg, int axis)
-  {
-    //if (arg.state.mAxes[axis].abs > 10000 || arg.state.mAxes[axis].abs < -10000)
-    //{ CCOUT(3) << "axis " << axis << " moved" << arg.state.mAxes[axis].abs << std::endl;}
-
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // keep in mind that the first 8 axes are reserved for the sliders
-    _fireAxis(iJoyStick, axis + 8, arg.state.mAxes[axis].abs);
-
-    return true;
-  }
-
-  bool InputManager::sliderMoved(const OIS::JoyStickEvent &arg, int id)
-  {
-    //if (arg.state.mSliders[id].abX > 10000 || arg.state.mSliders[id].abX < -10000)
-    //{CCOUT(3) << "slider " << id << " moved" << arg.state.mSliders[id].abX << std::endl;}
-    //CCOUT(3) << arg.state.mSliders[id].abX << "\t |" << arg.state.mSliders[id].abY << std::endl;
-
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    if (sliderStates_[iJoyStick].sliderStates[id].x != arg.state.mSliders[id].abX)
-      _fireAxis(iJoyStick, id * 2, arg.state.mSliders[id].abX);
-    else if (sliderStates_[iJoyStick].sliderStates[id].y != arg.state.mSliders[id].abY)
-      _fireAxis(iJoyStick, id * 2 + 1, arg.state.mSliders[id].abY);
-
-    return true;
-  }
-
-  bool InputManager::povMoved(const OIS::JoyStickEvent &arg, int id)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    // translate the POV into 8 simple buttons
-    int lastState = povStates_[iJoyStick][id];
-    if (lastState & OIS::Pov::North)
-      buttonReleased(arg, 32 + id * 4 + 0);
-    if (lastState & OIS::Pov::South)
-      buttonReleased(arg, 32 + id * 4 + 1);
-    if (lastState & OIS::Pov::East)
-      buttonReleased(arg, 32 + id * 4 + 2);
-    if (lastState & OIS::Pov::West)
-      buttonReleased(arg, 32 + id * 4 + 3);
-
-    povStates_[iJoyStick].povStates[id] = arg.state.mPOV[id].direction;
-
-    int currentState = povStates_[iJoyStick][id];
-    if (currentState & OIS::Pov::North)
-      buttonPressed(arg, 32 + id * 4 + 0);
-    if (currentState & OIS::Pov::South)
-      buttonPressed(arg, 32 + id * 4 + 1);
-    if (currentState & OIS::Pov::East)
-      buttonPressed(arg, 32 + id * 4 + 2);
-    if (currentState & OIS::Pov::West)
-      buttonPressed(arg, 32 + id * 4 + 3);
-
-    return true;
-  }
-
-  /*bool InputManager::vector3Moved(const OIS::JoyStickEvent &arg, int id)
-  {
-    unsigned int iJoyStick = _getJoystick(arg);
-
-    for (unsigned int iHandler = 0; iHandler < activeJoyStickHandlers_[iJoyStick].size(); iHandler++)
-      activeJoyStickHandlers_[iJoyStick][iHandler]->joyStickVector3Moved(JoyStickState(arg.state, iJoyStick), id);
-
-    return true;
-  }*/
-
-
-  // ################################
-  // ### Static Interface Methods ###
-  // ################################
-  // ################################
-
-  std::string InputManager::bindingCommmandString_s = "";
-
-  bool InputManager::initialise(const size_t windowHnd, int windowWidth, int windowHeight,
-    bool createKeyboard, bool createMouse, bool createJoySticks)
-  {
-    return _getSingleton()._initialise(windowHnd, windowWidth, windowHeight,
-          createKeyboard, createMouse, createJoySticks);
-  }
-
-  bool InputManager::initialiseKeyboard()
-  {
-    return _getSingleton()._initialiseKeyboard();
-  }
-
-  bool InputManager::initialiseMouse()
-  {
-    return _getSingleton()._initialiseMouse();
-  }
-
-  bool InputManager::initialiseJoySticks()
-  {
-    return _getSingleton()._initialiseJoySticks();
-  }
-
-  int InputManager::numberOfKeyboards()
-  {
-    if (_getSingleton().keyboard_ != 0)
-      return 1;
-    else
-      return 0;
-  }
-
-  int InputManager::numberOfMice()
-  {
-    if (_getSingleton().mouse_ != 0)
-      return 1;
-    else
-      return 0;
-  }
-
-  int InputManager::numberOfJoySticks()
-  {
-    return _getSingleton().joySticksSize_;
-  }
-
-  /*bool InputManager::isKeyDown(KeyCode::Enum key)
-  {
-    if (_getSingleton().keyboard_)
-      return _getSingleton().keyboard_->isKeyDown((OIS::KeyCode)key);
-    else
-      return false;
-  }*/
-
-  /*bool InputManager::isModifierDown(KeyboardModifier::Enum modifier)
-  {
-    if (_getSingleton().keyboard_)
-      return isModifierDown(modifier);
-    else
-      return false;
-  }*/
-
-  /*const MouseState InputManager::getMouseState()
-  {
-    if (_getSingleton().mouse_)
-      return _getSingleton().mouse_->getMouseState();
-    else
-      return MouseState();
-  }*/
-
-  /*const JoyStickState InputManager::getJoyStickState(unsigned int ID)
-  {
-    if (ID < _getSingleton().joySticksSize_)
-      return JoyStickState(_getSingleton().joySticks_[ID]->getJoyStickState(), ID);
-    else
-      return JoyStickState();
-  }*/
-
-  void InputManager::destroy()
-  {
-    _getSingleton()._destroy();
-  }
-
-  void InputManager::destroyKeyboard()
-  {
-    return _getSingleton()._destroyKeyboard();
-  }
-
-  void InputManager::destroyMouse()
-  {
-    return _getSingleton()._destroyMouse();
-  }
-
-  void InputManager::destroyJoySticks()
-  {
-    return _getSingleton()._destroyJoySticks();
-  }
-
-
-  /**
-    @brief Adjusts the mouse window metrics.
-    This method has to be called every time the size of the window changes.
-    @param width The new width of the render window
-    @param height the new height of the render window
-  */
-  void InputManager::setWindowExtents(const int width, const int height)
-  {
-    if (_getSingleton().mouse_)
-    {
-      // Set mouse region (if window resizes, we should alter this to reflect as well)
-      const OIS::MouseState &mouseState = _getSingleton().mouse_->getMouseState();
-      mouseState.width  = width;
-      mouseState.height = height;
-    }
-  }
-
-  /**
-    @brief Sets the input mode to either GUI, inGame or Buffer
-    @param mode The new input mode
-    @remark Only has an affect if the mode actually changes
-  */
-  void InputManager::setInputState(const InputState state)
-  {
-    _getSingleton().stateRequest_ = state;
-  }
-
-  /**
-    @brief Returns the current input handling method
-    @return The current input mode.
-  */
-  InputManager::InputState InputManager::getInputState()
-  {
-    return _getSingleton().state_;
-  }
-
-  void InputManager::storeKeyStroke(const std::string& name)
-  {
-    setInputState(IS_NODETECT);
-    COUT(0) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl;
-    CommandExecutor::execute("config KeyBinder " + name + " " + bindingCommmandString_s, false);
-  }
-
-  void InputManager::keyBind(const std::string& command)
-  {
-    bindingCommmandString_s = command;
-    setInputState(IS_DETECT);
-    COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
-  }
-
-  void InputManager::calibrate()
-  {
-    _getSingleton().setInputState(IS_CALIBRATE);
-  }
-
-  void InputManager::tick(float dt)
-  {
-    _getSingleton()._tick(dt);
-  }
-
-  // ###### KeyHandler ######
-
-  /**
-    @brief Adds a new key handler.
-    @param handler Pointer to the handler object.
-    @param name Unique name of the handler.
-    @return True if added, false if name already existed.
-  */
-  bool InputManager::addKeyHandler(KeyHandler* handler, const std::string& name)
-  {
-    if (!handler)
-      return false;
-    if (_getSingleton().keyHandlers_.find(name) == _getSingleton().keyHandlers_.end())
-    {
-      _getSingleton().keyHandlers_[name] = handler;
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Removes a Key handler from the list.
-    @param name Unique name of the handler.
-    @return True if removal was successful, false if name was not found.
-  */
-  bool InputManager::removeKeyHandler(const std::string &name)
-  {
-    disableKeyHandler(name);
-    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
-    if (it != _getSingleton().keyHandlers_.end())
-    {
-      _getSingleton().keyHandlers_.erase(it);
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Returns the pointer to a handler.
-    @param name Unique name of the handler.
-    @return Pointer to the instance, 0 if name was not found.
-  */
-  KeyHandler* InputManager::getKeyHandler(const std::string& name)
-  {
-    std::map<std::string, KeyHandler*>::iterator it = _getSingleton().keyHandlers_.find(name);
-    if (it != _getSingleton().keyHandlers_.end())
-    {
-      return (*it).second;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    @brief Enables a specific key handler that has already been added.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::enableKeyHandler(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
-    if (mapIt == _getSingleton().keyHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
-          it != _getSingleton().activeKeyHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        return true;
-      }
-    }
-    _getSingleton().activeKeyHandlers_.push_back((*mapIt).second);
-    _getSingleton().stateRequest_ = IS_CUSTOM;
-    _getSingleton()._updateTickables();
-    return true;
-  }
-
-  /**
-    @brief Disables a specific key handler.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::disableKeyHandler(const std::string &name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
-    if (mapIt == _getSingleton().keyHandlers_.end())
-      return false;
-    // look for the handler in the list
-    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
-          it != _getSingleton().activeKeyHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        _getSingleton().activeKeyHandlers_.erase(it);
-        _getSingleton().stateRequest_ = IS_CUSTOM;
-        _getSingleton()._updateTickables();
-        return true;
-      }
-    }
-    return true;
-  }
-
-  /**
-    @brief Checks whether a key handler is active
-    @param name Unique name of the handler.
-    @return False if key handler is not active or doesn't exist, true otherwise.
-  */
-  bool InputManager::isKeyHandlerActive(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, KeyHandler*>::const_iterator mapIt = _getSingleton().keyHandlers_.find(name);
-    if (mapIt == _getSingleton().keyHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<KeyHandler*>::iterator it = _getSingleton().activeKeyHandlers_.begin();
-          it != _getSingleton().activeKeyHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-        return true;
-    }
-    return false;
-  }
-
-
-  // ###### MouseHandler ######
-  /**
-    @brief Adds a new mouse handler.
-    @param handler Pointer to the handler object.
-    @param name Unique name of the handler.
-    @return True if added, false if name already existed.
-  */
-  bool InputManager::addMouseHandler(MouseHandler* handler, const std::string& name)
-  {
-    if (!handler)
-      return false;
-    if (_getSingleton().mouseHandlers_.find(name) == _getSingleton().mouseHandlers_.end())
-    {
-      _getSingleton().mouseHandlers_[name] = handler;
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Removes a Mouse handler from the list.
-    @param name Unique name of the handler.
-    @return True if removal was successful, false if name was not found.
-  */
-  bool InputManager::removeMouseHandler(const std::string &name)
-  {
-    disableMouseHandler(name);
-    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
-    if (it != _getSingleton().mouseHandlers_.end())
-    {
-      _getSingleton().mouseHandlers_.erase(it);
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Returns the pointer to a handler.
-    @param name Unique name of the handler.
-    @return Pointer to the instance, 0 if name was not found.
-  */
-  MouseHandler* InputManager::getMouseHandler(const std::string& name)
-  {
-    std::map<std::string, MouseHandler*>::iterator it = _getSingleton().mouseHandlers_.find(name);
-    if (it != _getSingleton().mouseHandlers_.end())
-    {
-      return (*it).second;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    @brief Enables a specific mouse handler that has already been added.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::enableMouseHandler(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
-    if (mapIt == _getSingleton().mouseHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
-          it != _getSingleton().activeMouseHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        return true;
-      }
-    }
-    _getSingleton().activeMouseHandlers_.push_back((*mapIt).second);
-    _getSingleton().stateRequest_ = IS_CUSTOM;
-    _getSingleton()._updateTickables();
-    return true;
-  }
-
-  /**
-    @brief Disables a specific mouse handler.
-    @param name Unique name of the handler.
-    @return False if name was not found, true otherwise.
-  */
-  bool InputManager::disableMouseHandler(const std::string &name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
-    if (mapIt == _getSingleton().mouseHandlers_.end())
-      return false;
-    // look for the handler in the list
-    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
-          it != _getSingleton().activeMouseHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-      {
-        _getSingleton().activeMouseHandlers_.erase(it);
-        _getSingleton().stateRequest_ = IS_CUSTOM;
-        _getSingleton()._updateTickables();
-        return true;
-      }
-    }
-    return true;
-  }
-
-  /**
-    @brief Checks whether a mouse handler is active
-    @param name Unique name of the handler.
-    @return False if key handler is not active or doesn't exist, true otherwise.
-  */
-  bool InputManager::isMouseHandlerActive(const std::string& name)
-  {
-    // get pointer from the map with all stored handlers
-    std::map<std::string, MouseHandler*>::const_iterator mapIt = _getSingleton().mouseHandlers_.find(name);
-    if (mapIt == _getSingleton().mouseHandlers_.end())
-      return false;
-    // see whether the handler already is in the list
-    for (std::vector<MouseHandler*>::iterator it = _getSingleton().activeMouseHandlers_.begin();
-          it != _getSingleton().activeMouseHandlers_.end(); it++)
-    {
-      if ((*it) == (*mapIt).second)
-        return true;
-    }
-    return false;
-  }
-
-
-  // ###### JoyStickHandler ######
-
-  /**
-    @brief Adds a new joy stick handler.
-    @param handler Pointer to the handler object.
-    @param name Unique name of the handler.
-    @return True if added, false if name already existed.
-  */
-  bool InputManager::addJoyStickHandler(JoyStickHandler* handler, const std::string& name)
-  {
-    if (!handler)
-      return false;
-    if (_getSingleton().joyStickHandlers_.find(name) == _getSingleton().joyStickHandlers_.end())
-    {
-      _getSingleton().joyStickHandlers_[name] = handler;
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Removes a JoyStick handler from the list.
-    @param name Unique name of the handler.
-    @return True if removal was successful, false if name was not found.
-  */
-  bool InputManager::removeJoyStickHandler(const std::string &name)
-  {
-    for (std::vector<OIS::JoyStick*>::iterator itstick = _getSingleton().joySticks_.begin();
-          itstick != _getSingleton().joySticks_.end(); itstick++)
-      disableJoyStickHandler(name, itstick - _getSingleton().joySticks_.begin());
-
-    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
-    if (it != _getSingleton().joyStickHandlers_.end())
-    {
-      _getSingleton().joyStickHandlers_.erase(it);
-      return true;
-    }
-    else
-      return false;
-  }
-
-  /**
-    @brief Returns the pointer to a handler.
-    @param name Unique name of the handler.
-    @return Pointer to the instance, 0 if name was not found.
-  */
-  JoyStickHandler* InputManager::getJoyStickHandler(const std::string& name)
-  {
-    std::map<std::string, JoyStickHandler*>::iterator it = _getSingleton().joyStickHandlers_.find(name);
-    if (it != _getSingleton().joyStickHandlers_.end())
-    {
-      return (*it).second;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    @brief Enables a specific joy stick handler that has already been added.
-    @param name Unique name of the handler.
-    @return False if name or id was not found, true otherwise.
-  */
-  bool InputManager::enableJoyStickHandler(const std::string& name, unsigned int ID)
-  {
-    // get handler pointer from the map with all stored handlers
-    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
-    if (handlerIt == _getSingleton().joyStickHandlers_.end())
-      return false;
-
-    // check for existence of the ID
-    if (ID >= _getSingleton().joySticksSize_)
-      return false;
-
-    // see whether the handler already is in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
-          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
-    {
-      if ((*it) == (*handlerIt).second)
-      {
-        return true;
-      }
-    }
-    _getSingleton().activeJoyStickHandlers_[ID].push_back((*handlerIt).second);
-    _getSingleton().stateRequest_ = IS_CUSTOM;
-    _getSingleton()._updateTickables();
-    return true;
-  }
-
-  /**
-    @brief Disables a specific joy stick handler.
-    @param name Unique name of the handler.
-    @return False if name or id was not found, true otherwise.
-  */
-  bool InputManager::disableJoyStickHandler(const std::string &name, unsigned int ID)
-  {
-    // get handler pointer from the map with all stored handlers
-    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
-    if (handlerIt == _getSingleton().joyStickHandlers_.end())
-      return false;
-
-    // check for existence of the ID
-    if (ID >= _getSingleton().joySticksSize_)
-      return false;
-
-    // look for the handler in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
-          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
-    {
-      if ((*it) == (*handlerIt).second)
-      {
-        _getSingleton().activeJoyStickHandlers_[ID].erase(it);
-        _getSingleton().stateRequest_ = IS_CUSTOM;
-        _getSingleton()._updateTickables();
-        return true;
-      }
-    }
-    return true;
-  }
-
-  /**
-    @brief Checks whether a joy stick handler is active
-    @param name Unique name of the handler.
-    @return False if key handler is not active or doesn't exist, true otherwise.
-  */
-  bool InputManager::isJoyStickHandlerActive(const std::string& name, unsigned int ID)
-  {
-    // get handler pointer from the map with all stored handlers
-    std::map<std::string, JoyStickHandler*>::const_iterator handlerIt = _getSingleton().joyStickHandlers_.find(name);
-    if (handlerIt == _getSingleton().joyStickHandlers_.end())
-      return false;
-
-    // check for existence of the ID
-    if (ID >= _getSingleton().joySticksSize_)
-      return false;
-
-    // see whether the handler already is in the list
-    for (std::vector<JoyStickHandler*>::iterator it = _getSingleton().activeJoyStickHandlers_[ID].begin();
-          it != _getSingleton().activeJoyStickHandlers_[ID].end(); it++)
-    {
-      if ((*it) == (*handlerIt).second)
-        return true;
-    }
-    return false;
-  }
-
+    }
+
+
+    // ############################################################
+    // #####                Console Commands                  #####
+    // ##########                                        ##########
+    // ############################################################
+
+    /**
+    @brief
+        Method for easily storing a string with the command executor. It is used by the
+        KeyDetector to get assign commands. The KeyDetector simply executes
+        the command 'storeKeyStroke myName' for each button/axis.
+    @remarks
+        This is only a temporary hack until we thourouhgly support multiple KeyBinders.
+    @param name
+        The name of the button/axis.
+    */
+    void InputManager::storeKeyStroke(const std::string& name)
+    {
+        getInstance().requestLeaveState("detector");
+        COUT(0) << "Binding string \"" << bindingCommmandString_s << "\" on key '" << name << "'" << std::endl;
+        CommandExecutor::execute("config KeyBinder " + name + " " + bindingCommmandString_s, false);
+    }
+
+    /**
+    @brief
+        Assigns a command string to a key/button/axis. The name is determined via KeyDetector
+        and InputManager::storeKeyStroke(.).
+    @param command
+        Command string that can be executed by the CommandExecutor
+    */
+    void InputManager::keyBind(const std::string& command)
+    {
+        bindingCommmandString_s = command;
+        getInstance().requestEnterState("detector");
+        COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
+    }
+
+    /**
+    @brief
+        Starts joy stick calibration.
+    */
+    void InputManager::calibrate()
+    {
+        getInstance().bCalibrating_ = true;
+        getInstance().requestEnterState("calibrator");
+    }
+
+    /**
+    @brief
+        Reloads the input system
+    */
+    void InputManager::reload(bool joyStickSupport)
+    {
+        getInstance().reloadInputSystem(joyStickSupport);
+    }
 }
Index: code/trunk/src/core/input/InputManager.h
===================================================================
--- code/trunk/src/core/input/InputManager.h	(revision 1754)
+++ code/trunk/src/core/input/InputManager.h	(revision 1755)
@@ -28,8 +28,9 @@
 
 /**
- @file
- @brief Implementation of a little Input handler that distributes everything
-        coming from OIS.
- */
+@file
+@brief
+    Implementation of a little Input handler that distributes everything
+    coming from OIS.
+*/
 
 #ifndef _InputManager_H__
@@ -40,5 +41,5 @@
 #include <map>
 #include <vector>
-
+#include <stack>
 #include "util/Math.h"
 #include "core/OrxonoxClass.h"
@@ -47,214 +48,188 @@
 namespace orxonox
 {
-  /**
-  * Helper class to realise a vector<int[4]>
-  */
-  class POVStates
-  {
-  public:
-    int operator[](unsigned int index) { return povStates[index]; }
-    int povStates[4];
-  };
-
-  /**
-  * Helper class to realise a vector< {int[4], int[4]} >
-  */
-  class SliderStates
-  {
-  public:
-    IntVector2 sliderStates[4];
-  };
-
-  /**
-  * Struct for storing a custom input state
-  */
-  struct StoredState
-  {
-    std::vector<KeyHandler*>                    activeKeyHandlers_;
-    std::vector<MouseHandler*>                  activeMouseHandlers_;
-    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
-    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
-  };
-
-  struct JoyStickCalibration
-  {
-    int zeroStates[24];
-    float positiveCoeff[24];
-    float negativeCoeff[24];
-  };
-
-  /**
-    @brief Captures and distributes mouse and keyboard input.
-  */
-  class _CoreExport InputManager
+    /**
+    @brief
+        Helper class to realise a vector<int[4]>
+    */
+    class POVStates
+    {
+    public:
+        int& operator[](unsigned int index) { return povStates[index]; }
+        int povStates[4];
+    };
+
+    /**
+    @brief
+        Helper class to realise a vector< {int[4], int[4]} >
+    */
+    class SliderStates
+    {
+    public:
+        IntVector2 sliderStates[4];
+    };
+
+    struct JoyStickCalibration
+    {
+        int zeroStates[24];
+        float positiveCoeff[24];
+        float negativeCoeff[24];
+    };
+
+    /**
+    @brief
+        Captures and distributes mouse and keyboard input.
+    */
+    class _CoreExport InputManager
         : public OrxonoxClass,
-          public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
-  {
-  public: // enumerations
-    /**
-      @brief Designates the way input is handled and redirected.
-    */
-    enum InputState
-    {
-      IS_UNINIT,    //!< InputManager has not yet been initialised.
-      IS_NONE,      //!< Input is discarded.
-      IS_NORMAL,    //!< Normal play state. Key and button bindings are active.
-      IS_GUI,       //!< All OIS input events are passed to CEGUI.
-      IS_CONSOLE,   //!< Keyboard input is redirected to the InputBuffer.
-      IS_DETECT,    //!< All the input additionally goes to the KeyDetector
-      IS_NODETECT,  //!< remove KeyDetector
-      IS_NOCALIBRATE,
-      IS_CALIBRATE,
-      IS_CUSTOM     //!< Any possible configuration.
-    };
-
-  public: // member functions
-    void setConfigValues();
-
-  public: // static functions
-    static bool initialise(const size_t windowHnd, int windowWidth, int windowHeight,
-          bool createKeyboard = true, bool createMouse = true, bool createJoySticks = false);
-    static bool initialiseKeyboard();
-    static bool initialiseMouse();
-    static bool initialiseJoySticks();
-    static int  numberOfKeyboards();
-    static int  numberOfMice();
-    static int  numberOfJoySticks();
-
-    static void destroy();
-    static void destroyKeyboard();
-    static void destroyMouse();
-    static void destroyJoySticks();
-
-    //static bool isModifierDown(KeyboardModifier::Enum modifier);
-    //static bool isKeyDown(KeyCode::Enum key);
-    //static const MouseState getMouseState();
-    //static const JoyStickState getJoyStickState(unsigned int ID);
-
-    static void setWindowExtents(const int width, const int height);
-
-    static void setInputState(const InputState state);
-    static InputState getInputState();
-
-    static void storeKeyStroke(const std::string& name);
-    static void keyBind(const std::string& command);
-
-    static void calibrate();
-
-    static void tick(float dt);
-
-    static bool addKeyHandler                 (KeyHandler* handler, const std::string& name);
-    static bool removeKeyHandler              (const std::string& name);
-    static KeyHandler* getKeyHandler          (const std::string& name);
-    static bool enableKeyHandler              (const std::string& name);
-    static bool disableKeyHandler             (const std::string& name);
-    static bool isKeyHandlerActive            (const std::string& name);
-
-    static bool addMouseHandler               (MouseHandler* handler, const std::string& name);
-    static bool removeMouseHandler            (const std::string& name);
-    static MouseHandler* getMouseHandler      (const std::string& name);
-    static bool enableMouseHandler            (const std::string& name);
-    static bool disableMouseHandler           (const std::string& name);
-    static bool isMouseHandlerActive          (const std::string& name);
-
-    static bool addJoyStickHandler            (JoyStickHandler* handler, const std::string& name);
-    static bool removeJoyStickHandler         (const std::string& name);
-    static JoyStickHandler* getJoyStickHandler(const std::string& name);
-    static bool enableJoyStickHandler         (const std::string& name, unsigned int id);
-    static bool disableJoyStickHandler        (const std::string& name, unsigned int id);
-    static bool isJoyStickHandlerActive       (const std::string& name, unsigned int id);
-
-  private: // functions
-    // don't mess with a Singleton
-    InputManager ();
-    InputManager (const InputManager&);
-    ~InputManager();
-
-    // Intenal methods
-    bool _initialise(const size_t, int, int, bool, bool, bool);
-    bool _initialiseKeyboard();
-    bool _initialiseMouse();
-    bool _initialiseJoySticks();
-
-    void _destroy();
-    void _destroyKeyboard();
-    void _destroyMouse();
-    void _destroyJoySticks();
-
-    void _updateTickables();
-
-    void _saveState();
-    void _restoreState();
-
-    void _completeCalibration();
-
-    void _fireAxis(unsigned int iJoyStick, int axis, int value);
-    unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
-
-    void _tick(float dt);
-
-    // input events
-    bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
-    bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
-    bool mouseMoved    (const OIS::MouseEvent    &arg);
-    bool keyPressed    (const OIS::KeyEvent      &arg);
-    bool keyReleased   (const OIS::KeyEvent      &arg);
-    bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
-    bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
-    bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
-    bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
-    bool povMoved      (const OIS::JoyStickEvent &arg, int id);
-    //bool vector3Moved  (const OIS::JoyStickEvent &arg, int id);
-
-    static InputManager& _getSingleton();
-    static InputManager* _getSingletonPtr() { return &_getSingleton(); }
-
-  private: // variables
-    OIS::InputManager*                          inputSystem_;     //!< OIS input manager
-    OIS::Keyboard*                              keyboard_;        //!< OIS mouse
-    OIS::Mouse*                                 mouse_;           //!< OIS keyboard
-    std::vector<OIS::JoyStick*>                 joySticks_;       //!< OIS joy sticks
-    unsigned int                                joySticksSize_;
-
-    KeyBinder*                                  keyBinder_;       //!< KeyBinder instance
-    KeyDetector*                                keyDetector_;     //!< KeyDetector instance
-    InputBuffer*                                buffer_;          //!< InputBuffer instance
-    CalibratorCallback*                         calibratorCallback_;
-
-    InputState state_;
-    InputState stateRequest_;
-    InputState savedState_;
-    unsigned int keyboardModifiers_;
-    StoredState savedHandlers_;
-
-    // joystick calibration
-    //std::vector<int> marginalsMaxConfig_;
-    //std::vector<int> marginalsMinConfig_;
-    int marginalsMax_[24];
-    int marginalsMin_[24];
-    bool bCalibrated_;
-
-    //! Keeps track of the joy stick POV states
-    std::vector<POVStates>                      povStates_;
-    //! Keeps track of the possibly two slider axes
-    std::vector<SliderStates>                   sliderStates_;
-    std::vector<JoyStickCalibration>            joySticksCalibration_;
-
-    std::map<std::string, KeyHandler*>          keyHandlers_;
-    std::map<std::string, MouseHandler*>        mouseHandlers_;
-    std::map<std::string, JoyStickHandler*>     joyStickHandlers_;
-
-    std::vector<KeyHandler*>                    activeKeyHandlers_;
-    std::vector<MouseHandler*>                  activeMouseHandlers_;
-    std::vector<std::vector<JoyStickHandler*> > activeJoyStickHandlers_;
-    std::vector<std::pair<InputTickable*, HandlerState> > activeHandlers_;
-
-    std::vector<Key>                            keysDown_;
-    std::vector<MouseButton::Enum>              mouseButtonsDown_;
-    std::vector<std::vector<int> >              joyStickButtonsDown_;
-
-    static std::string                          bindingCommmandString_s;
-  };
-
+        public OIS::KeyListener, public OIS::MouseListener, public OIS::JoyStickListener
+    {
+        // --> setConfigValues is private
+        friend class ClassIdentifier<InputManager>;
+        // let Core class use tick(.)
+        friend class Core;
+
+    public:
+        enum InputManagerState
+        {
+            Uninitialised    = 0x00,
+            OISReady         = 0x01,
+            InternalsReady   = 0x02,
+            Ticking          = 0x04,
+            Calibrating      = 0x08,
+            ReloadRequest    = 0x10,
+            JoyStickSupport  = 0x20 // used with ReloadRequest to store a bool
+        };
+
+        InputManager ();
+        ~InputManager();
+
+        void initialise(size_t windowHnd, int windowWidth, int windowHeight, bool joyStickSupport = true);
+
+        void reloadInputSystem(bool joyStickSupport = true);
+
+        int  numberOfKeyboards() { return keyboard_ ? 1 : 0; }
+        int  numberOfMice()      { return mouse_    ? 1 : 0; }
+        int  numberOfJoySticks() { return joySticksSize_; }
+
+        void setWindowExtents(const int width, const int height);
+
+        template <class T>
+        T* createInputState(const std::string& name, int priority)
+        {
+            T* state = new T;
+            if (_configureInputState(state, name, priority))
+                return state;
+            else
+            {
+                delete state;
+                return 0;
+            }
+        }
+
+        InputState* getState       (const std::string& name);
+        InputState* getCurrentState();
+        bool requestDestroyState   (const std::string& name);
+        bool requestEnterState     (const std::string& name);
+        bool requestLeaveState     (const std::string& name);
+
+        void tick(float dt);
+
+        static InputManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; }
+        static InputManager* getInstancePtr() { return singletonRef_s; }
+
+    public: // console commands
+        static void storeKeyStroke(const std::string& name);
+        static void keyBind(const std::string& command);
+        static void calibrate();
+        static void reload(bool joyStickSupport = true);
+
+    private: // functions
+        // don't mess with a Singleton
+        InputManager (const InputManager&);
+
+        // Intenal methods
+        void _initialiseKeyboard();
+        void _initialiseMouse();
+        void _initialiseJoySticks();
+        void _redimensionLists();
+
+        void _destroyKeyboard();
+        void _destroyMouse();
+        void _destroyJoySticks();
+        void _destroyState(InputState* state);
+        void _clearBuffers();
+
+        void _reload(bool joyStickSupport);
+
+        void _completeCalibration();
+
+        void _fireAxis(unsigned int iJoyStick, int axis, int value);
+        unsigned int _getJoystick(const OIS::JoyStickEvent& arg);
+
+        void _updateActiveStates();
+        bool _configureInputState(InputState* state, const std::string& name, int priority);
+
+        // input events
+        bool mousePressed  (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+        bool mouseReleased (const OIS::MouseEvent    &arg, OIS::MouseButtonID id);
+        bool mouseMoved    (const OIS::MouseEvent    &arg);
+        bool keyPressed    (const OIS::KeyEvent      &arg);
+        bool keyReleased   (const OIS::KeyEvent      &arg);
+        bool buttonPressed (const OIS::JoyStickEvent &arg, int button);
+        bool buttonReleased(const OIS::JoyStickEvent &arg, int button);
+        bool axisMoved     (const OIS::JoyStickEvent &arg, int axis);
+        bool sliderMoved   (const OIS::JoyStickEvent &arg, int id);
+        bool povMoved      (const OIS::JoyStickEvent &arg, int id);
+        // don't remove that! Or else add OIS as dependency library to orxonox.
+        bool vector3Moved  (const OIS::JoyStickEvent &arg, int id) { return true; }
+
+        void setConfigValues();
+
+    private: // variables
+        OIS::InputManager*                  inputSystem_;          //!< OIS input manager
+        OIS::Keyboard*                      keyboard_;             //!< OIS mouse
+        OIS::Mouse*                         mouse_;                //!< OIS keyboard
+        std::vector<OIS::JoyStick*>         joySticks_;            //!< OIS joy sticks
+        unsigned int                        joySticksSize_;
+        unsigned int                        devicesNum_;
+        size_t                              windowHnd_;            //!< Render window handle
+        InputManagerState                   internalState_;        //!< Current internal state
+
+        // some internally handled states
+        SimpleInputState*                   stateDetector_;        //!< KeyDetector instance
+        SimpleInputState*                   stateCalibrator_;
+        SimpleInputState*                   stateEmpty_;
+
+        std::map<std::string, InputState*>  inputStatesByName_;
+        std::map<int, InputState*>          inputStatesByPriority_;
+
+        std::set<InputState*>               stateEnterRequests_;   //!< Request to enter a new state
+        std::set<InputState*>               stateLeaveRequests_;   //!< Request to leave a running state
+        std::set<InputState*>               stateDestroyRequests_; //!< Request to destroy a state
+
+        std::map<int, InputState*>          activeStates_;
+        std::vector<InputState*>            activeStatesTop_;      //!< Current input states for joy stick events.
+        std::vector<InputState*>            activeStatesTicked_;   //!< Current input states for joy stick events.
+
+        // joystick calibration
+        //std::vector<int> marginalsMaxConfig_;
+        //std::vector<int> marginalsMinConfig_;
+        int                                 marginalsMax_[24];
+        int                                 marginalsMin_[24];
+        bool                                bCalibrated_;
+        bool                                bCalibrating_;
+
+        unsigned int                        keyboardModifiers_;    //!< Bit mask representing keyboard modifiers.
+        std::vector<POVStates>              povStates_;            //!< Keeps track of the joy stick POV states.
+        std::vector<SliderStates>           sliderStates_;         //!< Keeps track of the possibly two slider axes.
+        std::vector<JoyStickCalibration>    joySticksCalibration_; 
+
+        std::vector<Key>                    keysDown_;
+        std::vector<MouseButton::Enum>      mouseButtonsDown_;
+        std::vector<std::vector<JoyStickButton::Enum> >  joyStickButtonsDown_;
+
+        static std::string                  bindingCommmandString_s;
+        static InputManager*                singletonRef_s;
+    };
 }
 
Index: code/trunk/src/core/input/InputState.h
===================================================================
--- code/trunk/src/core/input/InputState.h	(revision 1755)
+++ code/trunk/src/core/input/InputState.h	(revision 1755)
@@ -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 
+*/
+
+#ifndef _InputState_H__
+#define _InputState_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <vector>
+#include "core/Executor.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class _CoreExport InputState
+    {
+        friend class InputManager;
+
+    public:
+        const std::string& getName() const { return name_; }
+        int getPriority()            const { return priority_; }
+
+        bool isInputDeviceEnabled(unsigned int device)
+        {
+            if (device < bInputDeviceEnabled_.size())
+                return bInputDeviceEnabled_[device];
+            else
+                return false;
+        }
+
+        virtual void onEnter() { if (executorOnEnter_) (*executorOnEnter_)(); }
+        virtual void onLeave() { if (executorOnLeave_) (*executorOnLeave_)(); }
+
+        virtual void registerOnEnter(Executor* executor)      { executorOnEnter_ = executor; }
+        virtual void unRegisterOnEnter()                      { executorOnEnter_ = 0; }
+        virtual void registerOnLeave(Executor* executor)      { executorOnLeave_ = executor; }
+        virtual void unRegisterOnLeave()                      { executorOnLeave_ = 0; }
+
+        virtual void tickInput(float dt, unsigned int device) = 0;
+        virtual void tickInput(float dt) = 0;
+
+        virtual void keyPressed (const KeyEvent& evt) = 0;
+        virtual void keyReleased(const KeyEvent& evt) = 0;
+        virtual void keyHeld    (const KeyEvent& evt) = 0;
+
+        virtual void mouseButtonPressed (MouseButton::Enum id) = 0;
+        virtual void mouseButtonReleased(MouseButton::Enum id) = 0;
+        virtual void mouseButtonHeld    (MouseButton::Enum id) = 0;
+        virtual void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize) = 0;
+        virtual void mouseScrolled      (int abs, int rel) = 0;
+
+        virtual void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id) = 0;
+        virtual void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id) = 0;
+        virtual void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id) = 0;
+        virtual void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value) = 0;
+
+    protected:
+        InputState() : priority_(0), executorOnEnter_(0), executorOnLeave_(0) { }
+        virtual ~InputState() { }
+
+        virtual void numberOfJoySticksChanged(unsigned int n) = 0;
+        void setInputDeviceEnabled(unsigned int device, bool bEnabled)
+        {
+            if (device < bInputDeviceEnabled_.size())
+                bInputDeviceEnabled_[device] = bEnabled;
+        }
+
+    private:
+        void setNumOfJoySticks(unsigned int n)
+        {
+            bInputDeviceEnabled_.resize(n + 2);
+            numberOfJoySticksChanged(n);
+        }
+        void setName(const std::string& name)  { name_ = name; }
+        void setPriority(int priority)         { priority_ = priority; }
+
+        std::string                                 name_;
+        int                                         priority_;
+        std::vector<bool>                           bInputDeviceEnabled_;
+
+        Executor*                                   executorOnEnter_;
+        Executor*                                   executorOnLeave_;
+    };
+}
+
+#endif /* _InputState_H__ */
Index: code/trunk/src/core/input/KeyBinder.cc
===================================================================
--- code/trunk/src/core/input/KeyBinder.cc	(revision 1754)
+++ code/trunk/src/core/input/KeyBinder.cc	(revision 1755)
@@ -43,499 +43,526 @@
 namespace orxonox
 {
-  /**
-    @brief Constructor that does as little as necessary.
-  */
-  KeyBinder::KeyBinder() : deriveTime_(0.0f)
-  {
-    mouseRelative_[0] = 0;
-    mouseRelative_[1] = 0;
-    mousePosition_[0] = 0;
-    mousePosition_[1] = 0;
-
-    RegisterRootObject(KeyBinder);
-
-    // keys
-    std::string keyNames[] = {
-      "UNASSIGNED",
-      "ESCAPE",
-      "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
-      "MINUS", "EQUALS", "BACK", "TAB",
-      "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
-      "LBRACKET", "RBRACKET",
-      "RETURN", "LCONTROL",
-      "A", "S", "D", "F", "G", "H", "J", "K", "L",
-      "SEMICOLON", "APOSTROPHE", "GRAVE",
-      "LSHIFT", "BACKSLASH",
-      "Z", "X", "C", "V", "B", "N", "M",
-      "COMMA", "PERIOD", "SLASH",
-      "RSHIFT",
-      "MULTIPLY",
-      "LMENU",
-      "SPACE",
-      "CAPITAL",
-      "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
-      "NUMLOCK", "SCROLL",
-      "NUMPAD7", "NUMPAD8", "NUMPAD9",
-      "SUBTRACT",
-      "NUMPAD4", "NUMPAD5", "NUMPAD6",
-      "ADD",
-      "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0",
-      "DECIMAL",
-      "","",
-      "OEM_102",
-      "F11", "F12",
-      "","","","","","","","","","","",
-      "F13", "F14", "F15",
-      "","","","","","","","","","",
-      "KANA",
-      "","",
-      "ABNT_C1",
-      "","","","","",
-      "CONVERT",
-      "",
-      "NOCONVERT",
-      "",
-      "YEN",
-      "ABNT_C2",
-      "","","","","","","","","","","","","","",
-      "NUMPADEQUALS",
-      "","",
-      "PREVTRACK",
-      "AT",
-      "COLON", "UNDERLINE",
-      "KANJI",
-      "STOP",
-      "AX",
-      "UNLABELED",
-      "NEXTTRACK",
-      "","",
-      "NUMPADENTER",
-      "RCONTROL",
-      "","",
-      "MUTE",
-      "CALCULATOR",
-      "PLAYPAUSE",
-      "",
-      "MEDIASTOP",
-      "","","","","","","","","",
-      "VOLUMEDOWN",
-      "",
-      "VOLUMEUP",
-      "",
-      "WEBHOME",
-      "NUMPADCOMMA",
-      "",
-      "DIVIDE",
-      "",
-      "SYSRQ",
-      "RMENU",
-      "","","","","","","","","","","","",
-      "PAUSE",
-      "",
-      "HOME",
-      "UP",
-      "PGUP",
-      "",
-      "LEFT",
-      "",
-      "RIGHT",
-      "",
-      "END", "DOWN", "PGDOWN", "INSERT", "DELETE",
-      "","","","","","","",
-      "LWIN", "RWIN", "APPS",
-      "POWER", "SLEEP",
-      "","","",
-      "WAKE",
-      "",
-      "WEBSEARCH", "WEBFAVORITES", "WEBREFRESH", "WEBSTOP", "WEBFORWARD", "WEBBACK",
-      "MYCOMPUTER", "MAIL", "MEDIASELECT"
-    };
-    for (unsigned int i = 0; i < nKeys_s; i++)
-      keys_[i].name_ = "Key" + keyNames[i];
-
-    // mouse buttons
-    std::string mouseButtonNames[] = {
-      "MouseLeft", "MouseRight", "MouseMiddle",
-      "MouseButton3", "MouseButton4", "MouseButton5",
-      "MouseButton6", "MouseButton7",
-      "MouseWheel1Up", "MouseWheel1Down",
-      "MouseWheel2Up", "MouseWheel2Down" };
-    for (unsigned int i = 0; i < nMouseButtons_s; i++)
-      mouseButtons_[i].name_ = mouseButtonNames[i];
-
-    // joy stick buttons
-    for (unsigned int i = 0; i < 32; i++)
-      joyStickButtons_[i].name_ = "JoyButton" + getConvertedValue<int, std::string>(i);
-    for (unsigned int i = 32; i < nJoyStickButtons_s; i += 4)
-    {
-		  joyStickButtons_[i + 0].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "North";
-		  joyStickButtons_[i + 1].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "South";
-		  joyStickButtons_[i + 2].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "East";
-		  joyStickButtons_[i + 3].name_ = "JoyPOV" + getConvertedValue<int, std::string>((i - 32)/4 + 1) + "West";
-    }
-
-    // half axes
-    std::string rawNames[nHalfAxes_s/2];
-    rawNames[0] = "MouseX";
-    rawNames[1] = "MouseY";
-    rawNames[2] = "Empty1";
-    rawNames[3] = "Empty2";
-    for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
-      rawNames[i] = "JoyAxis" + getConvertedValue<int, std::string>(i - 3);
-    for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
-    {
-      halfAxes_[i * 2 + 0].name_ = rawNames[i] + "Pos";
-      halfAxes_[i * 2 + 1].name_ = rawNames[i] + "Neg";
-    }
-
-    for (unsigned int i = 0; i < this->nHalfAxes_s; i++)
-      halfAxes_[i].buttonThreshold_ = buttonThreshold_;
-  }
-
-  /**
-    @brief Destructor
-  */
-  KeyBinder::~KeyBinder()
-  {
-    // almost no destructors required because most of the arrays are static.
-    clearBindings(); // does some destruction work
-  }
-
-  /**
-    @brief Loads the key and button bindings.
-    @return True if loading succeeded.
-  */
-  void KeyBinder::loadBindings()
-  {
-    COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
-
-    clearBindings();
-
-    std::ifstream infile;
-    infile.open("keybindings.ini");
-    if (!infile)
-    {
-      ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "def_keybindings.ini");
-      ConfigFileManager::getInstance()->save(CFT_Keybindings, "keybindings.ini");
-    }
-    else
-      infile.close();
-    ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "keybindings.ini");
-
-    // parse key bindings
-    setConfigValues();
-
-    COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
-  }
-
-  /**
-    @brief Loader for the key bindings, managed by config values.
-  */
-  void KeyBinder::setConfigValues()
-  {
-    SetConfigValue(analogThreshold_, 0.05f)  .description("Threshold for analog axes until which the state is 0.");
-    SetConfigValue(mouseSensitivity_, 1.0f)  .description("Mouse sensitivity.");
-    SetConfigValue(bDeriveMouseInput_, false).description("Whether or not to derive moues movement for the absolute value.");
-    SetConfigValue(derivePeriod_, 0.05f).description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
-    SetConfigValue(mouseSensitivityDerived_, 1.0f).description("Mouse sensitivity if mouse input is derived.");
-    SetConfigValue(bClipMouse_, true).description("Whether or not to clip absolute value of mouse in non derive mode.");
-
-    float oldThresh = buttonThreshold_;
-    SetConfigValue(buttonThreshold_, 0.80f).description("Threshold for analog axes until which the button is not pressed.");
-    if (oldThresh != buttonThreshold_)
-      for (unsigned int i = 0; i < nHalfAxes_s; i++)
-        if (halfAxes_[i].buttonThreshold_ == oldThresh)
-          halfAxes_[i].buttonThreshold_ = buttonThreshold_;
-
-    // keys
-    for (unsigned int i = 0; i < nKeys_s; i++)
-      readTrigger(keys_[i]);
-    // mouse buttons
-    for (unsigned int i = 0; i < nMouseButtons_s; i++)
-      readTrigger(mouseButtons_[i]);
-    // joy stick buttons
-    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
-      readTrigger(joyStickButtons_[i]);
-    // half axes
-    for (unsigned int i = 0; i < nHalfAxes_s; i++)
-      readTrigger(halfAxes_[i]);
-  }
-
-  void KeyBinder::readTrigger(Button& button)
-  {
-    // config value stuff
-    ConfigValueContainer* cont = ClassIdentifier<KeyBinder>::getIdentifier()->getConfigValueContainer(button.name_);
-    if (!cont)
-    {
-      cont = new ConfigValueContainer(CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "", button.name_);
-      ClassIdentifier<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont);
-    }
-    std::string old = button.bindingString_;
-    cont->getValue(&button.bindingString_, this);
-
-    // keybinder stuff
-    if (old != button.bindingString_)
-    {
-      // clear everything so we don't get old axis ParamCommands mixed up
-      button.clear();
-
-      // binding has changed
-      button.parse(paramCommandBuffer_);
-    }
-  }
-
-  /**
-    @brief Overwrites all bindings with ""
-  */
-  void KeyBinder::clearBindings()
-  {
-    for (unsigned int i = 0; i < nKeys_s; i++)
-      keys_[i].clear();
-
-    for (unsigned int i = 0; i < nMouseButtons_s; i++)
-      mouseButtons_[i].clear();
-
-    for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
-      joyStickButtons_[i].clear();
-
-    for (unsigned int i = 0; i < nHalfAxes_s; i++)
-      halfAxes_[i].clear();
-
-    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
-      delete paramCommandBuffer_[i];
-    paramCommandBuffer_.clear();
-  }
-
-  void KeyBinder::resetJoyStickAxes()
-  {
-    for (unsigned int i = 8; i < nHalfAxes_s; i++)
-    {
-      halfAxes_[i].absVal_ = 0.0f;
-      halfAxes_[i].relVal_ = 0.0f;
-    }
-  }
-
-  void KeyBinder::tickInput(float dt, const HandlerState& state)
-  {
-    // we have to process all the analog input since there is e.g. no 'mouseDoesntMove' event.
-    unsigned int iBegin = 8;
-    unsigned int iEnd   = 8;
-    if (state.joyStick)
-      iEnd = nHalfAxes_s;
-    if (state.mouse)
-      iBegin = 0;
-    for (unsigned int i = iBegin; i < iEnd; i++)
-    {
-      if (halfAxes_[i].hasChanged_)
-      {
-        if (!halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ > halfAxes_[i].buttonThreshold_)
-        {
-          halfAxes_[i].wasDown_ = true;
-          if (halfAxes_[i].nCommands_[KeybindMode::OnPress])
-            halfAxes_[i].execute(KeybindMode::OnPress);
-        }
-        else if (halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ < halfAxes_[i].buttonThreshold_)
-        {
-          halfAxes_[i].wasDown_ = false;
-          if (halfAxes_[i].nCommands_[KeybindMode::OnRelease])
-            halfAxes_[i].execute(KeybindMode::OnRelease);
-        }
-        halfAxes_[i].hasChanged_ = false;
-      }
-
-      if (halfAxes_[i].wasDown_)
-      {
-        if (halfAxes_[i].nCommands_[KeybindMode::OnHold])
-          halfAxes_[i].execute(KeybindMode::OnHold);
-      }
-
-      // these are the actually useful axis bindings for analog input AND output
-      if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_)
-      {
-        //COUT(3) << halfAxes_[i].name_ << "\t" << halfAxes_[i].absVal_ << std::endl;
-        halfAxes_[i].execute();
-      }
-    }
-
-    if (bDeriveMouseInput_ && state.mouse)
-    {
-      if (deriveTime_ > derivePeriod_)
-      {
-        //CCOUT(3) << "mouse abs: ";
+    /**
+    @brief
+        Constructor that does as little as necessary.
+    */
+    KeyBinder::KeyBinder()
+        : deriveTime_(0.0f)
+    {
+        mouseRelative_[0] = 0;
+        mouseRelative_[1] = 0;
+        mousePosition_[0] = 0;
+        mousePosition_[1] = 0;
+
+        RegisterRootObject(KeyBinder);
+
+        // keys
+        std::string keyNames[] = {
+        "UNASSIGNED",
+        "ESCAPE",
+        "1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
+        "MINUS", "EQUALS", "BACK", "TAB",
+        "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
+        "LBRACKET", "RBRACKET",
+        "RETURN", "LCONTROL",
+        "A", "S", "D", "F", "G", "H", "J", "K", "L",
+        "SEMICOLON", "APOSTROPHE", "GRAVE",
+        "LSHIFT", "BACKSLASH",
+        "Z", "X", "C", "V", "B", "N", "M",
+        "COMMA", "PERIOD", "SLASH",
+        "RSHIFT",
+        "MULTIPLY",
+        "LMENU",
+        "SPACE",
+        "CAPITAL",
+        "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10",
+        "NUMLOCK", "SCROLL",
+        "NUMPAD7", "NUMPAD8", "NUMPAD9",
+        "SUBTRACT",
+        "NUMPAD4", "NUMPAD5", "NUMPAD6",
+        "ADD",
+        "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0",
+        "DECIMAL",
+        "","",
+        "OEM_102",
+        "F11", "F12",
+        "","","","","","","","","","","",
+        "F13", "F14", "F15",
+        "","","","","","","","","","",
+        "KANA",
+        "","",
+        "ABNT_C1",
+        "","","","","",
+        "CONVERT",
+        "",
+        "NOCONVERT",
+        "",
+        "YEN",
+        "ABNT_C2",
+        "","","","","","","","","","","","","","",
+        "NUMPADEQUALS",
+        "","",
+        "PREVTRACK",
+        "AT",
+        "COLON", "UNDERLINE",
+        "KANJI",
+        "STOP",
+        "AX",
+        "UNLABELED",
+        "NEXTTRACK",
+        "","",
+        "NUMPADENTER",
+        "RCONTROL",
+        "","",
+        "MUTE",
+        "CALCULATOR",
+        "PLAYPAUSE",
+        "",
+        "MEDIASTOP",
+        "","","","","","","","","",
+        "VOLUMEDOWN",
+        "",
+        "VOLUMEUP",
+        "",
+        "WEBHOME",
+        "NUMPADCOMMA",
+        "",
+        "DIVIDE",
+        "",
+        "SYSRQ",
+        "RMENU",
+        "","","","","","","","","","","","",
+        "PAUSE",
+        "",
+        "HOME",
+        "UP",
+        "PGUP",
+        "",
+        "LEFT",
+        "",
+        "RIGHT",
+        "",
+        "END", "DOWN", "PGDOWN", "INSERT", "DELETE",
+        "","","","","","","",
+        "LWIN", "RWIN", "APPS",
+        "POWER", "SLEEP",
+        "","","",
+        "WAKE",
+        "",
+        "WEBSEARCH", "WEBFAVORITES", "WEBREFRESH", "WEBSTOP", "WEBFORWARD", "WEBBACK",
+        "MYCOMPUTER", "MAIL", "MEDIASELECT"
+        };
+        for (unsigned int i = 0; i < nKeys_s; i++)
+            keys_[i].name_ = "Key" + keyNames[i];
+
+        // mouse buttons
+        std::string mouseButtonNames[] = {
+            "MouseLeft",     "MouseRight",   "MouseMiddle",
+            "MouseButton3",  "MouseButton4", "MouseButton5",
+            "MouseButton6",  "MouseButton7",
+            "MouseWheel1Up", "MouseWheel1Down",
+            "MouseWheel2Up", "MouseWheel2Down"
+        };
+        for (unsigned int i = 0; i < nMouseButtons_s; i++)
+            mouseButtons_[i].name_ = mouseButtonNames[i];
+
+        // joy stick buttons
+        for (unsigned int i = 0; i < 32; i++)
+            joyStickButtons_[i].name_ = "JoyButton" + getConvertedValue<int, std::string>(i);
+        for (unsigned int i = 32; i < nJoyStickButtons_s; i += 4)
+        {
+            joyStickButtons_[i + 0].name_ = "JoyPOV" + convertToString((i - 32)/4 + 1) + "North";
+            joyStickButtons_[i + 1].name_ = "JoyPOV" + convertToString((i - 32)/4 + 1) + "South";
+            joyStickButtons_[i + 2].name_ = "JoyPOV" + convertToString((i - 32)/4 + 1) + "East";
+            joyStickButtons_[i + 3].name_ = "JoyPOV" + convertToString((i - 32)/4 + 1) + "West";
+        }
+
+        // half axes
+        std::string rawNames[nHalfAxes_s/2];
+        rawNames[0] = "MouseX";
+        rawNames[1] = "MouseY";
+        rawNames[2] = "Empty1";
+        rawNames[3] = "Empty2";
+        for (unsigned int i = 4; i < nHalfAxes_s/2; i++)
+            rawNames[i] = "JoyAxis" + convertToString(i - 3);
+        for (unsigned int i = 0; i < nHalfAxes_s/2; i++)
+        {
+            halfAxes_[i * 2 + 0].name_ = rawNames[i] + "Pos";
+            halfAxes_[i * 2 + 1].name_ = rawNames[i] + "Neg";
+        }
+
+        for (unsigned int i = 0; i < this->nHalfAxes_s; i++)
+            halfAxes_[i].buttonThreshold_ = buttonThreshold_;
+    }
+
+    /**
+    @brief
+        Destructor
+    */
+    KeyBinder::~KeyBinder()
+    {
+        // almost no destructors required because most of the arrays are static.
+        clearBindings(); // does some destruction work
+    }
+
+    /**
+    @brief
+        Loads the key and button bindings.
+    @return
+        True if loading succeeded.
+    */
+    void KeyBinder::loadBindings()
+    {
+        COUT(3) << "KeyBinder: Loading key bindings..." << std::endl;
+
+        clearBindings();
+
+        std::ifstream infile;
+        infile.open("keybindings.ini");
+        if (!infile)
+        {
+            ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "def_keybindings.ini");
+            ConfigFileManager::getInstance()->save(CFT_Keybindings, "keybindings.ini");
+        }
+        else
+            infile.close();
+        ConfigFileManager::getInstance()->setFile(CFT_Keybindings, "keybindings.ini");
+
+        // parse key bindings
+        setConfigValues();
+
+        COUT(3) << "KeyBinder: Loading key bindings done." << std::endl;
+    }
+
+    /**
+    @brief
+        Loader for the key bindings, managed by config values.
+    */
+    void KeyBinder::setConfigValues()
+    {
+        SetConfigValue(analogThreshold_, 0.05f)
+            .description("Threshold for analog axes until which the state is 0.");
+        SetConfigValue(mouseSensitivity_, 1.0f)
+            .description("Mouse sensitivity.");
+        SetConfigValue(bDeriveMouseInput_, false)
+            .description("Whether or not to derive moues movement for the absolute value.");
+        SetConfigValue(derivePeriod_, 0.05f)
+            .description("Accuracy of the mouse input deriver. The higher the more precise, but laggier.");
+        SetConfigValue(mouseSensitivityDerived_, 1.0f)
+            .description("Mouse sensitivity if mouse input is derived.");
+        SetConfigValue(bClipMouse_, true)
+            .description("Whether or not to clip absolute value of mouse in non derive mode.");
+
+        float oldThresh = buttonThreshold_;
+        SetConfigValue(buttonThreshold_, 0.80f)
+            .description("Threshold for analog axes until which the button is not pressed.");
+        if (oldThresh != buttonThreshold_)
+            for (unsigned int i = 0; i < nHalfAxes_s; i++)
+                if (halfAxes_[i].buttonThreshold_ == oldThresh)
+                    halfAxes_[i].buttonThreshold_ = buttonThreshold_;
+
+        // keys
+        for (unsigned int i = 0; i < nKeys_s; i++)
+            readTrigger(keys_[i]);
+        // mouse buttons
+        for (unsigned int i = 0; i < nMouseButtons_s; i++)
+            readTrigger(mouseButtons_[i]);
+        // joy stick buttons
+        for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
+            readTrigger(joyStickButtons_[i]);
+        // half axes
+        for (unsigned int i = 0; i < nHalfAxes_s; i++)
+            readTrigger(halfAxes_[i]);
+    }
+
+    void KeyBinder::readTrigger(Button& button)
+    {
+        // config value stuff
+        ConfigValueContainer* cont
+            = ClassIdentifier<KeyBinder>::getIdentifier()->getConfigValueContainer(button.name_);
+        if (!cont)
+        {
+            cont = new ConfigValueContainer
+                (CFT_Keybindings, ClassIdentifier<KeyBinder>::getIdentifier(), button.name_, "", button.name_);
+            ClassIdentifier<KeyBinder>::getIdentifier()->addConfigValueContainer(button.name_, cont);
+        }
+        std::string old = button.bindingString_;
+        cont->getValue(&button.bindingString_, this);
+
+        // keybinder stuff
+        if (old != button.bindingString_)
+        {
+            // clear everything so we don't get old axis ParamCommands mixed up
+            button.clear();
+
+            // binding has changed
+            button.parse(paramCommandBuffer_);
+        }
+    }
+
+    /**
+    @brief
+        Overwrites all bindings with ""
+    */
+    void KeyBinder::clearBindings()
+    {
+        for (unsigned int i = 0; i < nKeys_s; i++)
+            keys_[i].clear();
+
+        for (unsigned int i = 0; i < nMouseButtons_s; i++)
+            mouseButtons_[i].clear();
+
+        for (unsigned int i = 0; i < nJoyStickButtons_s; i++)
+            joyStickButtons_[i].clear();
+
+        for (unsigned int i = 0; i < nHalfAxes_s; i++)
+            halfAxes_[i].clear();
+
+        for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+            delete paramCommandBuffer_[i];
+        paramCommandBuffer_.clear();
+    }
+
+    void KeyBinder::resetJoyStickAxes()
+    {
+        for (unsigned int i = 8; i < nHalfAxes_s; i++)
+        {
+            halfAxes_[i].absVal_ = 0.0f;
+            halfAxes_[i].relVal_ = 0.0f;
+        }
+    }
+
+    void KeyBinder::tickMouse(float dt)
+    {
+        tickDevices(0, 8);
+
+        if (bDeriveMouseInput_)
+        {
+            if (deriveTime_ > derivePeriod_)
+            {
+                //CCOUT(3) << "mouse abs: ";
+                for (int i = 0; i < 2; i++)
+                {
+                    if (mouseRelative_[i] > 0)
+                    {
+                        halfAxes_[2*i + 0].absVal_
+                            =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+                        halfAxes_[2*i + 1].absVal_ = 0.0f;
+                    }
+                    else if (mouseRelative_[i] < 0)
+                    {
+                        halfAxes_[2*i + 0].absVal_ = 0.0f;
+                        halfAxes_[2*i + 1].absVal_
+                            = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
+                    }
+                    else
+                    {
+                        halfAxes_[2*i + 0].absVal_ = 0.0f;
+                        halfAxes_[2*i + 1].absVal_ = 0.0f;
+                    }
+                    //COUT(3) << mouseRelative_[i] << " | ";
+                    mouseRelative_[i] = 0;
+                    halfAxes_[2*i + 0].hasChanged_ = true;
+                    halfAxes_[2*i + 1].hasChanged_ = true;
+                }
+                deriveTime_ = 0.0f;
+                //COUT(3) << std::endl;
+            }
+            else
+                deriveTime_ += dt;
+        }
+    }
+
+    void KeyBinder::tickJoyStick(float dt, unsigned int joyStick)
+    {
+        tickDevices(8, nHalfAxes_s);
+    }
+
+    void KeyBinder::tickInput(float dt)
+    {
+        // execute all buffered bindings (additional parameter)
+        for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
+            paramCommandBuffer_[i]->execute();
+
+        // always reset the relative movement of the mouse
+        for (unsigned int i = 0; i < 8; i++)
+            halfAxes_[i].relVal_ = 0.0f;
+    }
+
+    void KeyBinder::tickDevices(unsigned int begin, unsigned int end)
+    {
+        for (unsigned int i = begin; i < end; i++)
+        {
+            // button mode
+            // TODO: optimize out all the half axes that don't act as a button at the moment
+            if (halfAxes_[i].hasChanged_)
+            {
+                if (!halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ > halfAxes_[i].buttonThreshold_)
+                {
+                    halfAxes_[i].wasDown_ = true;
+                    if (halfAxes_[i].nCommands_[KeybindMode::OnPress])
+                        halfAxes_[i].execute(KeybindMode::OnPress);
+                }
+                else if (halfAxes_[i].wasDown_ && halfAxes_[i].absVal_ < halfAxes_[i].buttonThreshold_)
+                {
+                    halfAxes_[i].wasDown_ = false;
+                    if (halfAxes_[i].nCommands_[KeybindMode::OnRelease])
+                        halfAxes_[i].execute(KeybindMode::OnRelease);
+                }
+                halfAxes_[i].hasChanged_ = false;
+            }
+
+            if (halfAxes_[i].wasDown_)
+            {
+                if (halfAxes_[i].nCommands_[KeybindMode::OnHold])
+                    halfAxes_[i].execute(KeybindMode::OnHold);
+            }
+
+            // these are the actually useful axis bindings for analog input
+            if (halfAxes_[i].relVal_ > analogThreshold_ || halfAxes_[i].absVal_ > analogThreshold_)
+            {
+                //COUT(3) << halfAxes_[i].name_ << "\t" << halfAxes_[i].absVal_ << std::endl;
+                halfAxes_[i].execute();
+            }
+        }
+    }
+
+    void KeyBinder::keyPressed (const KeyEvent& evt)
+    { keys_[evt.key].execute(KeybindMode::OnPress); }
+
+    void KeyBinder::keyReleased(const KeyEvent& evt)
+    { keys_[evt.key].execute(KeybindMode::OnRelease); }
+
+    void KeyBinder::keyHeld    (const KeyEvent& evt)
+    { keys_[evt.key].execute(KeybindMode::OnHold); }
+
+
+    void KeyBinder::mouseButtonPressed (MouseButton::Enum id)
+    { mouseButtons_[id].execute(KeybindMode::OnPress); }
+
+    void KeyBinder::mouseButtonReleased(MouseButton::Enum id)
+    { mouseButtons_[id].execute(KeybindMode::OnRelease); }
+
+    void KeyBinder::mouseButtonHeld    (MouseButton::Enum id)
+    { mouseButtons_[id].execute(KeybindMode::OnHold); }
+
+
+    void KeyBinder::joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id)
+    { joyStickButtons_[id].execute(KeybindMode::OnPress); }
+
+    void KeyBinder::joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id)
+    { joyStickButtons_[id].execute(KeybindMode::OnRelease); }
+
+    void KeyBinder::joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id)
+    { joyStickButtons_[id].execute(KeybindMode::OnHold); }
+
+    /**
+    @brief
+        Event handler for the mouseMoved Event.
+    @param e
+        Mouse state information
+    */
+    void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
+    {
+        // y axis of mouse input is inverted
+        int rel[] = { rel_.x, -rel_.y };
+
+        if (!bDeriveMouseInput_)
+        {
+            for (int i = 0; i < 2; i++)
+            {
+                if (rel[i])
+                {
+                    // absolute
+                    halfAxes_[2*i + 0].hasChanged_ = true;
+                    halfAxes_[2*i + 1].hasChanged_ = true;
+                    mousePosition_[i] += rel[i];
+
+                    if (bClipMouse_)
+                    {
+                        if (mousePosition_[i] > 1024)
+                            mousePosition_[i] =  1024;
+                        if (mousePosition_[i] < -1024)
+                            mousePosition_[i] = -1024;
+                    }
+
+                    if (mousePosition_[i] >= 0)
+                    {
+                        halfAxes_[2*i + 0].absVal_ =   mousePosition_[i]/1024.0f * mouseSensitivity_;
+                        halfAxes_[2*i + 1].absVal_ =  0.0f;
+                    }
+                    else
+                    {
+                        halfAxes_[2*i + 0].absVal_ =  0.0f;
+                        halfAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/1024.0f * mouseSensitivity_;
+                    }
+                }
+            }
+        }
+        else
+        {
+            mouseRelative_[0] += rel[0];
+            mouseRelative_[1] += rel[1];
+        }
+
+        // relative
         for (int i = 0; i < 2; i++)
         {
-          if (mouseRelative_[i] > 0)
-          {
-            halfAxes_[2*i + 0].absVal_ =  mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
-            halfAxes_[2*i + 1].absVal_ = 0.0f;
-          }
-          else if (mouseRelative_[i] < 0)
-          {
-            halfAxes_[2*i + 0].absVal_ = 0.0f;
-            halfAxes_[2*i + 1].absVal_ = -mouseRelative_[i] / deriveTime_ * 0.0005 * mouseSensitivityDerived_;
-          }
-          else
-          {
-            halfAxes_[2*i + 0].absVal_ = 0.0f;
-            halfAxes_[2*i + 1].absVal_ = 0.0f;
-          }
-          //COUT(3) << mouseRelative_[i] << " | ";
-          mouseRelative_[i] = 0;
-          halfAxes_[2*i + 0].hasChanged_ = true;
-          halfAxes_[2*i + 1].hasChanged_ = true;
-        }
-        deriveTime_ = 0.0f;
-        //COUT(3) << std::endl;
-      }
-      else
-        deriveTime_ += dt;
-    }
-
-    // execute all buffered bindings (addional parameter)
-    for (unsigned int i = 0; i < paramCommandBuffer_.size(); i++)
-      paramCommandBuffer_[i]->execute();
-
-    // always reset the relative movement of the mouse
-    if (state.mouse)
-      for (unsigned int i = 0; i < 8; i++)
-        halfAxes_[i].relVal_ = 0.0f;
-  }
-
-  void KeyBinder::keyPressed (const KeyEvent& evt)
-  { keys_[evt.key].execute(KeybindMode::OnPress); }
-
-  void KeyBinder::keyReleased(const KeyEvent& evt)
-  { keys_[evt.key].execute(KeybindMode::OnRelease); }
-
-  void KeyBinder::keyHeld    (const KeyEvent& evt)
-  { keys_[evt.key].execute(KeybindMode::OnHold); }
-
-
-  void KeyBinder::mouseButtonPressed (MouseButton::Enum id)
-  { mouseButtons_[id].execute(KeybindMode::OnPress); }
-
-  void KeyBinder::mouseButtonReleased(MouseButton::Enum id)
-  { mouseButtons_[id].execute(KeybindMode::OnRelease); }
-
-  void KeyBinder::mouseButtonHeld    (MouseButton::Enum id)
-  { mouseButtons_[id].execute(KeybindMode::OnHold); }
-
-
-  void KeyBinder::joyStickButtonPressed (int joyStickID, int button)
-  { joyStickButtons_[button].execute(KeybindMode::OnPress); }
-
-  void KeyBinder::joyStickButtonReleased(int joyStickID, int button)
-  { joyStickButtons_[button].execute(KeybindMode::OnRelease); }
-
-  void KeyBinder::joyStickButtonHeld    (int joyStickID, int button)
-  { joyStickButtons_[button].execute(KeybindMode::OnHold); }
-
-  /**
-    @brief Event handler for the mouseMoved Event.
-    @param e Mouse state information
-  */
-  void KeyBinder::mouseMoved(IntVector2 abs_, IntVector2 rel_, IntVector2 clippingSize)
-  {
-    // y axis of mouse input is inverted
-    int rel[] = { rel_.x, -rel_.y };
-
-    if (!bDeriveMouseInput_)
-    {
-      for (int i = 0; i < 2; i++)
-      {
-        if (rel[i])
-        {
-          // absolute
-          halfAxes_[2*i + 0].hasChanged_ = true;
-          halfAxes_[2*i + 1].hasChanged_ = true;
-          mousePosition_[i] += rel[i];
-
-          if (bClipMouse_)
-          {
-            if (mousePosition_[i] > 1024)
-              mousePosition_[i] =  1024;
-            if (mousePosition_[i] < -1024)
-              mousePosition_[i] = -1024;
-          }
-
-          if (mousePosition_[i] >= 0)
-          {
-            halfAxes_[2*i + 0].absVal_ =   mousePosition_[i]/1024.0f * mouseSensitivity_;
-            halfAxes_[2*i + 1].absVal_ =  0.0f;
-          }
-          else
-          {
-            halfAxes_[2*i + 0].absVal_ =  0.0f;
-            halfAxes_[2*i + 1].absVal_ =  -mousePosition_[i]/1024.0f * mouseSensitivity_;
-          }
-        }
-      }
-    }
-    else
-    {
-      mouseRelative_[0] += rel[0];
-      mouseRelative_[1] += rel[1];
-    }
-
-    // relative
-    for (int i = 0; i < 2; i++)
-    {
-      if (rel[i] > 0)
-        halfAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/1024 * mouseSensitivity_;
-      else
-        halfAxes_[1 + 2*i].relVal_ = -((float)rel[i])/1024 * mouseSensitivity_;
-    }
-  }
-
-  /**
+            if (rel[i] > 0)
+                halfAxes_[0 + 2*i].relVal_ =  ((float)rel[i])/1024 * mouseSensitivity_;
+            else
+                halfAxes_[1 + 2*i].relVal_ = -((float)rel[i])/1024 * mouseSensitivity_;
+        }
+    }
+
+    /**
     @brief Event handler for the mouseScrolled Event.
     @param e Mouse state information
-  */
-  void KeyBinder::mouseScrolled(int abs, int rel)
-  {
-    //COUT(3) << mouseButtons_[8].name_ << "   " << abs << " | " << rel << std::endl;
-
-    if (rel > 0)
-      for (int i = 0; i < rel/120; i++)
-        mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
-    else
-      for (int i = 0; i < -rel/120; i++)
-        mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
-  }
-
-  void KeyBinder::joyStickAxisMoved(int joyStickID, int axis, float value)
-  {
-    // TODO: Use proper calibration values instead of generally 16-bit integer
-    int i = 8 + axis * 2;
-    if (value >= 0)
-    {
-      //if (value > 10000)
-      //{ CCOUT(3) << halfAxes_[i].name_ << std::endl; }
-
-      halfAxes_[i].absVal_ = value;
-      halfAxes_[i].relVal_ = value;
-      halfAxes_[i].hasChanged_ = true;
-      if (halfAxes_[i + 1].absVal_ > 0.0f)
-      {
-        halfAxes_[i + 1].absVal_ = -0.0f;
-        halfAxes_[i + 1].relVal_ = -0.0f;
-        halfAxes_[i + 1].hasChanged_ = true;
-      }
-    }
-    else
-    {
-      //if (value < -10000)
-      //{ CCOUT(3) << halfAxes_[i + 1].name_ << std::endl; }
-
-      halfAxes_[i + 1].absVal_ = -value;
-      halfAxes_[i + 1].relVal_ = -value;
-      halfAxes_[i + 1].hasChanged_ = true;
-      if (halfAxes_[i].absVal_ > 0.0f)
-      {
-        halfAxes_[i].absVal_ = -0.0f;
-        halfAxes_[i].relVal_ = -0.0f;
-        halfAxes_[i].hasChanged_ = true;
-      }
-    }
-  }
+    */
+    void KeyBinder::mouseScrolled(int abs, int rel)
+    {
+        //COUT(3) << mouseButtons_[8].name_ << "   " << abs << " | " << rel << std::endl;
+
+        if (rel > 0)
+            for (int i = 0; i < rel/120; i++)
+                mouseButtons_[8].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
+        else
+            for (int i = 0; i < -rel/120; i++)
+                mouseButtons_[9].execute(KeybindMode::OnPress, ((float)abs)/120.0f);
+    }
+
+    void KeyBinder::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
+    {
+        int i = 8 + axis * 2;
+        if (value >= 0)
+        {
+            //if (value > 10000)
+            //{ CCOUT(3) << halfAxes_[i].name_ << std::endl; }
+
+            halfAxes_[i].absVal_ = value;
+            halfAxes_[i].relVal_ = value;
+            halfAxes_[i].hasChanged_ = true;
+            if (halfAxes_[i + 1].absVal_ > 0.0f)
+            {
+                halfAxes_[i + 1].absVal_ = -0.0f;
+                halfAxes_[i + 1].relVal_ = -0.0f;
+                halfAxes_[i + 1].hasChanged_ = true;
+            }
+        }
+        else
+        {
+            //if (value < -10000)
+            //{ CCOUT(3) << halfAxes_[i + 1].name_ << std::endl; }
+
+            halfAxes_[i + 1].absVal_ = -value;
+            halfAxes_[i + 1].relVal_ = -value;
+            halfAxes_[i + 1].hasChanged_ = true;
+            if (halfAxes_[i].absVal_ > 0.0f)
+            {
+                halfAxes_[i].absVal_ = -0.0f;
+                halfAxes_[i].relVal_ = -0.0f;
+                halfAxes_[i].hasChanged_ = true;
+            }
+        }
+    }
 }
Index: code/trunk/src/core/input/KeyBinder.h
===================================================================
--- code/trunk/src/core/input/KeyBinder.h	(revision 1754)
+++ code/trunk/src/core/input/KeyBinder.h	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Different definitions of input processing.
- */
+@file
+@brief
+    Different definitions of input processing.
+*/
 
 #ifndef _KeyBinder_H__
@@ -46,97 +47,106 @@
 namespace orxonox
 {
-  /**
-    @brief Handles mouse, keyboard and joy stick input while in the actual game mode.
-           Manages the key bindings.
-  */
-  class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
-  {
-  public:
-    KeyBinder ();
-    virtual ~KeyBinder();
+    /**
+    @brief
+        Handles mouse, keyboard and joy stick input while in the actual game mode.
+        Manages the key bindings.
+    */
+    class _CoreExport KeyBinder : public KeyHandler, public MouseHandler, public JoyStickHandler, public OrxonoxClass
+    {
+    public:
+        KeyBinder ();
+        virtual ~KeyBinder();
 
-    void loadBindings();
-    void clearBindings();
-    void setConfigValues();
-    void resetJoyStickAxes();
+        void loadBindings();
+        void clearBindings();
+        void setConfigValues();
+        void resetJoyStickAxes();
 
-  protected: // functions
-    void tickInput(float dt, const HandlerState& state);
+    protected: // functions
+        void tickInput(float dt);
+        //void tickInput(float dt, int device);
+        void tickKey(float dt) { }
+        void tickMouse(float dt);
+        void tickJoyStick(float dt, unsigned int joyStick);
+        void tickDevices(unsigned int begin, unsigned int end);
 
-    virtual void readTrigger(Button& button);
+        virtual void readTrigger(Button& button);
 
-    void keyPressed (const KeyEvent& evt);
-    void keyReleased(const KeyEvent& evt);
-    void keyHeld    (const KeyEvent& evt);
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt);
+        void keyHeld    (const KeyEvent& evt);
 
-    void mouseButtonPressed (MouseButton::Enum id);
-    void mouseButtonReleased(MouseButton::Enum id);
-    void mouseButtonHeld    (MouseButton::Enum id);
-    void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
-    void mouseScrolled      (int abs, int rel);
+        void mouseButtonPressed (MouseButton::Enum id);
+        void mouseButtonReleased(MouseButton::Enum id);
+        void mouseButtonHeld    (MouseButton::Enum id);
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+        void mouseScrolled      (int abs, int rel);
 
-    void joyStickButtonPressed (int joyStickID, int button);
-    void joyStickButtonReleased(int joyStickID, int button);
-    void joyStickButtonHeld    (int joyStickID, int button);
-    void joyStickAxisMoved     (int joyStickID, int axis, float value);
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);
 
-  protected: // variables
-    //! denotes the number of different keys there are in OIS.
-    static const unsigned int nKeys_s = 0xEE;
-    //! Actual key bindings as bundle for Press, Hold and Release
-    Button keys_ [nKeys_s];
+    protected: // variables
+        //! denotes the number of different keys there are in OIS.
+        static const unsigned int nKeys_s = 0xEE;
+        //! Actual key bindings as bundle for Press, Hold and Release
+        Button keys_ [nKeys_s];
 
-    //! denotes the number of different mouse buttons there are in OIS.
-    static const unsigned int nMouseButtons_s = 8 + 2*2; // 8 buttons and 2 scroll wheels
-    //! Actual key bindings as bundle for Press, Hold and Release
-    Button mouseButtons_ [nMouseButtons_s];
+        //! denotes the number of different mouse buttons there are in OIS.
+        static const unsigned int nMouseButtons_s = 8 + 2*2; // 8 buttons and 2 scroll wheels
+        //! Actual key bindings as bundle for Press, Hold and Release
+        Button mouseButtons_ [nMouseButtons_s];
 
-    //! denotes the number of different joy stick buttons there are in OIS.
-    static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
-    //! Actual key bindings as bundle for Press, Hold and Release
-    Button joyStickButtons_ [nJoyStickButtons_s];
+        //! denotes the number of different joy stick buttons there are in OIS.
+        static const unsigned int nJoyStickButtons_s = 32 + 4 * 4; // 32 buttons and 4 POVs with 4 buttons
+        //! Actual key bindings as bundle for Press, Hold and Release
+        Button joyStickButtons_ [nJoyStickButtons_s];
 
-    //! denotes the number of half axes (every axis twice) there can be.
-    static const unsigned int nHalfAxes_s = 56;
-    /**
-    * Array with all the half axes for mouse and joy sticks.
-    * Keep in mind that the positions are fixed and that the first entry is the
-    * positive one and the second is negative.
-    * Sequence is as follows:
-    *  0 -  3: Mouse x and y
-    *  4 -  7: empty
-    *  8 - 23: joy stick slider axes 1 to 8
-    * 24 - 55: joy stick axes 1 - 16
-    */
-    HalfAxis halfAxes_[nHalfAxes_s];
+        //! denotes the number of half axes (every axis twice) there can be.
+        static const unsigned int nHalfAxes_s = 56;
+        /**
+        * Array with all the half axes for mouse and joy sticks.
+        * Keep in mind that the positions are fixed and that the first entry is the
+        * positive one and the second is negative.
+        * Sequence is as follows:
+        *  0 -  3: Mouse x and y
+        *  4 -  7: empty
+        *  8 - 23: joy stick slider axes 1 to 8
+        * 24 - 55: joy stick axes 1 - 16
+        */
+        HalfAxis halfAxes_[nHalfAxes_s];
 
-    /**
-    * Commands that have additional parameters (axes) are executed at the end of
-    * the tick() so that all values can be buffered for single execution.
-    */
-    std::vector<BufferedParamCommand*> paramCommandBuffer_;
+        /**
+        @brief
+            Commands that have additional parameters (axes) are executed at the end of
+            the tick() so that all values can be buffered for single execution.
+        */
+        std::vector<BufferedParamCommand*> paramCommandBuffer_;
 
-    //! Keeps track of the absolute mouse value (incl. scroll wheel)
-    int mousePosition_[2];
-    //! Used to derive mouse input if requested
-    int mouseRelative_[2];
-    float deriveTime_;
+        //! Keeps track of the absolute mouse value (incl. scroll wheel)
+        int mousePosition_[2];
+        //! Used to derive mouse input if requested
+        int mouseRelative_[2];
+        float deriveTime_;
 
-    //##### ConfigValues #####
-    //! Threshold for analog triggers until which the state is 0.
-    float analogThreshold_;
-    //! Threshold for analog triggers until which the button is not pressed.
-    float buttonThreshold_;
-    //! Derive mouse input for absolute values?
-    bool bDeriveMouseInput_;
-    //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
-    float derivePeriod_;
-    //! mouse sensitivity
-    float mouseSensitivity_;
-    //! mouse sensitivity if mouse input is derived
-    float mouseSensitivityDerived_;
-    //! Whether or not to clip abslute mouse values to 1024
-    bool bClipMouse_;
-  };
+
+        //##### ConfigValues #####
+
+        //! Threshold for analog triggers until which the state is 0.
+        float analogThreshold_;
+        //! Threshold for analog triggers until which the button is not pressed.
+        float buttonThreshold_;
+        //! Derive mouse input for absolute values?
+        bool bDeriveMouseInput_;
+        //! Accuracy of the mouse input deriver. The higher the more precise, but laggier.
+        float derivePeriod_;
+        //! mouse sensitivity
+        float mouseSensitivity_;
+        //! mouse sensitivity if mouse input is derived
+        float mouseSensitivityDerived_;
+        //! Whether or not to clip abslute mouse values to 1024
+        bool bClipMouse_;
+    };
 }
 
Index: code/trunk/src/core/input/KeyDetector.cc
===================================================================
--- code/trunk/src/core/input/KeyDetector.cc	(revision 1754)
+++ code/trunk/src/core/input/KeyDetector.cc	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Implementation of the different input handlers.
- */
+@file
+@brief
+    Implementation of the different input handlers.
+*/
 
 #include "KeyDetector.h"
@@ -42,36 +43,41 @@
 namespace orxonox
 {
-  /**
-    @brief Constructor
-  */
-  KeyDetector::KeyDetector()
-  {
-    RegisterObject(KeyDetector);
-  }
+    /**
+    @brief
+        Constructor
+    */
+    KeyDetector::KeyDetector()
+    {
+        RegisterObject(KeyDetector);
+    }
 
-  /**
-    @brief Destructor
-  */
-  KeyDetector::~KeyDetector()
-  {
-  }
+    /**
+    @brief
+        Destructor
+    */
+    KeyDetector::~KeyDetector()
+    {
+    }
 
-  /**
-    @brief Loads the key and button bindings.
-    @return True if loading succeeded.
-  */
-  void KeyDetector::loadBindings()
-  {
-    clearBindings();
-    setConfigValues();
-  }
+    /**
+    @brief
+        Loads the key and button bindings.
+    @return
+        True if loading succeeded.
+    */
+    void KeyDetector::loadBindings(const std::string& command)
+    {
+        this->command_ = command;
+        clearBindings();
+        setConfigValues();
+    }
 
-  void KeyDetector::readTrigger(Button& button)
-  {
-    SimpleCommand* cmd = new SimpleCommand();
-    cmd->evaluation_ = CommandExecutor::evaluate("storeKeyStroke " + button.name_);
-    button.commands_[KeybindMode::OnPress] = new BaseCommand*[1];
-    button.commands_[KeybindMode::OnPress][0] = cmd;
-    button.nCommands_[KeybindMode::OnPress] = 1;
-  }
+    void KeyDetector::readTrigger(Button& button)
+    {
+        SimpleCommand* cmd = new SimpleCommand();
+        cmd->evaluation_ = CommandExecutor::evaluate(this->command_ + " " + button.name_);
+        button.commands_[KeybindMode::OnPress] = new BaseCommand*[1];
+        button.commands_[KeybindMode::OnPress][0] = cmd;
+        button.nCommands_[KeybindMode::OnPress] = 1;
+    }
 }
Index: code/trunk/src/core/input/KeyDetector.h
===================================================================
--- code/trunk/src/core/input/KeyDetector.h	(revision 1754)
+++ code/trunk/src/core/input/KeyDetector.h	(revision 1755)
@@ -28,7 +28,8 @@
 
 /**
- @file
- @brief Different definitions of input processing.
- */
+@file
+@brief
+    Different definitions of input processing.
+*/
 
 #ifndef _KeyDetector_H__
@@ -41,14 +42,17 @@
 namespace orxonox
 {
-  class _CoreExport KeyDetector : public KeyBinder
-  {
-  public:
-    KeyDetector();
-    ~KeyDetector();
-    void loadBindings();
+    class _CoreExport KeyDetector : public KeyBinder
+    {
+    public:
+        KeyDetector();
+        ~KeyDetector();
+        void loadBindings(const std::string& command);
 
-  protected:
-    void readTrigger(Button& button);
-  };
+    protected:
+        void readTrigger(Button& button);
+
+    private:
+        std::string command_;
+    };
 }
 
Index: code/trunk/src/core/input/SimpleInputState.cc
===================================================================
--- code/trunk/src/core/input/SimpleInputState.cc	(revision 1755)
+++ code/trunk/src/core/input/SimpleInputState.cc	(revision 1755)
@@ -0,0 +1,270 @@
+/*
+ *   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 SimpleInputState class.
+*/
+
+#include "SimpleInputState.h"
+
+#include <assert.h>
+#include "util/Debug.h"
+#include "core/Executor.h"
+
+namespace orxonox
+{
+    using namespace InputDevice;
+
+    SimpleInputState::SimpleInputState()
+        : keyHandler_(0)
+        , mouseHandler_(0)
+        , joyStickHandlerAll_(0)
+    {
+    }
+
+    void SimpleInputState::numberOfJoySticksChanged(unsigned int n)
+    {
+        unsigned int oldSize = joyStickHandler_.size();
+        joyStickHandler_.resize(n);
+
+        if (n > oldSize)
+        {
+            // we have to add the handler in joyStickHandlerAll_ to the joyStickHandler_[>n]
+            for (unsigned int i = oldSize; i < n; ++i)
+            {
+                joyStickHandler_[i] = joyStickHandlerAll_;
+            }
+        }
+        update();
+    }
+
+    void SimpleInputState::keyPressed(const KeyEvent& evt)
+    {
+        if (keyHandler_)
+            keyHandler_->keyPressed(evt);
+    }
+
+    void SimpleInputState::keyReleased(const KeyEvent& evt)
+    {
+        if (keyHandler_)
+            keyHandler_->keyReleased(evt);
+    }
+
+    void SimpleInputState::keyHeld(const KeyEvent& evt)
+    {
+        if (keyHandler_)
+            keyHandler_->keyHeld(evt);
+    }
+
+
+    void SimpleInputState::mouseMoved(IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseMoved(abs, rel, clippingSize);
+    }
+
+    void SimpleInputState::mouseScrolled(int abs, int rel)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseScrolled(abs, rel);
+    }
+
+    void SimpleInputState::mouseButtonPressed(MouseButton::Enum id)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseButtonPressed(id);
+    }
+
+    void SimpleInputState::mouseButtonReleased(MouseButton::Enum id)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseButtonReleased(id);
+    }
+
+    void SimpleInputState::mouseButtonHeld(MouseButton::Enum id)
+    {
+        if (mouseHandler_)
+            mouseHandler_->mouseButtonHeld(id);
+    }
+
+
+    void SimpleInputState::joyStickAxisMoved(unsigned int joyStickID, unsigned int axis, float value)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickAxisMoved(joyStickID, axis, value);
+    }
+
+    void SimpleInputState::joyStickButtonPressed(unsigned int joyStickID, JoyStickButton::Enum id)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickButtonPressed(joyStickID, id);
+    }
+
+    void SimpleInputState::joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickButtonReleased(joyStickID, id);
+    }
+
+    void SimpleInputState::joyStickButtonHeld(unsigned int joyStickID, JoyStickButton::Enum id)
+    {
+        assert(joyStickID < joyStickHandler_.size());
+        if (joyStickHandler_[joyStickID])
+            joyStickHandler_[joyStickID]->joyStickButtonHeld(joyStickID, id);
+    }
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @param joyStickID
+        ID of the joy stick
+    @return
+        True if added, false otherwise.
+    */
+    bool SimpleInputState::setJoyStickHandler(JoyStickHandler* handler, unsigned int joyStickID)
+    {
+        if (joyStickID >= joyStickHandler_.size())
+            return false;
+
+        joyStickHandler_[joyStickID] = handler;
+        update();
+        return true;
+    }
+
+    /**
+    @brief
+        Adds a joy stick handler.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool SimpleInputState::setJoyStickHandler(JoyStickHandler* handler)
+    {
+        if (handler == joyStickHandlerAll_)
+            return false;
+
+        joyStickHandlerAll_ = handler;
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandler_.size(); ++iJoyStick)
+            setJoyStickHandler(handler, iJoyStick);
+        update();
+        return true;
+    }
+
+    void SimpleInputState::removeAndDestroyAllHandlers()
+    {
+        for (std::vector<InputTickable*>::iterator it = allHandlers_.begin();
+            it != allHandlers_.end(); ++it)
+            delete *it;
+
+        allHandlers_.clear();
+        keyHandler_ = 0;
+        mouseHandler_ = 0;
+        joyStickHandlerAll_ = 0;
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandler_.size(); ++iJoyStick)
+            joyStickHandler_[iJoyStick] = 0;
+
+        update();
+    }
+
+    /**
+    @brief
+        Adds a handler of any kind. dynamic_cast determines to which list it is added.
+    @param handler
+        Pointer to the handler object.
+    @return
+        True if added, false if handler already existed.
+    */
+    bool SimpleInputState::setHandler(InputTickable* handler)
+    {
+        setKeyHandler(dynamic_cast<KeyHandler*>(handler));
+        setMouseHandler(dynamic_cast<MouseHandler*>(handler));
+        return setJoyStickHandler(dynamic_cast<JoyStickHandler*>(handler));
+    }
+
+    void SimpleInputState::tickInput(float dt)
+    {
+        for (unsigned int i = 0; i < allHandlers_.size(); ++i)
+        {
+            allHandlers_[i]->tickInput(dt);
+        }
+    }
+
+    void SimpleInputState::tickInput(float dt, unsigned int device)
+    {
+        switch (device)
+        {
+        case Keyboard:
+            if (keyHandler_)
+                keyHandler_->tickKey(dt);
+            break;
+
+        case Mouse:
+            if (mouseHandler_)
+                mouseHandler_->tickMouse(dt);
+            break;
+
+        default: // joy sticks
+            if (joyStickHandler_[device - 2])
+                joyStickHandler_[device - 2]->tickJoyStick(dt, device - 2);
+            break;
+        }
+    }
+
+    void SimpleInputState::update()
+    {
+        // we can use a set to have a list of unique pointers (an object can implement all 3 handlers)
+        std::set<InputTickable*> tempSet;
+        if (keyHandler_)
+            tempSet.insert(keyHandler_);
+        if (mouseHandler_)
+            tempSet.insert(mouseHandler_);
+        for (unsigned int iJoyStick = 0; iJoyStick < joyStickHandler_.size(); iJoyStick++)
+            if (joyStickHandler_[iJoyStick])
+                tempSet.insert(joyStickHandler_[iJoyStick]);
+
+        // copy the content of the map back to the actual vector
+        allHandlers_.clear();
+        for (std::set<InputTickable*>::const_iterator itHandler = tempSet.begin();
+            itHandler != tempSet.end(); itHandler++)
+            allHandlers_.push_back(*itHandler);
+
+        // update the deviceEnabled options
+        setInputDeviceEnabled(Keyboard, (keyHandler_ != 0));
+        setInputDeviceEnabled(Mouse, (mouseHandler_ != 0));
+        for (unsigned int i = 0; i < joyStickHandler_.size(); ++i)
+            setInputDeviceEnabled(2 + i, (joyStickHandler_[i] != 0));
+    }
+}
Index: code/trunk/src/core/input/SimpleInputState.h
===================================================================
--- code/trunk/src/core/input/SimpleInputState.h	(revision 1755)
+++ code/trunk/src/core/input/SimpleInputState.h	(revision 1755)
@@ -0,0 +1,90 @@
+/*
+ *   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 
+*/
+
+#ifndef _SimpleInputState_H__
+#define _SimpleInputState_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+#include "InputInterfaces.h"
+#include "InputState.h"
+
+namespace orxonox
+{
+    class _CoreExport SimpleInputState : public InputState
+    {
+        friend class InputManager;
+
+    public:
+        void setKeyHandler        (KeyHandler* handler) { keyHandler_ = handler; update(); }
+        void setMouseHandler      (MouseHandler* handler) { mouseHandler_ = handler; update(); }
+        bool setJoyStickHandler   (JoyStickHandler* handler, unsigned int joyStickID);
+        bool setJoyStickHandler   (JoyStickHandler* handler);
+        bool setHandler(InputTickable* handler);
+        void removeAndDestroyAllHandlers();
+
+    private:
+        SimpleInputState();
+        ~SimpleInputState() { }
+
+        void tickInput(float dt);
+        void tickInput(float dt, unsigned int device);
+
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt);
+        void keyHeld    (const KeyEvent& evt);
+
+        void mouseButtonPressed (MouseButton::Enum id);
+        void mouseButtonReleased(MouseButton::Enum id);
+        void mouseButtonHeld    (MouseButton::Enum id);
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize);
+        void mouseScrolled      (int abs, int rel);
+
+        void joyStickButtonPressed (unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickButtonReleased(unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickButtonHeld    (unsigned int joyStickID, JoyStickButton::Enum id);
+        void joyStickAxisMoved     (unsigned int joyStickID, unsigned int axis, float value);
+
+        void update();
+        void numberOfJoySticksChanged(unsigned int n);
+
+        KeyHandler*                   keyHandler_;
+        MouseHandler*                 mouseHandler_;
+        std::vector<JoyStickHandler*> joyStickHandler_;
+        JoyStickHandler*              joyStickHandlerAll_;
+        std::vector<InputTickable*>   allHandlers_;
+    };
+}
+
+#endif /* _SimpleInputState_H__ */
Index: code/trunk/src/core/tolua/tolua.pkg
===================================================================
--- code/trunk/src/core/tolua/tolua.pkg	(revision 1754)
+++ code/trunk/src/core/tolua/tolua.pkg	(revision 1755)
@@ -1,1 +1,2 @@
-$cfile "../../src/core/Script_clean.h"
+$cfile "../../src/core/Script.h"
+$cfile "../../src/core/CommandExecutor.h"
Index: code/trunk/src/network/ClientConnection.cc
===================================================================
--- code/trunk/src/network/ClientConnection.cc	(revision 1754)
+++ code/trunk/src/network/ClientConnection.cc	(revision 1755)
@@ -42,4 +42,5 @@
 #include <iostream>
 // boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
 
Index: code/trunk/src/network/ClientConnection.h
===================================================================
--- code/trunk/src/network/ClientConnection.h	(revision 1754)
+++ code/trunk/src/network/ClientConnection.h	(revision 1755)
@@ -45,7 +45,8 @@
 #include <string>
 #include <enet/enet.h>
-#include <boost/thread/thread.hpp>
+#include <boost/thread/recursive_mutex.hpp>
+#include "PacketBuffer.h"
 
-#include "PacketBuffer.h"
+namespace boost { class thread; }
 
 namespace network
Index: code/trunk/src/network/ConnectionManager.cc
===================================================================
--- code/trunk/src/network/ConnectionManager.cc	(revision 1754)
+++ code/trunk/src/network/ConnectionManager.cc	(revision 1755)
@@ -41,4 +41,5 @@
 #include <assert.h>
 // boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
 
Index: code/trunk/src/network/ConnectionManager.h
===================================================================
--- code/trunk/src/network/ConnectionManager.h	(revision 1754)
+++ code/trunk/src/network/ConnectionManager.h	(revision 1755)
@@ -47,9 +47,10 @@
 // enet library for networking support
 #include <enet/enet.h>
-#include <boost/thread/thread.hpp>
 #include <boost/thread/recursive_mutex.hpp>
 
 #include "PacketBuffer.h"
 #include "packet/Packet.h"
+
+namespace boost { class thread; }
 
 namespace std
Index: code/trunk/src/network/GamestateManager.cc
===================================================================
--- code/trunk/src/network/GamestateManager.cc	(revision 1754)
+++ code/trunk/src/network/GamestateManager.cc	(revision 1755)
@@ -44,5 +44,5 @@
 #include <iostream>
 #include <zlib.h>
-#include <assert.h>
+#include <cassert>
 
 #include "core/CoreIncludes.h"
Index: code/trunk/src/network/Server.cc
===================================================================
--- code/trunk/src/network/Server.cc	(revision 1754)
+++ code/trunk/src/network/Server.cc	(revision 1755)
@@ -42,4 +42,5 @@
 
 #include <iostream>
+#include <cassert>
 
 
@@ -339,5 +340,5 @@
     if(!client)
       return false;
-    orxonox::Identifier* id = ID("SpaceShip");
+    orxonox::Identifier* id = GetIdentifier("SpaceShip");
     if(!id){
       COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl;
Index: code/trunk/src/network/Synchronisable.cc
===================================================================
--- code/trunk/src/network/Synchronisable.cc	(revision 1754)
+++ code/trunk/src/network/Synchronisable.cc	(revision 1755)
@@ -101,5 +101,5 @@
       return true;
     
-    orxonox::Identifier* id = ID(classID);
+    orxonox::Identifier* id = GetIdentifier(classID);
     if(!id){
       COUT(3) << "We could not identify a new object; classid: " << classID << " uint: " << (unsigned int)classID << " objectID: " << objectID << " size: " << size << std::endl;
Index: code/trunk/src/network/packet/ClassID.cc
===================================================================
--- code/trunk/src/network/packet/ClassID.cc	(revision 1754)
+++ code/trunk/src/network/packet/ClassID.cc	(revision 1755)
@@ -73,5 +73,5 @@
 bool ClassID::process(){
   COUT(3) << "processing classid: " << getClassID() << " name: " << (const char*)(data_+_CLASSNAME) << std::endl;
-  orxonox::Identifier *id=ID( std::string((const char*)(data_+_CLASSNAME) ));
+  orxonox::Identifier *id=GetIdentifier( std::string((const char*)(data_+_CLASSNAME) ));
   if(id==NULL)
     return false;
Index: code/trunk/src/orxonox/CMakeLists.txt
===================================================================
--- code/trunk/src/orxonox/CMakeLists.txt	(revision 1754)
+++ code/trunk/src/orxonox/CMakeLists.txt	(revision 1755)
@@ -2,5 +2,4 @@
   GraphicsEngine.cc
   Main.cc
-  Orxonox.cc
   Radar.cc
   RadarListener.cc
@@ -8,4 +7,19 @@
   Settings.cc
   SignalHandler.cc
+
+  gamestates/GSClient.cc
+  gamestates/GSDedicated.cc
+  gamestates/GSGraphics.cc
+  gamestates/GSGUI.cc
+  gamestates/GSIOConsole.cc
+  gamestates/GSLevel.cc
+  gamestates/GSRoot.cc
+  gamestates/GSServer.cc
+  gamestates/GSStandalone.cc
+
+  gui/GUIManager.cc
+  gui/OgreCEGUIRenderer.cpp
+  gui/OgreCEGUIResourceProvider.cpp
+  gui/OgreCEGUITexture.cpp
 
   overlays/OrxonoxOverlay.cc
@@ -55,6 +69,6 @@
 ADD_CUSTOM_COMMAND(
   OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/tolua/tolua_bind.cc
-  COMMAND ${TOLUA_EXE} -n orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg
-  DEPENDS tolua
+  COMMAND ${TOLUA_EXE} -n Orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg
+  DEPENDS tolua ${CMAKE_SOURCE_DIR}/src/orxonox/tolua/tolua.pkg
   WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
 )
@@ -84,4 +98,6 @@
   ${OGRE_LIBRARIES}
   ${Lua_LIBRARIES}
+  ${CEGUI_LIBRARIES}
+  ${CEGUI_SCRIPT_LIBRARIES}
   tinyxml
   tolualib
Index: code/trunk/src/orxonox/GraphicsEngine.cc
===================================================================
--- code/trunk/src/orxonox/GraphicsEngine.cc	(revision 1754)
+++ code/trunk/src/orxonox/GraphicsEngine.cc	(revision 1755)
@@ -22,460 +22,126 @@
  *   Author:
  *      Reto Grieder
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
  *   Co-authors:
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess
+ *      Felix Schulthess
  *
  */
 
- /**
-    @file orxonox.cc
-    @brief Orxonox class
-  */
+/**
+@file
+@brief
+    Implementation of an partial interface to Ogre.
+*/
 
 #include "OrxonoxStableHeaders.h"
 #include "GraphicsEngine.h"
 
-#include <fstream>
-
-#include <OgreConfigFile.h>
-#include <OgreException.h>
-#include <OgreLogManager.h>
-#include <OgreRoot.h>
-#include <OgreSceneManager.h>
-#include <OgreTextureManager.h>
-#include <OgreViewport.h>
+#include <OgreRenderWindow.h>
 
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
-#include "core/Iterator.h"
-#include "core/CommandExecutor.h"
-#include "core/ConsoleCommand.h"
 #include "util/Debug.h"
 
-#include "overlays/console/InGameConsole.h"
-#include "overlays/OverlayGroup.h"
 #include "tools/ParticleInterface.h"
-#include "Settings.h"
-#include "tools/WindowEventListener.h"
-
 
 namespace orxonox
 {
-  /**
-    @brief Returns the singleton instance and creates it the first time.
-    @return The only instance of GraphicsEngine.
-  */
-  /*static*/ GraphicsEngine& GraphicsEngine::getSingleton()
-  {
-    static GraphicsEngine theOnlyInstance;
-    return theOnlyInstance;
-  }
+    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
 
-  /**
-    @brief Only use constructor to initialise variables and pointers!
-  */
-  GraphicsEngine::GraphicsEngine() :
-    root_(0),
-    scene_(0),
-    renderWindow_(0)
-  {
-    RegisterObject(GraphicsEngine);
+    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
 
-    this->detailLevelParticle_ = 0;
-
-    this->setConfigValues();
-    CCOUT(4) << "Constructed" << std::endl;
-  }
-
-  void GraphicsEngine::setConfigValues()
-  {
-    SetConfigValue(resourceFile_,    "resources.cfg").description("Location of the resources file in the data path.");
-    SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
-    SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
-    SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
-                                                             Use \"\" to suppress log file creation.");
-    SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
-    SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
-    SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
-
-    SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
-  }
-
-  void GraphicsEngine::detailLevelParticleChanged()
-  {
-    for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
-      it->detailLevelChanged(this->detailLevelParticle_);
-  }
-
-  /**
-    @brief Called after main() --> call destroyObjects()!
-  */
-  GraphicsEngine::~GraphicsEngine()
-  {
-    this->destroy();
-  }
-
-  /**
-    @brief Destroys all the internal objects. Call this method when you
-           normally would call the destructor.
-  */
-  void GraphicsEngine::destroy()
-  {
-    CCOUT(4) << "Destroying objects..." << std::endl;
-    Ogre::WindowEventUtilities::removeWindowEventListener(this->renderWindow_, this);
-    if (this->root_)
-      delete this->root_;
-    this->root_ = 0;
-    this->scene_ = 0;
-    this->renderWindow_ = 0;
-    // delete the ogre log and the logManager (since we have created it).
-    if (Ogre::LogManager::getSingletonPtr() != 0)
+    /**
+    @brief
+        Returns the singleton instance.
+    @return
+        The only instance of GraphicsEngine.
+    */
+    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
     {
-      Ogre::LogManager::getSingleton().getDefaultLog()->removeListener(this);
-      Ogre::LogManager::getSingleton().destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
-      delete Ogre::LogManager::getSingletonPtr();
-    }
-    CCOUT(4) << "Destroying objects done" << std::endl;
-  }
-
-  /**
-    @brief Creates the Ogre Root object and sets up the ogre log.
-  */
-  bool GraphicsEngine::setup()
-  {
-    CCOUT(3) << "Setting up..." << std::endl;
-    // temporary overwrite of dataPath, change ini file for permanent change
-
-// TODO: LogManager doesn't work on specific systems. The why is unknown yet.
-#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
-    // create a logManager
-    // note: If there's already a logManager, Ogre will complain by a failed assertation.
-    // but that shouldn't happen, since this is the first time to create a logManager..
-    Ogre::LogManager* logger = new Ogre::LogManager();
-    CCOUT(4) << "Ogre LogManager created" << std::endl;
-
-    // create our own log that we can listen to
-    Ogre::Log *myLog;
-    if (this->ogreLogFile_ == "")
-      myLog = logger->createLog("ogre.log", true, false, true);
-    else
-      myLog = logger->createLog(this->ogreLogFile_, true, false, false);
-    CCOUT(4) << "Ogre Log created" << std::endl;
-
-    myLog->setLogDetail(Ogre::LL_BOREME);
-    myLog->addListener(this);
-#endif
-
-    // Root will detect that we've already created a Log
-    CCOUT(4) << "Creating Ogre Root..." << std::endl;
-
-    if (ogrePluginsFile_ == "")
-    {
-      COUT(1) << "Error: Ogre plugins file set to \"\". Cannot load." << std::endl;
-      return false;
-    }
-    if (ogreConfigFile_ == "")
-    {
-      COUT(1) << "Error: Ogre config file set to \"\". Cannot load." << std::endl;
-      return false;
-    }
-    if (ogreLogFile_ == "")
-    {
-      COUT(1) << "Error: Ogre log file set to \"\". Cannot load." << std::endl;
-      return false;
+        assert(singletonRef_s);
+        return *singletonRef_s;
     }
 
-    try
+    /**
+    @brief
+        Non-initialising constructor.
+    */
+    GraphicsEngine::GraphicsEngine()
+        : root_(0)
+        , renderWindow_(0)
+        , levelSceneManager_(0)
+        , viewport_(0)
     {
-      root_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
-    }
-    catch (Ogre::Exception ex)
-    {
-      COUT(2) << "Error: There was an exception when creating Ogre Root." << std::endl;
-      return false;
+        RegisterObject(GraphicsEngine);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->detailLevelParticle_ = 0;
+
+        this->setConfigValues();
+        CCOUT(4) << "Constructed" << std::endl;
     }
 
-    if (!root_->getInstalledPlugins().size())
+    void GraphicsEngine::setConfigValues()
     {
-      COUT(1) << "Error: No plugins declared. Cannot load Ogre." << std::endl;
-      COUT(0) << "Is the plugins file correctly declared?" << std::endl;
-      return false;
+        SetConfigValue(detailLevelParticle_, 2).description("O: off, 1: low, 2: normal, 3: high").callback(this, &GraphicsEngine::detailLevelParticleChanged);
     }
 
-#if 0
-    // tame the ogre ouput so we don't get all the mess in the console
-    Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
-    defaultLog->setDebugOutputEnabled(false);
-    defaultLog->setLogDetail(Ogre::LL_BOREME);
-    defaultLog->addListener(this);
-#endif
-
-    CCOUT(4) << "Creating Ogre Root done" << std::endl;
-
-    // specify where Ogre has to look for resources. This call doesn't parse anything yet!
-    if (!declareRessourceLocations())
-      return false;
-
-    CCOUT(3) << "Set up done." << std::endl;
-    return true;
-  }
-
-  bool GraphicsEngine::declareRessourceLocations()
-  {
-    CCOUT(4) << "Declaring Resources" << std::endl;
-    //TODO: Specify layout of data file and maybe use xml-loader
-    //TODO: Work with ressource groups (should be generated by a special loader)
-
-    if (resourceFile_ == "")
+    void GraphicsEngine::detailLevelParticleChanged()
     {
-      COUT(1) << "Error: Resource file set to \"\". Cannot load." << std::endl;
-      return false;
+        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
+            it->detailLevelChanged(this->detailLevelParticle_);
     }
 
-    // Load resource paths from data file using configfile ressource type
-    Ogre::ConfigFile cf;
-    try
+    /**
+    @brief
+        Destroys all the Ogre related objects
+    */
+    GraphicsEngine::~GraphicsEngine()
     {
-      cf.load(Settings::getDataPath() + resourceFile_);
-    }
-    catch (Ogre::Exception ex)
-    {
-      COUT(1) << "Error: Could not load resources.cfg in path " << Settings::getDataPath() << std::endl;
-      COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
-      return false;
+        singletonRef_s = 0;
     }
 
-    // Go through all sections & settings in the file
-    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-    std::string secName, typeName, archName;
-    while (seci.hasMoreElements())
+    /**
+    @brief
+        Get the width of the render window
+    @return
+        The width of the render window
+    */
+    int GraphicsEngine::getWindowWidth() const
     {
-      try
-      {
-        secName = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-        Ogre::ConfigFile::SettingsMultiMap::iterator i;
-        for (i = settings->begin(); i != settings->end(); ++i)
-        {
-          typeName = i->first; // for instance "FileSystem" or "Zip"
-          archName = i->second; // name (and location) of archive
-
-          Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
-              std::string(Settings::getDataPath() + archName), typeName, secName);
-        }
-      }
-      catch (Ogre::Exception ex)
-      {
-        COUT(2) << "Exception while reading resources.cfg. Proceeding.." << ex.getDescription() << std::endl;
-      }
-    }
-    return true;
-  }
-
-  bool GraphicsEngine::loadRenderer()
-  {
-    CCOUT(4) << "Configuring Renderer" << std::endl;
-
-    // check for file existence because Ogre displays exceptions if not
-    std::ifstream probe;
-    probe.open(ogreConfigFile_.c_str());
-    if (!probe)
-    {
-      // create a zero sized file
-      std::ofstream creator;
-      creator.open(ogreConfigFile_.c_str());
-      creator.close();
-    }
-    else
-      probe.close();
-
-    if (!root_->restoreConfig())
-      if (!root_->showConfigDialog())
-        return false;
-
-    CCOUT(4) << "Creating render window" << std::endl;
-    try
-    {
-      this->renderWindow_ = root_->initialise(true, "OrxonoxV2");
-    }
-    catch (Ogre::Exception ex)
-    {
-      COUT(2) << "Error: There was an exception when initialising Ogre Root." << std::endl;
-      return false;
+        if (this->renderWindow_)
+            return this->renderWindow_->getWidth();
+        else
+            return 0;
     }
 
-    if (!root_->isInitialised())
+    /**
+    @brief
+        Get the height of the render window
+    @return
+        The height of the render window
+    */
+    int GraphicsEngine::getWindowHeight() const
     {
-      CCOUT(2) << "Error: Initialising Ogre root object failed." << std::endl;
-      return false;
+        if (this->renderWindow_)
+            return this->renderWindow_->getHeight();
+        else
+            return 0;
     }
-    Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
-    Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
-    return true;
-  }
 
-  bool GraphicsEngine::initialiseResources()
-  {
-    CCOUT(4) << "Initialising resources" << std::endl;
-    //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
-    try
+    /**
+    @brief
+        Returns the window aspect ratio height/width.
+    @return
+        The window aspect ratio
+    */
+    float GraphicsEngine::getWindowAspectRatio() const
     {
-      Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
-      /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
-      for (unsigned int i = 0; i < str.size(); i++)
-      {
-        Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
-      }*/
+        if (this->renderWindow_)
+            return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
+        else
+            return 1.0f;
     }
-    catch (Ogre::Exception e)
-    {
-      CCOUT(2) << "Error: There was an Error when initialising the resources." << std::endl;
-      CCOUT(2) << "ErrorMessage: " << e.getFullDescription() << std::endl;
-      return false;
-    }
-    return true;
-  }
-
-  /**
-   * @brief Creates the SceneManager
-   */
-  bool GraphicsEngine::createNewScene()
-  {
-    CCOUT(4) << "Creating new SceneManager..." << std::endl;
-    if (scene_)
-    {
-      CCOUT(2) << "SceneManager already exists! Skipping." << std::endl;
-      return false;
-    }
-    scene_ = root_->createSceneManager(Ogre::ST_GENERIC, "Default SceneManager");
-    CCOUT(3) << "Created SceneManager: " << scene_ << std::endl;
-    return true;
-  }
-
-  /**
-    Returns the window handle of the render window.
-    At least the InputHandler uses this to create the OIS::InputManager
-    @return The window handle of the render window
-  */
-  size_t GraphicsEngine::getWindowHandle()
-  {
-    if (this->renderWindow_)
-    {
-      size_t windowHnd = 0;
-      this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
-      return windowHnd;
-    }
-    else
-      return 0;
-  }
-
-  /**
-    Get the width of the current render window
-    @return The width of the current render window
-  */
-  int GraphicsEngine::getWindowWidth() const
-  {
-    if (this->renderWindow_)
-      return this->renderWindow_->getWidth();
-    else
-      return 0;
-  }
-
-  /**
-    Get the height of the current render window
-    @return The height of the current render window
-  */
-  int GraphicsEngine::getWindowHeight() const
-  {
-    if (this->renderWindow_)
-      return this->renderWindow_->getHeight();
-    else
-      return 0;
-  }
-
-  /**
-    @brief Returns the window aspect ratio height/width.
-    @return The ratio
-  */
-  float GraphicsEngine::getWindowAspectRatio() const
-  {
-    if (this->renderWindow_)
-        return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
-    else
-        return 1.0f;
-  }
-
-  /**
-    @brief Method called by the LogListener interface from Ogre.
-    We use it to capture Ogre log messages and handle it ourselves.
-    @param message The message to be logged
-    @param lml The message level the log is using
-    @param maskDebug If we are printing to the console or not
-    @param logName the name of this log (so you can have several listeners
-                   for different logs, and identify them)
-  */
-  void GraphicsEngine::messageLogged(const std::string& message,
-    Ogre::LogMessageLevel lml, bool maskDebug, const std::string &logName)
-  {
-    int orxonoxLevel;
-    switch (lml)
-    {
-      case Ogre::LML_TRIVIAL:
-        orxonoxLevel = this->ogreLogLevelTrivial_;
-        break;
-      case Ogre::LML_NORMAL:
-        orxonoxLevel = this->ogreLogLevelNormal_;
-        break;
-      case Ogre::LML_CRITICAL:
-        orxonoxLevel = this->ogreLogLevelCritical_;
-        break;
-      default:
-        orxonoxLevel = 0;
-    }
-    OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
-        << "Ogre: " << message << std::endl;
-  }
-
-  /**
-  * Window has moved.
-  * @param rw The render window it occured in
-  */
-  void GraphicsEngine::windowMoved(Ogre::RenderWindow *rw)
-  {
-    for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-      it->windowMoved();
-  }
-
-  /**
-  * Window has resized.
-  * @param rw The render window it occured in
-  * @note GraphicsEngine has a render window stored itself. This is the same
-  *       as rw. But we have to be careful when using multiple render windows!
-  */
-  void GraphicsEngine::windowResized(Ogre::RenderWindow *rw)
-  {
-    for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-      it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
-  }
-
-  /**
-  * Window has changed Focus.
-  * @param rw The render window it occured in
-  */
-  void GraphicsEngine::windowFocusChanged(Ogre::RenderWindow *rw)
-  {
-    for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
-      it->windowFocusChanged();
-  }
-
-  /**
-  * Window was closed.
-  * @param rw The render window it occured in
-  */
-  void GraphicsEngine::windowClosed(Ogre::RenderWindow *rw)
-  {
-    // using CommandExecutor in order to avoid depending on Orxonox.h.
-    CommandExecutor::execute("exit", false);
-  }
-
 }
Index: code/trunk/src/orxonox/GraphicsEngine.h
===================================================================
--- code/trunk/src/orxonox/GraphicsEngine.h	(revision 1754)
+++ code/trunk/src/orxonox/GraphicsEngine.h	(revision 1755)
@@ -22,6 +22,7 @@
  *   Author:
  *      Reto Grieder
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
  *   Co-authors:
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007, Felix Schulthess
+ *      Felix Schulthess
  *
  */
@@ -41,9 +42,5 @@
 
 #include <OgrePrerequisites.h>
-#include <OgreLog.h>
-#include <OgreRenderWindow.h>
-#include <OgreWindowEventUtilities.h>
 #include "core/OrxonoxClass.h"
-
 
 namespace orxonox
@@ -52,68 +49,54 @@
     @brief Graphics engine manager class
     */
-    class _OrxonoxExport GraphicsEngine : public Ogre::WindowEventListener, public Ogre::LogListener, public OrxonoxClass
+    class _OrxonoxExport GraphicsEngine : public OrxonoxClass
     {
-        public:
-            void setConfigValues();
-            void detailLevelParticleChanged();
-            bool setup();
-            bool declareRessourceLocations();
-            bool loadRenderer();
-            bool initialiseResources();
-            bool createNewScene();
+        // HACK: temporary means
+        friend class GSGraphics;
 
-            void destroy();
+    public:
+        GraphicsEngine();
+        ~GraphicsEngine();
 
-            Ogre::SceneManager* getSceneManager() { return scene_; }
+        void setConfigValues();
+        void detailLevelParticleChanged();
 
-            // several window properties
-            Ogre::RenderWindow* getRenderWindow() { return this->renderWindow_; }
-            size_t getWindowHandle();
-            int getWindowWidth() const;
-            int getWindowHeight() const;
-            float getWindowAspectRatio() const;
-            float getAverageFramesPerSecond() const { return this->avgFramesPerSecond_; }
-            float getAverageTickTime() const { return this->avgTickTime_; }
-            void setAverageTickTime(float tickTime) { this->avgTickTime_ = tickTime; }
-            void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
+        void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
+        Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
 
-            void setWindowActivity(bool activity)
-            { if (this->renderWindow_) this->renderWindow_->setActive(activity); }
+        Ogre::Viewport* getViewport() { return this->viewport_; }
+        Ogre::Root*     getOgreRoot() { return this->root_; }
 
-            void windowMoved       (Ogre::RenderWindow* rw);
-            void windowResized     (Ogre::RenderWindow* rw);
-            void windowFocusChanged(Ogre::RenderWindow* rw);
-            void windowClosed      (Ogre::RenderWindow* rw);
+        // several window properties
+        int getWindowWidth() const;
+        int getWindowHeight() const;
+        float getWindowAspectRatio() const;
+        float getAverageFramesPerSecond() const   { return this->avgFramesPerSecond_; }
+        float getAverageTickTime() const          { return this->avgTickTime_; }
+        void setAverageTickTime(float tickTime)   { this->avgTickTime_ = tickTime; }
+        void setAverageFramesPerSecond(float fps) { this->avgFramesPerSecond_ = fps; }
 
-            inline unsigned int getDetailLevelParticle() const
-              { return this->detailLevelParticle_; }
+        inline unsigned int getDetailLevelParticle() const
+        { return this->detailLevelParticle_; }
 
-            static GraphicsEngine& getSingleton();
-            static GraphicsEngine* getSingletonPtr() { return &getSingleton(); }
+        static GraphicsEngine& getInstance();
+        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
 
+    private:
+        // don't mess with singletons
+        GraphicsEngine(GraphicsEngine&);
 
-        private:
-            // don't mess with singletons
-            GraphicsEngine();
-            ~GraphicsEngine();
-            GraphicsEngine(GraphicsEngine&) { }
+        Ogre::Root*         root_;                  //!< Ogre's root
+        Ogre::RenderWindow* renderWindow_;          //!< the current render window
+        Ogre::SceneManager* levelSceneManager_;     //!< scene manager of the game
+        Ogre::Viewport*     viewport_;              //!< default full size viewport
 
-            //! Method called by the LogListener from Ogre
-            void messageLogged(const std::string&, Ogre::LogMessageLevel,
-                             bool, const std::string&);
+        // stats
+        float               avgTickTime_;           //!< time in ms to tick() one frame
+        float               avgFramesPerSecond_;    //!< number of frames processed in one second
 
-            Ogre::Root*         root_;                  //!< Ogre's root
-            Ogre::SceneManager* scene_;                 //!< scene manager of the game
-            Ogre::RenderWindow* renderWindow_;          //!< the current render window
-            std::string         resourceFile_;          //!< resources file name
-            std::string         ogreConfigFile_;        //!< ogre config file name
-            std::string         ogrePluginsFile_;       //!< ogre plugins file name
-            std::string         ogreLogFile_;           //!< log file name for Ogre log messages
-            int                 ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
-            int                 ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
-            int                 ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
-            unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
-            float               avgTickTime_;           //!< time in ms to tick() one frame
-            float               avgFramesPerSecond_;    //!< number of frames processed in one second
+        // config values
+        unsigned int        detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
+
+        static GraphicsEngine* singletonRef_s;      //!< Pointer to the Singleton
     };
 }
Index: code/trunk/src/orxonox/Main.cc
===================================================================
--- code/trunk/src/orxonox/Main.cc	(revision 1754)
+++ code/trunk/src/orxonox/Main.cc	(revision 1755)
@@ -22,4 +22,5 @@
  *   Author:
  *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *      Reto Grieder
  *   Co-authors:
  *      ...
@@ -35,10 +36,21 @@
 
 #include <exception>
+#include <cassert>
 
 #include "util/OrxonoxPlatform.h"
 #include "SignalHandler.h"
-#include "Orxonox.h"
+#include "util/Debug.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"
 
 using namespace orxonox;
+
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
 #include <CoreFoundation/CoreFoundation.h>
@@ -49,55 +61,57 @@
              std::string macBundlePath()
 {
-  char path[1024];
-  CFBundleRef mainBundle = CFBundleGetMainBundle();
-  assert(mainBundle);
+    char path[1024];
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    assert(mainBundle);
 
-  CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
-  assert(mainBundleURL);
+    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+    assert(mainBundleURL);
 
-  CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
-  assert(cfStringRef);
+    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
+    assert(cfStringRef);
 
-  CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
+    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
 
-  CFRelease(mainBundleURL);
-  CFRelease(cfStringRef);
+    CFRelease(mainBundleURL);
+    CFRelease(cfStringRef);
 
-  return std::string(path);
+    return std::string(path);
 }
 #endif
 
-#ifdef __cplusplus
-extern "C" {
-#endif
 
-int main(int argc, char **argv)
+//#ifdef __cplusplus
+//extern "C" {
+//#endif
+
+int main(int argc, char** argv)
 {
-  //try {
+    // create a signal handler (only works for linux)
     SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
-    Orxonox* orx = Orxonox::getSingleton();
 
-    bool res = false;
-#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
-    res = orx->init(argc, argv, macBundlePath());
-#else
-    res = orx->init(argc, argv);
-#endif
+    GSRoot root;
+    GSGraphics graphics;
+    GSStandalone standalone;
+    GSServer server;
+    GSClient client;
+    GSDedicated dedicated;
+    GSGUI gui;
+    GSIOConsole ioConsole;
 
-    if (res)
-      orx->start();
-    orx->destroySingleton();
-  /*}
-  catch (std::exception &ex)
-  {
-    std::cerr << "Exception:\n";
-    std::cerr << ex.what() << "\n";
-    return 1;
-  }*/
+    root.addChild(&graphics);
+    graphics.addChild(&standalone);
+    graphics.addChild(&server);
+    graphics.addChild(&client);
+    graphics.addChild(&gui);
 
-  return 0;
+    root.addChild(&ioConsole);
+    root.addChild(&dedicated);
+
+    root.start(argc, argv);
+
+    return 0;
 }
 
-#ifdef __cplusplus
-}
-#endif
+//#ifdef __cplusplus
+//}
+//#endif
Index: code/trunk/src/orxonox/Orxonox.cc
===================================================================
--- code/trunk/src/orxonox/Orxonox.cc	(revision 1754)
+++ 	(revision )
@@ -1,534 +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:
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *
- */
-
-/**
- @file
- @brief Orxonox Main Class
- */
-
-// Precompiled Headers
-#include "OrxonoxStableHeaders.h"
-#include "Orxonox.h"
-
-//****** STD *******
-#include <deque>
-
-//****** OGRE ******
-#include <OgreFrameListener.h>
-#include <OgreOverlay.h>
-#include <OgreOverlayManager.h>
-#include <OgreRoot.h>
-#include <OgreTimer.h>
-#include <OgreWindowEventUtilities.h>
-
-//***** ORXONOX ****
-// util
-//#include "util/Sleep.h"
-#include "util/ArgReader.h"
-
-// core
-#include "core/ConfigFileManager.h"
-#include "core/CoreIncludes.h"
-#include "core/Iterator.h"
-#include "core/ConsoleCommand.h"
-#include "core/Loader.h"
-#include "core/input/InputManager.h"
-#include "core/TclBind.h"
-#include "core/Core.h"
-#include "util/Debug.h"
-
-// audio
-#include "audio/AudioManager.h"
-
-// network
-#include "network/Server.h"
-#include "network/Client.h"
-
-// objects and tools
-#include "overlays/OverlayGroup.h"
-#include "overlays/console/InGameConsole.h"
-#include "objects/Tickable.h"
-#include "objects/Backlight.h"
-#include "tools/ParticleInterface.h"
-
-#include "GraphicsEngine.h"
-#include "Settings.h"
-#include "Radar.h"
-
-// globals for the server or client
-static network::Client *client_g = 0;
-static network::Server *server_g = 0;
-
-namespace orxonox
-{
-  SetConsoleCommandShortcut(Orxonox, exit).keybindMode(KeybindMode::OnPress);
-  SetConsoleCommandShortcut(Orxonox, slomo).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
-  SetConsoleCommandShortcut(Orxonox, setTimeFactor).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
-
-  /**
-    @brief Reference to the only instance of the class.
-  */
-  Orxonox *Orxonox::singletonRef_s = 0;
-
-  /**
-   * Create a new instance of Orxonox. Avoid doing any actual work here.
-   */
-  Orxonox::Orxonox()
-    : ogre_(0)
-    , startLevel_(0)
-    , hud_(0)
-    , radar_(0)
-    //, auMan_(0)
-    , timer_(0)
-    , bAbort_(false)
-    , timefactor_(1.0f)
-    , mode_(STANDALONE)
-    , serverIp_("")
-    , serverPort_(NETWORK_PORT)
-  {
-  }
-
-  /**
-   * Destruct Orxonox.
-   */
-  Orxonox::~Orxonox()
-  {
-    // keep in mind: the order of deletion is very important!
-    Loader::unload(startLevel_);
-    if (this->startLevel_)
-      delete this->startLevel_;
-
-    Loader::unload(hud_);
-    if (this->hud_)
-      delete this->hud_;
-
-    if (this->radar_)
-      delete this->radar_;
-
-    Loader::close();
-    //if (this->auMan_)
-    //  delete this->auMan_;
-    InGameConsole::getInstance().destroy();
-    if (this->timer_)
-      delete this->timer_;
-    InputManager::destroy();
-    GraphicsEngine::getSingleton().destroy();
-
-    if (client_g)
-      delete client_g;
-    if (server_g)
-      delete server_g;
-  }
-
-
-  /**
-    Asks the mainloop nicely to abort.
-  */
-  void Orxonox::abortRequest()
-  {
-    COUT(3) << "Orxonox: Abort requested." << std::endl;
-    bAbort_ = true;
-  }
-
-  /**
-   * @return singleton reference
-   */
-  Orxonox* Orxonox::getSingleton()
-  {
-    if (!singletonRef_s)
-      singletonRef_s = new Orxonox();
-    return singletonRef_s;
-  }
-
-  /**
-    @brief Destroys the Orxonox singleton.
-  */
-  void Orxonox::destroySingleton()
-  {
-    if (singletonRef_s)
-      delete singletonRef_s;
-    singletonRef_s = 0;
-  }
-
-  /**
-    @brief Changes the speed of Orxonox
-  */
-  void Orxonox::setTimeFactor(float factor)
-  {
-    float change = factor / Orxonox::getSingleton()->getTimeFactor();
-    Orxonox::getSingleton()->timefactor_ = factor;
-    for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
-        it->setSpeedFactor(it->getSpeedFactor() * change);
-
-    for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
-        it->setTimeFactor(Orxonox::getSingleton()->getTimeFactor());
-  }
-
-  /**
-   * initialization of Orxonox object
-   * @param argc argument counter
-   * @param argv list of argumenst
-   * @param path path to config (in home dir or something)
-   */
-  bool Orxonox::init(int argc, char **argv)
-  {
-#ifdef _DEBUG
-    ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox_d.ini");
-#else
-    ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox.ini");
-#endif
-    Factory::createClassHierarchy();
-
-    std::string mode;
-    std::string tempDataPath;
-
-    ArgReader ar(argc, argv);
-    ar.checkArgument("mode", &mode, false);
-    ar.checkArgument("data", &tempDataPath, false);
-    ar.checkArgument("ip",   &serverIp_, false);
-    ar.checkArgument("port", &serverPort_, false);
-    if(ar.errorHandling())
-    {
-      COUT(1) << "Error while parsing command line arguments" << std::endl;
-      COUT(1) << ar.getErrorString();
-      COUT(0) << "Usage:" << std::endl << "orxonox [mode client|server|dedicated|standalone] "
-        << "[--data PATH] [--ip IP] [--port PORT]" << std::endl;
-      return false;
-    }
-
-    if (mode == "client")
-      mode_ = CLIENT;
-    else if (mode == "server")
-      mode_ = SERVER;
-    else if (mode == "dedicated")
-      mode_ = DEDICATED;
-    else
-    {
-      if (mode == "")
-        mode = "standalone";
-      if (mode != "standalone")
-      {
-        COUT(2) << "Warning: mode \"" << mode << "\" doesn't exist. "
-          << "Defaulting to standalone" << std::endl;
-        mode = "standalone";
-      }
-      mode_ = STANDALONE;
-    }
-    COUT(3) << "Orxonox: Mode is " << mode << "." << std::endl;
-
-    if (tempDataPath != "")
-    {
-      if (tempDataPath[tempDataPath.size() - 1] != '/')
-        tempDataPath += "/";
-      Settings::tsetDataPath(tempDataPath);
-    }
-
-    // initialise TCL
-    TclBind::getInstance().setDataPath(Settings::getDataPath());
-
-    //if (mode_ == DEDICATED)
-      // TODO: decide what to do here
-    //else
-
-    // for playable server, client and standalone, the startup
-    // procedure until the GUI is identical
-
-    ogre_ = &GraphicsEngine::getSingleton();
-    if (!ogre_->setup())       // creates ogre root and other essentials
-      return false;
-
-    return true;
-  }
-
-  /**
-   * start modules
-   */
-  bool Orxonox::start()
-  {
-    if (mode_ == DEDICATED)
-    {
-      // do something else
-    }
-    else
-    { // not dedicated server
-      if (!ogre_->loadRenderer())    // creates the render window
-        return false;
-
-      // TODO: Spread this so that this call only initialises things needed for the Console
-      if (!ogre_->initialiseResources())
-        return false;
-
-      // Load the InGameConsole
-      InGameConsole::getInstance().initialise();
-
-      // Calls the InputManager which sets up the input devices.
-      // The render window width and height are used to set up the mouse movement.
-      if (!InputManager::initialise(ogre_->getWindowHandle(),
-            ogre_->getWindowWidth(), ogre_->getWindowHeight(), true, true, true))
-        return false;
-
-      // TOOD: load the GUI here
-      // set InputManager to GUI mode
-      InputManager::setInputState(InputManager::IS_GUI);
-      // TODO: run GUI here
-
-      // The following lines depend very much on the GUI output, so they're probably misplaced here..
-
-      InputManager::setInputState(InputManager::IS_NONE);
-
-      // create Ogre SceneManager
-      ogre_->createNewScene();
-
-      if (!loadPlayground())
-        return false;
-    }
-
-    switch (mode_)
-    {
-    case SERVER:
-      if (!serverLoad())
-        return false;
-      break;
-    case CLIENT:
-      if (!clientLoad())
-        return false;
-      break;
-    case DEDICATED:
-      if (!serverLoad())
-        return false;
-      break;
-    default:
-      if (!standaloneLoad())
-        return false;
-    }
-
-    InputManager::setInputState(InputManager::IS_NORMAL);
-
-    return startRenderLoop();
-  }
-
-  /**
-   * Loads everything in the scene except for the actual objects.
-   * This includes HUD, audio..
-   */
-  bool Orxonox::loadPlayground()
-  {
-    // Init audio
-    //auMan_ = new audio::AudioManager();
-    //auMan_->ambientAdd("a1");
-    //auMan_->ambientAdd("a2");
-    //auMan_->ambientAdd("a3");
-    //auMan->ambientAdd("ambient1");
-    //auMan_->ambientStart();
-
-    // Load the HUD
-    COUT(3) << "Orxonox: Loading HUD" << std::endl;
-    hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
-    Loader::load(hud_);
-
-    // Start the Radar
-    this->radar_ = new Radar();
-
-    return true;
-  }
-
-  /**
-   * Level loading method for server mode.
-   */
-  bool Orxonox::serverLoad()
-  {
-    COUT(0) << "Loading level in server mode" << std::endl;
-
-    server_g = new network::Server(serverPort_);
-    COUT(0) << "Loading scene in server mode" << std::endl;
-    if (!loadScene())
-      return false;
-
-    server_g->open();
-
-    return true;
-  }
-
-  /**
-   * Level loading method for client mode.
-   */
-  bool Orxonox::clientLoad()
-  {
-    COUT(0) << "Loading level in client mode" << std::endl;\
-
-    if (serverIp_.compare("") == 0)
-      client_g = new network::Client();
-    else
-
-      client_g = new network::Client(serverIp_, serverPort_);
-
-    if(!client_g->establishConnection())
-      return false;
-    client_g->tick(0);
-
-    return true;
-  }
-
-  /**
-   * Level loading method for standalone mode.
-   */
-  bool Orxonox::standaloneLoad()
-  {
-    COUT(0) << "Loading level in standalone mode" << std::endl;
-
-    if (!loadScene())
-      return false;
-
-    return true;
-  }
-
-  /**
-   * Helper method to load a level.
-   */
-  bool Orxonox::loadScene()
-  {
-    startLevel_ = new Level("levels/sample.oxw");
-    Loader::open(startLevel_);
-
-    return true;
-  }
-
-
-  /**
-    Main loop of the orxonox game.
-    About the loop: The design is almost exactly like the one in ogre, so that
-    if any part of ogre registers a framelisteners, it will still behave
-    correctly. Furthermore the time smoothing feature from ogre has been
-    implemented too. If turned on (see orxonox constructor), it will calculate
-    the dt_n by means of the recent most dt_n-1, dt_n-2, etc.
-  */
-  bool Orxonox::startRenderLoop()
-  {
-    // first check whether ogre root object has been created
-    if (Ogre::Root::getSingletonPtr() == 0)
-    {
-      COUT(2) << "Orxonox Error: Could not start rendering. No Ogre root object found" << std::endl;
-      return false;
-    }
-    Ogre::Root& ogreRoot = Ogre::Root::getSingleton();
-
-
-    // use the ogre timer class to measure time.
-    if (!timer_)
-      timer_ = new Ogre::Timer();
-
-    unsigned long frameCount = 0;
-
-    // TODO: this would very well fit into a configValue
-    const unsigned long refreshTime = 200000;
-    unsigned long refreshStartTime = 0;
-    unsigned long tickTime = 0;
-    unsigned long oldFrameCount = 0;
-
-    unsigned long timeBeforeTick = 0;
-    unsigned long timeBeforeTickOld = 0;
-    unsigned long timeAfterTick = 0;
-
-    COUT(3) << "Orxonox: Starting the main loop." << std::endl;
-
-    timer_->reset();
-    while (!bAbort_)
-    {
-      // get current time
-      timeBeforeTickOld = timeBeforeTick;
-      timeBeforeTick    = timer_->getMicroseconds();
-      float dt = (timeBeforeTick - timeBeforeTickOld) / 1000000.0;
-
-
-      // tick the core (needs real time for input and tcl thread management)
-      Core::tick(dt);
-
-      // Call those objects that need the real time
-      for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
-        it->tick(dt);
-      // Call the scene objects
-      for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
-        it->tick(dt * this->timefactor_);
-
-      // call server/client with normal dt
-      if (client_g)
-        client_g->tick(dt * this->timefactor_);
-      if (server_g)
-        server_g->tick(dt * this->timefactor_);
-
-
-      // get current time once again
-      timeAfterTick = timer_->getMicroseconds();
-
-      tickTime += timeAfterTick - timeBeforeTick;
-      if (timeAfterTick > refreshStartTime + refreshTime)
-      {
-        GraphicsEngine::getSingleton().setAverageTickTime(
-            (float)tickTime * 0.001 / (frameCount - oldFrameCount));
-        GraphicsEngine::getSingleton().setAverageFramesPerSecond(
-            (float)(frameCount - oldFrameCount) / (timeAfterTick - refreshStartTime) * 1000000.0);
-        oldFrameCount = frameCount;
-        tickTime = 0;
-        refreshStartTime = timeAfterTick;
-      }
-
-
-      // don't forget to call _fireFrameStarted in ogre to make sure
-      // everything goes smoothly
-      Ogre::FrameEvent evt;
-      evt.timeSinceLastFrame = dt;
-      evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
-      ogreRoot._fireFrameStarted(evt);
-
-      if (mode_ != DEDICATED)
-      {
-        // Pump messages in all registered RenderWindows
-        // This calls the WindowEventListener objects.
-        Ogre::WindowEventUtilities::messagePump();
-        // make sure the window stays active even when not focused
-        // (probably only necessary on windows)
-        GraphicsEngine::getSingleton().setWindowActivity(true);
-
-        // render
-        ogreRoot._updateAllRenderTargets();
-      }
-
-      // again, just to be sure ogre works fine
-      ogreRoot._fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
-
-      ++frameCount;
-    }
-
-    if (mode_ == CLIENT)
-      client_g->closeConnection();
-    else if (mode_ == SERVER)
-      server_g->close();
-
-    return true;
-  }
-}
Index: code/trunk/src/orxonox/Orxonox.h
===================================================================
--- code/trunk/src/orxonox/Orxonox.h	(revision 1754)
+++ 	(revision )
@@ -1,110 +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:
- *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
- *
- */
-
-/**
- @file  Orxonox.h
- @brief Main Orxonox Class File
- @author Benjamin Knecht <beni_at_orxonox.net>
- */
-
-#ifndef _Orxonox_H__
-#define _Orxonox_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-
-#include <OgrePrerequisites.h>
-#include "audio/AudioPrereqs.h"
-
-#include "GraphicsEngine.h"
-
-namespace orxonox {
-
-  enum gameMode{
-    SERVER,
-    CLIENT,
-    STANDALONE,
-    DEDICATED
-  };
-
-  //! Orxonox singleton class
-  class _OrxonoxExport Orxonox
-  {
-    public:
-      bool init(int argc, char **argv);
-      bool start();
-
-      void abortRequest();
-
-      static Orxonox* getSingleton();
-      static void destroySingleton();
-
-      static inline void slomo(float factor) { Orxonox::setTimeFactor(factor); }
-      static void setTimeFactor(float factor = 1.0);
-      static inline float getTimeFactor() { return Orxonox::getSingleton()->timefactor_; }
-      static inline void exit() { Orxonox::getSingleton()->abortRequest(); }
-
-   private:
-      // don't mess with singletons
-      Orxonox();
-      Orxonox(Orxonox& instance);
-      Orxonox& operator=(const Orxonox& instance);
-      ~Orxonox();
-
-      bool loadPlayground();
-
-      bool serverLoad();
-      bool clientLoad();
-      bool standaloneLoad();
-
-      bool loadScene();
-
-      bool startRenderLoop();
-
-      float calculateEventTime(unsigned long, std::deque<unsigned long>&);
-
-    private:
-      GraphicsEngine*       ogre_;          //!< our dearest graphics engine <3
-      Level*                startLevel_;    //!< current hard coded default level
-      Level*                hud_;           //!< 'level' object fo the HUD
-      Radar*                radar_;         //!< represents the Radar (not the HUD part)
-      //audio::AudioManager*  auMan_;         //!< audio manager
-      Ogre::Timer*          timer_;         //!< Main loop timer
-      bool                  bAbort_;        //!< aborts the render loop if true
-      float                 timefactor_;    //!< A factor to change the gamespeed
-
-      // this is used to identify the mode (server/client/...) we're in
-      gameMode              mode_;
-      std::string           serverIp_;
-      int                   serverPort_;
-
-      static Orxonox *singletonRef_s;
-  };
-}
-#endif /* _Orxonox_H__ */
Index: code/trunk/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 1754)
+++ code/trunk/src/orxonox/OrxonoxPrereqs.h	(revision 1755)
@@ -74,5 +74,5 @@
 
     class GraphicsEngine;
-    class Orxonox;
+    class Settings;
 
     class RadarViewable;
@@ -84,5 +84,4 @@
     class Backlight;
     class Camera;
-    class Fighter;
     class Model;
     class NPC;
@@ -118,4 +117,18 @@
     class OverlayGroup;
     class OverlayText;
+
+    //gui
+    class GUIManager;
+
+    // game states
+    class GSRoot;
+    class GSGraphics;
+    class GSIO;
+    class GSIOConsole;
+    class GSLevel;
+    class GSStandalone;
+    class GSServer;
+    class GSClient;
+    class GSGUI;
 }
 
@@ -128,3 +141,14 @@
 }
 
+namespace CEGUI
+{
+    class LuaScriptModule;
+
+    class OgreCEGUIRenderer;
+    class OgreCEGUIResourceProvider;
+    class OgreCEGUITexture;
+}
+
+struct lua_State;
+
 #endif /* _OrxonoxPrereqs_H__ */
Index: code/trunk/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- code/trunk/src/orxonox/OrxonoxStableHeaders.h	(revision 1754)
+++ code/trunk/src/orxonox/OrxonoxStableHeaders.h	(revision 1755)
@@ -28,6 +28,6 @@
 
 /**
- @file  OrxonoxStableHeaders.h
- @brief Contains the bigger (or smaller) header files in order to precompile them with MSVC
+ @file
+ @brief Contains the frequently used header files of our own writing
  */
 
@@ -37,5 +37,5 @@
 #include "util/OrxonoxPlatform.h"
 
-#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH)
 
 // including std headers here is useless since they're already precompiled
@@ -45,49 +45,19 @@
 #  define WIN32_LEAN_AND_MEAN
 #endif
-// not including the entire Ogre.h doesn't exceed the default heap size for pch
-//#include <Ogre.h>
-#include <OgreBillboardSet.h>
-#include <OgreCamera.h>
-#include <OgreColourValue.h>
-#include <OgreConfigFile.h>
-#include <OgreEntity.h>
-#include <OgreException.h>
-#include <OgreFrameListener.h>
-#include <OgreLight.h>
-#include <OgreLog.h>
-#include <OgreLogManager.h>
-#include <OgreMath.h>
-#include <OgreMatrix3.h>
-#include <OgreMatrix4.h>
-#include <OgreMesh.h>
-#include <OgreOverlay.h>
-#include <OgreOverlayElement.h>
-#include <OgreOverlayManager.h>
-#include <OgreParticleEmitter.h>
-#include <OgreParticleSystem.h>
-#include <OgreQuaternion.h>
-#include <OgreResourceGroupManager.h>
-#include <OgreRenderWindow.h>
-#include <OgreRoot.h>
-#include <OgreSceneManager.h>
-#include <OgreSceneNode.h>
-#include <OgreString.h>
-#include <OgreStringConverter.h>
-#include <OgreTextureManager.h>
-#include <OgreTimer.h>
-#include <OgreVector2.h>
-#include <OgreVector3.h>
-#include <OgreVector3.h>
-#include <OgreViewport.h>
-#include <OgreWindowEventUtilities.h>
+#include <Ogre.h>
+#include <CEGUI.h>
+#include <boost/thread/recursive_mutex.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread/thread.hpp>
 
-//-----------------------------------------------------------------------
-// ORXONOX HEADERS
-//-----------------------------------------------------------------------
-
-#include "ois/OIS.h"
-#include "cpptcl/CppTcl.h"
 #include "tinyxml/ticpp.h"
 #include "tinyxml/tinyxml.h"
+
+
+//----------- Our files ----------
+//--------------------------------
+// only include when not debugging so that we may find issues with missing headers quicker
+#if defined(NDEBUG)
 
 #include "util/Convert.h"
@@ -106,4 +76,5 @@
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
+#include "core/CommandExecutor.h"
 #include "core/Executor.h"
 #include "core/XMLPort.h"
@@ -117,5 +88,7 @@
 //#include "objects/WorldEntity.h"
 
-#endif /* Compiler MSVC */
+#endif /* ifdef NDEBUG */
+
+#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
 
 #endif /* _OrxonoxStableHeaders_H__ */
Index: code/trunk/src/orxonox/Radar.cc
===================================================================
--- code/trunk/src/orxonox/Radar.cc	(revision 1754)
+++ code/trunk/src/orxonox/Radar.cc	(revision 1755)
@@ -34,5 +34,6 @@
 #include "OrxonoxStableHeaders.h"
 #include "Radar.h"
-#include <float.h>
+#include <cfloat>
+#include <cassert>
 #include "objects/WorldEntity.h"
 #include "objects/SpaceShip.h"
Index: code/trunk/src/orxonox/RadarViewable.h
===================================================================
--- code/trunk/src/orxonox/RadarViewable.h	(revision 1754)
+++ code/trunk/src/orxonox/RadarViewable.h	(revision 1755)
@@ -32,4 +32,5 @@
 #include "OrxonoxPrereqs.h"
 #include <string>
+#include <cassert>
 #include "util/Math.h"
 #include "util/Debug.h"
Index: code/trunk/src/orxonox/Settings.cc
===================================================================
--- code/trunk/src/orxonox/Settings.cc	(revision 1754)
+++ code/trunk/src/orxonox/Settings.cc	(revision 1755)
@@ -28,6 +28,7 @@
 
 /**
-    @file
-    @brief Implementation of the Settings class.
+@file
+@brief
+    Implementation of the Settings class.
 */
 
@@ -35,4 +36,5 @@
 #include "Settings.h"
 
+#include "util/String.h"
 #include "core/CoreIncludes.h"
 #include "core/ConfigValueIncludes.h"
@@ -40,73 +42,57 @@
 namespace orxonox
 {
-  /**
-    @brief Constructor: Registers the object and sets the config-values.
-  */
-  Settings::Settings()
-  {
-    RegisterRootObject(Settings);
-    setConfigValues();
-  }
+    Settings* Settings::singletonRef_s = 0;
 
-  Settings::~Settings()
-  {
-  }
-
-  /**
-    @brief Returns a unique instance of Core.
-    @return The instance
-  */
-  Settings& Settings::getSingleton()
-  {
-    static Settings instance;
-    return instance;
-  }
-
-  /**
-    @brief Function to collect the SetConfigValue-macro calls.
-  */
-  void Settings::setConfigValues()
-  {
-    SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
-  }
-
-  /**
-    @brief Callback function if the datapath has changed.
-  */
-  void Settings::dataPathChanged()
-  {
-    if (dataPath_ != "" && dataPath_[dataPath_.size() - 1] != '/')
+    /**
+    @brief
+        Constructor: Registers the object and sets the config-values.
+    */
+    Settings::Settings()
+        : bShowsGraphics_(false)
+        , bHasServer_(false)
     {
-      ModifyConfigValue(dataPath_, set, dataPath_ + "/");
+        RegisterRootObject(Settings);
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+        setConfigValues();
     }
 
-    if (dataPath_ == "")
+    /**
+    @brief
+        Function to collect the SetConfigValue-macro calls.
+    */
+    void Settings::setConfigValues()
     {
-      ModifyConfigValue(dataPath_, set, "/");
-      COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
+        SetConfigValue(dataPath_, "../../Media/").description("Relative path to the game data.").callback(this, &Settings::dataPathChanged);
     }
-  }
 
-  /**
-    @brief Temporary sets the data path
-    @param path The new data path
-  */
-  void Settings::_tsetDataPath(const std::string& path)
-  {
-    ModifyConfigValue(dataPath_, tset, path);
-  }
+    /**
+    @brief
+        Callback function if the datapath has changed.
+    */
+    void Settings::dataPathChanged()
+    {
+        if (dataPath_ != "" && dataPath_[dataPath_.size() - 1] != '/')
+        {
+            ModifyConfigValue(dataPath_, set, dataPath_ + "/");
+        }
 
-  /*static*/ void Settings::tsetDataPath(const std::string& path)
-  {
-    getSingleton()._tsetDataPath(path);
-  }
+        if (dataPath_ == "")
+        {
+            ModifyConfigValue(dataPath_, set, "/");
+            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
+        }
+    }
 
-  /**
-    @brief Returns the relative path to the game data.
-    @return The path to the game data
-  */
-  /*static*/ const std::string& Settings::getDataPath()
-  {
-    return getSingleton().dataPath_;
-  }
+    /**
+    @brief
+        Temporary sets the data path
+    @param path
+        The new data path
+    */
+    void Settings::_tsetDataPath(const std::string& path)
+    {
+        ModifyConfigValue(dataPath_, tset, path);
+    }
+
 }
Index: code/trunk/src/orxonox/Settings.h
===================================================================
--- code/trunk/src/orxonox/Settings.h	(revision 1754)
+++ code/trunk/src/orxonox/Settings.h	(revision 1755)
@@ -29,5 +29,5 @@
 /**
     @file Core.h
-    @brief Definition of the Settings class.
+    @brief Declaration of the Settings class.
 
     The static Settings class is only used to configure some variables
@@ -41,27 +41,51 @@
 #include <string>
 #include "core/OrxonoxClass.h"
+#include "util/Debug.h"
+#include "util/MultiType.h"
+#include "util/Convert.h"
 
 namespace orxonox
 {
-  class _OrxonoxExport Settings : public OrxonoxClass
-  {
+    class _OrxonoxExport Settings : public OrxonoxClass
+    {
+        friend class ClassIdentifier<Settings>;
+        friend class GSRoot;
+        friend class GSGraphics;
+        friend class GSServer;
+        friend class GSDedicated;
+
     public:
-      void setConfigValues();
-      void dataPathChanged();
+        static const std::string& getDataPath()
+        { assert(singletonRef_s); return singletonRef_s->dataPath_; }
+        static void tsetDataPath(const std::string& path)
+        { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); }
 
-      static const std::string& getDataPath();
-
-      static void tsetDataPath(const std::string& path);
+        // an alternative to a global game mode variable
+        static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; }
+        static bool hasServer()     { assert(singletonRef_s); return singletonRef_s->bHasServer_; }
 
     private:
-      Settings();
-      Settings(const Settings& instance);
-      ~Settings();
-      static Settings& getSingleton();
+        // GSRoot has access to these
+        static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; }
+        static void setHasServer    (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_     = val; }
 
-      void _tsetDataPath(const std::string& path);
+        Settings();
+        Settings(const Settings& instance);
+        ~Settings() { singletonRef_s = 0; }
 
-      std::string dataPath_;               //!< Path to the game data
-  };
+        static Settings& _getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+        void _tsetDataPath(const std::string& path);
+        void dataPathChanged();
+
+        void setConfigValues();
+
+        bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics
+        bool bHasServer_;                                      //!< global variable that tells whether this is a server
+
+        std::string dataPath_;                                 //!< Path to the game data
+
+        static Settings* singletonRef_s;                       //!< Static pointer to the only instance.
+    };
+
 }
 
Index: code/trunk/src/orxonox/SignalHandler.h
===================================================================
--- code/trunk/src/orxonox/SignalHandler.h	(revision 1754)
+++ code/trunk/src/orxonox/SignalHandler.h	(revision 1755)
@@ -29,5 +29,5 @@
 /**
     @file SignalHandler.h
-    @brief Definition of the SignalHandler class.
+    @brief Declaration of the SignalHandler class.
 */
 
Index: code/trunk/src/orxonox/gamestates/GSClient.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSClient.cc	(revision 1755)
@@ -0,0 +1,88 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSClient.h"
+
+#include "core/input/InputManager.h"
+#include "core/CommandLine.h"
+#include "network/Client.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(ip, "127.0.0.1").setInformation("#.#.#.#");
+
+    GSClient::GSClient()
+        : GSLevel("client")
+        , client_(0)
+    {
+    }
+
+    GSClient::~GSClient()
+    {
+    }
+
+    void GSClient::enter()
+    {
+        GSLevel::enter();
+
+        int serverPort = CommandLine::getArgument<int>("port")->getValue();
+        std::string serverIP = CommandLine::getArgument<std::string>("ip")->getValue();
+        this->client_ = new network::Client(serverIP, serverPort);
+
+        if(!client_->establishConnection())
+            ThrowException(InitialisationFailed, "Could not establish connection with server.");
+
+        client_->tick(0);
+
+        // level is loaded: we can start capturing the input
+        InputManager::getInstance().requestEnterState("game");
+    }
+
+    void GSClient::leave()
+    {
+        InputManager::getInstance().requestLeaveState("game");
+
+        // TODO: How do we unload the level in client mode?
+
+        client_->closeConnection();
+
+        // destroy client
+        delete this->client_;
+
+        GSLevel::leave();
+    }
+
+    void GSClient::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        client_->tick(time.getDeltaTime());
+
+        this->tickChild(time);
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSClient.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSClient.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSClient.h	(revision 1755)
@@ -0,0 +1,54 @@
+/*
+ *   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 _GSClient_H__
+#define _GSClient_H__
+
+#include "OrxonoxPrereqs.h"
+#include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSClient : public GSLevel
+    {
+    public:
+        GSClient();
+        ~GSClient();
+
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        network::Client* client_;
+    };
+}
+
+#endif /* _GSClient_H__ */
Index: code/trunk/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSDedicated.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSDedicated.cc	(revision 1755)
@@ -0,0 +1,123 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSDedicated.h"
+
+#include <OgreRoot.h>
+#include <OgreSceneManager.h>
+#include "core/ConsoleCommand.h"
+#include "core/CommandLine.h"
+#include "core/Loader.h"
+#include "network/Server.h"
+#include "objects/Tickable.h"
+#include "GraphicsEngine.h"
+#include "Settings.h"
+
+namespace orxonox
+{
+    GSDedicated::GSDedicated()
+        : GameState<GSRoot>("dedicated")
+        , timeFactor_(0)
+        , server_(0)
+        , sceneManager_(0)
+        , startLevel_(0)
+    {
+    }
+
+    GSDedicated::~GSDedicated()
+    {
+    }
+
+    void GSDedicated::enter()
+    {
+        Settings::_getInstance().bHasServer_ = true;
+
+        // create Ogre SceneManager for the level
+        this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
+        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
+
+        // temporary hack
+        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
+
+        // reset game speed to normal
+        timeFactor_ = 1.0f;
+
+        int serverPort = CommandLine::getArgument<int>("port")->getValue();
+        this->server_ = new network::Server(serverPort);
+
+        // call the loader
+        COUT(0) << "Loading level..." << std::endl;
+        startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
+        Loader::open(startLevel_);
+
+        server_->open();
+
+        // add console commands
+        FunctorMember01<GSDedicated, float>* functor = createFunctor(&GSDedicated::setTimeFactor);
+        functor->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
+    }
+
+    void GSDedicated::leave()
+    {
+        // TODO: Remove and destroy console command
+
+        Loader::unload(startLevel_);
+        delete this->startLevel_;
+
+        this->server_->close();
+        delete this->server_;
+
+        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
+
+        Settings::_getInstance().bHasServer_ = false;
+    }
+
+    void GSDedicated::ticked(const Clock& time)
+    {
+        // Call those objects that need the real time
+        for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
+            it->tick(time.getDeltaTime());
+        // Call the scene objects
+        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
+            it->tick(time.getDeltaTime() * this->timeFactor_);
+
+        server_->tick(time.getDeltaTime());
+        this->tickChild(time);
+    }
+
+    /**
+    @brief
+        Changes the speed of Orxonox
+    */
+    void GSDedicated::setTimeFactor(float factor)
+    {
+        this->timeFactor_ = factor;
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSDedicated.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSDedicated.h	(revision 1755)
@@ -0,0 +1,62 @@
+/*
+ *   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 _GSDedicated_H__
+#define _GSDedicated_H__
+
+#include "OrxonoxPrereqs.h"
+#include "network/NetworkPrereqs.h"
+#include "GSRoot.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSDedicated : public GameState<GSRoot>
+    {
+    public:
+        GSDedicated();
+        ~GSDedicated();
+
+        void setTimeFactor(float factor);
+        float getTimeFactor() { return this->timeFactor_; }
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        void loadLevel();
+        void unloadLevel();
+
+        float                 timeFactor_;       //!< A factor to change the gamespeed
+        network::Server*      server_;
+        Ogre::SceneManager*   sceneManager_;
+        Level*                startLevel_;       //!< current hard coded default level
+    };
+}
+
+#endif /* _GSDedicated_H__ */
Index: code/trunk/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGUI.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSGUI.cc	(revision 1755)
@@ -0,0 +1,70 @@
+/*
+ *   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 "OrxonoxStableHeaders.h"
+#include "GSGUI.h"
+
+#include <OgreViewport.h>
+#include "GraphicsEngine.h"
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "gui/GUIManager.h"
+
+namespace orxonox
+{
+    GSGUI::GSGUI()
+        : GameState<GSGraphics>("gui")
+    {
+    }
+
+    GSGUI::~GSGUI()
+    {
+    }
+
+    void GSGUI::enter()
+    {
+        guiManager_ = getParent()->getGUIManager();
+
+        // show main menu
+        guiManager_->showGUI("MainMenu", 0);
+        getParent()->getViewport()->setCamera(guiManager_->getCamera());
+    }
+
+    void GSGUI::leave()
+    {
+        guiManager_->hideGUI();
+    }
+
+    void GSGUI::ticked(const Clock& time)
+    {
+        // tick CEGUI
+        guiManager_->tick(time.getDeltaTime());
+
+        this->tickChild(time);
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSGUI.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGUI.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSGUI.h	(revision 1755)
@@ -0,0 +1,53 @@
+/*
+ *   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 _GSGUI_H__
+#define _GSGUI_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/GameState.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSGUI : public GameState<GSGraphics>
+    {
+    public:
+        GSGUI();
+        ~GSGUI();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        GUIManager* guiManager_;
+    };
+}
+
+#endif /* _GSGUI_H__ */
Index: code/trunk/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGraphics.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSGraphics.cc	(revision 1755)
@@ -0,0 +1,361 @@
+/*
+ *   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 "OrxonoxStableHeaders.h"
+#include "GSGraphics.h"
+
+#include <fstream>
+#include <OgreConfigFile.h>
+#include <OgreFrameListener.h>
+#include <OgreRoot.h>
+#include <OgreException.h>
+#include <OgreRenderWindow.h>
+#include <OgreTextureManager.h>
+#include <OgreViewport.h>
+#include <OgreWindowEventUtilities.h>
+
+#include "util/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/input/InputManager.h"
+#include "core/Exception.h"
+#include "overlays/console/InGameConsole.h"
+#include "gui/GUIManager.h"
+#include "tools/WindowEventListener.h"
+#include "Settings.h"
+
+// for compatibility
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    GSGraphics::GSGraphics()
+        : GameState<GSRoot>("graphics")
+        , ogreRoot_(0)
+        , inputManager_(0)
+        , console_(0)
+        , guiManager_(0)
+        , frameCount_(0)
+        , statisticsRefreshCycle_(0)
+        , statisticsStartTime_(0)
+        , statisticsStartCount_(0)
+        , tickTime_(0)
+    {
+        RegisterRootObject(GSGraphics);
+    }
+
+    GSGraphics::~GSGraphics()
+    {
+    }
+
+    void GSGraphics::setConfigValues()
+    {
+        SetConfigValue(resourceFile_, "resources.cfg").description("Location of the resources file in the data path.");
+        SetConfigValue(statisticsRefreshCycle_, 200000).description("Sets the time in microseconds interval at which average fps, etc. get updated.");
+    }
+
+    void GSGraphics::enter()
+    {
+        Settings::_getInstance().bShowsGraphics_ = true;
+
+        setConfigValues();
+
+        this->ogreRoot_ = getParent()->getOgreRoot();
+
+        this->declareResources();
+        this->loadRenderer();    // creates the render window
+        // TODO: Spread this so that this call only initialises things needed for the Console and GUI
+        this->initialiseResources();
+
+
+        // HACK: temporary:
+        GraphicsEngine* graphicsEngine = getParent()->getGraphicsEngine();
+        graphicsEngine->renderWindow_  = this->renderWindow_;
+        graphicsEngine->root_          = this->ogreRoot_;
+        graphicsEngine->viewport_      = this->viewport_;
+
+
+        // Calls the InputManager which sets up the input devices.
+        // The render window width and height are used to set up the mouse movement.
+        inputManager_ = new InputManager();
+        size_t windowHnd = 0;
+        this->renderWindow_->getCustomAttribute("WINDOW", &windowHnd);
+        inputManager_->initialise(windowHnd, renderWindow_->getWidth(), renderWindow_->getHeight(), true);
+
+        // Load the InGameConsole
+        console_ = new InGameConsole();
+        console_->initialise();
+
+        // load the CEGUI interface
+        guiManager_ = new GUIManager();
+        guiManager_->initialise(this->renderWindow_);
+
+        // reset frame counter
+        this->frameCount_ = 0;
+        this->tickTime_ = 0;
+        statisticsStartTime_ = 0;
+        statisticsStartCount_ = 0;
+
+        // add console commands
+        FunctorMember<GSGraphics>* functor1 = createFunctor(&GSGraphics::printScreen);
+        functor1->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "printScreen"));
+    }
+
+    void GSGraphics::leave()
+    {
+        delete this->guiManager_;
+
+        delete this->console_;
+
+        delete this->inputManager_;
+
+        this->ogreRoot_->detachRenderTarget(this->renderWindow_);
+        delete this->renderWindow_;
+        //this->ogreRoot_->shutdown
+        // TODO: destroy render window
+
+        Settings::_getInstance().bShowsGraphics_ = false;
+    }
+
+    /**
+        Main loop of the orxonox game.
+        We use the Ogre::Timer to measure time since it uses the most precise
+        method an a platform (however the windows timer lacks time when under
+        heavy kernel load!).
+        There is a simple mechanism to measure the average time spent in our
+        ticks as it may indicate performance issues.
+        A note about the Ogre::FrameListener: Even though we don't use them,
+        they still get called. However, the delta times are not correct (except
+        for timeSinceLastFrame, which is the most important). A little research
+        as shown that there is probably only one FrameListener that doesn't even
+        need the time. So we shouldn't run into problems.
+    */
+    void GSGraphics::ticked(const Clock& time)
+    {
+        unsigned long long timeBeforeTick = time.getRealMicroseconds();
+        float dt = time.getDeltaTime();
+
+        this->inputManager_->tick(dt);
+        // tick console
+        this->console_->tick(dt);
+        this->tickChild(time);
+        
+        unsigned long long timeAfterTick = time.getRealMicroseconds();
+
+        tickTime_ += (unsigned int)(timeAfterTick - timeBeforeTick);
+        if (timeAfterTick > statisticsStartTime_ + statisticsRefreshCycle_)
+        {
+            GraphicsEngine::getInstance().setAverageTickTime(
+                (float)tickTime_ * 0.001f / (frameCount_ - statisticsStartCount_));
+            float avgFPS = (float)(frameCount_ - statisticsStartCount_)
+                / (timeAfterTick - statisticsStartTime_) * 1000000.0;
+            GraphicsEngine::getInstance().setAverageFramesPerSecond(avgFPS);
+
+            tickTime_ = 0;
+            statisticsStartCount_ = frameCount_;
+            statisticsStartTime_  = timeAfterTick;
+        }
+
+        // don't forget to call _fireFrameStarted in ogre to make sure
+        // everything goes smoothly
+        Ogre::FrameEvent evt;
+        evt.timeSinceLastFrame = dt;
+        evt.timeSinceLastEvent = dt; // note: same time, but shouldn't matter anyway
+        ogreRoot_->_fireFrameStarted(evt);
+
+        // Pump messages in all registered RenderWindows
+        // This calls the WindowEventListener objects.
+        Ogre::WindowEventUtilities::messagePump();
+        // make sure the window stays active even when not focused
+        // (probably only necessary on windows)
+        this->renderWindow_->setActive(true);
+
+        // render
+        ogreRoot_->_updateAllRenderTargets();
+
+        // again, just to be sure ogre works fine
+        ogreRoot_->_fireFrameEnded(evt); // note: uses the same time as _fireFrameStarted
+
+        ++frameCount_;
+    }
+
+    void GSGraphics::declareResources()
+    {
+        CCOUT(4) << "Declaring Resources" << std::endl;
+        //TODO: Specify layout of data file and maybe use xml-loader
+        //TODO: Work with ressource groups (should be generated by a special loader)
+
+        if (resourceFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre resource file set to \"\". Defaulting to resources.cfg" << std::endl;
+            ModifyConfigValue(resourceFile_, tset, "resources.cfg");
+        }
+
+        // Load resource paths from data file using configfile ressource type
+        Ogre::ConfigFile cf;
+        try
+        {
+            cf.load(Settings::getDataPath() + resourceFile_);
+        }
+        catch (...)
+        {
+            //COUT(1) << ex.getFullDescription() << std::endl;
+            COUT(0) << "Have you forgotten to set the data path in orxnox.ini?" << std::endl;
+            throw;
+        }
+
+        // Go through all sections & settings in the file
+        Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
+
+        std::string secName, typeName, archName;
+        while (seci.hasMoreElements())
+        {
+            try
+            {
+                secName = seci.peekNextKey();
+                Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
+                Ogre::ConfigFile::SettingsMultiMap::iterator i;
+                for (i = settings->begin(); i != settings->end(); ++i)
+                {
+                    typeName = i->first; // for instance "FileSystem" or "Zip"
+                    archName = i->second; // name (and location) of archive
+
+                    Ogre::ResourceGroupManager::getSingleton().addResourceLocation(
+                        std::string(Settings::getDataPath() + archName), typeName, secName);
+                }
+            }
+            catch (Ogre::Exception& ex)
+            {
+                COUT(1) << ex.getFullDescription() << std::endl;
+            }
+        }
+    }
+
+    void GSGraphics::loadRenderer()
+    {
+        CCOUT(4) << "Configuring Renderer" << std::endl;
+
+        if (!ogreRoot_->restoreConfig())
+            if (!ogreRoot_->showConfigDialog())
+                ThrowException(InitialisationFailed, "Could not show Ogre configuration dialogue.");
+
+        CCOUT(4) << "Creating render window" << std::endl;
+
+        this->renderWindow_ = ogreRoot_->initialise(true, "OrxonoxV2");
+
+        Ogre::WindowEventUtilities::addWindowEventListener(this->renderWindow_, this);
+
+        //Ogre::TextureManager::getSingleton().setDefaultNumMipmaps(5);
+
+        // create a full screen default viewport
+        this->viewport_ = this->renderWindow_->addViewport(0, 0);
+    }
+
+    void GSGraphics::initialiseResources()
+    {
+        CCOUT(4) << "Initialising resources" << std::endl;
+        //TODO: Do NOT load all the groups, why are we doing that? And do we really do that? initialise != load...
+        try
+        {
+            Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
+            /*Ogre::StringVector str = Ogre::ResourceGroupManager::getSingleton().getResourceGroups();
+            for (unsigned int i = 0; i < str.size(); i++)
+            {
+            Ogre::ResourceGroupManager::getSingleton().loadResourceGroup(str[i]);
+            }*/
+        }
+        catch (...)
+        {
+            CCOUT(2) << "Error: There was a serious error when initialising the resources." << std::endl;
+            throw;
+        }
+    }
+
+
+    /**
+    @brief
+        Window has moved.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowMoved(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowMoved();
+    }
+
+    /**
+    @brief
+        Window has resized.
+    @param rw
+        The render window it occured in
+    @note
+        GraphicsEngine has a render window stored itself. This is the same
+        as rw. But we have to be careful when using multiple render windows!
+    */
+    void GSGraphics::windowResized(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowResized(this->renderWindow_->getWidth(), this->renderWindow_->getHeight());
+    }
+
+    /**
+    @brief
+        Window focus has changed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowFocusChanged(Ogre::RenderWindow *rw)
+    {
+        for (ObjectList<orxonox::WindowEventListener>::iterator it = ObjectList<orxonox::WindowEventListener>::begin(); it; ++it)
+            it->windowFocusChanged();
+    }
+
+    /**
+    @brief
+        Window was closed.
+    @param rw
+        The render window it occured in
+    */
+    void GSGraphics::windowClosed(Ogre::RenderWindow *rw)
+    {
+        // using CommandExecutor in order to avoid depending on Orxonox.h.
+        //CommandExecutor::execute("exit", false);
+        this->requestState("root");
+    }
+
+    void GSGraphics::printScreen()
+    {
+        if (this->renderWindow_)
+        {
+            this->renderWindow_->writeContentsToTimestampedFile("shot_", ".jpg");
+        }
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSGraphics.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSGraphics.h	(revision 1755)
@@ -0,0 +1,92 @@
+/*
+ *   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 _GSGraphics_H__
+#define _GSGraphics_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <OgreWindowEventUtilities.h>
+#include "core/GameState.h"
+#include "core/OrxonoxClass.h"
+#include "GSRoot.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSGraphics : public GameState<GSRoot>, public OrxonoxClass, public Ogre::WindowEventListener
+    {
+        friend class ClassIdentifier<GSGraphics>;
+    public:
+        GSGraphics();
+        ~GSGraphics();
+
+        Ogre::Viewport* getViewport() { return this->viewport_; }
+        GUIManager* getGUIManager() { return this->guiManager_; }
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        void setConfigValues();
+
+        void declareResources();
+        void loadRenderer();
+        void initialiseResources();
+
+        void printScreen();
+
+        // window events from Ogre::WindowEventListener
+        void windowMoved       (Ogre::RenderWindow* rw);
+        void windowResized     (Ogre::RenderWindow* rw);
+        void windowFocusChanged(Ogre::RenderWindow* rw);
+        void windowClosed      (Ogre::RenderWindow* rw);
+
+        Ogre::Root*           ogreRoot_;
+        Ogre::RenderWindow*   renderWindow_;          //!< the current render window
+        Ogre::Viewport*       viewport_;              //!< default full size viewport
+
+        // managed singletons
+        InputManager*         inputManager_;
+        InGameConsole*        console_;
+        GUIManager*           guiManager_;
+
+        // variables for time statistics
+        unsigned long         frameCount_;
+        unsigned int          statisticsRefreshCycle_;
+        unsigned long long    statisticsStartTime_;
+        unsigned long         statisticsStartCount_;
+        unsigned int          tickTime_;
+
+        // config values
+        std::string           resourceFile_;          //!< resources file name
+        unsigned int          detailLevelParticle_;   //!< Detail level of particle effects (0: off, 1: low, 2: normal, 3: high)
+    };
+}
+
+#endif /* _GSGraphics_H__ */
Index: code/trunk/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSIOConsole.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSIOConsole.cc	(revision 1755)
@@ -0,0 +1,68 @@
+/*
+ *   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 "OrxonoxStableHeaders.h"
+#include "GSIOConsole.h"
+
+#include <iostream>
+#include <OgreFrameListener.h>
+#include <OgreRoot.h>
+#include <OgreTimer.h>
+
+#include "core/ConsoleCommand.h"
+#include "core/TclThreadManager.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    GSIOConsole::GSIOConsole()
+        : GameState<GSRoot>("ioConsole")
+    {
+    }
+
+    GSIOConsole::~GSIOConsole()
+    {
+    }
+
+    void GSIOConsole::enter()
+    {
+    }
+
+    void GSIOConsole::leave()
+    {
+    }
+
+    void GSIOConsole::ticked(const Clock& time)
+    {
+        std::string command;
+        std::getline(std::cin, command);
+        CommandExecutor::execute(command, true);
+        
+        tickChild(time);
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSIOConsole.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSIOConsole.h	(revision 1755)
@@ -0,0 +1,52 @@
+/*
+ *   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 _GSIOConsole_H__
+#define _GSIOConsole_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include "core/GameState.h"
+#include "GSRoot.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSIOConsole : public GameState<GSRoot>
+    {
+    public:
+        GSIOConsole();
+        ~GSIOConsole();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+    };
+}
+
+#endif /* _GSIOConsole_H__ */
Index: code/trunk/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSLevel.cc	(revision 1755)
@@ -0,0 +1,154 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSLevel.h"
+
+#include <OgreSceneManager.h>
+#include <OgreRoot.h>
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/input/KeyBinder.h"
+#include "core/Loader.h"
+#include "objects/Backlight.h"
+#include "objects/Tickable.h"
+#include "tools/Timer.h"
+#include "tools/ParticleInterface.h"
+#include "Settings.h"
+#include "Radar.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    GSLevel::GSLevel(const std::string& name)
+        : GameState<GSGraphics>(name)
+        , timeFactor_(1.0f)
+        , sceneManager_(0)
+        , keyBinder_(0)
+        , inputState_(0)
+        , radar_(0)
+        , startLevel_(0)
+        , hud_(0)
+    {
+    }
+
+    GSLevel::~GSLevel()
+    {
+    }
+
+    void GSLevel::enter()
+    {
+        inputState_ = InputManager::getInstance().createInputState<SimpleInputState>("game", 20);
+        keyBinder_ = new KeyBinder();
+        keyBinder_->loadBindings();
+        inputState_->setHandler(keyBinder_);
+
+        // create Ogre SceneManager for the level
+        this->sceneManager_ = Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "LevelSceneManager");
+        COUT(4) << "Created SceneManager: " << sceneManager_->getName() << std::endl;
+
+        // temporary hack
+        GraphicsEngine::getInstance().setLevelSceneManager(this->sceneManager_);
+
+        // Start the Radar
+        this->radar_ = new Radar();
+
+        // Load the HUD
+        COUT(3) << "Orxonox: Loading HUD" << std::endl;
+        hud_ = new Level(Settings::getDataPath() + "overlay/hud.oxo");
+        Loader::load(hud_);
+
+        // reset game speed to normal
+        timeFactor_ = 1.0f;
+
+        // TODO: insert slomo console command with
+        // .accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
+    }
+
+    void GSLevel::leave()
+    {
+        Loader::unload(hud_);
+        delete this->hud_;
+
+        // this call will delete every BaseObject!
+        // But currently this will call methods of objects that exist no more
+        // The only 'memory leak' is the ParticleSpawer. They would be deleted here
+        // and call a sceneNode method that has already been destroy by the corresponding space ship.
+        //Loader::close();
+
+        delete this->radar_;
+
+        Ogre::Root::getSingleton().destroySceneManager(this->sceneManager_);
+
+        inputState_->setHandler(0);
+        InputManager::getInstance().requestDestroyState("game");
+        delete this->keyBinder_;
+    }
+
+    void GSLevel::ticked(const Clock& time)
+    {
+        // Call those objects that need the real time
+        for (ObjectList<TickableReal>::iterator it = ObjectList<TickableReal>::begin(); it; ++it)
+            it->tick(time.getDeltaTime());
+        // Call the scene objects
+        for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ++it)
+            it->tick(time.getDeltaTime() * this->timeFactor_);
+
+        for (ObjectList<TimerBase>::iterator it = ObjectList<TimerBase>::begin(); it; ++it)
+            it->tick(time);
+    }
+
+    /**
+    @brief
+        Changes the speed of Orxonox
+    */
+    void GSLevel::setTimeFactor(float factor)
+    {
+        float change = factor / this->timeFactor_;
+        this->timeFactor_ = factor;
+        for (ObjectList<ParticleInterface>::iterator it = ObjectList<ParticleInterface>::begin(); it; ++it)
+            it->setSpeedFactor(it->getSpeedFactor() * change);
+
+        for (ObjectList<Backlight>::iterator it = ObjectList<Backlight>::begin(); it; ++it)
+            it->setTimeFactor(timeFactor_);
+    }
+
+    void GSLevel::loadLevel()
+    {
+        // call the loader
+        COUT(0) << "Loading level..." << std::endl;
+        startLevel_ = new Level(Settings::getDataPath() + "levels/sample.oxw");
+        Loader::open(startLevel_);
+    }
+
+    void GSLevel::unloadLevel()
+    {
+        Loader::unload(startLevel_);
+        delete this->startLevel_;
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSLevel.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSLevel.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSLevel.h	(revision 1755)
@@ -0,0 +1,69 @@
+/*
+ *   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 _GSLevel_H__
+#define _GSLevel_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include "core/GameState.h"
+#include "GSGraphics.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSLevel : public GameState<GSGraphics>
+    {
+    public:
+        GSLevel(const std::string& name);
+        virtual ~GSLevel();
+
+        // this has to be public because proteced triggers a bug in msvc
+        // when taking the function address.
+        void setTimeFactor(float factor);
+        float getTimeFactor() { return this->timeFactor_; }
+
+    protected:
+        virtual void enter();
+        virtual void leave();
+        virtual void ticked(const Clock& time);
+
+        void loadLevel();
+        void unloadLevel();
+
+        float timeFactor_;       //!< A factor to change the gamespeed
+
+        Ogre::SceneManager*   sceneManager_;
+        KeyBinder*            keyBinder_;        //!< tool that loads and manages the input bindings
+        SimpleInputState*     inputState_;
+        Radar*                radar_;            //!< represents the Radar (not the HUD part)
+        Level*                startLevel_;       //!< current hard coded default level
+        Level*                hud_;              //!< 'level' object fo the HUD
+    };
+}
+
+#endif /* _GSLevel_H__ */
Index: code/trunk/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSRoot.cc	(revision 1755)
@@ -0,0 +1,323 @@
+/*
+ *   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 "OrxonoxStableHeaders.h"
+#include "GSRoot.h"
+
+#include <OgreLogManager.h>
+#include <OgreRoot.h>
+
+//#include "util/SubString.h"
+#include "core/Factory.h"
+#include "core/ConfigFileManager.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandLine.h"
+#include "util/Debug.h"
+#include "core/Exception.h"
+#include "core/TclBind.h"
+#include "core/TclThreadManager.h"
+#include "GraphicsEngine.h"
+#include "Settings.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
+#  ifndef WIN32_LEAN_AND_MEAN
+#    define WIN32_LEAN_AND_MEAN
+#  endif
+#  include "windows.h"
+
+   //Get around Windows hackery
+#  ifdef max
+#    undef max
+#  endif
+#  ifdef min
+#    undef min
+#  endif
+#endif
+
+namespace orxonox
+{
+    SetCommandLineArgument(dataPath, "").setInformation("PATH");
+    SetCommandLineArgument(limitToCPU, 1).setInformation("0: off | #cpu");
+
+    GSRoot::GSRoot()
+        : RootGameState("root")
+        , settings_(0)
+        , ogreRoot_(0)
+        , ogreLogger_(0)
+        , graphicsEngine_(0)
+    {
+        RegisterRootObject(GSRoot);
+    }
+
+    GSRoot::~GSRoot()
+    {
+    }
+
+    void GSRoot::setConfigValues()
+    {
+        SetConfigValue(ogreConfigFile_,  "ogre.cfg").description("Location of the Ogre config file");
+        SetConfigValue(ogrePluginsFile_, "plugins.cfg").description("Location of the Ogre plugins file");
+        SetConfigValue(ogreLogFile_,     "ogre.log").description("Logfile for messages from Ogre. \
+                                                                 Use \"\" to suppress log file creation.");
+        SetConfigValue(ogreLogLevelTrivial_ , 5).description("Corresponding orxonox debug level for ogre Trivial");
+        SetConfigValue(ogreLogLevelNormal_  , 4).description("Corresponding orxonox debug level for ogre Normal");
+        SetConfigValue(ogreLogLevelCritical_, 2).description("Corresponding orxonox debug level for ogre Critical");
+    }
+
+    void GSRoot::enter()
+    {
+#if ORXONOX_DEBUG_MODE == 1
+        ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox_d.ini");
+#else
+        ConfigFileManager::getInstance()->setFile(CFT_Settings, "orxonox.ini");
+#endif
+
+        // do this after the previous call..
+        setConfigValues();
+
+        // creates the class hierarchy for all classes with factories
+        Factory::createClassHierarchy();
+
+        // instantiate Settings class
+        this->settings_ = new Settings();
+
+        std::string dataPath;
+        CommandLine::getValue("dataPath", &dataPath);
+        if (dataPath != "")
+        {
+            if (*dataPath.end() != '/' && *dataPath.end() != '\\')
+                Settings::tsetDataPath(dataPath + "/");
+            else
+                Settings::tsetDataPath(dataPath);
+        }
+
+        // initialise TCL
+        TclBind::getInstance().setDataPath(Settings::getDataPath());
+        TclThreadManager::getInstance();
+
+        setupOgre();
+
+        // initialise graphics engine. Doesn't load the render window yet!
+        graphicsEngine_ = new GraphicsEngine();
+
+        // limit the main thread to the first core so that QueryPerformanceCounter doesn't jump
+        // do this after ogre has initialised. Somehow Ogre changes the settings again (not through
+        // the timer though).
+        int limitToCPU;
+        CommandLine::getValue("limitToCPU", &limitToCPU);
+        if (limitToCPU > 0)
+            setThreadAffinity((unsigned int)(limitToCPU - 1));
+
+        // add console commands
+        FunctorMember<GSRoot>* functor1 = createFunctor(&GSRoot::exitGame);
+        functor1->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor1, "exit"));
+
+        // add console commands
+        FunctorMember01<GameStateBase, const std::string&>* functor2 = createFunctor(&GameStateBase::requestState);
+        functor2->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor2, "selectGameState"));
+    }
+
+    void GSRoot::leave()
+    {
+        delete graphicsEngine_;
+
+        delete this->ogreRoot_;
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // delete the ogre log and the logManager (since we have created it).
+        this->ogreLogger_->getDefaultLog()->removeListener(this);
+        this->ogreLogger_->destroyLog(Ogre::LogManager::getSingleton().getDefaultLog());
+        delete this->ogreLogger_;
+#endif
+
+        delete settings_;
+
+        // TODO: remove and destroy console commands
+    }
+
+    void GSRoot::ticked(const Clock& time)
+    {
+        TclThreadManager::getInstance().tick(time.getDeltaTime());
+
+        this->tickChild(time);
+    }
+
+    /**
+    @note
+        The code of this function has been copied and adjusted from OGRE, an open source graphics engine.
+            (Object-oriented Graphics Rendering Engine)
+        For the latest info, see http://www.ogre3d.org/
+
+        Copyright (c) 2000-2008 Torus Knot Software Ltd
+        
+        OGRE is licensed under the LGPL. For more info, see ogre license info.
+    */
+    void GSRoot::setThreadAffinity(unsigned int limitToCPU)
+    {
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // Get the current process core mask
+	    DWORD procMask;
+	    DWORD sysMask;
+#if _MSC_VER >= 1400 && defined (_M_X64)
+	    GetProcessAffinityMask(GetCurrentProcess(), (PDWORD_PTR)&procMask, (PDWORD_PTR)&sysMask);
+#else
+	    GetProcessAffinityMask(GetCurrentProcess(), &procMask, &sysMask);
+#endif
+
+	    // If procMask is 0, consider there is only one core available
+	    // (using 0 as procMask will cause an infinite loop below)
+	    if (procMask == 0)
+		    procMask = 1;
+
+        // if the core specified with limitToCPU is not available, take the lowest one
+        if (!(procMask & (1 << limitToCPU)))
+            limitToCPU = 0;
+
+	    // Find the lowest core that this process uses and limitToCPU suggests
+        DWORD threadMask = 1;
+	    while ((threadMask & procMask) == 0 || (threadMask < (1u << limitToCPU)))
+		    threadMask <<= 1;
+
+	    // Set affinity to the first core
+	    SetThreadAffinityMask(GetCurrentThread(), threadMask);
+#endif
+    }
+
+    /**
+    @brief
+        Creates the Ogre Root object and sets up the ogre log.
+    */
+    void GSRoot::setupOgre()
+    {
+        COUT(3) << "Setting up Ogre..." << std::endl;
+
+        // TODO: LogManager doesn't work on oli platform. The why is yet unknown.
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+        // create a new logManager
+        ogreLogger_ = new Ogre::LogManager();
+        COUT(4) << "Ogre LogManager created" << std::endl;
+
+        // create our own log that we can listen to
+        Ogre::Log *myLog;
+        if (this->ogreLogFile_ == "")
+            myLog = ogreLogger_->createLog("ogre.log", true, false, true);
+        else
+            myLog = ogreLogger_->createLog(this->ogreLogFile_, true, false, false);
+        COUT(4) << "Ogre Log created" << std::endl;
+
+        myLog->setLogDetail(Ogre::LL_BOREME);
+        myLog->addListener(this);
+#endif
+
+        // Root will detect that we've already created a Log
+        COUT(4) << "Creating Ogre Root..." << std::endl;
+
+        if (ogrePluginsFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre plugins file set to \"\". Defaulting to plugins.cfg" << std::endl;
+            ModifyConfigValue(ogrePluginsFile_, tset, "plugins.cfg");
+        }
+        if (ogreConfigFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre config file set to \"\". Defaulting to config.cfg" << std::endl;
+            ModifyConfigValue(ogreConfigFile_, tset, "config.cfg");
+        }
+        if (ogreLogFile_ == "")
+        {
+            COUT(2) << "Warning: Ogre log file set to \"\". Defaulting to ogre.log" << std::endl;
+            ModifyConfigValue(ogreLogFile_, tset, "ogre.log");
+        }
+
+        // check for config file existence because Ogre displays (caught) exceptions if not
+        std::ifstream probe;
+        probe.open(ogreConfigFile_.c_str());
+        if (!probe)
+        {
+            // create a zero sized file
+            std::ofstream creator;
+            creator.open(ogreConfigFile_.c_str());
+            creator.close();
+        }
+        else
+            probe.close();
+
+        ogreRoot_ = new Ogre::Root(ogrePluginsFile_, ogreConfigFile_, ogreLogFile_);
+
+#if 0 // Ogre 1.4.3 doesn't yet support setDebugOutputEnabled(.)
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+        // tame the ogre ouput so we don't get all the mess in the console
+        Ogre::Log* defaultLog = Ogre::LogManager::getSingleton().getDefaultLog();
+        defaultLog->setDebugOutputEnabled(false);
+        defaultLog->setLogDetail(Ogre::LL_BOREME);
+        defaultLog->addListener(this);
+#endif
+#endif
+
+        COUT(3) << "Ogre set up done." << std::endl;
+    }
+
+    /**
+    @brief
+        Method called by the LogListener interface from Ogre.
+        We use it to capture Ogre log messages and handle it ourselves.
+    @param message
+        The message to be logged
+    @param lml
+        The message level the log is using
+    @param maskDebug
+        If we are printing to the console or not
+    @param logName
+        The name of this log (so you can have several listeners
+        for different logs, and identify them)
+    */
+    void GSRoot::messageLogged(const std::string& message,
+        Ogre::LogMessageLevel lml, bool maskDebug, const std::string& logName)
+    {
+        int orxonoxLevel;
+        switch (lml)
+        {
+        case Ogre::LML_TRIVIAL:
+            orxonoxLevel = this->ogreLogLevelTrivial_;
+            break;
+        case Ogre::LML_NORMAL:
+            orxonoxLevel = this->ogreLogLevelNormal_;
+            break;
+        case Ogre::LML_CRITICAL:
+            orxonoxLevel = this->ogreLogLevelCritical_;
+            break;
+        default:
+            orxonoxLevel = 0;
+        }
+        OutputHandler::getOutStream().setOutputLevel(orxonoxLevel)
+            << "Ogre: " << message << std::endl;
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSRoot.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSRoot.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSRoot.h	(revision 1755)
@@ -0,0 +1,77 @@
+/*
+ *   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 _GSRoot_H__
+#define _GSRoot_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgreLog.h>
+#include "core/RootGameState.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSRoot : public RootGameState, public Ogre::LogListener, public OrxonoxClass
+    {
+        friend class ClassIdentifier<GSRoot>;
+    public:
+        GSRoot();
+        ~GSRoot();
+
+        void exitGame()
+        { requestState("root"); }
+
+        Ogre::Root* getOgreRoot() { return this->ogreRoot_; }
+        GraphicsEngine* getGraphicsEngine() { return this->graphicsEngine_; }
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        void setConfigValues();
+        void messageLogged(const std::string& message, Ogre::LogMessageLevel lml,
+            bool maskDebug, const std::string& logName);
+        void setThreadAffinity(unsigned int limitToCPU);
+        void setupOgre();
+
+        Settings*             settings_;
+        Ogre::Root*           ogreRoot_;                  //!< Ogre's root
+        Ogre::LogManager*     ogreLogger_;
+        GraphicsEngine*       graphicsEngine_;   //!< Interface to Ogre
+
+        std::string           ogreConfigFile_;        //!< ogre config file name
+        std::string           ogrePluginsFile_;       //!< ogre plugins file name
+        std::string           ogreLogFile_;           //!< log file name for Ogre log messages
+        int                   ogreLogLevelTrivial_;   //!< Corresponding Orxonx debug level for LL_TRIVIAL
+        int                   ogreLogLevelNormal_;    //!< Corresponding Orxonx debug level for LL_NORMAL
+        int                   ogreLogLevelCritical_;  //!< Corresponding Orxonx debug level for LL_CRITICAL
+    };
+}
+
+#endif /* _GSRoot_H__ */
Index: code/trunk/src/orxonox/gamestates/GSServer.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSServer.cc	(revision 1755)
@@ -0,0 +1,97 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSServer.h"
+
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "core/CommandLine.h"
+#include "network/Server.h"
+#include "Settings.h"
+
+namespace orxonox
+{
+    SetCommandLineArgument(port, 55556).setShortcut("p").setInformation("0-65535");
+
+    GSServer::GSServer()
+        : GSLevel("server")
+        , server_(0)
+    {
+    }
+
+    GSServer::~GSServer()
+    {
+    }
+
+    void GSServer::enter()
+    {
+        Settings::_getInstance().bHasServer_ = true;
+
+        GSLevel::enter();
+
+        int serverPort = CommandLine::getArgument<int>("port")->getValue();
+        this->server_ = new network::Server(serverPort);
+        COUT(0) << "Loading scene in server mode" << std::endl;
+
+        this->loadLevel();
+
+        server_->open();
+
+        // add console commands
+        FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
+        functor->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
+
+        // level is loaded: we can start capturing the input
+        InputManager::getInstance().requestEnterState("game");
+    }
+
+    void GSServer::leave()
+    {
+        InputManager::getInstance().requestLeaveState("game");
+
+        // TODO: Remove and destroy console command
+
+        this->unloadLevel();
+
+        this->server_->close();
+        delete this->server_;
+
+        GSLevel::leave();
+
+        Settings::_getInstance().bHasServer_ = false;
+    }
+
+    void GSServer::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        server_->tick(time.getDeltaTime());
+        this->tickChild(time);
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSServer.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSServer.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSServer.h	(revision 1755)
@@ -0,0 +1,54 @@
+/*
+ *   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 _GSServer_H__
+#define _GSServer_H__
+
+#include "OrxonoxPrereqs.h"
+#include "network/NetworkPrereqs.h"
+#include "GSLevel.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSServer : public GSLevel
+    {
+    public:
+        GSServer();
+        ~GSServer();
+
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+
+        network::Server*      server_;
+    };
+}
+
+#endif /* _GSServer_H__ */
Index: code/trunk/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- code/trunk/src/orxonox/gamestates/GSStandalone.cc	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSStandalone.cc	(revision 1755)
@@ -0,0 +1,77 @@
+/*
+ *   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:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSStandalone.h"
+
+#include "core/input/InputManager.h"
+#include "core/ConsoleCommand.h"
+
+namespace orxonox
+{
+    GSStandalone::GSStandalone()
+        : GSLevel("standalone")
+    {
+    }
+
+    GSStandalone::~GSStandalone()
+    {
+    }
+
+    void GSStandalone::enter()
+    {
+        GSLevel::enter();
+
+        this->loadLevel();
+
+        // add console commands
+        FunctorMember<GSLevel>* functor = createFunctor(&GSLevel::setTimeFactor);
+        functor->setObject(this);
+        CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(functor, "setTimeFactor")).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);;
+
+        // level is loaded: we can start capturing the input
+        InputManager::getInstance().requestEnterState("game");
+    }
+
+    void GSStandalone::leave()
+    {
+        InputManager::getInstance().requestLeaveState("game");
+
+        // TODO: Remove and destroy console command
+
+        this->unloadLevel();
+
+        GSLevel::leave();
+    }
+
+    void GSStandalone::ticked(const Clock& time)
+    {
+        GSLevel::ticked(time);
+        this->tickChild(time);
+    }
+}
Index: code/trunk/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- code/trunk/src/orxonox/gamestates/GSStandalone.h	(revision 1755)
+++ code/trunk/src/orxonox/gamestates/GSStandalone.h	(revision 1755)
@@ -0,0 +1,50 @@
+/*
+ *   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 _GSStandalone_H__
+#define _GSStandalone_H__
+
+#include "OrxonoxPrereqs.h"
+#include "GSLevel.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport GSStandalone : public GSLevel
+    {
+    public:
+        GSStandalone();
+        ~GSStandalone();
+
+    private:
+        void enter();
+        void leave();
+        void ticked(const Clock& time);
+    };
+}
+
+#endif /* _GSStandalone_H__ */
Index: code/trunk/src/orxonox/gui/GUIManager.cc
===================================================================
--- code/trunk/src/orxonox/gui/GUIManager.cc	(revision 1755)
+++ code/trunk/src/orxonox/gui/GUIManager.cc	(revision 1755)
@@ -0,0 +1,334 @@
+/*
+ *   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 GUIManager class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "GUIManager.h"
+
+#include <OgreRenderWindow.h>
+#include <OgreRoot.h>
+#include <CEGUI.h>
+#include <CEGUILua.h>
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/tolua/tolua_bind.h"
+#include "core/ConsoleCommand.h"
+#include "core/Exception.h"
+#include "core/Core.h"
+#include "tolua/tolua_bind.h"
+#include "GraphicsEngine.h"
+#include "OgreCEGUIRenderer.h"
+
+extern "C" {
+#include <lualib.h>
+#include <lauxlib.h>
+}
+
+namespace orxonox
+{
+    SetConsoleCommandShortcut(GUIManager, showGUI_s).keybindMode(KeybindMode::OnPress);
+
+    GUIManager* GUIManager::singletonRef_s = 0;
+
+    GUIManager::GUIManager()
+        //: emptySceneManager_(0)
+        : backgroundSceneManager_(0)
+        //, emptyCamera_(0)
+        , backgroundCamera_(0)
+        //, viewport_(0)
+        , renderWindow_(0)
+        , guiRenderer_(0)
+        , resourceProvider_(0)
+        , scriptModule_(0)
+        , guiSystem_(0)
+        , state_(Uninitialised)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+    }
+
+    GUIManager::~GUIManager()
+    {
+        if (backgroundCamera_)
+            backgroundSceneManager_->destroyCamera(backgroundCamera_);
+
+        if (backgroundSceneManager_)
+        {
+            // We have to make sure the SceneManager is not anymore referenced.
+            // For the case that the target SceneManager was yet another one, it
+            // wouldn't matter anyway since this is the destructor.
+            guiRenderer_->setTargetSceneManager(0);
+            Ogre::Root::getSingleton().destroySceneManager(backgroundSceneManager_);
+        }
+
+        InputManager::getInstance().requestDestroyState("gui");
+
+        if (guiSystem_)
+            delete guiSystem_;
+
+        if (scriptModule_)
+        {
+            // destroy our own tolua interfaces
+	        //lua_pushnil(luaState_);
+	        //lua_setglobal(luaState_, "Orxonox");
+	        //lua_pushnil(luaState_);
+	        //lua_setglobal(luaState_, "Core");
+            // TODO: deleting the script module fails an assertation.
+            // However there is not much we can do about it since it occurs too when
+            // we don't open Core or Orxonox. Might be a CEGUI issue.
+            // The memory leak is not a problem anyway..
+            //delete scriptModule_;
+        }
+
+        if (guiRenderer_)
+            delete guiRenderer_;
+
+        singletonRef_s = 0;
+    }
+
+    bool GUIManager::initialise(Ogre::RenderWindow* renderWindow)
+    {
+        using namespace CEGUI;
+        if (state_ == Uninitialised)
+        {
+            COUT(3) << "Intialising CEGUI." << std::endl;
+
+            try
+            {
+                // save the render window
+                renderWindow_ = renderWindow;
+
+                // Full screen viewport with Z order = 0 (top most). Don't yet feed a camera (so nothing gets rendered)
+                //this->viewport_ = renderWindow_->addViewport(0, 3);
+                //this->viewport_->setOverlaysEnabled(false);
+                //this->viewport_->setShadowsEnabled(false);
+                //this->viewport_->setSkiesEnabled(false);
+                //this->viewport_->setClearEveryFrame(false);
+
+                // Note: No SceneManager specified yet
+                this->guiRenderer_ = new OgreCEGUIRenderer(renderWindow_, Ogre::RENDER_QUEUE_MAIN, true, 3000);
+                this->resourceProvider_ = guiRenderer_->createResourceProvider();
+                this->resourceProvider_->setDefaultResourceGroup("GUI");
+                
+                // setup scripting
+                this->scriptModule_ = new LuaScriptModule();
+                this->luaState_ = this->scriptModule_->getLuaState();
+
+                // create the CEGUI system singleton
+                this->guiSystem_ = new System(this->guiRenderer_, this->resourceProvider_, 0, this->scriptModule_);
+                
+                // set the log level according to ours (translate by subtracting 1)
+                Logger::getSingleton().setLoggingLevel(
+                    (LoggingLevel)(Core::getSoftDebugLevel(OutputHandler::LD_Logfile) - 1));
+                
+                // do this after 'new CEGUI::Sytem' because that creates the lua state in the first place
+                tolua_Core_open(this->scriptModule_->getLuaState());
+                tolua_Orxonox_open(this->scriptModule_->getLuaState());
+
+                // register us as input handler
+                SimpleInputState* state = InputManager::getInstance().createInputState<SimpleInputState>("gui", 30);
+                state->setHandler(this);
+                state->setJoyStickHandler(new EmptyHandler());
+
+                // load the background scene
+                loadScenes();
+                //CEGUI::KeyEventArgs e;
+                //e.codepoint
+            }
+            catch (CEGUI::Exception& ex)
+            {
+#if CEGUI_VERSION_MAJOR == 0 && CEGUI_VERSION_MINOR < 6
+                throw GeneralException(ex.getMessage().c_str());
+#else
+                throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
+                    ex.getFileName().c_str(), ex.getName().c_str());
+#endif
+            }
+
+            state_ = Ready;
+        }
+        
+        return true;
+    }
+
+    void GUIManager::loadScenes()
+    {
+        // first of all, we need to have our own SceneManager for the GUI. The reason
+        // is that we might have multiple viewports when in play mode (e.g. the view of
+        // a camera fixed at the back of the ship). That forces us to create our own
+        // full screen viewport that is on top of all the others, but doesn't clear the
+        // port before rendering, so everything from the GUI gets on top eventually.
+        // But in order to realise that, we also need a SceneManager with an empty scene,
+        // because the SceneManager is responsible for the render queue.
+        //this->emptySceneManager_ = Ogre::Root::getSingleton()
+        //    .createSceneManager(Ogre::ST_GENERIC, "GUI/EmptySceneManager");
+
+        // we also need a camera or we won't see anything at all.
+        // The camera settings don't matter at all for an empty scene since the GUI
+        // gets rendered on top of the screen rather than into the scene.
+        //this->emptyCamera_ = this->emptySceneManager_->createCamera("GUI/EmptyCamera");
+
+        // Create another SceneManager that enables to display some 3D
+        // scene in the background of the main menu.
+        this->backgroundSceneManager_ = Ogre::Root::getSingleton()
+            .createSceneManager(Ogre::ST_GENERIC, "GUI/BackgroundSceneManager");
+        this->backgroundCamera_ = backgroundSceneManager_->createCamera("GUI/BackgroundCamera");
+
+        // TODO: create something 3D
+        try
+        {
+            this->scriptModule_->executeScriptFile("loadGUI.lua", "GUI");
+        }
+        catch (CEGUI::Exception& ex)
+        {
+#if CEGUI_VERSION_MINOR < 6
+            throw GeneralException(ex.getMessage().c_str());
+#else
+            throw GeneralException(ex.getMessage().c_str(), ex.getLine(),
+                ex.getFileName().c_str(), ex.getName().c_str());
+#endif
+        }
+    }
+
+    void GUIManager::showGUI(const std::string& name, Ogre::SceneManager* sceneManager)// bool showBackground)
+    {
+        if (state_ != Uninitialised)
+        {
+            if (state_ == OnDisplay)
+                hideGUI();
+
+            COUT(3) << "Loading GUI " << name << std::endl;
+            try
+            {
+                if (!sceneManager)
+                {
+                    // currently, only an image is loaded. We could do 3D, see loadBackground.
+                    //this->viewport_->setClearEveryFrame(true);
+                    this->guiRenderer_->setTargetSceneManager(this->backgroundSceneManager_);
+                    //this->viewport_->setCamera(this->backgroundCamera_);
+
+                    lua_pushboolean(this->scriptModule_->getLuaState(), true);
+                    lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
+                }
+                else
+                {
+                    //this->viewport_->setClearEveryFrame(false);
+                    this->guiRenderer_->setTargetSceneManager(sceneManager);
+                    //this->viewport_->setCamera(this->emptyCamera_);
+
+                    lua_pushboolean(this->scriptModule_->getLuaState(), false);
+                    lua_setglobal(this->scriptModule_->getLuaState(), "showBackground");
+                }
+
+                this->scriptModule_->executeScriptGlobal("showMainMenu");
+
+                InputManager::getInstance().requestEnterState("gui");
+
+                this->state_ = OnDisplay;
+            }
+            catch (CEGUI::Exception& ex)
+            {
+                COUT(2) << "Error while executing lua script. Message:\n" << ex.getMessage() << std::endl;
+            }
+            catch (...)
+            {
+                COUT(2) << "Could show a menu due to unknown reasons." << std::endl;
+            }
+        }
+        else
+        {
+            COUT(2) << "Warning: GUI Manager not yet initialised, cannot load a GUI" << std::endl;
+        }
+    }
+
+    void GUIManager::hideGUI()
+    {
+        if (this->state_ != OnDisplay)
+            return;
+        //this->viewport_->setCamera(0);
+        this->guiRenderer_->setTargetSceneManager(0);
+        this->state_ = Ready;
+        InputManager::getInstance().requestLeaveState("gui");
+    }
+
+    void GUIManager::mouseButtonPressed(MouseButton::Enum id)
+    {
+        try
+        {
+            guiSystem_->injectMouseButtonDown(convertButton(id));
+        }
+        catch (CEGUI::ScriptException& ex)
+        {
+            // We simply ignore the exception and proceed
+            COUT(1) << ex.getMessage() << std::endl;
+        }
+    }
+
+    void GUIManager::mouseButtonReleased(MouseButton::Enum id)
+    {
+        try
+        {
+            guiSystem_->injectMouseButtonUp(convertButton(id));
+        }
+        catch (CEGUI::ScriptException& ex)
+        {
+            // We simply ignore the exception and proceed
+            COUT(1) << ex.getMessage() << std::endl;
+        }
+    }
+
+
+    inline CEGUI::MouseButton GUIManager::convertButton(MouseButton::Enum button)
+    {
+        switch (button)
+        {
+        case MouseButton::Left:
+            return CEGUI::LeftButton;
+
+        case MouseButton::Right:
+            return CEGUI::RightButton;
+
+        case MouseButton::Middle:
+            return CEGUI::MiddleButton;
+
+        case MouseButton::Button3:
+            return CEGUI::X1Button;
+
+        case MouseButton::Button4:
+            return CEGUI::X2Button;
+
+        default:
+            return CEGUI::NoButton;
+        }
+    }
+}
Index: code/trunk/src/orxonox/gui/GUIManager.h
===================================================================
--- code/trunk/src/orxonox/gui/GUIManager.h	(revision 1755)
+++ code/trunk/src/orxonox/gui/GUIManager.h	(revision 1755)
@@ -0,0 +1,131 @@
+/*
+ *   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 the GUIManager class.
+*/
+
+#ifndef _GUIManager_H__
+#define _GUIManager_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <CEGUIForwardRefs.h>
+#include <CEGUIInputEvent.h>
+#include <CEGUISystem.h>
+#include "core/input/InputInterfaces.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+    /**
+    @brief
+        Provides a simple interface to CEGUI with tolua methods and console commands
+    */
+    class _OrxonoxExport GUIManager : public KeyHandler, public MouseHandler
+    /*
+    class GUIManager { // tolua_export
+    */
+    {
+    public:
+        enum State
+        {
+            Uninitialised,
+            Ready,
+            OnDisplay
+        };
+
+        GUIManager();
+        ~GUIManager();
+
+        bool initialise(Ogre::RenderWindow* renderWindow);
+        void tick(float dt)
+        {
+            assert(guiSystem_);
+            guiSystem_->injectTimePulse(dt);
+        }
+        void showGUI(const std::string& name, Ogre::SceneManager* sceneManager);// bool showBackground); // tolua_export
+        void hideGUI(); // tolua_export
+
+        Ogre::Camera* getCamera() { return this->backgroundCamera_; }
+
+        static void showGUI_s(const std::string& name, Ogre::SceneManager* sceneManager)//bool showBackground)
+        {
+            getInstance().showGUI(name, sceneManager);
+        }
+
+        static GUIManager& getInstance()    { assert(singletonRef_s); return *singletonRef_s; } // tolua_export
+        static GUIManager* getInstancePtr() { return singletonRef_s; }
+
+    private:
+        GUIManager(const GUIManager& instance);
+
+        void keyPressed (const KeyEvent& evt)
+        { guiSystem_->injectKeyDown(evt.key); guiSystem_->injectChar(evt.text); }
+        void keyReleased(const KeyEvent& evt)
+        { guiSystem_->injectKeyUp(evt.key); }
+        void keyHeld    (const KeyEvent& evt)
+        { }
+
+        void mouseButtonPressed (MouseButton::Enum id);
+        void mouseButtonReleased(MouseButton::Enum id);
+        void mouseButtonHeld    (MouseButton::Enum id)
+        { }
+        void mouseMoved         (IntVector2 abs, IntVector2 rel, IntVector2 clippingSize)
+        { guiSystem_->injectMouseMove(rel.x, rel.y); }
+        void mouseScrolled      (int abs, int rel)
+        { guiSystem_->injectMouseWheelChange(rel);}
+
+        void tickInput(float dt) { }
+        void tickKey(float dt) { }
+        void tickMouse(float dt) { }
+
+        void loadScenes();
+
+        //Ogre::SceneManager*       emptySceneManager_;
+        Ogre::SceneManager*       backgroundSceneManager_;
+        //Ogre::Camera*             emptyCamera_;
+        Ogre::Camera*             backgroundCamera_;
+        //Ogre::Viewport*           viewport_;
+        Ogre::RenderWindow*       renderWindow_;
+        CEGUI::OgreCEGUIRenderer* guiRenderer_;
+        CEGUI::ResourceProvider*  resourceProvider_;
+        CEGUI::LuaScriptModule*   scriptModule_;
+        CEGUI::System*            guiSystem_;
+        CEGUI::Imageset*          backgroundImage_;
+        lua_State*                luaState_;
+
+        State state_;
+
+        static CEGUI::MouseButton convertButton(MouseButton::Enum button);
+
+        static GUIManager*        singletonRef_s;
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _GUIManager_H__ */
Index: code/trunk/src/orxonox/gui/OgreCEGUIRenderer.cpp
===================================================================
--- code/trunk/src/orxonox/gui/OgreCEGUIRenderer.cpp	(revision 1755)
+++ code/trunk/src/orxonox/gui/OgreCEGUIRenderer.cpp	(revision 1755)
@@ -0,0 +1,802 @@
+/************************************************************************
+    filename: 	OgreCEGUIRenderer.cpp
+    created:	11/5/2004
+    author:		Paul D Turner
+    
+    purpose:	Implementation of Renderer class for Ogre engine
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+
+#include <CEGUIImagesetManager.h>
+#include <CEGUIImageset.h>
+#include <CEGUIImage.h>
+#include <CEGUIExceptions.h>
+#include <CEGUISystem.h>
+
+#include "OgreCEGUIRenderer.h"
+#include "OgreCEGUITexture.h"
+#include "OgreCEGUIResourceProvider.h"
+
+#include <OgreRenderSystem.h>
+#include <OgreRoot.h>
+#include <OgreHardwareBufferManager.h>
+#include <OgreRenderWindow.h>
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*************************************************************************
+    Constants definitions
+*************************************************************************/
+const size_t	OgreCEGUIRenderer::VERTEX_PER_QUAD			= 6;
+const size_t	OgreCEGUIRenderer::VERTEX_PER_TRIANGLE		= 3;
+const size_t	OgreCEGUIRenderer::VERTEXBUFFER_INITIAL_CAPACITY	= 256;
+const size_t    OgreCEGUIRenderer::UNDERUSED_FRAME_THRESHOLD = 50000; // halfs buffer every 8 minutes on 100fps
+
+/*************************************************************************
+    Utility function to create a render operation and vertex buffer to render quads
+*************************************************************************/
+static void createQuadRenderOp(Ogre::RenderOperation &d_render_op, 
+    Ogre::HardwareVertexBufferSharedPtr &d_buffer, size_t nquads)
+{
+    using namespace Ogre;
+    // Create and initialise the Ogre specific parts required for use in rendering later.
+    d_render_op.vertexData = new VertexData;
+    d_render_op.vertexData->vertexStart = 0;
+
+    // setup vertex declaration for the vertex format we use
+    VertexDeclaration* vd = d_render_op.vertexData->vertexDeclaration;
+    size_t vd_offset = 0;
+    vd->addElement(0, vd_offset, VET_FLOAT3, VES_POSITION);
+    vd_offset += VertexElement::getTypeSize(VET_FLOAT3);
+    vd->addElement(0, vd_offset, VET_COLOUR, VES_DIFFUSE);
+    vd_offset += VertexElement::getTypeSize(VET_COLOUR);
+    vd->addElement(0, vd_offset, VET_FLOAT2, VES_TEXTURE_COORDINATES);
+
+    // create hardware vertex buffer
+    d_buffer = HardwareBufferManager::getSingleton().createVertexBuffer(vd->getVertexSize(0), nquads,  
+        HardwareBuffer::HBU_DYNAMIC_WRITE_ONLY_DISCARDABLE, false);
+
+    // bind vertex buffer
+    d_render_op.vertexData->vertexBufferBinding->setBinding(0, d_buffer);
+
+    // complete render operation basic initialisation
+    d_render_op.operationType = RenderOperation::OT_TRIANGLE_LIST;
+    d_render_op.useIndexes = false;
+}
+
+static void destroyQuadRenderOp(Ogre::RenderOperation &d_render_op, 
+    Ogre::HardwareVertexBufferSharedPtr &d_buffer)
+{
+    delete d_render_op.vertexData;
+    d_render_op.vertexData = 0;
+    d_buffer.setNull();
+}
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+OgreCEGUIRenderer::OgreCEGUIRenderer(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads)
+{
+    constructor_impl(window, queue_id, post_queue, max_quads);
+}
+
+
+/*************************************************************************
+    Constructor (specifying scene manager)
+*************************************************************************/
+OgreCEGUIRenderer::OgreCEGUIRenderer(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads, Ogre::SceneManager* scene_manager)
+{
+    constructor_impl(window, queue_id, post_queue, max_quads);
+
+    // hook into ogre rendering system
+    setTargetSceneManager(scene_manager);
+}
+
+
+/*************************************************************************
+    Destructor
+*************************************************************************/
+OgreCEGUIRenderer::~OgreCEGUIRenderer(void)
+{
+    setTargetSceneManager(NULL);
+
+    if (d_ourlistener)
+    {
+        delete d_ourlistener;
+    }
+
+    // cleanup vertex data we allocated in constructor
+    destroyQuadRenderOp(d_render_op, d_buffer);
+    destroyQuadRenderOp(d_direct_render_op, d_direct_buffer);
+
+    destroyAllTextures();
+}
+
+
+/*************************************************************************
+    add's a quad to the list to be rendered
+*************************************************************************/
+void OgreCEGUIRenderer::addQuad(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode)
+{
+    // if not queueing, render directly (as in, right now!). This is used for the mouse cursor.
+    if (!d_queueing)
+    {
+        renderQuadDirect(dest_rect, z, tex, texture_rect, colours, quad_split_mode);
+    }
+    else
+    {
+        d_sorted = false;
+        QuadInfo quad;
+        
+        // set quad position, flipping y co-ordinates, and applying appropriate texel origin offset
+        quad.position.d_left	= dest_rect.d_left;
+        quad.position.d_right	= dest_rect.d_right;
+        quad.position.d_top		= d_display_area.getHeight() - dest_rect.d_top;
+        quad.position.d_bottom	= d_display_area.getHeight() - dest_rect.d_bottom;
+        quad.position.offset(d_texelOffset);
+
+        // convert quad co-ordinates for a -1 to 1 co-ordinate system.
+        quad.position.d_left	/= (d_display_area.getWidth() * 0.5f);
+        quad.position.d_right	/= (d_display_area.getWidth() * 0.5f);
+        quad.position.d_top		/= (d_display_area.getHeight() * 0.5f);
+        quad.position.d_bottom	/= (d_display_area.getHeight() * 0.5f);
+        quad.position.offset(Point(-1.0f, -1.0f));
+
+        quad.z				= -1 + z;
+        quad.texture		= ((OgreCEGUITexture*)tex)->getOgreTexture();
+        quad.texPosition	= texture_rect;
+
+        // covert colours for ogre, note that top / bottom are switched.
+        quad.topLeftCol		= colourToOgre(colours.d_bottom_left);
+        quad.topRightCol	= colourToOgre(colours.d_bottom_right);
+        quad.bottomLeftCol	= colourToOgre(colours.d_top_left);
+        quad.bottomRightCol	= colourToOgre(colours.d_top_right);
+        
+        // set quad split mode
+        quad.splitMode = quad_split_mode;
+
+        d_quadlist.insert(quad);
+    }
+}
+
+
+
+/*************************************************************************
+perform final rendering for all queued renderable quads.
+*************************************************************************/
+void OgreCEGUIRenderer::doRender(void)
+{
+    // Render if overlays enabled and the quad list is not empty
+
+    // ORXONOX CHANGE: Even render when OverlaysEnabled is deactivated
+    // The reason is that we don't want the HUD to be shown in the viewport of the
+    // GUI (uses its own viewport to be able render on top of all viewports).
+    // But since we don't use overlays in the GUI, it doesn't matter.
+    // ORXONOX REVERT: Changes are not in place anymore, but might be in the future!
+    if (d_render_sys->_getViewport()->getOverlaysEnabled() && !d_quadlist.empty())
+    //if (!d_quadlist.empty())
+    {
+        /// Quad list needs to be sorted and thus the vertex buffer rebuilt. If not, we can
+        /// reuse the vertex buffer resulting in a nice speed gain.
+        if(!d_sorted)
+        {
+            sortQuads();
+            /// Resize vertex buffer if it is too small
+            size_t size = d_buffer->getNumVertices();
+            size_t requestedSize = d_quadlist.size()*VERTEX_PER_QUAD;
+            if(size < requestedSize)
+            {
+                /// Double buffer size until smaller than requested size
+                while(size < requestedSize)
+                    size = size * 2;
+                /// Reallocate the buffer
+                destroyQuadRenderOp(d_render_op, d_buffer);
+                createQuadRenderOp(d_render_op, d_buffer, size);
+            }
+            else if(requestedSize < size/2 && d_underused_framecount >= UNDERUSED_FRAME_THRESHOLD)
+            {
+                /// Resize vertex buffer if it has been to big for too long
+                size = size / 2;
+                destroyQuadRenderOp(d_render_op, d_buffer);
+                createQuadRenderOp(d_render_op, d_buffer, size);
+                /// Reset underused framecount so it takes another UNDERUSED_FRAME_THRESHOLD to half again
+                d_underused_framecount = 0;
+            }
+            /// Fill the buffer
+            QuadVertex*	buffmem;
+            buffmem = (QuadVertex*)d_buffer->lock(Ogre::HardwareVertexBuffer::HBL_DISCARD);
+            // iterate over each quad in the list
+            for (QuadList::iterator i = d_quadlist.begin(); i != d_quadlist.end(); ++i)
+            {
+                const QuadInfo& quad = (*i);
+                // setup Vertex 1...
+                buffmem->x = quad.position.d_left;
+                buffmem->y = quad.position.d_bottom;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.topLeftCol;
+                buffmem->tu1 = quad.texPosition.d_left;
+                buffmem->tv1 = quad.texPosition.d_bottom;
+                ++buffmem;
+    
+                // setup Vertex 2...
+                
+                // top-left to bottom-right diagonal
+                if (quad.splitMode == TopLeftToBottomRight)
+                {
+                    buffmem->x = quad.position.d_right;
+                    buffmem->y = quad.position.d_bottom;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.topRightCol;
+                    buffmem->tu1 = quad.texPosition.d_right;
+                    buffmem->tv1 = quad.texPosition.d_bottom;
+                }
+                // bottom-left to top-right diagonal
+                else
+                {
+                    buffmem->x = quad.position.d_right;
+                    buffmem->y = quad.position.d_top;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.bottomRightCol;
+                    buffmem->tu1 = quad.texPosition.d_right;
+                    buffmem->tv1 = quad.texPosition.d_top;
+                }
+                ++buffmem;
+    
+                // setup Vertex 3...
+                buffmem->x = quad.position.d_left;
+                buffmem->y = quad.position.d_top;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.bottomLeftCol;
+                buffmem->tu1 = quad.texPosition.d_left;
+                buffmem->tv1 = quad.texPosition.d_top;
+                ++buffmem;
+    
+                // setup Vertex 4...
+                buffmem->x = quad.position.d_right;
+                buffmem->y = quad.position.d_bottom;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.topRightCol;
+                buffmem->tu1 = quad.texPosition.d_right;
+                buffmem->tv1 = quad.texPosition.d_bottom;
+                ++buffmem;
+    
+                // setup Vertex 5...
+                buffmem->x = quad.position.d_right;
+                buffmem->y = quad.position.d_top;
+                buffmem->z = quad.z;
+                buffmem->diffuse = quad.bottomRightCol;
+                buffmem->tu1 = quad.texPosition.d_right;
+                buffmem->tv1 = quad.texPosition.d_top;
+                ++buffmem;
+    
+                // setup Vertex 6...
+                
+                // top-left to bottom-right diagonal
+                if (quad.splitMode == TopLeftToBottomRight)
+                {
+                    buffmem->x = quad.position.d_left;
+                    buffmem->y = quad.position.d_top;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.bottomLeftCol;
+                    buffmem->tu1 = quad.texPosition.d_left;
+                    buffmem->tv1 = quad.texPosition.d_top;
+                }
+                // bottom-left to top-right diagonal
+                else
+                {
+                    buffmem->x = quad.position.d_left;
+                    buffmem->y = quad.position.d_bottom;
+                    buffmem->z = quad.z;
+                    buffmem->diffuse = quad.topLeftCol;
+                    buffmem->tu1 = quad.texPosition.d_left;
+                    buffmem->tv1 = quad.texPosition.d_bottom;
+                }
+                ++buffmem;
+            }
+    
+            // ensure we leave the buffer in the unlocked state
+            d_buffer->unlock();
+        }
+        
+        /// Render the buffer
+        d_bufferPos = 0;
+        bool first = true;
+
+        // Iterate over each quad in the list and render it
+        QuadList::iterator i = d_quadlist.begin();
+        while(i != d_quadlist.end())
+        {
+            
+            d_currTexture = i->texture;
+            d_render_op.vertexData->vertexStart = d_bufferPos;
+            for (; i != d_quadlist.end(); ++i)
+            {
+                const QuadInfo& quad = (*i);
+                if (d_currTexture != quad.texture)
+                {
+                    /// If it has a different texture, render this quad in next operation
+                    /// also need to reset render states
+                    first = true;
+                    break;
+                }
+                d_bufferPos += VERTEX_PER_QUAD;
+            }
+            d_render_op.vertexData->vertexCount = d_bufferPos - d_render_op.vertexData->vertexStart;
+            /// Set texture, and do the render
+            d_render_sys->_setTexture(0, true, d_currTexture);
+            if (first)
+            {
+                initRenderStates();
+                first = false;
+            }
+            d_render_sys->_render(d_render_op);
+        }
+
+    }
+    /// Count frames to check if utilization of vertex buffer was below half the capacity for 500,000 frames
+    if(d_bufferPos < d_buffer->getNumVertices()/2)
+       d_underused_framecount++;
+    else
+       d_underused_framecount = 0;
+}
+
+
+/*************************************************************************
+    clear the queue
+*************************************************************************/
+void OgreCEGUIRenderer::clearRenderList(void)
+{
+    d_sorted = true;
+    d_quadlist.clear();
+}
+
+
+/*************************************************************************
+    create an empty texture
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(void)
+{
+    OgreCEGUITexture* tex = new OgreCEGUITexture(this);
+    d_texturelist.push_back(tex);
+    return tex;
+}
+
+
+/*************************************************************************
+    create a texture and load it with the specified file.
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(const String& filename, const String& resourceGroup)
+{
+    OgreCEGUITexture* tex = (OgreCEGUITexture*)createTexture();
+    tex->loadFromFile(filename, resourceGroup);
+
+    return tex;
+}
+
+
+/*************************************************************************
+    create a texture and set it to the specified size
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(float size)
+{
+    OgreCEGUITexture* tex = (OgreCEGUITexture*)createTexture();
+    tex->setOgreTextureSize((uint)size);
+
+    return tex;
+}
+
+
+/*************************************************************************
+    destroy the given texture
+*************************************************************************/
+void OgreCEGUIRenderer::destroyTexture(Texture* texture)
+{
+    if (texture != NULL)
+    {
+        OgreCEGUITexture* tex = (OgreCEGUITexture*)texture;
+
+        d_texturelist.remove(tex);
+        delete tex;
+    }
+}
+
+
+/*************************************************************************
+    destroy all textures still active
+*************************************************************************/
+void OgreCEGUIRenderer::destroyAllTextures(void)
+{
+    while (!d_texturelist.empty())
+    {
+        destroyTexture(*(d_texturelist.begin()));
+    }
+}
+
+
+/*************************************************************************
+    setup states etc	
+*************************************************************************/
+void OgreCEGUIRenderer::initRenderStates(void)
+{
+    using namespace Ogre;
+
+    // set-up matrices
+    d_render_sys->_setWorldMatrix(Matrix4::IDENTITY);
+    d_render_sys->_setViewMatrix(Matrix4::IDENTITY);
+    d_render_sys->_setProjectionMatrix(Matrix4::IDENTITY);
+
+    // initialise render settings
+    d_render_sys->setLightingEnabled(false);
+    d_render_sys->_setDepthBufferParams(false, false);
+    d_render_sys->_setDepthBias(0, 0);
+    d_render_sys->_setCullingMode(CULL_NONE);
+    d_render_sys->_setFog(FOG_NONE);
+    d_render_sys->_setColourBufferWriteEnabled(true, true, true, true);
+    d_render_sys->unbindGpuProgram(GPT_FRAGMENT_PROGRAM);
+    d_render_sys->unbindGpuProgram(GPT_VERTEX_PROGRAM);
+    d_render_sys->setShadingType(SO_GOURAUD);
+    d_render_sys->_setPolygonMode(PM_SOLID);
+
+    // initialise texture settings
+    d_render_sys->_setTextureCoordCalculation(0, TEXCALC_NONE);
+    d_render_sys->_setTextureCoordSet(0, 0);
+    d_render_sys->_setTextureUnitFiltering(0, FO_LINEAR, FO_LINEAR, FO_POINT);
+    d_render_sys->_setTextureAddressingMode(0, d_uvwAddressMode);
+    d_render_sys->_setTextureMatrix(0, Matrix4::IDENTITY);
+    d_render_sys->_setAlphaRejectSettings(CMPF_ALWAYS_PASS, 0);
+    d_render_sys->_setTextureBlendMode(0, d_colourBlendMode);
+    d_render_sys->_setTextureBlendMode(0, d_alphaBlendMode);
+    d_render_sys->_disableTextureUnitsFrom(1);
+
+    // enable alpha blending
+    d_render_sys->_setSceneBlending(SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA);
+}
+
+
+ 
+/*************************************************************************
+    sort quads list according to texture	
+*************************************************************************/
+void OgreCEGUIRenderer::sortQuads(void)
+{
+    if (!d_sorted)
+    {
+        d_sorted = true;
+    }
+
+}
+
+/*************************************************************************
+render a quad directly to the display
+*************************************************************************/
+void OgreCEGUIRenderer::renderQuadDirect(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode)
+{
+    // ORXONOX CHANGE: Even render when OverlaysEnabled is deactivated
+    // The reason is that we don't want the HUD to be shown in the viewport of the
+    // GUI (uses its own viewport to be able render on top of all viewports).
+    // But since we don't use overlays in the GUI, it doesn't matter.
+    // ORXONOX REVERT: Changes are not in place anymore, but might be in the future!
+    if (d_render_sys->_getViewport()->getOverlaysEnabled())
+    //if (true)
+    {
+        z = -1 + z;
+
+        Rect final_rect;
+
+        // set quad position, flipping y co-ordinates, and applying appropriate texel origin offset
+        final_rect.d_left	= dest_rect.d_left;
+        final_rect.d_right	= dest_rect.d_right;
+        final_rect.d_top	= d_display_area.getHeight() - dest_rect.d_top;
+        final_rect.d_bottom	= d_display_area.getHeight() - dest_rect.d_bottom;
+        final_rect.offset(d_texelOffset);
+
+        // convert quad co-ordinates for a -1 to 1 co-ordinate system.
+        final_rect.d_left	/= (d_display_area.getWidth() * 0.5f);
+        final_rect.d_right	/= (d_display_area.getWidth() * 0.5f);
+        final_rect.d_top	/= (d_display_area.getHeight() * 0.5f);
+        final_rect.d_bottom	/= (d_display_area.getHeight() * 0.5f);
+        final_rect.offset(Point(-1.0f, -1.0f));
+
+        // convert colours for ogre, note that top / bottom are switched.
+        uint32 topLeftCol	= colourToOgre(colours.d_bottom_left);
+        uint32 topRightCol	= colourToOgre(colours.d_bottom_right);
+        uint32 bottomLeftCol	= colourToOgre(colours.d_top_left);
+        uint32 bottomRightCol= colourToOgre(colours.d_top_right);
+
+        QuadVertex*	buffmem = (QuadVertex*)d_direct_buffer->lock(Ogre::HardwareVertexBuffer::HBL_DISCARD);
+
+        // setup Vertex 1...
+        buffmem->x	= final_rect.d_left;
+        buffmem->y	= final_rect. d_bottom;
+        buffmem->z	= z;
+        buffmem->diffuse = topLeftCol;
+        buffmem->tu1	= texture_rect.d_left;
+        buffmem->tv1	= texture_rect.d_bottom;
+        ++buffmem;
+
+        // setup Vertex 2...
+        
+        // top-left to bottom-right diagonal
+        if (quad_split_mode == TopLeftToBottomRight)
+        {
+            buffmem->x	= final_rect.d_right;
+            buffmem->y = final_rect.d_bottom;
+            buffmem->z	= z;
+            buffmem->diffuse = topRightCol;
+            buffmem->tu1	= texture_rect.d_right;
+            buffmem->tv1	= texture_rect.d_bottom;
+            ++buffmem;
+        }
+        // bottom-left to top-right diagonal
+        else
+        {
+            buffmem->x	= final_rect.d_right;
+            buffmem->y = final_rect.d_top;
+            buffmem->z	= z;
+            buffmem->diffuse = bottomRightCol;
+            buffmem->tu1	= texture_rect.d_right;
+            buffmem->tv1	= texture_rect.d_top;
+            ++buffmem;
+        }
+
+        // setup Vertex 3...
+        buffmem->x	= final_rect.d_left;
+        buffmem->y	= final_rect.d_top;
+        buffmem->z	= z;
+        buffmem->diffuse = bottomLeftCol;
+        buffmem->tu1	= texture_rect.d_left;
+        buffmem->tv1	= texture_rect.d_top;
+        ++buffmem;
+
+        // setup Vertex 4...
+        buffmem->x	= final_rect.d_right;
+        buffmem->y	= final_rect.d_bottom;
+        buffmem->z	= z;
+        buffmem->diffuse = topRightCol;
+        buffmem->tu1	= texture_rect.d_right;
+        buffmem->tv1	= texture_rect.d_bottom;
+        ++buffmem;
+
+        // setup Vertex 5...
+        buffmem->x	= final_rect.d_right;
+        buffmem->y	= final_rect.d_top;
+        buffmem->z	= z;
+        buffmem->diffuse = bottomRightCol;
+        buffmem->tu1	= texture_rect.d_right;
+        buffmem->tv1	= texture_rect.d_top;
+        ++buffmem;
+
+        // setup Vertex 6...
+        
+        // top-left to bottom-right diagonal
+        if (quad_split_mode == TopLeftToBottomRight)
+        {
+            buffmem->x	= final_rect.d_left;
+            buffmem->y = final_rect.d_top;
+            buffmem->z	= z;
+            buffmem->diffuse = bottomLeftCol;
+            buffmem->tu1	= texture_rect.d_left;
+            buffmem->tv1	= texture_rect.d_top;
+        }
+        // bottom-left to top-right diagonal
+        else
+        {
+            buffmem->x	= final_rect.d_left;
+            buffmem->y = final_rect.d_bottom;
+            buffmem->z	= z;
+            buffmem->diffuse = topLeftCol;
+            buffmem->tu1	= texture_rect.d_left;
+            buffmem->tv1	= texture_rect.d_bottom;
+        }
+
+        d_direct_buffer->unlock();
+
+        //
+        // perform rendering...
+        //
+        d_render_sys->_setTexture(0, true, ((OgreCEGUITexture*)tex)->getOgreTexture()->getName());
+        initRenderStates();
+        d_direct_render_op.vertexData->vertexCount = VERTEX_PER_QUAD;
+        d_render_sys->_render(d_direct_render_op);
+    }
+
+}
+
+/*************************************************************************
+    convert ARGB colour value to whatever the Ogre render system is
+    expecting.	
+*************************************************************************/
+uint32 OgreCEGUIRenderer::colourToOgre(const colour& col) const
+{
+    Ogre::ColourValue cv(col.getRed(), col.getGreen(), col.getBlue(), col.getAlpha());
+
+    uint32 final;
+    d_render_sys->convertColourValue(cv, &final);
+
+    return final;
+}
+
+
+/*************************************************************************
+    Set the scene manager to be used for rendering the GUI.	
+*************************************************************************/
+void OgreCEGUIRenderer::setTargetSceneManager(Ogre::SceneManager* scene_manager)
+{
+    // unhook from current scene manager.
+    if (d_sceneMngr != NULL)
+    {
+        d_sceneMngr->removeRenderQueueListener(d_ourlistener);
+        d_sceneMngr = NULL;
+    }
+
+    // hook new scene manager if that is not NULL
+    if (scene_manager != NULL)
+    {
+        d_sceneMngr = scene_manager;
+        d_sceneMngr->addRenderQueueListener(d_ourlistener);
+    }
+
+}
+
+
+/*************************************************************************
+    Set the target render queue for GUI rendering.	
+*************************************************************************/
+void OgreCEGUIRenderer::setTargetRenderQueue(Ogre::uint8 queue_id, bool post_queue)
+{
+    d_queue_id		= queue_id;
+    d_post_queue	= post_queue;
+
+    if (d_ourlistener != NULL)
+    {
+        d_ourlistener->setTargetRenderQueue(queue_id);
+        d_ourlistener->setPostRenderQueue(post_queue);
+    }
+
+}
+
+
+/*************************************************************************
+    perform main work of the constructor
+*************************************************************************/
+void OgreCEGUIRenderer::constructor_impl(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads)
+{
+    using namespace Ogre;
+
+    // initialise the renderer fields
+    d_queueing		= true;
+    d_queue_id		= queue_id;
+    d_currTexture.isNull();
+    d_post_queue	= post_queue;
+    d_sceneMngr		= NULL;
+    d_bufferPos		= 0;
+    d_sorted		= true;
+    d_ogre_root		= Root::getSingletonPtr();
+    d_render_sys	= d_ogre_root->getRenderSystem();
+    // set ID string
+    d_identifierString = "CEGUI::OgreRenderer - Official Ogre based renderer module for CEGUI";
+
+    // Create and initialise the Ogre specific parts required for use in rendering later.
+    // Main GUI
+    createQuadRenderOp(d_render_op, d_buffer, VERTEXBUFFER_INITIAL_CAPACITY);
+    d_underused_framecount = 0;
+
+    // Mouse cursor
+    createQuadRenderOp(d_direct_render_op, d_direct_buffer, VERTEX_PER_QUAD);
+
+    // Discover display settings and setup d_display_area
+    d_display_area.d_left	= 0;
+    d_display_area.d_top	= 0;
+    d_display_area.d_right	= window->getWidth();
+    d_display_area.d_bottom	= window->getHeight();
+
+    // initialise required texel offset
+    d_texelOffset = Point((float)d_render_sys->getHorizontalTexelOffset(), -(float)d_render_sys->getVerticalTexelOffset());
+
+    // create listener which will handler the rendering side of things for us.
+    d_ourlistener = new CEGUIRQListener(this, queue_id, post_queue);
+
+    // Initialise blending modes to be used.
+    d_colourBlendMode.blendType	= Ogre::LBT_COLOUR;
+    d_colourBlendMode.source1	= Ogre::LBS_TEXTURE;
+    d_colourBlendMode.source2	= Ogre::LBS_DIFFUSE;
+    d_colourBlendMode.operation	= Ogre::LBX_MODULATE;
+
+    d_alphaBlendMode.blendType	= Ogre::LBT_ALPHA;
+    d_alphaBlendMode.source1	= Ogre::LBS_TEXTURE;
+    d_alphaBlendMode.source2	= Ogre::LBS_DIFFUSE;
+    d_alphaBlendMode.operation	= Ogre::LBX_MODULATE;
+
+    d_uvwAddressMode.u = Ogre::TextureUnitState::TAM_CLAMP;
+    d_uvwAddressMode.v = Ogre::TextureUnitState::TAM_CLAMP;
+    d_uvwAddressMode.w = Ogre::TextureUnitState::TAM_CLAMP;
+}
+
+
+/*************************************************************************
+    Create a texture from an existing Ogre::TexturePtr object	
+*************************************************************************/
+Texture* OgreCEGUIRenderer::createTexture(Ogre::TexturePtr& texture)
+{
+    OgreCEGUITexture* t = (OgreCEGUITexture*)createTexture();
+
+    if (!texture.isNull())
+    {
+        t->setOgreTexture(texture);
+    }
+
+    return t;
+
+}
+
+/*************************************************************************
+    Create a resource provider object
+*************************************************************************/
+ResourceProvider* OgreCEGUIRenderer::createResourceProvider(void)
+{
+    d_resourceProvider = new OgreCEGUIResourceProvider();
+    return d_resourceProvider;
+}
+
+/*************************************************************************
+Set the size of the display in pixels.	
+*************************************************************************/
+void OgreCEGUIRenderer::setDisplaySize(const Size& sz)
+{
+    if (d_display_area.getSize() != sz)
+    {
+        d_display_area.setSize(sz);
+
+        EventArgs args;
+        fireEvent(EventDisplaySizeChanged, args, EventNamespace);
+    }
+
+}
+
+/*************************************************************************
+    Callback from Ogre invoked before other stuff in our target queue
+    is rendered
+*************************************************************************/
+void CEGUIRQListener::renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, 
+                                         bool& skipThisQueue)
+{
+    if ((!d_post_queue) && (d_queue_id == id))
+    {
+        CEGUI::System::getSingleton().renderGUI();
+    }
+
+}
+
+
+/*************************************************************************
+Callback from Ogre invoked after other stuff in our target queue
+is rendered
+*************************************************************************/
+void CEGUIRQListener::renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue)
+{
+    if ((d_post_queue) && (d_queue_id == id))
+    {
+        CEGUI::System::getSingleton().renderGUI();
+    }
+
+}
+
+} // End of  CEGUI namespace section
Index: code/trunk/src/orxonox/gui/OgreCEGUIRenderer.h
===================================================================
--- code/trunk/src/orxonox/gui/OgreCEGUIRenderer.h	(revision 1755)
+++ code/trunk/src/orxonox/gui/OgreCEGUIRenderer.h	(revision 1755)
@@ -0,0 +1,464 @@
+/************************************************************************
+    filename: 	OgreCEGUIRenderer.h
+    created:	11/5/2004
+    author:		Paul D Turner
+
+    purpose:	Interface for main Ogre GUI renderer class
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+/*************************************************************************
+    This file contains code that is specific to Ogre (http://www.ogre3d.org)
+*************************************************************************/
+#ifndef _OgreCEGUIRenderer_h_
+#define _OgreCEGUIRenderer_h_
+
+#include <CEGUIBase.h>
+#include <CEGUIRenderer.h>
+#include <CEGUITexture.h>
+
+#include <OgreRenderQueueListener.h>
+#include <OgreSceneManagerEnumerator.h>
+#include <OgreTextureUnitState.h>
+
+#if (OGRE_PLATFORM == OGRE_PLATFORM_WIN32) && !defined(OGRE_STATIC_LIB)
+#   ifdef OGRE_GUIRENDERER_EXPORTS
+#       define OGRE_GUIRENDERER_API __declspec(dllexport)
+#   else
+#       if defined(__MINGW32__)
+#           define OGRE_GUIRENDERER_API
+#       else
+#           define OGRE_GUIRENDERER_API __declspec(dllimport)
+#       endif
+#   endif
+#elif defined ( OGRE_GCC_VISIBILITY )
+#    define OGRE_GUIRENDERER_API  __attribute__ ((visibility("default")))
+#else
+#    define OGRE_GUIRENDERER_API
+#endif
+
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*************************************************************************
+    Forward refs
+*************************************************************************/
+class OgreCEGUITexture;
+class OgreCEGUIRenderer;
+
+
+/*!
+\brief
+    RenderQueueListener based class used to hook into the ogre rendering system
+*/
+class _OgrePrivate CEGUIRQListener : public Ogre::RenderQueueListener
+{
+public:
+    CEGUIRQListener(OgreCEGUIRenderer* renderer, Ogre::uint8 queue_id, bool post_queue)
+    {
+        d_renderer		= renderer;
+        d_queue_id		= queue_id;
+        d_post_queue	= post_queue;
+    }
+
+    virtual ~CEGUIRQListener() {}
+
+    virtual void	renderQueueStarted(Ogre::uint8 id, const Ogre::String& invocation, bool& skipThisQueue);
+    virtual void	renderQueueEnded(Ogre::uint8 id, const Ogre::String& invocation, bool& repeatThisQueue);
+
+    // methods for adjusting target queue settings
+    void	setTargetRenderQueue(Ogre::uint8 queue_id)		{d_queue_id = queue_id;}
+    void	setPostRenderQueue(bool post_queue)		{d_post_queue = post_queue;}
+
+private:
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    OgreCEGUIRenderer*				d_renderer;		//!< CEGUI renderer object for Ogre.
+    Ogre::uint8	d_queue_id;		//!< ID of the queue that we are hooked into
+    bool						d_post_queue;	//!< true if we render after everything else in our queue.
+};
+
+
+/*!
+\brief
+    Renderer class to interface with Ogre engine.
+*/
+class OGRE_GUIRENDERER_API OgreCEGUIRenderer : public Renderer
+{
+public:
+    /*!
+    \brief
+        Constructor for renderer class that uses Ogre for rendering. Note that if
+        you use this option you must call setTargetSceneManager before rendering.
+
+    \param window
+        Pointer to an Ogre::RenderWindow object.
+
+    \param queue_id
+        Ogre::uint8 value that specifies where the GUI should appear in the ogre rendering output.
+
+    \param post_queue
+        set to true to have GUI rendered after render queue \a queue_id, or false to have the GUI rendered before render queue
+        \a queue_id.
+
+    \param max_quads
+        Obsolete.  Set to 0.
+
+    */
+    OgreCEGUIRenderer(Ogre::RenderWindow* window,
+        Ogre::uint8 queue_id = Ogre::RENDER_QUEUE_OVERLAY,
+        bool post_queue = false, uint max_quads = 0);
+
+
+    /*!
+    \brief
+        Constructor for renderer class that uses Ogre for rendering.
+
+    \param window
+        Pointer to an Ogre::RenderWindow object.
+
+    \param queue_id
+        Ogre::uint8 value that specifies where the GUI should appear in the ogre rendering output.
+
+    \param post_queue
+        set to true to have GUI rendered after render queue \a queue_id, or false to have the GUI rendered before render queue
+        \a queue_id.
+
+    \param max_quads
+        Obsolete.  Set to 0.
+
+    \param scene_manager
+        Pointer to an Ogre::SceneManager object that is to be used for GUI rendering.
+    */
+    OgreCEGUIRenderer(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads, Ogre::SceneManager* scene_manager);
+
+
+    /*!
+    \brief
+        Destructor for Ogre renderer.
+    */
+    virtual ~OgreCEGUIRenderer(void);
+
+
+
+    // add's a quad to the list to be rendered
+    virtual	void	addQuad(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
+
+    // perform final rendering for all queued renderable quads.
+    virtual	void	doRender(void);
+
+    // clear the queue
+    virtual	void	clearRenderList(void);
+
+
+    /*!
+    \brief
+        Enable or disable the queueing of quads from this point on.
+
+        This only affects queueing.  If queueing is turned off, any calls to addQuad will cause the quad to be rendered directly.  Note that
+        disabling queueing will not cause currently queued quads to be rendered, nor is the queue cleared - at any time the queue can still
+        be drawn by calling doRender, and the list can be cleared by calling clearRenderList.  Re-enabling the queue causes subsequent quads
+        to be added as if queueing had never been disabled.
+
+    \param setting
+        true to enable queueing, or false to disable queueing (see notes above).
+
+    \return
+        Nothing
+    */
+    virtual void	setQueueingEnabled(bool setting)		{d_queueing = setting;}
+
+
+    // create an empty texture
+    virtual	Texture*	createTexture(void);
+
+    // create a texture and load it with the specified file.
+    virtual	Texture*	createTexture(const String& filename, const String& resourceGroup = "General");
+
+    // create a texture and set it to the specified size
+    virtual	Texture*	createTexture(float size);
+
+    // create an OGRE resource provider.
+    virtual ResourceProvider* createResourceProvider(void);
+
+    // destroy the given texture
+    virtual	void		destroyTexture(Texture* texture);
+
+    // destroy all textures still active
+    virtual void		destroyAllTextures(void);
+
+
+    /*!
+    \brief
+        Return whether queueing is enabled.
+
+    \return
+        true if queueing is enabled, false if queueing is disabled.
+    */
+    virtual bool	isQueueingEnabled(void) const	{return d_queueing;}
+
+
+    /*!
+    \brief
+    Return the current width of the display in pixels
+
+    \return
+    float value equal to the current width of the display in pixels.
+    */
+    virtual float	getWidth(void) const		{return d_display_area.getWidth();}
+
+
+    /*!
+    \brief
+    Return the current height of the display in pixels
+
+    \return
+    float value equal to the current height of the display in pixels.
+    */
+    virtual float	getHeight(void) const		{return d_display_area.getHeight();}
+
+
+    /*!
+    \brief
+    Return the size of the display in pixels
+
+    \return
+    Size object describing the dimensions of the current display.
+    */
+    virtual Size	getSize(void) const			{return d_display_area.getSize();}
+
+
+    /*!
+    \brief
+    Return a Rect describing the screen
+
+    \return
+    A Rect object that describes the screen area.  Typically, the top-left values are always 0, and the size of the area described is
+    equal to the screen resolution.
+    */
+    virtual Rect	getRect(void) const			{return d_display_area;}
+
+
+    /*!
+    \brief
+        Return the maximum texture size available
+
+    \return
+        Size of the maximum supported texture in pixels (textures are always assumed to be square)
+    */
+    virtual	uint	getMaxTextureSize(void) const		{return 2048;}		// TODO: Change to proper value
+
+
+    /*!
+    \brief
+        Return the horizontal display resolution dpi
+
+    \return
+        horizontal resolution of the display in dpi.
+    */
+    virtual	uint	getHorzScreenDPI(void) const	{return 96;}
+
+
+    /*!
+    \brief
+        Return the vertical display resolution dpi
+
+    \return
+        vertical resolution of the display in dpi.
+    */
+    virtual	uint	getVertScreenDPI(void) const	{return 96;}
+
+
+    /*!
+    \brief
+        Set the scene manager to be used for rendering the GUI.
+
+        The GUI system will be unhooked from the current scene manager and attached to what ever
+        is specified here.
+
+    \param scene_manager
+        Pointer to an Ogre::SceneManager object that is the new target Ogre::SceneManager to be
+        used for GUI rendering.
+
+    \return
+        Nothing.
+    */
+    void	setTargetSceneManager(Ogre::SceneManager* scene_manager);
+
+
+    /*!
+    \brief
+        Set the target render queue for GUI rendering.
+
+    \param queue_id
+        Ogre::uint8 value specifying the render queue that the GUI system should attach to.
+
+    \param post_queue
+        - true to specify that the GUI should render after everything else in render queue \a queue_id.
+        - false to specify the GUI should render before everything else in render queue \a queue_id.
+
+    \return
+        Nothing.
+    */
+    void	setTargetRenderQueue(Ogre::uint8 queue_id, bool post_queue);
+
+
+    /*!
+    \brief
+        Create a texture from an existing Ogre::TexturePtr object.
+
+    \note
+        If you want to use an Ogre::RenderTexture (for putting rendered output onto Gui elements or other
+        advanced techniques), you can get the Ogre::TexturePtr to be used by calling Ogre::TextureManager::getByName()
+        passing the name returned from Ogre::RenderTexture::getName() (and casting the result as necessary).
+
+    \param texture
+        pointer to an Ogre::TexturePtr object to be used as the basis for the new CEGUI::Texture
+
+    \return
+        Pointer to the newly created CEGUI::TexturePtr object.
+    */
+    Texture*	createTexture(Ogre::TexturePtr& texture);
+
+
+    /*!
+    \brief
+    Set the size of the display in pixels.
+
+    You do not have to call this method under normal operation as the system
+    will automatically extract the size from the current view port.
+
+    \note
+    This method will cause the EventDisplaySizeChanged event to fire if the
+    display size has changed.
+
+    \param sz
+    Size object describing the size of the display.
+
+    \return
+    Nothing.
+    */
+    void	setDisplaySize(const Size& sz);
+
+
+private:
+    /************************************************************************
+        Implementation Constants
+    ************************************************************************/
+    static const size_t    VERTEX_PER_QUAD;						 //!< number of vertices per quad
+    static const size_t    VERTEX_PER_TRIANGLE;					 //!< number of vertices for a triangle
+    static const size_t    VERTEXBUFFER_INITIAL_CAPACITY;		 //!< initial capacity of the allocated vertex buffer
+    static const size_t    UNDERUSED_FRAME_THRESHOLD;            //!< number of frames to wait before shrinking buffer
+
+    /*************************************************************************
+        Implementation Structs & classes
+    *************************************************************************/
+    /*!
+    \brief
+        structure used for all vertices.
+    */
+    struct QuadVertex {
+        float x, y, z;			//!< The position for the vertex.
+        Ogre::RGBA diffuse;		//!< colour of the vertex
+        float tu1, tv1;			//!< texture coordinates
+    };
+
+    /*!
+    \brief
+        structure holding details about a quad to be drawn
+    */
+    struct QuadInfo
+    {
+        Ogre::TexturePtr		texture;
+        Rect				position;
+        float				z;
+        Rect				texPosition;
+        uint32		        topLeftCol;
+        uint32		        topRightCol;
+        uint32		        bottomLeftCol;
+        uint32		        bottomRightCol;
+
+        QuadSplitMode		splitMode;
+
+        bool operator<(const QuadInfo& other) const
+        {
+            // this is intentionally reversed.
+            return z > other.z;
+        }
+    };
+
+
+    /*************************************************************************
+        Implementation Methods
+    *************************************************************************/
+    // setup states etc
+    void	initRenderStates(void);
+
+    // sort quads list according to texture
+    void	sortQuads(void);
+
+    // render a quad directly to the display
+    void	renderQuadDirect(const Rect& dest_rect, float z, const Texture* tex, const Rect& texture_rect, const ColourRect& colours, QuadSplitMode quad_split_mode);
+
+    // convert colour value to whatever the Ogre render system is expecting.
+    uint32    colourToOgre(const colour& col) const;
+
+    // perform main work of the constructor.  This does everything except the final hook into the render system.
+    void	constructor_impl(Ogre::RenderWindow* window, Ogre::uint8 queue_id, bool post_queue, uint max_quads);
+
+
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    Rect				d_display_area;
+
+    typedef std::multiset<QuadInfo>		QuadList;
+    QuadList d_quadlist;
+    bool	 d_queueing;		//!< setting for queueing control.
+
+    // Ogre specific bits.
+    Ogre::Root*					d_ogre_root;		//!< pointer to the Ogre root object that we attach to
+    Ogre::RenderSystem*			d_render_sys;		//!< Pointer to the render system for Ogre.
+    Ogre::uint8	d_queue_id;			//!< ID of the queue that we are hooked into
+    Ogre::TexturePtr			d_currTexture;		//!< currently set texture;
+    Ogre::RenderOperation		d_render_op;		//!< Ogre render operation we use to do our stuff.
+    Ogre::HardwareVertexBufferSharedPtr	d_buffer;	//!< vertex buffer to queue sprite rendering
+    size_t d_underused_framecount;                  //!< Number of frames elapsed since buffer utilization was above half the capacity
+    Ogre::RenderOperation		d_direct_render_op;		//!< Renderop for cursor
+    Ogre::HardwareVertexBufferSharedPtr	d_direct_buffer;	//!< Renderop for cursor
+    Ogre::SceneManager*			d_sceneMngr;		//!< The scene manager we are hooked into.
+    Ogre::LayerBlendModeEx		d_colourBlendMode;	//!< Controls colour blending mode used.
+    Ogre::LayerBlendModeEx		d_alphaBlendMode;	//!< Controls alpha blending mode used.
+    Ogre::TextureUnitState::UVWAddressingMode d_uvwAddressMode;
+
+    CEGUIRQListener*			d_ourlistener;
+    bool						d_post_queue;		//!< true if we render after everything else in our queue.
+    size_t						d_bufferPos;		//!< index into buffer where next vertex should be put.
+    bool						d_sorted;			//!< true when data in quad list is sorted.
+    Point						d_texelOffset;		//!< Offset required for proper texel mapping.
+
+    std::list<OgreCEGUITexture*> d_texturelist;		//!< List used to track textures.
+};
+
+} // End of  CEGUI namespace section
+
+
+#endif	// end of guard _OgreCEGUIRenderer_h_
Index: code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.cpp
===================================================================
--- code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.cpp	(revision 1755)
+++ code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.cpp	(revision 1755)
@@ -0,0 +1,97 @@
+/************************************************************************
+    filename: 	OgreCEGUIResourceProvider.cpp
+    created:	8/7/2004
+    author:		James '_mental_' O'Sullivan
+
+    purpose:	Implements the Resource Provider common functionality
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+#include "OgreCEGUIResourceProvider.h"
+
+#include <CEGUIExceptions.h>
+#include <OgreArchiveManager.h>
+
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+    OgreCEGUIResourceProvider::OgreCEGUIResourceProvider() : ResourceProvider()
+    {
+        // set deafult resource group for Ogre
+        d_defaultResourceGroup = Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str();
+    }
+
+//    void OgreResourceProvider::loadInputSourceContainer(const String& filename, InputSourceContainer& output)
+//   {
+//        Ogre::DataStreamPtr input = Ogre::ResourceGroupManager::getSingleton().openResource(filename.c_str());
+//
+//		if (input.isNull())
+//		{
+//			throw InvalidRequestException((utf8*)
+//				"Scheme::Scheme - Filename supplied for Scheme loading must be valid");
+//		}
+//
+//       XERCES_CPP_NAMESPACE_USE
+//        size_t buffsz = input->size();
+//        unsigned char* mem = reinterpret_cast<unsigned char*>(XMLPlatformUtils::fgArrayMemoryManager->allocate(buffsz));
+//        memcpy(mem, input.getPointer()->getAsString().c_str(), buffsz);
+//        InputSource* mInputSource = new MemBufInputSource(mem, buffsz, filename.c_str(), true);
+//        input.setNull();
+//
+//       output.setData(mInputSource);
+//    }
+
+    void OgreCEGUIResourceProvider::loadRawDataContainer(const String& filename, RawDataContainer& output,  const String& resourceGroup)
+    {
+        String orpGroup;
+        if (resourceGroup.empty())
+            orpGroup = d_defaultResourceGroup.empty() ? Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() : d_defaultResourceGroup;
+        else
+            orpGroup = resourceGroup;
+
+        Ogre::DataStreamPtr input =
+            Ogre::ResourceGroupManager::getSingleton().openResource(filename.c_str(), orpGroup.c_str());
+
+        if (input.isNull())
+        {
+            throw InvalidRequestException((utf8*)
+                "OgreCEGUIResourceProvider::loadRawDataContainer - Unable to open resource file '" + filename + (utf8*)"' in resource group '" + orpGroup + (utf8*)"'.");
+        }
+
+        Ogre::String buf = input->getAsString();
+        const size_t memBuffSize = buf.length();
+
+        unsigned char* mem = new unsigned char[memBuffSize];
+        memcpy(mem, buf.c_str(), memBuffSize);
+
+        output.setData(mem);
+        output.setSize(memBuffSize);
+    }
+
+    void OgreCEGUIResourceProvider::unloadRawDataContainer(RawDataContainer& data)
+    {
+        if (data.getDataPtr())
+        {
+            delete[] data.getDataPtr();
+            data.setData(0);
+            data.setSize(0);
+        }
+    }
+} // End of  CEGUI namespace section
Index: code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.h
===================================================================
--- code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.h	(revision 1755)
+++ code/trunk/src/orxonox/gui/OgreCEGUIResourceProvider.h	(revision 1755)
@@ -0,0 +1,52 @@
+/************************************************************************
+    filename: 	CEGUIOgreResourceProvider.h
+    created:	8/7/2004
+    author:		James '_mental_' O'Sullivan
+    
+    purpose:	Defines abstract base class for CEGUIData objects
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+#ifndef _OgreCEGUIResourceProvider_h_
+#define _OgreCEGUIResourceProvider_h_
+
+#include <CEGUIResourceProvider.h>
+#include "OgreCEGUIRenderer.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+class _OgrePrivate OgreCEGUIResourceProvider : public ResourceProvider
+{
+public:
+    /*************************************************************************
+        Construction and Destruction
+    *************************************************************************/
+    OgreCEGUIResourceProvider();
+
+    ~OgreCEGUIResourceProvider(void) {}
+
+//    void loadInputSourceContainer(const String& filename, InputSourceContainer& output);
+    void loadRawDataContainer(const String& filename, RawDataContainer& output, const String& resourceGroup);
+    void unloadRawDataContainer(RawDataContainer& output);
+};
+
+} // End of  CEGUI namespace section
+
+#endif	// end of guard _OgreCEGUIResourceProvider_h_
Index: code/trunk/src/orxonox/gui/OgreCEGUITexture.cpp
===================================================================
--- code/trunk/src/orxonox/gui/OgreCEGUITexture.cpp	(revision 1755)
+++ code/trunk/src/orxonox/gui/OgreCEGUITexture.cpp	(revision 1755)
@@ -0,0 +1,268 @@
+/************************************************************************
+    filename: 	OgreCEGUITexture.cpp
+    created:	11/5/2004
+    author:		Paul D Turner
+    
+    purpose:	Implementation of Texture using Ogre engine
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+
+#include <CEGUISystem.h>
+#include <CEGUIExceptions.h>
+#include "OgreCEGUITexture.h"
+#include "OgreCEGUIRenderer.h"
+
+#include <OgreTextureManager.h>
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*************************************************************************
+    Static data definition / initialisation
+*************************************************************************/
+uint32 OgreCEGUITexture::d_texturenumber		= 0;
+
+
+/*************************************************************************
+    Constructor
+*************************************************************************/
+OgreCEGUITexture::OgreCEGUITexture(Renderer* owner) :
+    Texture(owner)
+{
+    d_ogre_texture.setNull();
+    d_isLinked = false;
+}
+
+
+/*************************************************************************
+    Destructor
+*************************************************************************/
+OgreCEGUITexture::~OgreCEGUITexture(void)
+{
+    freeOgreTexture();
+}
+
+
+/*************************************************************************
+    Loads the specified image file into the texture.  The texture is
+    resized as required to hold the image.	
+*************************************************************************/
+void OgreCEGUITexture::loadFromFile(const String& filename, const String& resourceGroup)
+{
+    using namespace Ogre;
+
+    // unload old ogre texture
+    freeOgreTexture();
+
+    // create / load a new ogre texture from the specified image
+    try
+    {
+        TextureManager& textureManager = TextureManager::getSingleton();
+
+        // see if texture already exists
+        Ogre::TexturePtr ogreTexture = (Ogre::TexturePtr)textureManager.getByName(filename.c_str());
+
+        if (!ogreTexture.isNull())
+        {
+            // texture already exists, so create a 'linked' texture (ensures texture is not destroyed twice)
+            d_ogre_texture = ogreTexture;
+            d_isLinked = true;
+        }
+        // texture does not already exist, so load it in
+        else
+        {
+            String orpGroup;
+            if (resourceGroup.empty())
+            {
+                const String& defGrp = CEGUI::System::getSingleton().getResourceProvider()->getDefaultResourceGroup();
+                orpGroup = defGrp.empty() ? Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME.c_str() : defGrp;
+            }
+            else
+            {
+                orpGroup = resourceGroup;
+            }
+
+            d_ogre_texture = TextureManager::getSingleton().load(filename.c_str(), orpGroup.c_str(), TEX_TYPE_2D, 0, 1.0f);
+            d_isLinked = false;
+        }
+
+    }
+    catch(Ogre::Exception e)
+    {
+        throw RendererException((utf8*)"Failed to create Texture object from file '" + filename + "'. Additional Information:\n" + e.getFullDescription().c_str());
+    }
+
+    // if we got a pointer cache some details
+    if (!d_ogre_texture.isNull())
+    {
+        d_width		= d_ogre_texture->getWidth();
+        d_height	= d_ogre_texture->getHeight();
+    }
+    // no texture from image so throw.
+    else
+    {
+        throw RendererException((utf8*)"Failed to create Texture object from file '" + filename + "'.  Ogre returned a NULL pointer.");
+    }
+
+}
+
+
+/*************************************************************************
+    Loads (copies) an image in memory into the texture.  The texture is
+    resized as required to hold the image.	
+*************************************************************************/
+
+void _byteSwap(unsigned char* b, int n)
+{
+    register int i = 0;
+    register int j = n-1;
+    while (i<j)
+    {
+        std::swap(b[i], b[j]);
+        i++, j--;
+    }
+}
+#define byteSwap(x) _byteSwap((unsigned char*) &x,sizeof(x))
+
+void OgreCEGUITexture::loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat)
+{
+    using namespace Ogre;
+
+    // get rid of old texture
+    freeOgreTexture();
+
+    // wrap input buffer with an Ogre DataChunk
+    uint32 bytesize = ((buffWidth * sizeof(uint32)) * buffHeight);
+
+#if OGRE_ENDIAN == OGRE_ENDIAN_BIG
+    uint32* swappedBuffer = new uint32[bytesize/4];
+    memcpy(swappedBuffer, buffPtr, bytesize);
+
+    for (int i=0; i < bytesize/4; i++)
+        byteSwap(swappedBuffer[i]);
+
+    DataStreamPtr odc(new MemoryDataStream(static_cast<void*>(swappedBuffer), bytesize, false));
+#else
+    DataStreamPtr odc(new MemoryDataStream(const_cast<void*>(buffPtr), bytesize, false));
+#endif
+
+    // get pixel type for the target texture - the elements here might look wrong, but is just
+    // differences in definition (at the core level, between GL and D3D).
+    Ogre::PixelFormat targetFmt =
+        (pixelFormat == PF_RGBA) ? Ogre::PF_A8R8G8B8 : Ogre::PF_R8G8B8;
+
+    // try to create a Ogre::Texture from the input data
+    d_ogre_texture = TextureManager::getSingleton().loadRawData(getUniqueName(), "General", odc, buffWidth, buffHeight, targetFmt , TEX_TYPE_2D, 0, 1.0f);
+
+    // if we got a pointer cache some details
+    if (!d_ogre_texture.isNull())
+    {
+        d_width		= d_ogre_texture->getWidth();
+        d_height	= d_ogre_texture->getHeight();
+    }
+    // no texture from memory so throw.
+    else
+    {
+        throw RendererException((utf8*)"Failed to create Texture object from memory:  Ogre returned a NULL Ogre::Texture pointer.");
+    }
+
+}
+
+
+/*************************************************************************
+    set the size of the internal Ogre texture.  Previous Ogre texture
+    is lost.	
+*************************************************************************/
+void OgreCEGUITexture::setOgreTextureSize(uint size)
+{
+    using namespace Ogre;
+
+    // unload any current Ogre::Texture
+    freeOgreTexture();
+
+    // Try to create an empty texture of the given size
+    d_ogre_texture = TextureManager::getSingleton().createManual(getUniqueName(), "General", TEX_TYPE_2D, size, size, 0, PF_A8R8G8B8, TU_DEFAULT);
+
+    // if we got a pointer cache some details
+    if (!d_ogre_texture.isNull())
+    {
+        d_width		= d_ogre_texture->getWidth();
+        d_height	= d_ogre_texture->getHeight();
+    }
+    // no texture so throw.
+    else
+    {
+        throw RendererException((utf8*)"Failed to create texture of specified size: Ogre::Texture creation failed.");
+    }
+
+}
+
+
+/*************************************************************************
+    safely free Ogre::Texture texture (can be called multiple times with
+    no ill effect)
+*************************************************************************/
+void OgreCEGUITexture::freeOgreTexture(void)
+{
+    if ((!d_ogre_texture.isNull()) && !d_isLinked)
+    {
+        Ogre::TextureManager::getSingleton().remove(d_ogre_texture->getHandle());
+    }
+    d_ogre_texture.setNull();
+}
+
+
+/*************************************************************************
+    return a Ogre::string that contains a unique name.	
+*************************************************************************/
+Ogre::String OgreCEGUITexture::getUniqueName(void)
+{
+    Ogre::String str;
+
+#ifdef CEGUI_USEOLDOGRESTRING
+    str << "_cegui_ogre_" << d_texturenumber;
+#else
+    Ogre::StringUtil::StrStreamType strstream;
+    strstream << "_cegui_ogre_" << d_texturenumber;
+    str = strstream.str();
+#endif
+
+    ++d_texturenumber;
+
+    return str;
+}
+
+
+/*************************************************************************
+    Set the internal Ogre::Texture object.
+*************************************************************************/
+void OgreCEGUITexture::setOgreTexture(Ogre::TexturePtr& texture)
+{
+    freeOgreTexture();
+
+    d_ogre_texture = texture;
+    d_width	 = d_ogre_texture->getWidth();
+    d_height = d_ogre_texture->getHeight();
+    d_isLinked = true;
+}
+
+
+} // End of  CEGUI namespace section
+
Index: code/trunk/src/orxonox/gui/OgreCEGUITexture.h
===================================================================
--- code/trunk/src/orxonox/gui/OgreCEGUITexture.h	(revision 1755)
+++ code/trunk/src/orxonox/gui/OgreCEGUITexture.h	(revision 1755)
@@ -0,0 +1,179 @@
+/************************************************************************
+    filename: 	OgreCEGUITexture.h
+    created:	11/5/2004
+    author:		Paul D Turner
+    
+    purpose:	Interface to Texture implemented via Ogre engine
+*************************************************************************/
+/*************************************************************************
+    Crazy Eddie's GUI System (http://www.cegui.org.uk)
+    Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library 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
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*************************************************************************/
+#ifndef _OgreCEGUITexture_h_
+#define _OgreCEGUITexture_h_
+
+#include <CEGUIBase.h>
+#include <CEGUIRenderer.h>
+#include <CEGUITexture.h>
+#include "OgreCEGUIRenderer.h"
+
+// Start of CEGUI namespace section
+namespace CEGUI
+{
+/*!
+\brief
+    Texture class that is created by OgreCEGUIRenderer objects
+*/
+class _OgrePrivate OgreCEGUITexture : public Texture
+{
+private:
+    /*************************************************************************
+        Friends (to allow construction and destruction)
+    *************************************************************************/
+    friend	Texture* OgreCEGUIRenderer::createTexture(void);
+    friend	Texture* OgreCEGUIRenderer::createTexture(const String& filename, const String& resourceGroup);
+    friend	Texture* OgreCEGUIRenderer::createTexture(float size);
+    friend	void	 OgreCEGUIRenderer::destroyTexture(Texture* texture);
+
+
+    /*************************************************************************
+        Construction & Destruction (by Renderer object only)
+    *************************************************************************/
+    OgreCEGUITexture(Renderer* owner);
+    virtual ~OgreCEGUITexture(void);
+
+public:
+    /*!
+    \brief
+        Returns the current pixel width of the texture
+
+    \return
+        ushort value that is the current width of the texture in pixels
+    */
+    virtual	ushort	getWidth(void) const		{return d_width;}
+
+
+    /*!
+    \brief
+        Returns the current pixel height of the texture
+
+    \return
+        ushort value that is the current height of the texture in pixels
+    */
+    virtual	ushort	getHeight(void) const		{return d_height;}
+
+
+    /*!
+    \brief
+        Loads the specified image file into the texture.  The texture is resized as required to hold the image.
+
+    \param filename
+        The filename of the image file that is to be loaded into the texture
+
+    \return
+        Nothing.
+    */
+    virtual void	loadFromFile(const String& filename, const String& resourceGroup);
+
+
+    /*!
+    \brief
+        Loads (copies) an image in memory into the texture.  The texture is resized as required to hold the image.
+    
+    \param buffPtr
+        Pointer to the buffer containing the image data
+    
+    \param buffWidth
+        Width of the buffer (in pixels as specified by \a pixelFormat )
+    
+    \param buffHeight
+        Height of the buffer (in pixels as specified by \a pixelFormat )
+    
+    \param pixelFormat
+    PixelFormat value describing the format contained in \a buffPtr
+    
+    \return
+        Nothing.
+    */
+    virtual void	loadFromMemory(const void* buffPtr, uint buffWidth, uint buffHeight, PixelFormat pixelFormat);
+
+
+    /*!
+    \brief
+        Return a pointer to the internal Ogre::Texture object
+
+    \return
+        Pointer to the Ogre::Texture object currently being used by this Texture object
+    */
+    Ogre::TexturePtr	getOgreTexture(void) const		{return d_ogre_texture;}
+
+
+    /*!
+    \brief
+        set the size of the internal Ogre texture.  Previous Ogre texture is lost.
+
+    \param size
+        pixel size of the new internal texture.  This will be rounded up to a power of 2.
+
+    \return
+        Nothing.
+    */
+    void	setOgreTextureSize(uint size);
+
+
+    /*!
+    \brief
+        Set the internal Ogre::TexturePtr object.
+
+    \param texture
+        Reference to an Ogre::TexturePtr object that is to be used by this Texture object.
+
+    \return
+        Nothing.
+    */
+    void	setOgreTexture(Ogre::TexturePtr& texture);
+
+
+private:
+    /*************************************************************************
+        Implementation Functions
+    *************************************************************************/
+    // safely free Ogre::Texture texture (can be called multiple times with no ill effect)
+    void	freeOgreTexture(void);
+
+    // return a Ogre::string that contains a unique name.
+    Ogre::String	getUniqueName(void);
+
+
+    /*************************************************************************
+        Implementation Data
+    *************************************************************************/
+    static	uint32          d_texturenumber;	//!< Counter used to provide unique texture names.
+
+    Ogre::TexturePtr		d_ogre_texture;		//!< The 'real' texture.
+
+    ushort					d_width;			//!< cached width of the texture
+    ushort					d_height;			//!< cached height of the texture
+
+    bool	d_isLinked;		//!< True if we are linked to a texture we did not actually create.
+};
+
+
+} // End of  CEGUI namespace section
+
+
+#endif	// end of guard _OgreCEGUITexture_h_
Index: code/trunk/src/orxonox/objects/Ambient.cc
===================================================================
--- code/trunk/src/orxonox/objects/Ambient.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/Ambient.cc	(revision 1755)
@@ -43,4 +43,5 @@
 #include "core/XMLPort.h"
 #include "core/ConsoleCommand.h"
+#include "Settings.h"
 #include "GraphicsEngine.h"
 
@@ -66,5 +67,6 @@
     bool Ambient::create()
     {
-        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(ambientLight_);
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(ambientLight_);
         return Synchronisable::create();
     }
@@ -77,13 +79,18 @@
     void Ambient::setAmbientLight(const ColourValue& colour)
     {
-        GraphicsEngine::getSingleton().getSceneManager()->setAmbientLight(colour);
-        ambientLight_=colour;
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(colour);
+        ambientLight_ = colour;
     }
 
     /**
-        @brief XML loading and saving.
-        @param xmlelement The XML-element
-        @param loading Loading (true) or saving (false)
-        @return The XML-element
+    @brief
+        XML loading and saving.
+    @param
+        xmlelement The XML-element
+    @param
+        loading Loading (true) or saving (false)
+    @return
+        The XML-element
     */
     void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Index: code/trunk/src/orxonox/objects/Backlight.cc
===================================================================
--- code/trunk/src/orxonox/objects/Backlight.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/Backlight.cc	(revision 1755)
@@ -32,4 +32,5 @@
 #include <OgreBillboard.h>
 #include <OgreRibbonTrail.h>
+#include <OgreSceneManager.h>
 
 #include "core/CoreIncludes.h"
@@ -38,5 +39,4 @@
 #include "util/Math.h"
 #include "GraphicsEngine.h"
-#include "Orxonox.h"
 
 namespace orxonox
@@ -58,6 +58,6 @@
         this->attachObject(this->billboard_.getBillboardSet());
 
-        this->ribbonTrail_ = GraphicsEngine::getSingleton().getSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
-        this->ribbonTrailNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
+        this->ribbonTrail_ = GraphicsEngine::getInstance().getLevelSceneManager()->createRibbonTrail(this->getName() + "RibbonTrail");
+        this->ribbonTrailNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName() + "RibbonTrailNode");
         this->ribbonTrailNode_->attachObject(this->ribbonTrail_);
         this->ribbonTrail_->addNode(this->getNode());
@@ -68,5 +68,6 @@
         this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
 
-        this->setTimeFactor(Orxonox::getSingleton()->getTimeFactor());
+        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
+        this->setTimeFactor(1.0f);
     }
 
@@ -76,6 +77,6 @@
         {
             this->detachObject(this->billboard_.getBillboardSet());
-            GraphicsEngine::getSingleton().getSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
-            GraphicsEngine::getSingleton().getSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
         }
     }
Index: code/trunk/src/orxonox/objects/Camera.cc
===================================================================
--- code/trunk/src/orxonox/objects/Camera.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/Camera.cc	(revision 1755)
@@ -52,5 +52,5 @@
   {
     this->bHasFocus_ = false;
-    this->cameraNode_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
+    this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
     if( node != NULL )
       this->setPositionNode(node);
@@ -60,5 +60,5 @@
   {
     CameraHandler::getInstance()->releaseFocus(this);
-    GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
+    GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
   }
 
Index: code/trunk/src/orxonox/objects/CameraHandler.cc
===================================================================
--- code/trunk/src/orxonox/objects/CameraHandler.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/CameraHandler.cc	(revision 1755)
@@ -44,6 +44,7 @@
   CameraHandler::CameraHandler()
   {
-    this->cam_ = GraphicsEngine::getSingleton().getSceneManager()->createCamera("Cam");
-    GraphicsEngine::getSingleton().getRenderWindow()->addViewport(this->cam_);
+    this->cam_ = GraphicsEngine::getInstance().getLevelSceneManager()->createCamera("Cam");
+    GraphicsEngine::getInstance().getViewport()->setCamera(this->cam_);
+    //GraphicsEngine::getInstance().getRenderWindow()->addViewport(this->cam_, 2, 0.4, 0.4, 0.2, 0.2);
     /*this->activeCamera_ = *ObjectList<Camera>::begin();
     this->activeCamera_->cam_ = this->cam_;*/
Index: code/trunk/src/orxonox/objects/ParticleSpawner.cc
===================================================================
--- code/trunk/src/orxonox/objects/ParticleSpawner.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/ParticleSpawner.cc	(revision 1755)
@@ -30,4 +30,5 @@
 #include "ParticleSpawner.h"
 
+#include <OgreSceneManager.h>
 #include "core/CoreIncludes.h"
 #include "core/Executor.h"
@@ -79,5 +80,5 @@
         this->setPosition(this->getNode()->getParent()->getPosition());
         this->getNode()->getParent()->removeChild(this->getNode());
-        GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->addChild(this->getNode());
+        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(this->getNode());
         if (this->particle_)
             this->particle_->setEnabled(false);
Index: code/trunk/src/orxonox/objects/Skybox.cc
===================================================================
--- code/trunk/src/orxonox/objects/Skybox.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/Skybox.cc	(revision 1755)
@@ -39,4 +39,5 @@
 #include "core/XMLPort.h"
 #include "util/Debug.h"
+#include "Settings.h"
 
 namespace orxonox
@@ -56,5 +57,6 @@
     void Skybox::setSkybox(const std::string& skyboxname)
     {
-    	GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(true, skyboxname);
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skyboxname);
     }
 
@@ -87,5 +89,6 @@
     {
         SUPER(Skybox, changedVisibility);
-        GraphicsEngine::getSingleton().getSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
     }
 }
Index: code/trunk/src/orxonox/objects/SpaceShip.cc
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/SpaceShip.cc	(revision 1755)
@@ -49,4 +49,5 @@
 #include "CameraHandler.h"
 #include "ParticleSpawner.h"
+#include "Settings.h"
 #include "RotatingProjectile.h"
 #include "ParticleProjectile.h"
@@ -79,4 +80,5 @@
       }
       assert(0);
+      return 0;
     }
 
@@ -194,88 +196,90 @@
     void SpaceShip::init()
     {
-        // START CREATING THRUSTERS
-        this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
-        this->tt1_->createNewEmitter();
-        this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
-        this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1));
-        this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1));
-        this->tt1_->setSpeedFactor(3.0);
-
-        Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a");
-        node2a->setInheritScale(false);
-        node2a->setScale(1, 1, 1);
-        tt1_->addToSceneNode(node2a);
-
-        this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
-        this->tt2_->createNewEmitter();
-        this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
-        this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2));
-        this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2));
-
-        Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b");
-        node2b->setInheritScale(false);
-        node2b->setScale(0.5, 0.5, 0.5);
-        tt2_->addToSceneNode(node2b);
-
-        this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5));
-        this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5));
-
-        Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c");
-        node2c->setInheritScale(false);
-        node2c->setScale(2, 2, 2);
-        node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
-        node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
-        // END CREATING THRUSTERS
-
-        // START CREATING BLINKING LIGHTS
-        this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
-        this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
-
-        this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
-        this->redNode_->setInheritScale(false);
-        this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
-        this->greenNode_->setInheritScale(false);
-
-        this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
-        this->redNode_->setScale(0.3, 0.3, 0.3);
-
-        this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
-        this->greenNode_->setScale(0.3, 0.3, 0.3);
-        // END CREATING BLINKING LIGHTS
-
-        // START CREATING ADDITIONAL EFFECTS
-        /*if(!network::Host::running() || network::Host::isServer()){
-          this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
-          this->attachObject(this->backlight_);
-          this->backlight_->setPosition(-2.35, 0, 0.2);
-          this->backlight_->setColour(this->getProjectileColour());
-    
-          this->smoke_ = new ParticleSpawner();
-          this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
-          this->attachObject(this->smoke_);
-    
-          this->fire_ = new ParticleSpawner();
-          this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
-          this->attachObject(this->fire_);
-        }*/
-        // END CREATING ADDITIONAL EFFECTS
-
-        if (this->isExactlyA(Class(SpaceShip)))
-        {
-            // START of testing crosshair
-            this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
-            this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
-
-            this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
-            this->chNearNode_->setInheritScale(false);
-            this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
-            this->chFarNode_->setInheritScale(false);
-
-            this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
-            this->chNearNode_->setScale(0.2, 0.2, 0.2);
-
-            this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
-            this->chFarNode_->setScale(0.4, 0.4, 0.4);
-            // END of testing crosshair
+        if (Settings::showsGraphics())
+        {
+            // START CREATING THRUSTERS
+            this->tt1_ = new ParticleInterface("Orxonox/thruster1", LODParticle::low);
+            this->tt1_->createNewEmitter();
+            this->tt1_->getAllEmitters()->setDirection(-this->getInitialDir());
+            this->tt1_->getEmitter(0)->setPosition(Vector3(-15, 20, -1));
+            this->tt1_->getEmitter(1)->setPosition(Vector3(-15, -20, -1));
+            this->tt1_->setSpeedFactor(3.0);
+
+            Ogre::SceneNode* node2a = this->getNode()->createChildSceneNode(this->getName() + "particle2a");
+            node2a->setInheritScale(false);
+            node2a->setScale(1, 1, 1);
+            tt1_->addToSceneNode(node2a);
+
+            this->tt2_ = new ParticleInterface("Orxonox/thruster2", LODParticle::normal);
+            this->tt2_->createNewEmitter();
+            this->tt2_->getAllEmitters()->setDirection(Vector3(-1, 0, 0));
+            this->tt2_->getEmitter(0)->setPosition(Vector3(-30, 40, -2));
+            this->tt2_->getEmitter(1)->setPosition(Vector3(-30, -40, -2));
+
+            Ogre::SceneNode* node2b = this->getNode()->createChildSceneNode(this->getName() + "particle2b");
+            node2b->setInheritScale(false);
+            node2b->setScale(0.5, 0.5, 0.5);
+            tt2_->addToSceneNode(node2b);
+
+            this->leftThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, -10, -0.5));
+            this->rightThrusterFlare_.setBillboardSet("Flares/ThrusterFlare1", Vector3(-7.5, 10, -0.5));
+
+            Ogre::SceneNode* node2c = this->getNode()->createChildSceneNode(this->getName() + "particle2c");
+            node2c->setInheritScale(false);
+            node2c->setScale(2, 2, 2);
+            node2c->attachObject(this->leftThrusterFlare_.getBillboardSet());
+            node2c->attachObject(this->rightThrusterFlare_.getBillboardSet());
+            // END CREATING THRUSTERS
+
+            // START CREATING BLINKING LIGHTS
+            this->redBillboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
+            this->greenBillboard_.setBillboardSet("Examples/Flare", ColourValue(0.0, 1.0, 0.0), 1);
+
+            this->redNode_ = this->getNode()->createChildSceneNode(this->getName() + "red", Vector3(0.3, 4.0, -0.3));
+            this->redNode_->setInheritScale(false);
+            this->greenNode_ = this->getNode()->createChildSceneNode(this->getName() + "green", Vector3(0.3, -4.0, -0.3));
+            this->greenNode_->setInheritScale(false);
+
+            this->redNode_->attachObject(this->redBillboard_.getBillboardSet());
+            this->redNode_->setScale(0.3, 0.3, 0.3);
+
+            this->greenNode_->attachObject(this->greenBillboard_.getBillboardSet());
+            this->greenNode_->setScale(0.3, 0.3, 0.3);
+            // END CREATING BLINKING LIGHTS
+
+            // START CREATING ADDITIONAL EFFECTS
+            /*this->backlight_ = new Backlight(this->maxSpeed_, 0.8);
+            this->attachObject(this->backlight_);
+            this->backlight_->setPosition(-2.35, 0, 0.2);
+            this->backlight_->setColour(this->getProjectileColour());
+
+            this->smoke_ = new ParticleSpawner();
+            this->smoke_->setParticle("Orxonox/smoke5", LODParticle::normal, 0, 0, 3);
+            this->attachObject(this->smoke_);
+
+            this->fire_ = new ParticleSpawner();
+            this->fire_->setParticle("Orxonox/fire3", LODParticle::normal, 0, 0, 1);
+            this->attachObject(this->fire_);
+            */
+            // END CREATING ADDITIONAL EFFECTS
+
+            if (this->isExactlyA(Class(SpaceShip)))
+            {
+                // START of testing crosshair
+                this->crosshairNear_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
+                this->crosshairFar_.setBillboardSet("Orxonox/Crosshair", ColourValue(1.0, 1.0, 0.0), 1);
+
+                this->chNearNode_ = this->getNode()->createChildSceneNode(this->getName() + "near", Vector3(50.0, 0.0, 0.0));
+                this->chNearNode_->setInheritScale(false);
+                this->chFarNode_ = this->getNode()->createChildSceneNode(this->getName() + "far", Vector3(200.0, 0.0, 0.0));
+                this->chFarNode_->setInheritScale(false);
+
+                this->chNearNode_->attachObject(this->crosshairNear_.getBillboardSet());
+                this->chNearNode_->setScale(0.2, 0.2, 0.2);
+
+                this->chFarNode_->attachObject(this->crosshairFar_.getBillboardSet());
+                this->chFarNode_->setScale(0.4, 0.4, 0.4);
+                // END of testing crosshair
+            }
         }
         // END of testing crosshair
@@ -429,24 +433,27 @@
             this->cam_->tick(dt);
 
-        if (this->smoke_)
-            this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
-        if (this->fire_)
-            this->fire_->setVisible(this->isVisible() && this->health_ < 20);
-
-        if (this->backlight_)
-        {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
-            if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
-                this->backlight_->setActive(false);
-            else
-                this->backlight_->setActive(true);
-        }
-
-        if (this->redNode_ && this->greenNode_)
-        {
-            this->blinkTime_ += dt;
-            float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
-            float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
-            this->redNode_->setScale(redScale, redScale, redScale);
-            this->greenNode_->setScale(greenScale, greenScale, greenScale);
+        if (Settings::showsGraphics())
+        {
+            if (this->smoke_)
+                this->smoke_->setVisible(this->isVisible() && this->health_ < 40);
+            if (this->fire_)
+                this->fire_->setVisible(this->isVisible() && this->health_ < 20);
+
+            if (this->backlight_)
+            {   // (there's already fire ||                 we're to slow                 ||                  we're moving backwards                  )
+                if (this->health_ < 20   || this->getVelocity().squaredLength() < 150*150 || this->getVelocity().dotProduct(this->getInitialDir()) < 0)
+                    this->backlight_->setActive(false);
+                else
+                    this->backlight_->setActive(true);
+            }
+
+            if (this->redNode_ && this->greenNode_)
+            {
+                this->blinkTime_ += dt;
+                float redScale = 0.15 + 0.15 * sin(this->blinkTime_ * 10.0);
+                float greenScale = 0.15 - 0.15 * sin(this->blinkTime_ * 10.0);
+                this->redNode_->setScale(redScale, redScale, redScale);
+                this->greenNode_->setScale(greenScale, greenScale, greenScale);
+            }
         }
 
Index: code/trunk/src/orxonox/objects/SpaceShipAI.cc
===================================================================
--- code/trunk/src/orxonox/objects/SpaceShipAI.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/SpaceShipAI.cc	(revision 1755)
@@ -39,4 +39,5 @@
 #include "core/XMLPort.h"
 #include "tools/ParticleInterface.h"
+#include "Settings.h"
 
 #define ACTION_INTERVAL 1.0f
@@ -102,7 +103,10 @@
             newenemy->XMLPort(xmlelement, XMLPort::LoadObject);
 
-            ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0, 0, newenemy->getOrth());
-            spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50);
-            spawneffect->create();
+            if (Settings::showsGraphics())
+            {
+                ParticleSpawner* spawneffect = new ParticleSpawner("Orxonox/fairytwirl", LODParticle::normal, 2.0, 0, 0, newenemy->getOrth());
+                spawneffect->setPosition(newenemy->getPosition() - newenemy->getOrth() * 50);
+                spawneffect->create();
+            }
         }
     }
@@ -182,33 +186,36 @@
     void SpaceShipAI::kill()
     {
-        ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", LODParticle::low, 3.0);
-        explosion->setPosition(this->getPosition());
-        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
-        explosion->setScale(4);
-        explosion->create();
-
-        explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::normal, 3.0);
-        explosion->setPosition(this->getPosition());
-        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
-        explosion->setScale(4);
-        explosion->create();
-        explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::high, 3.0);
-        explosion->setPosition(this->getPosition());
-        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
-        explosion->setScale(4);
-        explosion->create();
-
-        Vector3 ringdirection = Vector3(rnd(), rnd(), rnd());
-        ringdirection.normalise();
-        explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, 0, ringdirection);
-        explosion->setPosition(this->getPosition());
-        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
-        explosion->setScale(4);
-        explosion->create();
-        explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, 0, ringdirection);
-        explosion->setPosition(this->getPosition());
-        explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
-        explosion->setScale(4);
-        explosion->create();
+        if (Settings::showsGraphics())
+        {
+            ParticleSpawner* explosion = new ParticleSpawner("Orxonox/BigExplosion1part1", LODParticle::low, 3.0);
+            explosion->setPosition(this->getPosition());
+            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
+            explosion->setScale(4);
+            explosion->create();
+
+            explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::normal, 3.0);
+            explosion->setPosition(this->getPosition());
+            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
+            explosion->setScale(4);
+            explosion->create();
+            explosion = new ParticleSpawner("Orxonox/BigExplosion1part2", LODParticle::high, 3.0);
+            explosion->setPosition(this->getPosition());
+            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
+            explosion->setScale(4);
+            explosion->create();
+
+            Vector3 ringdirection = Vector3(rnd(), rnd(), rnd());
+            ringdirection.normalise();
+            explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::normal, 3.0, 0.5, 0, ringdirection);
+            explosion->setPosition(this->getPosition());
+            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
+            explosion->setScale(4);
+            explosion->create();
+            explosion = new ParticleSpawner("Orxonox/BigExplosion1part3", LODParticle::high, 3.0, 0.5, 0, ringdirection);
+            explosion->setPosition(this->getPosition());
+            explosion->getParticleInterface()->setKeepParticlesInLocalSpace(true);
+            explosion->setScale(4);
+            explosion->create();
+        }
 
         delete this;
Index: code/trunk/src/orxonox/objects/Tickable.h
===================================================================
--- code/trunk/src/orxonox/objects/Tickable.h	(revision 1754)
+++ code/trunk/src/orxonox/objects/Tickable.h	(revision 1755)
@@ -29,5 +29,5 @@
 /*!
     @file Tickable.h
-    @brief Definition of the Tickable interface.
+    @brief Declaration of the Tickable interface.
 
     The Tickable interface provides a tick(dt) function, that gets called every frame.
Index: code/trunk/src/orxonox/objects/WorldEntity.cc
===================================================================
--- code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1754)
+++ code/trunk/src/orxonox/objects/WorldEntity.cc	(revision 1755)
@@ -32,4 +32,5 @@
 #include <string>
 #include <sstream>
+#include <OgreSceneManager.h>
 
 #include "tinyxml/tinyxml.h"
@@ -49,10 +50,10 @@
         RegisterObject(WorldEntity);
 
-        if (GraphicsEngine::getSingleton().getSceneManager())
+        if (GraphicsEngine::getInstance().getLevelSceneManager())
         {
             std::ostringstream name;
             name << (WorldEntity::worldEntityCounter_s++);
             this->setName("WorldEntity" + name.str());
-            this->node_ = GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
+            this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
 
             registerAllVariables();
@@ -77,5 +78,5 @@
         {
             this->getNode()->removeAndDestroyAllChildren();
-            GraphicsEngine::getSingleton().getSceneManager()->destroySceneNode(this->getName());
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName());
         }
     }
@@ -177,5 +178,5 @@
     void WorldEntity::attachObject(const WorldEntity& obj) const
     {
-        GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
+        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
         this->getNode()->addChild(obj.getNode());
     }
@@ -183,5 +184,5 @@
     void WorldEntity::attachObject(WorldEntity* obj) const
     {
-        GraphicsEngine::getSingleton().getSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
+        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
         this->getNode()->addChild(obj->getNode());
     }
Index: code/trunk/src/orxonox/objects/WorldEntity.h
===================================================================
--- code/trunk/src/orxonox/objects/WorldEntity.h	(revision 1754)
+++ code/trunk/src/orxonox/objects/WorldEntity.h	(revision 1755)
@@ -31,8 +31,7 @@
 
 #include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
 
-#include <OgreSceneManager.h>
 #include <OgreSceneNode.h>
-
 #include "util/Math.h"
 #include "util/XMLIncludes.h"
Index: code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 1754)
+++ code/trunk/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 1755)
@@ -115,6 +115,6 @@
             // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
             // called automatically by the GraphicsEngine.
-            this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(),
-                GraphicsEngine::getSingleton().getWindowHeight());
+            this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
+                GraphicsEngine::getInstance().getWindowHeight());
 
             this->changedVisibility();
Index: code/trunk/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- code/trunk/src/orxonox/overlays/console/InGameConsole.cc	(revision 1754)
+++ code/trunk/src/orxonox/overlays/console/InGameConsole.cc	(revision 1755)
@@ -46,4 +46,6 @@
 #include "core/ConsoleCommand.h"
 #include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/input/InputBuffer.h"
 #include "GraphicsEngine.h"
 
@@ -56,13 +58,21 @@
     SetConsoleCommand(InGameConsole, closeConsole, true);
 
+    InGameConsole* InGameConsole::singletonRef_s = 0;
+
     /**
         @brief Constructor: Creates and initializes the InGameConsole.
     */
-    InGameConsole::InGameConsole() :
-        consoleOverlay_(0), consoleOverlayContainer_(0),
-        consoleOverlayNoise_(0), consoleOverlayCursor_(0), consoleOverlayBorder_(0),
-        consoleOverlayTextAreas_(0)
+    InGameConsole::InGameConsole()
+        : consoleOverlay_(0)
+        , consoleOverlayContainer_(0)
+        , consoleOverlayNoise_(0)
+        , consoleOverlayCursor_(0)
+        , consoleOverlayBorder_(0)
+        , consoleOverlayTextAreas_(0)
     {
         RegisterObject(InGameConsole);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
 
         this->bActive_ = false;
@@ -82,119 +92,9 @@
     InGameConsole::~InGameConsole(void)
     {
-        this->destroy();
-    }
-
-    /**
-        @brief Returns a reference to the only existing instance of InGameConsole.
-    */
-    InGameConsole& InGameConsole::getInstance()
-    {
-        static InGameConsole instance;
-        return instance;
-    }
-
-    /**
-        @brief Sets the config values, describing the size of the console.
-    */
-    void InGameConsole::setConfigValues()
-    {
-        SetConfigValue(relativeWidth, 0.8);
-        SetConfigValue(relativeHeight, 0.4);
-        SetConfigValue(blinkTime, 0.5);
-        SetConfigValue(scrollSpeed_, 3.0f);
-        SetConfigValue(noiseSize_, 1.0f);
-        SetConfigValue(cursorSymbol_, '|');
-    }
-
-    /**
-        @brief Initializes the InGameConsole.
-    */
-    void InGameConsole::initialise()
-    {
-        // create overlay and elements
-        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
-
-        // create actual overlay
-        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
-
-        // create a container
-        this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
-        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
-        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
-        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
-        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
-
-        // create BorderPanel
-        this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
-        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
-        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
-        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
-        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
-        this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
-        this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
-        this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
-        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
-        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
-
-        // create a new font to match the requested size exactly
-        Ogre::FontPtr font = static_cast<Ogre::FontPtr>
-            (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
-        font->setType(Ogre::FT_TRUETYPE);
-        font->setSource("Monofur.ttf");
-        font->setTrueTypeSize(18);
-        // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
-        font->setTrueTypeResolution(192);
-        font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
-        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
-
-        // create the text lines
-        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
-        for (int i = 0; i < LINES; i++)
-        {
-            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
-            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
-            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
-            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
-            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
-            this->consoleOverlayTextAreas_[i]->setLeft(8);
-            this->consoleOverlayTextAreas_[i]->setCaption("");
-            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
-        }
-
-        // create cursor (also a text area overlay element)
-        this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
-        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
-        this->consoleOverlayCursor_->setFontName("MonofurConsole");
-        this->consoleOverlayCursor_->setCharHeight(18);
-        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
-        this->consoleOverlayCursor_->setLeft(7);
-        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
-
-        // create noise
-        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
-        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
-        this->consoleOverlayNoise_->setPosition(5,0);
-        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
-        // comment following line to disable noise
-        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
-
-        this->windowResized(GraphicsEngine::getSingleton().getWindowWidth(), GraphicsEngine::getSingleton().getWindowHeight());
-
-        // move overlay "above" the top edge of the screen
-        // we take -1.2 because the border makes the panel bigger
-        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
-
-        Shell::getInstance().addOutputLevel(true);
-
-        COUT(4) << "Info: InGameConsole initialized" << std::endl;
-    }
-
-    /**
-        @brief Destroys all the elements if necessary.
-    */
-    void InGameConsole::destroy()
-    {
+        this->deactivate();
+
+        // destroy the input state previously created (InputBuffer gets destroyed by the Shell)
+        InputManager::getInstance().requestDestroyState("console");
+
         Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
         if (ovMan)
@@ -224,4 +124,108 @@
             this->consoleOverlayTextAreas_ = 0;
         }
+
+        singletonRef_s = 0;
+    }
+
+    /**
+        @brief Sets the config values, describing the size of the console.
+    */
+    void InGameConsole::setConfigValues()
+    {
+        SetConfigValue(relativeWidth, 0.8);
+        SetConfigValue(relativeHeight, 0.4);
+        SetConfigValue(blinkTime, 0.5);
+        SetConfigValue(scrollSpeed_, 3.0f);
+        SetConfigValue(noiseSize_, 1.0f);
+        SetConfigValue(cursorSymbol_, '|');
+    }
+
+    /**
+        @brief Initializes the InGameConsole.
+    */
+    void InGameConsole::initialise()
+    {
+        // create the corresponding input state
+        InputManager::getInstance().createInputState<SimpleInputState>("console", 40)
+            ->setKeyHandler(Shell::getInstance().getInputBuffer());
+
+        // create overlay and elements
+        Ogre::OverlayManager* ovMan = Ogre::OverlayManager::getSingletonPtr();
+
+        // create actual overlay
+        this->consoleOverlay_ = ovMan->create("InGameConsoleConsole");
+
+        // create a container
+        this->consoleOverlayContainer_ = static_cast<Ogre::OverlayContainer*>(ovMan->createOverlayElement("Panel", "InGameConsoleContainer"));
+        this->consoleOverlayContainer_->setMetricsMode(Ogre::GMM_RELATIVE);
+        this->consoleOverlayContainer_->setPosition((1 - this->relativeWidth) / 2, 0);
+        this->consoleOverlayContainer_->setDimensions(this->relativeWidth, this->relativeHeight);
+        this->consoleOverlay_->add2D(this->consoleOverlayContainer_);
+
+        // create BorderPanel
+        this->consoleOverlayBorder_ = static_cast<Ogre::BorderPanelOverlayElement*>(ovMan->createOverlayElement("BorderPanel", "InGameConsoleBorderPanel"));
+        this->consoleOverlayBorder_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayBorder_->setMaterialName("ConsoleCenter");
+        this->consoleOverlayBorder_->setBorderSize(16, 16, 0, 16);
+        this->consoleOverlayBorder_->setBorderMaterialName("ConsoleBorder");
+        this->consoleOverlayBorder_->setLeftBorderUV(0.0, 0.49, 0.5, 0.51);
+        this->consoleOverlayBorder_->setRightBorderUV(0.5, 0.49, 1.0, 0.5);
+        this->consoleOverlayBorder_->setBottomBorderUV(0.49, 0.5, 0.51, 1.0);
+        this->consoleOverlayBorder_->setBottomLeftBorderUV(0.0, 0.5, 0.5, 1.0);
+        this->consoleOverlayBorder_->setBottomRightBorderUV(0.5, 0.5, 1.0, 1.0);
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayBorder_);
+
+        // create a new font to match the requested size exactly
+        Ogre::FontPtr font = static_cast<Ogre::FontPtr>
+            (Ogre::FontManager::getSingleton().create("MonofurConsole", "General"));
+        font->setType(Ogre::FT_TRUETYPE);
+        font->setSource("Monofur.ttf");
+        font->setTrueTypeSize(18);
+        // reto: I don't know why, but setting the resolution twice as high makes the font look a lot clearer
+        font->setTrueTypeResolution(192);
+        font->addCodePointRange(Ogre::Font::CodePointRange(33, 126));
+        font->addCodePointRange(Ogre::Font::CodePointRange(161, 255));
+
+        // create the text lines
+        this->consoleOverlayTextAreas_ = new Ogre::TextAreaOverlayElement*[LINES];
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i] = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleTextArea" + convertToString(i)));
+            this->consoleOverlayTextAreas_[i]->setMetricsMode(Ogre::GMM_PIXELS);
+            this->consoleOverlayTextAreas_[i]->setFontName("MonofurConsole");
+            this->consoleOverlayTextAreas_[i]->setCharHeight(18);
+            this->consoleOverlayTextAreas_[i]->setParameter("colour_top", "0.21 0.69 0.21");
+            this->consoleOverlayTextAreas_[i]->setLeft(8);
+            this->consoleOverlayTextAreas_[i]->setCaption("");
+            this->consoleOverlayContainer_->addChild(this->consoleOverlayTextAreas_[i]);
+        }
+
+        // create cursor (also a text area overlay element)
+        this->consoleOverlayCursor_ = static_cast<Ogre::TextAreaOverlayElement*>(ovMan->createOverlayElement("TextArea", "InGameConsoleCursor"));
+        this->consoleOverlayCursor_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayCursor_->setFontName("MonofurConsole");
+        this->consoleOverlayCursor_->setCharHeight(18);
+        this->consoleOverlayCursor_->setParameter("colour_top", "0.21 0.69 0.21");
+        this->consoleOverlayCursor_->setLeft(7);
+        this->consoleOverlayCursor_->setCaption(std::string(this->cursorSymbol_, 1));
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayCursor_);
+
+        // create noise
+        this->consoleOverlayNoise_ = static_cast<Ogre::PanelOverlayElement*>(ovMan->createOverlayElement("Panel", "InGameConsoleNoise"));
+        this->consoleOverlayNoise_->setMetricsMode(Ogre::GMM_PIXELS);
+        this->consoleOverlayNoise_->setPosition(5,0);
+        this->consoleOverlayNoise_->setMaterialName("ConsoleNoiseSmall");
+        // comment following line to disable noise
+        this->consoleOverlayContainer_->addChild(this->consoleOverlayNoise_);
+
+        this->windowResized(GraphicsEngine::getInstance().getWindowWidth(), GraphicsEngine::getInstance().getWindowHeight());
+
+        // move overlay "above" the top edge of the screen
+        // we take -1.2 because the border makes the panel bigger
+        this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+
+        Shell::getInstance().addOutputLevel(true);
+
+        COUT(4) << "Info: InGameConsole initialized" << std::endl;
     }
 
@@ -453,8 +457,8 @@
                 if (output.size() > this->maxCharsPerLine_)
                 {
-                    if (Shell::getInstance().getInputBuffer().getCursorPosition() < this->inputWindowStart_)
-                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition();
-                    else if (Shell::getInstance().getInputBuffer().getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
-                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer().getCursorPosition() - this->maxCharsPerLine_ + 1;
+                    if (Shell::getInstance().getInputBuffer()->getCursorPosition() < this->inputWindowStart_)
+                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition();
+                    else if (Shell::getInstance().getInputBuffer()->getCursorPosition() >= (this->inputWindowStart_ + this->maxCharsPerLine_ - 1))
+                        this->inputWindowStart_ = Shell::getInstance().getInputBuffer()->getCursorPosition() - this->maxCharsPerLine_ + 1;
 
                     output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
@@ -476,5 +480,5 @@
         {
             this->bActive_ = true;
-            InputManager::setInputState(InputManager::IS_CONSOLE);
+            InputManager::getInstance().requestEnterState("console");
             Shell::getInstance().registerListener(this);
 
@@ -498,5 +502,5 @@
         {
             this->bActive_ = false;
-            InputManager::setInputState(InputManager::IS_NORMAL);
+            InputManager::getInstance().requestLeaveState("console");
             Shell::getInstance().unregisterListener(this);
 
Index: code/trunk/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- code/trunk/src/orxonox/overlays/console/InGameConsole.h	(revision 1754)
+++ code/trunk/src/orxonox/overlays/console/InGameConsole.h	(revision 1755)
@@ -37,5 +37,5 @@
 
 #include "core/Shell.h"
-#include "objects/Tickable.h"
+#include "core/OrxonoxClass.h"
 #include "tools/WindowEventListener.h"
 
@@ -43,68 +43,72 @@
 namespace orxonox
 {
-    class _OrxonoxExport InGameConsole : public TickableReal, public ShellListener, public WindowEventListener
+    class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener
     {
-        public: // functions
-            void initialise();
-            void destroy();
-            void setConfigValues();
+    public: // functions
+        InGameConsole();
+        ~InGameConsole();
 
-            virtual void tick(float dt);
+        void initialise();
+        void destroy();
+        void setConfigValues();
 
-            static InGameConsole& getInstance();
+        virtual void tick(float dt);
 
-            static void openConsole();
-            static void closeConsole();
+        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+        static InGameConsole* getInstancePtr() { return singletonRef_s; }
 
-        private: // functions
-            InGameConsole();
-            InGameConsole(const InGameConsole& other) {}
-            ~InGameConsole();
+        static void openConsole();
+        static void closeConsole();
 
-            void activate();
-            void deactivate();
+    private: // functions
+        InGameConsole(const InGameConsole& other) {}
 
-            void linesChanged();
-            void onlyLastLineChanged();
-            void lineAdded();
-            void inputChanged();
-            void cursorChanged();
-            void exit();
+        void activate();
+        void deactivate();
 
-            void shiftLines();
-            void colourLine(int colourcode, int index);
-            void setCursorPosition(unsigned int pos);
-            void print(const std::string& text, int index, bool alwaysShift = false);
+        void linesChanged();
+        void onlyLastLineChanged();
+        void lineAdded();
+        void inputChanged();
+        void cursorChanged();
+        void exit();
 
-            void windowResized(int newWidth, int newHeight);
+        void shiftLines();
+        void colourLine(int colourcode, int index);
+        void setCursorPosition(unsigned int pos);
+        void print(const std::string& text, int index, bool alwaysShift = false);
 
-            static Ogre::UTFString convert2UTF(std::string s);
+        void windowResized(int newWidth, int newHeight);
 
-        private: // variables
-            bool bActive_;
-            int windowW_;
-            int windowH_;
-            int desiredTextWidth_;
-            unsigned int maxCharsPerLine_;
-            unsigned int numLinesShifted_;
-            int scroll_;
-            float cursor_;
-            unsigned int inputWindowStart_;
-            bool bShowCursor_;
-            std::string displayedText_;
-            Ogre::Overlay* consoleOverlay_;
-            Ogre::OverlayContainer* consoleOverlayContainer_;
-            Ogre::PanelOverlayElement* consoleOverlayNoise_;
-            Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
-            Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
-            Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+        static Ogre::UTFString convert2UTF(std::string s);
 
-            // config values
-            float relativeWidth;
-            float relativeHeight;
-            float blinkTime;
-            float scrollSpeed_;
-            float noiseSize_;
-            char cursorSymbol_;
+    private: // variables
+        bool bActive_;
+        int windowW_;
+        int windowH_;
+        int desiredTextWidth_;
+        unsigned int maxCharsPerLine_;
+        unsigned int numLinesShifted_;
+        int scroll_;
+        float cursor_;
+        unsigned int inputWindowStart_;
+        bool bShowCursor_;
+        std::string displayedText_;
+        Ogre::Overlay* consoleOverlay_;
+        Ogre::OverlayContainer* consoleOverlayContainer_;
+        Ogre::PanelOverlayElement* consoleOverlayNoise_;
+        Ogre::TextAreaOverlayElement* consoleOverlayCursor_;
+        Ogre::BorderPanelOverlayElement* consoleOverlayBorder_;
+        Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_;
+
+        // config values
+        float relativeWidth;
+        float relativeHeight;
+        float blinkTime;
+        float scrollSpeed_;
+        float noiseSize_;
+        char cursorSymbol_;
+
+        static InGameConsole* singletonRef_s;
     };
 }
Index: code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc
===================================================================
--- code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 1754)
+++ code/trunk/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 1755)
@@ -49,5 +49,5 @@
     void DebugFPSText::tick(float dt)
     {
-        float fps = GraphicsEngine::getSingleton().getAverageFramesPerSecond();
+        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
         this->text_->setCaption(this->getCaption() + convertToString(fps));
     }
Index: code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc
===================================================================
--- code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 1754)
+++ code/trunk/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 1755)
@@ -49,5 +49,5 @@
     void DebugRTRText::tick(float dt)
     {
-        float rtr = GraphicsEngine::getSingleton().getAverageTickTime();
+        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
         this->text_->setCaption(this->getCaption() + convertToString(rtr));
     }
Index: code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc
===================================================================
--- code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 1754)
+++ code/trunk/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 1755)
@@ -54,5 +54,5 @@
             float v = ship->getVelocity().length();
             float value = v / ship->getMaxSpeed();
-			if (value != this->getValue())
+            if (value != this->getValue())
                 this->setValue(value);
         }
Index: code/trunk/src/orxonox/tolua/tolua.pkg
===================================================================
--- code/trunk/src/orxonox/tolua/tolua.pkg	(revision 1754)
+++ code/trunk/src/orxonox/tolua/tolua.pkg	(revision 1755)
@@ -0,0 +1,1 @@
+$cfile "../../src/orxonox/gui/GUIManager.h"
Index: code/trunk/src/orxonox/tools/BillboardSet.cc
===================================================================
--- code/trunk/src/orxonox/tools/BillboardSet.cc	(revision 1754)
+++ code/trunk/src/orxonox/tools/BillboardSet.cc	(revision 1755)
@@ -50,5 +50,5 @@
         std::ostringstream name;
         name << (BillboardSet::billboardSetCounter_s++);
-        this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
         this->billboardSet_->createBillboard(Vector3::ZERO);
         this->billboardSet_->setMaterialName(file);
@@ -59,5 +59,5 @@
         std::ostringstream name;
         name << (BillboardSet::billboardSetCounter_s++);
-        this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
         this->billboardSet_->createBillboard(Vector3::ZERO, colour);
         this->billboardSet_->setMaterialName(file);
@@ -68,5 +68,5 @@
         std::ostringstream name;
         name << (BillboardSet::billboardSetCounter_s++);
-        this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
         this->billboardSet_->createBillboard(position);
         this->billboardSet_->setMaterialName(file);
@@ -77,5 +77,5 @@
         std::ostringstream name;
         name << (BillboardSet::billboardSetCounter_s++);
-        this->billboardSet_ = GraphicsEngine::getSingleton().getSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
         this->billboardSet_->createBillboard(position, colour);
         this->billboardSet_->setMaterialName(file);
@@ -85,5 +85,5 @@
     {
         if (this->billboardSet_)
-            GraphicsEngine::getSingleton().getSceneManager()->destroyBillboardSet(this->billboardSet_);
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
     }
 }
Index: code/trunk/src/orxonox/tools/Light.cc
===================================================================
--- code/trunk/src/orxonox/tools/Light.cc	(revision 1754)
+++ code/trunk/src/orxonox/tools/Light.cc	(revision 1755)
@@ -49,5 +49,5 @@
         std::ostringstream name;
         name << (Light::lightCounter_s++);
-        this->light_ = GraphicsEngine::getSingleton().getSceneManager()->createLight("Light" + name.str());
+        this->light_ = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light" + name.str());
         this->light_->setType(type);
         this->light_->setDiffuseColour(diffuse);
@@ -58,5 +58,5 @@
     {
         if (this->light_)
-            GraphicsEngine::getSingleton().getSceneManager()->destroyLight(this->light_);
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyLight(this->light_);
     }
 }
Index: code/trunk/src/orxonox/tools/Mesh.cc
===================================================================
--- code/trunk/src/orxonox/tools/Mesh.cc	(revision 1754)
+++ code/trunk/src/orxonox/tools/Mesh.cc	(revision 1755)
@@ -31,8 +31,7 @@
 
 #include <sstream>
-
 #include <OgreSceneManager.h>
-
 #include "GraphicsEngine.h"
+#include "Settings.h"
 
 namespace orxonox
@@ -49,11 +48,12 @@
         std::ostringstream name;
         name << (Mesh::meshCounter_s++);
-        this->entity_ = GraphicsEngine::getSingleton().getSceneManager()->createEntity("Mesh" + name.str(), file);
+        if (Settings::showsGraphics())
+            this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
     }
 
     Mesh::~Mesh()
     {
-        if (this->entity_)
-            GraphicsEngine::getSingleton().getSceneManager()->destroyEntity(this->entity_);
+        if (this->entity_ && Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
     }
 }
Index: code/trunk/src/orxonox/tools/ParticleInterface.cc
===================================================================
--- code/trunk/src/orxonox/tools/ParticleInterface.cc	(revision 1754)
+++ code/trunk/src/orxonox/tools/ParticleInterface.cc	(revision 1755)
@@ -39,5 +39,4 @@
 
 #include "GraphicsEngine.h"
-#include "Orxonox.h"
 #include "core/CoreIncludes.h"
 #include "util/Convert.h"
@@ -55,8 +54,9 @@
     this->bEnabled_ = true;
     this->detaillevel_ = (unsigned int)detaillevel;
-    this->particleSystem_ = GraphicsEngine::getSingleton().getSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
-    this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor());
+    this->particleSystem_ = GraphicsEngine::getInstance().getLevelSceneManager()->createParticleSystem("particles" + getConvertedValue<unsigned int, std::string>(ParticleInterface::counter_s++), templateName);
+    //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor());
+    this->particleSystem_->setSpeedFactor(1.0f);
 
-    if (GraphicsEngine::getSingleton().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
+    if (GraphicsEngine::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
     {
       this->bVisible_ = false;
@@ -72,5 +72,5 @@
   {
     this->particleSystem_->removeAllEmitters();
-    GraphicsEngine::getSingleton().getSceneManager()->destroyParticleSystem(particleSystem_);
+    GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
   }
 
@@ -171,9 +171,11 @@
   void ParticleInterface::setSpeedFactor(float factor)
   {
-    this->particleSystem_->setSpeedFactor(Orxonox::getSingleton()->getTimeFactor() * factor);
+    //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
+    this->particleSystem_->setSpeedFactor(1.0f * factor);
   }
   float ParticleInterface::getSpeedFactor() const
   {
-    return (this->particleSystem_->getSpeedFactor() / Orxonox::getSingleton()->getTimeFactor());
+    //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
+    return (this->particleSystem_->getSpeedFactor() / 1.0f);
   }
 
Index: code/trunk/src/orxonox/tools/Timer.cc
===================================================================
--- code/trunk/src/orxonox/tools/Timer.cc	(revision 1754)
+++ code/trunk/src/orxonox/tools/Timer.cc	(revision 1755)
@@ -36,4 +36,5 @@
 #include "core/ConsoleCommand.h"
 #include "core/CommandExecutor.h"
+#include "core/Clock.h"
 
 namespace orxonox
@@ -125,10 +126,10 @@
         @brief Updates the timer before the frames are rendered.
     */
-    void TimerBase::tick(float dt)
+    void TimerBase::tick(const Clock& time)
     {
         if (this->bActive_)
         {
             // If active: Decrease the timer by the duration of the last frame
-            this->time_ -= dt;
+            this->time_ -= time.getDeltaTimeMicroseconds();
 
             if (this->time_ <= 0)
Index: code/trunk/src/orxonox/tools/Timer.h
===================================================================
--- code/trunk/src/orxonox/tools/Timer.h	(revision 1754)
+++ code/trunk/src/orxonox/tools/Timer.h	(revision 1755)
@@ -62,5 +62,5 @@
 
 #include "OrxonoxPrereqs.h"
-#include "objects/Tickable.h"
+#include "core/OrxonoxClass.h"
 
 namespace orxonox
@@ -72,5 +72,5 @@
 
     //! TimerBase is the parent of the Timer class.
-    class _OrxonoxExport TimerBase : public Tickable
+    class _OrxonoxExport TimerBase : public OrxonoxClass
     {
         public:
@@ -97,19 +97,19 @@
             /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
             inline float getRemainingTime() const
-                { return this->time_; }
+                { return (float)this->time_ / 1000000.0f; }
             /** @brief Gives the Timer some extra time. @param time The amount of extra time in seconds */
             inline void addTime(float time)
-                { this->time_ += time; }
+                { if (time > 0.0f) this->time_ += (long long)(time * 1000000.0f); }
             /** @brief Decreases the remaining time of the Timer. @param time The amount of time to remove */
             inline void removeTime(float time)
-                { this->time_ -= time; }
+                { if (time > 0.0f) this->time_ -= (long long)(time * 1000000.0f); }
             /** @brief Sets the interval of the Timer. @param interval The interval */
             inline void setInterval(float interval)
-                { this->interval_ = interval; }
+                { this->interval_ = (long long)(interval * 1000000.0f); }
             /** @brief Sets bLoop to a given value. @param bLoop True = loop */
             inline void setLoop(bool bLoop)
                 { this->bLoop_ = bLoop; }
 
-            void tick(float dt);
+            void tick(const Clock& time);
 
         protected:
@@ -118,9 +118,9 @@
             Executor* executor_; //!< The executor of the function that should be called when the time expires
 
-            float interval_;     //!< The time-interval in seconds
+            long long interval_; //!< The time-interval in micro seconds
             bool bLoop_;         //!< If true, the function gets called every 'interval' seconds
             bool bActive_;       //!< If true, the Timer ticks and calls the function if the time's up
 
-            float time_;         //!< Internal variable, counting the time till the next function-call
+            long long time_;     //!< Internal variable, counting the time till the next function-call
     };
 
@@ -155,5 +155,5 @@
                 this->deleteExecutor();
 
-                this->interval_ = interval;
+                this->setInterval(interval);
                 this->bLoop_ = bLoop;
                 executor->setObject(object);
@@ -161,5 +161,5 @@
                 this->bActive_ = true;
 
-                this->time_ = interval;
+                this->time_ = this->interval_;
             }
     };
@@ -193,10 +193,10 @@
                 this->deleteExecutor();
 
-                this->interval_ = interval;
+                this->setInterval(interval);
                 this->bLoop_ = bLoop;
                 this->executor_ = (Executor*)executor;
                 this->bActive_ = true;
 
-                this->time_ = interval;
+                this->time_ = this->interval_;
             }
     };
Index: code/trunk/src/orxonox/tools/WindowEventListener.h
===================================================================
--- code/trunk/src/orxonox/tools/WindowEventListener.h	(revision 1754)
+++ code/trunk/src/orxonox/tools/WindowEventListener.h	(revision 1755)
@@ -45,12 +45,12 @@
         virtual ~WindowEventListener() { }
 
-		    /** Window has moved position */
-		    virtual void windowMoved() { }
+            /** Window has moved position */
+            virtual void windowMoved() { }
 
-		    /** Window has resized */
-		    virtual void windowResized(int newWidth, int newHeight) { }
+            /** Window has resized */
+            virtual void windowResized(int newWidth, int newHeight) { }
 
-		    /** Window has lost/gained focus */
-		    virtual void windowFocusChanged() { }
+            /** Window has lost/gained focus */
+            virtual void windowFocusChanged() { }
     };
 }
Index: code/trunk/src/tolua/CMakeLists.txt
===================================================================
--- code/trunk/src/tolua/CMakeLists.txt	(revision 1754)
+++ code/trunk/src/tolua/CMakeLists.txt	(revision 1755)
@@ -13,7 +13,36 @@
 )
 
+
+SET (TOLUAGEN_SRC_FILES
+  tolua.c
+  toluabind.c
+)
+
+ADD_EXECUTABLE (toluagen ${TOLUAGEN_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (toluagen
+  ${Lua_LIBRARIES}
+  tolualib
+  m
+)
+
+
+IF (Lua_VERSION EQUAL 5.0)
+  SET (TOLUA_PACKAGE "../../src/tolua/tolua-5.0.pkg")
+ELSE (Lua_VERSION EQUAL 5.0)
+  SET (TOLUA_PACKAGE "../../src/tolua/tolua-5.1.pkg")
+ENDIF (Lua_VERSION EQUAL 5.0)
+
+GET_TARGET_PROPERTY(TOLUAGEN_EXE toluagen LOCATION)
+ADD_CUSTOM_COMMAND(
+  OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/toluabind_orxonox.c
+  COMMAND ${TOLUAGEN_EXE} -n tolua -o ../../src/tolua/toluabind_orxonox.c -H ../../src/tolua/toluabind_orxonox.h ${TOLUA_PACKAGE}
+  DEPENDS toluagen
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+
 SET (TOLUAEXE_SRC_FILES
   tolua.c
-  toluabind.c
+  toluabind_orxonox.c
 )
 
Index: code/trunk/src/tolua/lua/array.lua
===================================================================
--- code/trunk/src/tolua/lua/array.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/array.lua	(revision 1755)
@@ -0,0 +1,227 @@
+-- tolua: array class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1999
+-- $Id: array.lua,v 1.1 2000/11/06 22:03:57 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Array class
+-- Represents a extern array variable or a public member of a class.
+-- Stores all fields present in a declaration.
+classArray = {
+}
+classArray.__index = classArray
+setmetatable(classArray,classDeclaration)
+
+-- Print method
+function classArray:print (ident,close)
+ print(ident.."Array{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." def  = '"..self.def.."',")
+ print(ident.." dim  = '"..self.dim.."',")
+ print(ident.." ret  = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- check if it is a variable
+function classArray:isvariable ()
+ return true
+end
+
+
+-- get variable value
+function classArray:getvalue (class,static)
+ if class and static then
+  return class..'::'..self.name..'[tolua_index]'
+ elseif class then
+  return 'self->'..self.name..'[tolua_index]'
+ else
+  return self.name..'[tolua_index]'
+ end
+end
+
+-- Write binding functions
+function classArray:supcode ()
+ local class = self:inclass()
+
+ -- get function ------------------------------------------------
+ if class then
+  output("/* get function:",self.name," of class ",class," */")
+ else
+  output("/* get function:",self.name," */")
+ end
+ self.cgetname = self:cfuncname("tolua_get")
+ output("#ifndef TOLUA_DISABLE_"..self.cgetname)
+ output("\nstatic int",self.cgetname,"(lua_State* tolua_S)")
+ output("{")
+ output(" int tolua_index;")
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+  output(' ',self.parent.type,'*','self;')
+  output(' lua_pushstring(tolua_S,".self");')
+  output(' lua_rawget(tolua_S,1);')
+  output(' self = ')
+  output('(',self.parent.type,'*) ')
+  output('lua_touserdata(tolua_S,-1);')
+ elseif static then
+  _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+ -- check index
+	output('#ifndef TOLUA_RELEASE\n')
+	output(' {')
+	output('  tolua_Error tolua_err;')
+ output('  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
+ output('   tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
+	output(' }')
+	output('#endif\n')
+	if flags['1'] then -- for compatibility with tolua5 ?
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
+	else
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);')
+	end
+	output('#ifndef TOLUA_RELEASE\n')
+	if self.dim and self.dim ~= '' then
+	  output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
+	else
+	  output(' if (tolua_index<0)')
+	end
+ output('  tolua_error(tolua_S,"array indexing out of range.",NULL);')
+	output('#endif\n')
+
+ -- return value
+ local t,ct = isbasic(self.type)
+ if t then
+  output(' tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static)..');')
+ else
+		t = self.type
+  if self.ptr == '&' or self.ptr == '' then
+   output(' tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static)..',"',t,'");')
+  else
+   output(' tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static)..',"',t,'");')
+  end
+ end
+ output(' return 1;')
+ output('}')
+ output('#endif //#ifndef TOLUA_DISABLE\n')
+ output('\n')
+
+ -- set function ------------------------------------------------
+ if not strfind(self.type,'const') then
+  if class then
+   output("/* set function:",self.name," of class ",class," */")
+  else
+   output("/* set function:",self.name," */")
+  end
+  self.csetname = self:cfuncname("tolua_set")
+  output("#ifndef TOLUA_DISABLE_"..self.csetname)
+  output("\nstatic int",self.csetname,"(lua_State* tolua_S)")
+  output("{")
+
+  -- declare index
+  output(' int tolua_index;')
+
+  -- declare self, if the case
+  local _,_,static = strfind(self.mod,'^%s*(static)')
+  if class and static==nil then
+   output(' ',self.parent.type,'*','self;')
+   output(' lua_pushstring(tolua_S,".self");')
+   output(' lua_rawget(tolua_S,1);')
+   output(' self = ')
+   output('(',self.parent.type,'*) ')
+   output('lua_touserdata(tolua_S,-1);')
+  elseif static then
+   _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+  end
+
+  -- check index
+	 output('#ifndef TOLUA_RELEASE\n')
+	 output(' {')
+	 output('  tolua_Error tolua_err;')
+  output('  if (!tolua_isnumber(tolua_S,2,0,&tolua_err))')
+  output('   tolua_error(tolua_S,"#vinvalid type in array indexing.",&tolua_err);')
+		output(' }')
+		output('#endif\n')
+
+	if flags['1'] then -- for compatibility with tolua5 ?
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0)-1;')
+	else
+		output(' tolua_index = (int)tolua_tonumber(tolua_S,2,0);')
+	end
+
+	 output('#ifndef TOLUA_RELEASE\n')
+	if self.dim and self.dim ~= '' then
+	  output(' if (tolua_index<0 || tolua_index>='..self.dim..')')
+	else
+	  output(' if (tolua_index<0)')
+	end
+  output('  tolua_error(tolua_S,"array indexing out of range.",NULL);')
+		output('#endif\n')
+
+  -- assign value
+  local ptr = ''
+  if self.ptr~='' then ptr = '*' end
+  output(' ')
+  if class and static then
+   output(class..'::'..self.name..'[tolua_index]')
+  elseif class then
+   output('self->'..self.name..'[tolua_index]')
+  else
+   output(self.name..'[tolua_index]')
+  end
+  local t = isbasic(self.type)
+  output(' = ')
+  if not t and ptr=='' then output('*') end
+  output('((',self.mod,self.type)
+  if not t then
+   output('*')
+  end
+  output(') ')
+  local def = 0
+  if self.def ~= '' then def = self.def end
+  if t then
+   output('tolua_to'..t,'(tolua_S,3,',def,'));')
+  else
+   output('tolua_tousertype(tolua_S,3,',def,'));')
+  end
+  output(' return 0;')
+  output('}')
+  output('#endif //#ifndef TOLUA_DISABLE\n')
+  output('\n')
+ end
+
+end
+
+function classArray:register (pre)
+ pre = pre or ''
+ if self.csetname then
+  output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
+ else
+  output(pre..'tolua_array(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
+ end
+end
+
+-- Internal constructor
+function _Array (t)
+ setmetatable(t,classArray)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the variable declaration.
+function Array (s)
+ return _Array (Declaration(s,'var'))
+end
+
+
Index: code/trunk/src/tolua/lua/basic.lua
===================================================================
--- code/trunk/src/tolua/lua/basic.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/basic.lua	(revision 1755)
@@ -0,0 +1,356 @@
+-- tolua: basic utility functions
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Basic C types and their corresponding Lua types
+-- All occurrences of "char*" will be replaced by "_cstring",
+-- and all occurrences of "void*" will be replaced by "_userdata"
+_basic = {
+ ['void'] = '',
+ ['char'] = 'number',
+ ['int'] = 'number',
+ ['short'] = 'number',
+ ['long'] = 'number',
+ ['unsigned'] = 'number',
+ ['float'] = 'number',
+ ['double'] = 'number',
+ ['_cstring'] = 'string',
+ ['_userdata'] = 'userdata',
+ ['char*'] = 'string',
+ ['void*'] = 'userdata',
+ ['bool'] = 'boolean',
+ ['lua_Object'] = 'value',
+ ['LUA_VALUE'] = 'value',    -- for compatibility with tolua 4.0
+ ['lua_State*'] = 'state',
+ ['_lstate'] = 'state',
+ ['lua_Function'] = 'value',
+}
+
+_basic_ctype = {
+ number = "lua_Number",
+ string = "const char*",
+ userdata = "void*",
+ boolean = "bool",
+ value = "int",
+ state = "lua_State*",
+}
+
+-- functions the are used to do a 'raw push' of basic types
+_basic_raw_push = {}
+
+-- List of user defined types
+-- Each type corresponds to a variable name that stores its tag value.
+_usertype = {}
+
+-- List of types that have to be collected
+_collect = {}
+
+-- List of types
+_global_types = {n=0}
+_global_types_hash = {}
+
+-- list of classes
+_global_classes = {}
+
+-- List of enum constants
+_global_enums = {}
+
+-- List of auto renaming
+_renaming = {}
+function appendrenaming (s)
+ local b,e,old,new = strfind(s,"%s*(.-)%s*@%s*(.-)%s*$")
+	if not b then
+	 error("#Invalid renaming syntax; it should be of the form: pattern@pattern")
+	end
+	tinsert(_renaming,{old=old, new=new})
+end
+
+function applyrenaming (s)
+	for i=1,getn(_renaming) do
+	 local m,n = gsub(s,_renaming[i].old,_renaming[i].new)
+		if n ~= 0 then
+		 return m
+		end
+	end
+	return nil
+end
+
+-- Error handler
+function tolua_error (s,f)
+if _curr_code then
+	print("***curr code for error is "..tostring(_curr_code))
+	print(debug.traceback())
+end
+ local out = _OUTPUT
+ _OUTPUT = _STDERR
+ if strsub(s,1,1) == '#' then
+  write("\n** tolua: "..strsub(s,2)..".\n\n")
+  if _curr_code then
+   local _,_,s = strfind(_curr_code,"^%s*(.-\n)") -- extract first line
+   if s==nil then s = _curr_code end
+   s = gsub(s,"_userdata","void*") -- return with 'void*'
+   s = gsub(s,"_cstring","char*")  -- return with 'char*'
+   s = gsub(s,"_lstate","lua_State*")  -- return with 'lua_State*'
+   write("Code being processed:\n"..s.."\n")
+  end
+ else
+ if not f then f = "(f is nil)" end
+  print("\n** tolua internal error: "..f..s..".\n\n")
+  return
+ end
+ _OUTPUT = out
+end
+
+function warning (msg)
+ local out = _OUTPUT
+ _OUTPUT = _STDERR
+ write("\n** tolua warning: "..msg..".\n\n")
+ _OUTPUT = out
+end
+
+-- register an user defined type: returns full type
+function regtype (t)
+	--if isbasic(t) then
+	--	return t
+	--end
+	local ft = findtype(t)
+
+	if not _usertype[ft] then
+		return appendusertype(t)
+	end
+	return ft
+end
+
+-- return type name: returns full type
+function typevar(type)
+	if type == '' or type == 'void' then
+		return type
+	else
+		local ft = findtype(type)
+		if ft then
+			return ft
+		end
+		_usertype[type] = type
+		return type
+	end
+end
+
+-- check if basic type
+function isbasic (type)
+ local t = gsub(type,'const ','')
+ local m,t = applytypedef('', t)
+ local b = _basic[t]
+ if b then
+  return b,_basic_ctype[b]
+ end
+ return nil
+end
+
+-- split string using a token
+function split (s,t)
+ local l = {n=0}
+ local f = function (s)
+  l.n = l.n + 1
+  l[l.n] = s
+  return ""
+ end
+ local p = "%s*(.-)%s*"..t.."%s*"
+ s = gsub(s,"^%s+","")
+ s = gsub(s,"%s+$","")
+ s = gsub(s,p,f)
+ l.n = l.n + 1
+ l[l.n] = gsub(s,"(%s%s*)$","")
+ return l
+end
+
+-- splits a string using a pattern, considering the spacial cases of C code (templates, function parameters, etc)
+-- pattern can't contain the '^' (as used to identify the begining of the line)
+-- also strips whitespace
+function split_c_tokens(s, pat)
+
+	s = string.gsub(s, "^%s*", "")
+	s = string.gsub(s, "%s*$", "")
+
+	local token_begin = 1
+	local token_end = 1
+	local ofs = 1
+	local ret = {n=0}
+
+	function add_token(ofs)
+
+		local t = string.sub(s, token_begin, ofs)
+		t = string.gsub(t, "^%s*", "")
+		t = string.gsub(t, "%s*$", "")
+		ret.n = ret.n + 1
+		ret[ret.n] = t
+	end
+
+	while ofs <= string.len(s) do
+
+		local sub = string.sub(s, ofs, -1)
+		local b,e = string.find(sub, "^"..pat)
+		if b then
+			add_token(ofs-1)
+			ofs = ofs+e
+			token_begin = ofs
+		else
+			local char = string.sub(s, ofs, ofs)
+			if char == "(" or char == "<" then
+
+				local block
+				if char == "(" then block = "^%b()" end
+				if char == "<" then block = "^%b<>" end
+
+				b,e = string.find(sub, block)
+				if not b then
+					-- unterminated block?
+					ofs = ofs+1
+				else
+					ofs = ofs + e
+				end
+
+			else
+				ofs = ofs+1
+			end
+		end
+
+	end
+	add_token(ofs)
+	--if ret.n == 0 then
+
+	--	ret.n=1
+	--	ret[1] = ""
+	--end
+
+	return ret
+
+end
+
+-- concatenate strings of a table
+function concat (t,f,l,jstr)
+	jstr = jstr or " "
+ local s = ''
+ local i=f
+ while i<=l do
+  s = s..t[i]
+  i = i+1
+  if i <= l then s = s..jstr end
+ end
+ return s
+end
+
+-- concatenate all parameters, following output rules
+function concatparam (line, ...)
+ local i=1
+ while i<=arg.n do
+  if _cont and not strfind(_cont,'[%(,"]') and
+     strfind(arg[i],"^[%a_~]") then
+	    line = line .. ' '
+  end
+  line = line .. arg[i]
+  if arg[i] ~= '' then
+   _cont = strsub(arg[i],-1,-1)
+  end
+  i = i+1
+ end
+ if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
+  _cont=nil line = line .. '\n'
+ end
+	return line
+end
+
+-- output line
+function output (...)
+ local i=1
+ while i<=arg.n do
+  if _cont and not strfind(_cont,'[%(,"]') and
+     strfind(arg[i],"^[%a_~]") then
+	    write(' ')
+  end
+  write(arg[i])
+  if arg[i] ~= '' then
+   _cont = strsub(arg[i],-1,-1)
+  end
+  i = i+1
+ end
+ if strfind(arg[arg.n],"[%/%)%;%{%}]$") then
+  _cont=nil write('\n')
+ end
+end
+
+function get_property_methods(ptype, name)
+
+	if get_property_methods_hook and get_property_methods_hook(ptype,name) then
+		return get_property_methods_hook(ptype, name)
+	end
+
+	if ptype == "default" then -- get_name, set_name
+		return "get_"..name, "set_"..name
+	end
+
+	if ptype == "qt" then -- name, setName
+		return name, "set"..string.upper(string.sub(name, 1, 1))..string.sub(name, 2, -1)
+	end
+
+	if ptype == "overload" then -- name, name
+		return name,name
+	end
+
+	return nil
+end
+
+-------------- the hooks
+
+-- called right after processing the $[ichl]file directives,
+-- right before processing anything else
+-- takes the package object as the parameter
+function preprocess_hook(p)
+	-- p.code has all the input code from the pkg
+end
+
+
+-- called for every $ifile directive
+-- takes a table with a string called 'code' inside, the filename, and any extra arguments
+-- passed to $ifile. no return value
+function include_file_hook(t, filename, ...)
+
+end
+
+-- called after processing anything that's not code (like '$renaming', comments, etc)
+-- and right before parsing the actual code.
+-- takes the Package object with all the code on the 'code' key. no return value
+function preparse_hook(package)
+
+end
+
+
+-- called after writing all the output.
+-- takes the Package object
+function post_output_hook(package)
+
+end
+
+
+-- called from 'get_property_methods' to get the methods to retrieve a property
+-- according to its type
+function get_property_methods_hook(property_type, name)
+
+end
+
+-- called from ClassContainer:doparse with the string being parsed
+-- return nil, or a substring
+function parser_hook(s)
+
+	return nil
+end
+
+
Index: code/trunk/src/tolua/lua/class.lua
===================================================================
--- code/trunk/src/tolua/lua/class.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/class.lua	(revision 1755)
@@ -0,0 +1,220 @@
+-- tolua: class class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Class class
+-- Represents a class definition.
+-- Stores the following fields:
+--    name = class name
+--    base = class base, if any (only single inheritance is supported)
+--    {i}  = list of members
+classClass = {
+ classtype = 'class',
+ name = '',
+ base = '',
+ type = '',
+ btype = '',
+ ctype = '',
+}
+classClass.__index = classClass
+setmetatable(classClass,classContainer)
+
+
+-- register class
+function classClass:register (pre)
+	if not self:check_public_access() then
+		return
+	end
+
+ pre = pre or ''
+ push(self)
+	if _collect[self.type] then
+		output(pre,'#ifdef __cplusplus\n')
+  output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",'.._collect[self.type]..');')
+		output(pre,'#else\n')
+  output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
+		output(pre,'#endif\n')
+	else
+  output(pre..'tolua_cclass(tolua_S,"'..self.lname..'","'..self.type..'","'..self.btype..'",NULL);')
+	end
+	if self.extra_bases then
+		for k,base in ipairs(self.extra_bases) do
+			-- not now
+   --output(pre..' tolua_addbase(tolua_S, "'..self.type..'", "'..base..'");')
+		end
+	end
+ output(pre..'tolua_beginmodule(tolua_S,"'..self.lname..'");')
+ local i=1
+ while self[i] do
+  self[i]:register(pre..' ')
+  i = i+1
+ end
+ output(pre..'tolua_endmodule(tolua_S);')
+	pop()
+end
+
+-- return collection requirement
+function classClass:requirecollection (t)
+	if self.flags.protected_destructor then
+		return false
+	end
+ push(self)
+	local r = false
+ local i=1
+ while self[i] do
+  r = self[i]:requirecollection(t) or r
+  i = i+1
+ end
+	pop()
+	-- only class that exports destructor can be appropriately collected
+	-- classes that export constructors need to have a collector (overrided by -D flag on command line)
+	if self._delete or ((not flags['D']) and self._new) then
+		--t[self.type] = "tolua_collect_" .. gsub(self.type,"::","_")
+		t[self.type] = "tolua_collect_" .. clean_template(self.type)
+		r = true
+	end
+ return r
+end
+
+-- output tags
+function classClass:decltype ()
+ push(self)
+	self.type = regtype(self.original_name or self.name)
+	self.btype = typevar(self.base)
+	self.ctype = 'const '..self.type
+	if self.extra_bases then
+		for i=1,table.getn(self.extra_bases) do
+			self.extra_bases[i] = typevar(self.extra_bases[i])
+		end
+	end
+ local i=1
+ while self[i] do
+  self[i]:decltype()
+  i = i+1
+ end
+	pop()
+end
+
+
+-- Print method
+function classClass:print (ident,close)
+ print(ident.."Class{")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." base = '"..self.base.."';")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." btype = '"..self.btype.."',")
+ print(ident.." ctype = '"..self.ctype.."',")
+ local i=1
+ while self[i] do
+  self[i]:print(ident.." ",",")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+function classClass:set_protected_destructor(p)
+	self.flags.protected_destructor = self.flags.protected_destructor or p
+end
+
+-- Internal constructor
+function _Class (t)
+ setmetatable(t,classClass)
+ t:buildnames()
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects the name, the base (array) and the body of the class.
+function Class (n,p,b)
+
+	if table.getn(p) > 1 then
+		b = string.sub(b, 1, -2)
+		for i=2,table.getn(p),1 do
+			b = b.."\n tolua_inherits "..p[i].." __"..p[i].."__;\n"
+		end
+		b = b.."\n}"
+	end
+
+	-- check for template
+	b = string.gsub(b, "^{%s*TEMPLATE_BIND", "{\nTOLUA_TEMPLATE_BIND")
+	local t,_,T,I = string.find(b, "^{%s*TOLUA_TEMPLATE_BIND%s*%(+%s*\"?([^\",]*)\"?%s*,%s*([^%)]*)%s*%)+")
+	if t then
+
+		-- remove quotes
+		I = string.gsub(I, "\"", "")
+		T = string.gsub(T, "\"", "")
+		-- get type list
+		local types = split_c_tokens(I, ",")
+		-- remove TEMPLATE_BIND line
+		local bs = string.gsub(b, "^{%s*TOLUA_TEMPLATE_BIND[^\n]*\n", "{\n")
+
+		-- replace
+		for i =1 , types.n do
+
+			local Tl = split(T, " ")
+			local Il = split_c_tokens(types[i], " ")
+			local bI = bs
+			local pI = {}
+			for j = 1,Tl.n do
+				Tl[j] = findtype(Tl[j]) or Tl[j]
+				bI = string.gsub(bI, "([^_%w])"..Tl[j].."([^_%w])", "%1"..Il[j].."%2")
+				if p then
+					for i=1,table.getn(p) do
+						pI[i] = string.gsub(p[i], "([^_%w]?)"..Tl[j].."([^_%w]?)", "%1"..Il[j].."%2")
+					end
+				end
+			end
+			--local append = "<"..string.gsub(types[i], "%s+", ",")..">"
+			local append = "<"..concat(Il, 1, table.getn(Il), ",")..">"
+			append = string.gsub(append, "%s*,%s*", ",")
+			append = string.gsub(append, ">>", "> >")
+			for i=1,table.getn(pI) do
+				--pI[i] = string.gsub(pI[i], ">>", "> >")
+				pI[i] = resolve_template_types(pI[i])
+			end
+			bI = string.gsub(bI, ">>", "> >")
+			Class(n..append, pI, bI)
+		end
+		return
+	end
+
+	local mbase
+
+	if p then
+		mbase = table.remove(p, 1)
+		if not p[1] then p = nil end
+	end
+
+	mbase = mbase and resolve_template_types(mbase)
+
+	local c
+	local oname = string.gsub(n, "@.*$", "")
+	oname = getnamespace(classContainer.curr)..oname
+
+	if _global_classes[oname] then
+		c = _global_classes[oname]
+		if mbase and ((not c.base) or c.base == "") then
+			c.base = mbase
+		end
+	else
+		c = _Class(_Container{name=n, base=mbase, extra_bases=p})
+
+		local ft = getnamespace(c.parent)..c.original_name
+		append_global_type(ft, c)
+	end
+
+	push(c)
+	c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+	pop()
+end
+
Index: code/trunk/src/tolua/lua/clean.lua
===================================================================
--- code/trunk/src/tolua/lua/clean.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/clean.lua	(revision 1755)
@@ -0,0 +1,79 @@
+-- mark up comments and strings
+STR1 = "\001"
+STR2 = "\002"
+STR3 = "\003"
+STR4 = "\004"
+REM  = "\005"
+ANY  = "([\001-\005])"
+ESC1 = "\006"
+ESC2 = "\007"
+
+MASK = { -- the substitution order is important
+ {ESC1, "\\'"},
+ {ESC2, '\\"'},
+ {STR1, "'"},
+ {STR2, '"'},
+ {STR3, "%[%["},
+ {STR4, "%]%]"},
+ {REM , "%-%-"},
+}
+
+function mask (s)
+ for i = 1,getn(MASK)  do
+  s = gsub(s,MASK[i][2],MASK[i][1])
+ end
+ return s
+end
+
+function unmask (s)
+ for i = 1,getn(MASK)  do
+  s = gsub(s,MASK[i][1],MASK[i][2])
+ end
+ return s
+end
+
+function clean (s)
+ -- check for compilation error
+ local code = "return function ()\n" .. s .. "\n end"
+ if not dostring(code) then
+  return nil
+ end
+
+ if flags['C'] then
+ 	return s
+ end
+
+ local S = "" -- saved string
+
+ s = mask(s)
+
+ -- remove blanks and comments
+ while 1 do
+  local b,e,d = strfind(s,ANY)
+  if b then
+   S = S..strsub(s,1,b-1)
+   s = strsub(s,b+1)
+   if d==STR1 or d==STR2 then
+    e = strfind(s,d)
+    S = S ..d..strsub(s,1,e)
+    s = strsub(s,e+1)
+   elseif d==STR3 then
+    e = strfind(s,STR4)
+    S = S..d..strsub(s,1,e)
+    s = strsub(s,e+1)
+   elseif d==REM then
+    s = gsub(s,"[^\n]*(\n?)","%1",1)
+   end
+  else
+   S = S..s
+   break
+  end
+ end
+ -- eliminate unecessary spaces
+ S = gsub(S,"[ \t]+"," ")
+ S = gsub(S,"[ \t]*\n[ \t]*","\n")
+	S = gsub(S,"\n+","\n")
+ S = unmask(S)
+ return S
+end
+
Index: code/trunk/src/tolua/lua/code.lua
===================================================================
--- code/trunk/src/tolua/lua/code.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/code.lua	(revision 1755)
@@ -0,0 +1,96 @@
+-- tolua: code class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1999
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+-- global
+code_n = 1
+
+-- Code class
+-- Represents Lua code to be compiled and included
+-- in the initialization function.
+-- The following fields are stored:
+--   text = text code
+classCode = {
+ text = '',
+}
+classCode.__index = classCode
+setmetatable(classCode,classFeature)
+
+-- register code
+function classCode:register (pre)
+ pre = pre or ''
+ -- clean Lua code
+ local s = clean(self.text)
+ if not s then
+  --print(self.text)
+  error("parser error in embedded code")
+ end
+
+ -- get first line
+ local _, _, first_line=string.find(self.text, "^([^\n\r]*)")
+ if string.find(first_line, "^%s*%-%-") then
+	 if string.find(first_line, "^%-%-##") then
+		first_line = string.gsub(first_line, "^%-%-##", "")
+		if flags['C'] then
+			s = string.gsub(s, "^%-%-##[^\n\r]*\n", "")
+		end
+	 end
+ else
+ 	first_line = ""
+ end
+
+ -- convert to C
+ output('\n'..pre..'{ /* begin embedded lua code */\n')
+ output(pre..' int top = lua_gettop(tolua_S);')
+ output(pre..' static unsigned char B[] = {\n   ')
+ local t={n=0}
+ local b = gsub(s,'(.)',function (c)
+                         local e = ''
+                         t.n=t.n+1 if t.n==15 then t.n=0 e='\n'..pre..'  ' end
+                         return format('%3u,%s',strbyte(c),e)
+                        end
+               )
+ output(b..strbyte(" "))
+ output('\n'..pre..' };\n')
+ if first_line and first_line ~= "" then
+ 	output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: '..first_line..'");')
+ else
+ 	output(pre..' tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code '..code_n..'");')
+ end
+ output(pre..' lua_settop(tolua_S, top);')
+ output(pre..'} /* end of embedded lua code */\n\n')
+ code_n = code_n +1
+end
+
+
+-- Print method
+function classCode:print (ident,close)
+ print(ident.."Code{")
+ print(ident.." text = [["..self.text.."]],")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Code (t)
+ setmetatable(t,classCode)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the code text
+function Code (l)
+ return _Code {
+  text = l
+ }
+end
+
+
Index: code/trunk/src/tolua/lua/compat-5.1.lua
===================================================================
--- code/trunk/src/tolua/lua/compat-5.1.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/compat-5.1.lua	(revision 1755)
@@ -0,0 +1,53 @@
+if string.find(_VERSION, "5%.0") then
+	return
+end
+
+-- "loadfile"
+local function pp_dofile(path)
+
+	local loaded = false
+	local getfile = function()
+
+		if loaded then
+			return
+		else
+			local file,err = io.open(path)
+			if not file then
+				error("error loading file "..path..": "..err)
+			end
+			local ret = file:read("*a")
+			file:close()
+
+			ret = string.gsub(ret, "%.%.%.%s*%)", "...) local arg = {n=select('#', ...), ...};")
+
+			loaded = true
+			return ret
+		end
+	end
+
+	local f = load(getfile, path)
+	return f()
+end
+
+old_dofile = dofile
+dofile = pp_dofile
+
+
+-- string.gsub
+--[[
+local ogsub = string.gsub
+local function compgsub(a,b,c,d)
+  if type(c) == "function" then
+    local oc = c
+    c = function (...) return oc(...) or '' end
+  end
+  return ogsub(a,b,c,d)
+end
+string.repl = ogsub
+--]]
+
+--string.gsub = compgsub
+
+
+
+
Index: code/trunk/src/tolua/lua/compat.lua
===================================================================
--- code/trunk/src/tolua/lua/compat.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/compat.lua	(revision 1755)
@@ -0,0 +1,193 @@
+-------------------------------------------------------------------
+-- Real globals
+-- _ALERT
+-- _ERRORMESSAGE
+-- _VERSION
+-- _G
+-- assert
+-- error
+-- metatable
+-- next
+-- print
+-- require
+-- tonumber
+-- tostring
+-- type
+-- unpack
+
+-------------------------------------------------------------------
+-- collectgarbage
+-- gcinfo
+
+-- globals
+
+-- call   -> protect(f, err)
+-- loadfile
+-- loadstring
+
+-- rawget
+-- rawset
+
+-- getargs = Main.getargs ??
+
+rawtype = type
+
+function do_ (f, err)
+  if not f then print(err); return end
+  local a,b = pcall(f)
+  if not a then print(b); return nil
+  else return b or true
+  end
+end
+
+function dostring(s) return do_(loadstring(s)) end
+-- function dofile(s) return do_(loadfile(s)) end
+
+-------------------------------------------------------------------
+-- Table library
+local tab = table
+foreach = tab.foreach
+foreachi = tab.foreachi
+getn = tab.getn
+tinsert = tab.insert
+tremove = tab.remove
+sort = tab.sort
+
+-------------------------------------------------------------------
+-- Debug library
+local dbg = debug
+getinfo = dbg.getinfo
+getlocal = dbg.getlocal
+setcallhook = function () error"`setcallhook' is deprecated" end
+setlinehook = function () error"`setlinehook' is deprecated" end
+setlocal = dbg.setlocal
+
+-------------------------------------------------------------------
+-- math library
+local math = math
+abs = math.abs
+acos = function (x) return math.deg(math.acos(x)) end
+asin = function (x) return math.deg(math.asin(x)) end
+atan = function (x) return math.deg(math.atan(x)) end
+atan2 = function (x,y) return math.deg(math.atan2(x,y)) end
+ceil = math.ceil
+cos = function (x) return math.cos(math.rad(x)) end
+deg = math.deg
+exp = math.exp
+floor = math.floor
+frexp = math.frexp
+ldexp = math.ldexp
+log = math.log
+log10 = math.log10
+max = math.max
+min = math.min
+mod = math.mod
+PI = math.pi
+--??? pow = math.pow  
+rad = math.rad
+random = math.random
+randomseed = math.randomseed
+sin = function (x) return math.sin(math.rad(x)) end
+sqrt = math.sqrt
+tan = function (x) return math.tan(math.rad(x)) end
+
+-------------------------------------------------------------------
+-- string library
+local str = string
+strbyte = str.byte
+strchar = str.char
+strfind = str.find
+format = str.format
+gsub = str.gsub
+strlen = str.len
+strlower = str.lower
+strrep = str.rep
+strsub = str.sub
+strupper = str.upper
+
+-------------------------------------------------------------------
+-- os library
+clock = os.clock
+date = os.date
+difftime = os.difftime
+execute = os.execute --?
+exit = os.exit
+getenv = os.getenv
+remove = os.remove
+rename = os.rename
+setlocale = os.setlocale
+time = os.time
+tmpname = os.tmpname
+
+-------------------------------------------------------------------
+-- compatibility only
+getglobal = function (n) return _G[n] end
+setglobal = function (n,v) _G[n] = v end
+
+-------------------------------------------------------------------
+
+local io, tab = io, table
+
+-- IO library (files)
+_STDIN = io.stdin
+_STDERR = io.stderr
+_STDOUT = io.stdout
+_INPUT = io.stdin
+_OUTPUT = io.stdout
+seek = io.stdin.seek   -- sick ;-)
+tmpfile = io.tmpfile
+closefile = io.close
+openfile = io.open
+
+function flush (f)
+  if f then f:flush()
+  else _OUTPUT:flush()
+  end
+end
+
+function readfrom (name)
+  if name == nil then
+    local f, err, cod = io.close(_INPUT)
+    _INPUT = io.stdin
+    return f, err, cod
+  else
+    local f, err, cod = io.open(name, "r")
+    _INPUT = f or _INPUT
+    return f, err, cod
+  end
+end
+
+function writeto (name)
+  if name == nil then
+    local f, err, cod = io.close(_OUTPUT)
+    _OUTPUT = io.stdout
+    return f, err, cod
+  else
+    local f, err, cod = io.open(name, "w")
+    _OUTPUT = f or _OUTPUT
+    return f, err, cod
+  end
+end
+
+function appendto (name)
+  local f, err, cod = io.open(name, "a")
+  _OUTPUT = f or _OUTPUT
+  return f, err, cod
+end
+
+function read (...)
+  local f = _INPUT
+  if rawtype(arg[1]) == 'userdata' then
+    f = tab.remove(arg, 1)
+  end
+  return f:read(unpack(arg))
+end
+
+function write (...)
+  local f = _OUTPUT
+  if rawtype(arg[1]) == 'userdata' then
+    f = tab.remove(arg, 1)
+  end
+  return f:write(unpack(arg))
+end
+
Index: code/trunk/src/tolua/lua/container.lua
===================================================================
--- code/trunk/src/tolua/lua/container.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/container.lua	(revision 1755)
@@ -0,0 +1,771 @@
+-- tolua: container abstract class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+-- table to store namespaced typedefs/enums in global scope
+global_typedefs = {}
+global_enums = {}
+
+-- Container class
+-- Represents a container of features to be bound
+-- to lua.
+classContainer =
+{
+ curr = nil,
+}
+classContainer.__index = classContainer
+setmetatable(classContainer,classFeature)
+
+-- output tags
+function classContainer:decltype ()
+ push(self)
+ local i=1
+ while self[i] do
+  self[i]:decltype()
+  i = i+1
+ end
+ pop()
+end
+
+
+-- write support code
+function classContainer:supcode ()
+
+	if not self:check_public_access() then
+		return
+	end
+
+ push(self)
+ local i=1
+ while self[i] do
+  if self[i]:check_public_access() then
+  	self[i]:supcode()
+  end
+  i = i+1
+ end
+ pop()
+end
+
+function classContainer:hasvar ()
+ local i=1
+ while self[i] do
+  if self[i]:isvariable() then
+		 return 1
+		end
+  i = i+1
+ end
+	return 0
+end
+
+-- Internal container constructor
+function _Container (self)
+ setmetatable(self,classContainer)
+ self.n = 0
+ self.typedefs = {tolua_n=0}
+ self.usertypes = {}
+ self.enums = {tolua_n=0}
+ self.lnames = {}
+ return self
+end
+
+-- push container
+function push (t)
+	t.prox = classContainer.curr
+ classContainer.curr = t
+end
+
+-- pop container
+function pop ()
+--print("name",classContainer.curr.name)
+--foreach(classContainer.curr.usertypes,print)
+--print("______________")
+ classContainer.curr = classContainer.curr.prox
+end
+
+-- get current namespace
+function getcurrnamespace ()
+	return getnamespace(classContainer.curr)
+end
+
+-- append to current container
+function append (t)
+ return classContainer.curr:append(t)
+end
+
+-- append typedef to current container
+function appendtypedef (t)
+ return classContainer.curr:appendtypedef(t)
+end
+
+-- append usertype to current container
+function appendusertype (t)
+ return classContainer.curr:appendusertype(t)
+end
+
+-- append enum to current container
+function appendenum (t)
+ return classContainer.curr:appendenum(t)
+end
+
+-- substitute typedef
+function applytypedef (mod,type)
+ return classContainer.curr:applytypedef(mod,type)
+end
+
+-- check if is type
+function findtype (type)
+ local t = classContainer.curr:findtype(type)
+	return t
+end
+
+-- check if is typedef
+function istypedef (type)
+ return classContainer.curr:istypedef(type)
+end
+
+-- get fulltype (with namespace)
+function fulltype (t)
+ local curr =  classContainer.curr
+	while curr do
+	 if curr then
+		 if curr.typedefs and curr.typedefs[t] then
+		  return curr.typedefs[t]
+		 elseif curr.usertypes and curr.usertypes[t] then
+		  return curr.usertypes[t]
+			end
+		end
+	 curr = curr.prox
+	end
+	return t
+end
+
+-- checks if it requires collection
+function classContainer:requirecollection (t)
+ push(self)
+ local i=1
+	local r = false
+ while self[i] do
+  r = self[i]:requirecollection(t) or r
+  i = i+1
+ end
+	pop()
+	return r
+end
+
+
+-- get namesapce
+function getnamespace (curr)
+	local namespace = ''
+	while curr do
+	 if curr and
+		   ( curr.classtype == 'class' or curr.classtype == 'namespace')
+		then
+		 namespace = (curr.original_name or curr.name) .. '::' .. namespace
+		 --namespace = curr.name .. '::' .. namespace
+		end
+	 curr = curr.prox
+	end
+	return namespace
+end
+
+-- get namespace (only namespace)
+function getonlynamespace ()
+ local curr = classContainer.curr
+	local namespace = ''
+	while curr do
+		if curr.classtype == 'class' then
+		 return namespace
+		elseif curr.classtype == 'namespace' then
+		 namespace = curr.name .. '::' .. namespace
+		end
+	 curr = curr.prox
+	end
+	return namespace
+end
+
+-- check if is enum
+function isenum (type)
+ return classContainer.curr:isenum(type)
+end
+
+-- append feature to container
+function classContainer:append (t)
+ self.n = self.n + 1
+ self[self.n] = t
+ t.parent = self
+end
+
+-- append typedef
+function classContainer:appendtypedef (t)
+ local namespace = getnamespace(classContainer.curr)
+ self.typedefs.tolua_n = self.typedefs.tolua_n + 1
+ self.typedefs[self.typedefs.tolua_n] = t
+	self.typedefs[t.utype] = namespace .. t.utype
+	global_typedefs[namespace..t.utype] = t
+	t.ftype = findtype(t.type) or t.type
+	--print("appending typedef "..t.utype.." as "..namespace..t.utype.." with ftype "..t.ftype)
+	append_global_type(namespace..t.utype)
+	if t.ftype and isenum(t.ftype) then
+
+		global_enums[namespace..t.utype] = true
+	end
+end
+
+-- append usertype: return full type
+function classContainer:appendusertype (t)
+	local container
+	if t == (self.original_name or self.name) then
+		container = self.prox
+	else
+		container = self
+	end
+	local ft = getnamespace(container) .. t
+	container.usertypes[t] = ft
+	_usertype[ft] = ft
+	return ft
+end
+
+-- append enum
+function classContainer:appendenum (t)
+ local namespace = getnamespace(classContainer.curr)
+ self.enums.tolua_n = self.enums.tolua_n + 1
+ self.enums[self.enums.tolua_n] = t
+	global_enums[namespace..t.name] = t
+end
+
+-- determine lua function name overload
+function classContainer:overload (lname)
+ if not self.lnames[lname] then
+  self.lnames[lname] = 0
+ else
+  self.lnames[lname] = self.lnames[lname] + 1
+ end
+ return format("%02d",self.lnames[lname])
+end
+
+-- applies typedef: returns the 'the facto' modifier and type
+function classContainer:applytypedef (mod,type)
+	if global_typedefs[type] then
+		--print("found typedef "..global_typedefs[type].type)
+		local mod1, type1 = global_typedefs[type].mod, global_typedefs[type].ftype
+		local mod2, type2 = applytypedef(mod.." "..mod1, type1)
+		--return mod2 .. ' ' .. mod1, type2
+		return mod2, type2
+	end
+	do return mod,type end
+end
+
+-- check if it is a typedef
+function classContainer:istypedef (type)
+ local env = self
+ while env do
+  if env.typedefs then
+   local i=1
+   while env.typedefs[i] do
+    if env.typedefs[i].utype == type then
+         return type
+        end
+        i = i+1
+   end
+  end
+  env = env.parent
+ end
+ return nil
+end
+
+function find_enum_var(var)
+
+	if tonumber(var) then return var end
+
+	local c = classContainer.curr
+	while c do
+		local ns = getnamespace(c)
+		for k,v in pairs(_global_enums) do
+			if match_type(var, v, ns) then
+				return v
+			end
+		end
+		if c.base and c.base ~= '' then
+			c = _global_classes[c:findtype(c.base)]
+		else
+			c = nil
+		end
+	end
+
+	return var
+end
+
+-- check if is a registered type: return full type or nil
+function classContainer:findtype (t)
+
+	t = string.gsub(t, "=.*", "")
+	if _basic[t] then
+	 return t
+	end
+
+	local _,_,em = string.find(t, "([&%*])%s*$")
+	t = string.gsub(t, "%s*([&%*])%s*$", "")
+	p = self
+	while p and type(p)=='table' do
+		local st = getnamespace(p)
+
+		for i=_global_types.n,1,-1 do -- in reverse order
+
+			if match_type(t, _global_types[i], st) then
+				return _global_types[i]..(em or "")
+			end
+		end
+		if p.base and p.base ~= '' and p.base ~= t then
+			--print("type is "..t..", p is "..p.base.." self.type is "..self.type.." self.name is "..self.name)
+			p = _global_classes[p:findtype(p.base)]
+		else
+			p = nil
+		end
+	end
+
+	return nil
+end
+
+function append_global_type(t, class)
+	_global_types.n = _global_types.n +1
+	_global_types[_global_types.n] = t
+	_global_types_hash[t] = 1
+	if class then append_class_type(t, class) end
+end
+
+function append_class_type(t,class)
+	if _global_classes[t] then
+		class.flags = _global_classes[t].flags
+		class.lnames = _global_classes[t].lnames
+		if _global_classes[t].base and (_global_classes[t].base ~= '') then
+			class.base = _global_classes[t].base or class.base
+		end
+	end
+	_global_classes[t] = class
+	class.flags = class.flags or {}
+end
+
+function match_type(childtype, regtype, st)
+--print("findtype "..childtype..", "..regtype..", "..st)
+	local b,e = string.find(regtype, childtype, -string.len(childtype), true)
+	if b then
+
+		if e == string.len(regtype) and
+				(b == 1 or (string.sub(regtype, b-1, b-1) == ':' and
+				string.sub(regtype, 1, b-1) == string.sub(st, 1, b-1))) then
+			return true
+		end
+	end
+
+	return false
+end
+
+function findtype_on_childs(self, t)
+
+	local tchild
+	if self.classtype == 'class' or self.classtype == 'namespace' then
+		for k,v in ipairs(self) do
+			if v.classtype == 'class' or v.classtype == 'namespace' then
+				if v.typedefs and v.typedefs[t] then
+				 return v.typedefs[t]
+				elseif v.usertypes and v.usertypes[t] then
+				 return v.usertypes[t]
+				end
+				tchild = findtype_on_childs(v, t)
+				if tchild then return tchild end
+			end
+		end
+	end
+	return nil
+
+end
+
+function classContainer:isenum (type)
+ if global_enums[type] then
+	return type
+ else
+ 	return false
+ end
+
+ local basetype = gsub(type,"^.*::","")
+ local env = self
+ while env do
+  if env.enums then
+   local i=1
+   while env.enums[i] do
+    if env.enums[i].name == basetype then
+         return true
+        end
+        i = i+1
+   end
+  end
+  env = env.parent
+ end
+ return false
+end
+
+methodisvirtual = false -- a global
+
+-- parse chunk
+function classContainer:doparse (s)
+--print ("parse "..s)
+
+ -- try the parser hook
+ do
+ 	local sub = parser_hook(s)
+ 	if sub then
+ 		return sub
+ 	end
+ end
+
+ -- try the null statement
+ do
+ 	local b,e,code = string.find(s, "^%s*;")
+ 	if b then
+ 		return strsub(s,e+1)
+ 	end
+ end
+
+ -- try empty verbatim line
+ do
+ 	local b,e,code = string.find(s, "^%s*$\n")
+ 	if b then
+ 		return strsub(s,e+1)
+ 	end
+ end
+
+ -- try Lua code
+ do
+  local b,e,code = strfind(s,"^%s*(%b\1\2)")
+  if b then
+   Code(strsub(code,2,-2))
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try C code
+ do
+  local b,e,code = strfind(s,"^%s*(%b\3\4)")
+  if b then
+	code = '{'..strsub(code,2,-2)..'\n}\n'
+	Verbatim(code,'r')        -- verbatim code for 'r'egister fragment
+	return strsub(s,e+1)
+  end
+ end
+
+ -- try C code for preamble section
+ do
+ 	local b,e,code = string.find(s, "^%s*(%b\5\6)")
+ 	if b then
+ 		code = string.sub(code, 2, -2).."\n"
+		Verbatim(code, '')
+		return string.sub(s, e+1)
+ 	end
+ end
+
+ -- try default_property directive
+ do
+ 	local b,e,ptype = strfind(s, "^%s*TOLUA_PROPERTY_TYPE%s*%(+%s*([^%)%s]*)%s*%)+%s*;?")
+ 	if b then
+ 		if not ptype or ptype == "" then
+ 			ptype = "default"
+ 		end
+ 		self:set_property_type(ptype)
+	 	return strsub(s, e+1)
+ 	end
+ end
+
+ -- try protected_destructor directive
+ do
+ 	local b,e = string.find(s, "^%s*TOLUA_PROTECTED_DESTRUCTOR%s*;?")
+	if b then
+		if self.set_protected_destructor then
+	 		self:set_protected_destructor(true)
+	 	end
+ 		return strsub(s, e+1)
+ 	end
+ end
+
+ -- try 'extern' keyword
+ do
+ 	local b,e = string.find(s, "^%s*extern%s+")
+ 	if b then
+		-- do nothing
+ 		return strsub(s, e+1)
+ 	end
+ end
+	
+ -- try 'virtual' keyworkd
+ do
+ 	local b,e = string.find(s, "^%s*virtual%s+")
+ 	if b then
+ 		methodisvirtual = true
+ 		return strsub(s, e+1)
+ 	end
+ end
+
+ -- try labels (public, private, etc)
+ do
+ 	local b,e = string.find(s, "^%s*%w*%s*:[^:]")
+ 	if b then
+ 		return strsub(s, e) -- preserve the [^:]
+ 	end
+ end
+
+ -- try module
+ do
+  local b,e,name,body = strfind(s,"^%s*module%s%s*([_%w][_%w]*)%s*(%b{})%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Module(name,body)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try namesapce
+ do
+  local b,e,name,body = strfind(s,"^%s*namespace%s%s*([_%w][_%w]*)%s*(%b{})%s*;?")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Namespace(name,body)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try define
+ do
+  local b,e,name = strfind(s,"^%s*#define%s%s*([^%s]*)[^\n]*\n%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Define(name)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try enumerates
+
+ do
+  local b,e,name,body,varname = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*([^%s;]*)%s*;?%s*")
+  if b then
+   --error("#Sorry, declaration of enums and variables on the same statement is not supported.\nDeclare your variable separately (example: '"..name.." "..varname..";')")
+   _curr_code = strsub(s,b,e)
+   Enumerate(name,body,varname)
+   return strsub(s,e+1)
+  end
+ end
+
+-- do
+--  local b,e,name,body = strfind(s,"^%s*enum%s+(%S*)%s*(%b{})%s*;?%s*")
+--  if b then
+--   _curr_code = strsub(s,b,e)
+--   Enumerate(name,body)
+--  return strsub(s,e+1)
+--  end
+-- end
+
+ do
+  local b,e,body,name = strfind(s,"^%s*typedef%s+enum[^{]*(%b{})%s*([%w_][^%s]*)%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Enumerate(name,body)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try operator
+ do
+  local b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
+  if not b then
+		 -- try inline
+   b,e,decl,kind,arg,const = strfind(s,"^%s*([_%w][_%w%s%*&:<>,]-%s+operator)%s*([^%s][^%s]*)%s*(%b())%s*(c?o?n?s?t?)[%s\n]*%b{}%s*;?%s*")
+  end
+  if not b then
+  	-- try cast operator
+  	b,e,decl,kind,arg,const = strfind(s, "^%s*(operator)%s+([%w_:%d<>%*%&%s]+)%s*(%b())%s*(c?o?n?s?t?)");
+  	if b then
+  		local _,ie = string.find(s, "^%s*%b{}", e+1)
+  		if ie then
+  			e = ie
+  		end
+  	end
+  end
+  if b then
+   _curr_code = strsub(s,b,e)
+   Operator(decl,kind,arg,const)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try function
+ do
+  --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w])%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
+  local b,e,decl,arg,const,virt = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)%s*(=?%s*0?)%s*;%s*")
+  if not b then
+  	-- try function with template
+  	b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w]%b<>)%s*(%b())%s*(c?o?n?s?t?)%s*=?%s*0?%s*;%s*")
+  end
+  if not b then
+   -- try a single letter function name
+   b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?)%s*;%s*")
+  end
+  if b then
+  	if virt and string.find(virt, "[=0]") then
+  		if self.flags then
+  			self.flags.pure_virtual = true
+  		end
+  	end
+   _curr_code = strsub(s,b,e)
+   Function(decl,arg,const)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try inline function
+ do
+  local b,e,decl,arg,const = strfind(s,"^%s*([^%(\n]+)%s*(%b())%s*(c?o?n?s?t?)[^;{]*%b{}%s*;?%s*")
+  --local b,e,decl,arg,const = strfind(s,"^%s*([~_%w][_@%w%s%*&:<>]*[_%w>])%s*(%b())%s*(c?o?n?s?t?)[^;]*%b{}%s*;?%s*")
+  if not b then
+   -- try a single letter function name
+   b,e,decl,arg,const = strfind(s,"^%s*([_%w])%s*(%b())%s*(c?o?n?s?t?).-%b{}%s*;?%s*")
+  end
+  if b then
+   _curr_code = strsub(s,b,e)
+   Function(decl,arg,const)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try class
+ do
+	 local b,e,name,base,body
+		base = '' body = ''
+		b,e,name = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*;")  -- dummy class
+		if not b then
+			b,e,name = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*;")    -- dummy struct
+			if not b then
+				b,e,name,base,body = strfind(s,"^%s*class%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+				if not b then
+					b,e,name,base,body = strfind(s,"^%s*struct%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+					if not b then
+						b,e,name,base,body = strfind(s,"^%s*union%s*([_%w][_%w@]*)%s*(.-)%s*(%b{})%s*;%s*")
+						if not b then
+							base = ''
+							b,e,body,name = strfind(s,"^%s*typedef%s%s*struct%s%s*[_%w]*%s*(%b{})%s*([_%w][_%w@]*)%s*;%s*")
+						end
+					end
+				end
+			end
+		end
+		if b then
+			if base ~= '' then
+				base = string.gsub(base, "^%s*:%s*", "")
+				base = string.gsub(base, "%s*public%s*", "")
+				base = split(base, ",")
+				--local b,e
+				--b,e,base = strfind(base,".-([_%w][_%w<>,:]*)$")
+			else
+				base = {}
+			end
+			_curr_code = strsub(s,b,e)
+			Class(name,base,body)
+			return strsub(s,e+1)
+		end
+	end
+
+ -- try typedef
+ do
+  local b,e,types = strfind(s,"^%s*typedef%s%s*(.-)%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Typedef(types)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try variable
+ do
+  local b,e,decl = strfind(s,"^%s*([_%w][_@%s%w%d%*&:<>,]*[_%w%d])%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+
+	local list = split_c_tokens(decl, ",")
+	Variable(list[1])
+	if list.n > 1 then
+		local _,_,type = strfind(list[1], "(.-)%s+([^%s]*)$");
+
+		local i =2;
+		while list[i] do
+			Variable(type.." "..list[i])
+			i=i+1
+		end
+	end
+   --Variable(decl)
+   return strsub(s,e+1)
+  end
+ end
+
+	-- try string
+ do
+  local b,e,decl = strfind(s,"^%s*([_%w]?[_%s%w%d]-char%s+[_@%w%d]*%s*%[%s*%S+%s*%])%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Variable(decl)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- try array
+ do
+  local b,e,decl = strfind(s,"^%s*([_%w][][_@%s%w%d%*&:]*[]_%w%d])%s*;%s*")
+  if b then
+   _curr_code = strsub(s,b,e)
+   Array(decl)
+   return strsub(s,e+1)
+  end
+ end
+
+ -- no matching
+ if gsub(s,"%s%s*","") ~= "" then
+  _curr_code = s
+  error("#parse error")
+ else
+  return ""
+ end
+
+end
+
+function classContainer:parse (s)
+
+	self.curr_member_access = nil
+
+ while s ~= '' do
+  s = self:doparse(s)
+  methodisvirtual = false
+ end
+end
+
+
+-- property types
+
+function get_property_type()
+
+	return classContainer.curr:get_property_type()
+end
+
+function classContainer:set_property_type(ptype)
+	ptype = string.gsub(ptype, "^%s*", "")
+	ptype = string.gsub(ptype, "%s*$", "")
+
+	self.property_type = ptype
+end
+
+function classContainer:get_property_type()
+	return self.property_type or (self.parent and self.parent:get_property_type()) or "default"
+end
Index: code/trunk/src/tolua/lua/custom.lua
===================================================================
--- code/trunk/src/tolua/lua/custom.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/custom.lua	(revision 1755)
@@ -0,0 +1,45 @@
+
+function extract_code(fn,s)
+	local code = ""
+	if fn then
+		code = '\n$#include "'..fn..'"\n'
+	end
+	s= "\n" .. s .. "\n" -- add blank lines as sentinels
+	local _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n")
+	while e do
+		t = strlower(t)
+		if t == "bind_begin" then
+			_,e,c = strfind(s,"(.-)\n[^\n]*SCRIPT_BIND_END[^\n]*\n",e)
+			if not e then
+			 tolua_error("Unbalanced 'SCRIPT_BIND_BEGIN' directive in header file")
+			end
+		end
+		if t == "bind_class" or t == "bind_block" then
+			local b
+			_,e,c,b = string.find(s, "([^{]-)(%b{})", e)
+			c = c..'{\n'..extract_code(nil, b)..'\n};\n'
+		end
+		code = code .. c .. "\n"
+	 _,e,c,t = strfind(s, "\n([^\n]-)SCRIPT_([%w_]*)[^\n]*\n",e)
+	end
+	return code
+end
+
+function preprocess_hook(p)
+end
+
+function preparse_hook(p)
+end
+
+function include_file_hook(p, filename)
+	do return end
+--print("FILENAME is "..filename)
+	p.code = string.gsub(p.code, "\n%s*SigC::Signal", "\n\ttolua_readonly SigC::Signal")
+	p.code = string.gsub(p.code, "#ifdef __cplusplus\nextern \"C\" {\n#endif", "")
+	p.code = string.gsub(p.code, "#ifdef __cplusplus\n};?\n#endif", "")
+	p.code = string.gsub(p.code, "DECLSPEC", "")
+	p.code = string.gsub(p.code, "SDLCALL", "")
+	p.code = string.gsub(p.code, "DLLINTERFACE", "")
+	p.code = string.gsub(p.code, "#define[^\n]*_[hH]_?%s*\n", "\n")
+--print("code is "..p.code)
+end
Index: code/trunk/src/tolua/lua/custom_hide.lua
===================================================================
--- code/trunk/src/tolua/lua/custom_hide.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/custom_hide.lua	(revision 1755)
@@ -0,0 +1,21 @@
+-- extract code with tolua_hide, and also
+function extract_code(fn,s)
+	local code = '\n$#include "'..fn..'"\n'
+	s= "\n" .. s .. "\n" -- add blank lines as sentinels
+	local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
+	while e do
+		t = strlower(t)
+		if t == "begin" then
+			_,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
+			if not e then
+			 tolua_error("Unbalanced 'tolua_begin' directive in header file")
+			end
+		end
+		c = c.."\n"
+		c = string.gsub(c, "\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[hH][iI][Dd][eE][^\n]*\n", "\n");
+		c = string.gsub(c, "#define[^%(\n]*%(.-\n", "\n")
+		code = code .. c
+	 _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
+	end
+	return code
+end
Index: code/trunk/src/tolua/lua/declaration.lua
===================================================================
--- code/trunk/src/tolua/lua/declaration.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/declaration.lua	(revision 1755)
@@ -0,0 +1,567 @@
+-- tolua: declaration class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Declaration class
+-- Represents variable, function, or argument declaration.
+-- Stores the following fields:
+--  mod  = type modifiers
+--  type = type
+--  ptr  = "*" or "&", if representing a pointer or a reference
+--  name = name
+--  dim  = dimension, if a vector
+--  def  = default value, if any (only for arguments)
+--  ret  = "*" or "&", if value is to be returned (only for arguments)
+classDeclaration = {
+ mod = '',
+ type = '',
+ ptr = '',
+ name = '',
+ dim = '',
+ ret = '',
+ def = ''
+}
+classDeclaration.__index = classDeclaration
+setmetatable(classDeclaration,classFeature)
+
+-- Create an unique variable name
+function create_varname ()
+ if not _varnumber then _varnumber = 0 end
+ _varnumber = _varnumber + 1
+ return "tolua_var_".._varnumber
+end
+
+-- Check declaration name
+-- It also identifies default values
+function classDeclaration:checkname ()
+
+ if strsub(self.name,1,1) == '[' and not findtype(self.type) then
+  self.name = self.type..self.name
+  local m = split(self.mod,'%s%s*')
+  self.type = m[m.n]
+  self.mod = concat(m,1,m.n-1)
+ end
+
+ local t = split(self.name,'=')
+ if t.n==2 then
+  self.name = t[1]
+  self.def = find_enum_var(t[t.n])
+ end
+
+ local b,e,d = strfind(self.name,"%[(.-)%]")
+ if b then
+  self.name = strsub(self.name,1,b-1)
+  self.dim = find_enum_var(d)
+ end
+
+
+ if self.type ~= '' and self.type ~= 'void' and self.name == '' then
+  self.name = create_varname()
+ elseif self.kind=='var' then
+  if self.type=='' and self.name~='' then
+   self.type = self.type..self.name
+   self.name = create_varname()
+  elseif findtype(self.name) then
+   if self.type=='' then self.type = self.name
+   else self.type = self.type..' '..self.name end
+   self.name = create_varname()
+  end
+ end
+
+ -- adjust type of string
+ if self.type == 'char' and self.dim ~= '' then
+	 self.type = 'char*'
+ end
+
+	if self.kind and self.kind == 'var' then
+		self.name = string.gsub(self.name, ":.*$", "") -- ???
+	end
+end
+
+-- Check declaration type
+-- Substitutes typedef's.
+function classDeclaration:checktype ()
+
+ -- check if there is a pointer to basic type
+ local basic = isbasic(self.type)
+ if self.kind == 'func' and basic=='number' and string.find(self.ptr, "%*") then
+ 	self.type = '_userdata'
+ 	self.ptr = ""
+ end
+ if basic and self.ptr~='' then
+  self.ret = self.ptr
+  self.ptr = nil
+  if isbasic(self.type) == 'number' then
+  	self.return_userdata = true
+  end
+ end
+
+ -- check if there is array to be returned
+ if self.dim~='' and self.ret~='' then
+   error('#invalid parameter: cannot return an array of values')
+ end
+ -- restore 'void*' and 'string*'
+ if self.type == '_userdata' then self.type = 'void*'
+ elseif self.type == '_cstring' then self.type = 'char*'
+ elseif self.type == '_lstate' then self.type = 'lua_State*'
+ end
+
+ -- resolve types inside the templates
+ if self.type then
+	 self.type = resolve_template_types(self.type)
+ end
+
+--
+-- -- if returning value, automatically set default value
+-- if self.ret ~= '' and self.def == '' then
+--  self.def = '0'
+-- end
+--
+
+end
+
+function resolve_template_types(type)
+
+	if isbasic(type) then
+		return type
+	end
+	local b,_,m = string.find(type, "(%b<>)")
+	if b then
+
+		m = split_c_tokens(string.sub(m, 2, -2), ",")
+		for i=1, table.getn(m) do
+			m[i] = string.gsub(m[i],"%s*([%*&])", "%1")
+			m[i] = findtype(m[i]) or m[i]
+			m[i] = resolve_template_types(m[i])
+		end
+
+		local b,i
+		type,b,i = break_template(type)
+		local template_part = "<"..string.gsub(concat(m, 1, m.n), " ", ",")..">"
+		type = rebuild_template(type, b, template_part)
+		type = string.gsub(type, ">>", "> >")
+	end
+	return type
+end
+
+function break_template(s)
+	local b,e,timpl = string.find(s, "(%b<>)")
+	if timpl then
+		s = string.gsub(s, "%b<>", "")
+		return s, b, timpl
+	else
+		return s, 0, nil
+	end
+end
+
+function rebuild_template(s, b, timpl)
+
+	if b == 0 then
+		return s
+	end
+
+	return string.sub(s, 1, b-1)..timpl..string.sub(s, b, -1)
+end
+
+-- Print method
+function classDeclaration:print (ident,close)
+ print(ident.."Declaration{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." dim  = '"..self.dim.."',")
+ print(ident.." def  = '"..self.def.."',")
+ print(ident.." ret  = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- check if array of values are returned to Lua
+function classDeclaration:requirecollection (t)
+ if self.mod ~= 'const' and
+	    self.dim and self.dim ~= '' and
+				 not isbasic(self.type) and
+				 self.ptr == '' then
+		local type = gsub(self.type,"%s*const%s+","")
+		t[type] = "tolua_collect_" .. clean_template(type)
+		return true
+	end
+	return false
+end
+
+-- declare tag
+function classDeclaration:decltype ()
+
+	self.type = typevar(self.type)
+	if strfind(self.mod,'const') then
+		self.type = 'const '..self.type
+		self.mod = gsub(self.mod,'const%s*','')
+	end
+end
+
+
+-- output type checking
+function classDeclaration:outchecktype (narg)
+ local def
+ local t = isbasic(self.type)
+ if self.def~='' then
+  def = 1
+ else
+  def = 0
+ end
+ if self.dim ~= '' then
+	--if t=='string' then
+	--	return 'tolua_isstringarray(tolua_S,'..narg..','..def..',&tolua_err)'
+	--else
+	return 'tolua_istable(tolua_S,'..narg..',0,&tolua_err)'
+ 	--end
+ elseif t then
+	return 'tolua_is'..t..'(tolua_S,'..narg..','..def..',&tolua_err)'
+ else
+  return 'tolua_isusertype(tolua_S,'..narg..',"'..self.type..'",'..def..',&tolua_err)'
+ end
+end
+
+function classDeclaration:builddeclaration (narg, cplusplus)
+ local array = self.dim ~= '' and tonumber(self.dim)==nil
+	local line = ""
+ local ptr = ''
+	local mod
+	local type = self.type
+ if self.dim ~= '' then
+	 type = gsub(self.type,'const%s+','')  -- eliminates const modifier for arrays
+ end
+ if self.ptr~='' and not isbasic(type) then ptr = '*' end
+ line = concatparam(line," ",self.mod,type,ptr)
+ if array then
+  line = concatparam(line,'*')
+ end
+ line = concatparam(line,self.name)
+ if self.dim ~= '' then
+  if tonumber(self.dim)~=nil then
+   line = concatparam(line,'[',self.dim,'];')
+  else
+	if cplusplus then
+		line = concatparam(line,' = new',type,ptr,'['..self.dim..'];')
+	else
+		line = concatparam(line,' = (',type,ptr,'*)',
+		'malloc((',self.dim,')*sizeof(',type,ptr,'));')
+	end
+  end
+ else
+  local t = isbasic(type)
+  line = concatparam(line,' = ')
+  if t == 'state' then
+  	line = concatparam(line, 'tolua_S;')
+  else
+  	--print("t is "..tostring(t)..", ptr is "..tostring(self.ptr))
+  	if t == 'number' and string.find(self.ptr, "%*") then
+  		t = 'userdata'
+  	end
+	if not t and ptr=='' then line = concatparam(line,'*') end
+	line = concatparam(line,'((',self.mod,type)
+	if not t then
+		line = concatparam(line,'*')
+	end
+	line = concatparam(line,') ')
+			if isenum(type) then
+			line = concatparam(line,'(int) ')
+			end
+	local def = 0
+	if self.def ~= '' then
+		def = self.def
+		if (ptr == '' or self.ptr == '&') and not t then
+			def = "(void*)&(const "..type..")"..def
+		end
+	end
+	if t then
+	line = concatparam(line,'tolua_to'..t,'(tolua_S,',narg,',',def,'));')
+	else
+	line = concatparam(line,'tolua_tousertype(tolua_S,',narg,',',def,'));')
+	end
+  end
+ end
+	return line
+end
+
+-- Declare variable
+function classDeclaration:declare (narg)
+ if self.dim ~= '' and tonumber(self.dim)==nil then
+	 output('#ifdef __cplusplus\n')
+		output(self:builddeclaration(narg,true))
+		output('#else\n')
+		output(self:builddeclaration(narg,false))
+	 output('#endif\n')
+	else
+		output(self:builddeclaration(narg,false))
+	end
+end
+
+-- Get parameter value
+function classDeclaration:getarray (narg)
+ if self.dim ~= '' then
+	 local type = gsub(self.type,'const ','')
+  output('  {')
+	 output('#ifndef TOLUA_RELEASE\n')
+  local def; if self.def~='' then def=1 else def=0 end
+		local t = isbasic(type)
+		if (t) then
+   output('   if (!tolua_is'..t..'array(tolua_S,',narg,',',self.dim,',',def,',&tolua_err))')
+		else
+   output('   if (!tolua_isusertypearray(tolua_S,',narg,',"',type,'",',self.dim,',',def,',&tolua_err))')
+		end
+  output('    goto tolua_lerror;')
+  output('   else\n')
+	 output('#endif\n')
+  output('   {')
+  output('    int i;')
+  output('    for(i=0; i<'..self.dim..';i++)')
+  local t = isbasic(type)
+  local ptr = ''
+  if self.ptr~='' then ptr = '*' end
+  output('   ',self.name..'[i] = ')
+  if not t and ptr=='' then output('*') end
+  output('((',type)
+  if not t then
+   output('*')
+  end
+  output(') ')
+  local def = 0
+  if self.def ~= '' then def = self.def end
+  if t then
+   output('tolua_tofield'..t..'(tolua_S,',narg,',i+1,',def,'));')
+  else
+   output('tolua_tofieldusertype(tolua_S,',narg,',i+1,',def,'));')
+  end
+  output('   }')
+  output('  }')
+ end
+end
+
+-- Get parameter value
+function classDeclaration:setarray (narg)
+ if not strfind(self.type,'const%s+') and self.dim ~= '' then
+	 local type = gsub(self.type,'const ','')
+  output('  {')
+  output('   int i;')
+  output('   for(i=0; i<'..self.dim..';i++)')
+  local t,ct = isbasic(type)
+  if t then
+   output('    tolua_pushfield'..t..'(tolua_S,',narg,',i+1,(',ct,')',self.name,'[i]);')
+  else
+   if self.ptr == '' then
+     output('   {')
+     output('#ifdef __cplusplus\n')
+     output('    void* tolua_obj = new',type,'(',self.name,'[i]);')
+     output('    tolua_pushfieldusertype_and_takeownership(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
+     output('#else\n')
+     output('    void* tolua_obj = tolua_copy(tolua_S,(void*)&',self.name,'[i],sizeof(',type,'));')
+     output('    tolua_pushfieldusertype(tolua_S,',narg,',i+1,tolua_obj,"',type,'");')
+     output('#endif\n')
+     output('   }')
+   else
+    output('   tolua_pushfieldusertype(tolua_S,',narg,',i+1,(void*)',self.name,'[i],"',type,'");')
+   end
+  end
+  output('  }')
+ end
+end
+
+-- Free dynamically allocated array
+function classDeclaration:freearray ()
+ if self.dim ~= '' and tonumber(self.dim)==nil then
+	 output('#ifdef __cplusplus\n')
+		output('  delete []',self.name,';')
+	 output('#else\n')
+  output('  free(',self.name,');')
+	 output('#endif\n')
+ end
+end
+
+-- Pass parameter
+function classDeclaration:passpar ()
+ if self.ptr=='&' and not isbasic(self.type) then
+  output('*'..self.name)
+ elseif self.ret=='*' then
+  output('&'..self.name)
+ else
+  output(self.name)
+ end
+end
+
+-- Return parameter value
+function classDeclaration:retvalue ()
+ if self.ret ~= '' then
+  local t,ct = isbasic(self.type)
+  if t and t~='' then
+   output('   tolua_push'..t..'(tolua_S,(',ct,')'..self.name..');')
+  else
+   output('   tolua_pushusertype(tolua_S,(void*)'..self.name..',"',self.type,'");')
+  end
+  return 1
+ end
+ return 0
+end
+
+-- Internal constructor
+function _Declaration (t)
+
+ setmetatable(t,classDeclaration)
+ t:buildnames()
+ t:checkname()
+ t:checktype()
+ local ft = findtype(t.type) or t.type
+ if not isenum(ft) then
+	t.mod, t.type = applytypedef(t.mod, ft)
+ end
+
+ if t.kind=="var" and (string.find(t.mod, "tolua_property%s") or string.find(t.mod, "tolua_property$")) then
+ 	t.mod = string.gsub(t.mod, "tolua_property", "tolua_property__"..get_property_type())
+ end
+
+ return t
+end
+
+-- Constructor
+-- Expects the string declaration.
+-- The kind of declaration can be "var" or "func".
+function Declaration (s,kind,is_parameter)
+
+ -- eliminate spaces if default value is provided
+ s = gsub(s,"%s*=%s*","=")
+ s = gsub(s, "%s*<", "<")
+
+ local defb,tmpdef
+ defb,_,tmpdef = string.find(s, "(=.*)$")
+ if defb then
+ 	s = string.gsub(s, "=.*$", "")
+ else
+ 	tmpdef = ''
+ end
+ if kind == "var" then
+  -- check the form: void
+  if s == '' or s == 'void' then
+   return _Declaration{type = 'void', kind = kind, is_parameter = is_parameter}
+  end
+ end
+
+ -- check the form: mod type*& name
+ local t = split_c_tokens(s,'%*%s*&')
+ if t.n == 2 then
+  if kind == 'func' then
+   error("#invalid function return type: "..s)
+  end
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '*',
+   ret = '&',
+   --type = rebuild_template(m[m.n], tb, timpl),
+   type = m[m.n],
+   mod = concat(m,1,m.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ -- check the form: mod type** name
+ t = split_c_tokens(s,'%*%s*%*')
+ if t.n == 2 then
+  if kind == 'func' then
+   error("#invalid function return type: "..s)
+  end
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '*',
+   ret = '*',
+   --type = rebuild_template(m[m.n], tb, timpl),
+   type = m[m.n],
+   mod = concat(m,1,m.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ -- check the form: mod type& name
+ t = split_c_tokens(s,'&')
+ if t.n == 2 then
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '&',
+   --type = rebuild_template(m[m.n], tb, timpl),
+   type = m[m.n],
+   mod = concat(m,1,m.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ -- check the form: mod type* name
+ local s1 = gsub(s,"(%b\[\])",function (n) return gsub(n,'%*','\1') end)
+ t = split_c_tokens(s1,'%*')
+ if t.n == 2 then
+  t[2] = gsub(t[2],'\1','%*') -- restore * in dimension expression
+  --local m = split(t[1],'%s%s*')
+  local m = split_c_tokens(t[1],'%s+')
+  return _Declaration{
+   name = t[2]..tmpdef,
+   ptr = '*',
+   type = m[m.n],
+   --type = rebuild_template(m[m.n], tb, timpl),
+   mod = concat(m,1,m.n-1)   ,
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+ if kind == 'var' then
+  -- check the form: mod type name
+  --t = split(s,'%s%s*')
+  t = split_c_tokens(s,'%s+')
+  local v
+  if findtype(t[t.n]) then v = create_varname() else v = t[t.n]; t.n = t.n-1 end
+  return _Declaration{
+   name = v..tmpdef,
+   --type = rebuild_template(t[t.n], tb, timpl),
+   type = t[t.n],
+   mod = concat(t,1,t.n-1),
+   is_parameter = is_parameter,
+   kind = kind
+  }
+
+ else -- kind == "func"
+
+  -- check the form: mod type name
+  --t = split(s,'%s%s*')
+  t = split_c_tokens(s,'%s+')
+  local v = t[t.n]  -- last word is the function name
+  local tp,md
+  if t.n>1 then
+   tp = t[t.n-1]
+   md = concat(t,1,t.n-2)
+  end
+  --if tp then tp = rebuild_template(tp, tb, timpl) end
+  return _Declaration{
+   name = v,
+   type = tp,
+   mod = md,
+   is_parameter = is_parameter,
+   kind = kind
+  }
+ end
+
+end
+
Index: code/trunk/src/tolua/lua/define.lua
===================================================================
--- code/trunk/src/tolua/lua/define.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/define.lua	(revision 1755)
@@ -0,0 +1,63 @@
+-- tolua: define class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: define.lua,v 1.2 1999/07/28 22:21:08 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Define class
+-- Represents a numeric const definition
+-- The following filds are stored:
+--   name = constant name
+classDefine = {
+ name = '',
+}
+classDefine.__index = classDefine
+setmetatable(classDefine,classFeature)
+
+-- register define
+function classDefine:register (pre)
+	if not self:check_public_access() then
+		return
+	end
+
+ pre = pre or ''
+ output(pre..'tolua_constant(tolua_S,"'..self.lname..'",'..self.name..');')
+end
+
+-- Print method
+function classDefine:print (ident,close)
+ print(ident.."Define{")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Define (t)
+ setmetatable(t,classDefine)
+ t:buildnames()
+
+ if t.name == '' then
+  error("#invalid define")
+ end
+
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the constant name
+function Define (n)
+ return _Define{
+  name = n
+ }
+end
+
+
Index: code/trunk/src/tolua/lua/doit.lua
===================================================================
--- code/trunk/src/tolua/lua/doit.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/doit.lua	(revision 1755)
@@ -0,0 +1,95 @@
+-- Generate binding code
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- Last update: Apr 2003
+-- $Id: $
+
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+function parse_extra()
+
+	for k,v in ipairs(_extra_parameters or {}) do
+		
+		local b,e,name,value = string.find(v, "^([^=])=(.*)$")
+		if b then
+			_extra_parameters[name] = value
+		else
+			_extra_parameters[v] = true
+		end
+	end
+end
+
+function doit ()
+	-- define package name, if not provided
+	if not flags.n then
+		if flags.f then
+			flags.n = gsub(flags.f,"%..*$","")
+			_,_,flags.n = string.find(flags.n, "([^/\\]*)$")
+		else
+			error("#no package name nor input file provided")
+		end
+	end
+
+	-- parse table with extra paramters
+	parse_extra()
+
+	-- do this after setting the package name
+	if flags['L'] then
+		dofile(flags['L'])
+	end
+
+	-- add cppstring
+	if not flags['S'] then
+		_basic['string'] = 'cppstring'
+		_basic['std::string'] = 'cppstring'
+		_basic_ctype.cppstring = 'const char*'
+	end
+
+	-- proccess package
+	local p  = Package(flags.n,flags.f)
+
+	if flags.p then
+		return        -- only parse
+	end
+
+	if flags.o then
+		local st,msg = writeto(flags.o)
+		if not st then
+			error('#'..msg)
+		end
+	end
+
+	p:decltype()
+	if flags.P then
+		p:print()
+	else
+		p:preamble()
+		p:supcode()
+		p:register()
+		push(p)
+		post_output_hook(p)
+		pop()
+	end
+
+	if flags.o then
+		writeto()
+	end
+
+	-- write header file
+	if not flags.P then
+		if flags.H then
+			local st,msg = writeto(flags.H)
+			if not st then
+				error('#'..msg)
+			end
+			p:header()
+			writeto()
+		end
+	end
+end
+
Index: code/trunk/src/tolua/lua/enumerate.lua
===================================================================
--- code/trunk/src/tolua/lua/enumerate.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/enumerate.lua	(revision 1755)
@@ -0,0 +1,95 @@
+-- tolua: enumerate class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: enumerate.lua,v 1.3 2000/01/24 20:41:15 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Enumerate class
+-- Represents enumeration
+-- The following fields are stored:
+--    {i} = list of constant names
+classEnumerate = {
+}
+classEnumerate.__index = classEnumerate
+setmetatable(classEnumerate,classFeature)
+
+-- register enumeration
+function classEnumerate:register (pre)
+ pre = pre or ''
+ local nspace = getnamespace(classContainer.curr)
+ local i=1
+ while self[i] do
+  output(pre..'tolua_constant(tolua_S,"'..self.lnames[i]..'",'..nspace..self[i]..');')
+  i = i+1
+ end
+end
+
+-- Print method
+function classEnumerate:print (ident,close)
+ print(ident.."Enumerate{")
+ print(ident.." name = "..self.name)
+ local i=1
+ while self[i] do
+  print(ident.." '"..self[i].."'("..self.lnames[i].."),")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Enumerate (t,varname)
+ setmetatable(t,classEnumerate)
+ append(t)
+ appendenum(t)
+	 if varname and varname ~= "" then
+		if t.name ~= "" then
+			Variable(t.name.." "..varname)
+		else
+			local ns = getcurrnamespace()
+			warning("Variable "..ns..varname.." of type <anonymous enum> is declared as read-only")
+			Variable("tolua_readonly int "..varname)
+		end
+	end
+return t
+end
+
+-- Constructor
+-- Expects a string representing the enumerate body
+function Enumerate (n,b,varname)
+	b = string.gsub(b, ",[%s\n]*}", "\n}") -- eliminate last ','
+ local t = split(strsub(b,2,-2),',') -- eliminate braces
+ local i = 1
+ local e = {n=0}
+ while t[i] do
+  local tt = split(t[i],'=')  -- discard initial value
+  e.n = e.n + 1
+  e[e.n] = tt[1]
+  i = i+1
+ end
+ -- set lua names
+ i  = 1
+ e.lnames = {}
+ local ns = getcurrnamespace()
+ while e[i] do
+  local t = split(e[i],'@')
+  e[i] = t[1]
+		if not t[2] then
+		 t[2] = applyrenaming(t[1])
+		end
+  e.lnames[i] = t[2] or t[1]
+  _global_enums[ ns..e[i] ] = (ns..e[i])
+  i = i+1
+ end
+	e.name = n
+	if n ~= "" then
+		Typedef("int "..n)
+	end
+ return _Enumerate(e, varname)
+end
+
Index: code/trunk/src/tolua/lua/feature.lua
===================================================================
--- code/trunk/src/tolua/lua/feature.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/feature.lua	(revision 1755)
@@ -0,0 +1,128 @@
+-- tolua: abstract feature class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Feature class
+-- Represents the base class of all mapped feature.
+classFeature = {
+}
+classFeature.__index = classFeature
+
+-- write support code
+function classFeature:supcode ()
+end
+
+-- output tag
+function classFeature:decltype ()
+end
+
+-- register feature
+function classFeature:register (pre)
+end
+
+-- translate verbatim
+function classFeature:preamble ()
+end
+
+-- check if it is a variable
+function classFeature:isvariable ()
+ return false
+end
+
+-- check if it requires collection
+function classFeature:requirecollection (t)
+ return false
+end
+
+-- build names
+function classFeature:buildnames ()
+ if self.name and self.name~='' then
+  local n = split(self.name,'@')
+  self.name = n[1]
+  if not n[2] then
+   n[2] = applyrenaming(n[1])
+  end
+  self.lname = n[2] or gsub(n[1],"%[.-%]","")
+  self.original_name = self.name
+  self.lname = clean_template(self.lname)
+ end
+ if not self.is_parameter then
+	 self.name = getonlynamespace() .. self.name
+ end
+
+ local parent = classContainer.curr
+ if parent then
+ 	self.access = parent.curr_member_access
+ else
+ end
+end
+
+function classFeature:check_public_access()
+
+	if self.access and self.access ~= 0 then
+		return false
+	end
+
+	local parent = classContainer.curr
+	while parent do
+		if parent.access and parent.access ~= 0 then
+			return false
+		end
+		parent = parent.prox
+	end
+	return true
+end
+
+function clean_template(t)
+
+	return string.gsub(t, "[<>:, %*]", "_")
+end
+
+-- check if feature is inside a container definition
+-- it returns the container class name or nil.
+function classFeature:incontainer (which)
+ if self.parent then
+  local parent = self.parent
+  while parent do
+   if parent.classtype == which then
+    return parent.name
+   end
+   parent = parent.parent
+  end
+ end
+ return nil
+end
+
+function classFeature:inclass ()
+ return self:incontainer('class')
+end
+
+function classFeature:inmodule ()
+ return self:incontainer('module')
+end
+
+function classFeature:innamespace ()
+ return self:incontainer('namespace')
+end
+
+-- return C binding function name based on name
+-- the client specifies a prefix
+function classFeature:cfuncname (n)
+
+ if self.parent then
+  n = self.parent:cfuncname(n)
+ end
+
+  n = string.gsub(n..'_'.. (self.lname or self.name), "[<>:, \.%*&]", "_")
+
+  return n
+end
+
Index: code/trunk/src/tolua/lua/function.lua
===================================================================
--- code/trunk/src/tolua/lua/function.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/function.lua	(revision 1755)
@@ -0,0 +1,737 @@
+-- tolua: function class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: function.lua 1597 2008-03-11 22:25:01Z ice-drezday $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- CEGUILua mod
+-- exception handling
+-- patch from Tov
+-- modded by Lindquist
+exceptionDefs = exceptionDefs or {}
+exceptionDefs["std::exception"]             = {}
+exceptionDefs["std::exception"]["var"]      = "&e"
+exceptionDefs["std::exception"]["c_str"]    = "e.what()"
+
+exceptionDefs["any"]                        = {}
+exceptionDefs["any"]["var"]                 = ""
+exceptionDefs["any"]["c_str"]               = '"Unknown"'
+
+exceptionMessageBufferSize = 512
+
+function outputExceptionError(f,e,errBuf)
+    -- if the exception is not "..." then use the "c_str" info the get a real exception message
+    local messageC_str = true
+    if e.name == "any" then
+        messageC_str = false
+    end
+
+    -- make a default e.ret if empty
+    if not e.ret or e.ret == "" then
+        e.ret = "nil,message"
+    end
+
+    -- create a default exceptionDef if we dont have one
+    if not exceptionDefs[e.name] then
+        exceptionDefs[e.name] = {}
+        exceptionDefs[e.name].var = "&e"
+        exceptionDefs[e.name].c_str = '"Unknown"'
+    end
+
+    -- print catch header
+    local nameToEcho = e.name
+    if nameToEcho == "any" then
+        nameToEcho = "..."
+    end
+    if e.ret == "nil" then
+        output("catch(",nameToEcho," CEGUIDeadException(",exceptionDefs[e.name].var,"))\n{\n")
+	else
+    	output("catch(",nameToEcho,exceptionDefs[e.name].var,")\n{\n")
+	end
+
+    -- if just a nil
+    if e.ret == "nil" then
+        output("return 0;\n")
+    -- if error should be raised
+    elseif string.find(e.ret,"error") then
+        if messageC_str then
+            output("snprintf(errorBuffer,"..exceptionMessageBufferSize..",\"Exception of type '"..e.name.."' was thrown by function '"..f.."'\\nMessage: %s\","..exceptionDefs[e.name].c_str..");\n")
+        else
+            output("snprintf(errorBuffer,"..exceptionMessageBufferSize..",\"Unknown exception thrown by function '"..f.."'\");\n")
+        end
+        output("errorDoIt = true;\n")
+    -- else go through the returns
+    else
+        -- buffer for message
+        if string.find(e.ret,"message") and messageC_str and errBuf == false then
+            output("char errorBuffer["..exceptionMessageBufferSize.."];\n")
+        end
+        local numrets = 0
+        local retpat = "(%w+),?"
+        local i,j,retval = string.find(e.ret,retpat)
+        while i do
+            local code = ""
+
+            -- NIL
+            if retval == "nil" then
+                code = "tolua_pushnil(tolua_S);\n"
+
+            -- MESSAGE
+            elseif retval == "message" then
+                if messageC_str then
+                    code = "snprintf(errorBuffer,"..exceptionMessageBufferSize..",\"Exception of type '"..e.name.."' was thrown by function '"..f.."'\\nMessage: %s\","..exceptionDefs[e.name].c_str..");\ntolua_pushstring(tolua_S,errorBuffer);\n"
+                else
+                    code = "tolua_pushstring(tolua_S,\"Unknown exception thrown by function '"..f.."'\");\n"
+                end
+
+            -- TRUE
+            elseif retval == "true" then
+                code = "tolua_pushboolean(tolua_S, 1);\n"
+
+            -- FALSE
+            elseif retval == "false" then
+                code = "tolua_pushboolean(tolua_S, 0);\n"
+            end
+
+            -- print code for this return value
+            if code ~= "" then
+                output(code)
+                numrets = numrets + 1
+            end
+
+            -- next return value
+            i,j,retval = string.find(e.ret,retpat,j+1)
+        end
+        output("return ",numrets,";\n")
+    end
+
+    -- print catch footer
+    output("}\n")
+end
+
+function outputExceptionCatchBlocks(func,throws,err)
+    for i=1,table.getn(throws) do
+        outputExceptionError(func, throws[i], err)
+    end
+
+    -- if an error should be raised, we do it here
+    if err then
+        output("if (errorDoIt) {\n")
+        output("luaL_error(tolua_S,errorBuffer);\n")
+        output("}\n")
+    end
+end
+
+
+-- Function class
+-- Represents a function or a class method.
+-- The following fields are stored:
+--  mod  = type modifiers
+--  type = type
+--  ptr  = "*" or "&", if representing a pointer or a reference
+--  name = name
+--  lname = lua name
+--  args  = list of argument declarations
+--  const = if it is a method receiving a const "this".
+classFunction = {
+ mod = '',
+ type = '',
+ ptr = '',
+ name = '',
+ args = {n=0},
+ const = '',
+}
+classFunction.__index = classFunction
+setmetatable(classFunction,classFeature)
+
+-- declare tags
+function classFunction:decltype ()
+ self.type = typevar(self.type)
+ if strfind(self.mod,'const') then
+	 self.type = 'const '..self.type
+		self.mod = gsub(self.mod,'const','')
+	end
+ local i=1
+ while self.args[i] do
+  self.args[i]:decltype()
+  i = i+1
+ end
+end
+
+
+-- Write binding function
+-- Outputs C/C++ binding function.
+function classFunction:supcode (local_constructor)
+
+ local overload = strsub(self.cname,-2,-1) - 1  -- indicate overloaded func
+ local nret = 0      -- number of returned values
+ local class = self:inclass()
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class then
+
+ 	if self.name == 'new' and self.parent.flags.pure_virtual then
+ 		-- no constructor for classes with pure virtual methods
+ 		return
+ 	end
+
+ 	if local_constructor then
+		output("/* method: new_local of class ",class," */")
+	else
+		output("/* method:",self.name," of class ",class," */")
+	end
+ else
+  output("/* function:",self.name," */")
+ end
+
+ if local_constructor then
+  output("#ifndef TOLUA_DISABLE_"..self.cname.."_local")
+  output("\nstatic int",self.cname.."_local","(lua_State* tolua_S)")
+ else
+  output("#ifndef TOLUA_DISABLE_"..self.cname)
+  output("\nstatic int",self.cname,"(lua_State* tolua_S)")
+ end
+ output("{")
+
+ -- check types
+	if overload < 0 then
+	 output('#ifndef TOLUA_RELEASE\n')
+	end
+	output(' tolua_Error tolua_err;')
+ output(' if (\n')
+ -- check self
+ local narg
+ if class then narg=2 else narg=1 end
+ if class then
+		local func = 'tolua_isusertype'
+		local type = self.parent.type
+		if self.name=='new' or static~=nil then
+			func = 'tolua_isusertable'
+			type = self.parent.type
+		end
+		if self.const ~= '' then
+			type = "const "..type
+		end
+		output('     !'..func..'(tolua_S,1,"'..type..'",0,&tolua_err) ||\n')
+ end
+ -- check args
+ if self.args[1].type ~= 'void' then
+  local i=1
+  while self.args[i] do
+   local btype = isbasic(self.args[i].type)
+   if btype ~= 'value' and btype ~= 'state' then
+    output('     !'..self.args[i]:outchecktype(narg)..' ||\n')
+   end
+   if btype ~= 'state' then
+	   narg = narg+1
+   end
+   i = i+1
+  end
+ end
+ -- check end of list
+ output('     !tolua_isnoobj(tolua_S,'..narg..',&tolua_err)\n )')
+	output('  goto tolua_lerror;')
+
+ output(' else\n')
+	if overload < 0 then
+	 output('#endif\n')
+	end
+	output(' {')
+
+ -- declare self, if the case
+ local narg
+ if class then narg=2 else narg=1 end
+ if class and self.name~='new' and static==nil then
+  output(' ',self.const,self.parent.type,'*','self = ')
+  output('(',self.const,self.parent.type,'*) ')
+  output('tolua_tousertype(tolua_S,1,0);')
+ elseif static then
+  _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+ -- declare parameters
+ if self.args[1].type ~= 'void' then
+  local i=1
+  while self.args[i] do
+   self.args[i]:declare(narg)
+   if isbasic(self.args[i].type) ~= "state" then
+	   narg = narg+1
+   end
+   i = i+1
+  end
+ end
+
+ -- check self
+ if class and self.name~='new' and static==nil then
+	 output('#ifndef TOLUA_RELEASE\n')
+  output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
+	 output('#endif\n')
+ end
+
+ -- get array element values
+ if class then narg=2 else narg=1 end
+ if self.args[1].type ~= 'void' then
+  local i=1
+  while self.args[i] do
+   self.args[i]:getarray(narg)
+   narg = narg+1
+   i = i+1
+  end
+ end
+
+ --------------------------------------------------
+ -- CEGUILua mod
+ -- init exception handling
+ local throws = false
+ do
+  local pattern = "tolua_throws|.*|"
+  local i,j = string.find(self.mod, pattern)
+  if i then
+   throws = {}
+   -- ensure table is empty.  Used to be: table.setn(throws,0)
+   for x in pairs(throws) do
+     throws[x] = nil
+   end
+   local excepts = string.sub(self.mod, i+12,j)
+   local epattern = "|.-|"
+   local i,j = string.find(excepts, epattern)
+   while i do
+    local e = string.sub(excepts,i+1,j-1)
+    local _,_,name,rest = string.find(e, "([%w:_]+),?(.*)")
+    table.insert(throws,{name=name, ret=rest})
+    i,j = string.find(excepts, epattern, j)
+   end
+   self.mod = string.gsub(self.mod, pattern, "")
+  end
+ end
+ local exRaiseError = false
+ --------------------------------------------------
+
+ local out = string.find(self.mod, "tolua_outside")
+
+ ---------------
+ -- CEGUILua mod
+ -- remove "tolua_outside" from self.mod
+ if out then
+    self.mod = string.gsub(self.mod, "tolua_outside", "")
+ end
+
+ -- call function
+ if class and self.name=='delete' then
+  output('  delete self;')
+ elseif class and self.name == 'operator&[]' then
+  if flags['1'] then -- for compatibility with tolua5 ?
+	output('  self->operator[](',self.args[1].name,'-1) = ',self.args[2].name,';')
+  else
+    output('  self->operator[](',self.args[1].name,') = ',self.args[2].name,';')
+  end
+ else
+  -- CEGUILua mod begin- throws
+  if throws then
+    for i=1,table.getn(throws) do
+        if string.find(throws[i].ret, "error") then
+            output("char errorBuffer["..exceptionMessageBufferSize.."];\n")
+            output("bool errorDoIt = false;\n")
+            exRaiseError = true
+            break
+        end
+    end
+    output("try\n")
+  end
+  -- CEGUILua mod end - throws
+  output('  {')
+  if self.type ~= '' and self.type ~= 'void' then
+   output('  ',self.mod,self.type,self.ptr,'tolua_ret = ')
+   output('(',self.mod,self.type,self.ptr,') ')
+  else
+   output('  ')
+  end
+  if class and self.name=='new' then
+   output('new',self.type,'(')
+  elseif class and static then
+	if out then
+		output(self.name,'(')
+	else
+		output(class..'::'..self.name,'(')
+	end
+  elseif class then
+	if out then
+		output(self.name,'(')
+	else
+	  if self.cast_operator then
+	  	output('static_cast<',self.mod,self.type,self.ptr,'>(*self')
+	  else
+		output('self->'..self.name,'(')
+	  end
+	end
+  else
+   output(self.name,'(')
+  end
+
+  if out and not static then
+  	output('self')
+	if self.args[1] and self.args[1].name ~= '' then
+		output(',')
+	end
+  end
+  -- write parameters
+  local i=1
+  while self.args[i] do
+   self.args[i]:passpar()
+   i = i+1
+   if self.args[i] then
+    output(',')
+   end
+  end
+
+  if class and self.name == 'operator[]' and flags['1'] then
+	output('-1);')
+  else
+	output(');')
+  end
+
+  -- return values
+  if self.type ~= '' and self.type ~= 'void' then
+   nret = nret + 1
+   local t,ct = isbasic(self.type)
+   if t then
+   	if self.cast_operator and _basic_raw_push[t] then
+		output('   ',_basic_raw_push[t],'(tolua_S,(',ct,')tolua_ret);')
+   	else
+	    output('   tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
+	end
+   else
+			 t = self.type
+			 new_t = string.gsub(t, "const%s+", "")
+    if self.ptr == '' then
+     output('   {')
+     output('#ifdef __cplusplus\n')
+     output('    void* tolua_obj = new',new_t,'(tolua_ret);')
+     output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+     output('#else\n')
+     output('    void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
+     output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+     output('#endif\n')
+     output('   }')
+    elseif self.ptr == '&' then
+     output('   tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
+    else
+    	if local_constructor then
+	  output('   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
+    	else
+		     output('   tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
+	    end
+    end
+   end
+  end
+  local i=1
+  while self.args[i] do
+   nret = nret + self.args[i]:retvalue()
+   i = i+1
+  end
+  output('  }')
+
+  ------------------------------------------
+  -- CEGUILua mod
+  -- finish exception handling
+  -- catch
+  if throws then
+   outputExceptionCatchBlocks(self.name, throws, exRaiseError)
+  end
+  ------------------------------------------
+
+  -- set array element values
+  if class then narg=2 else narg=1 end
+  if self.args[1].type ~= 'void' then
+   local i=1
+   while self.args[i] do
+    self.args[i]:setarray(narg)
+    narg = narg+1
+    i = i+1
+   end
+  end
+
+  -- free dynamically allocated array
+  if self.args[1].type ~= 'void' then
+   local i=1
+   while self.args[i] do
+    self.args[i]:freearray()
+    i = i+1
+   end
+  end
+ end
+
+ output(' }')
+ output(' return '..nret..';')
+
+ -- call overloaded function or generate error
+	if overload < 0 then
+
+		output('#ifndef TOLUA_RELEASE\n')
+		output('tolua_lerror:\n')
+		output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
+		output(' return 0;')
+		output('#endif\n')
+	else
+		local _local = ""
+		if local_constructor then
+			_local = "_local"
+		end
+		output('tolua_lerror:\n')
+		output(' return '..strsub(self.cname,1,-3)..format("%02d",overload).._local..'(tolua_S);')
+	end
+ output('}')
+ output('#endif //#ifndef TOLUA_DISABLE\n')
+ output('\n')
+
+	-- recursive call to write local constructor
+	if class and self.name=='new' and not local_constructor then
+
+		self:supcode(1)
+	end
+
+end
+
+
+-- register function
+function classFunction:register (pre)
+
+	if not self:check_public_access() then
+		return
+	end
+
+ 	if self.name == 'new' and self.parent.flags.pure_virtual then
+ 		-- no constructor for classes with pure virtual methods
+ 		return
+ 	end
+
+ output(pre..'tolua_function(tolua_S,"'..self.lname..'",'..self.cname..');')
+  if self.name == 'new' then
+	  output(pre..'tolua_function(tolua_S,"new_local",'..self.cname..'_local);')
+	  output(pre..'tolua_function(tolua_S,".call",'..self.cname..'_local);')
+	  --output(' tolua_set_call_event(tolua_S,'..self.cname..'_local, "'..self.parent.type..'");')
+  end
+end
+
+-- Print method
+function classFunction:print (ident,close)
+ print(ident.."Function{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." const = '"..self.const.."',")
+ print(ident.." cname = '"..self.cname.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." args = {")
+ local i=1
+ while self.args[i] do
+  self.args[i]:print(ident.."  ",",")
+  i = i+1
+ end
+ print(ident.." }")
+ print(ident.."}"..close)
+end
+
+-- check if it returns an object by value
+function classFunction:requirecollection (t)
+	local r = false
+	if self.type ~= '' and not isbasic(self.type) and self.ptr=='' then
+		local type = gsub(self.type,"%s*const%s+","")
+	 t[type] = "tolua_collect_" .. clean_template(type)
+	 r = true
+	end
+	local i=1
+	while self.args[i] do
+		r = self.args[i]:requirecollection(t) or r
+		i = i+1
+	end
+	return r
+end
+
+-- determine lua function name overload
+function classFunction:overload ()
+ return self.parent:overload(self.lname)
+end
+
+
+function param_object(par) -- returns true if the parameter has an object as its default value
+
+	if not string.find(par, '=') then return false end -- it has no default value
+
+	local _,_,def = string.find(par, "=(.*)$")
+
+	if string.find(par, "|") then -- a list of flags
+
+		return true
+	end
+
+	if string.find(par, "%*") then -- it's a pointer with a default value
+
+		if string.find(par, '=%s*new') then -- it's a pointer with an instance as default parameter.. is that valid?
+			return true
+		end
+		return false -- default value is 'NULL' or something
+	end
+
+
+	if string.find(par, "[%(&]") then
+		return true
+	end -- default value is a constructor call (most likely for a const reference)
+
+	--if string.find(par, "&") then
+
+	--	if string.find(def, ":") or string.find(def, "^%s*new%s+") then
+
+	--		-- it's a reference with default to something like Class::member, or 'new Class'
+	--		return true
+	--	end
+	--end
+
+	return false -- ?
+end
+
+function strip_last_arg(all_args, last_arg) -- strips the default value from the last argument
+
+	local _,_,s_arg = string.find(last_arg, "^([^=]+)")
+	last_arg = string.gsub(last_arg, "([%%%(%)])", "%%%1");
+	all_args = string.gsub(all_args, "%s*,%s*"..last_arg.."%s*%)%s*$", ")")
+	return all_args, s_arg
+end
+
+
+
+-- Internal constructor
+function _Function (t)
+ setmetatable(t,classFunction)
+
+ if t.const ~= 'const' and t.const ~= '' then
+  error("#invalid 'const' specification")
+ end
+
+ append(t)
+ if t:inclass() then
+ --print ('t.name is '..t.name..', parent.name is '..t.parent.name)
+  if string.gsub(t.name, "%b<>", "") == string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then
+   t.name = 'new'
+   t.lname = 'new'
+   t.parent._new = true
+   t.type = t.parent.name
+   t.ptr = '*'
+  elseif string.gsub(t.name, "%b<>", "") == '~'..string.gsub(t.parent.original_name or t.parent.name, "%b<>", "") then
+   t.name = 'delete'
+   t.lname = 'delete'
+   t.parent._delete = true
+  end
+ end
+ t.cname = t:cfuncname("tolua")..t:overload(t)
+ return t
+end
+
+-- Constructor
+-- Expects three strings: one representing the function declaration,
+-- another representing the argument list, and the third representing
+-- the "const" or empty string.
+function Function (d,a,c)
+ --local t = split(strsub(a,2,-2),',') -- eliminate braces
+ --local t = split_params(strsub(a,2,-2))
+
+	if not flags['W'] and string.find(a, "%.%.%.%s*%)") then
+
+		warning("Functions with variable arguments (`...') are not supported. Ignoring "..d..a..c)
+		return nil
+	end
+
+
+ local i=1
+ local l = {n=0}
+
+ 	a = string.gsub(a, "%s*([%(%)])%s*", "%1")
+	local t,strip,last = strip_pars(strsub(a,2,-2));
+	if strip then
+		--local ns = string.sub(strsub(a,1,-2), 1, -(string.len(last)+1))
+		local ns = join(t, ",", 1, last-1)
+
+		ns = "("..string.gsub(ns, "%s*,%s*$", "")..')'
+		--ns = strip_defaults(ns)
+
+		Function(d, ns, c)
+		for i=1,last do
+			t[i] = string.gsub(t[i], "=.*$", "")
+		end
+	end
+
+ while t[i] do
+  l.n = l.n+1
+  l[l.n] = Declaration(t[i],'var',true)
+  i = i+1
+ end
+ local f = Declaration(d,'func')
+ f.args = l
+ f.const = c
+ return _Function(f)
+end
+
+function join(t, sep, first, last)
+
+	first = first or 1
+	last = last or table.getn(t)
+	local lsep = ""
+	local ret = ""
+	local loop = false
+	for i = first,last do
+
+		ret = ret..lsep..t[i]
+		lsep = sep
+		loop = true
+	end
+	if not loop then
+		return ""
+	end
+
+	return ret
+end
+
+function strip_pars(s)
+
+	local t = split_c_tokens(s, ',')
+	local strip = false
+	local last
+
+	for i=t.n,1,-1 do
+
+		if not strip and param_object(t[i]) then
+			last = i
+			strip = true
+		end
+		--if strip then
+		--	t[i] = string.gsub(t[i], "=.*$", "")
+		--end
+	end
+
+	return t,strip,last
+
+end
+
+function strip_defaults(s)
+
+	s = string.gsub(s, "^%(", "")
+	s = string.gsub(s, "%)$", "")
+
+	local t = split_c_tokens(s, ",")
+	local sep, ret = "",""
+	for i=1,t.n do
+		t[i] = string.gsub(t[i], "=.*$", "")
+		ret = ret..sep..t[i]
+		sep = ","
+	end
+
+	return "("..ret..")"
+end
+
+
Index: code/trunk/src/tolua/lua/module.lua
===================================================================
--- code/trunk/src/tolua/lua/module.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/module.lua	(revision 1755)
@@ -0,0 +1,68 @@
+-- tolua: module class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Module class
+-- Represents module.
+-- The following fields are stored:
+--    {i} = list of objects in the module.
+classModule = {
+ classtype = 'module'
+}
+classModule.__index = classModule
+setmetatable(classModule,classContainer)
+
+-- register module
+function classModule:register (pre)
+ pre = pre or ''
+ push(self)
+ output(pre..'tolua_module(tolua_S,"'..self.name..'",',self:hasvar(),');')
+ output(pre..'tolua_beginmodule(tolua_S,"'..self.name..'");')
+ local i=1
+ while self[i] do
+  self[i]:register(pre..' ')
+  i = i+1
+ end
+ output(pre..'tolua_endmodule(tolua_S);')
+	pop()
+end
+
+-- Print method
+function classModule:print (ident,close)
+ print(ident.."Module{")
+ print(ident.." name = '"..self.name.."';")
+ local i=1
+ while self[i] do
+  self[i]:print(ident.." ",",")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Module (t)
+ setmetatable(t,classModule)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects two string representing the module name and body.
+function Module (n,b)
+ local t = _Module(_Container{name=n})
+ push(t)
+ t:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+ return t
+end
+
+
Index: code/trunk/src/tolua/lua/namespace.lua
===================================================================
--- code/trunk/src/tolua/lua/namespace.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/namespace.lua	(revision 1755)
@@ -0,0 +1,52 @@
+-- tolua: namespace class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 2003
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Namespace class
+-- Represents a namesapce definition.
+-- Stores the following fields:
+--    name = class name
+--    {i}  = list of members
+classNamespace = {
+ classtype = 'namespace',
+ name = '',
+}
+classNamespace.__index = classNamespace
+setmetatable(classNamespace,classModule)
+
+-- Print method
+function classNamespace:print (ident,close)
+ print(ident.."Namespace{")
+ print(ident.." name = '"..self.name.."',")
+ local i=1
+ while self[i] do
+  self[i]:print(ident.." ",",")
+  i = i+1
+ end
+ print(ident.."}"..close)
+end
+
+-- Internal constructor
+function _Namespace (t)
+ setmetatable(t,classNamespace)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects the name and the body of the namespace.
+function Namespace (n,b)
+ local c = _Namespace(_Container{name=n})
+ push(c)
+ c:parse(strsub(b,2,strlen(b)-1)) -- eliminate braces
+ pop()
+end
+
Index: code/trunk/src/tolua/lua/operator.lua
===================================================================
--- code/trunk/src/tolua/lua/operator.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/operator.lua	(revision 1755)
@@ -0,0 +1,214 @@
+-- tolua: operator class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Operator class
+-- Represents an operator function or a class operator method.
+-- It stores the same fields as functions do plus:
+--  kind = set of character representing the operator (as it appers in C++ code)
+classOperator = {
+ kind = '',
+}
+classOperator.__index = classOperator
+setmetatable(classOperator,classFunction)
+
+-- table to transform operator kind into the appropriate tag method name
+_TM = {['+'] = 'add',
+       ['-'] = 'sub',
+       ['*'] = 'mul',
+       ['/'] = 'div',
+       ['<'] = 'lt',
+       ['<='] = 'le',
+       ['=='] = 'eq',
+       ['[]'] = 'geti',
+       ['&[]'] = 'seti',
+       --['->'] = 'flechita',
+      }
+
+
+-- Print method
+function classOperator:print (ident,close)
+ print(ident.."Operator{")
+ print(ident.." kind  = '"..self.kind.."',")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ print(ident.." const = '"..self.const.."',")
+ print(ident.." cname = '"..self.cname.."',")
+ print(ident.." lname = '"..self.lname.."',")
+ print(ident.." args = {")
+ local i=1
+ while self.args[i] do
+  self.args[i]:print(ident.."  ",",")
+  i = i+1
+ end
+ print(ident.." }")
+ print(ident.."}"..close)
+end
+
+function classOperator:supcode_tmp()
+
+	if not _TM[self.kind] then
+		return classFunction.supcode(self)
+	end
+
+	-- no overload, no parameters, always inclass
+	output("/* method:",self.name," of class ",self:inclass()," */")
+
+	output("#ifndef TOLUA_DISABLE_"..self.cname)
+	output("\nstatic int",self.cname,"(lua_State* tolua_S)")
+
+	if overload < 0 then
+	 output('#ifndef TOLUA_RELEASE\n')
+	end
+	output(' tolua_Error tolua_err;')
+	output(' if (\n')
+	-- check self
+	output('     !'..'tolua_isusertype(tolua_S,1,"'..self.parent.type..'",0,&tolua_err) ||\n')
+	output('     !tolua_isnoobj(tolua_S,2,&tolua_err)\n )')
+	output('  goto tolua_lerror;')
+
+	output(' else\n')
+	output('#endif\n') -- tolua_release
+	output(' {')
+
+	-- declare self
+	output(' ',self.const,self.parent.type,'*','self = ')
+	output('(',self.const,self.parent.type,'*) ')
+	output('tolua_tousertype(tolua_S,1,0);')
+
+	-- check self
+	output('#ifndef TOLUA_RELEASE\n')
+	output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in function \''..self.name..'\'",NULL);');
+	output('#endif\n')
+
+	-- cast self
+	output('  ',self.mod,self.type,self.ptr,'tolua_ret = ')
+	output('(',self.mod,self.type,self.ptr,')(*self);')
+
+	-- return value
+	local t,ct = isbasic(self.type)
+	if t then
+		output('   tolua_push'..t..'(tolua_S,(',ct,')tolua_ret);')
+	else
+		t = self.type
+		new_t = string.gsub(t, "const%s+", "")
+		if self.ptr == '' then
+			output('   {')
+			output('#ifdef __cplusplus\n')
+			output('    void* tolua_obj = new',new_t,'(tolua_ret);')
+			output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+			output('#else\n')
+			output('    void* tolua_obj = tolua_copy(tolua_S,(void*)&tolua_ret,sizeof(',t,'));')
+			output('    tolua_pushusertype_and_takeownership(tolua_S,tolua_obj,"',t,'");')
+			output('#endif\n')
+			output('   }')
+		elseif self.ptr == '&' then
+			output('   tolua_pushusertype(tolua_S,(void*)&tolua_ret,"',t,'");')
+		else
+			if local_constructor then
+				output('   tolua_pushusertype_and_takeownership(tolua_S,(void *)tolua_ret,"',t,'");')
+			else
+				output('   tolua_pushusertype(tolua_S,(void*)tolua_ret,"',t,'");')
+			end
+		end
+	end
+
+	output('  }')
+	output(' return 1;')
+
+	output('#ifndef TOLUA_RELEASE\n')
+	output('tolua_lerror:\n')
+	output(' tolua_error(tolua_S,"#ferror in function \''..self.lname..'\'.",&tolua_err);')
+	output(' return 0;')
+	output('#endif\n')
+
+
+	output('}')
+	output('#endif //#ifndef TOLUA_DISABLE\n')
+	output('\n')
+end
+
+-- Internal constructor
+function _Operator (t)
+ setmetatable(t,classOperator)
+
+ if t.const ~= 'const' and t.const ~= '' then
+  error("#invalid 'const' specification")
+ end
+
+ append(t)
+ if not t:inclass() then
+  error("#operator can only be defined as class member")
+ end
+
+ --t.name = t.name .. "_" .. (_TM[t.kind] or t.kind)
+ t.cname = t:cfuncname("tolua")..t:overload(t)
+ t.name = "operator" .. t.kind  -- set appropriate calling name
+ return t
+end
+
+-- Constructor
+function Operator (d,k,a,c)
+
+	local op_k = string.gsub(k, "^%s*", "")
+	op_k = string.gsub(k, "%s*$", "")
+	--if string.find(k, "^[%w_:%d<>%*%&]+$") then
+	if d == "operator" and k ~= '' then
+
+		d = k.." operator"
+	elseif not _TM[op_k] then
+
+		if flags['W'] then
+			error("tolua: no support for operator" .. f.kind)
+		else
+			warning("No support for operator "..op_k..", ignoring")
+			return nil
+		end
+	end
+
+	local ref = ''
+ local t = split_c_tokens(strsub(a,2,strlen(a)-1),',') -- eliminate braces
+ local i=1
+ local l = {n=0}
+ while t[i] do
+  l.n = l.n+1
+  l[l.n] = Declaration(t[i],'var')
+  i = i+1
+ end
+ if k == '[]' then
+	 local _
+	 _, _, ref = strfind(d,'(&)')
+  d = gsub(d,'&','')
+ elseif k=='&[]' then
+  l.n = l.n+1
+  l[l.n] = Declaration(d,'var')
+  l[l.n].name = 'tolua_value'
+ end
+ local f = Declaration(d,'func')
+ if k == '[]' and (l[1]==nil or isbasic(l[1].type)~='number') then
+  error('operator[] can only be defined for numeric index.')
+ end
+ f.args = l
+ f.const = c
+ f.kind = op_k
+ f.lname = "."..(_TM[f.kind] or f.kind)
+ if not _TM[f.kind] then
+ 	f.cast_operator = true
+ end
+ if f.kind == '[]' and ref=='&' and f.const~='const' then
+  Operator(d,'&'..k,a,c) 	-- create correspoding set operator
+ end
+ return _Operator(f)
+end
+
+
Index: code/trunk/src/tolua/lua/package.lua
===================================================================
--- code/trunk/src/tolua/lua/package.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/package.lua	(revision 1755)
@@ -0,0 +1,316 @@
+-- tolua: package class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Package class
+-- Represents the whole package being bound.
+-- The following fields are stored:
+--    {i} = list of objects in the package.
+classPackage = {
+ classtype = 'package'
+}
+classPackage.__index = classPackage
+setmetatable(classPackage,classContainer)
+
+-- Print method
+function classPackage:print ()
+ print("Package: "..self.name)
+ local i=1
+ while self[i] do
+  self[i]:print("","")
+  i = i+1
+ end
+end
+
+function classPackage:preprocess ()
+
+ -- avoid preprocessing embedded Lua code
+ local L = {}
+ self.code = gsub(self.code,"\n%s*%$%[","\1") -- deal with embedded lua code
+ self.code = gsub(self.code,"\n%s*%$%]","\2")
+ self.code = gsub(self.code,"(%b\1\2)",       function (c)
+                                               tinsert(L,c)
+                                               return "\n#["..getn(L).."]#"
+                                              end)
+ -- avoid preprocessing embedded C code
+ local C = {}
+ self.code = gsub(self.code,"\n%s*%$%<","\3") -- deal with embedded C code
+ self.code = gsub(self.code,"\n%s*%$%>","\4")
+ self.code = gsub(self.code,"(%b\3\4)",       function (c)
+                                               tinsert(C,c)
+                                               return "\n#<"..getn(C)..">#"
+                                              end)
+ -- avoid preprocessing embedded C code
+ self.code = gsub(self.code,"\n%s*%$%{","\5") -- deal with embedded C code
+ self.code = gsub(self.code,"\n%s*%$%}","\6")
+ self.code = gsub(self.code,"(%b\5\6)",       function (c)
+                                               tinsert(C,c)
+                                               return "\n#<"..getn(C)..">#"
+                                              end)
+
+ --self.code = gsub(self.code,"\n%s*#[^d][^\n]*\n", "\n\n") -- eliminate preprocessor directives that don't start with 'd'
+ self.code = gsub(self.code,"\n[ \t]*#[ \t]*[^d%<%[]", "\n//") -- eliminate preprocessor directives that don't start with 'd'
+
+ -- avoid preprocessing verbatim lines
+ local V = {}
+ self.code = gsub(self.code,"\n(%s*%$[^%[%]][^\n]*)",function (v)
+                                               tinsert(V,v)
+                                               return "\n#"..getn(V).."#"
+                                              end)
+
+ -- perform global substitution
+
+ self.code = gsub(self.code,"(//[^\n]*)","")     -- eliminate C++ comments
+ self.code = gsub(self.code,"/%*","\1")
+ self.code = gsub(self.code,"%*/","\2")
+ self.code = gsub(self.code,"%b\1\2","")
+ self.code = gsub(self.code,"\1","/%*")
+ self.code = gsub(self.code,"\2","%*/")
+ self.code = gsub(self.code,"%s*@%s*","@") -- eliminate spaces beside @
+ self.code = gsub(self.code,"%s?inline(%s)","%1") -- eliminate 'inline' keyword
+ --self.code = gsub(self.code,"%s?extern(%s)","%1") -- eliminate 'extern' keyword
+ --self.code = gsub(self.code,"%s?virtual(%s)","%1") -- eliminate 'virtual' keyword
+ --self.code = gsub(self.code,"public:","") -- eliminate 'public:' keyword
+ self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ self.code = gsub(self.code,"([^%w_])void%s*%*","%1_userdata ") -- substitute 'void*'
+ self.code = gsub(self.code,"([^%w_])char%s*%*","%1_cstring ")  -- substitute 'char*'
+ self.code = gsub(self.code,"([^%w_])lua_State%s*%*","%1_lstate ")  -- substitute 'lua_State*'
+
+ -- restore embedded Lua code
+ self.code = gsub(self.code,"%#%[(%d+)%]%#",function (n)
+                                              return L[tonumber(n)]
+                                            end)
+ -- restore embedded C code
+ self.code = gsub(self.code,"%#%<(%d+)%>%#",function (n)
+                                             return C[tonumber(n)]
+                                            end)
+ -- restore verbatim lines
+ self.code = gsub(self.code,"%#(%d+)%#",function (n)
+                                         return V[tonumber(n)]
+                                        end)
+
+ self.code = string.gsub(self.code, "\n%s*%$([^\n]+)", function (l)
+											Verbatim(l.."\n")
+											return "\n"
+										  end)
+end
+
+-- translate verbatim
+function classPackage:preamble ()
+ output('/*\n')
+ output('** Lua binding: '..self.name..'\n')
+ output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
+ output('*/\n\n')
+
+	output('#ifndef __cplusplus\n')
+	output('#include "stdlib.h"\n')
+	output('#endif\n')
+	output('#include "string.h"\n\n')
+ output('#include "tolua++.h"\n\n')
+
+ if not flags.h then
+--  local temp = string.reverse(flags.H)
+--  local start1, end1 = string.find(temp, '/')
+--  local start2, end2 = string.find(temp, '\\')
+--  local res
+--  if not start1 == nil then
+--   if not start2 == nil then
+--    if start1 > start2 then
+--     res = string.sub(temp, 1, start2)
+--    else
+--     res = string.sub(temp, 1, start1)
+--    end
+--   else
+--    res = string.sub(temp, 1, start1)
+--   end
+--  elseif not start2 == nil then
+--   res = string.sub(temp, 1, start2)
+--  end
+--  res = string.reverse(res)
+  output('#include "tolua_bind.h"')
+  output('\n')
+ end
+
+ local i=1
+ while self[i] do
+  self[i]:preamble()
+  i = i+1
+ end
+
+	if self:requirecollection(_collect) then
+		output('\n')
+		output('/* function to release collected object via destructor */')
+		output('#ifdef __cplusplus\n')
+		for i,v in pairs(_collect) do
+		 output('\nstatic int '..v..' (lua_State* tolua_S)')
+			output('{')
+			output(' '..i..'* self = ('..i..'*) tolua_tousertype(tolua_S,1,0);')
+			output('	delete self;')
+			output('	return 0;')
+			output('}')
+		end
+		output('#endif\n\n')
+	end
+
+ output('\n')
+ output('/* function to register type */')
+ output('static void tolua_reg_types (lua_State* tolua_S)')
+ output('{')
+ foreach(_usertype,function(n,v) output(' tolua_usertype(tolua_S,"',v,'");') end)
+	if flags.t then
+		output("#ifndef Mtolua_typeid\n#define Mtolua_typeid(L,TI,T)\n#endif\n")
+		foreach(_usertype,function(n,v) output(' Mtolua_typeid(tolua_S,typeid(',v,'), "',v,'");') end)
+	end
+ output('}')
+ output('\n')
+end
+
+-- register package
+-- write package open function
+function classPackage:register (pre)
+ pre = pre or ''
+ push(self)
+ output(pre.."/* Open function */")
+ output(pre.."int tolua_"..self.name.."_open (lua_State* tolua_S)")
+ output(pre.."{")
+ output(pre.." tolua_open(tolua_S);")
+ output(pre.." tolua_reg_types(tolua_S);")
+ output(pre.." tolua_module(tolua_S,NULL,",self:hasvar(),");")
+ output(pre.." tolua_beginmodule(tolua_S,NULL);")
+ local i=1
+ while self[i] do
+  self[i]:register(pre.."  ")
+  i = i+1
+ end
+ output(pre.." tolua_endmodule(tolua_S);")
+ output(pre.." return 1;")
+ output(pre.."}")
+
+ output("\n\n")
+ output("#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501\n");
+ output(pre.."int luaopen_"..self.name.." (lua_State* tolua_S) {")
+ output(pre.." return tolua_"..self.name.."_open(tolua_S);")
+ output(pre.."};")
+ output("#endif\n\n")
+
+	pop()
+end
+
+-- write header file
+function classPackage:header ()
+ output('/*\n') output('** Lua binding: '..self.name..'\n')
+ output('** Generated automatically by '..TOLUA_VERSION..' on '..date()..'.\n')
+ output('*/\n\n')
+
+ if not flags.h then
+  output('#include "../'..self.name..'Prereqs.h"\n')
+  output('/* Exported function */')
+  output('_'..self.name..'Export int  tolua_'..self.name..'_open (lua_State* tolua_S);')
+  output('\n')
+ end
+end
+
+-- Internal constructor
+function _Package (self)
+ setmetatable(self,classPackage)
+ return self
+end
+
+-- Parse C header file with tolua directives
+-- *** Thanks to Ariel Manzur for fixing bugs in nested directives ***
+function extract_code(fn,s)
+	local code = '\n$#include "'..fn..'"\n'
+	s= "\n" .. s .. "\n" -- add blank lines as sentinels
+	local _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n")
+	while e do
+		t = strlower(t)
+		if t == "begin" then
+			_,e,c = strfind(s,"(.-)\n[^\n]*[Tt][Oo][Ll][Uu][Aa]_[Ee][Nn][Dd][^\n]*\n",e)
+			if not e then
+			 tolua_error("Unbalanced 'tolua_begin' directive in header file")
+			end
+		end
+		code = code .. c .. "\n"
+	 _,e,c,t = strfind(s, "\n([^\n]-)[Tt][Oo][Ll][Uu][Aa]_([^%s]*)[^\n]*\n",e)
+	end
+	return code
+end
+
+-- Constructor
+-- Expects the package name, the file extension, and the file text.
+function Package (name,fn)
+ local ext = "pkg"
+
+ -- open input file, if any
+ if fn then
+  local st, msg = readfrom(flags.f)
+  if not st then
+   error('#'..msg)
+  end
+		local _; _, _, ext = strfind(fn,".*%.(.*)$")
+ end
+ local code = "\n" .. read('*a')
+	if ext == 'h' or ext == 'hpp' then
+	 code = extract_code(fn,code)
+	end
+
+ -- close file
+ if fn then
+  readfrom()
+ end
+
+ -- deal with include directive
+ local nsubst
+ repeat
+  code,nsubst = gsub(code,'\n%s*%$(.)file%s*"(.-)"([^\n]*)\n',
+		function (kind,fn,extra)
+			local _, _, ext = strfind(fn,".*%.(.*)$")
+			local fp,msg = openfile(fn,'r')
+			if not fp then
+				error('#'..msg..': '..fn)
+			end
+			local s = read(fp,'*a')
+			closefile(fp)
+			if kind == 'c' or kind == 'h' then
+				return extract_code(fn,s)
+			elseif kind == 'p' then
+				return "\n\n" .. s
+			elseif kind == 'l' then
+				return "\n$[--##"..fn.."\n" .. s .. "\n$]\n"
+			elseif kind == 'i' then
+				local t = {code=s}
+				extra = string.gsub(extra, "^%s*,%s*", "")
+				local pars = split_c_tokens(extra, ",")
+				include_file_hook(t, fn, unpack(pars))
+				return "\n\n" .. t.code
+			else
+				error('#Invalid include directive (use $cfile, $pfile, $lfile or $ifile)')
+			end
+		end)
+ until nsubst==0
+
+ -- deal with renaming directive
+ repeat -- I don't know why this is necesary
+	code,nsubst = gsub(code,'\n%s*%$renaming%s*(.-)%s*\n', function (r) appendrenaming(r) return "\n" end)
+ until nsubst == 0
+
+ local t = _Package(_Container{name=name, code=code})
+ push(t)
+ preprocess_hook(t)
+ t:preprocess()
+ preparse_hook(t)
+ t:parse(t.code)
+ pop()
+ return t
+end
+
+
Index: code/trunk/src/tolua/lua/typedef.lua
===================================================================
--- code/trunk/src/tolua/lua/typedef.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/typedef.lua	(revision 1755)
@@ -0,0 +1,71 @@
+-- tolua: typedef class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Typedef class
+-- Represents a type synonym.
+-- The 'de facto' type replaces the typedef before the
+-- remaining code is parsed.
+-- The following fields are stored:
+--   utype = typedef name
+--   type = 'the facto' type
+--   mod = modifiers to the 'de facto' type
+classTypedef = {
+ utype = '',
+ mod = '',
+ type = ''
+}
+classTypedef.__index = classTypedef
+
+-- Print method
+function classTypedef:print (ident,close)
+ print(ident.."Typedef{")
+ print(ident.." utype = '"..self.utype.."',")
+ print(ident.." mod = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.."}"..close)
+end
+
+-- Return it's not a variable
+function classTypedef:isvariable ()
+ return false
+end
+
+-- Internal constructor
+function _Typedef (t)
+ setmetatable(t,classTypedef)
+ t.type = resolve_template_types(t.type)
+ appendtypedef(t)
+ return t
+end
+
+-- Constructor
+-- Expects one string representing the type definition.
+function Typedef (s)
+ if strfind(string.gsub(s, '%b<>', ''),'[%*&]') then
+  tolua_error("#invalid typedef: pointers (and references) are not supported")
+ end
+ local o = {mod = ''}
+ if string.find(s, "[<>]") then
+ 	_,_,o.type,o.utype = string.find(s, "^%s*([^<>]+%b<>[^%s]*)%s+(.-)$")
+ else
+ 	local t = split(gsub(s,"%s%s*"," ")," ")
+ 	o = {
+	  utype = t[t.n],
+	  type = t[t.n-1],
+	  mod = concat(t,1,t.n-2),
+	 }
+ end
+ return _Typedef(o)
+end
+
+
Index: code/trunk/src/tolua/lua/variable.lua
===================================================================
--- code/trunk/src/tolua/lua/variable.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/variable.lua	(revision 1755)
@@ -0,0 +1,295 @@
+-- tolua: variable class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+-- Variable class
+-- Represents a extern variable or a public member of a class.
+-- Stores all fields present in a declaration.
+classVariable = {
+ _get = {},   -- mapped get functions
+ _set = {},   -- mapped set functions
+}
+classVariable.__index = classVariable
+setmetatable(classVariable,classDeclaration)
+
+-- Print method
+function classVariable:print (ident,close)
+ print(ident.."Variable{")
+ print(ident.." mod  = '"..self.mod.."',")
+ print(ident.." type = '"..self.type.."',")
+ print(ident.." ptr  = '"..self.ptr.."',")
+ print(ident.." name = '"..self.name.."',")
+ if self.dim then print(ident.." dim = '"..self.dim.."',") end
+ print(ident.." def  = '"..self.def.."',")
+ print(ident.." ret  = '"..self.ret.."',")
+ print(ident.."}"..close)
+end
+
+-- Generates C function name
+function classVariable:cfuncname (prefix)
+ local parent = ""
+ local unsigned = ""
+ local ptr = ""
+
+ local p = self:inmodule() or self:innamespace() or self:inclass()
+
+ if p then
+ 	if self.parent.classtype == 'class' then
+		parent = "_" .. self.parent.type
+	else
+	  parent = "_" .. p
+	end
+ end
+
+ if strfind(self.mod,"(unsigned)") then
+  unsigned = "_unsigned"
+ end
+
+ if self.ptr == "*" then ptr = "_ptr"
+ elseif self.ptr == "&" then ptr = "_ref"
+ end
+
+ local name =  prefix .. parent .. unsigned .. "_" .. gsub(self.lname or self.name,".*::","") .. ptr
+
+	name = clean_template(name)
+ return name
+
+end
+
+-- check if it is a variable
+function classVariable:isvariable ()
+ return true
+end
+
+-- get variable value
+function classVariable:getvalue (class,static, prop_get)
+
+	local name
+	if prop_get then
+
+		name = prop_get.."()"
+	else
+		name = self.name
+	end
+
+	if class and static then
+	 return self.parent.type..'::'..name
+	elseif class then
+	 return 'self->'..name
+	else
+	 return name
+	end
+end
+
+-- get variable pointer value
+function classVariable:getpointervalue (class,static)
+ if class and static then
+  return class..'::p'
+ elseif class then
+  return 'self->p'
+ else
+  return 'p'
+ end
+end
+
+-- Write binding functions
+function classVariable:supcode ()
+
+ local class = self:inclass()
+
+	local prop_get,prop_set
+	if string.find(self.mod, 'tolua_property') then
+
+		_,_,type = string.find(self.mod, "tolua_property__([^%s]*)")
+		type = type or "default"
+		prop_get,prop_set = get_property_methods(type, self.name)
+		self.mod = string.gsub(self.mod, "tolua_property[^%s]*", "")
+	end
+
+ -- get function ------------------------------------------------
+ if class then
+  output("/* get function:",self.name," of class ",class," */")
+ else
+  output("/* get function:",self.name," */")
+ end
+ self.cgetname = self:cfuncname("tolua_get")
+ output("#ifndef TOLUA_DISABLE_"..self.cgetname)
+ output("\nstatic int",self.cgetname,"(lua_State* tolua_S)")
+ output("{")
+
+ -- declare self, if the case
+ local _,_,static = strfind(self.mod,'^%s*(static)')
+ if class and static==nil then
+  output(' ',self.parent.type,'*','self = ')
+  output('(',self.parent.type,'*) ')
+  output('tolua_tousertype(tolua_S,1,0);')
+ elseif static then
+  _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+ end
+
+
+ -- check self value
+ if class and static==nil then
+	 output('#ifndef TOLUA_RELEASE\n')
+  output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+		output('#endif\n')
+ end
+
+ -- return value
+ if string.find(self.mod, 'tolua_inherits') then
+ 	output('#ifdef __cplusplus\n')
+	output('  tolua_pushusertype(tolua_S,(void*)static_cast<'..self.type..'*>(self), "',self.type,'");')
+	output('#else\n')
+	output('  tolua_pushusertype(tolua_S,(void*)(('..self.type..'*)self), "',self.type,'");')
+	output('#endif\n')
+ else
+	local t,ct = isbasic(self.type)
+	if t then
+		output('  tolua_push'..t..'(tolua_S,(',ct,')'..self:getvalue(class,static,prop_get)..');')
+	else
+		t = self.type
+		if self.ptr == '&' or self.ptr == '' then
+			output('  tolua_pushusertype(tolua_S,(void*)&'..self:getvalue(class,static,prop_get)..',"',t,'");')
+		else
+			output('  tolua_pushusertype(tolua_S,(void*)'..self:getvalue(class,static,prop_get)..',"',t,'");')
+		end
+	end
+ end
+ output(' return 1;')
+ output('}')
+ output('#endif //#ifndef TOLUA_DISABLE\n')
+ output('\n')
+
+ -- set function ------------------------------------------------
+ if not (strfind(self.type,'const%s+') or string.find(self.mod, 'tolua_readonly') or string.find(self.mod, 'tolua_inherits'))  then
+  if class then
+   output("/* set function:",self.name," of class ",class," */")
+  else
+   output("/* set function:",self.name," */")
+  end
+  self.csetname = self:cfuncname("tolua_set")
+  output("#ifndef TOLUA_DISABLE_"..self.csetname)
+  output("\nstatic int",self.csetname,"(lua_State* tolua_S)")
+  output("{")
+
+  -- declare self, if the case
+  if class and static==nil then
+   output(' ',self.parent.type,'*','self = ')
+   output('(',self.parent.type,'*) ')
+   output('tolua_tousertype(tolua_S,1,0);')
+   -- check self value
+		end
+  -- check types
+		output('#ifndef TOLUA_RELEASE\n')
+		output('  tolua_Error tolua_err;')
+  if class and static==nil then
+   output('  if (!self) tolua_error(tolua_S,"invalid \'self\' in accessing variable \''..self.name..'\'",NULL);');
+  elseif static then
+   _,_,self.mod = strfind(self.mod,'^%s*static%s%s*(.*)')
+  end
+
+  -- check variable type
+  output('  if (!'..self:outchecktype(2)..')')
+  output('   tolua_error(tolua_S,"#vinvalid type in variable assignment.",&tolua_err);')
+		output('#endif\n')
+
+  -- assign value
+		local def = 0
+		if self.def ~= '' then def = self.def end
+		if self.type == 'char*' and self.dim ~= '' then -- is string
+		 output(' strncpy(')
+			if class and static then
+				output(self.parent.type..'::'..self.name)
+			elseif class then
+				output('self->'..self.name)
+			else
+				output(self.name)
+			end
+			output(',tolua_tostring(tolua_S,2,',def,'),',self.dim,'-1);')
+		else
+			local ptr = ''
+			if self.ptr~='' then ptr = '*' end
+			output(' ')
+			local name = prop_set or self.name
+			if class and static then
+				output(self.parent.type..'::'..name)
+			elseif class then
+				output('self->'..name)
+			else
+				output(name)
+			end
+			local t = isbasic(self.type)
+			if prop_set then
+				output('(')
+			else
+				output(' = ')
+			end
+			if not t and ptr=='' then output('*') end
+			output('((',self.mod,self.type)
+			if not t then
+				output('*')
+			end
+			output(') ')
+			if t then
+				if isenum(self.type) then
+					output('(int) ')
+				end
+				output('tolua_to'..t,'(tolua_S,2,',def,'))')
+			else
+				output('tolua_tousertype(tolua_S,2,',def,'))')
+			end
+			if prop_set then
+				output(")")
+			end
+			output(";")
+		end
+  output(' return 0;')
+  output('}')
+  output('#endif //#ifndef TOLUA_DISABLE\n')
+  output('\n')
+ end
+
+end
+
+function classVariable:register (pre)
+
+	if not self:check_public_access() then
+		return
+	end
+ pre = pre or ''
+ local parent = self:inmodule() or self:innamespace() or self:inclass()
+ if not parent then
+  if classVariable._warning==nil then
+   warning("Mapping variable to global may degrade performance")
+   classVariable._warning = 1
+  end
+ end
+ if self.csetname then
+  output(pre..'tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..','..self.csetname..');')
+ else
+  output(pre..'tolua_variable(tolua_S,"'..self.lname..'",'..self.cgetname..',NULL);')
+ end
+end
+
+-- Internal constructor
+function _Variable (t)
+ setmetatable(t,classVariable)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the variable declaration.
+function Variable (s)
+ return _Variable (Declaration(s,'var'))
+end
+
+
Index: code/trunk/src/tolua/lua/verbatim.lua
===================================================================
--- code/trunk/src/tolua/lua/verbatim.lua	(revision 1755)
+++ code/trunk/src/tolua/lua/verbatim.lua	(revision 1755)
@@ -0,0 +1,78 @@
+-- tolua: verbatim class
+-- Written by Waldemar Celes
+-- TeCGraf/PUC-Rio
+-- Jul 1998
+-- $Id: verbatim.lua,v 1.3 2000/01/24 20:41:16 celes Exp $
+
+-- This code is free software; you can redistribute it and/or modify it.
+-- The software provided hereunder is on an "as is" basis, and
+-- the author has no obligation to provide maintenance, support, updates,
+-- enhancements, or modifications.
+
+
+
+-- Verbatim class
+-- Represents a line translated directed to the binding file.
+-- The following filds are stored:
+--   line = line text
+classVerbatim = {
+ line = '',
+	cond = nil,    -- condition: where to generate the code (s=suport, r=register)
+}
+classVerbatim.__index = classVerbatim
+setmetatable(classVerbatim,classFeature)
+
+-- preamble verbatim
+function classVerbatim:preamble ()
+ if self.cond == '' then
+  write(self.line)
+ end
+end
+
+-- support code
+function classVerbatim:supcode ()
+ if strfind(self.cond,'s') then
+  write(self.line)
+  write('\n')
+ end
+end
+
+-- register code
+function classVerbatim:register (pre)
+ if strfind(self.cond,'r') then
+  write(self.line)
+ end
+end
+
+
+-- Print method
+function classVerbatim:print (ident,close)
+ print(ident.."Verbatim{")
+ print(ident.." line = '"..self.line.."',")
+ print(ident.."}"..close)
+end
+
+
+-- Internal constructor
+function _Verbatim (t)
+ setmetatable(t,classVerbatim)
+ append(t)
+ return t
+end
+
+-- Constructor
+-- Expects a string representing the text line
+function Verbatim (l,cond)
+ if strsub(l,1,1) == "'" then
+  l = strsub(l,2)
+ elseif strsub(l,1,1) == '$' then
+  cond = 'sr'       -- generates in both suport and register fragments
+  l = strsub(l,2)
+ end
+ return _Verbatim {
+  line = l,
+  cond = cond or '',
+ }
+end
+
+
Index: code/trunk/src/tolua/tolua++.h
===================================================================
--- code/trunk/src/tolua/tolua++.h	(revision 1754)
+++ code/trunk/src/tolua/tolua++.h	(revision 1755)
@@ -17,7 +17,32 @@
 #define TOLUA_H
 
+/* original code */
+/*
 #ifndef TOLUA_API
 #define TOLUA_API extern
 #endif
+*/
+
+/********************************
+******* ORXONOX CHANGES *********
+********************************/
+
+#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined( TOLUA_STATIC_BUILD )
+#  ifdef TOLUA_SHARED_BUILD
+#    define TOLUA_API __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define TOLUA_API
+#    else
+#      define TOLUA_API __declspec(dllimport)
+#    endif
+#  endif
+#else
+#  define TOLUA_API extern
+#endif
+
+/********************************
+****** END ORXONOX CHANGES ******
+********************************/
 
 #define TOLUA_VERSION "tolua++-1.0.92"
Index: code/trunk/src/tolua/tolua-5.0.pkg
===================================================================
--- code/trunk/src/tolua/tolua-5.0.pkg	(revision 1755)
+++ code/trunk/src/tolua/tolua-5.0.pkg	(revision 1755)
@@ -0,0 +1,29 @@
+$lfile "../../src/tolua/lua/compat.lua"
+$lfile "../../src/tolua/lua/basic.lua"
+$lfile "../../src/tolua/lua/feature.lua"
+$lfile "../../src/tolua/lua/verbatim.lua"
+$lfile "../../src/tolua/lua/code.lua"
+$lfile "../../src/tolua/lua/typedef.lua"
+$lfile "../../src/tolua/lua/container.lua"
+$lfile "../../src/tolua/lua/package.lua"
+$lfile "../../src/tolua/lua/module.lua"
+$lfile "../../src/tolua/lua/namespace.lua"
+$lfile "../../src/tolua/lua/define.lua"
+$lfile "../../src/tolua/lua/enumerate.lua"
+$lfile "../../src/tolua/lua/declaration.lua"
+$lfile "../../src/tolua/lua/variable.lua"
+$lfile "../../src/tolua/lua/array.lua"
+$lfile "../../src/tolua/lua/function.lua"
+$lfile "../../src/tolua/lua/operator.lua"
+$lfile "../../src/tolua/lua/class.lua"
+$lfile "../../src/tolua/lua/clean.lua"
+$lfile "../../src/tolua/lua/doit.lua"
+
+$[
+local err,msg = pcall(doit)
+if not err then
+ local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
+ tolua_error(msg,label)
+ print(debug.traceback())
+end
+$]
Index: code/trunk/src/tolua/tolua-5.1.pkg
===================================================================
--- code/trunk/src/tolua/tolua-5.1.pkg	(revision 1755)
+++ code/trunk/src/tolua/tolua-5.1.pkg	(revision 1755)
@@ -0,0 +1,30 @@
+$lfile "../../src/tolua/lua/compat-5.1.lua"
+$lfile "../../src/tolua/lua/compat.lua"
+$lfile "../../src/tolua/lua/basic.lua"
+$lfile "../../src/tolua/lua/feature.lua"
+$lfile "../../src/tolua/lua/verbatim.lua"
+$lfile "../../src/tolua/lua/code.lua"
+$lfile "../../src/tolua/lua/typedef.lua"
+$lfile "../../src/tolua/lua/container.lua"
+$lfile "../../src/tolua/lua/package.lua"
+$lfile "../../src/tolua/lua/module.lua"
+$lfile "../../src/tolua/lua/namespace.lua"
+$lfile "../../src/tolua/lua/define.lua"
+$lfile "../../src/tolua/lua/enumerate.lua"
+$lfile "../../src/tolua/lua/declaration.lua"
+$lfile "../../src/tolua/lua/variable.lua"
+$lfile "../../src/tolua/lua/array.lua"
+$lfile "../../src/tolua/lua/function.lua"
+$lfile "../../src/tolua/lua/operator.lua"
+$lfile "../../src/tolua/lua/class.lua"
+$lfile "../../src/tolua/lua/clean.lua"
+$lfile "../../src/tolua/lua/doit.lua"
+
+$[
+local err,msg = pcall(doit)
+if not err then
+ local _,_,label,msg = strfind(msg,"(.-:.-:%s*)(.*)")
+ tolua_error(msg,label)
+ print(debug.traceback())
+end
+$]
Index: code/trunk/src/tolua/toluabind.c
===================================================================
--- code/trunk/src/tolua/toluabind.c	(revision 1754)
+++ code/trunk/src/tolua/toluabind.c	(revision 1755)
@@ -12,5 +12,5 @@
 
 /* Exported function */
-TOLUA_API int  tolua_tolua_open (lua_State* tolua_S);
+int  tolua_tolua_open (lua_State* tolua_S);
 
 
@@ -21,5 +21,5 @@
 
 /* Open function */
-TOLUA_API int tolua_tolua_open (lua_State* tolua_S)
+int tolua_tolua_open (lua_State* tolua_S)
 {
  tolua_open(tolua_S);
@@ -7622,5 +7622,5 @@
 
 #if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
- TOLUA_API int luaopen_tolua (lua_State* tolua_S) {
+ int luaopen_tolua (lua_State* tolua_S) {
  return tolua_tolua_open(tolua_S);
 };
Index: code/trunk/src/tolua/toluabind_orxonox.c
===================================================================
--- code/trunk/src/tolua/toluabind_orxonox.c	(revision 1755)
+++ code/trunk/src/tolua/toluabind_orxonox.c	(revision 1755)
@@ -0,0 +1,5719 @@
+/*
+** Lua binding: tolua
+** Generated automatically by tolua++-1.0.92 on 09/10/08 00:32:19.
+*/
+
+#ifndef __cplusplus
+#include "stdlib.h"
+#endif
+#include "string.h"
+
+#include "tolua++.h"
+
+/* Exported function */
+TOLUA_API int  tolua_tolua_open (lua_State* tolua_S);
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+}
+
+/* Open function */
+TOLUA_API int tolua_tolua_open (lua_State* tolua_S)
+{
+ tolua_open(tolua_S);
+ tolua_reg_types(tolua_S);
+ tolua_module(tolua_S,NULL,0);
+ tolua_beginmodule(tolua_S,NULL);
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100,
+     40, 95, 86, 69, 82, 83, 73, 79, 78, 44, 32, 34, 53, 37, 46,
+     48, 34, 41, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     10,101,110,100, 10,108,111, 99, 97,108, 32,102,117,110, 99,
+    116,105,111,110, 32,112,112, 95,100,111,102,105,108,101, 40,
+    112, 97,116,104, 41, 10,108,111, 99, 97,108, 32,108,111, 97,
+    100,101,100, 32, 61, 32,102, 97,108,115,101, 10,108,111, 99,
+     97,108, 32,103,101,116,102,105,108,101, 32, 61, 32,102,117,
+    110, 99,116,105,111,110, 40, 41, 10,105,102, 32,108,111, 97,
+    100,101,100, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     10,101,108,115,101, 10,108,111, 99, 97,108, 32,102,105,108,
+    101, 44,101,114,114, 32, 61, 32,105,111, 46,111,112,101,110,
+     40,112, 97,116,104, 41, 10,105,102, 32,110,111,116, 32,102,
+    105,108,101, 32,116,104,101,110, 10,101,114,114,111,114, 40,
+     34,101,114,114,111,114, 32,108,111, 97,100,105,110,103, 32,
+    102,105,108,101, 32, 34, 46, 46,112, 97,116,104, 46, 46, 34,
+     58, 32, 34, 46, 46,101,114,114, 41, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32,114,101,116, 32, 61, 32,102,105,108,101,
+     58,114,101, 97,100, 40, 34, 42, 97, 34, 41, 10,102,105,108,
+    101, 58, 99,108,111,115,101, 40, 41, 10,114,101,116, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,114,101,
+    116, 44, 32, 34, 37, 46, 37, 46, 37, 46, 37,115, 42, 37, 41,
+     34, 44, 32, 34, 46, 46, 46, 41, 32,108,111, 99, 97,108, 32,
+     97,114,103, 32, 61, 32,123,110, 61,115,101,108,101, 99,116,
+     40, 39, 35, 39, 44, 32, 46, 46, 46, 41, 44, 32, 46, 46, 46,
+    125, 59, 34, 41, 10,108,111, 97,100,101,100, 32, 61, 32,116,
+    114,117,101, 10,114,101,116,117,114,110, 32,114,101,116, 10,
+    101,110,100, 10,101,110,100, 10,108,111, 99, 97,108, 32,102,
+     32, 61, 32,108,111, 97,100, 40,103,101,116,102,105,108,101,
+     44, 32,112, 97,116,104, 41, 10,114,101,116,117,114,110, 32,
+    102, 40, 41, 10,101,110,100, 10,111,108,100, 95,100,111,102,
+    105,108,101, 32, 61, 32,100,111,102,105,108,101, 10,100,111,
+    102,105,108,101, 32, 61, 32,112,112, 95,100,111,102,105,108,
+    101, 10,108,111, 99, 97,108, 32,111,103,115,117, 98, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 10,108,111,
+     99, 97,108, 32,102,117,110, 99,116,105,111,110, 32, 99,111,
+    109,112,103,115,117, 98, 40, 97, 44, 98, 44, 99, 44,100, 41,
+     10,105,102, 32,116,121,112,101, 40, 99, 41, 32, 61, 61, 32,
+     34,102,117,110, 99,116,105,111,110, 34, 32,116,104,101,110,
+     10,108,111, 99, 97,108, 32,111, 99, 32, 61, 32, 99, 10, 99,
+     32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40, 46, 46,
+     46, 41, 32,114,101,116,117,114,110, 32,111, 99, 40, 46, 46,
+     46, 41, 32,111,114, 32, 39, 39, 32,101,110,100, 10,101,110,
+    100, 10,114,101,116,117,114,110, 32,111,103,115,117, 98, 40,
+     97, 44, 98, 44, 99, 44,100, 41, 10,101,110,100, 10,115,116,
+    114,105,110,103, 46,114,101,112,108, 32, 61, 32,111,103,115,
+    117, 98, 10,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/compat-5.1.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,114, 97,119,116,121,112,101, 32, 61, 32,116,121,112,101,
+     10,102,117,110, 99,116,105,111,110, 32,100,111, 95, 32, 40,
+    102, 44, 32,101,114,114, 41, 10,105,102, 32,110,111,116, 32,
+    102, 32,116,104,101,110, 32,112,114,105,110,116, 40,101,114,
+    114, 41, 59, 32,114,101,116,117,114,110, 32,101,110,100, 10,
+    108,111, 99, 97,108, 32, 97, 44, 98, 32, 61, 32,112, 99, 97,
+    108,108, 40,102, 41, 10,105,102, 32,110,111,116, 32, 97, 32,
+    116,104,101,110, 32,112,114,105,110,116, 40, 98, 41, 59, 32,
+    114,101,116,117,114,110, 32,110,105,108, 10,101,108,115,101,
+     32,114,101,116,117,114,110, 32, 98, 32,111,114, 32,116,114,
+    117,101, 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,
+    116,105,111,110, 32,100,111,115,116,114,105,110,103, 40,115,
+     41, 32,114,101,116,117,114,110, 32,100,111, 95, 40,108,111,
+     97,100,115,116,114,105,110,103, 40,115, 41, 41, 32,101,110,
+    100, 10,108,111, 99, 97,108, 32,116, 97, 98, 32, 61, 32,116,
+     97, 98,108,101, 10,102,111,114,101, 97, 99,104, 32, 61, 32,
+    116, 97, 98, 46,102,111,114,101, 97, 99,104, 10,102,111,114,
+    101, 97, 99,104,105, 32, 61, 32,116, 97, 98, 46,102,111,114,
+    101, 97, 99,104,105, 10,103,101,116,110, 32, 61, 32,116, 97,
+     98, 46,103,101,116,110, 10,116,105,110,115,101,114,116, 32,
+     61, 32,116, 97, 98, 46,105,110,115,101,114,116, 10,116,114,
+    101,109,111,118,101, 32, 61, 32,116, 97, 98, 46,114,101,109,
+    111,118,101, 10,115,111,114,116, 32, 61, 32,116, 97, 98, 46,
+    115,111,114,116, 10,108,111, 99, 97,108, 32,100, 98,103, 32,
+     61, 32,100,101, 98,117,103, 10,103,101,116,105,110,102,111,
+     32, 61, 32,100, 98,103, 46,103,101,116,105,110,102,111, 10,
+    103,101,116,108,111, 99, 97,108, 32, 61, 32,100, 98,103, 46,
+    103,101,116,108,111, 99, 97,108, 10,115,101,116, 99, 97,108,
+    108,104,111,111,107, 32, 61, 32,102,117,110, 99,116,105,111,
+    110, 32, 40, 41, 32,101,114,114,111,114, 34, 96,115,101,116,
+     99, 97,108,108,104,111,111,107, 39, 32,105,115, 32,100,101,
+    112,114,101, 99, 97,116,101,100, 34, 32,101,110,100, 10,115,
+    101,116,108,105,110,101,104,111,111,107, 32, 61, 32,102,117,
+    110, 99,116,105,111,110, 32, 40, 41, 32,101,114,114,111,114,
+     34, 96,115,101,116,108,105,110,101,104,111,111,107, 39, 32,
+    105,115, 32,100,101,112,114,101, 99, 97,116,101,100, 34, 32,
+    101,110,100, 10,115,101,116,108,111, 99, 97,108, 32, 61, 32,
+    100, 98,103, 46,115,101,116,108,111, 99, 97,108, 10,108,111,
+     99, 97,108, 32,109, 97,116,104, 32, 61, 32,109, 97,116,104,
+     10, 97, 98,115, 32, 61, 32,109, 97,116,104, 46, 97, 98,115,
+     10, 97, 99,111,115, 32, 61, 32,102,117,110, 99,116,105,111,
+    110, 32, 40,120, 41, 32,114,101,116,117,114,110, 32,109, 97,
+    116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97, 99,111,
+    115, 40,120, 41, 41, 32,101,110,100, 10, 97,115,105,110, 32,
+     61, 32,102,117,110, 99,116,105,111,110, 32, 40,120, 41, 32,
+    114,101,116,117,114,110, 32,109, 97,116,104, 46,100,101,103,
+     40,109, 97,116,104, 46, 97,115,105,110, 40,120, 41, 41, 32,
+    101,110,100, 10, 97,116, 97,110, 32, 61, 32,102,117,110, 99,
+    116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,110,
+     32,109, 97,116,104, 46,100,101,103, 40,109, 97,116,104, 46,
+     97,116, 97,110, 40,120, 41, 41, 32,101,110,100, 10, 97,116,
+     97,110, 50, 32, 61, 32,102,117,110, 99,116,105,111,110, 32,
+     40,120, 44,121, 41, 32,114,101,116,117,114,110, 32,109, 97,
+    116,104, 46,100,101,103, 40,109, 97,116,104, 46, 97,116, 97,
+    110, 50, 40,120, 44,121, 41, 41, 32,101,110,100, 10, 99,101,
+    105,108, 32, 61, 32,109, 97,116,104, 46, 99,101,105,108, 10,
+     99,111,115, 32, 61, 32,102,117,110, 99,116,105,111,110, 32,
+     40,120, 41, 32,114,101,116,117,114,110, 32,109, 97,116,104,
+     46, 99,111,115, 40,109, 97,116,104, 46,114, 97,100, 40,120,
+     41, 41, 32,101,110,100, 10,100,101,103, 32, 61, 32,109, 97,
+    116,104, 46,100,101,103, 10,101,120,112, 32, 61, 32,109, 97,
+    116,104, 46,101,120,112, 10,102,108,111,111,114, 32, 61, 32,
+    109, 97,116,104, 46,102,108,111,111,114, 10,102,114,101,120,
+    112, 32, 61, 32,109, 97,116,104, 46,102,114,101,120,112, 10,
+    108,100,101,120,112, 32, 61, 32,109, 97,116,104, 46,108,100,
+    101,120,112, 10,108,111,103, 32, 61, 32,109, 97,116,104, 46,
+    108,111,103, 10,108,111,103, 49, 48, 32, 61, 32,109, 97,116,
+    104, 46,108,111,103, 49, 48, 10,109, 97,120, 32, 61, 32,109,
+     97,116,104, 46,109, 97,120, 10,109,105,110, 32, 61, 32,109,
+     97,116,104, 46,109,105,110, 10,109,111,100, 32, 61, 32,109,
+     97,116,104, 46,109,111,100, 10, 80, 73, 32, 61, 32,109, 97,
+    116,104, 46,112,105, 10,114, 97,100, 32, 61, 32,109, 97,116,
+    104, 46,114, 97,100, 10,114, 97,110,100,111,109, 32, 61, 32,
+    109, 97,116,104, 46,114, 97,110,100,111,109, 10,114, 97,110,
+    100,111,109,115,101,101,100, 32, 61, 32,109, 97,116,104, 46,
+    114, 97,110,100,111,109,115,101,101,100, 10,115,105,110, 32,
+     61, 32,102,117,110, 99,116,105,111,110, 32, 40,120, 41, 32,
+    114,101,116,117,114,110, 32,109, 97,116,104, 46,115,105,110,
+     40,109, 97,116,104, 46,114, 97,100, 40,120, 41, 41, 32,101,
+    110,100, 10,115,113,114,116, 32, 61, 32,109, 97,116,104, 46,
+    115,113,114,116, 10,116, 97,110, 32, 61, 32,102,117,110, 99,
+    116,105,111,110, 32, 40,120, 41, 32,114,101,116,117,114,110,
+     32,109, 97,116,104, 46,116, 97,110, 40,109, 97,116,104, 46,
+    114, 97,100, 40,120, 41, 41, 32,101,110,100, 10,108,111, 99,
+     97,108, 32,115,116,114, 32, 61, 32,115,116,114,105,110,103,
+     10,115,116,114, 98,121,116,101, 32, 61, 32,115,116,114, 46,
+     98,121,116,101, 10,115,116,114, 99,104, 97,114, 32, 61, 32,
+    115,116,114, 46, 99,104, 97,114, 10,115,116,114,102,105,110,
+    100, 32, 61, 32,115,116,114, 46,102,105,110,100, 10,102,111,
+    114,109, 97,116, 32, 61, 32,115,116,114, 46,102,111,114,109,
+     97,116, 10,103,115,117, 98, 32, 61, 32,115,116,114, 46,103,
+    115,117, 98, 10,115,116,114,108,101,110, 32, 61, 32,115,116,
+    114, 46,108,101,110, 10,115,116,114,108,111,119,101,114, 32,
+     61, 32,115,116,114, 46,108,111,119,101,114, 10,115,116,114,
+    114,101,112, 32, 61, 32,115,116,114, 46,114,101,112, 10,115,
+    116,114,115,117, 98, 32, 61, 32,115,116,114, 46,115,117, 98,
+     10,115,116,114,117,112,112,101,114, 32, 61, 32,115,116,114,
+     46,117,112,112,101,114, 10, 99,108,111, 99,107, 32, 61, 32,
+    111,115, 46, 99,108,111, 99,107, 10,100, 97,116,101, 32, 61,
+     32,111,115, 46,100, 97,116,101, 10,100,105,102,102,116,105,
+    109,101, 32, 61, 32,111,115, 46,100,105,102,102,116,105,109,
+    101, 10,101,120,101, 99,117,116,101, 32, 61, 32,111,115, 46,
+    101,120,101, 99,117,116,101, 10,101,120,105,116, 32, 61, 32,
+    111,115, 46,101,120,105,116, 10,103,101,116,101,110,118, 32,
+     61, 32,111,115, 46,103,101,116,101,110,118, 10,114,101,109,
+    111,118,101, 32, 61, 32,111,115, 46,114,101,109,111,118,101,
+     10,114,101,110, 97,109,101, 32, 61, 32,111,115, 46,114,101,
+    110, 97,109,101, 10,115,101,116,108,111, 99, 97,108,101, 32,
+     61, 32,111,115, 46,115,101,116,108,111, 99, 97,108,101, 10,
+    116,105,109,101, 32, 61, 32,111,115, 46,116,105,109,101, 10,
+    116,109,112,110, 97,109,101, 32, 61, 32,111,115, 46,116,109,
+    112,110, 97,109,101, 10,103,101,116,103,108,111, 98, 97,108,
+     32, 61, 32,102,117,110, 99,116,105,111,110, 32, 40,110, 41,
+     32,114,101,116,117,114,110, 32, 95, 71, 91,110, 93, 32,101,
+    110,100, 10,115,101,116,103,108,111, 98, 97,108, 32, 61, 32,
+    102,117,110, 99,116,105,111,110, 32, 40,110, 44,118, 41, 32,
+     95, 71, 91,110, 93, 32, 61, 32,118, 32,101,110,100, 10,108,
+    111, 99, 97,108, 32,105,111, 44, 32,116, 97, 98, 32, 61, 32,
+    105,111, 44, 32,116, 97, 98,108,101, 10, 95, 83, 84, 68, 73,
+     78, 32, 61, 32,105,111, 46,115,116,100,105,110, 10, 95, 83,
+     84, 68, 69, 82, 82, 32, 61, 32,105,111, 46,115,116,100,101,
+    114,114, 10, 95, 83, 84, 68, 79, 85, 84, 32, 61, 32,105,111,
+     46,115,116,100,111,117,116, 10, 95, 73, 78, 80, 85, 84, 32,
+     61, 32,105,111, 46,115,116,100,105,110, 10, 95, 79, 85, 84,
+     80, 85, 84, 32, 61, 32,105,111, 46,115,116,100,111,117,116,
+     10,115,101,101,107, 32, 61, 32,105,111, 46,115,116,100,105,
+    110, 46,115,101,101,107, 10,116,109,112,102,105,108,101, 32,
+     61, 32,105,111, 46,116,109,112,102,105,108,101, 10, 99,108,
+    111,115,101,102,105,108,101, 32, 61, 32,105,111, 46, 99,108,
+    111,115,101, 10,111,112,101,110,102,105,108,101, 32, 61, 32,
+    105,111, 46,111,112,101,110, 10,102,117,110, 99,116,105,111,
+    110, 32,102,108,117,115,104, 32, 40,102, 41, 10,105,102, 32,
+    102, 32,116,104,101,110, 32,102, 58,102,108,117,115,104, 40,
+     41, 10,101,108,115,101, 32, 95, 79, 85, 84, 80, 85, 84, 58,
+    102,108,117,115,104, 40, 41, 10,101,110,100, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,114,101, 97,100,102,
+    114,111,109, 32, 40,110, 97,109,101, 41, 10,105,102, 32,110,
+     97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101,110,
+     10,108,111, 99, 97,108, 32,102, 44, 32,101,114,114, 44, 32,
+     99,111,100, 32, 61, 32,105,111, 46, 99,108,111,115,101, 40,
+     95, 73, 78, 80, 85, 84, 41, 10, 95, 73, 78, 80, 85, 84, 32,
+     61, 32,105,111, 46,115,116,100,105,110, 10,114,101,116,117,
+    114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10,
+    101,108,115,101, 10,108,111, 99, 97,108, 32,102, 44, 32,101,
+    114,114, 44, 32, 99,111,100, 32, 61, 32,105,111, 46,111,112,
+    101,110, 40,110, 97,109,101, 44, 32, 34,114, 34, 41, 10, 95,
+     73, 78, 80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 73,
+     78, 80, 85, 84, 10,114,101,116,117,114,110, 32,102, 44, 32,
+    101,114,114, 44, 32, 99,111,100, 10,101,110,100, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32,119,114,105,116,
+    101,116,111, 32, 40,110, 97,109,101, 41, 10,105,102, 32,110,
+     97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101,110,
+     10,108,111, 99, 97,108, 32,102, 44, 32,101,114,114, 44, 32,
+     99,111,100, 32, 61, 32,105,111, 46, 99,108,111,115,101, 40,
+     95, 79, 85, 84, 80, 85, 84, 41, 10, 95, 79, 85, 84, 80, 85,
+     84, 32, 61, 32,105,111, 46,115,116,100,111,117,116, 10,114,
+    101,116,117,114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,
+    111,100, 10,101,108,115,101, 10,108,111, 99, 97,108, 32,102,
+     44, 32,101,114,114, 44, 32, 99,111,100, 32, 61, 32,105,111,
+     46,111,112,101,110, 40,110, 97,109,101, 44, 32, 34,119, 34,
+     41, 10, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,102, 32,111,
+    114, 32, 95, 79, 85, 84, 80, 85, 84, 10,114,101,116,117,114,
+    110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10,101,
+    110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 97,112,112,101,110,100,116,111, 32, 40,110, 97,109,101,
+     41, 10,108,111, 99, 97,108, 32,102, 44, 32,101,114,114, 44,
+     32, 99,111,100, 32, 61, 32,105,111, 46,111,112,101,110, 40,
+    110, 97,109,101, 44, 32, 34, 97, 34, 41, 10, 95, 79, 85, 84,
+     80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 79, 85, 84,
+     80, 85, 84, 10,114,101,116,117,114,110, 32,102, 44, 32,101,
+    114,114, 44, 32, 99,111,100, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32,114,101, 97,100, 32, 40, 46, 46, 46,
+     41, 10,108,111, 99, 97,108, 32,102, 32, 61, 32, 95, 73, 78,
+     80, 85, 84, 10,105,102, 32,114, 97,119,116,121,112,101, 40,
+     97,114,103, 91, 49, 93, 41, 32, 61, 61, 32, 39,117,115,101,
+    114,100, 97,116, 97, 39, 32,116,104,101,110, 10,102, 32, 61,
+     32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103,
+     44, 32, 49, 41, 10,101,110,100, 10,114,101,116,117,114,110,
+     32,102, 58,114,101, 97,100, 40,117,110,112, 97, 99,107, 40,
+     97,114,103, 41, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32,119,114,105,116,101, 32, 40, 46, 46, 46, 41,
+     10,108,111, 99, 97,108, 32,102, 32, 61, 32, 95, 79, 85, 84,
+     80, 85, 84, 10,105,102, 32,114, 97,119,116,121,112,101, 40,
+     97,114,103, 91, 49, 93, 41, 32, 61, 61, 32, 39,117,115,101,
+    114,100, 97,116, 97, 39, 32,116,104,101,110, 10,102, 32, 61,
+     32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103,
+     44, 32, 49, 41, 10,101,110,100, 10,114,101,116,117,114,110,
+     32,102, 58,119,114,105,116,101, 40,117,110,112, 97, 99,107,
+     40, 97,114,103, 41, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/compat.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 95, 98, 97,115,105, 99, 32, 61, 32,123, 10, 91, 39,118,
+    111,105,100, 39, 93, 32, 61, 32, 39, 39, 44, 10, 91, 39, 99,
+    104, 97,114, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114,
+     39, 44, 10, 91, 39,105,110,116, 39, 93, 32, 61, 32, 39,110,
+    117,109, 98,101,114, 39, 44, 10, 91, 39,115,104,111,114,116,
+     39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44, 10,
+     91, 39,108,111,110,103, 39, 93, 32, 61, 32, 39,110,117,109,
+     98,101,114, 39, 44, 10, 91, 39,117,110,115,105,103,110,101,
+    100, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44,
+     10, 91, 39,102,108,111, 97,116, 39, 93, 32, 61, 32, 39,110,
+    117,109, 98,101,114, 39, 44, 10, 91, 39,100,111,117, 98,108,
+    101, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44,
+     10, 91, 39, 95, 99,115,116,114,105,110,103, 39, 93, 32, 61,
+     32, 39,115,116,114,105,110,103, 39, 44, 10, 91, 39, 95,117,
+    115,101,114,100, 97,116, 97, 39, 93, 32, 61, 32, 39,117,115,
+    101,114,100, 97,116, 97, 39, 44, 10, 91, 39, 99,104, 97,114,
+     42, 39, 93, 32, 61, 32, 39,115,116,114,105,110,103, 39, 44,
+     10, 91, 39,118,111,105,100, 42, 39, 93, 32, 61, 32, 39,117,
+    115,101,114,100, 97,116, 97, 39, 44, 10, 91, 39, 98,111,111,
+    108, 39, 93, 32, 61, 32, 39, 98,111,111,108,101, 97,110, 39,
+     44, 10, 91, 39,108,117, 97, 95, 79, 98,106,101, 99,116, 39,
+     93, 32, 61, 32, 39,118, 97,108,117,101, 39, 44, 10, 91, 39,
+     76, 85, 65, 95, 86, 65, 76, 85, 69, 39, 93, 32, 61, 32, 39,
+    118, 97,108,117,101, 39, 44, 10, 91, 39,108,117, 97, 95, 83,
+    116, 97,116,101, 42, 39, 93, 32, 61, 32, 39,115,116, 97,116,
+    101, 39, 44, 10, 91, 39, 95,108,115,116, 97,116,101, 39, 93,
+     32, 61, 32, 39,115,116, 97,116,101, 39, 44, 10, 91, 39,108,
+    117, 97, 95, 70,117,110, 99,116,105,111,110, 39, 93, 32, 61,
+     32, 39,118, 97,108,117,101, 39, 44, 10,125, 10, 95, 98, 97,
+    115,105, 99, 95, 99,116,121,112,101, 32, 61, 32,123, 10,110,
+    117,109, 98,101,114, 32, 61, 32, 34,108,117, 97, 95, 78,117,
+    109, 98,101,114, 34, 44, 10,115,116,114,105,110,103, 32, 61,
+     32, 34, 99,111,110,115,116, 32, 99,104, 97,114, 42, 34, 44,
+     10,117,115,101,114,100, 97,116, 97, 32, 61, 32, 34,118,111,
+    105,100, 42, 34, 44, 10, 98,111,111,108,101, 97,110, 32, 61,
+     32, 34, 98,111,111,108, 34, 44, 10,118, 97,108,117,101, 32,
+     61, 32, 34,105,110,116, 34, 44, 10,115,116, 97,116,101, 32,
+     61, 32, 34,108,117, 97, 95, 83,116, 97,116,101, 42, 34, 44,
+     10,125, 10, 95, 98, 97,115,105, 99, 95,114, 97,119, 95,112,
+    117,115,104, 32, 61, 32,123,125, 10, 95,117,115,101,114,116,
+    121,112,101, 32, 61, 32,123,125, 10, 95, 99,111,108,108,101,
+     99,116, 32, 61, 32,123,125, 10, 95,103,108,111, 98, 97,108,
+     95,116,121,112,101,115, 32, 61, 32,123,110, 61, 48,125, 10,
+     95,103,108,111, 98, 97,108, 95,116,121,112,101,115, 95,104,
+     97,115,104, 32, 61, 32,123,125, 10, 95,103,108,111, 98, 97,
+    108, 95, 99,108, 97,115,115,101,115, 32, 61, 32,123,125, 10,
+     95,103,108,111, 98, 97,108, 95,101,110,117,109,115, 32, 61,
+     32,123,125, 10, 95,114,101,110, 97,109,105,110,103, 32, 61,
+     32,123,125, 10,102,117,110, 99,116,105,111,110, 32, 97,112,
+    112,101,110,100,114,101,110, 97,109,105,110,103, 32, 40,115,
+     41, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,111,108,100,
+     44,110,101,119, 32, 61, 32,115,116,114,102,105,110,100, 40,
+    115, 44, 34, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 64, 37,
+    115, 42, 40, 46, 45, 41, 37,115, 42, 36, 34, 41, 10,105,102,
+     32,110,111,116, 32, 98, 32,116,104,101,110, 10,101,114,114,
+    111,114, 40, 34, 35, 73,110,118, 97,108,105,100, 32,114,101,
+    110, 97,109,105,110,103, 32,115,121,110,116, 97,120, 59, 32,
+    105,116, 32,115,104,111,117,108,100, 32, 98,101, 32,111,102,
+     32,116,104,101, 32,102,111,114,109, 58, 32,112, 97,116,116,
+    101,114,110, 64,112, 97,116,116,101,114,110, 34, 41, 10,101,
+    110,100, 10,116,105,110,115,101,114,116, 40, 95,114,101,110,
+     97,109,105,110,103, 44,123,111,108,100, 61,111,108,100, 44,
+     32,110,101,119, 61,110,101,119,125, 41, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 97,112,112,108,121,114,
+    101,110, 97,109,105,110,103, 32, 40,115, 41, 10,102,111,114,
+     32,105, 61, 49, 44,103,101,116,110, 40, 95,114,101,110, 97,
+    109,105,110,103, 41, 32,100,111, 10,108,111, 99, 97,108, 32,
+    109, 44,110, 32, 61, 32,103,115,117, 98, 40,115, 44, 95,114,
+    101,110, 97,109,105,110,103, 91,105, 93, 46,111,108,100, 44,
+     95,114,101,110, 97,109,105,110,103, 91,105, 93, 46,110,101,
+    119, 41, 10,105,102, 32,110, 32,126, 61, 32, 48, 32,116,104,
+    101,110, 10,114,101,116,117,114,110, 32,109, 10,101,110,100,
+     10,101,110,100, 10,114,101,116,117,114,110, 32,110,105,108,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,116,
+    111,108,117, 97, 95,101,114,114,111,114, 32, 40,115, 44,102,
+     41, 10,105,102, 32, 95, 99,117,114,114, 95, 99,111,100,101,
+     32,116,104,101,110, 10,112,114,105,110,116, 40, 34, 42, 42,
+     42, 99,117,114,114, 32, 99,111,100,101, 32,102,111,114, 32,
+    101,114,114,111,114, 32,105,115, 32, 34, 46, 46,116,111,115,
+    116,114,105,110,103, 40, 95, 99,117,114,114, 95, 99,111,100,
+    101, 41, 41, 10,112,114,105,110,116, 40,100,101, 98,117,103,
+     46,116,114, 97, 99,101, 98, 97, 99,107, 40, 41, 41, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32,111,117,116, 32, 61, 32,
+     95, 79, 85, 84, 80, 85, 84, 10, 95, 79, 85, 84, 80, 85, 84,
+     32, 61, 32, 95, 83, 84, 68, 69, 82, 82, 10,105,102, 32,115,
+    116,114,115,117, 98, 40,115, 44, 49, 44, 49, 41, 32, 61, 61,
+     32, 39, 35, 39, 32,116,104,101,110, 10,119,114,105,116,101,
+     40, 34, 92,110, 42, 42, 32,116,111,108,117, 97, 58, 32, 34,
+     46, 46,115,116,114,115,117, 98, 40,115, 44, 50, 41, 46, 46,
+     34, 46, 92,110, 92,110, 34, 41, 10,105,102, 32, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32,116,104,101,110, 10,108,111,
+     99, 97,108, 32, 95, 44, 95, 44,115, 32, 61, 32,115,116,114,
+    102,105,110,100, 40, 95, 99,117,114,114, 95, 99,111,100,101,
+     44, 34, 94, 37,115, 42, 40, 46, 45, 92,110, 41, 34, 41, 10,
+    105,102, 32,115, 61, 61,110,105,108, 32,116,104,101,110, 32,
+    115, 32, 61, 32, 95, 99,117,114,114, 95, 99,111,100,101, 32,
+    101,110,100, 10,115, 32, 61, 32,103,115,117, 98, 40,115, 44,
+     34, 95,117,115,101,114,100, 97,116, 97, 34, 44, 34,118,111,
+    105,100, 42, 34, 41, 10,115, 32, 61, 32,103,115,117, 98, 40,
+    115, 44, 34, 95, 99,115,116,114,105,110,103, 34, 44, 34, 99,
+    104, 97,114, 42, 34, 41, 10,115, 32, 61, 32,103,115,117, 98,
+     40,115, 44, 34, 95,108,115,116, 97,116,101, 34, 44, 34,108,
+    117, 97, 95, 83,116, 97,116,101, 42, 34, 41, 10,119,114,105,
+    116,101, 40, 34, 67,111,100,101, 32, 98,101,105,110,103, 32,
+    112,114,111, 99,101,115,115,101,100, 58, 92,110, 34, 46, 46,
+    115, 46, 46, 34, 92,110, 34, 41, 10,101,110,100, 10,101,108,
+    115,101, 10,105,102, 32,110,111,116, 32,102, 32,116,104,101,
+    110, 32,102, 32, 61, 32, 34, 40,102, 32,105,115, 32,110,105,
+    108, 41, 34, 32,101,110,100, 10,112,114,105,110,116, 40, 34,
+     92,110, 42, 42, 32,116,111,108,117, 97, 32,105,110,116,101,
+    114,110, 97,108, 32,101,114,114,111,114, 58, 32, 34, 46, 46,
+    102, 46, 46,115, 46, 46, 34, 46, 92,110, 92,110, 34, 41, 10,
+    114,101,116,117,114,110, 10,101,110,100, 10, 95, 79, 85, 84,
+     80, 85, 84, 32, 61, 32,111,117,116, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32,119, 97,114,110,105,110,103,
+     32, 40,109,115,103, 41, 10,108,111, 99, 97,108, 32,111,117,
+    116, 32, 61, 32, 95, 79, 85, 84, 80, 85, 84, 10, 95, 79, 85,
+     84, 80, 85, 84, 32, 61, 32, 95, 83, 84, 68, 69, 82, 82, 10,
+    119,114,105,116,101, 40, 34, 92,110, 42, 42, 32,116,111,108,
+    117, 97, 32,119, 97,114,110,105,110,103, 58, 32, 34, 46, 46,
+    109,115,103, 46, 46, 34, 46, 92,110, 92,110, 34, 41, 10, 95,
+     79, 85, 84, 80, 85, 84, 32, 61, 32,111,117,116, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32,114,101,103,116,
+    121,112,101, 32, 40,116, 41, 10,108,111, 99, 97,108, 32,102,
+    116, 32, 61, 32,102,105,110,100,116,121,112,101, 40,116, 41,
+     10,105,102, 32,110,111,116, 32, 95,117,115,101,114,116,121,
+    112,101, 91,102,116, 93, 32,116,104,101,110, 10,114,101,116,
+    117,114,110, 32, 97,112,112,101,110,100,117,115,101,114,116,
+    121,112,101, 40,116, 41, 10,101,110,100, 10,114,101,116,117,
+    114,110, 32,102,116, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32,116,121,112,101,118, 97,114, 40,116,121,112,
+    101, 41, 10,105,102, 32,116,121,112,101, 32, 61, 61, 32, 39,
+     39, 32,111,114, 32,116,121,112,101, 32, 61, 61, 32, 39,118,
+    111,105,100, 39, 32,116,104,101,110, 10,114,101,116,117,114,
+    110, 32,116,121,112,101, 10,101,108,115,101, 10,108,111, 99,
+     97,108, 32,102,116, 32, 61, 32,102,105,110,100,116,121,112,
+    101, 40,116,121,112,101, 41, 10,105,102, 32,102,116, 32,116,
+    104,101,110, 10,114,101,116,117,114,110, 32,102,116, 10,101,
+    110,100, 10, 95,117,115,101,114,116,121,112,101, 91,116,121,
+    112,101, 93, 32, 61, 32,116,121,112,101, 10,114,101,116,117,
+    114,110, 32,116,121,112,101, 10,101,110,100, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,105,115, 98, 97,115,
+    105, 99, 32, 40,116,121,112,101, 41, 10,108,111, 99, 97,108,
+     32,116, 32, 61, 32,103,115,117, 98, 40,116,121,112,101, 44,
+     39, 99,111,110,115,116, 32, 39, 44, 39, 39, 41, 10,108,111,
+     99, 97,108, 32,109, 44,116, 32, 61, 32, 97,112,112,108,121,
+    116,121,112,101,100,101,102, 40, 39, 39, 44, 32,116, 41, 10,
+    108,111, 99, 97,108, 32, 98, 32, 61, 32, 95, 98, 97,115,105,
+     99, 91,116, 93, 10,105,102, 32, 98, 32,116,104,101,110, 10,
+    114,101,116,117,114,110, 32, 98, 44, 95, 98, 97,115,105, 99,
+     95, 99,116,121,112,101, 91, 98, 93, 10,101,110,100, 10,114,
+    101,116,117,114,110, 32,110,105,108, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32,115,112,108,105,116, 32, 40,
+    115, 44,116, 41, 10,108,111, 99, 97,108, 32,108, 32, 61, 32,
+    123,110, 61, 48,125, 10,108,111, 99, 97,108, 32,102, 32, 61,
+     32,102,117,110, 99,116,105,111,110, 32, 40,115, 41, 10,108,
+     46,110, 32, 61, 32,108, 46,110, 32, 43, 32, 49, 10,108, 91,
+    108, 46,110, 93, 32, 61, 32,115, 10,114,101,116,117,114,110,
+     32, 34, 34, 10,101,110,100, 10,108,111, 99, 97,108, 32,112,
+     32, 61, 32, 34, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 34,
+     46, 46,116, 46, 46, 34, 37,115, 42, 34, 10,115, 32, 61, 32,
+    103,115,117, 98, 40,115, 44, 34, 94, 37,115, 43, 34, 44, 34,
+     34, 41, 10,115, 32, 61, 32,103,115,117, 98, 40,115, 44, 34,
+     37,115, 43, 36, 34, 44, 34, 34, 41, 10,115, 32, 61, 32,103,
+    115,117, 98, 40,115, 44,112, 44,102, 41, 10,108, 46,110, 32,
+     61, 32,108, 46,110, 32, 43, 32, 49, 10,108, 91,108, 46,110,
+     93, 32, 61, 32,103,115,117, 98, 40,115, 44, 34, 40, 37,115,
+     37,115, 42, 41, 36, 34, 44, 34, 34, 41, 10,114,101,116,117,
+    114,110, 32,108, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,
+    110,115, 40,115, 44, 32,112, 97,116, 41, 10,115, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32,
+     34, 94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,115, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44,
+     32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 10,108,111,
+     99, 97,108, 32,116,111,107,101,110, 95, 98,101,103,105,110,
+     32, 61, 32, 49, 10,108,111, 99, 97,108, 32,116,111,107,101,
+    110, 95,101,110,100, 32, 61, 32, 49, 10,108,111, 99, 97,108,
+     32,111,102,115, 32, 61, 32, 49, 10,108,111, 99, 97,108, 32,
+    114,101,116, 32, 61, 32,123,110, 61, 48,125, 10,102,117,110,
+     99,116,105,111,110, 32, 97,100,100, 95,116,111,107,101,110,
+     40,111,102,115, 41, 10,108,111, 99, 97,108, 32,116, 32, 61,
+     32,115,116,114,105,110,103, 46,115,117, 98, 40,115, 44, 32,
+    116,111,107,101,110, 95, 98,101,103,105,110, 44, 32,111,102,
+    115, 41, 10,116, 32, 61, 32,115,116,114,105,110,103, 46,103,
+    115,117, 98, 40,116, 44, 32, 34, 94, 37,115, 42, 34, 44, 32,
+     34, 34, 41, 10,116, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40,116, 44, 32, 34, 37,115, 42, 36, 34, 44,
+     32, 34, 34, 41, 10,114,101,116, 46,110, 32, 61, 32,114,101,
+    116, 46,110, 32, 43, 32, 49, 10,114,101,116, 91,114,101,116,
+     46,110, 93, 32, 61, 32,116, 10,101,110,100, 10,119,104,105,
+    108,101, 32,111,102,115, 32, 60, 61, 32,115,116,114,105,110,
+    103, 46,108,101,110, 40,115, 41, 32,100,111, 10,108,111, 99,
+     97,108, 32,115,117, 98, 32, 61, 32,115,116,114,105,110,103,
+     46,115,117, 98, 40,115, 44, 32,111,102,115, 44, 32, 45, 49,
+     41, 10,108,111, 99, 97,108, 32, 98, 44,101, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,115,117, 98, 44,
+     32, 34, 94, 34, 46, 46,112, 97,116, 41, 10,105,102, 32, 98,
+     32,116,104,101,110, 10, 97,100,100, 95,116,111,107,101,110,
+     40,111,102,115, 45, 49, 41, 10,111,102,115, 32, 61, 32,111,
+    102,115, 43,101, 10,116,111,107,101,110, 95, 98,101,103,105,
+    110, 32, 61, 32,111,102,115, 10,101,108,115,101, 10,108,111,
+     99, 97,108, 32, 99,104, 97,114, 32, 61, 32,115,116,114,105,
+    110,103, 46,115,117, 98, 40,115, 44, 32,111,102,115, 44, 32,
+    111,102,115, 41, 10,105,102, 32, 99,104, 97,114, 32, 61, 61,
+     32, 34, 40, 34, 32,111,114, 32, 99,104, 97,114, 32, 61, 61,
+     32, 34, 60, 34, 32,116,104,101,110, 10,108,111, 99, 97,108,
+     32, 98,108,111, 99,107, 10,105,102, 32, 99,104, 97,114, 32,
+     61, 61, 32, 34, 40, 34, 32,116,104,101,110, 32, 98,108,111,
+     99,107, 32, 61, 32, 34, 94, 37, 98, 40, 41, 34, 32,101,110,
+    100, 10,105,102, 32, 99,104, 97,114, 32, 61, 61, 32, 34, 60,
+     34, 32,116,104,101,110, 32, 98,108,111, 99,107, 32, 61, 32,
+     34, 94, 37, 98, 60, 62, 34, 32,101,110,100, 10, 98, 44,101,
+     32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    115,117, 98, 44, 32, 98,108,111, 99,107, 41, 10,105,102, 32,
+    110,111,116, 32, 98, 32,116,104,101,110, 10,111,102,115, 32,
+     61, 32,111,102,115, 43, 49, 10,101,108,115,101, 10,111,102,
+    115, 32, 61, 32,111,102,115, 32, 43, 32,101, 10,101,110,100,
+     10,101,108,115,101, 10,111,102,115, 32, 61, 32,111,102,115,
+     43, 49, 10,101,110,100, 10,101,110,100, 10,101,110,100, 10,
+     97,100,100, 95,116,111,107,101,110, 40,111,102,115, 41, 10,
+    114,101,116,117,114,110, 32,114,101,116, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,111,110, 99, 97,116,
+     32, 40,116, 44,102, 44,108, 44,106,115,116,114, 41, 10,106,
+    115,116,114, 32, 61, 32,106,115,116,114, 32,111,114, 32, 34,
+     32, 34, 10,108,111, 99, 97,108, 32,115, 32, 61, 32, 39, 39,
+     10,108,111, 99, 97,108, 32,105, 61,102, 10,119,104,105,108,
+    101, 32,105, 60, 61,108, 32,100,111, 10,115, 32, 61, 32,115,
+     46, 46,116, 91,105, 93, 10,105, 32, 61, 32,105, 43, 49, 10,
+    105,102, 32,105, 32, 60, 61, 32,108, 32,116,104,101,110, 32,
+    115, 32, 61, 32,115, 46, 46,106,115,116,114, 32,101,110,100,
+     10,101,110,100, 10,114,101,116,117,114,110, 32,115, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,111,110,
+     99, 97,116,112, 97,114, 97,109, 32, 40,108,105,110,101, 44,
+     32, 46, 46, 46, 41, 10,108,111, 99, 97,108, 32,105, 61, 49,
+     10,119,104,105,108,101, 32,105, 60, 61, 97,114,103, 46,110,
+     32,100,111, 10,105,102, 32, 95, 99,111,110,116, 32, 97,110,
+    100, 32,110,111,116, 32,115,116,114,102,105,110,100, 40, 95,
+     99,111,110,116, 44, 39, 91, 37, 40, 44, 34, 93, 39, 41, 32,
+     97,110,100, 10,115,116,114,102,105,110,100, 40, 97,114,103,
+     91,105, 93, 44, 34, 94, 91, 37, 97, 95,126, 93, 34, 41, 32,
+    116,104,101,110, 10,108,105,110,101, 32, 61, 32,108,105,110,
+    101, 32, 46, 46, 32, 39, 32, 39, 10,101,110,100, 10,108,105,
+    110,101, 32, 61, 32,108,105,110,101, 32, 46, 46, 32, 97,114,
+    103, 91,105, 93, 10,105,102, 32, 97,114,103, 91,105, 93, 32,
+    126, 61, 32, 39, 39, 32,116,104,101,110, 10, 95, 99,111,110,
+    116, 32, 61, 32,115,116,114,115,117, 98, 40, 97,114,103, 91,
+    105, 93, 44, 45, 49, 44, 45, 49, 41, 10,101,110,100, 10,105,
+     32, 61, 32,105, 43, 49, 10,101,110,100, 10,105,102, 32,115,
+    116,114,102,105,110,100, 40, 97,114,103, 91, 97,114,103, 46,
+    110, 93, 44, 34, 91, 37, 47, 37, 41, 37, 59, 37,123, 37,125,
+     93, 36, 34, 41, 32,116,104,101,110, 10, 95, 99,111,110,116,
+     61,110,105,108, 32,108,105,110,101, 32, 61, 32,108,105,110,
+    101, 32, 46, 46, 32, 39, 92,110, 39, 10,101,110,100, 10,114,
+    101,116,117,114,110, 32,108,105,110,101, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32,111,117,116,112,117,116,
+     32, 40, 46, 46, 46, 41, 10,108,111, 99, 97,108, 32,105, 61,
+     49, 10,119,104,105,108,101, 32,105, 60, 61, 97,114,103, 46,
+    110, 32,100,111, 10,105,102, 32, 95, 99,111,110,116, 32, 97,
+    110,100, 32,110,111,116, 32,115,116,114,102,105,110,100, 40,
+     95, 99,111,110,116, 44, 39, 91, 37, 40, 44, 34, 93, 39, 41,
+     32, 97,110,100, 10,115,116,114,102,105,110,100, 40, 97,114,
+    103, 91,105, 93, 44, 34, 94, 91, 37, 97, 95,126, 93, 34, 41,
+     32,116,104,101,110, 10,119,114,105,116,101, 40, 39, 32, 39,
+     41, 10,101,110,100, 10,119,114,105,116,101, 40, 97,114,103,
+     91,105, 93, 41, 10,105,102, 32, 97,114,103, 91,105, 93, 32,
+    126, 61, 32, 39, 39, 32,116,104,101,110, 10, 95, 99,111,110,
+    116, 32, 61, 32,115,116,114,115,117, 98, 40, 97,114,103, 91,
+    105, 93, 44, 45, 49, 44, 45, 49, 41, 10,101,110,100, 10,105,
+     32, 61, 32,105, 43, 49, 10,101,110,100, 10,105,102, 32,115,
+    116,114,102,105,110,100, 40, 97,114,103, 91, 97,114,103, 46,
+    110, 93, 44, 34, 91, 37, 47, 37, 41, 37, 59, 37,123, 37,125,
+     93, 36, 34, 41, 32,116,104,101,110, 10, 95, 99,111,110,116,
+     61,110,105,108, 32,119,114,105,116,101, 40, 39, 92,110, 39,
+     41, 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32,103,101,116, 95,112,114,111,112,101,114,116,
+    121, 95,109,101,116,104,111,100,115, 40,112,116,121,112,101,
+     44, 32,110, 97,109,101, 41, 10,105,102, 32,103,101,116, 95,
+    112,114,111,112,101,114,116,121, 95,109,101,116,104,111,100,
+    115, 95,104,111,111,107, 32, 97,110,100, 32,103,101,116, 95,
+    112,114,111,112,101,114,116,121, 95,109,101,116,104,111,100,
+    115, 95,104,111,111,107, 40,112,116,121,112,101, 44,110, 97,
+    109,101, 41, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     32,103,101,116, 95,112,114,111,112,101,114,116,121, 95,109,
+    101,116,104,111,100,115, 95,104,111,111,107, 40,112,116,121,
+    112,101, 44, 32,110, 97,109,101, 41, 10,101,110,100, 10,105,
+    102, 32,112,116,121,112,101, 32, 61, 61, 32, 34,100,101,102,
+     97,117,108,116, 34, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32, 34,103,101,116, 95, 34, 46, 46,110, 97,109,101,
+     44, 32, 34,115,101,116, 95, 34, 46, 46,110, 97,109,101, 10,
+    101,110,100, 10,105,102, 32,112,116,121,112,101, 32, 61, 61,
+     32, 34,113,116, 34, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32,110, 97,109,101, 44, 32, 34,115,101,116, 34, 46,
+     46,115,116,114,105,110,103, 46,117,112,112,101,114, 40,115,
+    116,114,105,110,103, 46,115,117, 98, 40,110, 97,109,101, 44,
+     32, 49, 44, 32, 49, 41, 41, 46, 46,115,116,114,105,110,103,
+     46,115,117, 98, 40,110, 97,109,101, 44, 32, 50, 44, 32, 45,
+     49, 41, 10,101,110,100, 10,105,102, 32,112,116,121,112,101,
+     32, 61, 61, 32, 34,111,118,101,114,108,111, 97,100, 34, 32,
+    116,104,101,110, 10,114,101,116,117,114,110, 32,110, 97,109,
+    101, 44,110, 97,109,101, 10,101,110,100, 10,114,101,116,117,
+    114,110, 32,110,105,108, 10,101,110,100, 10,102,117,110, 99,
+    116,105,111,110, 32,112,114,101,112,114,111, 99,101,115,115,
+     95,104,111,111,107, 40,112, 41, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32,105,110, 99,108,117,100,101, 95,
+    102,105,108,101, 95,104,111,111,107, 40,116, 44, 32,102,105,
+    108,101,110, 97,109,101, 44, 32, 46, 46, 46, 41, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32,112,114,101,112,
+     97,114,115,101, 95,104,111,111,107, 40,112, 97, 99,107, 97,
+    103,101, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32,112,111,115,116, 95,111,117,116,112,117,116, 95,104,
+    111,111,107, 40,112, 97, 99,107, 97,103,101, 41, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32,103,101,116, 95,
+    112,114,111,112,101,114,116,121, 95,109,101,116,104,111,100,
+    115, 95,104,111,111,107, 40,112,114,111,112,101,114,116,121,
+     95,116,121,112,101, 44, 32,110, 97,109,101, 41, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32,112, 97,114,115,
+    101,114, 95,104,111,111,107, 40,115, 41, 10,114,101,116,117,
+    114,110, 32,110,105,108, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/basic.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 32, 61,
+     32,123, 10,125, 10, 99,108, 97,115,115, 70,101, 97,116,117,
+    114,101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108,
+     97,115,115, 70,101, 97,116,117,114,101, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,
+    114,101, 58,115,117,112, 99,111,100,101, 32, 40, 41, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 70,101, 97,116,117,114,101, 58,100,101, 99,108,116,
+    121,112,101, 32, 40, 41, 10,101,110,100, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,
+    114,101, 58,114,101,103,105,115,116,101,114, 32, 40,112,114,
+    101, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,112,
+    114,101, 97,109, 98,108,101, 32, 40, 41, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,
+    101, 97,116,117,114,101, 58,105,115,118, 97,114,105, 97, 98,
+    108,101, 32, 40, 41, 10,114,101,116,117,114,110, 32,102, 97,
+    108,115,101, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,
+    114,101,113,117,105,114,101, 99,111,108,108,101, 99,116,105,
+    111,110, 32, 40,116, 41, 10,114,101,116,117,114,110, 32,102,
+     97,108,115,101, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101,
+     58, 98,117,105,108,100,110, 97,109,101,115, 32, 40, 41, 10,
+    105,102, 32,115,101,108,102, 46,110, 97,109,101, 32, 97,110,
+    100, 32,115,101,108,102, 46,110, 97,109,101,126, 61, 39, 39,
+     32,116,104,101,110, 10,108,111, 99, 97,108, 32,110, 32, 61,
+     32,115,112,108,105,116, 40,115,101,108,102, 46,110, 97,109,
+    101, 44, 39, 64, 39, 41, 10,115,101,108,102, 46,110, 97,109,
+    101, 32, 61, 32,110, 91, 49, 93, 10,105,102, 32,110,111,116,
+     32,110, 91, 50, 93, 32,116,104,101,110, 10,110, 91, 50, 93,
+     32, 61, 32, 97,112,112,108,121,114,101,110, 97,109,105,110,
+    103, 40,110, 91, 49, 93, 41, 10,101,110,100, 10,115,101,108,
+    102, 46,108,110, 97,109,101, 32, 61, 32,110, 91, 50, 93, 32,
+    111,114, 32,103,115,117, 98, 40,110, 91, 49, 93, 44, 34, 37,
+     91, 46, 45, 37, 93, 34, 44, 34, 34, 41, 10,115,101,108,102,
+     46,111,114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,
+     61, 32,115,101,108,102, 46,110, 97,109,101, 10,115,101,108,
+    102, 46,108,110, 97,109,101, 32, 61, 32, 99,108,101, 97,110,
+     95,116,101,109,112,108, 97,116,101, 40,115,101,108,102, 46,
+    108,110, 97,109,101, 41, 10,101,110,100, 10,105,102, 32,110,
+    111,116, 32,115,101,108,102, 46,105,115, 95,112, 97,114, 97,
+    109,101,116,101,114, 32,116,104,101,110, 10,115,101,108,102,
+     46,110, 97,109,101, 32, 61, 32,103,101,116,111,110,108,121,
+    110, 97,109,101,115,112, 97, 99,101, 40, 41, 32, 46, 46, 32,
+    115,101,108,102, 46,110, 97,109,101, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32,112, 97,114,101,110,116, 32, 61, 32, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,
+    117,114,114, 10,105,102, 32,112, 97,114,101,110,116, 32,116,
+    104,101,110, 10,115,101,108,102, 46, 97, 99, 99,101,115,115,
+     32, 61, 32,112, 97,114,101,110,116, 46, 99,117,114,114, 95,
+    109,101,109, 98,101,114, 95, 97, 99, 99,101,115,115, 10,101,
+    108,115,101, 10,101,110,100, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 70,101, 97,116,
+    117,114,101, 58, 99,104,101, 99,107, 95,112,117, 98,108,105,
+     99, 95, 97, 99, 99,101,115,115, 40, 41, 10,105,102, 32,115,
+    101,108,102, 46, 97, 99, 99,101,115,115, 32, 97,110,100, 32,
+    115,101,108,102, 46, 97, 99, 99,101,115,115, 32,126, 61, 32,
+     48, 32,116,104,101,110, 10,114,101,116,117,114,110, 32,102,
+     97,108,115,101, 10,101,110,100, 10,108,111, 99, 97,108, 32,
+    112, 97,114,101,110,116, 32, 61, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 10,119,
+    104,105,108,101, 32,112, 97,114,101,110,116, 32,100,111, 10,
+    105,102, 32,112, 97,114,101,110,116, 46, 97, 99, 99,101,115,
+    115, 32, 97,110,100, 32,112, 97,114,101,110,116, 46, 97, 99,
+     99,101,115,115, 32,126, 61, 32, 48, 32,116,104,101,110, 10,
+    114,101,116,117,114,110, 32,102, 97,108,115,101, 10,101,110,
+    100, 10,112, 97,114,101,110,116, 32, 61, 32,112, 97,114,101,
+    110,116, 46,112,114,111,120, 10,101,110,100, 10,114,101,116,
+    117,114,110, 32,116,114,117,101, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108,101, 97,110, 95,116,101,
+    109,112,108, 97,116,101, 40,116, 41, 10,114,101,116,117,114,
+    110, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116,
+     44, 32, 34, 91, 60, 62, 58, 44, 32, 37, 42, 93, 34, 44, 32,
+     34, 95, 34, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 70,101, 97,116,117,114,101,
+     58,105,110, 99,111,110,116, 97,105,110,101,114, 32, 40,119,
+    104,105, 99,104, 41, 10,105,102, 32,115,101,108,102, 46,112,
+     97,114,101,110,116, 32,116,104,101,110, 10,108,111, 99, 97,
+    108, 32,112, 97,114,101,110,116, 32, 61, 32,115,101,108,102,
+     46,112, 97,114,101,110,116, 10,119,104,105,108,101, 32,112,
+     97,114,101,110,116, 32,100,111, 10,105,102, 32,112, 97,114,
+    101,110,116, 46, 99,108, 97,115,115,116,121,112,101, 32, 61,
+     61, 32,119,104,105, 99,104, 32,116,104,101,110, 10,114,101,
+    116,117,114,110, 32,112, 97,114,101,110,116, 46,110, 97,109,
+    101, 10,101,110,100, 10,112, 97,114,101,110,116, 32, 61, 32,
+    112, 97,114,101,110,116, 46,112, 97,114,101,110,116, 10,101,
+    110,100, 10,101,110,100, 10,114,101,116,117,114,110, 32,110,
+    105,108, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 58,105,
+    110, 99,108, 97,115,115, 32, 40, 41, 10,114,101,116,117,114,
+    110, 32,115,101,108,102, 58,105,110, 99,111,110,116, 97,105,
+    110,101,114, 40, 39, 99,108, 97,115,115, 39, 41, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 70,101, 97,116,117,114,101, 58,105,110,109,111,100,117,
+    108,101, 32, 40, 41, 10,114,101,116,117,114,110, 32,115,101,
+    108,102, 58,105,110, 99,111,110,116, 97,105,110,101,114, 40,
+     39,109,111,100,117,108,101, 39, 41, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,101,
+     97,116,117,114,101, 58,105,110,110, 97,109,101,115,112, 97,
+     99,101, 32, 40, 41, 10,114,101,116,117,114,110, 32,115,101,
+    108,102, 58,105,110, 99,111,110,116, 97,105,110,101,114, 40,
+     39,110, 97,109,101,115,112, 97, 99,101, 39, 41, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 70,101, 97,116,117,114,101, 58, 99,102,117,110, 99,110,
+     97,109,101, 32, 40,110, 41, 10,105,102, 32,115,101,108,102,
+     46,112, 97,114,101,110,116, 32,116,104,101,110, 10,110, 32,
+     61, 32,115,101,108,102, 46,112, 97,114,101,110,116, 58, 99,
+    102,117,110, 99,110, 97,109,101, 40,110, 41, 10,101,110,100,
+     10,110, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,110, 46, 46, 39, 95, 39, 46, 46, 32, 40,115,101,108,
+    102, 46,108,110, 97,109,101, 32,111,114, 32,115,101,108,102,
+     46,110, 97,109,101, 41, 44, 32, 34, 91, 60, 62, 58, 44, 32,
+     92, 46, 37, 42, 38, 93, 34, 44, 32, 34, 95, 34, 41, 10,114,
+    101,116,117,114,110, 32,110, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/feature.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,109, 32,
+     61, 32,123, 10,108,105,110,101, 32, 61, 32, 39, 39, 44, 10,
+     99,111,110,100, 32, 61, 32,110,105,108, 44, 10,125, 10, 99,
+    108, 97,115,115, 86,101,114, 98, 97,116,105,109, 46, 95, 95,
+    105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 86,101,
+    114, 98, 97,116,105,109, 10,115,101,116,109,101,116, 97,116,
+     97, 98,108,101, 40, 99,108, 97,115,115, 86,101,114, 98, 97,
+    116,105,109, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,
+    101, 41, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 86,101,114, 98, 97,116,105,109, 58,112,114,101, 97,
+    109, 98,108,101, 32, 40, 41, 10,105,102, 32,115,101,108,102,
+     46, 99,111,110,100, 32, 61, 61, 32, 39, 39, 32,116,104,101,
+    110, 10,119,114,105,116,101, 40,115,101,108,102, 46,108,105,
+    110,101, 41, 10,101,110,100, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 86,101,114, 98,
+     97,116,105,109, 58,115,117,112, 99,111,100,101, 32, 40, 41,
+     10,105,102, 32,115,116,114,102,105,110,100, 40,115,101,108,
+    102, 46, 99,111,110,100, 44, 39,115, 39, 41, 32,116,104,101,
+    110, 10,119,114,105,116,101, 40,115,101,108,102, 46,108,105,
+    110,101, 41, 10,119,114,105,116,101, 40, 39, 92,110, 39, 41,
+     10,101,110,100, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 86,101,114, 98, 97,116,105,
+    109, 58,114,101,103,105,115,116,101,114, 32, 40,112,114,101,
+     41, 10,105,102, 32,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46, 99,111,110,100, 44, 39,114, 39, 41, 32,116,104,
+    101,110, 10,119,114,105,116,101, 40,115,101,108,102, 46,108,
+    105,110,101, 41, 10,101,110,100, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 86,101,114,
+     98, 97,116,105,109, 58,112,114,105,110,116, 32, 40,105,100,
+    101,110,116, 44, 99,108,111,115,101, 41, 10,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 86,101,114, 98, 97,
+    116,105,109,123, 34, 41, 10,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 32,108,105,110,101, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,108,105,110,101, 46, 46, 34,
+     39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,
+    101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 95, 86,
+    101,114, 98, 97,116,105,109, 32, 40,116, 41, 10,115,101,116,
+    109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,108, 97,
+    115,115, 86,101,114, 98, 97,116,105,109, 41, 10, 97,112,112,
+    101,110,100, 40,116, 41, 10,114,101,116,117,114,110, 32,116,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 86,
+    101,114, 98, 97,116,105,109, 32, 40,108, 44, 99,111,110,100,
+     41, 10,105,102, 32,115,116,114,115,117, 98, 40,108, 44, 49,
+     44, 49, 41, 32, 61, 61, 32, 34, 39, 34, 32,116,104,101,110,
+     10,108, 32, 61, 32,115,116,114,115,117, 98, 40,108, 44, 50,
+     41, 10,101,108,115,101,105,102, 32,115,116,114,115,117, 98,
+     40,108, 44, 49, 44, 49, 41, 32, 61, 61, 32, 39, 36, 39, 32,
+    116,104,101,110, 10, 99,111,110,100, 32, 61, 32, 39,115,114,
+     39, 10,108, 32, 61, 32,115,116,114,115,117, 98, 40,108, 44,
+     50, 41, 10,101,110,100, 10,114,101,116,117,114,110, 32, 95,
+     86,101,114, 98, 97,116,105,109, 32,123, 10,108,105,110,101,
+     32, 61, 32,108, 44, 10, 99,111,110,100, 32, 61, 32, 99,111,
+    110,100, 32,111,114, 32, 39, 39, 44, 10,125, 10,101,110,100,
+    32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/verbatim.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,111,100,101, 95,110, 32, 61, 32, 49, 10, 99,108, 97,
+    115,115, 67,111,100,101, 32, 61, 32,123, 10,116,101,120,116,
+     32, 61, 32, 39, 39, 44, 10,125, 10, 99,108, 97,115,115, 67,
+    111,100,101, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,
+    108, 97,115,115, 67,111,100,101, 10,115,101,116,109,101,116,
+     97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 67,111,100,
+    101, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,101, 41,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     67,111,100,101, 58,114,101,103,105,115,116,101,114, 32, 40,
+    112,114,101, 41, 10,112,114,101, 32, 61, 32,112,114,101, 32,
+    111,114, 32, 39, 39, 10,108,111, 99, 97,108, 32,115, 32, 61,
+     32, 99,108,101, 97,110, 40,115,101,108,102, 46,116,101,120,
+    116, 41, 10,105,102, 32,110,111,116, 32,115, 32,116,104,101,
+    110, 10,101,114,114,111,114, 40, 34,112, 97,114,115,101,114,
+     32,101,114,114,111,114, 32,105,110, 32,101,109, 98,101,100,
+    100,101,100, 32, 99,111,100,101, 34, 41, 10,101,110,100, 10,
+    108,111, 99, 97,108, 32, 95, 44, 32, 95, 44, 32,102,105,114,
+    115,116, 95,108,105,110,101, 61,115,116,114,105,110,103, 46,
+    102,105,110,100, 40,115,101,108,102, 46,116,101,120,116, 44,
+     32, 34, 94, 40, 91, 94, 92,110, 92,114, 93, 42, 41, 34, 41,
+     10,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100,
+     40,102,105,114,115,116, 95,108,105,110,101, 44, 32, 34, 94,
+     37,115, 42, 37, 45, 37, 45, 34, 41, 32,116,104,101,110, 10,
+    105,102, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    102,105,114,115,116, 95,108,105,110,101, 44, 32, 34, 94, 37,
+     45, 37, 45, 35, 35, 34, 41, 32,116,104,101,110, 10,102,105,
+    114,115,116, 95,108,105,110,101, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,102,105,114,115,116, 95,108,
+    105,110,101, 44, 32, 34, 94, 37, 45, 37, 45, 35, 35, 34, 44,
+     32, 34, 34, 41, 10,105,102, 32,102,108, 97,103,115, 91, 39,
+     67, 39, 93, 32,116,104,101,110, 10,115, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32, 34, 94,
+     37, 45, 37, 45, 35, 35, 91, 94, 92,110, 92,114, 93, 42, 92,
+    110, 34, 44, 32, 34, 34, 41, 10,101,110,100, 10,101,110,100,
+     10,101,108,115,101, 10,102,105,114,115,116, 95,108,105,110,
+    101, 32, 61, 32, 34, 34, 10,101,110,100, 10,111,117,116,112,
+    117,116, 40, 39, 92,110, 39, 46, 46,112,114,101, 46, 46, 39,
+    123, 32, 47, 42, 32, 98,101,103,105,110, 32,101,109, 98,101,
+    100,100,101,100, 32,108,117, 97, 32, 99,111,100,101, 32, 42,
+     47, 92,110, 39, 41, 10,111,117,116,112,117,116, 40,112,114,
+    101, 46, 46, 39, 32,105,110,116, 32,116,111,112, 32, 61, 32,
+    108,117, 97, 95,103,101,116,116,111,112, 40,116,111,108,117,
+     97, 95, 83, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+    112,114,101, 46, 46, 39, 32,115,116, 97,116,105, 99, 32,117,
+    110,115,105,103,110,101,100, 32, 99,104, 97,114, 32, 66, 91,
+     93, 32, 61, 32,123, 92,110, 32, 39, 41, 10,108,111, 99, 97,
+    108, 32,116, 61,123,110, 61, 48,125, 10,108,111, 99, 97,108,
+     32, 98, 32, 61, 32,103,115,117, 98, 40,115, 44, 39, 40, 46,
+     41, 39, 44,102,117,110, 99,116,105,111,110, 32, 40, 99, 41,
+     10,108,111, 99, 97,108, 32,101, 32, 61, 32, 39, 39, 10,116,
+     46,110, 61,116, 46,110, 43, 49, 32,105,102, 32,116, 46,110,
+     61, 61, 49, 53, 32,116,104,101,110, 32,116, 46,110, 61, 48,
+     32,101, 61, 39, 92,110, 39, 46, 46,112,114,101, 46, 46, 39,
+     32, 39, 32,101,110,100, 10,114,101,116,117,114,110, 32,102,
+    111,114,109, 97,116, 40, 39, 37, 51,117, 44, 37,115, 39, 44,
+    115,116,114, 98,121,116,101, 40, 99, 41, 44,101, 41, 10,101,
+    110,100, 10, 41, 10,111,117,116,112,117,116, 40, 98, 46, 46,
+    115,116,114, 98,121,116,101, 40, 34, 32, 34, 41, 41, 10,111,
+    117,116,112,117,116, 40, 39, 92,110, 39, 46, 46,112,114,101,
+     46, 46, 39, 32,125, 59, 92,110, 39, 41, 10,105,102, 32,102,
+    105,114,115,116, 95,108,105,110,101, 32, 97,110,100, 32,102,
+    105,114,115,116, 95,108,105,110,101, 32,126, 61, 32, 34, 34,
+     32,116,104,101,110, 10,111,117,116,112,117,116, 40,112,114,
+    101, 46, 46, 39, 32,116,111,108,117, 97, 95,100,111, 98,117,
+    102,102,101,114, 40,116,111,108,117, 97, 95, 83, 44, 40, 99,
+    104, 97,114, 42, 41, 66, 44,115,105,122,101,111,102, 40, 66,
+     41, 44, 34,116,111,108,117, 97, 32,101,109, 98,101,100,100,
+    101,100, 58, 32, 39, 46, 46,102,105,114,115,116, 95,108,105,
+    110,101, 46, 46, 39, 34, 41, 59, 39, 41, 10,101,108,115,101,
+     10,111,117,116,112,117,116, 40,112,114,101, 46, 46, 39, 32,
+    116,111,108,117, 97, 95,100,111, 98,117,102,102,101,114, 40,
+    116,111,108,117, 97, 95, 83, 44, 40, 99,104, 97,114, 42, 41,
+     66, 44,115,105,122,101,111,102, 40, 66, 41, 44, 34,116,111,
+    108,117, 97, 58, 32,101,109, 98,101,100,100,101,100, 32, 76,
+    117, 97, 32, 99,111,100,101, 32, 39, 46, 46, 99,111,100,101,
+     95,110, 46, 46, 39, 34, 41, 59, 39, 41, 10,101,110,100, 10,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 39, 32,108,
+    117, 97, 95,115,101,116,116,111,112, 40,116,111,108,117, 97,
+     95, 83, 44, 32,116,111,112, 41, 59, 39, 41, 10,111,117,116,
+    112,117,116, 40,112,114,101, 46, 46, 39,125, 32, 47, 42, 32,
+    101,110,100, 32,111,102, 32,101,109, 98,101,100,100,101,100,
+     32,108,117, 97, 32, 99,111,100,101, 32, 42, 47, 92,110, 92,
+    110, 39, 41, 10, 99,111,100,101, 95,110, 32, 61, 32, 99,111,
+    100,101, 95,110, 32, 43, 49, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,100,101,
+     58,112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,
+    108,111,115,101, 41, 10,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 67,111,100,101,123, 34, 41, 10,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,116,101,
+    120,116, 32, 61, 32, 91, 91, 34, 46, 46,115,101,108,102, 46,
+    116,101,120,116, 46, 46, 34, 93, 93, 44, 34, 41, 10,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46,
+     46, 99,108,111,115,101, 41, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 95, 67,111,100,101, 32, 40,116, 41,
+     10,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116,
+     44, 99,108, 97,115,115, 67,111,100,101, 41, 10, 97,112,112,
+    101,110,100, 40,116, 41, 10,114,101,116,117,114,110, 32,116,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 67,
+    111,100,101, 32, 40,108, 41, 10,114,101,116,117,114,110, 32,
+     95, 67,111,100,101, 32,123, 10,116,101,120,116, 32, 61, 32,
+    108, 10,125, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/code.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 84,121,112,101,100,101,102, 32, 61,
+     32,123, 10,117,116,121,112,101, 32, 61, 32, 39, 39, 44, 10,
+    109,111,100, 32, 61, 32, 39, 39, 44, 10,116,121,112,101, 32,
+     61, 32, 39, 39, 10,125, 10, 99,108, 97,115,115, 84,121,112,
+    101,100,101,102, 46, 95, 95,105,110,100,101,120, 32, 61, 32,
+     99,108, 97,115,115, 84,121,112,101,100,101,102, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 84,121,112,
+    101,100,101,102, 58,112,114,105,110,116, 32, 40,105,100,101,
+    110,116, 44, 99,108,111,115,101, 41, 10,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 84,121,112,101,100,101,
+    102,123, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,117,116,121,112,101, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,117,116,121,112,101, 46, 46, 34,
+     39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,109,111,100, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41,
+     10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10,112,
+    114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34,
+     46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 84,121,112,
+    101,100,101,102, 58,105,115,118, 97,114,105, 97, 98,108,101,
+     32, 40, 41, 10,114,101,116,117,114,110, 32,102, 97,108,115,
+    101, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 84,121,112,101,100,101,102, 32, 40,116, 41, 10,115,101,
+    116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,108,
+     97,115,115, 84,121,112,101,100,101,102, 41, 10,116, 46,116,
+    121,112,101, 32, 61, 32,114,101,115,111,108,118,101, 95,116,
+    101,109,112,108, 97,116,101, 95,116,121,112,101,115, 40,116,
+     46,116,121,112,101, 41, 10, 97,112,112,101,110,100,116,121,
+    112,101,100,101,102, 40,116, 41, 10,114,101,116,117,114,110,
+     32,116, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 84,121,112,101,100,101,102, 32, 40,115, 41, 10,105,102,
+     32,115,116,114,102,105,110,100, 40,115,116,114,105,110,103,
+     46,103,115,117, 98, 40,115, 44, 32, 39, 37, 98, 60, 62, 39,
+     44, 32, 39, 39, 41, 44, 39, 91, 37, 42, 38, 93, 39, 41, 32,
+    116,104,101,110, 10,116,111,108,117, 97, 95,101,114,114,111,
+    114, 40, 34, 35,105,110,118, 97,108,105,100, 32,116,121,112,
+    101,100,101,102, 58, 32,112,111,105,110,116,101,114,115, 32,
+     40, 97,110,100, 32,114,101,102,101,114,101,110, 99,101,115,
+     41, 32, 97,114,101, 32,110,111,116, 32,115,117,112,112,111,
+    114,116,101,100, 34, 41, 10,101,110,100, 10,108,111, 99, 97,
+    108, 32,111, 32, 61, 32,123,109,111,100, 32, 61, 32, 39, 39,
+    125, 10,105,102, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,115, 44, 32, 34, 91, 60, 62, 93, 34, 41, 32,116,104,
+    101,110, 10, 95, 44, 95, 44,111, 46,116,121,112,101, 44,111,
+     46,117,116,121,112,101, 32, 61, 32,115,116,114,105,110,103,
+     46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 40,
+     91, 94, 60, 62, 93, 43, 37, 98, 60, 62, 91, 94, 37,115, 93,
+     42, 41, 37,115, 43, 40, 46, 45, 41, 36, 34, 41, 10,101,108,
+    115,101, 10,108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,
+    108,105,116, 40,103,115,117, 98, 40,115, 44, 34, 37,115, 37,
+    115, 42, 34, 44, 34, 32, 34, 41, 44, 34, 32, 34, 41, 10,111,
+     32, 61, 32,123, 10,117,116,121,112,101, 32, 61, 32,116, 91,
+    116, 46,110, 93, 44, 10,116,121,112,101, 32, 61, 32,116, 91,
+    116, 46,110, 45, 49, 93, 44, 10,109,111,100, 32, 61, 32, 99,
+    111,110, 99, 97,116, 40,116, 44, 49, 44,116, 46,110, 45, 50,
+     41, 44, 10,125, 10,101,110,100, 10,114,101,116,117,114,110,
+     32, 95, 84,121,112,101,100,101,102, 40,111, 41, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/typedef.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,103,108,111, 98, 97,108, 95,116,121,112,101,100,101,102,
+    115, 32, 61, 32,123,125, 10,103,108,111, 98, 97,108, 95,101,
+    110,117,109,115, 32, 61, 32,123,125, 10, 99,108, 97,115,115,
+     67,111,110,116, 97,105,110,101,114, 32, 61, 10,123, 10, 99,
+    117,114,114, 32, 61, 32,110,105,108, 44, 10,125, 10, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 95, 95,
+    105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40, 99,108, 97,115,115, 67,111,110,116,
+     97,105,110,101,114, 44, 99,108, 97,115,115, 70,101, 97,116,
+    117,114,101, 41, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,100,
+    101, 99,108,116,121,112,101, 32, 40, 41, 10,112,117,115,104,
+     40,115,101,108,102, 41, 10,108,111, 99, 97,108, 32,105, 61,
+     49, 10,119,104,105,108,101, 32,115,101,108,102, 91,105, 93,
+     32,100,111, 10,115,101,108,102, 91,105, 93, 58,100,101, 99,
+    108,116,121,112,101, 40, 41, 10,105, 32, 61, 32,105, 43, 49,
+     10,101,110,100, 10,112,111,112, 40, 41, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 58,115,117,112, 99,111,100,
+    101, 32, 40, 41, 10,105,102, 32,110,111,116, 32,115,101,108,
+    102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, 95,
+     97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10,114,
+    101,116,117,114,110, 10,101,110,100, 10,112,117,115,104, 40,
+    115,101,108,102, 41, 10,108,111, 99, 97,108, 32,105, 61, 49,
+     10,119,104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,
+    100,111, 10,105,102, 32,115,101,108,102, 91,105, 93, 58, 99,
+    104,101, 99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, 99,
+    101,115,115, 40, 41, 32,116,104,101,110, 10,115,101,108,102,
+     91,105, 93, 58,115,117,112, 99,111,100,101, 40, 41, 10,101,
+    110,100, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,100, 10,
+    112,111,112, 40, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 58,104, 97,115,118, 97,114, 32, 40, 41, 10,108,
+    111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101, 32,
+    115,101,108,102, 91,105, 93, 32,100,111, 10,105,102, 32,115,
+    101,108,102, 91,105, 93, 58,105,115,118, 97,114,105, 97, 98,
+    108,101, 40, 41, 32,116,104,101,110, 10,114,101,116,117,114,
+    110, 32, 49, 10,101,110,100, 10,105, 32, 61, 32,105, 43, 49,
+     10,101,110,100, 10,114,101,116,117,114,110, 32, 48, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 95, 67,111,
+    110,116, 97,105,110,101,114, 32, 40,115,101,108,102, 41, 10,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,115,101,
+    108,102, 44, 99,108, 97,115,115, 67,111,110,116, 97,105,110,
+    101,114, 41, 10,115,101,108,102, 46,110, 32, 61, 32, 48, 10,
+    115,101,108,102, 46,116,121,112,101,100,101,102,115, 32, 61,
+     32,123,116,111,108,117, 97, 95,110, 61, 48,125, 10,115,101,
+    108,102, 46,117,115,101,114,116,121,112,101,115, 32, 61, 32,
+    123,125, 10,115,101,108,102, 46,101,110,117,109,115, 32, 61,
+     32,123,116,111,108,117, 97, 95,110, 61, 48,125, 10,115,101,
+    108,102, 46,108,110, 97,109,101,115, 32, 61, 32,123,125, 10,
+    114,101,116,117,114,110, 32,115,101,108,102, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,112,117,115,104, 32,
+     40,116, 41, 10,116, 46,112,114,111,120, 32, 61, 32, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,
+    114,114, 10, 99,108, 97,115,115, 67,111,110,116, 97,105,110,
+    101,114, 46, 99,117,114,114, 32, 61, 32,116, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,112,111,112, 32, 40,
+     41, 10, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 46, 99,117,114,114, 32, 61, 32, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 46, 99,117,114,114, 46,112,
+    114,111,120, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32,103,101,116, 99,117,114,114,110, 97,109,101,115,112,
+     97, 99,101, 32, 40, 41, 10,114,101,116,117,114,110, 32,103,
+    101,116,110, 97,109,101,115,112, 97, 99,101, 40, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,
+    114, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 97,112,112,101,110,100, 32, 40,116, 41, 10,114,101,116,
+    117,114,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 46, 99,117,114,114, 58, 97,112,112,101,110,100,
+     40,116, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 97,112,112,101,110,100,116,121,112,101,100,101,102,
+     32, 40,116, 41, 10,114,101,116,117,114,110, 32, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,
+    114, 58, 97,112,112,101,110,100,116,121,112,101,100,101,102,
+     40,116, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 97,112,112,101,110,100,117,115,101,114,116,121,112,
+    101, 32, 40,116, 41, 10,114,101,116,117,114,110, 32, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,
+    114,114, 58, 97,112,112,101,110,100,117,115,101,114,116,121,
+    112,101, 40,116, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 97,112,112,101,110,100,101,110,117,109, 32,
+     40,116, 41, 10,114,101,116,117,114,110, 32, 99,108, 97,115,
+    115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,114,
+     58, 97,112,112,101,110,100,101,110,117,109, 40,116, 41, 10,
+    101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 97,112,
+    112,108,121,116,121,112,101,100,101,102, 32, 40,109,111,100,
+     44,116,121,112,101, 41, 10,114,101,116,117,114,110, 32, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,
+    117,114,114, 58, 97,112,112,108,121,116,121,112,101,100,101,
+    102, 40,109,111,100, 44,116,121,112,101, 41, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,102,105,110,100,116,
+    121,112,101, 32, 40,116,121,112,101, 41, 10,108,111, 99, 97,
+    108, 32,116, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116,
+     97,105,110,101,114, 46, 99,117,114,114, 58,102,105,110,100,
+    116,121,112,101, 40,116,121,112,101, 41, 10,114,101,116,117,
+    114,110, 32,116, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32,105,115,116,121,112,101,100,101,102, 32, 40,116,
+    121,112,101, 41, 10,114,101,116,117,114,110, 32, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,
+    114, 58,105,115,116,121,112,101,100,101,102, 40,116,121,112,
+    101, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32,102,117,108,108,116,121,112,101, 32, 40,116, 41, 10,108,
+    111, 99, 97,108, 32, 99,117,114,114, 32, 61, 32, 99,108, 97,
+    115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,117,114,
+    114, 10,119,104,105,108,101, 32, 99,117,114,114, 32,100,111,
+     10,105,102, 32, 99,117,114,114, 32,116,104,101,110, 10,105,
+    102, 32, 99,117,114,114, 46,116,121,112,101,100,101,102,115,
+     32, 97,110,100, 32, 99,117,114,114, 46,116,121,112,101,100,
+    101,102,115, 91,116, 93, 32,116,104,101,110, 10,114,101,116,
+    117,114,110, 32, 99,117,114,114, 46,116,121,112,101,100,101,
+    102,115, 91,116, 93, 10,101,108,115,101,105,102, 32, 99,117,
+    114,114, 46,117,115,101,114,116,121,112,101,115, 32, 97,110,
+    100, 32, 99,117,114,114, 46,117,115,101,114,116,121,112,101,
+    115, 91,116, 93, 32,116,104,101,110, 10,114,101,116,117,114,
+    110, 32, 99,117,114,114, 46,117,115,101,114,116,121,112,101,
+    115, 91,116, 93, 10,101,110,100, 10,101,110,100, 10, 99,117,
+    114,114, 32, 61, 32, 99,117,114,114, 46,112,114,111,120, 10,
+    101,110,100, 10,114,101,116,117,114,110, 32,116, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 67,111,110,116, 97,105,110,101,114, 58,114,101,113,117,
+    105,114,101, 99,111,108,108,101, 99,116,105,111,110, 32, 40,
+    116, 41, 10,112,117,115,104, 40,115,101,108,102, 41, 10,108,
+    111, 99, 97,108, 32,105, 61, 49, 10,108,111, 99, 97,108, 32,
+    114, 32, 61, 32,102, 97,108,115,101, 10,119,104,105,108,101,
+     32,115,101,108,102, 91,105, 93, 32,100,111, 10,114, 32, 61,
+     32,115,101,108,102, 91,105, 93, 58,114,101,113,117,105,114,
+    101, 99,111,108,108,101, 99,116,105,111,110, 40,116, 41, 32,
+    111,114, 32,114, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,
+    100, 10,112,111,112, 40, 41, 10,114,101,116,117,114,110, 32,
+    114, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+    103,101,116,110, 97,109,101,115,112, 97, 99,101, 32, 40, 99,
+    117,114,114, 41, 10,108,111, 99, 97,108, 32,110, 97,109,101,
+    115,112, 97, 99,101, 32, 61, 32, 39, 39, 10,119,104,105,108,
+    101, 32, 99,117,114,114, 32,100,111, 10,105,102, 32, 99,117,
+    114,114, 32, 97,110,100, 10, 40, 32, 99,117,114,114, 46, 99,
+    108, 97,115,115,116,121,112,101, 32, 61, 61, 32, 39, 99,108,
+     97,115,115, 39, 32,111,114, 32, 99,117,114,114, 46, 99,108,
+     97,115,115,116,121,112,101, 32, 61, 61, 32, 39,110, 97,109,
+    101,115,112, 97, 99,101, 39, 41, 10,116,104,101,110, 10,110,
+     97,109,101,115,112, 97, 99,101, 32, 61, 32, 40, 99,117,114,
+    114, 46,111,114,105,103,105,110, 97,108, 95,110, 97,109,101,
+     32,111,114, 32, 99,117,114,114, 46,110, 97,109,101, 41, 32,
+     46, 46, 32, 39, 58, 58, 39, 32, 46, 46, 32,110, 97,109,101,
+    115,112, 97, 99,101, 10,101,110,100, 10, 99,117,114,114, 32,
+     61, 32, 99,117,114,114, 46,112,114,111,120, 10,101,110,100,
+     10,114,101,116,117,114,110, 32,110, 97,109,101,115,112, 97,
+     99,101, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32,103,101,116,111,110,108,121,110, 97,109,101,115,112, 97,
+     99,101, 32, 40, 41, 10,108,111, 99, 97,108, 32, 99,117,114,
+    114, 32, 61, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 46, 99,117,114,114, 10,108,111, 99, 97,108, 32,
+    110, 97,109,101,115,112, 97, 99,101, 32, 61, 32, 39, 39, 10,
+    119,104,105,108,101, 32, 99,117,114,114, 32,100,111, 10,105,
+    102, 32, 99,117,114,114, 46, 99,108, 97,115,115,116,121,112,
+    101, 32, 61, 61, 32, 39, 99,108, 97,115,115, 39, 32,116,104,
+    101,110, 10,114,101,116,117,114,110, 32,110, 97,109,101,115,
+    112, 97, 99,101, 10,101,108,115,101,105,102, 32, 99,117,114,
+    114, 46, 99,108, 97,115,115,116,121,112,101, 32, 61, 61, 32,
+     39,110, 97,109,101,115,112, 97, 99,101, 39, 32,116,104,101,
+    110, 10,110, 97,109,101,115,112, 97, 99,101, 32, 61, 32, 99,
+    117,114,114, 46,110, 97,109,101, 32, 46, 46, 32, 39, 58, 58,
+     39, 32, 46, 46, 32,110, 97,109,101,115,112, 97, 99,101, 10,
+    101,110,100, 10, 99,117,114,114, 32, 61, 32, 99,117,114,114,
+     46,112,114,111,120, 10,101,110,100, 10,114,101,116,117,114,
+    110, 32,110, 97,109,101,115,112, 97, 99,101, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,105,115,101,110,117,
+    109, 32, 40,116,121,112,101, 41, 10,114,101,116,117,114,110,
+     32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     46, 99,117,114,114, 58,105,115,101,110,117,109, 40,116,121,
+    112,101, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 58, 97,112,112,101,110,100, 32, 40,116, 41, 10,115,101,
+    108,102, 46,110, 32, 61, 32,115,101,108,102, 46,110, 32, 43,
+     32, 49, 10,115,101,108,102, 91,115,101,108,102, 46,110, 93,
+     32, 61, 32,116, 10,116, 46,112, 97,114,101,110,116, 32, 61,
+     32,115,101,108,102, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 58, 97,112,112,101,110,100,116,121,112,101,100,
+    101,102, 32, 40,116, 41, 10,108,111, 99, 97,108, 32,110, 97,
+    109,101,115,112, 97, 99,101, 32, 61, 32,103,101,116,110, 97,
+    109,101,115,112, 97, 99,101, 40, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 46, 99,117,114,114, 41, 10,115,
+    101,108,102, 46,116,121,112,101,100,101,102,115, 46,116,111,
+    108,117, 97, 95,110, 32, 61, 32,115,101,108,102, 46,116,121,
+    112,101,100,101,102,115, 46,116,111,108,117, 97, 95,110, 32,
+     43, 32, 49, 10,115,101,108,102, 46,116,121,112,101,100,101,
+    102,115, 91,115,101,108,102, 46,116,121,112,101,100,101,102,
+    115, 46,116,111,108,117, 97, 95,110, 93, 32, 61, 32,116, 10,
+    115,101,108,102, 46,116,121,112,101,100,101,102,115, 91,116,
+     46,117,116,121,112,101, 93, 32, 61, 32,110, 97,109,101,115,
+    112, 97, 99,101, 32, 46, 46, 32,116, 46,117,116,121,112,101,
+     10,103,108,111, 98, 97,108, 95,116,121,112,101,100,101,102,
+    115, 91,110, 97,109,101,115,112, 97, 99,101, 46, 46,116, 46,
+    117,116,121,112,101, 93, 32, 61, 32,116, 10,116, 46,102,116,
+    121,112,101, 32, 61, 32,102,105,110,100,116,121,112,101, 40,
+    116, 46,116,121,112,101, 41, 32,111,114, 32,116, 46,116,121,
+    112,101, 10, 97,112,112,101,110,100, 95,103,108,111, 98, 97,
+    108, 95,116,121,112,101, 40,110, 97,109,101,115,112, 97, 99,
+    101, 46, 46,116, 46,117,116,121,112,101, 41, 10,105,102, 32,
+    116, 46,102,116,121,112,101, 32, 97,110,100, 32,105,115,101,
+    110,117,109, 40,116, 46,102,116,121,112,101, 41, 32,116,104,
+    101,110, 10,103,108,111, 98, 97,108, 95,101,110,117,109,115,
+     91,110, 97,109,101,115,112, 97, 99,101, 46, 46,116, 46,117,
+    116,121,112,101, 93, 32, 61, 32,116,114,117,101, 10,101,110,
+    100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,
+     97,112,112,101,110,100,117,115,101,114,116,121,112,101, 32,
+     40,116, 41, 10,108,111, 99, 97,108, 32, 99,111,110,116, 97,
+    105,110,101,114, 10,105,102, 32,116, 32, 61, 61, 32, 40,115,
+    101,108,102, 46,111,114,105,103,105,110, 97,108, 95,110, 97,
+    109,101, 32,111,114, 32,115,101,108,102, 46,110, 97,109,101,
+     41, 32,116,104,101,110, 10, 99,111,110,116, 97,105,110,101,
+    114, 32, 61, 32,115,101,108,102, 46,112,114,111,120, 10,101,
+    108,115,101, 10, 99,111,110,116, 97,105,110,101,114, 32, 61,
+     32,115,101,108,102, 10,101,110,100, 10,108,111, 99, 97,108,
+     32,102,116, 32, 61, 32,103,101,116,110, 97,109,101,115,112,
+     97, 99,101, 40, 99,111,110,116, 97,105,110,101,114, 41, 32,
+     46, 46, 32,116, 10, 99,111,110,116, 97,105,110,101,114, 46,
+    117,115,101,114,116,121,112,101,115, 91,116, 93, 32, 61, 32,
+    102,116, 10, 95,117,115,101,114,116,121,112,101, 91,102,116,
+     93, 32, 61, 32,102,116, 10,114,101,116,117,114,110, 32,102,
+    116, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,
+     97,112,112,101,110,100,101,110,117,109, 32, 40,116, 41, 10,
+    108,111, 99, 97,108, 32,110, 97,109,101,115,112, 97, 99,101,
+     32, 61, 32,103,101,116,110, 97,109,101,115,112, 97, 99,101,
+     40, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     46, 99,117,114,114, 41, 10,115,101,108,102, 46,101,110,117,
+    109,115, 46,116,111,108,117, 97, 95,110, 32, 61, 32,115,101,
+    108,102, 46,101,110,117,109,115, 46,116,111,108,117, 97, 95,
+    110, 32, 43, 32, 49, 10,115,101,108,102, 46,101,110,117,109,
+    115, 91,115,101,108,102, 46,101,110,117,109,115, 46,116,111,
+    108,117, 97, 95,110, 93, 32, 61, 32,116, 10,103,108,111, 98,
+     97,108, 95,101,110,117,109,115, 91,110, 97,109,101,115,112,
+     97, 99,101, 46, 46,116, 46,110, 97,109,101, 93, 32, 61, 32,
+    116, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,
+    111,118,101,114,108,111, 97,100, 32, 40,108,110, 97,109,101,
+     41, 10,105,102, 32,110,111,116, 32,115,101,108,102, 46,108,
+    110, 97,109,101,115, 91,108,110, 97,109,101, 93, 32,116,104,
+    101,110, 10,115,101,108,102, 46,108,110, 97,109,101,115, 91,
+    108,110, 97,109,101, 93, 32, 61, 32, 48, 10,101,108,115,101,
+     10,115,101,108,102, 46,108,110, 97,109,101,115, 91,108,110,
+     97,109,101, 93, 32, 61, 32,115,101,108,102, 46,108,110, 97,
+    109,101,115, 91,108,110, 97,109,101, 93, 32, 43, 32, 49, 10,
+    101,110,100, 10,114,101,116,117,114,110, 32,102,111,114,109,
+     97,116, 40, 34, 37, 48, 50,100, 34, 44,115,101,108,102, 46,
+    108,110, 97,109,101,115, 91,108,110, 97,109,101, 93, 41, 10,
+    101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 67,111,110,116, 97,105,110,101,114, 58, 97,112,
+    112,108,121,116,121,112,101,100,101,102, 32, 40,109,111,100,
+     44,116,121,112,101, 41, 10,105,102, 32,103,108,111, 98, 97,
+    108, 95,116,121,112,101,100,101,102,115, 91,116,121,112,101,
+     93, 32,116,104,101,110, 10,108,111, 99, 97,108, 32,109,111,
+    100, 49, 44, 32,116,121,112,101, 49, 32, 61, 32,103,108,111,
+     98, 97,108, 95,116,121,112,101,100,101,102,115, 91,116,121,
+    112,101, 93, 46,109,111,100, 44, 32,103,108,111, 98, 97,108,
+     95,116,121,112,101,100,101,102,115, 91,116,121,112,101, 93,
+     46,102,116,121,112,101, 10,108,111, 99, 97,108, 32,109,111,
+    100, 50, 44, 32,116,121,112,101, 50, 32, 61, 32, 97,112,112,
+    108,121,116,121,112,101,100,101,102, 40,109,111,100, 46, 46,
+     34, 32, 34, 46, 46,109,111,100, 49, 44, 32,116,121,112,101,
+     49, 41, 10,114,101,116,117,114,110, 32,109,111,100, 50, 44,
+     32,116,121,112,101, 50, 10,101,110,100, 10,100,111, 32,114,
+    101,116,117,114,110, 32,109,111,100, 44,116,121,112,101, 32,
+    101,110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 58,105,115,116,121,112,101,100,101,102, 32, 40,116,121,
+    112,101, 41, 10,108,111, 99, 97,108, 32,101,110,118, 32, 61,
+     32,115,101,108,102, 10,119,104,105,108,101, 32,101,110,118,
+     32,100,111, 10,105,102, 32,101,110,118, 46,116,121,112,101,
+    100,101,102,115, 32,116,104,101,110, 10,108,111, 99, 97,108,
+     32,105, 61, 49, 10,119,104,105,108,101, 32,101,110,118, 46,
+    116,121,112,101,100,101,102,115, 91,105, 93, 32,100,111, 10,
+    105,102, 32,101,110,118, 46,116,121,112,101,100,101,102,115,
+     91,105, 93, 46,117,116,121,112,101, 32, 61, 61, 32,116,121,
+    112,101, 32,116,104,101,110, 10,114,101,116,117,114,110, 32,
+    116,121,112,101, 10,101,110,100, 10,105, 32, 61, 32,105, 43,
+     49, 10,101,110,100, 10,101,110,100, 10,101,110,118, 32, 61,
+     32,101,110,118, 46,112, 97,114,101,110,116, 10,101,110,100,
+     10,114,101,116,117,114,110, 32,110,105,108, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32,102,105,110,100, 95,
+    101,110,117,109, 95,118, 97,114, 40,118, 97,114, 41, 10,105,
+    102, 32,116,111,110,117,109, 98,101,114, 40,118, 97,114, 41,
+     32,116,104,101,110, 32,114,101,116,117,114,110, 32,118, 97,
+    114, 32,101,110,100, 10,108,111, 99, 97,108, 32, 99, 32, 61,
+     32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     46, 99,117,114,114, 10,119,104,105,108,101, 32, 99, 32,100,
+    111, 10,108,111, 99, 97,108, 32,110,115, 32, 61, 32,103,101,
+    116,110, 97,109,101,115,112, 97, 99,101, 40, 99, 41, 10,102,
+    111,114, 32,107, 44,118, 32,105,110, 32,112, 97,105,114,115,
+     40, 95,103,108,111, 98, 97,108, 95,101,110,117,109,115, 41,
+     32,100,111, 10,105,102, 32,109, 97,116, 99,104, 95,116,121,
+    112,101, 40,118, 97,114, 44, 32,118, 44, 32,110,115, 41, 32,
+    116,104,101,110, 10,114,101,116,117,114,110, 32,118, 10,101,
+    110,100, 10,101,110,100, 10,105,102, 32, 99, 46, 98, 97,115,
+    101, 32, 97,110,100, 32, 99, 46, 98, 97,115,101, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10, 99, 32, 61, 32, 95,103,
+    108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91, 99,
+     58,102,105,110,100,116,121,112,101, 40, 99, 46, 98, 97,115,
+    101, 41, 93, 10,101,108,115,101, 10, 99, 32, 61, 32,110,105,
+    108, 10,101,110,100, 10,101,110,100, 10,114,101,116,117,114,
+    110, 32,118, 97,114, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 58,102,105,110,100,116,121,112,101, 32, 40,116,
+     41, 10,116, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40,116, 44, 32, 34, 61, 46, 42, 34, 44, 32, 34, 34,
+     41, 10,105,102, 32, 95, 98, 97,115,105, 99, 91,116, 93, 32,
+    116,104,101,110, 10,114,101,116,117,114,110, 32,116, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32, 95, 44, 95, 44,101,109,
+     32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    116, 44, 32, 34, 40, 91, 38, 37, 42, 93, 41, 37,115, 42, 36,
+     34, 41, 10,116, 32, 61, 32,115,116,114,105,110,103, 46,103,
+    115,117, 98, 40,116, 44, 32, 34, 37,115, 42, 40, 91, 38, 37,
+     42, 93, 41, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 10,112,
+     32, 61, 32,115,101,108,102, 10,119,104,105,108,101, 32,112,
+     32, 97,110,100, 32,116,121,112,101, 40,112, 41, 61, 61, 39,
+    116, 97, 98,108,101, 39, 32,100,111, 10,108,111, 99, 97,108,
+     32,115,116, 32, 61, 32,103,101,116,110, 97,109,101,115,112,
+     97, 99,101, 40,112, 41, 10,102,111,114, 32,105, 61, 95,103,
+    108,111, 98, 97,108, 95,116,121,112,101,115, 46,110, 44, 49,
+     44, 45, 49, 32,100,111, 10,105,102, 32,109, 97,116, 99,104,
+     95,116,121,112,101, 40,116, 44, 32, 95,103,108,111, 98, 97,
+    108, 95,116,121,112,101,115, 91,105, 93, 44, 32,115,116, 41,
+     32,116,104,101,110, 10,114,101,116,117,114,110, 32, 95,103,
+    108,111, 98, 97,108, 95,116,121,112,101,115, 91,105, 93, 46,
+     46, 40,101,109, 32,111,114, 32, 34, 34, 41, 10,101,110,100,
+     10,101,110,100, 10,105,102, 32,112, 46, 98, 97,115,101, 32,
+     97,110,100, 32,112, 46, 98, 97,115,101, 32,126, 61, 32, 39,
+     39, 32, 97,110,100, 32,112, 46, 98, 97,115,101, 32,126, 61,
+     32,116, 32,116,104,101,110, 10,112, 32, 61, 32, 95,103,108,
+    111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,112, 58,
+    102,105,110,100,116,121,112,101, 40,112, 46, 98, 97,115,101,
+     41, 93, 10,101,108,115,101, 10,112, 32, 61, 32,110,105,108,
+     10,101,110,100, 10,101,110,100, 10,114,101,116,117,114,110,
+     32,110,105,108, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 97,112,112,101,110,100, 95,103,108,111, 98, 97,
+    108, 95,116,121,112,101, 40,116, 44, 32, 99,108, 97,115,115,
+     41, 10, 95,103,108,111, 98, 97,108, 95,116,121,112,101,115,
+     46,110, 32, 61, 32, 95,103,108,111, 98, 97,108, 95,116,121,
+    112,101,115, 46,110, 32, 43, 49, 10, 95,103,108,111, 98, 97,
+    108, 95,116,121,112,101,115, 91, 95,103,108,111, 98, 97,108,
+     95,116,121,112,101,115, 46,110, 93, 32, 61, 32,116, 10, 95,
+    103,108,111, 98, 97,108, 95,116,121,112,101,115, 95,104, 97,
+    115,104, 91,116, 93, 32, 61, 32, 49, 10,105,102, 32, 99,108,
+     97,115,115, 32,116,104,101,110, 32, 97,112,112,101,110,100,
+     95, 99,108, 97,115,115, 95,116,121,112,101, 40,116, 44, 32,
+     99,108, 97,115,115, 41, 32,101,110,100, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 97,112,112,101,110,100,
+     95, 99,108, 97,115,115, 95,116,121,112,101, 40,116, 44, 99,
+    108, 97,115,115, 41, 10,105,102, 32, 95,103,108,111, 98, 97,
+    108, 95, 99,108, 97,115,115,101,115, 91,116, 93, 32,116,104,
+    101,110, 10, 99,108, 97,115,115, 46,102,108, 97,103,115, 32,
+     61, 32, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,115,
+    101,115, 91,116, 93, 46,102,108, 97,103,115, 10, 99,108, 97,
+    115,115, 46,108,110, 97,109,101,115, 32, 61, 32, 95,103,108,
+    111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,116, 93,
+     46,108,110, 97,109,101,115, 10,105,102, 32, 95,103,108,111,
+     98, 97,108, 95, 99,108, 97,115,115,101,115, 91,116, 93, 46,
+     98, 97,115,101, 32, 97,110,100, 32, 40, 95,103,108,111, 98,
+     97,108, 95, 99,108, 97,115,115,101,115, 91,116, 93, 46, 98,
+     97,115,101, 32,126, 61, 32, 39, 39, 41, 32,116,104,101,110,
+     10, 99,108, 97,115,115, 46, 98, 97,115,101, 32, 61, 32, 95,
+    103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115, 91,
+    116, 93, 46, 98, 97,115,101, 32,111,114, 32, 99,108, 97,115,
+    115, 46, 98, 97,115,101, 10,101,110,100, 10,101,110,100, 10,
+     95,103,108,111, 98, 97,108, 95, 99,108, 97,115,115,101,115,
+     91,116, 93, 32, 61, 32, 99,108, 97,115,115, 10, 99,108, 97,
+    115,115, 46,102,108, 97,103,115, 32, 61, 32, 99,108, 97,115,
+    115, 46,102,108, 97,103,115, 32,111,114, 32,123,125, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32,109, 97,116,
+     99,104, 95,116,121,112,101, 40, 99,104,105,108,100,116,121,
+    112,101, 44, 32,114,101,103,116,121,112,101, 44, 32,115,116,
+     41, 10,108,111, 99, 97,108, 32, 98, 44,101, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,114,101,103,116,
+    121,112,101, 44, 32, 99,104,105,108,100,116,121,112,101, 44,
+     32, 45,115,116,114,105,110,103, 46,108,101,110, 40, 99,104,
+    105,108,100,116,121,112,101, 41, 44, 32,116,114,117,101, 41,
+     10,105,102, 32, 98, 32,116,104,101,110, 10,105,102, 32,101,
+     32, 61, 61, 32,115,116,114,105,110,103, 46,108,101,110, 40,
+    114,101,103,116,121,112,101, 41, 32, 97,110,100, 10, 40, 98,
+     32, 61, 61, 32, 49, 32,111,114, 32, 40,115,116,114,105,110,
+    103, 46,115,117, 98, 40,114,101,103,116,121,112,101, 44, 32,
+     98, 45, 49, 44, 32, 98, 45, 49, 41, 32, 61, 61, 32, 39, 58,
+     39, 32, 97,110,100, 10,115,116,114,105,110,103, 46,115,117,
+     98, 40,114,101,103,116,121,112,101, 44, 32, 49, 44, 32, 98,
+     45, 49, 41, 32, 61, 61, 32,115,116,114,105,110,103, 46,115,
+    117, 98, 40,115,116, 44, 32, 49, 44, 32, 98, 45, 49, 41, 41,
+     41, 32,116,104,101,110, 10,114,101,116,117,114,110, 32,116,
+    114,117,101, 10,101,110,100, 10,101,110,100, 10,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32,102,105,110,100,116,121,112,
+    101, 95,111,110, 95, 99,104,105,108,100,115, 40,115,101,108,
+    102, 44, 32,116, 41, 10,108,111, 99, 97,108, 32,116, 99,104,
+    105,108,100, 10,105,102, 32,115,101,108,102, 46, 99,108, 97,
+    115,115,116,121,112,101, 32, 61, 61, 32, 39, 99,108, 97,115,
+    115, 39, 32,111,114, 32,115,101,108,102, 46, 99,108, 97,115,
+    115,116,121,112,101, 32, 61, 61, 32, 39,110, 97,109,101,115,
+    112, 97, 99,101, 39, 32,116,104,101,110, 10,102,111,114, 32,
+    107, 44,118, 32,105,110, 32,105,112, 97,105,114,115, 40,115,
+    101,108,102, 41, 32,100,111, 10,105,102, 32,118, 46, 99,108,
+     97,115,115,116,121,112,101, 32, 61, 61, 32, 39, 99,108, 97,
+    115,115, 39, 32,111,114, 32,118, 46, 99,108, 97,115,115,116,
+    121,112,101, 32, 61, 61, 32, 39,110, 97,109,101,115,112, 97,
+     99,101, 39, 32,116,104,101,110, 10,105,102, 32,118, 46,116,
+    121,112,101,100,101,102,115, 32, 97,110,100, 32,118, 46,116,
+    121,112,101,100,101,102,115, 91,116, 93, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 32,118, 46,116,121,112,101,100,
+    101,102,115, 91,116, 93, 10,101,108,115,101,105,102, 32,118,
+     46,117,115,101,114,116,121,112,101,115, 32, 97,110,100, 32,
+    118, 46,117,115,101,114,116,121,112,101,115, 91,116, 93, 32,
+    116,104,101,110, 10,114,101,116,117,114,110, 32,118, 46,117,
+    115,101,114,116,121,112,101,115, 91,116, 93, 10,101,110,100,
+     10,116, 99,104,105,108,100, 32, 61, 32,102,105,110,100,116,
+    121,112,101, 95,111,110, 95, 99,104,105,108,100,115, 40,118,
+     44, 32,116, 41, 10,105,102, 32,116, 99,104,105,108,100, 32,
+    116,104,101,110, 32,114,101,116,117,114,110, 32,116, 99,104,
+    105,108,100, 32,101,110,100, 10,101,110,100, 10,101,110,100,
+     10,101,110,100, 10,114,101,116,117,114,110, 32,110,105,108,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 58,105,
+    115,101,110,117,109, 32, 40,116,121,112,101, 41, 10,105,102,
+     32,103,108,111, 98, 97,108, 95,101,110,117,109,115, 91,116,
+    121,112,101, 93, 32,116,104,101,110, 10,114,101,116,117,114,
+    110, 32,116,121,112,101, 10,101,108,115,101, 10,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32, 98, 97,115,101,116,121,112,101, 32, 61,
+     32,103,115,117, 98, 40,116,121,112,101, 44, 34, 94, 46, 42,
+     58, 58, 34, 44, 34, 34, 41, 10,108,111, 99, 97,108, 32,101,
+    110,118, 32, 61, 32,115,101,108,102, 10,119,104,105,108,101,
+     32,101,110,118, 32,100,111, 10,105,102, 32,101,110,118, 46,
+    101,110,117,109,115, 32,116,104,101,110, 10,108,111, 99, 97,
+    108, 32,105, 61, 49, 10,119,104,105,108,101, 32,101,110,118,
+     46,101,110,117,109,115, 91,105, 93, 32,100,111, 10,105,102,
+     32,101,110,118, 46,101,110,117,109,115, 91,105, 93, 46,110,
+     97,109,101, 32, 61, 61, 32, 98, 97,115,101,116,121,112,101,
+     32,116,104,101,110, 10,114,101,116,117,114,110, 32,116,114,
+    117,101, 10,101,110,100, 10,105, 32, 61, 32,105, 43, 49, 10,
+    101,110,100, 10,101,110,100, 10,101,110,118, 32, 61, 32,101,
+    110,118, 46,112, 97,114,101,110,116, 10,101,110,100, 10,114,
+    101,116,117,114,110, 32,102, 97,108,115,101, 10,101,110,100,
+     10,109,101,116,104,111,100,105,115,118,105,114,116,117, 97,
+    108, 32, 61, 32,102, 97,108,115,101, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,
+    110,101,114, 58,100,111,112, 97,114,115,101, 32, 40,115, 41,
+     10,100,111, 10,108,111, 99, 97,108, 32,115,117, 98, 32, 61,
+     32,112, 97,114,115,101,114, 95,104,111,111,107, 40,115, 41,
+     10,105,102, 32,115,117, 98, 32,116,104,101,110, 10,114,101,
+    116,117,114,110, 32,115,117, 98, 10,101,110,100, 10,101,110,
+    100, 10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,
+     99,111,100,101, 32, 61, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 59, 34, 41,
+     10,105,102, 32, 98, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49,
+     41, 10,101,110,100, 10,101,110,100, 10,100,111, 10,108,111,
+     99, 97,108, 32, 98, 44,101, 44, 99,111,100,101, 32, 61, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32,
+     34, 94, 37,115, 42, 36, 92,110, 34, 41, 10,105,102, 32, 98,
+     32,116,104,101,110, 10,114,101,116,117,114,110, 32,115,116,
+    114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,101,110,100,
+     10,101,110,100, 10,100,111, 10,108,111, 99, 97,108, 32, 98,
+     44,101, 44, 99,111,100,101, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 37, 98, 92, 49,
+     92, 50, 41, 34, 41, 10,105,102, 32, 98, 32,116,104,101,110,
+     10, 67,111,100,101, 40,115,116,114,115,117, 98, 40, 99,111,
+    100,101, 44, 50, 44, 45, 50, 41, 41, 10,114,101,116,117,114,
+    110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41,
+     10,101,110,100, 10,101,110,100, 10,100,111, 10,108,111, 99,
+     97,108, 32, 98, 44,101, 44, 99,111,100,101, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40,
+     37, 98, 92, 51, 92, 52, 41, 34, 41, 10,105,102, 32, 98, 32,
+    116,104,101,110, 10, 99,111,100,101, 32, 61, 32, 39,123, 39,
+     46, 46,115,116,114,115,117, 98, 40, 99,111,100,101, 44, 50,
+     44, 45, 50, 41, 46, 46, 39, 92,110,125, 92,110, 39, 10, 86,
+    101,114, 98, 97,116,105,109, 40, 99,111,100,101, 44, 39,114,
+     39, 41, 10,114,101,116,117,114,110, 32,115,116,114,115,117,
+     98, 40,115, 44,101, 43, 49, 41, 10,101,110,100, 10,101,110,
+    100, 10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,
+     99,111,100,101, 32, 61, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 40, 37, 98,
+     92, 53, 92, 54, 41, 34, 41, 10,105,102, 32, 98, 32,116,104,
+    101,110, 10, 99,111,100,101, 32, 61, 32,115,116,114,105,110,
+    103, 46,115,117, 98, 40, 99,111,100,101, 44, 32, 50, 44, 32,
+     45, 50, 41, 46, 46, 34, 92,110, 34, 10, 86,101,114, 98, 97,
+    116,105,109, 40, 99,111,100,101, 44, 32, 39, 39, 41, 10,114,
+    101,116,117,114,110, 32,115,116,114,105,110,103, 46,115,117,
+     98, 40,115, 44, 32,101, 43, 49, 41, 10,101,110,100, 10,101,
+    110,100, 10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101,
+     44,112,116,121,112,101, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 32, 34, 94, 37,115, 42, 84, 79, 76, 85, 65,
+     95, 80, 82, 79, 80, 69, 82, 84, 89, 95, 84, 89, 80, 69, 37,
+    115, 42, 37, 40, 43, 37,115, 42, 40, 91, 94, 37, 41, 37,115,
+     93, 42, 41, 37,115, 42, 37, 41, 43, 37,115, 42, 59, 63, 34,
+     41, 10,105,102, 32, 98, 32,116,104,101,110, 10,105,102, 32,
+    110,111,116, 32,112,116,121,112,101, 32,111,114, 32,112,116,
+    121,112,101, 32, 61, 61, 32, 34, 34, 32,116,104,101,110, 10,
+    112,116,121,112,101, 32, 61, 32, 34,100,101,102, 97,117,108,
+    116, 34, 10,101,110,100, 10,115,101,108,102, 58,115,101,116,
+     95,112,114,111,112,101,114,116,121, 95,116,121,112,101, 40,
+    112,116,121,112,101, 41, 10,114,101,116,117,114,110, 32,115,
+    116,114,115,117, 98, 40,115, 44, 32,101, 43, 49, 41, 10,101,
+    110,100, 10,101,110,100, 10,100,111, 10,108,111, 99, 97,108,
+     32, 98, 44,101, 32, 61, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,115, 44, 32, 34, 94, 37,115, 42, 84, 79, 76,
+     85, 65, 95, 80, 82, 79, 84, 69, 67, 84, 69, 68, 95, 68, 69,
+     83, 84, 82, 85, 67, 84, 79, 82, 37,115, 42, 59, 63, 34, 41,
+     10,105,102, 32, 98, 32,116,104,101,110, 10,105,102, 32,115,
+    101,108,102, 46,115,101,116, 95,112,114,111,116,101, 99,116,
+    101,100, 95,100,101,115,116,114,117, 99,116,111,114, 32,116,
+    104,101,110, 10,115,101,108,102, 58,115,101,116, 95,112,114,
+    111,116,101, 99,116,101,100, 95,100,101,115,116,114,117, 99,
+    116,111,114, 40,116,114,117,101, 41, 10,101,110,100, 10,114,
+    101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,
+     32,101, 43, 49, 41, 10,101,110,100, 10,101,110,100, 10,100,
+    111, 10,108,111, 99, 97,108, 32, 98, 44,101, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34,
+     94, 37,115, 42,101,120,116,101,114,110, 37,115, 43, 34, 41,
+     10,105,102, 32, 98, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44, 32,101, 43,
+     49, 41, 10,101,110,100, 10,101,110,100, 10,100,111, 10,108,
+    111, 99, 97,108, 32, 98, 44,101, 32, 61, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,115,
+     42,118,105,114,116,117, 97,108, 37,115, 43, 34, 41, 10,105,
+    102, 32, 98, 32,116,104,101,110, 10,109,101,116,104,111,100,
+    105,115,118,105,114,116,117, 97,108, 32, 61, 32,116,114,117,
+    101, 10,114,101,116,117,114,110, 32,115,116,114,115,117, 98,
+     40,115, 44, 32,101, 43, 49, 41, 10,101,110,100, 10,101,110,
+    100, 10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101, 32,
+     61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,115,
+     44, 32, 34, 94, 37,115, 42, 37,119, 42, 37,115, 42, 58, 91,
+     94, 58, 93, 34, 41, 10,105,102, 32, 98, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44, 32,101, 41, 10,101,110,100, 10,101,110,100, 10,100,
+    111, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,110, 97,109,
+    101, 44, 98,111,100,121, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42,109,111,100,117,108,101,
+     37,115, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119,
+     93, 42, 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42,
+     34, 41, 10,105,102, 32, 98, 32,116,104,101,110, 10, 95, 99,
+    117,114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,
+    117, 98, 40,115, 44, 98, 44,101, 41, 10, 77,111,100,117,108,
+    101, 40,110, 97,109,101, 44, 98,111,100,121, 41, 10,114,101,
+    116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10,101,110,100, 10,101,110,100, 10,100,111, 10,
+    108,111, 99, 97,108, 32, 98, 44,101, 44,110, 97,109,101, 44,
+     98,111,100,121, 32, 61, 32,115,116,114,102,105,110,100, 40,
+    115, 44, 34, 94, 37,115, 42,110, 97,109,101,115,112, 97, 99,
+    101, 37,115, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,
+    119, 93, 42, 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115,
+     42, 59, 63, 34, 41, 10,105,102, 32, 98, 32,116,104,101,110,
+     10, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115,
+    116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 78, 97,
+    109,101,115,112, 97, 99,101, 40,110, 97,109,101, 44, 98,111,
+    100,121, 41, 10,114,101,116,117,114,110, 32,115,116,114,115,
+    117, 98, 40,115, 44,101, 43, 49, 41, 10,101,110,100, 10,101,
+    110,100, 10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101,
+     44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115, 44, 34, 94, 37,115, 42, 35,100,101,102,105,110,101,
+     37,115, 37,115, 42, 40, 91, 94, 37,115, 93, 42, 41, 91, 94,
+     92,110, 93, 42, 92,110, 37,115, 42, 34, 41, 10,105,102, 32,
+     98, 32,116,104,101,110, 10, 95, 99,117,114,114, 95, 99,111,
+    100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98,
+     44,101, 41, 10, 68,101,102,105,110,101, 40,110, 97,109,101,
+     41, 10,114,101,116,117,114,110, 32,115,116,114,115,117, 98,
+     40,115, 44,101, 43, 49, 41, 10,101,110,100, 10,101,110,100,
+     10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,110,
+     97,109,101, 44, 98,111,100,121, 44,118, 97,114,110, 97,109,
+    101, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34,
+     94, 37,115, 42,101,110,117,109, 37,115, 43, 40, 37, 83, 42,
+     41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 40, 91,
+     94, 37,115, 59, 93, 42, 41, 37,115, 42, 59, 63, 37,115, 42,
+     34, 41, 10,105,102, 32, 98, 32,116,104,101,110, 10, 95, 99,
+    117,114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,
+    117, 98, 40,115, 44, 98, 44,101, 41, 10, 69,110,117,109,101,
+    114, 97,116,101, 40,110, 97,109,101, 44, 98,111,100,121, 44,
+    118, 97,114,110, 97,109,101, 41, 10,114,101,116,117,114,110,
+     32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,
+    101,110,100, 10,101,110,100, 10,100,111, 10,108,111, 99, 97,
+    108, 32, 98, 44,101, 44, 98,111,100,121, 44,110, 97,109,101,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94,
+     37,115, 42,116,121,112,101,100,101,102, 37,115, 43,101,110,
+    117,109, 91, 94,123, 93, 42, 40, 37, 98,123,125, 41, 37,115,
+     42, 40, 91, 37,119, 95, 93, 91, 94, 37,115, 93, 42, 41, 37,
+    115, 42, 59, 37,115, 42, 34, 41, 10,105,102, 32, 98, 32,116,
+    104,101,110, 10, 95, 99,117,114,114, 95, 99,111,100,101, 32,
+     61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41,
+     10, 69,110,117,109,101,114, 97,116,101, 40,110, 97,109,101,
+     44, 98,111,100,121, 41, 10,114,101,116,117,114,110, 32,115,
+    116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,101,110,
+    100, 10,101,110,100, 10,100,111, 10,108,111, 99, 97,108, 32,
+     98, 44,101, 44,100,101, 99,108, 44,107,105,110,100, 44, 97,
+    114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,
+    105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,
+    119, 93, 91, 95, 37,119, 37,115, 37, 42, 38, 58, 60, 62, 44,
+     93, 45, 37,115, 43,111,112,101,114, 97,116,111,114, 41, 37,
+    115, 42, 40, 91, 94, 37,115, 93, 91, 94, 37,115, 93, 42, 41,
+     37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,
+    111, 63,110, 63,115, 63,116, 63, 41, 37,115, 42, 59, 37,115,
+     42, 34, 41, 10,105,102, 32,110,111,116, 32, 98, 32,116,104,
+    101,110, 10, 98, 44,101, 44,100,101, 99,108, 44,107,105,110,
+    100, 44, 97,114,103, 44, 99,111,110,115,116, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40,
+     91, 95, 37,119, 93, 91, 95, 37,119, 37,115, 37, 42, 38, 58,
+     60, 62, 44, 93, 45, 37,115, 43,111,112,101,114, 97,116,111,
+    114, 41, 37,115, 42, 40, 91, 94, 37,115, 93, 91, 94, 37,115,
+     93, 42, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,115, 42,
+     40, 99, 63,111, 63,110, 63,115, 63,116, 63, 41, 91, 37,115,
+     92,110, 93, 42, 37, 98,123,125, 37,115, 42, 59, 63, 37,115,
+     42, 34, 41, 10,101,110,100, 10,105,102, 32,110,111,116, 32,
+     98, 32,116,104,101,110, 10, 98, 44,101, 44,100,101, 99,108,
+     44,107,105,110,100, 44, 97,114,103, 44, 99,111,110,115,116,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 32, 34,
+     94, 37,115, 42, 40,111,112,101,114, 97,116,111,114, 41, 37,
+    115, 43, 40, 91, 37,119, 95, 58, 37,100, 60, 62, 37, 42, 37,
+     38, 37,115, 93, 43, 41, 37,115, 42, 40, 37, 98, 40, 41, 41,
+     37,115, 42, 40, 99, 63,111, 63,110, 63,115, 63,116, 63, 41,
+     34, 41, 59, 10,105,102, 32, 98, 32,116,104,101,110, 10,108,
+    111, 99, 97,108, 32, 95, 44,105,101, 32, 61, 32,115,116,114,
+    105,110,103, 46,102,105,110,100, 40,115, 44, 32, 34, 94, 37,
+    115, 42, 37, 98,123,125, 34, 44, 32,101, 43, 49, 41, 10,105,
+    102, 32,105,101, 32,116,104,101,110, 10,101, 32, 61, 32,105,
+    101, 10,101,110,100, 10,101,110,100, 10,101,110,100, 10,105,
+    102, 32, 98, 32,116,104,101,110, 10, 95, 99,117,114,114, 95,
+     99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115,
+     44, 98, 44,101, 41, 10, 79,112,101,114, 97,116,111,114, 40,
+    100,101, 99,108, 44,107,105,110,100, 44, 97,114,103, 44, 99,
+    111,110,115,116, 41, 10,114,101,116,117,114,110, 32,115,116,
+    114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,101,110,100,
+     10,101,110,100, 10,100,111, 10,108,111, 99, 97,108, 32, 98,
+     44,101, 44,100,101, 99,108, 44, 97,114,103, 44, 99,111,110,
+    115,116, 44,118,105,114,116, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 94, 37, 40,
+     92,110, 93, 43, 41, 37,115, 42, 40, 37, 98, 40, 41, 41, 37,
+    115, 42, 40, 99, 63,111, 63,110, 63,115, 63,116, 63, 41, 37,
+    115, 42, 40, 61, 63, 37,115, 42, 48, 63, 41, 37,115, 42, 59,
+     37,115, 42, 34, 41, 10,105,102, 32,110,111,116, 32, 98, 32,
+    116,104,101,110, 10, 98, 44,101, 44,100,101, 99,108, 44, 97,
+    114,103, 44, 99,111,110,115,116, 32, 61, 32,115,116,114,102,
+    105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91,126, 95,
+     37,119, 93, 91, 95, 64, 37,119, 37,115, 37, 42, 38, 58, 60,
+     62, 93, 42, 91, 95, 37,119, 93, 37, 98, 60, 62, 41, 37,115,
+     42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,
+    110, 63,115, 63,116, 63, 41, 37,115, 42, 61, 63, 37,115, 42,
+     48, 63, 37,115, 42, 59, 37,115, 42, 34, 41, 10,101,110,100,
+     10,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10,
+     98, 44,101, 44,100,101, 99,108, 44, 97,114,103, 44, 99,111,
+    110,115,116, 32, 61, 32,115,116,114,102,105,110,100, 40,115,
+     44, 34, 94, 37,115, 42, 40, 91, 95, 37,119, 93, 41, 37,115,
+     42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,
+    110, 63,115, 63,116, 63, 41, 37,115, 42, 59, 37,115, 42, 34,
+     41, 10,101,110,100, 10,105,102, 32, 98, 32,116,104,101,110,
+     10,105,102, 32,118,105,114,116, 32, 97,110,100, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,118,105,114,116, 44,
+     32, 34, 91, 61, 48, 93, 34, 41, 32,116,104,101,110, 10,105,
+    102, 32,115,101,108,102, 46,102,108, 97,103,115, 32,116,104,
+    101,110, 10,115,101,108,102, 46,102,108, 97,103,115, 46,112,
+    117,114,101, 95,118,105,114,116,117, 97,108, 32, 61, 32,116,
+    114,117,101, 10,101,110,100, 10,101,110,100, 10, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117,
+     98, 40,115, 44, 98, 44,101, 41, 10, 70,117,110, 99,116,105,
+    111,110, 40,100,101, 99,108, 44, 97,114,103, 44, 99,111,110,
+    115,116, 41, 10,114,101,116,117,114,110, 32,115,116,114,115,
+    117, 98, 40,115, 44,101, 43, 49, 41, 10,101,110,100, 10,101,
+    110,100, 10,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101,
+     44,100,101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94,
+     37,115, 42, 40, 91, 94, 37, 40, 92,110, 93, 43, 41, 37,115,
+     42, 40, 37, 98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,
+    110, 63,115, 63,116, 63, 41, 91, 94, 59,123, 93, 42, 37, 98,
+    123,125, 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10,105,102,
+     32,110,111,116, 32, 98, 32,116,104,101,110, 10, 98, 44,101,
+     44,100,101, 99,108, 44, 97,114,103, 44, 99,111,110,115,116,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94,
+     37,115, 42, 40, 91, 95, 37,119, 93, 41, 37,115, 42, 40, 37,
+     98, 40, 41, 41, 37,115, 42, 40, 99, 63,111, 63,110, 63,115,
+     63,116, 63, 41, 46, 45, 37, 98,123,125, 37,115, 42, 59, 63,
+     37,115, 42, 34, 41, 10,101,110,100, 10,105,102, 32, 98, 32,
+    116,104,101,110, 10, 95, 99,117,114,114, 95, 99,111,100,101,
+     32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101,
+     41, 10, 70,117,110, 99,116,105,111,110, 40,100,101, 99,108,
+     44, 97,114,103, 44, 99,111,110,115,116, 41, 10,114,101,116,
+    117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43,
+     49, 41, 10,101,110,100, 10,101,110,100, 10,100,111, 10,108,
+    111, 99, 97,108, 32, 98, 44,101, 44,110, 97,109,101, 44, 98,
+     97,115,101, 44, 98,111,100,121, 10, 98, 97,115,101, 32, 61,
+     32, 39, 39, 32, 98,111,100,121, 32, 61, 32, 39, 39, 10, 98,
+     44,101, 44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 99,108, 97,115,115,
+     37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93,
+     42, 41, 37,115, 42, 59, 34, 41, 10,105,102, 32,110,111,116,
+     32, 98, 32,116,104,101,110, 10, 98, 44,101, 44,110, 97,109,
+    101, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 34,
+     94, 37,115, 42,115,116,114,117, 99,116, 37,115, 42, 40, 91,
+     95, 37,119, 93, 91, 95, 37,119, 64, 93, 42, 41, 37,115, 42,
+     59, 34, 41, 10,105,102, 32,110,111,116, 32, 98, 32,116,104,
+    101,110, 10, 98, 44,101, 44,110, 97,109,101, 44, 98, 97,115,
+    101, 44, 98,111,100,121, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42, 99,108, 97,115,115, 37,
+    115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64, 93, 42,
+     41, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 40, 37, 98,123,
+    125, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10,105,102, 32,
+    110,111,116, 32, 98, 32,116,104,101,110, 10, 98, 44,101, 44,
+    110, 97,109,101, 44, 98, 97,115,101, 44, 98,111,100,121, 32,
+     61, 32,115,116,114,102,105,110,100, 40,115, 44, 34, 94, 37,
+    115, 42,115,116,114,117, 99,116, 37,115, 42, 40, 91, 95, 37,
+    119, 93, 91, 95, 37,119, 64, 93, 42, 41, 37,115, 42, 40, 46,
+     45, 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,115, 42, 59,
+     37,115, 42, 34, 41, 10,105,102, 32,110,111,116, 32, 98, 32,
+    116,104,101,110, 10, 98, 44,101, 44,110, 97,109,101, 44, 98,
+     97,115,101, 44, 98,111,100,121, 32, 61, 32,115,116,114,102,
+    105,110,100, 40,115, 44, 34, 94, 37,115, 42,117,110,105,111,
+    110, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119, 64,
+     93, 42, 41, 37,115, 42, 40, 46, 45, 41, 37,115, 42, 40, 37,
+     98,123,125, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10,105,
+    102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10, 98, 97,
+    115,101, 32, 61, 32, 39, 39, 10, 98, 44,101, 44, 98,111,100,
+    121, 44,110, 97,109,101, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 34, 94, 37,115, 42,116,121,112,101,100,101,
+    102, 37,115, 37,115, 42,115,116,114,117, 99,116, 37,115, 37,
+    115, 42, 91, 95, 37,119, 93, 42, 37,115, 42, 40, 37, 98,123,
+    125, 41, 37,115, 42, 40, 91, 95, 37,119, 93, 91, 95, 37,119,
+     64, 93, 42, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10,101,
+    110,100, 10,101,110,100, 10,101,110,100, 10,101,110,100, 10,
+    101,110,100, 10,105,102, 32, 98, 32,116,104,101,110, 10,105,
+    102, 32, 98, 97,115,101, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 10, 98, 97,115,101, 32, 61, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40, 98, 97,115,101, 44, 32, 34, 94,
+     37,115, 42, 58, 37,115, 42, 34, 44, 32, 34, 34, 41, 10, 98,
+     97,115,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40, 98, 97,115,101, 44, 32, 34, 37,115, 42,112,117,
+     98,108,105, 99, 37,115, 42, 34, 44, 32, 34, 34, 41, 10, 98,
+     97,115,101, 32, 61, 32,115,112,108,105,116, 40, 98, 97,115,
+    101, 44, 32, 34, 44, 34, 41, 10,101,108,115,101, 10, 98, 97,
+    115,101, 32, 61, 32,123,125, 10,101,110,100, 10, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117,
+     98, 40,115, 44, 98, 44,101, 41, 10, 67,108, 97,115,115, 40,
+    110, 97,109,101, 44, 98, 97,115,101, 44, 98,111,100,121, 41,
+     10,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10,101,110,100, 10,101,110,100, 10,
+    100,111, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,116,121,
+    112,101,115, 32, 61, 32,115,116,114,102,105,110,100, 40,115,
+     44, 34, 94, 37,115, 42,116,121,112,101,100,101,102, 37,115,
+     37,115, 42, 40, 46, 45, 41, 37,115, 42, 59, 37,115, 42, 34,
+     41, 10,105,102, 32, 98, 32,116,104,101,110, 10, 95, 99,117,
+    114,114, 95, 99,111,100,101, 32, 61, 32,115,116,114,115,117,
+     98, 40,115, 44, 98, 44,101, 41, 10, 84,121,112,101,100,101,
+    102, 40,116,121,112,101,115, 41, 10,114,101,116,117,114,110,
+     32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,
+    101,110,100, 10,101,110,100, 10,100,111, 10,108,111, 99, 97,
+    108, 32, 98, 44,101, 44,100,101, 99,108, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91,
+     95, 37,119, 93, 91, 95, 64, 37,115, 37,119, 37,100, 37, 42,
+     38, 58, 60, 62, 44, 93, 42, 91, 95, 37,119, 37,100, 93, 41,
+     37,115, 42, 59, 37,115, 42, 34, 41, 10,105,102, 32, 98, 32,
+    116,104,101,110, 10, 95, 99,117,114,114, 95, 99,111,100,101,
+     32, 61, 32,115,116,114,115,117, 98, 40,115, 44, 98, 44,101,
+     41, 10,108,111, 99, 97,108, 32,108,105,115,116, 32, 61, 32,
+    115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,
+    100,101, 99,108, 44, 32, 34, 44, 34, 41, 10, 86, 97,114,105,
+     97, 98,108,101, 40,108,105,115,116, 91, 49, 93, 41, 10,105,
+    102, 32,108,105,115,116, 46,110, 32, 62, 32, 49, 32,116,104,
+    101,110, 10,108,111, 99, 97,108, 32, 95, 44, 95, 44,116,121,
+    112,101, 32, 61, 32,115,116,114,102,105,110,100, 40,108,105,
+    115,116, 91, 49, 93, 44, 32, 34, 40, 46, 45, 41, 37,115, 43,
+     40, 91, 94, 37,115, 93, 42, 41, 36, 34, 41, 59, 10,108,111,
+     99, 97,108, 32,105, 32, 61, 50, 59, 10,119,104,105,108,101,
+     32,108,105,115,116, 91,105, 93, 32,100,111, 10, 86, 97,114,
+    105, 97, 98,108,101, 40,116,121,112,101, 46, 46, 34, 32, 34,
+     46, 46,108,105,115,116, 91,105, 93, 41, 10,105, 61,105, 43,
+     49, 10,101,110,100, 10,101,110,100, 10,114,101,116,117,114,
+    110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41,
+     10,101,110,100, 10,101,110,100, 10,100,111, 10,108,111, 99,
+     97,108, 32, 98, 44,101, 44,100,101, 99,108, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115, 44, 34, 94, 37,115, 42, 40,
+     91, 95, 37,119, 93, 63, 91, 95, 37,115, 37,119, 37,100, 93,
+     45, 99,104, 97,114, 37,115, 43, 91, 95, 64, 37,119, 37,100,
+     93, 42, 37,115, 42, 37, 91, 37,115, 42, 37, 83, 43, 37,115,
+     42, 37, 93, 41, 37,115, 42, 59, 37,115, 42, 34, 41, 10,105,
+    102, 32, 98, 32,116,104,101,110, 10, 95, 99,117,114,114, 95,
+     99,111,100,101, 32, 61, 32,115,116,114,115,117, 98, 40,115,
+     44, 98, 44,101, 41, 10, 86, 97,114,105, 97, 98,108,101, 40,
+    100,101, 99,108, 41, 10,114,101,116,117,114,110, 32,115,116,
+    114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,101,110,100,
+     10,101,110,100, 10,100,111, 10,108,111, 99, 97,108, 32, 98,
+     44,101, 44,100,101, 99,108, 32, 61, 32,115,116,114,102,105,
+    110,100, 40,115, 44, 34, 94, 37,115, 42, 40, 91, 95, 37,119,
+     93, 91, 93, 91, 95, 64, 37,115, 37,119, 37,100, 37, 42, 38,
+     58, 93, 42, 91, 93, 95, 37,119, 37,100, 93, 41, 37,115, 42,
+     59, 37,115, 42, 34, 41, 10,105,102, 32, 98, 32,116,104,101,
+    110, 10, 95, 99,117,114,114, 95, 99,111,100,101, 32, 61, 32,
+    115,116,114,115,117, 98, 40,115, 44, 98, 44,101, 41, 10, 65,
+    114,114, 97,121, 40,100,101, 99,108, 41, 10,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49,
+     41, 10,101,110,100, 10,101,110,100, 10,105,102, 32,103,115,
+    117, 98, 40,115, 44, 34, 37,115, 37,115, 42, 34, 44, 34, 34,
+     41, 32,126, 61, 32, 34, 34, 32,116,104,101,110, 10, 95, 99,
+    117,114,114, 95, 99,111,100,101, 32, 61, 32,115, 10,101,114,
+    114,111,114, 40, 34, 35,112, 97,114,115,101, 32,101,114,114,
+    111,114, 34, 41, 10,101,108,115,101, 10,114,101,116,117,114,
+    110, 32, 34, 34, 10,101,110,100, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,111,110,
+    116, 97,105,110,101,114, 58,112, 97,114,115,101, 32, 40,115,
+     41, 10,115,101,108,102, 46, 99,117,114,114, 95,109,101,109,
+     98,101,114, 95, 97, 99, 99,101,115,115, 32, 61, 32,110,105,
+    108, 10,119,104,105,108,101, 32,115, 32,126, 61, 32, 39, 39,
+     32,100,111, 10,115, 32, 61, 32,115,101,108,102, 58,100,111,
+    112, 97,114,115,101, 40,115, 41, 10,109,101,116,104,111,100,
+    105,115,118,105,114,116,117, 97,108, 32, 61, 32,102, 97,108,
+    115,101, 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,
+    116,105,111,110, 32,103,101,116, 95,112,114,111,112,101,114,
+    116,121, 95,116,121,112,101, 40, 41, 10,114,101,116,117,114,
+    110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 46, 99,117,114,114, 58,103,101,116, 95,112,114,111,112,
+    101,114,116,121, 95,116,121,112,101, 40, 41, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     67,111,110,116, 97,105,110,101,114, 58,115,101,116, 95,112,
+    114,111,112,101,114,116,121, 95,116,121,112,101, 40,112,116,
+    121,112,101, 41, 10,112,116,121,112,101, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,112,116,121,112,101,
+     44, 32, 34, 94, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,112,
+    116,121,112,101, 32, 61, 32,115,116,114,105,110,103, 46,103,
+    115,117, 98, 40,112,116,121,112,101, 44, 32, 34, 37,115, 42,
+     36, 34, 44, 32, 34, 34, 41, 10,115,101,108,102, 46,112,114,
+    111,112,101,114,116,121, 95,116,121,112,101, 32, 61, 32,112,
+    116,121,112,101, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 67,111,110,116, 97,105,110,
+    101,114, 58,103,101,116, 95,112,114,111,112,101,114,116,121,
+     95,116,121,112,101, 40, 41, 10,114,101,116,117,114,110, 32,
+    115,101,108,102, 46,112,114,111,112,101,114,116,121, 95,116,
+    121,112,101, 32,111,114, 32, 40,115,101,108,102, 46,112, 97,
+    114,101,110,116, 32, 97,110,100, 32,115,101,108,102, 46,112,
+     97,114,101,110,116, 58,103,101,116, 95,112,114,111,112,101,
+    114,116,121, 95,116,121,112,101, 40, 41, 41, 32,111,114, 32,
+     34,100,101,102, 97,117,108,116, 34, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/container.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 32, 61,
+     32,123, 10, 99,108, 97,115,115,116,121,112,101, 32, 61, 32,
+     39,112, 97, 99,107, 97,103,101, 39, 10,125, 10, 99,108, 97,
+    115,115, 80, 97, 99,107, 97,103,101, 46, 95, 95,105,110,100,
+    101,120, 32, 61, 32, 99,108, 97,115,115, 80, 97, 99,107, 97,
+    103,101, 10,115,101,116,109,101,116, 97,116, 97, 98,108,101,
+     40, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 44, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 41, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 80,
+     97, 99,107, 97,103,101, 58,112,114,105,110,116, 32, 40, 41,
+     10,112,114,105,110,116, 40, 34, 80, 97, 99,107, 97,103,101,
+     58, 32, 34, 46, 46,115,101,108,102, 46,110, 97,109,101, 41,
+     10,108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,
+    101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,115,101,
+    108,102, 91,105, 93, 58,112,114,105,110,116, 40, 34, 34, 44,
+     34, 34, 41, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,100,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,112,114,101,
+    112,114,111, 99,101,115,115, 32, 40, 41, 10,108,111, 99, 97,
+    108, 32, 76, 32, 61, 32,123,125, 10,115,101,108,102, 46, 99,
+    111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 37, 36, 37,
+     91, 34, 44, 34, 92, 49, 34, 41, 10,115,101,108,102, 46, 99,
+    111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 37, 36, 37,
+     93, 34, 44, 34, 92, 50, 34, 41, 10,115,101,108,102, 46, 99,
+    111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46, 99,111,100,101, 44, 34, 40, 37, 98, 92, 49, 92, 50, 41,
+     34, 44, 32,102,117,110, 99,116,105,111,110, 32, 40, 99, 41,
+     10,116,105,110,115,101,114,116, 40, 76, 44, 99, 41, 10,114,
+    101,116,117,114,110, 32, 34, 92,110, 35, 91, 34, 46, 46,103,
+    101,116,110, 40, 76, 41, 46, 46, 34, 93, 35, 34, 10,101,110,
+    100, 41, 10,108,111, 99, 97,108, 32, 67, 32, 61, 32,123,125,
+     10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92,
+    110, 37,115, 42, 37, 36, 37, 60, 34, 44, 34, 92, 51, 34, 41,
+     10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92,
+    110, 37,115, 42, 37, 36, 37, 62, 34, 44, 34, 92, 52, 34, 41,
+     10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40,
+     37, 98, 92, 51, 92, 52, 41, 34, 44, 32,102,117,110, 99,116,
+    105,111,110, 32, 40, 99, 41, 10,116,105,110,115,101,114,116,
+     40, 67, 44, 99, 41, 10,114,101,116,117,114,110, 32, 34, 92,
+    110, 35, 60, 34, 46, 46,103,101,116,110, 40, 67, 41, 46, 46,
+     34, 62, 35, 34, 10,101,110,100, 41, 10,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 37, 36,
+     37,123, 34, 44, 34, 92, 53, 34, 41, 10,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 92,110, 37,115, 42, 37, 36,
+     37,125, 34, 44, 34, 92, 54, 34, 41, 10,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 40, 37, 98, 92, 53, 92, 54,
+     41, 34, 44, 32,102,117,110, 99,116,105,111,110, 32, 40, 99,
+     41, 10,116,105,110,115,101,114,116, 40, 67, 44, 99, 41, 10,
+    114,101,116,117,114,110, 32, 34, 92,110, 35, 60, 34, 46, 46,
+    103,101,116,110, 40, 67, 41, 46, 46, 34, 62, 35, 34, 10,101,
+    110,100, 41, 10,115,101,108,102, 46, 99,111,100,101, 32, 61,
+     32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,100,101,
+     44, 34, 92,110, 91, 32, 92,116, 93, 42, 35, 91, 32, 92,116,
+     93, 42, 91, 94,100, 37, 60, 37, 91, 93, 34, 44, 32, 34, 92,
+    110, 47, 47, 34, 41, 10,108,111, 99, 97,108, 32, 86, 32, 61,
+     32,123,125, 10,115,101,108,102, 46, 99,111,100,101, 32, 61,
+     32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,100,101,
+     44, 34, 92,110, 40, 37,115, 42, 37, 36, 91, 94, 37, 91, 37,
+     93, 93, 91, 94, 92,110, 93, 42, 41, 34, 44,102,117,110, 99,
+    116,105,111,110, 32, 40,118, 41, 10,116,105,110,115,101,114,
+    116, 40, 86, 44,118, 41, 10,114,101,116,117,114,110, 32, 34,
+     92,110, 35, 34, 46, 46,103,101,116,110, 40, 86, 41, 46, 46,
+     34, 35, 34, 10,101,110,100, 41, 10,115,101,108,102, 46, 99,
+    111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46, 99,111,100,101, 44, 34, 40, 47, 47, 91, 94, 92,110, 93,
+     42, 41, 34, 44, 34, 34, 41, 10,115,101,108,102, 46, 99,111,
+    100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46,
+     99,111,100,101, 44, 34, 47, 37, 42, 34, 44, 34, 92, 49, 34,
+     41, 10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,
+    115,117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34,
+     37, 42, 47, 34, 44, 34, 92, 50, 34, 41, 10,115,101,108,102,
+     46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46, 99,111,100,101, 44, 34, 37, 98, 92, 49, 92, 50,
+     34, 44, 34, 34, 41, 10,115,101,108,102, 46, 99,111,100,101,
+     32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,
+    100,101, 44, 34, 92, 49, 34, 44, 34, 47, 37, 42, 34, 41, 10,
+    115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117,
+     98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 92, 50,
+     34, 44, 34, 37, 42, 47, 34, 41, 10,115,101,108,102, 46, 99,
+    111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46, 99,111,100,101, 44, 34, 37,115, 42, 64, 37,115, 42, 34,
+     44, 34, 64, 34, 41, 10,115,101,108,102, 46, 99,111,100,101,
+     32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46, 99,111,
+    100,101, 44, 34, 37,115, 63,105,110,108,105,110,101, 40, 37,
+    115, 41, 34, 44, 34, 37, 49, 34, 41, 10,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 40, 91, 94, 37,119, 95, 93,
+     41,118,111,105,100, 37,115, 42, 37, 42, 34, 44, 34, 37, 49,
+     95,117,115,101,114,100, 97,116, 97, 32, 34, 41, 10,115,101,
+    108,102, 46, 99,111,100,101, 32, 61, 32,103,115,117, 98, 40,
+    115,101,108,102, 46, 99,111,100,101, 44, 34, 40, 91, 94, 37,
+    119, 95, 93, 41,118,111,105,100, 37,115, 42, 37, 42, 34, 44,
+     34, 37, 49, 95,117,115,101,114,100, 97,116, 97, 32, 34, 41,
+     10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,115,
+    117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34, 40,
+     91, 94, 37,119, 95, 93, 41, 99,104, 97,114, 37,115, 42, 37,
+     42, 34, 44, 34, 37, 49, 95, 99,115,116,114,105,110,103, 32,
+     34, 41, 10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,
+    103,115,117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44,
+     34, 40, 91, 94, 37,119, 95, 93, 41,108,117, 97, 95, 83,116,
+     97,116,101, 37,115, 42, 37, 42, 34, 44, 34, 37, 49, 95,108,
+    115,116, 97,116,101, 32, 34, 41, 10,115,101,108,102, 46, 99,
+    111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46, 99,111,100,101, 44, 34, 37, 35, 37, 91, 40, 37,100, 43,
+     41, 37, 93, 37, 35, 34, 44,102,117,110, 99,116,105,111,110,
+     32, 40,110, 41, 10,114,101,116,117,114,110, 32, 76, 91,116,
+    111,110,117,109, 98,101,114, 40,110, 41, 93, 10,101,110,100,
+     41, 10,115,101,108,102, 46, 99,111,100,101, 32, 61, 32,103,
+    115,117, 98, 40,115,101,108,102, 46, 99,111,100,101, 44, 34,
+     37, 35, 37, 60, 40, 37,100, 43, 41, 37, 62, 37, 35, 34, 44,
+    102,117,110, 99,116,105,111,110, 32, 40,110, 41, 10,114,101,
+    116,117,114,110, 32, 67, 91,116,111,110,117,109, 98,101,114,
+     40,110, 41, 93, 10,101,110,100, 41, 10,115,101,108,102, 46,
+     99,111,100,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,
+    102, 46, 99,111,100,101, 44, 34, 37, 35, 40, 37,100, 43, 41,
+     37, 35, 34, 44,102,117,110, 99,116,105,111,110, 32, 40,110,
+     41, 10,114,101,116,117,114,110, 32, 86, 91,116,111,110,117,
+    109, 98,101,114, 40,110, 41, 93, 10,101,110,100, 41, 10,115,
+    101,108,102, 46, 99,111,100,101, 32, 61, 32,115,116,114,105,
+    110,103, 46,103,115,117, 98, 40,115,101,108,102, 46, 99,111,
+    100,101, 44, 32, 34, 92,110, 37,115, 42, 37, 36, 40, 91, 94,
+     92,110, 93, 43, 41, 34, 44, 32,102,117,110, 99,116,105,111,
+    110, 32, 40,108, 41, 10, 86,101,114, 98, 97,116,105,109, 40,
+    108, 46, 46, 34, 92,110, 34, 41, 10,114,101,116,117,114,110,
+     32, 34, 92,110, 34, 10,101,110,100, 41, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 80,
+     97, 99,107, 97,103,101, 58,112,114,101, 97,109, 98,108,101,
+     32, 40, 41, 10,111,117,116,112,117,116, 40, 39, 47, 42, 92,
+    110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 42, 42, 32,
+     76,117, 97, 32, 98,105,110,100,105,110,103, 58, 32, 39, 46,
+     46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 92,110,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 42, 42, 32, 71,
+    101,110,101,114, 97,116,101,100, 32, 97,117,116,111,109, 97,
+    116,105, 99, 97,108,108,121, 32, 98,121, 32, 39, 46, 46, 84,
+     79, 76, 85, 65, 95, 86, 69, 82, 83, 73, 79, 78, 46, 46, 39,
+     32,111,110, 32, 39, 46, 46,100, 97,116,101, 40, 41, 46, 46,
+     39, 46, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     42, 47, 92,110, 92,110, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 35,105,102,110,100,101,102, 32, 95, 95, 99,112,108,
+    117,115,112,108,117,115, 92,110, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 35,105,110, 99,108,117,100,101, 32, 34,115,
+    116,100,108,105, 98, 46,104, 34, 92,110, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 35,105,110, 99,108,
+    117,100,101, 32, 34,115,116,114,105,110,103, 46,104, 34, 92,
+    110, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 35,
+    105,110, 99,108,117,100,101, 32, 34,116,111,108,117, 97, 43,
+     43, 46,104, 34, 92,110, 92,110, 39, 41, 10,105,102, 32,110,
+    111,116, 32,102,108, 97,103,115, 46,104, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39, 35,105,110, 99,108,117,
+    100,101, 32, 34,116,111,108,117, 97, 95, 98,105,110,100, 46,
+    104, 34, 39, 41, 10,111,117,116,112,117,116, 40, 39, 92,110,
+     39, 41, 10,101,110,100, 10,108,111, 99, 97,108, 32,105, 61,
+     49, 10,119,104,105,108,101, 32,115,101,108,102, 91,105, 93,
+     32,100,111, 10,115,101,108,102, 91,105, 93, 58,112,114,101,
+     97,109, 98,108,101, 40, 41, 10,105, 32, 61, 32,105, 43, 49,
+     10,101,110,100, 10,105,102, 32,115,101,108,102, 58,114,101,
+    113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,110,
+     40, 95, 99,111,108,108,101, 99,116, 41, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 47, 42, 32,102,117,110, 99,116,
+    105,111,110, 32,116,111, 32,114,101,108,101, 97,115,101, 32,
+     99,111,108,108,101, 99,116,101,100, 32,111, 98,106,101, 99,
+    116, 32,118,105, 97, 32,100,101,115,116,114,117, 99,116,111,
+    114, 32, 42, 47, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,115,112,
+    108,117,115, 92,110, 39, 41, 10,102,111,114, 32,105, 44,118,
+     32,105,110, 32,112, 97,105,114,115, 40, 95, 99,111,108,108,
+    101, 99,116, 41, 32,100,111, 10,111,117,116,112,117,116, 40,
+     39, 92,110,115,116, 97,116,105, 99, 32,105,110,116, 32, 39,
+     46, 46,118, 46, 46, 39, 32, 40,108,117, 97, 95, 83,116, 97,
+    116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39,123, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32, 39, 46, 46,105, 46, 46, 39, 42, 32,
+    115,101,108,102, 32, 61, 32, 40, 39, 46, 46,105, 46, 46, 39,
+     42, 41, 32,116,111,108,117, 97, 95,116,111,117,115,101,114,
+    116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 49, 44,
+     48, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+    100,101,108,101,116,101, 32,115,101,108,102, 59, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 32,114,101,116,117,114,110,
+     32, 48, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,125,
+     39, 41, 10,101,110,100, 10,111,117,116,112,117,116, 40, 39,
+     35,101,110,100,105,102, 92,110, 92,110, 39, 41, 10,101,110,
+    100, 10,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 47, 42, 32,102,117,110, 99,
+    116,105,111,110, 32,116,111, 32,114,101,103,105,115,116,101,
+    114, 32,116,121,112,101, 32, 42, 47, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39,115,116, 97,116,105, 99, 32,118,111,105,
+    100, 32,116,111,108,117, 97, 95,114,101,103, 95,116,121,112,
+    101,115, 32, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,
+    116,111,108,117, 97, 95, 83, 41, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39,123, 39, 41, 10,102,111,114,101, 97, 99,104,
+     40, 95,117,115,101,114,116,121,112,101, 44,102,117,110, 99,
+    116,105,111,110, 40,110, 44,118, 41, 32,111,117,116,112,117,
+    116, 40, 39, 32,116,111,108,117, 97, 95,117,115,101,114,116,
+    121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 44,
+    118, 44, 39, 34, 41, 59, 39, 41, 32,101,110,100, 41, 10,105,
+    102, 32,102,108, 97,103,115, 46,116, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 34, 35,105,102,110,100,101,102,
+     32, 77,116,111,108,117, 97, 95,116,121,112,101,105,100, 92,
+    110, 35,100,101,102,105,110,101, 32, 77,116,111,108,117, 97,
+     95,116,121,112,101,105,100, 40, 76, 44, 84, 73, 44, 84, 41,
+     92,110, 35,101,110,100,105,102, 92,110, 34, 41, 10,102,111,
+    114,101, 97, 99,104, 40, 95,117,115,101,114,116,121,112,101,
+     44,102,117,110, 99,116,105,111,110, 40,110, 44,118, 41, 32,
+    111,117,116,112,117,116, 40, 39, 32, 77,116,111,108,117, 97,
+     95,116,121,112,101,105,100, 40,116,111,108,117, 97, 95, 83,
+     44,116,121,112,101,105,100, 40, 39, 44,118, 44, 39, 41, 44,
+     32, 34, 39, 44,118, 44, 39, 34, 41, 59, 39, 41, 32,101,110,
+    100, 41, 10,101,110,100, 10,111,117,116,112,117,116, 40, 39,
+    125, 39, 41, 10,111,117,116,112,117,116, 40, 39, 92,110, 39,
+     41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,114,101,
+    103,105,115,116,101,114, 32, 40,112,114,101, 41, 10,112,114,
+    101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10,112,
+    117,115,104, 40,115,101,108,102, 41, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 34, 47, 42, 32, 79,112,101,110,
+     32,102,117,110, 99,116,105,111,110, 32, 42, 47, 34, 41, 10,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 34,105,110,
+    116, 32,116,111,108,117, 97, 95, 34, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 46, 46, 34, 95,111,112,101,110, 32, 40,
+    108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117,
+     97, 95, 83, 41, 34, 41, 10,111,117,116,112,117,116, 40,112,
+    114,101, 46, 46, 34,123, 34, 41, 10,111,117,116,112,117,116,
+     40,112,114,101, 46, 46, 34, 32,116,111,108,117, 97, 95,111,
+    112,101,110, 40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41,
+     10,111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,
+    116,111,108,117, 97, 95,114,101,103, 95,116,121,112,101,115,
+     40,116,111,108,117, 97, 95, 83, 41, 59, 34, 41, 10,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 34, 32,116,111,108,
+    117, 97, 95,109,111,100,117,108,101, 40,116,111,108,117, 97,
+     95, 83, 44, 78, 85, 76, 76, 44, 34, 44,115,101,108,102, 58,
+    104, 97,115,118, 97,114, 40, 41, 44, 34, 41, 59, 34, 41, 10,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 32,116,
+    111,108,117, 97, 95, 98,101,103,105,110,109,111,100,117,108,
+    101, 40,116,111,108,117, 97, 95, 83, 44, 78, 85, 76, 76, 41,
+     59, 34, 41, 10,108,111, 99, 97,108, 32,105, 61, 49, 10,119,
+    104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111,
+     10,115,101,108,102, 91,105, 93, 58,114,101,103,105,115,116,
+    101,114, 40,112,114,101, 46, 46, 34, 32, 34, 41, 10,105, 32,
+     61, 32,105, 43, 49, 10,101,110,100, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 34, 32,116,111,108,117, 97, 95,
+    101,110,100,109,111,100,117,108,101, 40,116,111,108,117, 97,
+     95, 83, 41, 59, 34, 41, 10,111,117,116,112,117,116, 40,112,
+    114,101, 46, 46, 34, 32,114,101,116,117,114,110, 32, 49, 59,
+     34, 41, 10,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     34,125, 34, 41, 10,111,117,116,112,117,116, 40, 34, 92,110,
+     92,110, 34, 41, 10,111,117,116,112,117,116, 40, 34, 35,105,
+    102, 32,100,101,102,105,110,101,100, 40, 76, 85, 65, 95, 86,
+     69, 82, 83, 73, 79, 78, 95, 78, 85, 77, 41, 32, 38, 38, 32,
+     76, 85, 65, 95, 86, 69, 82, 83, 73, 79, 78, 95, 78, 85, 77,
+     32, 62, 61, 32, 53, 48, 49, 92,110, 34, 41, 59, 10,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 34,105,110,116, 32,
+    108,117, 97,111,112,101,110, 95, 34, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 46, 46, 34, 32, 40,108,117, 97, 95, 83,
+    116, 97,116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 32,
+    123, 34, 41, 10,111,117,116,112,117,116, 40,112,114,101, 46,
+     46, 34, 32,114,101,116,117,114,110, 32,116,111,108,117, 97,
+     95, 34, 46, 46,115,101,108,102, 46,110, 97,109,101, 46, 46,
+     34, 95,111,112,101,110, 40,116,111,108,117, 97, 95, 83, 41,
+     59, 34, 41, 10,111,117,116,112,117,116, 40,112,114,101, 46,
+     46, 34,125, 59, 34, 41, 10,111,117,116,112,117,116, 40, 34,
+     35,101,110,100,105,102, 92,110, 92,110, 34, 41, 10,112,111,
+    112, 40, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 58,
+    104,101, 97,100,101,114, 32, 40, 41, 10,111,117,116,112,117,
+    116, 40, 39, 47, 42, 92,110, 39, 41, 32,111,117,116,112,117,
+    116, 40, 39, 42, 42, 32, 76,117, 97, 32, 98,105,110,100,105,
+    110,103, 58, 32, 39, 46, 46,115,101,108,102, 46,110, 97,109,
+    101, 46, 46, 39, 92,110, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 42, 42, 32, 71,101,110,101,114, 97,116,101,100, 32,
+     97,117,116,111,109, 97,116,105, 99, 97,108,108,121, 32, 98,
+    121, 32, 39, 46, 46, 84, 79, 76, 85, 65, 95, 86, 69, 82, 83,
+     73, 79, 78, 46, 46, 39, 32,111,110, 32, 39, 46, 46,100, 97,
+    116,101, 40, 41, 46, 46, 39, 46, 92,110, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 42, 47, 92,110, 92,110, 39, 41, 10,
+    105,102, 32,110,111,116, 32,102,108, 97,103,115, 46,104, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 35,105,
+    110, 99,108,117,100,101, 32, 34, 46, 46, 47, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 46, 46, 39, 80,114,101,114,
+    101,113,115, 46,104, 34, 92,110, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 47, 42, 32, 69,120,112,111,114,116,101,100,
+     32,102,117,110, 99,116,105,111,110, 32, 42, 47, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 95, 39, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 39, 69,120,112,111,114,116,
+     32,105,110,116, 32,116,111,108,117, 97, 95, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 46, 46, 39, 95,111,112,101,
+    110, 32, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,
+    111,108,117, 97, 95, 83, 41, 59, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 92,110, 39, 41, 10,101,110,100, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 95, 80, 97, 99,
+    107, 97,103,101, 32, 40,115,101,108,102, 41, 10,115,101,116,
+    109,101,116, 97,116, 97, 98,108,101, 40,115,101,108,102, 44,
+     99,108, 97,115,115, 80, 97, 99,107, 97,103,101, 41, 10,114,
+    101,116,117,114,110, 32,115,101,108,102, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32,101,120,116,114, 97, 99,
+    116, 95, 99,111,100,101, 40,102,110, 44,115, 41, 10,108,111,
+     99, 97,108, 32, 99,111,100,101, 32, 61, 32, 39, 92,110, 36,
+     35,105,110, 99,108,117,100,101, 32, 34, 39, 46, 46,102,110,
+     46, 46, 39, 34, 92,110, 39, 10,115, 61, 32, 34, 92,110, 34,
+     32, 46, 46, 32,115, 32, 46, 46, 32, 34, 92,110, 34, 10,108,
+    111, 99, 97,108, 32, 95, 44,101, 44, 99, 44,116, 32, 61, 32,
+    115,116,114,102,105,110,100, 40,115, 44, 32, 34, 92,110, 40,
+     91, 94, 92,110, 93, 45, 41, 91, 84,116, 93, 91, 79,111, 93,
+     91, 76,108, 93, 91, 85,117, 93, 91, 65, 97, 93, 95, 40, 91,
+     94, 37,115, 93, 42, 41, 91, 94, 92,110, 93, 42, 92,110, 34,
+     41, 10,119,104,105,108,101, 32,101, 32,100,111, 10,116, 32,
+     61, 32,115,116,114,108,111,119,101,114, 40,116, 41, 10,105,
+    102, 32,116, 32, 61, 61, 32, 34, 98,101,103,105,110, 34, 32,
+    116,104,101,110, 10, 95, 44,101, 44, 99, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115, 44, 34, 40, 46, 45, 41, 92,110,
+     91, 94, 92,110, 93, 42, 91, 84,116, 93, 91, 79,111, 93, 91,
+     76,108, 93, 91, 85,117, 93, 91, 65, 97, 93, 95, 91, 69,101,
+     93, 91, 78,110, 93, 91, 68,100, 93, 91, 94, 92,110, 93, 42,
+     92,110, 34, 44,101, 41, 10,105,102, 32,110,111,116, 32,101,
+     32,116,104,101,110, 10,116,111,108,117, 97, 95,101,114,114,
+    111,114, 40, 34, 85,110, 98, 97,108, 97,110, 99,101,100, 32,
+     39,116,111,108,117, 97, 95, 98,101,103,105,110, 39, 32,100,
+    105,114,101, 99,116,105,118,101, 32,105,110, 32,104,101, 97,
+    100,101,114, 32,102,105,108,101, 34, 41, 10,101,110,100, 10,
+    101,110,100, 10, 99,111,100,101, 32, 61, 32, 99,111,100,101,
+     32, 46, 46, 32, 99, 32, 46, 46, 32, 34, 92,110, 34, 10, 95,
+     44,101, 44, 99, 44,116, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115, 44, 32, 34, 92,110, 40, 91, 94, 92,110, 93, 45,
+     41, 91, 84,116, 93, 91, 79,111, 93, 91, 76,108, 93, 91, 85,
+    117, 93, 91, 65, 97, 93, 95, 40, 91, 94, 37,115, 93, 42, 41,
+     91, 94, 92,110, 93, 42, 92,110, 34, 44,101, 41, 10,101,110,
+    100, 10,114,101,116,117,114,110, 32, 99,111,100,101, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 80, 97, 99,
+    107, 97,103,101, 32, 40,110, 97,109,101, 44,102,110, 41, 10,
+    108,111, 99, 97,108, 32,101,120,116, 32, 61, 32, 34,112,107,
+    103, 34, 10,105,102, 32,102,110, 32,116,104,101,110, 10,108,
+    111, 99, 97,108, 32,115,116, 44, 32,109,115,103, 32, 61, 32,
+    114,101, 97,100,102,114,111,109, 40,102,108, 97,103,115, 46,
+    102, 41, 10,105,102, 32,110,111,116, 32,115,116, 32,116,104,
+    101,110, 10,101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,
+    115,103, 41, 10,101,110,100, 10,108,111, 99, 97,108, 32, 95,
+     59, 32, 95, 44, 32, 95, 44, 32,101,120,116, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,102,110, 44, 34, 46, 42, 37, 46,
+     40, 46, 42, 41, 36, 34, 41, 10,101,110,100, 10,108,111, 99,
+     97,108, 32, 99,111,100,101, 32, 61, 32, 34, 92,110, 34, 32,
+     46, 46, 32,114,101, 97,100, 40, 39, 42, 97, 39, 41, 10,105,
+    102, 32,101,120,116, 32, 61, 61, 32, 39,104, 39, 32,111,114,
+     32,101,120,116, 32, 61, 61, 32, 39,104,112,112, 39, 32,116,
+    104,101,110, 10, 99,111,100,101, 32, 61, 32,101,120,116,114,
+     97, 99,116, 95, 99,111,100,101, 40,102,110, 44, 99,111,100,
+    101, 41, 10,101,110,100, 10,105,102, 32,102,110, 32,116,104,
+    101,110, 10,114,101, 97,100,102,114,111,109, 40, 41, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32,110,115,117, 98,115,116,
+     10,114,101,112,101, 97,116, 10, 99,111,100,101, 44,110,115,
+    117, 98,115,116, 32, 61, 32,103,115,117, 98, 40, 99,111,100,
+    101, 44, 39, 92,110, 37,115, 42, 37, 36, 40, 46, 41,102,105,
+    108,101, 37,115, 42, 34, 40, 46, 45, 41, 34, 40, 91, 94, 92,
+    110, 93, 42, 41, 92,110, 39, 44, 10,102,117,110, 99,116,105,
+    111,110, 32, 40,107,105,110,100, 44,102,110, 44,101,120,116,
+    114, 97, 41, 10,108,111, 99, 97,108, 32, 95, 44, 32, 95, 44,
+     32,101,120,116, 32, 61, 32,115,116,114,102,105,110,100, 40,
+    102,110, 44, 34, 46, 42, 37, 46, 40, 46, 42, 41, 36, 34, 41,
+     10,108,111, 99, 97,108, 32,102,112, 44,109,115,103, 32, 61,
+     32,111,112,101,110,102,105,108,101, 40,102,110, 44, 39,114,
+     39, 41, 10,105,102, 32,110,111,116, 32,102,112, 32,116,104,
+    101,110, 10,101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,
+    115,103, 46, 46, 39, 58, 32, 39, 46, 46,102,110, 41, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32,115, 32, 61, 32,114,101,
+     97,100, 40,102,112, 44, 39, 42, 97, 39, 41, 10, 99,108,111,
+    115,101,102,105,108,101, 40,102,112, 41, 10,105,102, 32,107,
+    105,110,100, 32, 61, 61, 32, 39, 99, 39, 32,111,114, 32,107,
+    105,110,100, 32, 61, 61, 32, 39,104, 39, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 32,101,120,116,114, 97, 99,116,
+     95, 99,111,100,101, 40,102,110, 44,115, 41, 10,101,108,115,
+    101,105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,112, 39,
+     32,116,104,101,110, 10,114,101,116,117,114,110, 32, 34, 92,
+    110, 92,110, 34, 32, 46, 46, 32,115, 10,101,108,115,101,105,
+    102, 32,107,105,110,100, 32, 61, 61, 32, 39,108, 39, 32,116,
+    104,101,110, 10,114,101,116,117,114,110, 32, 34, 92,110, 36,
+     91, 45, 45, 35, 35, 34, 46, 46,102,110, 46, 46, 34, 92,110,
+     34, 32, 46, 46, 32,115, 32, 46, 46, 32, 34, 92,110, 36, 93,
+     92,110, 34, 10,101,108,115,101,105,102, 32,107,105,110,100,
+     32, 61, 61, 32, 39,105, 39, 32,116,104,101,110, 10,108,111,
+     99, 97,108, 32,116, 32, 61, 32,123, 99,111,100,101, 61,115,
+    125, 10,101,120,116,114, 97, 32, 61, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40,101,120,116,114, 97, 44, 32, 34,
+     94, 37,115, 42, 44, 37,115, 42, 34, 44, 32, 34, 34, 41, 10,
+    108,111, 99, 97,108, 32,112, 97,114,115, 32, 61, 32,115,112,
+    108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,101,120,
+    116,114, 97, 44, 32, 34, 44, 34, 41, 10,105,110, 99,108,117,
+    100,101, 95,102,105,108,101, 95,104,111,111,107, 40,116, 44,
+     32,102,110, 44, 32,117,110,112, 97, 99,107, 40,112, 97,114,
+    115, 41, 41, 10,114,101,116,117,114,110, 32, 34, 92,110, 92,
+    110, 34, 32, 46, 46, 32,116, 46, 99,111,100,101, 10,101,108,
+    115,101, 10,101,114,114,111,114, 40, 39, 35, 73,110,118, 97,
+    108,105,100, 32,105,110, 99,108,117,100,101, 32,100,105,114,
+    101, 99,116,105,118,101, 32, 40,117,115,101, 32, 36, 99,102,
+    105,108,101, 44, 32, 36,112,102,105,108,101, 44, 32, 36,108,
+    102,105,108,101, 32,111,114, 32, 36,105,102,105,108,101, 41,
+     39, 41, 10,101,110,100, 10,101,110,100, 41, 10,117,110,116,
+    105,108, 32,110,115,117, 98,115,116, 61, 61, 48, 10,114,101,
+    112,101, 97,116, 10, 99,111,100,101, 44,110,115,117, 98,115,
+    116, 32, 61, 32,103,115,117, 98, 40, 99,111,100,101, 44, 39,
+     92,110, 37,115, 42, 37, 36,114,101,110, 97,109,105,110,103,
+     37,115, 42, 40, 46, 45, 41, 37,115, 42, 92,110, 39, 44, 32,
+    102,117,110, 99,116,105,111,110, 32, 40,114, 41, 32, 97,112,
+    112,101,110,100,114,101,110, 97,109,105,110,103, 40,114, 41,
+     32,114,101,116,117,114,110, 32, 34, 92,110, 34, 32,101,110,
+    100, 41, 10,117,110,116,105,108, 32,110,115,117, 98,115,116,
+     32, 61, 61, 32, 48, 10,108,111, 99, 97,108, 32,116, 32, 61,
+     32, 95, 80, 97, 99,107, 97,103,101, 40, 95, 67,111,110,116,
+     97,105,110,101,114,123,110, 97,109,101, 61,110, 97,109,101,
+     44, 32, 99,111,100,101, 61, 99,111,100,101,125, 41, 10,112,
+    117,115,104, 40,116, 41, 10,112,114,101,112,114,111, 99,101,
+    115,115, 95,104,111,111,107, 40,116, 41, 10,116, 58,112,114,
+    101,112,114,111, 99,101,115,115, 40, 41, 10,112,114,101,112,
+     97,114,115,101, 95,104,111,111,107, 40,116, 41, 10,116, 58,
+    112, 97,114,115,101, 40,116, 46, 99,111,100,101, 41, 10,112,
+    111,112, 40, 41, 10,114,101,116,117,114,110, 32,116, 10,101,
+    110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/package.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 77,111,100,117,108,101, 32, 61, 32,
+    123, 10, 99,108, 97,115,115,116,121,112,101, 32, 61, 32, 39,
+    109,111,100,117,108,101, 39, 10,125, 10, 99,108, 97,115,115,
+     77,111,100,117,108,101, 46, 95, 95,105,110,100,101,120, 32,
+     61, 32, 99,108, 97,115,115, 77,111,100,117,108,101, 10,115,
+    101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,108, 97,
+    115,115, 77,111,100,117,108,101, 44, 99,108, 97,115,115, 67,
+    111,110,116, 97,105,110,101,114, 41, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 77,111,100,117,108,101,
+     58,114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41,
+     10,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39,
+     39, 10,112,117,115,104, 40,115,101,108,102, 41, 10,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117,
+     97, 95,109,111,100,117,108,101, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 39, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 39, 34, 44, 39, 44,115,101,108,102, 58,104, 97,115,
+    118, 97,114, 40, 41, 44, 39, 41, 59, 39, 41, 10,111,117,116,
+    112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97,
+     95, 98,101,103,105,110,109,111,100,117,108,101, 40,116,111,
+    108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,
+    110, 97,109,101, 46, 46, 39, 34, 41, 59, 39, 41, 10,108,111,
+     99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,
+    101,108,102, 91,105, 93, 32,100,111, 10,115,101,108,102, 91,
+    105, 93, 58,114,101,103,105,115,116,101,114, 40,112,114,101,
+     46, 46, 39, 32, 39, 41, 10,105, 32, 61, 32,105, 43, 49, 10,
+    101,110,100, 10,111,117,116,112,117,116, 40,112,114,101, 46,
+     46, 39,116,111,108,117, 97, 95,101,110,100,109,111,100,117,
+    108,101, 40,116,111,108,117, 97, 95, 83, 41, 59, 39, 41, 10,
+    112,111,112, 40, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 77,111,100,117,108,101,
+     58,112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,
+    108,111,115,101, 41, 10,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 77,111,100,117,108,101,123, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 46, 46, 34, 39, 59, 34, 41, 10,108,111,
+     99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,
+    101,108,102, 91,105, 93, 32,100,111, 10,115,101,108,102, 91,
+    105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32, 34, 44, 34, 44, 34, 41, 10,105, 32, 61, 32,105,
+     43, 49, 10,101,110,100, 10,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101,
+     41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 77,111,100,117,108,101, 32, 40,116, 41, 10,115,101,116,
+    109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,108, 97,
+    115,115, 77,111,100,117,108,101, 41, 10, 97,112,112,101,110,
+    100, 40,116, 41, 10,114,101,116,117,114,110, 32,116, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 77,111,100,
+    117,108,101, 32, 40,110, 44, 98, 41, 10,108,111, 99, 97,108,
+     32,116, 32, 61, 32, 95, 77,111,100,117,108,101, 40, 95, 67,
+    111,110,116, 97,105,110,101,114,123,110, 97,109,101, 61,110,
+    125, 41, 10,112,117,115,104, 40,116, 41, 10,116, 58,112, 97,
+    114,115,101, 40,115,116,114,115,117, 98, 40, 98, 44, 50, 44,
+    115,116,114,108,101,110, 40, 98, 41, 45, 49, 41, 41, 10,112,
+    111,112, 40, 41, 10,114,101,116,117,114,110, 32,116, 10,101,
+    110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/module.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 78, 97,109,101,115,112, 97, 99,101,
+     32, 61, 32,123, 10, 99,108, 97,115,115,116,121,112,101, 32,
+     61, 32, 39,110, 97,109,101,115,112, 97, 99,101, 39, 44, 10,
+    110, 97,109,101, 32, 61, 32, 39, 39, 44, 10,125, 10, 99,108,
+     97,115,115, 78, 97,109,101,115,112, 97, 99,101, 46, 95, 95,
+    105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 78, 97,
+    109,101,115,112, 97, 99,101, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40, 99,108, 97,115,115, 78, 97,109,101,
+    115,112, 97, 99,101, 44, 99,108, 97,115,115, 77,111,100,117,
+    108,101, 41, 10,102,117,110, 99,116,105,111,110, 32, 99,108,
+     97,115,115, 78, 97,109,101,115,112, 97, 99,101, 58,112,114,
+    105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,111,115,
+    101, 41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 78, 97,109,101,115,112, 97, 99,101,123, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,108,111,
+     99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,
+    101,108,102, 91,105, 93, 32,100,111, 10,115,101,108,102, 91,
+    105, 93, 58,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32, 34, 44, 34, 44, 34, 41, 10,105, 32, 61, 32,105,
+     43, 49, 10,101,110,100, 10,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34,125, 34, 46, 46, 99,108,111,115,101,
+     41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 78, 97,109,101,115,112, 97, 99,101, 32, 40,116, 41, 10,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44,
+     99,108, 97,115,115, 78, 97,109,101,115,112, 97, 99,101, 41,
+     10, 97,112,112,101,110,100, 40,116, 41, 10,114,101,116,117,
+    114,110, 32,116, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 78, 97,109,101,115,112, 97, 99,101, 32, 40,110,
+     44, 98, 41, 10,108,111, 99, 97,108, 32, 99, 32, 61, 32, 95,
+     78, 97,109,101,115,112, 97, 99,101, 40, 95, 67,111,110,116,
+     97,105,110,101,114,123,110, 97,109,101, 61,110,125, 41, 10,
+    112,117,115,104, 40, 99, 41, 10, 99, 58,112, 97,114,115,101,
+     40,115,116,114,115,117, 98, 40, 98, 44, 50, 44,115,116,114,
+    108,101,110, 40, 98, 41, 45, 49, 41, 41, 10,112,111,112, 40,
+     41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/namespace.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 68,101,102,105,110,101, 32, 61, 32,
+    123, 10,110, 97,109,101, 32, 61, 32, 39, 39, 44, 10,125, 10,
+     99,108, 97,115,115, 68,101,102,105,110,101, 46, 95, 95,105,
+    110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 68,101,102,
+    105,110,101, 10,115,101,116,109,101,116, 97,116, 97, 98,108,
+    101, 40, 99,108, 97,115,115, 68,101,102,105,110,101, 44, 99,
+    108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101,102,
+    105,110,101, 58,114,101,103,105,115,116,101,114, 32, 40,112,
+    114,101, 41, 10,105,102, 32,110,111,116, 32,115,101,108,102,
+     58, 99,104,101, 99,107, 95,112,117, 98,108,105, 99, 95, 97,
+     99, 99,101,115,115, 40, 41, 32,116,104,101,110, 10,114,101,
+    116,117,114,110, 10,101,110,100, 10,112,114,101, 32, 61, 32,
+    112,114,101, 32,111,114, 32, 39, 39, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, 99,
+    111,110,115,116, 97,110,116, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+     46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46,110, 97,
+    109,101, 46, 46, 39, 41, 59, 39, 41, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101,
+    102,105,110,101, 58,112,114,105,110,116, 32, 40,105,100,101,
+    110,116, 44, 99,108,111,115,101, 41, 10,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 68,101,102,105,110,101,
+    123, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34, 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34,
+     41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34, 32,108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34,
+     41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32, 95, 68,101,102,105,
+    110,101, 32, 40,116, 41, 10,115,101,116,109,101,116, 97,116,
+     97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 68,101,102,
+    105,110,101, 41, 10,116, 58, 98,117,105,108,100,110, 97,109,
+    101,115, 40, 41, 10,105,102, 32,116, 46,110, 97,109,101, 32,
+     61, 61, 32, 39, 39, 32,116,104,101,110, 10,101,114,114,111,
+    114, 40, 34, 35,105,110,118, 97,108,105,100, 32,100,101,102,
+    105,110,101, 34, 41, 10,101,110,100, 10, 97,112,112,101,110,
+    100, 40,116, 41, 10,114,101,116,117,114,110, 32,116, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 68,101,102,
+    105,110,101, 32, 40,110, 41, 10,114,101,116,117,114,110, 32,
+     95, 68,101,102,105,110,101,123, 10,110, 97,109,101, 32, 61,
+     32,110, 10,125, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/define.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101,
+     32, 61, 32,123, 10,125, 10, 99,108, 97,115,115, 69,110,117,
+    109,101,114, 97,116,101, 46, 95, 95,105,110,100,101,120, 32,
+     61, 32, 99,108, 97,115,115, 69,110,117,109,101,114, 97,116,
+    101, 10,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,
+     99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 44,
+     99,108, 97,115,115, 70,101, 97,116,117,114,101, 41, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 69,110,
+    117,109,101,114, 97,116,101, 58,114,101,103,105,115,116,101,
+    114, 32, 40,112,114,101, 41, 10,112,114,101, 32, 61, 32,112,
+    114,101, 32,111,114, 32, 39, 39, 10,108,111, 99, 97,108, 32,
+    110,115,112, 97, 99,101, 32, 61, 32,103,101,116,110, 97,109,
+    101,115,112, 97, 99,101, 40, 99,108, 97,115,115, 67,111,110,
+    116, 97,105,110,101,114, 46, 99,117,114,114, 41, 10,108,111,
+     99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,
+    101,108,102, 91,105, 93, 32,100,111, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, 99,
+    111,110,115,116, 97,110,116, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+    115, 91,105, 93, 46, 46, 39, 34, 44, 39, 46, 46,110,115,112,
+     97, 99,101, 46, 46,115,101,108,102, 91,105, 93, 46, 46, 39,
+     41, 59, 39, 41, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,
+    100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 69,110,117,109,101,114, 97,116,101,123, 34,
+     41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34, 32,110, 97,109,101, 32, 61, 32, 34, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 41, 10,108,111, 99, 97,108, 32,105,
+     61, 49, 10,119,104,105,108,101, 32,115,101,108,102, 91,105,
+     93, 32,100,111, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32, 39, 34, 46, 46,115,101,108,102, 91,105,
+     93, 46, 46, 34, 39, 40, 34, 46, 46,115,101,108,102, 46,108,
+    110, 97,109,101,115, 91,105, 93, 46, 46, 34, 41, 44, 34, 41,
+     10,105, 32, 61, 32,105, 43, 49, 10,101,110,100, 10,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46,
+     46, 99,108,111,115,101, 41, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 95, 69,110,117,109,101,114, 97,116,
+    101, 32, 40,116, 44,118, 97,114,110, 97,109,101, 41, 10,115,
+    101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44, 99,
+    108, 97,115,115, 69,110,117,109,101,114, 97,116,101, 41, 10,
+     97,112,112,101,110,100, 40,116, 41, 10, 97,112,112,101,110,
+    100,101,110,117,109, 40,116, 41, 10,105,102, 32,118, 97,114,
+    110, 97,109,101, 32, 97,110,100, 32,118, 97,114,110, 97,109,
+    101, 32,126, 61, 32, 34, 34, 32,116,104,101,110, 10,105,102,
+     32,116, 46,110, 97,109,101, 32,126, 61, 32, 34, 34, 32,116,
+    104,101,110, 10, 86, 97,114,105, 97, 98,108,101, 40,116, 46,
+    110, 97,109,101, 46, 46, 34, 32, 34, 46, 46,118, 97,114,110,
+     97,109,101, 41, 10,101,108,115,101, 10,108,111, 99, 97,108,
+     32,110,115, 32, 61, 32,103,101,116, 99,117,114,114,110, 97,
+    109,101,115,112, 97, 99,101, 40, 41, 10,119, 97,114,110,105,
+    110,103, 40, 34, 86, 97,114,105, 97, 98,108,101, 32, 34, 46,
+     46,110,115, 46, 46,118, 97,114,110, 97,109,101, 46, 46, 34,
+     32,111,102, 32,116,121,112,101, 32, 60, 97,110,111,110,121,
+    109,111,117,115, 32,101,110,117,109, 62, 32,105,115, 32,100,
+    101, 99,108, 97,114,101,100, 32, 97,115, 32,114,101, 97,100,
+     45,111,110,108,121, 34, 41, 10, 86, 97,114,105, 97, 98,108,
+    101, 40, 34,116,111,108,117, 97, 95,114,101, 97,100,111,110,
+    108,121, 32,105,110,116, 32, 34, 46, 46,118, 97,114,110, 97,
+    109,101, 41, 10,101,110,100, 10,101,110,100, 10,114,101,116,
+    117,114,110, 32,116, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 69,110,117,109,101,114, 97,116,101, 32, 40,
+    110, 44, 98, 44,118, 97,114,110, 97,109,101, 41, 10, 98, 32,
+     61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40, 98,
+     44, 32, 34, 44, 91, 37,115, 92,110, 93, 42,125, 34, 44, 32,
+     34, 92,110,125, 34, 41, 10,108,111, 99, 97,108, 32,116, 32,
+     61, 32,115,112,108,105,116, 40,115,116,114,115,117, 98, 40,
+     98, 44, 50, 44, 45, 50, 41, 44, 39, 44, 39, 41, 10,108,111,
+     99, 97,108, 32,105, 32, 61, 32, 49, 10,108,111, 99, 97,108,
+     32,101, 32, 61, 32,123,110, 61, 48,125, 10,119,104,105,108,
+    101, 32,116, 91,105, 93, 32,100,111, 10,108,111, 99, 97,108,
+     32,116,116, 32, 61, 32,115,112,108,105,116, 40,116, 91,105,
+     93, 44, 39, 61, 39, 41, 10,101, 46,110, 32, 61, 32,101, 46,
+    110, 32, 43, 32, 49, 10,101, 91,101, 46,110, 93, 32, 61, 32,
+    116,116, 91, 49, 93, 10,105, 32, 61, 32,105, 43, 49, 10,101,
+    110,100, 10,105, 32, 61, 32, 49, 10,101, 46,108,110, 97,109,
+    101,115, 32, 61, 32,123,125, 10,108,111, 99, 97,108, 32,110,
+    115, 32, 61, 32,103,101,116, 99,117,114,114,110, 97,109,101,
+    115,112, 97, 99,101, 40, 41, 10,119,104,105,108,101, 32,101,
+     91,105, 93, 32,100,111, 10,108,111, 99, 97,108, 32,116, 32,
+     61, 32,115,112,108,105,116, 40,101, 91,105, 93, 44, 39, 64,
+     39, 41, 10,101, 91,105, 93, 32, 61, 32,116, 91, 49, 93, 10,
+    105,102, 32,110,111,116, 32,116, 91, 50, 93, 32,116,104,101,
+    110, 10,116, 91, 50, 93, 32, 61, 32, 97,112,112,108,121,114,
+    101,110, 97,109,105,110,103, 40,116, 91, 49, 93, 41, 10,101,
+    110,100, 10,101, 46,108,110, 97,109,101,115, 91,105, 93, 32,
+     61, 32,116, 91, 50, 93, 32,111,114, 32,116, 91, 49, 93, 10,
+     95,103,108,111, 98, 97,108, 95,101,110,117,109,115, 91, 32,
+    110,115, 46, 46,101, 91,105, 93, 32, 93, 32, 61, 32, 40,110,
+    115, 46, 46,101, 91,105, 93, 41, 10,105, 32, 61, 32,105, 43,
+     49, 10,101,110,100, 10,101, 46,110, 97,109,101, 32, 61, 32,
+    110, 10,105,102, 32,110, 32,126, 61, 32, 34, 34, 32,116,104,
+    101,110, 10, 84,121,112,101,100,101,102, 40, 34,105,110,116,
+     32, 34, 46, 46,110, 41, 10,101,110,100, 10,114,101,116,117,
+    114,110, 32, 95, 69,110,117,109,101,114, 97,116,101, 40,101,
+     44, 32,118, 97,114,110, 97,109,101, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/enumerate.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,
+    111,110, 32, 61, 32,123, 10,109,111,100, 32, 61, 32, 39, 39,
+     44, 10,116,121,112,101, 32, 61, 32, 39, 39, 44, 10,112,116,
+    114, 32, 61, 32, 39, 39, 44, 10,110, 97,109,101, 32, 61, 32,
+     39, 39, 44, 10,100,105,109, 32, 61, 32, 39, 39, 44, 10,114,
+    101,116, 32, 61, 32, 39, 39, 44, 10,100,101,102, 32, 61, 32,
+     39, 39, 10,125, 10, 99,108, 97,115,115, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 46, 95, 95,105,110,100,101,120, 32,
+     61, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,
+    105,111,110, 10,115,101,116,109,101,116, 97,116, 97, 98,108,
+    101, 40, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,
+    105,111,110, 44, 99,108, 97,115,115, 70,101, 97,116,117,114,
+    101, 41, 10,102,117,110, 99,116,105,111,110, 32, 99,114,101,
+     97,116,101, 95,118, 97,114,110, 97,109,101, 32, 40, 41, 10,
+    105,102, 32,110,111,116, 32, 95,118, 97,114,110,117,109, 98,
+    101,114, 32,116,104,101,110, 32, 95,118, 97,114,110,117,109,
+     98,101,114, 32, 61, 32, 48, 32,101,110,100, 10, 95,118, 97,
+    114,110,117,109, 98,101,114, 32, 61, 32, 95,118, 97,114,110,
+    117,109, 98,101,114, 32, 43, 32, 49, 10,114,101,116,117,114,
+    110, 32, 34,116,111,108,117, 97, 95,118, 97,114, 95, 34, 46,
+     46, 95,118, 97,114,110,117,109, 98,101,114, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     68,101, 99,108, 97,114, 97,116,105,111,110, 58, 99,104,101,
+     99,107,110, 97,109,101, 32, 40, 41, 10,105,102, 32,115,116,
+    114,115,117, 98, 40,115,101,108,102, 46,110, 97,109,101, 44,
+     49, 44, 49, 41, 32, 61, 61, 32, 39, 91, 39, 32, 97,110,100,
+     32,110,111,116, 32,102,105,110,100,116,121,112,101, 40,115,
+    101,108,102, 46,116,121,112,101, 41, 32,116,104,101,110, 10,
+    115,101,108,102, 46,110, 97,109,101, 32, 61, 32,115,101,108,
+    102, 46,116,121,112,101, 46, 46,115,101,108,102, 46,110, 97,
+    109,101, 10,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112,
+    108,105,116, 40,115,101,108,102, 46,109,111,100, 44, 39, 37,
+    115, 37,115, 42, 39, 41, 10,115,101,108,102, 46,116,121,112,
+    101, 32, 61, 32,109, 91,109, 46,110, 93, 10,115,101,108,102,
+     46,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,109,
+     44, 49, 44,109, 46,110, 45, 49, 41, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32,116, 32, 61, 32,115,112,108,105,116, 40,
+    115,101,108,102, 46,110, 97,109,101, 44, 39, 61, 39, 41, 10,
+    105,102, 32,116, 46,110, 61, 61, 50, 32,116,104,101,110, 10,
+    115,101,108,102, 46,110, 97,109,101, 32, 61, 32,116, 91, 49,
+     93, 10,115,101,108,102, 46,100,101,102, 32, 61, 32,102,105,
+    110,100, 95,101,110,117,109, 95,118, 97,114, 40,116, 91,116,
+     46,110, 93, 41, 10,101,110,100, 10,108,111, 99, 97,108, 32,
+     98, 44,101, 44,100, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115,101,108,102, 46,110, 97,109,101, 44, 34, 37, 91, 40,
+     46, 45, 41, 37, 93, 34, 41, 10,105,102, 32, 98, 32,116,104,
+    101,110, 10,115,101,108,102, 46,110, 97,109,101, 32, 61, 32,
+    115,116,114,115,117, 98, 40,115,101,108,102, 46,110, 97,109,
+    101, 44, 49, 44, 98, 45, 49, 41, 10,115,101,108,102, 46,100,
+    105,109, 32, 61, 32,102,105,110,100, 95,101,110,117,109, 95,
+    118, 97,114, 40,100, 41, 10,101,110,100, 10,105,102, 32,115,
+    101,108,102, 46,116,121,112,101, 32,126, 61, 32, 39, 39, 32,
+     97,110,100, 32,115,101,108,102, 46,116,121,112,101, 32,126,
+     61, 32, 39,118,111,105,100, 39, 32, 97,110,100, 32,115,101,
+    108,102, 46,110, 97,109,101, 32, 61, 61, 32, 39, 39, 32,116,
+    104,101,110, 10,115,101,108,102, 46,110, 97,109,101, 32, 61,
+     32, 99,114,101, 97,116,101, 95,118, 97,114,110, 97,109,101,
+     40, 41, 10,101,108,115,101,105,102, 32,115,101,108,102, 46,
+    107,105,110,100, 61, 61, 39,118, 97,114, 39, 32,116,104,101,
+    110, 10,105,102, 32,115,101,108,102, 46,116,121,112,101, 61,
+     61, 39, 39, 32, 97,110,100, 32,115,101,108,102, 46,110, 97,
+    109,101,126, 61, 39, 39, 32,116,104,101,110, 10,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 32,115,101,108,102, 46,116,
+    121,112,101, 46, 46,115,101,108,102, 46,110, 97,109,101, 10,
+    115,101,108,102, 46,110, 97,109,101, 32, 61, 32, 99,114,101,
+     97,116,101, 95,118, 97,114,110, 97,109,101, 40, 41, 10,101,
+    108,115,101,105,102, 32,102,105,110,100,116,121,112,101, 40,
+    115,101,108,102, 46,110, 97,109,101, 41, 32,116,104,101,110,
+     10,105,102, 32,115,101,108,102, 46,116,121,112,101, 61, 61,
+     39, 39, 32,116,104,101,110, 32,115,101,108,102, 46,116,121,
+    112,101, 32, 61, 32,115,101,108,102, 46,110, 97,109,101, 10,
+    101,108,115,101, 32,115,101,108,102, 46,116,121,112,101, 32,
+     61, 32,115,101,108,102, 46,116,121,112,101, 46, 46, 39, 32,
+     39, 46, 46,115,101,108,102, 46,110, 97,109,101, 32,101,110,
+    100, 10,115,101,108,102, 46,110, 97,109,101, 32, 61, 32, 99,
+    114,101, 97,116,101, 95,118, 97,114,110, 97,109,101, 40, 41,
+     10,101,110,100, 10,101,110,100, 10,105,102, 32,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 61, 32, 39, 99,104, 97,114,
+     39, 32, 97,110,100, 32,115,101,108,102, 46,100,105,109, 32,
+    126, 61, 32, 39, 39, 32,116,104,101,110, 10,115,101,108,102,
+     46,116,121,112,101, 32, 61, 32, 39, 99,104, 97,114, 42, 39,
+     10,101,110,100, 10,105,102, 32,115,101,108,102, 46,107,105,
+    110,100, 32, 97,110,100, 32,115,101,108,102, 46,107,105,110,
+    100, 32, 61, 61, 32, 39,118, 97,114, 39, 32,116,104,101,110,
+     10,115,101,108,102, 46,110, 97,109,101, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,115,101,108,102, 46,
+    110, 97,109,101, 44, 32, 34, 58, 46, 42, 36, 34, 44, 32, 34,
+     34, 41, 10,101,110,100, 10,101,110,100, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,
+    114, 97,116,105,111,110, 58, 99,104,101, 99,107,116,121,112,
+    101, 32, 40, 41, 10,108,111, 99, 97,108, 32, 98, 97,115,105,
+     99, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,
+    102, 46,116,121,112,101, 41, 10,105,102, 32,115,101,108,102,
+     46,107,105,110,100, 32, 61, 61, 32, 39,102,117,110, 99, 39,
+     32, 97,110,100, 32, 98, 97,115,105, 99, 61, 61, 39,110,117,
+    109, 98,101,114, 39, 32, 97,110,100, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,115,101,108,102, 46,112,116,114,
+     44, 32, 34, 37, 42, 34, 41, 32,116,104,101,110, 10,115,101,
+    108,102, 46,116,121,112,101, 32, 61, 32, 39, 95,117,115,101,
+    114,100, 97,116, 97, 39, 10,115,101,108,102, 46,112,116,114,
+     32, 61, 32, 34, 34, 10,101,110,100, 10,105,102, 32, 98, 97,
+    115,105, 99, 32, 97,110,100, 32,115,101,108,102, 46,112,116,
+    114,126, 61, 39, 39, 32,116,104,101,110, 10,115,101,108,102,
+     46,114,101,116, 32, 61, 32,115,101,108,102, 46,112,116,114,
+     10,115,101,108,102, 46,112,116,114, 32, 61, 32,110,105,108,
+     10,105,102, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,
+    102, 46,116,121,112,101, 41, 32, 61, 61, 32, 39,110,117,109,
+     98,101,114, 39, 32,116,104,101,110, 10,115,101,108,102, 46,
+    114,101,116,117,114,110, 95,117,115,101,114,100, 97,116, 97,
+     32, 61, 32,116,114,117,101, 10,101,110,100, 10,101,110,100,
+     10,105,102, 32,115,101,108,102, 46,100,105,109,126, 61, 39,
+     39, 32, 97,110,100, 32,115,101,108,102, 46,114,101,116,126,
+     61, 39, 39, 32,116,104,101,110, 10,101,114,114,111,114, 40,
+     39, 35,105,110,118, 97,108,105,100, 32,112, 97,114, 97,109,
+    101,116,101,114, 58, 32, 99, 97,110,110,111,116, 32,114,101,
+    116,117,114,110, 32, 97,110, 32, 97,114,114, 97,121, 32,111,
+    102, 32,118, 97,108,117,101,115, 39, 41, 10,101,110,100, 10,
+    105,102, 32,115,101,108,102, 46,116,121,112,101, 32, 61, 61,
+     32, 39, 95,117,115,101,114,100, 97,116, 97, 39, 32,116,104,
+    101,110, 32,115,101,108,102, 46,116,121,112,101, 32, 61, 32,
+     39,118,111,105,100, 42, 39, 10,101,108,115,101,105,102, 32,
+    115,101,108,102, 46,116,121,112,101, 32, 61, 61, 32, 39, 95,
+     99,115,116,114,105,110,103, 39, 32,116,104,101,110, 32,115,
+    101,108,102, 46,116,121,112,101, 32, 61, 32, 39, 99,104, 97,
+    114, 42, 39, 10,101,108,115,101,105,102, 32,115,101,108,102,
+     46,116,121,112,101, 32, 61, 61, 32, 39, 95,108,115,116, 97,
+    116,101, 39, 32,116,104,101,110, 32,115,101,108,102, 46,116,
+    121,112,101, 32, 61, 32, 39,108,117, 97, 95, 83,116, 97,116,
+    101, 42, 39, 10,101,110,100, 10,105,102, 32,115,101,108,102,
+     46,116,121,112,101, 32,116,104,101,110, 10,115,101,108,102,
+     46,116,121,112,101, 32, 61, 32,114,101,115,111,108,118,101,
+     95,116,101,109,112,108, 97,116,101, 95,116,121,112,101,115,
+     40,115,101,108,102, 46,116,121,112,101, 41, 10,101,110,100,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,114,
+    101,115,111,108,118,101, 95,116,101,109,112,108, 97,116,101,
+     95,116,121,112,101,115, 40,116,121,112,101, 41, 10,105,102,
+     32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41, 32,
+    116,104,101,110, 10,114,101,116,117,114,110, 32,116,121,112,
+    101, 10,101,110,100, 10,108,111, 99, 97,108, 32, 98, 44, 95,
+     44,109, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,116,121,112,101, 44, 32, 34, 40, 37, 98, 60, 62, 41,
+     34, 41, 10,105,102, 32, 98, 32,116,104,101,110, 10,109, 32,
+     61, 32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,
+    115, 40,115,116,114,105,110,103, 46,115,117, 98, 40,109, 44,
+     32, 50, 44, 32, 45, 50, 41, 44, 32, 34, 44, 34, 41, 10,102,
+    111,114, 32,105, 61, 49, 44, 32,116, 97, 98,108,101, 46,103,
+    101,116,110, 40,109, 41, 32,100,111, 10,109, 91,105, 93, 32,
+     61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,109,
+     91,105, 93, 44, 34, 37,115, 42, 40, 91, 37, 42, 38, 93, 41,
+     34, 44, 32, 34, 37, 49, 34, 41, 10,109, 91,105, 93, 32, 61,
+     32,102,105,110,100,116,121,112,101, 40,109, 91,105, 93, 41,
+     32,111,114, 32,109, 91,105, 93, 10,109, 91,105, 93, 32, 61,
+     32,114,101,115,111,108,118,101, 95,116,101,109,112,108, 97,
+    116,101, 95,116,121,112,101,115, 40,109, 91,105, 93, 41, 10,
+    101,110,100, 10,108,111, 99, 97,108, 32, 98, 44,105, 10,116,
+    121,112,101, 44, 98, 44,105, 32, 61, 32, 98,114,101, 97,107,
+     95,116,101,109,112,108, 97,116,101, 40,116,121,112,101, 41,
+     10,108,111, 99, 97,108, 32,116,101,109,112,108, 97,116,101,
+     95,112, 97,114,116, 32, 61, 32, 34, 60, 34, 46, 46,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40, 99,111,110, 99, 97,
+    116, 40,109, 44, 32, 49, 44, 32,109, 46,110, 41, 44, 32, 34,
+     32, 34, 44, 32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10,116,
+    121,112,101, 32, 61, 32,114,101, 98,117,105,108,100, 95,116,
+    101,109,112,108, 97,116,101, 40,116,121,112,101, 44, 32, 98,
+     44, 32,116,101,109,112,108, 97,116,101, 95,112, 97,114,116,
+     41, 10,116,121,112,101, 32, 61, 32,115,116,114,105,110,103,
+     46,103,115,117, 98, 40,116,121,112,101, 44, 32, 34, 62, 62,
+     34, 44, 32, 34, 62, 32, 62, 34, 41, 10,101,110,100, 10,114,
+    101,116,117,114,110, 32,116,121,112,101, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 98,114,101, 97,107, 95,
+    116,101,109,112,108, 97,116,101, 40,115, 41, 10,108,111, 99,
+     97,108, 32, 98, 44,101, 44,116,105,109,112,108, 32, 61, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,115, 44, 32,
+     34, 40, 37, 98, 60, 62, 41, 34, 41, 10,105,102, 32,116,105,
+    109,112,108, 32,116,104,101,110, 10,115, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32, 34, 37,
+     98, 60, 62, 34, 44, 32, 34, 34, 41, 10,114,101,116,117,114,
+    110, 32,115, 44, 32, 98, 44, 32,116,105,109,112,108, 10,101,
+    108,115,101, 10,114,101,116,117,114,110, 32,115, 44, 32, 48,
+     44, 32,110,105,108, 10,101,110,100, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32,114,101, 98,117,105,108,100,
+     95,116,101,109,112,108, 97,116,101, 40,115, 44, 32, 98, 44,
+     32,116,105,109,112,108, 41, 10,105,102, 32, 98, 32, 61, 61,
+     32, 48, 32,116,104,101,110, 10,114,101,116,117,114,110, 32,
+    115, 10,101,110,100, 10,114,101,116,117,114,110, 32,115,116,
+    114,105,110,103, 46,115,117, 98, 40,115, 44, 32, 49, 44, 32,
+     98, 45, 49, 41, 46, 46,116,105,109,112,108, 46, 46,115,116,
+    114,105,110,103, 46,115,117, 98, 40,115, 44, 32, 98, 44, 32,
+     45, 49, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,
+    105,111,110, 58,112,114,105,110,116, 32, 40,105,100,101,110,
+    116, 44, 99,108,111,115,101, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 68,101, 99,108, 97,114, 97,
+    116,105,111,110,123, 34, 41, 10,112,114,105,110,116, 40,105,
+    100,101,110,116, 46, 46, 34, 32,109,111,100, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39,
+     44, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34,
+     41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34, 32,112,116,114, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,
+    109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32,100,105,109, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,100,105,109, 46,
+     46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 32,100,101,102, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,100,101,102, 46, 46, 34, 39, 44,
+     34, 41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,114,101,116, 32, 61, 32, 39, 34, 46, 46,115,101,
+    108,102, 46,114,101,116, 46, 46, 34, 39, 44, 34, 41, 10,112,
+    114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34,
+     46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 58,114,101,113,117,105,114,
+    101, 99,111,108,108,101, 99,116,105,111,110, 32, 40,116, 41,
+     10,105,102, 32,115,101,108,102, 46,109,111,100, 32,126, 61,
+     32, 39, 99,111,110,115,116, 39, 32, 97,110,100, 10,115,101,
+    108,102, 46,100,105,109, 32, 97,110,100, 32,115,101,108,102,
+     46,100,105,109, 32,126, 61, 32, 39, 39, 32, 97,110,100, 10,
+    110,111,116, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,
+    102, 46,116,121,112,101, 41, 32, 97,110,100, 10,115,101,108,
+    102, 46,112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,
+    110, 10,108,111, 99, 97,108, 32,116,121,112,101, 32, 61, 32,
+    103,115,117, 98, 40,115,101,108,102, 46,116,121,112,101, 44,
+     34, 37,115, 42, 99,111,110,115,116, 37,115, 43, 34, 44, 34,
+     34, 41, 10,116, 91,116,121,112,101, 93, 32, 61, 32, 34,116,
+    111,108,117, 97, 95, 99,111,108,108,101, 99,116, 95, 34, 32,
+     46, 46, 32, 99,108,101, 97,110, 95,116,101,109,112,108, 97,
+    116,101, 40,116,121,112,101, 41, 10,114,101,116,117,114,110,
+     32,116,114,117,101, 10,101,110,100, 10,114,101,116,117,114,
+    110, 32,102, 97,108,115,101, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,108,
+     97,114, 97,116,105,111,110, 58,100,101, 99,108,116,121,112,
+    101, 32, 40, 41, 10,115,101,108,102, 46,116,121,112,101, 32,
+     61, 32,116,121,112,101,118, 97,114, 40,115,101,108,102, 46,
+    116,121,112,101, 41, 10,105,102, 32,115,116,114,102,105,110,
+    100, 40,115,101,108,102, 46,109,111,100, 44, 39, 99,111,110,
+    115,116, 39, 41, 32,116,104,101,110, 10,115,101,108,102, 46,
+    116,121,112,101, 32, 61, 32, 39, 99,111,110,115,116, 32, 39,
+     46, 46,115,101,108,102, 46,116,121,112,101, 10,115,101,108,
+    102, 46,109,111,100, 32, 61, 32,103,115,117, 98, 40,115,101,
+    108,102, 46,109,111,100, 44, 39, 99,111,110,115,116, 37,115,
+     42, 39, 44, 39, 39, 41, 10,101,110,100, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,
+    101, 99,108, 97,114, 97,116,105,111,110, 58,111,117,116, 99,
+    104,101, 99,107,116,121,112,101, 32, 40,110, 97,114,103, 41,
+     10,108,111, 99, 97,108, 32,100,101,102, 10,108,111, 99, 97,
+    108, 32,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,
+    101,108,102, 46,116,121,112,101, 41, 10,105,102, 32,115,101,
+    108,102, 46,100,101,102,126, 61, 39, 39, 32,116,104,101,110,
+     10,100,101,102, 32, 61, 32, 49, 10,101,108,115,101, 10,100,
+    101,102, 32, 61, 32, 48, 10,101,110,100, 10,105,102, 32,115,
+    101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,
+    104,101,110, 10,114,101,116,117,114,110, 32, 39,116,111,108,
+    117, 97, 95,105,115,116, 97, 98,108,101, 40,116,111,108,117,
+     97, 95, 83, 44, 39, 46, 46,110, 97,114,103, 46, 46, 39, 44,
+     48, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 39, 10,
+    101,108,115,101,105,102, 32,116, 32,116,104,101,110, 10,114,
+    101,116,117,114,110, 32, 39,116,111,108,117, 97, 95,105,115,
+     39, 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83,
+     44, 39, 46, 46,110, 97,114,103, 46, 46, 39, 44, 39, 46, 46,
+    100,101,102, 46, 46, 39, 44, 38,116,111,108,117, 97, 95,101,
+    114,114, 41, 39, 10,101,108,115,101, 10,114,101,116,117,114,
+    110, 32, 39,116,111,108,117, 97, 95,105,115,117,115,101,114,
+    116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 39, 46,
+     46,110, 97,114,103, 46, 46, 39, 44, 34, 39, 46, 46,115,101,
+    108,102, 46,116,121,112,101, 46, 46, 39, 34, 44, 39, 46, 46,
+    100,101,102, 46, 46, 39, 44, 38,116,111,108,117, 97, 95,101,
+    114,114, 41, 39, 10,101,110,100, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 58, 98,117,105,108,100,100,
+    101, 99,108, 97,114, 97,116,105,111,110, 32, 40,110, 97,114,
+    103, 44, 32, 99,112,108,117,115,112,108,117,115, 41, 10,108,
+    111, 99, 97,108, 32, 97,114,114, 97,121, 32, 61, 32,115,101,
+    108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32, 97,110,
+    100, 32,116,111,110,117,109, 98,101,114, 40,115,101,108,102,
+     46,100,105,109, 41, 61, 61,110,105,108, 10,108,111, 99, 97,
+    108, 32,108,105,110,101, 32, 61, 32, 34, 34, 10,108,111, 99,
+     97,108, 32,112,116,114, 32, 61, 32, 39, 39, 10,108,111, 99,
+     97,108, 32,109,111,100, 10,108,111, 99, 97,108, 32,116,121,
+    112,101, 32, 61, 32,115,101,108,102, 46,116,121,112,101, 10,
+    105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,116,121,112,101, 32, 61, 32,
+    103,115,117, 98, 40,115,101,108,102, 46,116,121,112,101, 44,
+     39, 99,111,110,115,116, 37,115, 43, 39, 44, 39, 39, 41, 10,
+    101,110,100, 10,105,102, 32,115,101,108,102, 46,112,116,114,
+    126, 61, 39, 39, 32, 97,110,100, 32,110,111,116, 32,105,115,
+     98, 97,115,105, 99, 40,116,121,112,101, 41, 32,116,104,101,
+    110, 32,112,116,114, 32, 61, 32, 39, 42, 39, 32,101,110,100,
+     10,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112,
+     97,114, 97,109, 40,108,105,110,101, 44, 34, 32, 34, 44,115,
+    101,108,102, 46,109,111,100, 44,116,121,112,101, 44,112,116,
+    114, 41, 10,105,102, 32, 97,114,114, 97,121, 32,116,104,101,
+    110, 10,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,
+    112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 42, 39, 41,
+     10,101,110,100, 10,108,105,110,101, 32, 61, 32, 99,111,110,
+     99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44,115,
+    101,108,102, 46,110, 97,109,101, 41, 10,105,102, 32,115,101,
+    108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 10,105,102, 32,116,111,110,117,109, 98,101,114, 40,
+    115,101,108,102, 46,100,105,109, 41,126, 61,110,105,108, 32,
+    116,104,101,110, 10,108,105,110,101, 32, 61, 32, 99,111,110,
+     99, 97,116,112, 97,114, 97,109, 40,108,105,110,101, 44, 39,
+     91, 39, 44,115,101,108,102, 46,100,105,109, 44, 39, 93, 59,
+     39, 41, 10,101,108,115,101, 10,105,102, 32, 99,112,108,117,
+    115,112,108,117,115, 32,116,104,101,110, 10,108,105,110,101,
+     32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,
+    108,105,110,101, 44, 39, 32, 61, 32,110,101,119, 39, 44,116,
+    121,112,101, 44,112,116,114, 44, 39, 91, 39, 46, 46,115,101,
+    108,102, 46,100,105,109, 46, 46, 39, 93, 59, 39, 41, 10,101,
+    108,115,101, 10,108,105,110,101, 32, 61, 32, 99,111,110, 99,
+     97,116,112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 32,
+     61, 32, 40, 39, 44,116,121,112,101, 44,112,116,114, 44, 39,
+     42, 41, 39, 44, 10, 39,109, 97,108,108,111, 99, 40, 40, 39,
+     44,115,101,108,102, 46,100,105,109, 44, 39, 41, 42,115,105,
+    122,101,111,102, 40, 39, 44,116,121,112,101, 44,112,116,114,
+     44, 39, 41, 41, 59, 39, 41, 10,101,110,100, 10,101,110,100,
+     10,101,108,115,101, 10,108,111, 99, 97,108, 32,116, 32, 61,
+     32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41, 10,
+    108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,
+    114, 97,109, 40,108,105,110,101, 44, 39, 32, 61, 32, 39, 41,
+     10,105,102, 32,116, 32, 61, 61, 32, 39,115,116, 97,116,101,
+     39, 32,116,104,101,110, 10,108,105,110,101, 32, 61, 32, 99,
+    111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,101,
+     44, 32, 39,116,111,108,117, 97, 95, 83, 59, 39, 41, 10,101,
+    108,115,101, 10,105,102, 32,116, 32, 61, 61, 32, 39,110,117,
+    109, 98,101,114, 39, 32, 97,110,100, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,115,101,108,102, 46,112,116,114,
+     44, 32, 34, 37, 42, 34, 41, 32,116,104,101,110, 10,116, 32,
+     61, 32, 39,117,115,101,114,100, 97,116, 97, 39, 10,101,110,
+    100, 10,105,102, 32,110,111,116, 32,116, 32, 97,110,100, 32,
+    112,116,114, 61, 61, 39, 39, 32,116,104,101,110, 32,108,105,
+    110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,
+    109, 40,108,105,110,101, 44, 39, 42, 39, 41, 32,101,110,100,
+     10,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112,
+     97,114, 97,109, 40,108,105,110,101, 44, 39, 40, 40, 39, 44,
+    115,101,108,102, 46,109,111,100, 44,116,121,112,101, 41, 10,
+    105,102, 32,110,111,116, 32,116, 32,116,104,101,110, 10,108,
+    105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,112, 97,114,
+     97,109, 40,108,105,110,101, 44, 39, 42, 39, 41, 10,101,110,
+    100, 10,108,105,110,101, 32, 61, 32, 99,111,110, 99, 97,116,
+    112, 97,114, 97,109, 40,108,105,110,101, 44, 39, 41, 32, 39,
+     41, 10,105,102, 32,105,115,101,110,117,109, 40,116,121,112,
+    101, 41, 32,116,104,101,110, 10,108,105,110,101, 32, 61, 32,
+     99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108,105,110,
+    101, 44, 39, 40,105,110,116, 41, 32, 39, 41, 10,101,110,100,
+     10,108,111, 99, 97,108, 32,100,101,102, 32, 61, 32, 48, 10,
+    105,102, 32,115,101,108,102, 46,100,101,102, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,100,101,102, 32, 61, 32,115,
+    101,108,102, 46,100,101,102, 10,105,102, 32, 40,112,116,114,
+     32, 61, 61, 32, 39, 39, 32,111,114, 32,115,101,108,102, 46,
+    112,116,114, 32, 61, 61, 32, 39, 38, 39, 41, 32, 97,110,100,
+     32,110,111,116, 32,116, 32,116,104,101,110, 10,100,101,102,
+     32, 61, 32, 34, 40,118,111,105,100, 42, 41, 38, 40, 99,111,
+    110,115,116, 32, 34, 46, 46,116,121,112,101, 46, 46, 34, 41,
+     34, 46, 46,100,101,102, 10,101,110,100, 10,101,110,100, 10,
+    105,102, 32,116, 32,116,104,101,110, 10,108,105,110,101, 32,
+     61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108,
+    105,110,101, 44, 39,116,111,108,117, 97, 95,116,111, 39, 46,
+     46,116, 44, 39, 40,116,111,108,117, 97, 95, 83, 44, 39, 44,
+    110, 97,114,103, 44, 39, 44, 39, 44,100,101,102, 44, 39, 41,
+     41, 59, 39, 41, 10,101,108,115,101, 10,108,105,110,101, 32,
+     61, 32, 99,111,110, 99, 97,116,112, 97,114, 97,109, 40,108,
+    105,110,101, 44, 39,116,111,108,117, 97, 95,116,111,117,115,
+    101,114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44,
+     39, 44,110, 97,114,103, 44, 39, 44, 39, 44,100,101,102, 44,
+     39, 41, 41, 59, 39, 41, 10,101,110,100, 10,101,110,100, 10,
+    101,110,100, 10,114,101,116,117,114,110, 32,108,105,110,101,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     58,100,101, 99,108, 97,114,101, 32, 40,110, 97,114,103, 41,
+     10,105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61,
+     32, 39, 39, 32, 97,110,100, 32,116,111,110,117,109, 98,101,
+    114, 40,115,101,108,102, 46,100,105,109, 41, 61, 61,110,105,
+    108, 32,116,104,101,110, 10,111,117,116,112,117,116, 40, 39,
+     35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,115,112,
+    108,117,115, 92,110, 39, 41, 10,111,117,116,112,117,116, 40,
+    115,101,108,102, 58, 98,117,105,108,100,100,101, 99,108, 97,
+    114, 97,116,105,111,110, 40,110, 97,114,103, 44,116,114,117,
+    101, 41, 41, 10,111,117,116,112,117,116, 40, 39, 35,101,108,
+    115,101, 92,110, 39, 41, 10,111,117,116,112,117,116, 40,115,
+    101,108,102, 58, 98,117,105,108,100,100,101, 99,108, 97,114,
+     97,116,105,111,110, 40,110, 97,114,103, 44,102, 97,108,115,
+    101, 41, 41, 10,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10,101,108,115,101, 10,111,117,
+    116,112,117,116, 40,115,101,108,102, 58, 98,117,105,108,100,
+    100,101, 99,108, 97,114, 97,116,105,111,110, 40,110, 97,114,
+    103, 44,102, 97,108,115,101, 41, 41, 10,101,110,100, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 68,101, 99,108, 97,114, 97,116,105,111,110, 58,103,
+    101,116, 97,114,114, 97,121, 32, 40,110, 97,114,103, 41, 10,
+    105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,108,111, 99, 97,108, 32,116,
+    121,112,101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102,
+     46,116,121,112,101, 44, 39, 99,111,110,115,116, 32, 39, 44,
+     39, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,123, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,
+    101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83,
+     69, 92,110, 39, 41, 10,108,111, 99, 97,108, 32,100,101,102,
+     59, 32,105,102, 32,115,101,108,102, 46,100,101,102,126, 61,
+     39, 39, 32,116,104,101,110, 32,100,101,102, 61, 49, 32,101,
+    108,115,101, 32,100,101,102, 61, 48, 32,101,110,100, 10,108,
+    111, 99, 97,108, 32,116, 32, 61, 32,105,115, 98, 97,115,105,
+     99, 40,116,121,112,101, 41, 10,105,102, 32, 40,116, 41, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 32,105,
+    102, 32, 40, 33,116,111,108,117, 97, 95,105,115, 39, 46, 46,
+    116, 46, 46, 39, 97,114,114, 97,121, 40,116,111,108,117, 97,
+     95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44, 39, 44,115,
+    101,108,102, 46,100,105,109, 44, 39, 44, 39, 44,100,101,102,
+     44, 39, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 41,
+     39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116, 40,
+     39, 32,105,102, 32, 40, 33,116,111,108,117, 97, 95,105,115,
+    117,115,101,114,116,121,112,101, 97,114,114, 97,121, 40,116,
+    111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103, 44, 39,
+     44, 34, 39, 44,116,121,112,101, 44, 39, 34, 44, 39, 44,115,
+    101,108,102, 46,100,105,109, 44, 39, 44, 39, 44,100,101,102,
+     44, 39, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 41,
+     39, 41, 10,101,110,100, 10,111,117,116,112,117,116, 40, 39,
+     32,103,111,116,111, 32,116,111,108,117, 97, 95,108,101,114,
+    114,111,114, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     32,101,108,115,101, 92,110, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32,105,110,116, 32,105, 59, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 32,102,111,114, 40,105, 61,
+     48, 59, 32,105, 60, 39, 46, 46,115,101,108,102, 46,100,105,
+    109, 46, 46, 39, 59,105, 43, 43, 41, 39, 41, 10,108,111, 99,
+     97,108, 32,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,
+    116,121,112,101, 41, 10,108,111, 99, 97,108, 32,112,116,114,
+     32, 61, 32, 39, 39, 10,105,102, 32,115,101,108,102, 46,112,
+    116,114,126, 61, 39, 39, 32,116,104,101,110, 32,112,116,114,
+     32, 61, 32, 39, 42, 39, 32,101,110,100, 10,111,117,116,112,
+    117,116, 40, 39, 32, 39, 44,115,101,108,102, 46,110, 97,109,
+    101, 46, 46, 39, 91,105, 93, 32, 61, 32, 39, 41, 10,105,102,
+     32,110,111,116, 32,116, 32, 97,110,100, 32,112,116,114, 61,
+     61, 39, 39, 32,116,104,101,110, 32,111,117,116,112,117,116,
+     40, 39, 42, 39, 41, 32,101,110,100, 10,111,117,116,112,117,
+    116, 40, 39, 40, 40, 39, 44,116,121,112,101, 41, 10,105,102,
+     32,110,111,116, 32,116, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39, 42, 39, 41, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 41, 32, 39, 41, 10,108,111, 99, 97,
+    108, 32,100,101,102, 32, 61, 32, 48, 10,105,102, 32,115,101,
+    108,102, 46,100,101,102, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 32,100,101,102, 32, 61, 32,115,101,108,102, 46,100,
+    101,102, 32,101,110,100, 10,105,102, 32,116, 32,116,104,101,
+    110, 10,111,117,116,112,117,116, 40, 39,116,111,108,117, 97,
+     95,116,111,102,105,101,108,100, 39, 46, 46,116, 46, 46, 39,
+     40,116,111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103,
+     44, 39, 44,105, 43, 49, 44, 39, 44,100,101,102, 44, 39, 41,
+     41, 59, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,
+    116, 40, 39,116,111,108,117, 97, 95,116,111,102,105,101,108,
+    100,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,105, 43, 49,
+     44, 39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10,101,
+    110,100, 10,111,117,116,112,117,116, 40, 39, 32,125, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 32,125, 39, 41, 10,101,
+    110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,
+    111,110, 58,115,101,116, 97,114,114, 97,121, 32, 40,110, 97,
+    114,103, 41, 10,105,102, 32,110,111,116, 32,115,116,114,102,
+    105,110,100, 40,115,101,108,102, 46,116,121,112,101, 44, 39,
+     99,111,110,115,116, 37,115, 43, 39, 41, 32, 97,110,100, 32,
+    115,101,108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32,
+    116,104,101,110, 10,108,111, 99, 97,108, 32,116,121,112,101,
+     32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46,116,121,
+    112,101, 44, 39, 99,111,110,115,116, 32, 39, 44, 39, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,105,110,116, 32,105, 59, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 32,102,111,114, 40,
+    105, 61, 48, 59, 32,105, 60, 39, 46, 46,115,101,108,102, 46,
+    100,105,109, 46, 46, 39, 59,105, 43, 43, 41, 39, 41, 10,108,
+    111, 99, 97,108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98,
+     97,115,105, 99, 40,116,121,112,101, 41, 10,105,102, 32,116,
+     32,116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 32,
+    116,111,108,117, 97, 95,112,117,115,104,102,105,101,108,100,
+     39, 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83,
+     44, 39, 44,110, 97,114,103, 44, 39, 44,105, 43, 49, 44, 40,
+     39, 44, 99,116, 44, 39, 41, 39, 44,115,101,108,102, 46,110,
+     97,109,101, 44, 39, 91,105, 93, 41, 59, 39, 41, 10,101,108,
+    115,101, 10,105,102, 32,115,101,108,102, 46,112,116,114, 32,
+     61, 61, 32, 39, 39, 32,116,104,101,110, 10,111,117,116,112,
+    117,116, 40, 39, 32,123, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 35,105,102,100,101,102, 32, 95, 95, 99,112,108,117,
+    115,112,108,117,115, 92,110, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39, 32,118,111,105,100, 42, 32,116,111,108,117, 97,
+     95,111, 98,106, 32, 61, 32,110,101,119, 39, 44,116,121,112,
+    101, 44, 39, 40, 39, 44,115,101,108,102, 46,110, 97,109,101,
+     44, 39, 91,105, 93, 41, 59, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,104,102,
+    105,101,108,100,117,115,101,114,116,121,112,101, 95, 97,110,
+    100, 95,116, 97,107,101,111,119,110,101,114,115,104,105,112,
+     40,116,111,108,117, 97, 95, 83, 44, 39, 44,110, 97,114,103,
+     44, 39, 44,105, 43, 49, 44,116,111,108,117, 97, 95,111, 98,
+    106, 44, 34, 39, 44,116,121,112,101, 44, 39, 34, 41, 59, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 35,101,108,115,101,
+     92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,118,
+    111,105,100, 42, 32,116,111,108,117, 97, 95,111, 98,106, 32,
+     61, 32,116,111,108,117, 97, 95, 99,111,112,121, 40,116,111,
+    108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, 38, 39,
+     44,115,101,108,102, 46,110, 97,109,101, 44, 39, 91,105, 93,
+     44,115,105,122,101,111,102, 40, 39, 44,116,121,112,101, 44,
+     39, 41, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     32,116,111,108,117, 97, 95,112,117,115,104,102,105,101,108,
+    100,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 39, 44,110, 97,114,103, 44, 39, 44,105, 43, 49,
+     44,116,111,108,117, 97, 95,111, 98,106, 44, 34, 39, 44,116,
+    121,112,101, 44, 39, 34, 41, 59, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 32,125, 39, 41, 10,101,108,
+    115,101, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95,112,117,115,104,102,105,101,108,100,117,115,101,
+    114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 39,
+     44,110, 97,114,103, 44, 39, 44,105, 43, 49, 44, 40,118,111,
+    105,100, 42, 41, 39, 44,115,101,108,102, 46,110, 97,109,101,
+     44, 39, 91,105, 93, 44, 34, 39, 44,116,121,112,101, 44, 39,
+     34, 41, 59, 39, 41, 10,101,110,100, 10,101,110,100, 10,111,
+    117,116,112,117,116, 40, 39, 32,125, 39, 41, 10,101,110,100,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     58,102,114,101,101, 97,114,114, 97,121, 32, 40, 41, 10,105,
+    102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32, 39,
+     39, 32, 97,110,100, 32,116,111,110,117,109, 98,101,114, 40,
+    115,101,108,102, 46,100,105,109, 41, 61, 61,110,105,108, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 35,105,
+    102,100,101,102, 32, 95, 95, 99,112,108,117,115,112,108,117,
+    115, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+    100,101,108,101,116,101, 32, 91, 93, 39, 44,115,101,108,102,
+     46,110, 97,109,101, 44, 39, 59, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 35,101,108,115,101, 92,110, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,102,114,101,101, 40, 39, 44,
+    115,101,108,102, 46,110, 97,109,101, 44, 39, 41, 59, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102,
+     92,110, 39, 41, 10,101,110,100, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 68,101, 99,
+    108, 97,114, 97,116,105,111,110, 58,112, 97,115,115,112, 97,
+    114, 32, 40, 41, 10,105,102, 32,115,101,108,102, 46,112,116,
+    114, 61, 61, 39, 38, 39, 32, 97,110,100, 32,110,111,116, 32,
+    105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,
+    112,101, 41, 32,116,104,101,110, 10,111,117,116,112,117,116,
+     40, 39, 42, 39, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     41, 10,101,108,115,101,105,102, 32,115,101,108,102, 46,114,
+    101,116, 61, 61, 39, 42, 39, 32,116,104,101,110, 10,111,117,
+    116,112,117,116, 40, 39, 38, 39, 46, 46,115,101,108,102, 46,
+    110, 97,109,101, 41, 10,101,108,115,101, 10,111,117,116,112,
+    117,116, 40,115,101,108,102, 46,110, 97,109,101, 41, 10,101,
+    110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,
+    111,110, 58,114,101,116,118, 97,108,117,101, 32, 40, 41, 10,
+    105,102, 32,115,101,108,102, 46,114,101,116, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,108,111, 99, 97,108, 32,116,
+     44, 99,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,115,
+    101,108,102, 46,116,121,112,101, 41, 10,105,102, 32,116, 32,
+     97,110,100, 32,116,126, 61, 39, 39, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,
+    112,117,115,104, 39, 46, 46,116, 46, 46, 39, 40,116,111,108,
+    117, 97, 95, 83, 44, 40, 39, 44, 99,116, 44, 39, 41, 39, 46,
+     46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 41, 59,
+     39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104,117,115,101,
+    114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,
+    118,111,105,100, 42, 41, 39, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 39, 44, 34, 39, 44,115,101,108,102, 46,
+    116,121,112,101, 44, 39, 34, 41, 59, 39, 41, 10,101,110,100,
+     10,114,101,116,117,114,110, 32, 49, 10,101,110,100, 10,114,
+    101,116,117,114,110, 32, 48, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 95, 68,101, 99,108, 97,114, 97,116,
+    105,111,110, 32, 40,116, 41, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 68,101,
+     99,108, 97,114, 97,116,105,111,110, 41, 10,116, 58, 98,117,
+    105,108,100,110, 97,109,101,115, 40, 41, 10,116, 58, 99,104,
+    101, 99,107,110, 97,109,101, 40, 41, 10,116, 58, 99,104,101,
+     99,107,116,121,112,101, 40, 41, 10,108,111, 99, 97,108, 32,
+    102,116, 32, 61, 32,102,105,110,100,116,121,112,101, 40,116,
+     46,116,121,112,101, 41, 32,111,114, 32,116, 46,116,121,112,
+    101, 10,105,102, 32,110,111,116, 32,105,115,101,110,117,109,
+     40,102,116, 41, 32,116,104,101,110, 10,116, 46,109,111,100,
+     44, 32,116, 46,116,121,112,101, 32, 61, 32, 97,112,112,108,
+    121,116,121,112,101,100,101,102, 40,116, 46,109,111,100, 44,
+     32,102,116, 41, 10,101,110,100, 10,105,102, 32,116, 46,107,
+    105,110,100, 61, 61, 34,118, 97,114, 34, 32, 97,110,100, 32,
+     40,115,116,114,105,110,103, 46,102,105,110,100, 40,116, 46,
+    109,111,100, 44, 32, 34,116,111,108,117, 97, 95,112,114,111,
+    112,101,114,116,121, 37,115, 34, 41, 32,111,114, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,116, 46,109,111,100,
+     44, 32, 34,116,111,108,117, 97, 95,112,114,111,112,101,114,
+    116,121, 36, 34, 41, 41, 32,116,104,101,110, 10,116, 46,109,
+    111,100, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,116, 46,109,111,100, 44, 32, 34,116,111,108,117, 97,
+     95,112,114,111,112,101,114,116,121, 34, 44, 32, 34,116,111,
+    108,117, 97, 95,112,114,111,112,101,114,116,121, 95, 95, 34,
+     46, 46,103,101,116, 95,112,114,111,112,101,114,116,121, 95,
+    116,121,112,101, 40, 41, 41, 10,101,110,100, 10,114,101,116,
+    117,114,110, 32,116, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     32, 40,115, 44,107,105,110,100, 44,105,115, 95,112, 97,114,
+     97,109,101,116,101,114, 41, 10,115, 32, 61, 32,103,115,117,
+     98, 40,115, 44, 34, 37,115, 42, 61, 37,115, 42, 34, 44, 34,
+     61, 34, 41, 10,115, 32, 61, 32,103,115,117, 98, 40,115, 44,
+     32, 34, 37,115, 42, 60, 34, 44, 32, 34, 60, 34, 41, 10,108,
+    111, 99, 97,108, 32,100,101,102, 98, 44,116,109,112,100,101,
+    102, 10,100,101,102, 98, 44, 95, 44,116,109,112,100,101,102,
+     32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    115, 44, 32, 34, 40, 61, 46, 42, 41, 36, 34, 41, 10,105,102,
+     32,100,101,102, 98, 32,116,104,101,110, 10,115, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44, 32,
+     34, 61, 46, 42, 36, 34, 44, 32, 34, 34, 41, 10,101,108,115,
+    101, 10,116,109,112,100,101,102, 32, 61, 32, 39, 39, 10,101,
+    110,100, 10,105,102, 32,107,105,110,100, 32, 61, 61, 32, 34,
+    118, 97,114, 34, 32,116,104,101,110, 10,105,102, 32,115, 32,
+     61, 61, 32, 39, 39, 32,111,114, 32,115, 32, 61, 61, 32, 39,
+    118,111,105,100, 39, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,
+    123,116,121,112,101, 32, 61, 32, 39,118,111,105,100, 39, 44,
+     32,107,105,110,100, 32, 61, 32,107,105,110,100, 44, 32,105,
+    115, 95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,
+    115, 95,112, 97,114, 97,109,101,116,101,114,125, 10,101,110,
+    100, 10,101,110,100, 10,108,111, 99, 97,108, 32,116, 32, 61,
+     32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115,
+     40,115, 44, 39, 37, 42, 37,115, 42, 38, 39, 41, 10,105,102,
+     32,116, 46,110, 32, 61, 61, 32, 50, 32,116,104,101,110, 10,
+    105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,102,117,110,
+     99, 39, 32,116,104,101,110, 10,101,114,114,111,114, 40, 34,
+     35,105,110,118, 97,108,105,100, 32,102,117,110, 99,116,105,
+    111,110, 32,114,101,116,117,114,110, 32,116,121,112,101, 58,
+     32, 34, 46, 46,115, 41, 10,101,110,100, 10,108,111, 99, 97,
+    108, 32,109, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,
+    111,107,101,110,115, 40,116, 91, 49, 93, 44, 39, 37,115, 43,
+     39, 41, 10,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10,110, 97,109,101, 32, 61,
+     32,116, 91, 50, 93, 46, 46,116,109,112,100,101,102, 44, 10,
+    112,116,114, 32, 61, 32, 39, 42, 39, 44, 10,114,101,116, 32,
+     61, 32, 39, 38, 39, 44, 10,116,121,112,101, 32, 61, 32,109,
+     91,109, 46,110, 93, 44, 10,109,111,100, 32, 61, 32, 99,111,
+    110, 99, 97,116, 40,109, 44, 49, 44,109, 46,110, 45, 49, 41,
+     44, 10,105,115, 95,112, 97,114, 97,109,101,116,101,114, 32,
+     61, 32,105,115, 95,112, 97,114, 97,109,101,116,101,114, 44,
+     10,107,105,110,100, 32, 61, 32,107,105,110,100, 10,125, 10,
+    101,110,100, 10,116, 32, 61, 32,115,112,108,105,116, 95, 99,
+     95,116,111,107,101,110,115, 40,115, 44, 39, 37, 42, 37,115,
+     42, 37, 42, 39, 41, 10,105,102, 32,116, 46,110, 32, 61, 61,
+     32, 50, 32,116,104,101,110, 10,105,102, 32,107,105,110,100,
+     32, 61, 61, 32, 39,102,117,110, 99, 39, 32,116,104,101,110,
+     10,101,114,114,111,114, 40, 34, 35,105,110,118, 97,108,105,
+    100, 32,102,117,110, 99,116,105,111,110, 32,114,101,116,117,
+    114,110, 32,116,121,112,101, 58, 32, 34, 46, 46,115, 41, 10,
+    101,110,100, 10,108,111, 99, 97,108, 32,109, 32, 61, 32,115,
+    112,108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,116,
+     91, 49, 93, 44, 39, 37,115, 43, 39, 41, 10,114,101,116,117,
+    114,110, 32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,
+    123, 10,110, 97,109,101, 32, 61, 32,116, 91, 50, 93, 46, 46,
+    116,109,112,100,101,102, 44, 10,112,116,114, 32, 61, 32, 39,
+     42, 39, 44, 10,114,101,116, 32, 61, 32, 39, 42, 39, 44, 10,
+    116,121,112,101, 32, 61, 32,109, 91,109, 46,110, 93, 44, 10,
+    109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,109, 44,
+     49, 44,109, 46,110, 45, 49, 41, 44, 10,105,115, 95,112, 97,
+    114, 97,109,101,116,101,114, 32, 61, 32,105,115, 95,112, 97,
+    114, 97,109,101,116,101,114, 44, 10,107,105,110,100, 32, 61,
+     32,107,105,110,100, 10,125, 10,101,110,100, 10,116, 32, 61,
+     32,115,112,108,105,116, 95, 99, 95,116,111,107,101,110,115,
+     40,115, 44, 39, 38, 39, 41, 10,105,102, 32,116, 46,110, 32,
+     61, 61, 32, 50, 32,116,104,101,110, 10,108,111, 99, 97,108,
+     32,109, 32, 61, 32,115,112,108,105,116, 95, 99, 95,116,111,
+    107,101,110,115, 40,116, 91, 49, 93, 44, 39, 37,115, 43, 39,
+     41, 10,114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,
+    114, 97,116,105,111,110,123, 10,110, 97,109,101, 32, 61, 32,
+    116, 91, 50, 93, 46, 46,116,109,112,100,101,102, 44, 10,112,
+    116,114, 32, 61, 32, 39, 38, 39, 44, 10,116,121,112,101, 32,
+     61, 32,109, 91,109, 46,110, 93, 44, 10,109,111,100, 32, 61,
+     32, 99,111,110, 99, 97,116, 40,109, 44, 49, 44,109, 46,110,
+     45, 49, 41, 44, 10,105,115, 95,112, 97,114, 97,109,101,116,
+    101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101,116,
+    101,114, 44, 10,107,105,110,100, 32, 61, 32,107,105,110,100,
+     10,125, 10,101,110,100, 10,108,111, 99, 97,108, 32,115, 49,
+     32, 61, 32,103,115,117, 98, 40,115, 44, 34, 40, 37, 98, 92,
+     91, 92, 93, 41, 34, 44,102,117,110, 99,116,105,111,110, 32,
+     40,110, 41, 32,114,101,116,117,114,110, 32,103,115,117, 98,
+     40,110, 44, 39, 37, 42, 39, 44, 39, 92, 49, 39, 41, 32,101,
+    110,100, 41, 10,116, 32, 61, 32,115,112,108,105,116, 95, 99,
+     95,116,111,107,101,110,115, 40,115, 49, 44, 39, 37, 42, 39,
+     41, 10,105,102, 32,116, 46,110, 32, 61, 61, 32, 50, 32,116,
+    104,101,110, 10,116, 91, 50, 93, 32, 61, 32,103,115,117, 98,
+     40,116, 91, 50, 93, 44, 39, 92, 49, 39, 44, 39, 37, 42, 39,
+     41, 10,108,111, 99, 97,108, 32,109, 32, 61, 32,115,112,108,
+    105,116, 95, 99, 95,116,111,107,101,110,115, 40,116, 91, 49,
+     93, 44, 39, 37,115, 43, 39, 41, 10,114,101,116,117,114,110,
+     32, 95, 68,101, 99,108, 97,114, 97,116,105,111,110,123, 10,
+    110, 97,109,101, 32, 61, 32,116, 91, 50, 93, 46, 46,116,109,
+    112,100,101,102, 44, 10,112,116,114, 32, 61, 32, 39, 42, 39,
+     44, 10,116,121,112,101, 32, 61, 32,109, 91,109, 46,110, 93,
+     44, 10,109,111,100, 32, 61, 32, 99,111,110, 99, 97,116, 40,
+    109, 44, 49, 44,109, 46,110, 45, 49, 41, 32, 44, 10,105,115,
+     95,112, 97,114, 97,109,101,116,101,114, 32, 61, 32,105,115,
+     95,112, 97,114, 97,109,101,116,101,114, 44, 10,107,105,110,
+    100, 32, 61, 32,107,105,110,100, 10,125, 10,101,110,100, 10,
+    105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,118, 97,114,
+     39, 32,116,104,101,110, 10,116, 32, 61, 32,115,112,108,105,
+    116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44, 39, 37,
+    115, 43, 39, 41, 10,108,111, 99, 97,108, 32,118, 10,105,102,
+     32,102,105,110,100,116,121,112,101, 40,116, 91,116, 46,110,
+     93, 41, 32,116,104,101,110, 32,118, 32, 61, 32, 99,114,101,
+     97,116,101, 95,118, 97,114,110, 97,109,101, 40, 41, 32,101,
+    108,115,101, 32,118, 32, 61, 32,116, 91,116, 46,110, 93, 59,
+     32,116, 46,110, 32, 61, 32,116, 46,110, 45, 49, 32,101,110,
+    100, 10,114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,
+    114, 97,116,105,111,110,123, 10,110, 97,109,101, 32, 61, 32,
+    118, 46, 46,116,109,112,100,101,102, 44, 10,116,121,112,101,
+     32, 61, 32,116, 91,116, 46,110, 93, 44, 10,109,111,100, 32,
+     61, 32, 99,111,110, 99, 97,116, 40,116, 44, 49, 44,116, 46,
+    110, 45, 49, 41, 44, 10,105,115, 95,112, 97,114, 97,109,101,
+    116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,109,101,
+    116,101,114, 44, 10,107,105,110,100, 32, 61, 32,107,105,110,
+    100, 10,125, 10,101,108,115,101, 10,116, 32, 61, 32,115,112,
+    108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44,
+     39, 37,115, 43, 39, 41, 10,108,111, 99, 97,108, 32,118, 32,
+     61, 32,116, 91,116, 46,110, 93, 10,108,111, 99, 97,108, 32,
+    116,112, 44,109,100, 10,105,102, 32,116, 46,110, 62, 49, 32,
+    116,104,101,110, 10,116,112, 32, 61, 32,116, 91,116, 46,110,
+     45, 49, 93, 10,109,100, 32, 61, 32, 99,111,110, 99, 97,116,
+     40,116, 44, 49, 44,116, 46,110, 45, 50, 41, 10,101,110,100,
+     10,114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,114,
+     97,116,105,111,110,123, 10,110, 97,109,101, 32, 61, 32,118,
+     44, 10,116,121,112,101, 32, 61, 32,116,112, 44, 10,109,111,
+    100, 32, 61, 32,109,100, 44, 10,105,115, 95,112, 97,114, 97,
+    109,101,116,101,114, 32, 61, 32,105,115, 95,112, 97,114, 97,
+    109,101,116,101,114, 44, 10,107,105,110,100, 32, 61, 32,107,
+    105,110,100, 10,125, 10,101,110,100, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/declaration.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 32,
+     61, 32,123, 10, 95,103,101,116, 32, 61, 32,123,125, 44, 10,
+     95,115,101,116, 32, 61, 32,123,125, 44, 10,125, 10, 99,108,
+     97,115,115, 86, 97,114,105, 97, 98,108,101, 46, 95, 95,105,
+    110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 86, 97,114,
+    105, 97, 98,108,101, 10,115,101,116,109,101,116, 97,116, 97,
+     98,108,101, 40, 99,108, 97,115,115, 86, 97,114,105, 97, 98,
+    108,101, 44, 99,108, 97,115,115, 68,101, 99,108, 97,114, 97,
+    116,105,111,110, 41, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 58,112,
+    114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,111,
+    115,101, 41, 10,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34, 86, 97,114,105, 97, 98,108,101,123, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    109,111,100, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,
+    109,111,100, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32,116,121,112,101,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,116,121,112,
+    101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,112,116,114, 32, 61, 32,
+     39, 34, 46, 46,115,101,108,102, 46,112,116,114, 46, 46, 34,
+     39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,110, 97,109,101, 32, 61, 32, 39, 34, 46,
+     46,115,101,108,102, 46,110, 97,109,101, 46, 46, 34, 39, 44,
+     34, 41, 10,105,102, 32,115,101,108,102, 46,100,105,109, 32,
+    116,104,101,110, 32,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,100,105,109, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,100,105,109, 46, 46, 34, 39, 44, 34, 41,
+     32,101,110,100, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,100,101,102, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,100,101,102, 46, 46, 34, 39, 44, 34, 41,
+     10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,114,101,116, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,114,101,116, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46,
+     99,108,111,115,101, 41, 10,101,110,100, 10,102,117,110, 99,
+    116,105,111,110, 32, 99,108, 97,115,115, 86, 97,114,105, 97,
+     98,108,101, 58, 99,102,117,110, 99,110, 97,109,101, 32, 40,
+    112,114,101,102,105,120, 41, 10,108,111, 99, 97,108, 32,112,
+     97,114,101,110,116, 32, 61, 32, 34, 34, 10,108,111, 99, 97,
+    108, 32,117,110,115,105,103,110,101,100, 32, 61, 32, 34, 34,
+     10,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32, 34, 34,
+     10,108,111, 99, 97,108, 32,112, 32, 61, 32,115,101,108,102,
+     58,105,110,109,111,100,117,108,101, 40, 41, 32,111,114, 32,
+    115,101,108,102, 58,105,110,110, 97,109,101,115,112, 97, 99,
+    101, 40, 41, 32,111,114, 32,115,101,108,102, 58,105,110, 99,
+    108, 97,115,115, 40, 41, 10,105,102, 32,112, 32,116,104,101,
+    110, 10,105,102, 32,115,101,108,102, 46,112, 97,114,101,110,
+    116, 46, 99,108, 97,115,115,116,121,112,101, 32, 61, 61, 32,
+     39, 99,108, 97,115,115, 39, 32,116,104,101,110, 10,112, 97,
+    114,101,110,116, 32, 61, 32, 34, 95, 34, 32, 46, 46, 32,115,
+    101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101,
+     10,101,108,115,101, 10,112, 97,114,101,110,116, 32, 61, 32,
+     34, 95, 34, 32, 46, 46, 32,112, 10,101,110,100, 10,101,110,
+    100, 10,105,102, 32,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46,109,111,100, 44, 34, 40,117,110,115,105,103,110,
+    101,100, 41, 34, 41, 32,116,104,101,110, 10,117,110,115,105,
+    103,110,101,100, 32, 61, 32, 34, 95,117,110,115,105,103,110,
+    101,100, 34, 10,101,110,100, 10,105,102, 32,115,101,108,102,
+     46,112,116,114, 32, 61, 61, 32, 34, 42, 34, 32,116,104,101,
+    110, 32,112,116,114, 32, 61, 32, 34, 95,112,116,114, 34, 10,
+    101,108,115,101,105,102, 32,115,101,108,102, 46,112,116,114,
+     32, 61, 61, 32, 34, 38, 34, 32,116,104,101,110, 32,112,116,
+    114, 32, 61, 32, 34, 95,114,101,102, 34, 10,101,110,100, 10,
+    108,111, 99, 97,108, 32,110, 97,109,101, 32, 61, 32,112,114,
+    101,102,105,120, 32, 46, 46, 32,112, 97,114,101,110,116, 32,
+     46, 46, 32,117,110,115,105,103,110,101,100, 32, 46, 46, 32,
+     34, 95, 34, 32, 46, 46, 32,103,115,117, 98, 40,115,101,108,
+    102, 46,108,110, 97,109,101, 32,111,114, 32,115,101,108,102,
+     46,110, 97,109,101, 44, 34, 46, 42, 58, 58, 34, 44, 34, 34,
+     41, 32, 46, 46, 32,112,116,114, 10,110, 97,109,101, 32, 61,
+     32, 99,108,101, 97,110, 95,116,101,109,112,108, 97,116,101,
+     40,110, 97,109,101, 41, 10,114,101,116,117,114,110, 32,110,
+     97,109,101, 10,101,110,100, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101,
+     58,105,115,118, 97,114,105, 97, 98,108,101, 32, 40, 41, 10,
+    114,101,116,117,114,110, 32,116,114,117,101, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115,
+     86, 97,114,105, 97, 98,108,101, 58,103,101,116,118, 97,108,
+    117,101, 32, 40, 99,108, 97,115,115, 44,115,116, 97,116,105,
+     99, 44, 32,112,114,111,112, 95,103,101,116, 41, 10,108,111,
+     99, 97,108, 32,110, 97,109,101, 10,105,102, 32,112,114,111,
+    112, 95,103,101,116, 32,116,104,101,110, 10,110, 97,109,101,
+     32, 61, 32,112,114,111,112, 95,103,101,116, 46, 46, 34, 40,
+     41, 34, 10,101,108,115,101, 10,110, 97,109,101, 32, 61, 32,
+    115,101,108,102, 46,110, 97,109,101, 10,101,110,100, 10,105,
+    102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,
+    116,105, 99, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     32,115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,
+    112,101, 46, 46, 39, 58, 58, 39, 46, 46,110, 97,109,101, 10,
+    101,108,115,101,105,102, 32, 99,108, 97,115,115, 32,116,104,
+    101,110, 10,114,101,116,117,114,110, 32, 39,115,101,108,102,
+     45, 62, 39, 46, 46,110, 97,109,101, 10,101,108,115,101, 10,
+    114,101,116,117,114,110, 32,110, 97,109,101, 10,101,110,100,
+     10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 58,103,101,
+    116,112,111,105,110,116,101,114,118, 97,108,117,101, 32, 40,
+     99,108, 97,115,115, 44,115,116, 97,116,105, 99, 41, 10,105,
+    102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,
+    116,105, 99, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     32, 99,108, 97,115,115, 46, 46, 39, 58, 58,112, 39, 10,101,
+    108,115,101,105,102, 32, 99,108, 97,115,115, 32,116,104,101,
+    110, 10,114,101,116,117,114,110, 32, 39,115,101,108,102, 45,
+     62,112, 39, 10,101,108,115,101, 10,114,101,116,117,114,110,
+     32, 39,112, 39, 10,101,110,100, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 99,108, 97,115,115, 86, 97,114,
+    105, 97, 98,108,101, 58,115,117,112, 99,111,100,101, 32, 40,
+     41, 10,108,111, 99, 97,108, 32, 99,108, 97,115,115, 32, 61,
+     32,115,101,108,102, 58,105,110, 99,108, 97,115,115, 40, 41,
+     10,108,111, 99, 97,108, 32,112,114,111,112, 95,103,101,116,
+     44,112,114,111,112, 95,115,101,116, 10,105,102, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,115,101,108,102, 46,
+    109,111,100, 44, 32, 39,116,111,108,117, 97, 95,112,114,111,
+    112,101,114,116,121, 39, 41, 32,116,104,101,110, 10, 95, 44,
+     95, 44,116,121,112,101, 32, 61, 32,115,116,114,105,110,103,
+     46,102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44,
+     32, 34,116,111,108,117, 97, 95,112,114,111,112,101,114,116,
+    121, 95, 95, 40, 91, 94, 37,115, 93, 42, 41, 34, 41, 10,116,
+    121,112,101, 32, 61, 32,116,121,112,101, 32,111,114, 32, 34,
+    100,101,102, 97,117,108,116, 34, 10,112,114,111,112, 95,103,
+    101,116, 44,112,114,111,112, 95,115,101,116, 32, 61, 32,103,
+    101,116, 95,112,114,111,112,101,114,116,121, 95,109,101,116,
+    104,111,100,115, 40,116,121,112,101, 44, 32,115,101,108,102,
+     46,110, 97,109,101, 41, 10,115,101,108,102, 46,109,111,100,
+     32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,
+    115,101,108,102, 46,109,111,100, 44, 32, 34,116,111,108,117,
+     97, 95,112,114,111,112,101,114,116,121, 91, 94, 37,115, 93,
+     42, 34, 44, 32, 34, 34, 41, 10,101,110,100, 10,105,102, 32,
+     99,108, 97,115,115, 32,116,104,101,110, 10,111,117,116,112,
+    117,116, 40, 34, 47, 42, 32,103,101,116, 32,102,117,110, 99,
+    116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, 97,109,
+    101, 44, 34, 32,111,102, 32, 99,108, 97,115,115, 32, 34, 44,
+     99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41, 10,101,108,
+    115,101, 10,111,117,116,112,117,116, 40, 34, 47, 42, 32,103,
+    101,116, 32,102,117,110, 99,116,105,111,110, 58, 34, 44,115,
+    101,108,102, 46,110, 97,109,101, 44, 34, 32, 42, 47, 34, 41,
+     10,101,110,100, 10,115,101,108,102, 46, 99,103,101,116,110,
+     97,109,101, 32, 61, 32,115,101,108,102, 58, 99,102,117,110,
+     99,110, 97,109,101, 40, 34,116,111,108,117, 97, 95,103,101,
+    116, 34, 41, 10,111,117,116,112,117,116, 40, 34, 35,105,102,
+    110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65,
+     66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, 99,103,101,
+    116,110, 97,109,101, 41, 10,111,117,116,112,117,116, 40, 34,
+     92,110,115,116, 97,116,105, 99, 32,105,110,116, 34, 44,115,
+    101,108,102, 46, 99,103,101,116,110, 97,109,101, 44, 34, 40,
+    108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117,
+     97, 95, 83, 41, 34, 41, 10,111,117,116,112,117,116, 40, 34,
+    123, 34, 41, 10,108,111, 99, 97,108, 32, 95, 44, 95, 44,115,
+    116, 97,116,105, 99, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115,101,108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,
+     40,115,116, 97,116,105, 99, 41, 39, 41, 10,105,102, 32, 99,
+    108, 97,115,115, 32, 97,110,100, 32,115,116, 97,116,105, 99,
+     61, 61,110,105,108, 32,116,104,101,110, 10,111,117,116,112,
+    117,116, 40, 39, 32, 39, 44,115,101,108,102, 46,112, 97,114,
+    101,110,116, 46,116,121,112,101, 44, 39, 42, 39, 44, 39,115,
+    101,108,102, 32, 61, 32, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 40, 39, 44,115,101,108,102, 46,112, 97,114,101,110,
+    116, 46,116,121,112,101, 44, 39, 42, 41, 32, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39,116,111,108,117, 97, 95,116,111,
+    117,115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95,
+     83, 44, 49, 44, 48, 41, 59, 39, 41, 10,101,108,115,101,105,
+    102, 32,115,116, 97,116,105, 99, 32,116,104,101,110, 10, 95,
+     44, 95, 44,115,101,108,102, 46,109,111,100, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115,101,108,102, 46,109,111,100,
+     44, 39, 94, 37,115, 42,115,116, 97,116,105, 99, 37,115, 37,
+    115, 42, 40, 46, 42, 41, 39, 41, 10,101,110,100, 10,105,102,
+     32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,116,
+    105, 99, 61, 61,110,105,108, 32,116,104,101,110, 10,111,117,
+    116,112,117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84,
+     79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 32,105,102, 32, 40,
+     33,115,101,108,102, 41, 32,116,111,108,117, 97, 95,101,114,
+    114,111,114, 40,116,111,108,117, 97, 95, 83, 44, 34,105,110,
+    118, 97,108,105,100, 32, 92, 39,115,101,108,102, 92, 39, 32,
+    105,110, 32, 97, 99, 99,101,115,115,105,110,103, 32,118, 97,
+    114,105, 97, 98,108,101, 32, 92, 39, 39, 46, 46,115,101,108,
+    102, 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44, 78, 85,
+     76, 76, 41, 59, 39, 41, 59, 10,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10,101,110,100,
+     10,105,102, 32,115,116,114,105,110,103, 46,102,105,110,100,
+     40,115,101,108,102, 46,109,111,100, 44, 32, 39,116,111,108,
+    117, 97, 95,105,110,104,101,114,105,116,115, 39, 41, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 39, 35,105,102,
+    100,101,102, 32, 95, 95, 99,112,108,117,115,112,108,117,115,
+     92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,
+    100, 42, 41,115,116, 97,116,105, 99, 95, 99, 97,115,116, 60,
+     39, 46, 46,115,101,108,102, 46,116,121,112,101, 46, 46, 39,
+     42, 62, 40,115,101,108,102, 41, 44, 32, 34, 39, 44,115,101,
+    108,102, 46,116,121,112,101, 44, 39, 34, 41, 59, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 35,101,108,115,101, 92,110,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,101,
+     40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,100, 42,
+     41, 40, 40, 39, 46, 46,115,101,108,102, 46,116,121,112,101,
+     46, 46, 39, 42, 41,115,101,108,102, 41, 44, 32, 34, 39, 44,
+    115,101,108,102, 46,116,121,112,101, 44, 39, 34, 41, 59, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,
+    102, 92,110, 39, 41, 10,101,108,115,101, 10,108,111, 99, 97,
+    108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115,105,
+     99, 40,115,101,108,102, 46,116,121,112,101, 41, 10,105,102,
+     32,116, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104, 39, 46, 46,
+    116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39,
+     44, 99,116, 44, 39, 41, 39, 46, 46,115,101,108,102, 58,103,
+    101,116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,
+    116, 97,116,105, 99, 44,112,114,111,112, 95,103,101,116, 41,
+     46, 46, 39, 41, 59, 39, 41, 10,101,108,115,101, 10,116, 32,
+     61, 32,115,101,108,102, 46,116,121,112,101, 10,105,102, 32,
+    115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 38, 39,
+     32,111,114, 32,115,101,108,102, 46,112,116,114, 32, 61, 61,
+     32, 39, 39, 32,116,104,101,110, 10,111,117,116,112,117,116,
+     40, 39, 32,116,111,108,117, 97, 95,112,117,115,104,117,115,
+    101,114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44,
+     40,118,111,105,100, 42, 41, 38, 39, 46, 46,115,101,108,102,
+     58,103,101,116,118, 97,108,117,101, 40, 99,108, 97,115,115,
+     44,115,116, 97,116,105, 99, 44,112,114,111,112, 95,103,101,
+    116, 41, 46, 46, 39, 44, 34, 39, 44,116, 44, 39, 34, 41, 59,
+     39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104,117,115,101,
+    114,116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,
+    118,111,105,100, 42, 41, 39, 46, 46,115,101,108,102, 58,103,
+    101,116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,
+    116, 97,116,105, 99, 44,112,114,111,112, 95,103,101,116, 41,
+     46, 46, 39, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41,
+     10,101,110,100, 10,101,110,100, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 32,114,101,116,117,114,110, 32, 49,
+     59, 39, 41, 10,111,117,116,112,117,116, 40, 39,125, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102,
+     32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85,
+     65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 92,110, 39, 41, 10,105,102, 32,
+    110,111,116, 32, 40,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46,116,121,112,101, 44, 39, 99,111,110,115,116, 37,
+    115, 43, 39, 41, 32,111,114, 32,115,116,114,105,110,103, 46,
+    102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 32,
+     39,116,111,108,117, 97, 95,114,101, 97,100,111,110,108,121,
+     39, 41, 32,111,114, 32,115,116,114,105,110,103, 46,102,105,
+    110,100, 40,115,101,108,102, 46,109,111,100, 44, 32, 39,116,
+    111,108,117, 97, 95,105,110,104,101,114,105,116,115, 39, 41,
+     41, 32,116,104,101,110, 10,105,102, 32, 99,108, 97,115,115,
+     32,116,104,101,110, 10,111,117,116,112,117,116, 40, 34, 47,
+     42, 32,115,101,116, 32,102,117,110, 99,116,105,111,110, 58,
+     34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34, 32,111,
+    102, 32, 99,108, 97,115,115, 32, 34, 44, 99,108, 97,115,115,
+     44, 34, 32, 42, 47, 34, 41, 10,101,108,115,101, 10,111,117,
+    116,112,117,116, 40, 34, 47, 42, 32,115,101,116, 32,102,117,
+    110, 99,116,105,111,110, 58, 34, 44,115,101,108,102, 46,110,
+     97,109,101, 44, 34, 32, 42, 47, 34, 41, 10,101,110,100, 10,
+    115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 32, 61,
+     32,115,101,108,102, 58, 99,102,117,110, 99,110, 97,109,101,
+     40, 34,116,111,108,117, 97, 95,115,101,116, 34, 41, 10,111,
+    117,116,112,117,116, 40, 34, 35,105,102,110,100,101,102, 32,
+     84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, 34,
+     46, 46,115,101,108,102, 46, 99,115,101,116,110, 97,109,101,
+     41, 10,111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,
+    116,105, 99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,
+    115,101,116,110, 97,109,101, 44, 34, 40,108,117, 97, 95, 83,
+    116, 97,116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34,
+     41, 10,111,117,116,112,117,116, 40, 34,123, 34, 41, 10,105,
+    102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,
+    116,105, 99, 61, 61,110,105,108, 32,116,104,101,110, 10,111,
+    117,116,112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46,
+    112, 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42, 39,
+     44, 39,115,101,108,102, 32, 61, 32, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 40, 39, 44,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,116,121,112,101, 44, 39, 42, 41, 32, 39,
+     41, 10,111,117,116,112,117,116, 40, 39,116,111,108,117, 97,
+     95,116,111,117,115,101,114,116,121,112,101, 40,116,111,108,
+    117, 97, 95, 83, 44, 49, 44, 48, 41, 59, 39, 41, 10,101,110,
+    100, 10,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,
+    101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83,
+     69, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+    116,111,108,117, 97, 95, 69,114,114,111,114, 32,116,111,108,
+    117, 97, 95,101,114,114, 59, 39, 41, 10,105,102, 32, 99,108,
+     97,115,115, 32, 97,110,100, 32,115,116, 97,116,105, 99, 61,
+     61,110,105,108, 32,116,104,101,110, 10,111,117,116,112,117,
+    116, 40, 39, 32,105,102, 32, 40, 33,115,101,108,102, 41, 32,
+    116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111,108,
+    117, 97, 95, 83, 44, 34,105,110,118, 97,108,105,100, 32, 92,
+     39,115,101,108,102, 92, 39, 32,105,110, 32, 97, 99, 99,101,
+    115,115,105,110,103, 32,118, 97,114,105, 97, 98,108,101, 32,
+     92, 39, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46,
+     46, 39, 92, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 59,
+     10,101,108,115,101,105,102, 32,115,116, 97,116,105, 99, 32,
+    116,104,101,110, 10, 95, 44, 95, 44,115,101,108,102, 46,109,
+    111,100, 32, 61, 32,115,116,114,102,105,110,100, 40,115,101,
+    108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,115,116, 97,
+    116,105, 99, 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10,
+    101,110,100, 10,111,117,116,112,117,116, 40, 39, 32,105,102,
+     32, 40, 33, 39, 46, 46,115,101,108,102, 58,111,117,116, 99,
+    104,101, 99,107,116,121,112,101, 40, 50, 41, 46, 46, 39, 41,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 35,118,105,110,118, 97,108,105,100, 32,116,121,
+    112,101, 32,105,110, 32,118, 97,114,105, 97, 98,108,101, 32,
+     97,115,115,105,103,110,109,101,110,116, 46, 34, 44, 38,116,
+    111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39,
+     41, 10,108,111, 99, 97,108, 32,100,101,102, 32, 61, 32, 48,
+     10,105,102, 32,115,101,108,102, 46,100,101,102, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 32,100,101,102, 32, 61, 32,
+    115,101,108,102, 46,100,101,102, 32,101,110,100, 10,105,102,
+     32,115,101,108,102, 46,116,121,112,101, 32, 61, 61, 32, 39,
+     99,104, 97,114, 42, 39, 32, 97,110,100, 32,115,101,108,102,
+     46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39, 32,115,116,114,110, 99,
+    112,121, 40, 39, 41, 10,105,102, 32, 99,108, 97,115,115, 32,
+     97,110,100, 32,115,116, 97,116,105, 99, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,116,121,112,101, 46, 46, 39, 58, 58, 39,
+     46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10,101,108,
+    115,101,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39,115,101,108,102, 45, 62,
+     39, 46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10,101,
+    108,115,101, 10,111,117,116,112,117,116, 40,115,101,108,102,
+     46,110, 97,109,101, 41, 10,101,110,100, 10,111,117,116,112,
+    117,116, 40, 39, 44,116,111,108,117, 97, 95,116,111,115,116,
+    114,105,110,103, 40,116,111,108,117, 97, 95, 83, 44, 50, 44,
+     39, 44,100,101,102, 44, 39, 41, 44, 39, 44,115,101,108,102,
+     46,100,105,109, 44, 39, 45, 49, 41, 59, 39, 41, 10,101,108,
+    115,101, 10,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32,
+     39, 39, 10,105,102, 32,115,101,108,102, 46,112,116,114,126,
+     61, 39, 39, 32,116,104,101,110, 32,112,116,114, 32, 61, 32,
+     39, 42, 39, 32,101,110,100, 10,111,117,116,112,117,116, 40,
+     39, 32, 39, 41, 10,108,111, 99, 97,108, 32,110, 97,109,101,
+     32, 61, 32,112,114,111,112, 95,115,101,116, 32,111,114, 32,
+    115,101,108,102, 46,110, 97,109,101, 10,105,102, 32, 99,108,
+     97,115,115, 32, 97,110,100, 32,115,116, 97,116,105, 99, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40,115,101,108,
+    102, 46,112, 97,114,101,110,116, 46,116,121,112,101, 46, 46,
+     39, 58, 58, 39, 46, 46,110, 97,109,101, 41, 10,101,108,115,
+    101,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39,115,101,108,102, 45, 62, 39,
+     46, 46,110, 97,109,101, 41, 10,101,108,115,101, 10,111,117,
+    116,112,117,116, 40,110, 97,109,101, 41, 10,101,110,100, 10,
+    108,111, 99, 97,108, 32,116, 32, 61, 32,105,115, 98, 97,115,
+    105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 10,105,
+    102, 32,112,114,111,112, 95,115,101,116, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39, 40, 39, 41, 10,101,108,
+    115,101, 10,111,117,116,112,117,116, 40, 39, 32, 61, 32, 39,
+     41, 10,101,110,100, 10,105,102, 32,110,111,116, 32,116, 32,
+     97,110,100, 32,112,116,114, 61, 61, 39, 39, 32,116,104,101,
+    110, 32,111,117,116,112,117,116, 40, 39, 42, 39, 41, 32,101,
+    110,100, 10,111,117,116,112,117,116, 40, 39, 40, 40, 39, 44,
+    115,101,108,102, 46,109,111,100, 44,115,101,108,102, 46,116,
+    121,112,101, 41, 10,105,102, 32,110,111,116, 32,116, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 39, 42, 39, 41,
+     10,101,110,100, 10,111,117,116,112,117,116, 40, 39, 41, 32,
+     39, 41, 10,105,102, 32,116, 32,116,104,101,110, 10,105,102,
+     32,105,115,101,110,117,109, 40,115,101,108,102, 46,116,121,
+    112,101, 41, 32,116,104,101,110, 10,111,117,116,112,117,116,
+     40, 39, 40,105,110,116, 41, 32, 39, 41, 10,101,110,100, 10,
+    111,117,116,112,117,116, 40, 39,116,111,108,117, 97, 95,116,
+    111, 39, 46, 46,116, 44, 39, 40,116,111,108,117, 97, 95, 83,
+     44, 50, 44, 39, 44,100,101,102, 44, 39, 41, 41, 39, 41, 10,
+    101,108,115,101, 10,111,117,116,112,117,116, 40, 39,116,111,
+    108,117, 97, 95,116,111,117,115,101,114,116,121,112,101, 40,
+    116,111,108,117, 97, 95, 83, 44, 50, 44, 39, 44,100,101,102,
+     44, 39, 41, 41, 39, 41, 10,101,110,100, 10,105,102, 32,112,
+    114,111,112, 95,115,101,116, 32,116,104,101,110, 10,111,117,
+    116,112,117,116, 40, 34, 41, 34, 41, 10,101,110,100, 10,111,
+    117,116,112,117,116, 40, 34, 59, 34, 41, 10,101,110,100, 10,
+    111,117,116,112,117,116, 40, 39, 32,114,101,116,117,114,110,
+     32, 48, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,125,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 35,101,110,100,
+    105,102, 32, 47, 47, 35,105,102,110,100,101,102, 32, 84, 79,
+     76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10,101,
+    110,100, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 99,108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 58,
+    114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41, 10,
+    105,102, 32,110,111,116, 32,115,101,108,102, 58, 99,104,101,
+     99,107, 95,112,117, 98,108,105, 99, 95, 97, 99, 99,101,115,
+    115, 40, 41, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     10,101,110,100, 10,112,114,101, 32, 61, 32,112,114,101, 32,
+    111,114, 32, 39, 39, 10,108,111, 99, 97,108, 32,112, 97,114,
+    101,110,116, 32, 61, 32,115,101,108,102, 58,105,110,109,111,
+    100,117,108,101, 40, 41, 32,111,114, 32,115,101,108,102, 58,
+    105,110,110, 97,109,101,115,112, 97, 99,101, 40, 41, 32,111,
+    114, 32,115,101,108,102, 58,105,110, 99,108, 97,115,115, 40,
+     41, 10,105,102, 32,110,111,116, 32,112, 97,114,101,110,116,
+     32,116,104,101,110, 10,105,102, 32, 99,108, 97,115,115, 86,
+     97,114,105, 97, 98,108,101, 46, 95,119, 97,114,110,105,110,
+    103, 61, 61,110,105,108, 32,116,104,101,110, 10,119, 97,114,
+    110,105,110,103, 40, 34, 77, 97,112,112,105,110,103, 32,118,
+     97,114,105, 97, 98,108,101, 32,116,111, 32,103,108,111, 98,
+     97,108, 32,109, 97,121, 32,100,101,103,114, 97,100,101, 32,
+    112,101,114,102,111,114,109, 97,110, 99,101, 34, 41, 10, 99,
+    108, 97,115,115, 86, 97,114,105, 97, 98,108,101, 46, 95,119,
+     97,114,110,105,110,103, 32, 61, 32, 49, 10,101,110,100, 10,
+    101,110,100, 10,105,102, 32,115,101,108,102, 46, 99,115,101,
+    116,110, 97,109,101, 32,116,104,101,110, 10,111,117,116,112,
+    117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95,
+    118, 97,114,105, 97, 98,108,101, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,
+    101, 46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,
+    103,101,116,110, 97,109,101, 46, 46, 39, 44, 39, 46, 46,115,
+    101,108,102, 46, 99,115,101,116,110, 97,109,101, 46, 46, 39,
+     41, 59, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95,118,
+     97,114,105, 97, 98,108,101, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+     46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,103,
+    101,116,110, 97,109,101, 46, 46, 39, 44, 78, 85, 76, 76, 41,
+     59, 39, 41, 10,101,110,100, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 95, 86, 97,114,105, 97, 98,108,101,
+     32, 40,116, 41, 10,115,101,116,109,101,116, 97,116, 97, 98,
+    108,101, 40,116, 44, 99,108, 97,115,115, 86, 97,114,105, 97,
+     98,108,101, 41, 10, 97,112,112,101,110,100, 40,116, 41, 10,
+    114,101,116,117,114,110, 32,116, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 86, 97,114,105, 97, 98,108,101,
+     32, 40,115, 41, 10,114,101,116,117,114,110, 32, 95, 86, 97,
+    114,105, 97, 98,108,101, 32, 40, 68,101, 99,108, 97,114, 97,
+    116,105,111,110, 40,115, 44, 39,118, 97,114, 39, 41, 41, 10,
+    101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/variable.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 65,114,114, 97,121, 32, 61, 32,123,
+     10,125, 10, 99,108, 97,115,115, 65,114,114, 97,121, 46, 95,
+     95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,115, 65,
+    114,114, 97,121, 10,115,101,116,109,101,116, 97,116, 97, 98,
+    108,101, 40, 99,108, 97,115,115, 65,114,114, 97,121, 44, 99,
+    108, 97,115,115, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     41, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 65,114,114, 97,121, 58,112,114,105,110,116, 32, 40,105,
+    100,101,110,116, 44, 99,108,111,115,101, 41, 10,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 65,114,114, 97,
+    121,123, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,109,111,100, 32, 61, 32, 39, 34, 46, 46,
+    115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41,
+     10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10,112,
+    114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,112,
+    116,114, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,112,
+    116,114, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,105,
+    100,101,110,116, 46, 46, 34, 32,100,101,102, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,100,101,102, 46, 46, 34, 39,
+     44, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34, 32,100,105,109, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,100,105,109, 46, 46, 34, 39, 44, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    114,101,116, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,
+    114,101,116, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46, 46, 99,
+    108,111,115,101, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121, 58,
+    105,115,118, 97,114,105, 97, 98,108,101, 32, 40, 41, 10,114,
+    101,116,117,114,110, 32,116,114,117,101, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 65,
+    114,114, 97,121, 58,103,101,116,118, 97,108,117,101, 32, 40,
+     99,108, 97,115,115, 44,115,116, 97,116,105, 99, 41, 10,105,
+    102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,
+    116,105, 99, 32,116,104,101,110, 10,114,101,116,117,114,110,
+     32, 99,108, 97,115,115, 46, 46, 39, 58, 58, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 46, 46, 39, 91,116,111,108,
+    117, 97, 95,105,110,100,101,120, 93, 39, 10,101,108,115,101,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,114,
+    101,116,117,114,110, 32, 39,115,101,108,102, 45, 62, 39, 46,
+     46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 91,116,
+    111,108,117, 97, 95,105,110,100,101,120, 93, 39, 10,101,108,
+    115,101, 10,114,101,116,117,114,110, 32,115,101,108,102, 46,
+    110, 97,109,101, 46, 46, 39, 91,116,111,108,117, 97, 95,105,
+    110,100,101,120, 93, 39, 10,101,110,100, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 65,
+    114,114, 97,121, 58,115,117,112, 99,111,100,101, 32, 40, 41,
+     10,108,111, 99, 97,108, 32, 99,108, 97,115,115, 32, 61, 32,
+    115,101,108,102, 58,105,110, 99,108, 97,115,115, 40, 41, 10,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,111,
+    117,116,112,117,116, 40, 34, 47, 42, 32,103,101,116, 32,102,
+    117,110, 99,116,105,111,110, 58, 34, 44,115,101,108,102, 46,
+    110, 97,109,101, 44, 34, 32,111,102, 32, 99,108, 97,115,115,
+     32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41,
+     10,101,108,115,101, 10,111,117,116,112,117,116, 40, 34, 47,
+     42, 32,103,101,116, 32,102,117,110, 99,116,105,111,110, 58,
+     34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34, 32, 42,
+     47, 34, 41, 10,101,110,100, 10,115,101,108,102, 46, 99,103,
+    101,116,110, 97,109,101, 32, 61, 32,115,101,108,102, 58, 99,
+    102,117,110, 99,110, 97,109,101, 40, 34,116,111,108,117, 97,
+     95,103,101,116, 34, 41, 10,111,117,116,112,117,116, 40, 34,
+     35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68,
+     73, 83, 65, 66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46,
+     99,103,101,116,110, 97,109,101, 41, 10,111,117,116,112,117,
+    116, 40, 34, 92,110,115,116, 97,116,105, 99, 32,105,110,116,
+     34, 44,115,101,108,102, 46, 99,103,101,116,110, 97,109,101,
+     44, 34, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,
+    111,108,117, 97, 95, 83, 41, 34, 41, 10,111,117,116,112,117,
+    116, 40, 34,123, 34, 41, 10,111,117,116,112,117,116, 40, 34,
+     32,105,110,116, 32,116,111,108,117, 97, 95,105,110,100,101,
+    120, 59, 34, 41, 10,108,111, 99, 97,108, 32, 95, 44, 95, 44,
+    115,116, 97,116,105, 99, 32, 61, 32,115,116,114,102,105,110,
+    100, 40,115,101,108,102, 46,109,111,100, 44, 39, 94, 37,115,
+     42, 40,115,116, 97,116,105, 99, 41, 39, 41, 10,105,102, 32,
+     99,108, 97,115,115, 32, 97,110,100, 32,115,116, 97,116,105,
+     99, 61, 61,110,105,108, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,116,121,112,101, 44, 39, 42, 39, 44, 39,
+    115,101,108,102, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 32,108,117, 97, 95,112,117,115,104,115,116,114,105,110,
+    103, 40,116,111,108,117, 97, 95, 83, 44, 34, 46,115,101,108,
+    102, 34, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     32,108,117, 97, 95,114, 97,119,103,101,116, 40,116,111,108,
+    117, 97, 95, 83, 44, 49, 41, 59, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 32,115,101,108,102, 32, 61, 32, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 40, 39, 44,115,101,108,102,
+     46,112, 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42,
+     41, 32, 39, 41, 10,111,117,116,112,117,116, 40, 39,108,117,
+     97, 95,116,111,117,115,101,114,100, 97,116, 97, 40,116,111,
+    108,117, 97, 95, 83, 44, 45, 49, 41, 59, 39, 41, 10,101,108,
+    115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,101,
+    110, 10, 95, 44, 95, 44,115,101,108,102, 46,109,111,100, 32,
+     61, 32,115,116,114,102,105,110,100, 40,115,101,108,102, 46,
+    109,111,100, 44, 39, 94, 37,115, 42,115,116, 97,116,105, 99,
+     37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10,101,110,100,
+     10,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,101,
+    102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69,
+     92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,123,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95, 69,114,114,111,114, 32,116,111,108,117, 97, 95,
+    101,114,114, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     32,105,102, 32, 40, 33,116,111,108,117, 97, 95,105,115,110,
+    117,109, 98,101,114, 40,116,111,108,117, 97, 95, 83, 44, 50,
+     44, 48, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 41,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 35,118,105,110,118, 97,108,105,100, 32,116,121,
+    112,101, 32,105,110, 32, 97,114,114, 97,121, 32,105,110,100,
+    101,120,105,110,103, 46, 34, 44, 38,116,111,108,117, 97, 95,
+    101,114,114, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 32,125, 39, 41, 10,111,117,116,112,117,116, 40, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10,105,102, 32,102,108,
+     97,103,115, 91, 39, 49, 39, 93, 32,116,104,101,110, 10,111,
+    117,116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,105,
+    110,100,101,120, 32, 61, 32, 40,105,110,116, 41,116,111,108,
+    117, 97, 95,116,111,110,117,109, 98,101,114, 40,116,111,108,
+    117, 97, 95, 83, 44, 50, 44, 48, 41, 45, 49, 59, 39, 41, 10,
+    101,108,115,101, 10,111,117,116,112,117,116, 40, 39, 32,116,
+    111,108,117, 97, 95,105,110,100,101,120, 32, 61, 32, 40,105,
+    110,116, 41,116,111,108,117, 97, 95,116,111,110,117,109, 98,
+    101,114, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 41,
+     59, 39, 41, 10,101,110,100, 10,111,117,116,112,117,116, 40,
+     39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95,
+     82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,105,102, 32,
+    115,101,108,102, 46,100,105,109, 32, 97,110,100, 32,115,101,
+    108,102, 46,100,105,109, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40, 39, 32,105,102, 32,
+     40,116,111,108,117, 97, 95,105,110,100,101,120, 60, 48, 32,
+    124,124, 32,116,111,108,117, 97, 95,105,110,100,101,120, 62,
+     61, 39, 46, 46,115,101,108,102, 46,100,105,109, 46, 46, 39,
+     41, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116,
+     40, 39, 32,105,102, 32, 40,116,111,108,117, 97, 95,105,110,
+    100,101,120, 60, 48, 41, 39, 41, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,101,114,
+    114,111,114, 40,116,111,108,117, 97, 95, 83, 44, 34, 97,114,
+    114, 97,121, 32,105,110,100,101,120,105,110,103, 32,111,117,
+    116, 32,111,102, 32,114, 97,110,103,101, 46, 34, 44, 78, 85,
+     76, 76, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     35,101,110,100,105,102, 92,110, 39, 41, 10,108,111, 99, 97,
+    108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98, 97,115,105,
+     99, 40,115,101,108,102, 46,116,121,112,101, 41, 10,105,102,
+     32,116, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104, 39, 46, 46,
+    116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39,
+     44, 99,116, 44, 39, 41, 39, 46, 46,115,101,108,102, 58,103,
+    101,116,118, 97,108,117,101, 40, 99,108, 97,115,115, 44,115,
+    116, 97,116,105, 99, 41, 46, 46, 39, 41, 59, 39, 41, 10,101,
+    108,115,101, 10,116, 32, 61, 32,115,101,108,102, 46,116,121,
+    112,101, 10,105,102, 32,115,101,108,102, 46,112,116,114, 32,
+     61, 61, 32, 39, 38, 39, 32,111,114, 32,115,101,108,102, 46,
+    112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39, 32,116,111,108,117, 97, 95,
+    112,117,115,104,117,115,101,114,116,121,112,101, 40,116,111,
+    108,117, 97, 95, 83, 44, 40,118,111,105,100, 42, 41, 38, 39,
+     46, 46,115,101,108,102, 58,103,101,116,118, 97,108,117,101,
+     40, 99,108, 97,115,115, 44,115,116, 97,116,105, 99, 41, 46,
+     46, 39, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10,
+    101,108,115,101, 10,111,117,116,112,117,116, 40, 39, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,
+    100, 42, 41, 39, 46, 46,115,101,108,102, 58,103,101,116,118,
+     97,108,117,101, 40, 99,108, 97,115,115, 44,115,116, 97,116,
+    105, 99, 41, 46, 46, 39, 44, 34, 39, 44,116, 44, 39, 34, 41,
+     59, 39, 41, 10,101,110,100, 10,101,110,100, 10,111,117,116,
+    112,117,116, 40, 39, 32,114,101,116,117,114,110, 32, 49, 59,
+     39, 41, 10,111,117,116,112,117,116, 40, 39,125, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102, 32,
+     47, 47, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65,
+     95, 68, 73, 83, 65, 66, 76, 69, 92,110, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 92,110, 39, 41, 10,105,102, 32,110,
+    111,116, 32,115,116,114,102,105,110,100, 40,115,101,108,102,
+     46,116,121,112,101, 44, 39, 99,111,110,115,116, 39, 41, 32,
+    116,104,101,110, 10,105,102, 32, 99,108, 97,115,115, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 34, 47, 42, 32,
+    115,101,116, 32,102,117,110, 99,116,105,111,110, 58, 34, 44,
+    115,101,108,102, 46,110, 97,109,101, 44, 34, 32,111,102, 32,
+     99,108, 97,115,115, 32, 34, 44, 99,108, 97,115,115, 44, 34,
+     32, 42, 47, 34, 41, 10,101,108,115,101, 10,111,117,116,112,
+    117,116, 40, 34, 47, 42, 32,115,101,116, 32,102,117,110, 99,
+    116,105,111,110, 58, 34, 44,115,101,108,102, 46,110, 97,109,
+    101, 44, 34, 32, 42, 47, 34, 41, 10,101,110,100, 10,115,101,
+    108,102, 46, 99,115,101,116,110, 97,109,101, 32, 61, 32,115,
+    101,108,102, 58, 99,102,117,110, 99,110, 97,109,101, 40, 34,
+    116,111,108,117, 97, 95,115,101,116, 34, 41, 10,111,117,116,
+    112,117,116, 40, 34, 35,105,102,110,100,101,102, 32, 84, 79,
+     76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, 34, 46, 46,
+    115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 41, 10,
+    111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,116,105,
+     99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,115,101,
+    116,110, 97,109,101, 44, 34, 40,108,117, 97, 95, 83,116, 97,
+    116,101, 42, 32,116,111,108,117, 97, 95, 83, 41, 34, 41, 10,
+    111,117,116,112,117,116, 40, 34,123, 34, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32,105,110,116, 32,116,111,108,117, 97,
+     95,105,110,100,101,120, 59, 39, 41, 10,108,111, 99, 97,108,
+     32, 95, 44, 95, 44,115,116, 97,116,105, 99, 32, 61, 32,115,
+    116,114,102,105,110,100, 40,115,101,108,102, 46,109,111,100,
+     44, 39, 94, 37,115, 42, 40,115,116, 97,116,105, 99, 41, 39,
+     41, 10,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,
+    115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116,104,101,
+    110, 10,111,117,116,112,117,116, 40, 39, 32, 39, 44,115,101,
+    108,102, 46,112, 97,114,101,110,116, 46,116,121,112,101, 44,
+     39, 42, 39, 44, 39,115,101,108,102, 59, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32,108,117, 97, 95,112,117,115,104,
+    115,116,114,105,110,103, 40,116,111,108,117, 97, 95, 83, 44,
+     34, 46,115,101,108,102, 34, 41, 59, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32,108,117, 97, 95,114, 97,119,103,101,
+    116, 40,116,111,108,117, 97, 95, 83, 44, 49, 41, 59, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 32,115,101,108,102, 32,
+     61, 32, 39, 41, 10,111,117,116,112,117,116, 40, 39, 40, 39,
+     44,115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,
+    112,101, 44, 39, 42, 41, 32, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39,108,117, 97, 95,116,111,117,115,101,114,100, 97,
+    116, 97, 40,116,111,108,117, 97, 95, 83, 44, 45, 49, 41, 59,
+     39, 41, 10,101,108,115,101,105,102, 32,115,116, 97,116,105,
+     99, 32,116,104,101,110, 10, 95, 44, 95, 44,115,101,108,102,
+     46,109,111,100, 32, 61, 32,115,116,114,102,105,110,100, 40,
+    115,101,108,102, 46,109,111,100, 44, 39, 94, 37,115, 42,115,
+    116, 97,116,105, 99, 37,115, 37,115, 42, 40, 46, 42, 41, 39,
+     41, 10,101,110,100, 10,111,117,116,112,117,116, 40, 39, 35,
+    105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69,
+     76, 69, 65, 83, 69, 92,110, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39, 32,123, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95, 69,114,114,111,114, 32,116,
+    111,108,117, 97, 95,101,114,114, 59, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32,105,102, 32, 40, 33,116,111,108,117,
+     97, 95,105,115,110,117,109, 98,101,114, 40,116,111,108,117,
+     97, 95, 83, 44, 50, 44, 48, 44, 38,116,111,108,117, 97, 95,
+    101,114,114, 41, 41, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,116,
+    111,108,117, 97, 95, 83, 44, 34, 35,118,105,110,118, 97,108,
+    105,100, 32,116,121,112,101, 32,105,110, 32, 97,114,114, 97,
+    121, 32,105,110,100,101,120,105,110,103, 46, 34, 44, 38,116,
+    111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32,125, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+    105,102, 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 39, 32,116,111,
+    108,117, 97, 95,105,110,100,101,120, 32, 61, 32, 40,105,110,
+    116, 41,116,111,108,117, 97, 95,116,111,110,117,109, 98,101,
+    114, 40,116,111,108,117, 97, 95, 83, 44, 50, 44, 48, 41, 45,
+     49, 59, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,
+    116, 40, 39, 32,116,111,108,117, 97, 95,105,110,100,101,120,
+     32, 61, 32, 40,105,110,116, 41,116,111,108,117, 97, 95,116,
+    111,110,117,109, 98,101,114, 40,116,111,108,117, 97, 95, 83,
+     44, 50, 44, 48, 41, 59, 39, 41, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 35,105,102,110,100,101,102, 32, 84,
+     79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39,
+     41, 10,105,102, 32,115,101,108,102, 46,100,105,109, 32, 97,
+    110,100, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     39, 32,105,102, 32, 40,116,111,108,117, 97, 95,105,110,100,
+    101,120, 60, 48, 32,124,124, 32,116,111,108,117, 97, 95,105,
+    110,100,101,120, 62, 61, 39, 46, 46,115,101,108,102, 46,100,
+    105,109, 46, 46, 39, 41, 39, 41, 10,101,108,115,101, 10,111,
+    117,116,112,117,116, 40, 39, 32,105,102, 32, 40,116,111,108,
+    117, 97, 95,105,110,100,101,120, 60, 48, 41, 39, 41, 10,101,
+    110,100, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,
+    117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 97,114,114, 97,121, 32,105,110,100,101,120,105,
+    110,103, 32,111,117,116, 32,111,102, 32,114, 97,110,103,101,
+     46, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41,
+     10,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32, 39, 39,
+     10,105,102, 32,115,101,108,102, 46,112,116,114,126, 61, 39,
+     39, 32,116,104,101,110, 32,112,116,114, 32, 61, 32, 39, 42,
+     39, 32,101,110,100, 10,111,117,116,112,117,116, 40, 39, 32,
+     39, 41, 10,105,102, 32, 99,108, 97,115,115, 32, 97,110,100,
+     32,115,116, 97,116,105, 99, 32,116,104,101,110, 10,111,117,
+    116,112,117,116, 40, 99,108, 97,115,115, 46, 46, 39, 58, 58,
+     39, 46, 46,115,101,108,102, 46,110, 97,109,101, 46, 46, 39,
+     91,116,111,108,117, 97, 95,105,110,100,101,120, 93, 39, 41,
+     10,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 39,115,101,108,
+    102, 45, 62, 39, 46, 46,115,101,108,102, 46,110, 97,109,101,
+     46, 46, 39, 91,116,111,108,117, 97, 95,105,110,100,101,120,
+     93, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116,
+     40,115,101,108,102, 46,110, 97,109,101, 46, 46, 39, 91,116,
+    111,108,117, 97, 95,105,110,100,101,120, 93, 39, 41, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32,116, 32, 61, 32,105,115,
+     98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,112,101,
+     41, 10,111,117,116,112,117,116, 40, 39, 32, 61, 32, 39, 41,
+     10,105,102, 32,110,111,116, 32,116, 32, 97,110,100, 32,112,
+    116,114, 61, 61, 39, 39, 32,116,104,101,110, 32,111,117,116,
+    112,117,116, 40, 39, 42, 39, 41, 32,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 40, 40, 39, 44,115,101,108,102, 46,
+    109,111,100, 44,115,101,108,102, 46,116,121,112,101, 41, 10,
+    105,102, 32,110,111,116, 32,116, 32,116,104,101,110, 10,111,
+    117,116,112,117,116, 40, 39, 42, 39, 41, 10,101,110,100, 10,
+    111,117,116,112,117,116, 40, 39, 41, 32, 39, 41, 10,108,111,
+     99, 97,108, 32,100,101,102, 32, 61, 32, 48, 10,105,102, 32,
+    115,101,108,102, 46,100,101,102, 32,126, 61, 32, 39, 39, 32,
+    116,104,101,110, 32,100,101,102, 32, 61, 32,115,101,108,102,
+     46,100,101,102, 32,101,110,100, 10,105,102, 32,116, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 39,116,111,108,
+    117, 97, 95,116,111, 39, 46, 46,116, 44, 39, 40,116,111,108,
+    117, 97, 95, 83, 44, 51, 44, 39, 44,100,101,102, 44, 39, 41,
+     41, 59, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,
+    116, 40, 39,116,111,108,117, 97, 95,116,111,117,115,101,114,
+    116,121,112,101, 40,116,111,108,117, 97, 95, 83, 44, 51, 44,
+     39, 44,100,101,102, 44, 39, 41, 41, 59, 39, 41, 10,101,110,
+    100, 10,111,117,116,112,117,116, 40, 39, 32,114,101,116,117,
+    114,110, 32, 48, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+     39,125, 39, 41, 10,111,117,116,112,117,116, 40, 39, 35,101,
+    110,100,105,102, 32, 47, 47, 35,105,102,110,100,101,102, 32,
+     84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 92,110,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 92,110, 39, 41,
+     10,101,110,100, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 65,114,114, 97,121, 58,114,
+    101,103,105,115,116,101,114, 32, 40,112,114,101, 41, 10,112,
+    114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10,
+    105,102, 32,115,101,108,102, 46, 99,115,101,116,110, 97,109,
+    101, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,112,
+    114,101, 46, 46, 39,116,111,108,117, 97, 95, 97,114,114, 97,
+    121, 40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,
+    101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 39,
+     46, 46,115,101,108,102, 46, 99,103,101,116,110, 97,109,101,
+     46, 46, 39, 44, 39, 46, 46,115,101,108,102, 46, 99,115,101,
+    116,110, 97,109,101, 46, 46, 39, 41, 59, 39, 41, 10,101,108,
+    115,101, 10,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     39,116,111,108,117, 97, 95, 97,114,114, 97,121, 40,116,111,
+    108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,
+    108,110, 97,109,101, 46, 46, 39, 34, 44, 39, 46, 46,115,101,
+    108,102, 46, 99,103,101,116,110, 97,109,101, 46, 46, 39, 44,
+     78, 85, 76, 76, 41, 59, 39, 41, 10,101,110,100, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 95, 65,114,114,
+     97,121, 32, 40,116, 41, 10,115,101,116,109,101,116, 97,116,
+     97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 65,114,114,
+     97,121, 41, 10, 97,112,112,101,110,100, 40,116, 41, 10,114,
+    101,116,117,114,110, 32,116, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 65,114,114, 97,121, 32, 40,115, 41,
+     10,114,101,116,117,114,110, 32, 95, 65,114,114, 97,121, 32,
+     40, 68,101, 99,108, 97,114, 97,116,105,111,110, 40,115, 44,
+     39,118, 97,114, 39, 41, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/array.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,101,120, 99,101,112,116,105,111,110, 68,101,102,115, 32,
+     61, 32,101,120, 99,101,112,116,105,111,110, 68,101,102,115,
+     32,111,114, 32,123,125, 10,101,120, 99,101,112,116,105,111,
+    110, 68,101,102,115, 91, 34,115,116,100, 58, 58,101,120, 99,
+    101,112,116,105,111,110, 34, 93, 32, 61, 32,123,125, 10,101,
+    120, 99,101,112,116,105,111,110, 68,101,102,115, 91, 34,115,
+    116,100, 58, 58,101,120, 99,101,112,116,105,111,110, 34, 93,
+     91, 34,118, 97,114, 34, 93, 32, 61, 32, 34, 38,101, 34, 10,
+    101,120, 99,101,112,116,105,111,110, 68,101,102,115, 91, 34,
+    115,116,100, 58, 58,101,120, 99,101,112,116,105,111,110, 34,
+     93, 91, 34, 99, 95,115,116,114, 34, 93, 32, 61, 32, 34,101,
+     46,119,104, 97,116, 40, 41, 34, 10,101,120, 99,101,112,116,
+    105,111,110, 68,101,102,115, 91, 34, 97,110,121, 34, 93, 32,
+     61, 32,123,125, 10,101,120, 99,101,112,116,105,111,110, 68,
+    101,102,115, 91, 34, 97,110,121, 34, 93, 91, 34,118, 97,114,
+     34, 93, 32, 61, 32, 34, 34, 10,101,120, 99,101,112,116,105,
+    111,110, 68,101,102,115, 91, 34, 97,110,121, 34, 93, 91, 34,
+     99, 95,115,116,114, 34, 93, 32, 61, 32, 39, 34, 85,110,107,
+    110,111,119,110, 34, 39, 10,101,120, 99,101,112,116,105,111,
+    110, 77,101,115,115, 97,103,101, 66,117,102,102,101,114, 83,
+    105,122,101, 32, 61, 32, 53, 49, 50, 10,102,117,110, 99,116,
+    105,111,110, 32,111,117,116,112,117,116, 69,120, 99,101,112,
+    116,105,111,110, 69,114,114,111,114, 40,102, 44,101, 44,101,
+    114,114, 66,117,102, 41, 10,108,111, 99, 97,108, 32,109,101,
+    115,115, 97,103,101, 67, 95,115,116,114, 32, 61, 32,116,114,
+    117,101, 10,105,102, 32,101, 46,110, 97,109,101, 32, 61, 61,
+     32, 34, 97,110,121, 34, 32,116,104,101,110, 10,109,101,115,
+    115, 97,103,101, 67, 95,115,116,114, 32, 61, 32,102, 97,108,
+    115,101, 10,101,110,100, 10,105,102, 32,110,111,116, 32,101,
+     46,114,101,116, 32,111,114, 32,101, 46,114,101,116, 32, 61,
+     61, 32, 34, 34, 32,116,104,101,110, 10,101, 46,114,101,116,
+     32, 61, 32, 34,110,105,108, 44,109,101,115,115, 97,103,101,
+     34, 10,101,110,100, 10,105,102, 32,110,111,116, 32,101,120,
+     99,101,112,116,105,111,110, 68,101,102,115, 91,101, 46,110,
+     97,109,101, 93, 32,116,104,101,110, 10,101,120, 99,101,112,
+    116,105,111,110, 68,101,102,115, 91,101, 46,110, 97,109,101,
+     93, 32, 61, 32,123,125, 10,101,120, 99,101,112,116,105,111,
+    110, 68,101,102,115, 91,101, 46,110, 97,109,101, 93, 46,118,
+     97,114, 32, 61, 32, 34, 38,101, 34, 10,101,120, 99,101,112,
+    116,105,111,110, 68,101,102,115, 91,101, 46,110, 97,109,101,
+     93, 46, 99, 95,115,116,114, 32, 61, 32, 39, 34, 85,110,107,
+    110,111,119,110, 34, 39, 10,101,110,100, 10,108,111, 99, 97,
+    108, 32,110, 97,109,101, 84,111, 69, 99,104,111, 32, 61, 32,
+    101, 46,110, 97,109,101, 10,105,102, 32,110, 97,109,101, 84,
+    111, 69, 99,104,111, 32, 61, 61, 32, 34, 97,110,121, 34, 32,
+    116,104,101,110, 10,110, 97,109,101, 84,111, 69, 99,104,111,
+     32, 61, 32, 34, 46, 46, 46, 34, 10,101,110,100, 10,105,102,
+     32,101, 46,114,101,116, 32, 61, 61, 32, 34,110,105,108, 34,
+     32,116,104,101,110, 10,111,117,116,112,117,116, 40, 34, 99,
+     97,116, 99,104, 40, 34, 44,110, 97,109,101, 84,111, 69, 99,
+    104,111, 44, 34, 32, 67, 69, 71, 85, 73, 68,101, 97,100, 69,
+    120, 99,101,112,116,105,111,110, 40, 34, 44,101,120, 99,101,
+    112,116,105,111,110, 68,101,102,115, 91,101, 46,110, 97,109,
+    101, 93, 46,118, 97,114, 44, 34, 41, 41, 92,110,123, 92,110,
+     34, 41, 10,101,108,115,101, 10,111,117,116,112,117,116, 40,
+     34, 99, 97,116, 99,104, 40, 34, 44,110, 97,109,101, 84,111,
+     69, 99,104,111, 44,101,120, 99,101,112,116,105,111,110, 68,
+    101,102,115, 91,101, 46,110, 97,109,101, 93, 46,118, 97,114,
+     44, 34, 41, 92,110,123, 92,110, 34, 41, 10,101,110,100, 10,
+    105,102, 32,101, 46,114,101,116, 32, 61, 61, 32, 34,110,105,
+    108, 34, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     34,114,101,116,117,114,110, 32, 48, 59, 92,110, 34, 41, 10,
+    101,108,115,101,105,102, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,101, 46,114,101,116, 44, 34,101,114,114,111,
+    114, 34, 41, 32,116,104,101,110, 10,105,102, 32,109,101,115,
+    115, 97,103,101, 67, 95,115,116,114, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 34,115,110,112,114,105,110,116,
+    102, 40,101,114,114,111,114, 66,117,102,102,101,114, 44, 34,
+     46, 46,101,120, 99,101,112,116,105,111,110, 77,101,115,115,
+     97,103,101, 66,117,102,102,101,114, 83,105,122,101, 46, 46,
+     34, 44, 92, 34, 69,120, 99,101,112,116,105,111,110, 32,111,
+    102, 32,116,121,112,101, 32, 39, 34, 46, 46,101, 46,110, 97,
+    109,101, 46, 46, 34, 39, 32,119, 97,115, 32,116,104,114,111,
+    119,110, 32, 98,121, 32,102,117,110, 99,116,105,111,110, 32,
+     39, 34, 46, 46,102, 46, 46, 34, 39, 92, 92,110, 77,101,115,
+    115, 97,103,101, 58, 32, 37,115, 92, 34, 44, 34, 46, 46,101,
+    120, 99,101,112,116,105,111,110, 68,101,102,115, 91,101, 46,
+    110, 97,109,101, 93, 46, 99, 95,115,116,114, 46, 46, 34, 41,
+     59, 92,110, 34, 41, 10,101,108,115,101, 10,111,117,116,112,
+    117,116, 40, 34,115,110,112,114,105,110,116,102, 40,101,114,
+    114,111,114, 66,117,102,102,101,114, 44, 34, 46, 46,101,120,
+     99,101,112,116,105,111,110, 77,101,115,115, 97,103,101, 66,
+    117,102,102,101,114, 83,105,122,101, 46, 46, 34, 44, 92, 34,
+     85,110,107,110,111,119,110, 32,101,120, 99,101,112,116,105,
+    111,110, 32,116,104,114,111,119,110, 32, 98,121, 32,102,117,
+    110, 99,116,105,111,110, 32, 39, 34, 46, 46,102, 46, 46, 34,
+     39, 92, 34, 41, 59, 92,110, 34, 41, 10,101,110,100, 10,111,
+    117,116,112,117,116, 40, 34,101,114,114,111,114, 68,111, 73,
+    116, 32, 61, 32,116,114,117,101, 59, 92,110, 34, 41, 10,101,
+    108,115,101, 10,105,102, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,101, 46,114,101,116, 44, 34,109,101,115,115,
+     97,103,101, 34, 41, 32, 97,110,100, 32,109,101,115,115, 97,
+    103,101, 67, 95,115,116,114, 32, 97,110,100, 32,101,114,114,
+     66,117,102, 32, 61, 61, 32,102, 97,108,115,101, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40, 34, 99,104, 97,114,
+     32,101,114,114,111,114, 66,117,102,102,101,114, 91, 34, 46,
+     46,101,120, 99,101,112,116,105,111,110, 77,101,115,115, 97,
+    103,101, 66,117,102,102,101,114, 83,105,122,101, 46, 46, 34,
+     93, 59, 92,110, 34, 41, 10,101,110,100, 10,108,111, 99, 97,
+    108, 32,110,117,109,114,101,116,115, 32, 61, 32, 48, 10,108,
+    111, 99, 97,108, 32,114,101,116,112, 97,116, 32, 61, 32, 34,
+     40, 37,119, 43, 41, 44, 63, 34, 10,108,111, 99, 97,108, 32,
+    105, 44,106, 44,114,101,116,118, 97,108, 32, 61, 32,115,116,
+    114,105,110,103, 46,102,105,110,100, 40,101, 46,114,101,116,
+     44,114,101,116,112, 97,116, 41, 10,119,104,105,108,101, 32,
+    105, 32,100,111, 10,108,111, 99, 97,108, 32, 99,111,100,101,
+     32, 61, 32, 34, 34, 10,105,102, 32,114,101,116,118, 97,108,
+     32, 61, 61, 32, 34,110,105,108, 34, 32,116,104,101,110, 10,
+     99,111,100,101, 32, 61, 32, 34,116,111,108,117, 97, 95,112,
+    117,115,104,110,105,108, 40,116,111,108,117, 97, 95, 83, 41,
+     59, 92,110, 34, 10,101,108,115,101,105,102, 32,114,101,116,
+    118, 97,108, 32, 61, 61, 32, 34,109,101,115,115, 97,103,101,
+     34, 32,116,104,101,110, 10,105,102, 32,109,101,115,115, 97,
+    103,101, 67, 95,115,116,114, 32,116,104,101,110, 10, 99,111,
+    100,101, 32, 61, 32, 34,115,110,112,114,105,110,116,102, 40,
+    101,114,114,111,114, 66,117,102,102,101,114, 44, 34, 46, 46,
+    101,120, 99,101,112,116,105,111,110, 77,101,115,115, 97,103,
+    101, 66,117,102,102,101,114, 83,105,122,101, 46, 46, 34, 44,
+     92, 34, 69,120, 99,101,112,116,105,111,110, 32,111,102, 32,
+    116,121,112,101, 32, 39, 34, 46, 46,101, 46,110, 97,109,101,
+     46, 46, 34, 39, 32,119, 97,115, 32,116,104,114,111,119,110,
+     32, 98,121, 32,102,117,110, 99,116,105,111,110, 32, 39, 34,
+     46, 46,102, 46, 46, 34, 39, 92, 92,110, 77,101,115,115, 97,
+    103,101, 58, 32, 37,115, 92, 34, 44, 34, 46, 46,101,120, 99,
+    101,112,116,105,111,110, 68,101,102,115, 91,101, 46,110, 97,
+    109,101, 93, 46, 99, 95,115,116,114, 46, 46, 34, 41, 59, 92,
+    110,116,111,108,117, 97, 95,112,117,115,104,115,116,114,105,
+    110,103, 40,116,111,108,117, 97, 95, 83, 44,101,114,114,111,
+    114, 66,117,102,102,101,114, 41, 59, 92,110, 34, 10,101,108,
+    115,101, 10, 99,111,100,101, 32, 61, 32, 34,116,111,108,117,
+     97, 95,112,117,115,104,115,116,114,105,110,103, 40,116,111,
+    108,117, 97, 95, 83, 44, 92, 34, 85,110,107,110,111,119,110,
+     32,101,120, 99,101,112,116,105,111,110, 32,116,104,114,111,
+    119,110, 32, 98,121, 32,102,117,110, 99,116,105,111,110, 32,
+     39, 34, 46, 46,102, 46, 46, 34, 39, 92, 34, 41, 59, 92,110,
+     34, 10,101,110,100, 10,101,108,115,101,105,102, 32,114,101,
+    116,118, 97,108, 32, 61, 61, 32, 34,116,114,117,101, 34, 32,
+    116,104,101,110, 10, 99,111,100,101, 32, 61, 32, 34,116,111,
+    108,117, 97, 95,112,117,115,104, 98,111,111,108,101, 97,110,
+     40,116,111,108,117, 97, 95, 83, 44, 32, 49, 41, 59, 92,110,
+     34, 10,101,108,115,101,105,102, 32,114,101,116,118, 97,108,
+     32, 61, 61, 32, 34,102, 97,108,115,101, 34, 32,116,104,101,
+    110, 10, 99,111,100,101, 32, 61, 32, 34,116,111,108,117, 97,
+     95,112,117,115,104, 98,111,111,108,101, 97,110, 40,116,111,
+    108,117, 97, 95, 83, 44, 32, 48, 41, 59, 92,110, 34, 10,101,
+    110,100, 10,105,102, 32, 99,111,100,101, 32,126, 61, 32, 34,
+     34, 32,116,104,101,110, 10,111,117,116,112,117,116, 40, 99,
+    111,100,101, 41, 10,110,117,109,114,101,116,115, 32, 61, 32,
+    110,117,109,114,101,116,115, 32, 43, 32, 49, 10,101,110,100,
+     10,105, 44,106, 44,114,101,116,118, 97,108, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,101, 46,114,101,
+    116, 44,114,101,116,112, 97,116, 44,106, 43, 49, 41, 10,101,
+    110,100, 10,111,117,116,112,117,116, 40, 34,114,101,116,117,
+    114,110, 32, 34, 44,110,117,109,114,101,116,115, 44, 34, 59,
+     92,110, 34, 41, 10,101,110,100, 10,111,117,116,112,117,116,
+     40, 34,125, 92,110, 34, 41, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32,111,117,116,112,117,116, 69,120, 99,
+    101,112,116,105,111,110, 67, 97,116, 99,104, 66,108,111, 99,
+    107,115, 40,102,117,110, 99, 44,116,104,114,111,119,115, 44,
+    101,114,114, 41, 10,102,111,114, 32,105, 61, 49, 44,116, 97,
+     98,108,101, 46,103,101,116,110, 40,116,104,114,111,119,115,
+     41, 32,100,111, 10,111,117,116,112,117,116, 69,120, 99,101,
+    112,116,105,111,110, 69,114,114,111,114, 40,102,117,110, 99,
+     44, 32,116,104,114,111,119,115, 91,105, 93, 44, 32,101,114,
+    114, 41, 10,101,110,100, 10,105,102, 32,101,114,114, 32,116,
+    104,101,110, 10,111,117,116,112,117,116, 40, 34,105,102, 32,
+     40,101,114,114,111,114, 68,111, 73,116, 41, 32,123, 92,110,
+     34, 41, 10,111,117,116,112,117,116, 40, 34,108,117, 97, 76,
+     95,101,114,114,111,114, 40,116,111,108,117, 97, 95, 83, 44,
+    101,114,114,111,114, 66,117,102,102,101,114, 41, 59, 92,110,
+     34, 41, 10,111,117,116,112,117,116, 40, 34,125, 92,110, 34,
+     41, 10,101,110,100, 10,101,110,100, 10, 99,108, 97,115,115,
+     70,117,110, 99,116,105,111,110, 32, 61, 32,123, 10,109,111,
+    100, 32, 61, 32, 39, 39, 44, 10,116,121,112,101, 32, 61, 32,
+     39, 39, 44, 10,112,116,114, 32, 61, 32, 39, 39, 44, 10,110,
+     97,109,101, 32, 61, 32, 39, 39, 44, 10, 97,114,103,115, 32,
+     61, 32,123,110, 61, 48,125, 44, 10, 99,111,110,115,116, 32,
+     61, 32, 39, 39, 44, 10,125, 10, 99,108, 97,115,115, 70,117,
+    110, 99,116,105,111,110, 46, 95, 95,105,110,100,101,120, 32,
+     61, 32, 99,108, 97,115,115, 70,117,110, 99,116,105,111,110,
+     10,115,101,116,109,101,116, 97,116, 97, 98,108,101, 40, 99,
+    108, 97,115,115, 70,117,110, 99,116,105,111,110, 44, 99,108,
+     97,115,115, 70,101, 97,116,117,114,101, 41, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,
+    116,105,111,110, 58,100,101, 99,108,116,121,112,101, 32, 40,
+     41, 10,115,101,108,102, 46,116,121,112,101, 32, 61, 32,116,
+    121,112,101,118, 97,114, 40,115,101,108,102, 46,116,121,112,
+    101, 41, 10,105,102, 32,115,116,114,102,105,110,100, 40,115,
+    101,108,102, 46,109,111,100, 44, 39, 99,111,110,115,116, 39,
+     41, 32,116,104,101,110, 10,115,101,108,102, 46,116,121,112,
+    101, 32, 61, 32, 39, 99,111,110,115,116, 32, 39, 46, 46,115,
+    101,108,102, 46,116,121,112,101, 10,115,101,108,102, 46,109,
+    111,100, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46,
+    109,111,100, 44, 39, 99,111,110,115,116, 39, 44, 39, 39, 41,
+     10,101,110,100, 10,108,111, 99, 97,108, 32,105, 61, 49, 10,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10,115,101,108,102, 46, 97,114,103,
+    115, 91,105, 93, 58,100,101, 99,108,116,121,112,101, 40, 41,
+     10,105, 32, 61, 32,105, 43, 49, 10,101,110,100, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 70,117,110, 99,116,105,111,110, 58,115,117,112, 99,111,
+    100,101, 32, 40,108,111, 99, 97,108, 95, 99,111,110,115,116,
+    114,117, 99,116,111,114, 41, 10,108,111, 99, 97,108, 32,111,
+    118,101,114,108,111, 97,100, 32, 61, 32,115,116,114,115,117,
+     98, 40,115,101,108,102, 46, 99,110, 97,109,101, 44, 45, 50,
+     44, 45, 49, 41, 32, 45, 32, 49, 10,108,111, 99, 97,108, 32,
+    110,114,101,116, 32, 61, 32, 48, 10,108,111, 99, 97,108, 32,
+     99,108, 97,115,115, 32, 61, 32,115,101,108,102, 58,105,110,
+     99,108, 97,115,115, 40, 41, 10,108,111, 99, 97,108, 32, 95,
+     44, 95, 44,115,116, 97,116,105, 99, 32, 61, 32,115,116,114,
+    102,105,110,100, 40,115,101,108,102, 46,109,111,100, 44, 39,
+     94, 37,115, 42, 40,115,116, 97,116,105, 99, 41, 39, 41, 10,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,105,
+    102, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 61, 32,
+     39,110,101,119, 39, 32, 97,110,100, 32,115,101,108,102, 46,
+    112, 97,114,101,110,116, 46,102,108, 97,103,115, 46,112,117,
+    114,101, 95,118,105,114,116,117, 97,108, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 10,101,110,100, 10,105,102, 32,
+    108,111, 99, 97,108, 95, 99,111,110,115,116,114,117, 99,116,
+    111,114, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     34, 47, 42, 32,109,101,116,104,111,100, 58, 32,110,101,119,
+     95,108,111, 99, 97,108, 32,111,102, 32, 99,108, 97,115,115,
+     32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42, 47, 34, 41,
+     10,101,108,115,101, 10,111,117,116,112,117,116, 40, 34, 47,
+     42, 32,109,101,116,104,111,100, 58, 34, 44,115,101,108,102,
+     46,110, 97,109,101, 44, 34, 32,111,102, 32, 99,108, 97,115,
+    115, 32, 34, 44, 99,108, 97,115,115, 44, 34, 32, 42, 47, 34,
+     41, 10,101,110,100, 10,101,108,115,101, 10,111,117,116,112,
+    117,116, 40, 34, 47, 42, 32,102,117,110, 99,116,105,111,110,
+     58, 34, 44,115,101,108,102, 46,110, 97,109,101, 44, 34, 32,
+     42, 47, 34, 41, 10,101,110,100, 10,105,102, 32,108,111, 99,
+     97,108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 34, 35,105,
+    102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83,
+     65, 66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, 99,110,
+     97,109,101, 46, 46, 34, 95,108,111, 99, 97,108, 34, 41, 10,
+    111,117,116,112,117,116, 40, 34, 92,110,115,116, 97,116,105,
+     99, 32,105,110,116, 34, 44,115,101,108,102, 46, 99,110, 97,
+    109,101, 46, 46, 34, 95,108,111, 99, 97,108, 34, 44, 34, 40,
+    108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,108,117,
+     97, 95, 83, 41, 34, 41, 10,101,108,115,101, 10,111,117,116,
+    112,117,116, 40, 34, 35,105,102,110,100,101,102, 32, 84, 79,
+     76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69, 95, 34, 46, 46,
+    115,101,108,102, 46, 99,110, 97,109,101, 41, 10,111,117,116,
+    112,117,116, 40, 34, 92,110,115,116, 97,116,105, 99, 32,105,
+    110,116, 34, 44,115,101,108,102, 46, 99,110, 97,109,101, 44,
+     34, 40,108,117, 97, 95, 83,116, 97,116,101, 42, 32,116,111,
+    108,117, 97, 95, 83, 41, 34, 41, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 34,123, 34, 41, 10,105,102, 32,111,118,
+    101,114,108,111, 97,100, 32, 60, 32, 48, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,101,
+    102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83, 69,
+     92,110, 39, 41, 10,101,110,100, 10,111,117,116,112,117,116,
+     40, 39, 32,116,111,108,117, 97, 95, 69,114,114,111,114, 32,
+    116,111,108,117, 97, 95,101,114,114, 59, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32,105,102, 32, 40, 92,110, 39, 41,
+     10,108,111, 99, 97,108, 32,110, 97,114,103, 10,105,102, 32,
+     99,108, 97,115,115, 32,116,104,101,110, 32,110, 97,114,103,
+     61, 50, 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,
+    101,110,100, 10,105,102, 32, 99,108, 97,115,115, 32,116,104,
+    101,110, 10,108,111, 99, 97,108, 32,102,117,110, 99, 32, 61,
+     32, 39,116,111,108,117, 97, 95,105,115,117,115,101,114,116,
+    121,112,101, 39, 10,108,111, 99, 97,108, 32,116,121,112,101,
+     32, 61, 32,115,101,108,102, 46,112, 97,114,101,110,116, 46,
+    116,121,112,101, 10,105,102, 32,115,101,108,102, 46,110, 97,
+    109,101, 61, 61, 39,110,101,119, 39, 32,111,114, 32,115,116,
+     97,116,105, 99,126, 61,110,105,108, 32,116,104,101,110, 10,
+    102,117,110, 99, 32, 61, 32, 39,116,111,108,117, 97, 95,105,
+    115,117,115,101,114,116, 97, 98,108,101, 39, 10,116,121,112,
+    101, 32, 61, 32,115,101,108,102, 46,112, 97,114,101,110,116,
+     46,116,121,112,101, 10,101,110,100, 10,105,102, 32,115,101,
+    108,102, 46, 99,111,110,115,116, 32,126, 61, 32, 39, 39, 32,
+    116,104,101,110, 10,116,121,112,101, 32, 61, 32, 34, 99,111,
+    110,115,116, 32, 34, 46, 46,116,121,112,101, 10,101,110,100,
+     10,111,117,116,112,117,116, 40, 39, 32, 33, 39, 46, 46,102,
+    117,110, 99, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44,
+     49, 44, 34, 39, 46, 46,116,121,112,101, 46, 46, 39, 34, 44,
+     48, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 32,124,
+    124, 92,110, 39, 41, 10,101,110,100, 10,105,102, 32,115,101,
+    108,102, 46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101,
+     32,126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110,
+     10,108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,
+    101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,
+    100,111, 10,108,111, 99, 97,108, 32, 98,116,121,112,101, 32,
+     61, 32,105,115, 98, 97,115,105, 99, 40,115,101,108,102, 46,
+     97,114,103,115, 91,105, 93, 46,116,121,112,101, 41, 10,105,
+    102, 32, 98,116,121,112,101, 32,126, 61, 32, 39,118, 97,108,
+    117,101, 39, 32, 97,110,100, 32, 98,116,121,112,101, 32,126,
+     61, 32, 39,115,116, 97,116,101, 39, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39, 32, 33, 39, 46, 46,115,101,
+    108,102, 46, 97,114,103,115, 91,105, 93, 58,111,117,116, 99,
+    104,101, 99,107,116,121,112,101, 40,110, 97,114,103, 41, 46,
+     46, 39, 32,124,124, 92,110, 39, 41, 10,101,110,100, 10,105,
+    102, 32, 98,116,121,112,101, 32,126, 61, 32, 39,115,116, 97,
+    116,101, 39, 32,116,104,101,110, 10,110, 97,114,103, 32, 61,
+     32,110, 97,114,103, 43, 49, 10,101,110,100, 10,105, 32, 61,
+     32,105, 43, 49, 10,101,110,100, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 32, 33,116,111,108,117, 97, 95,105,
+    115,110,111,111, 98,106, 40,116,111,108,117, 97, 95, 83, 44,
+     39, 46, 46,110, 97,114,103, 46, 46, 39, 44, 38,116,111,108,
+    117, 97, 95,101,114,114, 41, 92,110, 32, 41, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,103,111,116,111, 32,116,111,
+    108,117, 97, 95,108,101,114,114,111,114, 59, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,101,108,115,101, 92,110, 39,
+     41, 10,105,102, 32,111,118,101,114,108,111, 97,100, 32, 60,
+     32, 48, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10,101,110,100,
+     10,111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,108,
+    111, 99, 97,108, 32,110, 97,114,103, 10,105,102, 32, 99,108,
+     97,115,115, 32,116,104,101,110, 32,110, 97,114,103, 61, 50,
+     32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,101,110,
+    100, 10,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,
+    115,101,108,102, 46,110, 97,109,101,126, 61, 39,110,101,119,
+     39, 32, 97,110,100, 32,115,116, 97,116,105, 99, 61, 61,110,
+    105,108, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+     39, 32, 39, 44,115,101,108,102, 46, 99,111,110,115,116, 44,
+    115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,
+    101, 44, 39, 42, 39, 44, 39,115,101,108,102, 32, 61, 32, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 40, 39, 44,115,101,
+    108,102, 46, 99,111,110,115,116, 44,115,101,108,102, 46,112,
+     97,114,101,110,116, 46,116,121,112,101, 44, 39, 42, 41, 32,
+     39, 41, 10,111,117,116,112,117,116, 40, 39,116,111,108,117,
+     97, 95,116,111,117,115,101,114,116,121,112,101, 40,116,111,
+    108,117, 97, 95, 83, 44, 49, 44, 48, 41, 59, 39, 41, 10,101,
+    108,115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,
+    101,110, 10, 95, 44, 95, 44,115,101,108,102, 46,109,111,100,
+     32, 61, 32,115,116,114,102,105,110,100, 40,115,101,108,102,
+     46,109,111,100, 44, 39, 94, 37,115, 42,115,116, 97,116,105,
+     99, 37,115, 37,115, 42, 40, 46, 42, 41, 39, 41, 10,101,110,
+    100, 10,105,102, 32,115,101,108,102, 46, 97,114,103,115, 91,
+     49, 93, 46,116,121,112,101, 32,126, 61, 32, 39,118,111,105,
+    100, 39, 32,116,104,101,110, 10,108,111, 99, 97,108, 32,105,
+     61, 49, 10,119,104,105,108,101, 32,115,101,108,102, 46, 97,
+    114,103,115, 91,105, 93, 32,100,111, 10,115,101,108,102, 46,
+     97,114,103,115, 91,105, 93, 58,100,101, 99,108, 97,114,101,
+     40,110, 97,114,103, 41, 10,105,102, 32,105,115, 98, 97,115,
+    105, 99, 40,115,101,108,102, 46, 97,114,103,115, 91,105, 93,
+     46,116,121,112,101, 41, 32,126, 61, 32, 34,115,116, 97,116,
+    101, 34, 32,116,104,101,110, 10,110, 97,114,103, 32, 61, 32,
+    110, 97,114,103, 43, 49, 10,101,110,100, 10,105, 32, 61, 32,
+    105, 43, 49, 10,101,110,100, 10,101,110,100, 10,105,102, 32,
+     99,108, 97,115,115, 32, 97,110,100, 32,115,101,108,102, 46,
+    110, 97,109,101,126, 61, 39,110,101,119, 39, 32, 97,110,100,
+     32,115,116, 97,116,105, 99, 61, 61,110,105,108, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40, 39, 35,105,102,110,
+    100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65,
+     83, 69, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     32,105,102, 32, 40, 33,115,101,108,102, 41, 32,116,111,108,
+    117, 97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95,
+     83, 44, 34,105,110,118, 97,108,105,100, 32, 92, 39,115,101,
+    108,102, 92, 39, 32,105,110, 32,102,117,110, 99,116,105,111,
+    110, 32, 92, 39, 39, 46, 46,115,101,108,102, 46,110, 97,109,
+    101, 46, 46, 39, 92, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39,
+     41, 59, 10,111,117,116,112,117,116, 40, 39, 35,101,110,100,
+    105,102, 92,110, 39, 41, 10,101,110,100, 10,105,102, 32, 99,
+    108, 97,115,115, 32,116,104,101,110, 32,110, 97,114,103, 61,
+     50, 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,101,
+    110,100, 10,105,102, 32,115,101,108,102, 46, 97,114,103,115,
+     91, 49, 93, 46,116,121,112,101, 32,126, 61, 32, 39,118,111,
+    105,100, 39, 32,116,104,101,110, 10,108,111, 99, 97,108, 32,
+    105, 61, 49, 10,119,104,105,108,101, 32,115,101,108,102, 46,
+     97,114,103,115, 91,105, 93, 32,100,111, 10,115,101,108,102,
+     46, 97,114,103,115, 91,105, 93, 58,103,101,116, 97,114,114,
+     97,121, 40,110, 97,114,103, 41, 10,110, 97,114,103, 32, 61,
+     32,110, 97,114,103, 43, 49, 10,105, 32, 61, 32,105, 43, 49,
+     10,101,110,100, 10,101,110,100, 10,108,111, 99, 97,108, 32,
+    116,104,114,111,119,115, 32, 61, 32,102, 97,108,115,101, 10,
+    100,111, 10,108,111, 99, 97,108, 32,112, 97,116,116,101,114,
+    110, 32, 61, 32, 34,116,111,108,117, 97, 95,116,104,114,111,
+    119,115,124, 46, 42,124, 34, 10,108,111, 99, 97,108, 32,105,
+     44,106, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,115,101,108,102, 46,109,111,100, 44, 32,112, 97,116,
+    116,101,114,110, 41, 10,105,102, 32,105, 32,116,104,101,110,
+     10,116,104,114,111,119,115, 32, 61, 32,123,125, 10,102,111,
+    114, 32,120, 32,105,110, 32,112, 97,105,114,115, 40,116,104,
+    114,111,119,115, 41, 32,100,111, 10,116,104,114,111,119,115,
+     91,120, 93, 32, 61, 32,110,105,108, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32,101,120, 99,101,112,116,115, 32, 61, 32,
+    115,116,114,105,110,103, 46,115,117, 98, 40,115,101,108,102,
+     46,109,111,100, 44, 32,105, 43, 49, 50, 44,106, 41, 10,108,
+    111, 99, 97,108, 32,101,112, 97,116,116,101,114,110, 32, 61,
+     32, 34,124, 46, 45,124, 34, 10,108,111, 99, 97,108, 32,105,
+     44,106, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,101,120, 99,101,112,116,115, 44, 32,101,112, 97,116,
+    116,101,114,110, 41, 10,119,104,105,108,101, 32,105, 32,100,
+    111, 10,108,111, 99, 97,108, 32,101, 32, 61, 32,115,116,114,
+    105,110,103, 46,115,117, 98, 40,101,120, 99,101,112,116,115,
+     44,105, 43, 49, 44,106, 45, 49, 41, 10,108,111, 99, 97,108,
+     32, 95, 44, 95, 44,110, 97,109,101, 44,114,101,115,116, 32,
+     61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,101,
+     44, 32, 34, 40, 91, 37,119, 58, 95, 93, 43, 41, 44, 63, 40,
+     46, 42, 41, 34, 41, 10,116, 97, 98,108,101, 46,105,110,115,
+    101,114,116, 40,116,104,114,111,119,115, 44,123,110, 97,109,
+    101, 61,110, 97,109,101, 44, 32,114,101,116, 61,114,101,115,
+    116,125, 41, 10,105, 44,106, 32, 61, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,101,120, 99,101,112,116,115, 44,
+     32,101,112, 97,116,116,101,114,110, 44, 32,106, 41, 10,101,
+    110,100, 10,115,101,108,102, 46,109,111,100, 32, 61, 32,115,
+    116,114,105,110,103, 46,103,115,117, 98, 40,115,101,108,102,
+     46,109,111,100, 44, 32,112, 97,116,116,101,114,110, 44, 32,
+     34, 34, 41, 10,101,110,100, 10,101,110,100, 10,108,111, 99,
+     97,108, 32,101,120, 82, 97,105,115,101, 69,114,114,111,114,
+     32, 61, 32,102, 97,108,115,101, 10,108,111, 99, 97,108, 32,
+    111,117,116, 32, 61, 32,115,116,114,105,110,103, 46,102,105,
+    110,100, 40,115,101,108,102, 46,109,111,100, 44, 32, 34,116,
+    111,108,117, 97, 95,111,117,116,115,105,100,101, 34, 41, 10,
+    105,102, 32,111,117,116, 32,116,104,101,110, 10,115,101,108,
+    102, 46,109,111,100, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40,115,101,108,102, 46,109,111,100, 44, 32,
+     34,116,111,108,117, 97, 95,111,117,116,115,105,100,101, 34,
+     44, 32, 34, 34, 41, 10,101,110,100, 10,105,102, 32, 99,108,
+     97,115,115, 32, 97,110,100, 32,115,101,108,102, 46,110, 97,
+    109,101, 61, 61, 39,100,101,108,101,116,101, 39, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40, 39, 32,100,101,108,
+    101,116,101, 32,115,101,108,102, 59, 39, 41, 10,101,108,115,
+    101,105,102, 32, 99,108, 97,115,115, 32, 97,110,100, 32,115,
+    101,108,102, 46,110, 97,109,101, 32, 61, 61, 32, 39,111,112,
+    101,114, 97,116,111,114, 38, 91, 93, 39, 32,116,104,101,110,
+     10,105,102, 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 32,115,
+    101,108,102, 45, 62,111,112,101,114, 97,116,111,114, 91, 93,
+     40, 39, 44,115,101,108,102, 46, 97,114,103,115, 91, 49, 93,
+     46,110, 97,109,101, 44, 39, 45, 49, 41, 32, 61, 32, 39, 44,
+    115,101,108,102, 46, 97,114,103,115, 91, 50, 93, 46,110, 97,
+    109,101, 44, 39, 59, 39, 41, 10,101,108,115,101, 10,111,117,
+    116,112,117,116, 40, 39, 32,115,101,108,102, 45, 62,111,112,
+    101,114, 97,116,111,114, 91, 93, 40, 39, 44,115,101,108,102,
+     46, 97,114,103,115, 91, 49, 93, 46,110, 97,109,101, 44, 39,
+     41, 32, 61, 32, 39, 44,115,101,108,102, 46, 97,114,103,115,
+     91, 50, 93, 46,110, 97,109,101, 44, 39, 59, 39, 41, 10,101,
+    110,100, 10,101,108,115,101, 10,105,102, 32,116,104,114,111,
+    119,115, 32,116,104,101,110, 10,102,111,114, 32,105, 61, 49,
+     44,116, 97, 98,108,101, 46,103,101,116,110, 40,116,104,114,
+    111,119,115, 41, 32,100,111, 10,105,102, 32,115,116,114,105,
+    110,103, 46,102,105,110,100, 40,116,104,114,111,119,115, 91,
+    105, 93, 46,114,101,116, 44, 32, 34,101,114,114,111,114, 34,
+     41, 32,116,104,101,110, 10,111,117,116,112,117,116, 40, 34,
+     99,104, 97,114, 32,101,114,114,111,114, 66,117,102,102,101,
+    114, 91, 34, 46, 46,101,120, 99,101,112,116,105,111,110, 77,
+    101,115,115, 97,103,101, 66,117,102,102,101,114, 83,105,122,
+    101, 46, 46, 34, 93, 59, 92,110, 34, 41, 10,111,117,116,112,
+    117,116, 40, 34, 98,111,111,108, 32,101,114,114,111,114, 68,
+    111, 73,116, 32, 61, 32,102, 97,108,115,101, 59, 92,110, 34,
+     41, 10,101,120, 82, 97,105,115,101, 69,114,114,111,114, 32,
+     61, 32,116,114,117,101, 10, 98,114,101, 97,107, 10,101,110,
+    100, 10,101,110,100, 10,111,117,116,112,117,116, 40, 34,116,
+    114,121, 92,110, 34, 41, 10,101,110,100, 10,111,117,116,112,
+    117,116, 40, 39, 32,123, 39, 41, 10,105,102, 32,115,101,108,
+    102, 46,116,121,112,101, 32,126, 61, 32, 39, 39, 32, 97,110,
+    100, 32,115,101,108,102, 46,116,121,112,101, 32,126, 61, 32,
+     39,118,111,105,100, 39, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46,109,111,
+    100, 44,115,101,108,102, 46,116,121,112,101, 44,115,101,108,
+    102, 46,112,116,114, 44, 39,116,111,108,117, 97, 95,114,101,
+    116, 32, 61, 32, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     40, 39, 44,115,101,108,102, 46,109,111,100, 44,115,101,108,
+    102, 46,116,121,112,101, 44,115,101,108,102, 46,112,116,114,
+     44, 39, 41, 32, 39, 41, 10,101,108,115,101, 10,111,117,116,
+    112,117,116, 40, 39, 32, 39, 41, 10,101,110,100, 10,105,102,
+     32, 99,108, 97,115,115, 32, 97,110,100, 32,115,101,108,102,
+     46,110, 97,109,101, 61, 61, 39,110,101,119, 39, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40, 39,110,101,119, 39,
+     44,115,101,108,102, 46,116,121,112,101, 44, 39, 40, 39, 41,
+     10,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32, 97,
+    110,100, 32,115,116, 97,116,105, 99, 32,116,104,101,110, 10,
+    105,102, 32,111,117,116, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39,
+     40, 39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116,
+     40, 99,108, 97,115,115, 46, 46, 39, 58, 58, 39, 46, 46,115,
+    101,108,102, 46,110, 97,109,101, 44, 39, 40, 39, 41, 10,101,
+    110,100, 10,101,108,115,101,105,102, 32, 99,108, 97,115,115,
+     32,116,104,101,110, 10,105,102, 32,111,117,116, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40,115,101,108,102, 46,
+    110, 97,109,101, 44, 39, 40, 39, 41, 10,101,108,115,101, 10,
+    105,102, 32,115,101,108,102, 46, 99, 97,115,116, 95,111,112,
+    101,114, 97,116,111,114, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39,115,116, 97,116,105, 99, 95, 99, 97,115,
+    116, 60, 39, 44,115,101,108,102, 46,109,111,100, 44,115,101,
+    108,102, 46,116,121,112,101, 44,115,101,108,102, 46,112,116,
+    114, 44, 39, 62, 40, 42,115,101,108,102, 39, 41, 10,101,108,
+    115,101, 10,111,117,116,112,117,116, 40, 39,115,101,108,102,
+     45, 62, 39, 46, 46,115,101,108,102, 46,110, 97,109,101, 44,
+     39, 40, 39, 41, 10,101,110,100, 10,101,110,100, 10,101,108,
+    115,101, 10,111,117,116,112,117,116, 40,115,101,108,102, 46,
+    110, 97,109,101, 44, 39, 40, 39, 41, 10,101,110,100, 10,105,
+    102, 32,111,117,116, 32, 97,110,100, 32,110,111,116, 32,115,
+    116, 97,116,105, 99, 32,116,104,101,110, 10,111,117,116,112,
+    117,116, 40, 39,115,101,108,102, 39, 41, 10,105,102, 32,115,
+    101,108,102, 46, 97,114,103,115, 91, 49, 93, 32, 97,110,100,
+     32,115,101,108,102, 46, 97,114,103,115, 91, 49, 93, 46,110,
+     97,109,101, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39, 44, 39, 41, 10,101,110,100,
+     10,101,110,100, 10,108,111, 99, 97,108, 32,105, 61, 49, 10,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10,115,101,108,102, 46, 97,114,103,
+    115, 91,105, 93, 58,112, 97,115,115,112, 97,114, 40, 41, 10,
+    105, 32, 61, 32,105, 43, 49, 10,105,102, 32,115,101,108,102,
+     46, 97,114,103,115, 91,105, 93, 32,116,104,101,110, 10,111,
+    117,116,112,117,116, 40, 39, 44, 39, 41, 10,101,110,100, 10,
+    101,110,100, 10,105,102, 32, 99,108, 97,115,115, 32, 97,110,
+    100, 32,115,101,108,102, 46,110, 97,109,101, 32, 61, 61, 32,
+     39,111,112,101,114, 97,116,111,114, 91, 93, 39, 32, 97,110,
+    100, 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,104,
+    101,110, 10,111,117,116,112,117,116, 40, 39, 45, 49, 41, 59,
+     39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116, 40,
+     39, 41, 59, 39, 41, 10,101,110,100, 10,105,102, 32,115,101,
+    108,102, 46,116,121,112,101, 32,126, 61, 32, 39, 39, 32, 97,
+    110,100, 32,115,101,108,102, 46,116,121,112,101, 32,126, 61,
+     32, 39,118,111,105,100, 39, 32,116,104,101,110, 10,110,114,
+    101,116, 32, 61, 32,110,114,101,116, 32, 43, 32, 49, 10,108,
+    111, 99, 97,108, 32,116, 44, 99,116, 32, 61, 32,105,115, 98,
+     97,115,105, 99, 40,115,101,108,102, 46,116,121,112,101, 41,
+     10,105,102, 32,116, 32,116,104,101,110, 10,105,102, 32,115,
+    101,108,102, 46, 99, 97,115,116, 95,111,112,101,114, 97,116,
+    111,114, 32, 97,110,100, 32, 95, 98, 97,115,105, 99, 95,114,
+     97,119, 95,112,117,115,104, 91,116, 93, 32,116,104,101,110,
+     10,111,117,116,112,117,116, 40, 39, 32, 39, 44, 95, 98, 97,
+    115,105, 99, 95,114, 97,119, 95,112,117,115,104, 91,116, 93,
+     44, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39, 44, 99,
+    116, 44, 39, 41,116,111,108,117, 97, 95,114,101,116, 41, 59,
+     39, 41, 10,101,108,115,101, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104, 39, 46, 46,
+    116, 46, 46, 39, 40,116,111,108,117, 97, 95, 83, 44, 40, 39,
+     44, 99,116, 44, 39, 41,116,111,108,117, 97, 95,114,101,116,
+     41, 59, 39, 41, 10,101,110,100, 10,101,108,115,101, 10,116,
+     32, 61, 32,115,101,108,102, 46,116,121,112,101, 10,110,101,
+    119, 95,116, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40,116, 44, 32, 34, 99,111,110,115,116, 37,115, 43,
+     34, 44, 32, 34, 34, 41, 10,105,102, 32,115,101,108,102, 46,
+    112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 35,105,102,100,101,102, 32, 95, 95,
+     99,112,108,117,115,112,108,117,115, 92,110, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,118,111,105,100, 42, 32,116,
+    111,108,117, 97, 95,111, 98,106, 32, 61, 32,110,101,119, 39,
+     44,110,101,119, 95,116, 44, 39, 40,116,111,108,117, 97, 95,
+    114,101,116, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104,117,115,101,
+    114,116,121,112,101, 95, 97,110,100, 95,116, 97,107,101,111,
+    119,110,101,114,115,104,105,112, 40,116,111,108,117, 97, 95,
+     83, 44,116,111,108,117, 97, 95,111, 98,106, 44, 34, 39, 44,
+    116, 44, 39, 34, 41, 59, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 35,101,108,115,101, 92,110, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32,118,111,105,100, 42, 32,116,111,108,
+    117, 97, 95,111, 98,106, 32, 61, 32,116,111,108,117, 97, 95,
+     99,111,112,121, 40,116,111,108,117, 97, 95, 83, 44, 40,118,
+    111,105,100, 42, 41, 38,116,111,108,117, 97, 95,114,101,116,
+     44,115,105,122,101,111,102, 40, 39, 44,116, 44, 39, 41, 41,
+     59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,
+    108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,
+    101, 95, 97,110,100, 95,116, 97,107,101,111,119,110,101,114,
+    115,104,105,112, 40,116,111,108,117, 97, 95, 83, 44,116,111,
+    108,117, 97, 95,111, 98,106, 44, 34, 39, 44,116, 44, 39, 34,
+     41, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 35,101,
+    110,100,105,102, 92,110, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 32,125, 39, 41, 10,101,108,115,101,105,102, 32,115,
+    101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 38, 39, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,
+    100, 42, 41, 38,116,111,108,117, 97, 95,114,101,116, 44, 34,
+     39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10,101,108,115,101,
+     10,105,102, 32,108,111, 99, 97,108, 95, 99,111,110,115,116,
+    114,117, 99,116,111,114, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,
+    104,117,115,101,114,116,121,112,101, 95, 97,110,100, 95,116,
+     97,107,101,111,119,110,101,114,115,104,105,112, 40,116,111,
+    108,117, 97, 95, 83, 44, 40,118,111,105,100, 32, 42, 41,116,
+    111,108,117, 97, 95,114,101,116, 44, 34, 39, 44,116, 44, 39,
+     34, 41, 59, 39, 41, 10,101,108,115,101, 10,111,117,116,112,
+    117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,104,
+    117,115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95,
+     83, 44, 40,118,111,105,100, 42, 41,116,111,108,117, 97, 95,
+    114,101,116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41,
+     10,101,110,100, 10,101,110,100, 10,101,110,100, 10,101,110,
+    100, 10,108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,
+    108,101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93,
+     32,100,111, 10,110,114,101,116, 32, 61, 32,110,114,101,116,
+     32, 43, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93,
+     58,114,101,116,118, 97,108,117,101, 40, 41, 10,105, 32, 61,
+     32,105, 43, 49, 10,101,110,100, 10,111,117,116,112,117,116,
+     40, 39, 32,125, 39, 41, 10,105,102, 32,116,104,114,111,119,
+    115, 32,116,104,101,110, 10,111,117,116,112,117,116, 69,120,
+     99,101,112,116,105,111,110, 67, 97,116, 99,104, 66,108,111,
+     99,107,115, 40,115,101,108,102, 46,110, 97,109,101, 44, 32,
+    116,104,114,111,119,115, 44, 32,101,120, 82, 97,105,115,101,
+     69,114,114,111,114, 41, 10,101,110,100, 10,105,102, 32, 99,
+    108, 97,115,115, 32,116,104,101,110, 32,110, 97,114,103, 61,
+     50, 32,101,108,115,101, 32,110, 97,114,103, 61, 49, 32,101,
+    110,100, 10,105,102, 32,115,101,108,102, 46, 97,114,103,115,
+     91, 49, 93, 46,116,121,112,101, 32,126, 61, 32, 39,118,111,
+    105,100, 39, 32,116,104,101,110, 10,108,111, 99, 97,108, 32,
+    105, 61, 49, 10,119,104,105,108,101, 32,115,101,108,102, 46,
+     97,114,103,115, 91,105, 93, 32,100,111, 10,115,101,108,102,
+     46, 97,114,103,115, 91,105, 93, 58,115,101,116, 97,114,114,
+     97,121, 40,110, 97,114,103, 41, 10,110, 97,114,103, 32, 61,
+     32,110, 97,114,103, 43, 49, 10,105, 32, 61, 32,105, 43, 49,
+     10,101,110,100, 10,101,110,100, 10,105,102, 32,115,101,108,
+    102, 46, 97,114,103,115, 91, 49, 93, 46,116,121,112,101, 32,
+    126, 61, 32, 39,118,111,105,100, 39, 32,116,104,101,110, 10,
+    108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101,
+     32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,100,
+    111, 10,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58,
+    102,114,101,101, 97,114,114, 97,121, 40, 41, 10,105, 32, 61,
+     32,105, 43, 49, 10,101,110,100, 10,101,110,100, 10,101,110,
+    100, 10,111,117,116,112,117,116, 40, 39, 32,125, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 32,114,101,116,117,114,110,
+     32, 39, 46, 46,110,114,101,116, 46, 46, 39, 59, 39, 41, 10,
+    105,102, 32,111,118,101,114,108,111, 97,100, 32, 60, 32, 48,
+     32,116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 35,
+    105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69,
+     76, 69, 65, 83, 69, 92,110, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39,116,111,108,117, 97, 95,108,101,114,114,111,114,
+     58, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+    116,111,108,117, 97, 95,101,114,114,111,114, 40,116,111,108,
+    117, 97, 95, 83, 44, 34, 35,102,101,114,114,111,114, 32,105,
+    110, 32,102,117,110, 99,116,105,111,110, 32, 92, 39, 39, 46,
+     46,115,101,108,102, 46,108,110, 97,109,101, 46, 46, 39, 92,
+     39, 46, 34, 44, 38,116,111,108,117, 97, 95,101,114,114, 41,
+     59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,114,101,
+    116,117,114,110, 32, 48, 59, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,101,
+    108,115,101, 10,108,111, 99, 97,108, 32, 95,108,111, 99, 97,
+    108, 32, 61, 32, 34, 34, 10,105,102, 32,108,111, 99, 97,108,
+     95, 99,111,110,115,116,114,117, 99,116,111,114, 32,116,104,
+    101,110, 10, 95,108,111, 99, 97,108, 32, 61, 32, 34, 95,108,
+    111, 99, 97,108, 34, 10,101,110,100, 10,111,117,116,112,117,
+    116, 40, 39,116,111,108,117, 97, 95,108,101,114,114,111,114,
+     58, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+    114,101,116,117,114,110, 32, 39, 46, 46,115,116,114,115,117,
+     98, 40,115,101,108,102, 46, 99,110, 97,109,101, 44, 49, 44,
+     45, 51, 41, 46, 46,102,111,114,109, 97,116, 40, 34, 37, 48,
+     50,100, 34, 44,111,118,101,114,108,111, 97,100, 41, 46, 46,
+     95,108,111, 99, 97,108, 46, 46, 39, 40,116,111,108,117, 97,
+     95, 83, 41, 59, 39, 41, 10,101,110,100, 10,111,117,116,112,
+    117,116, 40, 39,125, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 32, 47, 47, 35,105,102,110,100,
+    101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76,
+     69, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 92,
+    110, 39, 41, 10,105,102, 32, 99,108, 97,115,115, 32, 97,110,
+    100, 32,115,101,108,102, 46,110, 97,109,101, 61, 61, 39,110,
+    101,119, 39, 32, 97,110,100, 32,110,111,116, 32,108,111, 99,
+     97,108, 95, 99,111,110,115,116,114,117, 99,116,111,114, 32,
+    116,104,101,110, 10,115,101,108,102, 58,115,117,112, 99,111,
+    100,101, 40, 49, 41, 10,101,110,100, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 70,117,
+    110, 99,116,105,111,110, 58,114,101,103,105,115,116,101,114,
+     32, 40,112,114,101, 41, 10,105,102, 32,110,111,116, 32,115,
+    101,108,102, 58, 99,104,101, 99,107, 95,112,117, 98,108,105,
+     99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 10,101,110,100, 10,105,102, 32,
+    115,101,108,102, 46,110, 97,109,101, 32, 61, 61, 32, 39,110,
+    101,119, 39, 32, 97,110,100, 32,115,101,108,102, 46,112, 97,
+    114,101,110,116, 46,102,108, 97,103,115, 46,112,117,114,101,
+     95,118,105,114,116,117, 97,108, 32,116,104,101,110, 10,114,
+    101,116,117,114,110, 10,101,110,100, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95,102,
+    117,110, 99,116,105,111,110, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+     46, 46, 39, 34, 44, 39, 46, 46,115,101,108,102, 46, 99,110,
+     97,109,101, 46, 46, 39, 41, 59, 39, 41, 10,105,102, 32,115,
+    101,108,102, 46,110, 97,109,101, 32, 61, 61, 32, 39,110,101,
+    119, 39, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+    112,114,101, 46, 46, 39,116,111,108,117, 97, 95,102,117,110,
+     99,116,105,111,110, 40,116,111,108,117, 97, 95, 83, 44, 34,
+    110,101,119, 95,108,111, 99, 97,108, 34, 44, 39, 46, 46,115,
+    101,108,102, 46, 99,110, 97,109,101, 46, 46, 39, 95,108,111,
+     99, 97,108, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+    112,114,101, 46, 46, 39,116,111,108,117, 97, 95,102,117,110,
+     99,116,105,111,110, 40,116,111,108,117, 97, 95, 83, 44, 34,
+     46, 99, 97,108,108, 34, 44, 39, 46, 46,115,101,108,102, 46,
+     99,110, 97,109,101, 46, 46, 39, 95,108,111, 99, 97,108, 41,
+     59, 39, 41, 10,101,110,100, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,
+    116,105,111,110, 58,112,114,105,110,116, 32, 40,105,100,101,
+    110,116, 44, 99,108,111,115,101, 41, 10,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 70,117,110, 99,116,105,
+    111,110,123, 34, 41, 10,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,109,111,100, 32, 61, 32, 39, 34, 46,
+     46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34,
+     41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34, 32,116,121,112,101, 32, 61, 32, 39, 34, 46, 46,115,101,
+    108,102, 46,116,121,112,101, 46, 46, 34, 39, 44, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    112,116,114, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,
+    112,116,114, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,109,101,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110, 97,109,
+    101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,108,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,108,110, 97,109,
+    101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32, 99,111,110,115,116, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46, 99,111,110,115,
+    116, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32, 99,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46, 99,110, 97,109,
+    101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,108,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,108,110, 97,109,
+    101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32, 97,114,103,115, 32, 61,
+     32,123, 34, 41, 10,108,111, 99, 97,108, 32,105, 61, 49, 10,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10,115,101,108,102, 46, 97,114,103,
+    115, 91,105, 93, 58,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32, 34, 44, 34, 44, 34, 41, 10,105, 32, 61,
+     32,105, 43, 49, 10,101,110,100, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,125, 34, 41, 10,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34,125, 34, 46,
+     46, 99,108,111,115,101, 41, 10,101,110,100, 10,102,117,110,
+     99,116,105,111,110, 32, 99,108, 97,115,115, 70,117,110, 99,
+    116,105,111,110, 58,114,101,113,117,105,114,101, 99,111,108,
+    108,101, 99,116,105,111,110, 32, 40,116, 41, 10,108,111, 99,
+     97,108, 32,114, 32, 61, 32,102, 97,108,115,101, 10,105,102,
+     32,115,101,108,102, 46,116,121,112,101, 32,126, 61, 32, 39,
+     39, 32, 97,110,100, 32,110,111,116, 32,105,115, 98, 97,115,
+    105, 99, 40,115,101,108,102, 46,116,121,112,101, 41, 32, 97,
+    110,100, 32,115,101,108,102, 46,112,116,114, 61, 61, 39, 39,
+     32,116,104,101,110, 10,108,111, 99, 97,108, 32,116,121,112,
+    101, 32, 61, 32,103,115,117, 98, 40,115,101,108,102, 46,116,
+    121,112,101, 44, 34, 37,115, 42, 99,111,110,115,116, 37,115,
+     43, 34, 44, 34, 34, 41, 10,116, 91,116,121,112,101, 93, 32,
+     61, 32, 34,116,111,108,117, 97, 95, 99,111,108,108,101, 99,
+    116, 95, 34, 32, 46, 46, 32, 99,108,101, 97,110, 95,116,101,
+    109,112,108, 97,116,101, 40,116,121,112,101, 41, 10,114, 32,
+     61, 32,116,114,117,101, 10,101,110,100, 10,108,111, 99, 97,
+    108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,101,108,
+    102, 46, 97,114,103,115, 91,105, 93, 32,100,111, 10,114, 32,
+     61, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 58,
+    114,101,113,117,105,114,101, 99,111,108,108,101, 99,116,105,
+    111,110, 40,116, 41, 32,111,114, 32,114, 10,105, 32, 61, 32,
+    105, 43, 49, 10,101,110,100, 10,114,101,116,117,114,110, 32,
+    114, 10,101,110,100, 10,102,117,110, 99,116,105,111,110, 32,
+     99,108, 97,115,115, 70,117,110, 99,116,105,111,110, 58,111,
+    118,101,114,108,111, 97,100, 32, 40, 41, 10,114,101,116,117,
+    114,110, 32,115,101,108,102, 46,112, 97,114,101,110,116, 58,
+    111,118,101,114,108,111, 97,100, 40,115,101,108,102, 46,108,
+    110, 97,109,101, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32,112, 97,114, 97,109, 95,111, 98,106,101, 99,
+    116, 40,112, 97,114, 41, 10,105,102, 32,110,111,116, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114, 44,
+     32, 39, 61, 39, 41, 32,116,104,101,110, 32,114,101,116,117,
+    114,110, 32,102, 97,108,115,101, 32,101,110,100, 10,108,111,
+     99, 97,108, 32, 95, 44, 95, 44,100,101,102, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114, 44,
+     32, 34, 61, 40, 46, 42, 41, 36, 34, 41, 10,105,102, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114, 44,
+     32, 34,124, 34, 41, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32,116,114,117,101, 10,101,110,100, 10,105,102, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114,
+     44, 32, 34, 37, 42, 34, 41, 32,116,104,101,110, 10,105,102,
+     32,115,116,114,105,110,103, 46,102,105,110,100, 40,112, 97,
+    114, 44, 32, 39, 61, 37,115, 42,110,101,119, 39, 41, 32,116,
+    104,101,110, 10,114,101,116,117,114,110, 32,116,114,117,101,
+     10,101,110,100, 10,114,101,116,117,114,110, 32,102, 97,108,
+    115,101, 10,101,110,100, 10,105,102, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40,112, 97,114, 44, 32, 34, 91, 37,
+     40, 38, 93, 34, 41, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32,116,114,117,101, 10,101,110,100, 10,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10,101,110,100, 10,102,
+    117,110, 99,116,105,111,110, 32,115,116,114,105,112, 95,108,
+     97,115,116, 95, 97,114,103, 40, 97,108,108, 95, 97,114,103,
+    115, 44, 32,108, 97,115,116, 95, 97,114,103, 41, 10,108,111,
+     99, 97,108, 32, 95, 44, 95, 44,115, 95, 97,114,103, 32, 61,
+     32,115,116,114,105,110,103, 46,102,105,110,100, 40,108, 97,
+    115,116, 95, 97,114,103, 44, 32, 34, 94, 40, 91, 94, 61, 93,
+     43, 41, 34, 41, 10,108, 97,115,116, 95, 97,114,103, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,108, 97,
+    115,116, 95, 97,114,103, 44, 32, 34, 40, 91, 37, 37, 37, 40,
+     37, 41, 93, 41, 34, 44, 32, 34, 37, 37, 37, 49, 34, 41, 59,
+     10, 97,108,108, 95, 97,114,103,115, 32, 61, 32,115,116,114,
+    105,110,103, 46,103,115,117, 98, 40, 97,108,108, 95, 97,114,
+    103,115, 44, 32, 34, 37,115, 42, 44, 37,115, 42, 34, 46, 46,
+    108, 97,115,116, 95, 97,114,103, 46, 46, 34, 37,115, 42, 37,
+     41, 37,115, 42, 36, 34, 44, 32, 34, 41, 34, 41, 10,114,101,
+    116,117,114,110, 32, 97,108,108, 95, 97,114,103,115, 44, 32,
+    115, 95, 97,114,103, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 95, 70,117,110, 99,116,105,111,110, 32, 40,
+    116, 41, 10,115,101,116,109,101,116, 97,116, 97, 98,108,101,
+     40,116, 44, 99,108, 97,115,115, 70,117,110, 99,116,105,111,
+    110, 41, 10,105,102, 32,116, 46, 99,111,110,115,116, 32,126,
+     61, 32, 39, 99,111,110,115,116, 39, 32, 97,110,100, 32,116,
+     46, 99,111,110,115,116, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 10,101,114,114,111,114, 40, 34, 35,105,110,118, 97,
+    108,105,100, 32, 39, 99,111,110,115,116, 39, 32,115,112,101,
+     99,105,102,105, 99, 97,116,105,111,110, 34, 41, 10,101,110,
+    100, 10, 97,112,112,101,110,100, 40,116, 41, 10,105,102, 32,
+    116, 58,105,110, 99,108, 97,115,115, 40, 41, 32,116,104,101,
+    110, 10,105,102, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,116, 46,110, 97,109,101, 44, 32, 34, 37, 98, 60, 62,
+     34, 44, 32, 34, 34, 41, 32, 61, 61, 32,115,116,114,105,110,
+    103, 46,103,115,117, 98, 40,116, 46,112, 97,114,101,110,116,
+     46,111,114,105,103,105,110, 97,108, 95,110, 97,109,101, 32,
+    111,114, 32,116, 46,112, 97,114,101,110,116, 46,110, 97,109,
+    101, 44, 32, 34, 37, 98, 60, 62, 34, 44, 32, 34, 34, 41, 32,
+    116,104,101,110, 10,116, 46,110, 97,109,101, 32, 61, 32, 39,
+    110,101,119, 39, 10,116, 46,108,110, 97,109,101, 32, 61, 32,
+     39,110,101,119, 39, 10,116, 46,112, 97,114,101,110,116, 46,
+     95,110,101,119, 32, 61, 32,116,114,117,101, 10,116, 46,116,
+    121,112,101, 32, 61, 32,116, 46,112, 97,114,101,110,116, 46,
+    110, 97,109,101, 10,116, 46,112,116,114, 32, 61, 32, 39, 42,
+     39, 10,101,108,115,101,105,102, 32,115,116,114,105,110,103,
+     46,103,115,117, 98, 40,116, 46,110, 97,109,101, 44, 32, 34,
+     37, 98, 60, 62, 34, 44, 32, 34, 34, 41, 32, 61, 61, 32, 39,
+    126, 39, 46, 46,115,116,114,105,110,103, 46,103,115,117, 98,
+     40,116, 46,112, 97,114,101,110,116, 46,111,114,105,103,105,
+    110, 97,108, 95,110, 97,109,101, 32,111,114, 32,116, 46,112,
+     97,114,101,110,116, 46,110, 97,109,101, 44, 32, 34, 37, 98,
+     60, 62, 34, 44, 32, 34, 34, 41, 32,116,104,101,110, 10,116,
+     46,110, 97,109,101, 32, 61, 32, 39,100,101,108,101,116,101,
+     39, 10,116, 46,108,110, 97,109,101, 32, 61, 32, 39,100,101,
+    108,101,116,101, 39, 10,116, 46,112, 97,114,101,110,116, 46,
+     95,100,101,108,101,116,101, 32, 61, 32,116,114,117,101, 10,
+    101,110,100, 10,101,110,100, 10,116, 46, 99,110, 97,109,101,
+     32, 61, 32,116, 58, 99,102,117,110, 99,110, 97,109,101, 40,
+     34,116,111,108,117, 97, 34, 41, 46, 46,116, 58,111,118,101,
+    114,108,111, 97,100, 40,116, 41, 10,114,101,116,117,114,110,
+     32,116, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 70,117,110, 99,116,105,111,110, 32, 40,100, 44, 97, 44,
+     99, 41, 10,105,102, 32,110,111,116, 32,102,108, 97,103,115,
+     91, 39, 87, 39, 93, 32, 97,110,100, 32,115,116,114,105,110,
+    103, 46,102,105,110,100, 40, 97, 44, 32, 34, 37, 46, 37, 46,
+     37, 46, 37,115, 42, 37, 41, 34, 41, 32,116,104,101,110, 10,
+    119, 97,114,110,105,110,103, 40, 34, 70,117,110, 99,116,105,
+    111,110,115, 32,119,105,116,104, 32,118, 97,114,105, 97, 98,
+    108,101, 32, 97,114,103,117,109,101,110,116,115, 32, 40, 96,
+     46, 46, 46, 39, 41, 32, 97,114,101, 32,110,111,116, 32,115,
+    117,112,112,111,114,116,101,100, 46, 32, 73,103,110,111,114,
+    105,110,103, 32, 34, 46, 46,100, 46, 46, 97, 46, 46, 99, 41,
+     10,114,101,116,117,114,110, 32,110,105,108, 10,101,110,100,
+     10,108,111, 99, 97,108, 32,105, 61, 49, 10,108,111, 99, 97,
+    108, 32,108, 32, 61, 32,123,110, 61, 48,125, 10, 97, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40, 97, 44,
+     32, 34, 37,115, 42, 40, 91, 37, 40, 37, 41, 93, 41, 37,115,
+     42, 34, 44, 32, 34, 37, 49, 34, 41, 10,108,111, 99, 97,108,
+     32,116, 44,115,116,114,105,112, 44,108, 97,115,116, 32, 61,
+     32,115,116,114,105,112, 95,112, 97,114,115, 40,115,116,114,
+    115,117, 98, 40, 97, 44, 50, 44, 45, 50, 41, 41, 59, 10,105,
+    102, 32,115,116,114,105,112, 32,116,104,101,110, 10,108,111,
+     99, 97,108, 32,110,115, 32, 61, 32,106,111,105,110, 40,116,
+     44, 32, 34, 44, 34, 44, 32, 49, 44, 32,108, 97,115,116, 45,
+     49, 41, 10,110,115, 32, 61, 32, 34, 40, 34, 46, 46,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40,110,115, 44, 32, 34,
+     37,115, 42, 44, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 46,
+     46, 39, 41, 39, 10, 70,117,110, 99,116,105,111,110, 40,100,
+     44, 32,110,115, 44, 32, 99, 41, 10,102,111,114, 32,105, 61,
+     49, 44,108, 97,115,116, 32,100,111, 10,116, 91,105, 93, 32,
+     61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,116,
+     91,105, 93, 44, 32, 34, 61, 46, 42, 36, 34, 44, 32, 34, 34,
+     41, 10,101,110,100, 10,101,110,100, 10,119,104,105,108,101,
+     32,116, 91,105, 93, 32,100,111, 10,108, 46,110, 32, 61, 32,
+    108, 46,110, 43, 49, 10,108, 91,108, 46,110, 93, 32, 61, 32,
+     68,101, 99,108, 97,114, 97,116,105,111,110, 40,116, 91,105,
+     93, 44, 39,118, 97,114, 39, 44,116,114,117,101, 41, 10,105,
+     32, 61, 32,105, 43, 49, 10,101,110,100, 10,108,111, 99, 97,
+    108, 32,102, 32, 61, 32, 68,101, 99,108, 97,114, 97,116,105,
+    111,110, 40,100, 44, 39,102,117,110, 99, 39, 41, 10,102, 46,
+     97,114,103,115, 32, 61, 32,108, 10,102, 46, 99,111,110,115,
+    116, 32, 61, 32, 99, 10,114,101,116,117,114,110, 32, 95, 70,
+    117,110, 99,116,105,111,110, 40,102, 41, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32,106,111,105,110, 40,116,
+     44, 32,115,101,112, 44, 32,102,105,114,115,116, 44, 32,108,
+     97,115,116, 41, 10,102,105,114,115,116, 32, 61, 32,102,105,
+    114,115,116, 32,111,114, 32, 49, 10,108, 97,115,116, 32, 61,
+     32,108, 97,115,116, 32,111,114, 32,116, 97, 98,108,101, 46,
+    103,101,116,110, 40,116, 41, 10,108,111, 99, 97,108, 32,108,
+    115,101,112, 32, 61, 32, 34, 34, 10,108,111, 99, 97,108, 32,
+    114,101,116, 32, 61, 32, 34, 34, 10,108,111, 99, 97,108, 32,
+    108,111,111,112, 32, 61, 32,102, 97,108,115,101, 10,102,111,
+    114, 32,105, 32, 61, 32,102,105,114,115,116, 44,108, 97,115,
+    116, 32,100,111, 10,114,101,116, 32, 61, 32,114,101,116, 46,
+     46,108,115,101,112, 46, 46,116, 91,105, 93, 10,108,115,101,
+    112, 32, 61, 32,115,101,112, 10,108,111,111,112, 32, 61, 32,
+    116,114,117,101, 10,101,110,100, 10,105,102, 32,110,111,116,
+     32,108,111,111,112, 32,116,104,101,110, 10,114,101,116,117,
+    114,110, 32, 34, 34, 10,101,110,100, 10,114,101,116,117,114,
+    110, 32,114,101,116, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32,115,116,114,105,112, 95,112, 97,114,115, 40,
+    115, 41, 10,108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,
+    108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115, 44,
+     32, 39, 44, 39, 41, 10,108,111, 99, 97,108, 32,115,116,114,
+    105,112, 32, 61, 32,102, 97,108,115,101, 10,108,111, 99, 97,
+    108, 32,108, 97,115,116, 10,102,111,114, 32,105, 61,116, 46,
+    110, 44, 49, 44, 45, 49, 32,100,111, 10,105,102, 32,110,111,
+    116, 32,115,116,114,105,112, 32, 97,110,100, 32,112, 97,114,
+     97,109, 95,111, 98,106,101, 99,116, 40,116, 91,105, 93, 41,
+     32,116,104,101,110, 10,108, 97,115,116, 32, 61, 32,105, 10,
+    115,116,114,105,112, 32, 61, 32,116,114,117,101, 10,101,110,
+    100, 10,101,110,100, 10,114,101,116,117,114,110, 32,116, 44,
+    115,116,114,105,112, 44,108, 97,115,116, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32,115,116,114,105,112, 95,
+    100,101,102, 97,117,108,116,115, 40,115, 41, 10,115, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44,
+     32, 34, 94, 37, 40, 34, 44, 32, 34, 34, 41, 10,115, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,115, 44,
+     32, 34, 37, 41, 36, 34, 44, 32, 34, 34, 41, 10,108,111, 99,
+     97,108, 32,116, 32, 61, 32,115,112,108,105,116, 95, 99, 95,
+    116,111,107,101,110,115, 40,115, 44, 32, 34, 44, 34, 41, 10,
+    108,111, 99, 97,108, 32,115,101,112, 44, 32,114,101,116, 32,
+     61, 32, 34, 34, 44, 34, 34, 10,102,111,114, 32,105, 61, 49,
+     44,116, 46,110, 32,100,111, 10,116, 91,105, 93, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,116, 91,105,
+     93, 44, 32, 34, 61, 46, 42, 36, 34, 44, 32, 34, 34, 41, 10,
+    114,101,116, 32, 61, 32,114,101,116, 46, 46,115,101,112, 46,
+     46,116, 91,105, 93, 10,115,101,112, 32, 61, 32, 34, 44, 34,
+     10,101,110,100, 10,114,101,116,117,114,110, 32, 34, 40, 34,
+     46, 46,114,101,116, 46, 46, 34, 41, 34, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/function.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 79,112,101,114, 97,116,111,114, 32,
+     61, 32,123, 10,107,105,110,100, 32, 61, 32, 39, 39, 44, 10,
+    125, 10, 99,108, 97,115,115, 79,112,101,114, 97,116,111,114,
+     46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,115,
+    115, 79,112,101,114, 97,116,111,114, 10,115,101,116,109,101,
+    116, 97,116, 97, 98,108,101, 40, 99,108, 97,115,115, 79,112,
+    101,114, 97,116,111,114, 44, 99,108, 97,115,115, 70,117,110,
+     99,116,105,111,110, 41, 10, 95, 84, 77, 32, 61, 32,123, 91,
+     39, 43, 39, 93, 32, 61, 32, 39, 97,100,100, 39, 44, 10, 91,
+     39, 45, 39, 93, 32, 61, 32, 39,115,117, 98, 39, 44, 10, 91,
+     39, 42, 39, 93, 32, 61, 32, 39,109,117,108, 39, 44, 10, 91,
+     39, 47, 39, 93, 32, 61, 32, 39,100,105,118, 39, 44, 10, 91,
+     39, 60, 39, 93, 32, 61, 32, 39,108,116, 39, 44, 10, 91, 39,
+     60, 61, 39, 93, 32, 61, 32, 39,108,101, 39, 44, 10, 91, 39,
+     61, 61, 39, 93, 32, 61, 32, 39,101,113, 39, 44, 10, 91, 39,
+     91, 93, 39, 93, 32, 61, 32, 39,103,101,116,105, 39, 44, 10,
+     91, 39, 38, 91, 93, 39, 93, 32, 61, 32, 39,115,101,116,105,
+     39, 44, 10,125, 10,102,117,110, 99,116,105,111,110, 32, 99,
+    108, 97,115,115, 79,112,101,114, 97,116,111,114, 58,112,114,
+    105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,111,115,
+    101, 41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 79,112,101,114, 97,116,111,114,123, 34, 41, 10,112,
+    114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,107,
+    105,110,100, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,
+    107,105,110,100, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32,109,111,100,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,109,111,100,
+     46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,105,
+    100,101,110,116, 46, 46, 34, 32,116,121,112,101, 32, 61, 32,
+     39, 34, 46, 46,115,101,108,102, 46,116,121,112,101, 46, 46,
+     34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,112,116,114, 32, 61, 32, 39, 34, 46,
+     46,115,101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34,
+     41, 10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46,
+     34, 32,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,
+    108,102, 46,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+     99,111,110,115,116, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46, 99,111,110,115,116, 46, 46, 34, 39, 44, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+     99,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46, 99,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    108,110, 97,109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,
+    102, 46,108,110, 97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+     97,114,103,115, 32, 61, 32,123, 34, 41, 10,108,111, 99, 97,
+    108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,101,108,
+    102, 46, 97,114,103,115, 91,105, 93, 32,100,111, 10,115,101,
+    108,102, 46, 97,114,103,115, 91,105, 93, 58,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32, 34, 44, 34, 44,
+     34, 41, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,100, 10,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    125, 34, 41, 10,112,114,105,110,116, 40,105,100,101,110,116,
+     46, 46, 34,125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 79,112,101,114, 97,116,111,114, 58,115,117,112, 99,
+    111,100,101, 95,116,109,112, 40, 41, 10,105,102, 32,110,111,
+    116, 32, 95, 84, 77, 91,115,101,108,102, 46,107,105,110,100,
+     93, 32,116,104,101,110, 10,114,101,116,117,114,110, 32, 99,
+    108, 97,115,115, 70,117,110, 99,116,105,111,110, 46,115,117,
+    112, 99,111,100,101, 40,115,101,108,102, 41, 10,101,110,100,
+     10,111,117,116,112,117,116, 40, 34, 47, 42, 32,109,101,116,
+    104,111,100, 58, 34, 44,115,101,108,102, 46,110, 97,109,101,
+     44, 34, 32,111,102, 32, 99,108, 97,115,115, 32, 34, 44,115,
+    101,108,102, 58,105,110, 99,108, 97,115,115, 40, 41, 44, 34,
+     32, 42, 47, 34, 41, 10,111,117,116,112,117,116, 40, 34, 35,
+    105,102,110,100,101,102, 32, 84, 79, 76, 85, 65, 95, 68, 73,
+     83, 65, 66, 76, 69, 95, 34, 46, 46,115,101,108,102, 46, 99,
+    110, 97,109,101, 41, 10,111,117,116,112,117,116, 40, 34, 92,
+    110,115,116, 97,116,105, 99, 32,105,110,116, 34, 44,115,101,
+    108,102, 46, 99,110, 97,109,101, 44, 34, 40,108,117, 97, 95,
+     83,116, 97,116,101, 42, 32,116,111,108,117, 97, 95, 83, 41,
+     34, 41, 10,105,102, 32,111,118,101,114,108,111, 97,100, 32,
+     60, 32, 48, 32,116,104,101,110, 10,111,117,116,112,117,116,
+     40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65,
+     95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,101,110,
+    100, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,117,
+     97, 95, 69,114,114,111,114, 32,116,111,108,117, 97, 95,101,
+    114,114, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+    105,102, 32, 40, 92,110, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 32, 33, 39, 46, 46, 39,116,111,108,117, 97, 95,105,
+    115,117,115,101,114,116,121,112,101, 40,116,111,108,117, 97,
+     95, 83, 44, 49, 44, 34, 39, 46, 46,115,101,108,102, 46,112,
+     97,114,101,110,116, 46,116,121,112,101, 46, 46, 39, 34, 44,
+     48, 44, 38,116,111,108,117, 97, 95,101,114,114, 41, 32,124,
+    124, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,
+     33,116,111,108,117, 97, 95,105,115,110,111,111, 98,106, 40,
+    116,111,108,117, 97, 95, 83, 44, 50, 44, 38,116,111,108,117,
+     97, 95,101,114,114, 41, 92,110, 32, 41, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32,103,111,116,111, 32,116,111,108,
+    117, 97, 95,108,101,114,114,111,114, 59, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32,101,108,115,101, 92,110, 39, 41,
+     10,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,102,
+     92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,123,
+     39, 41, 10,111,117,116,112,117,116, 40, 39, 32, 39, 44,115,
+    101,108,102, 46, 99,111,110,115,116, 44,115,101,108,102, 46,
+    112, 97,114,101,110,116, 46,116,121,112,101, 44, 39, 42, 39,
+     44, 39,115,101,108,102, 32, 61, 32, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 40, 39, 44,115,101,108,102, 46, 99,111,
+    110,115,116, 44,115,101,108,102, 46,112, 97,114,101,110,116,
+     46,116,121,112,101, 44, 39, 42, 41, 32, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39,116,111,108,117, 97, 95,116,111,117,
+    115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95, 83,
+     44, 49, 44, 48, 41, 59, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 35,105,102,110,100,101,102, 32, 84, 79, 76, 85, 65,
+     95, 82, 69, 76, 69, 65, 83, 69, 92,110, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32,105,102, 32, 40, 33,115,101,108,
+    102, 41, 32,116,111,108,117, 97, 95,101,114,114,111,114, 40,
+    116,111,108,117, 97, 95, 83, 44, 34,105,110,118, 97,108,105,
+    100, 32, 92, 39,115,101,108,102, 92, 39, 32,105,110, 32,102,
+    117,110, 99,116,105,111,110, 32, 92, 39, 39, 46, 46,115,101,
+    108,102, 46,110, 97,109,101, 46, 46, 39, 92, 39, 34, 44, 78,
+     85, 76, 76, 41, 59, 39, 41, 59, 10,111,117,116,112,117,116,
+     40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 32, 39, 44,115,101,108,102, 46,109,
+    111,100, 44,115,101,108,102, 46,116,121,112,101, 44,115,101,
+    108,102, 46,112,116,114, 44, 39,116,111,108,117, 97, 95,114,
+    101,116, 32, 61, 32, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 40, 39, 44,115,101,108,102, 46,109,111,100, 44,115,101,
+    108,102, 46,116,121,112,101, 44,115,101,108,102, 46,112,116,
+    114, 44, 39, 41, 40, 42,115,101,108,102, 41, 59, 39, 41, 10,
+    108,111, 99, 97,108, 32,116, 44, 99,116, 32, 61, 32,105,115,
+     98, 97,115,105, 99, 40,115,101,108,102, 46,116,121,112,101,
+     41, 10,105,102, 32,116, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,
+    104, 39, 46, 46,116, 46, 46, 39, 40,116,111,108,117, 97, 95,
+     83, 44, 40, 39, 44, 99,116, 44, 39, 41,116,111,108,117, 97,
+     95,114,101,116, 41, 59, 39, 41, 10,101,108,115,101, 10,116,
+     32, 61, 32,115,101,108,102, 46,116,121,112,101, 10,110,101,
+    119, 95,116, 32, 61, 32,115,116,114,105,110,103, 46,103,115,
+    117, 98, 40,116, 44, 32, 34, 99,111,110,115,116, 37,115, 43,
+     34, 44, 32, 34, 34, 41, 10,105,102, 32,115,101,108,102, 46,
+    112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10,
+    111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,111,117,
+    116,112,117,116, 40, 39, 35,105,102,100,101,102, 32, 95, 95,
+     99,112,108,117,115,112,108,117,115, 92,110, 39, 41, 10,111,
+    117,116,112,117,116, 40, 39, 32,118,111,105,100, 42, 32,116,
+    111,108,117, 97, 95,111, 98,106, 32, 61, 32,110,101,119, 39,
+     44,110,101,119, 95,116, 44, 39, 40,116,111,108,117, 97, 95,
+    114,101,116, 41, 59, 39, 41, 10,111,117,116,112,117,116, 40,
+     39, 32,116,111,108,117, 97, 95,112,117,115,104,117,115,101,
+    114,116,121,112,101, 95, 97,110,100, 95,116, 97,107,101,111,
+    119,110,101,114,115,104,105,112, 40,116,111,108,117, 97, 95,
+     83, 44,116,111,108,117, 97, 95,111, 98,106, 44, 34, 39, 44,
+    116, 44, 39, 34, 41, 59, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 35,101,108,115,101, 92,110, 39, 41, 10,111,117,116,
+    112,117,116, 40, 39, 32,118,111,105,100, 42, 32,116,111,108,
+    117, 97, 95,111, 98,106, 32, 61, 32,116,111,108,117, 97, 95,
+     99,111,112,121, 40,116,111,108,117, 97, 95, 83, 44, 40,118,
+    111,105,100, 42, 41, 38,116,111,108,117, 97, 95,114,101,116,
+     44,115,105,122,101,111,102, 40, 39, 44,116, 44, 39, 41, 41,
+     59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,
+    108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,112,
+    101, 95, 97,110,100, 95,116, 97,107,101,111,119,110,101,114,
+    115,104,105,112, 40,116,111,108,117, 97, 95, 83, 44,116,111,
+    108,117, 97, 95,111, 98,106, 44, 34, 39, 44,116, 44, 39, 34,
+     41, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 35,101,
+    110,100,105,102, 92,110, 39, 41, 10,111,117,116,112,117,116,
+     40, 39, 32,125, 39, 41, 10,101,108,115,101,105,102, 32,115,
+    101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 38, 39, 32,
+    116,104,101,110, 10,111,117,116,112,117,116, 40, 39, 32,116,
+    111,108,117, 97, 95,112,117,115,104,117,115,101,114,116,121,
+    112,101, 40,116,111,108,117, 97, 95, 83, 44, 40,118,111,105,
+    100, 42, 41, 38,116,111,108,117, 97, 95,114,101,116, 44, 34,
+     39, 44,116, 44, 39, 34, 41, 59, 39, 41, 10,101,108,115,101,
+     10,105,102, 32,108,111, 99, 97,108, 95, 99,111,110,115,116,
+    114,117, 99,116,111,114, 32,116,104,101,110, 10,111,117,116,
+    112,117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,
+    104,117,115,101,114,116,121,112,101, 95, 97,110,100, 95,116,
+     97,107,101,111,119,110,101,114,115,104,105,112, 40,116,111,
+    108,117, 97, 95, 83, 44, 40,118,111,105,100, 32, 42, 41,116,
+    111,108,117, 97, 95,114,101,116, 44, 34, 39, 44,116, 44, 39,
+     34, 41, 59, 39, 41, 10,101,108,115,101, 10,111,117,116,112,
+    117,116, 40, 39, 32,116,111,108,117, 97, 95,112,117,115,104,
+    117,115,101,114,116,121,112,101, 40,116,111,108,117, 97, 95,
+     83, 44, 40,118,111,105,100, 42, 41,116,111,108,117, 97, 95,
+    114,101,116, 44, 34, 39, 44,116, 44, 39, 34, 41, 59, 39, 41,
+     10,101,110,100, 10,101,110,100, 10,101,110,100, 10,111,117,
+    116,112,117,116, 40, 39, 32,125, 39, 41, 10,111,117,116,112,
+    117,116, 40, 39, 32,114,101,116,117,114,110, 32, 49, 59, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 35,105,102,110,100,
+    101,102, 32, 84, 79, 76, 85, 65, 95, 82, 69, 76, 69, 65, 83,
+     69, 92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39,116,
+    111,108,117, 97, 95,108,101,114,114,111,114, 58, 92,110, 39,
+     41, 10,111,117,116,112,117,116, 40, 39, 32,116,111,108,117,
+     97, 95,101,114,114,111,114, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 35,102,101,114,114,111,114, 32,105,110, 32,102,117,
+    110, 99,116,105,111,110, 32, 92, 39, 39, 46, 46,115,101,108,
+    102, 46,108,110, 97,109,101, 46, 46, 39, 92, 39, 46, 34, 44,
+     38,116,111,108,117, 97, 95,101,114,114, 41, 59, 39, 41, 10,
+    111,117,116,112,117,116, 40, 39, 32,114,101,116,117,114,110,
+     32, 48, 59, 39, 41, 10,111,117,116,112,117,116, 40, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10,111,117,116,112,117,
+    116, 40, 39,125, 39, 41, 10,111,117,116,112,117,116, 40, 39,
+     35,101,110,100,105,102, 32, 47, 47, 35,105,102,110,100,101,
+    102, 32, 84, 79, 76, 85, 65, 95, 68, 73, 83, 65, 66, 76, 69,
+     92,110, 39, 41, 10,111,117,116,112,117,116, 40, 39, 92,110,
+     39, 41, 10,101,110,100, 10,102,117,110, 99,116,105,111,110,
+     32, 95, 79,112,101,114, 97,116,111,114, 32, 40,116, 41, 10,
+    115,101,116,109,101,116, 97,116, 97, 98,108,101, 40,116, 44,
+     99,108, 97,115,115, 79,112,101,114, 97,116,111,114, 41, 10,
+    105,102, 32,116, 46, 99,111,110,115,116, 32,126, 61, 32, 39,
+     99,111,110,115,116, 39, 32, 97,110,100, 32,116, 46, 99,111,
+    110,115,116, 32,126, 61, 32, 39, 39, 32,116,104,101,110, 10,
+    101,114,114,111,114, 40, 34, 35,105,110,118, 97,108,105,100,
+     32, 39, 99,111,110,115,116, 39, 32,115,112,101, 99,105,102,
+    105, 99, 97,116,105,111,110, 34, 41, 10,101,110,100, 10, 97,
+    112,112,101,110,100, 40,116, 41, 10,105,102, 32,110,111,116,
+     32,116, 58,105,110, 99,108, 97,115,115, 40, 41, 32,116,104,
+    101,110, 10,101,114,114,111,114, 40, 34, 35,111,112,101,114,
+     97,116,111,114, 32, 99, 97,110, 32,111,110,108,121, 32, 98,
+    101, 32,100,101,102,105,110,101,100, 32, 97,115, 32, 99,108,
+     97,115,115, 32,109,101,109, 98,101,114, 34, 41, 10,101,110,
+    100, 10,116, 46, 99,110, 97,109,101, 32, 61, 32,116, 58, 99,
+    102,117,110, 99,110, 97,109,101, 40, 34,116,111,108,117, 97,
+     34, 41, 46, 46,116, 58,111,118,101,114,108,111, 97,100, 40,
+    116, 41, 10,116, 46,110, 97,109,101, 32, 61, 32, 34,111,112,
+    101,114, 97,116,111,114, 34, 32, 46, 46, 32,116, 46,107,105,
+    110,100, 10,114,101,116,117,114,110, 32,116, 10,101,110,100,
+     10,102,117,110, 99,116,105,111,110, 32, 79,112,101,114, 97,
+    116,111,114, 32, 40,100, 44,107, 44, 97, 44, 99, 41, 10,108,
+    111, 99, 97,108, 32,111,112, 95,107, 32, 61, 32,115,116,114,
+    105,110,103, 46,103,115,117, 98, 40,107, 44, 32, 34, 94, 37,
+    115, 42, 34, 44, 32, 34, 34, 41, 10,111,112, 95,107, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40,107, 44,
+     32, 34, 37,115, 42, 36, 34, 44, 32, 34, 34, 41, 10,105,102,
+     32,100, 32, 61, 61, 32, 34,111,112,101,114, 97,116,111,114,
+     34, 32, 97,110,100, 32,107, 32,126, 61, 32, 39, 39, 32,116,
+    104,101,110, 10,100, 32, 61, 32,107, 46, 46, 34, 32,111,112,
+    101,114, 97,116,111,114, 34, 10,101,108,115,101,105,102, 32,
+    110,111,116, 32, 95, 84, 77, 91,111,112, 95,107, 93, 32,116,
+    104,101,110, 10,105,102, 32,102,108, 97,103,115, 91, 39, 87,
+     39, 93, 32,116,104,101,110, 10,101,114,114,111,114, 40, 34,
+    116,111,108,117, 97, 58, 32,110,111, 32,115,117,112,112,111,
+    114,116, 32,102,111,114, 32,111,112,101,114, 97,116,111,114,
+     34, 32, 46, 46, 32,102, 46,107,105,110,100, 41, 10,101,108,
+    115,101, 10,119, 97,114,110,105,110,103, 40, 34, 78,111, 32,
+    115,117,112,112,111,114,116, 32,102,111,114, 32,111,112,101,
+    114, 97,116,111,114, 32, 34, 46, 46,111,112, 95,107, 46, 46,
+     34, 44, 32,105,103,110,111,114,105,110,103, 34, 41, 10,114,
+    101,116,117,114,110, 32,110,105,108, 10,101,110,100, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32,114,101,102, 32, 61, 32,
+     39, 39, 10,108,111, 99, 97,108, 32,116, 32, 61, 32,115,112,
+    108,105,116, 95, 99, 95,116,111,107,101,110,115, 40,115,116,
+    114,115,117, 98, 40, 97, 44, 50, 44,115,116,114,108,101,110,
+     40, 97, 41, 45, 49, 41, 44, 39, 44, 39, 41, 10,108,111, 99,
+     97,108, 32,105, 61, 49, 10,108,111, 99, 97,108, 32,108, 32,
+     61, 32,123,110, 61, 48,125, 10,119,104,105,108,101, 32,116,
+     91,105, 93, 32,100,111, 10,108, 46,110, 32, 61, 32,108, 46,
+    110, 43, 49, 10,108, 91,108, 46,110, 93, 32, 61, 32, 68,101,
+     99,108, 97,114, 97,116,105,111,110, 40,116, 91,105, 93, 44,
+     39,118, 97,114, 39, 41, 10,105, 32, 61, 32,105, 43, 49, 10,
+    101,110,100, 10,105,102, 32,107, 32, 61, 61, 32, 39, 91, 93,
+     39, 32,116,104,101,110, 10,108,111, 99, 97,108, 32, 95, 10,
+     95, 44, 32, 95, 44, 32,114,101,102, 32, 61, 32,115,116,114,
+    102,105,110,100, 40,100, 44, 39, 40, 38, 41, 39, 41, 10,100,
+     32, 61, 32,103,115,117, 98, 40,100, 44, 39, 38, 39, 44, 39,
+     39, 41, 10,101,108,115,101,105,102, 32,107, 61, 61, 39, 38,
+     91, 93, 39, 32,116,104,101,110, 10,108, 46,110, 32, 61, 32,
+    108, 46,110, 43, 49, 10,108, 91,108, 46,110, 93, 32, 61, 32,
+     68,101, 99,108, 97,114, 97,116,105,111,110, 40,100, 44, 39,
+    118, 97,114, 39, 41, 10,108, 91,108, 46,110, 93, 46,110, 97,
+    109,101, 32, 61, 32, 39,116,111,108,117, 97, 95,118, 97,108,
+    117,101, 39, 10,101,110,100, 10,108,111, 99, 97,108, 32,102,
+     32, 61, 32, 68,101, 99,108, 97,114, 97,116,105,111,110, 40,
+    100, 44, 39,102,117,110, 99, 39, 41, 10,105,102, 32,107, 32,
+     61, 61, 32, 39, 91, 93, 39, 32, 97,110,100, 32, 40,108, 91,
+     49, 93, 61, 61,110,105,108, 32,111,114, 32,105,115, 98, 97,
+    115,105, 99, 40,108, 91, 49, 93, 46,116,121,112,101, 41,126,
+     61, 39,110,117,109, 98,101,114, 39, 41, 32,116,104,101,110,
+     10,101,114,114,111,114, 40, 39,111,112,101,114, 97,116,111,
+    114, 91, 93, 32, 99, 97,110, 32,111,110,108,121, 32, 98,101,
+     32,100,101,102,105,110,101,100, 32,102,111,114, 32,110,117,
+    109,101,114,105, 99, 32,105,110,100,101,120, 46, 39, 41, 10,
+    101,110,100, 10,102, 46, 97,114,103,115, 32, 61, 32,108, 10,
+    102, 46, 99,111,110,115,116, 32, 61, 32, 99, 10,102, 46,107,
+    105,110,100, 32, 61, 32,111,112, 95,107, 10,102, 46,108,110,
+     97,109,101, 32, 61, 32, 34, 46, 34, 46, 46, 40, 95, 84, 77,
+     91,102, 46,107,105,110,100, 93, 32,111,114, 32,102, 46,107,
+    105,110,100, 41, 10,105,102, 32,110,111,116, 32, 95, 84, 77,
+     91,102, 46,107,105,110,100, 93, 32,116,104,101,110, 10,102,
+     46, 99, 97,115,116, 95,111,112,101,114, 97,116,111,114, 32,
+     61, 32,116,114,117,101, 10,101,110,100, 10,105,102, 32,102,
+     46,107,105,110,100, 32, 61, 61, 32, 39, 91, 93, 39, 32, 97,
+    110,100, 32,114,101,102, 61, 61, 39, 38, 39, 32, 97,110,100,
+     32,102, 46, 99,111,110,115,116,126, 61, 39, 99,111,110,115,
+    116, 39, 32,116,104,101,110, 10, 79,112,101,114, 97,116,111,
+    114, 40,100, 44, 39, 38, 39, 46, 46,107, 44, 97, 44, 99, 41,
+     10,101,110,100, 10,114,101,116,117,114,110, 32, 95, 79,112,
+    101,114, 97,116,111,114, 40,102, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/operator.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 99,108, 97,115,115, 67,108, 97,115,115, 32, 61, 32,123,
+     10, 99,108, 97,115,115,116,121,112,101, 32, 61, 32, 39, 99,
+    108, 97,115,115, 39, 44, 10,110, 97,109,101, 32, 61, 32, 39,
+     39, 44, 10, 98, 97,115,101, 32, 61, 32, 39, 39, 44, 10,116,
+    121,112,101, 32, 61, 32, 39, 39, 44, 10, 98,116,121,112,101,
+     32, 61, 32, 39, 39, 44, 10, 99,116,121,112,101, 32, 61, 32,
+     39, 39, 44, 10,125, 10, 99,108, 97,115,115, 67,108, 97,115,
+    115, 46, 95, 95,105,110,100,101,120, 32, 61, 32, 99,108, 97,
+    115,115, 67,108, 97,115,115, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40, 99,108, 97,115,115, 67,108, 97,115,
+    115, 44, 99,108, 97,115,115, 67,111,110,116, 97,105,110,101,
+    114, 41, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,
+    115,115, 67,108, 97,115,115, 58,114,101,103,105,115,116,101,
+    114, 32, 40,112,114,101, 41, 10,105,102, 32,110,111,116, 32,
+    115,101,108,102, 58, 99,104,101, 99,107, 95,112,117, 98,108,
+    105, 99, 95, 97, 99, 99,101,115,115, 40, 41, 32,116,104,101,
+    110, 10,114,101,116,117,114,110, 10,101,110,100, 10,112,114,
+    101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10,112,
+    117,115,104, 40,115,101,108,102, 41, 10,105,102, 32, 95, 99,
+    111,108,108,101, 99,116, 91,115,101,108,102, 46,116,121,112,
+    101, 93, 32,116,104,101,110, 10,111,117,116,112,117,116, 40,
+    112,114,101, 44, 39, 35,105,102,100,101,102, 32, 95, 95, 99,
+    112,108,117,115,112,108,117,115, 92,110, 39, 41, 10,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117,
+     97, 95, 99, 99,108, 97,115,115, 40,116,111,108,117, 97, 95,
+     83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,
+    101, 46, 46, 39, 34, 44, 34, 39, 46, 46,115,101,108,102, 46,
+    116,121,112,101, 46, 46, 39, 34, 44, 34, 39, 46, 46,115,101,
+    108,102, 46, 98,116,121,112,101, 46, 46, 39, 34, 44, 39, 46,
+     46, 95, 99,111,108,108,101, 99,116, 91,115,101,108,102, 46,
+    116,121,112,101, 93, 46, 46, 39, 41, 59, 39, 41, 10,111,117,
+    116,112,117,116, 40,112,114,101, 44, 39, 35,101,108,115,101,
+     92,110, 39, 41, 10,111,117,116,112,117,116, 40,112,114,101,
+     46, 46, 39,116,111,108,117, 97, 95, 99, 99,108, 97,115,115,
+     40,116,111,108,117, 97, 95, 83, 44, 34, 39, 46, 46,115,101,
+    108,102, 46,108,110, 97,109,101, 46, 46, 39, 34, 44, 34, 39,
+     46, 46,115,101,108,102, 46,116,121,112,101, 46, 46, 39, 34,
+     44, 34, 39, 46, 46,115,101,108,102, 46, 98,116,121,112,101,
+     46, 46, 39, 34, 44, 78, 85, 76, 76, 41, 59, 39, 41, 10,111,
+    117,116,112,117,116, 40,112,114,101, 44, 39, 35,101,110,100,
+    105,102, 92,110, 39, 41, 10,101,108,115,101, 10,111,117,116,
+    112,117,116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97,
+     95, 99, 99,108, 97,115,115, 40,116,111,108,117, 97, 95, 83,
+     44, 34, 39, 46, 46,115,101,108,102, 46,108,110, 97,109,101,
+     46, 46, 39, 34, 44, 34, 39, 46, 46,115,101,108,102, 46,116,
+    121,112,101, 46, 46, 39, 34, 44, 34, 39, 46, 46,115,101,108,
+    102, 46, 98,116,121,112,101, 46, 46, 39, 34, 44, 78, 85, 76,
+     76, 41, 59, 39, 41, 10,101,110,100, 10,105,102, 32,115,101,
+    108,102, 46,101,120,116,114, 97, 95, 98, 97,115,101,115, 32,
+    116,104,101,110, 10,102,111,114, 32,107, 44, 98, 97,115,101,
+     32,105,110, 32,105,112, 97,105,114,115, 40,115,101,108,102,
+     46,101,120,116,114, 97, 95, 98, 97,115,101,115, 41, 32,100,
+    111, 10,101,110,100, 10,101,110,100, 10,111,117,116,112,117,
+    116, 40,112,114,101, 46, 46, 39,116,111,108,117, 97, 95, 98,
+    101,103,105,110,109,111,100,117,108,101, 40,116,111,108,117,
+     97, 95, 83, 44, 34, 39, 46, 46,115,101,108,102, 46,108,110,
+     97,109,101, 46, 46, 39, 34, 41, 59, 39, 41, 10,108,111, 99,
+     97,108, 32,105, 61, 49, 10,119,104,105,108,101, 32,115,101,
+    108,102, 91,105, 93, 32,100,111, 10,115,101,108,102, 91,105,
+     93, 58,114,101,103,105,115,116,101,114, 40,112,114,101, 46,
+     46, 39, 32, 39, 41, 10,105, 32, 61, 32,105, 43, 49, 10,101,
+    110,100, 10,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     39,116,111,108,117, 97, 95,101,110,100,109,111,100,117,108,
+    101, 40,116,111,108,117, 97, 95, 83, 41, 59, 39, 41, 10,112,
+    111,112, 40, 41, 10,101,110,100, 10,102,117,110, 99,116,105,
+    111,110, 32, 99,108, 97,115,115, 67,108, 97,115,115, 58,114,
+    101,113,117,105,114,101, 99,111,108,108,101, 99,116,105,111,
+    110, 32, 40,116, 41, 10,105,102, 32,115,101,108,102, 46,102,
+    108, 97,103,115, 46,112,114,111,116,101, 99,116,101,100, 95,
+    100,101,115,116,114,117, 99,116,111,114, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 32,102, 97,108,115,101, 10,101,
+    110,100, 10,112,117,115,104, 40,115,101,108,102, 41, 10,108,
+    111, 99, 97,108, 32,114, 32, 61, 32,102, 97,108,115,101, 10,
+    108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,108,101,
+     32,115,101,108,102, 91,105, 93, 32,100,111, 10,114, 32, 61,
+     32,115,101,108,102, 91,105, 93, 58,114,101,113,117,105,114,
+    101, 99,111,108,108,101, 99,116,105,111,110, 40,116, 41, 32,
+    111,114, 32,114, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,
+    100, 10,112,111,112, 40, 41, 10,105,102, 32,115,101,108,102,
+     46, 95,100,101,108,101,116,101, 32,111,114, 32, 40, 40,110,
+    111,116, 32,102,108, 97,103,115, 91, 39, 68, 39, 93, 41, 32,
+     97,110,100, 32,115,101,108,102, 46, 95,110,101,119, 41, 32,
+    116,104,101,110, 10,116, 91,115,101,108,102, 46,116,121,112,
+    101, 93, 32, 61, 32, 34,116,111,108,117, 97, 95, 99,111,108,
+    108,101, 99,116, 95, 34, 32, 46, 46, 32, 99,108,101, 97,110,
+     95,116,101,109,112,108, 97,116,101, 40,115,101,108,102, 46,
+    116,121,112,101, 41, 10,114, 32, 61, 32,116,114,117,101, 10,
+    101,110,100, 10,114,101,116,117,114,110, 32,114, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 67,108, 97,115,115, 58,100,101, 99,108,116,121,112,101,
+     32, 40, 41, 10,112,117,115,104, 40,115,101,108,102, 41, 10,
+    115,101,108,102, 46,116,121,112,101, 32, 61, 32,114,101,103,
+    116,121,112,101, 40,115,101,108,102, 46,111,114,105,103,105,
+    110, 97,108, 95,110, 97,109,101, 32,111,114, 32,115,101,108,
+    102, 46,110, 97,109,101, 41, 10,115,101,108,102, 46, 98,116,
+    121,112,101, 32, 61, 32,116,121,112,101,118, 97,114, 40,115,
+    101,108,102, 46, 98, 97,115,101, 41, 10,115,101,108,102, 46,
+     99,116,121,112,101, 32, 61, 32, 39, 99,111,110,115,116, 32,
+     39, 46, 46,115,101,108,102, 46,116,121,112,101, 10,105,102,
+     32,115,101,108,102, 46,101,120,116,114, 97, 95, 98, 97,115,
+    101,115, 32,116,104,101,110, 10,102,111,114, 32,105, 61, 49,
+     44,116, 97, 98,108,101, 46,103,101,116,110, 40,115,101,108,
+    102, 46,101,120,116,114, 97, 95, 98, 97,115,101,115, 41, 32,
+    100,111, 10,115,101,108,102, 46,101,120,116,114, 97, 95, 98,
+     97,115,101,115, 91,105, 93, 32, 61, 32,116,121,112,101,118,
+     97,114, 40,115,101,108,102, 46,101,120,116,114, 97, 95, 98,
+     97,115,101,115, 91,105, 93, 41, 10,101,110,100, 10,101,110,
+    100, 10,108,111, 99, 97,108, 32,105, 61, 49, 10,119,104,105,
+    108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,115,
+    101,108,102, 91,105, 93, 58,100,101, 99,108,116,121,112,101,
+     40, 41, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,100, 10,
+    112,111,112, 40, 41, 10,101,110,100, 10,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 67,108, 97,115,115, 58,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 67,108, 97,115,115,123, 34, 41, 10,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,110, 97,
+    109,101, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,110,
+     97,109,101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32, 98, 97,115,101,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46, 98, 97,115,
+    101, 46, 46, 34, 39, 59, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,108,110, 97,109,101, 32,
+     61, 32, 39, 34, 46, 46,115,101,108,102, 46,108,110, 97,109,
+    101, 46, 46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,116,121,112,101, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46,116,121,112,101, 46,
+     46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 32, 98,116,121,112,101, 32, 61, 32,
+     39, 34, 46, 46,115,101,108,102, 46, 98,116,121,112,101, 46,
+     46, 34, 39, 44, 34, 41, 10,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 32, 99,116,121,112,101, 32, 61, 32,
+     39, 34, 46, 46,115,101,108,102, 46, 99,116,121,112,101, 46,
+     46, 34, 39, 44, 34, 41, 10,108,111, 99, 97,108, 32,105, 61,
+     49, 10,119,104,105,108,101, 32,115,101,108,102, 91,105, 93,
+     32,100,111, 10,115,101,108,102, 91,105, 93, 58,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32, 34, 44, 34,
+     44, 34, 41, 10,105, 32, 61, 32,105, 43, 49, 10,101,110,100,
+     10,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+    125, 34, 46, 46, 99,108,111,115,101, 41, 10,101,110,100, 10,
+    102,117,110, 99,116,105,111,110, 32, 99,108, 97,115,115, 67,
+    108, 97,115,115, 58,115,101,116, 95,112,114,111,116,101, 99,
+    116,101,100, 95,100,101,115,116,114,117, 99,116,111,114, 40,
+    112, 41, 10,115,101,108,102, 46,102,108, 97,103,115, 46,112,
+    114,111,116,101, 99,116,101,100, 95,100,101,115,116,114,117,
+     99,116,111,114, 32, 61, 32,115,101,108,102, 46,102,108, 97,
+    103,115, 46,112,114,111,116,101, 99,116,101,100, 95,100,101,
+    115,116,114,117, 99,116,111,114, 32,111,114, 32,112, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 95, 67,108,
+     97,115,115, 32, 40,116, 41, 10,115,101,116,109,101,116, 97,
+    116, 97, 98,108,101, 40,116, 44, 99,108, 97,115,115, 67,108,
+     97,115,115, 41, 10,116, 58, 98,117,105,108,100,110, 97,109,
+    101,115, 40, 41, 10, 97,112,112,101,110,100, 40,116, 41, 10,
+    114,101,116,117,114,110, 32,116, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32, 67,108, 97,115,115, 32, 40,110,
+     44,112, 44, 98, 41, 10,105,102, 32,116, 97, 98,108,101, 46,
+    103,101,116,110, 40,112, 41, 32, 62, 32, 49, 32,116,104,101,
+    110, 10, 98, 32, 61, 32,115,116,114,105,110,103, 46,115,117,
+     98, 40, 98, 44, 32, 49, 44, 32, 45, 50, 41, 10,102,111,114,
+     32,105, 61, 50, 44,116, 97, 98,108,101, 46,103,101,116,110,
+     40,112, 41, 44, 49, 32,100,111, 10, 98, 32, 61, 32, 98, 46,
+     46, 34, 92,110, 32,116,111,108,117, 97, 95,105,110,104,101,
+    114,105,116,115, 32, 34, 46, 46,112, 91,105, 93, 46, 46, 34,
+     32, 95, 95, 34, 46, 46,112, 91,105, 93, 46, 46, 34, 95, 95,
+     59, 92,110, 34, 10,101,110,100, 10, 98, 32, 61, 32, 98, 46,
+     46, 34, 92,110,125, 34, 10,101,110,100, 10, 98, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40, 98, 44, 32,
+     34, 94,123, 37,115, 42, 84, 69, 77, 80, 76, 65, 84, 69, 95,
+     66, 73, 78, 68, 34, 44, 32, 34,123, 92,110, 84, 79, 76, 85,
+     65, 95, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, 73, 78, 68,
+     34, 41, 10,108,111, 99, 97,108, 32,116, 44, 95, 44, 84, 44,
+     73, 32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100,
+     40, 98, 44, 32, 34, 94,123, 37,115, 42, 84, 79, 76, 85, 65,
+     95, 84, 69, 77, 80, 76, 65, 84, 69, 95, 66, 73, 78, 68, 37,
+    115, 42, 37, 40, 43, 37,115, 42, 92, 34, 63, 40, 91, 94, 92,
+     34, 44, 93, 42, 41, 92, 34, 63, 37,115, 42, 44, 37,115, 42,
+     40, 91, 94, 37, 41, 93, 42, 41, 37,115, 42, 37, 41, 43, 34,
+     41, 10,105,102, 32,116, 32,116,104,101,110, 10, 73, 32, 61,
+     32,115,116,114,105,110,103, 46,103,115,117, 98, 40, 73, 44,
+     32, 34, 92, 34, 34, 44, 32, 34, 34, 41, 10, 84, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40, 84, 44, 32,
+     34, 92, 34, 34, 44, 32, 34, 34, 41, 10,108,111, 99, 97,108,
+     32,116,121,112,101,115, 32, 61, 32,115,112,108,105,116, 95,
+     99, 95,116,111,107,101,110,115, 40, 73, 44, 32, 34, 44, 34,
+     41, 10,108,111, 99, 97,108, 32, 98,115, 32, 61, 32,115,116,
+    114,105,110,103, 46,103,115,117, 98, 40, 98, 44, 32, 34, 94,
+    123, 37,115, 42, 84, 79, 76, 85, 65, 95, 84, 69, 77, 80, 76,
+     65, 84, 69, 95, 66, 73, 78, 68, 91, 94, 92,110, 93, 42, 92,
+    110, 34, 44, 32, 34,123, 92,110, 34, 41, 10,102,111,114, 32,
+    105, 32, 61, 49, 32, 44, 32,116,121,112,101,115, 46,110, 32,
+    100,111, 10,108,111, 99, 97,108, 32, 84,108, 32, 61, 32,115,
+    112,108,105,116, 40, 84, 44, 32, 34, 32, 34, 41, 10,108,111,
+     99, 97,108, 32, 73,108, 32, 61, 32,115,112,108,105,116, 95,
+     99, 95,116,111,107,101,110,115, 40,116,121,112,101,115, 91,
+    105, 93, 44, 32, 34, 32, 34, 41, 10,108,111, 99, 97,108, 32,
+     98, 73, 32, 61, 32, 98,115, 10,108,111, 99, 97,108, 32,112,
+     73, 32, 61, 32,123,125, 10,102,111,114, 32,106, 32, 61, 32,
+     49, 44, 84,108, 46,110, 32,100,111, 10, 84,108, 91,106, 93,
+     32, 61, 32,102,105,110,100,116,121,112,101, 40, 84,108, 91,
+    106, 93, 41, 32,111,114, 32, 84,108, 91,106, 93, 10, 98, 73,
+     32, 61, 32,115,116,114,105,110,103, 46,103,115,117, 98, 40,
+     98, 73, 44, 32, 34, 40, 91, 94, 95, 37,119, 93, 41, 34, 46,
+     46, 84,108, 91,106, 93, 46, 46, 34, 40, 91, 94, 95, 37,119,
+     93, 41, 34, 44, 32, 34, 37, 49, 34, 46, 46, 73,108, 91,106,
+     93, 46, 46, 34, 37, 50, 34, 41, 10,105,102, 32,112, 32,116,
+    104,101,110, 10,102,111,114, 32,105, 61, 49, 44,116, 97, 98,
+    108,101, 46,103,101,116,110, 40,112, 41, 32,100,111, 10,112,
+     73, 91,105, 93, 32, 61, 32,115,116,114,105,110,103, 46,103,
+    115,117, 98, 40,112, 91,105, 93, 44, 32, 34, 40, 91, 94, 95,
+     37,119, 93, 63, 41, 34, 46, 46, 84,108, 91,106, 93, 46, 46,
+     34, 40, 91, 94, 95, 37,119, 93, 63, 41, 34, 44, 32, 34, 37,
+     49, 34, 46, 46, 73,108, 91,106, 93, 46, 46, 34, 37, 50, 34,
+     41, 10,101,110,100, 10,101,110,100, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32, 97,112,112,101,110,100, 32, 61, 32, 34,
+     60, 34, 46, 46, 99,111,110, 99, 97,116, 40, 73,108, 44, 32,
+     49, 44, 32,116, 97, 98,108,101, 46,103,101,116,110, 40, 73,
+    108, 41, 44, 32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10, 97,
+    112,112,101,110,100, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40, 97,112,112,101,110,100, 44, 32, 34, 37,
+    115, 42, 44, 37,115, 42, 34, 44, 32, 34, 44, 34, 41, 10, 97,
+    112,112,101,110,100, 32, 61, 32,115,116,114,105,110,103, 46,
+    103,115,117, 98, 40, 97,112,112,101,110,100, 44, 32, 34, 62,
+     62, 34, 44, 32, 34, 62, 32, 62, 34, 41, 10,102,111,114, 32,
+    105, 61, 49, 44,116, 97, 98,108,101, 46,103,101,116,110, 40,
+    112, 73, 41, 32,100,111, 10,112, 73, 91,105, 93, 32, 61, 32,
+    114,101,115,111,108,118,101, 95,116,101,109,112,108, 97,116,
+    101, 95,116,121,112,101,115, 40,112, 73, 91,105, 93, 41, 10,
+    101,110,100, 10, 98, 73, 32, 61, 32,115,116,114,105,110,103,
+     46,103,115,117, 98, 40, 98, 73, 44, 32, 34, 62, 62, 34, 44,
+     32, 34, 62, 32, 62, 34, 41, 10, 67,108, 97,115,115, 40,110,
+     46, 46, 97,112,112,101,110,100, 44, 32,112, 73, 44, 32, 98,
+     73, 41, 10,101,110,100, 10,114,101,116,117,114,110, 10,101,
+    110,100, 10,108,111, 99, 97,108, 32,109, 98, 97,115,101, 10,
+    105,102, 32,112, 32,116,104,101,110, 10,109, 98, 97,115,101,
+     32, 61, 32,116, 97, 98,108,101, 46,114,101,109,111,118,101,
+     40,112, 44, 32, 49, 41, 10,105,102, 32,110,111,116, 32,112,
+     91, 49, 93, 32,116,104,101,110, 32,112, 32, 61, 32,110,105,
+    108, 32,101,110,100, 10,101,110,100, 10,109, 98, 97,115,101,
+     32, 61, 32,109, 98, 97,115,101, 32, 97,110,100, 32,114,101,
+    115,111,108,118,101, 95,116,101,109,112,108, 97,116,101, 95,
+    116,121,112,101,115, 40,109, 98, 97,115,101, 41, 10,108,111,
+     99, 97,108, 32, 99, 10,108,111, 99, 97,108, 32,111,110, 97,
+    109,101, 32, 61, 32,115,116,114,105,110,103, 46,103,115,117,
+     98, 40,110, 44, 32, 34, 64, 46, 42, 36, 34, 44, 32, 34, 34,
+     41, 10,111,110, 97,109,101, 32, 61, 32,103,101,116,110, 97,
+    109,101,115,112, 97, 99,101, 40, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 46, 99,117,114,114, 41, 46, 46,
+    111,110, 97,109,101, 10,105,102, 32, 95,103,108,111, 98, 97,
+    108, 95, 99,108, 97,115,115,101,115, 91,111,110, 97,109,101,
+     93, 32,116,104,101,110, 10, 99, 32, 61, 32, 95,103,108,111,
+     98, 97,108, 95, 99,108, 97,115,115,101,115, 91,111,110, 97,
+    109,101, 93, 10,105,102, 32,109, 98, 97,115,101, 32, 97,110,
+    100, 32, 40, 40,110,111,116, 32, 99, 46, 98, 97,115,101, 41,
+     32,111,114, 32, 99, 46, 98, 97,115,101, 32, 61, 61, 32, 34,
+     34, 41, 32,116,104,101,110, 10, 99, 46, 98, 97,115,101, 32,
+     61, 32,109, 98, 97,115,101, 10,101,110,100, 10,101,108,115,
+    101, 10, 99, 32, 61, 32, 95, 67,108, 97,115,115, 40, 95, 67,
+    111,110,116, 97,105,110,101,114,123,110, 97,109,101, 61,110,
+     44, 32, 98, 97,115,101, 61,109, 98, 97,115,101, 44, 32,101,
+    120,116,114, 97, 95, 98, 97,115,101,115, 61,112,125, 41, 10,
+    108,111, 99, 97,108, 32,102,116, 32, 61, 32,103,101,116,110,
+     97,109,101,115,112, 97, 99,101, 40, 99, 46,112, 97,114,101,
+    110,116, 41, 46, 46, 99, 46,111,114,105,103,105,110, 97,108,
+     95,110, 97,109,101, 10, 97,112,112,101,110,100, 95,103,108,
+    111, 98, 97,108, 95,116,121,112,101, 40,102,116, 44, 32, 99,
+     41, 10,101,110,100, 10,112,117,115,104, 40, 99, 41, 10, 99,
+     58,112, 97,114,115,101, 40,115,116,114,115,117, 98, 40, 98,
+     44, 50, 44,115,116,114,108,101,110, 40, 98, 41, 45, 49, 41,
+     41, 10,112,111,112, 40, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/class.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10, 83, 84, 82, 49, 32, 61, 32, 34, 92, 48, 48, 49, 34, 10,
+     83, 84, 82, 50, 32, 61, 32, 34, 92, 48, 48, 50, 34, 10, 83,
+     84, 82, 51, 32, 61, 32, 34, 92, 48, 48, 51, 34, 10, 83, 84,
+     82, 52, 32, 61, 32, 34, 92, 48, 48, 52, 34, 10, 82, 69, 77,
+     32, 61, 32, 34, 92, 48, 48, 53, 34, 10, 65, 78, 89, 32, 61,
+     32, 34, 40, 91, 92, 48, 48, 49, 45, 92, 48, 48, 53, 93, 41,
+     34, 10, 69, 83, 67, 49, 32, 61, 32, 34, 92, 48, 48, 54, 34,
+     10, 69, 83, 67, 50, 32, 61, 32, 34, 92, 48, 48, 55, 34, 10,
+     77, 65, 83, 75, 32, 61, 32,123, 10,123, 69, 83, 67, 49, 44,
+     32, 34, 92, 92, 39, 34,125, 44, 10,123, 69, 83, 67, 50, 44,
+     32, 39, 92, 92, 34, 39,125, 44, 10,123, 83, 84, 82, 49, 44,
+     32, 34, 39, 34,125, 44, 10,123, 83, 84, 82, 50, 44, 32, 39,
+     34, 39,125, 44, 10,123, 83, 84, 82, 51, 44, 32, 34, 37, 91,
+     37, 91, 34,125, 44, 10,123, 83, 84, 82, 52, 44, 32, 34, 37,
+     93, 37, 93, 34,125, 44, 10,123, 82, 69, 77, 32, 44, 32, 34,
+     37, 45, 37, 45, 34,125, 44, 10,125, 10,102,117,110, 99,116,
+    105,111,110, 32,109, 97,115,107, 32, 40,115, 41, 10,102,111,
+    114, 32,105, 32, 61, 32, 49, 44,103,101,116,110, 40, 77, 65,
+     83, 75, 41, 32,100,111, 10,115, 32, 61, 32,103,115,117, 98,
+     40,115, 44, 77, 65, 83, 75, 91,105, 93, 91, 50, 93, 44, 77,
+     65, 83, 75, 91,105, 93, 91, 49, 93, 41, 10,101,110,100, 10,
+    114,101,116,117,114,110, 32,115, 10,101,110,100, 10,102,117,
+    110, 99,116,105,111,110, 32,117,110,109, 97,115,107, 32, 40,
+    115, 41, 10,102,111,114, 32,105, 32, 61, 32, 49, 44,103,101,
+    116,110, 40, 77, 65, 83, 75, 41, 32,100,111, 10,115, 32, 61,
+     32,103,115,117, 98, 40,115, 44, 77, 65, 83, 75, 91,105, 93,
+     91, 49, 93, 44, 77, 65, 83, 75, 91,105, 93, 91, 50, 93, 41,
+     10,101,110,100, 10,114,101,116,117,114,110, 32,115, 10,101,
+    110,100, 10,102,117,110, 99,116,105,111,110, 32, 99,108,101,
+     97,110, 32, 40,115, 41, 10,108,111, 99, 97,108, 32, 99,111,
+    100,101, 32, 61, 32, 34,114,101,116,117,114,110, 32,102,117,
+    110, 99,116,105,111,110, 32, 40, 41, 92,110, 34, 32, 46, 46,
+     32,115, 32, 46, 46, 32, 34, 92,110, 32,101,110,100, 34, 10,
+    105,102, 32,110,111,116, 32,100,111,115,116,114,105,110,103,
+     40, 99,111,100,101, 41, 32,116,104,101,110, 10,114,101,116,
+    117,114,110, 32,110,105,108, 10,101,110,100, 10,105,102, 32,
+    102,108, 97,103,115, 91, 39, 67, 39, 93, 32,116,104,101,110,
+     10,114,101,116,117,114,110, 32,115, 10,101,110,100, 10,108,
+    111, 99, 97,108, 32, 83, 32, 61, 32, 34, 34, 10,115, 32, 61,
+     32,109, 97,115,107, 40,115, 41, 10,119,104,105,108,101, 32,
+     49, 32,100,111, 10,108,111, 99, 97,108, 32, 98, 44,101, 44,
+    100, 32, 61, 32,115,116,114,102,105,110,100, 40,115, 44, 65,
+     78, 89, 41, 10,105,102, 32, 98, 32,116,104,101,110, 10, 83,
+     32, 61, 32, 83, 46, 46,115,116,114,115,117, 98, 40,115, 44,
+     49, 44, 98, 45, 49, 41, 10,115, 32, 61, 32,115,116,114,115,
+    117, 98, 40,115, 44, 98, 43, 49, 41, 10,105,102, 32,100, 61,
+     61, 83, 84, 82, 49, 32,111,114, 32,100, 61, 61, 83, 84, 82,
+     50, 32,116,104,101,110, 10,101, 32, 61, 32,115,116,114,102,
+    105,110,100, 40,115, 44,100, 41, 10, 83, 32, 61, 32, 83, 32,
+     46, 46,100, 46, 46,115,116,114,115,117, 98, 40,115, 44, 49,
+     44,101, 41, 10,115, 32, 61, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10,101,108,115,101,105,102, 32,100,
+     61, 61, 83, 84, 82, 51, 32,116,104,101,110, 10,101, 32, 61,
+     32,115,116,114,102,105,110,100, 40,115, 44, 83, 84, 82, 52,
+     41, 10, 83, 32, 61, 32, 83, 46, 46,100, 46, 46,115,116,114,
+    115,117, 98, 40,115, 44, 49, 44,101, 41, 10,115, 32, 61, 32,
+    115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,101,
+    108,115,101,105,102, 32,100, 61, 61, 82, 69, 77, 32,116,104,
+    101,110, 10,115, 32, 61, 32,103,115,117, 98, 40,115, 44, 34,
+     91, 94, 92,110, 93, 42, 40, 92,110, 63, 41, 34, 44, 34, 37,
+     49, 34, 44, 49, 41, 10,101,110,100, 10,101,108,115,101, 10,
+     83, 32, 61, 32, 83, 46, 46,115, 10, 98,114,101, 97,107, 10,
+    101,110,100, 10,101,110,100, 10, 83, 32, 61, 32,103,115,117,
+     98, 40, 83, 44, 34, 91, 32, 92,116, 93, 43, 34, 44, 34, 32,
+     34, 41, 10, 83, 32, 61, 32,103,115,117, 98, 40, 83, 44, 34,
+     91, 32, 92,116, 93, 42, 92,110, 91, 32, 92,116, 93, 42, 34,
+     44, 34, 92,110, 34, 41, 10, 83, 32, 61, 32,103,115,117, 98,
+     40, 83, 44, 34, 92,110, 43, 34, 44, 34, 92,110, 34, 41, 10,
+     83, 32, 61, 32,117,110,109, 97,115,107, 40, 83, 41, 10,114,
+    101,116,117,114,110, 32, 83, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/clean.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,102,117,110, 99,116,105,111,110, 32,112, 97,114,115,101,
+     95,101,120,116,114, 97, 40, 41, 10,102,111,114, 32,107, 44,
+    118, 32,105,110, 32,105,112, 97,105,114,115, 40, 95,101,120,
+    116,114, 97, 95,112, 97,114, 97,109,101,116,101,114,115, 32,
+    111,114, 32,123,125, 41, 32,100,111, 10,108,111, 99, 97,108,
+     32, 98, 44,101, 44,110, 97,109,101, 44,118, 97,108,117,101,
+     32, 61, 32,115,116,114,105,110,103, 46,102,105,110,100, 40,
+    118, 44, 32, 34, 94, 40, 91, 94, 61, 93, 41, 61, 40, 46, 42,
+     41, 36, 34, 41, 10,105,102, 32, 98, 32,116,104,101,110, 10,
+     95,101,120,116,114, 97, 95,112, 97,114, 97,109,101,116,101,
+    114,115, 91,110, 97,109,101, 93, 32, 61, 32,118, 97,108,117,
+    101, 10,101,108,115,101, 10, 95,101,120,116,114, 97, 95,112,
+     97,114, 97,109,101,116,101,114,115, 91,118, 93, 32, 61, 32,
+    116,114,117,101, 10,101,110,100, 10,101,110,100, 10,101,110,
+    100, 10,102,117,110, 99,116,105,111,110, 32,100,111,105,116,
+     32, 40, 41, 10,105,102, 32,110,111,116, 32,102,108, 97,103,
+    115, 46,110, 32,116,104,101,110, 10,105,102, 32,102,108, 97,
+    103,115, 46,102, 32,116,104,101,110, 10,102,108, 97,103,115,
+     46,110, 32, 61, 32,103,115,117, 98, 40,102,108, 97,103,115,
+     46,102, 44, 34, 37, 46, 46, 42, 36, 34, 44, 34, 34, 41, 10,
+     95, 44, 95, 44,102,108, 97,103,115, 46,110, 32, 61, 32,115,
+    116,114,105,110,103, 46,102,105,110,100, 40,102,108, 97,103,
+    115, 46,110, 44, 32, 34, 40, 91, 94, 47, 92, 92, 93, 42, 41,
+     36, 34, 41, 10,101,108,115,101, 10,101,114,114,111,114, 40,
+     34, 35,110,111, 32,112, 97, 99,107, 97,103,101, 32,110, 97,
+    109,101, 32,110,111,114, 32,105,110,112,117,116, 32,102,105,
+    108,101, 32,112,114,111,118,105,100,101,100, 34, 41, 10,101,
+    110,100, 10,101,110,100, 10,112, 97,114,115,101, 95,101,120,
+    116,114, 97, 40, 41, 10,105,102, 32,102,108, 97,103,115, 91,
+     39, 76, 39, 93, 32,116,104,101,110, 10,100,111,102,105,108,
+    101, 40,102,108, 97,103,115, 91, 39, 76, 39, 93, 41, 10,101,
+    110,100, 10,105,102, 32,110,111,116, 32,102,108, 97,103,115,
+     91, 39, 83, 39, 93, 32,116,104,101,110, 10, 95, 98, 97,115,
+    105, 99, 91, 39,115,116,114,105,110,103, 39, 93, 32, 61, 32,
+     39, 99,112,112,115,116,114,105,110,103, 39, 10, 95, 98, 97,
+    115,105, 99, 91, 39,115,116,100, 58, 58,115,116,114,105,110,
+    103, 39, 93, 32, 61, 32, 39, 99,112,112,115,116,114,105,110,
+    103, 39, 10, 95, 98, 97,115,105, 99, 95, 99,116,121,112,101,
+     46, 99,112,112,115,116,114,105,110,103, 32, 61, 32, 39, 99,
+    111,110,115,116, 32, 99,104, 97,114, 42, 39, 10,101,110,100,
+     10,108,111, 99, 97,108, 32,112, 32, 61, 32, 80, 97, 99,107,
+     97,103,101, 40,102,108, 97,103,115, 46,110, 44,102,108, 97,
+    103,115, 46,102, 41, 10,105,102, 32,102,108, 97,103,115, 46,
+    112, 32,116,104,101,110, 10,114,101,116,117,114,110, 10,101,
+    110,100, 10,105,102, 32,102,108, 97,103,115, 46,111, 32,116,
+    104,101,110, 10,108,111, 99, 97,108, 32,115,116, 44,109,115,
+    103, 32, 61, 32,119,114,105,116,101,116,111, 40,102,108, 97,
+    103,115, 46,111, 41, 10,105,102, 32,110,111,116, 32,115,116,
+     32,116,104,101,110, 10,101,114,114,111,114, 40, 39, 35, 39,
+     46, 46,109,115,103, 41, 10,101,110,100, 10,101,110,100, 10,
+    112, 58,100,101, 99,108,116,121,112,101, 40, 41, 10,105,102,
+     32,102,108, 97,103,115, 46, 80, 32,116,104,101,110, 10,112,
+     58,112,114,105,110,116, 40, 41, 10,101,108,115,101, 10,112,
+     58,112,114,101, 97,109, 98,108,101, 40, 41, 10,112, 58,115,
+    117,112, 99,111,100,101, 40, 41, 10,112, 58,114,101,103,105,
+    115,116,101,114, 40, 41, 10,112,117,115,104, 40,112, 41, 10,
+    112,111,115,116, 95,111,117,116,112,117,116, 95,104,111,111,
+    107, 40,112, 41, 10,112,111,112, 40, 41, 10,101,110,100, 10,
+    105,102, 32,102,108, 97,103,115, 46,111, 32,116,104,101,110,
+     10,119,114,105,116,101,116,111, 40, 41, 10,101,110,100, 10,
+    105,102, 32,110,111,116, 32,102,108, 97,103,115, 46, 80, 32,
+    116,104,101,110, 10,105,102, 32,102,108, 97,103,115, 46, 72,
+     32,116,104,101,110, 10,108,111, 99, 97,108, 32,115,116, 44,
+    109,115,103, 32, 61, 32,119,114,105,116,101,116,111, 40,102,
+    108, 97,103,115, 46, 72, 41, 10,105,102, 32,110,111,116, 32,
+    115,116, 32,116,104,101,110, 10,101,114,114,111,114, 40, 39,
+     35, 39, 46, 46,109,115,103, 41, 10,101,110,100, 10,112, 58,
+    104,101, 97,100,101,114, 40, 41, 10,119,114,105,116,101,116,
+    111, 40, 41, 10,101,110,100, 10,101,110,100, 10,101,110,100,
+    32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: ../../src/tolua/lua/doit.lua");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+
+  { /* begin embedded lua code */
+   int top = lua_gettop(tolua_S);
+   static unsigned char B[] = {
+    10,108,111, 99, 97,108, 32,101,114,114, 44,109,115,103, 32,
+     61, 32,112, 99, 97,108,108, 40,100,111,105,116, 41, 10,105,
+    102, 32,110,111,116, 32,101,114,114, 32,116,104,101,110, 10,
+    108,111, 99, 97,108, 32, 95, 44, 95, 44,108, 97, 98,101,108,
+     44,109,115,103, 32, 61, 32,115,116,114,102,105,110,100, 40,
+    109,115,103, 44, 34, 40, 46, 45, 58, 46, 45, 58, 37,115, 42,
+     41, 40, 46, 42, 41, 34, 41, 10,116,111,108,117, 97, 95,101,
+    114,114,111,114, 40,109,115,103, 44,108, 97, 98,101,108, 41,
+     10,112,114,105,110,116, 40,100,101, 98,117,103, 46,116,114,
+     97, 99,101, 98, 97, 99,107, 40, 41, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua: embedded Lua code 22");
+   lua_settop(tolua_S, top);
+  } /* end of embedded lua code */
+
+ tolua_endmodule(tolua_S);
+ return 1;
+}
+
+
+#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 501
+ TOLUA_API int luaopen_tolua (lua_State* tolua_S) {
+ return tolua_tolua_open(tolua_S);
+};
+#endif
+
Index: code/trunk/src/tolua/toluabind_orxonox.h
===================================================================
--- code/trunk/src/tolua/toluabind_orxonox.h	(revision 1755)
+++ code/trunk/src/tolua/toluabind_orxonox.h	(revision 1755)
@@ -0,0 +1,8 @@
+/*
+** Lua binding: tolua
+** Generated automatically by tolua++-1.0.92 on 09/10/08 00:32:21.
+*/
+
+/* Exported function */
+TOLUA_API int  tolua_tolua_open (lua_State* tolua_S);
+
Index: code/trunk/src/util/ArgReader.cc
===================================================================
--- code/trunk/src/util/ArgReader.cc	(revision 1754)
+++ 	(revision )
@@ -1,94 +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:
- *      Benjamin Knecht <beni_at_orxonox.net>
- *
- */
-
-/**
- @file  ArgReader.cc
- @brief Argument Reader
- */
-
-#include "ArgReader.h"
-#include "SubString.h"
-
-ArgReader::ArgReader(int argc, char **argv)
-{
-  failure_ = false;
-  errorString_ = "";
-  CmdLineArg arg;
-
-  int i = 1;
-  while (i < argc)
-  {
-    if (argv[i][0] == '-' && argv[i][1] == '-') // name
-    {
-      if (argv[i][2] == '\0')
-      {
-        failure_ = true;
-        errorString_ += "Expected word after \"--\".\n";
-      }
-      arg.bChecked_ = false;
-      arg.name_ = argv[i] + 2;
-      arg.value_ = "";
-      arguments_.push_back(arg);
-    }
-    else // value
-    {
-      if (arguments_.size() == 0)
-      {
-        failure_ = true;
-        errorString_ += "Expected \"--\" in command line arguments.\n";
-        arg.bChecked_ = false;
-        arg.name_ = "";
-        arg.value_ = "";
-        arguments_.push_back(arg);
-      }
-
-      if (arguments_.back().value_ != "")
-        arguments_.back().value_ += " " + std::string(argv[i]);
-      else
-        arguments_.back().value_ = argv[i];
-    }
-    ++i;
-  }
-}
-
-bool ArgReader::errorHandling()
-{
-  bool argumentsChecked = true;
-  for (unsigned int i = 1; i < arguments_.size(); ++i)
-    argumentsChecked &= arguments_[i].bChecked_;
-
-  if (!argumentsChecked)
-    errorString_ += "Not all arguments could be matched.\n";
-
-  return !argumentsChecked || failure_;
-}
-
-const std::string& ArgReader::getErrorString()
-{
-  return errorString_;
-}
Index: code/trunk/src/util/ArgReader.h
===================================================================
--- code/trunk/src/util/ArgReader.h	(revision 1754)
+++ 	(revision )
@@ -1,116 +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:
- *      Benjamin Knecht <beni_at_orxonox.net>
- *
- */
-
-/**
- @file  Argreader.h
- @brief reads arguments
- @author Benjamin Knecht <beni_at_orxonox.net>
- */
-
-#ifndef _ArgReader_H__
-#define _ArgReader_H__
-
-#include "UtilPrereqs.h"
-
-#include <string>
-#include <vector>
-#include "Convert.h"
-
-struct _UtilExport CmdLineArg
-{
-  std::string name_;
-  std::string value_;
-  bool bChecked_;
-};
-
-class _UtilExport ArgReader
-{
-  public:
-    ArgReader(int argc, char **argv);
-    template <class T>
-    void checkArgument(std::string option, T* value, bool must = false);
-    bool errorHandling();
-    const std::string& getErrorString();
-
-  private:
-    std::vector<CmdLineArg> arguments_;
-    bool failure_;
-    std::string errorString_;
-};
-
-template <class T>
-void ArgReader::checkArgument(std::string option, T* value, bool must)
-{
-  unsigned int iArg = 0;
-  while (iArg < arguments_.size())
-  {
-    if (arguments_[iArg].name_ == option)
-      break;
-    ++iArg;
-  }
-  if (iArg == arguments_.size())
-  {
-    if (must)
-    {
-      failure_ = true;
-      errorString_ += "Cannot find mandatory argument \"" + option + "\"\n";
-      return;
-    }
-    else
-      return;
-  }
-
-  arguments_[iArg].bChecked_ = true;
-
-  if (!convertValue(value, arguments_[iArg].value_))
-  {
-    failure_ = true;
-    errorString_ += "Cannot convert argument value for option \"" + option + "\"\n";
-  }
-}
-
-template <>
-void ArgReader::checkArgument(std::string option, bool* value, bool must)
-{
-  // for type bool, only check whether the option was set or not
-  unsigned int iArg = 0;
-  while (iArg < arguments_.size())
-  {
-    if (arguments_[iArg].name_ == option)
-    {
-      arguments_[iArg].bChecked_ = true;
-      *value = true;
-      break;
-    }
-    ++iArg;
-  }
-  if (iArg == arguments_.size())
-    *value = false;
-}
-
-#endif /* _ArgReader_H__ */
Index: code/trunk/src/util/CMakeLists.txt
===================================================================
--- code/trunk/src/util/CMakeLists.txt	(revision 1754)
+++ code/trunk/src/util/CMakeLists.txt	(revision 1755)
@@ -1,4 +1,3 @@
 SET(UTIL_SRC_FILES
-  ArgReader.cc
   Clipboard.cc
   Error.cc
Index: code/trunk/src/util/CRC32.h
===================================================================
--- code/trunk/src/util/CRC32.h	(revision 1754)
+++ code/trunk/src/util/CRC32.h	(revision 1755)
@@ -30,11 +30,13 @@
 #define _Util_CRC_H__
 
+#include "UtilPrereqs.h"
 #include <iostream>
+#include "Integers.h"
 
 #define UTIL_CRC32POLY 0x04C11DB7 /* CRC-32 Polynom */
 
-void calcCRCBit(uint32_t &crc32, int bit);
+_UtilExport void calcCRCBit(uint32_t &crc32, int bit);
 
-uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
+_UtilExport uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
 
 
Index: code/trunk/src/util/Convert.h
===================================================================
--- code/trunk/src/util/Convert.h	(revision 1754)
+++ code/trunk/src/util/Convert.h	(revision 1755)
@@ -643,4 +643,27 @@
 };
 
+
+///////////////////////////
+// Static type detection //
+///////////////////////////
+
+/**
+    Template class that determines whether type T converts implicitly to type U.
+@note
+    This allows to detect type conversion at compile time.
+    From 'Modern C++ Design' (Alexandrescu 2001).
+*/
+template <class T, class U>
+class StaticConversion
+{
+    class Small { char dummy[1]; };
+    class Big   { char dummy[1024]; };
+    static Small Test(U);
+    static Big   Test(...);
+    static T MakeT();
+public:
+    enum { exists = sizeof(Test(MakeT())) == sizeof(Small) };
+};
+
 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
 #pragma warning(pop)
Index: code/trunk/src/util/Integers.h
===================================================================
--- code/trunk/src/util/Integers.h	(revision 1755)
+++ code/trunk/src/util/Integers.h	(revision 1755)
@@ -0,0 +1,55 @@
+/*
+ *   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
+    Defines fixed with integers
+ */
+
+#ifndef _Integers_H__
+#define _Integers_H__
+
+#include "OrxonoxPlatform.h"
+
+/* Define fixed with integers
+ * Note: This is not in a namespace to make it available everywhere!*/
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+typedef __int8            int8_t;
+typedef __int16           int16_t;
+typedef __int32           int32_t;
+typedef __int64           int64_t;
+typedef unsigned __int8   uint8_t;
+typedef unsigned __int16  uint16_t;
+typedef unsigned __int32  uint32_t;
+typedef unsigned __int64  uint64_t;
+#elif ORXONOX_COMPILER == ORXONOX_COMPILER_GCC
+# include "inttypes.h"
+#endif
+
+#endif /* _Integers_H__ */
Index: code/trunk/src/util/OrxonoxPlatform.h
===================================================================
--- code/trunk/src/util/OrxonoxPlatform.h	(revision 1754)
+++ code/trunk/src/util/OrxonoxPlatform.h	(revision 1755)
@@ -25,10 +25,13 @@
  *      Reto Grieder
  *
+ *   Original code: OgrePlatform.h, licensed under the LGPL. The code
+ *   has changed quite a bit however.
+ *
  */
 
 /**
  @file
- @brief Various constants for compiler, architecture and platform. It's a mere
-        copy of the file found in the Ogre source code (OgrePlatform.h).
+ @brief
+    Various constants for compiler, architecture and platform.
  */
 
@@ -36,6 +39,6 @@
 #define _OrxonoxPlatform_H__
 
-/* Initial platform/compiler-related stuff to set.
-*/
+/* Initial platform/compiler-related stuff to set. */
+
 #define ORXONOX_PLATFORM_WIN32 1
 #define ORXONOX_PLATFORM_LINUX 2
@@ -52,6 +55,7 @@
 #define ORXONOX_ARCHITECTURE_64 2
 
-/* Finds the compiler type and version.
-*/
+
+/* Finds the compiler type and version. */
+
 #if defined( _MSC_VER )
 #  define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC
@@ -73,4 +77,5 @@
 #endif
 
+
 /* See if we can use __forceinline or if we need to use __inline instead */
 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
@@ -87,16 +92,13 @@
 
 /* Finds the current platform */
-
 #if defined( __WIN32__ ) || defined( _WIN32 )
 #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_WIN32
-
 #elif defined( __APPLE_CC__)
 #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_APPLE
-
 #else
 #  define ORXONOX_PLATFORM ORXONOX_PLATFORM_LINUX
 #endif
 
-    /* Find the arch type */
+/* Find the arch type */
 #if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
 #  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64
@@ -105,26 +107,43 @@
 #endif
 
-// For generating compiler warnings - should work on any compiler
-// As a side note, if you start your message with 'Warning: ', the MSVC
-// IDE actually does catch a warning :)
-// FIXME: Try this on linux box. Doesn't work with msvc
-//#define ORXONOX_QUOTE_INPLACE(x) # x
-//#define ORXONOX_QUOTE(x) ORXONOX_QUOTE_INPLACE(x)
-//#define ORXONOX_WARN( x )  message( __FILE__ "(" QUOTE( __LINE__ ) ") : " x "\n" )
-
-//----------------------------------------------------------------------------
-// Windows Settings
+/* Try to define function information */
+#ifndef __FUNCTIONNAME__
+#  if ORXONOX_COMPILER == ORXONOX_COMPILER_BORL
+#    define __FUNCTIONNAME__ __FUNC__
+#  elif ORXONOX_COMPILER == ORXONOX_COMPILER_GNUC
+#    define __FUNCTIONNAME__ __PRETTY_FUNCTION__
+#  elif ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#    define __FUNCTIONNAME__ __FUNCTION__
+#  else
+#    define __FUNCTIONNAME__
+#  endif
+#endif
+
+/* Determine whether we're building in debug mode */
+#if defined(_DEBUG) || defined(DEBUG)
+#  define ORXONOX_DEBUG_MODE 1
+#else
+#  define ORXONOX_DEBUG_MODE 0
+#endif
+
+/* Define configurable floating point type */
+namespace orxonox
+{
+#ifdef ORXONOX_DOUBLE_PRECISION
+    typedef double Real;
+#else
+    typedef float  Real;
+#endif
+}
+
+
+
+/*---------------------------------
+ * Windows Settings
+ *-------------------------------*/
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
-
-// Win32 compilers use _DEBUG for specifying debug builds.
-#  ifdef _DEBUG
-#    define ORXONOX_DEBUG_MODE 1
-#  else
-#    define ORXONOX_DEBUG_MODE 0
-#  endif
-
-// Disable unicode support on MingW at the moment, poorly supported in stdlibc++
-// STLPORT fixes this though so allow if found
-// MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h
+/* Disable unicode support on MingW at the moment, poorly supported in stdlibc++
+ * STLPORT fixes this though so allow if found
+ * MinGW C++ Toolkit supports unicode and sets the define __MINGW32_TOOLKIT_UNICODE__ in _mingw.h */
 #  if defined( __MINGW32__ ) && !defined(_STLPORT_VERSION)
 #    include<_mingw.h>
@@ -137,146 +156,108 @@
 #    define ORXONOX_UNICODE_SUPPORT 1
 #  endif
-
 #endif /* Platform Win32 */
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// Linux/Apple Settings
+
+
+/*---------------------------------
+ * Linux/Apple Settings
+ *-------------------------------*/
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_LINUX || ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
 
-
-// A quick define to overcome different names for the same function
+/* A quick define to overcome different names for the same function */
 #  define stricmp strcasecmp
 
-// Unlike the Win32 compilers, Linux compilers seem to use DEBUG for when
-// specifying a debug build.
-// (??? this is wrong, on Linux debug builds aren't marked in any way unless
-// you mark it yourself any way you like it -- zap ???)
-#  ifdef DEBUG
-#    define ORXONOX_DEBUG_MODE 1
-#  else
-#    define ORXONOX_DEBUG_MODE 0
-#  endif
-
-/* FIXME: Check what this actually is and whether we need it or not
+/* TODO: Check what this actually is and whether we need it or not */
+#if 0
 #  if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
 #    define ORXONOX_PLATFORM_LIB "OrxonoxPlatform.bundle"
 #  else
-// ORXONOX_PLATFORM_LINUX
+/* ORXONOX_PLATFORM_LINUX */
 #    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"
 #  endif
-*/
-
-// Always enable unicode support for the moment
-// Perhaps disable in old versions of gcc if necessary
+#endif
+
+/* Always enable unicode support for the moment
+ * Perhaps disable in old versions of gcc if necessary */
 #  define ORXONOX_UNICODE_SUPPORT 1
 
 #endif /* Patform Linux/Apple */
 
-//For apple, we always have a custom config.h file
+
+/*---------------------------------
+ * Apple Settings
+ *-------------------------------*/
+/* For apple, we always have a custom config.h file */
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
 #  include "config.h"
 #endif
 
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// Endian Settings
-// check for BIG_ENDIAN config flag, set ORXONOX_ENDIAN correctly
-#ifdef ORXONOX_CONFIG_BIG_ENDIAN
-#  define ORXONOX_ENDIAN ORXONOX_ENDIAN_BIG
-#else
-#  define ORXONOX_ENDIAN ORXONOX_ENDIAN_LITTLE
-#endif
-
-//-----------------------------------------------------------------------
-// fixed width integers
-//-----------------------------------------------------------------------
+
+/*---------------------------------
+ * Visual Studio Settings
+ *-------------------------------*/
 #if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
-typedef __int8            int8_t;
-typedef __int16           int16_t;
-typedef __int32           int32_t;
-typedef __int64           int64_t;
-typedef unsigned __int8   uint8_t;
-typedef unsigned __int16  uint16_t;
-typedef unsigned __int32  uint32_t;
-typedef unsigned __int64  uint64_t;
-#else
-# include "inttypes.h"
-#endif
-
-namespace orxonox {
-#ifdef ORXONOX_DOUBLE_PRECISION
-typedef double Real;
-#else
-typedef float Real;
-#endif
-}
-
-
-#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
-// Turn off warnings generated by long std templates
-// This warns about truncation to 255 characters in debug/browse info
-//#   pragma warning (disable : 4786)
-
-// Turn off warnings generated by long std templates
-// This warns about truncation to 255 characters in debug/browse info
-//#   pragma warning (disable : 4503)
-
-// disable: conversion from 'double' to 'float', possible loss of data
-// disable: conversion from 'ogg_int64_t' to 'long', possible loss of data
-// This has been dealt with in base_properties of the solution since the
-// warning primarily occurs in library header files (which are mostly
-// included before OrxonoxPlatform.h is)
-//#   pragma warning (disable : 4244)
-
-// disable: "conversion from 'size_t' to 'unsigned int', possible loss of data
-//#   pragma warning (disable : 4267)
-
-// disable: "truncation from 'double' to 'float'
-//#   pragma warning (disable : 4305)
-
-// set to level 4: "<type> needs to have dll-interface to be used by clients'
-// Happens on STL member variables which are not public therefore is ok
+/* Turn off warnings generated by long std templates
+ * This warns about truncation to 255 characters in debug/browse info */
+/*#   pragma warning (disable : 4786)*/
+
+/* Turn off warnings generated by long std templates
+ * This warns about truncation to 255 characters in debug/browse info */
+/*#   pragma warning (disable : 4503)*/
+
+/* disable: conversion from 'double' to 'float', possible loss of data
+ * disable: conversion from 'ogg_int64_t' to 'long', possible loss of data
+ * This has been dealt with in base_properties of the solution since the
+ * warning primarily occurs in library header files (which are mostly
+ * included before OrxonoxPlatform.h is) */
+/*#   pragma warning (disable : 4244)*/
+
+/* disable: "conversion from 'size_t' to 'unsigned int', possible loss of data */
+/*#   pragma warning (disable : 4267)*/
+
+/* disable: "truncation from 'double' to 'float' */
+/*#   pragma warning (disable : 4305)*/
+
+/* set to level 4: "<type> needs to have dll-interface to be used by clients'
+ * Happens on STL member variables which are not public therefore is ok */
 #   pragma warning (disable : 4251)
 
-// disable: 'MultiTypeString' : multiple assignment operators specified
-// Used in MultiType and works fine so far
-//#   pragma warning (disable : 4522)
-
-// disable: "non dll-interface class used as base for dll-interface class"
-// Happens when deriving from Singleton because bug in compiler ignores
-// template export
-//#   pragma warning (disable : 4275)
-
-// disable: "C++ Exception Specification ignored"
-// This is because MSVC 6 did not implement all the C++ exception
-// specifications in the ANSI C++ draft.
-//#   pragma warning( disable : 4290 )
-
-// disable: "no suitable definition provided for explicit template
-// instantiation request" Occurs in VC7 for no justifiable reason on all
-// #includes of Singleton
-//#   pragma warning( disable: 4661)
-
-// disable: deprecation warnings when using CRT calls in VC8
-// These show up on all C runtime lib code in VC8, disable since they clutter
-// the warnings with things we may not be able to do anything about (e.g.
-// generated code from nvparse etc). I doubt very much that these calls
-// will ever be actually removed from VC anyway, it would break too much code.
-//#	pragma warning( disable: 4996)
-
-// disable: "conditional expression constant", always occurs on
-// ORXONOX_MUTEX_CONDITIONAL when no threading enabled
-//#   pragma warning (disable : 201)
-
-
-// Define the english written operators like and, or, xor
+/* disable: 'MultiTypeString' : multiple assignment operators specified
+ * Used in MultiType and works fine so far */
+/*#   pragma warning (disable : 4522)*/
+
+/* disable: "non dll-interface class used as base for dll-interface class"
+ * Happens when deriving from Singleton because bug in compiler ignores
+ * template export */
+/*#   pragma warning (disable : 4275)*/
+
+/* disable: "C++ Exception Specification ignored"
+ * This is because MSVC 6 did not implement all the C++ exception
+ * specifications in the ANSI C++ draft. */
+/*#   pragma warning( disable : 4290 )*/
+
+/* disable: "no suitable definition provided for explicit template
+ * instantiation request" Occurs in VC7 for no justifiable reason on all
+ * #includes of Singleton */
+/*#   pragma warning( disable: 4661)*/
+
+/* disable: deprecation warnings when using CRT calls in VC8
+ * These show up on all C runtime lib code in VC8, disable since they clutter
+ * the warnings with things we may not be able to do anything about (e.g.
+ * generated code from nvparse etc). I doubt very much that these calls
+ * will ever be actually removed from VC anyway, it would break too much code. */
+/*# pragma warning( disable: 4996)*/
+
+/* disable: "conditional expression constant", always occurs on
+ * ORXONOX_MUTEX_CONDITIONAL when no threading enabled */
+/*#   pragma warning (disable : 201)*/
+
+
+/* Define the english written operators like and, or, xor */
 #include <iso646.h>
 
+/* include visual leak detector to search for memory leaks */
+/* #include <vld.h> */
+
 #endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */
 
-// include visual leak detector to search for memory leaks
-//#include <vld.h>
-
 #endif /* _OrxonoxPlatform_H__ */
Index: code/trunk/src/util/Sleep.h
===================================================================
--- code/trunk/src/util/Sleep.h	(revision 1754)
+++ code/trunk/src/util/Sleep.h	(revision 1755)
@@ -28,32 +28,46 @@
 
 /**
- @file  Sleep.h
- @brief Macros for using sleep() and usleep() under windows
+ @file
+ @brief
+    Functions for using sleep() and usleep() under windows.
  */
 
-#include "UtilPrereqs.h"
+#ifndef _Sleep_H__
+#define _Sleep_H__
+
+#include "OrxonoxPlatform.h"
 
 #if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
-#  ifndef WIN32_LEAN_AND_MEAN
-#    define WIN32_LEAN_AND_MEAN
-#  endif
-#  include <windows.h>
+
+#ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+#endif
+#include <windows.h>
+
 inline void usleep(DWORD dwMicroseconds)
 {
   Sleep(dwMicroseconds / 1000);
 }
+
 inline void msleep(DWORD dwMilliseconds)
 {
   Sleep(dwMilliseconds);
 }
+
 inline void sleep(DWORD dwSeconds)
 {
   Sleep(dwSeconds * 1000);
 }
-#else
-#  include <unistd.h>
+
+#else /* Linux/Apple */
+
+#include <unistd.h>
+
 inline void msleep(unsigned long msec)
 {
   usleep(msec * 1000);
 }
+
 #endif
+
+#endif /* _Sleep_H__ */
Index: code/trunk/src/util/SubString.h
===================================================================
--- code/trunk/src/util/SubString.h	(revision 1754)
+++ code/trunk/src/util/SubString.h	(revision 1755)
@@ -131,4 +131,6 @@
   /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
   inline const std::string& getString(unsigned int i) const { return (*this)[i]; };
+  /** @brief Returns all Strings as std::vector */
+  inline const std::vector<std::string>& getAllStrings() const { return this->strings; }
   /** @brief Returns true if the token is in safemode. @param i the i'th token */
   inline bool isInSafemode(unsigned int i) const { return this->bInSafemode[i]; }
Index: code/trunk/visual_studio/base_properties.vsprops
===================================================================
--- code/trunk/visual_studio/base_properties.vsprops	(revision 1754)
+++ code/trunk/visual_studio/base_properties.vsprops	(revision 1755)
@@ -8,5 +8,5 @@
 	<Tool
 		Name="VCCLCompilerTool"
-		AdditionalIncludeDirectories="&quot;$(RootDir)&quot;;&quot;$(RootDir)src&quot;;&quot;$(RootDir)src\orxonox&quot;;&quot;$(RootDir)src\tolua&quot;;&quot;$(RootDir)src\ois&quot;;&quot;$(LibDir)ogre-1.4.9\OgreMain\include&quot;;&quot;$(LibDir)boost-1.35.0&quot;;&quot;$(LibDir)enet-1.2\include&quot;;&quot;$(LibDir)libogg-1.1.3\include&quot;;&quot;$(LibDir)libvorbis-1.2.0\include&quot;;&quot;$(LibDir)lua-5.1.3\src&quot;;&quot;$(LibDir)openal-1.1\include&quot;;&quot;$(LibDir)openal-1.1\alut\include&quot;;&quot;$(LibDir)tcl-8.5.\generic&quot;;&quot;$(LibDir)zlib-1.2.3&quot;"
+		AdditionalIncludeDirectories="&quot;$(RootDir)&quot;;&quot;$(RootDir)src&quot;;&quot;$(RootDir)src\orxonox&quot;;&quot;$(RootDir)src\tolua&quot;;&quot;$(RootDir)src\ois&quot;;&quot;$(LibDir)ogre-1.4.9\OgreMain\include&quot;;&quot;$(LibDir)boost-1.35.0&quot;;&quot;$(LibDir)cegui-0.6.1\include&quot;;&quot;$(LibDir)cegui-0.6.1\ScriptingModules\CEGUILua\LuaScriptModule\include&quot;;&quot;$(LibDir)enet-1.2\include&quot;;&quot;$(LibDir)libogg-1.1.3\include&quot;;&quot;$(LibDir)libvorbis-1.2.0\include&quot;;&quot;$(LibDir)lua-5.1.3\src&quot;;&quot;$(LibDir)openal-1.1\include&quot;;&quot;$(LibDir)openal-1.1\alut\include&quot;;&quot;$(LibDir)tcl-8.5.\generic&quot;;&quot;$(LibDir)zlib-1.2.3&quot;"
 		PreprocessorDefinitions="WIN32;__WIN32__;_WIN32;BOOST_ALL_DYN_LINK;OIS_DYNAMIC_LIB; ZLIB_WINAPI"
 		WarningLevel="3"
@@ -45,5 +45,5 @@
 	<UserMacro
 		Name="LibDir"
-		Value="$(RootDir)..\lib_src\"
+		Value="$(RootDir)..\lib_precompiled\include\"
 	/>
 </VisualStudioPropertySheet>
Index: code/trunk/visual_studio/core_properties.vsprops
===================================================================
--- code/trunk/visual_studio/core_properties.vsprops	(revision 1754)
+++ code/trunk/visual_studio/core_properties.vsprops	(revision 1755)
@@ -13,5 +13,5 @@
 	<Tool
 		Name="VCLinkerTool"
-		AdditionalDependencies="OgreMain$(CSS).lib lua-5.1.3$(CS).lib tcl85t.lib"
+		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib lua-5.1.3$(CS).lib"
 	/>
 </VisualStudioPropertySheet>
Index: code/trunk/visual_studio/orxonox_properties.vsprops
===================================================================
--- code/trunk/visual_studio/orxonox_properties.vsprops	(revision 1754)
+++ code/trunk/visual_studio/orxonox_properties.vsprops	(revision 1755)
@@ -9,5 +9,5 @@
 		Name="VCCLCompilerTool"
 		AdditionalOptions="/MP2"
-		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;OGRE_GUIRENDERER_EXPORTS"
 		UsePrecompiledHeader="2"
 		PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
@@ -15,5 +15,5 @@
 	<Tool
 		Name="VCLinkerTool"
-		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet-1.2$(CS).lib zlib-1.2.3$(CS).lib"
+		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib enet-1.2$(CS).lib zlib-1.2.3$(CS).lib CEGUILua$(CS).lib CEGUIBase$(CS).lib lua-5.1.3$(CS).lib"
 		OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
 		IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD"
Index: code/trunk/visual_studio/orxonox_vc8.sln
===================================================================
--- code/trunk/visual_studio/orxonox_vc8.sln	(revision 1754)
+++ code/trunk/visual_studio/orxonox_vc8.sln	(revision 1755)
@@ -10,4 +10,26 @@
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua", "vc8\tolua.vcproj", "{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
 EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua_gen", "vc8\tolua_gen.vcproj", "{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}"
+	ProjectSection(ProjectDependencies) = postProject
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua_app", "vc8\tolua_app.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
+	ProjectSection(ProjectDependencies) = postProject
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0} = {71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "vc8\util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "vc8\core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}"
+	ProjectSection(ProjectDependencies) = postProject
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E} = {9CC704CB-4956-4479-BDEC-57CBC03F700E}
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
+	EndProjectSection
+EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "audio", "vc8\audio.vcproj", "{4733BD1A-E04C-458D-8BFB-5010250EA497}"
 	ProjectSection(ProjectDependencies) = postProject
@@ -16,37 +38,18 @@
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tolua_app", "vc8\tolua_app.vcproj", "{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
-	ProjectSection(ProjectDependencies) = postProject
-		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "util", "vc8\util.vcproj", "{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
-	ProjectSection(ProjectDependencies) = postProject
-		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
-	EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "core", "vc8\core.vcproj", "{271715F3-5B90-4110-A552-70C788084A86}"
-	ProjectSection(ProjectDependencies) = postProject
-		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
-		{53C56131-E2AA-4A27-B460-7AC05D61A0E6} = {53C56131-E2AA-4A27-B460-7AC05D61A0E6}
-		{A0724246-CB7C-420B-BCF0-68EF205AFE34} = {A0724246-CB7C-420B-BCF0-68EF205AFE34}
-		{9CC704CB-4956-4479-BDEC-57CBC03F700E} = {9CC704CB-4956-4479-BDEC-57CBC03F700E}
-		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
-		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
-	EndProjectSection
-EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "network", "vc8\network.vcproj", "{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
 	ProjectSection(ProjectDependencies) = postProject
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
 		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
-		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "orxonox", "vc8\orxonox.vcproj", "{0B6C5CFD-F91B-432A-80A3-2610F61E060B}"
 	ProjectSection(ProjectDependencies) = postProject
-		{4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497}
-		{35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68}
-		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626} = {35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}
 		{F101C2F0-1CB9-4A57-827B-6C399A99B28F} = {F101C2F0-1CB9-4A57-827B-6C399A99B28F}
 		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68} = {35575B59-E1AE-40E8-89C4-2862B5B09B68}
+		{4733BD1A-E04C-458D-8BFB-5010250EA497} = {4733BD1A-E04C-458D-8BFB-5010250EA497}
 	EndProjectSection
 EndProject
@@ -73,8 +76,8 @@
 		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.ActiveCfg = Release|Win32
 		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.Build.0 = Release|Win32
-		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.Build.0 = Debug|Win32
-		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.ActiveCfg = Release|Win32
-		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.Build.0 = Release|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Debug|Win32.ActiveCfg = Debug|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Debug|Win32.Build.0 = Debug|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Release|Win32.ActiveCfg = Release|Win32
+		{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}.Release|Win32.Build.0 = Release|Win32
 		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Debug|Win32.ActiveCfg = Debug|Win32
 		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Debug|Win32.Build.0 = Debug|Win32
@@ -89,4 +92,8 @@
 		{271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.ActiveCfg = Release|Win32
 		{271715F3-5B90-4110-A552-70C788084A86}.Release|Win32.Build.0 = Release|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.ActiveCfg = Debug|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Debug|Win32.Build.0 = Debug|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.ActiveCfg = Release|Win32
+		{4733BD1A-E04C-458D-8BFB-5010250EA497}.Release|Win32.Build.0 = Release|Win32
 		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.ActiveCfg = Debug|Win32
 		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Debug|Win32.Build.0 = Debug|Win32
Index: code/trunk/visual_studio/tolua_app_properties.vsprops
===================================================================
--- code/trunk/visual_studio/tolua_app_properties.vsprops	(revision 1754)
+++ code/trunk/visual_studio/tolua_app_properties.vsprops	(revision 1755)
@@ -8,5 +8,6 @@
 	<Tool
 		Name="VCCLCompilerTool"
-		DisableSpecificWarnings="4996"
+		PreprocessorDefinitions="TOLUA_STATIC_BUILD"
+		CompileAs="1"
 	/>
 	<Tool
Index: code/trunk/visual_studio/tolua_gen_properties.vsprops
===================================================================
--- code/trunk/visual_studio/tolua_gen_properties.vsprops	(revision 1755)
+++ code/trunk/visual_studio/tolua_gen_properties.vsprops	(revision 1755)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_gen_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		CompileAs="1"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="lua-5.1.3$(CS).lib"
+		OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
+	/>
+</VisualStudioPropertySheet>
Index: code/trunk/visual_studio/tolua_properties.vsprops
===================================================================
--- code/trunk/visual_studio/tolua_properties.vsprops	(revision 1754)
+++ code/trunk/visual_studio/tolua_properties.vsprops	(revision 1755)
@@ -8,5 +8,11 @@
 	<Tool
 		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_SHARED_BUILD"
+		CompileAs="2"
 		DisableSpecificWarnings="4996"
 	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="lua-5.1.3$(CS).lib"
+	/>
 </VisualStudioPropertySheet>
Index: code/trunk/visual_studio/util_properties.vsprops
===================================================================
--- code/trunk/visual_studio/util_properties.vsprops	(revision 1754)
+++ code/trunk/visual_studio/util_properties.vsprops	(revision 1755)
@@ -8,4 +8,5 @@
 	<Tool
 		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
 		PreprocessorDefinitions="UTIL_SHARED_BUILD"
 	/>
Index: code/trunk/visual_studio/vc8/core.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/core.vcproj	(revision 1754)
+++ code/trunk/visual_studio/vc8/core.vcproj	(revision 1755)
@@ -149,4 +149,8 @@
 			>
 			<File
+				RelativePath="..\..\src\core\Clock.cc"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\ConfigFileManager.cc"
 				>
@@ -161,4 +165,12 @@
 			</File>
 			<File
+				RelativePath="..\..\src\core\Exception.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\GameState.cc"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\Language.cc"
 				>
@@ -169,4 +181,8 @@
 			</File>
 			<File
+				RelativePath="..\..\src\core\RootGameState.cc"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\Script.cc"
 				>
@@ -178,4 +194,15 @@
 					RelativePath="..\..\src\core\tolua\tolua.pkg"
 					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(OutDir)\tolua_app_d.exe&quot; -n Core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\core\Script.h; $(RootDir)\src\core\CommandExecutor.h"
+							Outputs="$(RootDir)\src\core\tolua\tolua_bind.cc; $(RootDir)\src\core\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
 					<FileConfiguration
 						Name="Release|Win32"
@@ -184,5 +211,5 @@
 							Name="VCCustomBuildTool"
 							Description="Generating tolua bind files..."
-							CommandLine="&quot;$(OutDir)\tolua_app.exe&quot; -n core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg"
+							CommandLine="&quot;$(OutDir)\tolua_app.exe&quot; -n Core -o ../../src/core/tolua/tolua_bind.cc -H ../../src/core/tolua/tolua_bind.h ../../src/core/tolua/tolua.pkg&#x0D;&#x0A;"
 							Outputs="$(RootDir)\src\core\tolua\tolua_bind.cc; $(RootDir)\src\core\tolua\tolua_bind.h"
 						/>
@@ -210,4 +237,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\core\CommandLine.cc"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\core\ConsoleCommand.cc"
 					>
@@ -282,4 +313,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\core\input\ExtendedInputState.cc"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\core\input\HalfAxis.cc"
 					>
@@ -303,4 +338,8 @@
 				<File
 					RelativePath="..\..\src\core\input\KeyDetector.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\SimpleInputState.cc"
 					>
 				</File>
@@ -333,4 +372,8 @@
 			>
 			<File
+				RelativePath="..\..\src\core\Clock.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\ConfigFileManager.h"
 				>
@@ -353,4 +396,12 @@
 			</File>
 			<File
+				RelativePath="..\..\src\core\Exception.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\GameState.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\Language.h"
 				>
@@ -361,12 +412,12 @@
 			</File>
 			<File
+				RelativePath="..\..\src\core\RootGameState.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\core\Script.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\core\Script_clean.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\core\Super.h"
 				>
@@ -384,4 +435,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\core\input\ExtendedInputState.h"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\core\input\HalfAxis.h"
 					>
@@ -404,4 +459,8 @@
 				</File>
 				<File
+					RelativePath="..\..\src\core\input\InputState.h"
+					>
+				</File>
+				<File
 					RelativePath="..\..\src\core\input\KeyBinder.h"
 					>
@@ -411,4 +470,8 @@
 					>
 				</File>
+				<File
+					RelativePath="..\..\src\core\input\SimpleInputState.h"
+					>
+				</File>
 			</Filter>
 			<Filter
@@ -433,4 +496,8 @@
 				<File
 					RelativePath="..\..\src\core\CommandExecutor.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandLine.h"
 					>
 				</File>
Index: code/trunk/visual_studio/vc8/ois.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/ois.vcproj	(revision 1754)
+++ code/trunk/visual_studio/vc8/ois.vcproj	(revision 1755)
@@ -43,4 +43,5 @@
 			<Tool
 				Name="VCCLCompilerTool"
+				AdditionalOptions="/MP2"
 				Optimization="2"
 				InlineFunctionExpansion="1"
@@ -128,4 +129,5 @@
 			<Tool
 				Name="VCCLCompilerTool"
+				AdditionalOptions="/MP2"
 				Optimization="0"
 				AdditionalIncludeDirectories="$(RootDir)\src\ois"
Index: code/trunk/visual_studio/vc8/orxonox.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/orxonox.vcproj	(revision 1754)
+++ code/trunk/visual_studio/vc8/orxonox.vcproj	(revision 1755)
@@ -161,8 +161,4 @@
 			</File>
 			<File
-				RelativePath="..\..\src\orxonox\Orxonox.cc"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\orxonox\PrecompiledHeaderFiles.cc"
 				>
@@ -289,128 +285,4 @@
 					>
 				</File>
-				<Filter
-					Name="weapon"
-					>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\AmmunitionDump.cc"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\BarrelGun.cc"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\BaseWeapon.cc"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\Bullet.cc"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\BulletManager.cc"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\WeaponStation.cc"
-						>
-						<FileConfiguration
-							Name="Debug|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-						<FileConfiguration
-							Name="Release|Win32"
-							ExcludedFromBuild="true"
-							>
-							<Tool
-								Name="VCCLCompilerTool"
-							/>
-						</FileConfiguration>
-					</File>
-				</Filter>
 			</Filter>
 			<Filter
@@ -449,4 +321,30 @@
 				Name="tolua"
 				>
+				<File
+					RelativePath="..\..\src\orxonox\tolua\tolua.pkg"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(OutDir)\tolua_app_d.exe&quot; -n Orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\orxonox\gui\GUIManager.h"
+							Outputs="$(RootDir)\src\orxonox\tolua\tolua_bind.cc; $(RootDir)\src\orxonox\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCustomBuildTool"
+							Description="Generating tolua bind files..."
+							CommandLine="&quot;$(OutDir)\tolua_app.exe&quot; -n Orxonox -o ../../src/orxonox/tolua/tolua_bind.cc -H ../../src/orxonox/tolua/tolua_bind.h ../../src/orxonox/tolua/tolua.pkg&#x0D;&#x0A;"
+							AdditionalDependencies="$(RootDir)\src\orxonox\gui\GUIManager.h"
+							Outputs="$(RootDir)\src\orxonox\tolua\tolua_bind.cc; $(RootDir)\src\orxonox\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+				</File>
 				<File
 					RelativePath="..\..\src\orxonox\tolua\tolua_bind.cc"
@@ -525,4 +423,112 @@
 					</File>
 				</Filter>
+			</Filter>
+			<Filter
+				Name="gui"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gui\GUIManager.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIRenderer.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIResourceProvider.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUITexture.cpp"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+			<Filter
+				Name="gamestates"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSClient.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSDedicated.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGraphics.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGUI.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSIOConsole.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSLevel.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSRoot.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSServer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSStandalone.cc"
+					>
+				</File>
 			</Filter>
 		</Filter>
@@ -537,5 +543,5 @@
 			</File>
 			<File
-				RelativePath="..\..\src\orxonox\Orxonox.h"
+				RelativePath="..\..\src\orxonox\OrxonoxLibraryHeaders.h"
 				>
 			</File>
@@ -635,32 +641,4 @@
 					>
 				</File>
-				<Filter
-					Name="weapon"
-					>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\AmmunitionDump.h"
-						>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\BarrelGun.h"
-						>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\BaseWeapon.h"
-						>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\Bullet.h"
-						>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\BulletManager.h"
-						>
-					</File>
-					<File
-						RelativePath="..\..\src\orxonox\objects\weapon\WeaponStation.h"
-						>
-					</File>
-				</Filter>
 			</Filter>
 			<Filter
@@ -759,4 +737,64 @@
 					</File>
 				</Filter>
+			</Filter>
+			<Filter
+				Name="gui"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gui\GUIManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIRenderer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUIResourceProvider.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gui\OgreCEGUITexture.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="gamestates"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSClient.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSDedicated.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGraphics.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSGUI.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSIOConsole.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSLevel.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSRoot.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSServer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\gamestates\GSStandalone.h"
+					>
+				</File>
 			</Filter>
 		</Filter>
Index: code/trunk/visual_studio/vc8/tolua.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/tolua.vcproj	(revision 1754)
+++ code/trunk/visual_studio/vc8/tolua.vcproj	(revision 1755)
@@ -18,5 +18,5 @@
 		<Configuration
 			Name="Debug|Win32"
-			ConfigurationType="4"
+			ConfigurationType="2"
 			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\tolua_properties.vsprops"
 			CharacterSet="1"
@@ -50,8 +50,11 @@
 			/>
 			<Tool
-				Name="VCLibrarianTool"
+				Name="VCLinkerTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
 			/>
 			<Tool
@@ -65,4 +68,10 @@
 			/>
 			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
 				Name="VCPostBuildEventTool"
 			/>
@@ -70,5 +79,5 @@
 		<Configuration
 			Name="Release|Win32"
-			ConfigurationType="4"
+			ConfigurationType="2"
 			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tolua_properties.vsprops"
 			CharacterSet="1"
@@ -103,8 +112,11 @@
 			/>
 			<Tool
-				Name="VCLibrarianTool"
+				Name="VCLinkerTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
 			/>
 			<Tool
@@ -116,4 +128,10 @@
 			<Tool
 				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
 			/>
 			<Tool
Index: code/trunk/visual_studio/vc8/tolua_app.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/tolua_app.vcproj	(revision 1754)
+++ code/trunk/visual_studio/vc8/tolua_app.vcproj	(revision 1755)
@@ -153,5 +153,29 @@
 			</File>
 			<File
-				RelativePath="..\..\src\tolua\toluabind.c"
+				RelativePath="..\..\src\tolua\tolua-5.1.pkg"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Generating tolua bind files..."
+						CommandLine="&quot;$(OutDir)\tolua_gen_d.exe&quot; -n tolua -o ../../src/tolua/toluabind_orxonox.c -H ../../src/tolua/toluabind_orxonox.h ../../src/tolua/tolua-5.1.pkg&#x0D;&#x0A;"
+						Outputs="$(RootDir)\src\tolua\toluabind_orxonox.c; $(RootDir)\src\tolua\toluabind_orxonox.h"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+						Description="Generating tolua bind files..."
+						CommandLine="&quot;$(OutDir)\tolua_gen.exe&quot; -n tolua -o ../../src/tolua/toluabind_orxonox.c -H ../../src/tolua/toluabind_orxonox.h ../../src/tolua/tolua-5.1.pkg&#x0D;&#x0A;"
+						Outputs="$(RootDir)\src\tolua\toluabind_orxonox.c; $(RootDir)\src\tolua\toluabind_orxonox.h"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind_orxonox.c"
 				>
 			</File>
@@ -162,4 +186,12 @@
 			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
 			>
+			<File
+				RelativePath="..\..\src\tolua\tolua++.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind_orxonox.h"
+				>
+			</File>
 		</Filter>
 	</Files>
Index: code/trunk/visual_studio/vc8/tolua_gen.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/tolua_gen.vcproj	(revision 1755)
+++ code/trunk/visual_studio/vc8/tolua_gen.vcproj	(revision 1755)
@@ -0,0 +1,176 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_gen"
+	ProjectGUID="{71FC0211-5EB5-4637-BE8A-A48EC3CC27D0}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\tolua_gen_properties.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tolua_gen_properties.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind.c"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tolua\tolua++.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\toluabind.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: code/trunk/visual_studio/vc8/util.vcproj
===================================================================
--- code/trunk/visual_studio/vc8/util.vcproj	(revision 1754)
+++ code/trunk/visual_studio/vc8/util.vcproj	(revision 1755)
@@ -149,9 +149,9 @@
 			>
 			<File
-				RelativePath="..\..\src\util\ArgReader.cc"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\util\Clipboard.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\CRC32.cc"
 				>
 			</File>
@@ -195,8 +195,4 @@
 			>
 			<File
-				RelativePath="..\..\src\util\ArgReader.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\util\Clipboard.h"
 				>
@@ -207,4 +203,8 @@
 			</File>
 			<File
+				RelativePath="..\..\src\util\CRC32.h"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\util\Debug.h"
 				>
@@ -216,4 +216,8 @@
 			<File
 				RelativePath="..\..\src\util\ExprParser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Integers.h"
 				>
 			</File>
