Index: /code/branches/ceguilua/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,115 @@
+PROJECT(Orxonox)
+
+cmake_minimum_required(VERSION 2.4)
+
+IF (COMMAND cmake_policy)
+  cmake_policy(SET CMP0003 NEW)
+ENDIF (COMMAND cmake_policy)
+
+# This sets where to look for modules (e.g. "Find*.cmake" files)
+SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
+
+# Check whether we are on a tardis box
+INCLUDE(CheckTardis)
+
+
+############## Testing options ##################
+
+OPTION(TESTING_ENABLED "Do you want to enable Testing")
+IF (TESTING_ENABLED)
+  ENABLE_TESTING()
+ENDIF(TESTING_ENABLED)
+
+OPTION (NETWORK_TESTING_ENABLED "Do you want to build network testing tools: i.e. chatclient chatserver and alike")
+OPTION (NETWORKTRAFFIC_TESTING_ENABLED "Do you want to build dummyserver4 and dummyclient4")
+
+
+########## Compiler/Linker options ##############
+
+# if on tardis change compiler and reset boost include directory
+IF(IS_TARDIS)
+  MESSAGE("System is a TARDIS: Setting Compiler to g++-4.1.1")
+  # Force-set the compiler on tardis machines, as default points to g++-3.3
+  SET(CMAKE_CXX_COMPILER "g++-4.1.1")
+  # Reset Boost serach path
+  SET(Boost_INCLUDE_DIR "/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/include")
+ELSE (IS_TARDIS)
+  IF (NOT WIN32)
+    SET(Boost_INCLUDE_DIR "/usr/include/boost")
+  ENDIF (NOT WIN32)
+ENDIF(IS_TARDIS)
+
+# Set binary output directories
+SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
+SET(LIBRARY_OUTPUT_PATH    ${PROJECT_SOURCE_DIR}/bin/lib)
+
+# Global compiler/linker flags. force -O2!
+SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O0 -Wall -g -ggdb")
+SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
+#SET(CMAKE_C_FLAGS "$ENV{CFLAGS} -O3")
+#SET(CMAKE_CXX_FLAGS "$ENV{CXXFLAGS} -O3")
+
+SET(CMAKE_LD_FLAGS "$ENV{LDFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS " --no-undefined")
+SET(CMAKE_SHARED_LINKER_FLAGS " --no-undefined")
+SET(CMAKE_MODULE_LINKER_FLAGS " --no-undefined")
+
+# Use 'cmake -D make_verb:1 path' to get verbose make output when compiling
+IF (MAKE_VERB)
+ SET(CMAKE_VERBOSE_MAKEFILE TRUE)
+ENDIF (MAKE_VERB)
+
+
+############### Library finding #################
+
+# Uncomment the following line if you want the include and library paths to be shown
+# Alternatively use the "-D VERBOSE_FIND:BOOL=true" option when executing cmake
+
+# SET (VERBOSE_FIND true)
+
+# Performs the search and sets the variables
+FIND_PACKAGE(OGRE)
+FIND_PACKAGE(CEGUI)
+# FIND_PACKAGE(CEGUI_OGRE)
+FIND_PACKAGE(ENet)
+FIND_PACKAGE(Boost REQUIRED thread filesystem)
+FIND_PACKAGE(OpenAL)
+FIND_PACKAGE(ALUT)
+FIND_PACKAGE(OggVorbis)
+FIND_PACKAGE(ZLIB)
+FIND_PACKAGE(Lua)
+FIND_PACKAGE(TCL)
+FIND_PACKAGE(DirectX)
+
+# Set the search paths for the linking
+LINK_DIRECTORIES(
+  ${OGRE_LIB_DIR}
+  ${CEGUI_LIB_DIR}
+  ${CEGUI_SCRIPT_LIB_DIR}
+#  ${CEGUI_OGRE_LIB_DIR}
+  ${ENet_LIBRARY}
+  ${Boost_LIBRARY_DIRS}
+  ${Zlib_LIBRARY_DIR}
+  ${TCL_LIBRARY}
+)
+
+# Set the search paths for include files
+INCLUDE_DIRECTORIES(
+  ${OGRE_INCLUDE_DIR}
+  ${CEGUI_INCLUDE_DIR}
+#  ${CEGUI_OGRE_INCLUDE_DIR}
+  ${ENet_INCLUDE_DIR}
+  ${Boost_INCLUDE_DIRS}
+  ${OPENAL_INCLUDE_DIR}
+  ${ALUT_INCLUDE_DIR}
+  ${VORBIS_INCLUDE_DIR}
+  ${OGG_INCLUDE_DIR}
+  ${Lua_INCLUDE_DIR}
+  ${TCL_INCLUDE_PATH}
+  ${DirectX_INCLUDE_DIR}
+  ${ZLIB_INCLUDE_DIR}
+)
+
+# Add main source dir
+ADD_SUBDIRECTORY(src)
+
Index: /code/branches/ceguilua/Doxyfile
===================================================================
--- /code/branches/ceguilua/Doxyfile	(revision 1801)
+++ /code/branches/ceguilua/Doxyfile	(revision 1801)
@@ -0,0 +1,280 @@
+# Doxyfile 1.5.1-KDevelop
+
+#---------------------------------------------------------------------------
+# Project related configuration options
+#---------------------------------------------------------------------------
+PROJECT_NAME           = Orxonox
+PROJECT_NUMBER         = 0.1.2_Bellatrix
+OUTPUT_DIRECTORY       =
+CREATE_SUBDIRS         = NO
+OUTPUT_LANGUAGE        = English
+BRIEF_MEMBER_DESC      = YES
+REPEAT_BRIEF           = YES
+ABBREVIATE_BRIEF       = "The $name class" \
+                         "The $name widget" \
+                         "The $name file" \
+                         is \
+                         provides \
+                         specifies \
+                         contains \
+                         represents \
+                         a \
+                         an \
+                         the
+ALWAYS_DETAILED_SEC    = NO
+INLINE_INHERITED_MEMB  = NO
+FULL_PATH_NAMES        = YES
+STRIP_FROM_PATH        = /home/nicolasc/
+STRIP_FROM_INC_PATH    =
+SHORT_NAMES            = NO
+JAVADOC_AUTOBRIEF      = NO
+MULTILINE_CPP_IS_BRIEF = NO
+DETAILS_AT_TOP         = NO
+INHERIT_DOCS           = YES
+SEPARATE_MEMBER_PAGES  = NO
+TAB_SIZE               = 8
+ALIASES                =
+OPTIMIZE_OUTPUT_FOR_C  = NO
+OPTIMIZE_OUTPUT_JAVA   = NO
+BUILTIN_STL_SUPPORT    = NO
+DISTRIBUTE_GROUP_DOC   = NO
+SUBGROUPING            = YES
+#---------------------------------------------------------------------------
+# Build related configuration options
+#---------------------------------------------------------------------------
+EXTRACT_ALL            = YES
+EXTRACT_PRIVATE        = NO
+EXTRACT_STATIC         = NO
+EXTRACT_LOCAL_CLASSES  = YES
+EXTRACT_LOCAL_METHODS  = NO
+HIDE_UNDOC_MEMBERS     = NO
+HIDE_UNDOC_CLASSES     = NO
+HIDE_FRIEND_COMPOUNDS  = NO
+HIDE_IN_BODY_DOCS      = NO
+INTERNAL_DOCS          = NO
+CASE_SENSE_NAMES       = YES
+HIDE_SCOPE_NAMES       = NO
+SHOW_INCLUDE_FILES     = YES
+INLINE_INFO            = YES
+SORT_MEMBER_DOCS       = YES
+SORT_BRIEF_DOCS        = NO
+SORT_BY_SCOPE_NAME     = NO
+GENERATE_TODOLIST      = YES
+GENERATE_TESTLIST      = YES
+GENERATE_BUGLIST       = YES
+GENERATE_DEPRECATEDLIST= YES
+ENABLED_SECTIONS       =
+MAX_INITIALIZER_LINES  = 30
+SHOW_USED_FILES        = YES
+SHOW_DIRECTORIES       = NO
+FILE_VERSION_FILTER    =
+#---------------------------------------------------------------------------
+# configuration options related to warning and progress messages
+#---------------------------------------------------------------------------
+QUIET                  = NO
+WARNINGS               = YES
+WARN_IF_UNDOCUMENTED   = YES
+WARN_IF_DOC_ERROR      = YES
+WARN_NO_PARAMDOC       = NO
+WARN_FORMAT            = "$file:$line: $text"
+WARN_LOGFILE           =
+#---------------------------------------------------------------------------
+# configuration options related to the input files
+#---------------------------------------------------------------------------
+INPUT                  = .
+FILE_PATTERNS          = *.c \
+                         *.cc \
+                         *.cxx \
+                         *.cpp \
+                         *.c++ \
+                         *.d \
+                         *.java \
+                         *.ii \
+                         *.ixx \
+                         *.ipp \
+                         *.i++ \
+                         *.inl \
+                         *.h \
+                         *.hh \
+                         *.hxx \
+                         *.hpp \
+                         *.h++ \
+                         *.idl \
+                         *.odl \
+                         *.cs \
+                         *.php \
+                         *.php3 \
+                         *.inc \
+                         *.m \
+                         *.mm \
+                         *.dox \
+                         *.py \
+                         *.C \
+                         *.CC \
+                         *.C++ \
+                         *.II \
+                         *.I++ \
+                         *.H \
+                         *.HH \
+                         *.H++ \
+                         *.CS \
+                         *.PHP \
+                         *.PHP3 \
+                         *.M \
+                         *.MM \
+                         *.PY \
+                         *.C \
+                         *.H \
+                         *.tlh \
+                         *.diff \
+                         *.patch \
+                         *.moc \
+                         *.xpm \
+                         *.dox
+RECURSIVE              = yes
+EXCLUDE                = .svn/
+EXCLUDE_SYMLINKS       = NO
+EXCLUDE_PATTERNS       =
+EXAMPLE_PATH           =
+EXAMPLE_PATTERNS       = *
+EXAMPLE_RECURSIVE      = NO
+IMAGE_PATH             =
+INPUT_FILTER           =
+FILTER_PATTERNS        =
+FILTER_SOURCE_FILES    = NO
+#---------------------------------------------------------------------------
+# configuration options related to source browsing
+#---------------------------------------------------------------------------
+SOURCE_BROWSER         = NO
+INLINE_SOURCES         = NO
+STRIP_CODE_COMMENTS    = YES
+REFERENCED_BY_RELATION = YES
+REFERENCES_RELATION    = YES
+REFERENCES_LINK_SOURCE = YES
+USE_HTAGS              = NO
+VERBATIM_HEADERS       = YES
+#---------------------------------------------------------------------------
+# configuration options related to the alphabetical class index
+#---------------------------------------------------------------------------
+ALPHABETICAL_INDEX     = NO
+COLS_IN_ALPHA_INDEX    = 5
+IGNORE_PREFIX          =
+#---------------------------------------------------------------------------
+# configuration options related to the HTML output
+#---------------------------------------------------------------------------
+GENERATE_HTML          = YES
+HTML_OUTPUT            = html
+HTML_FILE_EXTENSION    = .html
+HTML_HEADER            =
+HTML_FOOTER            =
+HTML_STYLESHEET        =
+HTML_ALIGN_MEMBERS     = YES
+GENERATE_HTMLHELP      = NO
+CHM_FILE               =
+HHC_LOCATION           =
+GENERATE_CHI           = NO
+BINARY_TOC             = NO
+TOC_EXPAND             = NO
+DISABLE_INDEX          = NO
+ENUM_VALUES_PER_LINE   = 4
+GENERATE_TREEVIEW      = NO
+TREEVIEW_WIDTH         = 250
+#---------------------------------------------------------------------------
+# configuration options related to the LaTeX output
+#---------------------------------------------------------------------------
+GENERATE_LATEX         = NO
+LATEX_OUTPUT           = latex
+LATEX_CMD_NAME         = latex
+MAKEINDEX_CMD_NAME     = makeindex
+COMPACT_LATEX          = NO
+PAPER_TYPE             = a4wide
+EXTRA_PACKAGES         =
+LATEX_HEADER           =
+PDF_HYPERLINKS         = NO
+USE_PDFLATEX           = NO
+LATEX_BATCHMODE        = NO
+LATEX_HIDE_INDICES     = NO
+#---------------------------------------------------------------------------
+# configuration options related to the RTF output
+#---------------------------------------------------------------------------
+GENERATE_RTF           = NO
+RTF_OUTPUT             = rtf
+COMPACT_RTF            = NO
+RTF_HYPERLINKS         = NO
+RTF_STYLESHEET_FILE    =
+RTF_EXTENSIONS_FILE    =
+#---------------------------------------------------------------------------
+# configuration options related to the man page output
+#---------------------------------------------------------------------------
+GENERATE_MAN           = NO
+MAN_OUTPUT             = man
+MAN_EXTENSION          = .3
+MAN_LINKS              = NO
+#---------------------------------------------------------------------------
+# configuration options related to the XML output
+#---------------------------------------------------------------------------
+GENERATE_XML           = NO
+XML_OUTPUT             = xml
+XML_SCHEMA             =
+XML_DTD                =
+XML_PROGRAMLISTING     = YES
+#---------------------------------------------------------------------------
+# configuration options for the AutoGen Definitions output
+#---------------------------------------------------------------------------
+GENERATE_AUTOGEN_DEF   = NO
+#---------------------------------------------------------------------------
+# configuration options related to the Perl module output
+#---------------------------------------------------------------------------
+GENERATE_PERLMOD       = NO
+PERLMOD_LATEX          = NO
+PERLMOD_PRETTY         = YES
+PERLMOD_MAKEVAR_PREFIX =
+#---------------------------------------------------------------------------
+# Configuration options related to the preprocessor
+#---------------------------------------------------------------------------
+ENABLE_PREPROCESSING   = YES
+MACRO_EXPANSION        = NO
+EXPAND_ONLY_PREDEF     = NO
+SEARCH_INCLUDES        = YES
+INCLUDE_PATH           =
+INCLUDE_FILE_PATTERNS  =
+PREDEFINED             =
+EXPAND_AS_DEFINED      =
+SKIP_FUNCTION_MACROS   = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to external references
+#---------------------------------------------------------------------------
+TAGFILES               =
+GENERATE_TAGFILE       = Orxonox.tag
+ALLEXTERNALS           = NO
+EXTERNAL_GROUPS        = YES
+PERL_PATH              = /usr/bin/perl
+#---------------------------------------------------------------------------
+# Configuration options related to the dot tool
+#---------------------------------------------------------------------------
+CLASS_DIAGRAMS         = YES
+HIDE_UNDOC_RELATIONS   = YES
+HAVE_DOT               = NO
+CLASS_GRAPH            = YES
+COLLABORATION_GRAPH    = YES
+GROUP_GRAPHS           = YES
+UML_LOOK               = NO
+TEMPLATE_RELATIONS     = NO
+INCLUDE_GRAPH          = YES
+INCLUDED_BY_GRAPH      = YES
+CALL_GRAPH             = NO
+CALLER_GRAPH           = NO
+GRAPHICAL_HIERARCHY    = YES
+DIRECTORY_GRAPH        = YES
+DOT_IMAGE_FORMAT       = png
+DOT_PATH               =
+DOTFILE_DIRS           =
+MAX_DOT_GRAPH_DEPTH    = 1000
+DOT_TRANSPARENT        = NO
+DOT_MULTI_TARGETS      = NO
+GENERATE_LEGEND        = YES
+DOT_CLEANUP            = YES
+#---------------------------------------------------------------------------
+# Configuration::additions related to the search engine
+#---------------------------------------------------------------------------
+SEARCHENGINE           = YES
Index: /code/branches/ceguilua/INSTALL
===================================================================
--- /code/branches/ceguilua/INSTALL	(revision 1801)
+++ /code/branches/ceguilua/INSTALL	(revision 1801)
@@ -0,0 +1,17 @@
+Here our installing directions
+
+requirements:
+ogre-1.4.5
+ois-1.0
+cegui-0.5.0b
+enet-1.1
+boost-1.34.1
+cmake-2.4.7
+openal-0.0.8
+freealut-1.1.0
+libvorbis-1.2.0
+(all named version were tested. lower version requirement may be possible)
+
+It is assumed, that you have a working graphical environment (i.e X11), including some sort of 3d acceleration (OpenGL, Direct3D)
+
+Further information about installing and running this application can be found on http://www.orxonox.net/wiki/Running
Index: /code/branches/ceguilua/LICENSE
===================================================================
--- /code/branches/ceguilua/LICENSE	(revision 1801)
+++ /code/branches/ceguilua/LICENSE	(revision 1801)
@@ -0,0 +1,344 @@
+
+        GNU GENERAL PUBLIC LICENSE
+           Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                       51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+          Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+        GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software
+    interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Program does not specify a
+version number of this License, you may choose any version ever
+published by the Free Software Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+          NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+         END OF TERMS AND CONDITIONS
+
+      How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these
+terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    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
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Index: /code/branches/ceguilua/README
===================================================================
--- /code/branches/ceguilua/README	(revision 1801)
+++ /code/branches/ceguilua/README	(revision 1801)
@@ -0,0 +1,20 @@
+Hi there,
+
+We are proud to present you Orxonox - the most ferious 3D space shooter ever to exist.
+
+This game is free, if you have paid for this, get your money back! The source code of this game is licensed under the GPL (GNU General Public License). 
+The game content is licensed under the Creative Commons Attribution-Sharealike 2.5 license. For more information read LICENSE in the same folder you found this file.
+
+For directions to install this game, please check out the file INSTALL or http://www.orxonox.net/wiki/Running
+
+This application uses the Ogre Graphics Engine (http://www.ogre3d.org), if you haven't already downloaded a precompiled version of Ogre with this package. Visit our webpage to get your Orxonox compatible version of the Ogre libraries.
+
+This is an open source game. If you want to contribute check out http://www.orxonox.net/wiki/development to find more information how you could help us making the game better. We are always looking for programmers and content designers, who like to contribute.
+
+We hope you have fun playing the game. Check out http://www.orxonox.net for news and newer versions of the game.
+
+Please contact us in our forum ( http://forum.orxonox.net ) or check out our contact page ( http://www.orxonox.net/wiki/about#Contact ). We hope to hear from you and are looking forward to your feedback.
+
+
+Cheers,
+The Orxonox Development Team
Index: /code/branches/ceguilua/TODO
===================================================================
--- /code/branches/ceguilua/TODO	(revision 1801)
+++ /code/branches/ceguilua/TODO	(revision 1801)
@@ -0,0 +1,2 @@
+- should we use enet_peer_ping to test if a client is still alive ?
+- enet_host_broadcast ? (to all peers)
Index: /code/branches/ceguilua/bin/Plugins.cfg
===================================================================
--- /code/branches/ceguilua/bin/Plugins.cfg	(revision 1801)
+++ /code/branches/ceguilua/bin/Plugins.cfg	(revision 1801)
@@ -0,0 +1,13 @@
+# Defines plugins to load
+
+# Define plugin folder
+PluginFolder=..\..\libs\ogre\Samples\Common\bin\Release
+
+# Define plugins
+Plugin=RenderSystem_Direct3D9
+Plugin=RenderSystem_GL
+Plugin=Plugin_ParticleFX
+Plugin=Plugin_BSPSceneManager
+Plugin=Plugin_OctreeSceneManager
+#Plugin=Plugin_CgProgramManager
+
Index: /code/branches/ceguilua/bin/def_keybindings.ini
===================================================================
--- /code/branches/ceguilua/bin/def_keybindings.ini	(revision 1801)
+++ /code/branches/ceguilua/bin/def_keybindings.ini	(revision 1801)
@@ -0,0 +1,264 @@
+[KeyBinder]
+KeyUNASSIGNED=openConsole
+KeyESCAPE=exit
+Key1=
+Key2=
+Key3=
+Key4=
+Key5=
+Key6=
+Key7=
+Key8=
+Key9=
+Key0=
+KeyMINUS=
+KeyEQUALS=openConsole
+KeyBACK=
+KeyTAB=cycleNavigationFocus
+KeyQ=moveRoll
+KeyW=moveLongitudinal
+KeyE=scale -1 moveRoll
+KeyR=
+KeyT=
+KeyY=
+KeyU=
+KeyI=
+KeyO=
+KeyP=
+KeyLBRACKET=
+KeyRBRACKET=
+KeyRETURN=
+KeyLCONTROL=
+KeyA=scale -1 moveLateral
+KeyS=scale -1 moveLongitudinal
+KeyD=moveLateral
+KeyF=
+KeyG=
+KeyH=scale -0.3 moveYaw
+KeyJ=scale -0.3 movePitch
+KeyK=scale  0.3 movePitch
+KeyL=scale  0.3 moveYaw
+KeySEMICOLON=
+KeyAPOSTROPHE=
+KeyGRAVE=openConsole
+KeyLSHIFT=
+KeyBACKSLASH=
+KeyZ=
+KeyX=
+KeyC=
+KeyV=
+KeyB=
+KeyN=
+KeyM=
+KeyCOMMA=
+KeyPERIOD=
+KeySLASH=
+KeyRSHIFT=
+KeyMULTIPLY=
+KeyLMENU=
+KeySPACE=
+KeyCAPITAL=
+KeyF1=Overlaygroup toggleVisibility Debug
+KeyF2=
+KeyF3=
+KeyF4=
+KeyF5=
+KeyF6=
+KeyF7=
+KeyF8=
+KeyF9=
+KeyF10=
+KeyNUMLOCK=
+KeySCROLL=
+KeyNUMPAD7=
+KeyNUMPAD8=
+KeyNUMPAD9=
+KeySUBTRACT=
+KeyNUMPAD4=
+KeyNUMPAD5=
+KeyNUMPAD6=
+KeyADD=
+KeyNUMPAD1=
+KeyNUMPAD2=
+KeyNUMPAD3=
+KeyNUMPAD0=
+KeyDECIMAL=
+Key=
+KeyOEM_102=
+KeyF11=
+KeyF12=
+KeyF13=
+KeyF14=
+KeyF15=
+KeyKANA=
+KeyABNT_C1=
+KeyCONVERT=
+KeyNOCONVERT=
+KeyYEN=
+KeyABNT_C2=
+KeyNUMPADEQUALS=
+KeyPREVTRACK=
+KeyAT=
+KeyCOLON=
+KeyUNDERLINE=
+KeyKANJI=
+KeySTOP=
+KeyAX=
+KeyUNLABELED=
+KeyNEXTTRACK=
+KeyNUMPADENTER=openConsole
+KeyRCONTROL=
+KeyMUTE=
+KeyCALCULATOR=
+KeyPLAYPAUSE=
+KeyMEDIASTOP=
+KeyVOLUMEDOWN=
+KeyVOLUMEUP=
+KeyWEBHOME=
+KeyNUMPADCOMMA=
+KeyDIVIDE=
+KeySYSRQ=
+KeyRMENU=
+KeyPAUSE=
+KeyHOME=
+KeyUP=
+KeyPGUP=
+KeyLEFT=
+KeyRIGHT=
+KeyEND=
+KeyDOWN=
+KeyPGDOWN=
+KeyINSERT=
+KeyDELETE=
+KeyLWIN=
+KeyRWIN=
+KeyAPPS=
+KeyPOWER=
+KeySLEEP=
+KeyWAKE=
+KeyWEBSEARCH=
+KeyWEBFAVORITES=
+KeyWEBREFRESH=
+KeyWEBSTOP=exit
+KeyWEBFORWARD=
+KeyWEBBACK=
+KeyMYCOMPUTER=
+KeyMAIL=
+KeyMEDIASELECT=
+MouseLeft=fire
+MouseRight=
+MouseMiddle=
+MouseButton3=
+MouseButton4=
+MouseButton5=
+MouseButton6=
+MouseButton7=
+MouseWheel1Up=
+MouseWheel1Down=
+MouseWheel2Up=
+MouseWheel2Down=
+MouseXPos=scale  1 moveYaw
+MouseXNeg=scale -1 moveYaw
+MouseYPos=scale  1 movePitch
+MouseYNeg=scale -1 movePitch
+Empty1Pos=
+Empty1Neg=
+Empty2Pos=
+Empty2Neg=
+JoyAxis1Pos=scale -1 movePitch
+JoyAxis1Neg=scale  1 movePitch
+JoyAxis2Pos=
+JoyAxis2Neg=
+JoyAxis3Pos=
+JoyAxis3Neg=
+JoyAxis4Pos=
+JoyAxis4Neg=
+JoyAxis5Pos=
+JoyAxis5Neg=
+JoyAxis6Pos=
+JoyAxis6Neg=
+JoyAxis7Pos=
+JoyAxis7Neg=
+JoyAxis8Pos=
+JoyAxis8Neg=
+JoyAxis9Pos=scale   1 moveYaw
+JoyAxis9Neg=scale  -1 moveYaw
+JoyAxis10Pos=
+JoyAxis10Neg=
+JoyAxis11Pos=scale -1 moveLongitudinal
+JoyAxis11Neg=scale  1 moveLongitudinal
+JoyAxis12Pos=scale  1 moveLateral
+JoyAxis12Neg=scale -1 moveLateral
+JoyAxis13Pos=
+JoyAxis13Neg=
+JoyAxis14Pos=
+JoyAxis14Neg=
+JoyAxis15Pos=
+JoyAxis15Neg=
+JoyAxis16Pos=
+JoyAxis16Neg=
+JoyAxis17Pos=
+JoyAxis17Neg=
+JoyAxis18Pos=
+JoyAxis18Neg=
+JoyAxis19Pos=
+JoyAxis19Neg=
+JoyAxis20Pos=
+JoyAxis20Neg=
+JoyAxis21Pos=
+JoyAxis21Neg=
+JoyAxis22Pos=
+JoyAxis22Neg=
+JoyAxis23Pos=
+JoyAxis23Neg=
+JoyAxis24Pos=
+JoyAxis24Neg=
+JoyButton0=cycleNavigationFocus
+JoyButton1=
+JoyButton2=
+JoyButton3=
+JoyButton4=
+JoyButton5=
+JoyButton6=scale  1 moveRoll
+JoyButton7=scale -1 moveRoll
+JoyButton8=
+JoyButton9=fire
+JoyButton10=
+JoyButton11=
+JoyButton12=
+JoyButton13=
+JoyButton14=
+JoyButton15=
+JoyButton16=
+JoyButton17=
+JoyButton18=
+JoyButton19=
+JoyButton20=
+JoyButton21=
+JoyButton22=
+JoyButton23=
+JoyButton24=
+JoyButton25=
+JoyButton26=
+JoyButton27=
+JoyButton28=
+JoyButton29=
+JoyButton30=
+JoyButton31=
+JoyPOV1North=
+JoyPOV1South=
+JoyPOV1East=
+JoyPOV1West=
+JoyPOV2North=
+JoyPOV2South=
+JoyPOV2East=
+JoyPOV2West=
+JoyPOV3North=
+JoyPOV3South=
+JoyPOV3East=
+JoyPOV3West=
+JoyPOV4North=
+JoyPOV4South=
+JoyPOV4East=
+JoyPOV4West=
+
Index: /code/branches/ceguilua/bin/disco.txt
===================================================================
--- /code/branches/ceguilua/bin/disco.txt	(revision 1801)
+++ /code/branches/ceguilua/bin/disco.txt	(revision 1801)
@@ -0,0 +1,4 @@
+delay 0 Ambient setAmbientLightTest 1,0,0,1
+delay 0.2 Ambient setAmbientLightTest 0,1,0,1
+delay 0.4 Ambient setAmbientLightTest 0,0,1,1
+delay 0.6 source disco.txt
Index: /code/branches/ceguilua/bin/irc.tcl
===================================================================
--- /code/branches/ceguilua/bin/irc.tcl	(revision 1801)
+++ /code/branches/ceguilua/bin/irc.tcl	(revision 1801)
@@ -0,0 +1,6 @@
+proc every {ms body} { eval $body; after $ms [list every $ms $body] }
+package require irk
+set conn [irk::connect datacore $nickname]
+irk::join $conn #orxonox
+every 25 {}
+vwait termination
Index: /code/branches/ceguilua/bin/ogre.cfg-init
===================================================================
--- /code/branches/ceguilua/bin/ogre.cfg-init	(revision 1801)
+++ /code/branches/ceguilua/bin/ogre.cfg-init	(revision 1801)
@@ -0,0 +1,7 @@
+Render System=OpenGL Rendering Subsystem
+
+[OpenGL Rendering Subsystem]
+FSAA=0
+Full Screen=No
+RTT Preferred Mode=FBO
+Video Mode=1024 x 768
Index: /code/branches/ceguilua/bin/orxonox.bat
===================================================================
--- /code/branches/ceguilua/bin/orxonox.bat	(revision 1801)
+++ /code/branches/ceguilua/bin/orxonox.bat	(revision 1801)
@@ -0,0 +1,4 @@
+title Orxonox
+path lib;..\..\libs;%path%
+orxonox.exe
+pause
Index: /code/branches/ceguilua/bin/plugins.cfg-init
===================================================================
--- /code/branches/ceguilua/bin/plugins.cfg-init	(revision 1801)
+++ /code/branches/ceguilua/bin/plugins.cfg-init	(revision 1801)
@@ -0,0 +1,14 @@
+# Defines plugins to load
+
+# Define plugin folder
+PluginFolder=/usr/lib/OGRE
+
+# Define plugins
+#Plugin=RenderSystem_Direct3D9
+Plugin=RenderSystem_GL
+Plugin=Plugin_ParticleFX
+Plugin=Plugin_BSPSceneManager
+Plugin=Plugin_OctreeSceneManager
+#Plugin=Plugin_CgProgramManager
+
+
Index: /code/branches/ceguilua/bin/remote.tcl
===================================================================
--- /code/branches/ceguilua/bin/remote.tcl	(revision 1801)
+++ /code/branches/ceguilua/bin/remote.tcl	(revision 1801)
@@ -0,0 +1,2 @@
+set telnetserverthreadid [TclThreadManager create]
+TclThreadManager execute $telnetserverthreadid source telnet_server.tcl
Index: /code/branches/ceguilua/bin/run-script
===================================================================
--- /code/branches/ceguilua/bin/run-script	(revision 1801)
+++ /code/branches/ceguilua/bin/run-script	(revision 1801)
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+if [[ !  -f orxonox ]] ; then
+	echo "orxonox does not exist"
+	echo "did you compile it?"
+
+	exit 1
+fi
+
+if [[ -ne orge.cfg ]] ; then
+	cp ogre.cfg-init ogre.cfg
+fi
+
+# check if plugins.cfg exists, and of not create it
+# and modify 
+if [[ ! -f plugins.cfg ]] ; then 
+	if uname -n | grep "tardis" > /dev/null ; then
+		sed -e 's:PluginFolder=/usr/lib/OGRE:PluginFolder=/usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/OGRE/:' \
+		-e 's:#Plugin=Plugin_CgProgramManager:Plugin=Plugin_CgProgramManager:' plugins.cfg-init > plugins.cfg
+	else
+                cp plugins.cfg-init plugins.cfg
+	fi
+fi
+
+trap "xset r && echo 'resetting autorepeat'" HUP INT TERM QUIT ABRT KILL ALRM
+./orxonox $@
Index: /code/branches/ceguilua/bin/telnet_server.tcl
===================================================================
--- /code/branches/ceguilua/bin/telnet_server.tcl	(revision 1801)
+++ /code/branches/ceguilua/bin/telnet_server.tcl	(revision 1801)
@@ -0,0 +1,209 @@
+ #!/usr/bin/env tclsh
+ # Pseudo-telnet server.  Includes basic auth, but no separate identities
+ # or proper multi-threaded operation, so whoever runs this had better
+ # trust those he gives identities/passwords to and they had better trust
+ # each other too.  Note this script does not support command-line arguments.
+
+ ## The names of this array are IP addresses of hosts that are not permitted
+ ## to connect to any of our services.  Admin account(s) can change this
+ ## at run-time, though this info is not maintained across whole-server shutdowns.
+ array set denyHosts {}
+
+ ## Keep the Tcl-thread busy
+ proc every {ms body} { eval $body; after $ms [list every $ms $body] }
+ every 200 {}
+
+ ## Create a server on the given port with the given name/password map
+ ## and the given core interaction handler.
+ proc telnetServer {port {passmap} {handlerCmd remoteCommand}} {
+     if {$port == 0} {
+         return -code error "Only non-zero port numbers are supported"
+     }
+     set server [socket -server [list connect $port $handlerCmd] $port]
+     global passwords services
+     foreach {id pass} $passmap {set passwords($port,$id) $pass}
+     set services($server) $handlerCmd
+     return $server
+ }
+
+ ## Removes the server on the given port, cleaning up the extra state too.
+ proc closedownServer {server} {
+     global services passwords connections auth
+     set port [lindex [fconfigure $server -sockname] 2]
+     catch {close $server}
+     unset services($server)
+     foreach passmap [array names passwords $port,*] {
+         unset passwords($passmap)
+     }
+     # Hmph!  Have to remove unauthorized connections too, though any
+     # connection which has been authorized can continue safely.
+     foreach {client data} [array get connections] {
+         if {$port == [lindex $data 0] && !$auth($client)} {
+             disconnect $client
+         }
+     }
+ }
+
+ ## Handle an incoming connection to the given server
+ proc connect {serverport handlerCmd client clienthost clientport} {
+     global auth cmd denyHosts connections
+     if {[info exist denyHosts($clienthost)]} {
+         puts stdout "${clienthost}:${clientport} attempted connection"
+         catch {puts $client "Connection denied"}
+         catch {close $client}
+         return
+     }
+     puts stdout "${clienthost}:${clientport} connected on $client"
+     fileevent $client readable "handle $serverport $client"
+     set auth($client) 0
+     set cmd($client) $handlerCmd
+     set connections($client) [list $serverport $clienthost $clientport]
+     fconfigure $client -buffering none
+     catch {puts -nonewline $client "Login: "}
+ }
+
+ ## Disconnect the given client, cleaning up any connection-specific data
+ proc disconnect {client} {
+     catch {close $client}
+     global auth cmd connections
+     unset auth($client)
+     unset cmd($client)
+     unset connections($client)
+     puts stdout "$client disconnected"
+ }
+
+ ## Handle data sent from the client.  Log-in is handled directly by this
+ ## procedure, and requires the name and password on the same line
+ proc handle {serverport client} {
+     global passwords auth cmd
+     if {[gets $client line] < 0} {
+         disconnect $client
+         return
+     }
+     if {[string equal $line "quit"] || [string equal $line "exit"]} {
+         disconnect $client
+         return
+     }
+     if {$auth($client)} {
+         eval $cmd($client) [list $client $line 0]
+         eval $cmd($client) [list $client $line 1]
+         return
+     }
+     foreach {id pass} [split $line] {break}
+     if {![info exist pass]} {
+         catch {puts -nonewline $client "Login: "}
+         return
+     }
+     if {
+         [info exist passwords($serverport,$id)] &&
+         [string equal $passwords($serverport,$id) $pass]
+     } then {
+         set auth($client) 1
+         puts stdout "$id logged in on $client"
+         catch {puts $client "Welcome, $id!"}
+         eval $cmd($client) [list $client $line 1]
+         return
+     }
+     puts stdout "AUTH FAILURE ON $client"
+     catch {puts $client "Unknown name or password"}
+     disconnect $client
+ }
+
+ ## Standard handler for logged-in conversations and prompt-generation.
+ proc execCommand {client line prompt} {
+     global tcl_platform
+     if {$prompt} {
+         catch {puts -nonewline $client "\$ "}
+         return
+     }
+     switch $tcl_platform(platform) {
+         unix {
+             catch {exec sh -c $line <@$client >@$client 2>@$client}
+         }
+         default {
+             catch {exec $line} data
+             puts $client $data
+         }
+     }
+ }
+
+ ## Administration service handler.  Chains to the normal handler for
+ ## everything it doesn't recognise itself.
+ proc admin {client line prompt} {
+     if {$prompt} {
+         catch {puts -nonewline $client "# "}
+         return
+     }
+     set cmd [split $line]
+     global denyHosts connections services
+     if {[string equal $line "shutdown"]} {
+         set ::termination 1
+         puts stdout "Shutdown requested on $client"
+         catch {puts $client "System will shut down as soon as possible"}
+         return -code return "SHUTTING DOWN"
+     } elseif {[string equal [lindex $cmd 0] "deny"]} {
+         set denyHosts([lindex $cmd 1]) 1
+     } elseif {[string equal [lindex $cmd 0] "allow"]} {
+         catch {unset denyHosts([lindex $cmd 1])}
+     } elseif {[string equal $line "denied"]} {
+         foreach host [array names denyHosts] {
+             catch {puts $client $host}
+         }
+     } elseif {[string equal $line "connections"]} {
+         set len 0
+         foreach conn [array names connections] {
+             if {$len < [string length $conn]} {
+                 set len [string length $conn]
+             }
+         }
+         foreach {conn details} [array get connections] {
+             catch {puts $client [format "%-*s = %s" $len $conn $details]}
+         }
+     } elseif {[string equal [lindex $cmd 0] "close"]} {
+         set sock [lindex $cmd 1]
+         if {[info exist connections($sock)]} {
+             disconnect $sock
+         }
+     } elseif {[string equal $line "services"]} {
+         set len 0
+         foreach serv [array names services] {
+             if {$len < [string length $serv]} {
+                 set len [string length $serv]
+             }
+         }
+         foreach {serv handler} [array get services] {
+             set port [lindex [fconfigure $serv -sockname] 2]
+             catch {puts $client [format "%-*s (port %d) = handler %s" $len $serv $port $handler]}
+         }
+     } elseif {[string equal [lindex $cmd 0] "addService"]} {
+         set service [eval telnetServer [lrange $cmd 1 end]]
+         catch {puts $client "Created service as $service"}
+     } elseif {[string equal [lindex $cmd 0] "removeService"]} {
+         set service [lindex $cmd 1]
+         if {[info exist services($service)]} {
+             closedownServer $service
+         }
+     } else {
+         # CHAIN TO DEFAULT
+         execCommand $client $line 0
+     }
+ }
+ 
+ ## Executes a given command
+ proc remoteCommand {client line prompt} {
+     global tcl_platform
+     if {$prompt} {
+         catch {puts -nonewline $client "\$ "}
+         return
+     }
+     catch {eval $line} data
+     puts $client $data
+ }
+
+ telnetServer 2560 {orxonox rocks} remoteCommand
+ telnetServer 2561 {orxadmin *****} admin
+
+ puts stdout "Ready for service"
+
+ vwait termination
+ execute exit
Index: /code/branches/ceguilua/cmake/CheckTardis.cmake
===================================================================
--- /code/branches/ceguilua/cmake/CheckTardis.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/CheckTardis.cmake	(revision 1801)
@@ -0,0 +1,31 @@
+################# Tardis check ##################
+# This code checks whether the current machine  #
+# is an ETH tardis box.                         #
+#################################################
+
+# only run this test on a lunix/unix machine
+IF (UNIX)
+
+  FIND_PROGRAM(UNAME_CMD "uname"
+  PATHS "/usr/bin /bin")
+  IF(NOT UNAME_CMD)
+    MESSAGE(ERROR "Unable to find uname. Tardis-Check cannot be done.")
+  ENDIF(NOT UNAME_CMD)
+
+  # run uname -n to get nodename
+  EXECUTE_PROCESS(
+  COMMAND "${UNAME_CMD}" "-n"
+  RESULT_VARIABLE UNAME_RV
+  ERROR_VARIABLE UNAME_EV
+  OUTPUT_VARIABLE UNAME_OV)
+
+  IF (NOT "${UNAME_RV}" STREQUAL "0")
+    MESSAGE(ERROR "ERROR: uname terminated unclean.")
+  ENDIF (NOT "${UNAME_RV}" STREQUAL "0")
+
+  # check wheter we are on a tardis machine
+  IF ("${UNAME_OV}" MATCHES "tardis")
+    SET (IS_TARDIS ON)
+  ENDIF ("${UNAME_OV}" MATCHES "tardis")
+
+ENDIF (UNIX)
Index: /code/branches/ceguilua/cmake/FindALUT.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindALUT.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindALUT.cmake	(revision 1801)
@@ -0,0 +1,113 @@
+# - Locate FreeAlut
+# This module defines
+#  ALUT_LIBRARY
+#  ALUT_FOUND, if false, do not try to link to Alut
+#  ALUT_INCLUDE_DIR, where to find the headers
+#
+# $ALUTDIR is an environment variable that would
+# correspond to the ./configure --prefix=$ALUTDIR
+# used in building Alut.
+#
+# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of
+# ALUT_LIBRARY to override this selection.
+# Tiger will include OpenAL as part of the System.
+# But for now, we have to look around.
+# Other (Unix) systems should be able to utilize the non-framework paths.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+  SET (ALUT_FIND_QUIETLY TRUE)
+ENDIF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+
+FIND_PATH(ALUT_INCLUDE_DIR AL/alut.h
+  $ENV{ALUTDIR}/include
+  ~/Library/Frameworks/OpenAL.framework/Headers
+  /Library/Frameworks/OpenAL.framework/Headers
+  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
+  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
+  /usr/local/include/
+  /usr/local/include/OpenAL
+  /usr/local/include
+  /usr/include/
+  /usr/include/OpenAL
+  /usr/include
+  /sw/include/ # Fink
+  /sw/include/OpenAL
+  /sw/include
+  /opt/local/include/AL # DarwinPorts
+  /opt/local/include/OpenAL
+  /opt/local/include
+  /opt/csw/include/ # Blastwave
+  /opt/csw/include/OpenAL
+  /opt/csw/include
+  /opt/include/
+  /opt/include/OpenAL
+  /opt/include
+  ../libs/freealut-1.1.0/include
+  )
+
+# I'm not sure if I should do a special casing for Apple. It is
+# unlikely that other Unix systems will find the framework path.
+# But if they do ([Next|Open|GNU]Step?),
+# do they want the -framework option also?
+IF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" ALUT_FRAMEWORK_PATH_TMP ${ALUT_INCLUDE_DIR})
+  IF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is in default search path, don't need to use -F
+    SET (ALUT_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ELSE("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is not /Library/Frameworks, need to use -F
+    SET(ALUT_LIBRARY "-F${ALUT_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ENDIF("${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+    OR "${ALUT_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+    )
+  # Clear the temp variable so nobody can see it
+  SET(ALUT_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
+
+ELSE(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+  FIND_LIBRARY(ALUT_LIBRARY
+    NAMES alut
+    PATHS
+    $ENV{ALUTDIR}/lib
+    $ENV{ALUTDIR}/libs
+    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
+    /usr/local/lib
+    /usr/lib
+    /sw/lib
+    /opt/local/lib
+    /opt/csw/lib
+    /opt/lib
+    ../libs/freealut-1.1.0/src/.libs
+    ../libs/freealut-1.1.0/lib
+    )
+ENDIF(${ALUT_INCLUDE_DIR} MATCHES ".framework")
+
+SET (ALUT_FOUND "NO")
+IF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+  SET (ALUT_FOUND "YES")
+  IF (NOT ALUT_FIND_QUIETLY)
+    MESSAGE (STATUS "FreeAlut was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${ALUT_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${ALUT_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    alut")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT ALUT_FIND_QUIETLY)
+ELSE (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+  IF (NOT ALUT_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "FreeAlut include path was not found.")
+  ENDIF (NOT ALUT_INCLUDE_DIR)
+  IF (NOT ALUT_LIBRARY)
+    MESSAGE (SEND_ERROR "FreeAlut library was not found.")
+  ENDIF (NOT ALUT_LIBRARY)
+ENDIF (ALUT_LIBRARY AND ALUT_INCLUDE_DIR)
+
+
Index: /code/branches/ceguilua/cmake/FindBoost.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindBoost.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindBoost.cmake	(revision 1801)
@@ -0,0 +1,311 @@
+# THIS FILE HAS BEEN MODIFIED TO WORK ON THE TARDIS INFRASTURUCTURE of THE ETH.
+# use with cation
+# Nicolas Schlumberger <nico AT orxonx DOT net> (C) 2007
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+#
+# - Find the Boost includes and libraries.
+# The following variables are set if Boost is found.  If Boost is not
+# found, Boost_FOUND is set to false.
+#  Boost_FOUND                  - True when the Boost include directory is found.
+#  Boost_INCLUDE_DIRS           - the path to where the boost include files are.
+#  Boost_LIBRARY_DIRS           - The path to where the boost library files are.
+#  Boost_LIB_DIAGNOSTIC_DEFINITIONS - Only set if using Windows.
+#  Boost_<library>_FOUND        - True if the Boost <library> is found.
+#  Boost_<library>_INCLUDE_DIRS - The include path for Boost <library>.
+#  Boost_<library>_LIBRARIES    - The libraries to link to to use Boost <library>.
+#  Boost_LIBRARIES              - The libraries to link to to use all Boost libraries.
+#
+# The following variables can be set to configure how Boost is found:
+#  Boost_LIB_PREFIX             - Look for Boost libraries prefixed with this, e.g. "lib"
+#  Boost_LIB_SUFFIX             - Look for Boost libraries ending with this, e.g. "vc80-mt"
+#  Boost_LIB_SUFFIX_DEBUG       - As for Boost_LIB_SUFFIX but for debug builds, e.g. "vs80-mt-gd"
+
+# ----------------------------------------------------------------------------
+# If you have installed Boost in a non-standard location or you have
+# just staged the boost files using bjam then you have three
+# options. In the following comments, it is assumed that <Your Path>
+# points to the root directory of the include directory of Boost. e.g
+# If you have put boost in C:\development\Boost then <Your Path> is
+# "C:/development/Boost" and in this directory there will be two
+# directories called "include" and "lib".
+# 1) After CMake runs, set Boost_INCLUDE_DIR to <Your Path>/include/boost<-version>
+# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/include. This will allow FIND_PATH()
+#    to locate Boost_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g.
+#    SET(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
+# 3) Set an environment variable called ${BOOST_ROOT} that points to the root of where you have
+#    installed Boost, e.g. <Your Path>. It is assumed that there is at least a subdirectory called
+#    include in this path.
+#
+# Note:
+#  1) If you are just using the boost headers, then you do not need to use
+#     Boost_LIBRARY_DIRS in your CMakeLists.txt file.
+#  2) If Boost has not been installed, then when setting Boost_LIBRARY_DIRS
+#     the script will look for /lib first and, if this fails, then for /stage/lib.
+#
+# Usage:
+# In your CMakeLists.txt file do something like this:
+# ...
+# # Boost
+# FIND_PACKAGE(Boost)
+# ...
+# INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+# LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
+
+#
+# TODO:
+#
+# 1) Automatically find the Boost library files and eliminate the need
+#    to use Link Directories.
+#
+
+IF (Boost_INCLUDE_DIR)
+  SET (Boost_INCLUDE_FIND_QUIETLY TRUE)
+ENDIF (Boost_INCLUDE_DIR)
+
+IF(WIN32)
+# In windows, automatic linking is performed, so you do not have to specify the libraries.
+# If you are linking to a dynamic runtime, then you can choose to link to either a static or a
+# dynamic Boost library, the default is to do a static link.  You can alter this for a specific
+# library "whatever" by defining BOOST_WHATEVER_DYN_LINK to force Boost library "whatever" to
+# be linked dynamically.  Alternatively you can force all Boost libraries to dynamic link by
+# defining BOOST_ALL_DYN_LINK.
+
+# This feature can be disabled for Boost library "whatever" by defining BOOST_WHATEVER_NO_LIB,
+# or for all of Boost by defining BOOST_ALL_NO_LIB.
+
+# If you want to observe which libraries are being linked against then defining
+# BOOST_LIB_DIAGNOSTIC will cause the auto-linking code to emit a #pragma message each time
+# a library is selected for linking.
+#  SET(Boost_LIB_DIAGNOSTIC_DEFINITIONS "-DBOOST_LIB_DIAGNOSTIC")
+#  SET(Boost_LIB_PREFIX "lib")
+#  SET(Boost_LIB_SUFFIX "gcc-mt-1_33_1.lib")
+ENDIF(WIN32)
+
+
+SET(BOOST_INCLUDE_PATH_DESCRIPTION "directory containing the boost include files.")
+
+SET(BOOST_DIR_MESSAGE "Set the Boost_INCLUDE_DIR cmake cache entry to the ${BOOST_INCLUDE_PATH_DESCRIPTION}")
+
+SET(BOOST_DIR_SEARCH $ENV{BOOST_ROOT})
+IF(BOOST_DIR_SEARCH)
+  FILE(TO_CMAKE_PATH ${BOOST_DIR_SEARCH} BOOST_DIR_SEARCH)
+  SET(BOOST_DIR_SEARCH ${BOOST_DIR_SEARCH}/include)
+ENDIF(BOOST_DIR_SEARCH)
+
+# Add in some path suffixes. These will have to be updated whenever a new Boost version comes out.
+SET(SUFFIX_FOR_PATH
+ boost
+ boost-1_35_0
+ boost-1_35
+ boost-1_34_1
+ boost-1_34_0
+ boost-1_34
+ boost-1_33_1
+ boost-1_33_0
+)
+
+#
+# Look for an installation.
+#
+FIND_PATH(Boost_INCLUDE_DIR NAMES boost/config.hpp PATH_SUFFIXES ${SUFFIX_FOR_PATH} PATHS
+
+# Look in other places.
+  ${BOOST_DIR_SEARCH}
+
+#    ../libs/boost_1_33_1
+    ../libs/boost_1_34_1
+#    ../libs/boost-1_35_0
+
+# Help the user find it if we cannot.
+  DOC "The ${BOOST_INCLUDE_PATH_DESCRIPTION}"
+)
+
+# Assume we didn't find it.
+SET(Boost_FOUND 0)
+
+# Now try to get the include and library path.
+IF(Boost_INCLUDE_DIR)
+
+# Look for the boost library path.
+# Note that the user may not have installed any libraries
+# so it is quite possible the Boost_LIBRARY_PATH may not exist.
+  SET(Boost_LIBRARY_DIR ${Boost_INCLUDE_DIR})
+
+  IF("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+")
+    GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH)
+  ENDIF ("${Boost_LIBRARY_DIR}" MATCHES "boost-[0-9]+")
+
+  IF("${Boost_LIBRARY_DIR}" MATCHES "/include$")
+# Strip off the trailing "/include" in the path.
+    GET_FILENAME_COMPONENT(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR} PATH)
+  ENDIF("${Boost_LIBRARY_DIR}" MATCHES "/include$")
+
+  IF(EXISTS "${Boost_LIBRARY_DIR}/lib")
+    SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/lib)
+  ELSEIF(EXISTS "${Boost_LIBRARY_DIR}/bin/boost/libs/thread/build/boost_thread.dll/gcc/release/threading-multi")
+    SET (Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/bin/boost/libs/thread/build/boost_thread.dll/gcc/release/threading-multi)
+  ELSE(EXISTS "${Boost_LIBRARY_DIR}/lib")
+    IF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
+      SET(Boost_LIBRARY_DIR ${Boost_LIBRARY_DIR}/stage/lib)
+    ELSE(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
+      IF(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
+        SET(Boost_LIBRARY_DIR "${Boost_LIBRARY_DIR}/../../lib")
+      ELSE(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
+        SET(Boost_LIBRARY_DIR "")
+      ENDIF(EXISTS "${Boost_LIBRARY_DIR}/../../lib")
+    ENDIF(EXISTS "${Boost_LIBRARY_DIR}/stage/lib")
+  ENDIF(EXISTS "${Boost_LIBRARY_DIR}/lib")
+
+
+  IF(EXISTS "${Boost_INCLUDE_DIR}")
+    SET(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
+# We have found boost. It is possible that the user has not
+# compiled any libraries so we set Boost_FOUND to be true here.
+    SET(Boost_FOUND 1)
+    MARK_AS_ADVANCED(Boost_INCLUDE_DIR)
+  ENDIF(EXISTS "${Boost_INCLUDE_DIR}")
+  IF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}")
+    SET(Boost_LIBRARY_DIRS ${Boost_LIBRARY_DIR})
+  ENDIF(Boost_LIBRARY_DIR AND EXISTS "${Boost_LIBRARY_DIR}")
+ENDIF(Boost_INCLUDE_DIR)
+
+
+#
+# Find boost libraries
+#
+
+# List of library suffixes to search, e.g. libboost_date_time-gcc
+SET(BOOST_SUFFIX_SEARCH
+  mt
+  gcc41-mt
+  gcc
+  il
+  gcc-1_33_1
+  gcc-mt-1_33_1
+  mgw34-mt-1_34_1
+  mgw34-mt-1_35
+)
+
+# List of all boost libraries
+SET(BOOST_ALL_LIBRARIES
+  date_time
+  filesystem
+  graph
+  iostreams
+  program_options
+  regex
+  serialization
+  signals
+  unit_test_framework
+  thread
+  wave
+)
+
+# Macro to find boost library called name
+MACRO(BOOST_FIND_LIBRARY name)
+
+# User can specify a particular build variant via the variables:
+#   Boost_LIB_PREFIX, Boost_LIB_SUFFIX, Boost_LIB_SUFFIX_DEBUG
+# otherwise we'll search the BOOST_SUFFIX_SEARCH list
+
+  SET(BOOST_LIB_NAMES ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX})
+  IF(NOT Boost_LIB_SUFFIX)
+    FOREACH(suffix ${BOOST_SUFFIX_SEARCH})
+      SET(BOOST_LIB_NAMES ${BOOST_LIB_NAMES} ${Boost_LIB_PREFIX}boost_${name}-${suffix})
+    ENDFOREACH(suffix)
+  ENDIF(NOT Boost_LIB_SUFFIX)
+
+# Find the library in the Boost_LIBRARY_DIRS
+  FIND_LIBRARY(Boost_${name}_LIBRARY
+    NAMES ${BOOST_LIB_NAMES}
+    PATHS ${Boost_LIBRARY_DIRS})
+
+# For MSVC builds find debug library
+  IF(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
+    FIND_LIBRARY(Boost_${name}_LIBRARY_DEBUG ${Boost_LIB_PREFIX}boost_${name}-${Boost_LIB_SUFFIX_DEBUG})
+
+    IF(MSVC_IDE)
+      IF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
+        SET(Boost_${name}_LIBRARIES debug ${Boost_${name}_LIBRARY_DEBUG} optimized ${Boost_${name}_LIBRARY})
+      ELSE(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
+        MESSAGE(FATAL_ERROR "Could not find the debug and release version of Boost ${name} library.")
+      ENDIF(Boost_${name}_LIBRARY AND Boost_${name}_LIBRARY_DEBUG)
+    ELSE(MSVC_IDE)
+      STRING(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER)
+      IF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+        SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY_DEBUG})
+      ELSE(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+        SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY})
+      ENDIF(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
+    ENDIF(MSVC_IDE)
+  ELSE(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
+    SET(Boost_${name}_LIBRARIES ${Boost_${name}_LIBRARY})
+  ENDIF(WIN32 AND MSVC AND Boost_${name}_LIBRARY)
+
+# If we've got it setup appropriate variables or issue error message
+  IF(Boost_${name}_LIBRARY)
+    SET(Boost_${name}_FOUND 1)
+    SET(Boost_${name}_INCLUDE_DIRS ${Boost_INCLUDE_DIR})
+    MARK_AS_ADVANCED(Boost_${name}_LIBRARY Boost_${name}_LIBRARY_DEBUG)
+  ELSE(Boost_${name}_LIBRARY)
+    IF(NOT Boost_FIND_QUIETLY)
+      MESSAGE(SEND_ERROR "Boost ${name} library was not found.")
+    ELSE(NOT Boost_FIND_QUIETLY)
+      IF(Boost_FIND_REQUIRED_${name})
+        MESSAGE(FATAL_ERROR "Could NOT find required Boost ${name} library.")
+      ENDIF(Boost_FIND_REQUIRED_${name})
+    ENDIF(NOT Boost_FIND_QUIETLY)
+  ENDIF(Boost_${name}_LIBRARY)
+ENDMACRO(BOOST_FIND_LIBRARY)
+
+IF(Boost_LIBRARY_DIRS)
+
+# If the user specified required components e.g. via
+# FIND_PACKAGE(Boost REQUIRED date_time regex)
+# find (just) those libraries. Otherwise find all libraries.
+  IF(Boost_FIND_COMPONENTS)
+    SET(Boost_FIND_LIBRARIES ${Boost_FIND_COMPONENTS})
+  ELSE(Boost_FIND_COMPONENTS)
+    SET(Boost_FIND_LIBRARIES ${BOOST_ALL_LIBRARIES})
+  ENDIF(Boost_FIND_COMPONENTS)
+
+  SET(Boost_LIBRARIES)
+  FOREACH(library ${Boost_FIND_LIBRARIES})
+    IF (Boost_${library}_LIBRARY)
+      SET (Boost_${name}_LIBRARY_FIND_QUIETLY TRUE)
+    ENDIF (Boost_${library}_LIBRARY)
+
+    BOOST_FIND_LIBRARY(${library})
+    IF(Boost_${library}_FOUND)
+      SET(Boost_LIBRARIES ${Boost_LIBRARIES} ${Boost_${library}_LIBRARIES})
+      IF (NOT Boost_${name}_LIBRARY_FIND_QUIETLY)
+        MESSAGE(STATUS "Found BoostLibrary: ${library}")
+        IF (VERBOSE_FIND)
+          MESSAGE (STATUS "  library path: ${Boost_${library}_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+      ENDIF (NOT Boost_${name}_LIBRARY_FIND_QUIETLY)
+    ENDIF(Boost_${library}_FOUND)
+  ENDFOREACH(library)
+ELSE(Boost_LIBRARY_DIRS)
+  MESSAGE(SEND_ERROR "Boost libraries not found: ${Boost_FIND_COMPONENTS}")
+ENDIF(Boost_LIBRARY_DIRS)
+
+IF(NOT Boost_FOUND)
+  IF(NOT Boost_FIND_QUIETLY)
+    MESSAGE(SEND_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
+  ELSE(NOT Boost_FIND_QUIETLY)
+    IF(Boost_FIND_REQUIRED)
+      MESSAGE(SEND_ERROR "Boost was not found. ${BOOST_DIR_MESSAGE}")
+    ENDIF(Boost_FIND_REQUIRED)
+  ENDIF(NOT Boost_FIND_QUIETLY)
+ELSE(NOT Boost_FOUND)
+  IF (NOT Boost_INCLUDE_FIND_QUIETLY)
+    MESSAGE(STATUS "Boost include path was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${Boost_INCLUDE_DIR}")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT Boost_INCLUDE_FIND_QUIETLY)
+ENDIF(NOT Boost_FOUND)
+
Index: /code/branches/ceguilua/cmake/FindCEGUI.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindCEGUI.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindCEGUI.cmake	(revision 1801)
@@ -0,0 +1,111 @@
+# Find CEGUI includes and library
+#
+# This module defines
+#  CEGUI_INCLUDE_DIR
+#  CEGUI_LIBRARIES, the libraries to link against to use CEGUI.
+#  CEGUI_LIB_DIR, the location of the libraries
+#  CEGUI_FOUND, If false, do not try to use CEGUI
+#
+# Created by Matt Williams to find OGRE libraries
+# Copyright © 2007, Matt Williams
+#
+# Modified by Nicolas Schlumberger to find CEGUI libraries
+# and make it run on the Tardis-Infrastucture of the ETH Zurich
+# Copyright 2007, Nicolas Schlumberger
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR AND CEGUI_LIB_DIR AND CEGUI_SCRIPT_LIBRARIES)
+    SET(CEGUI_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (CEGUI_LIBRARIES AND CEGUI_INCLUDE_DIR AND CEGUI_LIB_DIR AND CEGUI_SCRIPT_LIBRARIES)
+
+IF (WIN32) #Windows
+    FIND_PATH(CEGUI_INCLUDE_DIR CEGUI.h
+        ../libs/cegui-0.6.1/include
+    )
+
+    SET(CEGUI_LIBRARIES debug CEGUIBase_d optimized CEGUIBase)
+    FIND_LIBRARY(CEGUI_LIBDIR NAMES ${CEGUI_LIBRARIES} PATHS
+        ../libs/cegui-0.6.1/bin
+    )
+
+    # Strip the filename from the path
+    IF (CEGUI_LIBDIR)
+        GET_FILENAME_COMPONENT(CEGUI_LIBDIR ${CEGUI_LIBDIR} PATH)
+        SET (CEGUI_LIB_DIR ${CEGUI_LIBDIR} CACHE FILEPATH "")
+    ENDIF (CEGUI_LIBDIR)
+
+    IF (NOT CEGUI_SCRIPT_LIBDIR)
+        # Search Lua script module
+        SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule")
+        FIND_LIBRARY(CEGUI_SCRIPT_LIBDIR NAMES ${CEGUI_SCRIPT_LIBRARIES} PATHS
+            ../libs/cegui-0.6.1/bin
+        )
+        IF (NOT CEGUI_SCRIPT_LIBDIR)
+            SET(CEGUI_SCRIPT_LIBRARIES "CEGUILua")
+            FIND_LIBRARY(CEGUI_SCRIPT_LIBDIR NAMES ${CEGUI_SCRIPT_LIBRARIES} PATHS
+                ../libs/cegui-0.6.1/bin
+            )
+            IF (NOT CEGUI_SCRIPT_LIBDIR)
+                SET(CEGUI_SCRIPT_LIBRARIES)
+            ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
+        ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
+    ENDIF (NOT CEGUI_SCRIPT_LIBDIR)
+
+    # Strip the filename from the path
+    IF (CEGUI_SCRIPT_LIBDIR)
+        GET_FILENAME_COMPONENT(CEGUI_SCRIPT_LIBDIR ${CEGUI_SCRIPT_LIBDIR} PATH)
+        SET (CEGUI_SCRIPT_LIB_DIR ${CEGUI_SCRIPT_LIBDIR} CACHE FILEPATH "")
+    ENDIF (CEGUI_SCRIPT_LIBDIR)
+
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(CEGUI CEGUI /usr/pack/cegui-0.5.0-sd/i686-debian-linux3.1/lib/pkgconfig/CEGUI.pc) # tardis specific hack
+    SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIRS})
+    SET(CEGUI_LIB_DIR ${CEGUI_LIBDIR})
+    SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
+    SET(CEGUI_SCRIPT_LIBRARIES "CEGUILuaScriptModule")
+    SET(CEGUI_SCRIPT_LIB_DIR)
+ENDIF (WIN32)
+
+IF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES AND CEGUI_LIB_DIR AND CEGUI_SCRIPT_LIBRARIES)
+    SET(CEGUI_FOUND TRUE)
+
+    #Do some preparation
+    SEPARATE_ARGUMENTS(CEGUI_INCLUDE_DIR)
+    SEPARATE_ARGUMENTS(CEGUI_LIBRARIES)
+
+    SET(CEGUI_INCLUDE_DIR ${CEGUI_INCLUDE_DIR} CACHE PATH "")
+    SET(CEGUI_LIBRARIES ${CEGUI_LIBRARIES} CACHE STRING "")
+    SET(CEGUI_LIB_DIR ${CEGUI_LIB_DIR} CACHE PATH "")
+    SET(CEGUI_SCRIPT_LIBRARIES ${CEGUI_SCRIPT_LIBRARIES} CACHE PATH "")
+ENDIF (CEGUI_INCLUDE_DIR AND CEGUI_LIBRARIES AND CEGUI_LIB_DIR AND CEGUI_SCRIPT_LIBRARIES)
+
+IF (CEGUI_FOUND)
+    IF (NOT CEGUI_FIND_QUIETLY)
+        MESSAGE(STATUS "CEGUI was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${CEGUI_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${CEGUI_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${CEGUI_LIBRARIES}")
+            MESSAGE (STATUS "           :    ${CEGUI_SCRIPT_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT CEGUI_FIND_QUIETLY)
+ELSE (CEGUI_FOUND)
+    IF (NOT CEGUI_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "CEGUI include path was not found.")
+    ENDIF (NOT CEGUI_INCLUDE_DIR)
+    IF (NOT CEGUI_LIB_DIR)
+        MESSAGE(SEND_ERROR "CEGUI library was not found.")
+    ENDIF (NOT CEGUI_LIB_DIR)
+    IF (NOT CEGUI_LIBRARIES)
+        MESSAGE(SEND_ERROR "CEGUI libraries not known.")
+    ENDIF (NOT CEGUI_LIBRARIES)
+    IF (NOT CEGUI_SCRIPT_LIBRARIES)
+        MESSAGE(SEND_ERROR "CEGUI Lua script module was not found.")
+    ENDIF (NOT CEGUI_SCRIPT_LIBRARIES)
+ENDIF (CEGUI_FOUND)
+
Index: /code/branches/ceguilua/cmake/FindCEGUI_OGRE.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindCEGUI_OGRE.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindCEGUI_OGRE.cmake	(revision 1801)
@@ -0,0 +1,69 @@
+# Find CEGUI_OGRE includes and library
+#
+# This module defines
+#  CEGUI_OGRE_INCLUDE_DIR
+#  CEGUI_OGRE_LIBRARIES, the libraries to link against to use CEGUI_OGRE.
+#  CEGUI_OGRE_LIB_DIR, the location of the libraries
+#  CEGUI_OGRE_FOUND, If false, do not try to use CEGUI_OGRE
+#
+# Created by Matt Williams to find OGRE libraries
+# Copyright © 2007, Matt Williams
+#
+# Modified by Nicolas Schlumberger to find CEGUI-OGRE libraries
+# and make it run on the Tardis-Infrastucture of the ETH Zurich
+# Copyright 2007, Nicolas Schlumberger
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIB_DIR)
+    SET(CEGUI_OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIB_DIR)
+
+IF (WIN32) #Windows
+    MESSAGE(STATUS "Looking for CEGUI_OGRE")
+    SET(CEGUI_OGRE_INCLUDE_DIR ../libs/ogre/Samples/Common/CEGUIRenderer/include)
+    SET(CEGUI_OGRE_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../libs/ogre/Samples/Common/bin/Release/lib)
+    SET(CEGUI_OGRE_LIBRARIES debug OgreGUIRenderer_d optimized OgreGUIRenderer)
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(CEGUI_OGRE CEGUI-OGRE /usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/pkgconfig/CEGUI-OGRE.pc) # tardis specific hack
+    SET(CEGUI_OGRE_INCLUDE_DIR ${CEGUI_OGRE_INCLUDE_DIRS})
+    SET(CEGUI_OGRE_LIB_DIR ${CEGUI_OGRE_LIBDIR})
+    SET(CEGUI_OGRE_LIBRARIES ${CEGUI_OGRE_LIBRARIES} CACHE STRING "")
+ENDIF (WIN32)
+
+#Do some preparation
+SEPARATE_ARGUMENTS(CEGUI_OGRE_INCLUDE_DIR)
+SEPARATE_ARGUMENTS(CEGUI_OGRE_LIBRARIES)
+
+SET(CEGUI_OGRE_INCLUDE_DIR ${CEGUI_OGRE_INCLUDE_DIR} CACHE PATH "")
+SET(CEGUI_OGRE_LIBRARIES ${CEGUI_OGRE_LIBRARIES} CACHE STRING "")
+SET(CEGUI_OGRE_LIB_DIR ${CEGUI_OGRE_LIB_DIR} CACHE PATH "")
+
+IF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_LIB_DIR)
+    SET(CEGUI_OGRE_FOUND TRUE)
+ENDIF (CEGUI_OGRE_INCLUDE_DIR AND CEGUI_OGRE_LIBRARIES AND CEGUI_OGRE_LIB_DIR)
+
+IF (CEGUI_OGRE_FOUND)
+    IF (NOT CEGUI_OGRE_FIND_QUIETLY)
+        MESSAGE(STATUS "CEGUI_Ogre was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${CEGUI_OGRE_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${CEGUI_OGRE_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${CEGUI_OGRE_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT CEGUI_OGRE_FIND_QUIETLY)
+ELSE (CEGUI_OGRE_FOUND)
+    IF (NOT CEGUI_OGRE_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "CEGUI_Ogre include path was not found.")
+    ENDIF (NOT CEGUI_OGRE_INCLUDE_DIR)
+    IF (NOT CEGUI_OGRE_LIB_DIR)
+        MESSAGE(SEND_ERROR "CEGUI_Ogre library was not found.")
+    ENDIF (NOT CEGUI_OGRE_LIB_DIR)
+    IF (NOT CEGUI_OGRE_LIBRARIES)
+        MESSAGE(SEND_ERROR "CEGUI_Ogre libraries not known.")
+    ENDIF (NOT CEGUI_OGRE_LIBRARIES)
+ENDIF (CEGUI_OGRE_FOUND)
Index: /code/branches/ceguilua/cmake/FindDirectX.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindDirectX.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindDirectX.cmake	(revision 1801)
@@ -0,0 +1,47 @@
+IF(WIN32)
+  # - Test for DirectX
+  # Once loaded this will define
+  #   DirectX_FOUND        - system has DirectX
+  #   DirectX_INCLUDE_DIR  - include directory for DirectX
+  #   DirectX_LIB_DIR      - lib directory for DirectX
+  #
+  # Several changes and additions by Fabian 'x3n' Landau
+  #                 > www.orxonox.net <
+
+  IF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+    SET(DirectX_FIND_QUIETLY TRUE)
+  ENDIF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+
+  set(DirectX_FOUND "NO")
+
+  FIND_PATH(DirectX_INCLUDE_DIR "dinput.h"
+    C:/DXSDK/Include
+  )
+
+  FIND_PATH(DirectX_LIB_DIR "dinput8.lib"
+    C:/DXSDK/Lib
+    C:/DXSDK/Lib/x86
+  )
+
+  IF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+    SET (DirectX_FOUND "YES")
+  ENDIF (DirectX_INCLUDE_DIR AND DirectX_LIB_DIR)
+
+  IF (DirectX_FOUND)
+    IF (NOT DirectX_FIND_QUIETLY)
+      MESSAGE(STATUS "DirectX was found.")
+      IF (VERBOSE_FIND)
+        MESSAGE (STATUS "  include path: ${DirectX_INCLUDE_DIR}")
+        MESSAGE (STATUS "  library path: ${DirectX_LIB_DIR}")
+        MESSAGE (STATUS "  libraries:    dinput8.lib")
+      ENDIF (VERBOSE_FIND)
+    ENDIF (NOT DirectX_FIND_QUIETLY)
+  ELSE (DirectX_FOUND)
+    IF (NOT DirectX_INCLUDE_DIR)
+      MESSAGE(SEND_ERROR "DirectX include path was not found.")
+    ENDIF (NOT DirectX_INCLUDE_DIR)
+    IF (NOT DirectX_LIB_DIR)
+      MESSAGE(SEND_ERROR "DirectX library was not found.")
+    ENDIF (NOT DirectX_LIB_DIR)
+  ENDIF (DirectX_FOUND)
+ENDIF(WIN32)
Index: /code/branches/ceguilua/cmake/FindENet.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindENet.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindENet.cmake	(revision 1801)
@@ -0,0 +1,63 @@
+# - Try to find enet
+# Once done this will define
+#
+#  ENET_FOUND - system has enet
+#  ENET_INCLUDE_DIR - the enet include directory
+#  ENET_LIBRARIES - the libraries needed to use enet
+#  ENET_DEFINITIONS - Compiler switches required for using enet
+#
+#  Borrowed from The Mana World
+#  http://themanaworld.org/
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+   SET(ENet_FIND_QUIETLY TRUE)
+ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+
+FIND_PATH(ENet_INCLUDE_DIR enet/enet.h
+    /usr/include
+    /usr/local/include
+    /usr/pack/enet-2007-sd/include
+    ../libs/enet-1.1/include
+    )
+
+FIND_LIBRARY(ENet_LIBRARY
+    NAMES enet
+    PATHS /usr/lib /usr/local/lib /usr/pack/enet-2007-sd/i686-debian-linux3.1/lib/
+    ../libs/enet-1.1
+    )
+
+SET(ENET_FOUND FALSE)
+IF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+    SET(ENET_FOUND TRUE)
+    SET(ENET_INCLUDE_DIR ${ENet_INCLUDE_DIR})
+
+    IF(WIN32)
+        SET(WINDOWS_ENET_DEPENDENCIES "ws2_32;winmm")
+        SET(ENet_LIBRARY ${ENet_LIBRARY} ${WINDOWS_ENET_DEPENDENCIES})
+    ENDIF(WIN32)
+
+    SET(ENET_LIBRARIES ${ENet_LIBRARY})
+ENDIF (ENet_INCLUDE_DIR AND ENet_LIBRARY)
+
+IF (ENET_FOUND)
+    IF (NOT ENet_FIND_QUIETLY)
+        MESSAGE(STATUS "ENet was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${ENet_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${ENet_LIBRARY}")
+            MESSAGE (STATUS "  libraries:    enet")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT ENet_FIND_QUIETLY)
+ELSE (ENET_FOUND)
+    IF (NOT ENet_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "ENet include path was not found.")
+    ENDIF (NOT ENet_INCLUDE_DIR)
+    IF (NOT ENet_LIBRARY)
+        MESSAGE(SEND_ERROR "ENet library was not found.")
+    ENDIF (NOT ENet_LIBRARY)
+ENDIF (ENET_FOUND)
+
+MARK_AS_ADVANCED(ENet_INCLUDE_DIR ENet_LIBRARY)
Index: /code/branches/ceguilua/cmake/FindLua.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindLua.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindLua.cmake	(revision 1801)
@@ -0,0 +1,101 @@
+#  Find Lua header and library files
+#
+#  When called, this script tries to define:
+#  Lua_INCLUDE_DIR    Header files directory
+#  Lua_LIBRARIES      library files (or file when using lua 5.1)
+#  Lua_FOUND          defined (true) if lua was found
+#  Lua_VERSION        either 5.1 or 5.0 or undefined
+#
+#  authors: Benjamin Knecht, Reto Grieder
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
+  # Already in cache, be silent
+  SET(Lua_FOUND TRUE)
+  SET(Lua_FIND_QUIETLY TRUE) 
+#  MESSAGE(STATUS "Lua was found.")
+
+ELSE (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
+  FIND_PATH(Lua_INCLUDE_DIR_51 lua.h
+    /usr/include/lua5.1
+    /usr/local/include/lua5.1
+    ../libs/lua-5.1.3/include)
+
+  FIND_PATH(Lua_INCLUDE_DIR_50 lua.h
+    /usr/include/lua50
+    /usr/local/include/lua50
+    /usr/pack/lua-5.0.3-sd/include)
+
+  FIND_LIBRARY(Lua_LIBRARY_51 NAMES lua5.1 lua PATHS
+    /usr/lib
+    /usr/local/lib
+    ../libs/lua-5.1.3/lib)
+
+  FIND_LIBRARY(Lua_LIBRARY_1_50 NAMES lua50 lua PATHS
+    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
+    /usr/lib
+    /usr/local/lib)
+
+  FIND_LIBRARY(Lua_LIBRARY_2_50 NAMES lualib50 lualib PATHS
+    /usr/pack/lua-5.0.3-sd/i686-debian-linux3.1/lib #tardis
+    /usr/lib
+    /usr/local/lib)
+
+
+  IF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+
+    # Found newer lua 5.1 libs
+    SET(Lua_FOUND TRUE)
+    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 "")
+    SET(Lua_LIBRARY_NAMES "lua5.1 lua")
+
+  ELSEIF(Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
+
+    # Found older lua 5.0 libs
+    SET(Lua_FOUND TRUE)
+    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 "")
+    SET(Lua_LIBRARY_NAMES "lua50 lua, lualib50 lualib")
+
+  ENDIF (Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+	
+
+  IF (Lua_FOUND)
+    MESSAGE(STATUS "Lua was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${Lua_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${Lua_LIBRARIES}")
+      MESSAGE (STATUS "  libraries:    ${Lua_LIBRARY_NAMES}")
+    ENDIF (VERBOSE_FIND)
+  ELSE (Lua_FOUND)
+    IF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
+      MESSAGE(SEND_ERROR "Lua 5.1 library was not found")
+    ENDIF (Lua_INCLUDE_DIR_51 AND NOT Lua_LIBRARY_51)
+    IF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+      MESSAGE(SEND_ERROR "Lua 5.1 include path was not found")
+    ENDIF (NOT Lua_INCLUDE_DIR_51 AND Lua_LIBRARY_51)
+
+    IF (Lua_INCLUDE_DIR_50)
+      IF (NOT Lua_LIBRARY_1_50)
+       MESSAGE(SEND_ERROR "Lua 5.0 library "lua" was not found")
+      ENDIF (NOT Lua_LIBRARY_1_50)
+      IF (NOT Lua_LIBRARY_2_50)
+       MESSAGE(SEND_ERROR "Lua 5.0 library "lualib" was not found")
+      ENDIF (NOT Lua_LIBRARY_2_50)
+    ENDIF (Lua_INCLUDE_DIR_50)
+    IF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
+      MESSAGE(SEND_ERROR "Lua 5.0 include path was not found")
+    ENDIF (NOT Lua_INCLUDE_DIR_50 AND Lua_LIBRARY_1_50 AND Lua_LIBRARY_2_50)
+
+    MESSAGE(SEND_ERROR "Lua was not found.")
+  ENDIF (Lua_FOUND)
+
+ENDIF (Lua_LIBRARIES AND Lua_INCLUDE_DIR)
+
Index: /code/branches/ceguilua/cmake/FindODE.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindODE.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindODE.cmake	(revision 1801)
@@ -0,0 +1,46 @@
+# find ODE (Open Dynamics Engine) includes and library
+#
+# ODE_INCLUDE_DIR - where the directory containing the ODE headers can be
+#                   found
+# ODE_LIBRARY     - full path to the ODE library
+# ODE_FOUND       - TRUE if ODE was found
+
+IF (NOT ODE_FOUND)
+
+  FIND_PATH(ODE_INCLUDE_DIR ode/ode.h
+    /usr/include
+    /usr/local/include
+    $ENV{OGRE_HOME}/include # OGRE SDK on WIN32
+    $ENV{INCLUDE}
+  )
+  FIND_LIBRARY(ODE_LIBRARY
+    NAMES ode
+    PATHS
+    /usr/lib
+    /usr/local/lib
+    $ENV{OGRE_HOME}/lib # OGRE SDK on WIN32
+  )
+
+  IF(ODE_INCLUDE_DIR)
+    MESSAGE(STATUS "Found ODE include dir: ${ODE_INCLUDE_DIR}")
+  ELSE(ODE_INCLUDE_DIR)
+    MESSAGE(STATUS "Could NOT find ODE headers.")
+  ENDIF(ODE_INCLUDE_DIR)
+
+  IF(ODE_LIBRARY)
+    MESSAGE(STATUS "Found ODE library: ${ODE_LIBRARY}")
+  ELSE(ODE_LIBRARY)
+    MESSAGE(STATUS "Could NOT find ODE library.")
+  ENDIF(ODE_LIBRARY)
+
+  IF(ODE_INCLUDE_DIR AND ODE_LIBRARY)
+     SET(ODE_FOUND TRUE CACHE STRING "Whether ODE was found or not")
+   ELSE(ODE_INCLUDE_DIR AND ODE_LIBRARY)
+     SET(ODE_FOUND FALSE)
+     IF(ODE_FIND_REQUIRED)
+       MESSAGE(FATAL_ERROR "Could not find ODE. Please install ODE (http://www.ode.org)")
+     ENDIF(ODE_FIND_REQUIRED)
+   ENDIF(ODE_INCLUDE_DIR AND ODE_LIBRARY)
+ENDIF (NOT ODE_FOUND)
+
+# vim: et sw=4 ts=4
Index: /code/branches/ceguilua/cmake/FindOGRE.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindOGRE.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindOGRE.cmake	(revision 1801)
@@ -0,0 +1,75 @@
+# Find OGRE includes and library
+#
+# This module defines
+#  OGRE_INCLUDE_DIR
+#  OGRE_LIBRARIES, the libraries to link against to use OGRE.
+#  OGRE_LIB_DIR, the location of the libraries
+#  OGRE_FOUND, If false, do not try to use OGRE
+#
+# Copyright © 2007, Matt Williams
+# Modified by Nicolas Schlumberger to make it work on the Tardis-Infrastucture of the ETH Zurich
+#
+# Redistribution and use is allowed according to the terms of the BSD license.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR)
+    SET (OGRE_FIND_QUIETLY TRUE) # Already in cache, be silent
+ENDIF (OGRE_LIBRARIES AND OGRE_INCLUDE_DIR AND OGRE_LIB_DIR)
+
+IF (WIN32) #Windows
+    FIND_PATH(OGRE_INCLUDE_DIR Ogre.h
+        ../libs/ogre/OgreMain/include
+    )
+
+    SET(OGRE_LIBRARIES debug OgreMain_d optimized OgreMain)
+    FIND_LIBRARY(OGRE_LIBDIR NAMES ${OGRE_LIBRARIES} PATHS
+        ../libs/ogre/Samples/Common/bin/Release
+    )
+
+    # Strip the filename from the path
+    IF (OGRE_LIBDIR)
+        GET_FILENAME_COMPONENT(OGRE_LIBDIR ${OGRE_LIBDIR} PATH)
+        SET (OGRE_LIB_DIR ${OGRE_LIBDIR} CACHE FILEPATH "")
+    ENDIF (OGRE_LIBDIR)
+ELSE (WIN32) #Unix
+    FIND_PACKAGE(PkgConfig)
+    PKG_SEARCH_MODULE(OGRE OGRE /usr/pack/ogre-1.4.5-sd/i686-debian-linux3.1/lib/pkgconfig/OGRE.pc) # tardis specific hack
+    SET(OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIRS})
+    SET(OGRE_LIB_DIR ${OGRE_LIBDIR})
+    SET(OGRE_LIBRARIES ${OGRE_LIBRARIES})
+ENDIF (WIN32)
+
+#Do some preparation
+SEPARATE_ARGUMENTS(OGRE_INCLUDE_DIR)
+SEPARATE_ARGUMENTS(OGRE_LIBRARIES)
+
+SET (OGRE_INCLUDE_DIR ${OGRE_INCLUDE_DIR} CACHE PATH "")
+SET (OGRE_LIBRARIES ${OGRE_LIBRARIES} CACHE STRING "")
+SET (OGRE_LIB_DIR ${OGRE_LIB_DIR} CACHE PATH "")
+
+IF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES AND OGRE_LIB_DIR)
+    SET(OGRE_FOUND TRUE)
+ENDIF (OGRE_INCLUDE_DIR AND OGRE_LIBRARIES AND OGRE_LIB_DIR)
+
+IF (OGRE_FOUND)
+    IF (NOT OGRE_FIND_QUIETLY)
+        MESSAGE(STATUS "Ogre was found.")
+        IF (VERBOSE_FIND)
+            MESSAGE (STATUS "  include path: ${OGRE_INCLUDE_DIR}")
+            MESSAGE (STATUS "  library path: ${OGRE_LIB_DIR}")
+            MESSAGE (STATUS "  libraries:    ${OGRE_LIBRARIES}")
+        ENDIF (VERBOSE_FIND)
+    ENDIF (NOT OGRE_FIND_QUIETLY)
+ELSE (OGRE_FOUND)
+    IF (NOT OGRE_INCLUDE_DIR)
+        MESSAGE(SEND_ERROR "Ogre include path was not found.")
+    ENDIF (NOT OGRE_INCLUDE_DIR)
+    IF (NOT OGRE_LIB_DIR)
+        MESSAGE(SEND_ERROR "Ogre library was not found.")
+    ENDIF (NOT OGRE_LIB_DIR)
+    IF (NOT OGRE_LIBRARIES)
+        MESSAGE(SEND_ERROR "Ogre libraries not known.")
+    ENDIF (NOT OGRE_LIBRARIES)
+ENDIF (OGRE_FOUND)
Index: /code/branches/ceguilua/cmake/FindOggVorbis.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindOggVorbis.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindOggVorbis.cmake	(revision 1801)
@@ -0,0 +1,151 @@
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+  SET(OGG_FIND_QUIETLY TRUE)
+ENDIF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+
+IF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY)
+  SET(VORBIS_FIND_QUIETLY TRUE)
+ENDIF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY) 
+
+
+#SET(OGGVORBIS_LIBRARY_DIR "/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/lib")
+#SET(OGGVORBIS_LIBRARY "-L ${OGGVORBIS_LIBRARY_DIR} -lvorbisenc -lvorbisfile -logg -lvorbis ")
+#SET(OGGVORBIS_INCLUDE_DIR "/usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include")
+
+#
+# Includes
+#
+
+FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include 		# Tardis specific hack
+  /usr/local/include
+  /usr/include
+  /sw/include
+  /opt/local/include
+  /opt/csw/include
+  /opt/csw/include
+  /opt/include
+  ../libs/libogg-1.1.3/include
+  )
+
+FIND_PATH(VORBIS_INCLUDE_DIR vorbis/codec.h
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.0/include 		# Tardis specific hack
+  /usr/local/include
+  /usr/include
+  /sw/include
+  /opt/local/include
+  /opt/csw/include
+  /opt/csw/include
+  /opt/include
+  ../libs/libvorbis-1.2.0/include
+  )
+
+#
+# Libs
+#
+
+FIND_LIBRARY(OGG_LIBRARY
+  NAMES ogg
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libogg-1.1.3/src/.libs
+  )
+
+FIND_LIBRARY(VORBIS_LIBRARY
+  NAMES vorbis
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libvorbis-1.2.0/lib/.libs
+  )
+
+FIND_LIBRARY(VORBISENC_LIBRARY
+  NAMES vorbisenc
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libvorbis-1.2.0/lib/.libs
+  )
+
+FIND_LIBRARY(VORBISFILE_LIBRARY
+  NAMES vorbisfile
+  PATHS
+  /usr/pack/oggvorbis-1.0-ds/i686-debian-linux3.1/lib
+  /usr/local/lib
+  /usr/lib
+  /sw/lib
+  /opt/local/lib
+  /opt/csw/lib
+  /opt/lib
+  ../libs/libvorbis-1.2.0/lib/.libs
+  )
+
+SET (OGG_FOUND "NO")
+
+IF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+  SET (OGG_FOUND "YES")
+  IF (NOT OGG_FIND_QUIETLY)
+    MESSAGE (STATUS "Ogg was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${OGG_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${OGG_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    ogg")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT OGG_FIND_QUIETLY)
+ELSE (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+  IF (NOT OGG_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "Ogg include path was not found.")
+  ENDIF (NOT OGG_INCLUDE_DIR)
+  IF (NOT OGG_LIBRARY)
+    MESSAGE (SEND_ERROR "Ogg library was not found.")
+  ENDIF (NOT OGG_LIBRARY)
+ENDIF (OGG_INCLUDE_DIR AND OGG_LIBRARY)
+
+
+SET (VORBIS_FOUND "NO")
+
+IF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY)
+  SET (VORBIS_FOUND "YES")
+  IF (NOT VORBIS_FIND_QUIETLY)
+    MESSAGE (STATUS "Vorbis was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${VORBIS_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${VORBIS_LIBRARY}")
+      MESSAGE (STATUS "  library path: ${VORBISENC_LIBRARY}")
+      MESSAGE (STATUS "  library path: ${VORBISFILE_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    vorbis vorbisenc vorbisfile")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT VORBIS_FIND_QUIETLY)
+ELSE (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY)
+  IF (NOT VORBIS_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "Vorbis include path was not found.")
+  ENDIF (NOT VORBIS_INCLUDE_DIR)
+  IF (NOT VORBIS_LIBRARY)
+    MESSAGE (SEND_ERROR "Vorbis library \"vorbis\" was not found.")
+  ENDIF (NOT VORBIS_LIBRARY)
+  IF (NOT VORBISENC_LIBRARY)
+    MESSAGE (SEND_ERROR "Vorbis library \"vorbisenc\" was not found.")
+  ENDIF (NOT VORBISENC_LIBRARY)
+  IF (NOT VORBISFILE_LIBRARY)
+    MESSAGE (SEND_ERROR "Vorbis library \"vorbisfile\" was not found.")
+  ENDIF (NOT VORBISFILE_LIBRARY)
+ENDIF (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISENC_LIBRARY AND VORBISFILE_LIBRARY)
+
Index: /code/branches/ceguilua/cmake/FindOpenAL.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindOpenAL.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindOpenAL.cmake	(revision 1801)
@@ -0,0 +1,111 @@
+# - Locate OpenAL
+# This module defines
+#  OPENAL_LIBRARY
+#  OPENAL_FOUND, if false, do not try to link to OpenAL
+#  OPENAL_INCLUDE_DIR, where to find the headers
+#
+# $OPENALDIR is an environment variable that would
+# correspond to the ./configure --prefix=$OPENALDIR
+# used in building OpenAL.
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+  SET(OPENAL_FIND_QUIETLY TRUE)
+ENDIF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+
+# Created by Eric Wing. This was influenced by the FindSDL.cmake module.
+# On OSX, this will prefer the Framework version (if found) over others.
+# People will have to manually change the cache values of
+# OPENAL_LIBRARY to override this selection.
+# Tiger will include OpenAL as part of the System.
+# But for now, we have to look around.
+# Other (Unix) systems should be able to utilize the non-framework paths.
+FIND_PATH(OPENAL_INCLUDE_DIR AL/al.h
+  $ENV{OPENALDIR}/include
+  ~/Library/Frameworks/OpenAL.framework/Headers
+  /Library/Frameworks/OpenAL.framework/Headers
+  /System/Library/Frameworks/OpenAL.framework/Headers # Tiger
+  /usr/pack/openal-0.0.8-cl/include # Tardis specific hack
+  /usr/local/include/
+  /usr/local/include/OpenAL
+  /usr/local/include
+  /usr/include/
+  /usr/include/OpenAL
+  /usr/include
+  /sw/include # Fink
+  /sw/include/OpenAL
+  /sw/include
+  /opt/local/include # DarwinPorts
+  /opt/local/include/OpenAL
+  /opt/local/include
+  /opt/csw/include # Blastwave
+  /opt/csw/include/OpenAL
+  /opt/csw/include
+  /opt/include
+  /opt/include/OpenAL
+  /opt/include
+  ../libs/openal-0.0.8/common/include
+  )
+# I'm not sure if I should do a special casing for Apple. It is
+# unlikely that other Unix systems will find the framework path.
+# But if they do ([Next|Open|GNU]Step?),
+# do they want the -framework option also?
+IF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+  STRING(REGEX REPLACE "(.*)/.*\\.framework/.*" "\\1" OPENAL_FRAMEWORK_PATH_TMP ${OPENAL_INCLUDE_DIR})
+  IF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is in default search path, don't need to use -F
+    SET (OPENAL_LIBRARY "-framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ELSE("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+      OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+      )
+    # String is not /Library/Frameworks, need to use -F
+    SET(OPENAL_LIBRARY "-F${OPENAL_FRAMEWORK_PATH_TMP} -framework OpenAL" CACHE STRING "OpenAL framework for OSX")
+  ENDIF("${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/Library/Frameworks"
+    OR "${OPENAL_FRAMEWORK_PATH_TMP}" STREQUAL "/System/Library/Frameworks"
+    )
+  # Clear the temp variable so nobody can see it
+  SET(OPENAL_FRAMEWORK_PATH_TMP "" CACHE INTERNAL "")
+
+ELSE(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+  FIND_LIBRARY(OPENAL_LIBRARY
+    NAMES openal al OpenAL32
+    PATHS
+    $ENV{OPENALDIR}/lib
+    $ENV{OPENALDIR}/libs
+    /usr/pack/openal-0.0.8-cl/i686-debian-linux3.1/lib
+    /usr/local/lib
+    /usr/lib
+    /sw/lib
+    /opt/local/lib
+    /opt/csw/lib
+    /opt/lib
+    ../libs/openal-0.0.8/src/.libs
+    )
+ENDIF(${OPENAL_INCLUDE_DIR} MATCHES ".framework")
+
+SET (OPENAL_FOUND "NO")
+
+IF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+  SET (OPENAL_FOUND "YES")
+  IF (NOT OPENAL_FIND_QUIETLY)
+    MESSAGE (STATUS "OpenAL was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${OPENAL_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${OPENAL_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    openal al OpenAL32")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT OPENAL_FIND_QUIETLY)
+ELSE (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+  IF (NOT OPENAL_INCLUDE_DIR)
+    MESSAGE (SEND_ERROR "OpenAL include path was not found.")
+  ENDIF (NOT OPENAL_INCLUDE_DIR)
+  IF (NOT OPENAL_LIBRARY)
+    MESSAGE (SEND_ERROR "OpenAL library was not found.")
+  ENDIF (NOT OPENAL_LIBRARY)
+ENDIF (OPENAL_LIBRARY AND OPENAL_INCLUDE_DIR)
+
+
Index: /code/branches/ceguilua/cmake/FindPkgConfig.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindPkgConfig.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindPkgConfig.cmake	(revision 1801)
@@ -0,0 +1,360 @@
+# - a pkg-config module for CMake
+#
+# Usage:
+#   pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+#     checks for all the given modules
+#
+#   pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+#     checks for given modules and uses the first working one
+#
+# When the 'REQUIRED' argument was set, macros will fail with an error
+# when module(s) could not be found
+#
+# It sets the following variables:
+#   PKG_CONFIG_FOUND         ... true iff pkg-config works on the system
+#   PKG_CONFIG_EXECUTABLE    ... pathname of the pkg-config program
+#   <PREFIX>_FOUND           ... set to 1 iff module(s) exist
+#
+# For the following variables two sets of values exist; first one is the
+# common one and has the given PREFIX. The second set contains flags
+# which are given out when pkgconfig was called with the '--static'
+# option.
+#   <XPREFIX>_LIBRARIES      ... only the libraries (w/o the '-l')
+#   <XPREFIX>_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
+#   <XPREFIX>_LDFLAGS        ... all required linker flags
+#   <XPREFIX>_LDFLAGS_OTHERS ... all other linker flags
+#   <XPREFIX>_INCLUDE_DIRS   ... the '-I' preprocessor flags (w/o the '-I')
+#   <XPREFIX>_CFLAGS         ... all required cflags
+#   <XPREFIX>_CFLAGS_OTHERS  ... the other compiler flags
+#
+#   <XPREFIX> = <PREFIX>        for common case
+#   <XPREFIX> = <PREFIX>_STATIC for static linking
+#
+# There are some special variables whose prefix depends on the count
+# of given modules. When there is only one module, <PREFIX> stays
+# unchanged. When there are multiple modules, the prefix will be
+# changed to <PREFIX>_<MODNAME>:
+#   <XPREFIX>_VERSION    ... version of the module
+#   <XPREFIX>_PREFIX     ... prefix-directory of the module
+#   <XPREFIX>_INCLUDEDIR ... include-dir of the module
+#   <XPREFIX>_LIBDIR     ... lib-dir of the module
+#
+#   <XPREFIX> = <PREFIX>  when |MODULES| == 1, else
+#   <XPREFIX> = <PREFIX>_<MODNAME>
+#
+# A <MODULE> parameter can have the following formats:
+#   {MODNAME}            ... matches any version
+#   {MODNAME}>={VERSION} ... at least version <VERSION> is required
+#   {MODNAME}={VERSION}  ... exactly version <VERSION> is required
+#   {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
+#
+# Examples
+#   pkg_check_modules (GLIB2   glib-2.0)
+#
+#   pkg_check_modules (GLIB2   glib-2.0>=2.10)
+#     requires at least version 2.10 of glib2 and defines e.g.
+#       GLIB2_VERSION=2.10.3
+#
+#   pkg_check_modules (FOO     glib-2.0>=2.10 gtk+-2.0)
+#     requires both glib2 and gtk2, and defines e.g.
+#       FOO_glib-2.0_VERSION=2.10.3
+#       FOO_gtk+-2.0_VERSION=2.8.20
+#
+#   pkg_check_modules (XRENDER REQUIRED xrender)
+#     defines e.g.:
+#       XRENDER_LIBRARIES=Xrender;X11
+#       XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
+#
+#   pkg_search_module (BAR     libxml-2.0 libxml2 libxml>=2)
+
+
+# Copyright (C) 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+#
+# Redistribution and use, with or without modification, are permitted
+# provided that the following conditions are met:
+# 
+#    1. Redistributions must retain the above copyright notice, this
+#       list of conditions and the following disclaimer.
+#    2. The name of the author may not be used to endorse or promote
+#       products derived from this software without specific prior
+#       written permission.
+# 
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+### Common stuff ####
+set(PKG_CONFIG_VERSION 1)
+set(PKG_CONFIG_FOUND   0)
+
+find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
+mark_as_advanced(PKG_CONFIG_EXECUTABLE)
+
+if(PKG_CONFIG_EXECUTABLE)
+  set(PKG_CONFIG_FOUND 1)
+endif(PKG_CONFIG_EXECUTABLE)
+
+
+# Unsets the given variables
+macro(_pkgconfig_unset var)
+  set(${var} "" CACHE INTERNAL "")
+endmacro(_pkgconfig_unset)
+
+macro(_pkgconfig_set var value)
+  set(${var} ${value} CACHE INTERNAL "")
+endmacro(_pkgconfig_set)
+
+# Invokes pkgconfig, cleans up the result and sets variables
+macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp)
+  set(_pkgconfig_invoke_result)
+
+  execute_process(
+    COMMAND ${PKG_CONFIG_EXECUTABLE} ${ARGN} ${_pkglist}
+    OUTPUT_VARIABLE _pkgconfig_invoke_result
+    RESULT_VARIABLE _pkgconfig_failed)
+
+  if (_pkgconfig_failed)
+    set(_pkgconfig_${_varname} "")
+    _pkgconfig_unset(${_prefix}_${_varname})
+  else(_pkgconfig_failed)
+    string(REGEX REPLACE "[\r\n]"                  " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+    string(REGEX REPLACE " +$"                     ""  _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+
+    if (NOT ${_regexp} STREQUAL "")
+      string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}")
+    endif(NOT ${_regexp} STREQUAL "")
+
+    separate_arguments(_pkgconfig_invoke_result)
+
+    #message(STATUS "  ${_varname} ... ${_pkgconfig_invoke_result}")
+    set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result})
+    _pkgconfig_set(${_prefix}_${_varname} "${_pkgconfig_invoke_result}")
+  endif(_pkgconfig_failed)
+endmacro(_pkgconfig_invoke)
+
+# Invokes pkgconfig two times; once without '--static' and once with
+# '--static'
+macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
+  _pkgconfig_invoke("${_pkglist}" ${_prefix}        ${_varname} "${cleanup_regexp}" ${ARGN})
+  _pkgconfig_invoke("${_pkglist}" ${_prefix} STATIC_${_varname} "${cleanup_regexp}" --static  ${ARGN})
+endmacro(_pkgconfig_invoke_dyn)
+
+# Splits given arguments into options and a package list
+macro(_pkgconfig_parse_options _result _is_req)
+  set(${_is_req} 0)
+  
+  foreach(_pkg ${ARGN})
+    if (_pkg STREQUAL "REQUIRED")
+      set(${_is_req} 1)
+    endif (_pkg STREQUAL "REQUIRED")
+  endforeach(_pkg ${ARGN})
+
+  set(${_result} ${ARGN})
+  list(REMOVE_ITEM ${_result} "REQUIRED")
+endmacro(_pkgconfig_parse_options)
+
+###
+macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
+  _pkgconfig_unset(${_prefix}_FOUND)
+  _pkgconfig_unset(${_prefix}_VERSION)
+  _pkgconfig_unset(${_prefix}_PREFIX)
+  _pkgconfig_unset(${_prefix}_INCLUDEDIR)
+  _pkgconfig_unset(${_prefix}_LIBDIR)
+  _pkgconfig_unset(${_prefix}_LIBS)
+  _pkgconfig_unset(${_prefix}_LIBS_L)
+  _pkgconfig_unset(${_prefix}_LIBS_PATHS)
+  _pkgconfig_unset(${_prefix}_LIBS_OTHER)
+  _pkgconfig_unset(${_prefix}_CFLAGS)
+  _pkgconfig_unset(${_prefix}_CFLAGS_I)
+  _pkgconfig_unset(${_prefix}_CFLAGS_OTHER)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBDIR)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS_L)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS_PATHS)
+  _pkgconfig_unset(${_prefix}_STATIC_LIBS_OTHER)
+  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS)
+  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_I)
+  _pkgconfig_unset(${_prefix}_STATIC_CFLAGS_OTHER)
+
+  # create a better addressable variable of the modules and calculate its size
+  set(_pkg_check_modules_list ${ARGN})
+  list(LENGTH _pkg_check_modules_list _pkg_check_modules_cnt)
+
+  if(PKG_CONFIG_EXECUTABLE)
+    # give out status message telling checked module
+    if (NOT ${_is_silent})
+      if (_pkg_check_modules_cnt EQUAL 1)
+        message(STATUS "checking for module '${_pkg_check_modules_list}'")
+      else(_pkg_check_modules_cnt EQUAL 1)
+        message(STATUS "checking for modules '${_pkg_check_modules_list}'")
+      endif(_pkg_check_modules_cnt EQUAL 1)
+    endif(NOT ${_is_silent})
+    
+    set(_pkg_check_modules_packages)
+    set(_pkg_check_modules_failed)
+
+    # iterate through module list and check whether they exist and match the required version
+    foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
+      set(_pkg_check_modules_exist_query)
+
+      # check whether version is given
+      if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
+        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op   "${_pkg_check_modules_pkg}")
+        string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver  "${_pkg_check_modules_pkg}")
+      else(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+        set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
+        set(_pkg_check_modules_pkg_op)
+        set(_pkg_check_modules_pkg_ver)
+      endif(_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
+
+      # handle the operands
+      if (_pkg_check_modules_pkg_op STREQUAL ">=")
+        list(APPEND _pkg_check_modules_exist_query --atleast-version)
+      endif(_pkg_check_modules_pkg_op STREQUAL ">=")
+
+      if (_pkg_check_modules_pkg_op STREQUAL "=")
+        list(APPEND _pkg_check_modules_exist_query --exact-version)
+      endif(_pkg_check_modules_pkg_op STREQUAL "=")
+      
+      if (_pkg_check_modules_pkg_op STREQUAL "<=")
+        list(APPEND _pkg_check_modules_exist_query --max-version)
+      endif(_pkg_check_modules_pkg_op STREQUAL "<=")
+
+      # create the final query which is of the format:
+      # * --atleast-version <version> <pkg-name>
+      # * --exact-version <version> <pkg-name>      
+      # * --max-version <version> <pkg-name>
+      # * --exists <pkg-name>
+      if (_pkg_check_modules_pkg_op)
+        list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_ver}")
+      else(_pkg_check_modules_pkg_op)
+        list(APPEND _pkg_check_modules_exist_query --exists)
+      endif(_pkg_check_modules_pkg_op)
+
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_VERSION)
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_PREFIX)
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_INCLUDEDIR)
+      _pkgconfig_unset(${_prefix}_${_pkg_check_modules_pkg_name}_LIBDIR)
+
+      list(APPEND _pkg_check_modules_exist_query "${_pkg_check_modules_pkg_name}")
+      list(APPEND _pkg_check_modules_packages    "${_pkg_check_modules_pkg_name}")
+
+      # execute the query
+      execute_process(
+        COMMAND ${PKG_CONFIG_EXECUTABLE} ${_pkg_check_modules_exist_query}
+        RESULT_VARIABLE _pkgconfig_retval)
+
+      # evaluate result and tell failures
+      if (_pkgconfig_retval)
+        if(NOT ${_is_silent})
+          message(STATUS "  package '${_pkg_check_modules_pkg}' not found")
+        endif(NOT ${_is_silent})
+
+        set(_pkg_check_modules_failed 1)
+      endif(_pkgconfig_retval)
+    endforeach(_pkg_check_modules_pkg)
+
+    if(_pkg_check_modules_failed)
+      # fail when requested
+      if (${_is_required})
+        message(SEND_ERROR "A required package was not found")
+      endif (${_is_required})
+    else(_pkg_check_modules_failed)
+      # when we are here, we checked whether requested modules
+      # exist. Now, go through them and set variables
+      
+      _pkgconfig_set(${_prefix}_FOUND 1)
+      list(LENGTH _pkg_check_modules_packages pkg_count)
+
+      # iterate through all modules again and set individual variables
+      foreach (_pkg_check_modules_pkg ${_pkg_check_modules_packages})
+        # handle case when there is only one package required
+        if (pkg_count EQUAL 1)
+          set(_pkg_check_prefix "${_prefix}")
+        else(pkg_count EQUAL 1)
+          set(_pkg_check_prefix "${_prefix}_${_pkg_check_modules_pkg}")
+        endif(pkg_count EQUAL 1)
+        
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" VERSION    ""   --modversion )
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" PREFIX     ""   --variable=prefix )
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR ""   --variable=includedir )
+        _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR     ""   --variable=libdir )
+
+        message(STATUS "  found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}")
+      endforeach(_pkg_check_modules_pkg)
+
+      # set variables which are combined for multiple modules
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARIES           "(^| )-l" --libs-only-l )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS        "(^| )-L" --libs-only-L )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS             ""        --libs )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER       ""        --libs-only-other )
+
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS        "(^| )-I" --cflags-only-I )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS              ""        --cflags )
+      _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER        ""        --cflags-only-other )
+    endif(_pkg_check_modules_failed)
+  else(PKG_CONFIG_EXECUTABLE)
+    if (${_is_required})
+      message(SEND_ERROR "pkg-config tool not found")
+    endif (${_is_required})
+  endif(PKG_CONFIG_EXECUTABLE)
+endmacro(_pkg_check_modules_internal)
+
+###
+### User visible macros start here
+###
+
+###
+macro(pkg_check_modules _prefix _module0)
+  # check cached value
+  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+    _pkgconfig_parse_options   (_pkg_modules _pkg_is_required "${_module0}" ${ARGN})
+    _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules})
+
+    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+  endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+endmacro(pkg_check_modules)
+
+###
+macro(pkg_search_module _prefix _module0)
+  # check cached value
+  if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})
+    set(_pkg_modules_found 0)
+    _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN})
+
+    message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
+
+    # iterate through all modules and stop at the first working one.
+    foreach(_pkg_alt ${_pkg_modules_alt})
+      if(NOT _pkg_modules_found)
+        _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
+      endif(NOT _pkg_modules_found)
+
+      if (${_prefix}_FOUND)
+        set(_pkg_modules_found 1)
+      endif(${_prefix}_FOUND)
+    endforeach(_pkg_alt)
+
+    if (NOT ${_prefix}_FOUND)
+      if(${_pkg_is_required})
+        message(SEND_ERROR "None of the required '${_pkg_modules_alt}' found")
+      endif(${_pkg_is_required})
+    endif(NOT ${_prefix}_FOUND)
+    
+    _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
+  endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION})  
+endmacro(pkg_search_module)
+
+### Local Variables:
+### mode: cmake
+### End:
Index: /code/branches/ceguilua/cmake/FindTCL.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindTCL.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindTCL.cmake	(revision 1801)
@@ -0,0 +1,88 @@
+# - Find Tcl includes and libraries.
+# This module finds if TCL is installed and determines where the
+# include files and libraries are. It also determines what the name of
+# the library is. This code sets the following variables:
+#  TCL_LIBRARY        = path to Tcl library (tcl tcl80)
+#  TCL_LIBRARY_DEBUG  = path to Tcl library (debug)
+#  TCL_INCLUDE_PATH   = path to where tcl.h can be found
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+  SET(TCL_FIND_QUIETLY TRUE)
+ENDIF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+
+SET (TCLTK_POSSIBLE_LIB_PATHS
+  "${TCL_TCLSH_PATH}/../lib"
+  "${TK_WISH_PATH}/../lib"
+  "${TCL_INCLUDE_PATH}/../lib"
+  "${TK_INCLUDE_PATH}/../lib"
+  "$ENV{ProgramFiles}/Tcl/Lib"
+  "C:/Program Files/Tcl/lib" 
+  "C:/Tcl/lib" 
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/lib
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/lib
+  /usr/lib 
+  /usr/local/lib
+  /usr/pack/tcltk-8.4.9.linux-mo/lib
+  ../libs/tcl8.5.2/win
+  ../libs/tcl8.5.2/unix
+  ../libs/tcl8.5.2/macosx
+)
+
+FIND_LIBRARY(TCL_LIBRARY
+  NAMES tcl tcl85 tcl8.5 tcl84 tcl8.4
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+FIND_LIBRARY(TCL_LIBRARY_DEBUG
+  NAMES tcld tcl85d tcl8.5d tcl84d tcl8.4d
+  PATHS ${TCLTK_POSSIBLE_LIB_PATHS}
+)
+
+SET (TCLTK_POSSIBLE_INCLUDE_PATHS
+  ${TCL_TCLSH_PATH}/../include
+  ${TK_WISH_PATH}/../include
+  "${TCL_LIBRARY_PATH}/../include"
+  "${TK_LIBRARY_PATH}/../include"
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.5;Root]/include
+  [HKEY_LOCAL_MACHINE\\SOFTWARE\\Scriptics\\Tcl\\8.4;Root]/include
+  "$ENV{ProgramFiles}/Tcl/include"
+  "C:/Program Files/Tcl/include"
+  C:/Tcl/include
+  /usr/include
+  /usr/local/include
+  /usr/include/tcl8.5
+  /usr/include/tcl8.4
+  ../libs/tcl8.5.2/generic
+)
+
+FIND_PATH(TCL_INCLUDE_PATH tcl.h
+  ${TCL_FRAMEWORK_INCLUDES} ${TCLTK_POSSIBLE_INCLUDE_PATHS}
+)
+
+
+IF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+  IF (NOT TCL_FIND_QUIETLY)
+    MESSAGE(STATUS "Tcl was found")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${TCL_INCLUDE_PATH}")
+      MESSAGE (STATUS "  library path: ${TCL_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    tcld tcl85d tcl8.5d tcl84d tcl8.4d")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT TCL_FIND_QUIETLY)
+ELSE (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+  IF (NOT TCL_INCLUDE_PATH)
+    MESSAGE(SEND_ERROR "Tcl include path was not found.")
+  ENDIF (NOT TCL_INCLUDE_PATH)
+  IF (NOT TCL_LIBRARY )
+    MESSAGE(SEND_ERROR "Tcl library was not found.")
+  ENDIF (NOT TCL_LIBRARY )
+ENDIF (TCL_LIBRARY AND TCL_INCLUDE_PATH)
+
+IF(TCL_INCLUDE_PATH)
+  IF(TCL_LIBRARY)
+    SET(TCL_FOUND 1)
+  ENDIF(TCL_LIBRARY)
+ENDIF(TCL_INCLUDE_PATH)
Index: /code/branches/ceguilua/cmake/FindZLIB.cmake
===================================================================
--- /code/branches/ceguilua/cmake/FindZLIB.cmake	(revision 1801)
+++ /code/branches/ceguilua/cmake/FindZLIB.cmake	(revision 1801)
@@ -0,0 +1,74 @@
+# - Find zlib
+# Find the native ZLIB includes and library
+#
+#  ZLIB_INCLUDE_DIR - where to find zlib.h, etc.
+#  ZLIB_LIBRARY     - List of libraries when using zlib.
+#  ZLIB_FOUND       - True if zlib found.
+#
+#  Modified by Nicolas Schlumberger, (c) 2007
+#  to make it work on the Tardis Infrastucture of the ETH Zurich
+#
+# Several changes and additions by Fabian 'x3n' Landau
+#                 > www.orxonox.net <
+
+IF (ZLIB_INCLUDE_DIR)
+  SET(ZLIB_FIND_QUIETLY TRUE)
+ENDIF (ZLIB_INCLUDE_DIR)
+
+IF(UNIX)
+  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
+    /usr/pack/zziplib-0.13.49-sd/include/
+    /usr/local/include
+    /usr/include
+  )
+
+  SET(ZLIB_NAMES z zlib zdll)
+  FIND_LIBRARY(ZLIB_LIBRARY
+    NAMES ${ZLIB_NAMES}
+    PATHS /usr/pack/zziplib-0.13.49-sd/i686-debian-linux3.1/lib/ /usr/lib /usr/local/lib
+  )
+ENDIF(UNIX)
+
+IF(WIN32)
+  IF(EXISTS "../libs/zlib")
+    SET (ZLIB_LIBRARY_DIR "../libs/zlib")
+  ENDIF(EXISTS "../libs/zlib")
+
+  FIND_PATH(ZLIB_INCLUDE_DIR zlib.h
+    ../libs/zlib/include
+  )
+
+  FIND_LIBRARY(ZLIB_LIBRARY
+    NAMES zlib
+    PATHS ${ZLIB_LIBRARY_DIR}
+  )
+ENDIF(WIN32)
+
+SET(ZLIB_FOUND FALSE)
+IF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+  SET(ZLIB_FOUND TRUE)
+ENDIF (ZLIB_INCLUDE_DIR AND ZLIB_LIBRARY)
+
+IF (ZLIB_FOUND)
+  IF (NOT ZLIB_FIND_QUIETLY)
+    MESSAGE(STATUS "ZLIB was found.")
+    IF (VERBOSE_FIND)
+      MESSAGE (STATUS "  include path: ${ZLIB_INCLUDE_DIR}")
+      MESSAGE (STATUS "  library path: ${ZLIB_LIBRARY}")
+      MESSAGE (STATUS "  libraries:    zlib")
+    ENDIF (VERBOSE_FIND)
+  ENDIF (NOT ZLIB_FIND_QUIETLY)
+ELSE (ZLIB_FOUND)
+  IF (NOT ZLIB_INCLUDE_DIR)
+    MESSAGE(SEND_ERROR "ZLIB include path was not found.")
+  ENDIF (NOT ZLIB_INCLUDE_DIR)
+  IF (NOT ZLIB_LIBRARY)
+    MESSAGE(SEND_ERROR "ZLIB was not found.")
+    MESSAGE(STATUS "Looked for Z libraries named ${ZLIBS_NAMES}.")
+  ENDIF (NOT ZLIB_LIBRARY)
+ENDIF (ZLIB_FOUND)
+
+MARK_AS_ADVANCED(
+  ZLIB_LIBRARY
+  ZLIB_INCLUDE_DIR
+)
Index: /code/branches/ceguilua/cmakeclearcache
===================================================================
--- /code/branches/ceguilua/cmakeclearcache	(revision 1801)
+++ /code/branches/ceguilua/cmakeclearcache	(revision 1801)
@@ -0,0 +1,11 @@
+#!/bin/bash
+# Clears the cmake cache
+# Author: Nicolas Perrenoud <nicolape@ee.ethz.ch>
+# Co-Author: Nicolas Schlumberger <nico_at_orxonox.net>
+
+find . -name "CMakeCache.txt" -exec rm -f {} \;
+find . -name "cmake_install.cmake" -exec rm -f {} \;
+find . -name "CMakeFiles" -exec rm -fr {} \;
+find . -name "Makefile" -exec rm -fr {} \;
+
+echo "Cmake Cache cleared!"
Index: /code/branches/ceguilua/run
===================================================================
--- /code/branches/ceguilua/run	(revision 1801)
+++ /code/branches/ceguilua/run	(revision 1801)
@@ -0,0 +1,4 @@
+#!/bin/bash
+cd bin
+./run-script $@
+cd ..
Index: /code/branches/ceguilua/src/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,15 @@
+INCLUDE_DIRECTORIES(.)
+INCLUDE_DIRECTORIES(..)
+INCLUDE_DIRECTORIES(orxonox)
+INCLUDE_DIRECTORIES(tolua)
+
+ADD_SUBDIRECTORY(cpptcl)
+ADD_SUBDIRECTORY(ois)
+ADD_SUBDIRECTORY(tinyxml)
+ADD_SUBDIRECTORY(tolua)
+
+ADD_SUBDIRECTORY(util)
+ADD_SUBDIRECTORY(core)
+ADD_SUBDIRECTORY(audio)
+ADD_SUBDIRECTORY(network)
+ADD_SUBDIRECTORY(orxonox)
Index: /code/branches/ceguilua/src/audio/AudioBuffer.cc
===================================================================
--- /code/branches/ceguilua/src/audio/AudioBuffer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioBuffer.cc	(revision 1801)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioBuffer.h"
+
+namespace audio
+{
+    AudioBuffer::AudioBuffer(std::string fileName)
+    {
+        // Load wav data into buffers.
+        alGenBuffers(1, &buffer);
+
+        if (alGetError() != AL_NO_ERROR)
+            loaded=AL_FALSE;
+
+        //FIXME deprecated; seems unneeded
+//        alutLoadWAVFile((ALbyte*)fileName.c_str(), &format, &data, &size, &freq, &loop);
+        alBufferData(buffer, format, data, size, freq);
+        //FIXME deprecated; seems unneeded
+//        alutUnloadWAV(format, data, size, freq);
+
+        // Do another error check and return.
+        if (alGetError() != AL_NO_ERROR)
+            loaded=AL_FALSE;
+        else
+              loaded=AL_TRUE;
+    }
+
+    AudioBuffer::~AudioBuffer()
+    {
+
+    }
+}
Index: /code/branches/ceguilua/src/audio/AudioBuffer.h
===================================================================
--- /code/branches/ceguilua/src/audio/AudioBuffer.h	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioBuffer.h	(revision 1801)
@@ -0,0 +1,61 @@
+/*
+ *   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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioBuffer_H__
+#define _AudioBuffer_H__
+
+#include "AudioPrereqs.h"
+
+#include <string>
+#include <AL/al.h>
+
+namespace audio
+{
+    class _AudioExport AudioBuffer
+    {
+    public:
+        AudioBuffer(std::string fileName);
+        ~AudioBuffer();
+
+    private:
+        // Buffers hold sound data.
+        ALuint buffer;
+        // Identifier
+        std::string name;
+        // True if AL was able to load data
+        ALboolean loaded;
+
+        ALenum format;
+        ALsizei size;
+        ALvoid* data;
+        ALsizei freq;
+        ALboolean loop;
+    };
+}
+
+#endif /* _AudioBuffer_H__ */
Index: /code/branches/ceguilua/src/audio/AudioIncludes.h
===================================================================
--- /code/branches/ceguilua/src/audio/AudioIncludes.h	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioIncludes.h	(revision 1801)
@@ -0,0 +1,47 @@
+/*
+ *   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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Various headers used in the audio lib. Avoid including this to
+         increase accuracy of header file dependencies.
+*/
+
+#include "AudioPrereqs.h"
+
+#include <iostream>
+#include <vector>
+#include <string>
+
+#include <AL/al.h>
+#include <AL/alc.h>
+#include <AL/alut.h>
+#include <ogg/ogg.h>
+#include <vorbis/codec.h>
+#include <vorbis/vorbisenc.h>
+#include <vorbis/vorbisfile.h>
Index: /code/branches/ceguilua/src/audio/AudioManager.cc
===================================================================
--- /code/branches/ceguilua/src/audio/AudioManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioManager.cc	(revision 1801)
@@ -0,0 +1,145 @@
+/*
+ *   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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioManager.h"
+
+#include <cstdlib>
+#include <AL/alut.h>
+
+#include "util/Debug.h"
+#include "AudioBuffer.h"
+#include "AudioSource.h"
+#include "AudioStream.h"
+
+namespace audio
+{
+    AudioManager::AudioManager()
+    {
+        ambientPath = "audio/ambient";
+
+        alutInit(NULL, 0);
+    }
+
+    AudioManager::~AudioManager()
+    {
+        for (unsigned int i=0;i<bgSounds.size();i++)
+        {
+            bgSounds[i]->release();
+        }
+        alutExit();
+    }
+
+    void AudioManager::ambientStart()
+    {
+// 		currentBgSound = 0;
+        if (bgSounds.size() > 0)
+        {
+            currentBgSound = rand() % bgSounds.size();
+            if(!bgSounds[currentBgSound]->playback())
+            {
+                COUT(2) << "AudioManager: Ogg refused to play." << std::endl;
+            }
+            else
+            {
+                COUT(3) << "Info: Started playing background sound" << std::endl;
+            }
+        }
+    }
+
+    void AudioManager::ambientStop()
+    {
+        COUT(3) << "Info: Stopped playing background sound" << std::endl;
+    }
+
+    void AudioManager::ambientAdd(std::string file)
+    {
+        std::string path = ambientPath + "/" + file + ".ogg";
+        AudioStream* tmp = new AudioStream(path);
+        tmp->open();
+        if (tmp->isLoaded())
+        {
+            bgSounds.push_back(tmp);
+            COUT(3) << "Info: Added background sound " << file << std::endl;
+        }
+    }
+
+    void AudioManager::tick(float dt)
+    {
+        if (bgSounds.size() > 0)
+        {
+            if (bgSounds[currentBgSound]->isLoaded())
+            {
+                bool playing = bgSounds[currentBgSound]->update();
+                if (!bgSounds[currentBgSound]->playing() && playing)
+                {
+                    if (!bgSounds[currentBgSound]->playback())
+                        COUT(2) << "AudioManager: Ogg abruptly stopped." << std::endl;
+                    else
+                        COUT(2) << "AudioManager: Ogg stream was interrupted." << std::endl;
+
+                }
+                if (!playing)
+                {
+//                    if (currentBgSound < bgSounds.size()-1)
+//                    {
+//                        currentBgSound++;
+//                    }
+//                    else
+//                    {
+//                        currentBgSound=0;
+//                    }
+                    // switch to next sound in list/array
+                    currentBgSound = ++currentBgSound % bgSounds.size();
+
+                    if (!bgSounds[currentBgSound]->isLoaded())
+                    {
+                        bgSounds[currentBgSound]->release();
+                        bgSounds[currentBgSound]->open();
+                    }
+                    bgSounds[currentBgSound]->playback();
+                    COUT(3) << "Info: Playing next background sound" << std::endl;
+                }
+            }
+        }
+    }
+
+    void AudioManager::setPos(std::vector<float> newPosition)
+    {
+
+    }
+
+    void AudioManager::setSpeed(std::vector<float> newSpeed)
+    {
+
+    }
+
+    void AudioManager::setOri(std::vector<float> at, std::vector<float> up)
+    {
+
+    }
+}
Index: /code/branches/ceguilua/src/audio/AudioManager.h
===================================================================
--- /code/branches/ceguilua/src/audio/AudioManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioManager.h	(revision 1801)
@@ -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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioManager_H__
+#define _AudioManager_H__
+
+#include "AudioPrereqs.h"
+
+#include <vector>
+#include <string>
+
+namespace audio
+{
+    class _AudioExport AudioManager
+    {
+    public:
+        // Init audio
+        AudioManager();
+
+        // Kill audio and set buffers, sources and memory free
+        ~AudioManager();
+
+        // Set listener position
+        void setPos(std::vector<float> newPosition);
+
+        // Set listener speed
+        void setSpeed(std::vector<float> newSpeed);
+
+        // Set listener orientation (first is direction
+        // the listener looks at, the second is the direction
+        // upwards the listener)
+        void setOri(std::vector<float> at, std::vector<float> up);
+
+        // Update
+        void tick(float dt);
+
+        void ambientAdd(std::string file);
+        void ambientStart();
+        void ambientStop();
+
+    private:
+        // Background sound
+        std::vector<AudioStream*> bgSounds;
+        int currentBgSound;
+
+
+        std::string ambientPath;
+
+        // Vector containing all audio files
+        std::vector<AudioBuffer*> buffers;
+        // Vector containing all audio sources which referer to one buffer
+        std::vector<AudioSource*> sources;
+        // The ambient background sound
+        AudioSource* ambient;
+
+        std::vector<float> listenerPosition;
+        std::vector<float> listenerSpeed;
+        std::vector<float> listenerAt;
+        std::vector<float> listenerup;
+    };
+}
+
+#endif /* _AudioManager_H__ */
Index: /code/branches/ceguilua/src/audio/AudioPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/audio/AudioPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioPrereqs.h	(revision 1801)
@@ -0,0 +1,81 @@
+/*
+ *   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 Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _AudioPrereqs_H__
+#define _AudioPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( AUDIO_STATIC_BUILD )
+#  ifdef AUDIO_SHARED_BUILD
+#    define _AudioExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _AudioExport
+#    else
+#      define _AudioExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _AudioExport  __attribute__ ((visibility("default")))
+#else
+#  define _AudioExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace audio
+{
+  class AudioBuffer;
+  class AudioManager;
+  class AudioSource;
+  class AudioStream;
+}
+
+//-----------------------------------------------------------------------
+// Warnings
+//-----------------------------------------------------------------------
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+
+// set to 4: conversion from 'ogg_int64_t' to 'long', possible loss of data
+#pragma warning (4 : 4244)
+
+#endif
+
+
+#endif /* _AudioPrereqs_H__ */
Index: /code/branches/ceguilua/src/audio/AudioSource.cc
===================================================================
--- /code/branches/ceguilua/src/audio/AudioSource.cc	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioSource.cc	(revision 1801)
@@ -0,0 +1,42 @@
+/*
+ *   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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioSource.h"
+
+namespace audio
+{
+    AudioSource::AudioSource()
+    {
+
+    }
+
+    AudioSource::~AudioSource()
+    {
+
+    }
+}
Index: /code/branches/ceguilua/src/audio/AudioSource.h
===================================================================
--- /code/branches/ceguilua/src/audio/AudioSource.h	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioSource.h	(revision 1801)
@@ -0,0 +1,46 @@
+/*
+ *   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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioSource_H__
+#define _AudioSource_H__
+
+#include "AudioPrereqs.h"
+
+namespace audio
+{
+    class _AudioExport AudioSource
+    {
+    public:
+        AudioSource();
+        ~AudioSource();
+
+    private:
+    };
+}
+
+#endif /* _AudioSource_H__ */
Index: /code/branches/ceguilua/src/audio/AudioStream.cc
===================================================================
--- /code/branches/ceguilua/src/audio/AudioStream.cc	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioStream.cc	(revision 1801)
@@ -0,0 +1,272 @@
+/*
+ *   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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "AudioStream.h"
+#include "util/Debug.h"
+
+namespace audio
+{
+    AudioStream::AudioStream(std::string path)
+    {
+        this->path = path;
+        loaded = false;
+    }
+
+    void AudioStream::open()
+    {
+        int result;
+
+        oggFile = fopen(path.c_str(), "rb");
+        if (!oggFile)
+        {
+            COUT(2) << "AudioStream: Could not open Ogg file " << path << std::endl;
+            return;
+        }
+
+        if ((result = ov_open(oggFile, &oggStream, NULL, 0)) < 0)
+        {
+            fclose(oggFile);
+            COUT(2) << "AudioStream: Could not open Ogg stream. " << errorString(result) << std::endl;
+            return;
+        }
+
+        loaded = true;
+
+        vorbisInfo = ov_info(&oggStream, -1);
+        vorbisComment = ov_comment(&oggStream, -1);
+
+        if (vorbisInfo->channels == 1)
+            format = AL_FORMAT_MONO16;
+        else
+            format = AL_FORMAT_STEREO16;
+
+
+        alGenBuffers(2, buffers);
+        check();
+        alGenSources(1, &source);
+        check();
+
+        alSource3f(source, AL_POSITION,        0.0, 0.0, 0.0);
+        alSource3f(source, AL_VELOCITY,        0.0, 0.0, 0.0);
+        alSource3f(source, AL_DIRECTION,       0.0, 0.0, 0.0);
+        alSourcef (source, AL_ROLLOFF_FACTOR,  0.0          );
+        alSourcei (source, AL_SOURCE_RELATIVE, AL_FALSE     );
+    }
+
+
+
+    void AudioStream::release()
+    {
+        alSourceStop(source);
+        empty();
+        alDeleteSources(1, &source);
+        check();
+        alDeleteBuffers(1, buffers);
+        check();
+
+        ov_clear(&oggStream);
+        loaded = false;
+    }
+
+
+
+    void AudioStream::display()
+    {
+        if (loaded)
+        {
+            COUT(3)
+                << "version         " << vorbisInfo->version         << std::endl
+                << "channels        " << vorbisInfo->channels        << std::endl
+                << "rate (hz)       " << vorbisInfo->rate            << std::endl
+                << "bitrate upper   " << vorbisInfo->bitrate_upper   << std::endl
+                << "bitrate nominal " << vorbisInfo->bitrate_nominal << std::endl
+                << "bitrate lower   " << vorbisInfo->bitrate_lower   << std::endl
+                << "bitrate window  " << vorbisInfo->bitrate_window  << std::endl
+                << std::endl
+                << "vendor " << vorbisComment->vendor << std::endl;
+
+            for (int i = 0; i < vorbisComment->comments; i++)
+            {
+                COUT(3) << "   " << vorbisComment->user_comments[i] << std::endl;
+            }
+
+            COUT(3) << std::endl;
+        }
+    }
+
+
+
+    bool AudioStream::playback()
+    {
+        if (!loaded)
+        {
+            return false;
+        }
+
+        if (playing())
+            return true;
+
+        if (!stream(buffers[0]))
+            return false;
+
+        if (!stream(buffers[1]))
+            return false;
+
+        alSourceQueueBuffers(source, 2, buffers);
+        alSourcePlay(source);
+
+        return true;
+    }
+
+
+
+
+    bool AudioStream::playing()
+    {
+        if (!loaded)
+        {
+            return false;
+        }
+
+        ALenum state;
+        alGetSourcei(source, AL_SOURCE_STATE, &state);
+        return (state == AL_PLAYING);
+    }
+
+
+
+
+    bool AudioStream::update()
+    {
+        int processed;
+        bool active = true;
+
+        alGetSourcei(source, AL_BUFFERS_PROCESSED, &processed);
+
+        while (processed--)
+        {
+            ALuint buffer;
+
+            alSourceUnqueueBuffers(source, 1, &buffer);
+            check();
+
+            active = stream(buffer);
+
+            alSourceQueueBuffers(source, 1, &buffer);
+            check();
+        }
+
+        if (active==false)
+        {
+            loaded = false;
+        }
+        return active;
+    }
+
+
+
+
+    bool AudioStream::stream(ALuint buffer)
+    {
+        char pcm[BUFFER_SIZE];
+        int  size = 0;
+        int  section;
+        int  result;
+
+        while (size < BUFFER_SIZE)
+        {
+            result = ov_read(&oggStream, pcm + size, BUFFER_SIZE - size, 0, 2, 1, &section);
+
+            if (result > 0)
+                size += result;
+            else
+                if (result < 0)
+                    COUT(2) << "AudioStream: " << errorString(result) << std::endl;
+                else
+                    break;
+        }
+
+        if (size == 0)
+            return false;
+
+        alBufferData(buffer, format, pcm, size, vorbisInfo->rate);
+        check();
+
+        return true;
+    }
+
+
+
+    void AudioStream::empty()
+    {
+        int queued;
+
+        alGetSourcei(source, AL_BUFFERS_QUEUED, &queued);
+
+        while (queued--)
+        {
+            ALuint buffer;
+
+            alSourceUnqueueBuffers(source, 1, &buffer);
+            check();
+        }
+    }
+
+
+
+
+    void AudioStream::check()
+    {
+        int error = alGetError();
+
+        if (error != AL_NO_ERROR)
+            COUT(2) << "AudioStream: OpenAL error was raised." << std::endl;
+    }
+
+
+
+    std::string AudioStream::errorString(int code)
+    {
+        switch (code)
+        {
+            case OV_EREAD:
+                return std::string("Read from media.");
+            case OV_ENOTVORBIS:
+                return std::string("Not Vorbis data.");
+            case OV_EVERSION:
+                return std::string("Vorbis version mismatch.");
+            case OV_EBADHEADER:
+                return std::string("Invalid Vorbis header.");
+            case OV_EFAULT:
+                return std::string("Internal logic fault (bug or heap/stack corruption.");
+            default:
+                return std::string("Unknown Ogg error.");
+        }
+    }
+}
+
Index: /code/branches/ceguilua/src/audio/AudioStream.h
===================================================================
--- /code/branches/ceguilua/src/audio/AudioStream.h	(revision 1801)
+++ /code/branches/ceguilua/src/audio/AudioStream.h	(revision 1801)
@@ -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:
+ *      Nicolas Perrenoud <nicolape_at_ee.ethz.ch>
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _AudioStream_H__
+#define _AudioStream_H__
+
+#include "AudioPrereqs.h"
+
+#include <string>
+#include <iostream>
+#include <AL/al.h>
+#include <vorbis/vorbisfile.h>
+#include <vorbis/codec.h>
+
+
+namespace audio
+{
+    const int BUFFER_SIZE = 4096 * 4;
+
+    class _AudioExport AudioStream
+    {
+    public:
+        AudioStream(std::string path);
+        void open();
+        void release();
+        void display();
+        bool playback();
+        bool playing();
+        bool update();
+        inline bool isLoaded() { return loaded; }
+
+    protected:
+        bool stream(ALuint buffer);
+        void empty();
+        void check();
+        std::string errorString(int code);
+
+    private:
+        std::string path;
+
+        FILE*           oggFile;
+        OggVorbis_File  oggStream;
+        vorbis_info*    vorbisInfo;
+        vorbis_comment* vorbisComment;
+        bool loaded;
+
+        ALuint buffers[2];
+        ALuint source;
+        ALenum format;
+    };
+}
+
+#endif /* _AudioStream_H__ */
Index: /code/branches/ceguilua/src/audio/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/audio/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/audio/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,23 @@
+SET ( AUDIO_SRC_FILES
+  AudioBuffer.cc
+  AudioManager.cc
+  AudioSource.cc
+  AudioStream.cc
+)
+
+IF (WIN32)
+  ADD_LIBRARY( audio ${AUDIO_SRC_FILES} )
+ELSE (WIN32)
+  ADD_LIBRARY( audio SHARED ${AUDIO_SRC_FILES} )
+ENDIF (WIN32)
+
+TARGET_LINK_LIBRARIES( audio
+  ${OPENAL_LIBRARY}
+  ${ALUT_LIBRARY}
+  ${VORBISFILE_LIBRARY}
+  ${VORBIS_LIBRARY}
+  ${OGG_LIBRARY}
+  core
+)
+
+
Index: /code/branches/ceguilua/src/core/ArgumentCompleter.h
===================================================================
--- /code/branches/ceguilua/src/core/ArgumentCompleter.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ArgumentCompleter.h	(revision 1801)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompleter_H__
+#define _ArgumentCompleter_H__
+
+#include "CorePrereqs.h"
+#include "ArgumentCompletionListElement.h"
+
+namespace orxonox
+{
+    class _CoreExport ArgumentCompleter
+    {
+        public:
+            ArgumentCompleter(ArgumentCompletionList (*function) (void)) : paramCount_(0), function_0_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1)) : paramCount_(1), function_1_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2)) : paramCount_(2), function_2_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3)) : paramCount_(3), function_3_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4)) : paramCount_(4), function_4_(function) {}
+            ArgumentCompleter(ArgumentCompletionList (*function) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)) : paramCount_(5), function_5_(function) {}
+
+            ArgumentCompletionList operator()(const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "")
+            {
+                switch (this->paramCount_)
+                {
+                    case 0:
+                        return (*this->function_0_)();
+                    case 1:
+                        return (*this->function_1_)(param1);
+                    case 2:
+                        return (*this->function_2_)(param1, param2);
+                    case 3:
+                        return (*this->function_3_)(param1, param2, param3);
+                    case 4:
+                        return (*this->function_4_)(param1, param2, param3, param4);
+                    case 5:
+                        return (*this->function_5_)(param1, param2, param3, param4, param5);
+                    default:
+                        return ArgumentCompletionList();
+                }
+            }
+
+        private:
+            unsigned char paramCount_;
+            ArgumentCompletionList (*function_0_) (void);
+            ArgumentCompletionList (*function_1_) (const std::string& param1);
+            ArgumentCompletionList (*function_2_) (const std::string& param1, const std::string& param2);
+            ArgumentCompletionList (*function_3_) (const std::string& param1, const std::string& param2, const std::string& param3);
+            ArgumentCompletionList (*function_4_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4);
+            ArgumentCompletionList (*function_5_) (const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5);
+    };
+}
+
+#endif /* _ArgumentCompleter_H__ */
Index: /code/branches/ceguilua/src/core/ArgumentCompletionFunctions.cc
===================================================================
--- /code/branches/ceguilua/src/core/ArgumentCompletionFunctions.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ArgumentCompletionFunctions.cc	(revision 1801)
@@ -0,0 +1,144 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <iostream>
+#include <map>
+
+#include "boost/filesystem.hpp"
+
+#include "ArgumentCompletionFunctions.h"
+#include "CoreIncludes.h"
+#include "Identifier.h"
+#include "ConfigValueContainer.h"
+#include "TclThreadManager.h"
+#include "util/Convert.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    namespace autocompletion
+    {
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(fallback)()
+        {
+            return ArgumentCompletionList();
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(files)(const std::string& fragment)
+        {
+            ArgumentCompletionList dirlist;
+            ArgumentCompletionList filelist;
+
+            try
+            {
+                boost::filesystem::path input(fragment);
+                boost::filesystem::path startdirectory(input.branch_path());
+
+                if (!boost::filesystem::exists(startdirectory))
+                {
+                    startdirectory = ".";
+                }
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+                else
+                {
+                    std::string dir = startdirectory.string();
+                    if (dir.size() > 0 && dir[dir.size() - 1] == ':')
+                        startdirectory = dir + "/";
+                }
+#endif
+
+                boost::filesystem::directory_iterator file(startdirectory);
+                boost::filesystem::directory_iterator end;
+
+                while (file != end)
+                {
+                    if (boost::filesystem::is_directory(*file))
+                        dirlist.push_back(ArgumentCompletionListElement((*file).string() + "/", getLowercase((*file).string()) + "/", (*file).leaf() + "/"));
+                    else
+                        filelist.push_back(ArgumentCompletionListElement((*file).string(), getLowercase((*file).string()), (*file).leaf()));
+                    ++file;
+                }
+            }
+            catch (...) {}
+
+            filelist.insert(filelist.begin(), dirlist.begin(), dirlist.end());
+            return filelist;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalueclasses)()
+        {
+            ArgumentCompletionList classlist;
+
+            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
+                if ((*it).second->hasConfigValues())
+                    classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+
+            return classlist;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalues)(const std::string& fragment, const std::string& classname)
+        {
+            ArgumentCompletionList configvalues;
+            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getIdentifierMap().find(classname);
+
+            if (identifier != Identifier::getIdentifierMapEnd() && (*identifier).second->hasConfigValues())
+            {
+                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it)
+                    configvalues.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
+            }
+
+            return configvalues;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname)
+        {
+            ArgumentCompletionList oldvalue;
+            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
+            if (identifier != Identifier::getLowercaseIdentifierMapEnd())
+            {
+                std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
+                if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                {
+                    std::string valuestring = (*variable).second->toString();
+                    oldvalue.push_back(ArgumentCompletionListElement(valuestring, getLowercase(valuestring), "Old value: " + valuestring));
+                }
+            }
+            return oldvalue;
+        }
+
+        ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(tclthreads)()
+        {
+            std::list<unsigned int> threadnumbers = TclThreadManager::getInstance().getThreadList();
+            ArgumentCompletionList threads;
+
+            for (std::list<unsigned int>::const_iterator it = threadnumbers.begin(); it != threadnumbers.end(); ++it)
+                threads.push_back(ArgumentCompletionListElement(getConvertedValue<unsigned int, std::string>(*it)));
+
+            return threads;
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/ArgumentCompletionFunctions.h
===================================================================
--- /code/branches/ceguilua/src/core/ArgumentCompletionFunctions.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ArgumentCompletionFunctions.h	(revision 1801)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionFunctions_H__
+#define _ArgumentCompletionFunctions_H__
+
+#include "CorePrereqs.h"
+#include "ArgumentCompleter.h"
+
+
+#define ARGUMENT_COMPLETION_FUNCTION_DECLARATION(functionname) \
+    ArgumentCompleter* functionname(); \
+    _CoreExport ArgumentCompletionList acf_##functionname
+
+#define ARGUMENT_COMPLETION_FUNCTION_IMPLEMENTATION(functionname) \
+    ArgumentCompleter* functionname() \
+    { \
+        static ArgumentCompleter completer = ArgumentCompleter(&acf_##functionname); \
+        return &completer; \
+    } \
+    \
+    ArgumentCompletionList acf_##functionname
+
+
+namespace orxonox
+{
+    namespace autocompletion
+    {
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(fallback)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(files)(const std::string& fragment);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalueclasses)();
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalues)(const std::string& fragment, const std::string& classname);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(configvalue)(const std::string& fragment, const std::string& varname, const std::string& classname);
+        ARGUMENT_COMPLETION_FUNCTION_DECLARATION(tclthreads)();
+    }
+}
+
+#endif /* _ArgumentCompletionFunctions_H__ */
Index: /code/branches/ceguilua/src/core/ArgumentCompletionListElement.h
===================================================================
--- /code/branches/ceguilua/src/core/ArgumentCompletionListElement.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ArgumentCompletionListElement.h	(revision 1801)
@@ -0,0 +1,74 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ArgumentCompletionListElement_H__
+#define _ArgumentCompletionListElement_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+
+namespace orxonox
+{
+    const int ACL_MODE_NORMAL    = 1;
+    const int ACL_MODE_LOWERCASE = 2;
+    const int ACL_MODE_DISPLAY   = 4;
+
+    typedef std::list<ArgumentCompletionListElement> ArgumentCompletionList;
+
+    class _CoreExport ArgumentCompletionListElement
+    {
+        public:
+            ArgumentCompletionListElement(const std::string& normalcase) : mode_(ACL_MODE_NORMAL), normalCase_(normalcase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE), normalCase_(normalcase), lowerCase_(lowercase) {}
+            ArgumentCompletionListElement(const std::string& normalcase, const std::string& lowercase, const std::string& display) : mode_(ACL_MODE_NORMAL | ACL_MODE_LOWERCASE | ACL_MODE_DISPLAY), normalCase_(normalcase), lowerCase_(lowercase), display_(display) {}
+
+            const std::string& getString() const
+                { return this->normalCase_; }
+            const std::string& getComparable() const
+                { if (this->mode_ & ACL_MODE_LOWERCASE) { return this->lowerCase_; } else { return this->normalCase_; } }
+            const std::string& getDisplay() const
+                { if (this->mode_ & ACL_MODE_DISPLAY) { return this->display_; } else { return this->normalCase_; } }
+
+            bool lowercaseComparison() const
+                { return (this->mode_ & ACL_MODE_LOWERCASE); }
+
+            bool operator<(const ArgumentCompletionListElement& other) const
+                { return (this->getComparable() < other.getComparable()); }
+
+        private:
+            unsigned char mode_;
+            std::string normalCase_;
+            std::string lowerCase_;
+            std::string display_;
+    };
+}
+
+#endif /* _ArgumentCompletionListElement_H__ */
Index: /code/branches/ceguilua/src/core/BaseObject.cc
===================================================================
--- /code/branches/ceguilua/src/core/BaseObject.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/BaseObject.cc	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the BaseObject class.
+*/
+
+#include "BaseObject.h"
+#include "tinyxml/tinyxml.h"
+#include "CoreIncludes.h"
+#include "XMLPort.h"
+#include "Level.h"
+
+namespace orxonox
+{
+    CreateFactory(BaseObject);
+
+    /**
+        @brief Constructor: Registers the object in the BaseObject-list.
+    */
+    BaseObject::BaseObject() : bInitialized_(false)
+    {
+        RegisterRootObject(BaseObject);
+
+        this->bInitialized_ = true;
+
+        this->bActive_ = true;
+        this->bVisible_ = true;
+
+        this->level_ = 0;
+        this->namespace_ = 0;
+    }
+
+    /**
+        @brief Destructor
+    */
+    BaseObject::~BaseObject()
+    {
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void BaseObject::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        XMLPortParam(BaseObject, "name", setName, getName, xmlelement, mode);
+        XMLPortParam(BaseObject, "visible", setVisible, isVisible, xmlelement, mode);
+        XMLPortParam(BaseObject, "active", setActive, isActive, xmlelement, mode);
+    }
+
+    /**
+        @brief Returns the levelfile that loaded this object.
+        @return The levelfile
+    */
+    const std::string& BaseObject::getLevelfile() const
+    {
+        return this->level_->getFile();
+    }
+}
Index: /code/branches/ceguilua/src/core/BaseObject.h
===================================================================
--- /code/branches/ceguilua/src/core/BaseObject.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/BaseObject.h	(revision 1801)
@@ -0,0 +1,110 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file BaseObject.h
+    @brief Definition of the BaseObject class.
+
+    The BaseObject is the parent of all classes representing an instance in the game.
+*/
+
+#ifndef _BaseObject_H__
+#define _BaseObject_H__
+
+#include "CorePrereqs.h"
+
+#include "Super.h"
+#include "OrxonoxClass.h"
+#include "util/XMLIncludes.h"
+
+namespace orxonox
+{
+    //! The BaseObject is the parent of all classes representing an instance in the game.
+    class _CoreExport BaseObject : virtual public OrxonoxClass
+    {
+        friend class WorldEntity;
+
+        public:
+            BaseObject();
+            virtual ~BaseObject();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            /** @brief Returns if the object was initialized (passed the object registration). @return True was the object is initialized */
+            inline bool isInitialized() const { return this->bInitialized_; }
+
+            /** @brief Sets the name of the object. @param name The name */
+            inline void setName(const std::string& name) { this->name_ = name; this->changedName(); }
+            /** @brief Returns the name of the object. @return The name */
+            inline const std::string& getName() const { return this->name_; }
+            /** @brief This function gets called if the name of the object changes. */
+            virtual void changedName() {}
+
+            /** @brief Sets the state of the objects activity. @param bActive True = active */
+            inline void setActive(bool bActive) { this->bActive_ = bActive; this->changedActivity(); }
+            /** @brief Returns the state of the objects activity. @return The state of the activity */
+            inline bool isActive() const { return this->bActive_; }
+            /** @brief This function gets called if the activity of the object changes. */
+            virtual void changedActivity() {}
+
+            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
+            inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; this->changedVisibility(); }
+            /** @brief Returns the state of the objects visibility. @return The state of the visibility */
+            inline bool isVisible() const { return this->bVisible_; }
+            /** @brief This function gets called if the visibility of the object changes. */
+            virtual void changedVisibility() {}
+
+            /** @brief Sets a pointer to the level that loaded this object. @param level The pointer to the level */
+            inline void setLevel(const Level* level) { this->level_ = level; }
+            /** @brief Returns a pointer to the level that loaded this object. @return The level */
+            inline const Level* getLevel() const { return this->level_; }
+            const std::string& getLevelfile() const;
+
+            virtual inline void setNamespace(Namespace* ns) { this->namespace_ = ns; }
+            inline Namespace* getNamespace() const { return this->namespace_; }
+
+            /** @brief Sets the indentation of the debug output in the Loader. @param indentation The indentation */
+            inline void setLoaderIndentation(const std::string& indentation) { this->loaderIndentation_ = indentation; }
+            /** @brief Returns the indentation of the debug output in the Loader. @return The indentation */
+            inline const std::string& getLoaderIndentation() const { return this->loaderIndentation_; }
+
+        private:
+            std::string name_;                          //!< The name of the object
+            bool bInitialized_;                         //!< True if the object was initialized (passed the object registration)
+            bool bActive_;                              //!< True = the object is active
+            bool bVisible_;                             //!< True = the object is visible
+            const Level* level_;                        //!< The level that loaded this object
+            std::string loaderIndentation_;             //!< Indentation of the debug output in the Loader
+            Namespace* namespace_;
+    };
+
+    SUPER_FUNCTION(0, BaseObject, XMLPort, false);
+    SUPER_FUNCTION(2, BaseObject, changedActivity, false);
+    SUPER_FUNCTION(3, BaseObject, changedVisibility, false);
+}
+
+#endif /* _BaseObject_H__ */
Index: /code/branches/ceguilua/src/core/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/core/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/core/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,76 @@
+SET(CORE_SRC_FILES
+  Clock.cc
+  ConfigFileManager.cc
+  ConfigValueContainer.cc
+  Core.cc
+  GameState.cc
+  Language.cc
+  ObjectListBase.cc
+  OrxonoxClass.cc
+  RootGameState.cc
+  Script.cc
+
+  # command
+  ArgumentCompletionFunctions.cc
+  CommandEvaluation.cc
+  CommandExecutor.cc
+  CommandLine.cc
+  ConsoleCommand.cc
+  ConsoleCommandCompilation.cc
+  Executor.cc
+
+  # hierarchy
+  Factory.cc
+  Identifier.cc
+  MetaObjectList.cc
+
+  # level
+  BaseObject.cc
+  ClassTreeMask.cc
+  Loader.cc
+  Namespace.cc
+  NamespaceNode.cc
+  XMLPort.cc
+
+  # shell
+  IRC.cc
+  Shell.cc
+  TclBind.cc
+  TclThreadManager.cc
+
+  # input
+  input/Button.cc
+  input/CalibratorCallback.cc
+  input/ExtendedInputState.cc
+  input/HalfAxis.cc
+  input/InputBuffer.cc
+  input/InputCommands.cc
+  input/InputManager.cc
+  input/KeyBinder.cc
+  input/KeyDetector.cc
+  input/SimpleInputState.cc
+
+  tolua/tolua_bind.cc
+)
+
+GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
+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
+  DEPENDS tolua
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+
+ADD_LIBRARY(core SHARED ${CORE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES(core
+  ${Lua_LIBRARIES}
+  ${OGRE_LIBRARIES}
+  cpptcl
+  ois_orxonox
+  tinyxml
+  tolualib
+  util
+  ${Boost_thread_LIBRARIES}
+  ${Boost_filesystem_LIBRARIES}
+)
Index: /code/branches/ceguilua/src/core/ClassFactory.h
===================================================================
--- /code/branches/ceguilua/src/core/ClassFactory.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ClassFactory.h	(revision 1801)
@@ -0,0 +1,103 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ClassFactory.h
+    @brief Definition and implementation of the ClassFactory class
+
+    The ClassFactory is able to create new objects of a specific class.
+*/
+
+#ifndef _ClassFactory_H__
+#define _ClassFactory_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+#include "Factory.h"
+#include "Identifier.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###      ClassFactory       ###
+    // ###############################
+    //! The ClassFactory is able to create new objects of a specific class.
+    template <class T>
+    class ClassFactory : public BaseFactory
+    {
+        public:
+            static bool create(const std::string& name);
+            BaseObject* fabricate();
+
+        private:
+            ClassFactory() {}                               // Don't create
+            ClassFactory(const ClassFactory& factory) {}    // Don't copy
+            virtual ~ClassFactory() {}                      // Don't delete
+
+            static T* createNewObject();
+    };
+
+    /**
+        @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
+        @return Always true (this is needed because the compiler only allows assignments before main())
+    */
+    template <class T>
+    bool ClassFactory<T>::create(const std::string& name)
+    {
+        COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
+        ClassIdentifier<T>::getIdentifier(name)->addFactory(new ClassFactory<T>);
+        Factory::add(name, ClassIdentifier<T>::getIdentifier());
+
+        return true;
+    }
+
+    /**
+        @brief Creates and returns a new object of class T.
+        @return The new object
+    */
+    template <class T>
+    BaseObject* ClassFactory<T>::fabricate()
+    {
+        return ClassFactory<T>::createNewObject();
+    }
+
+    /**
+        @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
+        @return The new object
+    */
+    template <class T>
+    T* ClassFactory<T>::createNewObject()
+    {
+        return new T;
+    }
+}
+
+#endif /* _ClassFactory_H__ */
Index: /code/branches/ceguilua/src/core/ClassTreeMask.cc
===================================================================
--- /code/branches/ceguilua/src/core/ClassTreeMask.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ClassTreeMask.cc	(revision 1801)
@@ -0,0 +1,964 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ClassTreeMask.cc
+    @brief Implementation of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes.
+*/
+
+#include "ClassTreeMask.h"
+#include "Identifier.h"
+#include "BaseObject.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###    ClassTreeMaskNode    ###
+    // ###############################
+    /**
+        @brief Constructor: Creates the node, sets the subclass and the rule.
+        @param subclass The subclass the rule refers to
+        @param bIncluded The rule: included (true) or excluded (false)
+    */
+    ClassTreeMaskNode::ClassTreeMaskNode(const Identifier* subclass, bool bIncluded)
+    {
+        this->subclass_ = subclass;
+        this->bIncluded_ = bIncluded;
+    }
+
+    /**
+        @brief Destructor: Deletes all subnodes.
+    */
+    ClassTreeMaskNode::~ClassTreeMaskNode()
+    {
+        // Go through the list of all subnodes and delete them
+        this->deleteAllSubnodes();
+    }
+
+    /**
+        @brief Sets the rule for the node to "included".
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMaskNode::include(bool overwrite)
+    {
+        this->setIncluded(true, overwrite);
+    }
+
+    /**
+        @brief Sets the rule for the node to "excluded".
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMaskNode::exclude(bool overwrite)
+    {
+        this->setIncluded(false, overwrite);
+    }
+
+    /**
+        @brief Sets the rule for the node to a given value and erases all following rules.
+        @param bIncluded The rule: included (true) or excluded (false)
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMaskNode::setIncluded(bool bIncluded, bool overwrite)
+    {
+        if (overwrite)
+            this->deleteAllSubnodes();
+
+        this->bIncluded_ = bIncluded;
+    }
+
+    /**
+        @brief Adds a new subnode to the list of subnodes.
+        @param subnode The new subnode
+    */
+    void ClassTreeMaskNode::addSubnode(ClassTreeMaskNode* subnode)
+    {
+        this->subnodes_.insert(this->subnodes_.end(), subnode);
+    }
+
+    /**
+        @brief Deletes all subnodes of this node.
+    */
+    void ClassTreeMaskNode::deleteAllSubnodes()
+    {
+        // Go through the list of all subnodes and delete them
+        for (std::list<ClassTreeMaskNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); )
+            delete (*(it++));
+
+        // Clear the list
+        this->subnodes_.clear();
+    }
+
+
+    // ###############################
+    // ###  ClassTreeMaskIterator  ###
+    // ###############################
+    /**
+        @brief Constructor: Initializes the iterator by creating a helper-list with the root-node and putting it to the stack.
+        @param node The root-node
+    */
+    ClassTreeMaskIterator::ClassTreeMaskIterator(ClassTreeMaskNode* node)
+    {
+        // Create a list and put the root-note into it
+        std::list<ClassTreeMaskNode*>::iterator it = this->rootlist_.insert(this->rootlist_.end(), node);
+
+        // Put the iterator to the only element of the list and the corresponding end()-iterator on the stack
+        this->nodes_.push(std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>(it, this->rootlist_.end()));
+    }
+
+    /**
+        @brief Destructor: Does nothing.
+    */
+    ClassTreeMaskIterator::~ClassTreeMaskIterator()
+    {
+    }
+
+    /**
+        @brief Iterates through the rule-tree.
+        @return A reference to the iterator itself
+    */
+    const ClassTreeMaskIterator& ClassTreeMaskIterator::operator++()
+    {
+        // Check if the actual node has subnodes
+        if ((*this->nodes_.top().first)->subnodes_.begin() != (*this->nodes_.top().first)->subnodes_.end())
+        {
+            // Yes it has: Push an iterator, pointing at the first subnode, on the stack
+            this->nodes_.push(std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator>((*this->nodes_.top().first)->subnodes_.begin(), (*this->nodes_.top().first)->subnodes_.end()));
+        }
+        else
+        {
+            // No subnodes, meaning we reached a leaf: Go to the next node
+            do
+            {
+                // Iterate one step in the current list
+                ++this->nodes_.top().first;
+
+                // Check if we reached the end of the list (the second item in the stored pair always represents the end)
+                if (this->nodes_.top().first == this->nodes_.top().second)
+                {
+                    // Yes we've reached the end: Pop the list-iterator from the stack
+                    this->nodes_.pop();
+
+                    // Continue with the loop, meaning: Try to iterate through the previous list
+                    continue;
+                }
+
+                // If we reached this point, we aren't yet at the end of the list: Leave the loop
+                break;
+            } while (!this->nodes_.empty()); // Stop looping if the stack is empty, meaning: We've iterated to the end
+        }
+
+        // Finally return a reference to the iterator itself
+        return *this;
+    }
+
+    /**
+        @brief Returns a pointer to the ClassTreeMaskNode whereon the iterator points.
+        @return The pointer to the node
+    */
+    ClassTreeMaskNode* ClassTreeMaskIterator::operator*() const
+    {
+        return (*this->nodes_.top().first);
+    }
+
+    /**
+        @brief Returns a pointer to the ClassTreeMaskNode whereon the iterator points.
+        @return The pointer to the node
+    */
+    ClassTreeMaskNode* ClassTreeMaskIterator::operator->() const
+    {
+        return (*this->nodes_.top().first);
+    }
+
+    /**
+        @brief Returns true if the stack is empty, meaning we've reached the end of the tree.
+        @return True if we've reached the end of the tree
+    */
+    ClassTreeMaskIterator::operator bool() const
+    {
+        return (!this->nodes_.empty());
+    }
+
+    /**
+        @brief Compares the current node with the given one and returns true if they match.
+        @param compare The node to compare with
+        @return The result of the comparison (true if they match)
+    */
+    bool ClassTreeMaskIterator::operator==(ClassTreeMaskNode* compare) const
+    {
+        if (!this->nodes_.empty())
+            return ((*this->nodes_.top().first) == compare);
+        else
+            return (compare == 0);
+    }
+
+    /**
+        @brief Compares the current node with the given one and returns true if they don't match.
+        @param compare The node to compare with
+        @return The result of the comparison (true if they don't match)
+    */
+    bool ClassTreeMaskIterator::operator!=(ClassTreeMaskNode* compare) const
+    {
+        if (!this->nodes_.empty())
+            return ((*this->nodes_.top().first) != compare);
+        else
+            return (compare != 0);
+    }
+
+
+    // ###############################
+    // ###      ClassTreeMask      ###
+    // ###############################
+    /**
+        @brief Constructor: Adds the root-node of the tree with the first rule ("include everything").
+    */
+    ClassTreeMask::ClassTreeMask()
+    {
+        this->root_ = new ClassTreeMaskNode(ClassIdentifier<BaseObject>::getIdentifier(), true);
+    }
+
+    /**
+        @brief Copyconstructor: Adds the root-node of the tree with the first rule ("include everything") and adds all rules from the other mask.
+        @param other The other mask
+    */
+    ClassTreeMask::ClassTreeMask(const ClassTreeMask& other)
+    {
+        this->root_ = new ClassTreeMaskNode(ClassIdentifier<BaseObject>::getIdentifier(), true);
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+            this->add(it->getClass(), it->isIncluded(), false);
+    }
+
+    /**
+        @brief Destructor: Deletes the root node (which will delete all subnodes too).
+    */
+    ClassTreeMask::~ClassTreeMask()
+    {
+        delete this->root_;
+    }
+
+    /**
+        @brief Adds a new "include" rule for a given subclass to the mask.
+        @param subclass The subclass
+        @param overwrite True = overwrite previously added rules for inheriting classes
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::include(const Identifier* subclass, bool overwrite, bool clean)
+    {
+        this->add(subclass, true, overwrite, clean);
+    }
+
+    /**
+        @brief Adds a new "exclude" rule for a given subclass to the mask.
+        @param subclass The subclass
+        @param overwrite True = overwrite previously added rules for inheriting classes
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::exclude(const Identifier* subclass, bool overwrite, bool clean)
+    {
+        this->add(subclass, false, overwrite, clean);
+    }
+
+    /**
+        @brief Adds a new rule for a given subclass to the mask.
+        @param subclass The subclass
+        @param bInclude The rule: include (true) or exclude (false)
+        @param overwrite True = overwrite previously added rules for inheriting classes
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::add(const Identifier* subclass, bool bInclude, bool overwrite, bool clean)
+    {
+        // Check if the given subclass is a child of our root-class
+        if (subclass->isA(this->root_->getClass()))
+        {
+            // Yes it is: Just add the rule to the three
+            this->add(this->root_, subclass, bInclude, overwrite);
+        }
+        else
+        {
+            // No it's not: Search for classes inheriting from the given class and add the rules for them
+            for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+                if ((*it)->isA(this->root_->getClass()))
+                    if (overwrite || (!this->nodeExists(*it))) // If we don't want to overwrite, only add nodes that don't already exist
+                        this->add(this->root_, *it, bInclude, overwrite);
+        }
+
+        // Clean the rule-tree
+        if (clean)
+            this->clean();
+    }
+
+    /**
+        @brief Adds a new rule for a given subclass to a node of the internal rule-tree (recursive function).
+        @param node The node
+        @param subclass The subclass
+        @param bInclude The rule: include (true) or exclude (false)
+        @param overwrite True = overwrite previously added rules for inheriting classes
+    */
+    void ClassTreeMask::add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite)
+    {
+        // Check if the current node contains exactly the subclass we want to add
+        if (subclass == node->getClass())
+        {
+            // We're at the right place, just change the mask and return
+            node->setIncluded(bInclude, overwrite);
+            return;
+        }
+        else if (subclass->isA(node->getClass()))
+        {
+            // Search for an already existing node, containing the subclass we want to add
+            for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
+            {
+                if (subclass->isA((*it)->getClass()))
+                {
+                    // We've found an existing node -> delegate the work with a recursive function-call and return
+                    this->add(*it, subclass, bInclude, overwrite);
+                    return;
+                }
+            }
+
+            // There is no existing node satisfying our needs -> we create a new node
+            ClassTreeMaskNode* newnode = new ClassTreeMaskNode(subclass, bInclude);
+
+            // Search for nodes that should actually be subnodes of our new node and erase them
+            for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); )
+            {
+                if ((*it)->getClass()->isChildOf(subclass))
+                {
+                    // We've found a subnode: add it to the new node and erase it from the current node
+                    if (!overwrite)
+                        newnode->addSubnode(*it);
+                    else
+                        delete (*it);
+
+                    node->subnodes_.erase(it++);
+                }
+                else
+                {
+                    ++it;
+                }
+            }
+
+            // Finally add the new node as a subnode to the current node
+            node->addSubnode(newnode);
+        }
+    }
+
+    /**
+        @brief Adds a new "include" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
+        @param subclass The subclass
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::includeSingle(const Identifier* subclass, bool clean)
+    {
+        this->addSingle(subclass, true, clean);
+    }
+
+    /**
+        @brief Adds a new "exclude" rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
+        @param subclass The subclass
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::excludeSingle(const Identifier* subclass, bool clean)
+    {
+        this->addSingle(subclass, false, clean);
+    }
+
+    /**
+        @brief Adds a new rule for a single subclass. The new rule doesn't change the mask for inheriting classes.
+        @param bInclude The rule: include (true) or exclude (false)
+        @param subclass The subclass
+        @param clean True = clean the tree after adding the new rule
+    */
+    void ClassTreeMask::addSingle(const Identifier* subclass, bool bInclude, bool clean)
+    {
+        for (std::set<const Identifier*>::const_iterator it = subclass->getDirectChildrenBegin(); it != subclass->getDirectChildrenEnd(); ++it)
+            this->add(*it, this->isIncluded(*it), false, false);
+
+        this->add(subclass, bInclude, false, clean);
+    }
+
+    /**
+        @brief Resets the mask to "include everything".
+    */
+    void ClassTreeMask::reset()
+    {
+        delete this->root_;
+        this->root_ = new ClassTreeMaskNode(ClassIdentifier<BaseObject>::getIdentifier(), true);
+    }
+
+    /**
+        @brief Tells if a given subclass is included or not.
+        @param subclass The subclass
+        @return Included (true) or excluded (false)
+    */
+    bool ClassTreeMask::isIncluded(const Identifier* subclass) const
+    {
+        return this->isIncluded(this->root_, subclass);
+    }
+
+    /**
+        @brief Tells if a given subclass of a node in the rule-tree is included or not (recursive function).
+        @param node The node
+        @param subclass The subclass
+        @return Included (true) or excluded (false)
+    */
+    bool ClassTreeMask::isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const
+    {
+        // Check if the searched subclass is of the same type as the class in the current node or a derivative
+        if (subclass->isA(node->getClass()))
+        {
+            // Check for the special case
+            if (subclass == node->getClass())
+                return node->isIncluded();
+
+            // Go through the list of subnodes and look for a node containing the searched subclass and delegate the request by a recursive function-call.
+            for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); ++it)
+                if (subclass->isA((*it)->getClass()))
+                    return isIncluded(*it, subclass);
+
+            // There is no subnode containing our class -> the rule of the current node takes in effect
+            return node->isIncluded();
+        }
+        else
+        {
+            // The class is not included in the mask: return false
+            return false;
+        }
+    }
+
+    /**
+        @brief Tells if a given subclass is excluded or not.
+        @param subclass The subclass
+        @return The inverted rule: Excluded (true) or included (false)
+    */
+    bool ClassTreeMask::isExcluded(const Identifier* subclass) const
+    {
+        return (!this->isIncluded(subclass));
+    }
+
+    /**
+        @brief Removes all unneeded rules that don't change the information of the mask.
+    */
+    void ClassTreeMask::clean()
+    {
+        this->clean(this->root_);
+    }
+
+    /**
+        @brief Removes all unneded rules that don't change the information of a node of a mask (recursive function).
+        @param node The node
+    */
+    void ClassTreeMask::clean(ClassTreeMaskNode* node)
+    {
+        // Iterate through all subnodes of the given node
+        for (std::list<ClassTreeMaskNode*>::iterator it = node->subnodes_.begin(); it != node->subnodes_.end(); )
+        {
+            // Recursive function-call: Clean the subnode
+            this->clean(*it);
+
+            // Now check if the subnode contains the same rule as the current node
+            if ((*it)->isIncluded() == node->isIncluded())
+            {
+                // It does: Move all subnodes of the redundant subnode to the current node
+                node->subnodes_.insert(node->subnodes_.end(), (*it)->subnodes_.begin(), (*it)->subnodes_.end());
+                (*it)->subnodes_.clear();
+
+                // Remove the redundant subnode from the current node
+                node->subnodes_.erase(it++);
+            }
+            else
+            {
+                // The subnode is necessary: Move on to the next subnode
+                ++it;
+            }
+        }
+    }
+
+    /**
+        @brief Checks if a node for the given subclass exists.
+        @param subclass The Identifier of the subclass
+        @return True = the node exists
+    */
+    bool ClassTreeMask::nodeExists(const Identifier* subclass)
+    {
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+            if ((*it)->getClass() == subclass)
+                return true;
+
+        return false;
+    }
+
+    /**
+        @brief Assignment operator: Adds all rules of the other mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator=(const ClassTreeMask& other)
+    {
+        // Make a copy to avoid troubles with self-assignments (like A = A).
+        ClassTreeMask temp(other);
+
+        // Removes all current rules
+        this->reset();
+
+        // Copy all rules from the other mask
+        for (ClassTreeMaskIterator it = temp.root_; it; ++it)
+            this->add(it->getClass(), it->isIncluded(), false, false);
+
+        // Return a reference to the mask itself
+        return (*this);
+    }
+
+    /**
+        @brief Compares the mask with another mask and returns true if they represent the same logic.
+        @param other The other mask
+        @return True if both masks represent the same logic
+    */
+    bool ClassTreeMask::operator==(const ClassTreeMask& other) const
+    {
+        ClassTreeMask temp1 = other;
+        ClassTreeMask temp2 = (*this);
+
+        temp1.clean();
+        temp2.clean();
+
+        ClassTreeMaskIterator it1 = temp1.root_;
+        ClassTreeMaskIterator it2 = temp2.root_;
+
+        for ( ; it1 && it2; ++it1, ++it2)
+            if (it1->getClass() != it2->getClass())
+                return false;
+
+        return true;
+    }
+
+    /**
+        @brief Compares the mask with another mask and returns true if they represent different logics.
+        @param other The other mask
+        @return True if the masks represent different logics
+    */
+    bool ClassTreeMask::operator!=(const ClassTreeMask& other) const
+    {
+        return (!((*this) == other));
+    }
+
+    /**
+        @brief Prefix operator + does nothing.
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator+() const
+    {
+        return (*this);
+    }
+
+    /**
+        @brief Prefix operator - inverts the mask.
+        @return The inverted mask
+    */
+    ClassTreeMask ClassTreeMask::operator-() const
+    {
+        return (!(*this));
+    }
+
+    /**
+        @brief Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).
+        @param other The mask to unite with
+        @return The union
+    */
+    ClassTreeMask ClassTreeMask::operator+(const ClassTreeMask& other) const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the first mask, calculate the rule with the or-operation
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false);
+        }
+
+        // Add all nodes from the second mask, calculate the rule with the or-operation
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) or other.isIncluded(subclass), false, false);
+        }
+
+        // Drop all redundant rules
+        newmask.clean();
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).
+        @param other The mask to intersect with
+        @return The intersection
+    */
+    ClassTreeMask ClassTreeMask::operator*(const ClassTreeMask& other) const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the first mask, calculate the rule with the and-operation
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false);
+        }
+
+        // Add all nodes from the second mask, calculate the rule with the and-operation
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) and other.isIncluded(subclass), false, false);
+        }
+
+        // Drop all redundant rules
+        newmask.clean();
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Removes all elements of the second mask from the first mask (all classes that are included in the first mask stay included, except those that are included in the second mask too).
+        @param other The mask to subtract.
+        @return The difference
+    */
+    ClassTreeMask ClassTreeMask::operator-(const ClassTreeMask& other) const
+    {
+        return ((*this) * (!other));
+    }
+
+    /**
+        @brief Inverts the mask (all included classes are now excluded and vice versa).
+        @return The complement
+    */
+    ClassTreeMask ClassTreeMask::operator!() const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the other mask, inverting the rules
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, !this->isIncluded(subclass), false, false);
+        }
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Unites this mask with another mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator+=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) + other;
+        return (*this);
+    }
+
+    /**
+        @brief Intersects this mask with another mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator*=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) * other;
+        return (*this);
+    }
+
+    /**
+        @brief Subtracts another mask from this mask.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator-=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) - other;
+        return (*this);
+    }
+
+    /**
+        @brief Intersects two masks (only classes that are included in both masks will be included in the resulting mask too).
+        @param other The mask to intersect with
+        @return The intersection
+    */
+    ClassTreeMask ClassTreeMask::operator&(const ClassTreeMask& other) const
+    {
+        return ((*this) * other);
+    }
+
+    /**
+        @brief Adds two masks in the sense of a union (all classes that are included in at least one of the masks will be included in the resulting mask too).
+        @param other The mask to unite with
+        @return The union
+    */
+    ClassTreeMask ClassTreeMask::operator|(const ClassTreeMask& other) const
+    {
+        return ((*this) + other);
+    }
+
+    /**
+        @brief Joins two masks in the sense of a xor (exclusivity) operation (all classes that are included in exactly one of the masks, but not in both, will be included in the resulting mask too).
+        @param other The mask to join with
+        @return The result
+    */
+    ClassTreeMask ClassTreeMask::operator^(const ClassTreeMask& other) const
+    {
+        // Create a new mask
+        ClassTreeMask newmask;
+
+        // Add all nodes from the first mask, calculate the rule with the xor-operation
+        for (ClassTreeMaskIterator it = this->root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false);
+        }
+
+        // Add all nodes from the second mask, calculate the rule with the xor-operation
+        for (ClassTreeMaskIterator it = other.root_; it; ++it)
+        {
+            const Identifier* subclass = it->getClass();
+            newmask.add(subclass, this->isIncluded(subclass) xor other.isIncluded(subclass), false, false);
+        }
+
+        // Drop all redundant rules
+        newmask.clean();
+
+        // Return the new mask
+        return newmask;
+    }
+
+    /**
+        @brief Inverts the mask (all included classes are now excluded and vice versa).
+        @return The complement
+    */
+    ClassTreeMask ClassTreeMask::operator~() const
+    {
+        return (!(*this));
+    }
+
+    /**
+        @brief Intersects this mask with another mask (and-operation)
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator&=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) & other;
+        return (*this);
+    }
+
+    /**
+        @brief Unites this mask with another mask (or-operation).
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator|=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) | other;
+        return (*this);
+    }
+
+    /**
+        @brief Joins this mask with another mask with a xor-operation.
+        @param other The other mask
+        @return A reference to the mask itself
+    */
+    const ClassTreeMask& ClassTreeMask::operator^=(const ClassTreeMask& other)
+    {
+        (*this) = (*this) ^ other;
+        return (*this);
+    }
+
+    /**
+        @brief Converts the content of a mask into a human readable string and puts it on the ostream.
+        @param out The ostream
+        @param mask The mask
+        @return A reference to the ostream
+    */
+    std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask)
+    {
+        // Iterate through all rules
+        for (ClassTreeMaskIterator it = mask.root_; it; ++it)
+        {
+            // Calculate the prefix: + means included, - means excluded
+            if (it->isIncluded())
+                out << "+";
+            else
+                out << "-";
+
+            // Put the name of the corresponding class on the stream
+            out << it->getClass()->getName() << " ";
+        }
+
+        return out;
+    }
+
+
+    // ###################################
+    // ### ClassTreeMaskObjectIterator ###
+    // ###################################
+    /**
+        @brief Initializes the iterator from a given ClassTreeMask.
+        @param mask The mask
+    */
+    const ClassTreeMaskObjectIterator& ClassTreeMaskObjectIterator::operator=(const ClassTreeMask& mask)
+    {
+        // Clear everything, use a cleaned copy of the mask
+        this->subclasses_.clear();
+        ClassTreeMask temp = mask;
+        temp.clean();
+
+        // Create the subclass-list by going through the mask-tree, starting with the root-node
+        this->create(temp.root_);
+
+        // Move the subclass-iterator to the beginning of the subclass-list
+        this->subclassIterator_ = this->subclasses_.begin();
+
+        // If there is a first subclass, move the object-iterator to the first object of this class. Else go to the end
+        if (this->subclassIterator_ != this->subclasses_.end())
+            this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+        else
+            this->objectIterator_ = ObjectList<BaseObject>::end();
+
+        // Check if the iterator points on a valid object. If not, go to the next object by calling ++
+        if (!this->objectIterator_ || ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first)))
+            this->operator++();
+
+        return (*this);
+    }
+
+    /**
+        @brief Iterate to the next object (if any).
+        @return The iterator itself
+    */
+    const ClassTreeMaskObjectIterator& ClassTreeMaskObjectIterator::operator++()
+    {
+        if (this->objectIterator_)
+        {
+            // The iterator points on a valid object, therefore we also have a valid subclass-iterator at the moment
+            do
+            {
+                // Go to the next object
+                ++this->objectIterator_;
+
+                while (!this->objectIterator_)
+                {
+                    // We reached the end of the current objectlist - go to the next class
+                    ++this->subclassIterator_;
+
+                    // Check if there really is a next class. If yes, move the object-iterator to the first object
+                    if (this->subclassIterator_ != this->subclasses_.end())
+                        this->objectIterator_ = (*this->subclassIterator_).first->getObjects()->begin();
+                    else
+                        return (*this);
+                }
+
+            // Repeat this until we reach a valid object or the end
+            } while ((*this->subclassIterator_).second && !this->objectIterator_->isExactlyA((*this->subclassIterator_).first));
+        }
+        return (*this);
+    }
+
+    /**
+        @brief Recursive function to create the Iterators subclass-list by going through the node-tree of the mask.
+        @param node The current node
+    */
+    void ClassTreeMaskObjectIterator::create(ClassTreeMaskNode* node)
+    {
+        // Add the class of this node to the list, if the class is included
+        if (node->isIncluded())
+        {
+            // If there are some subnodes, the bool is "true", meaning we have to check for the exact clss when iterating
+            if (node->hasSubnodes())
+                this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(node->getClass(), true));
+            else
+                this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(node->getClass(), false));
+        }
+
+        // Now check if the node has subnodes
+        if (node->hasSubnodes())
+        {
+            // Get all _direct_ children of the nodes class
+            std::set<const Identifier*> directChildren = node->getClass()->getDirectChildren();
+
+            // Iterate through all subnodes
+            for (std::list<ClassTreeMaskNode*>::iterator it1 = node->subnodes_.begin(); it1 != node->subnodes_.end(); ++it1)
+            {
+                // Recursive call to this function with the subnode
+                this->create(*it1);
+
+                // Only execute the following code if the current node is included, meaning some of the subnodes might be included too
+                if (node->isIncluded())
+                {
+                    scanChildren: // This is a label for goto
+
+                    // Iterate through all direct children
+                    for (std::set<const Identifier*>::iterator it2 = directChildren.begin(); it2 != directChildren.end(); ++it2)
+                    {
+                        // Check if the subnode (it1) is a child of the directChild (it2)
+                        if ((*it1)->getClass()->isA(*it2))
+                        {
+                            // Yes it is - remove the directChild (it2) from the list, because it will already be handled by a recursive call to the create() function
+                            directChildren.erase(it2);
+
+                            // Check if the removed directChild was exactly the subnode
+                            if (!(*it1)->getClass()->isExactlyA(*it2))
+                            {
+                                // No, it wasn't exactly the subnode - therefore there are some classes between
+
+                                // Add the previously removed directChild (it2) to the subclass-list
+                                this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it2, true));
+
+                                // Insert all directChildren of the directChild
+                                directChildren.insert((*it2)->getDirectChildrenBegin(), (*it2)->getDirectChildrenEnd());
+
+                                // Restart the scan with the expanded set of directChildren
+                                goto scanChildren;
+                            }
+                            break;
+                        }
+                    }
+                }
+            }
+
+            // Now add all directChildren which don't have subnodes on their own to the subclass-list
+            // The bool is "false", meaning they have no subnodes and therefore need no further checks
+            if (node->isIncluded())
+                for (std::set<const Identifier*>::iterator it = directChildren.begin(); it != directChildren.end(); ++it)
+                    this->subclasses_.insert(this->subclasses_.end(), std::pair<const Identifier*, bool>(*it, false));
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/ClassTreeMask.h
===================================================================
--- /code/branches/ceguilua/src/core/ClassTreeMask.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ClassTreeMask.h	(revision 1801)
@@ -0,0 +1,287 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ClassTreeMask.h
+    @brief Definition of the ClassTreeMask, ClassTreeMaskNode and ClassTreeMaskIterator classes.
+
+    ClassTreeMask is a class to define a mask of the class-tree beginning with BaseObject.
+    You can include or exclude classes by calling the corresponding functions with the
+    Identifier of the class.
+
+    You can work with a ClassTreeMask in the sense of the set-theory, meaning that you can create
+    unions, intersections, complements and differences by using overloaded operators.
+
+
+
+    The ClassTreeMask is internally represented by a tree. The nodes in the tree are
+    ClassTreeMaskNodes, containing the rule (included or excluded) for this class and all
+    subclasses and a list of all subnodes. To minimize the size, the tree contains only
+    nodes changing the mask. By adding new rules, the tree gets reordered dynamically.
+
+    Adding a new rule overwrites all rules assigned to inherited classes. Use overwrite = false
+    if you don't like this feature. Useless rules that don't change the information of the mask
+    aren't saved in the internal tree. Use clean = false if you wan't to save them.
+
+    With overwrite = false and clean = false it doesn't matter in which way you create the mask.
+    You can manually drop useless rules from the tree by calling clean().
+
+
+
+    Because of the complicated shape of the internal tree, there is an iterator to iterate
+    through all ClassTreeMaskNodes of a mask. It starts with the BaseObject and moves on to
+    the first subclass until it reaches a leaf of the tree. Then the iterator moves one step
+    back and iterates to the second subclass. If there are no more subclasses, it steps another
+    step back, and so on.
+
+    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.
+
+    Note that the iterator doesn't move trough the whole class-tree, but only through the
+    internal tree of the mask, containing the minimal needed set of nodes to describe the mask.
+*/
+
+#ifndef _ClassTreeMask_H__
+#define _ClassTreeMask_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+#include <stack>
+
+#include "Iterator.h"
+#include "BaseObject.h"
+
+namespace orxonox
+{
+    // ###################################
+    // ###      ClassTreeMaskNode      ###
+    // ###################################
+    //! The ClassTreeMaskNode is a node in the internal tree of the ClassTreeMask, containing the rules of the mask.
+    /**
+        The ClassTreeMaskNode is used to store the rule (included or excluded) for a given
+        class (described by the corresponding Identifier). The nodes are used in the internal
+        tree of ClassTreeMask. To build a tree, they store a list of all subnodes.
+    */
+    class _CoreExport ClassTreeMaskNode
+    {
+        friend class ClassTreeMask;
+        friend class ClassTreeMaskIterator;
+        friend class ClassTreeMaskObjectIterator;
+
+        public:
+            ClassTreeMaskNode(const Identifier* subclass, bool bIncluded = true);
+            ~ClassTreeMaskNode();
+
+            void include(bool overwrite = true);
+            void exclude(bool overwrite = true);
+            void setIncluded(bool bIncluded, bool overwrite = true);
+
+            void addSubnode(ClassTreeMaskNode* subnode);
+
+            /** @brief Tells if the rule is "included" or not. @return The rule: true = included, false = excluded */
+            inline bool isIncluded() const { return this->bIncluded_; }
+            /** @brief Tells if the rule is "excluded" or not. @return The inverted rule: true = excluded, false = included */
+            inline bool isExcluded() const { return (!this->bIncluded_); }
+
+            /** @brief Returns the Identifier of the class the rule refers to. @return The Identifier representing the class */
+            inline const Identifier* getClass() const { return this->subclass_; }
+
+            /** @brief Returns true if the Node has some subnodes. */
+            inline bool hasSubnodes() const { return !this->subnodes_.empty(); }
+
+        private:
+            void deleteAllSubnodes();
+
+            const Identifier* subclass_;                //!< The Identifier of the subclass the rule refers to
+            bool bIncluded_;                            //!< The rule: included or excluded
+            std::list<ClassTreeMaskNode*> subnodes_;    //!< A list containing all subnodes in the tree
+    };
+
+
+    // ###################################
+    // ###    ClassTreeMaskIterator    ###
+    // ###################################
+    //! The ClassTreeMaskIterator moves through all ClassTreeMaskNodes of the internal tree of a ClassTreeMask, containing the rules.
+    /**
+        Because of the complicated shape of the internal rule-tree of ClassTreeMask, an
+        iterator is used to move through all nodes of the tree. It starts with the BaseObject
+        and moves on to the first subclass until it reaches a leaf of the tree. Then the
+        iterator moves one step back and iterates to the second subclass. If there are no more
+        subclasses, it steps another step back, and so on.
+    */
+    class _CoreExport ClassTreeMaskIterator
+    {
+        public:
+            ClassTreeMaskIterator(ClassTreeMaskNode* node);
+            ~ClassTreeMaskIterator();
+
+            const ClassTreeMaskIterator& operator++();
+            ClassTreeMaskNode* operator*() const;
+            ClassTreeMaskNode* operator->() const;
+            operator bool() const;
+            bool operator==(ClassTreeMaskNode* compare) const;
+            bool operator!=(ClassTreeMaskNode* compare) const;
+
+        private:
+            std::stack<std::pair<std::list<ClassTreeMaskNode*>::iterator, std::list<ClassTreeMaskNode*>::iterator> > nodes_;    //!< A stack to store list-iterators
+            std::list<ClassTreeMaskNode*> rootlist_;                                                                            //!< A list for internal use (it only stores the root-node)
+    };
+
+
+    // ###################################
+    // ###        ClassTreeMask        ###
+    // ###################################
+    //! The ClassTreeMask is a set of rules, containing the information for each class whether it's included or not.
+    /**
+        With a ClassTreeMask, you can include or exclude subtrees of the class-tree, starting
+        with a given subclass, described by the corresponding Identifier. To minimize the size
+        of the mask, the mask saves only relevant rules. But you can manually add rules that
+        don't change the information of the mask by using clean = false. If you want to drop
+        useless rules, call the clean() function.
+    */
+    class _CoreExport ClassTreeMask
+    {
+        friend class ClassTreeMaskObjectIterator;
+
+        public:
+            ClassTreeMask();
+            ClassTreeMask(const ClassTreeMask& other);
+            ~ClassTreeMask();
+
+            void include(const Identifier* subclass, bool overwrite = true, bool clean = true);
+            void exclude(const Identifier* subclass, bool overwrite = true, bool clean = true);
+            void add(const Identifier* subclass, bool bInclude, bool overwrite = true, bool clean = true);
+
+            void includeSingle(const Identifier* subclass, bool clean = true);
+            void excludeSingle(const Identifier* subclass, bool clean = true);
+            void addSingle(const Identifier* subclass, bool bInclude, bool clean = true);
+
+            void reset();
+            void clean();
+
+            bool isIncluded(const Identifier* subclass) const;
+            bool isExcluded(const Identifier* subclass) const;
+
+            /** @brief Begin of the ClassTreeMaskObjectIterator. */
+            inline const ClassTreeMask& begin() const { return (*this); }
+            /** @brief End of the ClassTreeMaskObjectIterator. */
+            inline BaseObject*          end()   const { return 0; }
+
+            const ClassTreeMask& operator=(const ClassTreeMask& other);
+
+            bool operator==(const ClassTreeMask& other) const;
+            bool operator!=(const ClassTreeMask& other) const;
+
+            const ClassTreeMask& operator+() const;
+            ClassTreeMask operator-() const;
+
+            ClassTreeMask operator+(const ClassTreeMask& other) const;
+            ClassTreeMask operator*(const ClassTreeMask& other) const;
+            ClassTreeMask operator-(const ClassTreeMask& other) const;
+            ClassTreeMask operator!() const;
+
+            const ClassTreeMask& operator+=(const ClassTreeMask& other);
+            const ClassTreeMask& operator*=(const ClassTreeMask& other);
+            const ClassTreeMask& operator-=(const ClassTreeMask& other);
+
+            ClassTreeMask operator&(const ClassTreeMask& other) const;
+            ClassTreeMask operator|(const ClassTreeMask& other) const;
+            ClassTreeMask operator^(const ClassTreeMask& other) const;
+            ClassTreeMask operator~() const;
+
+            const ClassTreeMask& operator&=(const ClassTreeMask& other);
+            const ClassTreeMask& operator|=(const ClassTreeMask& other);
+            const ClassTreeMask& operator^=(const ClassTreeMask& other);
+
+            friend std::ostream& operator<<(std::ostream& out, const ClassTreeMask& mask);
+
+        private:
+            void add(ClassTreeMaskNode* node, const Identifier* subclass, bool bInclude, bool overwrite = true);
+            bool isIncluded(ClassTreeMaskNode* node, const Identifier* subclass) const;
+            void clean(ClassTreeMaskNode* node);
+            bool nodeExists(const Identifier* subclass);
+
+            ClassTreeMaskNode* root_;   //!< The root-node of the internal rule-tree, usually BaseObject
+    };
+
+
+    // ###################################
+    // ### ClassTreeMaskObjectIterator ###
+    // ###################################
+    //! The ClassTreeMaskObjectIterator iterates through all objects of all classes, included by a ClassTreeMask.
+    /**
+        The ClassTreeMaskObjectIterator iterates through all objects of all classes,
+        included by a ClassTreeMask. This is done the following way:
+
+        ClassTreeMask mask;
+        for (ClassTreeMaskObjectIterator it = mask.begin(); it != mask.end(); ++it)
+            it->doSomething();
+
+        Note: The ClassTreeMaskObjectIterator handles all objects as BaseObjects. If
+              you want to use another class, you should use a dynamic_cast.
+
+        Performance of ClassTreeMaskObjectIterator is good as long as you don't exclude
+        subclasses of included classes. Of course you can still exlucde subclasses, but
+        if this is done more often, we need a new implementation using a second ObjectList
+        in the Identifier, containing all objects of exactly one class.
+    */
+    class _CoreExport ClassTreeMaskObjectIterator
+    {
+        public:
+            /** @brief Defaultconstructor: Does nothing. */
+            inline ClassTreeMaskObjectIterator() {}
+            /** @brief Constructor: Initializes the iterator from a given ClassTreeMask. @param mask The mask */
+            inline ClassTreeMaskObjectIterator(const ClassTreeMask& mask) { (*this) = mask; }
+
+            const ClassTreeMaskObjectIterator& operator=(const ClassTreeMask& mask);
+
+            const ClassTreeMaskObjectIterator& operator++();
+
+            /** @brief Returns true if the ClassTreeMaskObjectIterator points at the given object. @param pointer The pointer of the object */
+            inline bool operator==(BaseObject* pointer) const { return ((*this->objectIterator_) == pointer); }
+            /** @brief Returns true if the ClassTreeMaskObjectIterator doesn't point at the given object. @param pointer The pointer of the object */
+            inline bool operator!=(BaseObject* pointer) const { return ((*this->objectIterator_) != pointer); }
+            /** @brief Returns true if the ClassTreeMaskObjectIterator hasn't already reached the end. */
+            inline operator bool() const { return (this->objectIterator_); }
+            /** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */
+            inline BaseObject* operator*() const { return (*this->objectIterator_); }
+            /** @brief Returns the object the ClassTreeMaskObjectIterator currently points at. */
+            inline BaseObject* operator->() const { return (*this->objectIterator_); }
+
+        private:
+            void create(ClassTreeMaskNode* node);
+
+            std::list<std::pair<const Identifier*, bool> >           subclasses_;       //!< A list of all Identifiers through which objects the iterator should iterate
+            std::list<std::pair<const Identifier*, bool> >::iterator subclassIterator_; //!< The current class of the iterator
+            Iterator<BaseObject>                                     objectIterator_;   //!< The current object of the iterator
+    };
+}
+
+#endif /* _ClassTreeMask_H__ */
Index: /code/branches/ceguilua/src/core/Clock.cc
===================================================================
--- /code/branches/ceguilua/src/core/Clock.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Clock.cc	(revision 1801)
@@ -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/branches/ceguilua/src/core/Clock.h
===================================================================
--- /code/branches/ceguilua/src/core/Clock.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Clock.h	(revision 1801)
@@ -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/branches/ceguilua/src/core/CommandEvaluation.cc
===================================================================
--- /code/branches/ceguilua/src/core/CommandEvaluation.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/CommandEvaluation.cc	(revision 1801)
@@ -0,0 +1,312 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandEvaluation.h"
+#include "ConsoleCommand.h"
+#include "Identifier.h"
+#include "util/Debug.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    CommandEvaluation::CommandEvaluation()
+    {
+        this->initialize("");
+        this->state_ = CS_Uninitialized;
+    }
+
+    void CommandEvaluation::initialize(const std::string& command)
+    {
+        this->bNewCommand_ = true;
+        this->bCommandChanged_ = false;
+        this->originalCommand_ = command;
+        this->command_ = command;
+        this->commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
+
+        this->additionalParameter_ = "";
+
+        this->bEvaluatedParams_ = false;
+
+        this->listOfPossibleIdentifiers_.clear();
+        this->listOfPossibleFunctions_.clear();
+        this->listOfPossibleArguments_.clear();
+
+        this->functionclass_ = 0;
+        this->function_ = 0;
+        this->possibleArgument_ = "";
+        this->argument_ = "";
+
+        this->errorMessage_ = "";
+        this->state_ = CS_Empty;
+    }
+
+    bool CommandEvaluation::isValid() const
+    {
+        return (this->function_);
+    }
+
+    bool CommandEvaluation::execute() const
+    {
+        if (!this->isValid())
+            return false;
+
+        if (this->bEvaluatedParams_ && this->function_)
+        {
+            COUT(5) << "CE_execute (evaluation): " << this->function_->getName() << " " << this->param_[0] << " " << this->param_[1] << " " << this->param_[2] << " " << this->param_[3] << " " << this->param_[4] << std::endl;
+            (*this->function_)(this->param_[0], this->param_[1], this->param_[2], this->param_[3], this->param_[4]);
+            return true;
+        }
+
+        if (!this->bCommandChanged_ || removeTrailingWhitespaces(this->command_) == removeTrailingWhitespaces(this->originalCommand_))
+        {
+            COUT(4) << "CE_execute: " << this->command_ << "\n";
+
+            unsigned int startindex = this->getStartindex();
+            if (this->commandTokens_.size() > startindex)
+                return this->function_->parse(removeSlashes(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter()));
+            else
+                return this->function_->parse(removeSlashes(this->additionalParameter_));
+        }
+
+        return false;
+    }
+
+    std::string CommandEvaluation::complete()
+    {
+        if (!this->bNewCommand_)
+        {
+            switch (this->state_)
+            {
+                case CS_Uninitialized:
+                    break;
+                case CS_Empty:
+                    break;
+                case CS_ShortcutOrIdentifier:
+                    if (this->function_)
+                    {
+                        if (this->function_->getParamCount() == 0)
+                            return (this->command_ = this->function_->getName());
+                        else
+                            return (this->command_ = this->function_->getName() + " ");
+                    }
+                    else if (this->functionclass_)
+                        return (this->command_ = this->functionclass_->getName() + " ");
+                    break;
+                case CS_Function:
+                    if (this->function_)
+                    {
+                        if (this->function_->getParamCount() == 0)
+                            return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName());
+                        else
+                            return (this->command_ = this->functionclass_->getName() + " " + this->function_->getName() + " ");
+                    }
+                    break;
+                case CS_ParamPreparation:
+                case CS_Params:
+                {
+                    if (this->argument_ == "" && this->possibleArgument_ == "")
+                        break;
+
+                    unsigned int maxIndex = this->commandTokens_.size();
+                    if (this->command_[this->command_.size() - 1] != ' ')
+                        maxIndex -= 1;
+                    std::string whitespace = "";
+
+                    if (this->possibleArgument_ != "")
+                    {
+                        this->argument_ = this->possibleArgument_;
+                        if (this->function_->getParamCount() > (maxIndex + 1 - this->getStartindex()))
+                            whitespace = " ";
+                    }
+
+                    return (this->command_ = this->commandTokens_.subSet(0, maxIndex).join() + " " + this->argument_ + whitespace);
+                    break;
+                }
+                case CS_Finished:
+                    break;
+                case CS_Error:
+                    break;
+            }
+        }
+        this->bNewCommand_ = false;
+        return this->command_;
+    }
+
+    std::string CommandEvaluation::hint() const
+    {
+        switch (this->state_)
+        {
+            case CS_Uninitialized:
+                break;
+            case CS_Empty:
+            case CS_ShortcutOrIdentifier:
+                if (this->listOfPossibleFunctions_.size() == 0)
+                    return CommandEvaluation::dump(this->listOfPossibleIdentifiers_);
+                else if (this->listOfPossibleIdentifiers_.size() == 0)
+                    return CommandEvaluation::dump(this->listOfPossibleFunctions_);
+                else
+                    return (CommandEvaluation::dump(this->listOfPossibleFunctions_) + "\n" + CommandEvaluation::dump(this->listOfPossibleIdentifiers_));
+                break;
+            case CS_Function:
+                return CommandEvaluation::dump(this->listOfPossibleFunctions_);
+                break;
+            case CS_ParamPreparation:
+            case CS_Params:
+                if (this->listOfPossibleArguments_.size() > 0)
+                    return CommandEvaluation::dump(this->listOfPossibleArguments_);
+                else
+                    return CommandEvaluation::dump(this->function_);
+            case CS_Finished:
+                if (this->function_)
+                    return CommandEvaluation::dump(this->function_);
+                break;
+            case CS_Error:
+                return this->errorMessage_;
+                break;
+        }
+
+        return "";
+    }
+
+    void CommandEvaluation::evaluateParams()
+    {
+        this->bEvaluatedParams_ = false;
+
+        for (unsigned int i = 0; i < MAX_FUNCTOR_ARGUMENTS; i++)
+            this->param_[i] = MT_null;
+
+        if (!this->isValid())
+            return;
+
+        unsigned int startindex = this->getStartindex();
+
+        if (this->commandTokens_.size() <= startindex)
+        {
+            if (this->function_->evaluate(this->getAdditionalParameter(), this->param_, " "))
+                this->bEvaluatedParams_ = true;
+        }
+        else if (this->commandTokens_.size() > startindex)
+        {
+            if (this->function_->evaluate(this->commandTokens_.subSet(startindex).join() + this->getAdditionalParameter(), this->param_, " "))
+                this->bEvaluatedParams_ = true;
+        }
+    }
+
+    void CommandEvaluation::setEvaluatedParameter(unsigned int index, MultiType param)
+    {
+        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
+            this->param_[index] = param;
+    }
+
+    MultiType CommandEvaluation::getEvaluatedParameter(unsigned int index) const
+    {
+        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
+            return this->param_[index];
+
+        return MT_null;
+    }
+
+    bool CommandEvaluation::hasReturnvalue() const
+    {
+        if (this->function_)
+            return this->function_->hasReturnvalue();
+
+        return MT_null;
+    }
+
+    MultiType CommandEvaluation::getReturnvalue() const
+    {
+        if (this->function_)
+            return this->function_->getReturnvalue();
+
+        return MultiType();
+    }
+
+
+    unsigned int CommandEvaluation::getStartindex() const
+    {
+        if (this->functionclass_ && this->function_)
+            return 2;
+        else if (this->function_)
+            return 1;
+        else
+            return 0;
+    }
+
+    std::string CommandEvaluation::dump(const std::list<std::pair<const std::string*, const std::string*> >& list)
+    {
+        std::string output = "";
+        for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += " ";
+
+            output += *(*it).second;
+        }
+        return output;
+    }
+
+    std::string CommandEvaluation::dump(const ArgumentCompletionList& list)
+    {
+        std::string output = "";
+        for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += " ";
+
+            output += (*it).getDisplay();
+        }
+        return output;
+    }
+
+    std::string CommandEvaluation::dump(const ConsoleCommand* command)
+    {
+        std::string output = command->getName();
+        if (command->getParamCount() > 0)
+            output += ": ";
+
+        for (unsigned int i = 0; i < command->getParamCount(); i++)
+        {
+            if (i != 0)
+                output += " ";
+
+            if (command->defaultValueSet(i))
+                output += "[";
+            else
+                output += "{";
+
+            output += command->getTypenameParam(i);
+
+            if (command->defaultValueSet(i))
+                output += "=" + command->getDefaultValue(i).getString() + "]";
+            else
+                output += "}";
+        }
+        return output;
+    }
+}
Index: /code/branches/ceguilua/src/core/CommandEvaluation.h
===================================================================
--- /code/branches/ceguilua/src/core/CommandEvaluation.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/CommandEvaluation.h	(revision 1801)
@@ -0,0 +1,121 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandEvaluation_H__
+#define _CommandEvaluation_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+#include "ArgumentCompletionListElement.h"
+#include "util/SubString.h"
+#include "util/MultiType.h"
+
+namespace orxonox
+{
+    enum CommandState
+    {
+        CS_Uninitialized,
+        CS_Empty,
+        CS_ShortcutOrIdentifier,
+        CS_Function,
+        CS_ParamPreparation,
+        CS_Params,
+        CS_Finished,
+        CS_Error
+    };
+
+    class _CoreExport CommandEvaluation
+    {
+        friend class CommandExecutor;
+
+        public:
+            CommandEvaluation();
+
+            void initialize(const std::string& command);
+
+            bool execute() const;
+            std::string complete();
+            std::string hint() const;
+            void evaluateParams();
+
+            bool isValid() const;
+
+            inline ConsoleCommand* getConsoleCommand() const
+                { return this->function_; }
+            inline const std::string& getOriginalCommand() const
+                { return this->originalCommand_; }
+            inline const std::string& getCommand() const
+                { return this->command_; }
+
+            inline void setAdditionalParameter(const std::string& param)
+                { this->additionalParameter_ = param; this->bEvaluatedParams_ = false; }
+            inline std::string getAdditionalParameter() const
+                { return (this->additionalParameter_ != "") ? (" " + this->additionalParameter_) : ""; }
+
+            void setEvaluatedParameter(unsigned int index, MultiType param);
+            MultiType getEvaluatedParameter(unsigned int index) const;
+
+            bool hasReturnvalue() const;
+            MultiType getReturnvalue() const;
+
+        private:
+            unsigned int getStartindex() const;
+            static std::string dump(const std::list<std::pair<const std::string*, const std::string*> >& list);
+            static std::string dump(const ArgumentCompletionList& list);
+            static std::string dump(const ConsoleCommand* command);
+
+
+            bool bNewCommand_;
+            bool bCommandChanged_;
+
+            std::string originalCommand_;
+            std::string command_;
+            SubString commandTokens_;
+            std::string additionalParameter_;
+
+            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleIdentifiers_;
+            std::list<std::pair<const std::string*, const std::string*> > listOfPossibleFunctions_;
+            ArgumentCompletionList listOfPossibleArguments_;
+
+            Identifier* functionclass_;
+            ConsoleCommand* function_;
+            std::string possibleArgument_;
+            std::string argument_;
+
+            std::string errorMessage_;
+            CommandState state_;
+
+            bool bEvaluatedParams_;
+            MultiType param_[5];
+    };
+}
+
+#endif /* _CommandEvaluation_H__ */
Index: /code/branches/ceguilua/src/core/CommandExecutor.cc
===================================================================
--- /code/branches/ceguilua/src/core/CommandExecutor.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/CommandExecutor.cc	(revision 1801)
@@ -0,0 +1,649 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CommandExecutor.h"
+#include "ConsoleCommand.h"
+#include "util/String.h"
+#include "util/Debug.h"
+#include "Identifier.h"
+#include "Language.h"
+#include "TclBind.h"
+
+namespace orxonox
+{
+    CommandExecutor& CommandExecutor::getInstance()
+    {
+        static CommandExecutor instance;
+        return instance;
+    }
+
+    CommandEvaluation& CommandExecutor::getEvaluation()
+    {
+        return CommandExecutor::getInstance().evaluation_;
+    }
+
+    const CommandEvaluation& CommandExecutor::getLastEvaluation()
+    {
+        return CommandExecutor::getInstance().evaluation_;
+    }
+
+    ConsoleCommand& CommandExecutor::addConsoleCommandShortcut(ConsoleCommand* command)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(command->getName());
+        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
+        {
+            COUT(2) << "Warning: Overwriting console-command shortcut with name " << command->getName() << "." << std::endl;
+        }
+
+
+        CommandExecutor::getInstance().consoleCommandShortcuts_[command->getName()] = command;
+        CommandExecutor::getInstance().consoleCommandShortcuts_LC_[getLowercase(command->getName())] = command;
+        return (*command);
+    }
+
+    /**
+        @brief Returns the executor of a console command shortcut with given name.
+        @brief name The name of the requested console command shortcut
+        @return The executor of the requested console command shortcut
+    */
+    ConsoleCommand* CommandExecutor::getConsoleCommandShortcut(const std::string& name)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_.find(name);
+        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the executor of a console command shortcut with given name in lowercase.
+        @brief name The name of the requested console command shortcut in lowercase
+        @return The executor of the requested console command shortcut
+    */
+    ConsoleCommand* CommandExecutor::getLowercaseConsoleCommandShortcut(const std::string& name)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getInstance().consoleCommandShortcuts_LC_.find(name);
+        if (it != CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    bool CommandExecutor::execute(const std::string& command, bool useTcl)
+    {
+        if (useTcl)
+            return TclBind::eval(command);
+
+        CommandExecutor::parseIfNeeded(command);
+        return CommandExecutor::getEvaluation().execute();
+    }
+
+    std::string CommandExecutor::complete(const std::string& command)
+    {
+        CommandExecutor::parseIfNeeded(command);
+        return CommandExecutor::getEvaluation().complete();
+    }
+
+    std::string CommandExecutor::hint(const std::string& command)
+    {
+        CommandExecutor::parseIfNeeded(command);
+        return CommandExecutor::getEvaluation().hint();
+    }
+
+    CommandEvaluation CommandExecutor::evaluate(const std::string& command)
+    {
+        CommandExecutor::parse(command);
+        CommandExecutor::getEvaluation().evaluateParams();
+        return CommandExecutor::getEvaluation();
+    }
+
+    void CommandExecutor::parseIfNeeded(const std::string& command)
+    {
+        if (CommandExecutor::getEvaluation().state_ == CS_Uninitialized)
+        {
+            CommandExecutor::parse(command);
+        }
+        else if (CommandExecutor::getEvaluation().originalCommand_ != command)
+        {
+            if (CommandExecutor::getEvaluation().command_ == command)
+            {
+                CommandExecutor::parse(command);
+                CommandExecutor::getEvaluation().bNewCommand_ = false;
+            }
+            else
+            {
+                CommandExecutor::parse(command);
+            }
+        }
+    }
+
+    void CommandExecutor::parse(const std::string& command, bool bInitialize)
+    {
+        if (bInitialize)
+            CommandExecutor::getEvaluation().initialize(command);
+
+        CommandExecutor::getEvaluation().commandTokens_.split(command, " ", SubString::WhiteSpaces, false, '\\', false, '"', false, '(', ')', false, '\0');
+        CommandExecutor::getEvaluation().command_ = command;
+
+        switch (CommandExecutor::getEvaluation().state_)
+        {
+            case CS_Uninitialized:
+            {
+                // Impossible
+                break;
+            }
+            case CS_Empty:
+            {
+                if (CommandExecutor::argumentsGiven() == 0)
+                {
+                    CommandExecutor::createListOfPossibleFunctions("");
+                    CommandExecutor::createListOfPossibleIdentifiers("");
+                    break;
+                }
+                else
+                {
+                    CommandExecutor::getEvaluation().state_ = CS_ShortcutOrIdentifier;
+                    // Move on to next case
+                }
+            }
+            case CS_ShortcutOrIdentifier:
+            {
+                if (CommandExecutor::argumentsGiven() > 1)
+                {
+                    // There's a finished first argument - check if it's a shortcut or a classname
+                    CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
+                    CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
+
+                    if (CommandExecutor::getEvaluation().function_)
+                    {
+                        // It's a shortcut
+                        CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                        CommandExecutor::getEvaluation().functionclass_ = 0;
+                        // Move on to next case
+                    }
+                    else if (CommandExecutor::getEvaluation().functionclass_)
+                    {
+                        // It's a functionname
+                        CommandExecutor::getEvaluation().state_ = CS_Function;
+                        CommandExecutor::getEvaluation().function_ = 0;
+                        // Move on to next case
+                    }
+                    else
+                    {
+                        // The first argument is bad
+                        CommandExecutor::getEvaluation().state_ = CS_Error;
+                        AddLanguageEntry("commandexecutorunknownfirstargument", "is not a shortcut nor a classname");
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(0) + " " + GetLocalisation("commandexecutorunknownfirstargument") + ".";
+                        return;
+                    }
+                }
+                else
+                {
+                    // There's no finished first argument - search possible shortcuts or classnames
+                    CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(0));
+                    CommandExecutor::createListOfPossibleIdentifiers(CommandExecutor::getArgument(0));
+
+                    unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
+                    unsigned int num_identifiers = CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.size();
+
+                    if (num_functions == 1 && num_identifiers == 0)
+                    {
+                        // It's a shortcut
+                        std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname);
+                        if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(0)))
+                        {
+                            // Unfinished shortcut
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        }
+                        CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                        CommandExecutor::getEvaluation().functionclass_ = 0;
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().function_->getName();
+                        if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
+                        {
+                            CommandExecutor::getEvaluation().command_ += " ";
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        }
+                        // Move on to next case
+                    }
+                    else if (num_identifiers == 1 && num_functions == 0)
+                    {
+                        // It's a classname
+                        std::string classname = *(*CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin()).first;
+                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(classname);
+                        if (getLowercase(classname) != getLowercase(CommandExecutor::getArgument(0)))
+                        {
+                            // Unfinished classname
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        }
+                        CommandExecutor::getEvaluation().state_ = CS_Function;
+                        CommandExecutor::getEvaluation().function_ = 0;
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " ";
+                        // Move on to next case
+                    }
+                    else if (num_identifiers == 0 && num_functions == 0)
+                    {
+                        // No possibilities
+                        CommandExecutor::getEvaluation().state_ = CS_Error;
+                        AddLanguageEntry("commandexecutorunknownfirstargumentstart", "There is no command or classname starting with");
+                        CommandExecutor::getEvaluation().errorMessage_ = "Error: " + GetLocalisation("commandexecutorunknownfirstargumentstart") + " " + CommandExecutor::getArgument(0) + ".";
+                        return;
+                    }
+                    else
+                    {
+                        // There are several possiblilities
+                        std::list<std::pair<const std::string*, const std::string*> > temp;
+                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin(), CommandExecutor::getEvaluation().listOfPossibleFunctions_.end());
+                        temp.insert(temp.end(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.begin(), CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.end());
+                        CommandExecutor::getEvaluation().command_ = CommandExecutor::getCommonBegin(temp);
+                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(0));
+                        CommandExecutor::getEvaluation().functionclass_ = CommandExecutor::getPossibleIdentifier(CommandExecutor::getArgument(0));
+                        CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                        return;
+                    }
+                }
+            }
+            case CS_Function:
+            {
+                if (CommandExecutor::getEvaluation().functionclass_)
+                {
+                    // There is a classname - search for the commandname
+                    if (CommandExecutor::argumentsGiven() > 2)
+                    {
+                        // There is a finished second argument - check if it's a commandname
+                        CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
+
+                        if (CommandExecutor::getEvaluation().function_)
+                        {
+                            // It's a function
+                            CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                            // Move on to next case
+                        }
+                        else
+                        {
+                            // The second argument is bad
+                            CommandExecutor::getEvaluation().state_ = CS_Error;
+                            AddLanguageEntry("commandexecutorunknownsecondargument", "is not a function of");
+                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getArgument(1) + " " + GetLocalisation("commandexecutorunknownsecondargument") + " " + CommandExecutor::getEvaluation().functionclass_->getName() + ".";
+                            return;
+                        }
+                    }
+                    else
+                    {
+                        // There is no finished second argument - search for possibilities
+                        CommandExecutor::createListOfPossibleFunctions(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
+                        unsigned int num_functions = CommandExecutor::getEvaluation().listOfPossibleFunctions_.size();
+
+                        if (num_functions == 1)
+                        {
+                            // It's a function
+                            std::string functionname = *(*CommandExecutor::getEvaluation().listOfPossibleFunctions_.begin()).first;
+                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(functionname, CommandExecutor::getEvaluation().functionclass_);
+                            if (getLowercase(functionname) != getLowercase(CommandExecutor::getArgument(1)))
+                            {
+                                // Unfinished function
+                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                            }
+                            CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getEvaluation().function_->getName();
+                            if (CommandExecutor::getEvaluation().function_->getParamCount() > 0)
+                            {
+                                CommandExecutor::getEvaluation().command_ += " ";
+                                CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                            }
+                            // Move on to next case
+                        }
+                        else if (num_functions == 0)
+                        {
+                            // No possibilities
+                            CommandExecutor::getEvaluation().state_ = CS_Error;
+                            AddLanguageEntry("commandexecutorunknownsecondargumentstart", "has no function starting with");
+                            CommandExecutor::getEvaluation().errorMessage_ = "Error: " + CommandExecutor::getEvaluation().functionclass_->getName() + " " + GetLocalisation("commandexecutorunknownsecondargumentstart") + " " + CommandExecutor::getArgument(1) + ".";
+                            return;
+                        }
+                        else
+                        {
+                            // There are several possibilities
+                            CommandExecutor::getEvaluation().command_ = CommandExecutor::getEvaluation().functionclass_->getName() + " " + CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleFunctions_);
+                            CommandExecutor::getEvaluation().function_ = CommandExecutor::getPossibleCommand(CommandExecutor::getArgument(1), CommandExecutor::getEvaluation().functionclass_);
+                            CommandExecutor::getEvaluation().bCommandChanged_ = true;
+                            return;
+                        }
+                    }
+                }
+                else
+                {
+                    // There is no classname - move on to CS_ParamPreparation
+                }
+            }
+            case CS_ParamPreparation:
+            {
+                if (CommandExecutor::getEvaluation().function_->getParamCount() == 0 || CommandExecutor::enoughArgumentsGiven(CommandExecutor::getEvaluation().function_))
+                {
+                    CommandExecutor::getEvaluation().state_ = CS_Finished;
+                    return;
+                }
+                else
+                {
+                    unsigned int argumentNumber = CommandExecutor::argumentsGiven() - 2;
+                    if (CommandExecutor::getEvaluation().functionclass_)
+                        argumentNumber -= 1;
+
+                    CommandExecutor::createListOfPossibleArguments(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
+                    CommandExecutor::getEvaluation().state_ = CS_Params;
+
+                    if (CommandExecutor::getEvaluation().bCommandChanged_)
+                    {
+                        // Don't do more than one change
+                        return;
+                    }
+                }
+            }
+            case CS_Params:
+            {
+                if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 1)
+                {
+                    // There is exactly one possible argument
+                    CommandExecutor::getEvaluation().argument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+                    CommandExecutor::getEvaluation().possibleArgument_ = (*CommandExecutor::getEvaluation().listOfPossibleArguments_.begin()).getString();
+                    CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                    return;
+                }
+                else if (CommandExecutor::getEvaluation().listOfPossibleArguments_.size() == 0)
+                {
+                    // The user tries something new - we let him do
+                    CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getLastArgument();
+                    return;
+                }
+                else
+                {
+                    // There are several possibilities
+                    unsigned int argumentNumber = CommandExecutor::argumentsGiven();
+                    if (argumentNumber > 0)
+                        --argumentNumber;
+                    if (CommandExecutor::getEvaluation().functionclass_ && argumentNumber > 0)
+                        --argumentNumber;
+
+                    CommandExecutor::getEvaluation().argument_ = CommandExecutor::getCommonBegin(CommandExecutor::getEvaluation().listOfPossibleArguments_);
+                    CommandExecutor::getEvaluation().possibleArgument_ = CommandExecutor::getPossibleArgument(CommandExecutor::getLastArgument(), CommandExecutor::getEvaluation().function_, argumentNumber);
+                    CommandExecutor::getEvaluation().state_ = CS_ParamPreparation;
+                    return;
+                }
+            }
+            case CS_Finished:
+            {
+                // Nothing more to do
+                break;
+            }
+            case CS_Error:
+            {
+                // Bad, very bad
+                break;
+            }
+        }
+    }
+
+    unsigned int CommandExecutor::argumentsFinished()
+    {
+        unsigned int argumentsGiven = CommandExecutor::argumentsGiven();
+        if (argumentsGiven > 0)
+            return argumentsGiven - 1;
+        else
+            return 0;
+    }
+
+    unsigned int CommandExecutor::argumentsGiven()
+    {
+        if (CommandExecutor::getEvaluation().command_.size() > 0 && CommandExecutor::getEvaluation().command_[CommandExecutor::getEvaluation().command_.size() - 1] == ' ')
+            return CommandExecutor::getEvaluation().commandTokens_.size() + 1;
+        else
+            return CommandExecutor::getEvaluation().commandTokens_.size();
+    }
+
+    bool CommandExecutor::enoughArgumentsGiven(ConsoleCommand* command)
+    {
+        if (CommandExecutor::getEvaluation().functionclass_)
+            return (CommandExecutor::argumentsGiven() > (2 + command->getParamCount()));
+        else
+            return (CommandExecutor::argumentsGiven() > (1 + command->getParamCount()));
+    }
+
+    std::string CommandExecutor::getArgument(unsigned int index)
+    {
+        if (index < (CommandExecutor::getEvaluation().commandTokens_.size()))
+            return CommandExecutor::getEvaluation().commandTokens_[index];
+        else
+            return "";
+    }
+
+    std::string CommandExecutor::getLastArgument()
+    {
+        return CommandExecutor::getArgument(CommandExecutor::argumentsGiven() - 1);
+    }
+
+    void CommandExecutor::createListOfPossibleIdentifiers(const std::string& fragment)
+    {
+        CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
+        std::string lowercase = getLowercase(fragment);
+        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)
+            if ((*it).second->hasConsoleCommands())
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+    }
+
+    void CommandExecutor::createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier)
+    {
+        CommandExecutor::getEvaluation().listOfPossibleFunctions_.clear();
+        std::string lowercase = getLowercase(fragment);
+        if (!identifier)
+        {
+            for (std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMapBegin(); it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd(); ++it)
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+        }
+        else
+        {
+            for (std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMapBegin(); it != identifier->getLowercaseConsoleCommandMapEnd(); ++it)
+                if ((*it).first.find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleFunctions_.push_back(std::pair<const std::string*, const std::string*>(&(*it).first, &(*it).second->getName()));
+        }
+    }
+
+    void CommandExecutor::createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param)
+    {
+        CommandExecutor::createArgumentCompletionList(command, param);
+
+        CommandExecutor::getEvaluation().listOfPossibleArguments_.clear();
+        std::string lowercase = getLowercase(fragment);
+        for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
+        {
+            if ((*it).lowercaseComparison())
+            {
+                if ((*it).getComparable().find(lowercase) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
+            }
+            else
+            {
+                if ((*it).getComparable().find(fragment) == 0 || fragment == "")
+                    CommandExecutor::getEvaluation().listOfPossibleArguments_.push_back(*it);
+            }
+        }
+    }
+
+    Identifier* CommandExecutor::getPossibleIdentifier(const std::string& name)
+    {
+        std::string lowercase = getLowercase(name);
+        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMap().find(lowercase);
+        if ((it != Identifier::getLowercaseIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
+            return (*it).second;
+
+        return 0;
+    }
+
+    ConsoleCommand* CommandExecutor::getPossibleCommand(const std::string& name, Identifier* identifier)
+    {
+        std::string lowercase = getLowercase(name);
+        if (!identifier)
+        {
+            std::map<std::string, ConsoleCommand*>::const_iterator it = CommandExecutor::getLowercaseConsoleCommandShortcutMap().find(lowercase);
+            if (it != CommandExecutor::getLowercaseConsoleCommandShortcutMapEnd())
+                return (*it).second;
+        }
+        else
+        {
+            std::map<std::string, ConsoleCommand*>::const_iterator it = identifier->getLowercaseConsoleCommandMap().find(lowercase);
+            if (it != identifier->getLowercaseConsoleCommandMapEnd())
+                return (*it).second;
+        }
+        return 0;
+    }
+
+    std::string CommandExecutor::getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param)
+    {
+        CommandExecutor::createArgumentCompletionList(command, param);
+
+        std::string lowercase = getLowercase(name);
+        for (ArgumentCompletionList::const_iterator it = command->getArgumentCompletionListBegin(); it != command->getArgumentCompletionListEnd(); ++it)
+        {
+            if ((*it).lowercaseComparison())
+            {
+                if ((*it).getComparable() == lowercase)
+                    return (*it).getString();
+            }
+            else
+            {
+                if ((*it).getComparable() == name)
+                    return (*it).getString();
+            }
+        }
+
+        return "";
+    }
+
+    void CommandExecutor::createArgumentCompletionList(ConsoleCommand* command, unsigned int param)
+    {
+        std::string params[5];
+
+        unsigned int index = 0;
+        unsigned int lowestIndex = 1 + (CommandExecutor::getEvaluation().functionclass_ != 0);
+
+        for (unsigned int i = CommandExecutor::argumentsGiven() - 1; i >= lowestIndex; --i)
+        {
+            params[index] = CommandExecutor::getArgument(i);
+            ++index;
+            if (index >= 5)
+                break;
+        }
+
+        command->createArgumentCompletionList(param, params[0], params[1], params[2], params[3], params[4]);
+    }
+
+    std::string CommandExecutor::getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list)
+    {
+        if (list.size() == 0)
+        {
+            return "";
+        }
+        else if (list.size() == 1)
+        {
+            return ((*(*list.begin()).first) + " ");
+        }
+        else
+        {
+            std::string output = "";
+            for (unsigned int i = 0; true; i++)
+            {
+                char temp = 0;
+                for (std::list<std::pair<const std::string*, const std::string*> >::const_iterator it = list.begin(); it != list.end(); ++it)
+                {
+                    if ((*(*it).first).size() > i)
+                    {
+                        if (it == list.begin())
+                        {
+                            temp = (*(*it).first)[i];
+                        }
+                        else
+                        {
+                            if (temp != (*(*it).first)[i])
+                                return output;
+                        }
+                    }
+                    else
+                    {
+                        return output;
+                    }
+                }
+                output += temp;
+            }
+            return output;
+        }
+    }
+
+    std::string CommandExecutor::getCommonBegin(const ArgumentCompletionList& list)
+    {
+        if (list.size() == 0)
+        {
+            return "";
+        }
+        else if (list.size() == 1)
+        {
+            return ((*list.begin()).getComparable() + " ");
+        }
+        else
+        {
+            std::string output = "";
+            for (unsigned int i = 0; true; i++)
+            {
+                char temp = 0;
+                for (ArgumentCompletionList::const_iterator it = list.begin(); it != list.end(); ++it)
+                {
+                    std::string argument = (*it).getComparable();
+                    if (argument.size() > i)
+                    {
+                        if (it == list.begin())
+                        {
+                            temp = argument[i];
+                        }
+                        else
+                        {
+                            if (temp != argument[i])
+                                return output;
+                        }
+                    }
+                    else
+                    {
+                        return output;
+                    }
+                }
+                output += temp;
+            }
+            return output;
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/CommandExecutor.h
===================================================================
--- /code/branches/ceguilua/src/core/CommandExecutor.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/CommandExecutor.h	(revision 1801)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _CommandExecutor_H__
+#define _CommandExecutor_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+
+#include "CommandEvaluation.h"
+
+namespace orxonox // tolua_export
+{ // tolua_export
+    class _CoreExport CommandExecutor
+    /*
+    class CommandExecutor { // tolua_export
+    */
+    {
+        public:
+            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);
+
+            static CommandEvaluation evaluate(const std::string& command);
+            static const CommandEvaluation& getLastEvaluation();
+
+            static ConsoleCommand& addConsoleCommandShortcut(ConsoleCommand* command);
+            static ConsoleCommand* getConsoleCommandShortcut(const std::string& name);
+            static ConsoleCommand* getLowercaseConsoleCommandShortcut(const std::string& name);
+
+            /** @brief Returns the map that stores all console commands. @return The const_iterator */
+            static inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_.end(); }
+
+            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            static inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandShortcutMap() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapBegin() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandShortcutMapEnd() { return CommandExecutor::getInstance().consoleCommandShortcuts_LC_.end(); }
+
+        private:
+            CommandExecutor() {}
+            CommandExecutor(const CommandExecutor& other);
+            ~CommandExecutor() {}
+
+            static CommandExecutor& getInstance();
+            static CommandEvaluation& getEvaluation();
+
+            static void parseIfNeeded(const std::string& command);
+            static void parse(const std::string& command, bool bInitialize = true);
+
+            static unsigned int argumentsFinished();
+            static unsigned int argumentsGiven();
+            static bool enoughArgumentsGiven(ConsoleCommand* command);
+            static std::string getArgument(unsigned int index);
+            static std::string getLastArgument();
+
+            static void createListOfPossibleIdentifiers(const std::string& fragment);
+            static void createListOfPossibleFunctions(const std::string& fragment, Identifier* identifier = 0);
+            static void createListOfPossibleArguments(const std::string& fragment, ConsoleCommand* command, unsigned int param);
+
+            static Identifier* getPossibleIdentifier(const std::string& name);
+            static ConsoleCommand* getPossibleCommand(const std::string& name, Identifier* identifier = 0);
+            static std::string getPossibleArgument(const std::string& name, ConsoleCommand* command, unsigned int param);
+
+            static void createArgumentCompletionList(ConsoleCommand* command, unsigned int param);
+            static std::string getCommonBegin(const std::list<std::pair<const std::string*, const std::string*> >& list);
+            static std::string getCommonBegin(const ArgumentCompletionList& list);
+
+            CommandEvaluation evaluation_;
+            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_;
+            std::map<std::string, ConsoleCommand*> consoleCommandShortcuts_LC_;
+    }; // tolua_export
+} // tolua_export
+
+#endif /* _CommandExecutor_H__ */
Index: /code/branches/ceguilua/src/core/CommandLine.cc
===================================================================
--- /code/branches/ceguilua/src/core/CommandLine.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/CommandLine.cc	(revision 1801)
@@ -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/branches/ceguilua/src/core/CommandLine.h
===================================================================
--- /code/branches/ceguilua/src/core/CommandLine.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/CommandLine.h	(revision 1801)
@@ -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 "util/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/branches/ceguilua/src/core/ConfigFileManager.cc
===================================================================
--- /code/branches/ceguilua/src/core/ConfigFileManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConfigFileManager.cc	(revision 1801)
@@ -0,0 +1,564 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConfigFileManager.h"
+#include "ConfigValueContainer.h"
+#include "ConsoleCommand.h"
+#include "Identifier.h"
+#include "util/Convert.h"
+#include "util/String.h"
+
+
+namespace orxonox
+{
+    const int CONFIG_FILE_MAX_LINELENGHT  = 1024;
+    const char* const DEFAULT_CONFIG_FILE = "default.ini";
+
+    SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
+    SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
+    SetConsoleCommandShortcutExtern(reloadConfig);
+    SetConsoleCommandShortcutExtern(cleanConfig);
+    SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(loadKeybindings).argumentCompleter(0, autocompletion::files());
+
+    bool config(const std::string& classname, const std::string& varname, const std::string& value)
+    {
+        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
+        if (identifier != Identifier::getLowercaseIdentifierMapEnd())
+        {
+            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
+            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                return (*variable).second->set(value);
+        }
+        return false;
+    }
+
+    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
+    {
+        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
+        if (identifier != Identifier::getLowercaseIdentifierMapEnd())
+        {
+            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
+            if (variable != (*identifier).second->getLowercaseConfigValueMapEnd())
+                return (*variable).second->tset(value);
+        }
+        return false;
+    }
+
+    void reloadConfig()
+    {
+        ConfigFileManager::getInstance().load();
+    }
+
+    void cleanConfig()
+    {
+        ConfigFileManager::getInstance().clean(false);
+    }
+
+    void loadSettings(const std::string& filename)
+    {
+        ConfigFileManager::getInstance().setFile(CFT_Settings, filename, false);
+    }
+
+    void loadKeybindings(const std::string& filename)
+    {
+        ConfigFileManager::getInstance().setFile(CFT_Keybindings, filename);
+    }
+
+
+    //////////////////////////
+    // ConfigFileEntryValue //
+    //////////////////////////
+
+    void ConfigFileEntryValue::setValue(const std::string& value)
+    {
+        if (!this->bString_)
+            this->value_ = value;
+        else
+            this->value_ = "\"" + addSlashes(stripEnclosingQuotes(value)) + "\"";
+    }
+
+    std::string ConfigFileEntryValue::getValue() const
+    {
+        if (!this->bString_)
+            return this->value_;
+        else
+            return removeSlashes(stripEnclosingQuotes(this->value_));
+    }
+
+    std::string ConfigFileEntryValue::getFileEntry() const
+    {
+        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
+            return (this->name_ + "=" + this->value_);
+        else
+            return (this->name_ + "=" + this->value_ + " " + this->additionalComment_);
+    }
+
+
+    ///////////////////////////////
+    // ConfigFileEntryVectorValue //
+    ///////////////////////////////
+    std::string ConfigFileEntryVectorValue::getFileEntry() const
+    {
+        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
+            return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]" + "=" + this->value_);
+        else
+            return (this->name_ + "[" + getConvertedValue<unsigned int, std::string>(this->index_, "0") + "]=" + this->value_ + " " + this->additionalComment_);
+    }
+
+
+    ///////////////////////
+    // ConfigFileSection //
+    ///////////////////////
+    ConfigFileSection::~ConfigFileSection()
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); )
+            delete (*(it++));
+    }
+
+    void ConfigFileSection::deleteVectorEntries(const std::string& name, unsigned int startindex)
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); )
+        {
+            if (((*it)->getName() == name) && ((*it)->getIndex() >= startindex))
+            {
+                delete (*it);
+                this->entries_.erase(it++);
+            }
+            else
+            {
+                ++it;
+            }
+        }
+    }
+
+    unsigned int ConfigFileSection::getVectorSize(const std::string& name)
+    {
+        unsigned int size = 0;
+        for (std::list<ConfigFileEntry*>::const_iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+            if ((*it)->getName() == name)
+                if ((*it)->getIndex() > size)
+                    size = (*it)->getIndex();
+        return (size + 1);
+    }
+
+    std::string ConfigFileSection::getFileEntry() const
+    {
+        if (this->additionalComment_ == "" || this->additionalComment_.size() == 0)
+            return ("[" + this->name_ + "]");
+        else
+            return ("[" + this->name_ + "] " + this->additionalComment_);
+    }
+
+    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, const std::string& fallback, bool bString)
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+        {
+            if ((*it)->getName() == name)
+            {
+                (*it)->setString(bString);
+                return it;
+            }
+        }
+
+        this->bUpdated_ = true;
+
+        return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryValue(name, fallback, bString)));
+    }
+
+    std::list<ConfigFileEntry*>::iterator ConfigFileSection::getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+    {
+        for (std::list<ConfigFileEntry*>::iterator it = this->entries_.begin(); it != this->entries_.end(); ++it)
+        {
+            if (((*it)->getName() == name) && ((*it)->getIndex() == index))
+            {
+                (*it)->setString(bString);
+                return it;
+            }
+        }
+
+        this->bUpdated_ = true;
+
+        if (index == 0)
+            return this->entries_.insert(this->entries_.end(), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+        else
+            return this->entries_.insert(++this->getEntryIterator(name, index - 1, "", bString), (ConfigFileEntry*)(new ConfigFileEntryVectorValue(name, index, fallback, bString)));
+    }
+
+
+    ////////////////
+    // ConfigFile //
+    ////////////////
+    ConfigFile::~ConfigFile()
+    {
+        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); )
+            delete (*(it++));
+    }
+
+    void ConfigFile::load(bool bCreateIfNotExisting)
+    {
+        if (bCreateIfNotExisting)
+        {
+            // This creates the default config file if it's not existing
+            std::ofstream createFile;
+            createFile.open(this->filename_.c_str(), std::fstream::app);
+            createFile.close();
+        }
+
+        // Open the file
+        std::ifstream file;
+        file.open(this->filename_.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in ConfigFileManager.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open config-file \"" << this->filename_ << "\"." << std::endl;
+            return;
+        }
+
+        char linearray[CONFIG_FILE_MAX_LINELENGHT];
+
+        ConfigFileSection* newsection = 0;
+
+        while (file.good() && !file.eof())
+        {
+            file.getline(linearray, CONFIG_FILE_MAX_LINELENGHT);
+
+            std::string line = std::string(linearray);
+
+            std::string temp = getStripped(line);
+            if (!isEmpty(temp) && !isComment(temp))
+            {
+                unsigned int   pos1 = temp.find('[');
+                if (pos1 == 0) pos1 = line.find('['); else pos1 = std::string::npos;
+                unsigned int   pos2 = line.find(']');
+
+                if (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1)
+                {
+                    // New section
+                    std::string comment = line.substr(pos2 + 1);
+                    if (isComment(comment))
+                        newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1), comment);
+                    else
+                        newsection = new ConfigFileSection(line.substr(pos1 + 1, pos2 - pos1 - 1));
+                    this->sections_.insert(this->sections_.end(), newsection);
+                    continue;
+                }
+            }
+
+            if (newsection != 0)
+            {
+                if (isComment(line))
+                {
+                    // New comment
+                    newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryComment(removeTrailingWhitespaces(line)));
+                    continue;
+                }
+                else
+                {
+                    unsigned int pos1 = line.find('=');
+
+                    if (pos1 != std::string::npos && pos1 > 0)
+                    {
+                        // New entry
+                        unsigned int pos2 = line.find('[');
+                        unsigned int pos3 = line.find(']');
+                        unsigned int commentposition = getNextCommentPosition(line, pos1 + 1);
+                        while (isBetweenQuotes(line, commentposition))
+                        {
+                            commentposition = getNextCommentPosition(line, commentposition + 1);
+                        }
+                        std::string value = "", comment = "";
+                        if (commentposition == std::string::npos)
+                        {
+                            value = removeTrailingWhitespaces(line.substr(pos1 + 1));
+                        }
+                        else
+                        {
+                            value = removeTrailingWhitespaces(line.substr(pos1 + 1, commentposition - pos1 - 1));
+                            comment = removeTrailingWhitespaces(line.substr(commentposition));
+                        }
+
+                        if (pos2 != std::string::npos && pos3 != std::string::npos && pos3 > pos2 + 1)
+                        {
+                            // There might be an array index
+                            unsigned int index = 0;
+                            if (ConvertValue(&index, line.substr(pos2 + 1, pos3 - pos2 - 1)))
+                            {
+                                // New array
+                                std::list<ConfigFileEntry*>::iterator it = newsection->getEntryIterator(getStripped(line.substr(0, pos2)), index, value, false);
+                                (*it)->setValue(value);
+                                (*it)->setComment(comment);
+                                continue;
+                            }
+                        }
+
+                        // New value
+                        newsection->getEntries().insert(newsection->getEntries().end(), new ConfigFileEntryValue(getStripped(line.substr(0, pos1)), value, false, comment));
+                        continue;
+                    }
+                }
+            }
+        }
+
+        file.close();
+
+        COUT(0) << "Loaded config file \"" << this->filename_ << "\"." << std::endl;
+
+        // Save the file in case something changed (like stripped whitespaces)
+        this->save();
+    }
+
+    void ConfigFile::save() const
+    {
+        std::ofstream file;
+        file.open(this->filename_.c_str(), std::fstream::out);
+        file.setf(std::ios::fixed, std::ios::floatfield);
+        file.precision(6);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in ConfigFileManager.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open config-file \"" << this->filename_ << "\"." << std::endl;
+            return;
+        }
+
+        for (std::list<ConfigFileSection*>::const_iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+        {
+            file << (*it)->getFileEntry() << std::endl;
+
+            for (std::list<ConfigFileEntry*>::const_iterator it_entries = (*it)->getEntriesBegin(); it_entries != (*it)->getEntriesEnd(); ++it_entries)
+            {
+                file << (*it_entries)->getFileEntry() << std::endl;
+            }
+
+            file << std::endl;
+        }
+
+        file.close();
+
+        COUT(4) << "Saved config file \"" << this->filename_ << "\"." << std::endl;
+    }
+
+    void ConfigFile::save(const std::string& filename)
+    {
+        std::string temp = this->filename_;
+        this->filename_ = filename;
+        this->save();
+        this->filename_ = temp;
+    }
+
+    void ConfigFile::clean(bool bCleanComments)
+    {
+        for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
+        {
+            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getIdentifierMap().find((*it1)->getName());
+            if (it2 != Identifier::getIdentifierMapEnd() && (*it2).second->hasConfigValues())
+            {
+                // The section exists, delete comment
+                if (bCleanComments)
+                    (*it1)->setComment("");
+                for (std::list<ConfigFileEntry*>::iterator it3 = (*it1)->entries_.begin(); it3 != (*it1)->entries_.end(); )
+                {
+                    std::map<std::string, ConfigValueContainer*>::const_iterator it4 = (*it2).second->getConfigValueMap().find((*it3)->getName());
+                    if (it4 != (*it2).second->getConfigValueMapEnd())
+                    {
+                        // The config-value exists, delete comment
+                        if (bCleanComments)
+                            (*it3)->setComment("");
+                        ++it3;
+                    }
+                    else
+                    {
+                        // The config-value doesn't exist
+                        delete (*it3);
+                        (*it1)->entries_.erase(it3++);
+                    }
+                }
+                ++it1;
+            }
+            else
+            {
+                // The section doesn't exist
+                delete (*it1);
+                this->sections_.erase(it1++);
+            }
+        }
+
+        // Save the file
+        this->save();
+    }
+
+    ConfigFileSection* ConfigFile::getSection(const std::string& section)
+    {
+        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+            if ((*it)->getName() == section)
+                return (*it);
+
+        this->bUpdated_ = true;
+
+        return (*this->sections_.insert(this->sections_.end(), new ConfigFileSection(section)));
+    }
+
+    void ConfigFile::saveIfUpdated()
+    {
+        bool sectionsUpdated = false;
+
+        for (std::list<ConfigFileSection*>::iterator it = this->sections_.begin(); it != this->sections_.end(); ++it)
+        {
+            if ((*it)->bUpdated_)
+            {
+                sectionsUpdated = true;
+                (*it)->bUpdated_ = false;
+            }
+        }
+
+        if (this->bUpdated_ || sectionsUpdated)
+        {
+            this->bUpdated_ = false;
+            this->save();
+        }
+    }
+
+
+    ///////////////////////
+    // ConfigFileManager //
+    ///////////////////////
+    ConfigFileManager::ConfigFileManager()
+    {
+        this->setFile(CFT_Settings, DEFAULT_CONFIG_FILE);
+    }
+
+    ConfigFileManager::~ConfigFileManager()
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); )
+            delete (*(it++)).second;
+    }
+
+    ConfigFileManager& ConfigFileManager::getInstance()
+    {
+        static ConfigFileManager instance;
+        return instance;
+    }
+
+    void ConfigFileManager::setFile(ConfigFileType type, const std::string& filename, bool bCreateIfNotExisting)
+    {
+        std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.find(type);
+        if (it != this->configFiles_.end())
+            if ((*it).second != 0)
+                delete (*it).second;
+
+        this->configFiles_[type] = new ConfigFile(this->getFilePath(filename));
+        this->load(type, bCreateIfNotExisting);
+    }
+
+    void ConfigFileManager::load(bool bCreateIfNotExisting)
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            (*it).second->load(bCreateIfNotExisting);
+
+        this->updateConfigValues();
+    }
+
+    void ConfigFileManager::save()
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            (*it).second->save();
+    }
+
+    void ConfigFileManager::clean(bool bCleanComments)
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            this->clean((*it).first, bCleanComments);
+    }
+
+    void ConfigFileManager::load(ConfigFileType type, bool bCreateIfNotExisting)
+    {
+        this->getFile(type)->load(bCreateIfNotExisting);
+        this->updateConfigValues(type);
+    }
+
+    void ConfigFileManager::save(ConfigFileType type)
+    {
+        this->getFile(type)->save();
+    }
+
+    void ConfigFileManager::save(ConfigFileType type, const std::string& filename)
+    {
+        this->getFile(type)->save(filename);
+    }
+
+    void ConfigFileManager::clean(ConfigFileType type, bool bCleanComments)
+    {
+        this->getFile(type)->clean(bCleanComments);
+    }
+
+    void ConfigFileManager::updateConfigValues() const
+    {
+        for(std::map<ConfigFileType, ConfigFile*>::const_iterator it = this->configFiles_.begin(); it != this->configFiles_.end(); ++it)
+            this->updateConfigValues((*it).first);
+    }
+
+    void ConfigFileManager::updateConfigValues(ConfigFileType type) const
+    {
+        if (type == CFT_Settings)
+        {
+            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
+            {
+                if ((*it).second->hasConfigValues() /* && (*it).second != ClassIdentifier<KeyBinder>::getIdentifier()*/)
+                {
+                    for (std::map<std::string, ConfigValueContainer*>::const_iterator it2 = (*it).second->getConfigValueMapBegin(); it2 != (*it).second->getConfigValueMapEnd(); ++it2)
+                        (*it2).second->update();
+
+                    (*it).second->updateConfigValues();
+                }
+            }
+        }
+        else if (type == CFT_Keybindings)
+        {
+            // todo
+        }
+    }
+
+    ConfigFile* ConfigFileManager::getFile(ConfigFileType type)
+    {
+        std::map<ConfigFileType, ConfigFile*>::iterator it = this->configFiles_.find(type);
+        if (it != this->configFiles_.end())
+            return (*it).second;
+
+        if (type == CFT_Settings)
+            return this->configFiles_[type] = new ConfigFile(DEFAULT_CONFIG_FILE);
+        else
+            return this->configFiles_[type] = new ConfigFile("");
+    }
+
+    std::string ConfigFileManager::getFilePath(const std::string& name) const
+    {
+        return name;
+    }
+}
Index: /code/branches/ceguilua/src/core/ConfigFileManager.h
===================================================================
--- /code/branches/ceguilua/src/core/ConfigFileManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConfigFileManager.h	(revision 1801)
@@ -0,0 +1,304 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ConfigFileManager_H__
+#define _ConfigFileManager_H__
+
+#include "CorePrereqs.h"
+
+#include <iostream>
+#include <string>
+#include <list>
+#include <map>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    enum _CoreExport ConfigFileType
+    {
+        CFT_Settings,
+        CFT_Keybindings,
+        CFT_JoyStickCalibration,
+        CFT_KeyNames
+    };
+
+
+    bool config(const std::string& classname, const std::string& varname, const std::string& value);
+    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value);
+    void reloadConfig();
+    void saveConfig();
+    void cleanConfig();
+    void loadSettings(const std::string& filename);
+    void loadKeybindings(const std::string& filename);
+
+
+    /////////////////////
+    // ConfigFileEntry //
+    /////////////////////
+    class _CoreExport ConfigFileEntry
+    {
+        public:
+            virtual ~ConfigFileEntry() {};
+            virtual void setValue(const std::string& value) = 0;
+            virtual std::string getValue() const = 0;
+            virtual const std::string& getName() const = 0;
+            virtual void setComment(const std::string& comment) = 0;
+            virtual unsigned int getIndex() const { return 0; }
+            virtual void setString(bool bString) = 0;
+            virtual std::string getFileEntry() const = 0;
+    };
+
+
+    //////////////////////////
+    // ConfigFileEntryValue //
+    //////////////////////////
+    class _CoreExport ConfigFileEntryValue : public ConfigFileEntry
+    {
+        public:
+            inline ConfigFileEntryValue(const std::string& name, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : name_(name), value_(value), bString_(bString), additionalComment_(additionalComment) {}
+            inline virtual ~ConfigFileEntryValue() {}
+
+            inline virtual const std::string& getName() const
+                { return this->name_; }
+
+            inline virtual void setComment(const std::string& comment)
+                { this->additionalComment_ = comment; }
+
+            virtual void setValue(const std::string& value);
+            virtual std::string getValue() const;
+
+            inline bool isString() const
+                { return this->bString_; }
+            inline void setString(bool bString)
+                { this->bString_ = bString; }
+
+            virtual std::string getFileEntry() const;
+
+        protected:
+            std::string name_;
+            std::string value_;
+            bool bString_;
+            std::string additionalComment_;
+    };
+
+
+    ///////////////////////////////
+    // ConfigFileEntryVectorValue //
+    ///////////////////////////////
+    class _CoreExport ConfigFileEntryVectorValue : public ConfigFileEntryValue
+    {
+        public:
+            inline ConfigFileEntryVectorValue(const std::string& name, unsigned int index, const std::string& value = "", bool bString = false, const std::string& additionalComment = "") : ConfigFileEntryValue(name, value, bString, additionalComment), index_(index) {}
+            inline virtual ~ConfigFileEntryVectorValue() {}
+
+            inline virtual unsigned int getIndex() const
+                { return this->index_; }
+
+            virtual std::string getFileEntry() const;
+
+        private:
+            unsigned int index_;
+    };
+
+
+    ////////////////////////////
+    // ConfigFileEntryComment //
+    ////////////////////////////
+    class _CoreExport ConfigFileEntryComment : public ConfigFileEntry
+    {
+        public:
+            inline ConfigFileEntryComment(const std::string& comment) : comment_(comment) {}
+            inline virtual ~ConfigFileEntryComment() {}
+
+            inline virtual const std::string& getName() const
+                { return this->comment_; }
+
+            inline virtual void setComment(const std::string& comment)
+                { this->comment_ = comment; }
+
+            inline virtual void setValue(const std::string& value)
+                {}
+            inline virtual std::string getValue() const
+                { return this->comment_; }
+
+            inline void setString(bool bString) {}
+
+            inline virtual std::string getFileEntry() const
+                { return this->comment_; }
+
+        private:
+            std::string comment_;
+    };
+
+
+    ///////////////////////
+    // ConfigFileSection //
+    ///////////////////////
+    class _CoreExport ConfigFileSection
+    {
+        friend class ConfigFile;
+
+        public:
+            inline ConfigFileSection(const std::string& name, const std::string& additionalComment = "") : name_(name), additionalComment_(additionalComment), bUpdated_(false) {}
+            ~ConfigFileSection();
+
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            inline void setComment(const std::string& comment)
+                { this->additionalComment_ = comment; }
+
+            inline void setValue(const std::string& name, const std::string& value, bool bString)
+                { this->getEntry(name, value, bString)->setValue(value); }
+            inline std::string getValue(const std::string& name, const std::string& fallback, bool bString)
+                { return this->getEntry(name, fallback, bString)->getValue(); }
+
+            inline void setValue(const std::string& name, unsigned int index, const std::string& value, bool bString)
+                { this->getEntry(name, index, value, bString)->setValue(value); }
+            inline std::string getValue(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return this->getEntry(name, index, fallback, bString)->getValue(); }
+
+            void deleteVectorEntries(const std::string& name, unsigned int startindex = 0);
+            unsigned int getVectorSize(const std::string& name);
+
+            std::string getFileEntry() const;
+
+        private:
+            std::list<ConfigFileEntry*>& getEntries()
+                { return this->entries_; }
+            std::list<ConfigFileEntry*>::const_iterator getEntriesBegin() const
+                { return this->entries_.begin(); }
+            std::list<ConfigFileEntry*>::const_iterator getEntriesEnd() const
+                { return this->entries_.end(); }
+
+            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, const std::string& fallback, bool bString);
+            std::list<ConfigFileEntry*>::iterator getEntryIterator(const std::string& name, unsigned int index, const std::string& fallback, bool bString);
+
+            inline ConfigFileEntry* getEntry(const std::string& name, const std::string& fallback, bool bString)
+                { return (*this->getEntryIterator(name, fallback, bString)); }
+            inline ConfigFileEntry* getEntry(const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return (*this->getEntryIterator(name, index, fallback, bString)); }
+
+            std::string name_;
+            std::string additionalComment_;
+            std::list<ConfigFileEntry*> entries_;
+            bool bUpdated_;
+    };
+
+
+    ////////////////
+    // ConfigFile //
+    ////////////////
+    class _CoreExport ConfigFile
+    {
+        public:
+            inline ConfigFile(const std::string& filename) : filename_(filename), bUpdated_(false) {}
+            ~ConfigFile();
+
+            void load(bool bCreateIfNotExisting = true);
+            void save() const;
+            void save(const std::string& filename);
+            void clean(bool bCleanComments = false);
+
+            inline void setValue(const std::string& section, const std::string& name, const std::string& value, bool bString)
+                { this->getSection(section)->setValue(name, value, bString); this->save(); }
+            inline std::string getValue(const std::string& section, const std::string& name, const std::string& fallback, bool bString)
+                { std::string output = this->getSection(section)->getValue(name, fallback, bString); this->saveIfUpdated(); return output; }
+
+            inline void setValue(const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
+                { this->getSection(section)->setValue(name, index, value, bString); this->save(); }
+            inline std::string getValue(const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { std::string output = this->getSection(section)->getValue(name, index, fallback, bString); this->saveIfUpdated(); return output; }
+
+            inline void deleteVectorEntries(const std::string& section, const std::string& name, unsigned int startindex = 0)
+                { this->getSection(section)->deleteVectorEntries(name, startindex); }
+            inline unsigned int getVectorSize(const std::string& section, const std::string& name)
+                { return this->getSection(section)->getVectorSize(name); }
+
+        private:
+            ConfigFileSection* getSection(const std::string& section);
+            void saveIfUpdated();
+
+            std::string filename_;
+            std::list<ConfigFileSection*> sections_;
+            bool bUpdated_;
+    };
+
+
+    ///////////////////////
+    // ConfigFileManager //
+    ///////////////////////
+    class _CoreExport ConfigFileManager
+    {
+        public:
+            static ConfigFileManager& getInstance();
+
+            void setFile(ConfigFileType type, const std::string& filename, bool bCreateIfNotExisting = true);
+
+            void load(bool bCreateIfNotExisting = true);
+            void save();
+            void clean(bool bCleanComments = false);
+
+            void load(ConfigFileType type, bool bCreateIfNotExisting = true);
+            void save(ConfigFileType type);
+            void save(ConfigFileType type, const std::string& filename);
+            void clean(ConfigFileType type, bool bCleanComments = false);
+
+            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& value, bool bString)
+                { this->getFile(type)->setValue(section, name, value, bString); }
+            inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, const std::string& fallback, bool bString)
+                { return this->getFile(type)->getValue(section, name, fallback, bString); }
+
+            inline void setValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& value, bool bString)
+                { this->getFile(type)->setValue(section, name, index, value, bString); }
+            inline std::string getValue(ConfigFileType type, const std::string& section, const std::string& name, unsigned int index, const std::string& fallback, bool bString)
+                { return this->getFile(type)->getValue(section, name, index, fallback, bString); }
+
+            inline void deleteVectorEntries(ConfigFileType type, const std::string& section, const std::string& name, unsigned int startindex = 0)
+                { this->getFile(type)->deleteVectorEntries(section, name, startindex); }
+            inline unsigned int getVectorSize(ConfigFileType type, const std::string& section, const std::string& name)
+                { return this->getFile(type)->getVectorSize(section, name); }
+
+            void updateConfigValues() const;
+            void updateConfigValues(ConfigFileType type) const;
+
+        private:
+            ConfigFileManager();
+            ConfigFileManager(const ConfigFileManager& other);
+            ~ConfigFileManager();
+
+            ConfigFile* getFile(ConfigFileType type);
+
+            std::string getFilePath(const std::string& name) const;
+
+            std::map<ConfigFileType, ConfigFile*> configFiles_;
+    };
+}
+
+#endif /* _ConfigFileManager_H__ */
Index: /code/branches/ceguilua/src/core/ConfigValueContainer.cc
===================================================================
--- /code/branches/ceguilua/src/core/ConfigValueContainer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConfigValueContainer.cc	(revision 1801)
@@ -0,0 +1,348 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ConfigValueContainer.cc
+    @brief Implementation of the ConfigValueContainer class.
+*/
+
+#include "ConfigValueContainer.h"
+
+#include <fstream>
+
+#include "util/SubString.h"
+#include "util/Convert.h"
+#include "Language.h"
+#include "Identifier.h"
+
+
+
+namespace orxonox
+{
+    const unsigned int MAX_VECTOR_INDEX  = 255; // to avoid up to 4*10^9 vector entries in the config file after accidentally using a wrong argument
+
+    /**
+        @brief Initializes the ConfigValueContainer with defaultvalues.
+    */
+    void ConfigValueContainer::init(ConfigFileType type, Identifier* identifier, const std::string& varname)
+    {
+        this->type_ = type;
+        this->identifier_ = identifier;
+        this->sectionname_ = identifier->getName();
+        this->varname_ = varname;
+        this->callback_ = 0;
+        this->bContainerIsNew_ = true;
+        this->bDoInitialCallback_ = false;
+        this->bAddedDescription_ = false;
+    }
+
+    /**
+        @brief Does some special initialization for single config-values.
+    */
+    void ConfigValueContainer::initValue(const MultiType& defvalue)
+    {
+        this->value_ = defvalue;
+        this->bIsVector_ = false;
+
+        this->defvalueString_ = this->value_.getString();
+        this->update();
+    }
+
+    /**
+        @brief Does some special initialization for vector config-values.
+    */
+    void ConfigValueContainer::initVector()
+    {
+        this->bIsVector_ = true;
+
+        for (unsigned int i = 0; i < this->valueVector_.size(); i++)
+        {
+            ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
+            this->defvalueStringVector_.push_back(this->valueVector_[i]);
+        }
+
+        this->update();
+    }
+
+    /**
+        @brief Destructor: Deletes the callback object if necessary.
+    */
+    ConfigValueContainer::~ConfigValueContainer()
+    {
+        if (this->callback_)
+            delete this->callback_;
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects and writes the change into the config-file.
+        @param input The new value
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::set(const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            return this->callFunctionWithIndex(&ConfigValueContainer::set, input);
+        }
+        else
+        {
+            if (this->tset(input))
+            {
+                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, input, this->value_.isType(MT_string));
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects and writes the change into the config-file.
+        @param index The index in the vector
+        @param input The new value
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::set(unsigned int index, const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            if (this->tset(index, input))
+            {
+                ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, index, input, this->value_.isType(MT_string));
+                return true;
+            }
+        }
+        else
+        {
+            COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+        }
+        return false;
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary).
+        @param input The new value. If bIsVector_ then write "index value"
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::tset(const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            return this->callFunctionWithIndex(&ConfigValueContainer::tset, input);
+            return false;
+        }
+        else
+        {
+            this->value_ = input;
+
+            if (this->identifier_)
+                this->identifier_->updateConfigValues();
+
+            return true;
+        }
+    }
+
+    /**
+        @brief Assigns a new value to the config-value of all objects, but doesn't change the config-file (t stands for temporary).
+        @param index The index in the vector
+        @param input The new value
+        @return True if the new value was successfully assigned
+    */
+    bool ConfigValueContainer::tset(unsigned int index, const MultiType& input)
+    {
+        if (this->bIsVector_)
+        {
+            if (index > MAX_VECTOR_INDEX)
+            {
+                COUT(1) << "Error: Index " << index << " is too large." << std::endl;
+                return false;
+            }
+
+            if (index >= this->valueVector_.size())
+            {
+                for (unsigned int i = this->valueVector_.size(); i <= index; i++)
+                {
+                    this->valueVector_.push_back(MultiType());
+                }
+            }
+
+            this->valueVector_[index] = input;
+
+            if (this->identifier_)
+                this->identifier_->updateConfigValues();
+
+            return true;
+        }
+        else
+        {
+            COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+            return false;
+        }
+    }
+
+    /**
+        @brief Adds a new entry to the end of the vector.
+        @param input The new entry
+        @return True if the new entry was successfully added
+    */
+    bool ConfigValueContainer::add(const MultiType& input)
+    {
+        if (this->bIsVector_)
+            return this->set(this->valueVector_.size(), input);
+
+        COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+        return false;
+    }
+
+    /**
+        @brief Removes an existing entry from the vector.
+        @param index The index of the entry
+        @return True if the entry was removed
+    */
+    bool ConfigValueContainer::remove(unsigned int index)
+    {
+        if (this->bIsVector_)
+        {
+            if (index < this->valueVector_.size())
+            {
+                // Erase the entry from the vector, change (shift) all entries beginning with index in the config file, remove the last entry from the file
+                this->valueVector_.erase(this->valueVector_.begin() + index);
+                for (unsigned int i = index; i < this->valueVector_.size(); i++)
+                    ConfigFileManager::getInstance().setValue(this->type_, this->sectionname_, this->varname_, i, this->valueVector_[i], this->value_.isType(MT_string));
+                ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->valueVector_.size());
+
+                return true;
+            }
+            COUT(1) << "Error: Invalid vector-index." << std::endl;
+        }
+
+        COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is not a vector." << std::endl;
+        return false;
+    }
+
+    /**
+        @brief Sets the value of the variable back to the default value and resets the config-file entry.
+    */
+    bool ConfigValueContainer::reset()
+    {
+        if (!this->bIsVector_)
+            return this->set(this->defvalueString_);
+        else
+        {
+            bool success = true;
+            for (unsigned int i = 0; i < this->defvalueStringVector_.size(); i++)
+                if (!this->set(i, this->defvalueStringVector_[i]))
+                    success = false;
+            ConfigFileManager::getInstance().deleteVectorEntries(this->type_, this->sectionname_, this->varname_, this->defvalueStringVector_.size());
+            return success;
+        }
+    }
+
+    /**
+        @brief Retrieves the configured value from the currently loaded config-file.
+    */
+    void ConfigValueContainer::update()
+    {
+        if (!this->bIsVector_)
+            this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, this->defvalueString_, this->value_.isType(MT_string));
+        else
+        {
+            this->valueVector_.clear();
+            for (unsigned int i = 0; i < ConfigFileManager::getInstance().getVectorSize(this->type_, this->sectionname_, this->varname_); i++)
+            {
+                if (i < this->defvalueStringVector_.size())
+                {
+                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, this->defvalueStringVector_[i], this->value_.isType(MT_string));
+                }
+                else
+                {
+                    this->value_ = ConfigFileManager::getInstance().getValue(this->type_, this->sectionname_, this->varname_, i, MultiType(), this->value_.isType(MT_string));
+                }
+
+                this->valueVector_.push_back(this->value_);
+            }
+        }
+    }
+
+    /**
+        @brief Calls the given function with parsed index and the parsed argument from the input string.
+        @param function The function to call
+        @param input The input string
+        @return The returnvalue of the functioncall
+    */
+    bool ConfigValueContainer::callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input)
+    {
+        SubString token(input, " ", SubString::WhiteSpaces, true, '\\', false, '"', false, '(', ')', false, '\0');
+        int index = -1;
+        bool success = false;
+
+        if (token.size() > 0)
+            success = ConvertValue(&index, token[0]);
+
+        if (!success || index < 0 || index > (signed int)MAX_VECTOR_INDEX)
+        {
+            if (!success)
+            {
+                COUT(1) << "Error: Config-value '" << this->varname_ << "' in " << this->sectionname_ << " is a vector." << std::endl;
+            }
+            else
+            {
+                COUT(1) << "Error: Invalid vector-index." << std::endl;
+            }
+            return false;
+        }
+
+        if (token.size() >= 2)
+            return (this->*function)(index, token.subSet(1).join());
+        else
+            return (this->*function)(index, "");
+    }
+
+    /**
+        @brief Adds a description to the config-value.
+        @param description The description
+    */
+    ConfigValueContainer& ConfigValueContainer::description(const std::string& description)
+    {
+        if (!this->bAddedDescription_)
+        {
+            this->description_ = std::string("ConfigValueDescription::" + this->identifier_->getName() + "::" + this->varname_);
+            AddLanguageEntry(this->description_, description);
+            this->bAddedDescription_ = true;
+        }
+        return (*this);
+    }
+
+    /**
+        @brief Returns the description of the config-value.
+        @return The description
+    */
+    const std::string& ConfigValueContainer::getDescription() const
+    {
+        return GetLocalisation(this->description_);
+    }
+}
Index: /code/branches/ceguilua/src/core/ConfigValueContainer.h
===================================================================
--- /code/branches/ceguilua/src/core/ConfigValueContainer.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConfigValueContainer.h	(revision 1801)
@@ -0,0 +1,294 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ConfigValueContainer.h
+    @brief Definition of the ConfigValueContainer class.
+
+    The ConfigValueContainer class contains all needed informations about a configurable variable:
+     - the name of the variable
+     - the name of the class the variable belongs to
+     - the default value
+     - the user-specified value
+     - a pointer to the entry in the config-file
+
+    This is needed to assign the configured values to all newly created objects.
+*/
+
+#ifndef _ConfigValueContainer_H__
+#define _ConfigValueContainer_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+#include <vector>
+
+#include "util/Math.h"
+#include "util/MultiType.h"
+#include "ConfigFileManager.h"
+
+namespace orxonox
+{
+    class ConfigValueCallbackBase
+    {
+        public:
+            virtual void call(void* object) = 0;
+            inline virtual ~ConfigValueCallbackBase() {}
+    };
+
+    template <class T>
+    class ConfigValueCallback: public ConfigValueCallbackBase
+    {
+        public:
+            inline ConfigValueCallback(void (T::*function) (void)) : function_(function) {}
+            inline virtual ~ConfigValueCallback() {}
+            inline virtual void call(void* object)
+                { (((T*)object)->*this->function_)(); }
+
+        private:
+            void (T::*function_) (void);
+    };
+
+
+    //! The ConfigValuecontainer contains all needed informations about a configurable variable.
+    /**
+        The ConfigValueContainer class contains all needed informations about a configurable variable:
+         - the name of the variable
+         - the name of the class the variable belongs to
+         - the default value
+         - the user-specified value
+         - a pointer to the entry in the config-file
+
+        This is needed to assign the configured values to all newly created objects.
+
+        The container searches for the entry in the config file.
+        If there is an entry, it parses the specified value and assigns it to the variable of the right type.
+        If there is no entry, it adds the entry with the default-value to the section of the variables class.
+        If there is no section, the section and the entry are added to the end of the config-file.
+    */
+    class _CoreExport ConfigValueContainer
+    {
+        public:
+            /**
+                @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
+                @param type The type of the corresponding config-file
+                @param identifier The identifier of the class the variable belongs to
+                @param varname The name of the variable
+                @param defvalue The default-value
+                @param value Only needed do determine the right type.
+            */
+            template <class D, class V>
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const D& defvalue, const V& value)
+            {
+                this->init(type, identifier, varname);
+                this->initValue((V)defvalue);
+            }
+
+            /**
+                @brief Constructor: Converts the default-value to a string, checks the config-file for a changed value, sets the intern value variable.
+                @param type The type of the corresponding config-file
+                @param identifier The identifier of the class the variable belongs to
+                @param varname The name of the variable
+                @param defvalue The default-value
+            */
+            template <class V>
+            ConfigValueContainer(ConfigFileType type, Identifier* identifier, const std::string& varname, const std::vector<V>& defvalue)
+            {
+                this->init(type, identifier, varname);
+
+                this->value_ = V();
+                for (unsigned int i = 0; i < defvalue.size(); i++)
+                    this->valueVector_.push_back(MultiType(defvalue[i]));
+
+                this->initVector();
+            }
+
+            ~ConfigValueContainer();
+
+            /**
+                @brief Returns the configured value.
+                @param value A pointer to the variable to store the value.
+                @param object The object calling this function
+                @return The ConfigValueContainer
+            */
+            template <typename T, class C>
+            ConfigValueContainer& getValue(T* value, C* object)
+            {
+                if ((this->callback_ && object) || this->bContainerIsNew_)
+                {
+                    if (this->bContainerIsNew_)
+                        this->bContainerIsNew_ = false;
+
+                    T temp = *value;
+                    this->value_.getValue(value);
+                    if ((*value) != temp)
+                    {
+                        if (this->callback_ && object)
+                            this->callback_->call(object);
+                        else
+                            this->bDoInitialCallback_ = true;
+                    }
+                }
+                else
+                {
+                    this->value_.getValue(value);
+                }
+                return *this;
+            }
+
+            /**
+                @brief Returns the configured vector.
+                @param value A pointer to the vector to store the values.
+                @param object The object calling this function
+                @return The ConfigValueContainer
+            */
+            template <typename T, class C>
+            ConfigValueContainer& getValue(std::vector<T>* value, C* object)
+            {
+                if ((this->callback_ && object) || this->bContainerIsNew_)
+                {
+                    if (this->bContainerIsNew_)
+                        this->bContainerIsNew_ = false;
+
+                    std::vector<T> temp = *value;
+                    value->clear();
+                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
+                        value->push_back(this->valueVector_[i]);
+
+                    if (value->size() != temp.size())
+                    {
+                        if (this->callback_ && object)
+                            this->callback_->call(object);
+                        else
+                            this->bDoInitialCallback_ = true;
+                    }
+                    else
+                    {
+                        for (unsigned int i = 0; i < value->size(); ++i)
+                        {
+                            if ((*value)[i] != temp[i])
+                            {
+                                if (this->callback_ && object)
+                                    this->callback_->call(object);
+                                else
+                                    this->bDoInitialCallback_ = true;
+                                break;
+                            }
+                        }
+                    }
+                }
+                else
+                {
+                    value->clear();
+                    for (unsigned int i = 0; i < this->valueVector_.size(); ++i)
+                        value->push_back(this->valueVector_[i]);
+                }
+                return *this;
+            }
+
+            /** @brief Returns the name of this container. */
+            inline const std::string& getName() const
+                { return this->varname_; }
+            /** @brief Returns true if this config-value is a vector */
+            inline bool isVector() const
+                { return this->bIsVector_; }
+            /** @brief Returns the vectors size (or zero if it's not a vector). */
+            inline unsigned int getVectorSize() const
+                { return this->valueVector_.size(); }
+
+            ConfigValueContainer& description(const std::string& description);
+            const std::string& getDescription() const;
+
+            /**
+                @brief Adds a callback function, that gets called after getValue() if the newly assigned value differs from the old value of the variable.
+                @param object The object to call the function
+                @param function The callback function
+            */
+            template <class T>
+            inline ConfigValueContainer& callback(T* object, void (T::*function) (void))
+            {
+                if (!this->callback_)
+                {
+                    this->callback_ = new ConfigValueCallback<T>(function);
+
+                    if (this->bDoInitialCallback_)
+                    {
+                        this->bDoInitialCallback_ = false;
+                        this->callback_->call(object);
+                    }
+                }
+
+                return (*this);
+            }
+
+            bool set(const MultiType& input);
+            bool tset(const MultiType& input);
+
+            bool set(unsigned int index, const MultiType& input);
+            bool tset(unsigned int index, const MultiType& input);
+            bool add(const MultiType& input);
+            bool remove(unsigned int index);
+
+            bool reset();
+            void update();
+
+            /** @brief Converts the config-value to a string. @return The string */
+            inline std::string toString() const
+                { return this->value_; }
+            /** @brief Returns the typename of the assigned config-value. @return The typename */
+            inline std::string getTypename() const
+                { return this->value_.getTypename(); }
+
+        private:
+            void init(ConfigFileType type, Identifier* identifier, const std::string& varname);
+            void initValue(const MultiType& defvalue);
+            void initVector();
+            bool callFunctionWithIndex(bool (ConfigValueContainer::* function) (unsigned int, const MultiType&), const std::string& input);
+
+            bool                       bIsVector_;                  //!< True if the container contains a std::vector
+
+            ConfigFileType             type_;                       //!< The type of the corresponding config-file
+            Identifier*                identifier_;                 //!< The identifier of the class
+            std::string                sectionname_;                //!< The name of the class the variable belongs to
+            std::string                varname_;                    //!< The name of the variable
+            std::string                defvalueString_;             //!< The string of the default-value
+            std::vector<std::string>   defvalueStringVector_;       //!< A vector, containg the strings of the default-values in case we're storing a vector
+
+            MultiType                  value_;                      //!< The value
+            std::vector<MultiType>     valueVector_;                //!< A vector, containg the values in case we're storing a vector
+
+            bool                       bAddedDescription_;          //!< True if a description was added
+            LanguageEntryLabel         description_;                //!< The description
+            ConfigValueCallbackBase*   callback_;                   //!< A callback function to call after getValue if the value changed
+
+            bool                       bContainerIsNew_;            //!< True if it's the first time getValue() gets called
+            bool                       bDoInitialCallback_;         //!< True if the callback should be called as soon as it gets created
+    };
+}
+
+#endif /* _ConfigValueContainer_H__ */
Index: /code/branches/ceguilua/src/core/ConfigValueIncludes.h
===================================================================
--- /code/branches/ceguilua/src/core/ConfigValueIncludes.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConfigValueIncludes.h	(revision 1801)
@@ -0,0 +1,116 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ConfigValueIncludes.h
+    @brief Definition of macros for config-values.
+*/
+
+#ifndef _ConfigValueIncludes_H__
+#define _ConfigValueIncludes_H__
+
+#include "CorePrereqs.h"
+
+#include "Identifier.h"
+#include "ConfigValueContainer.h"
+#include "ConfigFileManager.h"
+
+
+/**
+    @brief Assigns the value, defined in the config-file, to the variable (or the default-value, if there is no entry in the file).
+    @param varname The name of the variable
+    @param defvalue The default-value of the variable
+*/
+#define SetConfigValueGeneric(type, varname, defvalue) \
+    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
+    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue, varname); \
+        identifier##varname->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname, this)
+
+#define SetConfigValue(varname, defvalue) SetConfigValueGeneric(CFT_Settings, varname, defvalue)
+#define SetKeybindingValue(varname, defvalue) SetConfigValueGeneric(CFT_Keybindings, varname, defvalue)
+
+
+/**
+    @brief Assigns the vector-values, defined in the config-file, to the vector (or the default-value, if there are no entries in the file).
+    @param varname The name of the std::vector
+    @param defvalue The default-value
+*/
+#define SetConfigValueVectorGeneric(type, varname, defvalue) \
+    static orxonox::Identifier* identifier##varname = this->getIdentifier(); \
+    orxonox::ConfigValueContainer* container##varname = identifier##varname->getConfigValueContainer(#varname); \
+    if (!container##varname) \
+    { \
+        container##varname = new orxonox::ConfigValueContainer(CFT_Settings, identifier##varname, #varname, defvalue); \
+        identifier##varname->addConfigValueContainer(#varname, container##varname); \
+    } \
+    container##varname->getValue(&varname, this)
+
+#define SetConfigValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Settings, varname, defvalue)
+#define SetKeybindingValueVector(varname, defvalue) SetConfigValueVectorGeneric(CFT_Keybindings, varname, defvalue)
+
+
+/**
+    @brief Sets the variable and the config-file entry back to the previously defined default-value.
+    @param varname The name of the variable
+*/
+#define ResetConfigValue(varname) \
+    orxonox::ConfigValueContainer* container##varname##reset = this->getIdentifier()->getConfigValueContainer(#varname); \
+    if (container##varname##reset) \
+    { \
+        container##varname##reset->reset(); \
+        container##varname##reset->getValue(&varname, this); \
+    } \
+    else \
+    { \
+        COUT(2) << "Warning: Couldn't reset config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+    }
+
+
+/**
+    @brief Modifies a config-value by using a modifier and some arguments.
+    @param varname The name of the config-value
+    @param modifier The name of the modifier: set, tset, add, remove, reset, update
+*/
+#define ModifyConfigValue(varname, modifier, ...) \
+    orxonox::ConfigValueContainer* container##varname##modify##modifier = this->getIdentifier()->getConfigValueContainer(#varname); \
+    if (container##varname##modify##modifier) \
+    { \
+        container##varname##modify##modifier->modifier(__VA_ARGS__); \
+        container##varname##modify##modifier->getValue(&varname, this); \
+    } \
+    else \
+    { \
+        COUT(2) << "Warning: Couln't modify config-value '" << #varname << "', corresponding container doesn't exist." << std::endl; \
+    }
+
+#endif /* _ConfigValueIncludes_H__ */
Index: /code/branches/ceguilua/src/core/ConsoleCommand.cc
===================================================================
--- /code/branches/ceguilua/src/core/ConsoleCommand.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConsoleCommand.cc	(revision 1801)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommand.h"
+
+namespace orxonox
+{
+    ConsoleCommand::ConsoleCommand(Functor* functor, const std::string& name) : Executor(functor, name)
+    {
+        this->accessLevel_ = AccessLevel::None;
+        this->argumentCompleter_[0] = 0;
+        this->argumentCompleter_[1] = 0;
+        this->argumentCompleter_[2] = 0;
+        this->argumentCompleter_[3] = 0;
+        this->argumentCompleter_[4] = 0;
+
+        this->keybindMode_ = KeybindMode::OnPress;
+        this->axisParamIndex_ = -1;
+        this->bAxisRelative_ = false;
+    }
+
+    ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer)
+    {
+        if (param < 5)
+            this->argumentCompleter_[param] = completer;
+        else
+        {
+            COUT(2) << "Warning: Couldn't add autocompletion-function for param " << param << ": index out of bound." << std::endl;
+        }
+        return (*this);
+    }
+
+    ArgumentCompleter* ConsoleCommand::getArgumentCompleter(unsigned int param) const
+    {
+        if (param < 5)
+            return this->argumentCompleter_[param];
+        else
+            return 0;
+    }
+
+    void ConsoleCommand::createArgumentCompletionList(unsigned int param, const std::string& param1, const std::string& param2, const std::string& param3, const std::string& param4, const std::string& param5)
+    {
+        if (param < 5 && this->argumentCompleter_[param])
+            this->argumentList_ = (*this->argumentCompleter_[param])(param1, param2, param3, param4, param5);
+        else
+            this->argumentList_.clear();
+    }
+}
Index: /code/branches/ceguilua/src/core/ConsoleCommand.h
===================================================================
--- /code/branches/ceguilua/src/core/ConsoleCommand.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConsoleCommand.h	(revision 1801)
@@ -0,0 +1,155 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ConsoleCommand_H__
+#define _ConsoleCommand_H__
+
+#include "CorePrereqs.h"
+
+#include "Executor.h"
+#include "Identifier.h"
+#include "CommandExecutor.h"
+#include "ArgumentCompletionFunctions.h"
+
+
+#define SetConsoleCommand(classname, function, bCreateShortcut) \
+    SetConsoleCommandAliasMulti(classname, function, #function, 0, bCreateShortcut)
+#define SetConsoleCommandAlias(classname, function, name, bCreateShortcut) \
+    SetConsoleCommandAliasMulti(classname, function, name, 0, bCreateShortcut)
+#define SetConsoleCommandAliasMulti(classname, function, name, number, bCreateShortcut) \
+    SetConsoleCommandGeneric(classname##function##consolecommand__##number, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name), bCreateShortcut)
+
+#define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \
+    orxonox::ConsoleCommand& fakevariable = orxonox::ClassIdentifier<classname>::getIdentifier(#classname)->addConsoleCommand(command, bCreateShortcut)
+
+
+#define SetConsoleCommandShortcut(classname, function) \
+    SetConsoleCommandShortcutAliasMulti(classname, function, #function, 0)
+#define SetConsoleCommandShortcutAlias(classname, function, name) \
+    SetConsoleCommandShortcutAliasMulti(classname, function, name, 0)
+#define SetConsoleCommandShortcutAliasMulti(classname, function, name, number) \
+    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name))
+
+#define SetConsoleCommandShortcutExtern(function) \
+    SetConsoleCommandShortcutExternAliasMulti(function, #function, 0)
+#define SetConsoleCommandShortcutExternAlias(function, name) \
+    SetConsoleCommandShortcutExternAliasMulti(function, name, 0)
+#define SetConsoleCommandShortcutExternAliasMulti(function, name, number) \
+    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&function), name))
+
+#define SetConsoleCommandShortcutGeneric(fakevariable, command) \
+    orxonox::ConsoleCommand& fakevariable = orxonox::CommandExecutor::addConsoleCommandShortcut(command)
+
+
+namespace orxonox
+{
+    namespace AccessLevel
+    {
+        enum Level
+        {
+            None,
+            User,
+            Admin,
+            Offline,
+            Debug,
+            Disabled
+        };
+    }
+
+    class _CoreExport ConsoleCommand : public Executor
+    {
+        public:
+            ConsoleCommand(Functor* functor, const std::string& name = "");
+
+            inline ConsoleCommand& description(const std::string& description)
+                { this->Executor::setDescription(description); return (*this); }
+            inline ConsoleCommand& descriptionParam(int param, const std::string& description)
+                { this->Executor::setDescriptionParam(param, description); return (*this); }
+            inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
+                { this->Executor::setDescriptionReturnvalue(description); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1)
+                { this->Executor::setDefaultValues(param1); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2)
+                { this->Executor::setDefaultValues(param1, param2); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+                { this->Executor::setDefaultValues(param1, param2, param3); return (*this); }
+            inline ConsoleCommand& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+                { 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->Executor::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
+            inline ConsoleCommand& defaultValue(unsigned int index, const MultiType& param)
+                { this->Executor::setDefaultValue(index, param); return (*this); }
+
+            inline ConsoleCommand& accessLevel(AccessLevel::Level level)
+                { this->accessLevel_ = level; return (*this); }
+            inline AccessLevel::Level getAccessLevel() const
+                { return this->accessLevel_; }
+
+            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
+            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
+
+            void createArgumentCompletionList(unsigned int param, const std::string& param1 = "", const std::string& param2 = "", const std::string& param3 = "", const std::string& param4 = "", const std::string& param5 = "");
+            const ArgumentCompletionList& getArgumentCompletionList() const
+                { return this->argumentList_; }
+            ArgumentCompletionList::const_iterator getArgumentCompletionListBegin() const
+                { return this->argumentList_.begin(); }
+            ArgumentCompletionList::const_iterator getArgumentCompletionListEnd() const
+                { return this->argumentList_.end(); }
+
+            inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
+                { this->keybindMode_ = mode; return *this; }
+            inline KeybindMode::Enum getKeybindMode() const
+                { return this->keybindMode_; }
+
+            inline ConsoleCommand& axisParamIndex(int index)
+                { this->axisParamIndex_ = index; return *this; }
+            inline int getAxisParamIndex() const
+                { return this->axisParamIndex_; }
+
+            inline ConsoleCommand& isAxisRelative(bool val)
+                { this->bAxisRelative_ = val; return *this; }
+            inline int getIsAxisRelative() const
+                { return this->bAxisRelative_; }
+
+        private:
+            AccessLevel::Level accessLevel_;
+            ArgumentCompleter* argumentCompleter_[5];
+            ArgumentCompletionList argumentList_;
+
+            KeybindMode::Enum keybindMode_;
+            int axisParamIndex_;
+            bool bAxisRelative_;
+    };
+
+    inline ConsoleCommand* createConsoleCommand(Functor* functor, const std::string& name = "")
+    {
+        return new ConsoleCommand(functor, name);
+    }
+}
+
+#endif /* _ConsoleCommand_H__ */
Index: /code/branches/ceguilua/src/core/ConsoleCommandCompilation.cc
===================================================================
--- /code/branches/ceguilua/src/core/ConsoleCommandCompilation.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConsoleCommandCompilation.cc	(revision 1801)
@@ -0,0 +1,175 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "ConsoleCommandCompilation.h"
+#include "ConsoleCommand.h"
+#include "util/Debug.h"
+#include "util/ExprParser.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(echo);
+    SetConsoleCommandShortcutExtern(puts);
+
+    SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());
+    SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());
+
+    SetConsoleCommandShortcutExtern(calculate);
+
+    void source(const std::string& filename)
+    {
+        static std::set<std::string> executingFiles;
+
+        std::set<std::string>::const_iterator it = executingFiles.find(filename);
+        if (it != executingFiles.end())
+        {
+            COUT(1) << "Error: Recurring source command in \"" << filename << "\". Stopped execution." << std::endl;
+            return;
+        }
+
+        // Open the file
+        std::ifstream file;
+        file.open(filename.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't open file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        executingFiles.insert(filename);
+
+        // Iterate through the file and put the lines into the CommandExecutor
+        char line[1024];
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            CommandExecutor::execute(line);
+        }
+
+        executingFiles.erase(filename);
+        file.close();
+    }
+
+    std::string echo(const std::string& text)
+    {
+        std::cout << text << std::endl;
+        return text;
+    }
+
+    void puts(bool newline, const std::string& text)
+    {
+        if (newline)
+        {
+            COUT(0) << text << std::endl;
+        }
+        else
+        {
+            COUT(0) << text;
+        }
+    }
+
+    void write(const std::string& filename, const std::string& text)
+    {
+        std::ofstream file;
+        file.open(filename.c_str(), std::fstream::out);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't write to file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        file << text << std::endl;
+        file.close();
+    }
+
+    void append(const std::string& filename, const std::string& text)
+    {
+        std::ofstream file;
+        file.open(filename.c_str(), std::fstream::app);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't append to file \"" << filename << "\"." << std::endl;
+            return;
+        }
+
+        file << text << std::endl;
+        file.close();
+    }
+
+    std::string read(const std::string& filename)
+    {
+        std::ifstream file;
+        file.open(filename.c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "Error: Couldn't read from file \"" << filename << "\"." << std::endl;
+            return "";
+        }
+
+        std::string output = "";
+        char line[1024];
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            output += line;
+            output += "\n";
+        }
+
+        file.close();
+
+        return output;
+    }
+
+    float calculate(const std::string& calculation)
+    {
+        ExprParser expr(calculation);
+        if (expr.getSuccess())
+        {
+            if (expr.getResult() == 42.0)
+            {
+                COUT(3) << "Greetings from the restaurant at the end of the universe." << std::endl;
+            }
+            if (expr.getRemains() != "")
+            {
+                COUT(2) << "Warning: Expression could not be parsed to the end! Remains: '" << expr.getRemains() << "'" << std::endl;
+            }
+            return expr.getResult();
+        }
+        else
+        {
+            COUT(1) << "Error: Cannot calculate expression: Parse error." << std::endl;
+            return 0;
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/ConsoleCommandCompilation.h
===================================================================
--- /code/branches/ceguilua/src/core/ConsoleCommandCompilation.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ConsoleCommandCompilation.h	(revision 1801)
@@ -0,0 +1,49 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ConsoleCommandCompilation_H__
+#define _ConsoleCommandCompilation_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+namespace orxonox
+{
+    _CoreExport void source(const std::string& filename);
+    _CoreExport std::string echo(const std::string& text);
+    _CoreExport void puts(bool newline, const std::string& test);
+
+    _CoreExport void write(const std::string& filename, const std::string& text);
+    _CoreExport void append(const std::string& filename, const std::string& text);
+    _CoreExport std::string read(const std::string& filename);
+
+    _CoreExport float calculate(const std::string& calculation);
+}
+
+#endif /* _ConsoleCommandCompilation_H__ */
Index: /code/branches/ceguilua/src/core/Core.cc
===================================================================
--- /code/branches/ceguilua/src/core/Core.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Core.cc	(revision 1801)
@@ -0,0 +1,218 @@
+/*
+ *   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.cc
+    @brief Implementation of the Core class.
+*/
+
+#include "Core.h"
+#include <cassert>
+#include "Language.h"
+#include "CoreIncludes.h"
+#include "ConfigValueIncludes.h"
+//#include "input/InputManager.h"
+//#include "TclThreadManager.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Registers the object and sets the config-values.
+        @param A reference to a global variable, used to avoid an infinite recursion in getSoftDebugLevel()
+    */
+    Core::Core()
+    {
+        RegisterRootObject(Core);
+        this->setConfigValues();
+        isCreatingCoreSettings() = false;
+    }
+
+    /**
+        @brief Sets the bool to true to avoid static functions accessing a deleted object.
+    */
+    Core::~Core()
+    {
+        isCreatingCoreSettings() = true;
+    }
+
+    /**
+        @brief Returns true if the Core instance is not yet ready and the static functions have to return a default value.
+    */
+    bool& Core::isCreatingCoreSettings()
+    {
+        static bool bCreatingCoreSettings = true;
+        return bCreatingCoreSettings;
+    }
+
+    /**
+        @brief Returns a unique instance of Core.
+        @return The instance
+    */
+    Core& Core::getInstance()
+    {
+        // If bCreatingSoftDebugLevelObject is true, we're just about to create an instance of the DebugLevel class
+        //if (Core::isCreatingCoreSettings())
+        //{
+        //    isCreatingCoreSettings() = false;
+        //    //instance.setConfigValues();
+        //}
+
+        static bool firstTime = true;
+        if (firstTime)
+            isCreatingCoreSettings() = true;
+
+        static Core instance;
+        return instance;
+    }
+
+    /**
+        @brief Function to collect the SetConfigValue-macro calls.
+    */
+    void Core::setConfigValues()
+    {
+        SetConfigValue(softDebugLevelConsole_, 3).description("The maximal level of debug output shown in the console").callback(this, &Core::debugLevelChanged);
+        SetConfigValue(softDebugLevelLogfile_, 3).description("The maximal level of debug output shown in the logfile").callback(this, &Core::debugLevelChanged);
+        SetConfigValue(softDebugLevelShell_, 1).description("The maximal level of debug output shown in the ingame shell").callback(this, &Core::debugLevelChanged);
+        SetConfigValue(language_, Language::getLanguage().defaultLanguage_).description("The language of the ingame text").callback(this, &Core::languageChanged);
+    }
+
+    /**
+        @brief Callback function if the debug level has changed.
+    */
+    void Core::debugLevelChanged()
+    {
+        // softDebugLevel_ is the maximum of the 3 variables
+        this->softDebugLevel_ = this->softDebugLevelConsole_;
+        if (this->softDebugLevelLogfile_ > this->softDebugLevel_)
+            this->softDebugLevel_ = this->softDebugLevelLogfile_;
+        if (this->softDebugLevelShell_ > this->softDebugLevel_)
+            this->softDebugLevel_ = this->softDebugLevelShell_;
+
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_All,     this->softDebugLevel_);
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Console, this->softDebugLevelConsole_);
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Logfile, this->softDebugLevelLogfile_);
+        OutputHandler::setSoftDebugLevel(OutputHandler::LD_Shell,   this->softDebugLevelShell_);
+    }
+
+    /**
+        @brief Callback function if the language has changed.
+    */
+    void Core::languageChanged()
+    {
+        // Read the translation file after the language was configured
+        Language::getLanguage().readTranslatedLanguageFile();
+    }
+
+    /**
+        @brief Returns the softDebugLevel for the given device (returns a default-value if the class ist right about to be created).
+        @param device The device
+        @return The softDebugLevel
+    */
+    int Core::getSoftDebugLevel(OutputHandler::OutputDevice device)
+    {
+        if (!Core::isCreatingCoreSettings())
+        {
+            switch (device)
+            {
+            case OutputHandler::LD_All:
+                return Core::getInstance().softDebugLevel_;
+            case OutputHandler::LD_Console:
+                return Core::getInstance().softDebugLevelConsole_;
+            case OutputHandler::LD_Logfile:
+                return Core::getInstance().softDebugLevelLogfile_;
+            case OutputHandler::LD_Shell:
+                return Core::getInstance().softDebugLevelShell_;
+            default:
+                assert(0);
+            }
+        }
+
+        // Return a constant value while we're creating the object
+        return 2;
+    }
+
+     /**
+        @brief Sets the softDebugLevel for the given device. Please use this only temporary and restore the value afterwards, as it overrides the configured value.
+        @param device The device
+        @param level The level
+    */
+     void Core::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
+     {
+        if (!Core::isCreatingCoreSettings())
+        {
+            if (device == OutputHandler::LD_All)
+                Core::getInstance().softDebugLevel_ = level;
+            else if (device == OutputHandler::LD_Console)
+                Core::getInstance().softDebugLevelConsole_ = level;
+            else if (device == OutputHandler::LD_Logfile)
+                Core::getInstance().softDebugLevelLogfile_ = level;
+            else if (device == OutputHandler::LD_Shell)
+                Core::getInstance().softDebugLevelShell_ = level;
+
+            OutputHandler::setSoftDebugLevel(device, level);
+        }
+     }
+
+    /**
+        @brief Returns the configured language.
+    */
+    const std::string& Core::getLanguage()
+    {
+        if (!Core::isCreatingCoreSettings())
+            return Core::getInstance().language_;
+
+        return Language::getLanguage().defaultLanguage_;
+    }
+
+    /**
+        @brief Sets the language in the config-file back to the default.
+    */
+    void Core::resetLanguage()
+    {
+        Core::getInstance().resetLanguageIntern();
+    }
+
+    /**
+        @brief Sets the language in the config-file back to the default.
+    */
+    void Core::resetLanguageIntern()
+    {
+        ResetConfigValue(language_);
+    }
+
+    ///**
+    //    @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/branches/ceguilua/src/core/Core.h
===================================================================
--- /code/branches/ceguilua/src/core/Core.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Core.h	(revision 1801)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   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 _Core_H__
+#define _Core_H__
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "util/OutputHandler.h"
+
+namespace orxonox
+{
+    //! The Core class is a singleton, only used to configure some config-values.
+    class _CoreExport Core : public OrxonoxClass
+    {
+        public:
+            static Core& getInstance();
+            static bool& isCreatingCoreSettings();
+            void setConfigValues();
+            void debugLevelChanged();
+            void languageChanged();
+
+            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
+            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
+            static const std::string& getLanguage();
+            static void resetLanguage();
+
+            //static void tick(float dt);
+
+        private:
+            void resetLanguageIntern();
+
+            Core();
+            Core(const Core& other);
+            virtual ~Core();
+
+            int softDebugLevel_;                            //!< The debug level
+            int softDebugLevelConsole_;                     //!< The debug level for the console
+            int softDebugLevelLogfile_;                     //!< The debug level for the logfile
+            int softDebugLevelShell_;                       //!< The debug level for the ingame shell
+            std::string language_;                          //!< The language
+    };
+}
+
+#endif /* _Core_H__ */
Index: /code/branches/ceguilua/src/core/CoreIncludes.h
===================================================================
--- /code/branches/ceguilua/src/core/CoreIncludes.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/CoreIncludes.h	(revision 1801)
@@ -0,0 +1,116 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file CoreIncludes.h
+    @brief Definition of macros for Identifier and Factory.
+
+    Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface
+    or the BaseObject itself, it needs the macro RegisterRootObject(class) instead.
+
+    To allow the object being created through the factory, use the CreateFactory(class) macro outside
+    the of the class implementation, so it gets executed before main().
+*/
+
+#ifndef _CoreIncludes_H__
+#define _CoreIncludes_H__
+
+#include "CorePrereqs.h"
+
+#include "Identifier.h"
+#include "Factory.h"
+#include "ClassFactory.h"
+#include "util/Debug.h"
+
+
+/**
+    @brief Intern macro, containing the common parts of RegisterObject and RegisterRootObject.
+    @param ClassName The name of the class
+    @param bRootClass True if the class is directly derived from OrxonoxClass
+*/
+#define InternRegisterObject(ClassName, bRootClass) \
+    this->setIdentifier(orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)); \
+    if (orxonox::Identifier::isCreatingHierarchy()) \
+    { \
+        if (this->getParents()) \
+        { \
+            orxonox::ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeClassHierarchy(this->getParents(), bRootClass); \
+            this->getParents()->insert(this->getParents()->end(), this->getIdentifier()); \
+        } \
+        this->setConfigValues(); \
+        return; \
+    } \
+    orxonox::ClassIdentifier<ClassName>::getIdentifier()->addObject(this)
+
+/**
+    @brief Intern macro, containing the specific part of RegisterRootObject.
+    @param ClassName The name of the class
+*/
+#define InternRegisterRootObject(ClassName) \
+    if (orxonox::Identifier::isCreatingHierarchy() && !this->getParents()) \
+        this->createParents(); \
+    InternRegisterObject(ClassName, true)
+
+/**
+    @brief RegisterObject - with and without debug output.
+    @param ClassName The name of the class
+*/
+#define RegisterObject(ClassName) \
+    COUT(5) << "*** Register Object: " << #ClassName << std::endl; \
+    InternRegisterObject(ClassName, false)
+
+/**
+    @brief RegisterRootObject - with and without debug output.
+    @param ClassName The name of the class
+*/
+#define RegisterRootObject(ClassName) \
+    COUT(5) << "*** Register Root-Object: " << #ClassName << std::endl; \
+    InternRegisterRootObject(ClassName)
+
+/**
+    @brief Returns the Identifier of the given class.
+    @param ClassName The name of the class
+*/
+#define Class(ClassName) \
+    ClassIdentifier<ClassName>::getIdentifier()
+
+/**
+    @brief Creates the entry in the Factory.
+    @param ClassName The name of the class
+*/
+#define CreateFactory(ClassName) \
+    bool bCreated##ClassName##Factory = orxonox::ClassFactory<ClassName>::create(#ClassName)
+
+/**
+    @brief Returns the Identifier with either a given name or a given network ID through the factory.
+    @param StringOrInt The name or the network ID of the class
+*/
+#define GetIdentifier(StringOrInt) \
+    orxonox::Factory::getIdentifier(StringOrInt)
+
+#endif /* _CoreIncludes_H__ */
Index: /code/branches/ceguilua/src/core/CorePrereqs.h
===================================================================
--- /code/branches/ceguilua/src/core/CorePrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/CorePrereqs.h	(revision 1801)
@@ -0,0 +1,189 @@
+/*
+ *   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 Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _CorePrereqs_H__
+#define _CorePrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+#include <string>
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( CORE_STATIC_BUILD )
+#  ifdef CORE_SHARED_BUILD
+#    define _CoreExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _CoreExport
+#    else
+#      define _CoreExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _CoreExport  __attribute__ ((visibility("default")))
+#else
+#  define _CoreExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace orxonox
+{
+  namespace XMLPort
+  {
+    enum Mode
+    {
+      LoadObject,
+      SaveObject
+    };
+  }
+
+  namespace KeybindMode
+  {
+    enum Enum
+    {
+      OnPress,
+      OnHold,
+      OnRelease,
+      None
+    };
+  };
+
+  typedef std::string LanguageEntryLabel;
+
+  class ArgumentCompleter;
+  class ArgumentCompletionListElement;
+  class BaseFactory;
+  class BaseMetaObjectListElement;
+  class BaseObject;
+  template <class T>
+  class ClassFactory;
+  template <class T>
+  class ClassIdentifier;
+  class ClassTreeMask;
+  class ClassTreeMaskIterator;
+  class ClassTreeMaskNode;
+  class ClassTreeMaskObjectIterator;
+  class Clock;
+  class CommandEvaluation;
+  class CommandExecutor;
+  class CommandLine;
+  class BaseCommandLineArgument;
+  template <class T>
+  class CommandLineArgument;
+  class ConfigFile;
+  class ConfigFileEntry;
+  class ConfigFileEntryComment;
+  class ConfigFileEntryValue;
+  class ConfigFileManager;
+  class ConfigFileSection;
+  class ConfigValueContainer;
+  class ConsoleCommand;
+  class Core;
+  class Executor;
+  template <class T>
+  class ExecutorMember;
+  class ExecutorStatic;
+  class Factory;
+  class Functor;
+  template <class T>
+  class FunctorMember;
+  class FunctorStatic;
+  class Identifier;
+  class IRC;
+  template <class T>
+  class Iterator;
+  class IteratorBase;
+  class Language;
+  class LanguageEntry;
+  class Level;
+  class Loader;
+  class MetaObjectList;
+  class MetaObjectListElement;
+  class Namespace;
+  class NamespaceNode;
+  template <class T>
+  class ObjectList;
+  class ObjectListBase;
+  class ObjectListBaseElement;
+  template <class T>
+  class ObjectListElement;
+  template <class T>
+  class ObjectListIterator;
+  class OrxonoxClass;
+  class Shell;
+  class ShellListener;
+  template <class T>
+  class SubclassIdentifier;
+  class TclBind;
+  struct TclInterpreterBundle;
+  class TclThreadManager;
+  class Tickable;
+  template <class T, class O>
+  class XMLPortClassObjectContainer;
+  template <class T>
+  class XMLPortClassParamContainer;
+  class XMLPortObjectContainer;
+  class XMLPortParamContainer;
+
+  // game states
+  class GameStateBase;
+  template <class ParentType>
+  class GameState;
+  class RootGameState;
+
+  // input
+  class BaseCommand;
+  class BufferedParamCommand;
+  class Button;
+  class CalibratorCallback;
+  class ExtendedInputState;
+  class HalfAxis;
+  class InputBuffer;
+  class InputManager;
+  class InputState;
+  class JoyStickHandler;
+  class MouseHandler;
+  class KeyBinder;
+  class KeyDetector;
+  class KeyHandler;
+  class ParamCommand;
+  class SimpleCommand;
+  class SimpleInputState;
+}
+
+#endif /* _CorePrereqs_H__ */
Index: /code/branches/ceguilua/src/core/Executor.cc
===================================================================
--- /code/branches/ceguilua/src/core/Executor.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Executor.cc	(revision 1801)
@@ -0,0 +1,252 @@
+/*
+ *   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:
+ *      ...
+ *
+ *   Inspiration: Executor by Benjamin Grauer
+ */
+
+#include "Executor.h"
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "Language.h"
+
+namespace orxonox
+{
+    Executor::Executor(Functor* functor, const std::string& name)
+    {
+        this->functor_ = functor;
+        this->name_ = name;
+
+        this->bAddedDescription_ = false;
+        this->bAddedDescriptionReturnvalue_ = false;
+
+        this->bAddedDescriptionParam_[0] = false;
+        this->bAddedDescriptionParam_[1] = false;
+        this->bAddedDescriptionParam_[2] = false;
+        this->bAddedDescriptionParam_[3] = false;
+        this->bAddedDescriptionParam_[4] = false;
+
+        this->bAddedDefaultValue_[0] = false;
+        this->bAddedDefaultValue_[1] = false;
+        this->bAddedDefaultValue_[2] = false;
+        this->bAddedDefaultValue_[3] = false;
+        this->bAddedDefaultValue_[4] = false;
+    }
+
+    Executor::~Executor()
+    {
+        delete this->functor_;
+    }
+
+    bool Executor::parse(const std::string& params, const std::string& delimiter) const
+    {
+        EXECUTOR_PARSE(normal);
+    }
+
+    bool Executor::evaluate(const std::string& params, MultiType param[5], const std::string& delimiter) const
+    {
+        unsigned int paramCount = this->functor_->getParamCount();
+
+        if (paramCount == 1)
+        {
+            // only one param: check if there are params given, otherwise try to use default values
+            std::string temp = getStripped(params);
+            if ((temp != "") && (temp.size() != 0))
+            {
+                param[0] = params;
+                this->functor_->evaluateParam(0, param[0]);
+                return true;
+            }
+            else if (this->bAddedDefaultValue_[0])
+            {
+                param[0] = this->defaultValue_[0];
+                this->functor_->evaluateParam(0, param[0]);
+                return true;
+            }
+            return false;
+        }
+        else
+        {
+            // more than one param
+            SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0');
+
+            // if there are not enough params given, check if there are default values
+            for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++)
+                if (!this->bAddedDefaultValue_[i])
+                    return false;
+
+            // assign all given arguments to the multitypes
+            for (unsigned int i = 0; i < min(tokens.size(), (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+                param[i] = tokens[i];
+
+            // fill the remaining multitypes with default values
+            for (unsigned int i = tokens.size(); i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+                param[i] = this->defaultValue_[i];
+
+            // evaluate the param types through the functor
+            for (unsigned int i = 0; i < min(paramCount, (unsigned int)MAX_FUNCTOR_ARGUMENTS); i++)
+                this->functor_->evaluateParam(i, param[i]);
+
+            return true;
+        }
+    }
+
+    Executor& Executor::setDescription(const std::string& description)
+    {
+        if (!this->bAddedDescription_)
+        {
+            this->description_ = std::string("ExecutorDescription::" + this->name_ + "::function");
+            AddLanguageEntry(this->description_, description);
+            this->bAddedDescription_ = true;
+        }
+        return (*this);
+    }
+
+    const std::string& Executor::getDescription() const
+    {
+        return GetLocalisation(this->description_);
+    }
+
+    Executor& Executor::setDescriptionParam(unsigned int param, const std::string& description)
+    {
+        if (param >= 0 && param < MAX_FUNCTOR_ARGUMENTS)
+        {
+            if (!this->bAddedDescriptionParam_[param])
+            {
+                std::string paramnumber;
+                if (!convertValue(&paramnumber, param))
+                    return (*this);
+
+                this->descriptionParam_[param] = std::string("ExecutorDescription::" + this->name_ + "::param" + paramnumber);
+                AddLanguageEntry(this->descriptionParam_[param], description);
+                this->bAddedDescriptionParam_[param] = true;
+            }
+        }
+        return (*this);
+    }
+
+    const std::string& Executor::getDescriptionParam(unsigned int param) const
+    {
+        if (param >= 0 && param < MAX_FUNCTOR_ARGUMENTS)
+            return GetLocalisation(this->descriptionParam_[param]);
+
+        return this->descriptionParam_[0];
+    }
+
+    Executor& Executor::setDescriptionReturnvalue(const std::string& description)
+    {
+        if (!this->bAddedDescriptionReturnvalue_)
+        {
+            this->descriptionReturnvalue_ = std::string("ExecutorDescription::" + this->name_ + "::returnvalue");
+            AddLanguageEntry(this->descriptionReturnvalue_, description);
+            this->bAddedDescriptionReturnvalue_ = true;
+        }
+        return (*this);
+    }
+
+    const std::string& Executor::getDescriptionReturnvalue(int param) const
+    {
+        return GetLocalisation(this->descriptionReturnvalue_);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+        this->defaultValue_[2] = param3;
+        this->bAddedDefaultValue_[2] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+        this->defaultValue_[2] = param3;
+        this->bAddedDefaultValue_[2] = true;
+        this->defaultValue_[3] = param4;
+        this->bAddedDefaultValue_[3] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+    {
+        this->defaultValue_[0] = param1;
+        this->bAddedDefaultValue_[0] = true;
+        this->defaultValue_[1] = param2;
+        this->bAddedDefaultValue_[1] = true;
+        this->defaultValue_[2] = param3;
+        this->bAddedDefaultValue_[2] = true;
+        this->defaultValue_[3] = param4;
+        this->bAddedDefaultValue_[3] = true;
+        this->defaultValue_[4] = param5;
+        this->bAddedDefaultValue_[4] = true;
+
+        return (*this);
+    }
+
+    Executor& Executor::setDefaultValue(unsigned int index, const MultiType& param)
+    {
+        if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
+        {
+            this->defaultValue_[index] = param;
+            this->bAddedDefaultValue_[index] = true;
+        }
+        return (*this);
+    }
+
+    bool Executor::allDefaultValuesSet() const
+    {
+        for (unsigned int i = 0; i < this->functor_->getParamCount(); i++)
+            if (!this->bAddedDefaultValue_[i])
+                return false;
+
+        return true;
+    }
+}
Index: /code/branches/ceguilua/src/core/Executor.h
===================================================================
--- /code/branches/ceguilua/src/core/Executor.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Executor.h	(revision 1801)
@@ -0,0 +1,305 @@
+/*
+ *   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:
+ *      ...
+ *
+ *   Inspiration: Executor by Benjamin Grauer
+ */
+
+#ifndef _Executor_H__
+#define _Executor_H__
+
+#include "CorePrereqs.h"
+
+#include "util/SubString.h"
+#include "util/String.h"
+#include "util/Math.h"
+#include "Functor.h"
+#include "util/Debug.h"
+
+
+#define EXECUTOR_PARSE_FUNCTORCALL(mode) EXECUTOR_PARSE_FUNCTORCALL##mode
+#define EXECUTOR_PARSE_FUNCTORCALLnormal (*this->functor_)
+#define EXECUTOR_PARSE_FUNCTORCALLobject (*((FunctorMember<T>*)this->functor_))
+
+#define EXECUTOR_PARSE_OBJECT(mode, comma) EXECUTOR_PARSE_OBJECT##mode##comma
+#define EXECUTOR_PARSE_OBJECTnormal0
+#define EXECUTOR_PARSE_OBJECTnormal1
+#define EXECUTOR_PARSE_OBJECTobject0 object
+#define EXECUTOR_PARSE_OBJECTobject1 object,
+
+#define EXECUTOR_PARSE(mode) \
+    unsigned int paramCount = this->functor_->getParamCount(); \
+    \
+    if (paramCount == 0) \
+    { \
+        COUT(5) << "Calling Executor " << this->name_ << " through parser without parameters." << std::endl; \
+        EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 0)); \
+    } \
+    else if (paramCount == 1) \
+    { \
+        std::string temp = getStripped(params); \
+        if ((temp != "") && (temp.size() != 0)) \
+        { \
+            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using whole string: " << params << std::endl; \
+            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) MultiType(params)); \
+        } \
+        else if (this->bAddedDefaultValue_[0]) \
+        { \
+            COUT(5) << "Calling Executor " << this->name_ << " through parser with one parameter, using default value: " << this->defaultValue_[0] << std::endl; \
+            EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) this->defaultValue_[0]); \
+        } \
+        else \
+        { \
+            COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input: " << temp << ")." << std::endl; \
+            return false; \
+        } \
+    } \
+    else \
+    { \
+        SubString tokens(params, delimiter, SubString::WhiteSpaces, false, '\\', true, '"', true, '(', ')', true, '\0'); \
+        \
+        for (unsigned int i = tokens.size(); i < this->functor_->getParamCount(); i++) \
+        { \
+            if (!this->bAddedDefaultValue_[i]) \
+            { \
+                COUT(2) << "Warning: Can't call executor " << this->name_ << " through parser: Not enough parameters or default values given (input:" << params << ")." << std::endl; \
+                return false; \
+            } \
+        } \
+        \
+        MultiType param[MAX_FUNCTOR_ARGUMENTS]; \
+        COUT(5) << "Calling Executor " << this->name_ << " through parser with " << paramCount << " parameters, using " << tokens.size() << " tokens ("; \
+        for (unsigned int i = 0; i < tokens.size() && i < MAX_FUNCTOR_ARGUMENTS; i++) \
+        { \
+            param[i] = tokens[i]; \
+            if (i != 0) \
+            { \
+                COUT(5) << ", "; \
+            } \
+            COUT(5) << tokens[i]; \
+        } \
+        COUT(5) << ") and " << max((int)paramCount - (int)tokens.size(), 0) << " default values ("; \
+        for (unsigned int i = tokens.size(); i < paramCount; i++) \
+        { \
+            param[i] = this->defaultValue_[i]; \
+            if (i != 0) \
+            { \
+                COUT(5) << ", "; \
+            } \
+            COUT(5) << this->defaultValue_[i]; \
+        } \
+        COUT(5) << ")." << std::endl; \
+        \
+        if ((tokens.size() > paramCount) && (this->functor_->getTypenameParam(paramCount - 1) == "string")) \
+            param[paramCount - 1] = tokens.subSet(paramCount - 1).join(); \
+        \
+        switch(paramCount) \
+        { \
+            case 2: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1]); \
+                break; \
+            case 3: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2]); \
+                break; \
+            case 4: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2], param[3]); \
+                break; \
+            case 5: \
+                EXECUTOR_PARSE_FUNCTORCALL(mode)(EXECUTOR_PARSE_OBJECT(mode, 1) param[0], param[1], param[2], param[3], param[4]); \
+                break; \
+        } \
+    } \
+    \
+    return true
+
+namespace orxonox
+{
+    class _CoreExport Executor
+    {
+        public:
+            Executor(Functor* functor, const std::string& name = "");
+            virtual ~Executor();
+
+            inline void operator()() const
+                { (*this->functor_)(this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1) const
+                { (*this->functor_)(param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2) const
+                { (*this->functor_)(param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { (*this->functor_)(param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { (*this->functor_)(param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { (*this->functor_)(param1, param2, param3, param4, param5); }
+
+            bool parse(const std::string& params, const std::string& delimiter = " ") const;
+
+            bool evaluate(const std::string& params, MultiType param[5], const std::string& delimiter = " ") const;
+
+            Executor& setDescription(const std::string& description);
+            const std::string& getDescription() const;
+
+            Executor& setDescriptionParam(unsigned int param, const std::string& description);
+            const std::string& getDescriptionParam(unsigned int param) const;
+
+            Executor& setDescriptionReturnvalue(const std::string& description);
+            const std::string& getDescriptionReturnvalue(int param) const;
+
+            inline Functor* getFunctor() const
+                { return this->functor_; }
+            inline unsigned int getParamCount() const
+                { return this->functor_->getParamCount(); }
+            inline bool hasReturnvalue() const
+                { return this->functor_->hasReturnvalue(); }
+            inline FunctionType getType() const
+                { return this->functor_->getType(); }
+            inline MultiType getReturnvalue() const
+                { return this->functor_->getReturnvalue(); }
+            inline std::string getTypenameParam(unsigned int param) const
+                { return this->functor_->getTypenameParam(param); }
+            inline std::string getTypenameReturnvalue() const
+                { return this->functor_->getTypenameReturnvalue(); }
+
+            inline void setName(const std::string name)
+                { this->name_ = name; }
+            inline const std::string& getName() const
+                { return this->name_; }
+
+            Executor& setDefaultValues(const MultiType& param1);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4);
+            Executor& setDefaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5);
+            Executor& setDefaultValue(unsigned int index, const MultiType& param);
+
+            inline MultiType getDefaultValue(unsigned int index) const
+            {
+                if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
+                    return this->defaultValue_[index];
+
+                return MT_null;
+            }
+
+            bool allDefaultValuesSet() const;
+            inline bool defaultValueSet(unsigned int index) const
+            {
+                if (index >= 0 && index < MAX_FUNCTOR_ARGUMENTS)
+                    return this->bAddedDefaultValue_[index];
+
+                return false;
+            }
+
+        protected:
+            Functor* functor_;
+            std::string name_;
+            MultiType defaultValue_[MAX_FUNCTOR_ARGUMENTS];
+            bool bAddedDefaultValue_[MAX_FUNCTOR_ARGUMENTS];
+
+        private:
+            LanguageEntryLabel description_;
+            LanguageEntryLabel descriptionReturnvalue_;
+            LanguageEntryLabel descriptionParam_[MAX_FUNCTOR_ARGUMENTS];
+
+            bool bAddedDescription_;
+            bool bAddedDescriptionReturnvalue_;
+            bool bAddedDescriptionParam_[MAX_FUNCTOR_ARGUMENTS];
+    };
+
+    class _CoreExport ExecutorStatic : public Executor
+    {
+        public:
+            ExecutorStatic(FunctorStatic* functor, const std::string& name = "") : Executor(functor, name) {}
+            virtual ~ExecutorStatic() {}
+    };
+
+    template <class T>
+    class ExecutorMember : public Executor
+    {
+        public:
+            ExecutorMember(FunctorMember<T>* functor, const std::string& name = "") : Executor(functor, name) {}
+            virtual ~ExecutorMember() {}
+
+            inline void operator()(T* object) const
+                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
+
+
+            inline void operator()(const T* object) const
+                { (*((FunctorMember<T>*)this->functor_))(object, this->defaultValue_[0], this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, this->defaultValue_[1], this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, this->defaultValue_[2], this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, this->defaultValue_[3], this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, this->defaultValue_[4]); }
+            inline void operator()(const T* object, const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) const
+                { (*((FunctorMember<T>*)this->functor_))(object, param1, param2, param3, param4, param5); }
+
+            inline void setObject(T* object) const
+                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
+            inline void setObject(const T* object) const
+                { ((FunctorMember<T>*)this->functor_)->setObject(object); }
+
+            bool parse(T* object, const std::string& params, const std::string& delimiter = " ") const
+            {
+                EXECUTOR_PARSE(object);
+            }
+
+            bool parse(const T* object, const std::string& params, const std::string& delimiter = " ") const
+            {
+                EXECUTOR_PARSE(object);
+            }
+    };
+
+    inline Executor* createExecutor(Functor* functor, const std::string& name = "")
+    {
+        return new Executor(functor, name);
+    }
+
+    template <class T>
+    inline ExecutorMember<T>* createExecutor(FunctorMember<T>* functor, const std::string& name = "")
+    {
+        return new ExecutorMember<T>(functor, name);
+    }
+
+    inline ExecutorStatic* createExecutor(FunctorStatic* functor, const std::string& name = "")
+    {
+        return new ExecutorStatic(functor, name);
+    }
+}
+
+#endif /* _Executor_H__ */
Index: /code/branches/ceguilua/src/core/Factory.cc
===================================================================
--- /code/branches/ceguilua/src/core/Factory.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Factory.cc	(revision 1801)
@@ -0,0 +1,130 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Factory.cc
+    @brief Implementation of the Factory class.
+*/
+
+#include "Factory.h"
+#include "Identifier.h"
+#include "BaseObject.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    /**
+        @brief Returns the Identifier with a given name.
+        @param name The name of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* Factory::getIdentifier(const std::string& name)
+    {
+        return getFactoryPointer()->identifierStringMap_[name];
+    }
+
+    /**
+        @brief Returns the Identifier with a given network ID.
+        @param id The network ID of the wanted Identifier
+        @return The Identifier
+    */
+    Identifier* Factory::getIdentifier(const unsigned int id)
+    {
+        return getFactoryPointer()->identifierNetworkIDMap_[id];
+    }
+
+    /**
+        @brief Adds a new Identifier to both maps.
+        @param name The name of the identifier
+        @param identifier The identifier to add
+    */
+    void Factory::add(const std::string& name, Identifier* identifier)
+    {
+        getFactoryPointer()->identifierStringMap_[name] = identifier;
+        getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
+    }
+
+    /**
+        @brief Removes the entry with the old network ID and adds a new one.
+        @param identifier The identifier to change
+        @param oldID The old networkID
+        @param newID The new networkID
+    */
+    void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
+    {
+        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
+        getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;
+    }
+
+    /**
+        @brief Creates the class-hierarchy by creating and destroying one object of each type.
+    */
+    void Factory::createClassHierarchy()
+    {
+        COUT(3) << "*** Factory: Create class-hierarchy" << std::endl;
+        std::map<std::string, Identifier*>::iterator it;
+        it = getFactoryPointer()->identifierStringMap_.begin();
+        (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy();
+        for (it = getFactoryPointer()->identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it)
+        {
+            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
+            BaseObject* temp = (*it).second->fabricate();
+            delete temp;
+        }
+        (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();
+        COUT(3) << "*** Factory: Finished class-hierarchy creation" << std::endl;
+    }
+
+    /**
+        @brief Ensures the Factory gets created in the right moment.
+        @return The Factory.
+    */
+    Factory* Factory::getFactoryPointer()
+    {
+      static Factory theOneAndOnlyFactoryInstance = Factory();
+      return &theOneAndOnlyFactoryInstance;
+    }
+
+    /**
+        @brief Returns the begin-iterator of the factory-map.
+        @return The begin-iterator
+    */
+    std::map<std::string, Identifier*>::const_iterator Factory::getFactoryBegin()
+    {
+        return Factory::getFactoryPointer()->identifierStringMap_.begin();
+    }
+
+    /**
+        @brief Returns the end-iterator of the factory-map.
+        @return The end-iterator
+    */
+    std::map<std::string, Identifier*>::const_iterator Factory::getFactoryEnd()
+    {
+        return Factory::getFactoryPointer()->identifierStringMap_.end();
+    }
+}
Index: /code/branches/ceguilua/src/core/Factory.h
===================================================================
--- /code/branches/ceguilua/src/core/Factory.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Factory.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Factory.h
+    @brief Definition of the Factory and the BaseFactory class.
+
+    The Factory is a singleton, containing two maps to map either the name or the network ID
+    of a class with the corresponding Identifier.
+
+    Usage:
+    ID(classname) or ID(networkID) returns the corresponding Identifier.
+
+
+    BaseObject is the parent of ClassFactory which is defined in ClassFactory.h.
+    It can't be defined in ClassFactory.h, because of circular dependencies.
+*/
+
+#ifndef _Factory_H__
+#define _Factory_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include <string>
+
+namespace orxonox
+{
+    // ###############################
+    // ###         Factory         ###
+    // ###############################
+    //! The Factory is used to map the name or the network ID of a class with its Identifier.
+    class _CoreExport Factory
+    {
+        public:
+            static Identifier* getIdentifier(const std::string& name);
+            static Identifier* getIdentifier(const unsigned int id);
+            static void add(const std::string& name, Identifier* identifier);
+            static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
+            static void createClassHierarchy();
+
+            static Factory* getFactoryPointer();    // avoid overriding order problem in the static intialisation process
+            static std::map<std::string, Identifier*>::const_iterator getFactoryBegin();
+            static std::map<std::string, Identifier*>::const_iterator getFactoryEnd();
+
+        private:
+            Factory() {}                            // don't create
+            Factory(const Factory& factory);        // don't copy
+            ~Factory() {}                           // don't delete
+
+            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
+            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
+    };
+
+    // ###############################
+    // ###       BaseFactory       ###
+    // ###############################
+    //! Base-class of ClassFactory. Has to be defined separate because of circular dependencies.
+    class _CoreExport BaseFactory
+    {
+        public:
+            virtual BaseObject* fabricate() = 0;
+            virtual ~BaseFactory() {};
+    };
+}
+
+#endif /* _Factory_H__ */
Index: /code/branches/ceguilua/src/core/Functor.h
===================================================================
--- /code/branches/ceguilua/src/core/Functor.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Functor.h	(revision 1801)
@@ -0,0 +1,478 @@
+/*
+ *   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:
+ *      ...
+ *
+ *   Inspiration: Functor by Benjamin Grauer
+ */
+
+#ifndef _Functor_H__
+#define _Functor_H__
+
+#include "CorePrereqs.h"
+
+#include "util/MultiType.h"
+#include "util/Debug.h"
+
+
+namespace orxonox
+{
+    const unsigned int MAX_FUNCTOR_ARGUMENTS = 5;
+
+    enum FunctionType
+    {
+        FT_MEMBER,
+        FT_CONSTMEMBER,
+        FT_STATIC
+    };
+
+
+    template <class T>
+    inline std::string typeToString() { return "unknown"; }
+
+#define CreateTypeToStringTemplate(type) \
+    template <> \
+    inline std::string typeToString<type>() { return #type; } \
+    template <> \
+    inline std::string typeToString<type&>() { return #type; } \
+    template <> \
+    inline std::string typeToString<const type>() { return #type; } \
+    template <> \
+    inline std::string typeToString<const type&>() { return #type; }
+
+    CreateTypeToStringTemplate(int);
+    CreateTypeToStringTemplate(unsigned int);
+    CreateTypeToStringTemplate(char);
+    CreateTypeToStringTemplate(unsigned char);
+    CreateTypeToStringTemplate(short);
+    CreateTypeToStringTemplate(unsigned short);
+    CreateTypeToStringTemplate(long);
+    CreateTypeToStringTemplate(unsigned long);
+    CreateTypeToStringTemplate(long long);
+    CreateTypeToStringTemplate(unsigned long long);
+    CreateTypeToStringTemplate(float);
+    CreateTypeToStringTemplate(double);
+    CreateTypeToStringTemplate(long double);
+    CreateTypeToStringTemplate(bool);
+    CreateTypeToStringTemplate(Vector2);
+    CreateTypeToStringTemplate(Vector3);
+    CreateTypeToStringTemplate(Quaternion);
+    CreateTypeToStringTemplate(ColourValue);
+    CreateTypeToStringTemplate(Radian);
+    CreateTypeToStringTemplate(Degree);
+
+    template <>
+    inline std::string typeToString<std::string>() { return "string"; }
+    template <>
+    inline std::string typeToString<std::string&>() { return "string"; }
+    template <>
+    inline std::string typeToString<const std::string>() { return "string"; }
+    template <>
+    inline std::string typeToString<const std::string&>() { return "string"; }
+
+    class _CoreExport Functor
+    {
+        public:
+            Functor() {}
+            virtual ~Functor() {}
+
+            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+
+            inline unsigned int getParamCount() const { return this->numParams_; }
+            inline bool hasReturnvalue() const { return this->hasReturnValue_; }
+            inline FunctionType getType() const { return this->type_; }
+            inline MultiType getReturnvalue() const { return this->returnedValue_; }
+
+            std::string getTypenameParam(unsigned int param) const { return (param >= 0 && param < 5) ? this->typeParam_[param] : ""; }
+            std::string getTypenameReturnvalue() const { return this->typeReturnvalue_; }
+
+            virtual void evaluateParam(unsigned int index, MultiType& param) const = 0;
+
+        protected:
+            unsigned int numParams_;
+            bool hasReturnValue_;
+            FunctionType type_;
+            MultiType returnedValue_;
+
+            std::string typeReturnvalue_;
+            std::string typeParam_[MAX_FUNCTOR_ARGUMENTS];
+    };
+
+    class _CoreExport FunctorStatic : public Functor
+    {
+        public:
+            virtual ~FunctorStatic() {}
+            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+    };
+
+    template <class T>
+    class FunctorMember : public Functor
+    {
+        public:
+            FunctorMember()
+            {
+                constObject_ = 0;
+                object_ = 0;
+                bConstObject_ = false;
+            }
+            virtual ~FunctorMember() {}
+
+            virtual void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+            virtual void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) = 0;
+
+            virtual void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null)
+            {
+                if (this->bConstObject_)
+                {
+                    if (this->constObject_)
+                        (*this)(this->constObject_, param1, param2, param3, param4, param5);
+                    else
+                    {
+                        COUT(1) << "An error occurred in Functor.h:" << std::endl;
+                        COUT(1) << "Error: No const object set." << std::endl;
+                    }
+                }
+                else
+                {
+                    if (this->object_)
+                        (*this)(this->object_, param1, param2, param3, param4, param5);
+                    else
+                    {
+                        COUT(1) << "An error occurred in Functor.h:" << std::endl;
+                        COUT(1) << "Error: No object set." << std::endl;
+                    }
+                }
+            }
+
+            void setObject(T* object)
+            {
+                this->bConstObject_ = false;
+                this->object_ = object;
+            }
+
+            void setObject(const T* object)
+            {
+                this->bConstObject_ = true;
+                this->constObject_ = object;
+            }
+
+        private:
+            const T* constObject_;
+            T* object_;
+            bool bConstObject_;
+    };
+
+
+
+#define FUNCTOR_TEMPLATE(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE##ismember##returnvalue##numparams
+#define FUNCTOR_TEMPLATE000
+#define FUNCTOR_TEMPLATE001 template <class P1>
+#define FUNCTOR_TEMPLATE002 template <class P1, class P2>
+#define FUNCTOR_TEMPLATE003 template <class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE004 template <class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE005 template <class P1, class P2, class P3, class P4, class P5>
+#define FUNCTOR_TEMPLATE010 template <class R>
+#define FUNCTOR_TEMPLATE011 template <class R, class P1>
+#define FUNCTOR_TEMPLATE012 template <class R, class P1, class P2>
+#define FUNCTOR_TEMPLATE013 template <class R, class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE014 template <class R, class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE015 template <class R, class P1, class P2, class P3, class P4, class P5>
+#define FUNCTOR_TEMPLATE100 template <class T>
+#define FUNCTOR_TEMPLATE101 template <class T, class P1>
+#define FUNCTOR_TEMPLATE102 template <class T, class P1, class P2>
+#define FUNCTOR_TEMPLATE103 template <class T, class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE104 template <class T, class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE105 template <class T, class P1, class P2, class P3, class P4, class P5>
+#define FUNCTOR_TEMPLATE110 template <class T, class R>
+#define FUNCTOR_TEMPLATE111 template <class T, class R, class P1>
+#define FUNCTOR_TEMPLATE112 template <class T, class R, class P1, class P2>
+#define FUNCTOR_TEMPLATE113 template <class T, class R, class P1, class P2, class P3>
+#define FUNCTOR_TEMPLATE114 template <class T, class R, class P1, class P2, class P3, class P4>
+#define FUNCTOR_TEMPLATE115 template <class T, class R, class P1, class P2, class P3, class P4, class P5>
+
+
+
+#define FUNCTOR_TEMPLATE_CLASSES(ismember, returnvalue, numparams) FUNCTOR_TEMPLATE_CLASSES##ismember##returnvalue##numparams
+#define FUNCTOR_TEMPLATE_CLASSES000
+#define FUNCTOR_TEMPLATE_CLASSES001 <P1>
+#define FUNCTOR_TEMPLATE_CLASSES002 <P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES003 <P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES004 <P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES005 <P1, P2, P3, P4, P5>
+#define FUNCTOR_TEMPLATE_CLASSES010 <R>
+#define FUNCTOR_TEMPLATE_CLASSES011 <R, P1>
+#define FUNCTOR_TEMPLATE_CLASSES012 <R, P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES013 <R, P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES014 <R, P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES015 <R, P1, P2, P3, P4, P5>
+#define FUNCTOR_TEMPLATE_CLASSES100 <T>
+#define FUNCTOR_TEMPLATE_CLASSES101 <T, P1>
+#define FUNCTOR_TEMPLATE_CLASSES102 <T, P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES103 <T, P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES104 <T, P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES105 <T, P1, P2, P3, P4, P5>
+#define FUNCTOR_TEMPLATE_CLASSES110 <T, R>
+#define FUNCTOR_TEMPLATE_CLASSES111 <T, R, P1>
+#define FUNCTOR_TEMPLATE_CLASSES112 <T, R, P1, P2>
+#define FUNCTOR_TEMPLATE_CLASSES113 <T, R, P1, P2, P3>
+#define FUNCTOR_TEMPLATE_CLASSES114 <T, R, P1, P2, P3, P4>
+#define FUNCTOR_TEMPLATE_CLASSES115 <T, R, P1, P2, P3, P4, P5>
+
+
+
+#define FUNCTOR_TYPENAME_PARAMS(numparams) FUNCTOR_TYPENAME_PARAMS##numparams
+#define FUNCTOR_TYPENAME_PARAMS0
+#define FUNCTOR_TYPENAME_PARAMS1 this->typeParam_[0] = typeToString<P1>();
+#define FUNCTOR_TYPENAME_PARAMS2 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>();
+#define FUNCTOR_TYPENAME_PARAMS3 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>();
+#define FUNCTOR_TYPENAME_PARAMS4 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>();
+#define FUNCTOR_TYPENAME_PARAMS5 this->typeParam_[0] = typeToString<P1>(); this->typeParam_[1] = typeToString<P2>(); this->typeParam_[2] = typeToString<P3>(); this->typeParam_[3] = typeToString<P4>(); this->typeParam_[4] = typeToString<P5>();
+
+#define FUNCTOR_TYPENAME_RETURN(returnvalue) FUNCTOR_TYPENAME_RETURN##returnvalue
+#define FUNCTOR_TYPENAME_RETURN0
+#define FUNCTOR_TYPENAME_RETURN1 this->typeReturnvalue_ = typeToString<R>();
+
+
+
+#define FUNCTOR_FUNCTION_PARAMS(numparams) FUNCTOR_FUNCTION_PARAMS##numparams
+#define FUNCTOR_FUNCTION_PARAMS0
+#define FUNCTOR_FUNCTION_PARAMS1 P1 param1
+#define FUNCTOR_FUNCTION_PARAMS2 P1 param1, P2 param2
+#define FUNCTOR_FUNCTION_PARAMS3 P1 param1, P2 param2, P3 param3
+#define FUNCTOR_FUNCTION_PARAMS4 P1 param1, P2 param2, P3 param3, P4 param4
+#define FUNCTOR_FUNCTION_PARAMS5 P1 param1, P2 param2, P3 param3, P4 param4, P5 param5
+
+#define FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) FUNCTOR_FUNCTION_RETURNVALUE##returnvalue
+#define FUNCTOR_FUNCTION_RETURNVALUE0 void
+#define FUNCTOR_FUNCTION_RETURNVALUE1 R
+
+
+
+#define FUNCTOR_FUNCTION_CALL(numparams) FUNCTOR_FUNCTION_CALL##numparams
+#define FUNCTOR_FUNCTION_CALL0
+#define FUNCTOR_FUNCTION_CALL1 param1
+#define FUNCTOR_FUNCTION_CALL2 param1, param2
+#define FUNCTOR_FUNCTION_CALL3 param1, param2, param3
+#define FUNCTOR_FUNCTION_CALL4 param1, param2, param3, param4
+#define FUNCTOR_FUNCTION_CALL5 param1, param2, param3, param4, param5
+
+#define FUNCTOR_STORE_RETURNVALUE(returnvalue, functioncall) FUNCTOR_STORE_RETURNVALUE##returnvalue(functioncall)
+#define FUNCTOR_STORE_RETURNVALUE0(functioncall) functioncall
+#define FUNCTOR_STORE_RETURNVALUE1(functioncall) this->returnedValue_ = functioncall
+
+
+
+#define FUNCTOR_EVALUATE_PARAM(numparams) FUNCTOR_EVALUATE_PARAM##numparams
+#define FUNCTOR_EVALUATE_PARAM0
+#define FUNCTOR_EVALUATE_PARAM1 \
+    if (index == 0) { param.convert<P1>(); }
+#define FUNCTOR_EVALUATE_PARAM2 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); }
+#define FUNCTOR_EVALUATE_PARAM3 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); } \
+    else if (index == 2) { param.convert<P3>(); }
+#define FUNCTOR_EVALUATE_PARAM4 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); } \
+    else if (index == 2) { param.convert<P3>(); } \
+    else if (index == 3) { param.convert<P4>(); }
+#define FUNCTOR_EVALUATE_PARAM5 \
+    if (index == 0) { param.convert<P1>(); } \
+    else if (index == 1) { param.convert<P2>(); } \
+    else if (index == 2) { param.convert<P3>(); } \
+    else if (index == 3) { param.convert<P4>(); } \
+    else if (index == 4) { param.convert<P5>(); }
+
+
+
+
+
+#define CREATE_STATIC_FUNCTOR(returnvalue, numparams) \
+    FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
+    class FunctorStatic##returnvalue##numparams : public FunctorStatic \
+    { \
+        public: \
+            FunctorStatic##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+            { \
+                this->numParams_ = numparams; \
+                this->hasReturnValue_ = returnvalue; \
+                this->type_ = FT_STATIC; \
+                this->functionPointer_ = functionPointer; \
+                \
+                FUNCTOR_TYPENAME_PARAMS(numparams); \
+                FUNCTOR_TYPENAME_RETURN(returnvalue); \
+            } \
+    \
+            void operator()(const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            { \
+                FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+        private: \
+            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
+    }; \
+    \
+    \
+    FUNCTOR_TEMPLATE(0, returnvalue, numparams) \
+    inline FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+    { \
+        return new FunctorStatic##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(0, returnvalue, numparams) (functionPointer); \
+    }
+
+
+
+
+
+#define CREATE_MEMBER_FUNCTOR(returnvalue, numparams) \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    class FunctorMember##returnvalue##numparams : public FunctorMember<T> \
+    { \
+        public: \
+            FunctorMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+            { \
+                this->numParams_ = numparams; \
+                this->hasReturnValue_ = returnvalue; \
+                this->type_ = FT_MEMBER; \
+                this->functionPointer_ = functionPointer; \
+            } \
+    \
+            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                COUT(1) << "An error occurred in Functor.h:" << std::endl; \
+                COUT(1) << "Error: Function is not const." << std::endl; \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            { \
+                FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+        private: \
+            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)); \
+    }; \
+    \
+    \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    class FunctorConstMember##returnvalue##numparams : public FunctorMember<T> \
+    { \
+        public: \
+            FunctorConstMember##returnvalue##numparams(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
+            { \
+                this->numParams_ = numparams; \
+                this->hasReturnValue_ = returnvalue; \
+                this->type_ = FT_CONSTMEMBER; \
+                this->functionPointer_ = functionPointer; \
+            } \
+    \
+            void operator()(T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            void operator()(const T* object, const MultiType& param1 = MT_null, const MultiType& param2 = MT_null, const MultiType& param3 = MT_null, const MultiType& param4 = MT_null, const MultiType& param5 = MT_null) \
+            { \
+                FUNCTOR_STORE_RETURNVALUE(returnvalue, (*object.*this->functionPointer_)(FUNCTOR_FUNCTION_CALL(numparams))); \
+            } \
+    \
+            virtual void evaluateParam(unsigned int index, MultiType& param) const \
+            { \
+                FUNCTOR_EVALUATE_PARAM(numparams); \
+            } \
+    \
+        private: \
+            FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer_)(FUNCTOR_FUNCTION_PARAMS(numparams)) const; \
+    }; \
+    \
+    \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    inline FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams))) \
+    { \
+        return new FunctorMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
+    } \
+    \
+    \
+    FUNCTOR_TEMPLATE(1, returnvalue, numparams) \
+    inline FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams)* createFunctor(FUNCTOR_FUNCTION_RETURNVALUE(returnvalue) (T::*functionPointer)(FUNCTOR_FUNCTION_PARAMS(numparams)) const) \
+    { \
+        return new FunctorConstMember##returnvalue##numparams FUNCTOR_TEMPLATE_CLASSES(1, returnvalue, numparams) (functionPointer); \
+    }
+
+
+// disable annoying warning about forcing value to boolean
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable:4100 4800)
+#endif
+
+#define CREATE_ALL_STATIC_FUNCTORS() \
+    CREATE_STATIC_FUNCTOR(0, 0); \
+    CREATE_STATIC_FUNCTOR(0, 1); \
+    CREATE_STATIC_FUNCTOR(0, 2); \
+    CREATE_STATIC_FUNCTOR(0, 3); \
+    CREATE_STATIC_FUNCTOR(0, 4); \
+    CREATE_STATIC_FUNCTOR(0, 5); \
+    CREATE_STATIC_FUNCTOR(1, 0); \
+    CREATE_STATIC_FUNCTOR(1, 1); \
+    CREATE_STATIC_FUNCTOR(1, 2); \
+    CREATE_STATIC_FUNCTOR(1, 3); \
+    CREATE_STATIC_FUNCTOR(1, 4); \
+    CREATE_STATIC_FUNCTOR(1, 5)
+
+
+#define CREATE_ALL_MEMBER_FUNCTORS() \
+    CREATE_MEMBER_FUNCTOR(0, 0); \
+    CREATE_MEMBER_FUNCTOR(0, 1); \
+    CREATE_MEMBER_FUNCTOR(0, 2); \
+    CREATE_MEMBER_FUNCTOR(0, 3); \
+    CREATE_MEMBER_FUNCTOR(0, 4); \
+    CREATE_MEMBER_FUNCTOR(0, 5); \
+    CREATE_MEMBER_FUNCTOR(1, 0); \
+    CREATE_MEMBER_FUNCTOR(1, 1); \
+    CREATE_MEMBER_FUNCTOR(1, 2); \
+    CREATE_MEMBER_FUNCTOR(1, 3); \
+    CREATE_MEMBER_FUNCTOR(1, 4); \
+    CREATE_MEMBER_FUNCTOR(1, 5)
+
+
+    CREATE_ALL_STATIC_FUNCTORS();
+    CREATE_ALL_MEMBER_FUNCTORS();
+}
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(pop)
+#endif
+
+#endif /* _Functor_H__ */
Index: /code/branches/ceguilua/src/core/GameState.cc
===================================================================
--- /code/branches/ceguilua/src/core/GameState.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/GameState.cc	(revision 1801)
@@ -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 "util/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/branches/ceguilua/src/core/GameState.h
===================================================================
--- /code/branches/ceguilua/src/core/GameState.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/GameState.h	(revision 1801)
@@ -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/branches/ceguilua/src/core/IRC.cc
===================================================================
--- /code/branches/ceguilua/src/core/IRC.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/IRC.cc	(revision 1801)
@@ -0,0 +1,140 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "IRC.h"
+
+#include <boost/thread/thread.hpp>
+#include "ConsoleCommand.h"
+#include "TclThreadManager.h"
+#include "CoreIncludes.h"
+#include "util/Convert.h"
+
+
+namespace orxonox
+{
+    static const unsigned int IRC_TCL_THREADID  = 1421421421;
+
+    SetConsoleCommand(IRC, say,  true).accessLevel(AccessLevel::User);
+    SetConsoleCommand(IRC, msg,  false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);
+
+    IRC::IRC()
+    {
+        RegisterRootObject(IRC);
+        this->bundle_ = 0;
+    }
+
+    void IRC::initialize()
+    {
+        unsigned int threadID = (unsigned int)IRC_TCL_THREADID;
+        TclThreadManager::createID(threadID);
+        this->bundle_ = TclThreadManager::getInstance().getInterpreterBundle(threadID);
+
+        try
+        {
+            this->bundle_->interpreter_->def("orxonox::irc::say", IRC::tcl_say, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::privmsg", IRC::tcl_privmsg, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::action", IRC::tcl_action, Tcl::variadic());
+            this->bundle_->interpreter_->def("orxonox::irc::info", IRC::tcl_info, Tcl::variadic());
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while initializing Tcl (IRC): " << e.what();   }
+
+        this->nickname_ = "orx" + getConvertedValue<int, std::string>((unsigned int)rand());
+        TclThreadManager::execute(threadID, "set nickname " + this->nickname_);
+        TclThreadManager::execute(threadID, "source irc.tcl");
+    }
+
+    IRC& IRC::getInstance()
+    {
+        static IRC instance;
+        return instance;
+    }
+
+    bool IRC::eval(const std::string& command)
+    {
+        if (!IRC::getInstance().bundle_)
+        {
+            IRC::getInstance().initialize();
+            COUT(1) << "Error: IRC client wasn't yet initialized, please try again." << std::endl;
+            return false;
+        }
+
+        try
+        {
+            IRC::getInstance().bundle_->interpreter_->eval(command);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl (IRC) error: " << e.what();   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while executing Tcl (IRC): " << e.what();   }
+
+        return false;
+    }
+
+    void IRC::say(const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn #orxonox {" + message + "}"))
+            IRC::tcl_say(Tcl::object(), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::msg(const std::string& channel, const std::string& message)
+    {
+        if (IRC::eval("irk::say $conn " + channel + " {" + message + "}"))
+            IRC::tcl_privmsg(Tcl::object(channel), Tcl::object(IRC::getInstance().nickname_), Tcl::object(message));
+    }
+
+    void IRC::nick(const std::string& nickname)
+    {
+        if (IRC::eval("irk::nick $conn " + nickname))
+            IRC::getInstance().nickname_ = nickname;
+    }
+
+    void IRC::tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC (" << query.get() << ")> " << nick.get() << ": " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> * " << nick.get() << " " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+
+    void IRC::tcl_info(Tcl::object const &channel, Tcl::object const &args)
+    {
+        COUT(0) << "IRC> --> " << stripEnclosingBraces(args.get()) << std::endl;
+    }
+}
Index: /code/branches/ceguilua/src/core/IRC.h
===================================================================
--- /code/branches/ceguilua/src/core/IRC.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/IRC.h	(revision 1801)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _IRC_H__
+#define _IRC_H__
+
+#include "CorePrereqs.h"
+
+#include "OrxonoxClass.h"
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class _CoreExport IRC : public OrxonoxClass
+    {
+        public:
+            static IRC& getInstance();
+
+            static void say(const std::string& message);
+            static void msg(const std::string& channel, const std::string& message);
+            static void nick(const std::string& nickname);
+
+            static void tcl_say(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_privmsg(Tcl::object const &query, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_action(Tcl::object const &channel, Tcl::object const &nick, Tcl::object const &args);
+            static void tcl_info(Tcl::object const &channel, Tcl::object const &args);
+
+        private:
+            static bool eval(const std::string& command);
+            void initialize();
+
+            IRC();
+            IRC(const IRC& other);
+            ~IRC() {}
+
+            TclInterpreterBundle* bundle_;
+            std::string nickname_;
+    };
+}
+
+#endif /* _IRC_H__ */
Index: /code/branches/ceguilua/src/core/Identifier.cc
===================================================================
--- /code/branches/ceguilua/src/core/Identifier.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Identifier.cc	(revision 1801)
@@ -0,0 +1,457 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Identifier.cc
+    @brief Implementation of the Identifier class.
+*/
+
+#include "Identifier.h"
+
+#include <ostream>
+
+#include "Factory.h"
+#include "ConfigValueContainer.h"
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "XMLPort.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###       Identifier        ###
+    // ###############################
+    int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero (this static member variable is ok: it's used in main(), not before)
+
+    /**
+        @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
+    */
+    Identifier::Identifier()
+    {
+        this->objects_ = new ObjectListBase(this);
+
+        this->bCreatedOneObject_ = false;
+        this->bSetName_ = false;
+        this->factory_ = 0;
+
+        this->bHasConfigValues_ = false;
+        this->bHasConsoleCommands_ = false;
+
+        this->children_ = new std::set<const Identifier*>();
+        this->directChildren_ = new std::set<const Identifier*>();
+
+        // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables
+        static unsigned int classIDcounter_s = 0;
+        this->classID_ = classIDcounter_s++;
+    }
+
+    /**
+        @brief Destructor: Deletes the list containing the children.
+    */
+    Identifier::~Identifier()
+    {
+        delete this->children_;
+        delete this->directChildren_;
+        delete this->objects_;
+
+        if (this->factory_)
+            delete this->factory_;
+
+        for (std::map<std::string, ConsoleCommand*>::iterator it = this->consoleCommands_.begin(); it != this->consoleCommands_.end(); ++it)
+            delete (it->second);
+        for (std::map<std::string, ConfigValueContainer*>::iterator it = this->configValues_.begin(); it != this->configValues_.end(); ++it)
+            delete (it->second);
+        for (std::map<std::string, XMLPortParamContainer*>::iterator it = this->xmlportParamContainers_.begin(); it != this->xmlportParamContainers_.end(); ++it)
+            delete (it->second);
+        for (std::map<std::string, XMLPortObjectContainer*>::iterator it = this->xmlportObjectContainers_.begin(); it != this->xmlportObjectContainers_.end(); ++it)
+            delete (it->second);
+    }
+
+    /**
+        @brief Returns an identifier by name and adds it if not available
+        @param name The name of the identifier as typeid().name() suggests
+        @param proposal A pointer to a newly created identifier for the case of non existance in the map
+        @return The identifier (unique instance)
+    */
+    Identifier* Identifier::getIdentifierSingleton(const std::string& name, Identifier* proposal)
+    {
+        static std::map<std::string, Identifier*> identifiers;    //!< The map to store all Identifiers.
+        std::map<std::string, Identifier*>::const_iterator it = identifiers.find(name);
+
+        if (it != identifiers.end())
+        {
+            // There is already an entry: return it and delete the proposal
+            delete proposal;
+            return (*it).second;
+        }
+        else
+        {
+            // There is no entry: put the proposal into the map and return it
+            identifiers[name] = proposal;
+            return proposal;
+        }
+    }
+
+    /**
+        @brief Initializes the Identifier with a list containing all parents of the class the Identifier belongs to.
+        @param parents A list containing all parents
+    */
+    void Identifier::initialize(std::set<const Identifier*>* parents)
+    {
+        COUT(4) << "*** Identifier: Initialize " << this->name_ << "-Singleton." << std::endl;
+        this->bCreatedOneObject_ = true;
+
+        if (parents)
+        {
+            this->parents_ = (*parents);
+            this->directParents_ = (*parents);
+
+            // Iterate through all parents
+            for (std::set<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it)
+            {
+                // Tell the parent we're one of it's children
+                (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);
+
+                // Erase all parents of our parent from our direct-parent-list
+                for (std::set<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1)
+                {
+                    // Search for the parent's parent in our direct-parent-list
+                    for (std::set<const Identifier*>::iterator it2 = this->directParents_.begin(); it2 != this->directParents_.end(); ++it2)
+                    {
+                        if ((*it1) == (*it2))
+                        {
+                            // We've found a non-direct parent in our list: Erase it
+                            this->directParents_.erase(it2);
+                            break;
+                        }
+                    }
+                }
+            }
+
+            // Now iterate through all direct parents
+            for (std::set<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
+            {
+                // Tell the parent we're one of it's direct children
+                (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
+
+                // Create the super-function dependencies
+                (*it)->createSuperFunctionCaller();
+            }
+        }
+    }
+
+    /**
+        @brief Destroys all Identifiers. Called when exiting the program.
+    */
+    void Identifier::destroyAllIdentifiers()
+    {
+        for (std::map<std::string, Identifier*>::iterator it = Identifier::getIdentifierMapIntern().begin(); it != Identifier::getIdentifierMapIntern().end(); ++it)
+            delete (it->second);
+    }
+
+    /**
+        @brief Sets the name of the class.
+        @param name The name
+    */
+    void Identifier::setName(const std::string& name)
+    {
+        if (!this->bSetName_)
+        {
+            this->name_ = name;
+            this->bSetName_ = true;
+            Identifier::getIdentifierMapIntern()[name] = this;
+            Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
+        }
+    }
+
+    /**
+        @brief Creates an object of the type the Identifier belongs to.
+        @return The new object
+    */
+    BaseObject* Identifier::fabricate()
+    {
+        if (this->factory_)
+        {
+            return this->factory_->fabricate(); // We have to return a BaseObject, because we don't know the exact type.
+        }
+        else
+        {
+            COUT(1) << "An error occurred in Identifier.cc:" << std::endl;
+            COUT(1) << "Error: Cannot fabricate an object of type '" << this->name_ << "'. Class has no factory." << std::endl;
+            COUT(1) << "Aborting..." << std::endl;
+            abort();
+            return NULL;
+        }
+    }
+
+    /**
+        @brief Sets the network ID to a new value and changes the entry in the Factory.
+        @param id The new network ID
+    */
+    void Identifier::setNetworkID(unsigned int id)
+    {
+        Factory::changeNetworkID(this, this->classID_, id);
+        this->classID_ = id;
+    }
+
+    /**
+        @brief Returns true, if the Identifier is at least of the given type.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isA(const Identifier* identifier) const
+    {
+        return (identifier == this || (this->parents_.find(identifier) != this->parents_.end()));
+    }
+
+    /**
+        @brief Returns true, if the Identifier is exactly of the given type.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isExactlyA(const Identifier* identifier) const
+    {
+        return (identifier == this);
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a child of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isChildOf(const Identifier* identifier) const
+    {
+        return (this->parents_.find(identifier) != this->parents_.end());
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a direct child of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isDirectChildOf(const Identifier* identifier) const
+    {
+        return (this->directParents_.find(identifier) != this->directParents_.end());
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a parent of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isParentOf(const Identifier* identifier) const
+    {
+        return (this->children_->find(identifier) != this->children_->end());
+    }
+
+    /**
+        @brief Returns true, if the assigned identifier is a direct parent of the given identifier.
+        @param identifier The identifier to compare with
+    */
+    bool Identifier::isDirectParentOf(const Identifier* identifier) const
+    {
+        return (this->directChildren_->find(identifier) != this->directChildren_->end());
+    }
+
+    /**
+        @brief Returns the map that stores all Identifiers.
+        @return The map
+    */
+    std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern()
+    {
+        static std::map<std::string, Identifier*> identifierMap;
+        return identifierMap;
+    }
+
+    /**
+        @brief Returns the map that stores all Identifiers.
+        @return The map
+    */
+    std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern()
+    {
+        static std::map<std::string, Identifier*> lowercaseIdentifierMap;
+        return lowercaseIdentifierMap;
+    }
+
+    /**
+        @brief Adds the ConfigValueContainer of a variable, given by the string of its name.
+        @param varname The name of the variablee
+        @param container The container
+    */
+    void Identifier::addConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
+    {
+        std::map<std::string, ConfigValueContainer*>::const_iterator it = this->configValues_.find(varname);
+        if (it != this->configValues_.end())
+        {
+            COUT(2) << "Warning: Overwriting config-value with name " << varname << " in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->bHasConfigValues_ = true;
+        this->configValues_[varname] = container;
+        this->configValues_LC_[getLowercase(varname)] = container;
+    }
+
+    /**
+        @brief Returns the ConfigValueContainer of a variable, given by the string of its name.
+        @param varname The name of the variable
+        @return The ConfigValueContainer
+    */
+    ConfigValueContainer* Identifier::getConfigValueContainer(const std::string& varname)
+    {
+        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_.find(varname);
+        if (it != configValues_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the ConfigValueContainer of a variable, given by the string of its name in lowercase.
+        @param varname The name of the variable in lowercase
+        @return The ConfigValueContainer
+    */
+    ConfigValueContainer* Identifier::getLowercaseConfigValueContainer(const std::string& varname)
+    {
+        std::map<std::string, ConfigValueContainer*>::const_iterator it = configValues_LC_.find(varname);
+        if (it != configValues_LC_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new console command of this class.
+        @param executor The executor of the command
+        @param bCreateShortcut If this is true a shortcut gets created so you don't have to add the classname to access this command
+        @return The executor of the command
+    */
+    ConsoleCommand& Identifier::addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut)
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(command->getName());
+        if (it != this->consoleCommands_.end())
+        {
+            COUT(2) << "Warning: Overwriting console-command with name " << command->getName() << " in class " << this->getName() << "." << std::endl;
+            delete (it->second);
+        }
+
+        this->bHasConsoleCommands_ = true;
+        this->consoleCommands_[command->getName()] = command;
+        this->consoleCommands_LC_[getLowercase(command->getName())] = command;
+
+        if (bCreateShortcut)
+            CommandExecutor::addConsoleCommandShortcut(command);
+
+        return (*command);
+    }
+
+    /**
+        @brief Returns the executor of a console command with given name.
+        @brief name The name of the requested console command
+        @return The executor of the requested console command
+    */
+    ConsoleCommand* Identifier::getConsoleCommand(const std::string& name) const
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_.find(name);
+        if (it != this->consoleCommands_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns the executor of a console command with given name in lowercase.
+        @brief name The name of the requested console command in lowercae
+        @return The executor of the requested console command
+    */
+    ConsoleCommand* Identifier::getLowercaseConsoleCommand(const std::string& name) const
+    {
+        std::map<std::string, ConsoleCommand*>::const_iterator it = this->consoleCommands_LC_.find(name);
+        if (it != this->consoleCommands_LC_.end())
+            return (*it).second;
+        else
+            return 0;
+    }
+
+    /**
+        @brief Returns a XMLPortParamContainer that loads a parameter of this class.
+        @param paramname The name of the parameter
+        @return The container
+    */
+    XMLPortParamContainer* Identifier::getXMLPortParamContainer(const std::string& paramname)
+    {
+        std::map<std::string, XMLPortParamContainer*>::const_iterator it = xmlportParamContainers_.find(paramname);
+        if (it != xmlportParamContainers_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new XMLPortParamContainer that loads a parameter of this class.
+        @param paramname The name of the parameter
+        @param container The container
+    */
+    void Identifier::addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container)
+    {
+        this->xmlportParamContainers_[paramname] = container;
+    }
+
+    /**
+        @brief Returns a XMLPortObjectContainer that attaches an object to this class.
+        @param sectionname The name of the section that contains the attachable objects
+        @return The container
+    */
+    XMLPortObjectContainer* Identifier::getXMLPortObjectContainer(const std::string& sectionname)
+    {
+        std::map<std::string, XMLPortObjectContainer*>::const_iterator it = xmlportObjectContainers_.find(sectionname);
+        if (it != xmlportObjectContainers_.end())
+            return ((*it).second);
+        else
+            return 0;
+    }
+
+    /**
+        @brief Adds a new XMLPortObjectContainer that attaches an object to this class.
+        @param sectionname The name of the section that contains the attachable objects
+        @param container The container
+    */
+    void Identifier::addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container)
+    {
+        this->xmlportObjectContainers_[sectionname] = container;
+    }
+
+    /**
+        @brief Lists the names of all Identifiers in a std::set<const Identifier*>.
+        @param out The outstream
+        @param list The list (or set) of Identifiers
+        @return The outstream
+    */
+    std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list)
+    {
+        for (std::set<const Identifier*>::const_iterator it = list.begin(); it != list.end(); ++it)
+            out << (*it)->getName() << " ";
+
+        return out;
+    }
+}
Index: /code/branches/ceguilua/src/core/Identifier.h
===================================================================
--- /code/branches/ceguilua/src/core/Identifier.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Identifier.h	(revision 1801)
@@ -0,0 +1,586 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Identifier.h
+    @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes.
+
+    The Identifier contains all needed informations about the class it belongs to:
+     - the name
+     - a list with all objects
+     - parents and children
+     - the factory (if available)
+     - the networkID that can be synchronised with the server
+     - all configurable variables (if available)
+
+    Every object has a pointer to the Identifier of its class. This allows the use isA(...),
+    isExactlyA(...), isChildOf(...) and isParentOf(...).
+
+    To create the class-hierarchy, the Identifier has some intern functions and variables.
+
+    Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier.
+
+    SubclassIdentifier is a separated class, acting like an Identifier, but has a given class.
+    You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier.
+*/
+
+#ifndef _Identifier_H__
+#define _Identifier_H__
+
+#include "CorePrereqs.h"
+
+#include <set>
+#include <map>
+#include <string>
+#include <utility>
+#include <typeinfo>
+#include <stdlib.h>
+
+#include "MetaObjectList.h"
+#include "Iterator.h"
+#include "Super.h"
+#include "util/Debug.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###       Identifier        ###
+    // ###############################
+    //! The Identifier is used to identify the class of an object and to store informations about the class.
+    /**
+        The Identifier contains all needed informations about the class it belongs to:
+         - the name
+         - a list with all objects
+         - parents and children
+         - the factory (if available)
+         - the networkID that can be synchronised with the server
+         - all configurable variables (if available)
+
+        Every object has a pointer to the Identifier of its class. This allows the use isA(...),
+        isExactlyA(...), isChildOf(...) and isParentOf(...).
+
+        You can't directly create an Identifier, it's just the base-class for ClassIdentifier.
+    */
+    class _CoreExport Identifier
+    {
+        template <class T>
+        friend class SubclassIdentifier;
+
+        friend class Factory;
+
+        public:
+            /** @brief Sets the Factory. @param factory The factory to assign */
+            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
+
+            BaseObject* fabricate();
+            bool isA(const Identifier* identifier) const;
+            bool isExactlyA(const Identifier* identifier) const;
+            bool isChildOf(const Identifier* identifier) const;
+            bool isDirectChildOf(const Identifier* identifier) const;
+            bool isParentOf(const Identifier* identifier) const;
+            bool isDirectParentOf(const Identifier* identifier) const;
+
+            /** @brief Returns the list of all existing objects of this class. @return The list */
+            inline ObjectListBase* getObjects() const
+                { return this->objects_; }
+
+            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
+            inline const std::string& getName() const { return this->name_; }
+            void setName(const std::string& name);
+
+            virtual void updateConfigValues(bool updateChildren = true) const = 0;
+
+            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
+            inline const std::set<const Identifier*>& getParents() const { return this->parents_; }
+            /** @brief Returns the begin-iterator of the parents-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getParentsBegin() const { return this->parents_.begin(); }
+            /** @brief Returns the end-iterator of the parents-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }
+
+            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
+            inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); }
+            /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }
+            /** @brief Returns the end-iterator of the children-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }
+
+            /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */
+            inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; }
+            /** @brief Returns the begin-iterator of the direct-parents-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectParentsBegin() const { return this->directParents_.begin(); }
+            /** @brief Returns the end-iterator of the direct-parents-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }
+
+            /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */
+            inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }
+            /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); }
+            /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */
+            inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
+
+
+            /** @brief Returns the map that stores all Identifiers. @return The map */
+            static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); }
+
+            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
+            static inline const std::map<std::string, Identifier*>& getLowercaseIdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
+            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); }
+
+
+            /** @brief Returns the map that stores all config values. @return The const_iterator */
+            inline const std::map<std::string, ConfigValueContainer*>& getConfigValueMap() const { return this->configValues_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all config values. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapBegin() const { return this->configValues_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all config values. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getConfigValueMapEnd() const { return this->configValues_.end(); }
+
+            /** @brief Returns the map that stores all config values with their names in lowercase. @return The const_iterator */
+            inline const std::map<std::string, ConfigValueContainer*>& getLowercaseConfigValueMap() const { return this->configValues_LC_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all config values with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapBegin() const { return this->configValues_LC_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all config values with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
+
+
+            /** @brief Returns the map that stores all console commands. @return The const_iterator */
+            inline const std::map<std::string, ConsoleCommand*>& getConsoleCommandMap() const { return this->consoleCommands_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapBegin() const { return this->consoleCommands_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getConsoleCommandMapEnd() const { return this->consoleCommands_.end(); }
+
+            /** @brief Returns the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            inline const std::map<std::string, ConsoleCommand*>& getLowercaseConsoleCommandMap() const { return this->consoleCommands_LC_; }
+            /** @brief Returns a const_iterator to the beginning of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapBegin() const { return this->consoleCommands_LC_.begin(); }
+            /** @brief Returns a const_iterator to the end of the map that stores all console commands with their names in lowercase. @return The const_iterator */
+            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
+
+
+            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
+            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
+            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
+            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
+
+            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
+            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
+
+            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
+            inline const unsigned int getNetworkID() const { return this->classID_; }
+
+            /** @brief Sets the network ID to a new value. @param id The new value */
+            void setNetworkID(unsigned int id);
+
+            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
+            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
+            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
+
+            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
+            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
+
+            void addXMLPortObjectContainer(const std::string& sectionname, XMLPortObjectContainer* container);
+            XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname);
+
+            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
+            ConsoleCommand* getConsoleCommand(const std::string& name) const;
+            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
+
+        protected:
+            Identifier();
+            Identifier(const Identifier& identifier); // don't copy
+            virtual ~Identifier();
+
+            void initialize(std::set<const Identifier*>* parents);
+            static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal);
+
+            virtual void createSuperFunctionCaller() const = 0;
+
+            /** @brief Returns the map that stores all Identifiers. @return The map */
+            static std::map<std::string, Identifier*>& getIdentifierMapIntern();
+            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
+            static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern();
+
+            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
+            inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
+            /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
+            inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
+
+            bool bCreatedOneObject_;                                       //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
+            ObjectListBase* objects_;                                      //!< The list of all objects of this class
+
+        private:
+            /**
+                @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
+            */
+            inline static void startCreatingHierarchy()
+            {
+                hierarchyCreatingCounter_s++;
+                COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
+            }
+
+            /**
+                @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
+            */
+            inline static void stopCreatingHierarchy()
+            {
+                hierarchyCreatingCounter_s--;
+                COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
+            }
+
+            static void destroyAllIdentifiers();
+
+            std::set<const Identifier*> parents_;                          //!< The parents of the class the Identifier belongs to
+            std::set<const Identifier*>* children_;                        //!< The children of the class the Identifier belongs to
+
+            std::set<const Identifier*> directParents_;                    //!< The direct parents of the class the Identifier belongs to
+            std::set<const Identifier*>* directChildren_;                  //!< The direct children of the class the Identifier belongs to
+
+            bool bSetName_;                                                //!< True if the name is set
+            std::string name_;                                             //!< The name of the class the Identifier belongs to
+            BaseFactory* factory_;                                         //!< The Factory, able to create new objects of the given class (if available)
+            static int hierarchyCreatingCounter_s;                         //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
+            unsigned int classID_;                                         //!< The network ID to identify a class through the network
+
+            bool bHasConfigValues_;                                        //!< True if this class has at least one assigned config value
+            std::map<std::string, ConfigValueContainer*> configValues_;    //!< A map to link the string of configurable variables with their ConfigValueContainer
+            std::map<std::string, ConfigValueContainer*> configValues_LC_; //!< A map to link the string of configurable variables with their ConfigValueContainer
+
+            bool bHasConsoleCommands_;                                     //!< True if this class has at least one assigned console command
+            std::map<std::string, ConsoleCommand*> consoleCommands_;       //!< All console commands of this class
+            std::map<std::string, ConsoleCommand*> consoleCommands_LC_;    //!< All console commands of this class with their names in lowercase
+
+            std::map<std::string, XMLPortParamContainer*> xmlportParamContainers_;     //!< All loadable parameters
+            std::map<std::string, XMLPortObjectContainer*> xmlportObjectContainers_;   //!< All attachable objects
+    };
+
+    _CoreExport std::ostream& operator<<(std::ostream& out, const std::set<const Identifier*>& list);
+
+
+    // ###############################
+    // ###     ClassIdentifier     ###
+    // ###############################
+    //! The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have.
+    /**
+        ClassIdentifier is a Singleton, which means that only one object of a given type T exists.
+        This makes it possible to store informations about a class, sharing them with all
+        objects of that class without defining static variables in every class.
+
+        To be really sure that not more than exactly one object exists (even with libraries),
+        ClassIdentifiers are stored in the Identifier Singleton.
+    */
+    template <class T>
+    class ClassIdentifier : public Identifier
+    {
+        #define SUPER_INTRUSIVE_DECLARATION_INCLUDE
+        #include "Super.h"
+
+        public:
+            static ClassIdentifier<T> *getIdentifier();
+            static ClassIdentifier<T> *getIdentifier(const std::string& name);
+            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
+            static bool isFirstCall();
+            void addObject(T* object);
+
+            void updateConfigValues(bool updateChildren = true) const;
+
+        private:
+            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
+            ClassIdentifier()
+            {
+                SuperFunctionInitialization<0, T>::initialize(this);
+            }
+            ~ClassIdentifier()
+            {
+                SuperFunctionDestruction<0, T>::destroy(this);
+            }
+
+            static ClassIdentifier<T> *classIdentifier_s;
+    };
+
+    template <class T>
+    ClassIdentifier<T> *ClassIdentifier<T>::classIdentifier_s = 0;
+
+    /**
+        @brief Registers a class, which means that the name and the parents get stored.
+        @param parents A list, containing the Identifiers of all parents of the class
+        @param bRootClass True if the class is either an Interface or the BaseObject itself
+    */
+    template <class T>
+    void ClassIdentifier<T>::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass)
+    {
+        // Check if at least one object of the given type was created
+        if (!this->bCreatedOneObject_ && Identifier::isCreatingHierarchy())
+        {
+            // If no: We have to store the informations and initialize the Identifier
+            COUT(4) << "*** ClassIdentifier: Register Class in " << this->getName() << "-Singleton -> Initialize Singleton." << std::endl;
+            if (bRootClass)
+                this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
+            else
+                this->initialize(parents);
+        }
+    }
+
+    /**
+        @brief Returns true if the function gets called the first time, false otherwise.
+        @return True if this function got called the first time.
+    */
+    template <class T>
+    bool ClassIdentifier<T>::isFirstCall()
+    {
+        static bool bFirstCall = true;
+
+        if (bFirstCall)
+        {
+            bFirstCall = false;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+    /**
+        @brief Returns the only instance of this class.
+        @return The unique Identifier
+    */
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
+    {
+        // check if the static field has already been filled
+        if (ClassIdentifier<T>::isFirstCall())
+        {
+            // Get the name of the class
+            std::string name = typeid(T).name();
+
+            // create a new identifier anyway. Will be deleted in Identifier::getIdentifier if not used.
+            ClassIdentifier<T>* proposal = new ClassIdentifier<T>();
+
+            // Get the entry from the map
+            ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)Identifier::getIdentifierSingleton(name, proposal);
+
+            if (ClassIdentifier<T>::classIdentifier_s == proposal)
+            {
+                COUT(4) << "*** Identifier: Requested Identifier for " << name << " was not yet existing and got created." << std::endl;
+            }
+            else
+            {
+                COUT(4) << "*** Identifier: Requested Identifier for " << name << " was already existing and got assigned." << std::endl;
+            }
+        }
+
+        // Finally return the unique ClassIdentifier
+        return ClassIdentifier<T>::classIdentifier_s;
+    }
+
+    /**
+        @brief Does the same as getIdentifier() but sets the name if this wasn't done yet.
+        @param name The name of this Identifier
+        @return The Identifier
+    */
+    template <class T>
+    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier(const std::string& name)
+    {
+        ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
+        identifier->setName(name);
+        return identifier;
+    }
+
+    /**
+        @brief Adds an object of the given type to the ObjectList.
+        @param object The object to add
+    */
+    template <class T>
+    void ClassIdentifier<T>::addObject(T* object)
+    {
+        COUT(5) << "*** ClassIdentifier: Added object to " << this->getName() << "-list." << std::endl;
+        object->getMetaList().add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
+    }
+
+    /**
+        @brief Updates the config-values of all existing objects of this class by calling their setConfigValues() function.
+    */
+    template <class T>
+    void ClassIdentifier<T>::updateConfigValues(bool updateChildren) const
+    {
+        if (!this->hasConfigValues())
+            return;
+
+        for (ObjectListIterator<T> it = ObjectList<T>::begin(); it; ++it)
+            it->setConfigValues();
+
+        if (updateChildren)
+            for (std::set<const Identifier*>::const_iterator it = this->getChildrenBegin(); it != this->getChildrenEnd(); ++it)
+                (*it)->updateConfigValues(false);
+    }
+
+
+    // ###############################
+    // ###   SubclassIdentifier    ###
+    // ###############################
+    //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
+    /**
+        You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>.
+        If you assign something else, the program aborts.
+        Because we know the minimal type, a dynamic_cast is done, which makes it easier to create a new object.
+    */
+    template <class T>
+    class SubclassIdentifier
+    {
+        public:
+            /**
+                @brief Constructor: Automaticaly assigns the Identifier of the given class.
+            */
+            SubclassIdentifier()
+            {
+                this->identifier_ = ClassIdentifier<T>::getIdentifier();
+            }
+
+            /**
+                @brief Copyconstructor: Assigns the given Identifier.
+                @param identifier The Identifier
+            */
+            SubclassIdentifier(Identifier* identifier)
+            {
+                this->identifier_ = identifier;
+            }
+
+            /**
+                @brief Overloading of the = operator: assigns the identifier and checks its type.
+                @param identifier The Identifier to assign
+                @return The SubclassIdentifier itself
+            */
+            SubclassIdentifier<T>& operator=(Identifier* identifier)
+            {
+                if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
+                {
+                    COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+                    COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+                    COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
+                    COUT(1) << "Aborting..." << std::endl;
+                    abort();
+                }
+                this->identifier_ = identifier;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the * operator: returns the assigned identifier.
+                @return The assigned identifier
+            */
+            Identifier* operator*()
+            {
+                return this->identifier_;
+            }
+
+            /**
+                @brief Overloading of the -> operator: returns the assigned identifier.
+                @return The assigned identifier
+            */
+            Identifier* operator->() const
+            {
+                return this->identifier_;
+            }
+
+            /**
+                @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
+                @return The new object
+            */
+            T* fabricate()
+            {
+                BaseObject* newObject = this->identifier_->fabricate();
+
+                // Check if the creation was successful
+                if (newObject)
+                {
+                    // Do a dynamic_cast, because an object of type T is much better than of type BaseObject
+                    return (T*)(newObject);
+                }
+                else
+                {
+                    // Something went terribly wrong
+                    if (this->identifier_)
+                    {
+                        COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
+                        COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
+                        COUT(1) << "Aborting..." << std::endl;
+                    }
+                    else
+                    {
+                        COUT(1) << "An error occurred in SubclassIdentifier (Identifier.h):" << std::endl;
+                        COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;
+                        COUT(1) << "Aborting..." << std::endl;
+                    }
+
+                    abort();
+                }
+            }
+
+            /** @brief Returns the assigned identifier. @return The identifier */
+            inline const Identifier* getIdentifier() const
+                { return this->identifier_; }
+
+            /** @brief Returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
+            inline bool isA(const Identifier* identifier) const
+                { return this->identifier_->isA(identifier); }
+
+            /** @brief Returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
+            inline bool isExactlyA(const Identifier* identifier) const
+                { return this->identifier_->isExactlyA(identifier); }
+
+            /** @brief Returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
+            inline bool isChildOf(const Identifier* identifier) const
+                { return this->identifier_->isChildOf(identifier); }
+
+            /** @brief Returns true, if the assigned identifier is a direct child of the given identifier. @param identifier The identifier to compare with */
+            inline bool isDirectChildOf(const Identifier* identifier) const
+                { return this->identifier_->isDirectChildOf(identifier); }
+
+            /** @brief Returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
+            inline bool isParentOf(const Identifier* identifier) const
+                { return this->identifier_->isParentOf(identifier); }
+
+            /** @brief Returns true, if the assigned identifier is a direct parent of the given identifier. @param identifier The identifier to compare with */
+            inline bool isDirectParentOf(const Identifier* identifier) const
+                { return this->identifier_->isDirectParentOf(identifier); }
+
+        private:
+            Identifier* identifier_;            //!< The assigned identifier
+    };
+}
+
+#endif /* _Identifier_H__ */
Index: /code/branches/ceguilua/src/core/Iterator.h
===================================================================
--- /code/branches/ceguilua/src/core/Iterator.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Iterator.h	(revision 1801)
@@ -0,0 +1,311 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Iterator.h
+    @brief Definition and implementation of the Iterator class.
+
+    The Iterator of a given class allows to iterate through an ObjectList. Objects in
+    this list are casted to the template argument of the Iterator.
+
+    Usage:
+    for (Iterator<myClass> it = anyidentifier->getObjects().begin(); it != anyidentifier->getObjects().end(); ++it)
+    {
+        it->someFunction(...);
+        myClass* myObject = *it;
+    }
+*/
+
+#ifndef _Iterator_H__
+#define _Iterator_H__
+
+#include "CorePrereqs.h"
+
+#include "ObjectListBase.h"
+#include "ObjectListIterator.h"
+#include "OrxonoxClass.h"
+
+namespace orxonox
+{
+    //! The Iterator allows to iterate through a given ObjectList
+    template <class T = OrxonoxClass>
+    class Iterator
+    {
+        public:
+            /**
+                @brief Constructor: Sets the element, whereon the iterator points, to zero.
+            */
+            inline Iterator()
+            {
+                this->element_ = 0;
+                this->list_ = 0;
+            }
+
+            /**
+                @brief Constructor: Sets this element to the exported element.
+                @param exp The exported element
+            */
+            inline Iterator(const ObjectListBase::Export& exp)
+            {
+                this->element_ = exp.element_;
+                this->list_ = exp.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element of another Iterator.
+                @param other The other Iterator
+            */
+            inline Iterator(const Iterator<T>& other)
+            {
+                this->element_ = other.element_;
+                this->list_ = other.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to a given element
+                @param element The element
+            */
+            template <class O>
+            inline Iterator(ObjectListElement<O>* element)
+            {
+                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element an ObjectListIterator.
+                @param other The ObjectListIterator
+            */
+            template <class O>
+            inline Iterator(const ObjectListIterator<O>& other)
+            {
+                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+            }
+
+            /**
+                @brief Unregisters the Iterator from the ObjectList.
+            */
+            inline ~Iterator()
+            {
+                this->list_->unregisterIterator(this->iterator_);
+            }
+
+            /**
+                @brief Assigns an exported element.
+                @param exp The exported element
+            */
+            inline const Iterator<T>& operator=(const ObjectListBase::Export& exp)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = exp.element_;
+                this->list_ = exp.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+            }
+
+            /**
+                @brief Assigns the element of another Iterator.
+                @param other The other Iterator
+            */
+            inline const Iterator<T>& operator=(const Iterator<T>& other)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = other.element_;
+                this->list_ = other.list_;
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+            }
+
+            /**
+                @brief Assigns a given element.
+                @param element The element
+            */
+            template <class O>
+            inline const Iterator<T>& operator=(ObjectListElement<O>* element)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = (element) ? (ObjectListBaseElement*)element : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+                return *this;
+            }
+
+            /**
+                @brief Assigns the element of an ObjectListIterator.
+                @param other The ObjectListIterator
+            */
+            template <class O>
+            inline const Iterator<T>& operator=(const ObjectListIterator<O>& other)
+            {
+                if (this->list_)
+                    this->list_->unregisterIterator(this->iterator_);
+
+                this->element_ = (other.element_) ? (ObjectListBaseElement*)other.element_ : 0;
+                this->list_ = ClassIdentifier<O>::getIdentifier()->getObjects();
+                this->iterator_ = this->list_->registerIterator(this);
+
+                return (*this);
+            }
+
+            /**
+                @brief Overloading of the ++it operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            inline const Iterator<T>& operator++()
+            {
+                if (this->element_)
+                    this->element_ = this->element_->next_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it++ operator: Iterator points to the next object in the list.
+                @return The Iterator itself
+            */
+            inline Iterator<T> operator++(int i)
+            {
+                Iterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = this->element_->next_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the --it operator: Iterator points to the previous object in the list.
+                @return The Iterator itself
+            */
+            inline const Iterator<T>& operator--()
+            {
+                if (this->element_)
+                    this->element_ = this->element_->prev_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it-- operator: Iterator points to the previous object in the list.
+                @return The Iterator itself
+            */
+            inline Iterator<T> operator--(int i)
+            {
+                Iterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = this->element_->prev_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the *it operator: returns the pointer to the object.
+                @return The object the Iterator points at
+            */
+            inline T* operator*() const
+            {
+                if (this->element_)
+                    return dynamic_cast<T*>(this->element_->objectBase_);
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the it-> operator: returns the pointer to the object.
+                @return The object the Iterator points at
+            */
+            inline T* operator->() const
+            {
+                if (this->element_)
+                    return dynamic_cast<T*>(this->element_->objectBase_);
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
+                @return True if the Iterator points to an existing object.
+            */
+            inline operator bool() const
+            {
+                return (this->element_ != 0);
+            }
+
+            /**
+                @brief Overloading of the == operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to the same element
+            */
+            inline bool operator==(const Iterator<T>& compare) const
+            {
+                return (this->element_ == compare.element_);
+            }
+
+            /**
+                @brief Overloading of the != operator to compare with another Iterator.
+                @param compare The other Iterator
+                @return True if the iterators point to different elements
+            */
+            inline bool operator!=(const Iterator<T>& compare) const
+            {
+                return (this->element_ != compare.element_);
+            }
+
+            /**
+                @brief Increments the Iterator if it points at the given object.
+                @param object The object to compare with
+            */
+            inline void incrementIfEqual(OrxonoxClass* object)
+            {
+                if (this->element_ && this->element_->objectBase_ == object)
+                    this->operator++();
+            }
+
+        protected:
+            ObjectListBaseElement* element_;       //!< The element the Iterator points at
+            ObjectListBase* list_;                 //!< The list wherein the element is
+            std::list<void*>::iterator iterator_;  //!< The iterator in the notifying list of the ObjectList
+    };
+
+    typedef Iterator<OrxonoxClass> BaseIterator;
+}
+
+// Include ObjectList.h so the user only has to include one file: Iterator.h
+#include "ObjectList.h"
+
+#endif /* _Iterator_H__ */
Index: /code/branches/ceguilua/src/core/Language.cc
===================================================================
--- /code/branches/ceguilua/src/core/Language.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Language.cc	(revision 1801)
@@ -0,0 +1,330 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Language.cc
+    @brief Implementation of the Language and the LanguageEntry classes.
+*/
+
+#include "Language.h"
+
+#include <fstream>
+
+#include "Core.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###      LanguageEntry      ###
+    // ###############################
+    /**
+        @brief Constructor: Sets the default entry.
+        @param fallbackEntry The default entry
+    */
+    LanguageEntry::LanguageEntry(const std::string& fallbackEntry)
+    {
+        this->fallbackEntry_ = fallbackEntry;
+        this->localisedEntry_ = fallbackEntry; // Set the localisation to the fallback entry, for the case that no translation gets assigned
+        this->bLocalisationSet_ = false;
+    }
+
+    /**
+        @brief Sets the localisation of the entry.
+        @param localisation The localisation
+    */
+    void LanguageEntry::setLocalisation(const std::string& localisation)
+    {
+        // Check if the translation is more than just an empty string
+        if ((localisation != "") && (localisation.size() > 0))
+        {
+            this->localisedEntry_ = localisation;
+            this->bLocalisationSet_ = true;
+        }
+        else
+            this->localisedEntry_ = this->fallbackEntry_;
+    }
+
+    /**
+        @brief Sets the default entry.
+        @param fallbackEntry The default entry
+    */
+    void LanguageEntry::setDefault(const std::string& fallbackEntry)
+    {
+        // If the default entry changes and the translation wasn't set yet, use the new default entry as translation
+        if (!this->bLocalisationSet_)
+            this->localisedEntry_ = fallbackEntry;
+
+        this->fallbackEntry_ = fallbackEntry;
+    }
+
+    // ###############################
+    // ###        Language         ###
+    // ###############################
+    /**
+        @brief Constructor: Reads the default language file and sets some values.
+    */
+    Language::Language()
+    {
+        this->defaultLanguage_ = "default";
+        this->defaultLocalisation_ = "ERROR: LANGUAGE ENTRY DOESN'T EXIST!";
+
+        // Read the default language file to create all known LanguageEntry objects
+        this->readDefaultLanguageFile();
+    }
+
+    /**
+        @brief Destructor: Deletes all language entries.
+    */
+    Language::~Language()
+    {
+        for (std::map<std::string, LanguageEntry*>::iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
+            delete (it->second);
+    }
+
+    /**
+        @brief Returns a reference to the only existing instance of the Language class and calls the setConfigValues() function.
+        @return The reference to the only existing instance
+    */
+    Language& Language::getLanguage()
+    {
+        static Language instance = Language();
+        return instance;
+    }
+
+    /**
+        @brief Creates a new LanguageEntry with a given label and a given default entry.
+        @param label The label of the entry
+        @param entry The default entry
+        @return The created LanguageEntry object
+    */
+    LanguageEntry* Language::createEntry(const LanguageEntryLabel& label, const std::string& entry)
+    {
+        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
+
+        // Make sure we don't create a duplicate entry
+        if (it == this->languageEntries_.end())
+        {
+            LanguageEntry* newEntry = new LanguageEntry(entry);
+            newEntry->setLabel(label);
+            this->languageEntries_[label] = newEntry;
+            return newEntry;
+        }
+
+        COUT(2) << "Warning: Language entry " << label << " is duplicate in " << getFileName(this->defaultLanguage_) << "!" << std::endl;
+        return it->second;
+    }
+
+    /**
+        @brief Adds a new LanguageEntry, if it's not already existing.
+        @param label The label of the entry
+        @param entry The default entry
+    */
+    void Language::addEntry(const LanguageEntryLabel& label, const std::string& entry)
+    {
+        COUT(5) << "Language: Called addEntry with\n  label: " << label << "\n  entry: " <<  entry << std::endl;
+        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
+        if (it == this->languageEntries_.end())
+        {
+            // The entry isn't available yet, meaning it's new, so create it
+            this->createEntry(label, entry);
+        }
+        else if (it->second->getDefault().compare(entry) == 0)
+        {
+            // The entry is available and the default string is the same, so return because everything is fine
+            return;
+        }
+        else
+        {
+            // The defined default entry is not the same as in the default language file - change it to the new entry
+            it->second->setDefault(entry);
+        }
+
+        // Write the default language file because either a new entry was created or an existing entry has changed
+        this->writeDefaultLanguageFile();
+
+    }
+
+    /**
+        @brief Returns the localisation of a given entry.
+        @param label The label of the entry
+        @return The localisation
+    */
+    const std::string& Language::getLocalisation(const LanguageEntryLabel& label) const
+    {
+        std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(label);
+        if (it != this->languageEntries_.end())
+            return it->second->getLocalisation();
+        else
+        {
+            // Uh, oh, an undefined entry was requested: return the default string
+            COUT(2) << "Warning: Language entry \"" << label << "\" not found!" << std::endl;
+            return this->defaultLocalisation_;
+        }
+    }
+
+    /**
+        @brief Creates the name of the language file out of the languages name.
+        @param language The name of the language
+        @return The filename
+    */
+    const std::string Language::getFileName(const std::string& language)
+    {
+        return std::string("translation_" + language + ".lang");
+    }
+
+    /**
+        @brief Reads the default language file and creates a LanguageEntry objects for every entry.
+    */
+    void Language::readDefaultLanguageFile()
+    {
+        COUT(4) << "Read default language file." << std::endl;
+
+        // This creates the file if it's not existing
+        std::ofstream createFile;
+        createFile.open(getFileName(this->defaultLanguage_).c_str(), std::fstream::app);
+        createFile.close();
+
+        // Open the file
+        std::ifstream file;
+        file.open(getFileName(this->defaultLanguage_).c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in Language.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFileName(this->defaultLanguage_) << " to read the default language entries!" << std::endl;
+            return;
+        }
+
+        char line[1024];
+
+        // Iterate through the file and create the LanguageEntries
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            std::string lineString = std::string(line);
+
+            // Check if the line is empty
+            if ((lineString != "") && (lineString.size() > 0))
+            {
+                unsigned int pos = lineString.find('=');
+
+                // Check if the length is at least 3 and if there's an entry before and behind the =
+                if (pos > 0 && pos < (lineString.size() - 1) && lineString.size() >= 3)
+                    this->createEntry(lineString.substr(0, pos), lineString.substr(pos + 1));
+                else
+                {
+                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(this->defaultLanguage_) << std::endl;
+                }
+            }
+        }
+
+        file.close();
+    }
+
+    /**
+        @brief Reads the language file of the configured language and assigns the localisation to the corresponding LanguageEntry object.
+    */
+    void Language::readTranslatedLanguageFile()
+    {
+        COUT(4) << "Read translated language file (" << Core::getLanguage() << ")." << std::endl;
+
+        // Open the file
+        std::ifstream file;
+        file.open(getFileName(Core::getLanguage()).c_str(), std::fstream::in);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in Language.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFileName(Core::getLanguage()) << " to read the translated language entries!" << std::endl;
+            Core::resetLanguage();
+            COUT(3) << "Info: Reset language to " << this->defaultLanguage_ << "." << std::endl;
+            return;
+        }
+
+        char line[1024];
+
+        // Iterate through the file and create the LanguageEntries
+        while (file.good() && !file.eof())
+        {
+            file.getline(line, 1024);
+            std::string lineString = std::string(line);
+
+            // Check if the line is empty
+            if ((lineString != "") && (lineString.size() > 0))
+            {
+                unsigned int pos = lineString.find('=');
+
+                // Check if the length is at least 3 and if there's an entry before and behind the =
+                if (pos > 0 && pos < (lineString.size() - 1) && lineString.size() >= 3)
+                {
+                    std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.find(lineString.substr(0, pos));
+
+                    // Check if the entry exists
+                    if (it != this->languageEntries_.end())
+                        it->second->setLocalisation(lineString.substr(pos + 1));
+                    else
+                        this->createEntry(lineString.substr(0, pos), this->defaultLocalisation_)->setLocalisation(lineString.substr(pos + 1));
+                }
+                else
+                {
+                    COUT(2) << "Warning: Invalid language entry \"" << lineString << "\" in " << getFileName(Core::getLanguage()) << std::endl;
+                }
+            }
+        }
+
+        file.close();
+    }
+
+    /**
+        @brief Writes all default entries to the default language file.
+    */
+    void Language::writeDefaultLanguageFile() const
+    {
+        COUT(4) << "Language: Write default language file." << std::endl;
+
+        // Open the file
+        std::ofstream file;
+        file.open(getFileName(this->defaultLanguage_).c_str(), std::fstream::out);
+
+        if (!file.is_open())
+        {
+            COUT(1) << "An error occurred in Language.cc:" << std::endl;
+            COUT(1) << "Error: Couldn't open file " << getFileName(this->defaultLanguage_) << " to write the default language entries!" << std::endl;
+            return;
+        }
+
+        // Iterate through the list an write the lines into the file
+        for (std::map<std::string, LanguageEntry*>::const_iterator it = this->languageEntries_.begin(); it != this->languageEntries_.end(); ++it)
+        {
+            file << (*it).second->getLabel() << "=" << (*it).second->getDefault() << std::endl;
+        }
+
+        file.close();
+    }
+}
Index: /code/branches/ceguilua/src/core/Language.h
===================================================================
--- /code/branches/ceguilua/src/core/Language.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Language.h	(revision 1801)
@@ -0,0 +1,139 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Language.h
+    @brief Definition of the Language and the LanguageEntry class.
+
+    The Language class is used, to get a localisation of a string in the configured language.
+    The string is identified by another string, the label of the entry.
+    If the translation in the configured language isn't available, the default entry, defined in the code, is used.
+
+    Usage:
+     - Set the entry with the default string:
+       Language::getLanguage()->addEntry("label of the entry", "the string to translate");
+
+     - Get the localisation of the entry in the configured language:
+       std::cout << Language::getLanguage()->getLocalisation("name of the entry") << std::endl;
+*/
+
+#ifndef _Language_H__
+#define _Language_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include <string>
+
+#define AddLanguageEntry(label, fallbackstring) \
+    orxonox::Language::getLanguage().addEntry(label, fallbackstring)
+
+#define GetLocalisation(label) \
+    orxonox::Language::getLanguage().getLocalisation(label)
+
+
+namespace orxonox
+{
+    // ###############################
+    // ###      LanguageEntry      ###
+    // ###############################
+    //! The LanguageEntry class stores the default- and the translated string of a given entry in the language file.
+    class _CoreExport LanguageEntry
+    {
+        public:
+            explicit LanguageEntry(const std::string& fallbackEntry);
+            void setLocalisation(const std::string& localisation);
+            void setDefault(const std::string& fallbackEntry);
+
+            /**
+              @brief Returns the localised entry in the configured language.
+              @return The translated entry
+            */
+            inline const std::string& getLocalisation()
+                { return this->localisedEntry_; }
+
+            /**
+              @brief Returns the default entry.
+              @return The default entry
+            */
+            inline const std::string& getDefault()
+                { return this->fallbackEntry_; }
+
+            /**
+                @brief Sets the label of this entry.
+                @param label The label
+            */
+            inline void setLabel(const LanguageEntryLabel& label)
+                { this->label_ = label; }
+
+            /**
+                @brief Returns the label of this entry.
+                @return The label
+            */
+            inline const LanguageEntryLabel& getLabel() const
+                { return this->label_; }
+
+        private:
+            LanguageEntryLabel label_;              //!< The label of the entry
+            std::string fallbackEntry_;             //!< The default entry: Used, if no translation is available or no language configured
+            std::string localisedEntry_;            //!< The localised entry in the configured language
+            bool bLocalisationSet_;                 //!< True if the translation was set
+    };
+
+
+    // ###############################
+    // ###         Language        ###
+    // ###############################
+    //! The Language class manges the language files and entries and stores the LanguageEntry objects in a map.
+    class _CoreExport Language
+    {
+        friend class Core;
+
+        public:
+            static Language& getLanguage();
+            void addEntry(const LanguageEntryLabel& label, const std::string& entry);
+            const std::string& getLocalisation(const LanguageEntryLabel& label) const;
+
+        private:
+            Language();
+            Language(const Language& language);     // don't copy
+            virtual ~Language();
+
+            void readDefaultLanguageFile();
+            void readTranslatedLanguageFile();
+            void writeDefaultLanguageFile() const;
+            static const std::string getFileName(const std::string& language);
+            LanguageEntry* createEntry(const LanguageEntryLabel& label, const std::string& entry);
+
+            std::string defaultLanguage_;                           //!< The default language
+            std::string defaultLocalisation_;                       //!< The returned string, if an entry unavailable entry is requested
+            std::map<std::string, LanguageEntry*> languageEntries_; //!< A map to store all LanguageEntry objects and their labels
+    };
+}
+
+#endif /* _Language_H__ */
Index: /code/branches/ceguilua/src/core/Level.h
===================================================================
--- /code/branches/ceguilua/src/core/Level.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Level.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Level_H__
+#define _Level_H__
+
+#include "CorePrereqs.h"
+
+#include <string>
+
+#include "ClassTreeMask.h"
+
+namespace orxonox
+{
+    class _CoreExport Level
+    {
+        public:
+            Level(const std::string& file) : file_(file) {}
+            Level(const std::string& file, const ClassTreeMask& mask) : file_(file), mask_(mask) {};
+
+            const std::string& getFile() const { return this->file_; }
+            const ClassTreeMask& getMask() const { return this->mask_; }
+
+        private:
+            std::string file_;
+            ClassTreeMask mask_;
+    };
+}
+
+#endif /* _Level_H__ */
Index: /code/branches/ceguilua/src/core/Loader.cc
===================================================================
--- /code/branches/ceguilua/src/core/Loader.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Loader.cc	(revision 1801)
@@ -0,0 +1,191 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Loader.h"
+#include "Level.h"
+#include "BaseObject.h"
+#include "Identifier.h"
+#include "Iterator.h"
+#include "ObjectList.h"
+#include "CoreIncludes.h"
+#include "Script.h"
+#include "Namespace.h"
+#include "util/Debug.h"
+
+#include "tinyxml/ticpp.h"
+
+namespace orxonox
+{
+    std::vector<std::pair<const Level*, ClassTreeMask> > Loader::levels_s;
+    ClassTreeMask Loader::currentMask_s;
+
+    bool Loader::open(const Level* level, const ClassTreeMask& mask)
+    {
+        Loader::add(level, mask);
+        return Loader::load(level, mask);
+    }
+
+    void Loader::close()
+    {
+        Loader::unload();
+        Loader::levels_s.clear();
+    }
+
+    void Loader::close(const Level* level)
+    {
+        Loader::unload(level);
+        Loader::remove(level);
+    }
+
+    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));
+    }
+
+    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)
+        {
+            if ((*it).first == level)
+            {
+                Loader::levels_s.erase(it);
+                break;
+            }
+        }
+    }
+
+    bool Loader::load(const ClassTreeMask& mask)
+    {
+        bool success = true;
+        for (std::vector<std::pair<const Level*, ClassTreeMask> >::iterator it = Loader::levels_s.begin(); it != Loader::levels_s.end(); ++it)
+            if (!Loader::load((*it).first, (*it).second * mask))
+                success = false;
+
+        return success;
+    }
+
+    void Loader::unload(const ClassTreeMask& mask)
+    {
+        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it != ObjectList<BaseObject>::end(); )
+        {
+            if (mask.isIncluded(it->getIdentifier()))
+                delete (*(it++));
+            else
+                ++it;
+        }
+    }
+
+    bool Loader::reload(const ClassTreeMask& mask)
+    {
+        Loader::unload(mask);
+        return Loader::load(mask);
+    }
+
+    bool Loader::load(const Level* level, const ClassTreeMask& mask)
+    {
+        if (!level)
+            return false;
+
+        Loader::currentMask_s = level->getMask() * mask;
+
+        // let Lua work this out:
+        //Script* lua;
+        /*Script::loadFile(level->getFile(), true);
+        Script::init(Script::getLuaState());
+        Script::run();*/
+        Script* lua = Script::getInstance();
+        lua->clearLuaOutput();
+        lua->loadFile(level->getFile(), true);
+        lua->run();
+
+        try
+        {
+            COUT(0) << "Start loading " << level->getFile() << "..." << std::endl;
+            COUT(3) << "Mask: " << Loader::currentMask_s << std::endl;
+
+            //ticpp::Document xmlfile(level->getFile());
+            //xmlfile.LoadFile();
+            //ticpp::Element myelement(*Script::getFileString());
+            ticpp::Document xmlfile;
+            //xmlfile.ToDocument();
+            xmlfile.Parse(lua->getLuaOutput(), true);
+
+            ticpp::Element rootElement;
+            rootElement.SetAttribute("name", "root");
+            rootElement.SetAttribute("bAutogenerated", true);
+
+            for (ticpp::Iterator<ticpp::Element> child = xmlfile.FirstChildElement(false); child != child.end(); child++)
+                rootElement.InsertEndChild(*child);
+
+            COUT(4) << "  creating root-namespace..." << std::endl;
+            Namespace* rootNamespace = new Namespace();
+            rootNamespace->setLoaderIndentation("    ");
+            rootNamespace->setLevel(level);
+            rootNamespace->setNamespace(rootNamespace);
+            rootNamespace->setRoot(true);
+            rootNamespace->XMLPort(rootElement, XMLPort::LoadObject);
+
+            COUT(0) << "Finished loading " << level->getFile() << "." << std::endl;
+
+            COUT(4) << "Namespace-tree:" << std::endl << rootNamespace->toString("  ") << std::endl;
+
+            return true;
+        }
+        catch(ticpp::Exception& ex)
+        {
+            COUT(1) << std::endl;
+            COUT(1) << "An error occurred in Loader.cc while loading " << level->getFile() << ":" << std::endl;
+            COUT(1) << ex.what() << std::endl;
+            COUT(1) << "Loading aborted." << std::endl;
+            return false;
+        }
+    }
+
+    void Loader::unload(const Level* level, const ClassTreeMask& mask)
+    {
+        if (!level)
+            return;
+        for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(); it; )
+        {
+            if ((it->getLevel() == level) && mask.isIncluded(it->getIdentifier()))
+                delete (*(it++));
+            else
+                ++it;
+        }
+    }
+
+    bool Loader::reload(const Level* level, const ClassTreeMask& mask)
+    {
+        Loader::unload(level, mask);
+        return Loader::load(level, mask);
+    }
+}
Index: /code/branches/ceguilua/src/core/Loader.h
===================================================================
--- /code/branches/ceguilua/src/core/Loader.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Loader.h	(revision 1801)
@@ -0,0 +1,66 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Loader_H__
+#define _Loader_H__
+
+#include "CorePrereqs.h"
+
+#include <vector>
+
+#include "ClassTreeMask.h"
+#include "Level.h"
+
+namespace orxonox
+{
+    class _CoreExport Loader
+    {
+        public:
+            static bool open(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
+            static void close();
+            static void close(const Level* level);
+
+            static void add(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
+            static void remove(const Level* level);
+
+            static bool load(const ClassTreeMask& mask = ClassTreeMask());
+            static void unload(const ClassTreeMask& mask = ClassTreeMask());
+            static bool reload(const ClassTreeMask& mask = ClassTreeMask());
+
+            static bool load(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
+            static void unload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
+            static bool reload(const Level* level, const ClassTreeMask& mask = ClassTreeMask());
+
+            static ClassTreeMask currentMask_s;
+
+        private:
+            static std::vector<std::pair<const Level*, ClassTreeMask> > levels_s;
+    };
+}
+
+#endif /* _Loader_H__ */
Index: /code/branches/ceguilua/src/core/MetaObjectList.cc
===================================================================
--- /code/branches/ceguilua/src/core/MetaObjectList.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/MetaObjectList.cc	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MetaObjectList.cc
+    @brief Implementation of the MetaObjectList class.
+*/
+
+#include "MetaObjectList.h"
+#include "ObjectListBase.h"
+#include "Identifier.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  MetaObjectListElement  ###
+    // ###############################
+    /**
+        @brief Destructor: Removes the ObjectListBaseElement from the ObjectListBase by linking next_ and prev_ of the ObjectListBaseElement.
+    */
+    MetaObjectListElement::~MetaObjectListElement()
+    {
+        COUT(5) << "*** MetaObjectList: Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << std::endl;
+        this->list_->notifyIterators(this->element_->objectBase_);
+
+        if (this->element_->next_)
+            this->element_->next_->prev_ = this->element_->prev_;
+        else
+            this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
+
+        if (this->element_->prev_)
+            this->element_->prev_->next_ = this->element_->next_;
+        else
+            this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
+
+        delete this->element_;
+    }
+
+
+    // ###############################
+    // ###     MetaObjectList      ###
+    // ###############################
+    /**
+        @brief Constructor: Sets first_ to zero.
+    */
+    MetaObjectList::MetaObjectList()
+    {
+        this->first_ = 0;
+    }
+
+    /**
+        @brief Destructor: Removes all elements from the list, causing them to remove the stored ObjectListElement from the ObjectList.
+    */
+    MetaObjectList::~MetaObjectList()
+    {
+        MetaObjectListElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
+    }
+
+    /**
+        @brief Adds an ObjectList and an element of that list to the MetaObjectList.
+        @param list The ObjectList wherein the element is
+        @param element The element wherein the object is
+    */
+    void MetaObjectList::add(ObjectListBase* list, ObjectListBaseElement* element)
+    {
+        MetaObjectListElement* temp = this->first_;
+        this->first_ = new MetaObjectListElement(list, element);
+        this->first_->next_ = temp;
+    }
+}
Index: /code/branches/ceguilua/src/core/MetaObjectList.h
===================================================================
--- /code/branches/ceguilua/src/core/MetaObjectList.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/MetaObjectList.h	(revision 1801)
@@ -0,0 +1,84 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MetaObjectList.h
+    @brief Definition of the MetaObjectList class.
+
+    The MetaObjectList is a single-linked list, containing all list-elements and their
+    lists wherein the object, owning the MetaObjectList, is registered.
+    This allows much faster deletion of objects because no iteration is needed.
+*/
+
+#ifndef _MetaObjectList_H__
+#define _MetaObjectList_H__
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  MetaObjectListElement  ###
+    // ###############################
+    //! The list-element of the MetaObjectList
+    class _CoreExport MetaObjectListElement
+    {
+        public:
+            /**
+                @brief Constructor: Creates the list-element with given list and element.
+            */
+            MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {}
+            ~MetaObjectListElement();
+
+            MetaObjectListElement* next_;       //!< The next Element in the list
+            ObjectListBaseElement* element_;    //!< The list element, containing the object
+            ObjectListBase* list_;              //!< The list, containing the element
+    };
+
+
+    // ###############################
+    // ###     MetaObjectList      ###
+    // ###############################
+    //!  The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.
+    /**
+        The MetaObjectList is a single-linked list, containing all list-elements and their
+        lists wherein the object that owns the MetaObjectList is registered.
+        This allows much faster deletion of objects because no iteration is needed.
+    */
+    class _CoreExport MetaObjectList
+    {
+        public:
+            MetaObjectList();
+            ~MetaObjectList();
+            void add(ObjectListBase* list, ObjectListBaseElement* element);
+
+            MetaObjectListElement* first_;      //!< The first element in the list
+    };
+}
+
+#endif /* _MetaObjectList_H__ */
Index: /code/branches/ceguilua/src/core/Namespace.cc
===================================================================
--- /code/branches/ceguilua/src/core/Namespace.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Namespace.cc	(revision 1801)
@@ -0,0 +1,179 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Namespace.h"
+#include "NamespaceNode.h"
+#include "CoreIncludes.h"
+#include "XMLPort.h"
+#include "util/SubString.h"
+
+namespace orxonox
+{
+    CreateFactory(Namespace);
+
+    Namespace::Namespace() :
+      bAutogeneratedFileRootNamespace_(false),
+      bRoot_(false),
+      operator_("or")
+    {
+        RegisterObject(Namespace);
+    }
+
+    Namespace::~Namespace()
+    {
+        if (this->bRoot_)
+            for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
+                delete (*it);
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void Namespace::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Namespace, XMLPort, xmlelement, mode);
+
+        std::string name = this->getName();
+        unsigned int pos = 0;
+        while ((pos = name.find(',')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        while ((pos = name.find(';')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        while ((pos = name.find('\n')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        while ((pos = name.find('\t')) != std::string::npos)
+            name.replace(pos, 1, " ");
+        SubString tokens(name, " ", "", false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (this->bRoot_)
+        {
+            this->representingNamespaces_.insert(new NamespaceNode(this->getName()));
+        }
+        else
+        {
+            for (unsigned int i = 0; i < tokens.size(); i++)
+            {
+                for (std::set<NamespaceNode*>::iterator it = this->getNamespace()->representingNamespaces_.begin(); it != this->getNamespace()->representingNamespaces_.end(); ++it)
+                {
+                    std::set<NamespaceNode*> temp = (*it)->getNodeRelative(tokens[i]);
+                    this->representingNamespaces_.insert(temp.begin(), temp.end());
+                }
+            }
+        }
+
+        XMLPortParam(Namespace, "operator", setOperator, getOperator, xmlelement, mode);
+        XMLPortParam(Namespace, "bAutogenerated", setAutogenerated, isAutogenerated, xmlelement, mode);
+
+        if (this->bAutogeneratedFileRootNamespace_)
+        {
+            for (std::set<NamespaceNode*>::iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); ++it)
+            {
+                (*it)->setRoot(true);
+                (*it)->setHidden(true);
+            }
+        }
+
+        XMLPortObject(Namespace, BaseObject, "", loadObjects, saveObjects, xmlelement, mode, true, false);
+    }
+
+    void Namespace::loadObjects(BaseObject* object)
+    {
+        object->setNamespace(this);
+    }
+
+    const BaseObject* Namespace::saveObjects(unsigned int index) const
+    {
+        return 0; // todo
+    }
+
+    bool Namespace::includes(const Namespace* ns) const
+    {
+        for (std::set<NamespaceNode*>::const_iterator it1 = this->representingNamespaces_.begin(); it1 != this->representingNamespaces_.end(); ++it1)
+        {
+            for (std::set<NamespaceNode*>::const_iterator it2 = ns->representingNamespaces_.begin(); it2 != ns->representingNamespaces_.end(); ++it2)
+            {
+                if ((*it1)->includes(*it2))
+                {
+                    if (this->operator_ == "or")
+                        return true;
+
+                    if (this->operator_ == "not")
+                        return false;
+                }
+                else
+                {
+                    if (this->operator_ == "and")
+                        return false;
+                }
+            }
+        }
+
+        if (this->operator_ == "or")
+            return false;
+        else if (this->operator_ == "and")
+            return true;
+        else if (this->operator_ == "not")
+            return true;
+
+        return false;
+    }
+
+    std::string Namespace::toString() const
+    {
+        std::string output;
+
+        int i = 0;
+        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+        {
+            if (i > 0)
+                output += " / ";
+
+            output += (*it)->toString();
+        }
+
+        return output;
+    }
+
+    std::string Namespace::toString(const std::string& indentation) const
+    {
+        std::string output;
+
+        int i = 0;
+        for (std::set<NamespaceNode*>::const_iterator it = this->representingNamespaces_.begin(); it != this->representingNamespaces_.end(); i++, ++it)
+        {
+            if (i > 0)
+                output += "\n";
+
+            output += (*it)->toString(indentation);
+        }
+
+        return output;
+    }
+}
Index: /code/branches/ceguilua/src/core/Namespace.h
===================================================================
--- /code/branches/ceguilua/src/core/Namespace.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Namespace.h	(revision 1801)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Namespace_H__
+#define _Namespace_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+
+#include "util/XMLIncludes.h"
+#include "BaseObject.h"
+
+namespace orxonox
+{
+    class Namespace : public BaseObject
+    {
+        public:
+            Namespace();
+            virtual ~Namespace();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+
+            void loadObjects(BaseObject* object);
+            const BaseObject* saveObjects(unsigned int index) const;
+
+            void setAutogenerated(bool bAutogenerated)
+                { this->bAutogeneratedFileRootNamespace_ = bAutogenerated; }
+            bool isAutogenerated() const
+                { return this->bAutogeneratedFileRootNamespace_; }
+
+            void setOperator(const std::string& op)
+                { this->operator_ = op; }
+            const std::string& getOperator() const
+                { return this->operator_; }
+
+            void setRoot(bool bRoot)
+                { this->bRoot_ = bRoot; }
+
+            bool includes(const Namespace* ns) const;
+            bool isIncludedIn(const Namespace* ns) const { return ns->includes(this); }
+
+            std::string toString() const;
+            std::string toString(const std::string& indentation) const;
+
+        private:
+            std::set<NamespaceNode*> representingNamespaces_;
+            bool bAutogeneratedFileRootNamespace_;
+            bool bRoot_;
+            std::string operator_;
+    };
+}
+
+#endif /* _Namespace_H__ */
Index: /code/branches/ceguilua/src/core/NamespaceNode.cc
===================================================================
--- /code/branches/ceguilua/src/core/NamespaceNode.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/NamespaceNode.cc	(revision 1801)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "NamespaceNode.h"
+#include "util/Debug.h"
+
+namespace orxonox
+{
+    NamespaceNode::NamespaceNode(const std::string& name, NamespaceNode* parent)
+    {
+        this->name_ = name;
+        this->parent_ = parent;
+        this->bRoot_ = false;
+        this->bHidden_ = false;
+    }
+
+    NamespaceNode::~NamespaceNode()
+    {
+        for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); )
+            delete ((*(it++)).second);
+    }
+
+    std::set<NamespaceNode*> NamespaceNode::getNodeRelative(const std::string& name)
+    {
+        std::set<NamespaceNode*> nodes;
+
+        if ((name.size() == 0) || (name == ""))
+        {
+            nodes.insert(this);
+        }
+        else
+        {
+            unsigned int pos = name.find("::");
+            std::string firstPart = name;
+            std::string secondPart;
+
+            if (pos != std::string::npos)
+            {
+                firstPart = name.substr(0, pos);
+                secondPart = name.substr(pos + 2, std::string::npos);
+            }
+
+            if (firstPart == "..")
+            {
+                if (this->bRoot_)
+                {
+                    COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", namespace is root." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+                else if (!this->parent_)
+                {
+                    COUT(2) << "Warning: Can't go to enclosing namespace with '..' operator in namespace " << this->name_ << ", no parent namespace set." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+                else
+                {
+                    nodes = this->parent_->getNodeRelative(secondPart);
+                }
+            }
+            else if (name.find('@') != 0)
+            {
+                std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.find(firstPart);
+                if (it == this->subnodes_.end())
+                    it = this->subnodes_.insert(this->subnodes_.begin(), std::pair<std::string, NamespaceNode*>(firstPart, new NamespaceNode(firstPart, this)));
+
+                if ((*it).second->isHidden())
+                {
+                    COUT(2) << "Warning: Subnamespace '" << firstPart << "' in namespace '" << this->name_ << "' is hidden and can't be accessed." << std::endl;
+                    nodes.insert(this);
+                }
+                else
+                {
+                    nodes = (*it).second->getNodeRelative(secondPart);
+                }
+            }
+            else
+            {
+                bool bFoundMatchingNamespace = false;
+
+                for (std::map<std::string, NamespaceNode*>::iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+                {
+                    if ((*it).first.find(firstPart) == ((*it).first.size() - firstPart.size()))
+                    {
+                        std::set<NamespaceNode*> temp2 = (*it).second->getNodeRelative(secondPart);
+                        nodes.insert(temp2.begin(), temp2.end());
+                        bFoundMatchingNamespace = true;
+                    }
+                }
+
+                if (!bFoundMatchingNamespace)
+                {
+                    COUT(2) << "Warning: No file included with name '" << firstPart.substr(1, std::string::npos) << "' at this part of the level file, using parent namespace instead." << std::endl;
+                    nodes = this->getNodeRelative(secondPart);
+                }
+            }
+        }
+
+        return nodes;
+    }
+
+    bool NamespaceNode::includes(const NamespaceNode* ns) const
+    {
+        if (ns == this)
+        {
+            return true;
+        }
+        else
+        {
+            for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+                if ((*it).second->includes(ns))
+                    return true;
+        }
+
+        return false;
+    }
+
+    std::string NamespaceNode::toString() const
+    {
+        std::string output = this->name_;
+
+        if (this->subnodes_.size() > 0)
+        {
+            output += " (";
+
+            int i = 0;
+            for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); i++, ++it)
+            {
+                if (i > 0)
+                    output += ", ";
+
+                output += (*it).second->toString();
+            }
+
+            output += ")";
+        }
+
+        return output;
+    }
+
+    std::string NamespaceNode::toString(const std::string& indentation) const
+    {
+        std::string output = (indentation + this->name_ + "\n");
+
+        for (std::map<std::string, NamespaceNode*>::const_iterator it = this->subnodes_.begin(); it != this->subnodes_.end(); ++it)
+            output += (*it).second->toString(indentation + "  ");
+
+        return output;
+    }
+}
Index: /code/branches/ceguilua/src/core/NamespaceNode.h
===================================================================
--- /code/branches/ceguilua/src/core/NamespaceNode.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/NamespaceNode.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _NamespaceNode_H__
+#define _NamespaceNode_H__
+
+#include "CorePrereqs.h"
+
+#include <map>
+#include <set>
+#include <string>
+
+namespace orxonox
+{
+    class NamespaceNode
+    {
+        public:
+            NamespaceNode(const std::string& name, NamespaceNode* parent = 0);
+            ~NamespaceNode();
+
+            std::set<NamespaceNode*> getNodeRelative(const std::string& name);
+
+            void setRoot(bool bRoot) { this->bRoot_ = bRoot; }
+            void setHidden(bool bHidden) { this->bHidden_ = bHidden; }
+
+            bool isRoot() const { return this->bRoot_; }
+            bool isHidden() const { return this->bHidden_; }
+
+            bool includes(const NamespaceNode*) const;
+
+            std::string toString() const;
+            std::string toString(const std::string& indentation) const;
+
+        private:
+            std::string name_;
+            NamespaceNode* parent_;
+            std::map<std::string, NamespaceNode*> subnodes_;
+            bool bHidden_;
+            bool bRoot_;
+    };
+}
+
+#endif /* _NamespaceNode_H__ */
Index: /code/branches/ceguilua/src/core/ObjectList.h
===================================================================
--- /code/branches/ceguilua/src/core/ObjectList.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ObjectList.h	(revision 1801)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ObjectList.h
+    @brief Definition and implementation of the ObjectList class.
+
+    The ObjectList is a wrapper of an ObjectListBase of a given class.
+    Use Iterator<class> to iterate through all objects of the class.
+*/
+
+#ifndef _ObjectList_H__
+#define _ObjectList_H__
+
+#include "CorePrereqs.h"
+
+#include "Identifier.h"
+#include "ObjectListIterator.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###       ObjectList        ###
+    // ###############################
+    //! The ObjectList contains all objects of the given class.
+    /**
+        Wraps the ObjectListBase of the corresponding Identifier.
+        Use ObjectListIterator<class> to iterate through all objects in the list.
+    */
+    template <class T>
+    class ObjectList
+    {
+        public:
+            typedef ObjectListIterator<T> iterator;
+
+            /** @brief Returns an Iterator to the first element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* begin()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->begin().element_); }
+
+            /** @brief Returns an Iterator to the element after the last element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* end()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->end().element_); }
+
+            /** @brief Returns an Iterator to the last element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* rbegin()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rbegin().element_); }
+
+            /** @brief Returns an Iterator to the element before the first element in the list. @return The Iterator */
+            inline static ObjectListElement<T>* rend()
+                { return ((ObjectListElement<T>*)ClassIdentifier<T>::getIdentifier()->getObjects()->rend().element_); }
+    };
+}
+
+#endif /* _ObjectList_H__ */
Index: /code/branches/ceguilua/src/core/ObjectListBase.cc
===================================================================
--- /code/branches/ceguilua/src/core/ObjectListBase.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/ObjectListBase.cc	(revision 1801)
@@ -0,0 +1,107 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ObjectListBase.cc
+    @brief Implementation of the ObjectListBase class.
+
+    The ObjectListBase is a double-linked list, used by Identifiers to store all objects of a given class.
+    Newly created objects are added through the RegisterObject-macro in its constructor.
+*/
+
+#include <set>
+
+#include "CorePrereqs.h"
+
+#include "ObjectListBase.h"
+#include "Identifier.h"
+#include "Iterator.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Sets default values.
+    */
+    ObjectListBase::ObjectListBase(Identifier* identifier)
+    {
+        this->identifier_ = identifier;
+        this->first_ = 0;
+        this->last_ = 0;
+    }
+
+    /**
+        @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
+    */
+    ObjectListBase::~ObjectListBase()
+    {
+        ObjectListBaseElement* temp;
+        while (this->first_)
+        {
+            temp = this->first_->next_;
+            delete this->first_;
+            this->first_ = temp;
+        }
+    }
+
+    /**
+        @brief Increases all Iterators that currently point on the given element (because it gets removed).
+        @param element The element that gets removed
+    */
+    void ObjectListBase::notifyIterators(OrxonoxClass* object) const
+    {
+        for (std::list<void*>::const_iterator it = this->iterators_.begin(); it != this->iterators_.end(); ++it)
+            ((Iterator<OrxonoxClass>*)(*it))->incrementIfEqual(object);
+        for (std::list<void*>::const_iterator it = this->objectListIterators_.begin(); it != this->objectListIterators_.end(); ++it)
+            ((ObjectListIterator<OrxonoxClass>*)(*it))->incrementIfEqual(object);
+    }
+
+    /**
+        @brief Adds a new object to the end of the list.
+        @param object The object to add
+        @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
+    */
+    ObjectListBaseElement* ObjectListBase::add(ObjectListBaseElement* element)
+    {
+        if (!this->last_)
+        {
+            // If the list is empty
+            this->last_ = element;
+            this->first_ = this->last_; // There's only one object in the list now
+        }
+        else
+        {
+            // If the list isn't empty
+            ObjectListBaseElement* temp = this->last_;
+            this->last_ = element;
+            this->last_->prev_ = temp;
+            temp->next_ = this->last_;
+        }
+
+        return this->last_;
+    }
+}
Index: /code/branches/ceguilua/src/core/ObjectListBase.h
===================================================================
--- /code/branches/ceguilua/src/core/ObjectListBase.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ObjectListBase.h	(revision 1801)
@@ -0,0 +1,129 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file ObjectListBase.h
+    @brief Definition of the ObjectListBase class.
+
+    The ObjectListBase is a double-linked list, used by Identifiers to store all objects of a given class.
+    Newly created objects are added through the RegisterObject-macro in its constructor.
+*/
+
+#ifndef _ObjectListBase_H__
+#define _ObjectListBase_H__
+
+#include <list>
+
+#include "CorePrereqs.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  ObjectListBaseElement  ###
+    // ###############################
+    //! The list-element of the ObjectListBase
+    class _CoreExport ObjectListBaseElement
+    {
+        public:
+            /**
+                @brief Constructor: Creates the list-element with an object.
+                @param object The object to store
+            */
+            ObjectListBaseElement(OrxonoxClass* objectBase) : next_(0), prev_(0), objectBase_(objectBase) {}
+
+            ObjectListBaseElement* next_;       //!< The next element in the list
+            ObjectListBaseElement* prev_;       //!< The previous element in the list
+            OrxonoxClass* objectBase_;
+    };
+
+
+    // ###############################
+    // ###    ObjectListElement    ###
+    // ###############################
+    //! The list-element that actually contains the object
+    template <class T>
+    class ObjectListElement : public ObjectListBaseElement
+    {
+        public:
+            ObjectListElement(T* object) : ObjectListBaseElement(object), object_(object) {}
+            T* object_;              //!< The object
+    };
+
+
+    // ###############################
+    // ###     ObjectListBase      ###
+    // ###############################
+    //! The ObjectListBase contains all objects of a given class.
+    /**
+        The ObjectListBase is used by Identifiers to store all objects of their given class.
+        Use ObjectList<T> to get the list of all T's and Iterator<T> to iterate through them.
+    */
+    class _CoreExport ObjectListBase
+    {
+        friend class MetaObjectListElement;
+
+        public:
+            ObjectListBase(Identifier* identifier);
+            ~ObjectListBase();
+
+            ObjectListBaseElement* add(ObjectListBaseElement* element);
+
+            struct Export
+            {
+                Export(ObjectListBase* list, ObjectListBaseElement* element) : list_(list), element_(element) {}
+                ObjectListBase* list_;
+                ObjectListBaseElement* element_;
+            };
+
+            /** @brief Returns a pointer to the first element in the list. @return The element */
+            inline Export begin() { return ObjectListBase::Export(this, this->first_); }
+            /** @brief Returns a pointer to the element after the last element in the list. @return The element */
+            inline Export end() { return ObjectListBase::Export(this, 0); }
+            /** @brief Returns a pointer to the last element in the list. @return The element */
+            inline Export rbegin() { return ObjectListBase::Export(this, this->last_); }
+            /** @brief Returns a pointer to the element in front of the first element in the list. @return The element */
+            inline Export rend() { return ObjectListBase::Export(this, 0); }
+
+            inline std::list<void*>::iterator registerIterator(void* iterator) { return this->iterators_.insert(this->iterators_.begin(), iterator); }
+            inline void unregisterIterator(const std::list<void*>::iterator& iterator) { this->iterators_.erase(iterator); }
+            inline std::list<void*>::iterator registerObjectListIterator(void* iterator) { return this->objectListIterators_.insert(this->objectListIterators_.begin(), iterator); }
+            inline void unregisterObjectListIterator(const std::list<void*>::iterator& iterator) { this->objectListIterators_.erase(iterator); }
+            void notifyIterators(OrxonoxClass* object) const;
+
+            inline Identifier* getIdentifier() const { return this->identifier_; }
+
+        private:
+            Identifier* identifier_;               //!< The Iterator owning this list
+            ObjectListBaseElement* first_;         //!< The first element in the list
+            ObjectListBaseElement* last_;          //!< The last element in the list
+            std::list<void*> iterators_;           //!< A list of Iterators pointing on an element in this list
+            std::list<void*> objectListIterators_; //!< A list of ObjectListIterators pointing on an element in this list
+    };
+}
+
+#endif /* _ObjectListBase_H__ */
Index: /code/branches/ceguilua/src/core/ObjectListIterator.h
===================================================================
--- /code/branches/ceguilua/src/core/ObjectListIterator.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/ObjectListIterator.h	(revision 1801)
@@ -0,0 +1,236 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Iterator.h
+    @brief Definition and implementation of the Iterator class.
+
+    The ObjectListIterator of a given class allows to iterate through the
+    ObjectList of this class, containing all objects of that type.
+    This is the only way to access the objects stored in an ObjectList.
+
+    Usage:
+    for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it)
+    {
+        it->someFunction(...);
+        myClass* myObject = *it;
+    }
+*/
+
+#ifndef _ObjectListIterator_H__
+#define _ObjectListIterator_H__
+
+#include "CorePrereqs.h"
+#include "ObjectListBase.h"
+
+namespace orxonox
+{
+    //! The Iterator allows to iterate through the ObjectList of a given class.
+    template <class T>
+    class ObjectListIterator
+    {
+        template <class I>
+        friend class Iterator;
+
+        public:
+            /**
+                @brief Constructor: Sets the element, whereon the ObjectListIterator points, to zero.
+            */
+            inline ObjectListIterator()
+            {
+                this->element_ = 0;
+                this->iterator_ = ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to a given element.
+                @param element The element to start with
+            */
+            inline ObjectListIterator(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+                this->iterator_ = ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
+            }
+
+            /**
+                @brief Constructor: Sets this element to the element of another ObjectListIterator.
+                @param other The other ObjectListIterator
+            */
+            inline ObjectListIterator(const ObjectListIterator<T>& other)
+            {
+                this->element_ = other.element_;
+                this->iterator_ = ClassIdentifier<T>::getIdentifier()->getObjects()->registerObjectListIterator(this);
+            }
+
+            /**
+                @brief Unregisters the ObjectListIterator from the ObjectList.
+            */
+            inline ~ObjectListIterator()
+            {
+                ClassIdentifier<T>::getIdentifier()->getObjects()->unregisterObjectListIterator(this->iterator_);
+            }
+
+            /**
+                @brief Assigns an ObjectListElement.
+                @param element The ObjectListElement
+            */
+            inline const ObjectListIterator<T>& operator=(ObjectListElement<T>* element)
+            {
+                this->element_ = element;
+                return (*this);
+            }
+
+            /**
+                @brief Assigns the element of another ObjectListIterator.
+                @param element The other ObjectListIterator
+            */
+            inline const ObjectListIterator<T>& operator=(const ObjectListIterator<T>& other)
+            {
+                this->element_ = other.element_;
+                return (*this);
+            }
+
+            /**
+                @brief Overloading of the ++it operator: ObjectListIterator points to the next object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline const ObjectListIterator<T>& operator++()
+            {
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->next_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it++ operator: ObjectListIterator points to the next object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline ObjectListIterator<T> operator++(int i)
+            {
+                ObjectListIterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->next_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the --it operator: ObjectListIterator points to the previous object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline const ObjectListIterator<T>& operator--()
+            {
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->prev_;
+                return *this;
+            }
+
+            /**
+                @brief Overloading of the it-- operator: ObjectListIterator points to the previous object in the list.
+                @return The ObjectListIterator itself
+            */
+            inline ObjectListIterator<T> operator--(int i)
+            {
+                ObjectListIterator<T> copy = *this;
+                if (this->element_)
+                    this->element_ = (ObjectListElement<T>*)this->element_->prev_;
+                return copy;
+            }
+
+            /**
+                @brief Overloading of the *it operator: returns the pointer to the object.
+                @return The object the ObjectListIterator points at
+            */
+            inline T* operator*() const
+            {
+                if (this->element_)
+                    return this->element_->object_;
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the it-> operator: returns the pointer to the object.
+                @return The object the ObjectListIterator points at
+            */
+            inline T* operator->() const
+            {
+                if (this->element_)
+                    return this->element_->object_;
+                else
+                    return 0;
+            }
+
+            /**
+                @brief Overloading of the typecast-operator to bool: returns true if the ObjectListIterator points to an existing object.
+                @return True if the ObjectListIterator points to an existing object.
+            */
+            inline operator bool() const
+            {
+                return (this->element_ != 0);
+            }
+
+            /**
+                @brief Overloading of the == operator to compare with another ObjectListIterator.
+                @param compare The other ObjectListIterator
+                @return True if the ObjectListIterator point to the same element
+            */
+            inline bool operator==(const ObjectListIterator<T>& compare) const
+            {
+                return (this->element_ == compare.element_);
+            }
+
+            /**
+                @brief Overloading of the != operator to compare with another ObjectListIterator.
+                @param compare The other ObjectListIterator
+                @return True if the ObjectListIterator point to different elements
+            */
+            inline bool operator!=(const ObjectListIterator<T>& compare) const
+            {
+                return (this->element_ != compare.element_);
+            }
+
+            /**
+                @brief Increments the ObjectListIterator if it points at the given object.
+                @param object The object to compare with
+            */
+            inline void incrementIfEqual(OrxonoxClass* object)
+            {
+                if (this->element_ && this->element_->objectBase_ == object)
+                    this->operator++();
+            }
+
+        private:
+            ObjectListElement<T>* element_;        //!< The element the Iterator points at
+            std::list<void*>::iterator iterator_;  //!< The iterator in the notifying list of the ObjectList
+    };
+}
+
+// Include ObjectList.h so the user only has to include one file: Iterator.h
+#include "ObjectList.h"
+
+#endif /* _ObjectListIterator_H__ */
Index: /code/branches/ceguilua/src/core/OrxonoxClass.cc
===================================================================
--- /code/branches/ceguilua/src/core/OrxonoxClass.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/OrxonoxClass.cc	(revision 1801)
@@ -0,0 +1,136 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxonoxClass.cc
+    @brief Implementation of the OrxonoxClass Class.
+*/
+
+#include "OrxonoxClass.h"
+#include "MetaObjectList.h"
+#include "Identifier.h"
+
+namespace orxonox
+{
+    /** @brief Constructor: Sets the default values. */
+    OrxonoxClass::OrxonoxClass()
+    {
+        this->identifier_ = 0;
+        this->parents_ = 0;
+        this->metaList_ = new MetaObjectList();
+    }
+
+    /** @brief Destructor: Deletes, if existing, the list of the parents. */
+    OrxonoxClass::~OrxonoxClass()
+    {
+        delete this->metaList_;
+
+        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
+        if (this->parents_)
+            delete this->parents_;
+    }
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const Identifier* identifier)
+        { return this->getIdentifier()->isA(identifier); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const Identifier* identifier)
+        { return this->getIdentifier()->isExactlyA(identifier); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const Identifier* identifier)
+        { return this->getIdentifier()->isChildOf(identifier); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const Identifier* identifier)
+        { return this->getIdentifier()->isDirectChildOf(identifier); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const Identifier* identifier)
+        { return this->getIdentifier()->isParentOf(identifier); }
+    /** @brief Returns true if the objects class is a direct parent of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const Identifier* identifier)
+        { return this->getIdentifier()->isDirectParentOf(identifier); }
+
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isA(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isExactlyA(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isDirectChildOf(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct parent of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B>* identifier)
+        { return this->getIdentifier()->isDirectParentOf(identifier->getIdentifier()); }
+
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isA(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isExactlyA(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isDirectChildOf(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct parent of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const SubclassIdentifier<class B> identifier)
+        { return this->getIdentifier()->isDirectParentOf(identifier.getIdentifier()); }
+
+
+    /** @brief Returns true if the objects class is of the given type or a derivative. */
+    bool OrxonoxClass::isA(const OrxonoxClass* object)
+        { return this->getIdentifier()->isA(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is exactly of the given type. */
+    bool OrxonoxClass::isExactlyA(const OrxonoxClass* object)
+        { return this->getIdentifier()->isExactlyA(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a child of the given type. */
+    bool OrxonoxClass::isChildOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectChildOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isDirectChildOf(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a parent of the given type. */
+    bool OrxonoxClass::isParentOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
+    /** @brief Returns true if the objects class is a direct child of the given type. */
+    bool OrxonoxClass::isDirectParentOf(const OrxonoxClass* object)
+        { return this->getIdentifier()->isDirectParentOf(object->getIdentifier()); }
+}
Index: /code/branches/ceguilua/src/core/OrxonoxClass.h
===================================================================
--- /code/branches/ceguilua/src/core/OrxonoxClass.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/OrxonoxClass.h	(revision 1801)
@@ -0,0 +1,112 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OrxonoxClass.h
+    @brief Declaration of the OrxonoxClass Class.
+
+    All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass.
+    It stores the Identifier and the MetaObjectList and has all needed functions to create and use the class-hierarchy.
+*/
+
+#ifndef _OrxonoxClass_H__
+#define _OrxonoxClass_H__
+
+#include "CorePrereqs.h"
+
+#include <set>
+#include <string>
+
+namespace orxonox
+{
+    //! The class all objects and interfaces of the game-logic (not the engine) are derived from.
+    /**
+        The BaseObject and Interfaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass.
+        OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList.
+    */
+    class _CoreExport OrxonoxClass
+    {
+        public:
+            OrxonoxClass();
+            virtual ~OrxonoxClass();
+
+            /** @brief Function to collect the SetConfigValue-macro calls. */
+            void setConfigValues() {};
+
+            /** @brief Returns the Identifier of the object. @return The Identifier */
+            inline Identifier* getIdentifier() const { return this->identifier_; }
+
+            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
+            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
+
+            /** @brief Returns the list of all parents of the object. @return The list */
+            inline std::set<const Identifier*>* getParents() const { return this->parents_; }
+
+            /** @brief Creates the parents-list. */
+            inline void createParents() { this->parents_ = new std::set<const Identifier*>(); }
+
+            /** @brief Returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. @return The list */
+            inline MetaObjectList& getMetaList() { return (*this->metaList_); }
+
+
+            bool isA(const Identifier* identifier);
+            bool isExactlyA(const Identifier* identifier);
+            bool isChildOf(const Identifier* identifier);
+            bool isDirectChildOf(const Identifier* identifier);
+            bool isParentOf(const Identifier* identifier);
+            bool isDirectParentOf(const Identifier* identifier);
+
+            bool isA(const SubclassIdentifier<class B>* identifier);
+            bool isExactlyA(const SubclassIdentifier<class B>* identifier);
+            bool isChildOf(const SubclassIdentifier<class B>* identifier);
+            bool isDirectChildOf(const SubclassIdentifier<class B>* identifier);
+            bool isParentOf(const SubclassIdentifier<class B>* identifier);
+            bool isDirectParentOf(const SubclassIdentifier<class B>* identifier);
+
+            bool isA(const SubclassIdentifier<class B> identifier);
+            bool isExactlyA(const SubclassIdentifier<class B> identifier);
+            bool isChildOf(const SubclassIdentifier<class B> identifier);
+            bool isDirectChildOf(const SubclassIdentifier<class B> identifier);
+            bool isParentOf(const SubclassIdentifier<class B> identifier);
+            bool isDirectParentOf(const SubclassIdentifier<class B> identifier);
+
+            bool isA(const OrxonoxClass* object);
+            bool isExactlyA(const OrxonoxClass* object);
+            bool isChildOf(const OrxonoxClass* object);
+            bool isDirectChildOf(const OrxonoxClass* object);
+            bool isParentOf(const OrxonoxClass* object);
+            bool isDirectParentOf(const OrxonoxClass* object);
+
+        private:
+            Identifier* identifier_;                   //!< The Identifier of the object
+            std::set<const Identifier*>* parents_;     //!< List of all parents of the object
+            MetaObjectList* metaList_;                 //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
+    };
+}
+
+#endif /* _OrxonoxClass_H__ */
Index: /code/branches/ceguilua/src/core/RootGameState.cc
===================================================================
--- /code/branches/ceguilua/src/core/RootGameState.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/RootGameState.cc	(revision 1801)
@@ -0,0 +1,217 @@
+/*
+ *   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 "util/Exception.h"
+#include "Core.h"
+#include "Clock.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;
+
+        // create the Core settings to configure the output level
+        Core::getInstance();
+
+        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/branches/ceguilua/src/core/RootGameState.h
===================================================================
--- /code/branches/ceguilua/src/core/RootGameState.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/RootGameState.h	(revision 1801)
@@ -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/branches/ceguilua/src/core/Script.cc
===================================================================
--- /code/branches/ceguilua/src/core/Script.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Script.cc	(revision 1801)
@@ -0,0 +1,294 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+
+#include "Script.h"
+
+#include <fstream>
+#include <map>
+
+#include "CoreIncludes.h"
+
+extern "C" {
+#include <lualib.h>
+#include <lauxlib.h>
+}
+
+#include "tolua/tolua++.h"
+#include "tolua/tolua_bind.h"
+
+namespace orxonox
+{
+  Script* Script::singletonRef = NULL;
+
+  Script::Script()
+  {
+    luaState_ = lua_open();
+    luaSource_ = "";
+#if LUA_VERSION_NUM == 501
+    luaL_openlibs(luaState_);
+#else
+    luaopen_base(luaState_);
+    luaopen_string(luaState_);
+    luaopen_table(luaState_);
+    luaopen_math(luaState_);
+    luaopen_io(luaState_);
+    luaopen_debug(luaState_);
+#endif
+    tolua_Core_open(luaState_);
+    output_ = "";
+  }
+
+  void Script::luaPrint(std::string str)
+  {
+    output_ += str;
+//    COUT(4) << "Lua_output!:" << std::endl << str << std::endl << "***" << std::endl;
+    COUT(5) << str;
+  }
+
+  /**
+      @brief Loads the specified file line by line
+      @param filename The filename of the file
+      @param luaTags if true, the loaded file gets stripped off luaTags
+  */
+  void Script::loadFile(std::string filename, bool luaTags)
+  {
+    std::ifstream file;
+    file.open(filename.c_str(), std::fstream::in);
+
+    if (!file.is_open())
+    {
+      // some error msg
+    }
+
+    char line[1024];
+    std::string levelString = "";
+
+    while (file.good() && !file.eof())
+    {
+      file.getline(line, 1024);
+      levelString += line;
+      levelString += "\n";
+    }
+
+    file.close();
+    //std::string output;
+
+    if (luaTags) luaSource_ = replaceLuaTags(levelString);
+    COUT(5) << "ParsedSourceCode: " << luaSource_ << std::endl;
+  }
+
+#if LUA_VERSION_NUM != 501
+  const char * Script::lua_Chunkreader(lua_State *L, void *data, size_t *size)
+  {
+    LoadS* ls = ((LoadS*)data);
+    if (ls->size == 0) return NULL;
+    *size = ls->size;
+    ls->size = 0;
+    return ls->s;
+  }
+#endif
+  void Script::run()
+  {
+    int error = 0;
+    std::string init = "local scr = orxonox.Script:getInstance()\nprint = function(s)\nscr:luaPrint(s)\nend\n";
+    init += luaSource_;
+#if LUA_VERSION_NUM == 501
+    error = luaL_loadstring(luaState_, init.c_str());
+#else
+    LoadS ls;
+    ls.s = init.c_str();
+    ls.size = init.size();
+    error = lua_load(luaState_, &orxonox::Script::lua_Chunkreader, &ls, init.c_str());
+#endif
+    if (error == 0)
+      error = lua_pcall(luaState_, 0, 0, 0);
+    if (error != 0)
+    {
+      COUT(2) << "Error in Lua-script: " << lua_tostring(luaState_, -1) << std::endl;
+    }
+  }
+
+  unsigned int Script::getNextQuote(const std::string& text, unsigned int start)
+  {
+    unsigned int quote = start - 1;
+
+    while ((quote = text.find('\"', quote + 1)) != std::string::npos)
+    {
+      unsigned int backslash = quote;
+      unsigned int numbackslashes = 0;
+      for (; backslash > 0; backslash--, numbackslashes++)
+        if (text[backslash - 1] != '\\')
+          break;
+
+      if (numbackslashes % 2 == 0)
+        break;
+    }
+
+    return quote;
+  }
+
+  std::string Script::replaceLuaTags(const std::string& text)
+  {
+    // chreate map with all Lua tags
+    std::map<unsigned int, bool> luaTags;
+    {
+      unsigned int pos = 0;
+      while ((pos = text.find("<?lua", pos)) != std::string::npos)
+        luaTags[pos++] = true;
+    }
+    {
+      unsigned int pos = 0;
+      while ((pos = text.find("?>", pos)) != std::string::npos)
+        luaTags[pos++] = false;
+    }
+
+    // erase all tags from the map that are between two quotes
+    {
+      std::map<unsigned int, bool>::iterator it = luaTags.begin();
+      std::map<unsigned int, bool>::iterator it2 = it;
+      bool bBetweenQuotes = false;
+      unsigned int pos = 0;
+      while ((pos = getNextQuote(text, pos)) != std::string::npos)
+      {
+        while ((it != luaTags.end()) && (it->first < pos))
+        {
+          if (bBetweenQuotes) {
+            it2++;
+            if(it->second && !(it2->second) && it2->first < pos)
+              it = ++it2;
+            else
+              luaTags.erase(it++);
+          }
+          else
+            ++it;
+        }
+        bBetweenQuotes = !bBetweenQuotes;
+        pos++;
+      }
+    }
+
+    // check whether on every opening <?lua tag a closing ?> tag follows
+    {
+      bool expectedValue = true;
+      for (std::map<unsigned int, bool>::iterator it = luaTags.begin(); it != luaTags.end(); ++it)
+      {
+        if (it->second == expectedValue)
+          expectedValue = !expectedValue;
+        else
+        {
+          expectedValue = false;
+          break;
+        }
+      }
+      if (!expectedValue) {
+        // todo: errorhandling
+        return "";
+      }
+    }
+
+    // cut the original string into pieces and put them together with print() instead of lua tags
+    std::string output;
+    {
+      std::map<unsigned int, bool>::iterator it = luaTags.begin();
+      bool bInPrintFunction = true;
+      unsigned int start = 0;
+      unsigned int end = 0;
+
+      do
+      {
+        if (it != luaTags.end())
+          end = (*(it++)).first;
+        else
+          end = std::string::npos;
+
+        unsigned int equalSignCounter = 0;
+
+        if (bInPrintFunction)
+        {
+          // count ['='[ and ]'='] and replace tags with print([[ and ]])
+          std::string temp = text.substr(start, end - start);
+          {
+            unsigned int pos = 0;
+            while ((pos = temp.find('[', pos)) != std::string::npos)
+            {
+              unsigned int tempCounter = 1;
+              unsigned int tempPos = pos++;
+              while(temp[++tempPos] == '=') {
+                tempCounter++;
+              }
+              if(temp[tempPos] != '[') {
+                tempCounter = 0;
+              }
+              else if(tempCounter == 0) {
+                tempCounter = 1;
+              }
+              if (tempCounter > equalSignCounter)
+                equalSignCounter = tempCounter;
+            }
+          }
+          {
+            unsigned int pos = 0;
+            while ((pos = temp.find(']', pos)) != std::string::npos)
+            {
+              unsigned int tempCounter = 1;
+              unsigned int tempPos = pos++;
+              while(temp[++tempPos] == '=') {
+                tempCounter++;
+              }
+              if(temp[tempPos] != ']') {
+                tempCounter = 0;
+              }
+              else if(tempCounter == 0) {
+                tempCounter = 1;
+              }
+              if (tempCounter > equalSignCounter)
+                equalSignCounter = tempCounter;
+            }
+          }
+          std::string equalSigns = "";
+          for(unsigned int i = 0; i < equalSignCounter; i++) {
+            equalSigns += "=";
+          }
+          output += "print([" + equalSigns + "[" + temp + "]" + equalSigns +"])";
+          start = end + 5;
+        }
+        else
+        {
+          output += text.substr(start, end - start);
+          start = end + 2;
+        }
+
+        bInPrintFunction = !bInPrintFunction;
+      }
+      while (end != std::string::npos);
+    }
+
+    return output;
+  }
+
+}
Index: /code/branches/ceguilua/src/core/Script.h
===================================================================
--- /code/branches/ceguilua/src/core/Script.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Script.h	(revision 1801)
@@ -0,0 +1,91 @@
+/*
+ *   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
+ @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 _CoreExport Script
+  /*
+  class Script { // tolua_export
+  */
+  {
+    struct LoadS {
+      const char *s;
+      size_t size;
+    };
+
+    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
+    static const char * lua_Chunkreader(lua_State *L, void *data, size_t *size);
+#endif
+
+    inline lua_State* getLuaState() { return luaState_; };
+    inline std::string getLuaOutput() { return output_; };
+    //inline std::string* getFileString() { return &fileString_; };
+    inline void clearLuaOutput() { output_ = ""; }
+
+    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/branches/ceguilua/src/core/Shell.cc
===================================================================
--- /code/branches/ceguilua/src/core/Shell.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/Shell.cc	(revision 1801)
@@ -0,0 +1,393 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Shell.h"
+#include "CommandExecutor.h"
+#include "CoreIncludes.h"
+#include "ConfigValueIncludes.h"
+#include "Core.h"
+#include "ConsoleCommand.h"
+#include "util/OutputHandler.h"
+
+#define SHELL_UPDATE_LISTENERS(function) \
+    for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ) \
+        (*(it++))->function()
+
+namespace orxonox
+{
+    SetConsoleCommand(Shell, clearShell, true);
+    SetConsoleCommand(Shell, history, true);
+
+    SetConsoleCommandShortcut(OutputHandler, log);
+    SetConsoleCommandShortcut(OutputHandler, error);
+    SetConsoleCommandShortcut(OutputHandler, warning);
+    SetConsoleCommandShortcut(OutputHandler, info);
+    SetConsoleCommandShortcut(OutputHandler, debug);
+
+    Shell* Shell::singletonRef_s = 0;
+
+    Shell::Shell()
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        int level = Core::getSoftDebugLevel(OutputHandler::LD_Shell);
+        Core::setSoftDebugLevel(OutputHandler::LD_Shell, -1);
+
+        RegisterRootObject(Shell);
+
+        this->scrollPosition_ = 0;
+        this->maxHistoryLength_ = 100;
+        this->historyPosition_ = 0;
+        this->historyOffset_ = 0;
+        this->finishedLastLine_ = true;
+        this->bAddOutputLevel_ = false;
+
+        this->clearLines();
+
+        this->inputBuffer_ = new InputBuffer();
+        this->configureInputBuffer();
+
+        this->outputBuffer_.registerListener(this);
+        OutputHandler::getOutStream().setOutputBuffer(this->outputBuffer_);
+
+        this->setConfigValues();
+
+        Core::setSoftDebugLevel(OutputHandler::LD_Shell, level);
+    }
+
+    Shell::~Shell()
+    {
+        if (this->inputBuffer_)
+            delete this->inputBuffer_;
+        singletonRef_s = 0;
+    }
+
+    void Shell::setConfigValues()
+    {
+        SetConfigValue(maxHistoryLength_, 100).callback(this, &Shell::commandHistoryLengthChanged);
+        SetConfigValue(historyOffset_, 0).callback(this, &Shell::commandHistoryOffsetChanged);
+        SetConfigValueVector(commandHistory_, std::vector<std::string>());
+    }
+
+    void Shell::commandHistoryOffsetChanged()
+    {
+        if (this->historyOffset_ >= this->maxHistoryLength_)
+            this->historyOffset_ = 0;
+    }
+
+    void Shell::commandHistoryLengthChanged()
+    {
+        this->commandHistoryOffsetChanged();
+
+        while (this->commandHistory_.size() > this->maxHistoryLength_)
+        {
+            unsigned int index = this->commandHistory_.size() - 1;
+            this->commandHistory_.erase(this->commandHistory_.begin() + index);
+            ModifyConfigValue(commandHistory_, remove, index);
+        }
+    }
+
+    void Shell::configureInputBuffer()
+    {
+        this->inputBuffer_->registerListener(this, &Shell::inputChanged, true);
+        this->inputBuffer_->registerListener(this, &Shell::execute, '\r', false);
+        this->inputBuffer_->registerListener(this, &Shell::hintandcomplete, '\t', true);
+        this->inputBuffer_->registerListener(this, &Shell::backspace, '\b', true);
+        this->inputBuffer_->registerListener(this, &Shell::deletechar, KeyCode::Delete);
+        this->inputBuffer_->registerListener(this, &Shell::exit, (char)27, true);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_right, KeyCode::Right);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_left, KeyCode::Left);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_end, KeyCode::End);
+        this->inputBuffer_->registerListener(this, &Shell::cursor_home, KeyCode::Home);
+        this->inputBuffer_->registerListener(this, &Shell::history_up, KeyCode::Up);
+        this->inputBuffer_->registerListener(this, &Shell::history_down, KeyCode::Down);
+        this->inputBuffer_->registerListener(this, &Shell::scroll_up, KeyCode::PageUp);
+        this->inputBuffer_->registerListener(this, &Shell::scroll_down, KeyCode::PageDown);
+    }
+
+    void Shell::clearShell()
+    {
+        Shell::getInstance().clearLines();
+    }
+
+    void Shell::history()
+    {
+        Shell& instance = Shell::getInstance();
+
+        for (int i = instance.historyOffset_; i < (int)instance.commandHistory_.size(); ++i)
+            instance.addLine(instance.commandHistory_[i], -1);
+        for (int i =  0; i < (int)instance.historyOffset_; ++i)
+            instance.addLine(instance.commandHistory_[i], -1);
+    }
+
+    void Shell::registerListener(ShellListener* listener)
+    {
+        this->listeners_.insert(this->listeners_.end(), listener);
+    }
+
+    void Shell::unregisterListener(ShellListener* listener)
+    {
+        for (std::list<ShellListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+        {
+            if ((*it) == listener)
+                this->listeners_.erase(it++);
+            else
+                ++it;
+        }
+    }
+
+    void Shell::setCursorPosition(unsigned int cursor)
+    {
+        this->inputBuffer_->setCursorPosition(cursor);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::setInput(const std::string& input)
+    {
+        this->inputBuffer_->set(input);
+        this->inputChanged();
+    }
+
+    void Shell::addLine(const std::string& line, int level)
+    {
+        int original_level = OutputHandler::getOutStream().getOutputLevel();
+        OutputHandler::getOutStream().setOutputLevel(level);
+
+        if (!this->finishedLastLine_)
+            this->outputBuffer_ << std::endl;
+
+        this->outputBuffer_ << line << std::endl;
+        OutputHandler::getOutStream().setOutputLevel(original_level);
+    }
+
+    void Shell::clearLines()
+    {
+        this->lines_.clear();
+        this->scrollIterator_ = this->lines_.begin();
+
+        this->scrollPosition_ = 0;
+        this->finishedLastLine_ = true;
+
+        SHELL_UPDATE_LISTENERS(linesChanged);
+    }
+
+    std::list<std::string>::const_iterator Shell::getNewestLineIterator() const
+    {
+        if (this->scrollPosition_)
+            return this->scrollIterator_;
+        else
+            return this->lines_.begin();
+    }
+
+    std::list<std::string>::const_iterator Shell::getEndIterator() const
+    {
+        return this->lines_.end();
+    }
+
+    void Shell::addToHistory(const std::string& command)
+    {
+        ModifyConfigValue(commandHistory_, set, this->historyOffset_, command);
+        this->historyPosition_ = 0;
+        ModifyConfigValue(historyOffset_, set, (this->historyOffset_ + 1) % this->maxHistoryLength_);
+    }
+
+    std::string Shell::getFromHistory() const
+    {
+        unsigned int index = mod(((int)this->historyOffset_) - ((int)this->historyPosition_), this->maxHistoryLength_);
+        if (index < this->commandHistory_.size() && this->historyPosition_ != 0)
+            return this->commandHistory_[index];
+        else
+            return "";
+    }
+
+    void Shell::outputChanged()
+    {
+        std::string output;
+        bool newline;
+        do
+        {
+            newline = this->outputBuffer_.getLine(&output);
+
+            if (!newline && output == "")
+                break;
+
+            if (this->finishedLastLine_)
+            {
+                if (this->bAddOutputLevel_)
+                    output.insert(0, 1, (char)OutputHandler::getOutStream().getOutputLevel());
+
+                this->lines_.insert(this->lines_.begin(), output);
+
+                if (this->scrollPosition_)
+                    this->scrollPosition_++;
+                else
+                    this->scrollIterator_ = this->lines_.begin();
+
+                this->finishedLastLine_ = newline;
+
+                if (!this->scrollPosition_)
+                {
+                    SHELL_UPDATE_LISTENERS(lineAdded);
+                }
+            }
+            else
+            {
+                (*this->lines_.begin()) += output;
+                this->finishedLastLine_ = newline;
+                SHELL_UPDATE_LISTENERS(onlyLastLineChanged);
+            }
+
+        } while (newline);
+    }
+
+    void Shell::inputChanged()
+    {
+        SHELL_UPDATE_LISTENERS(inputChanged);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::execute()
+    {
+        this->addToHistory(this->inputBuffer_->get());
+        this->addLine(this->inputBuffer_->get(), 0);
+
+        if (!CommandExecutor::execute(this->inputBuffer_->get()))
+            this->addLine("Error: Can't execute \"" + this->inputBuffer_->get() + "\".", 1);
+
+        this->clear();
+    }
+
+    void Shell::hintandcomplete()
+    {
+        this->inputBuffer_->set(CommandExecutor::complete(this->inputBuffer_->get()));
+        this->addLine(CommandExecutor::hint(this->inputBuffer_->get()), -1);
+
+        this->inputChanged();
+    }
+
+    void Shell::backspace()
+    {
+        this->inputBuffer_->removeBehindCursor();
+        SHELL_UPDATE_LISTENERS(inputChanged);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::deletechar()
+    {
+        this->inputBuffer_->removeAtCursor();
+        SHELL_UPDATE_LISTENERS(inputChanged);
+    }
+
+    void Shell::clear()
+    {
+        this->inputBuffer_->clear();
+        this->historyPosition_ = 0;
+        SHELL_UPDATE_LISTENERS(inputChanged);
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_right()
+    {
+        this->inputBuffer_->increaseCursor();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_left()
+    {
+        this->inputBuffer_->decreaseCursor();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_end()
+    {
+        this->inputBuffer_->setCursorToEnd();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::cursor_home()
+    {
+        this->inputBuffer_->setCursorToBegin();
+        SHELL_UPDATE_LISTENERS(cursorChanged);
+    }
+
+    void Shell::history_up()
+    {
+        if (this->historyPosition_ < this->commandHistory_.size())
+        {
+            this->historyPosition_++;
+            this->inputBuffer_->set(this->getFromHistory());
+        }
+    }
+
+    void Shell::history_down()
+    {
+        if (this->historyPosition_ > 0)
+        {
+            this->historyPosition_--;
+            this->inputBuffer_->set(this->getFromHistory());
+        }
+    }
+
+    void Shell::scroll_up()
+    {
+        if (this->scrollIterator_ != this->lines_.end())
+        {
+            ++this->scrollIterator_;
+            ++this->scrollPosition_;
+
+            SHELL_UPDATE_LISTENERS(linesChanged);
+        }
+    }
+
+    void Shell::scroll_down()
+    {
+        if (this->scrollIterator_ != this->lines_.begin())
+        {
+            --this->scrollIterator_;
+            --this->scrollPosition_;
+
+            SHELL_UPDATE_LISTENERS(linesChanged);
+        }
+    }
+
+    void Shell::exit()
+    {
+        if (this->inputBuffer_->getSize() > 0)
+        {
+            this->clear();
+            return;
+        }
+
+        this->clear();
+        this->scrollPosition_ = 0;
+        this->scrollIterator_ = this->lines_.begin();
+
+        SHELL_UPDATE_LISTENERS(exit);
+    }
+}
Index: /code/branches/ceguilua/src/core/Shell.h
===================================================================
--- /code/branches/ceguilua/src/core/Shell.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Shell.h	(revision 1801)
@@ -0,0 +1,149 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Shell_H__
+#define _Shell_H__
+
+#include "CorePrereqs.h"
+
+#include <list>
+#include <vector>
+
+#include "OrxonoxClass.h"
+#include "input/InputBuffer.h"
+#include "util/OutputBuffer.h"
+
+namespace orxonox
+{
+    class _CoreExport ShellListener
+    {
+        friend class Shell;
+
+        public:
+            virtual ~ShellListener() {}
+
+        private:
+            virtual void linesChanged() {}
+            virtual void onlyLastLineChanged() {}
+            virtual void lineAdded() {}
+            virtual void inputChanged() {}
+            virtual void cursorChanged() {}
+            virtual void exit() {}
+    };
+
+    class _CoreExport Shell : virtual public OrxonoxClass, public OutputBufferListener
+    {
+        public:
+            Shell();
+            virtual ~Shell();
+
+            static Shell& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+            static void clearShell();
+            static void history();
+
+            virtual void setConfigValues();
+            void commandHistoryOffsetChanged();
+            void commandHistoryLengthChanged();
+
+            void registerListener(ShellListener* listener);
+            void unregisterListener(ShellListener* listener);
+
+            inline InputBuffer* getInputBuffer()
+                { return this->inputBuffer_; }
+            inline OutputBuffer& getOutputBuffer()
+                { return this->outputBuffer_; }
+
+            void setCursorPosition(unsigned int cursor);
+            inline unsigned int getCursorPosition() const
+                { return this->inputBuffer_->getCursorPosition(); }
+
+            void setInput(const std::string& input);
+
+            inline void clearInput()
+                { this->setInput(""); }
+            inline std::string getInput() const
+                { return this->inputBuffer_->get(); }
+
+            std::list<std::string>::const_iterator getNewestLineIterator() const;
+            std::list<std::string>::const_iterator getEndIterator() const;
+
+            void addLine(const std::string& line, int level = 0);
+            void clearLines();
+
+            inline unsigned int getNumLines() const
+                { return this->lines_.size(); }
+            inline unsigned int getScrollPosition() const
+                { return this->scrollPosition_; }
+
+            inline void addOutputLevel(bool bAddOutputLevel)
+                { this->bAddOutputLevel_ = bAddOutputLevel; }
+
+        private:
+            Shell(const Shell& other);
+
+            void configureInputBuffer();
+
+            void addToHistory(const std::string& command);
+            std::string getFromHistory() const;
+
+            virtual void outputChanged();
+            void inputChanged();
+            void execute();
+            void hintandcomplete();
+            void backspace();
+            void deletechar();
+            void clear();
+            void cursor_right();
+            void cursor_left();
+            void cursor_end();
+            void cursor_home();
+            void history_up();
+            void history_down();
+            void scroll_up();
+            void scroll_down();
+            void exit();
+
+            std::list<ShellListener*> listeners_;
+            InputBuffer* inputBuffer_;
+            OutputBuffer outputBuffer_;
+            bool finishedLastLine_;
+            std::list<std::string> lines_;
+            std::list<std::string>::const_iterator scrollIterator_;
+            unsigned int scrollPosition_;
+            std::vector<std::string> commandHistory_;
+            unsigned int maxHistoryLength_;
+            unsigned int historyPosition_;
+            unsigned int historyOffset_;
+            bool bAddOutputLevel_;
+
+            static Shell* singletonRef_s;
+    };
+}
+
+#endif /* _Shell_H__ */
Index: /code/branches/ceguilua/src/core/Super.h
===================================================================
--- /code/branches/ceguilua/src/core/Super.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/Super.h	(revision 1801)
@@ -0,0 +1,486 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Super.h
+    @brief Definition of all super-function related macros.
+
+    This file defines all macros needed to add a new "super-function".
+    If you add a super-function, you can call SUPER(myclass, functionname) inside your
+    code and the function of the parentclass gets called. This is comparable with
+    super.functionname() in Java or other languages.
+
+    This works only with virtual functions that return nothing (void) and belong to
+    classes that have an Identifier. Arguments however are supported.
+
+    To add a new super-function, you have process 4 steps:
+
+    1) Add a new SUPER macro
+       This allows you to call the super-function in your code.
+       Location: This file (Super.h), marked with --> HERE <-- comments (1/3)
+
+    2) Call the SUPER_FUNCTION_GLOBAL_DECLARATION_PART1/2 macros.
+       This defines some global classes and templates, needed to create and call the super-functions.
+       Location: This file (Super.h), marked with --> HERE <-- comments (2/3)
+
+    3) Call the SUPER_INTRUSIVE_DECLARATION macro.
+       This will be included into the declaration of ClassIdentifier<T>.
+       Location: This file (Super.h), marked with --> HERE <-- comments (3/3)
+
+    4) Call the SUPER_FUNCTION macro.
+       This defines a partially specialized template that will decide if a class is "super" to another class.
+       If the check returns true, a SuperFunctionCaller gets created, which will be used by the SUPER macro.
+       You have to add this into the header-file of the baseclass of the super-function (the class that first
+       implements the function), below the class declaration. You can't call it directly in this file, because
+       otherwise you had to include the headerfile right here, which would cause some ugly backdependencies,
+       include loops and slower compilation.
+       Dont forget to include Super.h in the header-file.
+       Location: The header-file of the baseclass (Baseclass.h), below the class declaration
+*/
+
+#ifndef _Super_H__
+#define _Super_H__
+
+#include <iostream>
+
+#include "CorePrereqs.h"
+
+#include "util/Debug.h"
+#include "util/XMLIncludes.h"
+
+///////////////////////
+// Macro definitions //
+///////////////////////
+
+//// Common macros ////
+
+    /**
+        @brief Declares a new super-function by creating a specialized template. Add this below the class declaration of the baseclass.
+        @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
+        @param baseclass The baseclass of the super-function (~the root)
+        @param functionname The name of the super-function
+        @param purevirtualbase "true" if the function is pure virtual in the baseclass, "false" if the function is implemented (without "")
+    */
+    #define SUPER_FUNCTION(functionnumber, baseclass, functionname, purevirtualbase) \
+        template <class T, int templatehack2> \
+        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2> \
+        { \
+            static void check() \
+            { \
+                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0); \
+                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check(); \
+            } \
+            \
+            static void apply(void* temp) {} \
+            static void apply(baseclass* temp) \
+            { \
+                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \
+                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \
+                { \
+                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \
+                    { \
+                        COUT(5) << "Added SuperFunctionCaller for " << #functionname << ": " << ClassIdentifier<T>::getIdentifier()->getName() << " <- " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl; \
+                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>; \
+                    } \
+                } \
+            } \
+        }; \
+        \
+        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase(functionnumber, baseclass)
+
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND0(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND1(functionnumber, baseclass) SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass)
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDfalse(functionnumber, baseclass)
+    #define SUPER_FUNCTION_PUREVIRTUAL_WORKAROUNDtrue(functionnumber, baseclass) \
+        template <int templatehack2> \
+        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
+        { \
+            static void check() \
+            { \
+                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
+            } \
+        };
+
+
+    /*
+    //// Comments about the macro ////
+
+        // Partially specialized template (templatehack is now specialized too).
+        //
+        // This ensures the compiler takes THIS template if the header-file of the super-function
+        // is included. In any other case, the compiler just uses the fallback template which is
+        // defined in this file.
+        template <class T, templatehack2>
+        struct SuperFunctionCondition<functionnumber, T, 0, templatehack2>
+        {
+            static void check()
+            {
+                // This call to the apply-function is the whole check. By calling the function with
+                // a T* pointer, the right function get's called.
+                SuperFunctionCondition<functionnumber, T, 0, templatehack2>::apply((T*)0);
+
+                // Go go the check for of next super-function (functionnumber + 1)
+                SuperFunctionCondition<functionnumber + 1, T, 0, templatehack2>::check();
+            }
+
+            // This function gets called if T is not a child of the baseclass.
+            // The function does nothing.
+            static void apply(void* temp) {}
+
+            // This function gets called if T is a child of the baseclass and can therefore be converted.
+            // The function adds a SuperFunctionCaller to the Identifier of all subclasses of T.
+            static void apply(baseclass* temp)
+            {
+                ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier();
+
+                // Iterate through all children
+                for (std::set<const Identifier*>::iterator it = identifier->getDirectChildrenIntern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)
+                {
+                    // Check if there's not already a caller
+                    if (!((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_)
+                    {
+                        // Add the SuperFunctionCaller
+                        COUT(5) << "adding functionpointer to " << ((ClassIdentifier<T>*)(*it))->getName() << std::endl;
+                        ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_ = new SuperFunctionClassCaller_##functionname <T>;
+                    }
+                }
+            }
+        };
+        SUPER_FUNCTION_PUREVIRTUAL_WORKAROUND##purevirtualbase
+
+
+        // The following piece of code is only added if purevirtualbase = true
+
+        // Explicit specialization of the Condition template for the baseclass to avoid
+        // errors if the function is pure virtual in the baseclass.
+        template <int templatehack2> \
+        struct SuperFunctionCondition<functionnumber, baseclass, 0, templatehack2> \
+        { \
+            // The check function just behaves like the fallback - it advances to the check for the next super-function (functionnumber + 1)
+            static void check() \
+            { \
+                SuperFunctionCondition<functionnumber + 1, baseclass, 0, templatehack2>::check(); \
+            } \
+        };
+    */
+
+    // SUPER-macro: Calls Parent::functionname() where Parent is the direct parent of classname
+    #define SUPER(classname, functionname, ...) \
+        SUPER_##functionname(classname, functionname, __VA_ARGS__)
+
+    // helper macro: for functions without arguments
+    #define SUPER_NOARGS(classname, functionname) \
+        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this)
+
+    // helper macro: for functions with arguments
+    #define SUPER_ARGS(classname, functionname, ...) \
+        (*ClassIdentifier<classname>::getIdentifier()->superFunctionCaller_##functionname##_)(this, __VA_ARGS__)
+
+
+//// Function-specific macros ////
+
+    /*
+        Add a macro for each super-function
+
+        Example (no arguments):
+        #define SUPER_myfunction(classname, functionname, ...) \
+            SUPER_NOARGS(classname, functionname)
+
+        Example (with arguments):
+        #define SUPER_myfunction(classname, functionname, ...) \
+            SUPER_ARGS(classname, functionname, __VA_ARGS__)
+    */
+
+    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+    #define SUPER_XMLPort(classname, functionname, ...) \
+        SUPER_ARGS(classname, functionname, __VA_ARGS__)
+
+    #define SUPER_tick(classname, functionname, ...) \
+        SUPER_ARGS(classname, functionname, __VA_ARGS__)
+
+    #define SUPER_changedActivity(classname, functionname, ...) \
+        SUPER_NOARGS(classname, functionname)
+
+    #define SUPER_changedVisibility(classname, functionname, ...) \
+        SUPER_NOARGS(classname, functionname)
+    // (1/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+
+
+namespace orxonox
+{
+    /////////////////////////////////////////////////////////////////////////////////////////////////////
+    // This code gets included by Identifier.h and every other header file that needs a super-function //
+    /////////////////////////////////////////////////////////////////////////////////////////////////////
+
+    //// Common code ////
+
+        // Base templates
+        /**
+            @brief Creates the SuperFunctionCaller if T is a child of the super-functions baseclass.
+        */
+        template <int functionnumber, class T, int templatehack1, int templatehack2>
+        struct SuperFunctionCondition
+        {
+            static void check() {}
+        };
+
+        /**
+            @brief Initializes the SuperFunctionCaller-pointer with zero.
+        */
+        template <int functionnumber, class T>
+        struct SuperFunctionInitialization
+        {
+            static void initialize(ClassIdentifier<T>* identifier) {}
+        };
+
+        /**
+            @brief Deletes the SuperFunctionCaller.
+        */
+        template <int functionnumber, class T>
+        struct SuperFunctionDestruction
+        {
+            static void destroy(ClassIdentifier<T>* identifier) {}
+        };
+
+
+    //// Function-specific code ////
+
+        /**
+            @brief Creates the needed objects and templates to call a super-function.
+            @param functionnumber Each super-function needs a unique number, starting with zero, increasing by one
+            @param functionname The name of the super-function
+            @param hasarguments "false" if the function doesn't take any arguments, "true" if it does (without "")
+            @param ... Variadic: If the function takes arguments, add them here with type and name. Example: int myvalue, float myothervalue
+        */
+        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(functionnumber, functionname, hasarguments, ...) \
+            template <class T, int templatehack1, int templatehack2> \
+            struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2> \
+            { \
+                static void check() \
+                { \
+                    SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check(); \
+                } \
+            }; \
+            \
+            template <class T> \
+            struct SuperFunctionInitialization<functionnumber, T> \
+            { \
+                static void initialize(ClassIdentifier<T>* identifier) \
+                { \
+                    identifier->superFunctionCaller_##functionname##_ = 0; \
+                    SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier); \
+                } \
+            }; \
+            \
+            template <class T> \
+            struct SuperFunctionDestruction<functionnumber, T> \
+            { \
+                static void destroy(ClassIdentifier<T>* identifier) \
+                { \
+                    if (identifier->superFunctionCaller_##functionname##_) \
+                        delete identifier->superFunctionCaller_##functionname##_; \
+                    SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier); \
+                } \
+            }; \
+            \
+            class _CoreExport SuperFunctionCaller_##functionname \
+            { \
+                public: \
+                    virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0; \
+                    virtual ~SuperFunctionCaller_##functionname () {} \
+            }; \
+            \
+            template <class T> \
+            class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname \
+            { \
+                public: \
+                    inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) \
+                    { \
+                        (dynamic_cast<T*>(object))->T:: functionname
+
+        /*
+            JUST ADD THE FUNCTION ARGUMENTS BETWEEN BOTH MACROS, ENCLOSED BY BRACKETS
+            EXAMPLE:
+
+              SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, myfunction, true, int myvalue, float myothervalue) <-- !!! DONT ADD A SEMICOLON HERE !!!
+                (myvalue, myothervalue)
+              SUPER_FUNCTION_GLOBAL_DECLARATION_PART2
+        */
+
+        #define SUPER_FUNCTION_GLOBAL_DECLARATION_PART2 \
+                                                        ; \
+                    } \
+            };
+
+        #define SUPER_CALL_ARGUMENTSfalse(...) OrxonoxClass* object
+        #define SUPER_CALL_ARGUMENTS0(...)     OrxonoxClass* object
+        #define SUPER_CALL_ARGUMENTStrue(...) OrxonoxClass* object, __VA_ARGS__
+        #define SUPER_CALL_ARGUMENTS1(...)    OrxonoxClass* object, __VA_ARGS__
+
+
+    /*
+    //// COMMENTS ABOUT THE MACRO ////
+
+        // Partially specialized template (templatehack not yet specialized, this
+        // will be done by the real condition in the header-file of the super-function)
+        // Only used as fallback
+        template <class T, int templatehack1, int templatehack2>
+        struct SuperFunctionCondition<functionnumber, T, templatehack1, templatehack2>
+        {
+            // If this function gets called, the header-file of the super function is not
+            // included, so this fallback template (templatehack not specialized) is used
+            static void check()
+            {
+                // Calls the condition-check of the next super-function (functionnumber + 1)
+                SuperFunctionCondition<functionnumber + 1, T, templatehack1, templatehack2>::check();
+            }
+        };
+
+        // Initializes the SuperFunctionCaller-pointer with zero.
+        template <class T>
+        struct SuperFunctionInitialization<functionnumber, T>
+        {
+            static void initialize(ClassIdentifier<T>* identifier)
+            {
+                identifier->superFunctionCaller_##functionname##_ = 0;
+
+                // Calls the initialization of the next super-function (functionnumber + 1)
+                SuperFunctionInitialization<functionnumber + 1, T>::initialize(identifier);
+            }
+        };
+
+        // Deletes the SuperFunctionCaller.
+        template <class T>
+        struct SuperFunctionDestruction<functionnumber, T>
+        {
+            static void destroy(ClassIdentifier<T>* identifier)
+            {
+                if (identifier->superFunctionCaller_##functionname##_)
+                    delete identifier->superFunctionCaller_##functionname##_;
+
+                // Calls the destruction of the next super-function (functionnumber + 1)
+                SuperFunctionDestruction<functionnumber + 1, T>::destroy(identifier);
+            }
+        };
+
+        // Baseclass of the super-function caller. The real call will be done by a
+        // templatized subclass through the virtual () operator.
+        class _CoreExport SuperFunctionCaller_##functionname
+        {
+            public:
+                virtual void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) ) = 0;
+                virtual ~SuperFunctionCaller_##functionname () {}
+        };
+
+        // The real super-function caller: Calls T::functionname()
+        // T should be the parent, but this will be done by the spezialized condition template
+        template <class T>
+        class SuperFunctionClassCaller_##functionname : public SuperFunctionCaller_##functionname
+        {
+            public:
+                // @brief Calls the function.
+                // @param object The object to call the function on
+                // @param ... The arguments of the function
+                inline void operator()( SUPER_CALL_ARGUMENTS##hasarguments(__VA_ARGS__) )
+                {
+                    (dynamic_cast<T*>(object))->T:: functionname ( Call the function with it's arguments );
+                }
+        }
+    */
+
+
+    //// Execute the code for each super-function ////
+
+        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(0, XMLPort, true, Element& xmlelement, XMLPort::Mode mode)
+            (xmlelement, mode)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(1, tick, true, float dt)
+            (dt)
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(2, changedActivity, false)
+            ()
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART1(3, changedVisibility, false)
+            ()
+        SUPER_FUNCTION_GLOBAL_DECLARATION_PART2;
+        // (2/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+
+}
+
+#else /* _Super_H__ */
+  #ifdef SUPER_INTRUSIVE_DECLARATION_INCLUDE
+
+//////////////////////////////////////////////////////////////////////////
+// This code gets included within the declaration of ClassIdentifier<T> //
+//////////////////////////////////////////////////////////////////////////
+
+//// Common code ////
+
+    private:
+
+        template <int functionnumber, class TT, int templatehack1, int templatehack2>
+        friend struct SuperFunctionCondition;
+
+        // Creates the super-function-callers by calling the first SuperFunctionCondition check
+        // This get's called within the initialization of an Identifier
+        virtual void createSuperFunctionCaller() const
+        {
+            SuperFunctionCondition<0, T, 0, 0>::check();
+        }
+
+
+//// Function-specific code ////
+
+    public:
+        /**
+            @brief Adds a pointer to the SuperFunctionCaller as a member of ClassIdentifier.
+            @param functionname The name of the super-function
+        */
+        #ifndef SUPER_INTRUSIVE_DECLARATION
+          #define SUPER_INTRUSIVE_DECLARATION(functionname) \
+            SuperFunctionCaller_##functionname * superFunctionCaller_##functionname##_
+        #endif
+
+
+//// Execute the code for each super-function ////
+
+    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+    SUPER_INTRUSIVE_DECLARATION(XMLPort);
+    SUPER_INTRUSIVE_DECLARATION(tick);
+    SUPER_INTRUSIVE_DECLARATION(changedActivity);
+    SUPER_INTRUSIVE_DECLARATION(changedVisibility);
+    // (3/3) --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <-- --> HERE <--
+
+
+    #undef SUPER_INTRUSIVE_DECLARATION_INCLUDE
+  #endif /* SUPER_INTRUSIVE_DECLARATION_INCLUDE */
+#endif /* _Super_H__ */
Index: /code/branches/ceguilua/src/core/TclBind.cc
===================================================================
--- /code/branches/ceguilua/src/core/TclBind.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/TclBind.cc	(revision 1801)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TclBind.h"
+
+#include <iostream>
+#include <string>
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "TclThreadManager.h"
+#include "util/Debug.h"
+#include "util/String.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcut(TclBind, tcl);
+    SetConsoleCommandShortcut(TclBind, bgerror);
+
+    TclBind* TclBind::singletonRef_s = 0;
+
+    TclBind::TclBind(const std::string& datapath)
+    {
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+        this->interpreter_ = 0;
+        this->bSetTclLibPath_ = false;
+        this->setDataPath(datapath);
+    }
+
+    TclBind::~TclBind()
+    {
+        if (this->interpreter_)
+            delete this->interpreter_;
+        singletonRef_s = 0;
+    }
+
+    void TclBind::setDataPath(const std::string& datapath)
+    {
+        this->tclLibPath_ = datapath + "/tcl" + TCL_VERSION + "/";
+        this->bSetTclLibPath_ = true;
+
+        this->createTclInterpreter();
+    }
+
+    void TclBind::createTclInterpreter()
+    {
+        if (this->bSetTclLibPath_ && !this->interpreter_)
+        {
+            this->interpreter_ = new Tcl::interpreter(this->tclLibPath_);
+            this->interpreter_->def("orxonox::query", TclBind::tcl_query, Tcl::variadic());
+            this->interpreter_->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
+            this->interpreter_->def("execute", TclBind::tcl_execute, Tcl::variadic());
+
+            try
+            {
+                this->interpreter_->eval("proc query args { orxonox::query $args }");
+                this->interpreter_->eval("proc crossquery {id args} { orxonox::crossquery 0 $id $args }");
+                this->interpreter_->eval("set id 0");
+                this->interpreter_->eval("rename exit tcl::exit; proc exit {} { execute exit }");
+                this->interpreter_->eval("redef_puts");
+            }
+            catch (Tcl::tcl_error const &e)
+            {   COUT(1) << "Tcl error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+            catch (std::exception const &e)
+            {   COUT(1) << "Error while creating Tcl-interpreter: " << e.what() << std::endl;   }
+        }
+    }
+
+    void TclBind::createNewTclInterpreter()
+    {
+        if (this->interpreter_)
+        {
+            delete this->interpreter_;
+            this->interpreter_ = 0;
+        }
+
+        this->createTclInterpreter();
+    }
+
+    std::string TclBind::tcl_query(Tcl::object const &args)
+    {
+        COUT(4) << "Tcl_query: " << args.get() << std::endl;
+
+        std::string command = stripEnclosingBraces(args.get());
+
+        if (!CommandExecutor::execute(command, false))
+        {
+            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+        }
+
+        if (CommandExecutor::getLastEvaluation().hasReturnvalue())
+            return CommandExecutor::getLastEvaluation().getReturnvalue().getString();
+
+        return "";
+    }
+
+    void TclBind::tcl_execute(Tcl::object const &args)
+    {
+        COUT(4) << "Tcl_execute: " << args.get() << std::endl;
+        std::string command = stripEnclosingBraces(args.get());
+
+        if (!CommandExecutor::execute(command, false))
+        {
+            COUT(1) << "Error: Can't execute command \"" << command << "\"!" << std::endl;
+        }
+    }
+
+    std::string TclBind::tcl(const std::string& tclcode)
+    {
+        if (TclBind::getInstance().interpreter_)
+        {
+            try
+            {
+                std::string output = TclBind::getInstance().interpreter_->eval(tclcode);
+                if (output != "")
+                {
+                    COUT(0) << "tcl> " << output << std::endl;
+                }
+                return output;
+            }
+            catch (Tcl::tcl_error const &e)
+            {   COUT(1) << "tcl> Error: " << e.what() << std::endl;   }
+            catch (std::exception const &e)
+            {   COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;   }
+        }
+
+        return "";
+    }
+
+    void TclBind::bgerror(std::string error)
+    {
+        COUT(1) << "Tcl background error: " << stripEnclosingBraces(error) << std::endl;
+    }
+
+    bool TclBind::eval(const std::string& tclcode)
+    {
+        try
+        {
+            TclBind::getInstance().interpreter_->eval(tclcode);
+            return true;
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error: " << e.what() << std::endl;   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while executing Tcl: " << e.what() << std::endl;   }
+
+        return false;
+    }
+}
Index: /code/branches/ceguilua/src/core/TclBind.h
===================================================================
--- /code/branches/ceguilua/src/core/TclBind.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/TclBind.h	(revision 1801)
@@ -0,0 +1,71 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TclBind_H__
+#define _TclBind_H__
+
+#include "CorePrereqs.h"
+
+#include "cpptcl/CppTcl.h"
+
+namespace orxonox
+{
+    class _CoreExport TclBind
+    {
+        public:
+            TclBind(const std::string& datapath);
+            ~TclBind();
+
+            static TclBind& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+            static std::string tcl(const std::string& tclcode);
+            static void bgerror(std::string error);
+
+            void setDataPath(const std::string& datapath);
+            std::string getTclLibPath() const { return this->tclLibPath_; }
+            void createTclInterpreter();
+            void createNewTclInterpreter();
+            Tcl::interpreter* getTclInterpreter() const { return this->interpreter_; }
+
+            static std::string tcl_query(Tcl::object const &args);
+            static void tcl_execute(Tcl::object const &args);
+
+            static bool eval(const std::string& tclcode);
+
+        private:
+            TclBind(const TclBind& other);
+
+            Tcl::interpreter* interpreter_;
+            std::string tclLibPath_;
+            bool bSetTclLibPath_;
+
+            static TclBind* singletonRef_s;
+    };
+}
+
+#endif /* _TclBind_H__ */
Index: /code/branches/ceguilua/src/core/TclThreadManager.cc
===================================================================
--- /code/branches/ceguilua/src/core/TclThreadManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/TclThreadManager.cc	(revision 1801)
@@ -0,0 +1,680 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TclThreadManager.h"
+
+#include <iostream>
+#include <string>
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+#include <OgreTimer.h>
+
+#include "CoreIncludes.h"
+#include "ConsoleCommand.h"
+#include "CommandExecutor.h"
+#include "TclBind.h"
+#include "util/Debug.h"
+#include "util/Convert.h"
+
+
+namespace orxonox
+{
+    const unsigned int TCLTHREADMANAGER_MAX_QUEUE_LENGTH = 100;
+    const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f;
+
+    SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommandShortcutAlias(TclThreadManager, query,   "tclquery"  ).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, create,  false);
+    SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, query,   false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, status,  false);
+    SetConsoleCommand(TclThreadManager, dump,    false).argumentCompleter(0, autocompletion::tclthreads());
+    SetConsoleCommand(TclThreadManager, flush,   false).argumentCompleter(0, autocompletion::tclthreads());
+
+    TclThreadManager* TclThreadManager::singletonRef_s = 0;
+
+    TclThreadManager::TclThreadManager(Tcl::interpreter* interpreter)
+    {
+        RegisterRootObject(TclThreadManager);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->threadCounter_ = 0;
+        this->orxonoxInterpreterBundle_.id_ = 0;
+        this->orxonoxInterpreterBundle_.interpreter_ = interpreter;
+#if (BOOST_VERSION >= 103500)
+        this->threadID_ = boost::this_thread::get_id();
+#else
+        //
+#endif
+    }
+
+    TclThreadManager::~TclThreadManager()
+    {
+        unsigned int threadID;
+        {
+            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+            if (this->interpreterBundles_.begin() == this->interpreterBundles_.end())
+                return;
+            else
+                threadID = this->interpreterBundles_.begin()->first;
+        }
+        this->destroy(threadID);
+
+        singletonRef_s = 0;
+    }
+
+    unsigned int TclThreadManager::create()
+    {
+        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        TclThreadManager::getInstance().threadCounter_++;
+        std::string name = getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().threadCounter_);
+
+        TclInterpreterBundle* bundle = new TclInterpreterBundle;
+        bundle->id_ = TclThreadManager::getInstance().threadCounter_;
+        bundle->interpreter_ = TclThreadManager::getInstance().createNewTclInterpreter(name);
+        bundle->interpreterName_ = name;
+        bundle->running_ = true;
+        bundle->finished_ = true;
+
+        TclThreadManager::getInstance().interpreterBundles_[TclThreadManager::getInstance().threadCounter_] = bundle;
+        COUT(0) << "Created new Tcl-interpreter with ID " << TclThreadManager::getInstance().threadCounter_ << std::endl;
+        return TclThreadManager::getInstance().threadCounter_;
+    }
+
+    unsigned int TclThreadManager::createID(unsigned int threadID)
+    {
+        unsigned int temp = TclThreadManager::getInstance().threadCounter_;
+        TclThreadManager::getInstance().threadCounter_ = threadID - 1;
+        TclThreadManager::create();
+        TclThreadManager::getInstance().threadCounter_ = temp;
+        return threadID;
+    }
+
+    void TclThreadManager::destroy(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            {
+                boost::mutex::scoped_lock running_lock(bundle->runningMutex_);
+                bundle->running_ = false;
+            }
+            while (true)
+            {
+                {
+                    boost::mutex::scoped_lock finished_lock(bundle->finishedMutex_);
+                    if (bundle->finished_)
+                    {
+                        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+#if (BOOST_VERSION >= 103500)
+                        boost::mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
+#else
+                        boost::try_mutex::scoped_try_lock interpreter_lock(bundle->interpreterMutex_);
+#endif
+                        try
+                        {
+                            while (!interpreter_lock.try_lock())
+                            {
+                                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
+#if (BOOST_VERSION >= 103500)
+                                boost::this_thread::yield();
+#else
+                                boost::thread::yield();
+#endif
+                            }
+                        } catch (...) {}
+                        delete bundle->interpreter_;
+                        delete bundle;
+                        TclThreadManager::getInstance().interpreterBundles_.erase(threadID);
+                        break;
+                    }
+                }
+
+                TclThreadManager::getInstance().orxonoxEvalCondition_.notify_one();
+#if (BOOST_VERSION >= 103500)
+                boost::this_thread::yield();
+#else
+                boost::thread::yield();
+#endif
+            }
+
+            COUT(0) << "Destroyed Tcl-interpreter with ID " << threadID << std::endl;
+        }
+    }
+
+    void TclThreadManager::execute(unsigned int threadID, const std::string& _command)
+    {
+        std::string command = stripEnclosingBraces(_command);
+
+        if (threadID == 0)
+            TclThreadManager::getInstance().pushCommandToQueue(command);
+        else
+            TclThreadManager::getInstance().pushCommandToQueue(threadID, command);
+    }
+
+    std::string TclThreadManager::query(unsigned int threadID, const std::string& command)
+    {
+        return TclThreadManager::getInstance().evalQuery(TclThreadManager::getInstance().orxonoxInterpreterBundle_.id_, threadID, command);
+    }
+
+    void TclThreadManager::status()
+    {
+        COUT(0) << "Thread ID" << '\t' << "Queue size" << '\t' << "State" << std::endl;
+
+        std::string output = "Orxonox";
+        output += "\t\t";
+        {
+            boost::mutex::scoped_lock queue_lock(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queueMutex_);
+            output += getConvertedValue<unsigned int, std::string>(TclThreadManager::getInstance().orxonoxInterpreterBundle_.queue_.size());
+        }
+        output += "\t\t";
+        output += "busy";
+        COUT(0) << output << std::endl;
+
+        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = TclThreadManager::getInstance().interpreterBundles_.begin(); it != TclThreadManager::getInstance().interpreterBundles_.end(); ++it)
+        {
+            std::string output = getConvertedValue<unsigned int, std::string>((*it).first);
+            output += "\t\t";
+            {
+                boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
+                output += getConvertedValue<unsigned int, std::string>((*it).second->queue_.size());
+            }
+            output += "\t\t";
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
+#else
+                boost::try_mutex::scoped_try_lock interpreter_lock((*it).second->interpreterMutex_);
+#endif
+                if (interpreter_lock.try_lock())
+                    output += "ready";
+                else
+                    output += "busy";
+            }
+            COUT(0) << output << std::endl;
+        }
+    }
+
+    void TclThreadManager::dump(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = 0;
+        if (threadID == 0)
+        {
+            bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_;
+            COUT(0) << "Queue dump of Orxonox:" << std::endl;
+        }
+        else
+        {
+            if ((bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)))
+            {
+                COUT(0) << "Queue dump of Tcl-thread " << threadID << ":" << std::endl;
+            }
+            else
+                return;
+        }
+
+        boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+        unsigned int index = 0;
+        for (std::list<std::string>::const_iterator it = bundle->queue_.begin(); it != bundle->queue_.end(); ++it)
+        {
+            index++;
+            COUT(0) << index << ": " << (*it) << std::endl;
+        }
+    }
+
+    void TclThreadManager::flush(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = 0;
+        if (threadID == 0)
+            bundle = &TclThreadManager::getInstance().orxonoxInterpreterBundle_;
+        else
+            if (!(bundle = TclThreadManager::getInstance().getInterpreterBundle(threadID)))
+                return;
+
+        boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+        bundle->queue_.clear();
+        if (threadID == 0)
+        {
+            COUT(0) << "Flushed queue of Orxonox Tcl-interpreter." << std::endl;
+        }
+        else
+        {
+            COUT(0) << "Flushed queue of Tcl-interpreter " << threadID << "." << std::endl;
+        }
+    }
+
+    void TclThreadManager::tcl_execute(Tcl::object const &args)
+    {
+        TclThreadManager::getInstance().pushCommandToQueue(stripEnclosingBraces(args.get()));
+    }
+
+    std::string TclThreadManager::tcl_query(int querierID, Tcl::object const &args)
+    {
+        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, stripEnclosingBraces(args.get()));
+    }
+
+    std::string TclThreadManager::tcl_crossquery(int querierID, int threadID, Tcl::object const &args)
+    {
+        return TclThreadManager::getInstance().evalQuery((unsigned int)querierID, (unsigned int)threadID, stripEnclosingBraces(args.get()));
+    }
+
+    bool TclThreadManager::tcl_running(int threadID)
+    {
+        TclInterpreterBundle* bundle = TclThreadManager::getInstance().getInterpreterBundle((unsigned int)threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock running_lock(bundle->runningMutex_);
+            return bundle->running_;
+        }
+        return false;
+    }
+
+    Tcl::interpreter* TclThreadManager::createNewTclInterpreter(const std::string& threadID)
+    {
+        Tcl::interpreter* i = 0;
+        i = new Tcl::interpreter(TclBind::getInstance().getTclLibPath());
+
+        try
+        {
+            i->def("orxonox::query", TclThreadManager::tcl_query, Tcl::variadic());
+            i->def("orxonox::crossquery", TclThreadManager::tcl_crossquery, Tcl::variadic());
+            i->def("orxonox::execute", TclThreadManager::tcl_execute, Tcl::variadic());
+            i->def("orxonox::running", TclThreadManager::tcl_running);
+
+            i->def("execute", TclThreadManager::tcl_execute, Tcl::variadic());
+            i->eval("proc query args { orxonox::query " + threadID + " $args }");
+            i->eval("proc crossquery {id args} { orxonox::crossquery " + threadID + " $id $args }");
+            i->eval("set id " + threadID);
+
+            i->eval("rename exit tcl::exit");
+            i->eval("proc exit {} { orxonox TclThreadManager destroy " + threadID + " }");
+
+            i->eval("redef_puts");
+
+//            i->eval("rename while tcl::while");
+//            i->eval("proc while {test command} { tcl::while {[uplevel 1 expr $test]} {uplevel 1 $command} }"); // (\"$test\" && [orxonox::running " + threadID + "]])
+//            i->eval("rename for tcl::for");
+//            i->eval("proc for {start test next command} { uplevel tcl::for \"$start\" \"$test\" \"$next\" \"$command\" }");
+        }
+        catch (Tcl::tcl_error const &e)
+        {   COUT(1) << "Tcl error while creating Tcl-interpreter (" << threadID << "): " << e.what() << std::endl;   }
+        catch (std::exception const &e)
+        {   COUT(1) << "Error while creating Tcl-interpreter (" << threadID << "): " << e.what() << std::endl;   }
+
+        return i;
+    }
+
+    TclInterpreterBundle* TclThreadManager::getInterpreterBundle(unsigned int threadID)
+    {
+        boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+        std::map<unsigned int, TclInterpreterBundle*>::iterator it = this->interpreterBundles_.find(threadID);
+        if (it != this->interpreterBundles_.end())
+        {
+            return (*it).second;
+        }
+        else
+        {
+            this->error("Error: No Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + " existing.");
+            return 0;
+        }
+    }
+
+    std::string TclThreadManager::dumpList(const std::list<unsigned int>& list)
+    {
+        std::string output = "";
+        for (std::list<unsigned int>::const_iterator it = list.begin(); it != list.end(); ++it)
+        {
+            if (it != list.begin())
+                output += " ";
+
+            output += getConvertedValue<unsigned int, std::string>(*it);
+        }
+        return output;
+    }
+
+    void TclThreadManager::error(const std::string& error)
+    {
+#if (BOOST_VERSION >= 103500)
+        if (boost::this_thread::get_id() != this->threadID_)
+#else
+        if (boost::thread() != this->threadID_)
+#endif
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::this_thread::yield();
+#else
+                boost::thread::yield();
+#endif
+                return;
+            }
+        }
+
+        this->forceCommandToFrontOfQueue("error " + error);
+    }
+
+    void TclThreadManager::debug(const std::string& error)
+    {
+#if (BOOST_VERSION >= 103500)
+        if (boost::this_thread::get_id() != this->threadID_)
+#else
+        if (boost::thread() != this->threadID_)
+#endif
+        {
+            boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+            if (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::this_thread::yield();
+#else
+                boost::thread::yield();
+#endif
+                return;
+            }
+        }
+
+        this->forceCommandToFrontOfQueue("debug " + error);
+    }
+
+    void TclThreadManager::pushCommandToQueue(const std::string& command)
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        while (this->orxonoxInterpreterBundle_.queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            this->fullQueueCondition_.wait(queue_lock);
+
+        this->orxonoxInterpreterBundle_.queue_.push_back(command);
+    }
+
+    void TclThreadManager::forceCommandToFrontOfQueue(const std::string& command)
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        this->orxonoxInterpreterBundle_.queue_.push_front(command);
+    }
+
+    std::string TclThreadManager::popCommandFromQueue()
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        std::string temp = this->orxonoxInterpreterBundle_.queue_.front();
+        this->orxonoxInterpreterBundle_.queue_.pop_front();
+        this->fullQueueCondition_.notify_one();
+        return temp;
+    }
+
+    bool TclThreadManager::queueIsEmpty()
+    {
+        boost::mutex::scoped_lock queue_lock(this->orxonoxInterpreterBundle_.queueMutex_);
+        return this->orxonoxInterpreterBundle_.queue_.empty();
+    }
+
+    void TclThreadManager::pushCommandToQueue(unsigned int threadID, const std::string& command)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+            if (bundle->queue_.size() >= TCLTHREADMANAGER_MAX_QUEUE_LENGTH)
+            {
+                this->error("Error: Queue of Tcl-interpreter " + getConvertedValue<unsigned int, std::string>(threadID) + " is full, couldn't add command.");
+                return;
+            }
+
+            bundle->queue_.push_back(command);
+        }
+    }
+
+    std::string TclThreadManager::popCommandFromQueue(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+            std::string temp = bundle->queue_.front();
+            bundle->queue_.pop_front();
+            return temp;
+        }
+        return "";
+    }
+
+    bool TclThreadManager::queueIsEmpty(unsigned int threadID)
+    {
+        TclInterpreterBundle* bundle = this->getInterpreterBundle(threadID);
+        if (bundle)
+        {
+            boost::mutex::scoped_lock queue_lock(bundle->queueMutex_);
+            return bundle->queue_.empty();
+        }
+        return true;
+    }
+
+    bool TclThreadManager::updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target)
+    {
+        if (querier == target)
+            return false;
+
+        boost::mutex::scoped_lock queriers_lock(target->queriersMutex_);
+
+        {
+            boost::mutex::scoped_lock queriers_lock(querier->queriersMutex_);
+            target->queriers_.insert(target->queriers_.end(), querier->queriers_.begin(), querier->queriers_.end());
+        }
+
+        target->queriers_.insert(target->queriers_.end(), querier->id_);
+
+        if (std::find(target->queriers_.begin(), target->queriers_.end(), target->id_) != target->queriers_.end())
+        {
+            this->error("Error: Circular query (" + this->dumpList(target->queriers_) + " -> " + getConvertedValue<unsigned int, std::string>(target->id_) + "), couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(target->id_) + " from other interpreter with ID " + getConvertedValue<unsigned int, std::string>(querier->id_) + ".");
+            return false;
+        }
+
+        return true;
+    }
+
+    std::string TclThreadManager::evalQuery(unsigned int querierID, const std::string& command)
+    {
+        TclInterpreterBundle* querier = this->getInterpreterBundle(querierID);
+        std::string output = "";
+        if (querier)
+        {
+            if (this->updateQueriersList(querier, &this->orxonoxInterpreterBundle_))
+            {
+#if (BOOST_VERSION >= 103500)
+                boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#else
+                boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#endif
+                this->orxonoxEvalCondition_.wait(interpreter_lock);
+
+                if (!CommandExecutor::execute(command, false))
+                    this->error("Error: Can't execute command \"" + command + "\"!");
+
+                if (CommandExecutor::getLastEvaluation().hasReturnvalue())
+                    output = CommandExecutor::getLastEvaluation().getReturnvalue().getString();
+            }
+
+            boost::mutex::scoped_lock queriers_lock(this->orxonoxInterpreterBundle_.queriersMutex_);
+            this->orxonoxInterpreterBundle_.queriers_.clear();
+        }
+        return output;
+    }
+
+    std::string TclThreadManager::evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command)
+    {
+        TclInterpreterBundle* target = 0;
+        if (threadID)
+            target = this->getInterpreterBundle(threadID);
+        else
+            target = &this->orxonoxInterpreterBundle_;
+
+        std::string output = "";
+        if (target)
+        {
+            TclInterpreterBundle* querier = 0;
+            if (querierID)
+                querier = this->getInterpreterBundle(querierID);
+            else
+                querier = &this->orxonoxInterpreterBundle_;
+
+            if (querier)
+            {
+                if (this->updateQueriersList(querier, target))
+                {
+#if (BOOST_VERSION >= 103500)
+                    boost::mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
+#else
+                    boost::try_mutex::scoped_try_lock interpreter_lock(target->interpreterMutex_);
+#endif
+                    bool successfullyLocked = false;
+                    try
+                    {
+                        if (querierID == 0 || std::find(querier->queriers_.begin(), querier->queriers_.end(), (unsigned int)0) != querier->queriers_.end())
+                            successfullyLocked = interpreter_lock.try_lock();
+                        else
+                        {
+                            while (!interpreter_lock.try_lock())
+                            {
+#if (BOOST_VERSION >= 103500)
+                                boost::this_thread::yield();
+#else
+                                boost::thread::yield();
+#endif
+                            }
+
+                            successfullyLocked = true;
+                        }
+                    } catch (...) {}
+
+                    if (successfullyLocked)
+                    {
+                        this->debug("TclThread_query: " + command);
+                        try
+                        {   output = (std::string)target->interpreter_->eval(command);   }
+                        catch (Tcl::tcl_error const &e)
+                        {   this->error("Tcl error: " + (std::string)e.what());   }
+                        catch (std::exception const &e)
+                        {   this->error("Error while executing Tcl: " + (std::string)e.what());   }
+                    }
+                    else
+                    {
+                        this->error("Error: Couldn't query Tcl-interpreter with ID " + getConvertedValue<unsigned int, std::string>(threadID) + ", interpreter is busy right now.");
+                    }
+                }
+
+                boost::mutex::scoped_lock queriers_lock(target->queriersMutex_);
+                target->queriers_.clear();
+            }
+        }
+        return output;
+    }
+
+    void TclThreadManager::tick(float dt)
+    {
+        {
+            this->orxonoxEvalCondition_.notify_one();
+#if (BOOST_VERSION >= 103500)
+            boost::this_thread::yield();
+#else
+            boost::thread::yield();
+#endif
+        }
+
+        {
+            boost::mutex::scoped_lock bundles_lock(this->bundlesMutex_);
+            for (std::map<unsigned int, TclInterpreterBundle*>::iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
+            {
+                boost::mutex::scoped_lock queue_lock((*it).second->queueMutex_);
+                if (!(*it).second->queue_.empty())
+                {
+                    std::string command = (*it).second->queue_.front();
+                    (*it).second->queue_.pop_front();
+                    {
+                        boost::mutex::scoped_lock finished_lock((*it).second->finishedMutex_);
+                        (*it).second->finished_ = false;
+                    }
+                    boost::thread(boost::bind(&tclThread, (*it).second, command));
+                }
+            }
+        }
+
+        {
+#if (BOOST_VERSION >= 103500)
+            boost::mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#else
+            boost::try_mutex::scoped_lock interpreter_lock(this->orxonoxInterpreterBundle_.interpreterMutex_);
+#endif
+            unsigned long maxtime = (unsigned long)(dt * 1000000 * TCLTHREADMANAGER_MAX_CPU_USAGE);
+            Ogre::Timer timer;
+            while (!this->queueIsEmpty())
+            {
+                CommandExecutor::execute(this->popCommandFromQueue(), false);
+                if (timer.getMicroseconds() > maxtime)
+                    break;
+            }
+        }
+    }
+
+    std::list<unsigned int> TclThreadManager::getThreadList() const
+    {
+        boost::mutex::scoped_lock bundles_lock(TclThreadManager::getInstance().bundlesMutex_);
+        std::list<unsigned int> threads;
+        for (std::map<unsigned int, TclInterpreterBundle*>::const_iterator it = this->interpreterBundles_.begin(); it != this->interpreterBundles_.end(); ++it)
+            threads.push_back((*it).first);
+        return threads;
+    }
+
+    void tclThread(TclInterpreterBundle* interpreterBundle, std::string command)
+    {
+        TclThreadManager::getInstance().debug("TclThread_execute: " + command);
+#if (BOOST_VERSION >= 103500)
+        boost::mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
+#else
+        boost::try_mutex::scoped_lock interpreter_lock(interpreterBundle->interpreterMutex_);
+#endif
+        try
+        {
+            interpreterBundle->interpreter_->eval(command);
+        }
+        catch (Tcl::tcl_error const &e)
+        {
+            TclThreadManager::getInstance().error("Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + ") error: " + e.what());
+        }
+        catch (std::exception const &e)
+        {
+            TclThreadManager::getInstance().error("Error while executing Tcl (ID " + getConvertedValue<unsigned int, std::string>(interpreterBundle->id_) + "): " + e.what());
+        }
+
+        boost::mutex::scoped_lock finished_lock(interpreterBundle->finishedMutex_);
+        interpreterBundle->finished_ = true;
+        interpreterBundle->finishedCondition_.notify_all();
+    }
+}
Index: /code/branches/ceguilua/src/core/TclThreadManager.h
===================================================================
--- /code/branches/ceguilua/src/core/TclThreadManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/TclThreadManager.h	(revision 1801)
@@ -0,0 +1,140 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TclThreadManager_H__
+#define _TclThreadManager_H__
+
+#include "CorePrereqs.h"
+
+#include <queue>
+#include <map>
+#include <list>
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/thread/thread.hpp>
+
+#include "cpptcl/CppTcl.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    struct _CoreExport TclInterpreterBundle
+    {
+        unsigned int id_;
+
+        std::list<std::string> queue_;
+        boost::mutex queueMutex_;
+
+        Tcl::interpreter* interpreter_;
+        std::string interpreterName_;
+        boost::try_mutex interpreterMutex_;
+
+        std::list<unsigned int> queriers_;
+        boost::mutex queriersMutex_;
+
+        bool running_;
+        boost::mutex runningMutex_;
+
+        bool finished_;
+        boost::mutex finishedMutex_;
+        boost::condition finishedCondition_;
+    };
+
+    class _CoreExport TclThreadManager : public OrxonoxClass
+    {
+        friend class IRC;
+        friend class TclBind;
+
+        public:
+            TclThreadManager(Tcl::interpreter* interpreter);
+            ~TclThreadManager();
+
+            static TclThreadManager& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+
+            static unsigned int create();
+            static unsigned int createID(unsigned int threadID);
+            static void destroy(unsigned int threadID);
+            static void execute(unsigned int threadID, const std::string& command);
+            static std::string query(unsigned int threadID, const std::string& command);
+            static void status();
+            static void dump(unsigned int threadID);
+            static void flush(unsigned int threadID);
+
+            void error(const std::string& error);
+            void debug(const std::string& error);
+
+            virtual void tick(float dt);
+
+            std::list<unsigned int> getThreadList() const;
+
+        private:
+            TclThreadManager(const TclThreadManager& other);
+
+            static void tcl_execute(Tcl::object const &args);
+            static std::string tcl_query(int querierID, Tcl::object const &args);
+            static std::string tcl_crossquery(int querierID, int threadID, Tcl::object const &args);
+            static bool tcl_running(int threadID);
+
+            Tcl::interpreter* createNewTclInterpreter(const std::string& threadID);
+            TclInterpreterBundle* getInterpreterBundle(unsigned int threadID);
+            std::string dumpList(const std::list<unsigned int>& list);
+
+            void pushCommandToQueue(const std::string& command);
+            void forceCommandToFrontOfQueue(const std::string& command);
+            std::string popCommandFromQueue();
+            bool queueIsEmpty();
+
+            void pushCommandToQueue(unsigned int threadID, const std::string& command);
+            std::string popCommandFromQueue(unsigned int threadID);
+            bool queueIsEmpty(unsigned int threadID);
+
+            bool updateQueriersList(TclInterpreterBundle* querier, TclInterpreterBundle* target);
+
+            std::string evalQuery(unsigned int querierID, const std::string& command);
+            std::string evalQuery(unsigned int querierID, unsigned int threadID, const std::string& command);
+
+            unsigned int threadCounter_;
+            TclInterpreterBundle orxonoxInterpreterBundle_;
+            std::map<unsigned int, TclInterpreterBundle*> interpreterBundles_;
+            boost::mutex bundlesMutex_;
+            boost::condition fullQueueCondition_;
+            boost::condition orxonoxEvalCondition_;
+#if (BOOST_VERSION >= 103500)
+            boost::thread::id threadID_;
+#else
+            boost::thread threadID_;
+#endif
+
+            static TclThreadManager* singletonRef_s;
+    };
+
+    _CoreExport void tclThread(TclInterpreterBundle* interpreterBundle, std::string command);
+}
+
+#endif /* _TclThreadManager_H__ */
Index: /code/branches/ceguilua/src/core/XMLPort.cc
===================================================================
--- /code/branches/ceguilua/src/core/XMLPort.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/XMLPort.cc	(revision 1801)
@@ -0,0 +1,44 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "XMLPort.h"
+#include "Language.h"
+#include "Loader.h"
+#include "Namespace.h"
+#include "CoreIncludes.h"
+
+namespace orxonox
+{
+    // ################################
+    // ###  XMLPortObjectContainer  ###
+    // ################################
+    bool XMLPortObjectContainer::identifierIsIncludedInLoaderMask(const Identifier* identifier)
+    {
+        return ((!this->bApplyLoaderMask_) || identifier->isA(Class(Namespace)) || Loader::currentMask_s.isIncluded(identifier));
+    }
+}
Index: /code/branches/ceguilua/src/core/XMLPort.h
===================================================================
--- /code/branches/ceguilua/src/core/XMLPort.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/XMLPort.h	(revision 1801)
@@ -0,0 +1,370 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _XMLPort_H__
+#define _XMLPort_H__
+
+#include "CorePrereqs.h"
+
+#include "util/Debug.h"
+#include "util/XMLIncludes.h"
+#include "util/MultiType.h"
+#include "tinyxml/ticpp.h"
+#include "Executor.h"
+#include "CoreIncludes.h"
+#include "BaseObject.h"
+
+
+#define XMLPortParam(classname, paramname, loadfunction, savefunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
+#define XMLPortParamTemplate(classname, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode)
+
+#define XMLPortParamLoadOnly(classname, paramname, loadfunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
+#define XMLPortParamLoadOnlyTemplate(classname, paramname, loadfunction, xmlelement, mode, ...) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##0, classname, classname, this, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), 0, xmlelement, mode)
+
+#define XMLPortParamExtern(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
+#define XMLPortParamExternTemplate(classname, externclass, object, paramname, loadfunction, savefunction, xmlelement, mode, ...) \
+    XMLPortParamGeneric(xmlcontainer##loadfunction##savefunction, classname, externclass, object, paramname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&externclass::loadfunction), std::string( #externclass ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&externclass::savefunction), std::string( #externclass ) + "::" + #savefunction), xmlelement, mode);
+
+#define XMLPortParamGeneric(containername, classname, objectclass, object, paramname, loadexecutor, saveexecutor, xmlelement, mode) \
+    orxonox::XMLPortClassParamContainer<objectclass>* containername = (orxonox::XMLPortClassParamContainer<objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortParamContainer(paramname)); \
+    if (!containername) \
+    { \
+        containername = new orxonox::XMLPortClassParamContainer<objectclass>(std::string(paramname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor); \
+        ClassIdentifier<classname>::getIdentifier()->addXMLPortParamContainer(paramname, containername); \
+    } \
+    containername->port((BaseObject*)this, object, xmlelement, mode)
+
+
+#define XMLPortObject(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+#define XMLPortObjectTemplate(classname, objectclass, sectionname, loadfunction, savefunction, xmlelement, mode, bApplyLoaderMask, bLoadBefore, ...) \
+    XMLPortObjectGeneric(xmlcontainer##loadfunction##savefunction, classname, objectclass, sectionname, orxonox::createExecutor(orxonox::createFunctor< __VA_ARGS__ >(&classname::loadfunction), std::string( #classname ) + "::" + #loadfunction), orxonox::createExecutor(orxonox::createFunctor(&classname::savefunction), std::string( #classname ) + "::" + #savefunction), xmlelement, mode, bApplyLoaderMask, bLoadBefore)
+
+#define XMLPortObjectGeneric(containername, classname, objectclass, sectionname, loadexecutor, saveexecutor, xmlelement, mode, bApplyLoaderMask, bLoadBefore) \
+    orxonox::XMLPortClassObjectContainer<classname, objectclass>* containername = (orxonox::XMLPortClassObjectContainer<classname, objectclass>*)(ClassIdentifier<classname>::getIdentifier()->getXMLPortObjectContainer(sectionname)); \
+    if (!containername) \
+    { \
+        containername = new orxonox::XMLPortClassObjectContainer<classname, objectclass>(std::string(sectionname), ClassIdentifier<classname>::getIdentifier(), loadexecutor, saveexecutor, bApplyLoaderMask, bLoadBefore); \
+        ClassIdentifier<classname>::getIdentifier()->addXMLPortObjectContainer(sectionname, containername); \
+    } \
+    containername->port(this, xmlelement, mode)
+
+
+namespace orxonox
+{
+    // ###############################
+    // ###  XMLPortParamContainer  ###
+    // ###############################
+    class _CoreExport XMLPortParamContainer
+    {
+    public:
+        enum ParseResult
+        {
+            PR_not_started,
+            PR_finished,
+            PR_waiting_for_default_values
+        };
+
+        public:
+            XMLPortParamContainer()
+                { this->parseResult_ = PR_not_started; }
+            virtual ~XMLPortParamContainer() {}
+
+            inline const std::string& getName() const
+                { return this->paramname_; }
+
+            virtual XMLPortParamContainer& description(const std::string description) = 0;
+            virtual const std::string& getDescription() = 0;
+
+            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4) = 0;
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5) = 0;
+
+        protected:
+            std::string paramname_;
+            ParseResult parseResult_;
+            Identifier* identifier_;
+            BaseObject* owner_;
+    };
+
+    template <class T>
+    class XMLPortClassParamContainer : public XMLPortParamContainer
+    {
+        struct ParseParams
+        {
+            T* object;
+            Element* xmlelement;
+            XMLPort::Mode mode;
+        };
+
+        public:
+            XMLPortClassParamContainer(const std::string paramname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor)
+            {
+                this->paramname_ = paramname;
+                this->identifier_ = identifier;
+                this->loadexecutor_ = loadexecutor;
+                this->saveexecutor_ = saveexecutor;
+            }
+
+            XMLPortParamContainer& port(BaseObject* owner, T* object, Element& xmlelement, XMLPort::Mode mode)
+            {
+                this->owner_ = owner;
+                this->parseParams_.object = object;
+                this->parseParams_.xmlelement = &xmlelement;
+                this->parseParams_.mode = mode;
+
+                if (mode == XMLPort::LoadObject)
+                {
+                    try
+                    {
+                        std::string attribute = xmlelement.GetAttribute(this->paramname_);
+                        if ((attribute.size() > 0) || (this->loadexecutor_->allDefaultValuesSet()))
+                        {
+                            COUT(5) << this->owner_->getLoaderIndentation() << "Loading parameter " << this->paramname_ << " in " << this->identifier_->getName() << " (objectname " << this->owner_->getName() << ")." << std::endl << this->owner_->getLoaderIndentation();
+                            if (this->loadexecutor_->parse(object, attribute, ","))
+                                this->parseResult_ = PR_finished;
+                            else
+                                this->parseResult_ = PR_waiting_for_default_values;
+                        }
+                        else
+                            this->parseResult_ = PR_waiting_for_default_values;
+                    }
+                    catch (ticpp::Exception& ex)
+                    {
+                        COUT(1) << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading attribute '" << this->paramname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << this->owner_->getName() << ") in " << this->owner_->getLevelfile() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
+                    }
+                }
+                else
+                {
+                    if (this->saveexecutor_)
+                    {
+//                        xmlelement.SetAttribute(this->paramname_, "...");
+                    }
+                }
+
+                return (*this);
+            }
+
+            XMLPortParamContainer& port(BaseObject* owner, const ParseParams& parseParams)
+            {
+                return this->port(owner, parseParams.object, *parseParams.xmlelement, parseParams.mode);
+            }
+
+            XMLPortParamContainer& portIfWaitingForDefaultValues(const ParseResult& result, const ParseParams& params)
+            {
+                if (result == PR_waiting_for_default_values)
+                    return this->port(this->owner_, params);
+                else
+                    return (*this);
+            }
+
+            virtual XMLPortParamContainer& description(const std::string description)
+                { this->loadexecutor_->setDescription(description); return (*this); }
+            virtual const std::string& getDescription()
+                { return this->loadexecutor_->getDescription(); }
+
+            virtual XMLPortParamContainer& defaultValue(unsigned int index, const MultiType& param)
+            {
+                if (!this->loadexecutor_->defaultValueSet(index))
+                    this->loadexecutor_->setDefaultValue(index, param);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1)
+            {
+                if (!this->loadexecutor_->defaultValueSet(0))
+                    this->loadexecutor_->setDefaultValues(param1);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)))
+                    this->loadexecutor_->setDefaultValues(param1, param2);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)))
+                    this->loadexecutor_->setDefaultValues(param1, param2, param3);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)))
+                    this->loadexecutor_->setDefaultValues(param1, param2, param3, param4);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+            virtual XMLPortParamContainer& defaultValues(const MultiType& param1, const MultiType& param2, const MultiType& param3, const MultiType& param4, const MultiType& param5)
+            {
+                if ((!this->loadexecutor_->defaultValueSet(0)) || (!this->loadexecutor_->defaultValueSet(1)) || (!this->loadexecutor_->defaultValueSet(2)) || (!this->loadexecutor_->defaultValueSet(3)) || (!this->loadexecutor_->defaultValueSet(4)))
+                    this->loadexecutor_->setDefaultValues(param1, param2, param3, param4, param5);
+                return this->portIfWaitingForDefaultValues(this->parseResult_, this->parseParams_);
+            }
+
+        private:
+            ExecutorMember<T>* loadexecutor_;
+            ExecutorMember<T>* saveexecutor_;
+            ParseParams parseParams_;
+    };
+
+
+    // ################################
+    // ###  XMLPortObjectContainer  ###
+    // ################################
+    class _CoreExport XMLPortObjectContainer
+    {
+        public:
+            XMLPortObjectContainer()
+                { this->bApplyLoaderMask_ = false; }
+            virtual ~XMLPortObjectContainer() {}
+
+            inline const std::string& getName() const
+                { return this->sectionname_; }
+
+            virtual XMLPortObjectContainer& description(const std::string description) = 0;
+            virtual const std::string& getDescription() = 0;
+
+            bool identifierIsIncludedInLoaderMask(const Identifier* identifier);
+
+        protected:
+            std::string sectionname_;
+            bool bApplyLoaderMask_;
+            bool bLoadBefore_;
+            Identifier* identifier_;
+    };
+
+    template <class T, class O>
+    class XMLPortClassObjectContainer : public XMLPortObjectContainer
+    {
+        public:
+            XMLPortClassObjectContainer(const std::string sectionname, Identifier* identifier, ExecutorMember<T>* loadexecutor, ExecutorMember<T>* saveexecutor, bool bApplyLoaderMask, bool bLoadBefore)
+            {
+                this->sectionname_ = sectionname;
+                this->identifier_ = identifier;
+                this->loadexecutor_ = loadexecutor;
+                this->saveexecutor_ = saveexecutor;
+                this->bApplyLoaderMask_ = bApplyLoaderMask;
+                this->bLoadBefore_ = bLoadBefore;
+            }
+
+            XMLPortObjectContainer& port(T* object, Element& xmlelement, XMLPort::Mode mode)
+            {
+                if (mode == XMLPort::LoadObject)
+                {
+                    try
+                    {
+                        Element* xmlsubelement;
+                        if ((this->sectionname_ != "") && (this->sectionname_.size() > 0))
+                            xmlsubelement = xmlelement.FirstChildElement(this->sectionname_, false);
+                        else
+                            xmlsubelement = &xmlelement;
+
+                        if (xmlsubelement)
+                        {
+                            for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
+                            {
+                                Identifier* identifier = GetIdentifier(child->Value());
+                                if (identifier)
+                                {
+                                    if (identifier->isA(Class(O)))
+                                    {
+                                        if (this->identifierIsIncludedInLoaderMask(identifier))
+                                        {
+                                            COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "fabricating " << child->Value() << "..." << std::endl;
+
+                                            BaseObject* newObject = identifier->fabricate();
+                                            newObject->setLoaderIndentation(((BaseObject*)object)->getLoaderIndentation() + "  ");
+                                            newObject->setLevel(((BaseObject*)object)->getLevel());
+                                            newObject->setNamespace(((BaseObject*)object)->getNamespace());
+
+                                            if (this->bLoadBefore_)
+                                            {
+                                                newObject->XMLPort(*child, XMLPort::LoadObject);
+                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (objectname " << newObject->getName() << ") to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+                                            }
+                                            else
+                                            {
+                                                COUT(4) << ((BaseObject*)object)->getLoaderIndentation() << "assigning " << child->Value() << " (object not yet loaded) to " << this->identifier_->getName() << " (objectname " << ((BaseObject*)object)->getName() << ")" << std::endl;
+                                            }
+
+                                            COUT(5) << ((BaseObject*)object)->getLoaderIndentation();
+                                            (*this->loadexecutor_)(object, newObject);
+
+                                            if (!this->bLoadBefore_)
+                                                newObject->XMLPort(*child, XMLPort::LoadObject);
+
+                                            COUT(5) << ((BaseObject*)object)->getLoaderIndentation() << "...fabricated " << child->Value() << " (objectname " << newObject->getName() << ")." << std::endl;
+                                        }
+                                    }
+                                    else
+                                    {
+                                        COUT(2) << ((BaseObject*)object)->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a '" << Class(O)->getName() << "'." << std::endl;
+                                    }
+                                }
+                                else
+                                {
+                                    COUT(2) << object->getLoaderIndentation() << "Warning: '" << child->Value() << "' is not a valid classname." << std::endl;
+                                }
+                            }
+                        }
+                    }
+                    catch (ticpp::Exception& ex)
+                    {
+                        COUT(1) << std::endl;
+                        COUT(1) << "An error occurred in XMLPort.h while loading a '" << Class(O)->getName() << "' in '" << this->sectionname_ << "' of '" << this->identifier_->getName() << "' (objectname: " << ((BaseObject*)object)->getName() << ") in " << object->getLevelfile() << ":" << std::endl;
+                        COUT(1) << ex.what() << std::endl;
+                    }
+                }
+                else
+                {
+                }
+
+                return (*this);
+            }
+
+            virtual XMLPortObjectContainer& description(const std::string description)
+                { this->loadexecutor_->setDescription(description); return (*this); }
+            virtual const std::string& getDescription()
+                { return this->loadexecutor_->getDescription(); }
+
+        private:
+            ExecutorMember<T>* loadexecutor_;
+            ExecutorMember<T>* saveexecutor_;
+    };
+}
+
+#endif /* _XMLPort_H__ */
Index: /code/branches/ceguilua/src/core/input/Button.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/Button.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/Button.cc	(revision 1801)
@@ -0,0 +1,231 @@
+/*
+ *   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 different input handlers.
+*/
+
+#include "Button.h"
+#include "util/Convert.h"
+#include "util/SubString.h"
+#include "util/String.h"
+#include "util/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandEvaluation.h"
+#include "core/CommandExecutor.h"
+#include "InputCommands.h"
+
+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,
+                    '\\', 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
+        {
+            COUT(3) << "Warning while parsing binding for button/axis " << this->name_ << ". "
+                << message << std::endl;
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/input/Button.h
===================================================================
--- /code/branches/ceguilua/src/core/input/Button.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/Button.h	(revision 1801)
@@ -0,0 +1,72 @@
+/*
+ *   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
+    Different definitions of input processing.
+*/
+
+#ifndef _Button_H__
+#define _Button_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <vector>
+
+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);
+
+        //! 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);
+    };
+}
+
+#endif /* _Button_H__ */
Index: /code/branches/ceguilua/src/core/input/CalibratorCallback.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/CalibratorCallback.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/CalibratorCallback.cc	(revision 1801)
@@ -0,0 +1,47 @@
+/*
+ *   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 different input handlers.
+*/
+
+#include "CalibratorCallback.h"
+#include "InputManager.h"
+
+namespace orxonox
+{
+    void CalibratorCallback::keyPressed(const orxonox::KeyEvent &evt)
+    {
+        if (evt.key == KeyCode::Return)
+        {
+            //InputManager::setInputState(InputManager::IS_NOCALIBRATE);
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/input/CalibratorCallback.h
===================================================================
--- /code/branches/ceguilua/src/core/input/CalibratorCallback.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/CalibratorCallback.h	(revision 1801)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+@file
+@brief
+    Different definitions of input processing.
+*/
+
+#ifndef _CalibratorCallback_H__
+#define _CalibratorCallback_H__
+
+#include "core/CorePrereqs.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class _CoreExport CalibratorCallback : public KeyHandler
+    {
+    public:
+        CalibratorCallback()  { }
+        ~CalibratorCallback() { }
+
+    private:
+        void keyPressed (const KeyEvent& evt);
+        void keyReleased(const KeyEvent& evt) { }
+        void keyHeld    (const KeyEvent& evt) { }
+
+        void tickInput(float dt) { }
+    };
+}
+
+#endif /* _CalibratorCallback_H__ */
Index: /code/branches/ceguilua/src/core/input/ExtendedInputState.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/ExtendedInputState.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/ExtendedInputState.cc	(revision 1801)
@@ -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/branches/ceguilua/src/core/input/ExtendedInputState.h
===================================================================
--- /code/branches/ceguilua/src/core/input/ExtendedInputState.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/ExtendedInputState.h	(revision 1801)
@@ -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/branches/ceguilua/src/core/input/HalfAxis.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/HalfAxis.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/HalfAxis.cc	(revision 1801)
@@ -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
+    Implementation of the different input handlers.
+*/
+
+#include "HalfAxis.h"
+#include "core/CommandEvaluation.h"
+#include "InputCommands.h"
+
+namespace orxonox
+{
+    void HalfAxis::clear()
+    {
+        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;
+        }
+    }
+
+    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;
+    }
+}
Index: /code/branches/ceguilua/src/core/input/HalfAxis.h
===================================================================
--- /code/branches/ceguilua/src/core/input/HalfAxis.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/HalfAxis.h	(revision 1801)
@@ -0,0 +1,71 @@
+/*
+ *   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
+    Different definitions of input processing.
+*/
+
+#ifndef _HalfAxis_H__
+#define _HalfAxis_H__
+
+#include "core/CorePrereqs.h"
+#include "Button.h"
+
+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();
+
+        // axis related
+        float relVal_;
+        float absVal_;
+        ParamCommand** paramCommands_;
+        unsigned int nParamCommands_;
+
+        // button related
+        bool wasDown_;
+        bool hasChanged_;
+    };
+}
+
+#endif /* _HalfAxis_H__ */
Index: /code/branches/ceguilua/src/core/input/InputBuffer.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/InputBuffer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputBuffer.cc	(revision 1801)
@@ -0,0 +1,257 @@
+/*
+ *   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
+ *
+ */
+
+#include "InputBuffer.h"
+
+#include <iostream>
+
+#include "util/Clipboard.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    InputBuffer::InputBuffer()
+    {
+        RegisterRootObject(InputBuffer);
+
+        this->buffer_ = "";
+        this->cursor_ = 0;
+        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
+                               ABCDEFGHIJKLMNOPQRSTUVWXYZ \
+                               äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \
+                               0123456789 \
+                               \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
+
+        this->lastKey_ = KeyCode::Unassigned;
+        this->timeSinceKeyPressed_ = 0.0f;
+        this->timeSinceKeyRepeated_ = 0.0f;
+        this->keysToRepeat_ = 0;
+
+        setConfigValues();
+    }
+
+    InputBuffer::InputBuffer(const std::string allowedChars)
+    {
+        RegisterRootObject(InputBuffer);
+
+        this->allowedChars_ = allowedChars;
+        this->buffer_ = "";
+        this->cursor_ = 0;
+
+        this->lastKey_ = KeyCode::Unassigned;
+        this->timeSinceKeyPressed_ = 0.0f;
+        this->timeSinceKeyRepeated_ = 0.0f;
+        this->keysToRepeat_ = 0;
+
+        setConfigValues();
+    }
+
+    void InputBuffer::setConfigValues()
+    {
+        SetConfigValue(keyRepeatDeleay_, 0.4).description("Key repeat deleay of the input buffer");
+        SetConfigValue(keyRepeatTime_, 0.022).description("Key repeat time of the input buffer");
+
+        if (keyRepeatDeleay_ < 0.0)
+        {
+            ResetConfigValue(keyRepeatDeleay_);
+        }
+        if (keyRepeatTime_ < 0.0)
+        {
+            ResetConfigValue(keyRepeatTime_);
+        }
+    }
+
+    void InputBuffer::set(const std::string& input, bool update)
+    {
+        this->clear(false);
+        this->insert(input, update);
+    }
+
+    void InputBuffer::insert(const std::string& input, bool update)
+    {
+        for (unsigned int i = 0; i < input.size(); ++i)
+        {
+            this->insert(input[i], false);
+
+            if (update)
+                this->updated(input[i], false);
+        }
+
+        if (update)
+            this->updated();
+    }
+
+    void InputBuffer::insert(const char& input, bool update)
+    {
+        if (this->charIsAllowed(input))
+        {
+            this->buffer_.insert(this->cursor_, 1, input);
+            ++this->cursor_;
+        }
+
+        if (update)
+            this->updated(input, true);
+    }
+
+    void InputBuffer::clear(bool update)
+    {
+        this->buffer_ = "";
+        this->cursor_ = 0;
+
+        if (update)
+            this->updated();
+    }
+
+    void InputBuffer::removeBehindCursor(bool update)
+    {
+        if (this->cursor_ > 0)
+        {
+            --this->cursor_;
+            this->buffer_.erase(this->cursor_, 1);
+
+            if (update)
+                this->updated();
+        }
+    }
+
+    void InputBuffer::removeAtCursor(bool update)
+    {
+        if (this->cursor_ < this->buffer_.size())
+        {
+            this->buffer_.erase(this->cursor_, 1);
+
+            if (update)
+                this->updated();
+        }
+    }
+
+    void InputBuffer::updated()
+    {
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->bListenToAllChanges_)
+                (*it)->callFunction();
+        }
+    }
+
+    void InputBuffer::updated(const char& update, bool bSingleInput)
+    {
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((!(*it)->trueKeyFalseChar_) && ((*it)->bListenToAllChanges_ || ((*it)->char_ == update)) && (!(*it)->bOnlySingleInput_ || bSingleInput))
+                (*it)->callFunction();
+        }
+    }
+
+    bool InputBuffer::charIsAllowed(const char& input)
+    {
+        if (this->allowedChars_ == "")
+            return true;
+        else
+            return (this->allowedChars_.find(input) != std::string::npos);
+    }
+
+
+    void InputBuffer::processKey(const KeyEvent &evt)
+    {
+        if (evt.isModifierDown(KeyboardModifier::Alt) && evt.key == KeyCode::Tab)
+            return;
+
+        for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+        {
+            if ((*it)->trueKeyFalseChar_ && ((*it)->key_ == evt.key))
+                (*it)->callFunction();
+        }
+
+        if (evt.isModifierDown(KeyboardModifier::Ctrl))
+        {
+            if (evt.key == KeyCode::V)
+                this->insert(fromClipboard());
+            else if (evt.key == KeyCode::C)
+                toClipboard(this->buffer_);
+            else if (evt.key == KeyCode::X)
+            {
+                toClipboard(this->buffer_);
+                this->clear();
+            }
+        }
+        else if (evt.isModifierDown(KeyboardModifier::Shift))
+        {
+            if (evt.key == KeyCode::Insert)
+                this->insert(fromClipboard());
+            else if (evt.key == KeyCode::Delete)
+            {
+                toClipboard(this->buffer_);
+                this->clear();
+            }
+        }
+
+        this->insert((char)evt.text);
+    }
+
+    /**
+        @brief This tick() function is called by the InputManager if the InputBuffer is active.
+        @param dt Delta time
+    */
+    void InputBuffer::tickInput(float dt)
+    {
+        timeSinceKeyPressed_ += dt;
+        if (keysToRepeat_ < 10 && timeSinceKeyPressed_ > keyRepeatDeleay_)
+        {
+            // initial time out has gone by, start repeating keys
+            while (timeSinceKeyPressed_ - timeSinceKeyRepeated_ > keyRepeatTime_)
+            {
+                timeSinceKeyRepeated_ += keyRepeatTime_;
+                keysToRepeat_++;
+            }
+        }
+    }
+
+    void InputBuffer::keyPressed(const KeyEvent &evt)
+    {
+        lastKey_ = evt.key;
+        timeSinceKeyPressed_ = 0.0;
+        timeSinceKeyRepeated_ = keyRepeatDeleay_;
+        keysToRepeat_ = 0;
+
+        processKey(evt);
+    }
+
+    void InputBuffer::keyHeld(const KeyEvent& evt)
+    {
+        if (evt.key == lastKey_)
+        {
+            while (keysToRepeat_)
+            {
+                processKey(evt);
+                keysToRepeat_--;
+            }
+        }
+    }
+}
Index: /code/branches/ceguilua/src/core/input/InputBuffer.h
===================================================================
--- /code/branches/ceguilua/src/core/input/InputBuffer.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputBuffer.h	(revision 1801)
@@ -0,0 +1,190 @@
+/*
+ *   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
+ *
+ */
+
+#ifndef _InputBuffer_H__
+#define _InputBuffer_H__
+
+#include "core/CorePrereqs.h"
+
+#include <string>
+#include <list>
+
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    class BaseInputBufferListenerTuple
+    {
+    public:
+        BaseInputBufferListenerTuple(bool bListenToAllChanges, bool bOnlySingleInput,
+            bool trueKeyFalseChar, char _char, KeyCode::Enum key)
+            : bListenToAllChanges_(bListenToAllChanges), bOnlySingleInput_(bOnlySingleInput),
+              trueKeyFalseChar_(trueKeyFalseChar), char_(_char), key_(key)
+        { }
+        virtual ~BaseInputBufferListenerTuple() { }
+        virtual void callFunction() = 0;
+        bool bListenToAllChanges_;
+        bool bOnlySingleInput_;
+        bool trueKeyFalseChar_;
+        char char_;
+        KeyCode::Enum key_;
+    };
+
+    template <class T>
+    class InputBufferListenerTuple : public BaseInputBufferListenerTuple
+    {
+    public:
+        InputBufferListenerTuple(T* listener, void (T::*function)(), bool bListenToAllChanges,
+            bool bOnlySingleInput, bool trueKeyFalseChar, char _char, KeyCode::Enum key)
+            : BaseInputBufferListenerTuple(bListenToAllChanges, bOnlySingleInput, trueKeyFalseChar, _char, key),
+              listener_(listener), function_(function)
+        { }
+        virtual ~InputBufferListenerTuple() { }
+        void callFunction()
+        {
+            (listener_->*function_)();
+        }
+        T* listener_;
+        void (T::*function_)();
+    };
+
+    class _CoreExport InputBuffer : public KeyHandler, public OrxonoxClass
+    {
+        public:
+            InputBuffer();
+            InputBuffer(const std::string allowedChars);
+
+            void setConfigValues();
+
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, true, bOnlySingleInput, false, '\0', KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), char _char, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, char _char, bool bOnlySingleInput)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, bOnlySingleInput, false, _char, KeyCode::Unassigned);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+
+            template <class T>
+            void registerListener(T* listener, void (T::*function)(), KeyCode::Enum key)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+            template <class T>
+            void registerListener(T* listener, void (T::*function)() const, KeyCode::Enum key)
+            {
+                InputBufferListenerTuple<T>* newTuple = new InputBufferListenerTuple<T>(listener, (void (T::*)())function, false, true, true, '\0', key);
+                this->listeners_.insert(this->listeners_.end(), newTuple);
+            }
+
+            template <class T>
+            void unregisterListener(T* listener)
+            {
+                for (std::list<BaseInputBufferListenerTuple*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+                {
+                    InputBufferListenerTuple<T>* refListener = dynamic_cast<InputBufferListenerTuple<T>*>(*it);
+                    if (refListener && refListener->listener_ == listener)
+                        this->listeners_.erase(it++);
+                    else
+                        it++;
+                }
+            }
+
+            void set(const std::string& input, bool update = true);
+            void insert(const std::string& input, bool update = true);
+            void insert(const char& input, bool update = true);
+            void clear(bool update = true);
+            void removeAtCursor(bool update = true);
+            void removeBehindCursor(bool update = true);
+
+            void updated();
+            void updated(const char& update, bool bSingleInput);
+
+            inline std::string get() const
+                { return this->buffer_; }
+            inline unsigned int getSize() const
+                { return this->buffer_.size(); }
+
+            inline unsigned int getCursorPosition() const
+                { return this->cursor_; }
+            inline void setCursorPosition(unsigned int cursor)
+                { if (cursor <= this->buffer_.size()) { this->cursor_ = cursor; } }
+            inline void setCursorToEnd()
+                { this->cursor_ = this->buffer_.size(); }
+            inline void setCursorToBegin()
+                { this->cursor_ = 0; }
+            inline void increaseCursor()
+                { if (this->cursor_ < this->buffer_.size()) { ++this->cursor_; } }
+            inline void decreaseCursor()
+                { if (this->cursor_ > 0) { --this->cursor_; } }
+
+        private:
+            bool charIsAllowed(const char& input);
+
+            void keyPressed (const KeyEvent& evt);
+            void keyReleased(const KeyEvent& evt) { }
+            void keyHeld    (const KeyEvent& evt);
+            void processKey (const KeyEvent &e);
+
+            void tickInput(float dt);
+            void tickKey(float dt) { }
+
+            std::string buffer_;
+            std::list<BaseInputBufferListenerTuple*> listeners_;
+            std::string allowedChars_;
+            unsigned int cursor_;
+
+            KeyCode::Enum lastKey_;
+            float timeSinceKeyPressed_;
+            float timeSinceKeyRepeated_;
+            int keysToRepeat_;
+
+            float keyRepeatDeleay_;
+            float keyRepeatTime_;
+    };
+}
+
+#endif /* _InputBuffer_H__ */
Index: /code/branches/ceguilua/src/core/input/InputCommands.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/InputCommands.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputCommands.cc	(revision 1801)
@@ -0,0 +1,134 @@
+/*
+ *   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 different input handlers.
+*/
+
+#include "InputCommands.h"
+#include "core/CommandExecutor.h"
+
+namespace orxonox
+{
+    // ###############################
+    // ###  BufferedParamCommand   ###
+    // ###############################
+
+    /**
+    @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()
+    {
+        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;
+    }
+
+    // ###############################
+    // #####    SimpleCommand    #####
+    // ###############################
+
+    /**
+    @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     #####
+    // ###############################
+
+    /**
+    @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)
+    {
+        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;
+    }
+}
Index: /code/branches/ceguilua/src/core/input/InputCommands.h
===================================================================
--- /code/branches/ceguilua/src/core/input/InputCommands.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputCommands.h	(revision 1801)
@@ -0,0 +1,82 @@
+/*
+ *   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
+    Different definitions of input processing.
+*/
+
+#ifndef _InputCommands_H__
+#define _InputCommands_H__
+
+#include "core/CorePrereqs.h"
+#include "core/CommandEvaluation.h"
+
+namespace orxonox
+{
+    class _CoreExport BufferedParamCommand
+    {
+    public:
+        BufferedParamCommand() : value_(0.0f), nValuesAdded_(0), paramIndex_(-1) { }
+        bool execute();
+
+        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 SimpleCommand : public BaseCommand
+    {
+    public:
+        bool execute(float abs = 1.0f, float rel = 1.0f);
+
+        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);
+
+        bool bRelative_;
+        float paramModifier_;
+        BufferedParamCommand* paramCommand_;
+    };
+}
+
+#endif /* _InputCommands_H__ */
Index: /code/branches/ceguilua/src/core/input/InputInterfaces.h
===================================================================
--- /code/branches/ceguilua/src/core/input/InputInterfaces.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputInterfaces.h	(revision 1801)
@@ -0,0 +1,368 @@
+/*
+ *   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
+    Declarations of various interface classes for the input management.
+*/
+
+#ifndef _InputInterfaces_H__
+#define _InputInterfaces_H__
+
+#include "core/CorePrereqs.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 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) { }
+    };
+
+}
+
+#endif /* _InputInterfaces_H__ */
Index: /code/branches/ceguilua/src/core/input/InputManager.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/InputManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputManager.cc	(revision 1801)
@@ -0,0 +1,1376 @@
+/*
+ *   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 InputManager that captures all the input from OIS
+    and redirects it to handlers.
+ */
+
+#include "InputManager.h"
+
+#include <climits>
+#include <cassert>
+
+#include "ois/OISException.h"
+#include "ois/OISInputManager.h"
+
+#include "util/Exception.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/ConsoleCommand.h"
+#include "util/Debug.h"
+
+#include "InputBuffer.h"
+#include "KeyBinder.h"
+#include "KeyDetector.h"
+#include "CalibratorCallback.h"
+#include "InputState.h"
+#include "SimpleInputState.h"
+#include "ExtendedInputState.h"
+
+namespace orxonox
+{
+    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)
+        , stateMaster_(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")));
+#endif
+
+            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);
+
+            stateMaster_ = new ExtendedInputState();
+            stateMaster_->setName("master");
+
+            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 master input state. This might trigger a memory leak
+                // because the user has forgotten to destroy the KeyBinder or any Handler!
+                delete stateMaster_;
+
+                // 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;
+            }
+        }
+	singletonRef_s = 0;
+    }
+
+    /**
+    @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++)
+            {
+                KeyEvent kEvt(keysDown_[iKey], keyboardModifiers_);
+                activeStatesTop_[Keyboard]->keyHeld(kEvt);
+                stateMaster_->keyHeld(kEvt);
+            }
+
+            // call all the handlers for the held mouse button events
+            for (unsigned int iButton = 0; iButton < mouseButtonsDown_.size(); iButton++)
+            {
+                activeStatesTop_[Mouse]->mouseButtonHeld(mouseButtonsDown_[iButton]);
+                stateMaster_->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]);
+                    stateMaster_->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);
+                if (stateMaster_->isInputDeviceEnabled(i))
+                    stateMaster_->tickInput(dt, i);
+            }
+
+            // tick the handler with a general tick afterwards
+            for (unsigned int i = 0; i < activeStatesTicked_.size(); ++i)
+                activeStatesTicked_[i]->tickInput(dt);
+            stateMaster_->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
+        {
+            // This happens when XAutoRepeat is set under linux. The KeyPressed event gets then sent
+            // continuously.
+            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
+
+        KeyEvent kEvt(e, keyboardModifiers_);
+        activeStatesTop_[Keyboard]->keyPressed(kEvt);
+        stateMaster_->keyPressed(kEvt);
+
+        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
+
+        KeyEvent kEvt(e, keyboardModifiers_);
+        activeStatesTop_[Keyboard]->keyReleased(kEvt);
+        stateMaster_->keyReleased(kEvt);
+
+        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)
+        {
+            IntVector2 abs(e.state.X.abs, e.state.Y.abs);
+            IntVector2 rel(e.state.X.rel, e.state.Y.rel);
+            IntVector2 clippingSize(e.state.width, e.state.height);
+            activeStatesTop_[Mouse]->mouseMoved(abs, rel, clippingSize);
+            stateMaster_->mouseMoved(abs, rel, clippingSize);
+        }
+
+        // check for mouse scrolled event
+        if (e.state.Z.rel != 0)
+        {
+            activeStatesTop_[Mouse]->mouseScrolled(e.state.Z.abs, e.state.Z.rel);
+            stateMaster_->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);
+        stateMaster_->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);
+        stateMaster_->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);
+        stateMaster_->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);
+        stateMaster_->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);
+            stateMaster_->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;
+    }
+
+    /**
+    @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;
+    }
+
+    /**
+    @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;
+    }
+
+
+    // ############################################################
+    // #####                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/branches/ceguilua/src/core/input/InputManager.h
===================================================================
--- /code/branches/ceguilua/src/core/input/InputManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputManager.h	(revision 1801)
@@ -0,0 +1,238 @@
+/*
+ *   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 a little Input handler that distributes everything
+    coming from OIS.
+*/
+
+#ifndef _InputManager_H__
+#define _InputManager_H__
+
+#include "core/CorePrereqs.h"
+
+#include <map>
+#include <vector>
+#include <stack>
+#include "util/Math.h"
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+
+namespace orxonox
+{
+    /**
+    @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
+    {
+        // --> 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();
+        ExtendedInputState* getMasterInputState() { return this->stateMaster_; }
+        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_;
+        ExtendedInputState*                 stateMaster_;          //!< Always active master input state
+
+        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;
+    };
+}
+
+#endif /* _InputManager_H__ */
Index: /code/branches/ceguilua/src/core/input/InputState.h
===================================================================
--- /code/branches/ceguilua/src/core/input/InputState.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/InputState.h	(revision 1801)
@@ -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/branches/ceguilua/src/core/input/KeyBinder.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/KeyBinder.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/KeyBinder.cc	(revision 1801)
@@ -0,0 +1,569 @@
+/*
+ *   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 different input handlers.
+ */
+
+#include "KeyBinder.h"
+#include <fstream>
+#include <string>
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigFileManager.h"
+#include "InputCommands.h"
+
+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" + 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 (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(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/branches/ceguilua/src/core/input/KeyBinder.h
===================================================================
--- /code/branches/ceguilua/src/core/input/KeyBinder.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/KeyBinder.h	(revision 1801)
@@ -0,0 +1,153 @@
+/*
+ *   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
+    Different definitions of input processing.
+*/
+
+#ifndef _KeyBinder_H__
+#define _KeyBinder_H__
+
+#include "core/CorePrereqs.h"
+
+#include <vector>
+
+#include "core/OrxonoxClass.h"
+#include "InputInterfaces.h"
+#include "Button.h"
+#include "HalfAxis.h"
+
+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();
+
+        void loadBindings();
+        void clearBindings();
+        void setConfigValues();
+        void resetJoyStickAxes();
+
+    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);
+
+        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);
+
+    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 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];
+
+        /**
+        @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_;
+
+
+        //##### 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_;
+    };
+}
+
+#endif /* _KeyBinder_H__ */
Index: /code/branches/ceguilua/src/core/input/KeyDetector.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/KeyDetector.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/KeyDetector.cc	(revision 1801)
@@ -0,0 +1,83 @@
+/*
+ *   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 different input handlers.
+*/
+
+#include "KeyDetector.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/CommandEvaluation.h"
+#include "InputCommands.h"
+#include "Button.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Constructor
+    */
+    KeyDetector::KeyDetector()
+    {
+        RegisterObject(KeyDetector);
+    }
+
+    /**
+    @brief
+        Destructor
+    */
+    KeyDetector::~KeyDetector()
+    {
+    }
+
+    /**
+    @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(this->command_ + " " + button.name_);
+        button.commands_[KeybindMode::OnPress] = new BaseCommand*[1];
+        button.commands_[KeybindMode::OnPress][0] = cmd;
+        button.nCommands_[KeybindMode::OnPress] = 1;
+    }
+}
Index: /code/branches/ceguilua/src/core/input/KeyDetector.h
===================================================================
--- /code/branches/ceguilua/src/core/input/KeyDetector.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/KeyDetector.h	(revision 1801)
@@ -0,0 +1,59 @@
+/*
+ *   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
+    Different definitions of input processing.
+*/
+
+#ifndef _KeyDetector_H__
+#define _KeyDetector_H__
+
+#include "core/CorePrereqs.h"
+
+#include "KeyBinder.h"
+
+namespace orxonox
+{
+    class _CoreExport KeyDetector : public KeyBinder
+    {
+    public:
+        KeyDetector();
+        ~KeyDetector();
+        void loadBindings(const std::string& command);
+
+    protected:
+        void readTrigger(Button& button);
+
+    private:
+        std::string command_;
+    };
+}
+
+#endif /* _KeyDetector_H__ */
Index: /code/branches/ceguilua/src/core/input/SimpleInputState.cc
===================================================================
--- /code/branches/ceguilua/src/core/input/SimpleInputState.cc	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/SimpleInputState.cc	(revision 1801)
@@ -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/branches/ceguilua/src/core/input/SimpleInputState.h
===================================================================
--- /code/branches/ceguilua/src/core/input/SimpleInputState.h	(revision 1801)
+++ /code/branches/ceguilua/src/core/input/SimpleInputState.h	(revision 1801)
@@ -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/branches/ceguilua/src/core/tolua/tolua.pkg
===================================================================
--- /code/branches/ceguilua/src/core/tolua/tolua.pkg	(revision 1801)
+++ /code/branches/ceguilua/src/core/tolua/tolua.pkg	(revision 1801)
@@ -0,0 +1,2 @@
+$cfile "../../src/core/Script.h"
+$cfile "../../src/core/CommandExecutor.h"
Index: /code/branches/ceguilua/src/cpptcl/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/cpptcl/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,5 @@
+ADD_LIBRARY(cpptcl SHARED CppTcl.cc)
+
+TARGET_LINK_LIBRARIES(cpptcl
+  ${TCL_LIBRARY}
+)
Index: /code/branches/ceguilua/src/cpptcl/CREDITS
===================================================================
--- /code/branches/ceguilua/src/cpptcl/CREDITS	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/CREDITS	(revision 1801)
@@ -0,0 +1,11 @@
+I would like to thank you very much for your contributions:
+
+---
+Alexey Pakhunov provided patches with various bugfixes and enhancements.
+His patches were used in the 1.1.2 release.
+
+---
+Christoph Pesch provided a small patch for the g++ 3.2 compiler.
+
+After the 1.1.0 release, Christoph provided also a patch for newer g++ 3.4.3.
+(included in 1.1.1)
Index: /code/branches/ceguilua/src/cpptcl/CppTcl.cc
===================================================================
--- /code/branches/ceguilua/src/cpptcl/CppTcl.cc	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/CppTcl.cc	(revision 1801)
@@ -0,0 +1,1099 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#include "CppTcl.h"
+#include <map>
+#include <sstream>
+#include <iterator>
+
+
+using namespace Tcl;
+using namespace Tcl::details;
+using namespace std;
+using namespace boost;
+
+
+result::result(Tcl_Interp *interp) : interp_(interp) {}
+
+result::operator bool() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     int val, cc;
+     cc = Tcl_GetBooleanFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return static_cast<bool>(val);
+}
+
+result::operator double() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     double val;
+     int cc = Tcl_GetDoubleFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator int() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     int val, cc;
+     cc = Tcl_GetIntFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator long() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+
+     long val;
+     int cc;
+     cc = Tcl_GetLongFromObj(interp_, obj, &val);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return val;
+}
+
+result::operator string() const
+{
+     Tcl_Obj *obj = Tcl_GetObjResult(interp_);
+     return Tcl_GetString(obj);
+}
+
+result::operator object() const
+{
+     return object(Tcl_GetObjResult(interp_));
+}
+
+
+void details::set_result(Tcl_Interp *interp, bool b)
+{
+     Tcl_SetObjResult(interp, Tcl_NewBooleanObj(b));
+}
+
+void details::set_result(Tcl_Interp *interp, int i)
+{
+     Tcl_SetObjResult(interp, Tcl_NewIntObj(i));
+}
+
+void details::set_result(Tcl_Interp *interp, long i)
+{
+     Tcl_SetObjResult(interp, Tcl_NewLongObj(i));
+}
+
+void details::set_result(Tcl_Interp *interp, double d)
+{
+     Tcl_SetObjResult(interp, Tcl_NewDoubleObj(d));
+}
+
+void details::set_result(Tcl_Interp *interp, string const &s)
+{
+     Tcl_SetObjResult(interp,
+          Tcl_NewStringObj(s.data(), static_cast<int>(s.size())));
+}
+
+void details::set_result(Tcl_Interp *interp, void *p)
+{
+     ostringstream ss;
+     ss << 'p' << p;
+     string s(ss.str());
+
+     Tcl_SetObjResult(interp,
+          Tcl_NewStringObj(s.data(), static_cast<int>(s.size())));
+}
+
+void details::set_result(Tcl_Interp *interp, object const &o)
+{
+     Tcl_SetObjResult(interp, o.get_object());
+}
+
+
+void details::check_params_no(int objc, int required)
+{
+     if (objc < required)
+     {
+          throw tcl_error("Too few arguments.");
+     }
+}
+
+object details::get_var_params(Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[],
+     int from, policies const &pol)
+{
+     object o;
+     if (pol.variadic_)
+     {
+          check_params_no(objc, from);
+          o.assign(objv + from, objv + objc);
+     }
+     else
+     {
+          check_params_no(objc, from + 1);
+          o.assign(objv[from]);
+     }
+
+     o.set_interp(interp);
+
+     return o;
+}
+
+
+namespace // anonymous
+{
+
+// map of polymorphic callbacks
+typedef map<string, shared_ptr<callback_base> > callback_interp_map;
+typedef map<Tcl_Interp *, callback_interp_map> callback_map;
+
+callback_map callbacks;
+callback_map constructors;
+
+// map of call policies
+typedef map<string, policies> policies_interp_map;
+typedef map<Tcl_Interp *, policies_interp_map> policies_map;
+
+policies_map call_policies;
+
+// map of object handlers
+typedef map<string, shared_ptr<class_handler_base> > class_interp_map;
+typedef map<Tcl_Interp *, class_interp_map> class_handlers_map;
+
+class_handlers_map class_handlers;
+
+
+// helper for finding call policies - returns true when found
+bool find_policies(Tcl_Interp *interp, string const &cmdName,
+     policies_interp_map::iterator &piti)
+{
+     policies_map::iterator pit = call_policies.find(interp);
+     if (pit == call_policies.end())
+     {
+          return false;
+     }
+
+     piti = pit->second.find(cmdName);
+     return piti != pit->second.end();
+}
+
+extern "C"
+int object_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[]);
+
+// helper function for post-processing call policies
+// for both free functions (isMethod == false)
+// and class methods (isMethod == true)
+void post_process_policies(Tcl_Interp *interp, policies &pol,
+     Tcl_Obj * CONST objv[], bool isMethod)
+{
+     // check if it is a factory
+     if (!pol.factory_.empty())
+     {
+          class_handlers_map::iterator it = class_handlers.find(interp);
+          if (it == class_handlers.end())
+          {
+               throw tcl_error(
+                    "Factory was registered for unknown class.");
+          }
+
+          class_interp_map::iterator oit = it->second.find(pol.factory_);
+          if (oit == it->second.end())
+          {
+               throw tcl_error(
+                    "Factory was registered for unknown class.");
+          }
+
+          class_handler_base *chb = oit->second.get();
+
+          // register a new command for the object returned
+          // by this factory function
+          // if everything went OK, the result is the address of the
+          // new object in the 'pXXX' form
+          // - the new command will be created with this name
+
+          Tcl_CreateObjCommand(interp,
+               Tcl_GetString(Tcl_GetObjResult(interp)),
+               object_handler, static_cast<ClientData>(chb), 0);
+     }
+
+     // process all declared sinks
+     // - unregister all object commands that envelopes the pointers
+     for (vector<int>::iterator s = pol.sinks_.begin();
+          s != pol.sinks_.end(); ++s)
+     {
+          if (isMethod == false)
+          {
+               // example: if there is a declared sink at parameter 3,
+               // and the Tcl command was:
+               // % fun par1 par2 PAR3 par4
+               // then the index 3 correctly points into the objv array
+
+               int index = *s;
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[index]));
+          }
+          else
+          {
+               // example: if there is a declared sink at parameter 3,
+               // and the Tcl command was:
+               // % $p method par1 par2 PAR3 par4
+               // then the index 3 needs to be incremented
+               // in order correctly point into the 4th index of objv array
+
+               int index = *s + 1;
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[index]));
+          }
+     }
+}
+
+// actual functions handling various callbacks
+
+// generic callback handler
+extern "C"
+int callback_handler(ClientData, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     callback_map::iterator it = callbacks.find(interp);
+     if (it == callbacks.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong interpreter?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     string cmdName(Tcl_GetString(objv[0]));
+     callback_interp_map::iterator iti = it->second.find(cmdName);
+     if (iti == it->second.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong cmd name?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_map::iterator pit = call_policies.find(interp);
+     if (pit == call_policies.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_interp_map::iterator piti;
+     if (find_policies(interp, cmdName, piti) == false)
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies &pol = piti->second;
+
+     try
+     {
+          iti->second->invoke(interp, objc, objv, pol);
+
+          post_process_policies(interp, pol, objv, false);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+// generic "object" command handler
+extern "C"
+int object_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     // here, client data points to the singleton object
+     // which is responsible for managing commands for
+     // objects of a given type
+
+     class_handler_base *chb = reinterpret_cast<class_handler_base*>(cd);
+
+     // the command name has the form 'pXXX' where XXX is the address
+     // of the "this" object
+
+     string const str(Tcl_GetString(objv[0]));
+     istringstream ss(str);
+     char dummy;
+     void *p;
+     ss >> dummy >> p;
+
+     try
+     {
+          string methodName(Tcl_GetString(objv[1]));
+          policies &pol = chb->get_policies(methodName);
+
+          chb->invoke(p, interp, objc, objv, pol);
+
+          post_process_policies(interp, pol, objv, true);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+// generic "constructor" command
+extern "C"
+int constructor_handler(ClientData cd, Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[])
+{
+     // here, client data points to the singleton object
+     // which is responsible for managing commands for
+     // objects of a given type
+
+     class_handler_base *chb = reinterpret_cast<class_handler_base*>(cd);
+
+     callback_map::iterator it = constructors.find(interp);
+     if (it == constructors.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong interpreter?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     string className(Tcl_GetString(objv[0]));
+     callback_interp_map::iterator iti = it->second.find(className);
+     if (iti == it->second.end())
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke non-existent callback (wrong class name?)",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies_interp_map::iterator piti;
+     if (find_policies(interp, className, piti) == false)
+     {
+          Tcl_SetResult(interp,
+               "Trying to invoke callback with no known policies",
+               TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     policies &pol = piti->second;
+
+     try
+     {
+          iti->second->invoke(interp, objc, objv, pol);
+
+          // if everything went OK, the result is the address of the
+          // new object in the 'pXXX' form
+          // - we can create a new command with this name
+
+          Tcl_CreateObjCommand(interp,
+               Tcl_GetString(Tcl_GetObjResult(interp)),
+               object_handler, static_cast<ClientData>(chb), 0);
+     }
+     catch (exception const &e)
+     {
+          Tcl_SetResult(interp, const_cast<char*>(e.what()), TCL_VOLATILE);
+          return TCL_ERROR;
+     }
+     catch (...)
+     {
+          Tcl_SetResult(interp, "Unknown error.", TCL_STATIC);
+          return TCL_ERROR;
+     }
+
+     return TCL_OK;
+}
+
+} // namespace anonymous
+
+Tcl::details::no_init_type Tcl::no_init;
+
+
+policies & policies::factory(string const &name)
+{
+     factory_ = name;
+     return *this;
+}
+
+policies & policies::sink(int index)
+{
+     sinks_.push_back(index);
+     return *this;
+}
+
+policies & policies::variadic()
+{
+     variadic_ = true;
+     return *this;
+}
+
+policies Tcl::factory(string const &name)
+{
+     return policies().factory(name);
+}
+
+policies Tcl::sink(int index)
+{
+     return policies().sink(index);
+}
+
+policies Tcl::variadic()
+{
+     return policies().variadic();
+}
+
+
+class_handler_base::class_handler_base()
+{
+     // default policies for the -delete command
+     policies_["-delete"] = policies();
+}
+
+void class_handler_base::register_method(string const &name,
+     shared_ptr<object_cmd_base> ocb, policies const &p)
+{
+     methods_[name] = ocb;
+     policies_[name] = p;
+}
+
+policies & class_handler_base::get_policies(string const &name)
+{
+     policies_map_type::iterator it = policies_.find(name);
+     if (it == policies_.end())
+     {
+          throw tcl_error("Trying to use non-existent policy: " + name);
+     }
+
+     return it->second;
+}
+
+
+object::object()
+     : interp_(0)
+{
+     obj_ = Tcl_NewObj();
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(bool b)
+     : interp_(0)
+{
+     obj_ = Tcl_NewBooleanObj(b);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(char const *buf, size_t size)
+     : interp_(0)
+{
+     obj_ = Tcl_NewByteArrayObj(
+          reinterpret_cast<unsigned char const *>(buf),
+          static_cast<int>(size));
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(double d)
+     : interp_(0)
+{
+     obj_ = Tcl_NewDoubleObj(d);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(int i)
+     : interp_(0)
+{
+     obj_ = Tcl_NewIntObj(i);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(long l)
+     : interp_(0)
+{
+     obj_ = Tcl_NewLongObj(l);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(char const *s)
+     : interp_(0)
+{
+     obj_ = Tcl_NewStringObj(s, -1);
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(string const &s)
+     : interp_(0)
+{
+     obj_ = Tcl_NewStringObj(s.data(), static_cast<int>(s.size()));
+     Tcl_IncrRefCount(obj_);
+}
+
+object::object(Tcl_Obj *o, bool shared)
+     : interp_(0)
+{
+     init(o, shared);
+}
+
+object::object(object const &other, bool shared)
+     : interp_(other.get_interp())
+{
+     init(other.obj_, shared);
+}
+
+void object::init(Tcl_Obj *o, bool shared)
+{
+     if (shared)
+     {
+          obj_ = o;
+     }
+     else
+     {
+          obj_ = Tcl_DuplicateObj(o);
+     }
+     Tcl_IncrRefCount(obj_);
+}
+
+object::~object()
+{
+     Tcl_DecrRefCount(obj_);
+}
+
+object & object::assign(bool b)
+{
+     Tcl_SetBooleanObj(obj_, b);
+     return *this;
+}
+
+object & object::resize(size_t size)
+{
+     Tcl_SetByteArrayLength(obj_, static_cast<int>(size));
+     return *this;
+}
+
+object & object::assign(char const *buf, size_t size)
+{
+     Tcl_SetByteArrayObj(obj_,
+          reinterpret_cast<unsigned char const *>(buf),
+          static_cast<int>(size));
+     return *this;
+}
+
+object & object::assign(double d)
+{
+     Tcl_SetDoubleObj(obj_, d);
+     return *this;
+}
+
+object & object::assign(int i)
+{
+     Tcl_SetIntObj(obj_, i);
+     return *this;
+}
+
+object & object::assign(long l)
+{
+     Tcl_SetLongObj(obj_, l);
+     return *this;
+}
+
+object & object::assign(char const *s)
+{
+     Tcl_SetStringObj(obj_, s, -1);
+     return *this;
+}
+
+object & object::assign(string const &s)
+{
+     Tcl_SetStringObj(obj_, s.data(), static_cast<int>(s.size()));
+     return *this;
+}
+
+object & object::assign(object const &other)
+{
+     object(other).swap(*this);
+     return *this;
+}
+
+object & object::assign(Tcl_Obj *o)
+{
+     object(o).swap(*this);
+     return *this;
+}
+
+object & object::swap(object &other)
+{
+     std::swap(obj_, other.obj_);
+     std::swap(interp_, other.interp_);
+     return *this;
+}
+
+template <>
+bool object::get<bool>(interpreter &i) const
+{
+     int retVal;
+     int res = Tcl_GetBooleanFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return static_cast<bool>(retVal);
+}
+
+template <>
+vector<char> object::get<vector<char> >(interpreter &) const
+{
+     size_t size;
+     char const *buf = get(size);
+     return vector<char>(buf, buf + size);
+}
+
+template <>
+double object::get<double>(interpreter &i) const
+{
+     double retVal;
+     int res = Tcl_GetDoubleFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+int object::get<int>(interpreter &i) const
+{
+     int retVal;
+
+     int res = Tcl_GetIntFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+long object::get<long>(interpreter &i) const
+{
+     long retVal;
+     int res = Tcl_GetLongFromObj(i.get(), obj_, &retVal);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return retVal;
+}
+
+template <>
+char const * object::get<char const *>(interpreter &) const
+{
+     return get();
+}
+
+template <>
+string object::get<string>(interpreter &) const
+{
+     int len;
+     char const *buf = Tcl_GetStringFromObj(obj_, &len);
+     return string(buf, buf + len);
+}
+
+char const * object::get() const
+{
+     return Tcl_GetString(obj_);
+}
+
+char const * object::get(size_t &size) const
+{
+     int len;
+     unsigned char *buf = Tcl_GetByteArrayFromObj(obj_, &len);
+     size = len;
+     return const_cast<char const *>(reinterpret_cast<char *>(buf));
+}
+
+size_t object::length(interpreter &i) const
+{
+     int len;
+     int res = Tcl_ListObjLength(i.get(), obj_, &len);
+
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return static_cast<size_t>(len);
+}
+
+object object::at(interpreter &i, size_t index) const
+{
+     Tcl_Obj *o;
+     int res = Tcl_ListObjIndex(i.get(), obj_, static_cast<int>(index), &o);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+     if (o == NULL)
+     {
+          throw tcl_error("Index out of range.");
+     }
+
+     return object(o);
+}
+
+object & object::append(interpreter &i, object const &o)
+{
+     int res = Tcl_ListObjAppendElement(i.get(), obj_, o.obj_);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::append_list(interpreter &i, object const &o)
+{
+     int res = Tcl_ListObjAppendList(i.get(), obj_, o.obj_);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::replace(interpreter &i, size_t index, size_t count,
+     object const &o)
+{
+     int res = Tcl_ListObjReplace(i.get(), obj_,
+          static_cast<int>(index), static_cast<int>(count),
+          1, &(o.obj_));
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+object & object::replace_list(interpreter &i, size_t index, size_t count,
+     object const &o)
+{
+     int objc;
+     Tcl_Obj **objv;
+
+     int res = Tcl_ListObjGetElements(i.get(), o.obj_, &objc, &objv);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     res = Tcl_ListObjReplace(i.get(), obj_,
+          static_cast<int>(index), static_cast<int>(count),
+          objc, objv);
+     if (res != TCL_OK)
+     {
+          throw tcl_error(i.get());
+     }
+
+     return *this;
+}
+
+void object::set_interp(Tcl_Interp *interp)
+{
+     interp_ = interp;
+}
+
+Tcl_Interp * object::get_interp() const
+{
+     return interp_;
+}
+
+
+interpreter::interpreter()
+{
+     interp_ =  Tcl_CreateInterp();
+     owner_ = true;
+}
+
+interpreter::interpreter(string const &libpath)
+{
+     interp_ =  Tcl_CreateInterp();
+     owner_ = true;
+
+     try
+     {
+        this->eval("set tcl_library " + libpath);
+        Tcl_Init(this->interp_);
+     } catch (...) {}
+}
+
+interpreter::interpreter(Tcl_Interp *interp, bool owner)
+{
+     interp_ =  interp;
+     owner_ = owner;
+}
+
+interpreter::~interpreter()
+{
+     if (owner_)
+     {
+          // clear all callback info belonging to this interpreter
+          clear_definitions(interp_);
+
+          Tcl_DeleteInterp(interp_);
+     }
+}
+
+void interpreter::make_safe()
+{
+     int cc = Tcl_MakeSafe(interp_);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+result interpreter::eval(string const &script)
+{
+     int cc = Tcl_Eval(interp_, script.c_str());
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return result(interp_);
+}
+
+result interpreter::eval(istream &s)
+{
+     string str(
+          istreambuf_iterator<char>(s.rdbuf()),
+          istreambuf_iterator<char>()
+     );
+     return eval(str);
+}
+
+result interpreter::eval(object const &o)
+{
+     int cc = Tcl_EvalObjEx(interp_, o.get_object(), 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return result(interp_);
+}
+
+void interpreter::pkg_provide(string const &name, string const &version)
+{
+     int cc = Tcl_PkgProvide(interp_, name.c_str(), version.c_str());
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+void interpreter::create_alias(string const &cmd,
+     interpreter &targetInterp, string const &targetCmd)
+{
+     int cc = Tcl_CreateAlias(interp_, cmd.c_str(),
+          targetInterp.interp_, targetCmd.c_str(), 0, 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+}
+
+void interpreter::clear_definitions(Tcl_Interp *interp)
+{
+     // delete all callbacks that were registered for given interpreter
+
+     {
+          // TODO: why could this probably be necessary? map::find of empty map
+          // shouldn't be a problem.
+          if (callbacks.size() == 0)
+            return;
+          callback_map::iterator it = callbacks.find(interp);
+          if (it == callbacks.end())
+          {
+               // no callbacks defined for this interpreter
+               return;
+          }
+
+          callback_interp_map &imap = it->second;
+          for (callback_interp_map::iterator it2 = imap.begin();
+               it2 != imap.end(); ++it2)
+          {
+               Tcl_DeleteCommand(interp, it2->first.c_str());
+          }
+
+          callbacks.erase(interp);
+     }
+
+     // delete all constructors
+
+     {
+          callback_map::iterator it = constructors.find(interp);
+          if (it == constructors.end())
+          {
+               // no callbacks defined for this interpreter
+               return;
+          }
+
+          callback_interp_map &imap = it->second;
+          for (callback_interp_map::iterator it2 = imap.begin();
+               it2 != imap.end(); ++it2)
+          {
+               Tcl_DeleteCommand(interp, it2->first.c_str());
+          }
+
+          callbacks.erase(interp);
+     }
+
+     // delete all call policies
+
+     call_policies.erase(interp);
+
+     // delete all object handlers
+     // (we have to assume that all living objects were destroyed,
+     // otherwise Bad Things will happen)
+
+     class_handlers.erase(interp);
+}
+
+void interpreter::add_function(string const &name,
+     shared_ptr<callback_base> cb, policies const &p)
+{
+     Tcl_CreateObjCommand(interp_, name.c_str(),
+          callback_handler, 0, 0);
+
+     callbacks[interp_][name] = cb;
+     call_policies[interp_][name] = p;
+}
+
+void interpreter::add_class(string const &name,
+     shared_ptr<class_handler_base> chb)
+{
+     class_handlers[interp_][name] = chb;
+}
+
+void interpreter::add_constructor(string const &name,
+     shared_ptr<class_handler_base> chb, shared_ptr<callback_base> cb,
+     policies const &p)
+{
+     Tcl_CreateObjCommand(interp_, name.c_str(),
+          constructor_handler, static_cast<ClientData>(chb.get()), 0);
+
+     constructors[interp_][name] = cb;
+     call_policies[interp_][name] = p;
+}
+
+
+int tcl_cast<int>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     int res;
+     int cc = Tcl_GetIntFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+long tcl_cast<long>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     long res;
+     int cc = Tcl_GetLongFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+bool tcl_cast<bool>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     int res;
+     int cc = Tcl_GetBooleanFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res != 0;
+}
+
+double tcl_cast<double>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     double res;
+     int cc = Tcl_GetDoubleFromObj(interp, obj, &res);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp);
+     }
+
+     return res;
+}
+
+string tcl_cast<string>::from(Tcl_Interp *, Tcl_Obj *obj)
+{
+     return Tcl_GetString(obj);
+}
+
+char const * tcl_cast<char const *>::from(Tcl_Interp *, Tcl_Obj *obj)
+{
+     return Tcl_GetString(obj);
+}
+
+object tcl_cast<object>::from(Tcl_Interp *interp, Tcl_Obj *obj)
+{
+     object o(obj);
+     o.set_interp(interp);
+
+     return o;
+}
Index: /code/branches/ceguilua/src/cpptcl/CppTcl.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/CppTcl.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/CppTcl.h	(revision 1801)
@@ -0,0 +1,871 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+#ifndef CPPTCL_INCLUDED
+#define CPPTCL_INCLUDED
+
+#include <tcl.h>
+#include <string>
+#include <stdexcept>
+#include <sstream>
+#include <map>
+#include <vector>
+#include <boost/shared_ptr.hpp>
+#include <boost/bind.hpp>
+
+
+namespace Tcl
+{
+
+// exception class used for reporting all Tcl errors
+
+class tcl_error : public std::runtime_error
+{
+public:
+     explicit tcl_error(std::string const &msg)
+          : std::runtime_error(msg) {}
+     explicit tcl_error(Tcl_Interp *interp)
+          : std::runtime_error(Tcl_GetString(Tcl_GetObjResult(interp))) {}
+};
+
+// call policies
+
+struct policies
+{
+     policies() : variadic_(false) {}
+
+     policies & factory(std::string const &name);
+
+     // note: this is additive
+     policies & sink(int index);
+
+     policies & variadic();
+
+     std::string factory_;
+     std::vector<int> sinks_;
+     bool variadic_;
+};
+
+// syntax short-cuts
+policies factory(std::string const &name);
+policies sink(int index);
+policies variadic();
+
+
+class interpreter;
+class object;
+
+namespace details
+{
+
+// wrapper for the evaluation result
+class result
+{
+public:
+     result(Tcl_Interp *interp);
+
+     operator bool() const;
+     operator double() const;
+     operator int() const;
+     operator long() const;
+     operator std::string() const;
+     operator object() const;
+
+private:
+     Tcl_Interp *interp_;
+};
+
+// helper functions used to set the result value
+
+void set_result(Tcl_Interp *interp, bool b);
+void set_result(Tcl_Interp *interp, int i);
+void set_result(Tcl_Interp *interp, long i);
+void set_result(Tcl_Interp *interp, double d);
+void set_result(Tcl_Interp *interp, std::string const &s);
+void set_result(Tcl_Interp *interp, void *p);
+void set_result(Tcl_Interp *interp, object const &o);
+
+// helper functor for converting Tcl objects to the given type
+#include "details/conversions.h"
+
+// dispatchers able to capture (or ignore) the result
+#include "details/dispatchers.h"
+
+// helper for checking for required number of parameters
+// (throws tcl_error when not met)
+void check_params_no(int objc, int required);
+
+// helper for gathering optional params in variadic functions
+object get_var_params(Tcl_Interp *interp,
+     int objc, Tcl_Obj * CONST objv[],
+     int from, policies const &pol);
+
+// the callback_base is used to store callback handlers in a polynorphic map
+class callback_base
+{
+public:
+     virtual ~callback_base() {}
+
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol) = 0;
+};
+
+
+// base class for object command handlers
+// and for class handlers
+class object_cmd_base
+{
+public:
+     // destructor not needed, but exists to shut up the compiler warnings
+     virtual ~object_cmd_base() {}
+
+     virtual void invoke(void *p, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol) = 0;
+};
+
+// base class for all class handlers, still abstract
+class class_handler_base : public object_cmd_base
+{
+public:
+     typedef std::map<std::string, policies> policies_map_type;
+
+     class_handler_base();
+
+     void register_method(std::string const &name,
+          boost::shared_ptr<object_cmd_base> ocb, policies const &p);
+
+     policies & get_policies(std::string const &name);
+
+protected:
+     typedef std::map<
+          std::string,
+          boost::shared_ptr<object_cmd_base>
+          > method_map_type;
+
+     // a map of methods for the given class
+     method_map_type methods_;
+
+     policies_map_type policies_;
+};
+
+// class handler - responsible for executing class methods
+template <class C>
+class class_handler : public class_handler_base
+{
+public:
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C * p = static_cast<C*>(pv);
+
+          if (objc < 2)
+          {
+               throw tcl_error("Too few arguments.");
+          }
+
+          std::string methodName(Tcl_GetString(objv[1]));
+
+          if (methodName == "-delete")
+          {
+               Tcl_DeleteCommand(interp, Tcl_GetString(objv[0]));
+               delete p;
+               return;
+          }
+
+          // dispatch on the method name
+
+          method_map_type::iterator it = methods_.find(methodName);
+          if (it == methods_.end())
+          {
+               throw tcl_error("Method " + methodName + " not found.");
+          }
+
+          it->second->invoke(pv, interp, objc, objv, pol);
+     }
+};
+
+
+// factory functions for creating class objects
+#include "details/constructors.h"
+
+// actual callback envelopes
+#include "details/callbacks.h"
+
+// actual method envelopes
+#include "details/methods.h"
+
+// helper meta function for figuring appropriate constructor callback
+#include "details/metahelpers.h"
+
+
+// this class is used to provide the "def" interface for defining
+// class member functions
+
+template <class C>
+class class_definer
+{
+public:
+     class_definer(boost::shared_ptr<class_handler<C> > ch) : ch_(ch) {}
+
+     template <typename R>
+     class_definer & def(std::string const &name, R (C::*f)(),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method0<C, R>(f)), p);
+          return *this;
+     }
+
+     template <typename R>
+     class_definer & def(std::string const &name, R (C::*f)() const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method0<C, R>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1>
+     class_definer & def(std::string const &name, R (C::*f)(T1),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method1<C, R, T1>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1>
+     class_definer & def(std::string const &name, R (C::*f)(T1) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method1<C, R, T1>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method2<C, R, T1, T2>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method2<C, R, T1, T2>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method3<C, R, T1, T2, T3>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method3<C, R, T1, T2, T3>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     class_definer & def(std::string const &name, R (C::*f)(T1, T2, T3, T4),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method4<C, R, T1, T2, T3, T4>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method4<C, R, T1, T2, T3, T4>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5), policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method5<C, R, T1, T2, T3, T4, T5>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5) const, policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method5<C, R, T1, T2, T3, T4, T5>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6), policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method6<C, R, T1, T2, T3, T4, T5, T6>(f)),
+               p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method6<C, R, T1, T2, T3, T4, T5, T6>(f)),
+               p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method7<C, R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method7<C, R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method8<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method8<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9),
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method9<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+          return *this;
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+     class_definer & def(std::string const &name,
+          R (C::*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const,
+          policies const &p = policies())
+     {
+          ch_->register_method(name,
+               boost::shared_ptr<details::object_cmd_base>(
+                    new details::method9<C, R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+          return *this;
+     }
+
+private:
+     boost::shared_ptr<class_handler<C> > ch_;
+};
+
+} // namespace details
+
+
+// init type for defining class constructors
+template <typename T1 = void, typename T2 = void, typename T3 = void,
+          typename T4 = void, typename T5 = void, typename T6 = void,
+          typename T7 = void, typename T8 = void, typename T9 = void>
+class init {};
+
+// no_init type and object - to define classes without constructors
+namespace details
+{
+     struct no_init_type {};
+} // namespace details
+extern details::no_init_type no_init;
+
+
+// interpreter wrapper
+class interpreter
+{
+public:
+     interpreter();
+     interpreter(std::string const &libpath);
+     interpreter(Tcl_Interp *, bool owner = true);
+     ~interpreter();
+
+     void make_safe();
+
+     Tcl_Interp * get() const { return interp_; }
+
+     // free function definitions
+
+     template <typename R>
+     void def(std::string const &name, R (*f)(),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback0<R>(f)), p);
+     }
+
+     template <typename R, typename T1>
+     void def(std::string const &name, R (*f)(T1),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback1<R, T1>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2>
+     void def(std::string const &name, R (*f)(T1, T2),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback2<R, T1, T2>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3>
+     void def(std::string const &name, R (*f)(T1, T2, T3),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback3<R, T1, T2, T3>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3, typename T4>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback4<R, T1, T2, T3, T4>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback5<R, T1, T2, T3, T4, T5>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback6<R, T1, T2, T3, T4, T5, T6>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6, T7),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback7<R,
+                    T1, T2, T3, T4, T5, T6, T7>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7, typename T8>
+     void def(std::string const &name, R (*f)(T1, T2, T3, T4, T5, T6, T7, T8),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback8<R,
+                    T1, T2, T3, T4, T5, T6, T7, T8>(f)), p);
+     }
+
+     template <typename R, typename T1, typename T2, typename T3,
+          typename T4, typename T5, typename T6, typename T7, typename T8,
+          typename T9>
+     void def(std::string const &name,
+          R (*f)(T1, T2, T3, T4, T5, T6, T7, T8, T9),
+          policies const &p = policies())
+     {
+          add_function(name,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback9<R,
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(f)), p);
+     }
+
+
+     // class definitions
+
+     template <class C>
+     details::class_definer<C> class_(std::string const &name)
+     {
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          add_constructor(name, ch,
+               boost::shared_ptr<details::callback_base>(
+                    new details::callback0<C*>(&details::construct<
+                         C, void, void, void, void, void, void, void,
+                         void, void>::doit)));
+
+          return details::class_definer<C>(ch);
+     }
+
+     template <class C, typename T1, typename T2, typename T3, typename T4,
+               typename T5, typename T6, typename T7, typename T8,
+               typename T9>
+     details::class_definer<C> class_(std::string const &name,
+          init<T1, T2, T3, T4, T5, T6, T7, T8, T9> const &,
+          policies const &p = policies())
+     {
+          typedef typename details::get_callback_type_for_construct<
+               C, T1, T2, T3, T4, T5, T6, T7, T8, T9>::type
+               callback_type;
+
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          add_constructor(name, ch,
+               boost::shared_ptr<details::callback_base>(
+                    new callback_type(&details::construct<
+                         C, T1, T2, T3, T4, T5, T6, T7, T8, T9>::doit)), p);
+
+          return details::class_definer<C>(ch);
+     }
+
+     template <class C>
+     details::class_definer<C> class_(
+          std::string const &name, details::no_init_type const &)
+     {
+          boost::shared_ptr<details::class_handler<C> > ch(
+               new details::class_handler<C>());
+
+          add_class(name, ch);
+
+          return details::class_definer<C>(ch);
+     }
+
+     // free script evaluation
+     details::result eval(std::string const &script);
+     details::result eval(std::istream &s);
+
+     details::result eval(object const &o);
+
+     // the InputIterator should give object& or Tcl_Obj* when dereferenced
+     template <class InputIterator>
+     details::result eval(InputIterator first, InputIterator last);
+
+     // create alias from the *this interpreter to the target interpreter
+     void create_alias(std::string const &cmd,
+          interpreter &targetInterp, std::string const &targetCmd);
+
+     // register a package info (useful when defining packages)
+     void pkg_provide(std::string const &name, std::string const &version);
+
+     // helper for cleaning up callbacks in non-managed interpreters
+     static void clear_definitions(Tcl_Interp *);
+
+private:
+
+     // copy not supported
+     interpreter(const interpreter &);
+     void operator=(const interpreter &);
+
+     void add_function(std::string const &name,
+          boost::shared_ptr<details::callback_base> cb,
+          policies const &p = policies());
+
+     void add_class(std::string const &name,
+          boost::shared_ptr<details::class_handler_base> chb);
+
+     void add_constructor(std::string const &name,
+          boost::shared_ptr<details::class_handler_base> chb,
+          boost::shared_ptr<details::callback_base> cb,
+          policies const &p = policies());
+
+     Tcl_Interp *interp_;
+     bool owner_;
+};
+
+
+// object wrapper
+class object
+{
+public:
+
+     // constructors
+
+     object();
+
+     explicit object(bool b);
+     object(char const *buf, size_t size); // byte array
+     explicit object(double b);
+     explicit object(int i);
+
+     // list creation
+     // the InputIterator should give object& or Tcl_Obj* when dereferenced
+     template <class InputIterator>
+     object(InputIterator first, InputIterator last)
+          : interp_(0)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          obj_ = Tcl_NewListObj(static_cast<int>(v.size()),
+               v.empty() ? NULL : &v[0]);
+          Tcl_IncrRefCount(obj_);
+     }
+
+     explicit object(long i);
+     explicit object(char const *s);        // string construction
+     explicit object(std::string const &s); // string construction
+
+     explicit object(Tcl_Obj *o, bool shared = false);
+
+     object(object const &other, bool shared = false);
+     ~object();
+
+     // assignment
+
+     object & assign(bool b);
+     object & resize(size_t size);                  // byte array resize
+     object & assign(char const *buf, size_t size); // byte array assignment
+     object & assign(double d);
+     object & assign(int i);
+
+     // list assignment
+     // the InputIterator should give Tcl_Obj* or object& when dereferenced
+     template <class InputIterator>
+     object & assign(InputIterator first, InputIterator last)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          Tcl_SetListObj(obj_, static_cast<int>(v.size()),
+               v.empty() ? NULL : &v[0]);
+          return *this;
+     }
+
+     object & assign(long l);
+     object & assign(char const *s);        // string assignment
+     object & assign(std::string const &s); // string assignment
+     object & assign(object const &o);
+     object & assign(Tcl_Obj *o);
+
+     object & operator=(bool b)               { return assign(b); }
+     object & operator=(double d)             { return assign(d); }
+     object & operator=(int i)                { return assign(i); }
+     object & operator=(long l)               { return assign(l); }
+     object & operator=(char const *s)        { return assign(s); }
+     object & operator=(std::string const &s) { return assign(s); }
+
+     object & operator=(object const &o)      { return assign(o); }
+     object & swap(object &other);
+
+     // (logically) non-modifying members
+
+     template <typename T>
+     T get(interpreter &i) const;
+
+     char const * get() const;             // string get
+     char const * get(size_t &size) const; // byte array get
+
+     size_t length(interpreter &i) const;  // returns list length
+     object at(interpreter &i, size_t index) const;
+
+     Tcl_Obj * get_object() const { return obj_; }
+
+     // modifying members
+
+     object & append(interpreter &i, object const &o);
+     object & append_list(interpreter &i, object const &o);
+
+     // list replace
+     // the InputIterator should give Tcl_Obj* or object& when dereferenced
+     template <class InputIterator>
+     object & replace(interpreter &i, size_t index, size_t count,
+          InputIterator first, InputIterator last)
+     {
+          std::vector<Tcl_Obj*> v;
+          fill_vector(v, first, last);
+          int res = Tcl_ListObjReplace(i.get(), obj_,
+               static_cast<int>(index), static_cast<int>(count),
+               static_cast<int>(v.size()), v.empty() ? NULL : &v[0]);
+          if (res != TCL_OK)
+          {
+               throw tcl_error(i.get());
+          }
+
+          return *this;
+     }
+
+     object & replace(interpreter &i, size_t index, size_t count,
+          object const &o);
+     object & replace_list(interpreter &i, size_t index, size_t count,
+          object const &o);
+
+     // helper functions for piggy-backing interpreter info
+     void set_interp(Tcl_Interp *interp);
+     Tcl_Interp * get_interp() const;
+
+     // helper function, also used from interpreter::eval
+     template <class InputIterator>
+     static void fill_vector(std::vector<Tcl_Obj*> &v,
+          InputIterator first, InputIterator last)
+     {
+          for (; first != last; ++first)
+          {
+               object o(*first, true);
+               v.push_back(o.obj_);
+          }
+     }
+
+private:
+
+     // helper function used from copy constructors
+     void init(Tcl_Obj *o, bool shared);
+
+     Tcl_Obj *obj_;
+     Tcl_Interp *interp_;
+};
+
+// available specializations for object::get
+template <> bool         object::get<bool>(interpreter &i) const;
+template <> double       object::get<double>(interpreter &i) const;
+template <> int          object::get<int>(interpreter &i) const;
+template <> long         object::get<long>(interpreter &i) const;
+template <> char const * object::get<char const *>(interpreter &i) const;
+template <> std::string  object::get<std::string>(interpreter &i) const;
+template <>
+std::vector<char> object::get<std::vector<char> >(interpreter &i) const;
+
+// the InputIterator should give object& or Tcl_Obj* when dereferenced
+template <class InputIterator>
+details::result interpreter::eval(InputIterator first, InputIterator last)
+{
+     std::vector<Tcl_Obj*> v;
+     object::fill_vector(v, first, last);
+     int cc = Tcl_EvalObjv(interp_,
+          static_cast<int>(v.size()), v.empty() ? NULL : &v[0], 0);
+     if (cc != TCL_OK)
+     {
+          throw tcl_error(interp_);
+     }
+
+     return details::result(interp_);
+}
+
+namespace details
+{
+
+// additional callback envelopes for variadic functions
+#include "details/callbacks_v.h"
+
+// additional method envelopes for variadic methods
+#include "details/methods_v.h"
+
+} // namespace details
+
+} // namespace Tcl
+
+
+// macro for defining loadable module entry point
+// - used for extending Tcl interpreter
+
+#define CPPTCL_MODULE(name, i) void name##_cpptcl_Init(Tcl::interpreter &i); \
+     extern "C" int name##_Init(Tcl_Interp *interp) \
+     { \
+          Tcl::interpreter i(interp, false); \
+          name##_cpptcl_Init(i); \
+          return TCL_OK; \
+     } \
+     void name##_cpptcl_Init(Tcl::interpreter &i)
+
+
+#endif // CPPTCL_INCLUDED
Index: /code/branches/ceguilua/src/cpptcl/LICENSE
===================================================================
--- /code/branches/ceguilua/src/cpptcl/LICENSE	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/LICENSE	(revision 1801)
@@ -0,0 +1,39 @@
+Each source file contains the following notice:
+
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+The above is the shortest license I have found.
+I have copied this wording from one of the source files of the Boost library.
+
+Just to explain the above terms:
+
+1. The library is free (like in "freedom").
+
+2. You can use it for any purpose you wish. You can even sell it.
+
+3. You can modify the source files. If you do this, please feel free to add
+   your own copyright notices wherever you want, if you want.
+   You may also add more restrictive license terms.
+   You only have to keep the above notice unchanged in all source files.
+
+4. You can combine this library or its modified version with other software.
+   The license claims nothing that would affect the resulting work.
+   See point 3. if you need to make any modifications.
+
+5. You can compile this library or its modified version to the binary form.
+   The license does not affect the compiled result in any way.
+   In particular, you do not need to (but you still can) display the above
+   copyright notice to the final user, and you do not need to (but you still
+   can) inform the final user that your product was prepared with the help
+   of this library.
+
+6. Do not sue me for my (and your) mistakes and errors.
+
+As you see, this license is very permissive.
Index: /code/branches/ceguilua/src/cpptcl/README
===================================================================
--- /code/branches/ceguilua/src/cpptcl/README	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/README	(revision 1801)
@@ -0,0 +1,32 @@
+C++/Tcl - a C++ library for interoperability between C++ and Tcl.
+
+Copyright (C) 2004-2006, Maciej Sobczak
+
+---
+
+You should see the following directories here:
+
+- doc      - contains a short documentation for the library
+- examples - some simple examples to show C++/Tcl basics
+- test     - tests used for development - use them for regression testing
+             if you want to modify the library
+- details  - some additional code used by the library (not for client use)
+
+In addition, the following files may be of interest to you:
+
+- README   - this file
+- LICENSE  - explanation of the license terms
+- CHANGES  - the history of changes
+
+
+The C++/Tcl itself consists of these files:
+- cpptcl.h   - to be included in your own files
+- cpptcl.cc  - to be compiled and linked with your code
+
+
+In order to compile the tests and the examples you may need to change the
+compiler options to fit your particular environment (different paths to the
+Tcl headers and libs, another compiler, etc.)
+
+
+Anyway - have fun! :-)
Index: /code/branches/ceguilua/src/cpptcl/details/callbacks.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/callbacks.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/callbacks.h	(revision 1801)
@@ -0,0 +1,273 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <typename R>
+class callback0 : public callback_base
+{
+     typedef R (*functor_type)();
+     
+public:
+     callback0(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int, Tcl_Obj * CONST [],
+          policies const &)
+     {
+          dispatch<R>::do_dispatch(interp, f_);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1>
+class callback1 : public callback_base
+{
+     typedef R (*functor_type)(T1);
+     
+public:
+     callback1(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 2);
+          
+          dispatch<R>::template do_dispatch<T1>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2>
+class callback2 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2);
+     
+public:
+     callback2(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 3);
+          
+          dispatch<R>::template do_dispatch<T1, T2>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3>
+class callback3 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3);
+     
+public:
+     callback3(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 4);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4>
+class callback4 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4);
+     
+public:
+     callback4(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 5);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5>
+class callback5 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5);
+     
+public:
+     callback5(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 6);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6>
+class callback6 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6);
+     
+public:
+     callback6(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 7);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7>
+class callback7 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7);
+     
+public:
+     callback7(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 8);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8>
+class callback8 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     
+public:
+     callback8(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 9);
+          
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]));
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8, typename T9>
+class callback9 : public callback_base
+{
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     
+public:
+     callback9(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &)
+     {
+          check_params_no(objc, 10);
+          
+          dispatch<R>::template do_dispatch<
+               T1, T2, T3, T4, T5, T6, T7, T8, T9>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]),
+               tcl_cast<T9>::from(interp, objv[9]));
+     }
+
+private:
+     functor_type f_;
+};
Index: /code/branches/ceguilua/src/cpptcl/details/callbacks_v.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/callbacks_v.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/callbacks_v.h	(revision 1801)
@@ -0,0 +1,267 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <typename R>
+class callback1<R, object const &> : public callback_base
+{
+     typedef object const & T1;
+     typedef R (*functor_type)(T1);
+     enum { var_start = 1 };
+     
+public:
+     callback1(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t1 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1>(interp, f_,
+               t1);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1>
+class callback2<R, T1, object const &> : public callback_base
+{
+     typedef object const & T2;
+     typedef R (*functor_type)(T1, T2);
+     enum { var_start = 2 };
+     
+public:
+     callback2(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t2 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               t2);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2>
+class callback3<R, T1, T2, object const &> : public callback_base
+{
+     typedef object const & T3;
+     typedef R (*functor_type)(T1, T2, T3);
+     enum { var_start = 3 };
+     
+public:
+     callback3(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t3 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               t3);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3>
+class callback4<R, T1, T2, T3, object const &> : public callback_base
+{
+     typedef object const & T4;
+     typedef R (*functor_type)(T1, T2, T3, T4);
+     enum { var_start = 4 };
+     
+public:
+     callback4(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t4 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4>(interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               t4);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4>
+class callback5<R, T1, T2, T3, T4, object const &> : public callback_base
+{
+     typedef object const & T5;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5);
+     enum { var_start = 5 };
+     
+public:
+     callback5(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t5 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               t5);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5>
+class callback6<R, T1, T2, T3, T4, T5, object const &> : public callback_base
+{
+     typedef object const & T6;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6);
+     enum { var_start = 6 };
+     
+public:
+     callback6(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t6 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               t6);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6>
+class callback7<R, T1, T2, T3, T4, T5, T6, object const &>
+     : public callback_base
+{
+     typedef object const & T7;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7);
+     enum { var_start = 7 };
+     
+public:
+     callback7(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t7 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               t7);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7>
+class callback8<R, T1, T2, T3, T4, T5, T6, T7, object const &>
+     : public callback_base
+{
+     typedef object const & T8;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     enum { var_start = 8 };
+     
+public:
+     callback8(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t8 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7, T8>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               t8);
+     }
+
+private:
+     functor_type f_;
+};
+
+template <typename R, typename T1, typename T2, typename T3, typename T4,
+     typename T5, typename T6, typename T7, typename T8>
+class callback9<R, T1, T2, T3, T4, T5, T6, T7, T8, object const &>
+     : public callback_base
+{
+     typedef object const & T9;
+     typedef R (*functor_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     enum { var_start = 9 };
+     
+public:
+     callback9(functor_type f) : f_(f) {}
+     
+     virtual void invoke(Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[],
+          policies const &pol)
+     {
+          object t9 = get_var_params(interp, objc, objv, var_start, pol);
+          dispatch<R>::template do_dispatch<
+               T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+               interp, f_,
+               tcl_cast<T1>::from(interp, objv[1]),
+               tcl_cast<T2>::from(interp, objv[2]),
+               tcl_cast<T3>::from(interp, objv[3]),
+               tcl_cast<T4>::from(interp, objv[4]),
+               tcl_cast<T5>::from(interp, objv[5]),
+               tcl_cast<T6>::from(interp, objv[6]),
+               tcl_cast<T7>::from(interp, objv[7]),
+               tcl_cast<T8>::from(interp, objv[8]),
+               t9);
+     }
+
+private:
+     functor_type f_;
+};
Index: /code/branches/ceguilua/src/cpptcl/details/constructors.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/constructors.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/constructors.h	(revision 1801)
@@ -0,0 +1,88 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9>
+struct construct
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7,
+          T8 t8, T9 t9)
+     { return new C(t1, t2, t3, t4, t5, t6, t7, t8, t9); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+struct construct<C, T1, T2, T3, T4, T5, T6, T7, T8, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     { return new C(t1, t2, t3, t4, t5, t6, t7, t8); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+struct construct<C, T1, T2, T3, T4, T5, T6, T7, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     { return new C(t1, t2, t3, t4, t5, t6, t7); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+struct construct<C, T1, T2, T3, T4, T5, T6, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     { return new C(t1, t2, t3, t4, t5, t6); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+struct construct<C, T1, T2, T3, T4, T5, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     { return new C(t1, t2, t3, t4, t5); }
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4>
+struct construct<C, T1, T2, T3, T4, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3, T4 t4)
+     { return new C(t1, t2, t3, t4); }
+};
+
+template <class C, typename T1, typename T2, typename T3>
+struct construct<C, T1, T2, T3, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2, T3 t3)
+     { return new C(t1, t2, t3); }
+};
+
+template <class C, typename T1, typename T2>
+struct construct<C, T1, T2, void, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1, T2 t2)
+     { return new C(t1, t2); }
+};
+
+template <class C, typename T1>
+struct construct<C, T1, void, void, void, void, void, void, void, void>
+{
+     static C * doit(T1 t1)
+     { return new C(t1); }
+};
+
+template <class C>
+struct construct<C, void, void, void, void, void,
+                 void, void, void, void>
+{
+     static C * doit()
+     { return new C(); }
+};
Index: /code/branches/ceguilua/src/cpptcl/details/conversions.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/conversions.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/conversions.h	(revision 1801)
@@ -0,0 +1,101 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+// helper functor for converting Tcl objects to the given type
+// (it is a struct instead of function,
+// because I need to partially specialize it)
+
+template <typename T>
+struct tcl_cast;
+
+template <typename T>
+struct tcl_cast<T*>
+{
+     static T * from(Tcl_Interp *, Tcl_Obj *obj)
+     {
+          std::string s(Tcl_GetString(obj));
+          if (s.size() == 0)
+          {
+               throw tcl_error("Expected pointer value, got empty string.");
+          }
+
+          if (s[0] != 'p')
+          {
+               throw tcl_error("Expected pointer value.");
+          }
+
+          std::istringstream ss(s);
+          char dummy;
+          void *p;
+          ss >> dummy >> p;
+
+          return static_cast<T*>(p);
+     }
+};
+
+// the following partial specialization is to strip reference
+// (it returns a temporary object of the underlying type, which
+// can be bound to the const-ref parameter of the actual function)
+
+template <typename T>
+struct tcl_cast<T const &>
+{
+     static T from(Tcl_Interp *interp, Tcl_Obj *obj)
+     {
+          return tcl_cast<T>::from(interp, obj);
+     }
+};
+
+
+// the following specializations are implemented
+
+template <>
+struct tcl_cast<int>
+{
+     static int from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<long>
+{
+     static long from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<bool>
+{
+     static bool from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<double>
+{
+     static double from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<std::string>
+{
+     static std::string from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<char const *>
+{
+     static char const * from(Tcl_Interp *, Tcl_Obj *);
+};
+
+template <>
+struct tcl_cast<object>
+{
+     static object from(Tcl_Interp *, Tcl_Obj *);
+};
Index: /code/branches/ceguilua/src/cpptcl/details/dispatchers.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/dispatchers.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/dispatchers.h	(revision 1801)
@@ -0,0 +1,181 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+// the dispatch class is used to execute the callback functor and to
+// capture its return value
+// further dispatch<void> specialization ignores the res
+
+template <typename R>
+struct dispatch
+{
+     template <class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f)
+     {
+          R res = f();
+          set_result(interp, res);
+     }
+
+     template <typename T1, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f, T1 t1)
+     {
+          R res = f(t1);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f, T1 t1, T2 t2)
+     {
+          R res = f(t1, t2);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3)
+     {
+          R res = f(t1, t2, t3);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4)
+     {
+          R res = f(t1, t2, t3, t4);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     {
+          R res = f(t1, t2, t3, t4, t5);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7, t8);
+          set_result(interp, res);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *interp, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+     {
+          R res = f(t1, t2, t3, t4, t5, t6, t7, t8, t9);
+          set_result(interp, res);
+     }
+};
+
+template <>
+struct dispatch<void>
+{
+     template <class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f)
+     {
+          f();
+     }
+
+     template <typename T1, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f, T1 t1)
+     {
+          f(t1);
+     }
+
+     template <typename T1, typename T2, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f, T1 t1, T2 t2)
+     {
+          f(t1, t2);
+     }
+
+     template <typename T1, typename T2, typename T3, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3)
+     {
+          f(t1, t2, t3);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4)
+     {
+          f(t1, t2, t3, t4);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
+     {
+          f(t1, t2, t3, t4, t5);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
+     {
+          f(t1, t2, t3, t4, t5, t6);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7, t8);
+     }
+
+     template <typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8, typename T9,
+          class Functor>
+     static void do_dispatch(Tcl_Interp *, Functor f,
+          T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8, T9 t9)
+     {
+          f(t1, t2, t3, t4, t5, t6, t7, t8, t9);
+     }
+};
Index: /code/branches/ceguilua/src/cpptcl/details/metahelpers.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/metahelpers.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/metahelpers.h	(revision 1801)
@@ -0,0 +1,86 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8,
+          typename T9>
+struct get_callback_type_for_construct
+{
+     typedef callback9<C*, T1, T2, T3, T4, T5, T6, T7, T8, T9> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7, typename T8>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, T7, T8, void>
+{
+     typedef callback8<C*, T1, T2, T3, T4, T5, T6, T7, T8> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6, typename T7>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, T7, void, void>
+{
+     typedef callback7<C*, T1, T2, T3, T4, T5, T6, T7> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5, typename T6>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, T6, void, void, void>
+{
+     typedef callback6<C*, T1, T2, T3, T4, T5, T6> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4,
+          typename T5>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, T5, void, void, void, void>
+{
+     typedef callback5<C*, T1, T2, T3, T4, T5> type;
+};
+
+template <class C, typename T1, typename T2, typename T3, typename T4>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, T4, void, void, void, void, void>
+{
+     typedef callback4<C*, T1, T2, T3, T4> type;
+};
+
+template <class C, typename T1, typename T2, typename T3>
+struct get_callback_type_for_construct<
+     C, T1, T2, T3, void, void, void, void, void, void>
+{
+     typedef callback3<C*, T1, T2, T3> type;
+};
+
+template <class C, typename T1, typename T2>
+struct get_callback_type_for_construct<
+     C, T1, T2, void, void, void, void, void, void, void>
+{
+     typedef callback2<C*, T1, T2> type;
+};
+
+template <class C, typename T1>
+struct get_callback_type_for_construct<
+     C, T1, void, void, void, void, void, void, void, void>
+{
+     typedef callback1<C*, T1> type;
+};
+
+template <class C>
+struct get_callback_type_for_construct<
+     C, void, void, void, void, void, void, void, void, void>
+{
+     typedef callback0<C*> type;
+};
Index: /code/branches/ceguilua/src/cpptcl/details/methods.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/methods.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/methods.h	(revision 1801)
@@ -0,0 +1,452 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename R>
+class method0 : public object_cmd_base
+{
+     typedef R (C::*mem_type)();
+     typedef R (C::*cmem_type)() const;
+     
+public:
+     method0(mem_type f) : f_(f), cmem_(false) {}
+     method0(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int, Tcl_Obj * CONST [], policies const &)
+     {
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::do_dispatch(interp, boost::bind(cf_, p));
+          }
+          else
+          {
+               dispatch<R>::do_dispatch(interp, boost::bind(f_, p));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1>
+class method1 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1);
+     typedef R (C::*cmem_type)(T1) const;
+     
+public:
+     method1(mem_type f) : f_(f), cmem_(false) {}
+     method1(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 3);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(cf_, p, _1),
+                    tcl_cast<T1>::from(interp, objv[2]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(f_, p, _1),
+                    tcl_cast<T1>::from(interp, objv[2]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2>
+class method2 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2);
+     typedef R (C::*cmem_type)(T1, T2) const;
+     
+public:
+     method2(mem_type f) : f_(f), cmem_(false) {}
+     method2(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 4);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(cf_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(f_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3>
+class method3 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3);
+     typedef R (C::*cmem_type)(T1, T2, T3) const;
+     
+public:
+     method3(mem_type f) : f_(f), cmem_(false) {}
+     method3(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 5);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(cf_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(f_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4>
+class method4 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4) const;
+     
+public:
+     method4(mem_type f) : f_(f), cmem_(false) {}
+     method4(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 6);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5>
+class method5 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const;
+     
+public:
+     method5(mem_type f) : f_(f), cmem_(false) {}
+     method5(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 7);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6>
+class method6 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const;
+     
+public:
+     method6(mem_type f) : f_(f), cmem_(false) {}
+     method6(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 8);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7>
+class method7 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const;
+     
+public:
+     method7(mem_type f) : f_(f), cmem_(false) {}
+     method7(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 9);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8>
+class method8 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const;
+     
+public:
+     method8(mem_type f) : f_(f), cmem_(false) {}
+     method8(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 10);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8,
+     typename T9>
+class method9 : public object_cmd_base
+{
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const;
+     
+public:
+     method9(mem_type f) : f_(f), cmem_(false) {}
+     method9(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &)
+     {
+          check_params_no(objc, 11);
+          
+          C *p = static_cast<C*>(pv);
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    tcl_cast<T9>::from(interp, objv[10]));
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    tcl_cast<T9>::from(interp, objv[10]));
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
Index: /code/branches/ceguilua/src/cpptcl/details/methods_v.h
===================================================================
--- /code/branches/ceguilua/src/cpptcl/details/methods_v.h	(revision 1801)
+++ /code/branches/ceguilua/src/cpptcl/details/methods_v.h	(revision 1801)
@@ -0,0 +1,451 @@
+//
+// Copyright (C) 2004-2006, Maciej Sobczak
+//
+// Permission to copy, use, modify, sell and distribute this software
+// is granted provided this copyright notice appears in all copies.
+// This software is provided "as is" without express or implied
+// warranty, and with no claim as to its suitability for any purpose.
+//
+
+// Note: this file is not supposed to be a stand-alone header
+
+
+template <class C, typename R>
+class method1<C, R, object const &> : public object_cmd_base
+{
+     typedef object const & T1;
+     typedef R (C::*mem_type)(T1);
+     typedef R (C::*cmem_type)(T1) const;
+     enum { var_start = 2 };
+     
+public:
+     method1(mem_type f) : f_(f), cmem_(false) {}
+     method1(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t1 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(cf_, p, _1),
+                    t1);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1>(
+                    interp, boost::bind(f_, p, _1),
+                    t1);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1>
+class method2<C, R, T1, object const &> : public object_cmd_base
+{
+     typedef object const & T2;
+     typedef R (C::*mem_type)(T1, T2);
+     typedef R (C::*cmem_type)(T1, T2) const;
+     enum { var_start = 3 };
+     
+public:
+     method2(mem_type f) : f_(f), cmem_(false) {}
+     method2(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t2 = get_var_params(interp, objc, objv, var_start, pol);
+          
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(cf_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    t2);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2>(
+                    interp, boost::bind(f_, p, _1, _2),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    t2);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2>
+class method3<C, R, T1, T2, object const &> : public object_cmd_base
+{
+     typedef object const & T3;
+     typedef R (C::*mem_type)(T1, T2, T3);
+     typedef R (C::*cmem_type)(T1, T2, T3) const;
+     enum { var_start = 4 };
+     
+public:
+     method3(mem_type f) : f_(f), cmem_(false) {}
+     method3(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t3 = get_var_params(interp, objc, objv, var_start, pol);
+          
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(cf_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    t3);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3>(
+                    interp, boost::bind(f_, p, _1, _2, _3),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    t3);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3>
+class method4<C, R, T1, T2, T3, object const &> : public object_cmd_base
+{
+     typedef object const & T4;
+     typedef R (C::*mem_type)(T1, T2, T3, T4);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4) const;
+     enum { var_start = 5 };
+     
+public:
+     method4(mem_type f) : f_(f), cmem_(false) {}
+     method4(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t4 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    t4);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    t4);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4>
+class method5<C, R, T1, T2, T3, T4, object const &> : public object_cmd_base
+{
+     typedef object const & T5;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5) const;
+     enum { var_start = 6 };
+     
+public:
+     method5(mem_type f) : f_(f), cmem_(false) {}
+     method5(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t5 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    t5);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    t5);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5>
+class method6<C, R, T1, T2, T3, T4, T5, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T6;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6) const;
+     enum { var_start = 7 };
+     
+public:
+     method6(mem_type f) : f_(f), cmem_(false) {}
+     method6(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t6 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    t6);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    t6);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6>
+class method7<C, R, T1, T2, T3, T4, T5, T6, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T7;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7) const;
+     enum { var_start = 8 };
+     
+public:
+     method7(mem_type f) : f_(f), cmem_(false) {}
+     method7(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t7 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(cf_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    t7);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<T1, T2, T3, T4, T5, T6, T7>(
+                    interp, boost::bind(f_, p, _1, _2, _3, _4, _5, _6, _7),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    t7);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7>
+class method8<C, R, T1, T2, T3, T4, T5, T6, T7, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T8;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8) const;
+     enum { var_start = 9 };
+     
+public:
+     method8(mem_type f) : f_(f), cmem_(false) {}
+     method8(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t8 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    t8);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    t8);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
+
+template <class C, typename R, typename T1, typename T2, typename T3,
+     typename T4, typename T5, typename T6, typename T7, typename T8>
+class method9<C, R, T1, T2, T3, T4, T5, T6, T7, T8, object const &>
+     : public object_cmd_base
+{
+     typedef object const & T9;
+     typedef R (C::*mem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9);
+     typedef R (C::*cmem_type)(T1, T2, T3, T4, T5, T6, T7, T8, T9) const;
+     enum { var_start = 10 };
+     
+public:
+     method9(mem_type f) : f_(f), cmem_(false) {}
+     method9(cmem_type f) : cf_(f), cmem_(true) {}
+     
+     virtual void invoke(void *pv, Tcl_Interp *interp,
+          int objc, Tcl_Obj * CONST objv[], policies const &pol)
+     {
+          C *p = static_cast<C*>(pv);
+
+          object t9 = get_var_params(interp, objc, objv, var_start, pol);
+
+          if (cmem_)
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(cf_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    t9);
+          }
+          else
+          {
+               dispatch<R>::template do_dispatch<
+                    T1, T2, T3, T4, T5, T6, T7, T8, T9>(
+                    interp, boost::bind(f_, p,
+                         _1, _2, _3, _4, _5, _6, _7, _8, _9),
+                    tcl_cast<T1>::from(interp, objv[2]),
+                    tcl_cast<T2>::from(interp, objv[3]),
+                    tcl_cast<T3>::from(interp, objv[4]),
+                    tcl_cast<T4>::from(interp, objv[5]),
+                    tcl_cast<T5>::from(interp, objv[6]),
+                    tcl_cast<T6>::from(interp, objv[7]),
+                    tcl_cast<T7>::from(interp, objv[8]),
+                    tcl_cast<T8>::from(interp, objv[9]),
+                    t9);
+          }
+     }
+
+private:
+     mem_type f_;
+     cmem_type cf_;
+     bool cmem_;
+};
Index: /code/branches/ceguilua/src/network/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/network/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/network/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,50 @@
+SET( NETWORK_SRC_FILES
+  Client.cc
+  ClientConnection.cc
+  ClientInformation.cc
+  ConnectionManager.cc
+  GamestateManager.cc
+  GamestateClient.cc
+  GamestateHandler.cc
+  PacketBuffer.cc
+  Server.cc
+  Synchronisable.cc
+  Host.cc
+  packet/Packet.cc
+  packet/Chat.cc
+  packet/ClassID.cc
+  packet/Acknowledgement.cc
+  packet/Gamestate.cc
+  packet/Welcome.cc
+)
+
+IF(WIN32)
+  ADD_LIBRARY( network ${NETWORK_SRC_FILES} )
+ELSE(WIN32)
+  ADD_LIBRARY( network SHARED ${NETWORK_SRC_FILES} )
+ENDIF(WIN32)
+
+TARGET_LINK_LIBRARIES( network
+  ${ZLIB_LIBRARY}
+  ${ENet_LIBRARY}
+  ${Boost_thread_LIBRARIES}
+  core
+)
+
+
+# build those parts only on request.
+IF(NETWORK_TESTING_ENABLED)
+  ##### test for gamestate stuff #####
+  SET( TEST_SRC_FILES
+    ${NETWORK_SRC_FILES}
+  )
+  ADD_EXECUTABLE(networktest ${TEST_SRC_FILES})
+  TARGET_LINK_LIBRARIES( networktest
+    ${OGRE_LIBRARIES}
+    network
+    ${ENet_LIBRARY}
+    ${ZLIB_LIBRARY}
+    ${WINDOWS_ENET_DEPENDENCIES}
+  )
+  ##### end test for gamestate stuff #####
+ENDIF(NETWORK_TESTING_ENABLED)
Index: /code/branches/ceguilua/src/network/Client.cc
===================================================================
--- /code/branches/ceguilua/src/network/Client.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/Client.cc	(revision 1801)
@@ -0,0 +1,178 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: Client
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "Client.h"
+#include "Host.h"
+#include "Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "packet/Packet.h"
+// #include "packet/Acknowledgement.h"
+
+namespace network
+{
+//   SetConsoleCommandShortcut(Client, chat);
+
+
+  /**
+  * Constructor for the Client class
+  * initializes the address and the port to default localhost:NETWORK_PORT
+  */
+  Client::Client(): client_connection(NETWORK_PORT,"127.0.0.1"){
+    // set server address to localhost
+    isConnected=false;
+    isSynched_=false;
+    gameStateFailure_=false;
+    isServer_ = false;
+  }
+
+  /**
+  * Constructor for the Client class
+  * @param address the server address
+  * @param port port of the application on the server
+  */
+  Client::Client(std::string address, int port) : client_connection(port, address){
+    isConnected=false;
+    isSynched_=false;
+    gameStateFailure_=false;
+    isServer_ = false;
+  }
+
+  /**
+  * Constructor for the Client class
+  * @param address the server address
+  * @param port port of the application on the server
+  */
+  Client::Client(const char *address, int port) : client_connection(port, address){
+    isConnected=false;
+    isSynched_=false;
+    gameStateFailure_=false;
+    isServer_ = false;
+  }
+
+  Client::~Client(){
+    if(isConnected)
+      closeConnection();
+  }
+
+  /**
+  * Establish the Connection to the Server
+  * @return true/false
+  */
+  bool Client::establishConnection(){
+    Synchronisable::setClient(true);
+    isConnected=client_connection.createConnection();
+    if(!isConnected)
+      COUT(1) << "could not create connection laber" << std::endl;
+    return isConnected;
+  }
+
+  /**
+  * closes the Connection to the Server
+  * @return true/false
+  */
+  bool Client::closeConnection(){
+    isConnected=false;
+    return client_connection.closeConnection();
+  }
+
+  bool Client::queuePacket(ENetPacket *packet, int clientID){
+    return client_connection.addPacket(packet);
+  }
+
+  bool Client::processChat(packet::Chat *message, unsigned int clientID){
+    return message->process();
+  }
+
+  /*bool Client::sendChat(packet::Chat *chat){
+    chat->process();
+    packet::Packet *p = new packet::Packet(chat);
+    return p->send();
+  }*/
+
+
+  /**
+  * submits a chat message to the server
+  * @param message message to send
+  * @return true/false
+  */
+  bool Client::sendChat( std::string message ){
+    // generate packet and add it to queue
+    if(!isConnected)
+      return false;
+    packet::Chat chat(message, 0);
+    return chat.send();
+    // send packets
+  }
+
+  /**
+  * Performs a GameState update
+  */
+  void Client::tick(float time){
+//     COUT(3) << ".";
+    if(client_connection.isConnected() && isSynched_){
+      COUT(4) << "popping partial gamestate: " << std::endl;
+      packet::Gamestate *gs = gamestate.getGamestate();
+      if(gs){
+        COUT(4) << "client tick: sending gs " << gs << std::endl;
+        if( !gs->send() )
+          COUT(3) << "Problem adding partial gamestate to queue" << std::endl;
+        // gs gets automatically deleted by enet callback
+      }
+    }
+    ENetEvent *event;
+    // stop if the packet queue is empty
+    while(!(client_connection.queueEmpty())){
+      event = client_connection.getEvent();
+      COUT(5) << "tick packet size " << event->packet->dataLength << std::endl;
+      packet::Packet *packet = packet::Packet::createPacket(event->packet, event->peer);
+      assert(packet->process());
+    }
+    if(gamestate.processGamestates())
+    {
+      if(!isSynched_)
+        isSynched_=true;
+    }else
+      COUT(3) << "gamestate has not been processed sucessfully" << std::endl;
+    gamestate.cleanup();
+    return;
+  }
+
+}
Index: /code/branches/ceguilua/src/network/Client.h
===================================================================
--- /code/branches/ceguilua/src/network/Client.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/Client.h	(revision 1801)
@@ -0,0 +1,106 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: Client
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _Client_H__
+#define _Client_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+
+#include "Host.h"
+#include "packet/Chat.h"
+#include "ClientConnection.h"
+#include "GamestateClient.h"
+//#include "NetworkFrameListener.h"
+
+
+
+namespace network
+{
+  /**
+  network::Client *client;
+  * The network/Client class
+  * This class implements all necessary function for the network communication
+  * It is the root class of the network module
+  *
+  */
+  class _NetworkExport Client : public Host{
+  public:
+    Client();
+    Client(std::string address, int port);
+    Client(const char *address, int port);
+    ~Client();
+    
+    bool establishConnection();
+    bool closeConnection();
+    bool queuePacket(ENetPacket *packet, int clientID);
+    bool processChat(packet::Chat *message, unsigned int clientID);
+    //bool sendChat(packet::Chat *chat);
+    
+//    static void Chat( std::string message );
+    
+    unsigned int shipID(){return shipID_;}
+    int playerID(){return clientID_;}
+    //static void setShipID( unsigned int shipID){ dynamic_cast<Client *>(instance_)->shipID_=shipID; }
+    static void setClientID( unsigned int clientID){ dynamic_cast<Client *>(instance_)->clientID_=clientID; }
+    
+    void tick(float time);
+
+  private:
+    
+    ClientConnection client_connection;
+    GamestateClient gamestate;
+    bool isConnected;
+    bool isSynched_;
+
+    bool sendChat( std::string message );
+    
+    // implement data processing functions of PacketDecoder
+//     void processChat( chat *data, int clientId );
+    int clientID_;     // this is the id the server gave to us
+    int shipID_;
+    bool gameStateFailure_;
+  };
+
+
+}
+
+#endif /* _Client_H__ */
Index: /code/branches/ceguilua/src/network/ClientConnection.cc
===================================================================
--- /code/branches/ceguilua/src/network/ClientConnection.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/ClientConnection.cc	(revision 1801)
@@ -0,0 +1,258 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ClientConnection
+//
+// Description: The Class ClientConnection manages the servers conenctions to the clients.
+// each connection is provided by a new process. communication between master process and
+// connection processes is provided by ...
+//
+//
+// Author:  Oliver Scheuss
+//
+
+#include "ClientConnection.h"
+
+#include <iostream>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "util/Sleep.h"
+#include "util/Debug.h"
+
+namespace network
+{
+  //static boost::thread_group network_threads;
+
+  boost::recursive_mutex ClientConnection::enet_mutex_;
+
+  ClientConnection::ClientConnection(int port, std::string address) {
+    quit=false;
+    server=NULL;
+    enet_address_set_host(&serverAddress, address.c_str());
+    serverAddress.port = port;
+    established=false;
+  }
+
+  ClientConnection::ClientConnection(int port, const char *address) {
+    quit=false;
+    server=NULL;
+    enet_address_set_host(&serverAddress, address);
+    serverAddress.port = port;
+    established=false;
+  }
+
+  bool ClientConnection::waitEstablished(int milisec) {
+    for(int i=0; i<=milisec && !established; i++)
+      usleep(1000);
+
+    return established;
+  }
+
+
+  /*ENetPacket *ClientConnection::getPacket(ENetAddress &address) {
+    if(!buffer.isEmpty()) {
+      //std::cout << "###BUFFER IS NOT EMPTY###" << std::endl;
+      return buffer.pop(address);
+    }
+    else{
+      return NULL;
+    }
+  }
+
+  ENetPacket *ClientConnection::getPacket() {
+    ENetAddress address; //sems that address is not needed
+    return getPacket(address);
+  }*/
+
+  ENetEvent *ClientConnection::getEvent(){
+    if(!buffer.isEmpty())
+      return buffer.pop();
+    else
+      return NULL;
+  }
+
+  bool ClientConnection::queueEmpty() {
+    return buffer.isEmpty();
+  }
+
+  bool ClientConnection::createConnection() {
+    receiverThread_ = new boost::thread(boost::bind(&ClientConnection::receiverThread, this));
+    //network_threads.create_thread(boost::bind(boost::mem_fn(&ClientConnection::receiverThread), this));
+    // wait 10 seconds for the connection to be established
+    return waitEstablished(NETWORK_CLIENT_CONNECT_TIMEOUT);
+  }
+
+  bool ClientConnection::closeConnection() {
+    quit=true;
+    //network_threads.join_all();
+    receiverThread_->join();
+    established=false;
+    return true;
+  }
+
+
+  bool ClientConnection::addPacket(ENetPacket *packet) {
+    if(server==NULL)
+      return false;
+    if(packet==NULL){
+      COUT(3) << "Cl.con: addpacket: invalid packet" << std::endl;
+      return false;
+    }
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    if(enet_peer_send(server, 0, packet)<0)
+      return false;
+    else
+      return true;
+  }
+
+  bool ClientConnection::sendPackets() {
+    if(server==NULL)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    enet_host_flush(client);
+    lock.unlock();
+    return true;
+  }
+
+  void ClientConnection::receiverThread() {
+    // what about some error-handling here ?
+    atexit(enet_deinitialize);
+    ENetEvent *event;
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      enet_initialize();
+      client = enet_host_create(NULL, NETWORK_CLIENT_MAX_CONNECTIONS, 0, 0);
+      lock.unlock();
+    }
+    if(client==NULL) {
+      COUT(2) << "ClientConnection: could not create client host" << std::endl;
+      // add some error handling here ==========================
+      quit=true;
+    }
+    //connect to the server
+    if(!establishConnection()){
+      COUT(2) << "clientConn: receiver thread: could not establishConnection" << std::endl;
+      quit=true;
+      return;
+    }
+    event = new ENetEvent;
+    //main loop
+    while(!quit){
+      //std::cout << "connection loop" << std::endl;
+      {
+        boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+        if(enet_host_service(client, event, NETWORK_CLIENT_WAIT_TIME)<0){
+          // we should never reach this point
+          quit=true;
+          continue;
+          // add some error handling here ========================
+        }
+        lock.unlock();
+      }
+      switch(event->type){
+        // log handling ================
+      case ENET_EVENT_TYPE_CONNECT:
+        break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        COUT(5) << "Cl.Con: receiver-Thread while loop: got new packet" << std::endl;
+        if ( !processData(event) ) COUT(2) << "Current packet was not pushed to packetBuffer -> ev ongoing SegFault" << std::endl;
+        COUT(5) << "Cl.Con: processed Data in receiver-thread while loop" << std::endl;
+        event = new ENetEvent;
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        quit=true;
+        // server closed the connection
+        return;
+        break;
+      case ENET_EVENT_TYPE_NONE:
+        //receiverThread_->yield();
+        usleep(1000);
+        break;
+      }
+    }
+    // now disconnect
+
+    if(!disconnectConnection())
+      // if disconnecting failed destroy conn.
+      boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+      enet_peer_reset(server);
+    return;
+  }
+
+  bool ClientConnection::disconnectConnection() {
+    ENetEvent event;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    enet_peer_disconnect(server, 0);
+    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME) > 0){
+      switch (event.type)
+      {
+      case ENET_EVENT_TYPE_NONE:
+      case ENET_EVENT_TYPE_CONNECT:
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        return true;
+      }
+    }
+    enet_peer_reset(server);
+    return false;
+  }
+
+  bool ClientConnection::establishConnection() {
+    ENetEvent event;
+    // connect to peer (server is type ENetPeer*)
+    boost::recursive_mutex::scoped_lock lock(enet_mutex_);
+    server = enet_host_connect(client, &serverAddress, NETWORK_CLIENT_CHANNELS);
+    if(server==NULL) {
+      COUT(2) << "ClientConnection: server == NULL" << std::endl;
+      // error handling
+      return false;
+    }
+    // handshake
+    while(enet_host_service(client, &event, NETWORK_CLIENT_WAIT_TIME)>=0 && !quit){
+      if( event.type == ENET_EVENT_TYPE_CONNECT ){
+        established=true;
+        return true;
+      }
+    }
+    COUT(2) << "ClientConnection: enet_host_service < 0 or event.type != ENET_EVENT_TYPE_CONNECT # EVENT:" << event.type << std::endl;
+    return false;
+  }
+
+  bool ClientConnection::processData(ENetEvent *event) {
+    COUT(5) << "Cl.Con: got packet, pushing to queue" << std::endl;
+    // just add packet to the buffer
+    // this can be extended with some preprocessing
+    return buffer.push(event);
+  }
+
+}
Index: /code/branches/ceguilua/src/network/ClientConnection.h
===================================================================
--- /code/branches/ceguilua/src/network/ClientConnection.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/ClientConnection.h	(revision 1801)
@@ -0,0 +1,112 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ClientConnection
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _ClientConnection_H__
+#define _ClientConnection_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+#include "PacketBuffer.h"
+
+namespace boost { class thread; }
+
+namespace network
+{
+
+    const int NETWORK_PORT = 55556;
+    const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
+    const int NETWORK_CLIENT_WAIT_TIME = 1;
+    const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
+    const int NETWORK_CLIENT_CHANNELS = 2;
+
+
+  class ClientConnection{
+  public:
+    ClientConnection(int port, std::string address);
+    ClientConnection(int port, const char* address);
+    //ENetPacket *getPacket(ENetAddress &address); // thread1
+    //ENetPacket *getPacket(); // thread1
+    ENetEvent *getEvent();
+    // check wheter the packet queue is empty
+    bool queueEmpty();
+    // create a new listener thread
+    bool createConnection();
+    bool closeConnection();
+    // add a packet to queue for the server
+    bool addPacket(ENetPacket *packet);
+    // send out all queued packets
+    bool sendPackets();
+    // send out all queued packets and save result in event
+    //bool sendPackets(ENetEvent *event);
+    bool waitEstablished(int milisec);
+    bool isConnected(){return established;}
+  private:
+    bool processData(ENetEvent *event);
+    // implementation of the listener
+    void receiverThread(); //thread2
+    //packetbuffer
+    bool establishConnection();
+    bool disconnectConnection();
+    PacketBuffer buffer;
+    // enet stuff
+    ENetHost *client;
+    ENetAddress serverAddress;
+    // quit-variable (communication with threads)
+    bool quit;
+    bool established;
+    // clientlist
+    ENetPeer *server;
+    boost::thread *receiverThread_;
+    
+    static boost::recursive_mutex enet_mutex_;
+  };
+
+
+
+
+
+
+
+
+}
+
+#endif /* _ClientConnection_H__ */
Index: /code/branches/ceguilua/src/network/ClientInformation.cc
===================================================================
--- /code/branches/ceguilua/src/network/ClientInformation.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/ClientInformation.cc	(revision 1801)
@@ -0,0 +1,271 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: ClientInformation
+//
+// Description:
+//
+//
+// Author:  <>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "ClientInformation.h"
+
+#include <iostream> //debug
+
+namespace network
+{
+  
+  ClientInformation *ClientInformation::head_=0;
+  
+  ClientInformation::ClientInformation() {
+    if(!head_)
+      head_=this;
+    gamestateID_=GAMESTATEID_INITIAL;
+    preve=0;
+    nexte=0;
+    partialGamestateID_=GAMESTATEID_INITIAL-1;
+    synched_=false;
+  }
+
+  ClientInformation::~ClientInformation() {
+    if(this==head_)
+      head_=next();
+    if(prev()!=0)
+      prev()->setNext(this->next());
+    if(next()!=0)
+      next()->setPrev(this->prev());
+  }
+
+  ClientInformation *ClientInformation::next() {
+    if(this!=0)
+      return this->nexte;
+    else
+      return 0;
+  }
+  ClientInformation *ClientInformation::prev() {
+    if(this!=0)
+      return this->preve;
+    else
+      return 0;
+  }
+
+  bool ClientInformation::setPrev(ClientInformation *prev) {
+    if(this==head_)
+      head_=prev;
+    this->preve = prev;
+    return true;
+  }
+
+  bool ClientInformation::setNext(ClientInformation *next) {
+    this->nexte = next;
+    return true;
+  }
+
+  ClientInformation *ClientInformation::insertAfter(ClientInformation *ins) {
+    this->next()->setPrev(ins);
+    ins->setNext(this->next());
+    ins->setPrev(this);
+    this->nexte = ins;
+    return ins;
+  }
+
+  ClientInformation *ClientInformation::insertBefore(ClientInformation *ins){
+    if(!this)
+      return NULL;
+    this->prev()->setNext(ins);
+    ins->setPrev(this->prev());
+    this->preve=ins;
+    ins->setNext(this);
+    return ins;
+  }
+
+  void ClientInformation::setID(int clientID){
+    if(!this)
+      return;
+    clientID_ = clientID;
+  }
+
+  bool ClientInformation::setPeer(ENetPeer *peer){
+    if(!this)
+      return false;
+    peer_ = peer;
+    return true;
+  }
+
+  bool ClientInformation::setGamestateID(int id){
+    if(!this)
+      return false;
+    gamestateID_=id;
+    return true;
+  }
+  
+  bool ClientInformation::setPartialGamestateID(int id){
+    if(!this)
+      return false;
+    partialGamestateID_=id;
+    return true;
+  }
+
+  int ClientInformation::getID() {
+    if(!this)
+      return CLIENTID_UNKNOWN;
+    else
+      return clientID_;
+  }
+
+  ENetPeer *ClientInformation::getPeer() {
+    if(this)
+      return peer_;
+    else
+      return NULL;
+  }
+  
+  int ClientInformation::getFailures(){
+    return failures_;
+  }
+  void ClientInformation::addFailure(){
+    failures_++;
+  }
+  void ClientInformation::resetFailures(){
+    failures_=0;
+  }
+  
+  enet_uint32 ClientInformation::getRTT(){
+    return peer_->roundTripTime;
+  }
+  
+  enet_uint32 ClientInformation::getPacketLoss(){
+    return peer_->packetLoss;
+  }
+
+  int ClientInformation::getGamestateID() {
+    if(this)
+      return gamestateID_;
+    else
+      return -1;
+  }
+  
+  int ClientInformation::getPartialGamestateID() {
+    if(this)
+      return partialGamestateID_;
+    else
+      return -1;
+  }
+
+  ClientInformation *ClientInformation::insertBack(ClientInformation *ins) {
+    ClientInformation *temp = head_;
+    if(temp==head_){
+      return head_;
+    }
+    while(temp->next()!=0){
+      temp = temp->next();
+    }
+    temp->setNext(ins);
+    ins->setPrev(temp);
+    return ins;
+  }
+
+  bool ClientInformation::removeClient(int clientID) {
+    if(clientID==CLIENTID_UNKNOWN)
+      return false;
+    ClientInformation *temp = head_;
+    while(temp!=0 && temp->getID()!=clientID)
+      temp = temp->next();
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  bool ClientInformation::removeClient(ENetPeer *peer) {
+    if(!peer)
+      return false;
+    ClientInformation *temp = head_;
+    while(temp!=0){
+      if(temp->getPeer()->address.host==peer->address.host && temp->getPeer()->address.port==peer->address.port)
+        break;
+      temp = temp->next();
+    }
+    if(temp==0)
+      return false;
+    delete temp;
+    return true;
+  }
+
+  /**
+  * This function goes forward through the list and looks for an element with clientID
+  * This function should only be applied to the head of the list
+  * @param clientID id to look for
+  * @return pointer to the last element in the list or 0 if the search was unsuccessfull
+  */
+  ClientInformation *ClientInformation::findClient(int clientID, bool look_backwards) {
+    ClientInformation *temp = head_;
+    while(temp!=0 && temp->getID()!=clientID){
+      temp = temp->next();
+    }
+    // returns 0 if nothing has been found
+    return temp;
+  }
+
+  /**
+  * This function goes forward through the list and looks for an element with clientID
+  * This function should only be applied to the head of the list
+  * @param peer peer to look for
+  * @return pointer to the element in the list
+  */
+  ClientInformation *ClientInformation::findClient(ENetAddress *address, bool look_backwards) {
+    ClientInformation *temp = head_;
+    while(temp!=0){
+      if(temp->getPeer()->address.host==address->host && temp->getPeer()->address.port == address->port)
+        break;
+      temp = temp->next();
+    }
+    // returns 0 if nothing has been found
+    return temp;
+  }
+
+  bool ClientInformation::setSynched(bool s) {
+    if(!this)
+      return false;
+    synched_=s;
+    return true;
+  }
+
+  bool ClientInformation::getSynched() {
+    if(this)
+      return synched_;
+    else
+      return false;
+  }
+
+}
Index: /code/branches/ceguilua/src/network/ClientInformation.h
===================================================================
--- /code/branches/ceguilua/src/network/ClientInformation.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/ClientInformation.h	(revision 1801)
@@ -0,0 +1,122 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ClientInformation
+//
+// Description:
+//
+//
+// Author:  <>, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _ClientInformation_H__
+#define _ClientInformation_H__
+
+#include "NetworkPrereqs.h"
+
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+
+#define GAMESTATEID_INITIAL -1
+#define CLIENTID_UNKNOWN -2
+
+// WATCH OUT: THE CLIENTINFORMATION LIST IS NOT THREADSAFE ANYMORE
+
+namespace network
+{
+  /**
+  * This class implements a list for client informations
+  * @author Oliver Scheuss
+  */
+  class ClientInformation{
+  public:
+    ClientInformation();
+    //   ClientInformation(ClientInformation *prev, ClientInformation *next);
+    //   ClientInformation(ClientInformation *prev);
+    ~ClientInformation();
+    ClientInformation *next();
+    ClientInformation *prev();
+    static ClientInformation *insertBack(ClientInformation *ins);
+    
+    // set functions
+    void setID(int clientID);
+    bool setPeer(ENetPeer *peer);
+    bool setGamestateID(int id);
+    bool setPartialGamestateID(int id);
+    inline void setShipID(unsigned int id){ShipID_=id;}
+    
+    // get functions
+    inline unsigned int getShipID(){return ShipID_;}
+    int getID();
+    int getGamestateID();
+    int getPartialGamestateID();
+    ENetPeer *getPeer();
+    
+    int getFailures();
+    void addFailure();
+    void resetFailures();
+    enet_uint32 getRTT();
+    enet_uint32 getPacketLoss();
+    
+    static bool removeClient(int clientID);
+    static bool removeClient(ENetPeer *peer);
+    static ClientInformation *findClient(int clientID, bool look_backwards=false);
+    static ClientInformation *findClient(ENetAddress *address, bool look_backwards=false);
+    static ClientInformation *getBegin(){return head_;}
+
+    bool setSynched(bool s);
+    bool getSynched();
+
+
+  private:
+    static ClientInformation *head_;
+    
+    bool setNext(ClientInformation *next);
+    bool setPrev(ClientInformation *prev);
+    ClientInformation *insertAfter(ClientInformation *ins);
+    ClientInformation *insertBefore(ClientInformation *ins);
+    
+    ClientInformation *preve;
+    ClientInformation *nexte;
+    //actual information:
+    ENetPeer *peer_;
+    int clientID_;
+    int gamestateID_;
+    int partialGamestateID_;
+    unsigned int ShipID_;   // this is the unique objectID
+    bool synched_;
+    unsigned short failures_;
+    
+  };
+
+}
+
+#endif /* _ClientInformation_H__ */
Index: /code/branches/ceguilua/src/network/ConnectionManager.cc
===================================================================
--- /code/branches/ceguilua/src/network/ConnectionManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/ConnectionManager.cc	(revision 1801)
@@ -0,0 +1,392 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ConnectionManager
+//
+// Description: The Class ConnectionManager manages the servers conenctions to the clients.
+// each connection is provided by a new process. communication between master process and
+// connection processes is provided by ...
+//
+//
+// Author:  Oliver Scheuss
+//
+
+#include <iostream>
+#include <assert.h>
+// boost.thread library for multithreading support
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "core/Iterator.h"
+#include "objects/SpaceShip.h"
+#include "util/Math.h"
+#include "util/Sleep.h"
+#include "ClientInformation.h"
+#include "ConnectionManager.h"
+#include "Synchronisable.h"
+#include "packet/ClassID.h"
+
+namespace std
+{
+  bool operator< (ENetAddress a, ENetAddress b) {
+    if(a.host <= b.host)
+      return true;
+    else
+      return false;
+  }
+}
+
+namespace network
+{
+  //boost::thread_group network_threads;
+
+  ConnectionManager *ConnectionManager::instance_=0;
+
+  ConnectionManager::ConnectionManager():receiverThread_(0){
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    bindAddress.host = ENET_HOST_ANY;
+    bindAddress.port = NETWORK_PORT;
+  }
+  boost::recursive_mutex ConnectionManager::enet_mutex;
+
+//   ConnectionManager::ConnectionManager(ClientInformation *head) : receiverThread_(0) {
+//     assert(instance_==0);
+//     instance_=this;
+//     quit=false;
+//     bindAddress.host = ENET_HOST_ANY;
+//     bindAddress.port = NETWORK_PORT;
+//   }
+
+  ConnectionManager::ConnectionManager(int port){
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    bindAddress.host = ENET_HOST_ANY;
+    bindAddress.port = port;
+  }
+
+  ConnectionManager::ConnectionManager(int port, std::string address) :receiverThread_(0) {
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    enet_address_set_host (& bindAddress, address.c_str());
+    bindAddress.port = NETWORK_PORT;
+  }
+
+  ConnectionManager::ConnectionManager(int port, const char *address) : receiverThread_(0) {
+    assert(instance_==0);
+    instance_=this;
+    quit=false;
+    enet_address_set_host (& bindAddress, address);
+    bindAddress.port = NETWORK_PORT;
+  }
+
+  ConnectionManager::~ConnectionManager(){
+    instance_=0;
+    if(!quit)
+      quitListener();
+  }
+
+  /*ENetPacket *ConnectionManager::getPacket(ENetAddress &address) {
+    if(!buffer.isEmpty())
+      return buffer.pop(address);
+    else
+      return NULL;
+  }*/
+/**
+This function only pops the first element in PacketBuffer (first in first out)
+used by processQueue in Server.cc
+*/
+  /*ENetPacket *ConnectionManager::getPacket(int &clientID) {
+    ENetAddress address;
+    ENetPacket *packet=getPacket(address);
+    ClientInformation *temp =head_->findClient(&address);
+    if(!temp)
+      return NULL;
+    clientID=temp->getID();
+    return packet;
+  }*/
+
+  ENetEvent *ConnectionManager::getEvent(){
+    if(!buffer.isEmpty())
+      return buffer.pop();
+    else
+      return NULL;
+  }
+
+  bool ConnectionManager::queueEmpty() {
+    return buffer.isEmpty();
+  }
+
+  void ConnectionManager::createListener() {
+    receiverThread_ = new boost::thread(boost::bind(&ConnectionManager::receiverThread, this));
+    //network_threads.create_thread(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+         //boost::thread thr(boost::bind(boost::mem_fn(&ConnectionManager::receiverThread), this));
+    return;
+  }
+
+  bool ConnectionManager::quitListener() {
+    quit=true;
+    //network_threads.join_all();
+    receiverThread_->join();
+    return true;
+  }
+
+//   bool ConnectionManager::addPacket(Packet::Packet *packet){
+//     ClientInformation *temp = instance_->head_->findClient(packet->getClientID());
+//     if(!temp){
+//       COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
+//       return false;
+//     }
+//     ENetPacket *packet = new ENetPacket;
+//     //  TODO: finish implementation
+//   }
+//
+
+  bool ConnectionManager::addPacket(ENetPacket *packet, ENetPeer *peer) {
+    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
+    if(enet_peer_send(peer, NETWORK_DEFAULT_CHANNEL, packet)!=0)
+      return false;
+    return true;
+  }
+
+  bool ConnectionManager::addPacket(ENetPacket *packet, int clientID) {
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    if(!temp){
+      COUT(3) << "C.Man: addPacket findClient failed" << std::endl;
+      return false;
+    }
+    return addPacket(packet, temp->getPeer());
+  }
+
+  bool ConnectionManager::addPacketAll(ENetPacket *packet) {
+    if(!instance_)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(instance_->enet_mutex);
+    for(ClientInformation *i=ClientInformation::getBegin()->next(); i!=0; i=i->next()){
+      COUT(3) << "adding broadcast packet for client: " << i->getID() << std::endl;
+      if(enet_peer_send(i->getPeer(), 0, packet)!=0)
+        return false;
+    }
+    return true;
+  }
+
+  // we actually dont need that function, because host_service does that for us
+  bool ConnectionManager::sendPackets() {
+    if(server==NULL || !instance_)
+      return false;
+    boost::recursive_mutex::scoped_lock lock(enet_mutex);
+    enet_host_flush(server);
+    lock.unlock();
+    return true;
+  }
+
+  void ConnectionManager::receiverThread() {
+    // what about some error-handling here ?
+    ENetEvent *event;
+    atexit(enet_deinitialize);
+    { //scope of the mutex
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
+      enet_initialize();
+      server = enet_host_create(&bindAddress, NETWORK_MAX_CONNECTIONS, 0, 0);
+      lock.unlock();
+    }
+    if(server==NULL){
+      // add some error handling here ==========================
+      quit=true;
+      return;
+    }
+
+    event = new ENetEvent;
+    while(!quit){
+      { //mutex scope
+        boost::recursive_mutex::scoped_lock lock(enet_mutex);
+        if(enet_host_service(server, event, NETWORK_WAIT_TIMEOUT)<0){
+          // we should never reach this point
+          quit=true;
+          continue;
+          // add some error handling here ========================
+        }
+        lock.unlock();
+      }
+      switch(event->type){
+        // log handling ================
+        case ENET_EVENT_TYPE_CONNECT:
+          COUT(3) << "adding event_type_connect to queue" << std::endl;
+        case ENET_EVENT_TYPE_DISCONNECT:
+          //addClient(event);
+          //this is a workaround to ensure thread safety
+          //COUT(5) << "Con.Man: connection event has occured" << std::endl;
+          //break;
+        case ENET_EVENT_TYPE_RECEIVE:
+          //std::cout << "received data" << std::endl;
+          COUT(5) << "Con.Man: receive event has occured" << std::endl;
+          // only add, if client has connected yet and not been disconnected
+          //if(head_->findClient(&event->peer->address))
+            processData(event);
+            event = new ENetEvent;
+//           else
+//             COUT(3) << "received a packet from a client we don't know" << std::endl;
+          break;
+        //case ENET_EVENT_TYPE_DISCONNECT:
+          //clientDisconnect(event->peer);
+          //break;
+        case ENET_EVENT_TYPE_NONE:
+          //receiverThread_->yield();
+          usleep(1000);
+          break;
+      }
+//       usleep(100);
+      //receiverThread_->yield(); //TODO: find apropriate
+    }
+    disconnectClients();
+    // if we're finishied, destroy server
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
+      enet_host_destroy(server);
+      lock.unlock();
+    }
+  }
+
+  //### added some bugfixes here, but we cannot test them because
+  //### the server crashes everytime because of some gamestates
+  //### (trying to resolve that now)
+  void ConnectionManager::disconnectClients() {
+    ENetEvent event;
+    ClientInformation *temp = ClientInformation::getBegin()->next();
+    while(temp!=0){
+      {
+        boost::recursive_mutex::scoped_lock lock(enet_mutex);
+        enet_peer_disconnect(temp->getPeer(), 0);
+        lock.unlock();
+      }
+      temp = temp->next();
+    }
+    //bugfix: might be the reason why server crashes when clients disconnects
+    temp = ClientInformation::getBegin()->next();
+    boost::recursive_mutex::scoped_lock lock(enet_mutex);
+    while( temp!=0 && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) >= 0){
+      switch (event.type)
+      {
+      case ENET_EVENT_TYPE_NONE: break;
+      case ENET_EVENT_TYPE_CONNECT: break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        enet_packet_destroy(event.packet);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        COUT(4) << "disconnecting all clients" << std::endl;
+        if(ClientInformation::findClient(&(event.peer->address)))
+          delete ClientInformation::findClient(&(event.peer->address));
+        //maybe needs bugfix: might also be a reason for the server to crash
+        temp = temp->next();
+        break;
+      }
+    }
+    return;
+  }
+
+  bool ConnectionManager::processData(ENetEvent *event) {
+    // just add packet to the buffer
+    // this can be extended with some preprocessing
+    return buffer.push(event);
+  }
+
+
+
+  int ConnectionManager::getClientID(ENetPeer peer) {
+    return getClientID(peer.address);
+  }
+
+  int ConnectionManager::getClientID(ENetAddress address) {
+    return ClientInformation::findClient(&address)->getID();
+  }
+
+  ENetPeer *ConnectionManager::getClientPeer(int clientID) {
+    return ClientInformation::findClient(clientID)->getPeer();
+  }
+
+  /**
+   *
+   * @param clientID
+   */
+  void ConnectionManager::syncClassid(unsigned int clientID) {
+    unsigned int network_id=0, failures=0;
+    std::string classname;
+    orxonox::Identifier *id;
+    std::map<std::string, orxonox::Identifier*>::const_iterator it = orxonox::Factory::getFactoryBegin();
+    while(it != orxonox::Factory::getFactoryEnd()){
+      id = (*it).second;
+      if(id == NULL)
+        continue;
+      classname = id->getName();
+      network_id = id->getNetworkID();
+      if(network_id==0)
+        COUT(3) << "we got a null class id: " << id->getName() << std::endl;
+      COUT(4) << "Con.Man:syncClassid:\tnetwork_id: " << network_id << ", classname: " << classname << std::endl;
+
+      packet::ClassID *classid = new packet::ClassID( network_id, classname );
+      classid->setClientID(clientID);
+      while(!classid->send() && failures < 10){
+        failures++;
+      }
+      ++it;
+    }
+    //sendPackets();
+    COUT(4) << "syncClassid:\tall synchClassID packets have been sent" << std::endl;
+  }
+
+
+
+  bool ConnectionManager::removeShip(ClientInformation *client){
+    unsigned int id=client->getShipID();
+    orxonox::ObjectList<orxonox::SpaceShip>::iterator it;
+    for(it = orxonox::ObjectList<orxonox::SpaceShip>::begin(); it; ++it){
+      if(it->objectID!=id)
+        continue;
+      delete *it;
+    }
+    return true;
+  }
+
+
+  void ConnectionManager::disconnectClient(ClientInformation *client){
+    {
+      boost::recursive_mutex::scoped_lock lock(enet_mutex);
+      enet_peer_disconnect(client->getPeer(), 0);
+      lock.unlock();
+    }
+    removeShip(client);
+  }
+
+
+}
Index: /code/branches/ceguilua/src/network/ConnectionManager.h
===================================================================
--- /code/branches/ceguilua/src/network/ConnectionManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/ConnectionManager.h	(revision 1801)
@@ -0,0 +1,125 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: ConnectionManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _ConnectionManager_H__
+#define _ConnectionManager_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+#include <map>
+// enet library for networking support
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+
+#include "PacketBuffer.h"
+#include "packet/Packet.h"
+
+namespace boost { class thread; }
+
+namespace std
+{
+  bool operator<(ENetAddress a, ENetAddress b);
+}
+
+namespace network
+{
+    const int NETWORK_PORT = 55556;
+    const int NETWORK_MAX_CONNECTIONS = 50;
+    const int NETWORK_WAIT_TIMEOUT = 1;
+    const int NETWORK_DEFAULT_CHANNEL = 0;
+
+  struct ClientList{
+    ENetEvent *event;
+    int ID;
+    ClientList *next;
+  };
+
+  class ConnectionManager{
+    public:
+    static boost::recursive_mutex enet_mutex;
+    ConnectionManager();
+    //ConnectionManager(ClientInformation *head);
+    ConnectionManager(int port);
+    ConnectionManager(int port, const char *address);
+    ConnectionManager(int port, std::string address);
+    ~ConnectionManager();
+    //ENetPacket *getPacket(ENetAddress &address); // thread1
+    //ENetPacket *getPacket(int &clientID);
+    ENetEvent *getEvent();
+    bool queueEmpty();
+    void createListener();
+    bool quitListener();
+//     bool addPacket(Packet::Packet *packet);
+    static bool addPacket(ENetPacket *packet, ENetPeer *peer);
+    static bool addPacket(ENetPacket *packet, int ID);
+    static bool addPacketAll(ENetPacket *packet);
+  //  bool sendPackets(ENetEvent *event);
+    bool sendPackets();
+    //bool createClient(int clientID);
+    void disconnectClient(ClientInformation *client);
+    void syncClassid(unsigned int clientID);
+
+  private:
+//     bool clientDisconnect(ENetPeer *peer);
+//     bool removeClient(int clientID);
+    bool processData(ENetEvent *event);
+    //bool addClient(ENetEvent *event);
+    void receiverThread();
+    void disconnectClients();
+    int getClientID(ENetPeer peer);
+    int getClientID(ENetAddress address);
+    ENetPeer *getClientPeer(int clientID);
+    //bool createShip(ClientInformation *client);
+    bool removeShip(ClientInformation *client);
+    PacketBuffer buffer;
+
+    ENetHost *server;
+    ENetAddress bindAddress;
+
+    bool quit; // quit-variable (communication with threads)
+
+    boost::thread *receiverThread_;
+    static ConnectionManager *instance_;
+
+  };
+
+}
+
+#endif /* _ConnectionManager_H__ */
Index: /code/branches/ceguilua/src/network/GamestateClient.cc
===================================================================
--- /code/branches/ceguilua/src/network/GamestateClient.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/GamestateClient.cc	(revision 1801)
@@ -0,0 +1,204 @@
+/*
+ *   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:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Dumeni Manatschal
+ *
+ */
+
+#include "GamestateClient.h"
+
+#include <zlib.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "core/Iterator.h"
+#include "Synchronisable.h"
+#include "packet/Acknowledgement.h"
+
+
+namespace network
+{
+  struct GameStateItem{
+    packet::Gamestate *state;
+    int id;
+  };
+
+  GamestateClient::GamestateClient() {
+    COUT(5) << "this: " << this << std::endl;
+    last_diff_=0;
+    last_gamestate_=GAMESTATEID_INITIAL-1;
+    tempGamestate_=NULL;
+    myShip_=NULL;
+  }
+
+  GamestateClient::~GamestateClient() {
+  }
+
+  bool GamestateClient::ack(int gamestateID, int clientID){
+    return true;
+  }
+
+  bool GamestateClient::add(packet::Gamestate *gs, int clientID){
+    if(tempGamestate_!=NULL){
+      //delete the obsolete gamestate
+      if(tempGamestate_->getID()>gs->getID())
+        return false;
+      delete tempGamestate_;
+    }
+    tempGamestate_=gs;
+    return true;
+  }
+
+  bool GamestateClient::processGamestates(){
+    if(tempGamestate_==NULL)
+      return false;
+    int id = GAMESTATEID_INITIAL;
+    bool b = saveShipCache();
+    packet::Gamestate *processed = processGamestate(tempGamestate_);
+    if(!processed){
+      if(b)
+        loadShipCache();
+      return false;
+    }
+//    assert(processed);
+    //successfully loaded data from gamestate. now save gamestate for diff and delete the old gs
+    tempGamestate_=NULL;
+    gamestateMap_[processed->getID()]=processed;
+    last_diff_ = processed->getID();
+    if(b)
+      loadShipCache();
+    id = processed->getID();
+    sendAck(id);
+    return true;
+  }
+
+
+  /**
+  * This function removes a Synchronisable out of the universe
+  * @param it iterator of the list pointing to the object
+  * @return iterator pointing to the next object in the list
+  */
+  void GamestateClient::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
+    orxonox::ObjectList<Synchronisable>::iterator temp=it;
+    ++it;
+    delete  *temp;
+  }
+
+  packet::Gamestate *GamestateClient::getGamestate(){
+    packet::Gamestate *gs = new packet::Gamestate();
+    gs->collectData(0);
+    return gs;
+  }
+
+  void GamestateClient::cleanup(){
+    std::map<int, packet::Gamestate*>::iterator temp, it = gamestateMap_.begin();
+    while(it!=gamestateMap_.end()){
+      if(it->first>=last_diff_)
+        break;
+      // otherwise delete that stuff
+      delete (*it).second;
+      temp=it++;
+      gamestateMap_.erase(temp);
+    }
+    tempGamestate_=NULL;
+  }
+
+  void GamestateClient::printGamestateMap(){
+    std::map<int, packet::Gamestate*>::iterator it;
+    COUT(4) << "gamestates: ";
+    for(it=gamestateMap_.begin(); it!=gamestateMap_.end(); it++){
+      COUT(4) << it->first << ":" << it->second << "|";
+    }
+    COUT(4) << std::endl;
+
+  }
+  
+  bool GamestateClient::sendAck(unsigned int gamestateID){
+    packet::Acknowledgement *ack = new packet::Acknowledgement(gamestateID, 0);
+    if(!ack->send()){
+      COUT(3) << "could not ack gamestate: " << gamestateID << std::endl;
+      return false;
+    }
+    else{
+      COUT(3) << "acked a gamestate: " << gamestateID << std::endl;
+      return true;
+    }
+  }
+
+  bool GamestateClient::saveShipCache(){
+    if(myShip_==NULL){
+      myShip_ = orxonox::SpaceShip::getLocalShip();
+//      COUT(2) << "myShip_: " << myShip_ << " getLocalShip(): " << orxonox::SpaceShip::getLocalShip() << std::endl;
+      if(!myShip_)
+	return false;
+    }
+    if(myShip_){
+      //      unsigned char *data = new unsigned char[myShip_->getSize()];
+      int size=myShip_->getSize2(0, 0x1);
+      if(size==0)
+        return false;
+      shipCache_ = new unsigned char [size];
+      unsigned char *temp = shipCache_;
+      if(!myShip_->getData(temp, 0, 0x1))
+        COUT(3) << "could not save shipCache" << std::endl;
+      return true;
+    }else
+      return false;
+  }
+
+  bool GamestateClient::loadShipCache(){
+    myShip_=orxonox::SpaceShip::getLocalShip(); //TODO: remove this (only a hack)
+    if(myShip_ && shipCache_){
+      assert(myShip_->getIdentifier());
+      unsigned char *temp = shipCache_;
+      myShip_->updateData(temp, 0x2);
+      delete shipCache_;
+      return true;
+    }else
+      return false;
+  }
+
+  packet::Gamestate *GamestateClient::processGamestate(packet::Gamestate *gs){
+    if(gs->isCompressed())
+      assert(gs->decompressData());
+    if(gs->isDiffed()){
+      packet::Gamestate *base = gamestateMap_[gs->getBaseID()];
+      if(!base){
+        delete gs;
+        return 0;
+      }
+//      assert(base); //TODO: fix this
+      packet::Gamestate *undiffed = gs->undiff(base);
+      delete gs;
+      gs=undiffed;
+      COUT(3) << "successfully undiffed gamestate id: " << undiffed->getID() << std::endl;
+    }
+    if(gs->spreadData())
+      return gs;
+    else
+      return NULL;
+  }
+
+}
+
Index: /code/branches/ceguilua/src/network/GamestateClient.h
===================================================================
--- /code/branches/ceguilua/src/network/GamestateClient.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/GamestateClient.h	(revision 1801)
@@ -0,0 +1,86 @@
+/*
+ *   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:
+ *      Oliver Scheuss
+ *   Co-authors:
+ *      Dumeni Manatschal
+ *
+ */
+
+//
+// C++ Interface: GameStateClient
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _GamestateClient_H__
+#define _GamestateClient_H__
+
+#include <map>
+//
+#include "NetworkPrereqs.h"
+#include "core/CorePrereqs.h"
+#include "packet/Gamestate.h"
+#include "objects/SpaceShip.h"
+#include "GamestateHandler.h"
+
+#define GAMESTATEID_INITIAL -1
+
+namespace network
+{
+  class GamestateClient: public GamestateHandler
+  {
+  public:
+    GamestateClient();
+    ~GamestateClient();
+
+    bool add(packet::Gamestate *gs, int clientID);
+    bool ack(int gamestateID, int clientID);
+
+    bool processGamestates();
+    packet::Gamestate *getGamestate();
+    void cleanup();
+  private:
+    packet::Gamestate *processGamestate(packet::Gamestate *gs);
+    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
+    void printGamestateMap();
+    bool sendAck(unsigned int gamestateID);
+    bool saveShipCache();
+    bool loadShipCache();
+
+    int           last_diff_;
+    int           last_gamestate_;
+    std::map<int, packet::Gamestate *> gamestateMap_;
+    packet::Gamestate *tempGamestate_; // we save the received gamestates here during processQueue
+    orxonox::SpaceShip *myShip_;
+    unsigned char *shipCache_;
+
+  };
+
+}
+
+#endif /* _GamestateClient_H__ */
Index: /code/branches/ceguilua/src/network/GamestateHandler.cc
===================================================================
--- /code/branches/ceguilua/src/network/GamestateHandler.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/GamestateHandler.cc	(revision 1801)
@@ -0,0 +1,24 @@
+#include <assert.h>
+
+#include "GamestateHandler.h"
+#include "packet/Packet.h"
+
+namespace network {
+
+GamestateHandler *GamestateHandler::instance_=0;
+  
+GamestateHandler::GamestateHandler()
+{
+  assert(instance_==0);
+  instance_=this;
+}
+
+
+GamestateHandler::~GamestateHandler()
+{
+  instance_=0;
+}
+
+
+
+}//namespace network
Index: /code/branches/ceguilua/src/network/GamestateHandler.h
===================================================================
--- /code/branches/ceguilua/src/network/GamestateHandler.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/GamestateHandler.h	(revision 1801)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKGAMESTATEHANDLER_H
+#define NETWORKGAMESTATEHANDLER_H
+
+#include <string>
+
+#include "NetworkPrereqs.h"
+#include "packet/Chat.h"
+
+namespace network {
+
+/**
+	@author Oliver Scheuss
+*/
+class GamestateHandler{
+  private:
+    virtual bool add(packet::Gamestate *gs, int clientID)=0;
+    virtual bool ack(int gamestateID, int clientID)=0;
+
+    static GamestateHandler *instance_;
+
+
+  protected:
+    GamestateHandler();
+    virtual ~GamestateHandler();
+
+  public:
+    static bool addGamestate(packet::Gamestate *gs, int clientID){ return instance_->add(gs, clientID); }
+    static bool ackGamestate(int gamestateID, int clientID){ return instance_->ack(gamestateID, clientID); }
+};
+
+}
+
+#endif
Index: /code/branches/ceguilua/src/network/GamestateManager.cc
===================================================================
--- /code/branches/ceguilua/src/network/GamestateManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/GamestateManager.cc	(revision 1801)
@@ -0,0 +1,202 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: GameStateManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "GamestateManager.h"
+
+#include <utility>
+#include <iostream>
+#include <zlib.h>
+#include <cassert>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+
+namespace network
+{
+  GamestateManager::GamestateManager() {
+    id_=0;
+  }
+
+  GamestateManager::~GamestateManager() {
+  }
+
+  bool GamestateManager::update(){
+    cleanup();
+    return getSnapshot();
+  }
+  
+  bool GamestateManager::add(packet::Gamestate *gs, int clientID){
+    assert(gs);
+    std::map<int, packet::Gamestate*>::iterator it = gamestateQueue.find(clientID);
+    if(it!=gamestateQueue.end()){
+      // delete obsolete gamestate
+      delete it->second;
+    }
+    gamestateQueue[clientID] = gs;
+    return true;
+  }
+  
+  bool GamestateManager::processGamestates(){
+    std::map<int, packet::Gamestate*>::iterator it;
+    // now push only the most recent gamestates we received (ignore obsolete ones)
+    for(it = gamestateQueue.begin(); it!=gamestateQueue.end(); it++){
+      assert(processGamestate(it->second));
+      delete it->second;
+    }
+    // now clear the queue
+    gamestateQueue.clear();
+    return true;
+  }
+  
+  
+  bool GamestateManager::getSnapshot(){
+    reference = new packet::Gamestate();
+    reference->collectData(++id_);
+    COUT(4) << "inserting gamestate: " << reference << std::endl;
+    gamestateMap.insert(std::pair<int, packet::Gamestate*>(id_, reference));
+    gamestateUsed[id_]=0;
+    return true;
+  }
+  
+  /**
+   * this function is used to keep the memory usage low
+   * it tries to delete all the unused gamestates
+   * 
+   * 
+   */
+  void GamestateManager::cleanup(){
+    std::map<int,int>::iterator it = gamestateUsed.begin();
+    while(it!=gamestateUsed.end()){
+      if((id_-(*it).first)<KEEP_GAMESTATES)
+        break;
+      if( (*it).second <= 0 ){
+        COUT(5) << "GameStateManager: deleting gamestate with id: " << (*it).first << ", uses: " << (*it).second << std::endl;
+        std::map<int, packet::Gamestate *>::iterator tempit = gamestateMap.find((*it).first);
+        if( tempit != gamestateMap.end() ){
+          packet::Gamestate *temp = tempit->second;
+          if(temp){
+            delete gamestateMap[(*it).first];
+            gamestateMap.erase((*it).first);
+          }
+        }
+        gamestateUsed.erase(it++);
+        continue;
+      }
+      it++;
+    }
+  }
+
+  packet::Gamestate *GamestateManager::popGameState(int clientID) {
+    //why are we searching the same client's gamestate id as we searched in
+    //Server::sendGameState?
+    packet::Gamestate *gs;
+    int gID = ClientInformation::findClient(clientID)->getGamestateID();
+    //COUT(4) << "G.St.Man: popgamestate: sending gstate_id: " << id_ << " diffed from: " << gID << std::endl;
+    //chose wheather the next gamestate is the first or not
+    if(gID != GAMESTATEID_INITIAL){
+      packet::Gamestate *client=NULL;
+      std::map<int, packet::Gamestate*>::iterator it = gamestateMap.find(gID);
+      if(it!=gamestateMap.end())
+        client = it->second;
+      if(client)
+        gs = reference->diff(client);
+      else
+        gs = new packet::Gamestate(*reference);
+    } else {
+      COUT(4) << "we got a GAMESTATEID_INITIAL for clientID: " << clientID << std::endl;
+      gs = new packet::Gamestate(*reference);
+    }
+    assert(gs->compressData());
+    return gs;
+  }
+  
+  
+  bool GamestateManager::ack(int gamestateID, int clientID) {
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    if(temp==0)
+      return false;
+    int curid = temp->getGamestateID();
+    
+    if(gamestateID == 0){
+      temp->setGamestateID(GAMESTATEID_INITIAL);
+      if(curid!=GAMESTATEID_INITIAL){
+        assert(gamestateUsed.find(curid)!=gamestateUsed.end());
+        --(gamestateUsed.find(curid)->second);
+      }
+      return true;
+    }
+    //if(curid > gamestateID)
+    assert(curid<gamestateID);
+      // the network packets got messed up 
+      //return true;
+    COUT(4) << "acking gamestate " << gamestateID << " for clientid: " << clientID << " curid: " << curid << std::endl;
+    // decrease usage of gamestate and save it
+//     deleteUnusedGameState(curid);
+    //increase gamestateused
+    std::map<int, int>::iterator it = gamestateUsed.find(curid);
+    if(curid!=GAMESTATEID_INITIAL){
+      if(it!=gamestateUsed.end())
+        --(it->second);
+    }
+    it = gamestateUsed.find(gamestateID);
+    if(it!=gamestateUsed.end()){
+      ++(it->second);
+      temp->setGamestateID(gamestateID);
+    }
+    return true;
+  }
+
+  void GamestateManager::removeClient(ClientInformation* client){
+    if(!client)
+      return;
+    if(client->getGamestateID()>=0)
+      gamestateUsed[client->getGamestateID()]--;
+  }
+  
+  bool GamestateManager::processGamestate(packet::Gamestate *gs){
+    if(gs->isCompressed())
+       assert(gs->decompressData());
+    assert(!gs->isDiffed());
+    return gs->spreadData();
+  }
+
+}
Index: /code/branches/ceguilua/src/network/GamestateManager.h
===================================================================
--- /code/branches/ceguilua/src/network/GamestateManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/GamestateManager.h	(revision 1801)
@@ -0,0 +1,95 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: GamestateManager
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+#ifndef _GamestateManager_H__
+#define _GamestateManager_H__
+
+#include "NetworkPrereqs.h"
+#include "GamestateHandler.h"
+#include <map>
+
+#include "packet/Gamestate.h"
+
+namespace network
+{
+
+    const int KEEP_GAMESTATES = 10;
+
+  /**
+  * This Class implements a manager for gamestates:
+  * - creating snapshots of gamestates
+  * - writing gamestates to universe
+  * - diffing gamestates
+  * EN/DECODATION:
+  * a: last Gamestate a client has received
+  * b: new Gamestate
+  * x: diffed and compressed gamestate
+  * x=(a^b)
+  * b=(a^x)
+  * diff(a,diff(a,x))=x (hope this is correct)
+  * @author Oliver Scheuss
+  */
+  class GamestateManager: public GamestateHandler{
+  public:
+    GamestateManager();
+    ~GamestateManager();
+
+    bool add(packet::Gamestate *gs, int clientID);
+    bool processGamestates();
+    bool update();
+    packet::Gamestate *popGameState(int clientID);
+
+    bool getSnapshot();
+
+    bool ack(int gamestateID, int clientID);
+    void removeClient(ClientInformation *client);
+    private:
+    void cleanup(); // "garbage handler"
+    bool processGamestate(packet::Gamestate *gs);
+
+    std::map<int, packet::Gamestate*> gamestateMap; //map gsID to gamestate*
+    std::map<int, int> gamestateUsed; // save the number of clients, that use the specific gamestate
+    std::map<int, packet::Gamestate*> gamestateQueue;
+    packet::Gamestate *reference;
+    int id_;
+  };
+
+}
+
+#endif /* _GameStateManager_H__ */
Index: /code/branches/ceguilua/src/network/Host.cc
===================================================================
--- /code/branches/ceguilua/src/network/Host.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/Host.cc	(revision 1801)
@@ -0,0 +1,84 @@
+/*
+ *   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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <assert.h>
+
+#include "Host.h"
+#include "packet/Packet.h"
+
+namespace network {
+
+Host *Host::instance_=0;
+  
+Host::Host()
+{
+  assert(instance_==0);
+  instance_=this;
+}
+
+
+Host::~Host()
+{
+  instance_=0;
+}
+
+bool Host::addPacket(ENetPacket *packet, int clientID){
+  if(instance_)
+    return instance_->queuePacket(packet, clientID);
+  else
+    return false;
+}
+
+
+// bool Host::chat(std::string& message){
+//   if(!instance_)
+//     return false;
+//   packet::Chat *c = new packet::Chat(message, getPlayerID());
+//   return instance_->sendChat(c);
+// }
+
+// bool Host::receiveChat(network::packet::Chat *message, unsigned int clientID){
+//   if(instance_)
+//     return instance_->processChat(message, clientID);
+//   else
+//     return false;
+// }
+
+int Host::getPlayerID(){ 
+  if(!instance_)
+    return 0;
+  return instance_->playerID();
+}
+
+// unsigned int Host::getShipID(){ 
+//   if(!instance_)
+//     assert(0);
+//   return instance_->shipID();
+// }
+
+}//namespace network
Index: /code/branches/ceguilua/src/network/Host.h
===================================================================
--- /code/branches/ceguilua/src/network/Host.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/Host.h	(revision 1801)
@@ -0,0 +1,75 @@
+/*
+ *   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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKHOST_H
+#define NETWORKHOST_H
+
+#include <string>
+
+#include "NetworkPrereqs.h"
+#include "packet/Chat.h"
+
+namespace network {
+
+/**
+	@author Oliver Scheuss
+*/
+class Host{
+  private:
+    //TODO add theese functions or adequate
+    //virtual bool processChat(packet::Chat *message, unsigned int clientID)=0;
+    //virtual bool sendChat(packet::Chat *chat)=0;
+    virtual bool queuePacket(ENetPacket *packet, int clientID)=0;
+    virtual unsigned int shipID()=0;
+    virtual int playerID()=0;
+
+
+
+  protected:
+    Host();
+    virtual ~Host();
+    static Host *instance_;
+    bool isServer_;	
+
+  public:
+    static bool running(){return instance_!=0;}
+    static bool addPacket(ENetPacket *packet, int clientID=0);
+    //static bool chat(std::string& message);
+//     static bool receiveChat(packet::Chat *message, unsigned int clientID);
+    static int getPlayerID();
+    static unsigned int getShipID(){return instance_->shipID_;}
+    static void setClientID(unsigned int id){ instance_->clientID_ = id; }
+    static void setShipID(unsigned int id){ instance_->shipID_ = id; }
+    static bool isServer(){ return instance_->isServer_; }		
+  private:
+    unsigned int clientID_;
+    unsigned int shipID_;
+};
+
+}
+
+#endif
Index: /code/branches/ceguilua/src/network/Makefile.norm
===================================================================
--- /code/branches/ceguilua/src/network/Makefile.norm	(revision 1801)
+++ /code/branches/ceguilua/src/network/Makefile.norm	(revision 1801)
@@ -0,0 +1,40 @@
+CC=g++
+MAIN_INC=..
+INC=-I ${MAIN_INC}
+
+all: server client
+
+# Link command:
+server: PacketBuffer.o ConnectionManager.o dummyserver.o PacketDecoder.o PacketGenerator.o
+	${CC} PacketDecoder.o PacketGenerator.o ConnectionManager.o dummyserver.o PacketBuffer.o -o server -lenet -lboost_thread -g
+
+dummyserver.o: dummyserver.cc
+	${CC} -c dummyserver.cc -o dummyserver.o -g ${INC}
+# Compilation commands:
+ConnectionManager.o: ConnectionManager.cc ConnectionManager.h
+	${CC} -c ConnectionManager.cc -o ConnectionManager.o -g ${INC}
+ClientConnection.o: ClientConnection.cc ClientConnection.h
+	${CC} -c ClientConnection.cc -o ClientConnection.o -g ${INC}
+
+PacketBuffer.o: PacketBuffer.cc
+	${CC} -c PacketBuffer.cc -o PacketBuffer.o -g ${INC}
+PacketGenerator.o: PacketGenerator.cc
+	${CC} -c PacketGenerator.cc -o PacketGenerator.o -g ${INC}
+PacketDecoder.o: PacketDecoder.cc
+	${CC} -c PacketDecoder.cc -o PacketDecoder.o -g ${INC}
+Client.o: Client.cc
+	${CC} -c Client.cc -g ${INC}
+Server.o: Server.cc
+	${CC} -c Server.cc -g ${INC}
+Synchronisable.o: Synchronisable.cc
+	${CC} -c Synchronisable.cc -g ${INC}
+GameStateManager.o: GameStateManager.cc
+	${CC} -c GameStateManager.cc -g ${INC}
+
+clean:
+	rm -rf *.o
+
+client_old: PacketGenerator.o dummyclient.cc
+	${CC} dummyclient.cc PacketGenerator.o -o client -lenet -g ${INC}
+client: PacketGenerator.o ClientConnection.o PacketBuffer.o dummyclient2.cc 
+	${CC} dummyclient2.cc PacketGenerator.o PacketBuffer.o ClientConnection.o -o client -lenet -lboost_thread -g ${INC}
Index: /code/branches/ceguilua/src/network/Makefile.tardis
===================================================================
--- /code/branches/ceguilua/src/network/Makefile.tardis	(revision 1801)
+++ /code/branches/ceguilua/src/network/Makefile.tardis	(revision 1801)
@@ -0,0 +1,39 @@
+all: server client
+
+CC=g++-4.1.1
+
+BOOST_INC=/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/include/boost-1_34_1/
+BOOST_LIB=/usr/pack/boost-1.34.1-sd/i686-debian-linux3.1/lib/
+MAIN_INC=..
+ENET_INC=/usr/pack/enet-2007-sd/include/
+ENET_LIB=/usr/pack/enet-2007-sd/i686-debian-linux3.1/lib/
+INC=-I ${BOOST_INC} -I ${MAIN_INC} -I ${ENET_INC}
+LIB=-L ${BOOST_LIB} -L ${ENET_LIB}
+
+# Link command:
+server: clean PacketBuffer.o ConnectionManager.o dummyserver.o PacketGenerator.o PacketDecoder.o
+	${CC} ConnectionManager.o dummyserver.o PacketBuffer.o PacketDecoder.o PacketGenerator.o -o server -lenet -lboost_thread-gcc41-mt -g ${INC} ${LIB} -Wl,-rpath,${BOOST_LIB} -Wl,-rpath,${ENET_LIB}
+
+dummyserver.o:
+	${CC} -c dummyserver.cc -o dummyserver.o -g ${INC}
+# Compilation commands:
+
+ConnectionManager.o:
+	${CC} -c ConnectionManager.cc -o ConnectionManager.o -g ${INC}
+
+PacketBuffer.o: 
+	${CC} -c PacketBuffer.cc -o PacketBuffer.o -g ${INC}
+PacketGenerator.o: PacketGenerator.cc
+	${CC} -c PacketGenerator.cc -o PacketGenerator.o -g ${INC}
+PacketDecoder.o: PacketDecoder.cc
+	${CC} -c PacketDecoder.cc -o PacketDecoder.o -g ${INC}
+Synchronisable.o: Synchronisable.cc
+	${CC} -c Synchronisable.cc -g ${INC}
+GameStateManager.o: GameStateManager.cc
+	${CC} -c GameStateManager.cc -g ${INC}
+
+clean:
+	rm -rf *.o
+
+client: dummyclient.cc PacketDecoder.o PacketGenerator.o
+	${CC} PacketGenerator.o PacketDecoder.o dummyclient.cc -o client -lenet ${LIB} ${INC} -Wl,-rpath,${BOOST_LIB}
Index: /code/branches/ceguilua/src/network/Makefile.test
===================================================================
--- /code/branches/ceguilua/src/network/Makefile.test	(revision 1801)
+++ /code/branches/ceguilua/src/network/Makefile.test	(revision 1801)
@@ -0,0 +1,45 @@
+CC=g++
+MAIN_INC=..
+INC=-I ${MAIN_INC} -I..
+
+all: server client
+
+# Link command:
+server: PacketBuffer.o ConnectionManager.o dummyserver.o PacketDecoder.o PacketGenerator.o ClientInformation.o
+	${CC} PacketDecoder.o PacketGenerator.o ClientInformation.o ConnectionManager.o dummyserver.o PacketBuffer.o -o server -lenet -lboost_thread -g
+
+dummyserver.o: dummyserver.cc
+	${CC} -c dummyserver.cc -o dummyserver.o -g ${INC}
+# Compilation commands:
+ConnectionManager.o: ConnectionManager.cc ConnectionManager.h
+	${CC} -c ConnectionManager.cc -o ConnectionManager.o -g ${INC}
+ClientConnection.o: ClientConnection.cc ClientConnection.h
+	${CC} -c ClientConnection.cc -o ClientConnection.o -g ${INC}
+
+PacketBuffer.o: PacketBuffer.cc
+	${CC} -c PacketBuffer.cc -o PacketBuffer.o -g ${INC}
+PacketGenerator.o: PacketGenerator.cc
+	${CC} -c PacketGenerator.cc -o PacketGenerator.o -g ${INC}
+PacketDecoder.o: PacketDecoder.cc
+	${CC} -c PacketDecoder.cc -o PacketDecoder.o -g ${INC}
+Client.o: Client.cc
+	${CC} -c Client.cc -g ${INC}
+Server.o: Server.cc
+	${CC} -c Server.cc -g ${INC}
+Synchronisable.o: Synchronisable.cc
+	${CC} -c Synchronisable.cc -g ${INC}
+GameStateManager.o: GameStateManager.cc
+	${CC} -c GameStateManager.cc -g ${INC}
+ClientInformation.o: ClientInformation.cc
+	${CC} -c ClientInformation.cc -g ${INC}
+
+clean:
+	rm -rf *.o
+
+client_old: PacketGenerator.o dummyclient.cc
+	${CC} dummyclient.cc PacketGenerator.o -o client -lenet -g ${INC}
+client: PacketGenerator.o ClientConnection.o PacketBuffer.o dummyclient2.cc 
+	${CC} dummyclient2.cc PacketGenerator.o PacketBuffer.o ClientConnection.o -o client -lenet -lboost_thread -g ${INC}
+
+chatserver: Server.o ConnectionManager.o PacketGenerator.o PacketDecoder.o PacketBuffer.o ClientInformation.o GameStateManager.o
+	${CC} dummyserver3.cc Server.o ConnectionManager.o PacketGenerator.o PacketBuffer.o GameStateManager.o ClientInformation.o -o chatserver -lenet -lboost_thread -g ${INC}
Index: /code/branches/ceguilua/src/network/NetworkCallback.h
===================================================================
--- /code/branches/ceguilua/src/network/NetworkCallback.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/NetworkCallback.h	(revision 1801)
@@ -0,0 +1,30 @@
+#ifndef _NETWORK_CALLBACK__
+#define _NETWORK_CALLBACK__
+
+namespace network{
+  class NetworkCallbackBase
+  {
+    public:
+      virtual void call() = 0;
+	  virtual ~NetworkCallbackBase() {}
+  };
+  
+  template <class T>
+  class NetworkCallback: public NetworkCallbackBase
+  {
+    public:
+      NetworkCallback(T* object, void (T::*function) (void)) : object_(object), function_(function) {}
+	  virtual ~NetworkCallback() {}
+      virtual void call()
+        { (this->object_->*function_)(); }
+  
+    private:
+      T* object_;
+      void (T::*function_) (void);
+  }; 
+
+
+}
+
+
+#endif
Index: /code/branches/ceguilua/src/network/NetworkPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/network/NetworkPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/NetworkPrereqs.h	(revision 1801)
@@ -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 Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _NetworkPrereqs_H__
+#define _NetworkPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( NETWORK_STATIC_BUILD )
+#  ifdef NETWORK_SHARED_BUILD
+#    define _NetworkExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _NetworkExport
+#    else
+#      define _NetworkExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _NetworkExport  __attribute__ ((visibility("default")))
+#else
+#  define _NetworkExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+namespace network
+{
+  class Client;
+  class ClientConnection;
+  class ClientFrameListener;
+  class ClientInformation;
+  class ConnectionManager;
+  class GamestateClient;
+  class GamestateManager;
+  class GamestateHandler;
+  class PacketBuffer;
+  class Server;
+  class ServerFrameListener;
+  class Synchronisable;
+  struct ClientList;
+  struct PacketEnvelope;
+  struct QueueItem;
+  struct syncData;
+  struct synchronisableVariable;
+  namespace packet{
+    class Gamestate;
+    class Packet;
+    class Acknowledgement;
+    class ClassID;
+    class Welcome;
+    class Chat;
+  }
+}
+
+#endif /* _NetworkPrereqs_H__ */
Index: /code/branches/ceguilua/src/network/PacketBuffer.cc
===================================================================
--- /code/branches/ceguilua/src/network/PacketBuffer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/PacketBuffer.cc	(revision 1801)
@@ -0,0 +1,149 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+// C++ PacketBuffer
+// d
+// Author Oliver Scheuss
+
+#include "PacketBuffer.h"
+
+#include <iostream>
+#include <queue>
+#include <string>
+#include <boost/bind.hpp>
+#include <boost/thread/mutex.hpp>
+
+namespace network
+{
+   boost::recursive_mutex PacketBuffer::mutex_;
+
+  PacketBuffer::PacketBuffer() {
+    closed=false;
+    first=NULL;
+    last=NULL;
+  }
+  //this is needed in order to make the packetbuffer threadsafe
+
+
+  bool PacketBuffer::push(ENetEvent *ev) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    //std::cout << "event size inside packetbuffer " << ev->packet->dataLength << std::endl;
+    //   if(closed)
+    //     return false;
+    // first element?
+    if(first==NULL){
+      first=new QueueItem;
+      last=first;
+      last->next=NULL;
+      // change this!!!!!!!  ---- we are not doing stl so we won't change this
+      last->event = ev;
+      //last->address = ev->peer->address;
+    } else {
+      //insert a new element at the bottom
+      last->next = new QueueItem;
+      last=last->next;
+      // initialize last->next
+      last->next=NULL;
+      // save the packet to the new element
+      last->event = ev;
+      //last->address = ev->peer->address;
+    }
+    lock.unlock();
+    return true;
+  }
+
+  //returns the first element in the list without deleting it but
+  //moving first pointer to next element
+  /*ENetPacket *PacketBuffer::pop() {
+    ENetAddress address;
+    return pop(address);
+  }*/
+  
+  ENetEvent *PacketBuffer::pop(){
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    //std::cout << "packetbuffer pop(address)" << std::endl;
+    if(first!=NULL /*&& !closed*/){
+      QueueItem *temp = first;
+      // get packet
+      ENetEvent *ev=first->event;
+      //address = first->address;
+      // remove first element
+      first = first->next;
+      delete temp;
+      lock.unlock();
+      //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
+      return ev;
+    } else{
+      lock.unlock();
+      return NULL;
+    }
+  }
+
+  /*ENetPacket *PacketBuffer::pop(ENetAddress &address) {
+    boost::recursive_mutex::scoped_lock lock(mutex_);
+    //std::cout << "packetbuffer pop(address)" << std::endl;
+    if(first!=NULL ){
+      QueueItem *temp = first;
+      // get packet
+      ENetPacket *pck=first->event->packet;
+      address = first->event->peer->address;
+      // remove first element
+      first = first->next;
+      delete temp;
+      lock.unlock();
+      //std::cout << "pop(address) size of packet " << pck->dataLength << std::endl;
+      return pck;
+    } else{
+      lock.unlock();
+      return NULL;
+    }
+  }*/
+
+  bool PacketBuffer::isEmpty() {
+    return (first==NULL);
+  }
+
+  void PacketBuffer::print() {
+    QueueItem *temp=first;
+    while(temp!=NULL){
+      //    std::cout << temp->packet->data << std::endl;
+      temp=temp->next;
+    }
+
+  }
+
+  bool PacketBuffer::isClosed() {
+    return closed;
+  }
+
+  void PacketBuffer::setClosed(bool value){
+    closed=value;
+    return;
+  }
+
+} // namespace network
Index: /code/branches/ceguilua/src/network/PacketBuffer.h
===================================================================
--- /code/branches/ceguilua/src/network/PacketBuffer.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/PacketBuffer.h	(revision 1801)
@@ -0,0 +1,84 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: PacketBuffer
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _PacketBuffer_H__
+#define _PacketBuffer_H__
+
+#include "NetworkPrereqs.h"
+
+#include <enet/enet.h>
+#include <boost/thread/recursive_mutex.hpp>
+
+namespace network
+{
+  struct PacketEnvelope{
+    int length;
+    int data;
+  };
+
+  struct QueueItem{
+    ENetEvent *event;
+    //ENetAddress address;
+    QueueItem *next;
+  };
+
+  class PacketBuffer{
+  public:
+    PacketBuffer();
+    bool isEmpty();
+    bool isClosed();
+    void setClosed(bool value);
+    void print();
+    // pops a packet from the queue
+    //ENetPacket *pop();
+    //ENetPacket *pop(ENetAddress &address);
+    ENetEvent *pop();
+    // pushs a packet to the queue
+    bool push(ENetEvent *ev);
+
+  private:
+    QueueItem *first;
+    QueueItem *last;
+    bool closed;
+    static boost::recursive_mutex mutex_;
+  };
+
+} //namespace
+#endif /* _PacketBuffer_H__ */
Index: /code/branches/ceguilua/src/network/Server.cc
===================================================================
--- /code/branches/ceguilua/src/network/Server.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/Server.cc	(revision 1801)
@@ -0,0 +1,400 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: Server
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include "Server.h"
+
+#include <iostream>
+#include <cassert>
+
+
+#include "ConnectionManager.h"
+#include "GamestateManager.h"
+#include "ClientInformation.h"
+#include "util/Sleep.h"
+#include "objects/SpaceShip.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+#include "packet/Chat.h"
+#include "packet/Packet.h"
+#include "packet/Welcome.h"
+#include <util/Convert.h>
+
+namespace network
+{
+  const int MAX_FAILURES = 20;
+  const int NETWORK_FREQUENCY = 30;
+
+  /**
+  * Constructor for default values (bindaddress is set to ENET_HOST_ANY
+  *
+  */
+  Server::Server() {
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager();
+    gamestates_ = new GamestateManager();
+    isServer_ = true;
+  }
+
+  Server::Server(int port){
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager(port);
+    gamestates_ = new GamestateManager();
+    isServer_ = true;
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, std::string bindAddress) {
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager(port, bindAddress);
+    gamestates_ = new GamestateManager();
+    isServer_ = true;
+  }
+
+  /**
+  * Constructor
+  * @param port Port to listen on
+  * @param bindAddress Address to listen on
+  */
+  Server::Server(int port, const char *bindAddress) {
+    timeSinceLastUpdate_=0;
+    connection = new ConnectionManager(port, bindAddress);
+    gamestates_ = new GamestateManager();
+    isServer_ = true;
+  }
+
+  /**
+  * This function opens the server by creating the listener thread
+  */
+  void Server::open() {
+    connection->createListener();
+    return;
+  }
+
+  /**
+  * This function closes the server
+  */
+  void Server::close() {
+    connection->quitListener();
+    return;
+  }
+
+  bool Server::processChat(packet::Chat *message, unsigned int clientID){
+    ClientInformation *temp = ClientInformation::getBegin();
+    while(temp){
+      message->setClientID(temp->getID());
+      if(!message->send())
+        COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
+      temp = temp->next();
+    }
+    return message->process();
+  }
+
+  /**
+  * This function sends out a message to all clients
+  * @param msg message
+  * @return true/false
+  */
+  bool Server::sendChat(packet::Chat *chat) {
+    //TODO: change this (no informations about who wrote a message)
+    assert(0);
+    ClientInformation *temp = ClientInformation::getBegin();
+    while(temp){
+      chat->setClientID(temp->getID());
+      if(!chat->send())
+        COUT(3) << "could not send Chat message to client ID: " << temp->getID() << std::endl;
+    }
+    return chat->process();;
+  }
+
+  /**
+  * This function sends out a message to all clients
+  * @param msg message
+  * @return true/false
+  */
+//   bool Server::sendChat(const char *msg) {
+//     char *message = new char [strlen(msg)+10+1];
+//     sprintf(message, "Player %d: %s", CLIENTID_SERVER, msg);
+//     COUT(1) << message << std::endl;
+//     ENetPacket *packet = packet_gen.chatMessage(message);
+//     COUT(5) <<"Server: adding Packets" << std::endl;
+//     return connection->addPacketAll(packet);
+//   }
+
+  /**
+  * Run this function once every tick
+  * calls processQueue and updateGamestate
+  * @param time time since last tick
+  */
+  void Server::tick(float time) {
+    processQueue();
+    //this steers our network frequency
+    timeSinceLastUpdate_+=time;
+    if(timeSinceLastUpdate_>=(1./NETWORK_FREQUENCY)){
+      timeSinceLastUpdate_=(float)((int)(timeSinceLastUpdate_*NETWORK_FREQUENCY))/timeSinceLastUpdate_;
+//      timeSinceLastUpdate_-=1./NETWORK_FREQUENCY;
+      gamestates_->processGamestates();
+      updateGamestate();
+    }
+    /*while(timeSinceLastUpdate_>1./NETWORK_FREQUENCY)
+      timeSinceLastUpdate_-=1./NETWORK_FREQUENCY;*/
+//     usleep(5000); // TODO remove
+    return;
+  }
+
+  bool Server::queuePacket(ENetPacket *packet, int clientID){
+    return connection->addPacket(packet, clientID);
+  }
+
+  /**
+  * processes all the packets waiting in the queue
+  */
+  void Server::processQueue() {
+    ENetEvent *event;
+    while(!connection->queueEmpty()){
+      //std::cout << "Client " << clientID << " sent: " << std::endl;
+      //clientID here is a reference to grab clientID from ClientInformation
+      event = connection->getEvent();
+      if(!event)
+        continue;
+      assert(event->type != ENET_EVENT_TYPE_NONE);
+      switch( event->type ) {
+      case ENET_EVENT_TYPE_CONNECT:
+        COUT(3) << "processing event_Type_connect" << std::endl;
+        addClient(event);
+        break;
+      case ENET_EVENT_TYPE_DISCONNECT:
+        if(ClientInformation::findClient(&event->peer->address))
+          disconnectClient(event);
+        break;
+      case ENET_EVENT_TYPE_RECEIVE:
+        if(!processPacket(event->packet, event->peer))
+          COUT(3) << "processing incoming packet failed" << std::endl;
+        break;
+      default:
+        break;
+      }
+      delete event;
+      //if statement to catch case that packetbuffer is empty
+    }
+  }
+
+  /**
+  * takes a new snapshot of the gamestate and sends it to the clients
+  */
+  void Server::updateGamestate() {
+    gamestates_->update();
+    COUT(5) << "Server: one gamestate update complete, goig to sendGameState" << std::endl;
+    //std::cout << "updated gamestate, sending it" << std::endl;
+    //if(clients->getGamestateID()!=GAMESTATEID_INITIAL)
+    sendGameState();
+    COUT(5) << "Server: one sendGameState turn complete, repeat in next tick" << std::endl;
+    //std::cout << "sent gamestate" << std::endl;
+  }
+
+  bool Server::processPacket( ENetPacket *packet, ENetPeer *peer ){
+    packet::Packet *p = packet::Packet::createPacket(packet, peer);
+    return p->process();
+  }
+
+  /**
+  * sends the gamestate
+  */
+  bool Server::sendGameState() {
+    COUT(5) << "Server: starting function sendGameState" << std::endl;
+    ClientInformation *temp = ClientInformation::getBegin();
+    bool added=false;
+    while(temp != NULL){
+      if( !(temp->getSynched()) ){
+        COUT(5) << "Server: not sending gamestate" << std::endl;
+        temp=temp->next();
+        if(!temp)
+          break;
+        //think this works without continue
+        continue;
+      }
+      COUT(4) << "client id: " << temp->getID() << " RTT: " << temp->getRTT() << " loss: " << temp->getPacketLoss() << std::endl;
+      COUT(5) << "Server: doing gamestate gamestate preparation" << std::endl;
+      int gid = temp->getGamestateID(); //get gamestate id
+      int cid = temp->getID(); //get client id
+      COUT(5) << "Server: got acked (gamestate) ID from clientlist: " << gid << std::endl;
+      packet::Gamestate *gs = gamestates_->popGameState(cid);
+      if(gs==NULL){
+        COUT(2) << "Server: could not generate gamestate (NULL from compress)" << std::endl;
+        continue;
+      }
+      //std::cout << "adding gamestate" << std::endl;
+      gs->setClientID(cid);
+      if ( !gs->send() ){
+        COUT(3) << "Server: packet with client id (cid): " << cid << " not sended: " << temp->getFailures() << std::endl;
+        temp->addFailure();
+      }else
+        temp->resetFailures();
+      added=true;
+      temp=temp->next();
+      // gs gets automatically deleted by enet callback
+    }
+    /*if(added) {
+      //std::cout << "send gamestates from server.cc in sendGameState" << std::endl;
+      return connection->sendPackets();
+    }*/
+    //COUT(5) << "Server: had no gamestates to send" << std::endl;
+    return true;
+  }
+
+//   void Server::processChat( chat *data, int clientId){
+//     char *message = new char [strlen(data->message)+10+1];
+//     sprintf(message, "Player %d: %s", clientId, data->message);
+//     COUT(1) << message << std::endl;
+//     ENetPacket *pck = packet_gen.chatMessage(message);
+//     connection->addPacketAll(pck);
+//     delete[] data->message;
+//     delete data;
+//   }
+
+  bool Server::addClient(ENetEvent *event){
+    ClientInformation *temp = ClientInformation::insertBack(new ClientInformation);
+    if(!temp){
+      COUT(2) << "Server: could not add client" << std::endl;
+      return false;
+    }
+    if(temp==ClientInformation::getBegin()) { //not good if you use anything else than insertBack
+      temp->setID(1);
+    }
+    else
+      temp->setID(temp->prev()->getID()+1);
+    temp->setPeer(event->peer);
+    COUT(3) << "Server: added client id: " << temp->getID() << std::endl;
+    return createClient(temp->getID());
+  }
+
+  bool Server::createClient(int clientID){
+    ClientInformation *temp = ClientInformation::findClient(clientID);
+    if(!temp){
+      COUT(2) << "Conn.Man. could not create client with id: " << clientID << std::endl;
+      return false;
+    }
+    COUT(4) << "Con.Man: creating client id: " << temp->getID() << std::endl;
+    connection->syncClassid(temp->getID());
+    COUT(5) << "creating spaceship for clientid: " << temp->getID() << std::endl;
+    // TODO: this is only a hack, untill we have a possibility to define default player-join actions
+    if(!createShip(temp))
+      COUT(2) << "Con.Man. could not create ship for clientid: " << clientID << std::endl;
+    else
+      COUT(3) << "created spaceship" << std::endl;
+    temp->setSynched(true);
+    COUT(3) << "sending welcome" << std::endl;
+    packet::Welcome *w = new packet::Welcome(temp->getID(), temp->getShipID());
+    w->setClientID(temp->getID());
+    assert(w->send());
+    packet::Gamestate *g = new packet::Gamestate();
+    g->setClientID(temp->getID());
+    assert(g->collectData(0));
+    assert(g->compressData());
+    assert(g->send());
+    return true;
+  }
+
+  bool Server::createShip(ClientInformation *client){
+    if(!client)
+      return false;
+    orxonox::Identifier* id = GetIdentifier("SpaceShip");
+    if(!id){
+      COUT(4) << "We could not create the SpaceShip for client: " << client->getID() << std::endl;
+      return false;
+    }
+    orxonox::SpaceShip *no = dynamic_cast<orxonox::SpaceShip *>(id->fabricate());
+    no->classID = id->getNetworkID();
+    client->setShipID(no->objectID);
+    no->setPosition(orxonox::Vector3(0,0,80));
+    no->setScale(10);
+    //no->setYawPitchRoll(orxonox::Degree(-90),orxonox::Degree(-90),orxonox::Degree(0));
+    no->setMesh("assff.mesh");
+    no->setMaxSpeed(500);
+    no->setMaxSideAndBackSpeed(50);
+    no->setMaxRotation(1.0);
+    no->setTransAcc(200);
+    no->setRotAcc(3.0);
+    no->setTransDamp(75);
+    no->setRotDamp(1.0);
+    no->setCamera(std::string("cam_") + convertToString(client->getID()));
+    no->create();
+
+    return true;
+  }
+
+  bool Server::disconnectClient(ENetEvent *event){
+    COUT(4) << "removing client from list" << std::endl;
+    //return removeClient(head_->findClient(&(peer->address))->getID());
+
+    //boost::recursive_mutex::scoped_lock lock(head_->mutex_);
+    orxonox::ObjectList<orxonox::SpaceShip>::iterator it = orxonox::ObjectList<orxonox::SpaceShip>::begin();
+    ClientInformation *client = ClientInformation::findClient(&event->peer->address);
+    if(!client)
+      return false;
+    gamestates_->removeClient(client);
+    while(it){
+      if(it->objectID!=client->getShipID()){
+        ++it;
+        continue;
+      }
+      orxonox::ObjectList<orxonox::SpaceShip>::iterator temp=it;
+      ++it;
+      delete  *temp;
+      return ClientInformation::removeClient(event->peer);
+    }
+    return false;
+  }
+
+  void Server::disconnectClient(int clientID){
+    ClientInformation *client = ClientInformation::findClient(clientID);
+    if(client)
+      disconnectClient(client);
+  }
+  void Server::disconnectClient( ClientInformation *client){
+    connection->disconnectClient(client);
+    gamestates_->removeClient(client);
+  }
+
+}
Index: /code/branches/ceguilua/src/network/Server.h
===================================================================
--- /code/branches/ceguilua/src/network/Server.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/Server.h	(revision 1801)
@@ -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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Interface: Server
+//
+// Description:
+//
+//
+// Author:  Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef _Server_H__
+#define _Server_H__
+
+#include "NetworkPrereqs.h"
+
+#include <string>
+
+#include "Host.h"
+#include "GamestateManager.h"
+
+namespace network
+{
+  const int CLIENTID_SERVER = 0;
+  
+  /**
+  * This class is the root class of the network module for a server.
+  * It implements all functions necessary for a Server
+  */
+  class _NetworkExport Server : public Host{
+  public:
+    Server();
+    Server(int port);
+    Server(int port, std::string bindAddress);
+    Server(int port, const char *bindAddress);
+    
+    void open();
+    void close();
+    bool processChat(packet::Chat *message, unsigned int clientID);
+    bool sendChat(packet::Chat *chat);
+    bool queuePacket(ENetPacket *packet, int clientID);
+    void tick(float time);
+  protected:
+    void processQueue();
+    void updateGamestate();
+  private:
+    unsigned int shipID(){return 0;}
+    int playerID(){return 0;}
+    
+    bool addClient(ENetEvent *event);
+    bool createClient(int clientID);
+    bool createShip(ClientInformation *client);
+    bool disconnectClient(ENetEvent *event);
+    void disconnectClient(int clientID);
+    void disconnectClient( ClientInformation *client);
+    bool processPacket( ENetPacket *packet, ENetPeer *peer );
+    bool sendGameState();
+    
+    
+    //void processChat( chat *data, int clientId);
+    ConnectionManager *connection;
+    GamestateManager *gamestates_;
+
+    
+    float timeSinceLastUpdate_;
+  };
+
+
+
+
+}
+
+#endif /* _Server_H__ */
Index: /code/branches/ceguilua/src/network/Synchronisable.cc
===================================================================
--- /code/branches/ceguilua/src/network/Synchronisable.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/Synchronisable.cc	(revision 1801)
@@ -0,0 +1,350 @@
+/*
+ *   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:
+ *      Dumeni Manatschal, (C) 2007
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+//
+// C++ Implementation: synchronisable
+//
+// Description:
+//
+//
+// Author:  Dumeni, Oliver Scheuss, (C) 2007
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+
+#include "Synchronisable.h"
+
+#include <string>
+#include <iostream>
+#include <assert.h>
+
+#include "core/CoreIncludes.h"
+#include "core/BaseObject.h"
+// #include "core/Identifier.h"
+
+namespace network
+{
+
+
+  int Synchronisable::state_=0x1; // detemines wheter we are server (default) or client
+
+  /**
+  * Constructor:
+  * calls registarAllVariables, that has to be implemented by the inheriting classID
+  */
+  Synchronisable::Synchronisable(){
+    RegisterRootObject(Synchronisable);
+    static int idCounter=0;
+    datasize=0;
+    objectFrequency_=1;
+    objectMode_=0x1; // by default do not send data to servere
+    objectID=idCounter++;
+    syncList = new std::list<synchronisableVariable *>;
+    //registerAllVariables();
+  }
+
+  Synchronisable::~Synchronisable(){
+    // delete callback function objects
+    if(!orxonox::Identifier::isCreatingHierarchy())
+      for(std::list<synchronisableVariable *>::iterator it = syncList->begin(); it!=syncList->end(); it++)
+        delete (*it)->callback;
+  }
+
+  bool Synchronisable::create(){
+    this->classID = this->getIdentifier()->getNetworkID();
+    COUT(4) << "creating synchronisable: setting classid from " << this->getIdentifier()->getName() << " to: " << classID << std::endl;
+    return true;
+  }
+
+  
+  void Synchronisable::setClient(bool b){
+    if(b) // client
+      state_=0x2;
+    else  // server
+      state_=0x1;
+  }
+  
+  bool Synchronisable::fabricate(unsigned char*& mem, int mode)
+  {
+    unsigned int size, objectID, classID;
+    size = *(unsigned int *)mem;
+    objectID = *(unsigned int*)(mem+sizeof(unsigned int));
+    classID = *(unsigned int*)(mem+2*sizeof(unsigned int));
+    
+    if(size==3*sizeof(unsigned int)){ //not our turn, dont do anything
+      mem+=3*sizeof(unsigned int);
+      return true;
+    }
+    
+    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;
+      assert(0);
+      return false; // most probably the gamestate is corrupted
+    }
+    orxonox::BaseObject *bo = id->fabricate();
+    Synchronisable *no = dynamic_cast<Synchronisable *>(bo);
+    assert(no);
+    no->objectID=objectID;
+    no->classID=classID;
+    COUT(3) << "fabricate objectID: " << no->objectID << " classID: " << no->classID << std::endl;
+          // update data and create object/entity...
+    if( !no->updateData(mem, mode) ){
+      COUT(1) << "We couldn't update the object: " << objectID << std::endl;
+      return false;
+    }
+    if( !no->create() )
+    {
+      COUT(1) << "We couldn't manifest (create() ) the object: " << objectID << std::endl;
+      return false;
+    }
+    return true;
+  }
+
+  /**
+  * This function is used to register a variable to be synchronized
+  * also counts the total datasize needed to save the variables
+  * @param var pointer to the variable
+  * @param size size of the datatype the variable consists of
+  */
+  void Synchronisable::registerVar(void *var, int size, variableType t, int mode, NetworkCallbackBase *cb){
+    // create temporary synch.Var struct
+    synchronisableVariable *temp = new synchronisableVariable;
+    temp->size = size;
+    temp->var = var;
+    temp->mode = mode;
+    temp->type = t;
+    temp->callback = cb;
+    COUT(5) << "Syncronisable::registering var with size: " << temp->size << " and type: " << temp->type << std::endl;
+    // increase datasize
+    datasize+=sizeof(int)+size;
+    //std::cout << "push temp to syncList (at the bottom) " << datasize << std::endl;
+    COUT(5) << "Syncronisable::objectID: " << objectID << " this: " << this << " name: " << this->getIdentifier()->getName() << " networkID: " << this->getIdentifier()->getNetworkID() << std::endl;
+    syncList->push_back(temp);
+  }
+  
+  /**
+   * This function takes all SynchronisableVariables out of the Synchronisable and saves it into a syncData struct
+   * Difference to the above function:
+   * takes a pointer to already allocated memory (must have at least getSize bytes length)
+   * structure of the bitstream:
+   * (var1_size,var1,var2_size,var2,...)
+   * varx_size: size = sizeof(int)
+   * varx: size = varx_size
+   * @return data containing all variables and their sizes
+   */
+  bool Synchronisable::getData(unsigned char*& mem, unsigned int id, int mode){
+    //std::cout << "inside getData" << std::endl;
+    unsigned int tempsize = 0;
+    if(mode==0x0)
+      mode=state_;
+    if(classID==0)
+      COUT(3) << "classid 0 " << this->getIdentifier()->getName() << std::endl;
+    this->classID=this->getIdentifier()->getNetworkID(); // TODO: correct this
+    std::list<synchronisableVariable *>::iterator i;
+    unsigned int size;
+    size=getSize2(id, mode);
+    
+    // start copy header
+    memcpy(mem, &size, sizeof(unsigned int));
+    mem+=sizeof(unsigned int);
+    memcpy(mem, &(this->objectID), sizeof(unsigned int));
+    mem+=sizeof(unsigned int);
+    memcpy(mem, &(this->classID), sizeof(unsigned int));
+    mem+=sizeof(unsigned int);
+    tempsize+=12;
+    // end copy header
+    
+    //if this tick is we dont synchronise, then abort now
+    if(!isMyTick(id))
+      return true;
+    
+    COUT(5) << "Synchronisable getting data from objectID: " << objectID << " classID: " << classID << " length: " << size << std::endl;
+    // copy to location
+    for(i=syncList->begin(); i!=syncList->end(); ++i){
+      //(std::memcpy(retVal.data+n, (const void*)(&(i->size)), sizeof(int));
+      if( ((*i)->mode & mode) == 0 ){
+        COUT(5) << "not getting data: " << std::endl;
+        continue;  // this variable should only be received
+      }
+      switch((*i)->type){
+        case DATA:
+          memcpy( (void *)(mem), (void*)((*i)->var), (*i)->size);
+          mem+=(*i)->size;
+          tempsize+=(*i)->size;
+          break;
+        case STRING:
+          memcpy( (void *)(mem), (void *)&((*i)->size), sizeof(int) );
+          mem+=sizeof(int);
+          const char *data = ( ( *(std::string *) (*i)->var).c_str());
+          memcpy( mem, (void*)data, (*i)->size);
+          COUT(5) << "synchronisable: char: " << (const char *)(mem) << " data: " << data << " string: " << *(std::string *)((*i)->var) << std::endl;
+          mem+=(*i)->size;
+          tempsize+=(*i)->size + 4;
+          break;
+      }
+    }
+    assert(tempsize==size);
+    return true;
+  }
+
+  
+  /**
+   * This function takes a syncData struct and takes it to update the variables
+   * @param vars data of the variables
+   * @return true/false
+   */
+  bool Synchronisable::updateData(unsigned char*& mem, int mode){
+    unsigned char *data = mem;
+    if(mode==0x0)
+      mode=state_;
+    std::list<synchronisableVariable *>::iterator i;
+    if(syncList->empty()){
+      COUT(4) << "Synchronisable::updateData syncList is empty" << std::endl;
+      return false;
+    }
+    
+    // start extract header
+    unsigned int objectID, classID, size;
+    size = *(int *)mem;
+    mem+=sizeof(size);
+    objectID = *(int *)mem;
+    mem+=sizeof(objectID);
+    classID = *(int *)mem;
+    mem+=sizeof(classID);
+    // stop extract header
+    assert(this->objectID==objectID);
+    assert(this->classID==classID);
+    if(size==3*sizeof(unsigned int)) //if true, only the header is available
+      return true;
+      //assert(0);
+    
+    COUT(5) << "Synchronisable: objectID " << objectID << ", classID " << classID << " size: " << size << " synchronising data" << std::endl;
+    for(i=syncList->begin(); i!=syncList->end() && mem <= data+size; i++){
+      if( ((*i)->mode ^ mode) == 0 ){
+        COUT(5) << "synchronisable: not updating variable " << std::endl;
+        continue;  // this variable should only be set
+      }
+      COUT(5) << "Synchronisable: element size: " << (*i)->size << " type: " << (*i)->type << std::endl;
+      bool callback=false;
+      switch((*i)->type){
+        case DATA:
+          if((*i)->callback) // check whether this variable changed (but only if callback was set)
+            if(strncmp((char *)(*i)->var, (char *)mem, (*i)->size)!=0)
+              callback=true;
+          memcpy((void*)(*i)->var, mem, (*i)->size);
+          mem+=(*i)->size;
+          break;
+        case STRING:
+          (*i)->size = *(int *)mem;
+          COUT(5) << "string size: " << (*i)->size << std::endl;
+          mem+=sizeof(int);
+          if((*i)->callback) // check whether this string changed
+            if( *(std::string *)((*i)->var) != std::string((char *)mem) )
+              callback=true;
+          *((std::string *)((*i)->var)) = std::string((const char*)mem);
+          COUT(5) << "synchronisable: char: " << (const char*)mem << " string: " << std::string((const char*)mem) << std::endl;
+          mem += (*i)->size;
+          break;
+      }
+      // call the callback function, if defined
+      if(callback && (*i)->callback)
+        (*i)->callback->call();
+    }
+    return true;
+  }
+
+  /**
+  * This function returns the total amount of bytes needed by getData to save the whole content of the variables
+  * @return amount of bytes
+  */
+  int Synchronisable::getSize(unsigned int id, int mode){
+    if(!isMyTick(id))
+      return 0;
+    int tsize=0;
+    if(mode==0x0)
+      mode=state_;
+    std::list<synchronisableVariable *>::iterator i;
+    for(i=syncList->begin(); i!=syncList->end(); i++){
+      if( ((*i)->mode & mode) == 0 )
+        continue;  // this variable should only be received, so dont add its size to the send-size
+      switch((*i)->type){
+      case DATA:
+        tsize+=(*i)->size;
+        break;
+      case STRING:
+        tsize+=sizeof(int);
+        (*i)->size=((std::string *)(*i)->var)->length()+1;
+        COUT(5) << "String size: " << (*i)->size << std::endl;
+        tsize+=(*i)->size;
+        break;
+      }
+    }
+    return tsize;
+  }
+
+  /**
+   * This function returns the total amount of bytes needed by getData to save the whole content of the variables
+   * @return amount of bytes
+   */
+  int Synchronisable::getSize2(unsigned int id, int mode){
+    return sizeof(synchronisableHeader) + getSize( id, mode );
+  }
+  
+  /**
+   * 
+   * @param id 
+   * @return 
+   */
+  bool Synchronisable::isMyTick(unsigned int id){
+//     return true;
+    return ( id==0 || id%objectFrequency_==objectID%objectFrequency_ ) && ((objectMode_&state_)!=0);
+  }
+  
+  bool Synchronisable::isMyData(unsigned char* mem)
+  {
+    unsigned int objectID, classID, size;
+    size = *(int *)mem;
+    mem+=sizeof(size);
+    objectID = *(int *)mem;
+    mem+=sizeof(objectID);
+    classID = *(int *)mem;
+    mem+=sizeof(classID);
+    
+    assert(classID == this->classID);
+    return (objectID == this->objectID);
+  }
+  
+  void Synchronisable::setObjectMode(int mode){
+    assert(mode==0x1 || mode==0x2 || mode==0x3);
+    objectMode_=mode;
+  }
+
+
+}
Index: /code/branches/ceguilua/src/network/Synchronisable.h
===================================================================
--- /code/branches/ceguilua/src/network/Synchronisable.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/Synchronisable.h	(revision 1801)
@@ -0,0 +1,101 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2007
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Synchronisable_H__
+#define _Synchronisable_H__
+
+#include "NetworkPrereqs.h"
+
+#include <list>
+#include "core/OrxonoxClass.h"
+#include "util/XMLIncludes.h"
+#include "NetworkCallback.h"
+
+namespace network
+{
+  enum variableType{
+    DATA,
+    STRING,
+  };
+
+  struct synchronisableHeader{
+    unsigned int size;
+    unsigned int objectID;
+    unsigned int classID;
+  };
+
+  typedef struct synchronisableVariable{
+    unsigned int size;
+    int mode; // this determines in which direction the variable gets synchronised
+    void *var;
+    variableType type;
+    NetworkCallbackBase *callback;
+  }SYNCVAR;
+
+
+  /**
+  * This class is the base class of all the Objects in the universe that need to be synchronised over the network
+   * Every class, t
+  int mode;hat inherits from this class has to link the DATA THAT NEEDS TO BE SYNCHRONISED into the linked list. Additionally it also has to provide a Constructor, that takes exactly the variables in this linked list.
+  * @author Oliver Scheuss
+  */
+  class _NetworkExport Synchronisable : virtual public orxonox::OrxonoxClass{
+  public:
+    
+    virtual ~Synchronisable();
+    unsigned int objectID;
+    unsigned int classID;
+
+    void registerVar(void *var, int size, variableType t, int mode=1, NetworkCallbackBase *cb=0);
+    bool getData(unsigned char*& men, unsigned int id, int mode=0x0);
+    int getSize2(unsigned int id, int mode=0x0);
+    bool updateData(unsigned char*& mem, int mode=0x0);
+    bool isMyData(unsigned char* mem);
+    void setObjectMode(int mode);
+    void setObjectFrequency(unsigned int freq){ objectFrequency_ = freq; }
+    
+    virtual void registerAllVariables()=0;
+    virtual bool create();
+    static void setClient(bool b);
+    
+    static bool fabricate(unsigned char*& mem, int mode=0x0);
+  protected:
+    Synchronisable();
+  private:
+    int getSize(unsigned int id, int mode=0x0);
+    bool isMyTick(unsigned int id);
+    std::list<synchronisableVariable *> *syncList;
+    int datasize;
+    static int state_; // detemines wheter we are server (default) or client
+    bool backsync_; // if true the variables with mode > 1 will be synchronised to server (client -> server)
+    unsigned int objectFrequency_;
+    int objectMode_;
+  };
+}
+
+#endif /* _Synchronisable_H__ */
Index: /code/branches/ceguilua/src/network/TODO
===================================================================
--- /code/branches/ceguilua/src/network/TODO	(revision 1801)
+++ /code/branches/ceguilua/src/network/TODO	(revision 1801)
@@ -0,0 +1,15 @@
+TODO:
+
+- change ConnectionManager clientlist [done]
+- change gamestatemanager clientlist [done]
+- put them together into ClientInformation [done]
+
+- do better gamestate-update/snapshot-handling [partially done]
+- integrate ClientInformation into gamestatemanager [done]
+
+- write dummyserver and dummyclient (chat system) [done]
+
+- include GameStateClient into Client and write processGamestate (also packetdecoder (virtual))
+- create object with worldentity .....
+
+- try and error ;)
Index: /code/branches/ceguilua/src/network/diffTest.cc
===================================================================
--- /code/branches/ceguilua/src/network/diffTest.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/diffTest.cc	(revision 1801)
@@ -0,0 +1,726 @@
+#include "enet/enet.h"
+#include "Orxonox.h"
+#include "NetworkPrereqs.h"
+#include "PacketTypes.h"
+#include "GameStateManager.h"
+#include "Synchronisable.h"
+#include "GameStateClient.h"
+#include "iostream"
+#include "core/CoreIncludes.h"
+#include "time.h"
+#include "ConnectionManager.h"
+#include "ClientInformation.h"
+#include "Synchronisable.h"
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+#include "util/Sleep.h"
+
+using namespace network;
+
+void printData( unsigned char* data, int length ) {
+  for ( int i=0; i<length; i++ )
+    std::cout << (int)data[i] << " ";
+  std::cout << std::endl;
+}
+
+void printGameStateCompressed( GameStateCompressed* gc ) {
+  //std::cout << "=================================================" << std::endl;
+  std::cout << "GameStateCompressed id:\t\t" << gc->id << std::endl;
+  std::cout << "GameStateCompressed normsize:\t" << gc->normsize << std::endl;
+  std::cout << "GameStateCompressed compsize:\t" << gc->compsize << std::endl;
+  std::cout << "GameStateCompressed diffed:\t" << gc->diffed << std::endl;
+  //std::cout << "GameState data:\t" << gc->data << std::endl;
+  std::cout << "GameStateCompressed compressing rate:\t" << 100.0-((100.0/(gc->normsize))*(gc->compsize)) << "%" << std::endl;
+  std::cout << "=================================================" << std::endl;
+  return;
+}
+
+bool compareData( GameState* g1, GameState* g2 ) {
+  if ( g1->id != g2->id ) {
+    std::cout << "\t--> GameStates are not comparable -> not same id" << std::endl;
+    return true;
+  }
+  else if ( g1->size != g2->size ) {
+    std::cout << "\t--> GameStates are not the same size!!" << std::endl;
+    std::cout << g1->size << " != " << g2->size << std::endl;
+  }
+  int length = g1->size;
+  for ( int i=0; i<length; i++ ) {
+    if ( g1->data[i] != g2->data[i] ) {
+      std::cout << "\t--> data of both GameStates are not identical" << std::endl;
+      return false;
+    }
+  }
+  //std::cout << "\t--> GameData are identical (compareData)" << std::endl;
+  return true;
+}
+
+bool compareData2( GameState* g1, GameState* g2 ) {
+  int length = g1->size;
+  for ( int i=0; i<length; i++ ) {
+    if ( g1->data[i] != g2->data[i] ) {
+      return false;
+    }
+  }
+  //std::cout << "\t--> GameData are identical (compareData)" << std::endl;
+  return true;
+}
+
+bool compareGameStates( GameState* g1, GameState* g2 ) {
+  if ( g1->id != g2->id ) {
+    std::cout << "\t==> GameState id's not identical (GameStateCompare)" << std::endl;
+  }
+  if( g1->size != g2->size ) {
+    std::cout << "\t==> GameState sizes are not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  else if ( g1->diffed != g2->diffed ) {
+    std::cout << "\t==> GameState diffed params not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  else if ( !compareData2( g1, g2 ) ) {
+    std::cout << "\t==> GameState data are not identical (GameStateCompare)" << std::endl;
+    return false;
+  }
+  //std::cout << "\t==> GameStates are identical (GameStateCompare)" << std::endl;
+  return true;
+}
+
+void printGameState( GameState* gstate ) {
+  //std::cout << "=================================================" << std::endl;
+  std::cout << "GameState id:\t\t" << gstate->id << std::endl;
+  std::cout << "GameState size:\t\t" << gstate->size << std::endl;
+  std::cout << "GameState diffed:\t" << gstate->diffed << std::endl;
+  //std::cout << "GameState data:\t" << gstate->data << std::endl;
+  std::cout << "=================================================" << std::endl;
+  return;
+}
+
+unsigned char* createData( int length, int mode ) {
+  char* data = new char[ length ];
+  if ( mode == 1 ) {
+    for ( int i=0; i<length; i++ )
+      data[i] = (char)(i%255);
+  }
+  else if ( mode == 2 ) {
+    for ( int i=0; i<length; i++ ) {
+      if ( i%98 == 0 ) data[i] = (char)(i%255);
+      else data[i] = (char)0;
+    }
+  }
+  else if ( mode == 3 ) {
+    for ( int i=0; i<length; i++ ){
+      data[i] = (char)(rand()%255);
+    }
+  }
+  else if ( mode == 4 ) {
+    for ( int i=0; i<length; i++ ){
+      data[i] = (char)(rand()%127);
+    }
+  }
+
+  //printData( data, length );  
+
+  unsigned char* dat = (unsigned char*)data;
+  return dat;
+}
+
+GameState* changeGameStateABit( GameState* a, int mode ) {
+  int length = a->size;
+  GameState* b = new GameState;
+  b->id = a->id;
+  b->diffed = a->diffed;
+
+  if ( mode == 1 ) {
+    b->data = new unsigned char[length];
+    b->size = a->size;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+  else if ( mode == 2 ) {
+    b->data = new unsigned char[length];
+    b->size = length;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%(rand()%((length)/11)+rand()) == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+  else if ( mode == 3 ) {
+    int s = length + (rand()%(length));
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+    for( int i=length; i<s; i++ ) {
+      b->data[i] = (char)rand()%255;
+    }
+  }
+  else if ( mode == 4 ) {
+    int s = length + (rand()%(length));
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<length; i++ ) {
+      if ( i%(rand()%(length)+rand()) == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+    for( int i=length; i<s; i++ ) {
+      b->data[i] = rand()%255;
+    }
+  }
+    else if ( mode == 5 ) {
+    int s = (length)/2;
+    b->data = new unsigned char[s];
+    b->size = s;
+    for ( int i=0; i<s; i++ ) {
+      if ( i%10 == 0 ) b->data[i] = (char)rand()%255;
+      else b->data[i] = a->data[i];
+    }
+  }
+
+  return b;
+}
+
+void testCompression( int size, int mode ) {
+  std::cout << "testing compression with: size = " << size << " ,mode = " << mode << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameState* g_new = new GameState;
+  GameState* g_old = new GameState;
+  GameStateCompressed* gc = new GameStateCompressed;
+  
+  g_old->data = createData( size, mode );
+  g_old->size = size;
+  g_old->id = 0;
+  g_old->diffed = false;
+  printGameState( g_old );
+  
+  gc = g_manager->testCompress( g_old );
+  printGameStateCompressed( gc );
+
+  g_new = g_client->testDecompress( gc );
+  printGameState( g_new );
+
+  compareGameStates( g_new, g_old );
+
+  return;
+}
+
+void testDifferentiation( int size, int modeCreateData, int modeChangeData ) {
+  std::cout << "testing diff with: size = " << size << " modeCreateData = " 
+            << modeCreateData << " modeChangeData = " << modeChangeData << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;
+  
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_result;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  printGameState( g_undiff1 );
+
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  printGameState( g_undiff2 );
+
+  if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " BUT THAT'S HOW IT HAS TO BE" << std::endl;
+
+  //printData( g_undiff1->data, g_undiff1->size );
+  //printData( g_undiff2->data, g_undiff2->size );
+  
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  printGameState( g_diffed );
+  //printData( g_diffed->data, g_diffed->size );
+  
+  g_result = g_client->testUndiff( g_undiff1, g_diffed );
+  compareGameStates( g_result, g_undiff2 );
+
+  return;
+}
+
+void testCompressWithDiff( int size, int modeCreateData, int modeChangeData ) {
+  std::cout << "testing CompressWithDiff with: size = " << size << " modeCreateData = " 
+            << modeCreateData << " modeChangeData = " << modeChangeData << std::endl; 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameStateCompressed* gc = new GameStateCompressed;
+  GameStateCompressed* g_compressedNoDiff;
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_resultDiffed;
+  GameState* g_resultUndiffed;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  
+  std::cout << "---First generated Gamestate" << std::endl;
+  printGameState( g_undiff1 );
+
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  std::cout << "---First gererated Gamestate with some changes ev. longer" << std::endl;
+  printGameState( g_undiff2 );  
+
+  if( !compareData( g_undiff1, g_undiff2 ) ) std::cout << " DATA not identical.. ok" << std::endl;
+
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  std::cout << "---Diffed Gamestate not compressed" << std::endl;
+  printGameState( g_diffed );
+
+  gc = g_manager->testCompress( g_diffed );
+  std::cout << "---Diffed Gamestate compressed" << std::endl;
+  printGameStateCompressed( gc );
+
+  g_compressedNoDiff = g_manager->testCompress( g_undiff2 );
+  std::cout << "---Same not Diffed Gamestate compressen" << std::endl;
+  printGameStateCompressed( g_compressedNoDiff ); 
+
+  g_resultDiffed = g_client->testDecompress( gc );
+  std::cout << "---Diffed Gamestate of above uncompressed" << std::endl;
+  printGameState( g_resultDiffed );
+
+  std::cout << "---Diffed Gamestates before compressed and after uncompress comparsion" << std::endl;
+  if ( compareGameStates( g_resultDiffed, g_diffed ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl;
+ 
+  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
+  std::cout << "---New Gamestate of pseudo Server compared with new gamestate that Client gets" << std::endl;
+  if ( compareGameStates( g_resultUndiffed, g_undiff2 ) ) std::cout << "GAMESTATES IDENTICAL" << std::endl;
+
+  return;  
+}
+
+bool testNCompressWithDiff( int n, int size, int modeCreateData, int modeChangeData ) { 
+
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameStateCompressed* gc = new GameStateCompressed;
+  GameState* g_undiff1 = new GameState;
+  GameState* g_undiff2 = new GameState;
+  GameState* g_diffed;
+  GameState* g_resultDiffed;
+  GameState* g_resultUndiffed;
+
+  g_undiff1->data = createData( size, modeCreateData );
+  g_undiff1->size = size;
+  g_undiff1->id = 1;
+  g_undiff1->diffed = false;
+  //l = -1;
+  g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+
+  while( compareData2( g_undiff1, g_undiff2 ) ) {
+    delete g_undiff2->data;
+    g_undiff2 = changeGameStateABit( g_undiff1, modeChangeData );
+  } 
+  //l = -2;
+  g_diffed = g_manager->testDiff( g_undiff1, g_undiff2 );
+  gc = g_manager->testCompress( g_diffed );
+  g_resultDiffed = g_client->testDecompress( gc );
+
+  if ( !compareGameStates( g_resultDiffed, g_diffed ) ) return false;
+  //l = -3;
+  g_resultUndiffed = g_client->testUndiff( g_undiff1, g_resultDiffed );
+  if ( !compareGameStates( g_resultUndiffed, g_undiff2 ) ) return false;
+  //l = 1;
+  /*if ( gc != NULL && gc->data != NULL )
+    delete gc->data;
+  //l = 2;
+  //if ( gc != NULL ) 
+    //delete gc;
+  //l = 3;
+  if ( g_undiff1 != NULL && g_undiff1->data != NULL )
+    delete g_undiff1->data;
+  //l = 4; 
+  //if ( g_undiff1 != NULL )
+   //delete g_undiff1;
+  //l = 5;
+  if ( g_undiff2 != NULL && g_undiff2->data )
+    delete g_undiff2->data;
+  //l = 6; 
+  //if ( g_undiff2 != NULL )
+    //delete g_undiff2;
+  //l = 7;
+  if ( g_diffed != NULL && g_diffed->data )
+    //delete g_diffed->data;
+  //l = 8; 
+  //if ( g_diffed )
+    //delete g_diffed;
+  //l = 9;
+  if ( g_resultDiffed != NULL && g_resultDiffed->data )
+    delete g_resultDiffed->data;
+  //l = 10; 
+  //if ( g_resultDiffed )
+    //delete g_resultDiffed;
+  //l = 11;*/
+  
+  return true;
+}
+
+bool testNCompression( int n, int size, int mode ) { 
+  GameStateClient* g_client;
+  GameStateManager* g_manager;;
+  
+  GameState* g_new = new GameState;
+  GameState* g_old = new GameState;
+  GameStateCompressed* gc = new GameStateCompressed;
+  
+  g_old->data = createData( size, mode );
+  g_old->size = size;
+  g_old->id = 0;
+  g_old->diffed = false;
+  
+  gc = g_manager->testCompress( g_old );
+
+  g_new = g_client->testDecompress( gc );
+
+  if ( !compareGameStates( g_new, g_old ) ) return false;
+  
+  
+  if ( g_new != NULL && g_new->data != NULL )
+    delete g_new->data;
+
+  if ( g_old != NULL && g_old->data != NULL )
+    delete g_old->data;
+
+  if ( gc != NULL && gc->data )
+    delete gc->data;
+
+  return true;
+}
+
+void printClientObjectMapping( ConnectionManager* cmanager, int clients ) {
+  std::map<int, int>::iterator iter;
+  std::map<int, int> clientsmap = cmanager->testGetClientsShip();   
+  for( iter = clientsmap.begin(); iter != clientsmap.end(); iter++ ) {
+    std::cout << "clientID: " << iter->first << "\t-> objectID: " << iter->second << std::endl;
+  }
+  return;
+}
+
+bool is( int a[], int b, int size ) {
+  for ( int i=0; i<size; i++ ) {
+    if ( a[i] == b ) return true;
+  }
+  return false;
+}
+
+void testClientObjectMapping( int clients ) {
+  ConnectionManager* cmanager = new ConnectionManager();
+  int shift = 2;
+  std::cout << "create a map length [clients]" << std::endl;
+  for ( int i=0; i<clients; i++ ) {
+    cmanager->testAddClientsShipID( i, i+shift );
+  }
+  printClientObjectMapping( cmanager, clients );
+  
+  std::cout << "get random client's ship id" << std::endl;
+  int id;
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = rand()%clients;
+    std::cout << "client: " << id << "\t-> ship: " << cmanager->testGetClientsShipID( id ) << std::endl;  
+  }
+
+  std::cout <<"get random ship's client id" << std::endl;
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = (rand()%clients)+shift;
+    std::cout << "ship:   " << id << "\t-> client: " << cmanager->testGetObjectsClientID( id ) << std::endl;  
+  }
+
+  std::cout << "delete random client from map" << std::endl;
+  int deleted[clients/3];
+  for ( int i=0; i<(clients/3); i++ ) {
+    id = rand()%clients;
+    if ( !is( deleted, id, clients/3 ) ) {
+      std::cout << "delete client " << id << std::endl;
+      cmanager->testDeleteClientsIDReg( id ); 
+    }
+    deleted[i] = id;
+  }
+  std::cout << "resulting list:" << std::endl;
+  printClientObjectMapping( cmanager, clients-(clients/3));
+  
+  std::cout << "delete random object from map" << std::endl;
+  int jap = 0;
+  while( jap < 3 ) {
+    id = (rand()%clients) + shift;
+    if ( !is( deleted, id, clients/3 ) ) {
+      std::cout << "delete object: " << id << std::endl;
+      cmanager->testDeleteObjectIDReg( id );
+      jap++;
+    }
+  }
+  std::cout << "resulting list:" << std::endl;
+  printClientObjectMapping( cmanager, clients-(clients/3)-3);
+}
+
+bool addClientTest( ENetEvent* event, ClientInformation*& head ) {
+  ClientInformation *temp = head->insertBack(new ClientInformation);
+  if(!temp)
+    return false;
+  if(temp->prev()->head) {
+    temp->prev()->setID(0);
+    temp->setID(1);
+  }
+  else
+    temp->setID(temp->prev()->getID()+1);
+  temp->setPeer(event->peer);
+  std::cout << "added client id: " << temp->getID() << std::endl;
+
+  return temp->setSynched(true);
+}
+
+void printClientInformationBox( ClientInformation* box ) {
+  if(!box)
+    return;
+  std::cout << "ClientList: id: " << box->getID() << "\t";
+  std::cout << "g_id: " << box->getGamestateID() << " \t";
+  std::cout << "synched: " << box->getSynched() << "\t";
+  std::cout << "is head: " << box->head << std::endl;
+}
+
+void printClientInformationList( ClientInformation* list ) {
+  printClientInformationBox( list );
+  list = list->next();
+  
+  while( list != 0 ) {
+    printClientInformationBox( list );
+    list = list->next();
+  }
+  return;
+}
+
+void testClientInformation( int numberOfClients ) {
+  ClientInformation* head = new ClientInformation( true );
+  ConnectionManager* connectionManager;
+  ENetEvent event;
+  
+  for ( int i=0; i<numberOfClients; i++ ) {
+    if ( !addClientTest( &event, head ) ) {
+      std::cout << "addClientTest didn't work with: " << i << std::endl;
+    }
+  }
+  std::cout << "(now id should be synched, since that works and this is test of list, this step is left out)" << std::endl;
+
+  printClientInformationList( head );
+
+  std::cout << "remove some clients" << std::endl;
+  if ( head->removeClient( numberOfClients/3 ) ) std::cout << "client " << numberOfClients/3 << " removed" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients/3 << std::endl;
+  if ( head->removeClient( numberOfClients ) ) std::cout << "client " << numberOfClients << " removed" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients << std::endl;
+  if ( head->removeClient( 1 ) ) std::cout << "client " << 1 << " removed" << std::endl;
+  else std::cout << "could not remove client: " << 1 << std::endl;
+  if ( head->removeClient( 1 ) ) std::cout << "client " << 1 << " removed a second time" << std::endl;
+  else std::cout << "could not remove client: " << 1 << std::endl;
+  if ( head->removeClient( numberOfClients + 100 ) ) std::cout << "client " << numberOfClients + 100 << " removed a second time" << std::endl;
+  else std::cout << "could not remove client: " << numberOfClients + 100 << std::endl;
+
+  printClientInformationList( head );
+  
+  std::cout << "try to find some clients with findClient(..., false)" << std::endl;
+  ClientInformation* temp = head->findClient( 2 );
+  printClientInformationBox( temp );
+  temp = head->findClient( numberOfClients/3 );
+  printClientInformationBox( temp );
+  temp = head->findClient( 0 );
+  printClientInformationBox( temp );
+  temp = head->findClient( 8 );
+  printClientInformationBox( temp );
+
+  std::cout << "find the same, output should be identical with above but with findClient(..., TRUE)" << std::endl;
+  temp = head->findClient( 2, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( numberOfClients/3, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( 0, true );
+  printClientInformationBox( temp );
+  temp = head->findClient( 8, true );
+  printClientInformationBox( temp );
+
+  std::cout << "test setGamestateID" << std::endl;
+  temp->setGameStateID( 8 );
+  printClientInformationBox( temp );
+
+  std::cout << "test insertAfter() and insertBefore()" << std::endl;
+  ClientInformation* newInfo = new ClientInformation;
+  ClientInformation* toool = new ClientInformation;
+  newInfo->setGamestateID( 200 );
+  newInfo->setID( numberOfClients+2);
+  newInfo->setSynched( true );
+  newInfo->setPeer( NULL );
+  toool->setGameStateID( 199 );
+  toool->setID( numberOfClients+1);
+  toool->setSynched( true );
+  toool->setPeer( NULL );
+
+  //never use the same ClientInformation box in this situation
+  //-> results in endless loop
+  temp->insertAfter( newInfo );
+  temp->insertBefore( toool );
+
+  printClientInformationList( head );
+  return;
+}
+
+//### following stuff is to test buffer, took from PacketBufferTestExt.cc ###
+
+void write(PacketBuffer *test){
+  ENetEvent event;
+  ENetPacket *packet;
+  if(test->isEmpty())
+    std::cout << "buffer is empty" << std::endl;
+  for(int i=0; i<10; i++){
+    std::string temp = "packet ";
+    packet = enet_packet_create("packet", strlen("packet ")+1,
+      ENET_PACKET_FLAG_RELIABLE);
+    std::cout << i << ": pushing " << packet->data << std::endl;
+    event.packet=packet;
+    test->push(&event);
+    if(i==5)
+      usleep(200000);
+  }
+  test->setClosed(true);
+  return;
+}
+
+void read(PacketBuffer *test){
+  //test->print();
+  // exit if the queue is closed and empty
+  while(!test->isClosed() || !test->isEmpty()){
+    // only pop if the queue isn't empty
+    while(!test->isEmpty()){
+      std::cout << "We popped the value " << test->pop()->data << std::endl;
+    }
+  }
+  return;
+}
+
+void testPacketBuffer() {
+  PacketBuffer test = PacketBuffer();
+  boost::thread thrd1(boost::bind(&write, &test));
+  boost::thread thrd2(boost::bind(&read, &test));
+
+  thrd1.join();
+  thrd2.join();
+  return;
+}
+
+//### end packetbuffer test stuff ###
+
+void testSynchronisable() {
+  Synchronisable* synchtest;
+  unsigned char* data = new unsigned char[100];
+  for( int i=0; i<100; i++ ) {
+    data[i] = i%10;
+  }
+  //synchtest->registerVar( (const void*)data, 100, network::DATA );
+}
+
+//#########################################################################
+//### this stuff is only a loop to chose one of the prev test functions ###
+//#########################################################################
+void displayModes() {
+  std::cout << "mode datalength: length of data array to create" << std::endl;
+  std::cout << "mode Data:" << std::endl;
+  std::cout << "\t-1 -> array[length] with numbers length%255" << std::endl;
+  std::cout << "\t-2 -> array[length] with numbers length%255, every %98 is != 0" << std::endl;
+  std::cout << "\t-3 -> array[length] with random numbers (-126:127) no modulo zeros" << std::endl;
+  std::cout << "\t-4 -> array[length] with random numbers (0:127) no modulo zeros" << std::endl;
+  std::cout << "---------------------------------------------------------------------------------" << std::endl;
+  std::cout << "mode Change:" << std::endl;
+  std::cout << "\t-1 -> every %10 == 0 index is different from original" << std::endl;
+  std::cout << "\t-2 -> every %(rand()%(length/11)) is different from original" << std::endl;
+  std::cout << "\t-3 -> every %10 == 0 index is different and randomly longer till 2xlonger" << std::endl;
+  std::cout << "\t-4 -> random differences and randomly longer" << std::endl;
+  std::cout << "\t-5 -> only half as long and ever %10 == 0 index is different" << std::endl;
+}
+
+int main( int argc, char* argv[] ) {
+  int a,b,c,n;
+  std::string dec = "nothing";
+  std::cout << "############### START TEST (quit q) ###############" << std::endl;
+  std::cout << "possible tests: " << std::endl;
+  std::cout << "displayModes:\t\t modes" << std::endl;
+  std::cout << "testCompression:\t tc [datalength] [mode Data]" << std::endl;
+  std::cout << "testNCompression:\t tnc [#of loops] [datalength] [mode Data]" << std::endl;
+  std::cout << "testDifferentiation:\t td [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testCompressWithDiff:\t tcd [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testNCompressWithDiff:\t tncd [#of loops] [datalength] [mode Data] [mode Change]" << std::endl;
+  std::cout << "testClientObjectMapping: tcom [#clients]" << std::endl;
+  std::cout << "testClientInformation:\t tci [#clients] (call with >10)" << std::endl;
+  std::cout << "testPacketBuffer:\t tbuf (comment address assignements in PacketBuffer.cc!)" << std::endl;
+  while ( dec.compare("q") != 0 ) {
+    std::cin >> dec;
+    if ( dec.compare("tc") == 0 ) {
+      std::cin >> a; std::cin >> b;
+      testCompression( a, b );
+    }
+    else if ( dec.compare("td") == 0 ) {
+      std::cin>> a; std::cin >> b; std::cin >> c;
+      testDifferentiation( a, b, c );
+    }
+    else if ( dec.compare("tcd") == 0 ) {
+      std::cin>> a; std::cin >> b; std::cin >> c;
+      testCompressWithDiff( a, b, c );
+    }
+    else if ( dec.compare("modes") == 0 )
+      displayModes();
+    else if ( dec.compare("tcom") == 0 ) {
+      std::cin>> a;
+      testClientObjectMapping( a );
+    }
+    else if ( dec.compare("tci") == 0 ) {
+      std::cin >> a;
+      testClientInformation( a );
+    } 
+    else if ( dec.compare("tbuf") == 0 ) {
+      testPacketBuffer();
+    } 
+    else if ( dec.compare("tncd") == 0 ) {
+      std::cin >> n; std::cin >> a; std::cin >> b; std::cin >> c;
+      for ( int i=1; i<=n; i++ ) {  
+        std::cout << i << " s" << a << " ";      
+        //std::cout << "start loop test " << i << std::endl;
+        if ( !testNCompressWithDiff( i, a, b, c ) ) {
+          std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl;
+          break;
+        }
+      }
+      std::cout << "end loop comparsion test" << std::endl;
+    }
+    else if ( dec.compare("tnc") == 0 ) {
+      std::cin >> n; std::cin >> a; std::cin >> b;
+      for ( int i=1; i<=n; i++ ) {  
+        std::cout << i << " s" << a << " ";      
+        //std::cout << "start loop test " << i << std::endl;
+        if ( !testNCompression( i, a, b ) ) {
+          std::cout << "#COMPARSION ERROR->VERYVERY BAD" << std::endl;
+          break;
+        }
+      }
+      std::cout << "end loop comparsion test" << std::endl;
+    }
+    else std::cout << "invalid input" << std::endl;  
+    std::cout << "################## END ONE TURN ##################@" << std::endl;
+  }
+  return 0;
+}
+/*
+int main() {
+  std::cout << "############### START TEST (quit q) ###############" << std::endl;
+  testSynchronisable();
+}*/
+
+//#########################################################################
+//### the prev loop is only to chose one prev prev test functions       ###
+//#########################################################################
Index: /code/branches/ceguilua/src/network/packet/Acknowledgement.cc
===================================================================
--- /code/branches/ceguilua/src/network/packet/Acknowledgement.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Acknowledgement.cc	(revision 1801)
@@ -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:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Acknowledgement.h"
+#include "network/Host.h"
+#include "network/GamestateHandler.h"
+#include "core/CoreIncludes.h"
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_ACK    0
+#define _PACKETID           0
+#define _ACKID              _PACKETID + sizeof(network::packet::ENUM::Type)
+  
+Acknowledgement::Acknowledgement( unsigned int id, int clientID )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_ACK;
+  data_=new unsigned char[ getSize() ];
+  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::Acknowledgement;
+  *(unsigned int *)(data_ + _ACKID ) = id;
+  clientID_=clientID;
+}
+
+Acknowledgement::Acknowledgement( unsigned char *data, int clientID )
+  : Packet(data, clientID)
+{
+}
+
+Acknowledgement::~Acknowledgement()
+{
+}
+
+unsigned int Acknowledgement::getSize() const{
+  return _ACKID + sizeof(unsigned int);
+}
+
+bool Acknowledgement::process(){
+  bool b = GamestateHandler::ackGamestate(getAckID(), clientID_);
+  delete this;
+  return b;
+}
+
+unsigned int Acknowledgement::getAckID(){
+  return *(unsigned int *)(data_ + _ACKID);
+}
+
+} //namespace packet
+} //namespace network
Index: /code/branches/ceguilua/src/network/packet/Acknowledgement.h
===================================================================
--- /code/branches/ceguilua/src/network/packet/Acknowledgement.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Acknowledgement.h	(revision 1801)
@@ -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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKACKNOLEDGEMENT_H
+#define NETWORKACKNOLEDGEMENT_H
+
+#include "Packet.h"
+
+
+namespace network {
+namespace packet {
+/**
+	@author 
+*/
+class Acknowledgement : public Packet
+{
+public:
+  Acknowledgement( unsigned int id, int clientID );
+  Acknowledgement( unsigned char* data, int clientID );
+  ~Acknowledgement();
+  
+  inline unsigned int getSize() const;
+  bool process();
+  
+  unsigned int getAckID();
+private:
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/ceguilua/src/network/packet/Chat.cc
===================================================================
--- /code/branches/ceguilua/src/network/packet/Chat.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Chat.cc	(revision 1801)
@@ -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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Chat.h"
+#include <assert.h>
+
+namespace network {
+namespace packet {
+  
+#define PACKET_FLAGS_CHAT ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID         0
+#define _MESSAGELENGTH    _PACKETID + sizeof(ENUM::Type)
+#define _MESSAGE          _MESSAGELENGTH + sizeof(unsigned int)
+
+Chat::Chat( std::string& message, int clientID )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_CHAT;
+  messageLength_ = message.length()+1;
+  data_=new unsigned char[ getSize() ];
+  *(ENUM::Type *)&data_[ _PACKETID ] = ENUM::Chat;
+  *(unsigned int *)&data_[ _MESSAGELENGTH ] = messageLength_;
+  memcpy( &data_[ _MESSAGE ], (void *)message.c_str(), messageLength_ );
+  clientID_=clientID;
+}
+
+Chat::Chat( unsigned char *data, int clientID )
+  : Packet(data, clientID)
+{
+  messageLength_ = *(unsigned int *)&data[ _MESSAGELENGTH ];
+}
+
+Chat::~Chat()
+{
+}
+
+unsigned int Chat::getSize() const{
+  return _MESSAGE + messageLength_;
+}
+
+bool Chat::process(){
+  //TODO: change this !!!
+  assert(0);
+  delete this;
+  return true;
+}
+
+unsigned char *Chat::getMessage(){
+  return &data_[ _MESSAGE ];
+}
+
+} //namespace packet
+} //namespace network
Index: /code/branches/ceguilua/src/network/packet/Chat.h
===================================================================
--- /code/branches/ceguilua/src/network/packet/Chat.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Chat.h	(revision 1801)
@@ -0,0 +1,34 @@
+
+#ifndef NETWORKCHAT_H
+#define NETWORKCHAT_H
+
+#include <string>
+
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+/**
+	@author 
+*/
+class Chat : public Packet
+{
+public:
+  Chat( std::string& message, int clientID );
+  Chat( unsigned char* data, int clientID );
+  ~Chat();
+  
+  inline unsigned int getSize() const;
+  bool process();
+  
+  unsigned int getMessageLength(){ return messageLength_; };
+  unsigned char *getMessage();
+private:
+  unsigned int messageLength_;
+  int clientID_;
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/ceguilua/src/network/packet/ClassID.cc
===================================================================
--- /code/branches/ceguilua/src/network/packet/ClassID.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/ClassID.cc	(revision 1801)
@@ -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:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+
+#include "ClassID.h"
+#include "core/CoreIncludes.h"
+#include <string>
+#include <assert.h>
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID             0
+#define _CLASSID              _PACKETID + sizeof(ENUM::Type)
+#define _CLASSNAMELENGTH      _CLASSID + sizeof(unsigned int)
+#define _CLASSNAME            _CLASSNAMELENGTH + sizeof(classNameLength_)
+  
+  ClassID::ClassID( unsigned int classID, std::string className )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  classNameLength_=className.length()+1;
+  assert(getSize());
+  data_=new unsigned char[ getSize() ];
+  assert(data_);
+  *(ENUM::Type *)(data_ + _PACKETID ) = ENUM::ClassID;
+  *(unsigned int *)(data_ + _CLASSID ) = classID;
+  *(unsigned int *)(data_ + _CLASSNAMELENGTH ) = classNameLength_;
+  memcpy( data_+_CLASSNAME, (void *)className.c_str(), classNameLength_ );
+}
+
+ClassID::ClassID( unsigned char *data, int clientID )
+  : Packet(data, clientID)
+{
+  memcpy( (void *)&classNameLength_, &data[ _CLASSNAMELENGTH ], sizeof(classNameLength_) );
+}
+
+ClassID::~ClassID()
+{
+}
+
+unsigned int ClassID::getSize() const{
+  return sizeof(network::packet::ENUM::Type) + 2*sizeof(unsigned int) + classNameLength_;
+}
+
+bool ClassID::process(){
+  COUT(3) << "processing classid: " << getClassID() << " name: " << (const char*)(data_+_CLASSNAME) << std::endl;
+  orxonox::Identifier *id=GetIdentifier( std::string((const char*)(data_+_CLASSNAME) ));
+  if(id==NULL)
+    return false;
+  id->setNetworkID( getClassID() );
+  delete this;
+  return true;
+}
+
+unsigned int ClassID::getClassID(){
+  return *(unsigned int *)&data_[ _CLASSID ];
+}
+
+} //namespace packet
+}//namespace network
Index: /code/branches/ceguilua/src/network/packet/ClassID.h
===================================================================
--- /code/branches/ceguilua/src/network/packet/ClassID.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/ClassID.h	(revision 1801)
@@ -0,0 +1,61 @@
+/*
+ *   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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKCLASSID_H
+#define NETWORKCLASSID_H
+
+#include <string>
+
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+
+/**
+	@author 
+*/
+class ClassID : public Packet
+{
+public:
+  ClassID( unsigned int classID, std::string className );
+  ClassID( unsigned char* data, int clientID );
+  ~ClassID();
+  
+  inline unsigned int getSize() const;
+  bool process();
+  
+  unsigned int getClassID();
+  unsigned int getClassNameLength(){ return classNameLength_; }
+  unsigned char *getClassName();
+private:
+  unsigned int classNameLength_;
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/ceguilua/src/network/packet/Gamestate.cc
===================================================================
--- /code/branches/ceguilua/src/network/packet/Gamestate.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Gamestate.cc	(revision 1801)
@@ -0,0 +1,401 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Gamestate.h"
+#include "network/ClientInformation.h"
+#include "network/GamestateHandler.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+
+#include <zlib.h>
+#include <assert.h>
+
+
+
+namespace network {
+
+namespace packet {
+
+#define GAMESTATE_START(data) (data + sizeof(GamestateHeader))
+#define GAMESTATE_HEADER(data) ((GamestateHeader *)data)
+#define HEADER GAMESTATE_HEADER(data_)
+
+Gamestate::Gamestate()
+{
+}
+
+Gamestate::Gamestate(unsigned char *data, int clientID):
+    Packet(data, clientID)
+{
+}
+
+
+Gamestate::~Gamestate()
+{
+}
+
+bool Gamestate::collectData(int id, int mode)
+{
+  int tempsize=0, currentsize=0;
+  assert(data_==0);
+  int size = calcGamestateSize(id, mode);
+
+  COUT(4) << "G.ST.Man: producing gamestate with id: " << id << std::endl;
+  if(size==0)
+    return false;
+  data_ = new unsigned char[size + sizeof(GamestateHeader)];
+  if(!data_){
+    COUT(2) << "GameStateManager: could not allocate memory" << std::endl;
+    return false;
+  }
+
+  //start collect data synchronisable by synchronisable
+  unsigned char *mem=data_;
+  mem+=sizeof(GamestateHeader);
+  orxonox::ObjectList<Synchronisable>::iterator it;
+  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it){
+    tempsize=it->getSize2(id, mode);
+
+    if(currentsize+tempsize > size){
+      // start allocate additional memory
+      COUT(3) << "G.St.Man: need additional memory" << std::endl;
+      orxonox::ObjectList<Synchronisable>::iterator temp = it;
+      int addsize=tempsize;
+      while(++temp)
+        addsize+=temp->getSize2(id, mode);
+      data_ = (unsigned char *)realloc(data_, sizeof(GamestateHeader) + currentsize + addsize);
+      if(!data_)
+        return false;
+      size = currentsize+addsize;
+    }// stop allocate additional memory
+
+    if(!it->getData(mem, id, mode))
+      return false; // mem pointer gets automatically increased because of call by reference
+    // increase size counter by size of current synchronisable
+    currentsize+=tempsize;
+  }
+
+
+  //start write gamestate header
+  HEADER->packetType = ENUM::Gamestate;
+  assert( *(ENUM::Type *)(data_) == ENUM::Gamestate);
+  HEADER->normsize = currentsize;
+  HEADER->id = id;
+  HEADER->diffed = false;
+  HEADER->complete = true;
+  HEADER->compressed = false;
+  //stop write gamestate header
+
+  COUT(5) << "G.ST.Man: Gamestate size: " << currentsize << std::endl;
+  COUT(5) << "G.ST.Man: 'estimated' (and corrected) Gamestate size: " << size << std::endl;
+  return true;
+}
+
+bool Gamestate::spreadData(int mode)
+{
+  assert(data_);
+  assert(!HEADER->compressed);
+  assert(!HEADER->diffed);
+  unsigned int size, objectID, classID;
+  unsigned char *mem=data_+sizeof(GamestateHeader);
+    // get the start of the Synchronisable list
+  orxonox::ObjectList<Synchronisable>::iterator it=orxonox::ObjectList<Synchronisable>::begin();
+
+  while(mem < data_+sizeof(GamestateHeader)+HEADER->normsize){
+      // extract synchronisable header
+    size = *(unsigned int *)mem;
+    objectID = *(unsigned int*)(mem+sizeof(unsigned int));
+    classID = *(unsigned int*)(mem+2*sizeof(unsigned int));
+
+    if(!it || it->objectID!=objectID || it->classID!=classID){
+        // bad luck ;)
+        // delete the synchronisable (obviously seems to be deleted on the server)
+      while(it && it->objectID!=objectID)
+        removeObject(it);
+
+      if(!it){
+        //fabricate the new synchronisable
+        if(!Synchronisable::fabricate(mem, mode))
+          return false;
+        it=orxonox::ObjectList<Synchronisable>::end();
+      }else{
+	if(! it->updateData(mem, mode))
+        {
+          COUT(1) << "We couldn't update objectID: " \
+            << objectID << "; classID: " << classID << std::endl;
+        }
+      }
+    } else
+    {
+        // we have our object
+      if(! it->updateData(mem, mode))
+      {
+        COUT(1) << "We couldn't update objectID: " \
+            << objectID << "; classID: " << classID << std::endl;
+      }
+    }
+    ++it;
+  }
+
+  return true;
+}
+
+int Gamestate::getID(){
+  return HEADER->id;
+}
+
+unsigned int Gamestate::getSize() const
+{
+  assert(data_);
+  if(HEADER->compressed)
+    return HEADER->compsize+sizeof(GamestateHeader);
+  else
+  {
+    return HEADER->normsize+sizeof(GamestateHeader);
+  }
+}
+
+bool Gamestate::operator==(packet::Gamestate gs){
+  unsigned char *d1 = data_+sizeof(GamestateHeader);
+  unsigned char *d2 = gs.data_+sizeof(GamestateHeader);
+  assert(!isCompressed());
+  assert(!gs.isCompressed());
+  while(d1<data_+HEADER->normsize)
+  {
+    if(*d1!=*d2)
+      return false;
+    d1++;
+    d2++;
+  }
+  return true;
+}
+
+bool Gamestate::process()
+{
+  return GamestateHandler::addGamestate(this, getClientID());
+}
+
+bool Gamestate::compressData()
+{
+  assert(HEADER);
+  assert(!HEADER->compressed);
+  uLongf buffer = (uLongf)(((HEADER->normsize + 12)*1.01)+1);
+  if(buffer==0)
+    return false;
+
+  unsigned char *ndata = new unsigned char[buffer+sizeof(GamestateHeader)];
+  unsigned char *dest = GAMESTATE_START(ndata);
+  //unsigned char *dest = new unsigned char[buffer];
+  unsigned char *source = GAMESTATE_START(data_);
+  int retval;
+  retval = compress( dest, &buffer, source, (uLong)(HEADER->normsize) );
+  switch ( retval ) {
+    case Z_OK: COUT(5) << "G.St.Man: compress: successfully compressed" << std::endl; break;
+    case Z_MEM_ERROR: COUT(1) << "G.St.Man: compress: not enough memory available in gamestate.compress" << std::endl; return false;
+    case Z_BUF_ERROR: COUT(2) << "G.St.Man: compress: not enough memory available in the buffer in gamestate.compress" << std::endl; return false;
+    case Z_DATA_ERROR: COUT(2) << "G.St.Man: compress: data corrupted in gamestate.compress" << std::endl; return false;
+  }
+#ifndef NDEBUG
+  //decompress and compare the start and the decompressed data
+  unsigned char *rdata = new unsigned char[HEADER->normsize+sizeof(GamestateHeader)];
+  unsigned char *d2 = GAMESTATE_START(rdata);
+  uLongf length2 = HEADER->normsize;
+  uncompress(d2, &length2, dest, buffer);
+  for(unsigned int i=0; i<HEADER->normsize; i++){
+    assert(*(source+i)==*(d2+i));
+  }
+  delete[] rdata;
+#endif
+
+  //copy and modify header
+#ifndef NDEBUG
+  HEADER->crc32 = calcCRC(data_+sizeof(GamestateHeader), HEADER->normsize);
+#endif
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  //delete old data
+  delete[] data_;
+  //save new data
+  data_ = ndata;
+  HEADER->compsize = buffer;
+  HEADER->compressed = true;
+  assert(HEADER->compressed);
+  COUT(3) << "gamestate compress normsize: " << HEADER->normsize << " compsize: " << HEADER->compsize << std::endl;
+  return true;
+}
+bool Gamestate::decompressData()
+{
+  assert(HEADER);
+  assert(HEADER->compressed);
+  COUT(3) << "GameStateClient: uncompressing gamestate. id: " << HEADER->id << ", baseid: " << HEADER->base_id << ", normsize: " << HEADER->normsize << ", compsize: " << HEADER->compsize << std::endl;
+  unsigned int normsize = HEADER->normsize;
+  unsigned int compsize = HEADER->compsize;
+  unsigned int bufsize;
+  assert(compsize<=normsize);
+  bufsize = normsize;
+  assert(bufsize!=0);
+  unsigned char *ndata = new unsigned char[bufsize + sizeof(GamestateHeader)];
+  unsigned char *dest = ndata + sizeof(GamestateHeader);
+  unsigned char *source = data_ + sizeof(GamestateHeader);
+  int retval;
+  uLongf length=bufsize;
+  retval = uncompress( dest, &length, source, (uLong)compsize );
+  switch ( retval ) {
+    case Z_OK: COUT(5) << "successfully decompressed" << std::endl; break;
+    case Z_MEM_ERROR: COUT(1) << "not enough memory available" << std::endl; return false;
+    case Z_BUF_ERROR: COUT(2) << "not enough memory available in the buffer" << std::endl; return false;
+    case Z_DATA_ERROR: COUT(2) << "data corrupted (zlib)" << std::endl; return false;
+  }
+#ifndef NDEBUG
+  assert(HEADER->crc32==calcCRC(ndata+sizeof(GamestateHeader), HEADER->normsize));
+#endif
+
+  //copy over the header
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  //delete old (compressed data)
+  delete[] data_;
+  //set new pointers
+  data_ = ndata;
+  HEADER->compressed = false;
+  assert(HEADER->normsize==normsize);
+  assert(HEADER->compsize==compsize);
+  return true;
+}
+
+Gamestate *Gamestate::diff(Gamestate *base)
+{
+  assert(HEADER);
+  assert(!HEADER->compressed);
+  assert(!HEADER->diffed);
+  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
+  unsigned char *basep = GAMESTATE_START(base->data_), *gs = GAMESTATE_START(this->data_);
+  unsigned int of=0; // pointers offset
+  unsigned int dest_length=0;
+  dest_length=HEADER->normsize;
+  if(dest_length==0)
+    return NULL;
+  unsigned char *ndata = new unsigned char[dest_length*sizeof(unsigned char)+sizeof(GamestateHeader)];
+  unsigned char *dest = ndata + sizeof(GamestateHeader);
+  while(of < GAMESTATE_HEADER(base->data_)->normsize && of < HEADER->normsize){
+    *(dest+of)=*(basep+of)^*(gs+of); // do the xor
+    ++of;
+  }
+  if(GAMESTATE_HEADER(base->data_)->normsize!=HEADER->normsize){
+    unsigned char n=0;
+    if(GAMESTATE_HEADER(base->data_)->normsize < HEADER->normsize){
+      while(of<dest_length){
+        *(dest+of)=n^*(gs+of);
+        of++;
+      }
+    }
+  }
+
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  GAMESTATE_HEADER(ndata)->diffed = true;
+  GAMESTATE_HEADER(ndata)->base_id = base->getID();
+  Gamestate *g = new Gamestate(ndata, getClientID());
+  g->flags_=flags_;
+  g->packetDirection_ = packetDirection_;
+  return g;
+}
+
+Gamestate *Gamestate::undiff(Gamestate *base)
+{
+  assert(this && base);assert(HEADER);
+  assert(HEADER->diffed);
+  assert(!HEADER->compressed && !GAMESTATE_HEADER(base->data_)->compressed);
+  //unsigned char *basep = base->getGs()/*, *gs = getGs()*/;
+  unsigned char *basep = GAMESTATE_START(base->data_);
+  unsigned char *gs = GAMESTATE_START(this->data_);
+  unsigned int of=0; // pointers offset
+  unsigned int dest_length=0;
+  dest_length=HEADER->normsize;
+  if(dest_length==0)
+    return NULL;
+  unsigned char *ndata = new unsigned char[dest_length*sizeof(unsigned char)+sizeof(GamestateHeader)];
+  unsigned char *dest = ndata + sizeof(GamestateHeader);
+  while(of < GAMESTATE_HEADER(base->data_)->normsize && of < HEADER->normsize){
+    *(dest+of)=*(basep+of)^*(gs+of); // do the xor
+    ++of;
+  }
+  if(GAMESTATE_HEADER(base->data_)->normsize!=HEADER->normsize){
+    unsigned char n=0;
+    if(GAMESTATE_HEADER(base->data_)->normsize < HEADER->normsize){
+      while(of < dest_length){
+        *(dest+of)=n^*(gs+of);
+        of++;
+      }
+    }
+  }
+  *GAMESTATE_HEADER(ndata) = *HEADER;
+  GAMESTATE_HEADER(ndata)->diffed = false;
+  Gamestate *g = new Gamestate(ndata, getClientID());
+  g->flags_=flags_;
+  g->packetDirection_ = packetDirection_;
+  assert(!g->isDiffed());
+  assert(!g->isCompressed());
+  return g;
+}
+
+
+unsigned int Gamestate::calcGamestateSize(unsigned int id, int mode)
+{
+  int size=0;
+    // get the start of the Synchronisable list
+  orxonox::ObjectList<Synchronisable>::iterator it;
+    // get total size of gamestate
+  for(it = orxonox::ObjectList<Synchronisable>::begin(); it; ++it)
+    size+=it->getSize2(id, mode); // size of the actual data of the synchronisable
+//  size+=sizeof(GamestateHeader);
+  return size;
+}
+
+/**
+ * This function removes a Synchronisable out of the universe
+ * @param it iterator of the list pointing to the object
+ * @return iterator pointing to the next object in the list
+ */
+  void Gamestate::removeObject(orxonox::ObjectList<Synchronisable>::iterator &it) {
+    orxonox::ObjectList<Synchronisable>::iterator temp=it;
+    ++it;
+    delete  *temp;
+  }
+
+  bool Gamestate::isDiffed(){
+    return HEADER->diffed;
+  }
+
+  bool Gamestate::isCompressed(){
+    return HEADER->compressed;
+  }
+
+  int Gamestate::getBaseID(){
+    return HEADER->base_id;
+  }
+}
+
+}
Index: /code/branches/ceguilua/src/network/packet/Gamestate.h
===================================================================
--- /code/branches/ceguilua/src/network/packet/Gamestate.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Gamestate.h	(revision 1801)
@@ -0,0 +1,95 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "Packet.h"
+#include "network/Synchronisable.h"
+#ifndef NDEBUG
+#include "util/CRC32.h"
+#endif
+
+#ifndef NETWORK_PACKETGAMESTATE_H
+#define NETWORK_PACKETGAMESTATE_H
+
+namespace network {
+
+namespace packet {
+
+struct GamestateHeader{
+  ENUM::Type packetType;
+  int id; // id of the gamestate
+  unsigned int compsize;
+  unsigned int normsize;
+  int base_id; // id of the base-gamestate diffed from
+  bool diffed; // wheter diffed or not
+  bool complete; // wheter it is a complete gamestate or only partial
+  bool compressed;
+#ifndef NDEBUG
+  uint32_t crc32;
+#endif
+};
+
+/**
+	@author
+*/
+class Gamestate: public Packet{
+  public:
+    Gamestate();
+    Gamestate(unsigned char *data, int clientID);
+
+    ~Gamestate();
+
+    bool collectData(int id, int mode=0x0);
+    bool spreadData(int mode=0x0);
+    int getID();
+    bool isDiffed();
+    bool isCompressed();
+    int getBaseID();
+    Gamestate *diff(Gamestate *base);
+    Gamestate *undiff(Gamestate *base);
+    bool compressData();
+    bool decompressData();
+
+    // Packet functions
+    virtual unsigned int getSize() const;
+    virtual bool process();
+
+    bool operator ==(packet::Gamestate gs);
+  private:
+    unsigned int calcGamestateSize(unsigned int id, int mode=0x0);
+    void removeObject(orxonox::ObjectListIterator<Synchronisable> &it);
+
+
+    //Bytestream *bs_;
+    //GamestateHeader *header_;
+};
+
+}
+
+}
+
+#endif
Index: /code/branches/ceguilua/src/network/packet/Packet.cc
===================================================================
--- /code/branches/ceguilua/src/network/packet/Packet.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Packet.cc	(revision 1801)
@@ -0,0 +1,183 @@
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Packet.h"
+
+#include <cassert>
+#include <enet/enet.h>
+#include <boost/bind.hpp>
+
+#include "network/ConnectionManager.h"
+#include "network/ClientInformation.h"
+
+#include "Acknowledgement.h"
+#include "Chat.h"
+#include "ClassID.h"
+#include "Gamestate.h"
+#include "Welcome.h"
+#include "network/Host.h"
+#include "core/CoreIncludes.h"
+
+namespace network{
+
+namespace packet{
+  
+#define PACKET_FLAG_DEFAULT ENET_PACKET_FLAG_NO_ALLOCATE
+#define _PACKETID           0
+  
+std::map<ENetPacket *, Packet *> Packet::packetMap_;
+  
+Packet::Packet(){
+  flags_ = PACKET_FLAG_DEFAULT;
+  packetDirection_ = ENUM::Outgoing;
+  clientID_=0;
+  data_=0;
+  enetPacket_=0;
+}
+
+void blub(ENetPacket *packet){
+  COUT(4) << "blubb" << std::endl;
+}
+
+Packet::Packet(unsigned char *data, int clientID){
+  flags_ = PACKET_FLAG_DEFAULT;
+  packetDirection_ = ENUM::Incoming;
+  clientID_=clientID;
+  data_=data;
+  enetPacket_=0;
+}
+
+/*Packet::Packet(ENetPacket *packet, ENetPeer *peer){
+  packetDirection_ = ENUM::Incoming;
+  enetPacket_ = packet;
+  clientID_ = ClientInformation::findClient(&peer->address)->getID();
+  data_ = packet->data;
+}*/
+
+Packet::Packet(const Packet &p){
+  enetPacket_=p.enetPacket_;
+  flags_=p.flags_;
+  packetDirection_ = p.packetDirection_;
+  clientID_ = p.clientID_;
+  if(p.data_){
+    data_ = new unsigned char[p.getSize()];
+    memcpy(data_, p.data_, p.getSize());
+  }else
+    data_=0;
+}
+
+Packet::~Packet(){
+  if(enetPacket_){
+    assert(enetPacket_->freeCallback==0);
+    enet_packet_destroy(enetPacket_);
+  }
+  if(data_)
+    delete[] data_;
+}
+
+bool Packet::send(){
+  if(packetDirection_ != ENUM::Outgoing && packetDirection_ != ENUM::Bidirectional ){
+    assert(0);
+    return false;
+  }
+  if(!enetPacket_){
+    if(!data_){
+      assert(0);
+      return false;
+    }
+    enetPacket_ = enet_packet_create(getData(), getSize(), getFlags());
+    enetPacket_->freeCallback = &Packet::deletePacket;
+//     enetPacket_->freeCallback = &blub;
+    packetMap_[enetPacket_] = this;
+  }
+#ifndef NDEBUG 
+  switch( *(ENUM::Type *)(data_ + _PACKETID) )
+  {
+    case ENUM::Acknowledgement:
+    case ENUM::Chat:
+    case ENUM::ClassID:
+    case ENUM::Gamestate:
+    case ENUM::Welcome:
+      break;
+    default:
+      assert(0); //there was some error, if this is the case
+      break;
+  }
+#endif
+  ENetPacket *temp = enetPacket_;
+  enetPacket_ = 0; // otherwise we have a double free because enet already handles the deallocation of the packet
+  network::Host::addPacket( temp, clientID_);
+  return true;
+}
+
+Packet *Packet::createPacket(ENetPacket *packet, ENetPeer *peer){
+  unsigned char *data = packet->data;
+  unsigned int clientID = ClientInformation::findClient(&peer->address)->getID();
+  Packet *p;
+  COUT(3) << "packet type: " << *(ENUM::Type *)&data[_PACKETID] << std::endl;
+  switch( *(ENUM::Type *)(data + _PACKETID) )
+  {
+    case ENUM::Acknowledgement:
+      COUT(3) << "ack" << std::endl;
+      p = new Acknowledgement( data, clientID );
+      break;
+    case ENUM::Chat:
+      COUT(3) << "chat" << std::endl;
+      p = new Chat( data, clientID );
+      break;
+    case ENUM::ClassID:
+      COUT(3) << "classid" << std::endl;
+      p = new ClassID( data, clientID );
+      break;
+    case ENUM::Gamestate:
+      COUT(3) << "gamestate" << std::endl;
+      // TODO: remove brackets
+      p = new Gamestate( data, clientID );
+      break;
+    case ENUM::Welcome:
+      COUT(3) << "welcome" << std::endl;
+      p = new Welcome( data, clientID );
+      break;
+    default:
+      assert(0); //TODO: repair this
+      break;
+  }
+  return p;
+}
+
+void Packet::deletePacket(ENetPacket *packet){
+  assert(packetMap_[packet]);
+  assert(packetMap_[packet]->enetPacket_==0);
+  delete packetMap_[packet];
+}
+
+} // namespace packet
+
+} // namespace network
+
Index: /code/branches/ceguilua/src/network/packet/Packet.h
===================================================================
--- /code/branches/ceguilua/src/network/packet/Packet.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Packet.h	(revision 1801)
@@ -0,0 +1,91 @@
+/*
+ *   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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKPACKET_H
+#define NETWORKPACKET_H
+
+#include <map>
+#include <enet/enet.h>
+
+namespace network {
+
+namespace packet{
+  
+namespace ENUM{
+  enum Direction{
+    Incoming,
+    Outgoing,
+    Bidirectional
+  };
+  enum Type{
+    Acknowledgement,
+    Gamestate,
+    ClassID,
+    Chat,
+    Welcome
+  };
+}
+  
+/**
+	@author Oliver Scheuss <scheusso [at] ee.ethz.ch>
+*/
+class Packet{
+  public:
+    Packet(const Packet &p);
+    virtual ~Packet();
+    static Packet *createPacket(ENetPacket *packet, ENetPeer *peer);
+    static void deletePacket(ENetPacket *packet);
+    
+    virtual unsigned char *getData(){ return data_; };
+    virtual unsigned int getSize() const =0;
+    virtual bool process()=0;
+    enet_uint32 getFlags()
+      { return flags_; }
+    int getClientID()
+      { return clientID_; }
+    void setClientID( int id )
+      { clientID_ = id; }
+    
+    bool send();
+  protected:
+    Packet();
+    Packet(unsigned char *data, int clientID);
+//    Packet(ENetPacket *packet, ENetPeer *peer);
+    enet_uint32 flags_;
+    int clientID_;
+    ENUM::Direction packetDirection_;
+    unsigned char *data_;
+  private:
+    static std::map<ENetPacket *, Packet *> packetMap_;
+    ENetPacket *enetPacket_;
+};
+
+} //namespace packet
+
+} //namespace network
+
+#endif
Index: /code/branches/ceguilua/src/network/packet/Welcome.cc
===================================================================
--- /code/branches/ceguilua/src/network/packet/Welcome.cc	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Welcome.cc	(revision 1801)
@@ -0,0 +1,89 @@
+
+
+/*
+ *   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:
+ *      Oliver Scheuss, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+
+#include "Welcome.h"
+#include "network/Host.h"
+#include "network/Synchronisable.h"
+#include "core/CoreIncludes.h"
+#include <assert.h>
+
+namespace network {
+namespace packet {
+
+#define PACKET_FLAGS_CLASSID  ENET_PACKET_FLAG_RELIABLE
+#define _PACKETID             0
+#define _CLIENTID             _PACKETID + sizeof(ENUM::Type)
+#define _SHIPID               _CLIENTID + sizeof(unsigned int)
+  
+  Welcome::Welcome( unsigned int clientID, unsigned int shipID )
+ : Packet()
+{
+  flags_ = flags_ | PACKET_FLAGS_CLASSID;
+  assert(getSize());
+  data_=new unsigned char[ getSize() ];
+  assert(data_);
+  *(packet::ENUM::Type *)(data_ + _PACKETID ) = packet::ENUM::Welcome;
+  *(unsigned int *)&data_[ _CLIENTID ] = clientID;
+  *(unsigned int *)&data_[ _SHIPID ] = shipID;
+}
+
+Welcome::Welcome( unsigned char *data, int clientID )
+  : Packet(data, clientID)
+{
+}
+
+Welcome::~Welcome()
+{
+}
+
+unsigned char *Welcome::getData(){
+  return data_;
+}
+
+unsigned int Welcome::getSize() const{
+  return sizeof(network::packet::ENUM::Type) + 2*sizeof(unsigned int);
+}
+
+bool Welcome::process(){
+  unsigned int shipID, clientID;
+  clientID = *(unsigned int *)&data_[ _CLIENTID ];
+  shipID = *(unsigned int *)&data_[ _SHIPID ];
+  Host::setClientID(clientID);
+  Host::setShipID(shipID);
+  COUT(3) << "Welcome set clientId: " << clientID << " shipID: " << shipID << std::endl;
+  Synchronisable::setClient(true);
+  delete this;
+  return true;
+}
+
+
+} //namespace packet
+}//namespace network
Index: /code/branches/ceguilua/src/network/packet/Welcome.h
===================================================================
--- /code/branches/ceguilua/src/network/packet/Welcome.h	(revision 1801)
+++ /code/branches/ceguilua/src/network/packet/Welcome.h	(revision 1801)
@@ -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:
+ *      Oliver Scheuss <scheusso [at] ee.ethz.ch>, (C) 2008
+ *   Co-authors:
+ *      ...
+ *
+ */
+#ifndef NETWORKWELCOME_H
+#define NETWORKWELCOME_H
+
+#include "Packet.h"
+
+namespace network {
+namespace packet {
+
+/**
+	@author 
+*/
+class Welcome : public Packet
+{
+public:
+  Welcome( unsigned int clientID, unsigned int shipID );
+  Welcome( unsigned char* data, int clientID );
+  virtual ~Welcome();
+  
+  unsigned char *getData();
+  inline unsigned int getSize() const;
+  bool process();
+  
+private:
+};
+
+} //namespace packet
+} //namespace network
+
+#endif
Index: /code/branches/ceguilua/src/ois/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/ois/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/ois/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,49 @@
+INCLUDE_DIRECTORIES(.)
+
+SET( OIS_SRC_FILES
+  OISEffect.cpp
+  OISException.cpp
+  OISForceFeedback.cpp
+  OISInputManager.cpp
+  OISJoyStick.cpp
+  OISKeyboard.cpp
+  OISObject.cpp
+)
+
+IF(WIN32)
+  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
+    win32/Win32ForceFeedback.cpp
+    win32/Win32InputManager.cpp
+    win32/Win32JoyStick.cpp
+    win32/Win32KeyBoard.cpp
+    win32/Win32Mouse.cpp
+  )
+ELSEIF (APPLE)
+  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
+    mac/MacHelpers.cpp
+    mac/MacHIDManager.cpp
+    mac/MacInputManager.cpp
+    mac/MacKeyboard.cpp
+    mac/MacMouse.cpp
+  )
+ELSEIF (UNIX)
+  SET( OIS_SRC_FILES ${OIS_SRC_FILES}
+    linux/EventHelpers.cpp
+    linux/LinuxForceFeedback.cpp
+    linux/LinuxInputManager.cpp
+    linux/LinuxJoyStickEvents.cpp
+    linux/LinuxKeyboard.cpp
+    linux/LinuxMouse.cpp
+  )
+ENDIF (WIN32)
+
+ADD_LIBRARY( ois_orxonox SHARED ${OIS_SRC_FILES} )
+
+IF(WIN32)
+  LINK_DIRECTORIES(${DirectX_LIB_DIR})
+  TARGET_LINK_LIBRARIES( ois_orxonox
+    dxguid
+    dinput8
+  )
+ENDIF(WIN32)
+
Index: /code/branches/ceguilua/src/ois/OIS.h
===================================================================
--- /code/branches/ceguilua/src/ois/OIS.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OIS.h	(revision 1801)
@@ -0,0 +1,40 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_OISALL_H
+#define OIS_OISALL_H
+
+#include "OISPrereqs.h"
+#include "OISObject.h"
+#include "OISMouse.h"
+#include "OISKeyboard.h"
+#include "OISJoyStick.h"
+#include "OISInputManager.h"
+#include "OISFactoryCreator.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include "OISEffect.h"
+#include "OISInterface.h"
+#include "OISForceFeedback.h"
+
+#endif
Index: /code/branches/ceguilua/src/ois/OISConfig.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISConfig.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISConfig.h	(revision 1801)
@@ -0,0 +1,77 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_CONFIG_HEADER
+#define OIS_CONFIG_HEADER
+
+//----------------------------------------------------------------------------//
+//* This file contains defines for building certain parts of this Lib
+//*	This file is not meant for External inclusion. However, you can edit this 
+//* file before a build to effect what features are used internally
+//----------------------------------------------------------------------------//
+
+/** 
+@remarks
+	These lines have no bearing on internal build of OIS. This is here for
+	external build settings. Meaning, changing this does not require a
+	rebuild of OIS. This just affects VC dll import settings, as the DLL
+	build already defines this during its build for setting dll exports.
+	The undefine here is here just incase you decide to only use
+	DLL, and want to set it permently and recompile OIS too.. Avoid redefinition
+	from DLL build of OIS.
+
+	So, if wanting to link against DLL version, just uncomment these lines.
+*/
+//#ifdef OIS_DYNAMIC_LIB
+//#  undef OIS_DYNAMIC_LIB
+//#endif
+//#define OIS_DYNAMIC_LIB
+
+/**
+@remarks
+	Build in support for LIRC / WinLIRC - remote control support.
+	Requires Boost::asio
+@notes
+	Experimental - Supports connecting and enumerating. Control does not
+	yet return state or events
+*/
+//#define OIS_LIRC_SUPPORT
+
+/**
+@remarks
+	Build in support for PC Nintendo WiiMote Win32 HID interface.
+	Requires Boost::threads
+@notes
+	Useable, but not quite finished - supports rumble, all buttons, & main orientation axis.
+	Still needs Nunchuck, IR, and LED/Battery support.
+*/
+//#define OIS_WIN32_WIIMOTE_SUPPORT
+
+/**
+@remarks
+	Build in support for Win32 XInput (Xbox 360 Controller)
+@notes
+	Not Yet Implemented
+*/
+//#define OIS_WIN32_XINPUT_SUPPORT
+
+#endif
Index: /code/branches/ceguilua/src/ois/OISEffect.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISEffect.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISEffect.cpp	(revision 1801)
@@ -0,0 +1,93 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISEffect.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//VC7.1 had a problem with these not getting included.. 
+//Perhaps a case of a crazy extreme optimizer :/ (moved to header)
+//const unsigned int Effect::OIS_INFINITE = 0xFFFFFFFF;
+
+//------------------------------------------------------------------------------//
+Effect::Effect() : 
+	force(UnknownForce), 
+	type(Unknown),
+	effect(0),
+	axes(1)
+{
+}
+
+//------------------------------------------------------------------------------//
+Effect::Effect(EForce ef, EType et) : 
+	force(ef), 
+	type(et),
+	direction(North), 
+	trigger_button(-1),
+	trigger_interval(0),
+	replay_length(Effect::OIS_INFINITE),
+	replay_delay(0),
+	_handle(-1),
+	axes(1)
+{
+	effect = 0;
+
+	switch( ef )
+	{
+	case ConstantForce:    effect = new ConstantEffect(); break;
+	case RampForce:	       effect = new RampEffect(); break;
+	case PeriodicForce:    effect = new PeriodicEffect(); break;
+	case ConditionalForce: effect = new ConditionalEffect(); break;
+	default: break;
+	}
+}
+
+//------------------------------------------------------------------------------//
+Effect::~Effect()
+{
+	delete effect;
+}
+
+//------------------------------------------------------------------------------//
+ForceEffect* Effect::getForceEffect() const
+{
+	//If no effect was created in constructor, then we raise an error here
+	if( effect == 0 )
+		OIS_EXCEPT( E_NotSupported, "Requested ForceEffect is null!" );
+
+	return effect;
+}
+
+//------------------------------------------------------------------------------//
+void Effect::setNumAxes(short nAxes)
+{
+	//Can only be set before a handle was assigned (effect created)
+	if( _handle != -1 )
+        axes = nAxes;
+}
+
+//------------------------------------------------------------------------------//
+short Effect::getNumAxes() const
+{
+	return axes;
+}
Index: /code/branches/ceguilua/src/ois/OISEffect.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISEffect.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISEffect.h	(revision 1801)
@@ -0,0 +1,260 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Effect_H
+#define OIS_Effect_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	//Predeclare some Effect Property structs
+	class ForceEffect;
+	class ConstantEffect;
+	class RampEffect;
+	class PeriodicEffect;
+	class ConditionalEffect;
+
+	/**
+		Force Feedback is a relatively complex set of properties to upload to a device.
+		The best place for information on the different properties, effects, etc is in
+		the DX Documentation and MSDN - there are even pretty graphs ther =)
+		As this class is modeled on the the DX interface you can apply that same
+		knowledge to creating effects via this class on any OS supported by OIS.
+
+		In anycase, this is the main class you will be using. There is *absolutely* no
+		need to instance any of the supporting ForceEffect classes yourself.
+	*/
+	class _OISExport Effect
+	{
+		/**
+			hidden so this class cannot be instanced with default constructor
+		*/
+		Effect();
+	public:
+		//! Type of force
+		enum EForce
+		{
+			UnknownForce = 0,
+			ConstantForce,
+			RampForce,
+			PeriodicForce,
+			ConditionalForce,
+			CustomForce
+		};
+
+		//! Type of effect
+		enum EType
+		{
+			//Type ----- Pairs with force:
+			Unknown = 0, //UnknownForce
+			Constant,    //ConstantForce
+			Ramp,        //RampForce
+			Square,      //PeriodicForce
+			Triangle,    //PeriodicForce
+            Sine,        //PeriodicForce
+			SawToothUp,  //PeriodicForce
+			SawToothDown,//PeriodicForce
+			Friction,    //ConditionalForce
+			Damper,      //ConditionalForce
+			Inertia,     //ConditionalForce
+			Spring,      //ConditionalForce
+			Custom       //CustomForce
+		};
+
+		//! Direction of the Force
+		enum EDirection
+		{
+			NorthWest,
+			North,
+			NorthEast,
+			East,
+			SouthEast,
+			South,
+			SouthWest,
+			West
+		};
+
+		/**
+			This constructor allows you to set the force type and effect.
+		*/
+		Effect(EForce ef, EType et);
+		virtual ~Effect();
+
+		const EForce force;
+		const EType type;
+
+		//Infinite Time
+		static const unsigned int OIS_INFINITE = 0xFFFFFFFF;
+
+		//-------------------------------------------------------------------//
+		//--- Set these variables before uploading or modifying an effect ---//
+
+		//Direction to apply to the force - affects two axes+ effects
+		EDirection direction;
+
+		//Number of button triggering an effect (-1 means no trigger)
+		short trigger_button;
+
+		//Time to wait before an effect can be re-triggered (microseconds)
+		unsigned int trigger_interval;
+
+		//Duration of an effect (microseconds)
+		unsigned int replay_length;
+
+		//Time to wait before to start playing an effect (microseconds)
+		unsigned int replay_delay;
+
+		//Get the specific Force Effect. This should be cast depending on the EForce
+		ForceEffect* getForceEffect() const;
+
+		/**
+		@remarks
+			Set the number of Axes to use before the initial creation of the effect.
+			Can only be done prior to creation! Use the FF interface to determine
+			how many axes can be used (are availiable)
+		*/
+		void setNumAxes(short nAxes);
+
+		/**
+		@remarks
+			Returns the number of axes used in this effect
+		*/
+		short getNumAxes() const;
+
+		//------------- Library Internal -------------------------------------//
+		/**
+			set internally.. do not change or you will not be able to upload/stop
+			this effect any more. It will become lost. It is mutable so even
+			with const reference it can/will be changed by this lib
+		*/
+		mutable int _handle;
+	protected:
+		ForceEffect* effect; //Properties depend on EForce
+		short axes;          //Number of axes to use in effect
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Base class of all effect property classes
+	*/
+	class _OISExport ForceEffect
+	{
+	public:
+		virtual ~ForceEffect() {}
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		An optional envelope to be applied to the start/end of an effect. If any of
+		these values are nonzero, then the envelope will be used in setting up the
+		effect. Not currently utilised.. But, will be soon.
+	*/
+	class _OISExport Envelope : public ForceEffect
+	{
+	public:
+		Envelope() : attackLength(0), attackLevel(0), fadeLength(0), fadeLevel(0) {}
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (push)
+  #pragma warning (disable : 4800)
+#endif
+		bool isUsed() { return attackLength | attackLevel | fadeLength | fadeLevel; }
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (pop)
+#endif
+
+		unsigned short attackLength;
+		unsigned short attackLevel;
+		unsigned short fadeLength;
+		unsigned short fadeLevel;
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Constant
+	*/
+	class _OISExport ConstantEffect : public ForceEffect
+	{
+	public:
+		ConstantEffect() : level(5000) {}
+
+		class Envelope envelope; //Optional envolope
+		signed short level;       //-10K to +10k
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Ramp
+	*/
+	class _OISExport RampEffect : public ForceEffect
+	{
+	public:
+		RampEffect() : startLevel(0), endLevel(0) {}
+
+        class Envelope envelope; //Optional envolope
+		signed short startLevel;  //-10K to +10k
+		signed short endLevel;    //-10K to +10k
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Periodic
+	*/
+	class _OISExport PeriodicEffect : public ForceEffect
+	{
+	public:
+		PeriodicEffect() : magnitude(0), offset(0), phase(0), period(0) {}
+
+		class Envelope envelope;  //Optional Envelope
+
+		unsigned short magnitude;  //0 to 10,0000
+		signed short   offset;
+		unsigned short phase;      //Position at which playback begins 0 to 35,999
+		unsigned int   period;     //Period of effect (microseconds)
+	};
+
+	//-----------------------------------------------------------------------------//
+	/**
+		Use this class when dealing with Force type of Condional
+	*/
+	class _OISExport ConditionalEffect : public ForceEffect
+	{
+	public:
+		ConditionalEffect() :
+            rightCoeff(0), leftCoeff(0), rightSaturation(0), leftSaturation(0),
+			deadband(0), center(0) {}
+
+		signed short   rightCoeff;      //-10k to +10k (Positive Coeff)
+		signed short   leftCoeff;       //-10k to +10k (Negative Coeff)
+
+		unsigned short rightSaturation; //0 to 10k (Pos Saturation)
+		unsigned short leftSaturation;  //0 to 10k (Neg Saturation)
+
+		//Region around center in which the condition is not active, in the range
+		//from 0 through 10,000
+		unsigned short deadband;
+
+		//(Offset in DX) -10k and 10k
+		signed short center;
+	};
+}
+#endif //OIS_Effect_H
Index: /code/branches/ceguilua/src/ois/OISEvents.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISEvents.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISEvents.h	(revision 1801)
@@ -0,0 +1,43 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _OIS_EVENTHEADERS_
+#define _OIS_EVENTHEADERS_
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	/**
+		Base class of all events
+	*/
+	class _OISExport EventArg
+	{
+	public:
+		EventArg( Object* obj ) : device(obj) {}
+		virtual ~EventArg() {}
+
+		//! Pointer to the Input Device
+		const Object* device;
+	};
+}
+
+#endif //_OIS_EVENTHEADERS_
Index: /code/branches/ceguilua/src/ois/OISException.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISException.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISException.cpp	(revision 1801)
@@ -0,0 +1,32 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISException.h"
+
+using namespace OIS;
+
+//----------------------------------------------------------------------------//
+/*const char* Exception::what() const throw()
+{
+	return eText;
+}
+*/
Index: /code/branches/ceguilua/src/ois/OISException.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISException.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISException.h	(revision 1801)
@@ -0,0 +1,77 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _OIS_EXCEPTION_HEADER_
+#define _OIS_EXCEPTION_HEADER_
+#include "OISPrereqs.h"
+#include <exception>
+
+namespace OIS
+{
+	//! Simple enum's for dealing with exceptions
+    enum OIS_ERROR
+	{
+		E_InputDisconnected,
+		E_InputDeviceNonExistant,
+		E_InputDeviceNotSupported,
+		E_DeviceFull,
+		E_NotSupported,
+		E_NotImplemented,
+		E_Duplicate,
+		E_InvalidParam,
+		E_General
+	};
+
+	/**
+	@remarks
+		Class for handling OIS exceptions. Much cleaner than checking every method for reurn value.
+		Inherits from std::exception so you can simply log those messages if you want to be generic.
+		Also note that this has a source file now since OSX was not finding the OIS::Exception symbol
+		which would cause program abortion with now correponding exception type.
+	*/
+	class _OISExport Exception : public std::exception
+	{
+		//! Hidden default
+		Exception() : eType(E_General), eLine(0), eFile(0) {}
+	public:
+		//! Creates exception object
+		Exception( OIS_ERROR err, const char* str, int line, const char *file )
+			: eType(err), eLine(line), eFile(file), eText(str) {}
+
+		virtual const char* what() const throw()
+            { return eText; }
+
+		//! The type of exception raised
+		const OIS_ERROR eType;
+		//! The line number it occurred on
+		const int eLine;
+		//! The source file
+		const char* eFile;
+		//! A message passed along when the exception was raised
+		const char* eText;
+	};
+}
+
+//! Use this macro to handle exceptions easily
+#define OIS_EXCEPT( err, str ) throw( OIS::Exception(err, str, __LINE__, __FILE__) )
+
+#endif //_OIS_EXCEPTION_HEADER_
Index: /code/branches/ceguilua/src/ois/OISFactoryCreator.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISFactoryCreator.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISFactoryCreator.h	(revision 1801)
@@ -0,0 +1,81 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_FactoryCreator_H
+#define OIS_FactoryCreator_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	/**
+		Interface for creating devices - all devices ultimately get enumerated/created via a factory.
+		A factory can create multiple types of objects.
+	*/
+	class _OISExport FactoryCreator
+	{
+	public:
+		/**
+			@remarks Virtual Destructor
+		*/
+		virtual ~FactoryCreator() {};
+
+		/**
+			@remarks Return a list of all unused devices the factory maintains
+		*/
+		virtual DeviceList freeDeviceList() = 0;
+
+		/**
+			@remarks Number of total devices of requested type
+			@param iType Type of devices to check
+		*/
+		virtual int totalDevices(Type iType) = 0;
+
+		/**
+			@remarks Number of free devices of requested type
+			@param iType Type of devices to check
+		*/
+		virtual int freeDevices(Type iType) = 0;
+
+		/**
+			@remarks Does a Type exist with the given vendor name
+			@param iType Type to check
+			@param vendor Vendor name to test
+		*/
+		virtual bool vendorExist(Type iType, const std::string & vendor) = 0;
+
+		/**
+			@remarks Creates the object
+			@param iType Type to create
+			@param bufferMode True to setup for buffered events
+			@param vendor Create a device with the vendor name, "" means vendor name is unimportant
+		*/
+		virtual Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "") = 0;
+
+		/**
+			@remarks Destroys object
+			@param obj Object to destroy
+		*/
+		virtual void destroyObject(Object* obj) = 0;
+	};
+}
+#endif //OIS_FactoryCreator_H
Index: /code/branches/ceguilua/src/ois/OISForceFeedback.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISForceFeedback.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISForceFeedback.cpp	(revision 1801)
@@ -0,0 +1,42 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISForceFeedback.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//-------------------------------------------------------------//
+void ForceFeedback::_addEffectTypes( Effect::EForce force, Effect::EType type )
+{
+	if( force == Effect::UnknownForce || type == Effect::Unknown )
+		OIS_EXCEPT( E_General, "Unknown Force||Type was added too effect list..." );
+
+	mSupportedEffects[force] = type;
+}
+
+//-------------------------------------------------------------//
+const ForceFeedback::SupportedEffectList& 
+						ForceFeedback::getSupportedEffects() const
+{
+	return mSupportedEffects;
+}
Index: /code/branches/ceguilua/src/ois/OISForceFeedback.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISForceFeedback.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISForceFeedback.h	(revision 1801)
@@ -0,0 +1,102 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_ForceFeedBack_H
+#define OIS_ForceFeedBack_H
+
+#include "OISPrereqs.h"
+#include "OISInterface.h"
+#include "OISEffect.h"
+
+namespace OIS
+{
+	/**
+		Interface class for dealing with Force Feedback devices
+	*/
+	class _OISExport ForceFeedback : public Interface
+	{
+	public:
+		ForceFeedback() {}
+		virtual ~ForceFeedback() {}
+
+		/**
+		@remarks
+			This is like setting the master volume of an audio device.
+			Individual effects have gain levels; however, this affects all
+			effects at once.
+		@param level
+			A value between 0.0 and 1.0 represent the percentage of gain. 1.0
+			being the highest possible force level (means no scaling).
+		*/
+		virtual void setMasterGain( float level ) = 0;
+		
+		/**
+		@remarks
+			If using Force Feedback effects, this should be turned off
+			before uploading any effects. Auto centering is the motor moving
+			the joystick back to center. DirectInput only has an on/off setting,
+			whereas linux has levels.. Though, we go with DI's on/off mode only
+		@param auto_on
+			true to turn auto centering on, false to turn off.
+		*/
+		virtual void setAutoCenterMode( bool auto_on ) = 0;
+
+		/**
+		@remarks
+			Creates and Plays the effect immediately. If the device is full
+			of effects, it will fail to be uploaded. You will know this by
+			an invalid Effect Handle
+		*/
+		virtual void upload( const Effect* effect ) = 0;
+
+		/**
+		@remarks
+			Modifies an effect that is currently playing
+		*/
+		virtual void modify( const Effect* effect ) = 0;
+
+		/**
+		@remarks
+			Remove the effect from the device
+		*/
+		virtual void remove( const Effect* effect ) = 0;
+
+		/**
+		@remarks
+			Get the number of supported Axes for FF usage
+		*/
+        virtual short getFFAxesNumber() = 0;
+
+		typedef std::map<Effect::EForce, Effect::EType> SupportedEffectList;
+		/**
+		@remarks
+			Get a list of all supported effects
+		*/
+		const SupportedEffectList& getSupportedEffects() const;
+
+		void _addEffectTypes( Effect::EForce force, Effect::EType type );
+
+	protected:
+		SupportedEffectList mSupportedEffects;
+	};
+}
+#endif //OIS_ForceFeedBack_H
Index: /code/branches/ceguilua/src/ois/OISInputManager.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISInputManager.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISInputManager.cpp	(revision 1801)
@@ -0,0 +1,284 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISInputManager.h"
+#include "OISException.h"
+#include "OISFactoryCreator.h"
+#include "OISObject.h"
+#include <sstream>
+#include <algorithm>
+
+//Bring in correct Header / InputManager for current build platform
+#if defined OIS_SDL_PLATFORM
+#  include "SDL/SDLInputManager.h"
+#elif defined OIS_WIN32_PLATFORM
+#  include "win32/Win32InputManager.h"
+#elif defined OIS_LINUX_PLATFORM
+#  include "linux/LinuxInputManager.h"
+#elif defined OIS_APPLE_PLATFORM
+#  include "mac/MacInputManager.h"
+#elif defined OIS_XBOX_PLATFORM
+#  include "xbox/XBoxInputManager.h"
+#endif
+
+//Bring in extra controls
+#if defined OIS_LIRC_SUPPORT
+#  include "extras/LIRC/OISLIRCFactoryCreator.h"
+#endif
+#if defined OIS_WIN32_WIIMOTE_SUPPORT
+#  include "win32/extras/WiiMote/OISWiiMoteFactoryCreator.h"
+#endif
+
+
+using namespace OIS;
+
+//----------------------------------------------------------------------------//
+InputManager::InputManager(const std::string& name) :
+	m_VersionName(OIS_VERSION_NAME),
+	mInputSystemName(name),
+	m_lircSupport(0),
+	m_wiiMoteSupport(0)
+{
+}
+
+//----------------------------------------------------------------------------//
+InputManager::~InputManager()
+{
+#if defined OIS_LIRC_SUPPORT
+	delete m_lircSupport;
+#endif
+
+#if defined OIS_WIN32_WIIMOTE_SUPPORT
+	delete m_wiiMoteSupport;
+#endif
+}
+
+//----------------------------------------------------------------------------//
+unsigned int InputManager::getVersionNumber()
+{
+	return OIS_VERSION;
+}
+
+//----------------------------------------------------------------------------//
+const std::string &InputManager::getVersionName()
+{
+	return m_VersionName;
+}
+
+//----------------------------------------------------------------------------//
+InputManager* InputManager::createInputSystem( std::size_t windowhandle )
+{
+	ParamList pl;
+	std::ostringstream wnd;
+	wnd << windowhandle;
+	pl.insert(std::make_pair( std::string("WINDOW"), wnd.str() ));
+
+	return createInputSystem( pl );
+}
+
+//----------------------------------------------------------------------------//
+InputManager* InputManager::createInputSystem( ParamList &paramList )
+{
+	InputManager* im = 0;
+
+#if defined OIS_SDL_PLATFORM
+	im = new SDLInputManager();
+#elif defined OIS_WIN32_PLATFORM
+	im = new Win32InputManager();
+#elif defined OIS_XBOX_PLATFORM
+	im = new XBoxInputManager();
+#elif defined OIS_LINUX_PLATFORM
+	im = new LinuxInputManager();
+#elif defined OIS_APPLE_PLATFORM
+	im = new MacInputManager();
+#else
+	OIS_EXCEPT(E_General, "No platform library.. check build platform defines!");
+#endif 
+
+	try
+	{
+		im->_initialize(paramList);
+	}
+	catch(...)
+	{
+		delete im;
+		throw; //rethrow
+	}
+
+	return im;
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::destroyInputSystem(InputManager* manager)
+{
+	if( manager == 0 )
+		return;
+
+	//Cleanup before deleting...
+	for( FactoryCreatedObject::iterator i = manager->mFactoryObjects.begin(); 
+		i != manager->mFactoryObjects.end(); ++i )
+	{
+		i->second->destroyObject( i->first );
+	}
+
+	manager->mFactoryObjects.clear();
+	delete manager;
+}
+
+//--------------------------------------------------------------------------------//
+const std::string& InputManager::inputSystemName()
+{
+	return mInputSystemName;
+}
+
+//--------------------------------------------------------------------------------//
+int InputManager::getNumberOfDevices( Type iType )
+{
+	//Count up all the factories devices
+	int factoyObjects = 0;
+	FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
+	for( ; i != e; ++i )
+		factoyObjects += (*i)->totalDevices(iType);
+
+	return factoyObjects;
+}
+
+//----------------------------------------------------------------------------//
+DeviceList InputManager::listFreeDevices()
+{
+	DeviceList list;
+	FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
+	for( ; i != e; ++i )
+	{
+		DeviceList temp = (*i)->freeDeviceList();
+		list.insert(temp.begin(), temp.end());
+	}
+
+	return list;
+}
+
+//----------------------------------------------------------------------------//
+Object* InputManager::createInputObject( Type iType, bool bufferMode, const std::string &vendor )
+{
+	Object* obj = 0;
+	FactoryList::iterator i = mFactories.begin(), e = mFactories.end();
+	for( ; i != e; ++i)
+	{
+		if( (*i)->freeDevices(iType) > 0 )
+		{
+			if( vendor == "" || (*i)->vendorExist(iType, vendor) )
+			{
+				obj = (*i)->createObject(this, iType, bufferMode, vendor);
+				mFactoryObjects[obj] = (*i);
+				break;
+			}
+		}
+	}
+
+	if(!obj)
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	try
+	{	//Intialize device
+		obj->_initialize();
+	}
+	catch(...)
+	{	//Somekind of error, cleanup and rethrow
+		destroyInputObject(obj);
+		throw;
+	}
+
+	return obj;
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::destroyInputObject( Object* obj )
+{
+	if( obj == 0 )
+		return;
+
+	FactoryCreatedObject::iterator i = mFactoryObjects.find(obj);
+	if( i != mFactoryObjects.end() )
+	{
+		i->second->destroyObject(obj);
+		mFactoryObjects.erase(i);
+	}
+	else
+	{
+		OIS_EXCEPT(E_General, "Object creator not known.");
+	}
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::addFactoryCreator( FactoryCreator* factory )
+{
+	if(factory != 0)
+		mFactories.push_back(factory);
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::removeFactoryCreator( FactoryCreator* factory )
+{
+	if(factory != 0)
+	{
+		//First, destroy all devices created with the factory
+		for( FactoryCreatedObject::iterator i = mFactoryObjects.begin(); i != mFactoryObjects.end(); ++i )
+		{
+			if( i->second == factory )
+			{
+				i->second->destroyObject(i->first);
+				mFactoryObjects.erase(i++);
+			}
+		}
+
+		//Now, remove the factory itself
+		FactoryList::iterator fact = std::find(mFactories.begin(), mFactories.end(), factory);
+		if( fact != mFactories.end() )
+			mFactories.erase(fact);
+	}
+}
+
+//----------------------------------------------------------------------------//
+void InputManager::enableAddOnFactory(AddOnFactories factory)
+{
+#if defined OIS_LIRC_SUPPORT
+	if( factory == AddOn_LIRC || factory == AddOn_All )
+	{
+		if( m_lircSupport == 0 )
+		{
+			m_lircSupport = new LIRCFactoryCreator();
+			addFactoryCreator(m_lircSupport);
+		}
+	}
+#endif
+
+#if defined OIS_WIN32_WIIMOTE_SUPPORT
+	if( factory == AddOn_WiiMote || factory == AddOn_All )
+	{
+		if( m_wiiMoteSupport == 0 )
+		{
+			m_wiiMoteSupport = new WiiMoteFactoryCreator();
+			addFactoryCreator(m_wiiMoteSupport);
+		}
+	}
+#endif
+}
Index: /code/branches/ceguilua/src/ois/OISInputManager.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISInputManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISInputManager.h	(revision 1801)
@@ -0,0 +1,205 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_InputManager_H
+#define OIS_InputManager_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	//Forward declare a couple of classes we might use later
+	class LIRCFactoryCreator;
+	class WiiMoteFactoryCreator;
+
+	/**
+		Base Manager class. No longer a Singleton; so feel free to create as many InputManager's as you have
+		windows.
+	*/
+	class _OISExport InputManager
+	{
+	public:
+		/**
+		@remarks
+			Returns version number (useful in DLL/SO libs)
+		@returns
+			Bits: 1-8 Patch number, 9-16 Minor version, 17-32 Major version
+		*/
+		static unsigned int getVersionNumber();
+
+		/**
+		@remarks
+			Returns version string (useful in DLL/SO libs)
+		@returns
+			Version name
+		*/
+		const std::string &getVersionName();
+
+		/**
+		@remarks
+			Creates appropriate input system dependent on platform. 
+		@param winHandle
+			Contains OS specific window handle (such as HWND or X11 Window)
+		@returns
+			A pointer to the created manager, or raises Exception
+		*/
+		static InputManager* createInputSystem( std::size_t winHandle );
+
+		/**
+		@remarks
+			Creates appropriate input system dependent on platform. 
+		@param paramList
+			ParamList contains OS specific info (such as HWND and HINSTANCE for window apps),
+			and access mode.
+		@returns
+			A pointer to the created manager, or raises Exception
+		*/
+		static InputManager* createInputSystem( ParamList &paramList );
+
+		/**
+		@remarks
+			Destroys the InputManager
+		@param manager
+			Manager to destroy
+		*/
+		static void destroyInputSystem(InputManager* manager);
+
+		/**
+		@remarks Gets the name of the current platform input system
+		*/
+		const std::string& inputSystemName();
+
+		/**
+		@remarks
+			Returns the number of the specified OIS::Type devices discovered by OIS
+		@param iType
+			Type that you are interested in
+		*/
+		int getNumberOfDevices( Type iType );
+
+		/**
+		@remarks
+			Lists all unused devices
+		@returns
+			DeviceList which contains Type and vendor of device
+		*/
+		DeviceList listFreeDevices();
+
+		/**
+		@remarks
+			Tries to create an object with the specified vendor. If you have no
+			preference of vendor, leave vender as default (""). Raises exception on failure
+		*/
+		Object* createInputObject( Type iType, bool bufferMode, const std::string &vendor = "");
+
+		/**
+		@remarks Destroys Input Object
+		*/
+		void destroyInputObject( Object* obj );
+
+		/**
+		@remarks
+			Add a custom object factory to allow for user controls.
+		@param factory
+			Factory instance to add
+		@notes
+			Make sure you do not delete the factory before devices created from
+			the factory are destroyed (either by calling RemoveFactoryCreator, or shutting down
+			the input system). Order should be something like the following:
+				* Create Input System
+				* Create Factory Instance
+				* AddFactoryCreator(factory)
+				* Create a device from the InputManager (device created by factory)
+				* One of the follwoing:
+					* removeFactoryCreator(factory)
+					* inputManager->destroyInputObject(obj)
+				* destroyInputSystem(inputManager)
+				* destroy Factory Instance
+			You can safely delete the factory instance once you have removed it or shut down the
+			input manager.
+		*/
+		void addFactoryCreator( FactoryCreator* factory );
+
+		/**
+		@remarks
+			Remove a previously added object factory
+		@param factory
+			Factory object to remove.
+		@notes
+			Removing a factory will automatically destroy any Objects created from the factory
+		*/
+		void removeFactoryCreator( FactoryCreator* factory );
+
+		//! All generic devices OIS supports internally (if they are compiled in)
+		enum AddOnFactories
+		{
+			AddOn_All = 0,		//All Devices
+			AddOn_LIRC = 1,		//PC Linux Infrared Remote Control
+			AddOn_WiiMote = 2	//PC WiiMote Support
+		};
+
+		/**
+		@remarks
+			Enable an addon FactoryCreator extension. By default, none are activated.
+			If the desired support was not compiled in, this has no effect. Calling
+			multiple times has no effect. Once activated, there is no way to deactivate -
+			simply destroy and recreate input manager.
+		*/
+		void enableAddOnFactory(AddOnFactories factory);
+
+	protected:
+		/**
+		@remarks
+			Called from createInputSystem, gives derived input class a chance to setup after it is created
+		*/
+		virtual void _initialize(ParamList &paramList) = 0;
+
+		/**
+		@remarks
+			Derived classes must provide input system name
+		*/
+		InputManager(const std::string& name);
+
+		/**
+		@remarks
+			Virtual Destructor - this base class will clean up all devices still opened in mFactoryObjects list
+		*/
+		virtual ~InputManager();
+
+		//! OIS Version name
+		const std::string m_VersionName;
+
+		//! FactoryCreator list	
+		FactoryList mFactories;
+
+		//! Factory created objects - useful so we can find creator to send destruction request to
+		FactoryCreatedObject mFactoryObjects;
+
+		//! Name of the input system
+		const std::string mInputSystemName;
+
+		//! Extra factory (not enabled by default)
+		LIRCFactoryCreator *m_lircSupport;
+		WiiMoteFactoryCreator *m_wiiMoteSupport;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/OISInterface.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISInterface.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISInterface.h	(revision 1801)
@@ -0,0 +1,47 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Interface_H
+#define OIS_Interface_H
+
+#include "OISPrereqs.h"
+
+namespace OIS
+{
+	/**
+		An Object's interface is a way to gain write access to devices which support
+		it. For example, force feedack.
+	*/
+	class _OISExport Interface
+	{
+	public:
+		virtual ~Interface() {};
+
+		//! Type of Interface
+		enum IType
+		{
+			ForceFeedback,
+			Reserved
+		};
+	};
+}
+#endif //OIS_Interface_H
Index: /code/branches/ceguilua/src/ois/OISJoyStick.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISJoyStick.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISJoyStick.cpp	(revision 1801)
@@ -0,0 +1,73 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISJoyStick.h"
+
+using namespace OIS;
+
+//----------------------------------------------------------------------------//
+JoyStick::JoyStick(const std::string &vendor, bool buffered, int devID, InputManager* creator) :
+	Object(vendor, OISJoyStick, buffered, devID, creator),
+	mSliders(0),
+	mPOVs(0),
+	mListener(0),
+	mVector3Sensitivity(OIS_JOYSTICK_VECTOR3_DEFAULT)
+{
+}
+
+//----------------------------------------------------------------------------//
+int JoyStick::getNumberOfComponents(ComponentType cType) const
+{
+	switch( cType )
+	{
+	case OIS_Button:	return (int)mState.mButtons.size();
+	case OIS_Axis:		return (int)mState.mAxes.size();
+	case OIS_Slider:	return mSliders;
+	case OIS_POV:		return mPOVs;
+	case OIS_Vector3:	return (int)mState.mVectors.size();
+	default:			return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+void JoyStick::setVector3Sensitivity(float degrees)
+{
+	mVector3Sensitivity = degrees;
+}
+
+//----------------------------------------------------------------------------//
+float JoyStick::getVector3Sensitivity() const
+{
+	return mVector3Sensitivity;
+}
+
+//----------------------------------------------------------------------------//
+void JoyStick::setEventCallback( JoyStickListener *joyListener )
+{
+	mListener = joyListener;
+}
+
+//----------------------------------------------------------------------------//
+JoyStickListener* JoyStick::getEventCallback() const
+{
+	return mListener;
+}
Index: /code/branches/ceguilua/src/ois/OISJoyStick.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISJoyStick.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISJoyStick.h	(revision 1801)
@@ -0,0 +1,228 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Joystick_H
+#define OIS_Joystick_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+namespace OIS
+{
+	/** @remarks default sensitivity for vector3 component of joystick */
+	#define OIS_JOYSTICK_VECTOR3_DEFAULT 2.28f
+
+	//! POV / HAT Joystick component
+	class _OISExport Pov : Component
+	{
+	public:
+		Pov() : Component(OIS_POV), direction(0) {}
+
+		static const int Centered  = 0x00000000;
+		static const int North     = 0x00000001;
+		static const int South     = 0x00000010;
+		static const int East      = 0x00000100;
+		static const int West      = 0x00001000;
+		static const int NorthEast = 0x00000101;
+		static const int SouthEast = 0x00000110;
+		static const int NorthWest = 0x00001001;
+		static const int SouthWest = 0x00001010;
+
+		int direction;
+	};
+
+	//! A sliding axis - only used in Win32 Right Now
+	class _OISExport Slider : Component
+	{
+	public:
+		Slider() : Component(OIS_Slider), abX(0), abY(0) {};
+		//! true if pushed, false otherwise
+		int abX, abY;
+	};
+
+	/**
+		Represents the state of the joystick
+		All members are valid for both buffered and non buffered mode
+		Sticks with zero values are not present on the device
+	*/
+	class _OISExport JoyStickState
+	{
+	public:
+		//! Constructor
+		JoyStickState() { clear(); }
+
+		//! Represents all the buttons (uses a bitset)
+		std::vector<bool> mButtons;
+
+		//! Represents all the single axes on the device
+		std::vector<Axis> mAxes;
+
+		//! Represents the value of a POV. Maximum of 4
+		Pov mPOV[4];
+
+		//! Represent the max sliders
+		Slider mSliders[4];
+
+		//! Represents all Vector type controls the device exports
+		std::vector<Vector3> mVectors;
+
+		//! internal method to reset all variables to initial values
+		void clear()
+		{
+			for( std::vector<bool>::iterator i = mButtons.begin(), e = mButtons.end(); i != e; ++i )
+			{
+				(*i) = false;
+			}
+
+			for( std::vector<Axis>::iterator i = mAxes.begin(), e = mAxes.end(); i != e; ++i )
+			{
+				i->absOnly = true; //Currently, joysticks only report Absolute values
+				i->clear();
+			}
+
+			for( std::vector<Vector3>::iterator i = mVectors.begin(), e = mVectors.end(); i != e; ++i )
+			{
+				i->clear();
+			}
+
+			for( int i = 0; i < 4; ++i )
+			{
+				mPOV[i].direction = Pov::Centered;
+				mSliders[i].abX = mSliders[i].abY = 0;
+			}
+		}
+	};
+
+	/** Specialised for joystick events */
+	class _OISExport JoyStickEvent : public EventArg
+	{
+	public:
+		JoyStickEvent( Object* obj, const JoyStickState &st ) : EventArg(obj), state(st) {}
+		virtual ~JoyStickEvent() {}
+
+		const JoyStickState &state;
+	};
+
+	/**
+		To recieve buffered joystick input, derive a class from this, and implement the
+		methods here. Then set the call back to your JoyStick instance with JoyStick::setEventCallback
+		Each JoyStick instance can use the same callback class, as a devID number will be provided
+		to differentiate between connected joysticks. Of course, each can have a seperate
+		callback instead.
+	*/
+	class _OISExport JoyStickListener
+	{
+	public:
+		virtual ~JoyStickListener() {}
+		/** @remarks Joystick button down event */
+		virtual bool buttonPressed( const JoyStickEvent &arg, int button ) = 0;
+		
+		/** @remarks Joystick button up event */
+		virtual bool buttonReleased( const JoyStickEvent &arg, int button ) = 0;
+
+		/** @remarks Joystick axis moved event */
+		virtual bool axisMoved( const JoyStickEvent &arg, int axis ) = 0;
+
+		//-- Not so common control events, so are not required --//
+		//! Joystick Event, and sliderID
+		virtual bool sliderMoved( const JoyStickEvent &, int index) {return true;}
+		
+		//! Joystick Event, and povID
+		virtual bool povMoved( const JoyStickEvent &arg, int index) {return true;}
+
+		//! Joystick Event, and Vector3ID
+		virtual bool vector3Moved( const JoyStickEvent &arg, int index) {return true;}
+	};
+
+	/**
+		Joystick base class. To be implemented by specific system (ie. DirectX joystick)
+		This class is useful as you remain OS independent using this common interface.
+	*/
+	class _OISExport JoyStick : public Object
+	{
+	public:
+		virtual ~JoyStick() {}
+
+		/**
+		@remarks
+			Returns the number of requested components
+		@param cType
+			The ComponentType you are interested in knowing about
+		*/
+		int getNumberOfComponents(ComponentType cType) const;
+
+		/**
+		@remarks
+			Sets a cutoff limit for changes in the Vector3 component for movement to 
+			be ignored. Helps reduce much event traffic for frequent small/sensitive
+			changes
+		@param degrees
+			The degree under which Vector3 events should be discarded
+		*/
+		void setVector3Sensitivity(float degrees = OIS_JOYSTICK_VECTOR3_DEFAULT);
+
+		/**
+		@remarks
+			Returns the sensitivity cutoff for Vector3 Component
+		*/
+		float getVector3Sensitivity() const;
+
+		/**
+		@remarks
+			Register/unregister a JoyStick Listener - Only one allowed for simplicity. If broadcasting
+			is neccessary, just broadcast from the callback you registered.
+		@param joyListener
+			Send a pointer to a class derived from JoyStickListener or 0 to clear the callback
+		*/
+		virtual void setEventCallback( JoyStickListener *joyListener );
+
+		/** @remarks Returns currently set callback.. or null */
+		JoyStickListener* getEventCallback() const;
+
+		/** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */
+		const JoyStickState& getJoyStickState() const { return mState; }
+
+		//! The minimal axis value
+		static const int MIN_AXIS = -32768;
+
+		//! The maximum axis value
+		static const int MAX_AXIS = 32767;
+
+	protected:
+		JoyStick(const std::string &vendor, bool buffered, int devID, InputManager* creator);
+
+		//! Number of sliders
+		int mSliders;
+
+		//! Number of POVs
+		int mPOVs;
+
+		//! The JoyStickState structure (contains all component values)
+		JoyStickState mState;
+
+		//! The callback listener
+		JoyStickListener *mListener;
+
+		//! Adjustment factor for orientation vector accuracy
+		float mVector3Sensitivity;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/OISKeyboard.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISKeyboard.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISKeyboard.cpp	(revision 1801)
@@ -0,0 +1,45 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISKeyboard.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//----------------------------------------------------------------------//
+void Keyboard::setTextTranslation( TextTranslationMode mode )
+{
+	mTextMode = mode;
+}
+
+//----------------------------------------------------------------------//
+bool Keyboard::isModifierDown( Modifier mod ) const
+{
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (push)
+  #pragma warning (disable : 4800)
+#endif
+	return (mModifiers & mod);
+#if defined(OIS_MSVC_COMPILER)
+  #pragma warning (pop)
+#endif
+}
Index: /code/branches/ceguilua/src/ois/OISKeyboard.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISKeyboard.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISKeyboard.h	(revision 1801)
@@ -0,0 +1,312 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Keyboard_H
+#define OIS_Keyboard_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+namespace OIS
+{
+	//! Keyboard scan codes
+	enum KeyCode
+	{
+		KC_UNASSIGNED  = 0x00,
+		KC_ESCAPE      = 0x01,
+		KC_1           = 0x02,
+		KC_2           = 0x03,
+		KC_3           = 0x04,
+		KC_4           = 0x05,
+		KC_5           = 0x06,
+		KC_6           = 0x07,
+		KC_7           = 0x08,
+		KC_8           = 0x09,
+		KC_9           = 0x0A,
+		KC_0           = 0x0B,
+		KC_MINUS       = 0x0C,    // - on main keyboard
+		KC_EQUALS      = 0x0D,
+		KC_BACK        = 0x0E,    // backspace
+		KC_TAB         = 0x0F,
+		KC_Q           = 0x10,
+		KC_W           = 0x11,
+		KC_E           = 0x12,
+		KC_R           = 0x13,
+		KC_T           = 0x14,
+		KC_Y           = 0x15,
+		KC_U           = 0x16,
+		KC_I           = 0x17,
+		KC_O           = 0x18,
+		KC_P           = 0x19,
+		KC_LBRACKET    = 0x1A,
+		KC_RBRACKET    = 0x1B,
+		KC_RETURN      = 0x1C,    // Enter on main keyboard
+		KC_LCONTROL    = 0x1D,
+		KC_A           = 0x1E,
+		KC_S           = 0x1F,
+		KC_D           = 0x20,
+		KC_F           = 0x21,
+		KC_G           = 0x22,
+		KC_H           = 0x23,
+		KC_J           = 0x24,
+		KC_K           = 0x25,
+		KC_L           = 0x26,
+		KC_SEMICOLON   = 0x27,
+		KC_APOSTROPHE  = 0x28,
+		KC_GRAVE       = 0x29,    // accent
+		KC_LSHIFT      = 0x2A,
+		KC_BACKSLASH   = 0x2B,
+		KC_Z           = 0x2C,
+		KC_X           = 0x2D,
+		KC_C           = 0x2E,
+		KC_V           = 0x2F,
+		KC_B           = 0x30,
+		KC_N           = 0x31,
+		KC_M           = 0x32,
+		KC_COMMA       = 0x33,
+		KC_PERIOD      = 0x34,    // . on main keyboard
+		KC_SLASH       = 0x35,    // / on main keyboard
+		KC_RSHIFT      = 0x36,
+		KC_MULTIPLY    = 0x37,    // * on numeric keypad
+		KC_LMENU       = 0x38,    // left Alt
+		KC_SPACE       = 0x39,
+		KC_CAPITAL     = 0x3A,
+		KC_F1          = 0x3B,
+		KC_F2          = 0x3C,
+		KC_F3          = 0x3D,
+		KC_F4          = 0x3E,
+		KC_F5          = 0x3F,
+		KC_F6          = 0x40,
+		KC_F7          = 0x41,
+		KC_F8          = 0x42,
+		KC_F9          = 0x43,
+		KC_F10         = 0x44,
+		KC_NUMLOCK     = 0x45,
+		KC_SCROLL      = 0x46,    // Scroll Lock
+		KC_NUMPAD7     = 0x47,
+		KC_NUMPAD8     = 0x48,
+		KC_NUMPAD9     = 0x49,
+		KC_SUBTRACT    = 0x4A,    // - on numeric keypad
+		KC_NUMPAD4     = 0x4B,
+		KC_NUMPAD5     = 0x4C,
+		KC_NUMPAD6     = 0x4D,
+		KC_ADD         = 0x4E,    // + on numeric keypad
+		KC_NUMPAD1     = 0x4F,
+		KC_NUMPAD2     = 0x50,
+		KC_NUMPAD3     = 0x51,
+		KC_NUMPAD0     = 0x52,
+		KC_DECIMAL     = 0x53,    // . on numeric keypad
+		KC_OEM_102     = 0x56,    // < > | on UK/Germany keyboards
+		KC_F11         = 0x57,
+		KC_F12         = 0x58,
+		KC_F13         = 0x64,    //                     (NEC PC98)
+		KC_F14         = 0x65,    //                     (NEC PC98)
+		KC_F15         = 0x66,    //                     (NEC PC98)
+		KC_KANA        = 0x70,    // (Japanese keyboard)
+		KC_ABNT_C1     = 0x73,    // / ? on Portugese (Brazilian) keyboards
+		KC_CONVERT     = 0x79,    // (Japanese keyboard)
+		KC_NOCONVERT   = 0x7B,    // (Japanese keyboard)
+		KC_YEN         = 0x7D,    // (Japanese keyboard)
+		KC_ABNT_C2     = 0x7E,    // Numpad . on Portugese (Brazilian) keyboards
+		KC_NUMPADEQUALS= 0x8D,    // = on numeric keypad (NEC PC98)
+		KC_PREVTRACK   = 0x90,    // Previous Track (KC_CIRCUMFLEX on Japanese keyboard)
+		KC_AT          = 0x91,    //                     (NEC PC98)
+		KC_COLON       = 0x92,    //                     (NEC PC98)
+		KC_UNDERLINE   = 0x93,    //                     (NEC PC98)
+		KC_KANJI       = 0x94,    // (Japanese keyboard)
+		KC_STOP        = 0x95,    //                     (NEC PC98)
+		KC_AX          = 0x96,    //                     (Japan AX)
+		KC_UNLABELED   = 0x97,    //                        (J3100)
+		KC_NEXTTRACK   = 0x99,    // Next Track
+		KC_NUMPADENTER = 0x9C,    // Enter on numeric keypad
+		KC_RCONTROL    = 0x9D,
+		KC_MUTE        = 0xA0,    // Mute
+		KC_CALCULATOR  = 0xA1,    // Calculator
+		KC_PLAYPAUSE   = 0xA2,    // Play / Pause
+		KC_MEDIASTOP   = 0xA4,    // Media Stop
+		KC_VOLUMEDOWN  = 0xAE,    // Volume -
+		KC_VOLUMEUP    = 0xB0,    // Volume +
+		KC_WEBHOME     = 0xB2,    // Web home
+		KC_NUMPADCOMMA = 0xB3,    // , on numeric keypad (NEC PC98)
+		KC_DIVIDE      = 0xB5,    // / on numeric keypad
+		KC_SYSRQ       = 0xB7,
+		KC_RMENU       = 0xB8,    // right Alt
+		KC_PAUSE       = 0xC5,    // Pause
+		KC_HOME        = 0xC7,    // Home on arrow keypad
+		KC_UP          = 0xC8,    // UpArrow on arrow keypad
+		KC_PGUP        = 0xC9,    // PgUp on arrow keypad
+		KC_LEFT        = 0xCB,    // LeftArrow on arrow keypad
+		KC_RIGHT       = 0xCD,    // RightArrow on arrow keypad
+		KC_END         = 0xCF,    // End on arrow keypad
+		KC_DOWN        = 0xD0,    // DownArrow on arrow keypad
+		KC_PGDOWN      = 0xD1,    // PgDn on arrow keypad
+		KC_INSERT      = 0xD2,    // Insert on arrow keypad
+		KC_DELETE      = 0xD3,    // Delete on arrow keypad
+		KC_LWIN        = 0xDB,    // Left Windows key
+		KC_RWIN        = 0xDC,    // Right Windows key
+		KC_APPS        = 0xDD,    // AppMenu key
+		KC_POWER       = 0xDE,    // System Power
+		KC_SLEEP       = 0xDF,    // System Sleep
+		KC_WAKE        = 0xE3,    // System Wake
+		KC_WEBSEARCH   = 0xE5,    // Web Search
+		KC_WEBFAVORITES= 0xE6,    // Web Favorites
+		KC_WEBREFRESH  = 0xE7,    // Web Refresh
+		KC_WEBSTOP     = 0xE8,    // Web Stop
+		KC_WEBFORWARD  = 0xE9,    // Web Forward
+		KC_WEBBACK     = 0xEA,    // Web Back
+		KC_MYCOMPUTER  = 0xEB,    // My Computer
+		KC_MAIL        = 0xEC,    // Mail
+		KC_MEDIASELECT = 0xED     // Media Select
+	};
+
+	/**
+		Specialised for key events
+	*/
+	class _OISExport KeyEvent : public EventArg
+	{
+	public:
+		KeyEvent( Object* obj, KeyCode kc, unsigned int txt ) : EventArg(obj), key(kc), text(txt) {}
+		virtual ~KeyEvent() {}
+
+		//! KeyCode of event
+		const KeyCode key;
+		//! Text character, depends on current TextTranslationMode
+		unsigned int text;
+	};
+
+	/**
+		To recieve buffered keyboard input, derive a class from this, and implement the
+		methods here. Then set the call back to your Keyboard instance with Keyboard::setEventCallback
+	*/
+	class _OISExport KeyListener
+	{
+	public:
+		virtual ~KeyListener() {}
+		virtual bool keyPressed( const KeyEvent &arg ) = 0;
+		virtual bool keyReleased( const KeyEvent &arg ) = 0;		
+	};
+
+	/**
+		Keyboard base class. To be implemented by specific system (ie. DirectX Keyboard)
+		This class is useful as you remain OS independent using this common interface.
+	*/
+	class _OISExport Keyboard : public Object
+	{
+	public:
+		virtual ~Keyboard() {};
+		
+		/**
+		@remarks
+			Returns true if key is donwn
+		@param key
+			A KeyCode to check
+		*/
+		virtual bool isKeyDown( KeyCode key ) const = 0;
+
+		/**
+		@remarks
+			Register/unregister a Keyboard Listener - Only one allowed for simplicity. If broadcasting
+			is neccessary, just broadcast from the callback you registered.
+		@param keyListener
+			Send a pointer to a class derived from KeyListener or 0 to clear the callback
+		*/
+		virtual void setEventCallback( KeyListener *keyListener ) { mListener = keyListener;}
+
+		/**
+		@remarks
+			Returns currently set callback.. or 0
+		*/
+		KeyListener* getEventCallback() const {return mListener;}
+
+		//! TextTranslation Mode
+		enum TextTranslationMode
+		{
+			Off,
+			Unicode,
+			Ascii
+		};
+
+		/**
+		@remarks
+			Enable extra processing to translate KC_*** to an
+			actual text character based off of locale. Different 
+			managers may implement none or all. Check the 
+			translation mode after setting to be sure
+		@param mode
+			Off, Unicode, Ascii
+		*/
+		virtual void setTextTranslation( TextTranslationMode mode );
+
+		/**
+		@remarks
+			Returns current translation mode
+		*/
+		TextTranslationMode getTextTranslation() const {return mTextMode;}
+		
+		/**
+		@remarks
+			Translates KeyCode to string representation.
+			For example, KC_ENTER will be "Enter" - Locale
+			specific of course.
+		@param kc
+			KeyCode to convert
+		@returns
+			The string as determined from the current locale
+		*/
+		virtual const std::string& getAsString( KeyCode kc ) = 0;
+
+		//! Enum of bit position of modifer
+		enum Modifier
+		{
+			Shift = 0x0000001,
+			Ctrl  = 0x0000010,
+			Alt   = 0x0000100
+		};
+
+		/**
+		@remarks
+			Check modifier status
+		*/
+		bool isModifierDown( Modifier mod ) const;
+
+		/**
+		@remarks
+			Copies the state of the keys into the sent buffer
+			(in the form of 1 is down and 0 is up)
+		*/
+		virtual void copyKeyStates( char keys[256] ) const = 0;
+		
+	protected:
+		Keyboard(const std::string &vendor, bool buffered, int devID, InputManager* creator)
+			: Object(vendor, OISKeyboard, buffered, devID, creator),
+			mModifiers(0), mListener(0), mTextMode(Unicode) {}
+
+		//! Bit field that holds status of Alt, Ctrl, Shift
+		unsigned int mModifiers;
+
+		//! Used for buffered/actionmapping callback
+		KeyListener *mListener;
+
+		//! The current translation mode
+		TextTranslationMode mTextMode;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/OISMouse.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISMouse.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISMouse.h	(revision 1801)
@@ -0,0 +1,138 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Mouse_H
+#define OIS_Mouse_H
+#include "OISObject.h"
+#include "OISEvents.h"
+
+namespace OIS
+{
+	//! Button ID for mouse devices
+	enum MouseButtonID
+	{
+		MB_Left = 0, MB_Right, MB_Middle,
+		MB_Button3, MB_Button4,	MB_Button5, MB_Button6,	MB_Button7
+	};
+
+	/**
+		Represents the state of the mouse
+		All members are valid for both buffered and non buffered mode
+	*/
+	class _OISExport MouseState
+	{
+	public:
+		MouseState() : width(50), height(50), buttons(0) {};
+
+		/** Represents the height/width of your display area.. used if mouse clipping
+		or mouse grabbed in case of X11 - defaults to 50.. Make sure to set this
+		and change when your size changes.. */
+		mutable int width, height;
+
+		//! X Axis component
+		Axis X;
+
+		//! Y Axis Component
+		Axis Y;
+
+		//! Z Axis Component
+		Axis Z;
+
+		//! represents all buttons - bit position indicates button down
+		int buttons;
+
+		//! Button down test
+		inline bool buttonDown( MouseButtonID button ) const
+		{
+			return ((buttons & ( 1L << button )) == 0) ? false : true;
+		}
+
+		//! Clear all the values
+		void clear()
+		{
+			X.clear();
+			Y.clear();
+			Z.clear();
+			buttons = 0;
+		}
+	};
+
+	/** Specialised for mouse events */
+	class _OISExport MouseEvent : public EventArg
+	{
+	public:
+		MouseEvent( Object *obj, const MouseState &ms )	: EventArg(obj), state(ms) {}
+		virtual ~MouseEvent() {}
+
+		//! The state of the mouse - including buttons and axes
+		const MouseState &state;
+	};
+
+	/**
+		To recieve buffered mouse input, derive a class from this, and implement the
+		methods here. Then set the call back to your Mouse instance with Mouse::setEventCallback
+	*/
+	class _OISExport MouseListener
+	{
+	public:
+		virtual ~MouseListener() {}
+		virtual bool mouseMoved( const MouseEvent &arg ) = 0;
+		virtual bool mousePressed( const MouseEvent &arg, MouseButtonID id ) = 0;
+		virtual bool mouseReleased( const MouseEvent &arg, MouseButtonID id ) = 0;
+	};
+
+	/**
+		Mouse base class. To be implemented by specific system (ie. DirectX Mouse)
+		This class is useful as you remain OS independent using this common interface.
+	*/
+	class _OISExport Mouse : public Object
+	{
+	public:
+		virtual ~Mouse() {}
+
+		/**
+		@remarks
+			Register/unregister a Mouse Listener - Only one allowed for simplicity. If broadcasting
+			is neccessary, just broadcast from the callback you registered.
+		@param mouseListener
+			Send a pointer to a class derived from MouseListener or 0 to clear the callback
+		*/
+		virtual void setEventCallback( MouseListener *mouseListener ) {mListener = mouseListener;}
+
+		/** @remarks Returns currently set callback.. or 0 */
+		MouseListener* getEventCallback() const {return mListener;}
+
+		/** @remarks Returns the state of the mouse - is valid for both buffered and non buffered mode */
+		const MouseState& getMouseState() const { return mState; }
+
+	protected:
+		Mouse(const std::string &vendor, bool buffered, int devID, InputManager* creator)
+			: Object(vendor, OISMouse, buffered, devID, creator), mListener(0) {}
+
+		//! The state of the mouse
+		MouseState mState;
+
+		//! Used for buffered/actionmapping callback
+		MouseListener *mListener;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/OISObject.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/OISObject.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISObject.cpp	(revision 1801)
@@ -0,0 +1,23 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+//#include "OISObject.h"
Index: /code/branches/ceguilua/src/ois/OISObject.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISObject.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISObject.h	(revision 1801)
@@ -0,0 +1,95 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Object_H
+#define OIS_Object_H
+
+#include "OISPrereqs.h"
+#include "OISInterface.h"
+
+namespace OIS
+{
+	/**	The base class of all input types. */
+	class _OISExport Object
+	{
+	public:
+		virtual ~Object() {}
+
+		/**	@remarks Get the type of device	*/
+		Type type() const { return mType; }
+
+		/**	@remarks Get the vender string name	*/
+		const std::string& vendor() const { return mVendor; }
+
+		/**	@remarks Get buffered mode - true is buffered, false otherwise */
+		virtual bool buffered() const { return mBuffered; }
+
+		/** @remarks Returns this input object's creator */
+		InputManager* getCreator() const { return mCreator; }
+
+		/** @remarks Sets buffered mode	*/
+		virtual void setBuffered(bool buffered) = 0;
+
+		/**	@remarks Used for updating call once per frame before checking state or to update events */
+		virtual void capture() = 0;
+
+		/**	@remarks This may/may not) differentiate the different controllers based on (for instance) a port number (useful for console InputManagers) */
+		virtual int getID() const {return mDevID;}
+
+		/**
+		@remarks
+			If available, get an interface to write to some devices.
+			Examples include, turning on and off LEDs, ForceFeedback, etc
+		@param type
+			The type of interface you are looking for
+		*/
+		virtual Interface* queryInterface(Interface::IType type) = 0;
+
+		/**	@remarks Internal... Do not call this directly. */
+		virtual void _initialize() = 0;
+
+	protected:
+		Object(const std::string &vendor, Type iType, bool buffered,
+			   int devID, InputManager* creator) :
+					mVendor(vendor),
+					mType(iType),
+					mBuffered(buffered),
+					mDevID(devID),
+					mCreator(creator) {}
+
+		//! Vendor name if applicable/known
+		std::string mVendor;
+
+		//! Type of controller object
+		Type mType;
+
+		//! Buffered flag
+		bool mBuffered;
+
+		//! Not fully implemented yet
+		int mDevID;
+
+		//! The creator who created this object
+		InputManager* mCreator;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/OISPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/ois/OISPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/OISPrereqs.h	(revision 1801)
@@ -0,0 +1,217 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Prereqs_H
+#define OIS_Prereqs_H
+//----------------------------------------------------------------------------//
+// This Header File contains: forward declared classes
+//  * Forward Declarations of all public API classes
+//  * Several typedef's used around the library
+//  * Base class component types
+//  * Preprocessor definitons
+//----------------------------------------------------------------------------//
+
+//-------------- Common STL Containers ---------------------------------------//
+#include <vector>
+#include <string>
+#include <map>
+#include "OISConfig.h"
+
+// Default is blank for most OS's
+#define _OISExport
+
+//-------------- Determine Compiler ---------------------------------
+#if defined( _MSC_VER )
+#	define OIS_MSVC_COMPILER
+#elif defined( __GNUC__ )
+#	if defined( __WIN32__ ) || defined( _WIN32 )
+#		define OIS_MINGW_COMPILER
+#	else
+#		define OIS_GCC_COMPILER
+#	endif
+#elif defined( __BORLANDC__ )
+#	define OIS_BORLAND_COMPILER
+#else
+#	error No Recognized Compiler!
+#endif
+
+// --------------- Determine Operating System Platform ---------------
+#if defined( __WIN32__ ) || defined( _WIN32 ) // Windows 2000, XP, ETC
+#	if defined ( _XBOX )
+#		define OIS_XBOX_PLATFORM
+#	else
+#		define OIS_WIN32_PLATFORM
+#		if defined( OIS_DYNAMIC_LIB )
+#			undef _OISExport
+			//Ignorable Dll interface warning...
+#           if !defined(OIS_MINGW_COMPILER)
+#			    pragma warning (disable : 4251)
+#           endif
+#			if defined( OIS_NONCLIENT_BUILD )
+#				define _OISExport __declspec( dllexport )
+#			else
+#               if defined(OIS_MINGW_COMPILER)
+#                   define _OISExport
+#               else
+#				    define _OISExport __declspec( dllimport )
+#               endif
+#			endif
+#		endif
+#	endif
+#elif defined( __APPLE_CC__ ) // Apple OS X
+#	define OIS_APPLE_PLATFORM
+#	undef _OISExport
+#	define _OISExport __attribute__((visibility("default")))
+#else //Probably Linux
+#	define OIS_LINUX_PLATFORM
+#endif
+
+//Is Processor 32 or 64 bits...
+#if defined(__x86_64__)
+#	define OIS_ARCH_64
+#else
+#	define OIS_ARCH_32
+#endif
+
+//-------------- Common Classes, Enums, and Typdef's -------------------------//
+#define OIS_VERSION_MAJOR 1
+#define OIS_VERSION_MINOR 2 
+#define OIS_VERSION_PATCH 0
+#define OIS_VERSION_NAME "Smash"
+
+#define OIS_VERSION ((OIS_VERSION_MAJOR << 16) | (OIS_VERSION_MINOR << 8) | OIS_VERSION_PATCH)
+
+namespace OIS
+{
+	//Forward Declarations
+	class InputManager;
+	class FactoryCreator;
+	class Object;
+	class Keyboard;
+	class Mouse;
+	class JoyStick;
+	class KeyListener;
+	class MouseListener;
+	class JoyStickListener;
+	class Interface;
+	class ForceFeedback;
+	class Effect;
+	class Exception;
+
+	//! Way to send OS nuetral parameters.. ie OS Window handles, modes, flags
+	typedef std::multimap<std::string, std::string> ParamList;
+
+	//! List of FactoryCreator's
+	typedef std::vector<FactoryCreator*> FactoryList;
+
+	//! Map of FactoryCreator created Objects
+	typedef std::map<Object*, FactoryCreator*> FactoryCreatedObject;
+
+	//! Each Input class has a General Type variable, a form of RTTI
+    enum Type
+	{
+		OISUnknown   = 0,
+		OISKeyboard  = 1,
+		OISMouse     = 2,
+		OISJoyStick  = 3,
+		OISTablet    = 4
+	};
+
+	//! Map of device objects connected and their respective vendors
+	typedef std::multimap<Type, std::string> DeviceList;
+
+	//--------     Shared common components    ------------------------//
+
+	//! Base type for all device components (button, axis, etc)
+    enum ComponentType
+	{
+		OIS_Unknown = 0,
+		OIS_Button  = 1, //ie. Key, mouse button, joy button, etc
+		OIS_Axis    = 2, //ie. A joystick or mouse axis
+		OIS_Slider  = 3, //
+		OIS_POV     = 4, //ie. Arrow direction keys
+		OIS_Vector3 = 5  //ie. WiiMote orientation
+	};
+
+	//! Base of all device components (button, axis, etc)
+	class _OISExport Component
+	{
+	public:
+		Component() : cType(OIS_Unknown) {};
+		Component(ComponentType type) : cType(type) {};
+		//! Indicates what type of coponent this is
+		ComponentType cType;
+	};
+
+	//! Button can be a keyboard key, mouse button, etc
+	class _OISExport Button : public Component
+	{
+	public:
+		Button() {}
+		Button(bool bPushed) : Component(OIS_Button), pushed(bPushed) {};
+		//! true if pushed, false otherwise
+		bool pushed;
+	};
+
+	//! Axis component
+	class _OISExport Axis : public Component
+	{
+	public:
+		Axis() : Component(OIS_Axis), abs(0), rel(0), absOnly(false) {};
+
+		//! Absoulte and Relative value components
+		int abs, rel;
+
+		//! Indicates if this Axis only supports Absoulte (ie JoyStick)
+		bool absOnly;
+
+		//! Used internally by OIS
+		void clear()
+		{
+			abs = rel = 0;
+		}
+	};
+
+	//! A 3D Vector component (perhaps an orientation, as in the WiiMote)
+	class _OISExport Vector3 : public Component
+	{
+	public:
+		Vector3() {}
+		Vector3(float _x, float _y, float _z) : Component(OIS_Vector3), x(_x), y(_y), z(_z) {};
+		
+		//! X component of vector
+		float x;
+		
+		//! Y component of vector
+		float y;
+
+		//! Z component of vector
+		float z;
+
+		void clear()
+		{
+			x = y = z = 0.0f;
+		}
+	};
+}
+
+#endif //end if prereq header defined
Index: /code/branches/ceguilua/src/ois/ReadMe.txt
===================================================================
--- /code/branches/ceguilua/src/ois/ReadMe.txt	(revision 1801)
+++ /code/branches/ceguilua/src/ois/ReadMe.txt	(revision 1801)
@@ -0,0 +1,87 @@
+======================================================================================
+================ LICENSE =============================================================
+======================================================================================
+
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no 
+event will the authors be held liable for any damages arising from the use of this 
+software.
+
+Permission is granted to anyone to use this software for any purpose, including 
+commercial applications, and to alter it and redistribute it freely, subject to the 
+following restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated 
+		but is not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+
+
+======================================================================================
+================ LICENSE EXPLAINED ===================================================
+======================================================================================
+In case the license was not clear enough... Basically, you can link with this lib 
+which puts no restrictions on what you have to license your code as. You can modify 
+this lib, and not have release your changes. Though, as explained above, <bold> 
+Altered source versions must be plainly marked as such, and must not be misrepresented
+as being the original software </bold>
+
+This is to allow users the greatest flexibility in what you can use this lib for.
+
+======================================================================================
+================ INFO ================================================================
+======================================================================================
+
+Cross Platform Object Oriented Input Lib System. Meant to be very robust and 
+compatiable with many systems and operating systems
+
+Win32/
+	Contains Visual Studio .Net Solution Files
+	Contains CodeBlocks + MinGW + StlPort project files for OIS
+	
+	---- Dependencies ------------------------------------------------------
+	DirectInput 8
+	Ogre & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
+
+	SDL/
+		A test bed for an OIS InputManager with SDL as the backend. Not recommended;
+		however, useful for platforms with non-native OIS ports for temporary use.
+
+Linux/
+	---- Dependencies ------------------------------------------------------
+	X11
+	Ogre (GLX Platform) & CEGUI 0.4.0 If building CEGUIOgre OIS Demo
+        Newer Linux Kernel (2.6+ ?) for Event API - else, use --disable-joyevents
+
+	Steps to build on Linux:
+	./bootstrap
+	./configure
+	./make && make install
+
+	---- Configure build options --------------------------------------------
+	./configure --help              --- List all configure options
+	./configure --disable-ogre      --- Disables CEGUIOgre ActionMapping Demo
+	./configure --disable-joyevents --- Uses /dev/input/jsX instead of 
+	                                    /dev/input/eventX
+
+LinuxCB/
+        Contains CodeBlock files for building OIS and Demos with codeblocks
+        This project file looks for Ogre and other dependencies in /usr/local/lib
+        and /usr/local/include. If installed elsewhere, modify the project
+        settings. It also installs libOIS to ~/libs
+
+Mac/
+	
+	XCode-1.5/
+		Non-complete native OIS port.
+
+	XCode-2.2/
+		Working, complete, OIS port to OSX using SDL as a backend.
Index: /code/branches/ceguilua/src/ois/linux/EventHelpers.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/linux/EventHelpers.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/EventHelpers.cpp	(revision 1801)
@@ -0,0 +1,242 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/EventHelpers.h"
+#include "linux/LinuxPrereqs.h"
+#include "linux/LinuxForceFeedback.h"
+#include "OISException.h"
+#include "OISJoyStick.h"
+
+#include <linux/input.h>
+#include <cstring>
+
+//#define OIS_LINUX_JOY_DEBUG
+
+#ifdef OIS_LINUX_JOY_DEBUG
+# include <iostream>
+  using namespace std;
+#endif
+
+using namespace OIS;
+
+class DeviceComponentInfo
+{
+public:
+	std::vector<int> buttons, relAxes, absAxes, hats;
+};
+
+bool inline isBitSet(unsigned long bits[], unsigned int bit)
+{
+	return (bits[bit/(sizeof(long)*8)] >> ((bit)%(sizeof(long)*8))) & 1;
+}
+//-----------------------------------------------------------------------------//
+DeviceComponentInfo getComponentInfo( int deviceID )
+{
+	unsigned long info[2][((KEY_MAX-1)/(sizeof(long)*8)) +1];
+	memset( info, 0, sizeof(info) );
+
+	DeviceComponentInfo components;
+
+	//Read "all" (hence 0) components of the device - read into first entry
+	ioctl(deviceID, EVIOCGBIT(0, EV_MAX), info[0]);
+
+	for (int i = 0; i < EV_MAX; i++)
+	{
+		if( isBitSet(info[0], i) )
+		{
+			memset( info[1], 0, sizeof(info) / 2 );
+			ioctl(deviceID, EVIOCGBIT(i, KEY_MAX), info[1]);
+			for (int j = 0; j < KEY_MAX; j++)
+			{
+				if( isBitSet(info[1], j) )
+				{
+					if(i == EV_ABS)
+					{
+						//input_absinfo abInfo;
+						//ioctl( fd, EVIOCGABS(j), abInfo );
+						if( j >= ABS_HAT0X && j <= ABS_HAT3Y )
+						{
+							components.hats.push_back(j);
+						}
+						else
+						{
+							components.absAxes.push_back(j);
+							//input_absinfo absinfo;
+							//ioctl(deviceID, EVIOCGABS(j), &absinfo);
+							//We cannot actually change these values :|
+							//absinfo.minimum = JoyStick::MIN_AXIS;
+							//absinfo.maximum = JoyStick::MAX_AXIS;
+							//ioctl(deviceID, EVIOCSABS(j), &absinfo);
+						}
+					}
+					else if(i == EV_REL)
+					{
+						components.relAxes.push_back(j);
+					}
+					else if(i == EV_KEY)
+					{
+						components.buttons.push_back(j);
+					}
+				}
+			}
+		}
+	}
+
+	return components;
+}
+
+//-----------------------------------------------------------------------------//
+bool EventUtils::isJoyStick( int deviceID, JoyStickInfo &js )
+{
+	if( deviceID == -1 ) OIS_EXCEPT( E_General, "Error with File Descriptor" );
+
+	DeviceComponentInfo info = getComponentInfo( deviceID );
+
+	int buttons = 0;
+	bool joyButtonFound = false;
+	js.button_map.clear();
+
+	#ifdef OIS_LINUX_JOY_DEBUG
+	  cout << "\n\nDisplaying ButtonMapping Status:";
+	#endif
+	for(std::vector<int>::iterator i = info.buttons.begin(), e = info.buttons.end(); i != e; ++i )
+	{
+		//Check to ensure we find at least one joy only button
+		if( (*i >= BTN_JOYSTICK && *i <= BTN_THUMBR) || (*i >= BTN_WHEEL && *i <= BTN_GEAR_UP ) )
+			joyButtonFound = true;
+
+		js.button_map[*i] = buttons++;
+
+		#ifdef OIS_LINUX_JOY_DEBUG
+		  cout << "\nButton Mapping ID (hex): " << hex << *i << " OIS Button Num: " << dec << (buttons-1);
+		#endif
+	}
+
+	//Joy Buttons found, so it must be a joystick or pad
+	if( joyButtonFound )
+	{
+		js.joyFileD = deviceID;
+		js.vendor = getName(deviceID);
+		js.buttons = buttons;
+		js.axes = info.relAxes.size() + info.absAxes.size();
+		js.hats = info.hats.size();
+
+		//Map the Axes
+		#ifdef OIS_LINUX_JOY_DEBUG
+		  cout << "\n\nDisplaying AxisMapping Status:";
+		#endif
+		int axes = 0;
+		for(std::vector<int>::iterator i = info.absAxes.begin(), e = info.absAxes.end(); i != e; ++i )
+		{
+			js.axis_map[*i] = axes;
+
+			input_absinfo absinfo;
+			ioctl(deviceID, EVIOCGABS(*i), &absinfo);
+			js.axis_range[axes] = Range(absinfo.minimum, absinfo.maximum);
+
+			#ifdef OIS_LINUX_JOY_DEBUG
+			  cout << "\nAxis Mapping ID (hex): " << hex << *i << " OIS Axis Num: " << dec << axes;
+			#endif
+
+			++axes;
+		}
+	}
+
+	return joyButtonFound;
+}
+
+//-----------------------------------------------------------------------------//
+std::string EventUtils::getName( int deviceID )
+{
+	char name[OIS_DEVICE_NAME];
+	ioctl(deviceID, EVIOCGNAME(OIS_DEVICE_NAME), name);
+	return std::string(name);
+}
+
+//-----------------------------------------------------------------------------//
+void EventUtils::enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff )
+{
+	//Linux Event to OIS Event Mappings
+	std::map<int, Effect::EType> typeMap;
+	typeMap[FF_CONSTANT] = Effect::Constant;
+	typeMap[FF_RAMP]     = Effect::Ramp;
+	typeMap[FF_SPRING]   = Effect::Spring;
+	typeMap[FF_FRICTION] = Effect::Friction;
+	typeMap[FF_SQUARE]   = Effect::Square;
+	typeMap[FF_TRIANGLE] = Effect::Triangle;
+	typeMap[FF_SINE]     = Effect::Sine;
+	typeMap[FF_SAW_UP]   = Effect::SawToothUp;
+	typeMap[FF_SAW_DOWN] = Effect::SawToothDown;
+	typeMap[FF_DAMPER]   = Effect::Damper;
+	typeMap[FF_INERTIA]  = Effect::Inertia;
+	typeMap[FF_CUSTOM]   = Effect::Custom;
+
+	std::map<int, Effect::EForce> forceMap;
+	forceMap[FF_CONSTANT] = Effect::ConstantForce;
+	forceMap[FF_RAMP] = Effect::RampForce;
+	forceMap[FF_PERIODIC] = Effect::PeriodicForce;
+	forceMap[FF_CUSTOM] = Effect::CustomForce;
+
+	//Remove any previously existing memory and create fresh
+	removeForceFeedback( ff );
+	*ff = new LinuxForceFeedback();
+
+	unsigned long info[4] = {0,0,0,0};
+	unsigned long subinfo[4]= {0,0,0,0};
+
+	//Read overall force feedback components of the device
+	ioctl(deviceID, EVIOCGBIT(EV_FF, sizeof(long)*4), info);
+
+	//FF Axes
+	//if( isBitSet(info, ABS_X) ) //X Axis
+	//if( isBitSet(info, ABS_Y) ) //Y Axis
+	//if( isBitSet(info, ABS_WHEEL) ) //Wheel
+
+	//FF Effects
+	for( int effect = ABS_WHEEL+1; effect < FF_MAX; effect++ )
+	{
+		if(isBitSet(info, effect))
+		{
+			//std::cout << "\tEffect Type: " << effect << std::endl;
+			memset(subinfo, 0, sizeof(subinfo));
+			//Read any info about this supported effect
+			ioctl(deviceID, EVIOCGBIT(effect, sizeof(long)*4), subinfo);
+			for( int force = 0; force < FF_MAX; force++ )
+			{
+				if(isBitSet(subinfo, force))
+					(*ff)->_addEffectTypes( forceMap[force], typeMap[effect] );
+			}
+		}
+	}
+
+	//Check to see if any effects were added, else destroy the pointer
+	const ForceFeedback::SupportedEffectList &list = (*ff)->getSupportedEffects();
+	if( list.size() == 0 )
+		removeForceFeedback( ff );
+}
+
+//-----------------------------------------------------------------------------//
+void EventUtils::removeForceFeedback( LinuxForceFeedback** ff )
+{
+	delete *ff;
+	*ff = 0;
+}
Index: /code/branches/ceguilua/src/ois/linux/EventHelpers.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/EventHelpers.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/EventHelpers.h	(revision 1801)
@@ -0,0 +1,47 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_OISEVENT_HEADER_
+#define _LINUX_OISEVENT_HEADER_
+
+#include "linux/LinuxPrereqs.h"
+
+#define OIS_MAX_DEVICES 32
+#define OIS_DEVICE_NAME 128
+
+namespace OIS
+{
+	class EventUtils
+	{
+	public:
+		static bool isJoyStick( int deviceID, JoyStickInfo &js );
+		static bool isMouse( int ) {return false;}
+		static bool isKeyboard( int ) {return false;}
+
+		//Double pointer is so that we can set the value of the sent pointer
+		static void enumerateForceFeedback( int deviceID, LinuxForceFeedback** ff );
+		static void removeForceFeedback( LinuxForceFeedback** ff );
+
+		static std::string getName( int deviceID );
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/linux/LinuxForceFeedback.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxForceFeedback.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxForceFeedback.cpp	(revision 1801)
@@ -0,0 +1,61 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/LinuxForceFeedback.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//--------------------------------------------------------------//
+LinuxForceFeedback::LinuxForceFeedback()
+{
+}
+//--------------------------------------------------------------//
+LinuxForceFeedback::~LinuxForceFeedback()
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::setMasterGain(float)
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::setAutoCenterMode(bool)
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::upload( const Effect* /*effect*/ )
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::modify( const Effect* /*effect*/ )
+{
+}
+
+//--------------------------------------------------------------//
+void LinuxForceFeedback::remove( const Effect* /*effect*/ )
+{
+}
+
Index: /code/branches/ceguilua/src/ois/linux/LinuxForceFeedback.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxForceFeedback.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxForceFeedback.h	(revision 1801)
@@ -0,0 +1,56 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_LinuxForceFeedBack_H
+#define OIS_LinuxForceFeedBack_H
+
+#include "linux/LinuxPrereqs.h"
+#include "OISForceFeedback.h"
+
+namespace OIS
+{
+	class LinuxForceFeedback : public ForceFeedback
+	{
+	public:
+		LinuxForceFeedback();
+		~LinuxForceFeedback();
+
+		/** @copydoc ForceFeedback::setMasterGain */
+		void setMasterGain(float);
+		
+		/** @copydoc ForceFeedback::setAutoCenterMode */
+		void setAutoCenterMode(bool);
+
+		/** @copydoc ForceFeedback::upload */
+		void upload( const Effect* effect );
+
+		/** @copydoc ForceFeedback::modify */
+		void modify( const Effect* effect );
+
+		/** @copydoc ForceFeedback::remove */
+		void remove( const Effect* effect );
+
+		/** FF is not yet implemented fully on Linux.. just retun 0 for now. todo, xxx */
+		short int getFFAxesNumber() { return 0; }
+	};
+}
+#endif //OIS_LinuxForceFeedBack_H
Index: /code/branches/ceguilua/src/ois/linux/LinuxInputManager.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxInputManager.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxInputManager.cpp	(revision 1801)
@@ -0,0 +1,218 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/LinuxInputManager.h"
+#include "linux/LinuxKeyboard.h"
+#include "linux/LinuxJoyStickEvents.h"
+#include "linux/LinuxMouse.h"
+#include "OISException.h"
+#include <cstdlib>
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------//
+LinuxInputManager::LinuxInputManager() : InputManager("X11InputManager")
+{
+	window = 0;
+
+	//Default settings
+	grabMouse = true;
+	grabKeyboard = true;
+	hideMouse = true;
+	mGrabs = true;
+	useXRepeat = false;
+	keyboardUsed = mouseUsed = false;
+
+	//Setup our internal factories
+	mFactories.push_back(this);
+}
+
+//--------------------------------------------------------------------------------//
+LinuxInputManager::~LinuxInputManager()
+{
+	//Close all joysticks
+	LinuxJoyStick::_clearJoys(unusedJoyStickList);
+}
+
+//--------------------------------------------------------------------------------//
+void LinuxInputManager::_initialize( ParamList &paramList )
+{
+	_parseConfigSettings( paramList );
+
+	//Enumerate all devices attached
+	_enumerateDevices();
+}
+
+//--------------------------------------------------------------------------------//
+void LinuxInputManager::_parseConfigSettings( ParamList &paramList )
+{
+	ParamList::iterator i = paramList.find("WINDOW");
+	if( i == paramList.end() ) 
+		OIS_EXCEPT( E_InvalidParam, "LinuxInputManager >> No WINDOW!" );
+
+	//TODO 64 bit proof this little conversion xxx wip
+	window  = strtoul(i->second.c_str(), 0, 10);
+
+	//--------- Keyboard Settings ------------//
+	i = paramList.find("XAutoRepeatOn");
+	if( i != paramList.end() )
+		if( i->second == "true" )
+			useXRepeat = true;
+
+	i = paramList.find("x11_keyboard_grab");
+	if( i != paramList.end() )
+		if( i->second == "false" )
+			grabKeyboard = false;
+
+	//--------- Mouse Settings ------------//
+	i = paramList.find("x11_mouse_grab");
+	if( i != paramList.end() )
+		if( i->second == "false" )
+			grabMouse = false;
+
+	i = paramList.find("x11_mouse_hide");
+	if( i != paramList.end() )
+		if( i->second == "false" )
+			hideMouse = false;
+}
+
+//--------------------------------------------------------------------------------//
+void LinuxInputManager::_enumerateDevices()
+{
+	//Enumerate all attached devices
+	unusedJoyStickList = LinuxJoyStick::_scanJoys();
+	joySticks = unusedJoyStickList.size();
+}
+
+//----------------------------------------------------------------------------//
+DeviceList LinuxInputManager::freeDeviceList()
+{
+	DeviceList ret;
+
+	if( keyboardUsed == false )
+		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
+
+	if( mouseUsed == false )
+		ret.insert(std::make_pair(OISMouse, mInputSystemName));
+
+	for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		ret.insert(std::make_pair(OISJoyStick, i->vendor));
+
+	return ret;
+}
+
+//----------------------------------------------------------------------------//
+int LinuxInputManager::totalDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return 1;
+	case OISMouse: return 1;
+	case OISJoyStick: return joySticks;
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+int LinuxInputManager::freeDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return keyboardUsed ? 0 : 1;
+	case OISMouse: return mouseUsed ? 0 : 1;
+	case OISJoyStick: return (int)unusedJoyStickList.size();
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+bool LinuxInputManager::vendorExist(Type iType, const std::string & vendor)
+{
+	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
+	{
+		return true;
+	}
+	else if( iType == OISJoyStick )
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+			if(i->vendor == vendor)
+				return true;
+	}
+
+	return false;
+}
+
+//----------------------------------------------------------------------------//
+Object* LinuxInputManager::createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor)
+{
+	Object *obj = 0;
+
+	switch(iType)
+	{
+	case OISKeyboard:
+	{
+		if( keyboardUsed == false )
+			obj = new LinuxKeyboard(this, bufferMode, grabKeyboard, useXRepeat);
+		break;
+	}
+	case OISMouse:
+	{
+		if( mouseUsed == false )
+			obj = new LinuxMouse(this, bufferMode, grabMouse, hideMouse);
+		break;
+	}
+	case OISJoyStick:
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		{
+			if(vendor == "" || i->vendor == vendor)
+			{
+				obj = new LinuxJoyStick(this, bufferMode, *i);
+				unusedJoyStickList.erase(i);
+				break;
+			}
+		}
+		break;
+	}
+	default:
+		break;
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//----------------------------------------------------------------------------//
+void LinuxInputManager::destroyObject( Object* obj )
+{
+	if( obj )
+	{
+		if( obj->type() == OISJoyStick )
+		{
+			unusedJoyStickList.push_back( ((LinuxJoyStick*)obj)->_getJoyInfo() );
+		}
+
+		delete obj;
+	}
+}
Index: /code/branches/ceguilua/src/ois/linux/LinuxInputManager.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxInputManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxInputManager.h	(revision 1801)
@@ -0,0 +1,108 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_LinuxInputManager_H
+#define OIS_LinuxInputManager_H
+
+#include "linux/LinuxPrereqs.h"
+#include "OISFactoryCreator.h"
+#include "OISInputManager.h"
+#include <X11/Xlib.h>
+
+namespace OIS
+{
+	/**
+		Linux X11 InputManager specialization - Using lowlevel joys
+	*/
+	class LinuxInputManager : public InputManager, public FactoryCreator
+	{
+	public:
+		LinuxInputManager();
+		virtual ~LinuxInputManager();
+
+		//InputManager Overrides
+		/** @copydoc InputManager::_initialize */
+		void _initialize( ParamList &paramList );
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager *creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+		//Internal Items
+		//! Method for retrieving the XWindow Handle
+		Window _getWindow() {return window;}
+
+		//! Internal method for checking if regrabbing is needed
+		void _setGrabState(bool grab) {mGrabs = grab;}
+		bool _getGrabState() {return mGrabs;}
+
+		//! Internal method, used for flaggin keyboard as available/unavailable for creation
+		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
+
+		//! Internal method, used for flaggin mouse as available/unavailable for creation
+		void _setMouseUsed(bool used) { mouseUsed = used; }
+		
+	protected:
+		//! internal class method for dealing with param list
+		void _parseConfigSettings( ParamList &paramList );
+		//! internal class method for finding attached devices
+		void _enumerateDevices();
+
+		//! List of unused joysticks ready to be used
+		JoyStickInfoList unusedJoyStickList;
+		//! Number of joysticks found
+		char joySticks;
+
+		//! Used to know if we used up keyboard
+		bool keyboardUsed;
+
+		//! Used to know if we used up mouse
+		bool mouseUsed;
+
+		//! X11 Stuff
+		Window window;
+		
+		/// Keyboard, Mouse Settings
+		bool grabMouse, grabKeyboard;
+		bool mGrabs;
+		bool hideMouse;
+
+		//! By default, keyboard disables XRepeatRate
+		bool useXRepeat;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/linux/LinuxJoyStickEvents.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxJoyStickEvents.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxJoyStickEvents.cpp	(revision 1801)
@@ -0,0 +1,299 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "OISConfig.h"
+
+#include "linux/LinuxJoyStickEvents.h"
+#include "linux/LinuxInputManager.h"
+#include "linux/LinuxForceFeedback.h"
+#include "linux/EventHelpers.h"
+
+#include "OISEvents.h"
+#include "OISException.h"
+
+#include <fcntl.h>        //Needed to Open a file descriptor
+#include <cassert>	
+#include <linux/input.h>
+
+
+#include <sstream>
+
+using namespace OIS;
+
+//#define OIS_LINUX_JOY_DEBUG
+
+#ifdef OIS_LINUX_JOY_DEBUG
+# include <iostream>
+  using namespace std;
+#endif
+
+//-------------------------------------------------------------------//
+LinuxJoyStick::LinuxJoyStick(InputManager* creator, bool buffered, const JoyStickInfo& js)
+	: JoyStick(js.vendor, buffered, js.devId, creator)
+{
+	mJoyStick = js.joyFileD;
+
+	mState.mAxes.clear();
+	mState.mAxes.resize(js.axes);
+	mState.mButtons.clear();
+	mState.mButtons.resize(js.buttons);
+
+	mPOVs = js.hats;
+
+	mButtonMap = js.button_map;
+	mAxisMap = js.axis_map;
+	mRanges = js.axis_range;
+
+	ff_effect = 0;
+}
+
+//-------------------------------------------------------------------//
+LinuxJoyStick::~LinuxJoyStick()
+{
+	EventUtils::removeForceFeedback( &ff_effect );
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::_initialize()
+{
+	//Clear old joy state
+	mState.mAxes.resize(mAxisMap.size());
+	mState.clear();
+
+	//This will create and new us a force feedback structure if it exists
+	EventUtils::enumerateForceFeedback( mJoyStick, &ff_effect );
+
+	if( mJoyStick == -1 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "LinuxJoyStick::_initialize() >> JoyStick Not Found!");
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::capture()
+{
+	static const short POV_MASK[8] = {0,0,1,1,2,2,3,3};
+
+	//Used to determine if an axis has been changed and needs an event
+	bool axisMoved[32] = {false, false, false, false, false, false, false, false, false, false, false, false, false,
+						  false, false, false, false, false, false, false, false, false, false, false, false, false,
+						  false, false, false, false, false, false};
+
+	//We are in non blocking mode - we just read once, and try to fill up buffer
+	input_event js[JOY_BUFFERSIZE];
+	int ret = read(mJoyStick, &js, sizeof(struct input_event) * JOY_BUFFERSIZE);
+	if( ret <= 0 )
+		return;
+
+	//Determine how many whole events re read up
+	ret /= sizeof(struct input_event);
+	for(int i = 0; i < ret; ++i)
+	{
+		switch(js[i].type)
+		{
+		case EV_KEY:  //Button
+		{
+			int button = mButtonMap[js[i].code];
+
+			#ifdef OIS_LINUX_JOY_DEBUG
+			  std::cout << "\nButton Code: " << js[i].code << ", OIS Value: " << button << std::endl;
+			#endif
+
+			//Check to see whether push or released event...
+			if(js[i].value)
+			{
+				mState.mButtons[button] = true;
+				if( mBuffered && mListener )
+					if(!mListener->buttonPressed(JoyStickEvent(this,mState), button)) return;
+			}
+			else
+			{
+				mState.mButtons[button] = false;
+				if( mBuffered && mListener )
+					if(!mListener->buttonReleased(JoyStickEvent(this,mState), button)) return;
+			}
+			break;
+		}
+		case EV_ABS:  //Absoulte Axis
+		{
+			//A Stick (BrakeDefine is the highest possible Axis)
+			if( js[i].code <= ABS_BRAKE )
+			{
+				int axis = mAxisMap[js[i].code];
+				assert( axis < 32 && "Too many axes, not supported. Report this to OIS forums!" );
+				
+				axisMoved[axis] = true;
+
+				//check for rescaling:
+				if( mRanges[axis].min == JoyStick::MIN_AXIS && mRanges[axis].max != JoyStick::MAX_AXIS )
+				{	//Scale is perfect
+					mState.mAxes[axis].abs = js[i].value;
+				}
+				else
+				{	//Rescale
+					float proportion = (float)(js[i].value-mRanges[axis].max)/(float)(mRanges[axis].min-mRanges[axis].max);
+					mState.mAxes[axis].abs = (int)(32767.0f - (65535.0f * proportion));
+				}
+			}
+			else if( js[i].code <= ABS_HAT3Y ) //A POV - Max four POVs allowed
+			{
+				//Normalise the POV to between 0-7
+				//Even is X Axis, Odd is Y Axis
+				unsigned char LinuxPovNumber = js[i].code - 16;
+				short OIS_POVIndex = POV_MASK[LinuxPovNumber];
+
+				//Handle X Axis first (Even) (left right)
+				if((LinuxPovNumber & 0x0001) == 0)
+				{
+					//Why do this? Because, we use a bit field, and when this axis is east,
+					//it can't possibly be west too. So clear out the two X axes, then refil
+					//it in with the new direction bit.
+					//Clear the East/West Bit Flags first
+					mState.mPOV[OIS_POVIndex].direction &= 0x11110011;
+					if( js[i].value == -1 )	//Left
+						mState.mPOV[OIS_POVIndex].direction |= Pov::West;
+					else if( js[i].value == 1 ) //Right
+						mState.mPOV[OIS_POVIndex].direction |= Pov::East;
+				}
+				//Handle Y Axis (Odd) (up down)
+				else
+				{
+					//Clear the North/South Bit Flags first
+					mState.mPOV[OIS_POVIndex].direction &= 0x11111100;
+					if( js[i].value == -1 )	//Up
+						mState.mPOV[OIS_POVIndex].direction |= Pov::North;
+					else if( js[i].value == 1 ) //Down
+						mState.mPOV[OIS_POVIndex].direction |= Pov::South;
+				}
+
+				if( mBuffered && mListener )
+					if( mListener->povMoved( JoyStickEvent(this,mState), OIS_POVIndex) == false )
+						return;
+			}
+			break;
+		}
+		//Relative Axes (Do any joysticks actually have a relative axis?)
+		case EV_REL:
+		default: break;
+		}
+	}
+
+	//All axes and POVs are combined into one movement per pair per captured frame
+	if( mBuffered && mListener )
+	{
+		for( int i = 0; i < 32; ++i )
+			if( axisMoved[i] )
+				if( mListener->axisMoved( JoyStickEvent(this,mState), i) == false )
+					return;
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::setBuffered(bool buffered)
+{
+	if( buffered != mBuffered )
+	{
+		mBuffered = buffered;
+		_initialize();
+	}
+}
+
+//-------------------------------------------------------------------//
+JoyStickInfo LinuxJoyStick::_getJoyInfo()
+{
+	JoyStickInfo js;
+
+	js.devId = mDevID;
+	js.joyFileD = mJoyStick;
+	js.vendor = mVendor;
+	js.axes = (int)mState.mAxes.size();
+	js.buttons = (int)mState.mButtons.size();
+	js.hats = mPOVs;
+	js.button_map = mButtonMap;
+	js.axis_map = mAxisMap;
+	js.axis_range = mRanges;
+
+	return js;
+}
+
+//-------------------------------------------------------------------//
+JoyStickInfoList LinuxJoyStick::_scanJoys()
+{
+	JoyStickInfoList joys;
+
+	//Search through all of the event devices.. and identify which ones are joysticks
+	//xxx move this to InputManager, as it can also scan all other events
+	for(int i = 0; i < 64; ++i )
+	{
+		std::stringstream s;
+		s << "/dev/input/event" << i;
+		int fd = open( s.str().c_str(), O_RDONLY |O_NONBLOCK );
+		if(fd == -1)
+			continue;
+		
+        #ifdef OIS_LINUX_JOY_DEBUG
+          std::cout << "\nOpening " << s.str() << "...";
+        #endif
+		try
+		{
+			JoyStickInfo js;
+			if( EventUtils::isJoyStick(fd, js) )
+			{
+				joys.push_back(js);
+                #ifdef OIS_LINUX_JOY_DEBUG
+                  std::cout << "\n__Joystick added to list";
+                #endif
+			}
+			else
+			{
+                #ifdef OIS_LINUX_JOY_DEBUG
+                  std::cout << "\n__Not a joystick!!";
+                #endif
+				close(fd);
+			}
+		}
+		catch(...)
+		{
+            #ifdef OIS_LINUX_JOY_DEBUG
+              std::cout << "\nException caught!!";
+            #endif
+			close(fd);
+		}
+	}
+
+	return joys;
+}
+
+//-------------------------------------------------------------------//
+void LinuxJoyStick::_clearJoys(JoyStickInfoList &joys)
+{
+	for(JoyStickInfoList::iterator i = joys.begin(); i != joys.end(); ++i)
+		close(i->joyFileD);
+	joys.clear();
+}
+
+//-------------------------------------------------------------------//
+Interface* LinuxJoyStick::queryInterface(Interface::IType type)
+{
+	if( ff_effect && type == Interface::ForceFeedback )
+		return ff_effect;
+
+	return 0;
+}
Index: /code/branches/ceguilua/src/ois/linux/LinuxJoyStickEvents.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxJoyStickEvents.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxJoyStickEvents.h	(revision 1801)
@@ -0,0 +1,72 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_JOYSTICK_H_EADER_
+#define _LINUX_JOYSTICK_H_EADER_
+
+#include "linux/LinuxPrereqs.h"
+#include "OISJoyStick.h"
+
+namespace OIS
+{
+	/**
+		Linux specialization of JoyStick class.. This version is favored over the other.. and has the
+		*possibility* of Force Feedback.. notice I say possibility, i make no gaurantees under linux,
+		as FF support is sketchy at best AFAIK.
+	*/
+	class LinuxJoyStick : public JoyStick
+	{
+	public:
+		LinuxJoyStick(InputManager* creator, bool buffered, const JoyStickInfo& js);
+		virtual ~LinuxJoyStick();
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type);
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+		/**
+		@remarks
+			For internal use only... Returns a structure to the manager, to make the device
+			availiable for use again
+		*/
+		JoyStickInfo _getJoyInfo();
+
+		static JoyStickInfoList _scanJoys();
+		static void _clearJoys(JoyStickInfoList &joys);
+	protected:
+
+		int mJoyStick;
+		LinuxForceFeedback* ff_effect;
+		std::map <int, int> mButtonMap;
+		std::map <int, int> mAxisMap;
+		std::map <int, Range> mRanges;
+	};
+}
+#endif //_LINUX_JOYSTICK_H_EADER_
Index: /code/branches/ceguilua/src/ois/linux/LinuxKeyboard.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxKeyboard.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxKeyboard.cpp	(revision 1801)
@@ -0,0 +1,449 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "linux/LinuxInputManager.h"
+#include "linux/LinuxKeyboard.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include <cstring>
+
+using namespace OIS;
+#include <iostream>
+//-------------------------------------------------------------------//
+LinuxKeyboard::LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat)
+	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
+{
+	setlocale(LC_CTYPE, ""); //Set the locale to (hopefully) the users LANG UTF-8 Env var
+
+	display = 0;
+	window = 0;
+
+	grabKeyboard = grab;
+	keyFocusLost = false;
+
+	xAutoRepeat = useXRepeat;
+	oldXAutoRepeat = false;
+
+	//X Key Map to KeyCode
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_1, KC_1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_2, KC_2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_3, KC_3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_4, KC_4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_5, KC_5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_6, KC_6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_7, KC_7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_8, KC_8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_9, KC_9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_0, KC_0));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_BackSpace, KC_BACK));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_minus, KC_MINUS));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_equal, KC_EQUALS));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_space, KC_SPACE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_comma, KC_COMMA));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_period, KC_PERIOD));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_backslash, KC_BACKSLASH));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_slash, KC_SLASH));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_bracketleft, KC_LBRACKET));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_bracketright, KC_RBRACKET));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Escape,KC_ESCAPE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Caps_Lock, KC_CAPITAL));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Tab, KC_TAB));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Return, KC_RETURN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Control_L, KC_LCONTROL));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Control_R, KC_RCONTROL));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_colon, KC_COLON));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_semicolon, KC_SEMICOLON));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_apostrophe, KC_APOSTROPHE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_grave, KC_GRAVE));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_b, KC_B));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_a, KC_A));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_c, KC_C));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_d, KC_D));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_e, KC_E));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_f, KC_F));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_g, KC_G));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_h, KC_H));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_i, KC_I));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_j, KC_J));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_k, KC_K));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_l, KC_L));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_m, KC_M));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_n, KC_N));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_o, KC_O));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_p, KC_P));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_q, KC_Q));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_r, KC_R));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_s, KC_S));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_t, KC_T));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_u, KC_U));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_v, KC_V));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_w, KC_W));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_x, KC_X));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_y, KC_Y));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_z, KC_Z));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F1, KC_F1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F2, KC_F2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F3, KC_F3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F4, KC_F4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F5, KC_F5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F6, KC_F6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F7, KC_F7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F8, KC_F8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F9, KC_F9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F10, KC_F10));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F11, KC_F11));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F12, KC_F12));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F13, KC_F13));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F14, KC_F14));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_F15, KC_F15));
+
+	//Keypad
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_0, KC_NUMPAD0));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_1, KC_NUMPAD1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_2, KC_NUMPAD2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_3, KC_NUMPAD3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_4, KC_NUMPAD4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_5, KC_NUMPAD5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_6, KC_NUMPAD6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_7, KC_NUMPAD7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_8, KC_NUMPAD8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_9, KC_NUMPAD9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Add, KC_ADD));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Subtract, KC_SUBTRACT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Decimal, KC_DECIMAL));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Equal, KC_NUMPADEQUALS));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Divide, KC_DIVIDE));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Multiply, KC_MULTIPLY));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Enter, KC_NUMPADENTER));
+
+	//Keypad with numlock off
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Home, KC_NUMPAD7));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Page_Up, KC_NUMPAD9));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Left, KC_NUMPAD4));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Begin, KC_NUMPAD5));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Right, KC_NUMPAD6));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_End, KC_NUMPAD1));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Down, KC_NUMPAD2));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Up, KC_UP));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Down, KC_DOWN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Left, KC_LEFT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Right, KC_RIGHT));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Page_Up, KC_PGUP));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Page_Down, KC_PGDOWN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Home, KC_HOME));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_End, KC_END));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Num_Lock, KC_NUMLOCK));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Shift_R, KC_RSHIFT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Shift_L, KC_LSHIFT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Alt_R, KC_RMENU));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Alt_L, KC_LMENU));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Delete, KC_DELETE));
+
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Super_L, KC_LWIN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Super_R, KC_RWIN));
+	keyConversion.insert(XtoOIS_KeyMap::value_type(XK_Menu, KC_APPS));
+
+	static_cast<LinuxInputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::_initialize()
+{
+	//Clear our keyboard state buffer
+	memset( &KeyBuffer, 0, 256 );
+	mModifiers = 0;
+
+	if( display ) XCloseDisplay(display);
+	display = 0;
+	window = static_cast<LinuxInputManager*>(mCreator)->_getWindow();
+
+	//Create our local X mListener connection
+	if( !(display = XOpenDisplay(0)) )
+		OIS_EXCEPT(E_General, "LinuxKeyboard::_initialize >> Error opening X!");
+
+	//Set it to recieve Input events
+	if( XSelectInput(display, window, KeyPressMask | KeyReleaseMask) == BadWindow )
+		OIS_EXCEPT(E_General, "LinuxKeyboard::_initialize: X error!");
+
+	if( grabKeyboard )
+		XGrabKeyboard(display,window,True,GrabModeAsync,GrabModeAsync,CurrentTime);
+
+	keyFocusLost = false;
+
+	if( xAutoRepeat == false )
+	{
+		//We do not want to blindly turn on autorepeat later when quiting if
+		//it was not on to begin with.. So, let us check and see first
+		XKeyboardState old;
+		XGetKeyboardControl( display, &old );
+		oldXAutoRepeat = false;
+
+		if( old.global_auto_repeat == AutoRepeatModeOn )
+			oldXAutoRepeat = true;
+
+		XAutoRepeatOff( display );
+	}
+}
+
+//-------------------------------------------------------------------//
+LinuxKeyboard::~LinuxKeyboard()
+{
+	if( display )
+	{
+		if( oldXAutoRepeat )
+			XAutoRepeatOn(display);
+
+		if( grabKeyboard )
+			XUngrabKeyboard(display, CurrentTime);
+
+		XCloseDisplay(display);
+	}
+
+	static_cast<LinuxInputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//-------------------------------------------------------------------//
+unsigned int UTF8ToUTF32(unsigned char* buf)
+{
+	unsigned char &FirstChar = buf[0];
+
+	if(FirstChar < 128)
+		return FirstChar;
+
+	unsigned int val = 0;
+	unsigned int len = 0;
+
+	if((FirstChar & 0xE0) == 0xC0) //2 Chars
+	{
+		len = 2;
+		val = FirstChar & 0x1F;
+	}
+	else if((FirstChar & 0xF0) == 0xE0) //3 Chars
+	{
+		len = 3;
+		val = FirstChar & 0x0F;
+	}
+	else if((FirstChar & 0xF8) == 0xF0) //4 Chars
+	{
+		len = 4;
+		val = FirstChar & 0x07;
+	}
+	else if((FirstChar & 0xFC) == 0xF8) //5 Chars
+	{
+		len = 5;
+		val = FirstChar & 0x03;
+	}
+	else // if((FirstChar & 0xFE) == 0xFC) //6 Chars
+	{
+		len = 6;
+		val = FirstChar & 0x01;
+	}
+
+	for(unsigned int i = 1; i < len; i++)
+		val = (val << 6) | (buf[i] & 0x3F);
+
+	return val;
+}
+
+//-------------------------------------------------------------------//
+bool LinuxKeyboard::isKeyDown( KeyCode key ) const
+{
+	return (KeyBuffer[key]);
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::capture()
+{
+	KeySym key;
+	XEvent event;
+	LinuxInputManager* linMan = static_cast<LinuxInputManager*>(mCreator);
+
+	while( XPending(display) > 0 )
+	{
+		XNextEvent(display, &event);
+
+		if( KeyPress == event.type )
+		{
+			unsigned int character = 0;
+
+			if( mTextMode != Off )
+			{
+				unsigned char buffer[6] = {0,0,0,0,0,0};
+				XLookupString(&event.xkey, (char*)buffer, 6, &key, 0);
+
+				if( mTextMode == Unicode )
+					character = UTF8ToUTF32(buffer);
+				else if( mTextMode == Ascii)
+					character = buffer[0];
+			}
+
+			//Mask out the modifier states X11 sets and read again
+			event.xkey.state &= ~ShiftMask;
+			event.xkey.state &= ~LockMask;
+			XLookupString(&event.xkey, 0, 0,&key, 0);
+
+			_injectKeyDown(key, character);
+
+			//Just printing out some debugging info.. to verify all chars are mapped
+			//std::cout << "KEY PRESSED X=" << event.xkey.keycode;
+			//std::cout << "\n KeySym=" << key << std::endl;
+
+			//Check for Alt-Tab
+			if( event.xkey.state & Mod1Mask && key == XK_Tab )
+				linMan->_setGrabState(false);
+		}
+		else if( KeyRelease == event.type )
+		{
+			//Mask out the modifier states X sets.. or we will get improper values
+			event.xkey.state &= ~ShiftMask;
+			event.xkey.state &= ~LockMask;
+
+			//Else, it is a valid key release
+			XLookupString(&event.xkey,NULL,0,&key,NULL);
+			_injectKeyUp(key);
+		}
+	}
+
+	//If grabbing mode is on.. Handle focus lost/gained via Alt-Tab and mouse clicks
+	if( grabKeyboard )
+	{
+		if( linMan->_getGrabState() == false )
+		{
+			// are no longer grabbing
+			if( keyFocusLost == false )
+			{
+				//UnGrab KeyBoard
+				XUngrabKeyboard(display, CurrentTime);
+				keyFocusLost = true;
+			}
+		}
+		else
+		{
+			//We are grabbing - and regained focus
+			if( keyFocusLost == true )
+			{
+				//ReGrab KeyBoard
+				XGrabKeyboard(display, window, True, GrabModeAsync, GrabModeAsync, CurrentTime);
+				keyFocusLost = false;
+			}
+		}
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//-------------------------------------------------------------------//
+bool LinuxKeyboard::_injectKeyDown( KeySym key, int text )
+{
+	KeyCode kc = keyConversion[key];
+	KeyBuffer[kc] = 1;
+
+	//Turn on modifier flags
+	if( kc == KC_LCONTROL || kc == KC_RCONTROL)
+		mModifiers |= Ctrl;
+	else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+		mModifiers |= Shift;
+	else if( kc == KC_LMENU || kc == KC_RMENU )
+		mModifiers |= Alt;
+
+	if( mBuffered && mListener )
+		return mListener->keyPressed(KeyEvent(this,kc,text));
+
+	return true;
+}
+
+//-------------------------------------------------------------------//
+bool LinuxKeyboard::_injectKeyUp( KeySym key )
+{
+	KeyCode kc = keyConversion[key];
+	KeyBuffer[kc] = 0;
+
+	//Turn off modifier flags
+	if( kc == KC_LCONTROL || kc == KC_RCONTROL)
+		mModifiers &= ~Ctrl;
+	else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+		mModifiers &= ~Shift;
+	else if( kc == KC_LMENU || kc == KC_RMENU )
+		mModifiers &= ~Alt;
+
+	if( mBuffered && mListener )
+		return mListener->keyReleased(KeyEvent(this, kc, 0));
+
+	return true;
+}
+
+//-------------------------------------------------------------------//
+const std::string& LinuxKeyboard::getAsString( KeyCode kc )
+{
+	mGetString = "Unknown";
+	char *temp = 0;
+
+	XtoOIS_KeyMap::iterator i = keyConversion.begin(),
+				e = keyConversion.end();
+
+	for( ; i != e; ++i )
+	{
+		if( i->second == kc )
+		{
+			temp = XKeysymToString(i->first);
+			if( temp )
+				mGetString = temp;
+			break;
+		}
+	}
+
+	return mGetString;
+}
+
+//-------------------------------------------------------------------//
+void LinuxKeyboard::copyKeyStates( char keys[256] ) const
+{
+	memcpy( keys, KeyBuffer, 256 );
+}
Index: /code/branches/ceguilua/src/ois/linux/LinuxKeyboard.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxKeyboard.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxKeyboard.h	(revision 1801)
@@ -0,0 +1,84 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_KEYBOARD_H_EADER_
+#define _LINUX_KEYBOARD_H_EADER_
+
+#include "linux/LinuxPrereqs.h"
+#include "OISKeyboard.h"
+#include <X11/Xlib.h>
+
+namespace OIS
+{
+	/** Linux implementation of Keyboard object - uses x11 */
+	class LinuxKeyboard : public Keyboard
+	{
+	public:
+		LinuxKeyboard(InputManager* creator, bool buffered, bool grab, bool useXRepeat );
+		virtual ~LinuxKeyboard();
+
+		/** @copydoc Keyboard::isKeyDown */
+		virtual bool isKeyDown( KeyCode key ) const;
+
+		/** @copydoc Keyboard::getAsString */
+		virtual const std::string& getAsString( KeyCode kc );
+
+		/** @copydoc Keyboard::copyKeyStates */
+		virtual void copyKeyStates( char keys[256] ) const;
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+	protected:
+		bool _injectKeyDown( KeySym key, int text );
+		bool _injectKeyUp( KeySym key );
+
+		//! 1:1 Conversion Map between X Key Events and OIS KeyCodes
+		typedef std::map<KeySym, KeyCode> XtoOIS_KeyMap;
+		XtoOIS_KeyMap keyConversion;
+
+		//! Depressed Key List
+		char KeyBuffer[256];
+
+		//! X11 Stuff
+		Window window;
+		Display *display;
+		bool grabKeyboard;
+		bool keyFocusLost;
+
+		bool xAutoRepeat;
+		bool oldXAutoRepeat;
+
+		std::string mGetString;
+	};
+}
+
+#endif //_LINUX_KEYBOARD_H_EADER_
Index: /code/branches/ceguilua/src/ois/linux/LinuxMouse.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxMouse.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxMouse.cpp	(revision 1801)
@@ -0,0 +1,270 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered friosom any source distribution.
+*/
+#include "linux/LinuxMouse.h"
+#include "linux/LinuxInputManager.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+using namespace OIS;
+
+//-------------------------------------------------------------------//
+LinuxMouse::LinuxMouse(InputManager* creator, bool buffered, bool grab, bool hide)
+	: Mouse(creator->inputSystemName(), buffered, 0, creator)
+{
+	display = 0;
+	window = 0;
+	cursor = 0;
+
+	grabMouse = grab;
+	hideMouse = hide;
+
+	static_cast<LinuxInputManager*>(mCreator)->_setMouseUsed(true);
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::_initialize()
+{
+	//Clear old state
+	mState.clear();
+	mMoved  = false;
+	mWarped = false;
+
+	//6 is just some random value... hardly ever would anyone have a window smaller than 6
+	oldXMouseX = oldXMouseY = 6;
+	oldXMouseZ = 0;
+
+	if( display ) XCloseDisplay(display);
+	display = 0;
+	window = static_cast<LinuxInputManager*>(mCreator)->_getWindow();
+
+	//Create our local X mListener connection
+	if( !(display = XOpenDisplay(0)) )
+		OIS_EXCEPT(E_General, "LinuxMouse::_initialize >> Error opening X!");
+
+	//Set it to recieve Mouse Input events
+	if( XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask) == BadWindow )
+		OIS_EXCEPT(E_General, "LinuxMouse::_initialize >> X error!");
+
+	//Warp mouse inside window
+	XWarpPointer(display,None,window,0,0,0,0, 6,6);
+
+	//Create a blank cursor:
+	Pixmap bm_no;
+	XColor black, dummy;
+	Colormap colormap;
+	static char no_data[] = { 0,0,0,0,0,0,0,0 };
+
+	colormap = DefaultColormap( display, DefaultScreen(display) );
+	XAllocNamedColor( display, colormap, "black", &black, &dummy );
+	bm_no = XCreateBitmapFromData( display, window, no_data, 8, 8 );
+	cursor = XCreatePixmapCursor( display, bm_no, bm_no, &black, &black, 0, 0 );
+
+	grab( grabMouse );
+	hide( hideMouse );
+
+	mouseFocusLost = false;
+}
+
+//-------------------------------------------------------------------//
+LinuxMouse::~LinuxMouse()
+{
+	if( display )
+	{
+		grab(false);
+		hide(false);
+		XFreeCursor(display, cursor);
+		XCloseDisplay(display);
+	}
+
+	static_cast<LinuxInputManager*>(mCreator)->_setMouseUsed(false);
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::capture()
+{
+	//Clear out last frames values
+	mState.X.rel = 0;
+	mState.Y.rel = 0;
+	mState.Z.rel = 0;
+
+	_processXEvents();
+
+	mWarped = false;
+
+	if( mMoved == true )
+	{
+		if( mBuffered && mListener )
+			mListener->mouseMoved( MouseEvent( this, mState ) );
+
+		mMoved = false;
+	}
+
+	//Check for losing/gaining mouse grab focus (alt-tab, etc)
+	if( grabMouse )
+	{
+		if( static_cast<LinuxInputManager*>(mCreator)->_getGrabState() )
+		{
+			if( mouseFocusLost )	//We just regained mouse grab focus
+			{
+				grab( true );
+				hide( hideMouse );
+				mouseFocusLost = false;
+			}
+		}
+		else
+		{
+			if( mouseFocusLost == false )	//We just lost mouse grab focus
+			{
+				grab( false );
+				hide( false );
+				mouseFocusLost = true;
+			}
+		}
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::_processXEvents()
+{
+	//X11 Button Events: 1=left 2=middle 3=right; Our Bit Postion: 1=Left 2=Right 3=Middle
+	char mask[4] = {0,1,4,2};
+	XEvent event;
+
+	//Poll x11 for events mouse events
+	while( XPending(display) > 0 ) 
+	{
+		XNextEvent(display, &event);
+
+		if( event.type == MotionNotify )
+		{	//Mouse moved
+			//Ignore out of bounds mouse if we just warped
+			if( mWarped )
+			{
+				if(event.xmotion.x < 5 || event.xmotion.x > mState.width - 5 ||
+				   event.xmotion.y < 5 || event.xmotion.y > mState.height - 5)
+					continue;
+			}
+
+			//Compute this frames Relative X & Y motion
+			mState.X.rel = event.xmotion.x - oldXMouseX;
+			mState.Y.rel = event.xmotion.y - oldXMouseY;
+		
+			//Store old values for next time to compute relative motion
+			oldXMouseX = event.xmotion.x;
+			oldXMouseY = event.xmotion.y;
+
+			mState.X.abs += mState.X.rel;
+			mState.Y.abs += mState.Y.rel;
+
+			//Check to see if we are grabbing the mouse to the window (requires clipping and warping)
+			if( grabMouse )
+			{
+				if( mState.X.abs < 0 )
+					mState.X.abs = 0;
+				else if( mState.X.abs > mState.width )
+					mState.X.abs = mState.width;
+
+				if( mState.Y.abs < 0 )
+					mState.Y.abs = 0;
+				else if( mState.Y.abs > mState.height )
+					mState.Y.abs = mState.height;
+
+				if( mouseFocusLost == false )
+				{
+					//Keep mouse in window (fudge factor)
+					if(event.xmotion.x < 5 || event.xmotion.x > mState.width - 5 ||
+					   event.xmotion.y < 5 || event.xmotion.y > mState.height - 5 )
+					{
+						oldXMouseX = mState.width >> 1;  //center x
+						oldXMouseY = mState.height >> 1; //center y
+						XWarpPointer(display, None, window, 0, 0, 0, 0, oldXMouseX, oldXMouseY);
+						mWarped = true;
+					}
+				}
+			}
+			mMoved = true;
+		}
+		else if( event.type == ButtonPress )
+		{	//Button down
+			static_cast<LinuxInputManager*>(mCreator)->_setGrabState(true);
+
+			if( event.xbutton.button < 4 )
+			{
+				mState.buttons |= mask[event.xbutton.button];
+				if( mBuffered && mListener )
+					if( mListener->mousePressed( MouseEvent( this, mState ),
+						(MouseButtonID)(mask[event.xbutton.button] >> 1)) == false )
+						return;
+			}
+		}
+		else if( event.type == ButtonRelease )
+		{	//Button up
+			if( event.xbutton.button < 4 )
+			{
+				mState.buttons &= ~mask[event.xbutton.button];
+				if( mBuffered && mListener )
+					if( mListener->mouseReleased( MouseEvent( this, mState ),
+						(MouseButtonID)(mask[event.xbutton.button] >> 1)) == false )
+						return;
+			}
+			//The Z axis gets pushed/released pair message (this is up)
+			else if( event.xbutton.button == 4 )
+			{
+				mState.Z.rel += 120;
+				mState.Z.abs += 120;
+				mMoved = true;
+			}
+			//The Z axis gets pushed/released pair message (this is down)
+			else if( event.xbutton.button == 5 )
+			{
+				mState.Z.rel -= 120;
+				mState.Z.abs -= 120;
+				mMoved = true;
+			}
+		}
+	}
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::grab(bool grab)
+{
+	if( grab )
+		XGrabPointer(display, window, True, 0, GrabModeAsync, GrabModeAsync, window, None, CurrentTime);
+	else
+		XUngrabPointer(display, CurrentTime);
+}
+
+//-------------------------------------------------------------------//
+void LinuxMouse::hide(bool hide)
+{
+	if( hide )
+		XDefineCursor(display, window, cursor);
+	else
+		XUndefineCursor(display, window);
+}
Index: /code/branches/ceguilua/src/ois/linux/LinuxMouse.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxMouse.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxMouse.h	(revision 1801)
@@ -0,0 +1,75 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_MOUSE_H_EADER_
+#define _LINUX_MOUSE_H_EADER_
+
+#include "linux/LinuxPrereqs.h"
+#include "OISMouse.h"
+#include <X11/Xlib.h>
+
+namespace OIS
+{
+	class LinuxMouse : public Mouse
+	{
+	public:
+		LinuxMouse(InputManager* creator, bool buffered, bool grab, bool hide);
+		virtual ~LinuxMouse();
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/**
+		@remarks
+			Note: Calling this will also update the keyboard (X11 updates in a single
+			event queue). Updates State and/or raises event for buffered mode..
+		*/
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+		void grab(bool grab);
+		void hide(bool hide);
+
+	protected:
+		void _processXEvents();
+
+		bool mMoved, mWarped;
+
+		//Since X11 provides us with absolute values, we need to keep track of relative values
+		long oldXMouseX, oldXMouseY, oldXMouseZ;
+
+		Window window;		//The X Window
+		Display *display;	//The X display
+		Cursor cursor;		//A blank cursor
+
+		bool grabMouse;		//Are we grabbing the mouse to the window?
+		bool hideMouse;		//Are we hiding OS mouse?
+		bool mouseFocusLost;//Has the mouse just lost focus?
+	};
+}
+
+#endif //_LINUX_MOUSE_H_EADER_
Index: /code/branches/ceguilua/src/ois/linux/LinuxPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/ois/linux/LinuxPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/linux/LinuxPrereqs.h	(revision 1801)
@@ -0,0 +1,82 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _LINUX_INPUTSYSTEM_PREREQS_H
+#define _LINUX_INPUTSYSTEM_PREREQS_H
+
+//Bring in any auto generated config files
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "OISPrereqs.h"
+
+//! Max number of elements to collect from buffered input
+#define JOY_BUFFERSIZE 10
+
+namespace OIS
+{
+	class LinuxInputManager;
+	class LinuxKeyboard;
+	class LinuxJoyStick;
+	class LinuxMouse;
+	
+	class LinuxForceFeedback;
+
+	class Range
+	{
+	public:
+		Range() {};
+		Range(int _min, int _max) : min(_min), max(_max) {};
+		int min, max;
+	};
+
+	class JoyStickInfo
+	{
+	public:
+		JoyStickInfo(): devId(-1),joyFileD(-1),version(0),axes(0),buttons(0),hats(0) {}
+		//! Device number (/dev/input/j#) or /dev/input/event#
+		int devId;
+		//! File descriptor
+		int joyFileD;
+		//! Driver version
+		int version;
+		//! Joy vendor
+		std::string vendor;
+		//! Number of axes
+		unsigned char axes;
+		//! Number of buttons
+		unsigned char buttons;
+		//! Number of hats
+		unsigned char hats;
+		//! Maps Linux button values to OIS buttons values
+		std::map<int, int> button_map;
+		//! Maps Linux axis values to OIS axis
+		std::map<int, int> axis_map;
+		//! Maps OIS axis values to it's range
+		std::map<int, Range> axis_range;
+	};
+
+	typedef std::vector< JoyStickInfo > JoyStickInfoList;
+}
+
+#endif //_LINUX_INPUTSYSTEM_PREREQS_H
Index: /code/branches/ceguilua/src/ois/mac/MacHIDManager.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacHIDManager.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacHIDManager.cpp	(revision 1801)
@@ -0,0 +1,392 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Phillip Castaneda
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "mac/MacHIDManager.h"
+#include "OISException.h"
+#include "OISObject.h"
+
+#include <iostream>
+using namespace std;
+
+using namespace OIS;
+
+//------------------------------------------------------------------------------------------------------//
+//------------------------------------------------------------------------------------------------------//
+template<typename T>
+T getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	return CFDictionaryGetValue(dict, OIS_CFString(keyName));
+}
+
+template<>
+CFArrayRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
+
+	if(temp && CFGetTypeID(temp) == CFArrayGetTypeID())
+		return (CFArrayRef)temp;
+	else
+		return 0;
+}
+
+template<>
+CFStringRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
+
+	if(temp && CFGetTypeID(temp) == CFStringGetTypeID())
+		return (CFStringRef)temp;
+	else
+		return 0;
+}
+
+template<>
+CFNumberRef getDictionaryItemAsRef(CFDictionaryRef dict, const char* keyName)
+{
+	CFTypeRef temp = CFDictionaryGetValue(dict, OIS_CFString(keyName));
+
+	if(temp && CFGetTypeID(temp) == CFNumberGetTypeID())
+		return (CFNumberRef)temp;
+	else
+		return 0;
+}
+
+//------------------------------------------------------------------------------------------------------//
+//------------------------------------------------------------------------------------------------------//
+template<typename T>
+T getArrayItemAsRef(CFArrayRef array, CFIndex idx)
+{
+	return CFArrayGetValueAtIndex(array, idx);
+}
+
+template<>
+CFDictionaryRef getArrayItemAsRef(CFArrayRef array, CFIndex idx)
+{
+	CFTypeRef temp = CFArrayGetValueAtIndex(array, idx);
+
+	if(temp && CFGetTypeID(temp) == CFDictionaryGetTypeID())
+		return (CFDictionaryRef)temp;
+	else
+		return 0;
+}
+
+//------------------------------------------------------------------------------------------------------//
+int getInt32(CFNumberRef ref)
+{
+   int r = 0;
+   if (r) 
+      CFNumberGetValue(ref, kCFNumberIntType, &r);
+   return r;
+}
+
+//--------------------------------------------------------------------------------//
+MacHIDManager::MacHIDManager()
+{
+}
+
+//--------------------------------------------------------------------------------//
+MacHIDManager::~MacHIDManager()
+{
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::initialize()
+{
+	CFMutableDictionaryRef deviceLookupMap = IOServiceMatching(kIOHIDDeviceKey);
+	if(!deviceLookupMap)
+		OIS_EXCEPT(E_General, "Could not setup HID device search parameters");
+
+	//Make the search more specific by adding usage flags
+	int usage = kHIDUsage_GD_GamePad | kHIDUsage_GD_Joystick,
+	    page  = kHIDPage_GenericDesktop;
+
+	CFNumberRef usageRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &usage),
+				pageRef  = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &page);
+
+	CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsageKey), usageRef);
+	CFDictionarySetValue(deviceLookupMap, CFSTR(kIOHIDPrimaryUsagePageKey), pageRef);
+
+	//IOServiceGetMatchingServices consumes the map so we do not have to release it ourself
+	io_iterator_t iterator = 0;
+	IOReturn result = IOServiceGetMatchingServices(kIOMasterPortDefault, deviceLookupMap, &iterator);
+	if (result == kIOReturnSuccess && iterator)
+	{
+		io_object_t hidDevice = 0;
+		while ((hidDevice = IOIteratorNext(iterator)) !=0)
+		{
+			//Get the current registry items property map
+			CFMutableDictionaryRef propertyMap = 0;
+			if (IORegistryEntryCreateCFProperties(hidDevice, &propertyMap, kCFAllocatorDefault, kNilOptions) == KERN_SUCCESS && propertyMap)
+			{
+				//Go through device to find all needed info
+				HidInfo* hid = enumerateDeviceProperties(propertyMap);
+				if(hid)
+					mDeviceList.push_back(hid);
+					
+				//todo - we need to hold an open interface so we do not have to enumerate again later
+				//should be able to watch for device removals also
+
+				/// Testing opening / closing interface
+				//IOCFPlugInInterface **pluginInterface = NULL;
+				//SInt32 score = 0;
+				//if (IOCreatePlugInInterfaceForService(hidDevice, kIOHIDDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &pluginInterface, &score) == kIOReturnSuccess)
+				//{
+				//	IOHIDDeviceInterface **interface;
+				//	HRESULT pluginResult = (*pluginInterface)->QueryInterface(pluginInterface, CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID), (void **)&(interface));
+				//	if(pluginResult == S_OK)
+				//		cout << "Successfully created plugin interface for device\n";
+				//	else
+				//		cout << "Not able to create plugin interface\n";
+
+				//	IODestroyPlugInInterface(pluginInterface);
+
+				//	if ((*interface)->open(interface, 0) == KERN_SUCCESS)
+				//		cout << "Opened interface.\n";
+				//	else
+				//		cout << "Failed to open\n";
+
+				//	(*interface)->close(interface);
+				//}
+				//
+			}
+		}
+
+		IOObjectRelease(iterator);
+	}
+
+	CFRelease(usageRef);
+	CFRelease(pageRef);
+}
+
+//------------------------------------------------------------------------------------------------------//
+HidInfo* MacHIDManager::enumerateDeviceProperties(CFMutableDictionaryRef propertyMap)
+{
+	HidInfo* info = new HidInfo();
+	
+	info->type = OISJoyStick;
+	
+	CFStringRef str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDManufacturerKey);
+	if (str)
+		info->vendor = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
+
+	str = getDictionaryItemAsRef<CFStringRef>(propertyMap, kIOHIDProductKey);
+	if (str)
+		info->productKey = CFStringGetCStringPtr(str, CFStringGetSystemEncoding());
+		
+	info->combinedKey = info->vendor + " " + info->productKey;
+
+	//Go through all items in this device (i.e. buttons, hats, sticks, axes, etc)
+	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(propertyMap, kIOHIDElementKey);
+	if (array)
+		for (int i = 0; i < CFArrayGetCount(array); i++)
+			parseDeviceProperties(getArrayItemAsRef<CFDictionaryRef>(array, i));
+
+	return info;
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::parseDeviceProperties(CFDictionaryRef properties)
+{
+	if(!properties)
+		return;
+
+	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
+	if (array)
+	{
+		for (int i = 0; i < CFArrayGetCount(array); i++)
+		{
+			CFDictionaryRef element = getArrayItemAsRef<CFDictionaryRef>(array, i);
+			if (element)
+			{
+				if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementTypeKey)) == kIOHIDElementTypeCollection) 
+				{	//Check if we need to recurse further intoi another collection
+					if(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)) == kHIDPage_GenericDesktop)
+						parseDeviceProperties(element);
+				}
+				else
+				{
+					switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
+					{
+					case kHIDPage_GenericDesktop:
+						switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+						{
+						case kHIDUsage_GD_Pointer:
+							cout << "\tkHIDUsage_GD_Pointer\n";
+							parseDevicePropertiesGroup(element);
+							break;
+						case kHIDUsage_GD_X:
+						case kHIDUsage_GD_Y:
+						case kHIDUsage_GD_Z:
+						case kHIDUsage_GD_Rx:
+						case kHIDUsage_GD_Ry:
+						case kHIDUsage_GD_Rz:
+							cout << "\tAxis\n";
+							break;
+						case kHIDUsage_GD_Slider:
+						case kHIDUsage_GD_Dial:
+						case kHIDUsage_GD_Wheel:
+							cout << "\tUnsupported kHIDUsage_GD_Wheel\n";
+							break;
+						case kHIDUsage_GD_Hatswitch:
+							cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+							break;
+						}
+						break;
+					case kHIDPage_Button:
+						cout << "\tkHIDPage_Button\n";
+						break;
+					}
+				}
+			}
+		}
+	}
+}
+
+//------------------------------------------------------------------------------------------------------//
+void MacHIDManager::parseDevicePropertiesGroup(CFDictionaryRef properties)
+{
+	if(!properties)
+		return;
+
+	CFArrayRef array = getDictionaryItemAsRef<CFArrayRef>(properties, kIOHIDElementKey);
+	if(array)
+	{
+		for (int i = 0; i < CFArrayGetCount(array); i++)
+		{
+			CFDictionaryRef element = getArrayItemAsRef<CFDictionaryRef>(array, i);
+			if (element)
+			{
+				switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsagePageKey)))
+				{
+				case kHIDPage_GenericDesktop:
+					switch(getInt32(getDictionaryItemAsRef<CFNumberRef>(element, kIOHIDElementUsageKey)))
+					{
+					case kHIDUsage_GD_X:
+					case kHIDUsage_GD_Y:
+					case kHIDUsage_GD_Z:
+					case kHIDUsage_GD_Rx:
+					case kHIDUsage_GD_Ry:
+					case kHIDUsage_GD_Rz:
+						cout << "\t\tAxis\n";
+						break;
+					case kHIDUsage_GD_Slider:
+					case kHIDUsage_GD_Dial:
+					case kHIDUsage_GD_Wheel:
+						cout << "\tUnsupported - kHIDUsage_GD_Wheel\n";
+						break;
+					case kHIDUsage_GD_Hatswitch:
+						cout << "\tUnsupported - kHIDUsage_GD_Hatswitch\n";
+						break;
+					}
+					break;
+				case kHIDPage_Button:
+					break;
+				}
+			}
+		}
+	}
+}
+
+//--------------------------------------------------------------------------------//
+DeviceList MacHIDManager::freeDeviceList()
+{
+	DeviceList ret;
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+	for(; it != end; ++it)
+	{
+		if((*it)->inUse == false)
+			ret.insert(std::make_pair((*it)->type, (*it)->combinedKey));
+	}
+
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+int MacHIDManager::totalDevices(Type iType)
+{
+	int ret = 0;
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+
+	for(; it != end; ++it)
+	{
+		if((*it)->type == iType)
+			ret++;
+	}
+	
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+int MacHIDManager::freeDevices(Type iType)
+{
+	int ret = 0;
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+
+	for(; it != end; ++it)
+	{
+		if((*it)->inUse == false && (*it)->type == iType)
+			ret++;
+	}
+
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+bool MacHIDManager::vendorExist(Type iType, const std::string & vendor)
+{
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+
+	for(; it != end; ++it)
+	{
+		if((*it)->type == iType && (*it)->combinedKey == vendor)
+			return true;
+	}
+	
+	return false;
+}
+
+//--------------------------------------------------------------------------------//
+Object* MacHIDManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
+									  const std::string & vendor)
+{
+	Object *obj = 0;
+
+	HidInfoList::iterator it = mDeviceList.begin(), end = mDeviceList.end();
+	for(; it != end; ++it)
+	{
+		if((*it)->inUse == false && (*it)->type == iType && (vendor == "" || (*it)->combinedKey == vendor))
+		{
+			//create device
+		}
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//--------------------------------------------------------------------------------//
+void MacHIDManager::destroyObject(Object* obj)
+{
+	delete obj;
+}
Index: /code/branches/ceguilua/src/ois/mac/MacHIDManager.h
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacHIDManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacHIDManager.h	(revision 1801)
@@ -0,0 +1,100 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2007 Phillip
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacHIDManager_Header
+#define OIS_MacHIDManager_Header
+
+#include "OISPrereqs.h"
+#include "mac/MacPrereqs.h"
+#include "OISFactoryCreator.h"
+
+#import <CoreFoundation/CFString.h>
+#import <IOKit/IOKitLib.h>
+#import <IOKit/IOCFPlugIn.h>
+#import <IOKit/hid/IOHIDLib.h>
+#import <IOKit/hid/IOHIDKeys.h>
+#import <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
+
+namespace OIS
+{
+	//Information needed to create Mac HID Devices
+	class HidInfo
+	{
+	public:
+		HidInfo() : type(OISUnknown), numButtons(0), numHats(0), numAxes(0), inUse(false), interface(0)
+		{
+		}
+
+		//Useful tracking information
+		Type type;
+		std::string vendor;
+		std::string productKey;
+		std::string combinedKey;
+
+		//Retain some count information for recreating devices without having to reparse
+		int numButtons;
+		int numHats;
+		int numAxes;
+		bool inUse;
+
+		//Used for opening a read/write/tracking interface to device
+		IOHIDDeviceInterface **interface;
+	};
+
+	typedef std::vector<HidInfo*> HidInfoList;
+		
+	class MacHIDManager : public FactoryCreator
+	{
+	public:
+		MacHIDManager();
+		~MacHIDManager();
+
+		void initialize();
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+	private:
+		HidInfo* enumerateDeviceProperties(CFMutableDictionaryRef propertyMap);
+		void parseDeviceProperties(CFDictionaryRef properties);
+		void parseDevicePropertiesGroup(CFDictionaryRef properties);
+
+		HidInfoList mDeviceList;		
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/mac/MacHelpers.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacHelpers.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacHelpers.cpp	(revision 1801)
@@ -0,0 +1,158 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "mac/MacHelpers.h"
+#include "mac/MacKeyboard.h"
+#include "mac/MacMouse.h"
+#include "OISException.h"
+
+#include <Carbon/Carbon.h>
+
+using namespace OIS;
+    
+//-------------------------------------------------------------------//
+OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler,
+                        EventRef               theEvent,
+                        void*                  callClass )
+{
+    // TODO find a better way. This cast isn't very safe
+    if (callClass != NULL) {
+        ((MacKeyboard*)callClass)->_keyDownCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+    }
+    else {
+        OIS_EXCEPT(E_General, "KeyDownWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler,
+                       EventRef               theEvent,
+                       void*                  callClass )
+{
+    if (callClass != NULL) {
+        ((MacKeyboard*)callClass)->_keyUpCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+    }
+    else {
+        OIS_EXCEPT(E_General, "KeyUpWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus KeyModWrapper( EventHandlerCallRef nextHandler,
+                        EventRef               theEvent,
+                        void*                  callClass )
+{
+    if (callClass != NULL) {
+        ((MacKeyboard*)callClass)->_modChangeCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "KeyModWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+/*
+//-------------------------------------------------------------------//
+OSStatus MouseMoveWrapper( EventHandlerCallRef nextHandler,
+                           EventRef            theEvent,
+                           void*               callClass )
+{
+    if (callClass != NULL) {
+        ((MacMouse*)callClass)->_mouseMoveCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "MouseMoveWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus MouseScrollWrapper( EventHandlerCallRef nextHandler,
+                             EventRef            theEvent,
+                             void*               callClass )
+{
+    if (callClass != NULL) {
+        ((MacMouse*)callClass)->_mouseScrollCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "MouseScrollWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+
+
+//-------------------------------------------------------------------//
+OSStatus MouseButtonWrapper( EventHandlerCallRef nextHandler,
+                             EventRef            theEvent,
+                             void*               callClass )
+{
+    if (callClass != NULL) {
+        ((MacMouse*)callClass)->_mouseButtonCallback( theEvent );
+        
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );
+        
+    }
+    else {
+        OIS_EXCEPT(E_General, "MouseButtonWrapper >> Being called by something other than our event handler!");
+        return noErr;
+    }
+}
+*/
+
+//-------------------------------------------------------------------//
+OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass )
+{
+    if (callClass != NULL)
+	{
+        ((MacMouse*)callClass)->_mouseCallback( theEvent );
+
+        // propagate the event down the chain
+        return CallNextEventHandler( nextHandler, theEvent );        
+    }
+    else
+        OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
+}
Index: /code/branches/ceguilua/src/ois/mac/MacHelpers.h
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacHelpers.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacHelpers.h	(revision 1801)
@@ -0,0 +1,94 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacHelpers_H
+#define OIS_MacHelpers_H
+
+#include "mac/MacPrereqs.h"
+#include "OISEvents.h"
+#include "OISKeyboard.h"
+#include "OISMouse.h"
+
+#include <Carbon/Carbon.h>
+
+// This is a hack needed to get the event handler working. 
+// The carbon lib expects a "OSStatus (*)(EventHandlerCallRef, EventRef, void*)",
+// so I cannot give it a class member function (unless it is static which is pointless)
+// Instead, I just pass the class* through the last paramter that gets passed to the
+// callback every time an event occurs. Then I dereference it and call the member function.
+OSStatus KeyDownWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+OSStatus KeyUpWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+OSStatus KeyModWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+OSStatus MouseWrapper( EventHandlerCallRef nextHandler, EventRef theEvent, void* callClass );
+
+
+// This is needed for keeping an event stack for keyboard and mouse
+namespace OIS
+{
+    
+    // used in the eventStack to store the type
+    enum Mac_EventType { MAC_KEYUP = 0,
+                         MAC_KEYDOWN = 1,
+                         MAC_KEYREPEAT,
+                         MAC_MOUSEDOWN,
+                         MAC_MOUSEUP,
+                         MAC_MOUSEMOVED,
+                         MAC_MOUSESCROLL};
+    typedef enum Mac_EventType MacEventType;
+    
+    
+    // only used by MacKeyboard
+    typedef class Mac_KeyStackEvent
+    {
+        friend class MacKeyboard;
+        
+        
+    private:
+        Mac_KeyStackEvent( KeyEvent event, MacEventType type ) : Event(event), Type(type) {}
+        
+        MacEventType Type;
+        KeyEvent Event;
+    } MacKeyStackEvent;
+ 
+    
+
+    // only used by MacMouse
+    typedef class Mac_MouseStackEvent
+    {
+        friend class MacMouse;
+        
+    private:
+        Mac_MouseStackEvent( MouseEvent event, MacEventType type,  MouseButtonID button) : Event(event), Type(type), Button(button) {}
+        
+        MacEventType Type;
+        MouseEvent Event;
+		MouseButtonID Button;
+        
+    } MacMouseStackEvent;
+        
+}
+
+
+#endif
Index: /code/branches/ceguilua/src/ois/mac/MacInputManager.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacInputManager.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacInputManager.cpp	(revision 1801)
@@ -0,0 +1,203 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "mac/MacInputManager.h"
+#include "mac/MacKeyboard.h"
+#include "mac/MacMouse.h"
+#include "mac/MacHIDManager.h"
+#include "OISException.h"
+
+#include <Carbon/Carbon.h>
+
+#include <iostream>
+using namespace std;
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------//
+MacInputManager::MacInputManager() : InputManager("Mac OSX Input Manager")
+{
+    mHideMouse = true;
+    mUseRepeat = false;
+    mEventTargetRef = NULL;
+	mWindow = NULL;
+
+	keyboardUsed = mouseUsed = false;
+
+	//Setup our internal factories
+	mFactories.push_back(this);
+
+	mHIDManager = new MacHIDManager();
+	mFactories.push_back(mHIDManager);
+}
+
+//--------------------------------------------------------------------------------//
+MacInputManager::~MacInputManager()
+{
+	delete mHIDManager;
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::_initialize( ParamList &paramList )
+{
+	_parseConfigSettings( paramList );
+    
+	//Enumerate all devices attached
+	_enumerateDevices();
+	
+	mHIDManager->initialize();
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::_parseConfigSettings( ParamList &paramList )
+{
+    // Some carbon apps are running in a window, however full screen apps
+	// do not have a window, so we need to account for that too.
+	ParamList::iterator i = paramList.find("WINDOW");
+	if(i != paramList.end())
+	{
+		mWindow = (WindowRef)strtoul(i->second.c_str(), 0, 10);
+		if(mWindow == 0)
+		{
+			mWindow = NULL;
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+		else
+		{
+			//mEventTargetRef = GetWindowEventTarget(mWindow);
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+    }
+	else
+	{
+		// else get the main active window.. user might not have access to it through some
+		// graphics libraries, if that fails then try at the application level.
+		mWindow = ActiveNonFloatingWindow();
+		if(mWindow == NULL)
+		{
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+		else
+		{
+			//mEventTargetRef = GetWindowEventTarget(mWindow);
+			mEventTargetRef = GetApplicationEventTarget();
+		}
+	}
+	
+	if(mEventTargetRef == NULL)
+		OIS_EXCEPT( E_General, "MacInputManager::_parseConfigSettings >> Unable to find a window or event target" );
+    
+    // Keyboard
+    if(paramList.find("MacAutoRepeatOn") != paramList.end())
+	{
+        if(paramList.find("MacAutoRepeatOn")->second == "true")
+		{
+            mUseRepeat = true;
+        }
+    }
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::_enumerateDevices()
+{
+}
+
+//--------------------------------------------------------------------------------//
+DeviceList MacInputManager::freeDeviceList()
+{
+	DeviceList ret;
+
+	if( keyboardUsed == false )
+		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
+
+	if( mouseUsed == false )
+		ret.insert(std::make_pair(OISMouse, mInputSystemName));
+
+	return ret;
+}
+
+//--------------------------------------------------------------------------------//
+int MacInputManager::totalDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return 1;
+	case OISMouse: return 1;
+	default: return 0;
+	}
+}
+
+//--------------------------------------------------------------------------------//
+int MacInputManager::freeDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return keyboardUsed ? 0 : 1;
+	case OISMouse: return mouseUsed ? 0 : 1;
+	default: return 0;
+	}
+}
+
+//--------------------------------------------------------------------------------//
+bool MacInputManager::vendorExist(Type iType, const std::string & vendor)
+{
+	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
+		return true;
+
+	return false;
+}
+
+//--------------------------------------------------------------------------------//
+Object* MacInputManager::createObject(InputManager* creator, Type iType, bool bufferMode, 
+									  const std::string & vendor)
+{
+	Object *obj = 0;
+
+	switch(iType)
+	{
+	case OISKeyboard: 
+	{
+		if( keyboardUsed == false )
+			obj = new MacKeyboard(this, bufferMode, mUseRepeat);
+		break;
+	}
+	case OISMouse:
+	{
+		if( mouseUsed == false )
+			obj = new MacMouse(this, bufferMode);
+		break;
+	}
+	default:
+		break;
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//--------------------------------------------------------------------------------//
+void MacInputManager::destroyObject(Object* obj)
+{
+	delete obj;
+}
Index: /code/branches/ceguilua/src/ois/mac/MacInputManager.h
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacInputManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacInputManager.h	(revision 1801)
@@ -0,0 +1,101 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacInputManager_H
+#define OIS_MacInputManager_H
+
+#include "OISInputManager.h"
+#include "OISFactoryCreator.h"
+#include "mac/MacPrereqs.h"
+#include <Carbon/Carbon.h>
+
+namespace OIS
+{
+    
+    class MacInputManager : public InputManager, public FactoryCreator
+    {
+    public:
+        MacInputManager();
+        virtual ~MacInputManager();
+        
+		//InputManager Overrides
+		/** @copydoc InputManager::_initialize */
+		void _initialize( ParamList &paramList );
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+		//Internal Items
+		//! Internal method, used for flaggin keyboard as available/unavailable for creation
+		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
+
+		//! Internal method, used for flaggin mouse as available/unavailable for creation
+		void _setMouseUsed(bool used) { mouseUsed = used; }
+        
+        //! methodfor getting the event target
+        EventTargetRef _getEventTarget() {return mEventTargetRef;}
+        
+        //! method for getting window
+        WindowRef _getWindow() {return mWindow;}
+        
+    protected:        
+        void _parseConfigSettings( ParamList& paramList );
+        
+        void _enumerateDevices();
+        
+        static const std::string iName;
+        
+        // Mac stuff
+		EventTargetRef mEventTargetRef;
+		WindowRef mWindow;
+        
+        // settings
+        bool mHideMouse;
+        bool mUseRepeat;
+
+		//! Used to know if we used up keyboard
+		bool keyboardUsed;
+
+		//! Used to know if we used up mouse
+		bool mouseUsed;
+		
+		//! HID Manager class handling devices other than keyboard/mouse
+		MacHIDManager *mHIDManager;
+    };
+}
+#endif
Index: /code/branches/ceguilua/src/ois/mac/MacKeyboard.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacKeyboard.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacKeyboard.cpp	(revision 1801)
@@ -0,0 +1,467 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+#include "mac/MacKeyboard.h"
+#include "mac/MacInputManager.h"
+#include "mac/MacHelpers.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include <Carbon/Carbon.h>
+
+#include <list>
+#include <string>
+
+const EventTypeSpec DownSpec[] = {{kEventClassKeyboard, kEventRawKeyDown},	//non - repeats
+							{kEventClassKeyboard, kEventRawKeyRepeat}}; //repeats
+const EventTypeSpec UpSpec = {kEventClassKeyboard, kEventRawKeyUp},
+			  ModSpec = {kEventClassKeyboard, kEventRawKeyModifiersChanged};
+
+const EventTypeSpec AllSpecs[] = {{kEventClassKeyboard, kEventRawKeyDown},
+						  {kEventClassKeyboard, kEventRawKeyRepeat},
+						  {kEventClassKeyboard, kEventRawKeyUp},
+						  {kEventClassKeyboard, kEventRawKeyModifiersChanged}};
+
+using namespace OIS;
+
+//-------------------------------------------------------------------//
+MacKeyboard::MacKeyboard( InputManager* creator, bool buffered, bool repeat )
+	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
+{
+	keyDownEventRef = NULL;
+	keyUpEventRef = NULL;
+	keyModEventRef = NULL;
+	
+	useRepeat = repeat;
+
+	// Get a so-called "Univeral procedure pointer" for our callback
+	keyDownUPP = NewEventHandlerUPP( KeyDownWrapper );
+	keyUpUPP   = NewEventHandlerUPP( KeyUpWrapper );
+	keyModUPP  = NewEventHandlerUPP( KeyModWrapper );
+	
+	// populate the conversion map
+	populateKeyConversion();
+
+	static_cast<MacInputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//-------------------------------------------------------------------//
+MacKeyboard::~MacKeyboard()
+{
+	// Remove our handlers so that this instance doesn't get called
+	// after it is deleted
+	if (keyDownEventRef != NULL)
+		RemoveEventHandler(keyDownEventRef);
+		
+	if (keyUpEventRef != NULL)
+		RemoveEventHandler(keyUpEventRef);
+	
+	if (keyModEventRef != NULL)
+		RemoveEventHandler(keyModEventRef);
+	
+	// dispose of our UPPs
+	DisposeEventHandlerUPP(keyDownUPP);
+	DisposeEventHandlerUPP(keyUpUPP);
+	DisposeEventHandlerUPP(keyModUPP);
+
+	//Free the input managers keyboard
+	static_cast<MacInputManager*>(mCreator)->_setKeyboardUsed(false);
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::_initialize()
+{
+	EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget();
+
+	memset( &KeyBuffer, 0, 256 );
+	mModifiers = 0;
+	prevModMask = 0;
+	
+	// just in case this gets called after the first time.. better safe
+	if (keyDownEventRef != NULL)
+		RemoveEventHandler(keyDownEventRef);
+		
+	if (keyUpEventRef != NULL)
+		RemoveEventHandler(keyUpEventRef);
+		
+	if (keyModEventRef != NULL)
+		RemoveEventHandler(keyModEventRef);
+   
+	keyDownEventRef = NULL;
+	keyUpEventRef = NULL;
+	keyModEventRef = NULL;
+
+	OSStatus status;
+	// send both elements of downspec array... second index is for repeat events
+	if ( useRepeat )
+		status = InstallEventHandler( event, keyDownUPP, 2, DownSpec, this, &keyDownEventRef );
+	else
+		status = InstallEventHandler( event, keyDownUPP, 1, DownSpec, this, &keyDownEventRef );
+		
+	if (status != noErr)
+		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyDown event handler" );
+
+	if (InstallEventHandler( event, keyUpUPP, 1, &UpSpec, this, &keyUpEventRef ) != noErr)
+		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading KeyUp event handler" );
+
+	if (InstallEventHandler( event, keyModUPP, 1, &ModSpec, this, &keyModEventRef ) != noErr )
+		OIS_EXCEPT( E_General, "MacKeyboard::_initialize >> Error loading Keymods event handler" );
+}
+
+//-------------------------------------------------------------------//
+bool MacKeyboard::isKeyDown( KeyCode key ) const
+{
+	return (bool)KeyBuffer[key];
+}
+
+
+//-------------------------------------------------------------------//
+void MacKeyboard::capture()
+{
+	// if not buffered just return, we update the unbuffered automatically
+	if ( !mBuffered || !mListener )
+		return;
+	
+	//If the mListener returns false, that means that we are probably deleted...
+	//send no more events and just leave as the this pointer is invalid now...
+	bool ret = true;
+	
+	// run through our event stack
+	eventStack::iterator cur_it;
+	
+	for (cur_it = pendingEvents.begin(); cur_it != pendingEvents.end(); cur_it++)
+	{
+		
+		if ( (*cur_it).Type == MAC_KEYDOWN || (*cur_it).Type == MAC_KEYREPEAT)
+			mListener->keyPressed( (*cur_it).Event );
+		else if ( (*cur_it).Type == MAC_KEYUP )
+			mListener->keyReleased( (*cur_it).Event );
+	}
+	
+	pendingEvents.clear();
+}
+
+
+//-------------------------------------------------------------------//
+std::string& MacKeyboard::getAsString( KeyCode key )
+{
+	getString = "";
+	
+	return getString;
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::setBuffered( bool buffered )
+{
+	mBuffered = buffered;
+}
+
+#include <iostream>
+//-------------------------------------------------------------------//
+void MacKeyboard::_keyDownCallback( EventRef theEvent )
+{
+	
+	UInt32 virtualKey;
+	OSStatus status;
+	
+	unsigned int time = (unsigned int)GetEventTime(theEvent);
+	
+	status = GetEventParameter(theEvent,
+					'kcod',			// get it in virtual keycode
+					typeUInt32, NULL,	// desired return type
+					sizeof(UInt32), NULL, 	// bufsize
+					&virtualKey );
+	
+	KeyCode kc = keyConversion[virtualKey];
+
+	// record what kind of text we should pass the KeyEvent
+	UniChar text[10];
+	char macChar;
+	
+	// TODO clean this up
+	if (mTextMode == Unicode)
+	{
+		//get string size
+		UInt32 stringsize;
+		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL);
+		//status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text );
+		status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text );
+		std::cout << "String length: " << stringsize << std::endl;
+		
+		//wstring unitext;
+		//for (int i=0;i<10;i++) unitext += (wchar_t)text[i];
+		//wcout << "Unicode out: " << unitext << endl;
+		
+		if(stringsize > 0)
+		{
+			// for each unicode char, send an event
+			stringsize--; // no termination char
+			for ( int i = 0; i < stringsize; i++ )
+			{
+				injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)text[i] );
+			}
+		}
+	} 
+	else if (mTextMode == Ascii)
+	{
+		 
+		status = GetEventParameter( theEvent, 'kchr', typeChar, NULL, sizeof(char), NULL, &macChar );
+		injectEvent( kc, time, MAC_KEYDOWN, (unsigned int)macChar );
+	}
+	else
+	{
+		injectEvent( kc, time, MAC_KEYDOWN );
+	}
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::_keyUpCallback( EventRef theEvent )
+{
+	UInt32 virtualKey;
+	
+	OSStatus status;
+	status = GetEventParameter( theEvent, kEventParamKeyCode, typeUInt32,
+								NULL, sizeof(UInt32), NULL, &virtualKey );
+	
+	KeyCode kc = keyConversion[virtualKey];
+	injectEvent( kc, (int)GetEventTime(theEvent), MAC_KEYUP );
+	
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::_modChangeCallback( EventRef theEvent )
+{
+	UInt32 mods;
+	
+	OSStatus status;
+	status = GetEventParameter( theEvent, kEventParamKeyModifiers,
+								typeUInt32, NULL, sizeof(UInt32), NULL, &mods );
+	
+	// find the changed bit
+	UInt32 change = prevModMask ^ mods;
+	MacEventType newstate = ((change & prevModMask) > 0) ? MAC_KEYUP : MAC_KEYDOWN;
+	unsigned int time = (int)GetEventTime( theEvent );
+	
+	//cout << "preMask: " << hex << prevModMask << endl;
+	//cout << "ModMask: " << hex << mods << endl;
+	//cout << "Change:  " << hex << (change & prevModMask) << endl << endl;
+	
+	// TODO test modifiers on a full keyboard to check if different mask for left/right
+	switch (change)
+	{
+		case (shiftKey): // shift
+			mModifiers &= (newstate == MAC_KEYDOWN) ? Shift : ~Shift;
+			injectEvent( KC_LSHIFT, time, newstate );
+			//injectEvent( KC_RSHIFT, time, newstate );
+			break;
+			
+		case (optionKey): // option (alt)
+			mModifiers &= (newstate == MAC_KEYDOWN) ? Alt : -Alt;
+			//injectEvent( KC_RMENU, time, newstate );
+			injectEvent( KC_LMENU, time, newstate );
+			break;
+			
+		case (controlKey): // Ctrl
+			mModifiers += (newstate == MAC_KEYDOWN) ? Ctrl : -Ctrl;
+			//injectEvent( KC_RCONTROL, time, newstate );
+			injectEvent( KC_LCONTROL, time, newstate );
+			break;
+	
+		case (cmdKey): // apple
+			//injectEvent( KC_RWIN, time, newstate );
+			injectEvent( KC_LWIN, time, newstate );
+			break;
+	
+		case (kEventKeyModifierFnMask): // fn key
+			injectEvent( KC_APPS, time, newstate );
+			break;
+			
+		case (kEventKeyModifierNumLockMask): // numlock
+			injectEvent( KC_NUMLOCK, time, newstate );
+			break;
+			
+		case (alphaLock): // caps lock
+			injectEvent( KC_CAPITAL, time, newstate );
+			break;
+	}
+	
+	prevModMask = mods;
+}
+
+//-------------------------------------------------------------------//
+void MacKeyboard::injectEvent( KeyCode kc, unsigned int time, MacEventType type, unsigned int txt )
+{
+	// set to 1 if this is either a keydown or repeat
+	KeyBuffer[kc] = ( type == MAC_KEYUP ) ? 0 : 1;
+	
+	if ( mBuffered && mListener )
+		pendingEvents.push_back( MacKeyStackEvent( KeyEvent(this, kc, txt), type) );
+}
+
+
+//-------------------------------------------------------------------//
+void MacKeyboard::copyKeyStates( char keys[256] ) const
+{
+	memcpy( keys, KeyBuffer, 256 );
+}
+
+
+
+//-------------------------------------------------------------------//
+void MacKeyboard::populateKeyConversion()
+{
+	// TODO finish the key mapping
+	
+	// Virtual Key Map to KeyCode
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x12, KC_1));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x13, KC_2));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x14, KC_3));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x15, KC_4));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x17, KC_5));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x16, KC_6));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1A, KC_7));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1C, KC_8));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x19, KC_9));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1D, KC_0));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x33, KC_BACK));  // might be wrong
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1B, KC_MINUS));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x18, KC_EQUALS));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x31, KC_SPACE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2B, KC_COMMA));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2F, KC_PERIOD));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2A, KC_BACKSLASH));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2C, KC_SLASH));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x21, KC_LBRACKET));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1E, KC_RBRACKET));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x35, KC_ESCAPE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x39, KC_CAPITAL));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x30, KC_TAB));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x24, KC_RETURN));  // double check return/enter
+	
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_colon, KC_COLON));	 // no colon?
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x29, KC_SEMICOLON));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x27, KC_APOSTROPHE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x32, KC_GRAVE));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0B, KC_B));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x00, KC_A));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x08, KC_C));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x02, KC_D));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0E, KC_E));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x03, KC_F));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x05, KC_G));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x04, KC_H));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x22, KC_I));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x26, KC_J));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x28, KC_K));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x25, KC_L));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2E, KC_M));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x2D, KC_N));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x1F, KC_O));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x23, KC_P));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0C, KC_Q));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0F, KC_R));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x01, KC_S));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x11, KC_T));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x20, KC_U));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x09, KC_V));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x0D, KC_W));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x07, KC_X));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x10, KC_Y));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x06, KC_Z));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7A, KC_F1));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x78, KC_F2));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x63, KC_F3));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x76, KC_F4));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x60, KC_F5));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x61, KC_F6));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x62, KC_F7));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x64, KC_F8));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x65, KC_F9));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6D, KC_F10));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x67, KC_F11));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6F, KC_F12));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x69, KC_F13));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x6B, KC_F14));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x71, KC_F15));
+	
+	//Keypad
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x52, KC_NUMPAD0));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x53, KC_NUMPAD1));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x54, KC_NUMPAD2));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x55, KC_NUMPAD3));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x56, KC_NUMPAD4));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x57, KC_NUMPAD5));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x58, KC_NUMPAD6));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x59, KC_NUMPAD7));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5B, KC_NUMPAD8));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x5C, KC_NUMPAD9));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x45, KC_ADD));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4E, KC_SUBTRACT));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x41, KC_DECIMAL));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x51, KC_NUMPADEQUALS));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4B, KC_DIVIDE));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x43, KC_MULTIPLY));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x4C, KC_NUMPADENTER));
+	
+	//Keypad with numlock off
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_NUMPAD7));  // not sure of these
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Up, KC_NUMPAD8)); // check on a non-laptop
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Up, KC_NUMPAD9));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Left, KC_NUMPAD4));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Begin, KC_NUMPAD5));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Right, KC_NUMPAD6));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_End, KC_NUMPAD1));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Down, KC_NUMPAD2));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Page_Down, KC_NUMPAD3));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Insert, KC_NUMPAD0));
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_KP_Delete, KC_DECIMAL));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7E, KC_UP));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7D, KC_DOWN));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7B, KC_LEFT));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x7C, KC_RIGHT));
+	
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x74, KC_PGUP));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x79, KC_PGDOWN));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x73, KC_HOME));
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x77, KC_END));
+	
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Print, KC_SYSRQ));		// ??
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Scroll_Lock, KC_SCROLL)); // ??
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Pause, KC_PAUSE));		// ??
+	
+	
+	//keyConversion.insert(VirtualtoOIS_KeyMap::value_type(XK_Insert, KC_INSERT));	  // ??
+	keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key?
+}
+
+
+
+
Index: /code/branches/ceguilua/src/ois/mac/MacKeyboard.h
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacKeyboard.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacKeyboard.h	(revision 1801)
@@ -0,0 +1,102 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacKeyboard_H
+#define OIS_MacKeyboard_H
+
+#include "OISKeyboard.h"
+#include "mac/MacHelpers.h"
+#include "mac/MacPrereqs.h"
+
+#include <Carbon/Carbon.h>
+
+namespace OIS
+{
+    
+    class MacKeyboard : public Keyboard
+    {
+    public:
+        MacKeyboard( InputManager* creator, bool buffered, bool repeat );
+        virtual ~MacKeyboard();
+        
+        // Sets buffered mode
+        virtual void setBuffered( bool buffered );
+        
+        // unbuffered keydown check
+        virtual bool isKeyDown( KeyCode key ) const;
+        
+        // This will send listener events if buffered is on.
+        // Note that in the mac implementation, unbuffered input is
+        // automatically updated without calling this.
+        virtual void capture();
+        
+        // Copies the current key buffer
+        virtual void copyKeyStates( char keys[256] ) const;
+        
+        // Returns a description of the given key
+        virtual std::string& getAsString( KeyCode key );
+        
+        virtual Interface* queryInterface( Interface::IType type ) { return 0; }
+        
+        
+        // Public but reserved for internal use:
+        virtual void _initialize();
+        void _keyDownCallback( EventRef theEvent );
+        void _keyUpCallback( EventRef theEvent );
+        void _modChangeCallback( EventRef theEvent );
+        
+
+    protected:
+        // just to get this out of the way
+        void populateKeyConversion();
+        
+        // updates the keybuffer and optionally the eventStack
+        void injectEvent(KeyCode kc, unsigned int time, MacEventType type, unsigned int txt = 0 );
+                
+        typedef std::map<UInt32, KeyCode> VirtualtoOIS_KeyMap;
+        VirtualtoOIS_KeyMap keyConversion;
+        
+        std::string getString;
+        
+        char KeyBuffer[256];
+        UInt32 prevModMask;
+        
+        
+        // "universal procedure pointers" - required reference for callbacks
+        EventHandlerUPP keyDownUPP;
+        EventHandlerUPP keyUpUPP;
+        EventHandlerUPP keyModUPP;
+        
+        // so we can delete the handlers on destruction
+        EventHandlerRef keyDownEventRef;
+        EventHandlerRef keyUpEventRef;
+        EventHandlerRef keyModEventRef;
+        
+        // buffered events, fifo stack
+        typedef std::list<MacKeyStackEvent> eventStack;
+        eventStack pendingEvents;
+        
+        bool useRepeat;
+        
+    };
+}
+#endif
Index: /code/branches/ceguilua/src/ois/mac/MacMouse.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacMouse.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacMouse.cpp	(revision 1801)
@@ -0,0 +1,346 @@
+#include "mac/MacMouse.h"
+#include "mac/MacInputManager.h"
+#include "mac/MacHelpers.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+#include <Carbon/Carbon.h>
+
+#include <list>
+
+#include <iostream>
+
+using namespace OIS;
+
+//Events we subscribe to and remove from queue
+const EventTypeSpec mouseEvents[] = {
+	{ kEventClassMouse, kEventMouseDown },
+	{ kEventClassMouse, kEventMouseUp },
+	{ kEventClassMouse, kEventMouseMoved },
+	{ kEventClassMouse, kEventMouseDragged },
+	{ kEventClassMouse, kEventMouseWheelMoved }		
+};
+
+const EventTypeSpec WinFocusAcquired [] = {{kEventClassApplication, kEventAppDeactivated}};
+
+//-------------------------------------------------------------------//
+MacMouse::MacMouse( InputManager* creator, bool buffered )
+	: Mouse(creator->inputSystemName(), buffered, 0, creator), mNeedsToRegainFocus( false )
+{
+    mouseEventRef = NULL;
+	mWindowFocusHandler = NULL;
+
+    // Get a "Univeral procedure pointer" for our callback
+    mouseUPP = NewEventHandlerUPP(MouseWrapper);
+	mWindowFocusListener = NewEventHandlerUPP(WindowFocusChanged);
+
+	static_cast<MacInputManager*>(mCreator)->_setMouseUsed(true);
+}
+
+MacMouse::~MacMouse()
+{
+    if(mouseEventRef != NULL)
+		RemoveEventHandler(mouseEventRef);
+
+	if(mWindowFocusHandler != NULL)
+		RemoveEventHandler(mWindowFocusHandler);
+	
+	DisposeEventHandlerUPP(mouseUPP);
+	DisposeEventHandlerUPP(mWindowFocusListener);
+	
+	// Restore Mouse
+	CGAssociateMouseAndMouseCursorPosition(TRUE);
+	CGDisplayShowCursor(kCGDirectMainDisplay);
+
+	static_cast<MacInputManager*>(mCreator)->_setMouseUsed(false);
+}
+
+void MacMouse::_initialize()
+{
+	mState.clear();
+	mTempState.clear();
+	mMouseWarped = false;
+	
+	// Hide OS Mouse
+ 	CGDisplayHideCursor(kCGDirectMainDisplay);
+
+	MacInputManager* im = static_cast<MacInputManager*>(mCreator);
+	WindowRef win = im->_getWindow();
+	
+	if(win)
+	{
+		Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
+		GetWindowBounds(win, kWindowContentRgn, &clipRect);
+		
+		CGPoint warpPoint;
+		warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left;
+		warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top;
+		CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin
+		
+		mMouseWarped = true;
+	}
+
+	//Now that mouse is warped, start listening for events
+	EventTargetRef event = ((MacInputManager*)mCreator)->_getEventTarget();
+    
+	if(mouseEventRef != NULL)
+		RemoveEventHandler(mouseEventRef);
+		
+	if(mWindowFocusHandler != NULL)
+		RemoveEventHandler(mWindowFocusHandler);
+
+	mouseEventRef = mWindowFocusHandler = NULL;
+
+	if(InstallEventHandler(event, mouseUPP, GetEventTypeCount(mouseEvents), mouseEvents, this, &mouseEventRef) != noErr)
+		OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" );
+
+	if(InstallEventHandler(event, mWindowFocusListener, GetEventTypeCount(WinFocusAcquired), WinFocusAcquired, this, &mWindowFocusHandler) != noErr)
+		OIS_EXCEPT( E_General, "MacMouse::_initialize >> Error loading Mouse event handler" );		
+
+	//Lock OS Mouse movement
+	mNeedsToRegainFocus = false;
+	CGAssociateMouseAndMouseCursorPosition(FALSE);
+}
+
+OSStatus MacMouse::WindowFocusChanged(EventHandlerCallRef nextHandler, EventRef event, void* macMouse)
+{
+	//std::cout << "Window Focus Changed\n";
+
+	MacMouse* _this = static_cast<MacMouse*>(macMouse);
+    if (_this)
+	{
+		_this->mNeedsToRegainFocus = true;
+		CGAssociateMouseAndMouseCursorPosition(TRUE);
+
+        // propagate the event down the chain
+        return CallNextEventHandler(nextHandler, event);
+    }
+    else
+        OIS_EXCEPT(E_General, "MouseWrapper >> Being called by something other than our event handler!");
+}
+
+void MacMouse::setBuffered( bool buffered )
+{
+	mBuffered = buffered;
+}
+
+void MacMouse::capture()
+{
+	mState.X.rel = 0;
+	mState.Y.rel = 0;
+	mState.Z.rel = 0;
+	    
+	if(mTempState.X.rel || mTempState.Y.rel || mTempState.Z.rel)
+	{
+		//printf("%i %i %i\n\n", mTempState.X.rel, mTempState.Y.rel, mTempState.Z.rel);
+
+		//Set new relative motion values
+		mState.X.rel = mTempState.X.rel;
+		mState.Y.rel = mTempState.Y.rel;
+		mState.Z.rel = mTempState.Z.rel;
+		
+		//Update absolute position
+		mState.X.abs += mTempState.X.rel;
+		mState.Y.abs += mTempState.Y.rel;
+		
+		if(mState.X.abs > mState.width)
+			mState.X.abs = mState.width;
+		else if(mState.X.abs < 0)
+			mState.X.abs = 0;
+
+		if(mState.Y.abs > mState.height)
+			mState.Y.abs = mState.height;
+		else if(mState.Y.abs < 0)
+			mState.Y.abs = 0;
+			
+		mState.Z.abs += mTempState.Z.rel;
+		
+		//Fire off event
+		if(mListener && mBuffered)
+			mListener->mouseMoved(MouseEvent(this, mState));
+	}
+
+	mTempState.clear();
+}
+
+void MacMouse::_mouseCallback( EventRef theEvent )
+{
+	OSStatus result = eventNotHandledErr;
+    UInt32 kind = GetEventKind (theEvent);
+
+	switch(kind)
+	{
+		case kEventMouseDragged:
+		case kEventMouseMoved:
+		{
+			//HIPoint location = {0.0f, 0.0f};
+			HIPoint delta = {0.0f, 0.0f};
+			//Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
+			
+			if(mNeedsToRegainFocus)
+				break;
+
+			// Capture the parameters
+			// TODO: Look into HIViewNewTrackingArea
+			//GetEventParameter(theEvent, kEventParamMouseLocation, typeHIPoint, NULL, sizeof(HIPoint), NULL, &location);
+			GetEventParameter(theEvent, kEventParamMouseDelta, typeHIPoint, NULL, sizeof(HIPoint), NULL, &delta);
+			
+			// Mouse X and Y are the position on the screen, 
+			// startng from top-left at 0,0 caps at full monitor resolution
+			
+			// If we have a window we need to return adjusted coordinates
+			// If not, just use raw coordinates - only do this if showing OS mouse
+			//MacInputManager* im = static_cast<MacInputManager*>(mCreator);
+			//WindowRef win = im->_getWindow();
+			
+			//if(win != NULL)
+			//{
+			//	GetWindowBounds(win, kWindowContentRgn, &clipRect);
+			//}
+            //else
+            //{
+            //    clipRect.right = mState.width;
+            //    clipRect.bottom = mState.height;
+            //}
+                
+            // clip the mouse, absolute positioning
+            //if (location.x <= clipRect.left)
+			//	mState.X.abs = 0;
+			//else if(location.x >= clipRect.right)
+			//	mState.X.abs = clipRect.right - clipRect.left;
+			//else
+			//	mState.X.abs = location.x - clipRect.left;
+			
+			//if (location.y <= clipRect.top)
+			//	mState.Y.abs = 0;
+			//else if(location.y >= clipRect.bottom)
+			//	mState.Y.abs = clipRect.bottom - clipRect.top;
+			//else
+			//	mState.Y.abs = location.y - clipRect.top;
+			
+			// relative positioning
+			if(!mMouseWarped)
+			{
+				mTempState.X.rel += delta.x;
+				mTempState.Y.rel += delta.y;
+			}
+			
+			mMouseWarped = false;
+
+			break;
+		}
+		case kEventMouseDown:
+		{
+			EventMouseButton button = 0;
+			int mouseButton = 3;
+			UInt32 modifiers = 0;
+			
+			if(mNeedsToRegainFocus)
+				break;
+
+			// Capture parameters
+			GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
+			GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
+			
+			if((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey)))
+			{
+				mouseButton = 2;
+				mState.buttons |= 1 << mouseButton;
+			}
+            else if((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey)))
+            {	
+                mouseButton = 1;
+                mState.buttons |= 1 << mouseButton;
+            }
+            else if(button == kEventMouseButtonPrimary)
+            {
+                mouseButton = 0;
+                mState.buttons |= 1 << mouseButton;
+            }
+
+            if( mListener && mBuffered )
+                mListener->mousePressed( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+
+            break;
+		}
+		case kEventMouseUp:
+		{
+			EventMouseButton button = 0;
+			int mouseButton = 3;
+			UInt32 modifiers = 0;
+			
+			if(mNeedsToRegainFocus)
+			{
+				mNeedsToRegainFocus = false;
+				CGAssociateMouseAndMouseCursorPosition(false);
+				
+				MacInputManager* im = static_cast<MacInputManager*>(mCreator);
+				WindowRef win = im->_getWindow();
+				
+				if(win)
+				{
+					Rect clipRect = {0.0f, 0.0f, 0.0f, 0.0f};
+					GetWindowBounds(win, kWindowContentRgn, &clipRect);
+					
+					CGPoint warpPoint;
+					warpPoint.x = ((clipRect.right - clipRect.left) / 2) + clipRect.left;
+					warpPoint.y = ((clipRect.bottom - clipRect.top) / 2) + clipRect.top;
+					CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, warpPoint); //Place at display origin
+					
+					CGDisplayHideCursor(kCGDirectMainDisplay);
+					
+					mMouseWarped = true;
+				}
+				
+				//Once we regain focus, we do not really know what state all the buttons are in - for now, set to not pressed. todo, check current status
+				//compare against old status, and send off any needed events
+				mState.buttons = 0;
+				
+				break;
+			}
+			
+			// Capture parameters
+			GetEventParameter(theEvent, kEventParamMouseButton, typeMouseButton, NULL, sizeof(EventMouseButton), NULL, &button);
+			GetEventParameter(theEvent, kEventParamKeyModifiers, typeUInt32, NULL, sizeof(UInt32), NULL, &modifiers);
+			
+			if ((button == kEventMouseButtonTertiary) || ((button == kEventMouseButtonPrimary) && (modifiers & optionKey)))
+			{
+				mouseButton = 2;
+				mState.buttons &= ~(1 << mouseButton);
+			}
+            else if ((button == kEventMouseButtonSecondary) || ((button == kEventMouseButtonPrimary) && (modifiers & controlKey)))
+            {	
+                mouseButton = 1;
+                mState.buttons &= ~(1 << mouseButton);
+            }
+            else if (button == kEventMouseButtonPrimary)
+            {
+                mouseButton = 0;
+                mState.buttons &= ~(1 << mouseButton);
+            }
+
+            if( mListener && mBuffered )
+                mListener->mouseReleased( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+
+            break;
+		}
+		case kEventMouseWheelMoved:
+		{
+			SInt32 wheelDelta = 0;
+			EventMouseWheelAxis	wheelAxis = 0; 
+
+			// Capture parameters
+			GetEventParameter(theEvent, kEventParamMouseWheelAxis, typeMouseWheelAxis, NULL, sizeof(EventMouseWheelAxis), NULL, &wheelAxis);
+			GetEventParameter(theEvent, kEventParamMouseWheelDelta, typeSInt32, NULL, sizeof(SInt32), NULL, &wheelDelta);
+			
+			// If the Y axis of the wheel changed, then update the Z
+			// Does OIS care about the X wheel axis?
+			if(wheelAxis == kEventMouseWheelAxisY)
+				mTempState.Z.rel += (wheelDelta * 60);
+
+            break;
+		}
+		default:
+			break;
+	}    
+}
Index: /code/branches/ceguilua/src/ois/mac/MacMouse.h
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacMouse.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacMouse.h	(revision 1801)
@@ -0,0 +1,51 @@
+#ifndef OIS_MacMouse_H
+#define OIS_MacMouse_H
+
+#include "OISMouse.h"
+#include "mac/MacHelpers.h"
+#include "mac/MacPrereqs.h"
+
+#include <Carbon/Carbon.h>
+
+namespace OIS
+{
+	class MacMouse : public Mouse
+    {
+	public:
+		MacMouse( InputManager* creator, bool buffered );
+		virtual ~MacMouse();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+        
+	public:
+        void _mouseCallback( EventRef theEvent );
+
+	protected:
+		static OSStatus WindowFocusChanged(EventHandlerCallRef nextHandler, EventRef event, void* macMouse);
+        
+        // "universal procedure pointers" - required reference for callbacks
+		EventHandlerUPP mouseUPP;
+		EventHandlerRef mouseEventRef;
+		
+		EventHandlerUPP mWindowFocusListener;
+		EventHandlerRef mWindowFocusHandler;
+		
+		bool mNeedsToRegainFocus;
+		bool mMouseWarped;
+		
+		MouseState mTempState;
+	};
+}
+
+
+#endif // OIS_MacMouse_H
Index: /code/branches/ceguilua/src/ois/mac/MacPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/ois/mac/MacPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/mac/MacPrereqs.h	(revision 1801)
@@ -0,0 +1,57 @@
+/*
+ The zlib/libpng License
+ 
+ Copyright (c) 2006 Chris Snyder 
+ 
+ This software is provided 'as-is', without any express or implied warranty. In no event will
+ the authors be held liable for any damages arising from the use of this software.
+ 
+ Permission is granted to anyone to use this software for any purpose, including commercial 
+ applications, and to alter it and redistribute it freely, subject to the following
+ restrictions:
+ 
+ 1. The origin of this software must not be misrepresented; you must not claim that 
+ you wrote the original software. If you use this software in a product, 
+ an acknowledgment in the product documentation would be appreciated but is 
+ not required.
+ 
+ 2. Altered source versions must be plainly marked as such, and must not be 
+ misrepresented as being the original software.
+ 
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_MacPrereqs_H
+#define OIS_MacPrereqs_H
+
+#include <string>
+#include <list>
+#include <CoreFoundation/CoreFoundation.h>
+
+namespace OIS
+{
+    class MacInputManager;
+	class MacHIDManager;
+	class MacMouse;
+    class MacKeyboard;
+
+	/** 
+		Simple wrapper class for CFString which will create a valid CFString and retain ownership until class instance is outof scope
+		To Access the CFStringRef instance, simply cast to void*, pass into a function expecting a void* CFStringRef object, or access via cf_str() method
+	*/
+	class OIS_CFString
+	{
+	public:
+		OIS_CFString() { m_StringRef = CFStringCreateWithCString(NULL, "", kCFStringEncodingUTF8); }
+		OIS_CFString(const char* c_str) { m_StringRef = CFStringCreateWithCString(NULL, c_str, kCFStringEncodingUTF8); }
+		OIS_CFString(const std::string &s_str) { m_StringRef = CFStringCreateWithCString(NULL, s_str.c_str(), kCFStringEncodingUTF8); }
+		~OIS_CFString() { CFRelease(m_StringRef); }
+
+		//Allow this class to be autoconverted to base class of StringRef (void*)
+		operator void*() { return (void*)m_StringRef; }
+		CFStringRef cf_str() { return m_StringRef; }
+	
+	private:
+		CFStringRef m_StringRef;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/win32/Win32ForceFeedback.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32ForceFeedback.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32ForceFeedback.cpp	(revision 1801)
@@ -0,0 +1,334 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32ForceFeedback.h"
+#include "OISException.h"
+#include <Math.h>
+
+#if defined (_DEBUG)
+  #include <sstream>
+#endif
+
+using namespace OIS;
+
+//--------------------------------------------------------------//
+Win32ForceFeedback::Win32ForceFeedback(IDirectInputDevice8* joy) :
+	mHandles(0), mJoyStick(joy)
+{
+}
+
+//--------------------------------------------------------------//
+Win32ForceFeedback::~Win32ForceFeedback()
+{
+	//Get the effect - if it exists
+	for(EffectList::iterator i = mEffectList.begin(); i != mEffectList.end(); ++i )
+	{
+		LPDIRECTINPUTEFFECT dxEffect = i->second;
+		if( dxEffect )
+			dxEffect->Unload();
+	}
+
+	mEffectList.clear();
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::upload( const Effect* effect )
+{
+	switch( effect->force )
+	{
+		case OIS::Effect::ConstantForce: _updateConstantEffect(effect);	break;
+		case OIS::Effect::RampForce: _updateRampEffect(effect);	break;
+		case OIS::Effect::PeriodicForce: _updatePeriodicEffect(effect);	break;
+		case OIS::Effect::ConditionalForce:	_updateConditionalEffect(effect); break;
+		//case OIS::Effect::CustomForce: _updateCustomEffect(effect); break;
+		default: OIS_EXCEPT(E_NotImplemented, "Requested Force not Implemented yet, sorry!"); break;
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::modify( const Effect* eff )
+{
+	//Modifying is essentially the same as an upload, so, just reuse that function
+	upload(eff);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::remove( const Effect* eff )
+{
+	//Get the effect - if it exists
+	EffectList::iterator i = mEffectList.find(eff->_handle);
+	if( i != mEffectList.end() )
+	{
+		LPDIRECTINPUTEFFECT dxEffect = i->second;
+		if( dxEffect )
+		{
+			dxEffect->Stop();
+			//We care about the return value - as the effect might not
+			//have been unlaoded
+			if( SUCCEEDED(dxEffect->Unload()) )
+				mEffectList.erase(i);
+		}
+		else
+			mEffectList.erase(i);
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::setMasterGain( float level )
+{
+	//Between 0 - 10,000
+	int gain_level = (int)(10000.0f * level);
+
+	if( gain_level > 10000 )
+		gain_level = 10000;
+	else if( gain_level < 0 )
+		gain_level = 0;
+
+	DIPROPDWORD DIPropGain;
+	DIPropGain.diph.dwSize       = sizeof(DIPropGain);
+	DIPropGain.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	DIPropGain.diph.dwObj        = 0;
+	DIPropGain.diph.dwHow        = DIPH_DEVICE;
+	DIPropGain.dwData            = gain_level;
+
+	mJoyStick->SetProperty(DIPROP_FFGAIN, &DIPropGain.diph);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::setAutoCenterMode( bool auto_on )
+{
+	//DI Property DIPROPAUTOCENTER_OFF = 0, 1 is on
+	DIPROPDWORD DIPropAutoCenter;
+	DIPropAutoCenter.diph.dwSize       = sizeof(DIPropAutoCenter);
+	DIPropAutoCenter.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	DIPropAutoCenter.diph.dwObj        = 0;
+	DIPropAutoCenter.diph.dwHow        = DIPH_DEVICE;
+	DIPropAutoCenter.dwData            = auto_on;
+
+	//hr =
+	mJoyStick->SetProperty(DIPROP_AUTOCENTER, &DIPropAutoCenter.diph);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateConstantEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DICONSTANTFORCE cf;
+	DIEFFECT        diEffect;
+
+	//Currently only support 1 axis
+	//if( effect->getNumAxes() == 1 )
+	cf.lMagnitude = static_cast<ConstantEffect*>(effect->getForceEffect())->level;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DICONSTANTFORCE), &cf, effect);
+	_upload(GUID_ConstantForce, &diEffect, effect);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateRampEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DIRAMPFORCE     rf;
+	DIEFFECT        diEffect;
+
+	//Currently only support 1 axis
+	rf.lStart = static_cast<RampEffect*>(effect->getForceEffect())->startLevel;
+	rf.lEnd = static_cast<RampEffect*>(effect->getForceEffect())->endLevel;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DIRAMPFORCE), &rf, effect);
+	_upload(GUID_RampForce, &diEffect, effect);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updatePeriodicEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DIPERIODIC      pf;
+	DIEFFECT        diEffect;
+
+	//Currently only support 1 axis
+	pf.dwMagnitude = static_cast<PeriodicEffect*>(effect->getForceEffect())->magnitude;
+	pf.lOffset = static_cast<PeriodicEffect*>(effect->getForceEffect())->offset;
+	pf.dwPhase = static_cast<PeriodicEffect*>(effect->getForceEffect())->phase;
+	pf.dwPeriod = static_cast<PeriodicEffect*>(effect->getForceEffect())->period;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DIPERIODIC), &pf, effect);
+
+	switch( effect->type )
+	{
+	case OIS::Effect::Square: _upload(GUID_Square, &diEffect, effect); break;
+	case OIS::Effect::Triangle: _upload(GUID_Triangle, &diEffect, effect); break;
+	case OIS::Effect::Sine: _upload(GUID_Sine, &diEffect, effect); break;
+	case OIS::Effect::SawToothUp: _upload(GUID_SawtoothUp, &diEffect, effect); break;
+	case OIS::Effect::SawToothDown:	_upload(GUID_SawtoothDown, &diEffect, effect); break;
+	default: break;
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateConditionalEffect( const Effect* effect )
+{
+	DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	LONG            rglDirection[2] = { 0, 0 };
+	DICONDITION     cf;
+	DIEFFECT        diEffect;
+
+	cf.lOffset = static_cast<ConditionalEffect*>(effect->getForceEffect())->deadband;
+	cf.lPositiveCoefficient = static_cast<ConditionalEffect*>(effect->getForceEffect())->rightCoeff;
+	cf.lNegativeCoefficient = static_cast<ConditionalEffect*>(effect->getForceEffect())->leftCoeff;
+	cf.dwPositiveSaturation = static_cast<ConditionalEffect*>(effect->getForceEffect())->rightSaturation;
+	cf.dwNegativeSaturation = static_cast<ConditionalEffect*>(effect->getForceEffect())->leftSaturation;
+	cf.lDeadBand = static_cast<ConditionalEffect*>(effect->getForceEffect())->deadband;
+
+	_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DICONDITION), &cf, effect);
+
+	switch( effect->type )
+	{
+	case OIS::Effect::Friction:	_upload(GUID_Friction, &diEffect, effect); break;
+	case OIS::Effect::Damper: _upload(GUID_Damper, &diEffect, effect); break;
+	case OIS::Effect::Inertia: _upload(GUID_Inertia, &diEffect, effect); break;
+	case OIS::Effect::Spring: _upload(GUID_Spring, &diEffect, effect); break;
+	default: break;
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_updateCustomEffect( const Effect* /*effect*/ )
+{
+	//DWORD           rgdwAxes[2]     = { DIJOFS_X, DIJOFS_Y };
+	//LONG            rglDirection[2] = { 0, 0 };
+	//DICUSTOMFORCE cf;
+	//DIEFFECT        diEffect;
+	//cf.cChannels = 0;
+	//cf.dwSamplePeriod = 0;
+	//cf.cSamples = 0;
+	//cf.rglForceData = 0;
+	//_setCommonProperties(&diEffect, rgdwAxes, rglDirection, sizeof(DICUSTOMFORCE), &cf, effect);
+	//_upload(GUID_CustomForce, &diEffect, effect);
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_setCommonProperties(
+		DIEFFECT* diEffect, DWORD* rgdwAxes,
+		LONG* rglDirection, DWORD struct_size,
+		LPVOID struct_type, const Effect* effect )
+{
+	ZeroMemory(diEffect, sizeof(DIEFFECT));
+
+	diEffect->dwSize                  = sizeof(DIEFFECT);
+	diEffect->dwFlags                 = DIEFF_CARTESIAN | DIEFF_OBJECTOFFSETS;
+	diEffect->dwDuration              = effect->replay_length;
+	diEffect->dwSamplePeriod          = 0;
+	diEffect->dwGain                  = DI_FFNOMINALMAX;
+	diEffect->dwTriggerButton         = DIEB_NOTRIGGER;
+	diEffect->dwTriggerRepeatInterval = 0;
+	diEffect->cAxes                   = effect->getNumAxes();
+	diEffect->rgdwAxes                = rgdwAxes;
+	diEffect->rglDirection            = rglDirection;
+	diEffect->lpEnvelope              = 0;
+	diEffect->cbTypeSpecificParams    = struct_size;
+	diEffect->lpvTypeSpecificParams   = struct_type;
+	diEffect->dwStartDelay            = effect->replay_delay;
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_upload( GUID guid, DIEFFECT* diEffect, const Effect* effect)
+{
+	LPDIRECTINPUTEFFECT dxEffect = 0;
+
+	//Get the effect - if it exists
+	EffectList::iterator i = mEffectList.find(effect->_handle);
+	//It has been created already
+	if( i != mEffectList.end() )
+		dxEffect = i->second;
+	else //This effect has not yet been created - generate a handle
+		effect->_handle = mHandles++;
+
+	if( dxEffect == 0 )
+	{
+		//This effect has not yet been created, so create it
+		HRESULT hr = mJoyStick->CreateEffect(guid, diEffect, &dxEffect, NULL);
+		if(SUCCEEDED(hr))
+		{
+			mEffectList[effect->_handle] = dxEffect;
+			dxEffect->Start(INFINITE,0);
+		}
+		else if( hr == DIERR_DEVICEFULL )
+			OIS_EXCEPT(E_DeviceFull, "Remove an effect before adding more!");
+		else
+			OIS_EXCEPT(E_General, "Unknown error creating effect->..");
+	}
+	else
+	{
+		//ToDo -- Update the Effect
+		HRESULT hr = dxEffect->SetParameters( diEffect, DIEP_DIRECTION |
+			DIEP_DURATION | DIEP_ENVELOPE | DIEP_STARTDELAY | DIEP_TRIGGERBUTTON |
+			DIEP_TRIGGERREPEATINTERVAL | DIEP_TYPESPECIFICPARAMS | DIEP_START );
+
+		if(FAILED(hr)) OIS_EXCEPT(E_InvalidParam, "Error updating device!");
+	}
+}
+
+//--------------------------------------------------------------//
+void Win32ForceFeedback::_addEffectSupport( LPCDIEFFECTINFO pdei )
+{
+	//Determine what the effect is and how it corresponds to our OIS's Enums
+	//We could save the GUIDs too, however, we will just use the predefined
+	//ones later
+	if( pdei->guid == GUID_ConstantForce )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Constant );
+	else if( pdei->guid == GUID_Triangle )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Triangle );
+	else if( pdei->guid == GUID_Spring )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Spring );
+	else if( pdei->guid == GUID_Friction )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Friction );
+	else if( pdei->guid == GUID_Square )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Square );
+	else if( pdei->guid == GUID_Sine )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Sine );
+	else if( pdei->guid == GUID_SawtoothUp )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::SawToothUp );
+	else if( pdei->guid == GUID_SawtoothDown )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::SawToothDown );
+	else if( pdei->guid == GUID_Damper )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Damper );
+	else if( pdei->guid == GUID_Inertia )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Inertia );
+	else if( pdei->guid == GUID_CustomForce )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Custom );
+	else if( pdei->guid == GUID_RampForce )
+		_addEffectTypes((Effect::EForce)DIEFT_GETTYPE(pdei->dwEffType), Effect::Ramp );
+#if defined (_DEBUG)
+	//Only care about this for Debugging Purposes
+	//else
+	//{
+	//	std::ostringstream ss;
+	//	ss << "Win32ForceFeedback, DirectInput8 Effect not found. Reported as: "
+	//	   << pdei->tszName;
+	//	OIS_EXCEPT( E_General, ss.str().c_str());
+	//}
+#endif
+}
Index: /code/branches/ceguilua/src/ois/win32/Win32ForceFeedback.h
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32ForceFeedback.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32ForceFeedback.h	(revision 1801)
@@ -0,0 +1,89 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Win32ForceFeedBack_H
+#define OIS_Win32ForceFeedBack_H
+
+#include "OISPrereqs.h"
+#include "OISForceFeedback.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32ForceFeedback : public ForceFeedback
+	{
+		Win32ForceFeedback() {}
+	public:
+		Win32ForceFeedback(IDirectInputDevice8* joy);
+		~Win32ForceFeedback();
+
+		/** @copydoc ForceFeedback::upload */
+		void upload( const Effect* effect );
+
+		/** @copydoc ForceFeedback::modify */
+		void modify( const Effect* effect );
+
+		/** @copydoc ForceFeedback::remove */
+		void remove( const Effect* effect );
+
+		/** @copydoc ForceFeedback::setMasterGain */
+		void setMasterGain( float level );
+		
+		/** @copydoc ForceFeedback::setAutoCenterMode */
+		void setAutoCenterMode( bool auto_on );
+
+		/** @copydoc ForceFeedback::getFFAxesNumber 
+			xxx todo - Actually return correct number
+		*/
+		short getFFAxesNumber() {return 1;}
+
+		/**
+			@remarks
+			Internal use.. Used during enumeration to build a list of a devices
+			support effects.
+		*/
+		void _addEffectSupport( LPCDIEFFECTINFO pdei );
+
+	protected:
+		//Specific Effect Settings
+		void _updateConstantEffect( const Effect* effect );
+		void _updateRampEffect( const Effect* effect );
+		void _updatePeriodicEffect( const Effect* effect );
+		void _updateConditionalEffect( const Effect* effect );
+		void _updateCustomEffect( const Effect* effect );
+		//Sets the common properties to all effects
+		void _setCommonProperties( DIEFFECT* diEffect, DWORD* rgdwAxes,
+									LONG* rglDirection, DWORD struct_size, 
+									LPVOID struct_type, const Effect* effect );
+		//Actually do the upload
+		void _upload( GUID, DIEFFECT*, const Effect* );
+
+		typedef std::map<int,LPDIRECTINPUTEFFECT> EffectList;
+		EffectList mEffectList;
+		//Simple unique handle creation - allows for upto 2+ million effects
+		//during the lifetime of application. Hopefully, that is enough.
+		int mHandles;
+
+		IDirectInputDevice8* mJoyStick;
+	};
+}
+#endif //OIS_Win32ForceFeedBack_H
Index: /code/branches/ceguilua/src/ois/win32/Win32InputManager.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32InputManager.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32InputManager.cpp	(revision 1801)
@@ -0,0 +1,254 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32InputManager.h"
+#include "Win32/Win32Keyboard.h"
+#include "Win32/Win32Mouse.h"
+#include "Win32/Win32JoyStick.h"
+#include "OISException.h"
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------//
+Win32InputManager::Win32InputManager() : InputManager("Win32InputManager")
+{
+	hWnd = 0;
+	mDirectInput = 0;
+
+	kbSettings    = 0;
+	mouseSettings = 0;
+	joySettings   = 0;
+
+	joySticks = 0;
+	keyboardUsed = mouseUsed = false;
+
+	//Setup our internal factories
+	mFactories.push_back(this);
+}
+
+//--------------------------------------------------------------------------------//
+Win32InputManager::~Win32InputManager()
+{
+	if( mDirectInput )
+	{
+		mDirectInput->Release();
+		mDirectInput = 0;
+	}
+}
+
+//--------------------------------------------------------------------------------//
+void Win32InputManager::_initialize( ParamList &paramList )
+{
+	HINSTANCE hInst = 0;
+	HRESULT hr;
+
+	//TODO 64 bit proof this little conversion xxx wip
+	//First of all, get the Windows Handle and Instance
+	ParamList::iterator i = paramList.find("WINDOW");
+	if( i == paramList.end() ) 
+		OIS_EXCEPT( E_InvalidParam, "Win32InputManager::Win32InputManager >> No HWND found!" );
+
+	hWnd  = (HWND)strtoul(i->second.c_str(), 0, 10);
+
+	if( IsWindow(hWnd) == 0 )
+		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> The sent HWND is not valid!");
+
+	hInst = GetModuleHandle(0);
+
+	//Create the device
+	hr = DirectInput8Create( hInst, DIRECTINPUT_VERSION, IID_IDirectInput8, (VOID**)&mDirectInput, NULL );
+    if (FAILED(hr))	
+		OIS_EXCEPT( E_General, "Win32InputManager::Win32InputManager >> Not able to init DirectX8 Input!");
+
+	//Ok, now we have DirectInput, parse whatever extra settings were sent to us
+	_parseConfigSettings( paramList );
+	_enumerateDevices();
+}
+
+//--------------------------------------------------------------------------------//
+void Win32InputManager::_parseConfigSettings( ParamList &paramList )
+{
+	//Here we pick up settings such as a device's cooperation mode
+	std::map<std::string, DWORD> temp;
+	temp["DISCL_BACKGROUND"]	= DISCL_BACKGROUND;
+	temp["DISCL_EXCLUSIVE"]		= DISCL_EXCLUSIVE;
+	temp["DISCL_FOREGROUND"]	= DISCL_FOREGROUND;
+	temp["DISCL_NONEXCLUSIVE"]	= DISCL_NONEXCLUSIVE;
+	temp["DISCL_NOWINKEY"]		= DISCL_NOWINKEY;
+
+	//Check for pairs: ie. ("w32_keyboard","DISCL_NOWINKEY")("w32_keyboard","DISCL_FOREGROUND")
+	ParamList::iterator i = paramList.begin(), e = paramList.end();
+	for( ; i != e; ++i ) 
+	{
+		if( i->first == "w32_keyboard" )
+				kbSettings |= temp[i->second];
+		else if( i->first == "w32_mouse" )
+				mouseSettings |= temp[i->second];
+		else if( i->first == "w32_joystick" )
+				joySettings |= temp[i->second];
+	}
+	if( kbSettings == 0 ) kbSettings = DISCL_FOREGROUND | DISCL_NONEXCLUSIVE | DISCL_NOWINKEY;
+	if( mouseSettings == 0 ) mouseSettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
+	if( joySettings == 0 ) joySettings = DISCL_FOREGROUND | DISCL_EXCLUSIVE;
+}
+
+//--------------------------------------------------------------------------------//
+void Win32InputManager::_enumerateDevices()
+{
+	//Enumerate all attached devices
+	mDirectInput->EnumDevices(NULL, _DIEnumKbdCallback, this, DIEDFL_ATTACHEDONLY); 
+}
+
+//--------------------------------------------------------------------------------//
+BOOL CALLBACK Win32InputManager::_DIEnumKbdCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef)
+{
+	Win32InputManager *_this_ = static_cast<Win32InputManager*>(pvRef);
+	if( GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_JOYSTICK ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_GAMEPAD ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_1STPERSON ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_DRIVING ||
+		GET_DIDEVICE_TYPE(lpddi->dwDevType) == DI8DEVTYPE_FLIGHT)
+	{
+		JoyStickInfo jsInfo;
+		jsInfo.deviceID = lpddi->guidInstance;
+		jsInfo.vendor = lpddi->tszInstanceName;
+		jsInfo.devId = _this_->joySticks;
+
+		_this_->joySticks++;
+		
+		_this_->unusedJoyStickList.push_back( jsInfo );
+	}
+
+	return DIENUM_CONTINUE;
+}
+
+//----------------------------------------------------------------------------//
+void Win32InputManager::_returnJoyStick(const JoyStickInfo& joystick)
+{
+	unusedJoyStickList.push_back(joystick);
+}
+
+//----------------------------------------------------------------------------//
+DeviceList Win32InputManager::freeDeviceList()
+{
+	DeviceList ret;
+
+	if( keyboardUsed == false )
+		ret.insert(std::make_pair(OISKeyboard, mInputSystemName));
+
+	if( mouseUsed == false )
+		ret.insert(std::make_pair(OISMouse, mInputSystemName));
+
+	for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		ret.insert(std::make_pair(OISJoyStick, i->vendor));
+
+	return ret;
+}
+
+//----------------------------------------------------------------------------//
+int Win32InputManager::totalDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return 1;
+	case OISMouse: return 1;
+	case OISJoyStick: return joySticks;
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+int Win32InputManager::freeDevices(Type iType)
+{
+	switch(iType)
+	{
+	case OISKeyboard: return keyboardUsed ? 0 : 1;
+	case OISMouse: return mouseUsed ? 0 : 1;
+	case OISJoyStick: return (int)unusedJoyStickList.size();
+	default: return 0;
+	}
+}
+
+//----------------------------------------------------------------------------//
+bool Win32InputManager::vendorExist(Type iType, const std::string & vendor)
+{
+	if( (iType == OISKeyboard || iType == OISMouse) && vendor == mInputSystemName )
+	{
+		return true;
+	}
+	else if( iType == OISJoyStick )
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+			if(i->vendor == vendor)
+				return true;
+	}
+
+	return false;
+}
+
+//----------------------------------------------------------------------------//
+Object* Win32InputManager::createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor)
+{
+	Object *obj = 0;
+
+	switch(iType)
+	{
+	case OISKeyboard: 
+	{
+		if( keyboardUsed == false )
+			obj = new Win32Keyboard(this, mDirectInput, bufferMode, kbSettings);
+		break;
+	}
+	case OISMouse:
+	{
+		if( mouseUsed == false )
+			obj = new Win32Mouse(this, mDirectInput, bufferMode, mouseSettings);
+		break;
+	}
+	case OISJoyStick:
+	{
+		for(JoyStickInfoList::iterator i = unusedJoyStickList.begin(); i != unusedJoyStickList.end(); ++i)
+		{
+			if(vendor == "" || i->vendor == vendor)
+			{
+				obj = new Win32JoyStick(this, mDirectInput, bufferMode, joySettings, *i);
+				unusedJoyStickList.erase(i);
+				break;
+			}
+		}
+		break;
+	}
+	default:
+		break;
+	}
+
+	if( obj == 0 )
+		OIS_EXCEPT(E_InputDeviceNonExistant, "No devices match requested type.");
+
+	return obj;
+}
+
+//----------------------------------------------------------------------------//
+void Win32InputManager::destroyObject(Object* obj)
+{
+	delete obj;
+}
Index: /code/branches/ceguilua/src/ois/win32/Win32InputManager.h
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32InputManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32InputManager.h	(revision 1801)
@@ -0,0 +1,113 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef OIS_Win32InputManager_H
+#define OIS_Win32InputManager_H
+
+#include "OISInputManager.h"
+#include "OISFactoryCreator.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	/**	Win32InputManager specialization - Using DirectInput8 */
+	class Win32InputManager : public InputManager, public FactoryCreator
+	{
+	public:
+		Win32InputManager();
+		virtual ~Win32InputManager();
+
+		//InputManager Overrides
+		/** @copydoc InputManager::_initialize */
+		void _initialize( ParamList &paramList );
+
+		//FactoryCreator Overrides
+		/** @copydoc FactoryCreator::deviceList */
+		DeviceList freeDeviceList();
+
+		/** @copydoc FactoryCreator::totalDevices */
+		int totalDevices(Type iType);
+
+		/** @copydoc FactoryCreator::freeDevices */
+		int freeDevices(Type iType);
+
+		/** @copydoc FactoryCreator::vendorExist */
+		bool vendorExist(Type iType, const std::string & vendor);
+
+		/** @copydoc FactoryCreator::createObject */
+		Object* createObject(InputManager* creator, Type iType, bool bufferMode, const std::string & vendor = "");
+
+		/** @copydoc FactoryCreator::destroyObject */
+		void destroyObject(Object* obj);
+
+		//Internal Items
+		//! Internal method, used for flaggin keyboard as available/unavailable for creation
+		void _setKeyboardUsed(bool used) {keyboardUsed = used; }
+
+		//! Internal method, used for flaggin mouse as available/unavailable for creation
+		void _setMouseUsed(bool used) { mouseUsed = used; }
+		
+		//! Internal method, return unused joystick to queue
+		void _returnJoyStick(const JoyStickInfo& joystick);
+
+		//! Returns HWND needed by DirectInput Device Object
+		HWND getWindowHandle() { return hWnd; }
+
+	protected:
+		//! internal class method for dealing with param list
+		void _parseConfigSettings( ParamList &paramList );
+		
+		//! internal class method for finding attached devices
+		void _enumerateDevices();
+
+		//! Used during device enumeration
+		static BOOL CALLBACK _DIEnumKbdCallback(LPCDIDEVICEINSTANCE lpddi, LPVOID pvRef);
+
+		//! Keep a list of all joysticks enumerated, but not in use
+		JoyStickInfoList unusedJoyStickList;
+
+		//! The window handle we are using
+		HWND hWnd;
+
+		//! Direct Input Interface
+		IDirectInput8* mDirectInput;
+
+		//! Used for keyboard device settings
+		DWORD kbSettings;
+
+		//! Used for mouse device settings
+		DWORD mouseSettings;
+
+		//! Used for joystick device settings
+		DWORD joySettings;
+
+		//! Number of total joysticks (inuse or not)
+		char joySticks;
+
+		//! Used to know if we used up keyboard
+		bool keyboardUsed;
+
+		//! Used to know if we used up mouse
+		bool mouseUsed;
+	};
+}
+#endif
Index: /code/branches/ceguilua/src/ois/win32/Win32JoyStick.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32JoyStick.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32JoyStick.cpp	(revision 1801)
@@ -0,0 +1,403 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that
+		you wrote the original software. If you use this software in a product,
+		an acknowledgment in the product documentation would be appreciated but is
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32JoyStick.h"
+#include "Win32/Win32InputManager.h"
+#include "Win32/Win32ForceFeedback.h"
+#include "OISEvents.h"
+#include "OISException.h"
+
+#include <cassert>
+
+//DX Only defines macros for the JOYSTICK not JOYSTICK2, so fix it
+#undef DIJOFS_BUTTON
+#undef DIJOFS_POV
+
+#define DIJOFS_BUTTON(n)  (FIELD_OFFSET(DIJOYSTATE2, rgbButtons) + (n))
+#define DIJOFS_POV(n)     (FIELD_OFFSET(DIJOYSTATE2, rgdwPOV)+(n)*sizeof(DWORD))
+#define DIJOFS_SLIDER0(n) (FIELD_OFFSET(DIJOYSTATE2, rglSlider)+(n) * sizeof(LONG))
+#define DIJOFS_SLIDER1(n) (FIELD_OFFSET(DIJOYSTATE2, rglVSlider)+(n) * sizeof(LONG))
+#define DIJOFS_SLIDER2(n) (FIELD_OFFSET(DIJOYSTATE2, rglASlider)+(n) * sizeof(LONG))
+#define DIJOFS_SLIDER3(n) (FIELD_OFFSET(DIJOYSTATE2, rglFSlider)+(n) * sizeof(LONG))
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+Win32JoyStick::Win32JoyStick( InputManager* creator, IDirectInput8* pDI,
+	bool buffered, DWORD coopSettings, const JoyStickInfo &info )
+	: JoyStick(info.vendor, buffered, info.devId, creator)
+{
+	mDirectInput = pDI;
+	coopSetting = coopSettings;
+	mJoyStick = 0;
+
+	deviceGuid = info.deviceID;
+
+	ff_device = 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+Win32JoyStick::~Win32JoyStick()
+{
+	delete ff_device;
+
+	if(mJoyStick)
+	{
+		mJoyStick->Unacquire();
+		mJoyStick->Release();
+		mJoyStick = 0;
+	}
+
+	//Return joystick to pool
+	JoyStickInfo js;
+	js.deviceID = deviceGuid;
+	js.devId = mDevID;
+	js.vendor = mVendor;
+	static_cast<Win32InputManager*>(mCreator)->_returnJoyStick(js);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::_initialize()
+{
+	//Clear old state
+	mState.mAxes.clear();
+
+	delete ff_device;
+	ff_device = 0;
+
+	DIPROPDWORD dipdw;
+
+	dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
+	dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	dipdw.diph.dwObj        = 0;
+	dipdw.diph.dwHow        = DIPH_DEVICE;
+	dipdw.dwData            = JOYSTICK_DX_BUFFERSIZE;
+
+	if(FAILED(mDirectInput->CreateDevice(deviceGuid, &mJoyStick, NULL)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
+
+	if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
+
+	HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
+
+	if( FAILED(mJoyStick->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set buffer size property" );
+
+	//Enumerate all axes/buttons/sliders/etc before aquiring
+	_enumerate();
+
+	mState.clear();
+
+	capture();
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::_enumerate()
+{
+	//We can check force feedback here too
+	DIDEVCAPS  DIJoyCaps;
+	DIJoyCaps.dwSize = sizeof(DIDEVCAPS);
+	mJoyStick->GetCapabilities(&DIJoyCaps);
+
+	mPOVs = (short)DIJoyCaps.dwPOVs;
+
+	mState.mButtons.resize(DIJoyCaps.dwButtons);
+	mState.mAxes.resize(DIJoyCaps.dwAxes);
+
+	//Reset the axis mapping enumeration value
+	_AxisNumber = 0;
+
+	//Enumerate Force Feedback (if any)
+	mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
+
+	//Enumerate and set axis constraints (and check FF Axes)
+	mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
+}
+
+//--------------------------------------------------------------------------------------------------//
+BOOL CALLBACK Win32JoyStick::DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef)
+{
+	Win32JoyStick* _this = (Win32JoyStick*)pvRef;
+
+	//Setup mappings
+	DIPROPPOINTER diptr;
+	diptr.diph.dwSize       = sizeof(DIPROPPOINTER);
+	diptr.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	diptr.diph.dwHow        = DIPH_BYID;
+	diptr.diph.dwObj        = lpddoi->dwType;
+	//Add a magic number to recognise we set seomthing
+	diptr.uData             = 0x13130000 | _this->_AxisNumber;
+
+	//Check if axis is slider, if so, do not treat as regular axis
+	if(GUID_Slider == lpddoi->guidType)
+	{
+		++_this->mSliders;
+
+		//Decrease Axes, since this slider shows up in a different place
+		_this->mState.mAxes.pop_back();
+	}
+	else if (FAILED(_this->mJoyStick->SetProperty(DIPROP_APPDATA, &diptr.diph)))
+	{	//If for some reason we could not set needed user data, just ignore this axis
+		return DIENUM_CONTINUE;
+	}
+
+	//Increase for next time through
+	if(GUID_Slider != lpddoi->guidType)
+		_this->_AxisNumber += 1;
+
+	//Set range
+	DIPROPRANGE diprg;
+	diprg.diph.dwSize       = sizeof(DIPROPRANGE);
+	diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	diprg.diph.dwHow        = DIPH_BYID;
+	diprg.diph.dwObj        = lpddoi->dwType;
+	diprg.lMin              = MIN_AXIS;
+	diprg.lMax              = MAX_AXIS;
+
+	if (FAILED(_this->mJoyStick->SetProperty(DIPROP_RANGE, &diprg.diph)))
+		OIS_EXCEPT( E_General, "Win32JoyStick::_DIEnumDeviceObjectsCallback >> Failed to set min/max range property" );
+
+	//Check if FF Axes
+	if((lpddoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
+	{
+		if( _this->ff_device )
+		{
+			//todo - increment force feedback axis count
+		}
+	}
+
+	return DIENUM_CONTINUE;
+}
+
+//--------------------------------------------------------------------------------------------------//
+BOOL CALLBACK Win32JoyStick::DIEnumEffectsCallback(LPCDIEFFECTINFO pdei, LPVOID pvRef)
+{
+	Win32JoyStick* _this = (Win32JoyStick*)pvRef;
+
+	//Create the FF class after we know there is at least one effect type
+	if( _this->ff_device == 0 )
+		_this->ff_device = new Win32ForceFeedback(_this->mJoyStick);
+
+	_this->ff_device->_addEffectSupport( pdei );
+
+	return DIENUM_CONTINUE;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::capture()
+{
+	DIDEVICEOBJECTDATA diBuff[JOYSTICK_DX_BUFFERSIZE];
+	DWORD entries = JOYSTICK_DX_BUFFERSIZE;
+
+	// Poll the device to read the current state
+	HRESULT hr = mJoyStick->Poll();
+	if( hr == DI_OK )
+		hr = mJoyStick->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+
+	if( hr != DI_OK )
+	{
+		hr = mJoyStick->Acquire();
+		while( hr == DIERR_INPUTLOST )
+			hr = mJoyStick->Acquire();
+
+		// Poll the device to read the current state
+	    mJoyStick->Poll();
+		hr = mJoyStick->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+		//Perhaps the user just tabbed away
+		if( FAILED(hr) )
+			return;
+	}
+
+	bool axisMoved[24] = {false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
+						  false,false,false,false,false,false,false,false};
+	bool sliderMoved[4] = {false,false,false,false};
+
+	//Loop through all the events
+	for(unsigned int i = 0; i < entries; ++i)
+	{
+		//This may seem outof order, but is in order of the way these variables
+		//are declared in the JoyStick State 2 structure.
+		switch(diBuff[i].dwOfs)
+		{
+		//------ slider -//
+		case DIJOFS_SLIDER0(0):
+			sliderMoved[0] = true;
+			mState.mSliders[0].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER0(1):
+			sliderMoved[0] = true;
+			mState.mSliders[0].abY = diBuff[i].dwData;
+			break;
+		//----- Max 4 POVs Next ---------------//
+		case DIJOFS_POV(0):
+			if(!_changePOV(0,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(1):
+			if(!_changePOV(1,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(2):
+			if(!_changePOV(2,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_POV(3):
+			if(!_changePOV(3,diBuff[i]))
+				return;
+			break;
+		case DIJOFS_SLIDER1(0):
+			sliderMoved[1] = true;
+			mState.mSliders[1].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER1(1):
+			sliderMoved[1] = true;
+			mState.mSliders[1].abY = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER2(0):
+			sliderMoved[2] = true;
+			mState.mSliders[2].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER2(1):
+			sliderMoved[2] = true;
+			mState.mSliders[2].abY = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER3(0):
+			sliderMoved[3] = true;
+			mState.mSliders[3].abX = diBuff[i].dwData;
+			break;
+		case DIJOFS_SLIDER3(1):
+			sliderMoved[3] = true;
+			mState.mSliders[3].abY = diBuff[i].dwData;
+			break;
+		//-----------------------------------------//
+		default:
+			//Handle Button Events Easily using the DX Offset Macros
+			if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
+			{
+				if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
+					return;
+			}
+			else if((short)(diBuff[i].uAppData >> 16) == 0x1313)
+			{	//If it was nothing else, might be axis enumerated earlier (determined by magic number)
+				int axis = (int)(0x0000FFFF & diBuff[i].uAppData); //Mask out the high bit
+				assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
+
+				if(axis >= 0 && axis < (int)mState.mAxes.size())
+				{
+					mState.mAxes[axis].abs = diBuff[i].dwData;
+					axisMoved[axis] = true;
+				}
+			}
+
+			break;
+		} //end case
+	} //end for
+
+	//Check to see if any of the axes values have changed.. if so send events
+	if( mBuffered && mListener && entries > 0 )
+	{
+		JoyStickEvent temp(this, mState);
+
+		//Update axes
+		for( int i = 0; i < 24; ++i )
+			if( axisMoved[i] )
+				if( mListener->axisMoved( temp, i ) == false )
+					return;
+
+		//Now update sliders
+		for( int i = 0; i < 4; ++i )
+			if( sliderMoved[i] )
+				if( mListener->sliderMoved( temp, i ) == false )
+					return;
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32JoyStick::_doButtonClick( int button, DIDEVICEOBJECTDATA& di )
+{
+	if( di.dwData & 0x80 )
+	{
+		mState.mButtons[button] = true;
+		if( mBuffered && mListener )
+			return mListener->buttonPressed( JoyStickEvent( this, mState ), button );
+	}
+	else
+	{
+		mState.mButtons[button] = false;
+		if( mBuffered && mListener )
+			return mListener->buttonReleased( JoyStickEvent( this, mState ), button );
+	}
+
+	return true;
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32JoyStick::_changePOV( int pov, DIDEVICEOBJECTDATA& di )
+{
+	//Some drivers report a value of 65,535, instead of 1,
+	//for the center position
+	if(LOWORD(di.dwData) == 0xFFFF)
+	{
+		mState.mPOV[pov].direction = Pov::Centered;
+	}
+	else
+	{
+		switch(di.dwData)
+		{
+			case 0: mState.mPOV[pov].direction = Pov::North; break;
+			case 4500: mState.mPOV[pov].direction = Pov::NorthEast; break;
+			case 9000: mState.mPOV[pov].direction = Pov::East; break;
+			case 13500: mState.mPOV[pov].direction = Pov::SouthEast; break;
+			case 18000: mState.mPOV[pov].direction = Pov::South; break;
+			case 22500: mState.mPOV[pov].direction = Pov::SouthWest; break;
+			case 27000: mState.mPOV[pov].direction = Pov::West; break;
+			case 31500: mState.mPOV[pov].direction = Pov::NorthWest; break;
+		}
+	}
+
+	if( mBuffered && mListener )
+		return mListener->povMoved( JoyStickEvent( this, mState ), pov );
+
+	return true;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32JoyStick::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
+
+//--------------------------------------------------------------------------------------------------//
+Interface* Win32JoyStick::queryInterface(Interface::IType type)
+{
+	//Thought about using covariant return type here.. however,
+	//some devices may allow LED light changing, or other interface stuff
+
+	if( ff_device && type == Interface::ForceFeedback )
+		return ff_device;
+	else
+		return 0;
+}
Index: /code/branches/ceguilua/src/ois/win32/Win32JoyStick.h
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32JoyStick.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32JoyStick.h	(revision 1801)
@@ -0,0 +1,73 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_JOYSTICK_H_EADER_
+#define _WIN32_JOYSTICK_H_EADER_
+
+#include "OISJoyStick.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32JoyStick : public JoyStick
+	{
+	public:
+		Win32JoyStick( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings, const JoyStickInfo &info );
+		virtual ~Win32JoyStick();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+		
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type);
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+	protected:
+		//! Enumerates all things
+		void _enumerate();
+		//! Enumerate axis callback
+		static BOOL CALLBACK DIEnumDeviceObjectsCallback(LPCDIDEVICEOBJECTINSTANCE lpddoi, LPVOID pvRef);
+		//! Enumerate Force Feedback callback
+		static BOOL CALLBACK DIEnumEffectsCallback(LPCDIEFFECTINFO pdei, LPVOID pvRef);
+
+		bool _doButtonClick( int button, DIDEVICEOBJECTDATA& di );
+		bool _changePOV( int pov, DIDEVICEOBJECTDATA& di );
+
+		IDirectInput8* mDirectInput;
+		IDirectInputDevice8* mJoyStick;
+		DWORD coopSetting;
+		GUID deviceGuid;
+
+		//! A force feedback device
+		Win32ForceFeedback* ff_device;
+
+		//! Mapping
+		int _AxisNumber;
+	};
+}
+
+#endif //_WIN32_JOYSTICK_H_EADER_
Index: /code/branches/ceguilua/src/ois/win32/Win32KeyBoard.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32KeyBoard.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32KeyBoard.cpp	(revision 1801)
@@ -0,0 +1,334 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32InputManager.h"
+#include "Win32/Win32KeyBoard.h"
+#include "OISException.h"
+#include "OISEvents.h"
+#include <sstream>
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+Win32Keyboard::Win32Keyboard( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings )
+	: Keyboard(creator->inputSystemName(), buffered, 0, creator)
+{
+	mKeyboard = 0;
+	mDirectInput = pDI;
+	coopSetting = coopSettings;
+
+	//Clear our keyboard state buffer
+	memset( &KeyBuffer, 0, 256 );
+	deadKey = '\0';
+	static_cast<Win32InputManager*>(mCreator)->_setKeyboardUsed(true);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::_initialize()
+{
+	mModifiers = 0;
+	deadKey = '\0';
+
+	if(FAILED(mDirectInput->CreateDevice(GUID_SysKeyboard, &mKeyboard, NULL)))
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> Could not init device!");
+
+	if(FAILED(mKeyboard->SetDataFormat(&c_dfDIKeyboard)))
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> format error!");
+
+	HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	if(FAILED(mKeyboard->SetCooperativeLevel( hwin, coopSetting)))
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> coop error!");
+
+	if( mBuffered )
+	{
+		DIPROPDWORD dipdw;
+		dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
+		dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+		dipdw.diph.dwObj        = 0;
+		dipdw.diph.dwHow        = DIPH_DEVICE;
+		dipdw.dwData            = KEYBOARD_DX_BUFFERSIZE;
+
+		if (FAILED(mKeyboard->SetProperty( DIPROP_BUFFERSIZE, &dipdw.diph )))
+			OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> buffer error!");
+	}
+
+	HRESULT hr = mKeyboard->Acquire();
+	if(FAILED(hr) && hr != DIERR_OTHERAPPHASPRIO)
+		OIS_EXCEPT( E_General, "Win32Keyboard::Win32Keyboard >> aquire error!");
+}
+
+//--------------------------------------------------------------------------------------------------//
+Win32Keyboard::~Win32Keyboard()
+{
+	if(mKeyboard)
+	{
+		mKeyboard->Unacquire();
+		mKeyboard->Release();
+		mKeyboard = 0;
+	}
+	static_cast<Win32InputManager*>(mCreator)->_setKeyboardUsed(false);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::capture()
+{
+	if( mBuffered )
+		_readBuffered();
+	else
+		_read();
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::_readBuffered()
+{
+	DIDEVICEOBJECTDATA diBuff[KEYBOARD_DX_BUFFERSIZE];
+	DWORD entries = KEYBOARD_DX_BUFFERSIZE;
+	HRESULT hr;
+	//Only one keyboard allowed per app, so static is ok
+	static bool verifyAfterAltTab = false;
+
+	hr = mKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+	if( hr != DI_OK )
+	{
+		hr = mKeyboard->Acquire();
+		if (hr == E_ACCESSDENIED)
+			verifyAfterAltTab = true;
+
+		while( hr == DIERR_INPUTLOST )
+			hr = mKeyboard->Acquire();
+
+		return;
+	}
+
+	if( FAILED(hr) )
+		OIS_EXCEPT( E_General, "Win32Keyboard::_readBuffered() >> Problem with Device!" );
+
+	//Update keyboard and modifier states.. And, if mListener, fire events
+	for(unsigned int i = 0; i < entries; ++i )
+	{
+		//If the listener returns false, that means that we are probably deleted...
+		//send no more events and just leave as the this pointer is invalid now...
+		bool ret = true;
+		KeyCode kc = (KeyCode)diBuff[ i ].dwOfs;
+			
+		//Store result in our keyBuffer too
+		KeyBuffer[kc] = static_cast<unsigned char>(diBuff[ i ].dwData);
+			
+		if( diBuff[ i ].dwData & 0x80 )
+		{
+			//Turn on modifier
+			if( kc == KC_LCONTROL || kc == KC_RCONTROL )
+				mModifiers |= Ctrl;
+			else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+				mModifiers |= Shift;
+			else if( kc == KC_LMENU || kc == KC_RMENU )
+				mModifiers |= Alt;
+
+			if( mListener )
+				ret = mListener->keyPressed( KeyEvent( this, kc, _translateText(kc) ) );
+		}
+		else
+		{
+			//Turn off modifier
+			if( kc == KC_LCONTROL || kc == KC_RCONTROL )
+				mModifiers &= ~Ctrl;
+			else if( kc == KC_LSHIFT || kc == KC_RSHIFT )
+				mModifiers &= ~Shift;
+			else if( kc == KC_LMENU || kc == KC_RMENU )
+				mModifiers &= ~Alt;
+
+			//Fire off event
+			if( mListener )
+				ret = mListener->keyReleased( KeyEvent( this, kc, 0 ) );
+		}
+
+		if(ret == false)
+			break;
+	}
+
+	// If a lost device/access denied was detected, recover gracefully with new events
+	if(verifyAfterAltTab)
+	{
+		bool ret = true;
+		
+		//Copy old buffer to temp location to compare against
+		unsigned char keyBufferCopy[256];
+		memcpy(keyBufferCopy, KeyBuffer, 256);
+
+		//Update new state
+		_read();
+
+		for (unsigned i = 0; i < 256; i++)
+		{
+			if (keyBufferCopy[i] != KeyBuffer[i])
+			{
+				if (mListener)
+				{
+					if (KeyBuffer[i])
+						ret = mListener->keyPressed( KeyEvent( this, (KeyCode)i, _translateText((KeyCode)i) ) );
+					else
+						ret = mListener->keyReleased( KeyEvent( this, (KeyCode)i, 0 ) );
+				}
+			}
+
+			//If user returned false from callback, return immediately
+			if(ret == false)
+				return;
+		}
+
+		verifyAfterAltTab = false;
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::_read()
+{
+    HRESULT  hr = mKeyboard->GetDeviceState( sizeof(KeyBuffer), &KeyBuffer );
+
+	if( hr == DIERR_INPUTLOST || hr == DIERR_NOTACQUIRED )
+	{
+		hr = mKeyboard->Acquire();
+		if (hr != DIERR_OTHERAPPHASPRIO)
+			mKeyboard->GetDeviceState(sizeof(KeyBuffer), &KeyBuffer);
+	}
+
+	//Set Shift, Ctrl, Alt
+	mModifiers = 0;
+	if( isKeyDown(KC_LCONTROL) || isKeyDown(KC_RCONTROL) )
+		mModifiers |= Ctrl;
+	if( isKeyDown(KC_LSHIFT) || isKeyDown(KC_RSHIFT) )
+		mModifiers |= Shift;
+	if( isKeyDown(KC_LMENU) || isKeyDown(KC_RMENU) )
+		mModifiers |= Alt;
+}
+
+//--------------------------------------------------------------------------------------------------//
+int Win32Keyboard::_translateText( KeyCode kc )
+{
+	if( mTextMode == Off )
+		return 0;
+
+	BYTE keyState[256];
+	HKL  layout = GetKeyboardLayout(0);
+	if( GetKeyboardState(keyState) == 0 )
+		return 0;
+
+	unsigned int vk = MapVirtualKeyEx(kc, 3, layout);
+	if( vk == 0 )
+		return 0;
+
+	unsigned char buff[3] = {0,0,0};
+	int ascii = ToAsciiEx(vk, kc, keyState, (LPWORD) buff, 0, layout);
+	//WCHAR wide[3];
+	//int ascii = ToUnicodeEx(vk, kc, keyState, wide, 3, 0, layout);
+	if(ascii == 1 && deadKey != '\0' )
+	{
+		// A dead key is stored and we have just converted a character key
+		// Combine the two into a single character
+		WCHAR wcBuff[3] = {buff[0], deadKey, '\0'};
+		WCHAR out[3];
+		
+		deadKey = '\0';
+		if(FoldStringW(MAP_PRECOMPOSED, (LPWSTR)wcBuff, 3, (LPWSTR)out, 3))
+			return out[0];
+	}
+	else if (ascii == 1)
+	{	// We have a single character
+		deadKey = '\0';
+		return buff[0];
+	}
+	else if(ascii == 2)
+	{	// Convert a non-combining diacritical mark into a combining diacritical mark
+		// Combining versions range from 0x300 to 0x36F; only 5 (for French) have been mapped below
+		// http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/images.htm
+		switch(buff[0])	{
+		case 0x5E: // Circumflex accent: â
+			deadKey = 0x302; break;
+		case 0x60: // Grave accent: à
+			deadKey = 0x300; break;
+		case 0xA8: // Diaeresis: ü
+			deadKey = 0x308; break;
+		case 0xB4: // Acute accent: é
+			deadKey = 0x301; break;
+		case 0xB8: // Cedilla: ç
+			deadKey = 0x327; break;
+		default:
+			deadKey = buff[0]; break;
+		}
+	}
+
+	return 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32Keyboard::isKeyDown( KeyCode key ) const
+{
+	return (KeyBuffer[key] & 0x80) != 0;
+}
+
+//--------------------------------------------------------------------------------------------------//
+const std::string& Win32Keyboard::getAsString( KeyCode kc )
+{
+	char temp[256];
+
+	DIPROPSTRING prop;
+	prop.diph.dwSize = sizeof(DIPROPSTRING);
+	prop.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+	prop.diph.dwObj = static_cast<DWORD>(kc);
+	prop.diph.dwHow = DIPH_BYOFFSET;
+
+	if ( SUCCEEDED( mKeyboard->GetProperty( DIPROP_KEYNAME, &prop.diph ) ) )
+	{
+		// convert the WCHAR in "wsz" to multibyte
+		if ( WideCharToMultiByte( CP_ACP, 0, prop.wsz, -1, temp, sizeof(temp), NULL, NULL) )
+			return mGetString.assign( temp );
+	}
+
+	std::stringstream ss;
+	ss << "Key_" << (int)kc;
+	return mGetString.assign( ss.str() );
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::copyKeyStates( char keys[256] ) const
+{
+	for(int i = 0; i < 256; ++i)
+		keys[i] = KeyBuffer[i] > 0; //Normalise the DX values (0x80)
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Keyboard::setBuffered(bool buffered)
+{
+	if( buffered != mBuffered )
+	{
+		if(mKeyboard)
+		{
+			mKeyboard->Unacquire();
+			mKeyboard->Release();
+			mKeyboard = 0;
+		}
+		
+		mBuffered = buffered;
+		_initialize();
+	}
+}
Index: /code/branches/ceguilua/src/ois/win32/Win32KeyBoard.h
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32KeyBoard.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32KeyBoard.h	(revision 1801)
@@ -0,0 +1,87 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_KEYBOARD_H_EADER_
+#define _WIN32_KEYBOARD_H_EADER_
+
+#include "OISKeyboard.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32Keyboard : public Keyboard
+	{
+	public:
+		/**
+		@remarks
+			Constructor
+		@param pDI
+			Valid DirectInput8 Interface
+		@param buffered
+			True for buffered input mode
+		@param coopSettings
+			A combination of DI Flags (see DX Help for info on input device settings)
+		*/
+		Win32Keyboard( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings );
+		virtual ~Win32Keyboard();
+
+		/** @copydoc Keyboard::isKeyDown */
+		virtual bool isKeyDown( KeyCode key ) const;
+		
+		/** @copydoc Keyboard::getAsString */
+		virtual const std::string& getAsString( KeyCode kc );
+
+		/** @copydoc Keyboard::copyKeyStates */
+		virtual void copyKeyStates( char keys[256] ) const;
+
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+		
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type) {return 0;}
+		
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+	protected:
+		void _readBuffered();
+		void _read();
+
+		IDirectInput8* mDirectInput;
+		IDirectInputDevice8* mKeyboard;
+		DWORD coopSetting;
+
+		unsigned char KeyBuffer[256];
+		
+		//! Internal method for translating KeyCodes to Text
+		int _translateText( KeyCode kc );
+
+		//! Stored dead key from last translation
+		WCHAR deadKey;
+
+		//! used for getAsString
+		std::string mGetString;
+	};
+}
+#endif //_WIN32_KEYBOARD_H_EADER_
Index: /code/branches/ceguilua/src/ois/win32/Win32Mouse.cpp
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32Mouse.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32Mouse.cpp	(revision 1801)
@@ -0,0 +1,216 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#include "Win32/Win32Mouse.h"
+#include "Win32/Win32InputManager.h"
+#include "OISException.h"
+#include "OISEvents.h"
+
+using namespace OIS;
+
+//--------------------------------------------------------------------------------------------------//
+Win32Mouse::Win32Mouse( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings )
+	: Mouse(creator->inputSystemName(), buffered, 0, creator)
+{
+	mMouse = 0;
+	mDirectInput = pDI;
+	coopSetting = coopSettings;
+	mHwnd = 0;
+
+	static_cast<Win32InputManager*>(mCreator)->_setMouseUsed(true);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Mouse::_initialize()
+{
+	DIPROPDWORD dipdw;
+
+	//Clear old state
+	mState.clear();
+
+    dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
+    dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
+    dipdw.diph.dwObj        = 0;
+    dipdw.diph.dwHow        = DIPH_DEVICE;
+	dipdw.dwData            = MOUSE_DX_BUFFERSIZE;
+	
+	if( FAILED(mDirectInput->CreateDevice(GUID_SysMouse, &mMouse, NULL)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to create device" );
+
+	if( FAILED(mMouse->SetDataFormat(&c_dfDIMouse2)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set format" );
+	
+	mHwnd = ((Win32InputManager*)mCreator)->getWindowHandle();
+
+	if( FAILED(mMouse->SetCooperativeLevel(mHwnd, coopSetting)) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set coop level" );
+	
+	if( FAILED(mMouse->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph )) )
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set property" );
+
+	HRESULT hr = mMouse->Acquire();
+	if (FAILED(hr) && hr != DIERR_OTHERAPPHASPRIO)
+		OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to aquire mouse!" );
+}
+
+//--------------------------------------------------------------------------------------------------//
+Win32Mouse::~Win32Mouse()
+{
+	if (mMouse)
+	{
+		mMouse->Unacquire();
+		mMouse->Release();
+		mMouse = 0;
+	}
+
+	static_cast<Win32InputManager*>(mCreator)->_setMouseUsed(false);
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Mouse::capture()
+{
+	//Clear old relative values
+	mState.X.rel = mState.Y.rel = mState.Z.rel = 0;
+
+	DIDEVICEOBJECTDATA diBuff[MOUSE_DX_BUFFERSIZE];
+	DWORD entries = MOUSE_DX_BUFFERSIZE;
+
+	HRESULT hr = mMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+	if( hr != DI_OK )
+	{
+		hr = mMouse->Acquire();
+		while( hr == DIERR_INPUTLOST ) 
+			hr = mMouse->Acquire();
+
+		hr = mMouse->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
+		
+		//Perhaps the user just tabbed away, and coop settings
+		//are nonexclusive..so just ignore
+		if( FAILED(hr) )
+			return;
+	}
+
+	bool axesMoved = false;
+	//Accumulate all axis movements for one axesMove message..
+	//Buttons are fired off as they are found
+	for(unsigned int i = 0; i < entries; ++i )
+	{
+		switch( diBuff[i].dwOfs )
+		{
+			case DIMOFS_BUTTON0:
+				if(!_doMouseClick(0, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON1:
+				if(!_doMouseClick(1, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON2:
+				if(!_doMouseClick(2, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON3:
+				if(!_doMouseClick(3, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON4:
+				if(!_doMouseClick(4, diBuff[i])) return;
+				break;	
+			case DIMOFS_BUTTON5:
+				if(!_doMouseClick(5, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON6:
+				if(!_doMouseClick(6, diBuff[i])) return;
+				break;
+			case DIMOFS_BUTTON7:
+				if(!_doMouseClick(7, diBuff[i])) return;
+				break;
+			case DIMOFS_X:
+				mState.X.rel += diBuff[i].dwData;
+				axesMoved = true;
+				break;
+			case DIMOFS_Y:
+				mState.Y.rel += diBuff[i].dwData;
+				axesMoved = true;
+				break;
+			case DIMOFS_Z:
+				mState.Z.rel += diBuff[i].dwData;
+				axesMoved = true;
+				break;
+			default: break;
+		} //end switch
+	}//end for
+
+	if( axesMoved )
+	{
+		if( coopSetting & DISCL_NONEXCLUSIVE )
+		{
+			//DirectInput provides us with meaningless values, so correct that
+			POINT point;
+			GetCursorPos(&point);
+			ScreenToClient(mHwnd, &point);
+			mState.X.abs = point.x;
+			mState.Y.abs = point.y;
+		}
+		else
+		{
+			mState.X.abs +=  mState.X.rel;
+			mState.Y.abs +=  mState.Y.rel;
+		}
+		mState.Z.abs +=  mState.Z.rel;
+
+		//Clip values to window
+		if( mState.X.abs < 0 )
+			mState.X.abs = 0;
+		else if( mState.X.abs > mState.width )
+			mState.X.abs = mState.width;
+		if( mState.Y.abs < 0 )
+			mState.Y.abs = 0;
+		else if( mState.Y.abs > mState.height )
+			mState.Y.abs = mState.height;
+
+		//Do the move
+		if( mListener && mBuffered )
+			mListener->mouseMoved( MouseEvent( this, mState ) );
+	}
+}
+
+//--------------------------------------------------------------------------------------------------//
+bool Win32Mouse::_doMouseClick( int mouseButton, DIDEVICEOBJECTDATA& di )
+{
+	if( di.dwData & 0x80 )
+	{
+		mState.buttons |= 1 << mouseButton; //turn the bit flag on
+		if( mListener && mBuffered )
+			return mListener->mousePressed( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+	}
+	else
+	{
+		mState.buttons &= ~(1 << mouseButton); //turn the bit flag off
+		if( mListener && mBuffered )
+			return mListener->mouseReleased( MouseEvent( this, mState ), (MouseButtonID)mouseButton );
+	}
+
+	return true;
+}
+
+//--------------------------------------------------------------------------------------------------//
+void Win32Mouse::setBuffered(bool buffered)
+{
+	mBuffered = buffered;
+}
Index: /code/branches/ceguilua/src/ois/win32/Win32Mouse.h
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32Mouse.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32Mouse.h	(revision 1801)
@@ -0,0 +1,59 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+	1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+	2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+	3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_MOUSE_H_EADER_
+#define _WIN32_MOUSE_H_EADER_
+
+#include "OISMouse.h"
+#include "Win32/Win32Prereqs.h"
+
+namespace OIS
+{
+	class Win32Mouse : public Mouse
+	{
+	public:
+		Win32Mouse( InputManager* creator, IDirectInput8* pDI, bool buffered, DWORD coopSettings );
+		virtual ~Win32Mouse();
+		
+		/** @copydoc Object::setBuffered */
+		virtual void setBuffered(bool buffered);
+
+		/** @copydoc Object::capture */
+		virtual void capture();
+
+		/** @copydoc Object::queryInterface */
+		virtual Interface* queryInterface(Interface::IType type) {return 0;}
+
+		/** @copydoc Object::_initialize */
+		virtual void _initialize();
+
+	protected:
+		bool _doMouseClick( int mouseButton, DIDEVICEOBJECTDATA& di );
+
+		IDirectInput8* mDirectInput;
+		IDirectInputDevice8* mMouse;
+		DWORD coopSetting;
+		HWND mHwnd;
+	};
+}
+
+#endif //_WIN32_MOUSE_H_EADER_
Index: /code/branches/ceguilua/src/ois/win32/Win32Prereqs.h
===================================================================
--- /code/branches/ceguilua/src/ois/win32/Win32Prereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/ois/win32/Win32Prereqs.h	(revision 1801)
@@ -0,0 +1,63 @@
+/*
+The zlib/libpng License
+
+Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com)
+
+This software is provided 'as-is', without any express or implied warranty. In no event will
+the authors be held liable for any damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any purpose, including commercial 
+applications, and to alter it and redistribute it freely, subject to the following
+restrictions:
+
+    1. The origin of this software must not be misrepresented; you must not claim that 
+		you wrote the original software. If you use this software in a product, 
+		an acknowledgment in the product documentation would be appreciated but is 
+		not required.
+
+    2. Altered source versions must be plainly marked as such, and must not be 
+		misrepresented as being the original software.
+
+    3. This notice may not be removed or altered from any source distribution.
+*/
+#ifndef _WIN32_INPUTSYSTEM_PREREQS_H
+#define _WIN32_INPUTSYSTEM_PREREQS_H
+
+#define WIN32_LEAN_AND_MEAN
+#define DIRECTINPUT_VERSION 0x0800
+#include <windows.h>
+#include <dinput.h>
+
+//Max number of elements to collect from buffered DirectInput
+#define KEYBOARD_DX_BUFFERSIZE 17
+#define MOUSE_DX_BUFFERSIZE 64
+#define JOYSTICK_DX_BUFFERSIZE 124
+
+//MinGW defines
+#if defined(OIS_MINGW_COMPILER)
+#	undef FIELD_OFFSET
+#	define FIELD_OFFSET offsetof
+#endif
+
+namespace OIS
+{
+	//Local Forward declarations
+	class Win32InputManager;
+	class Win32Keyboard;
+	class Win32JoyStick;
+	class Win32Mouse;
+	class Win32ForceFeedback;
+
+	//Information needed to create DirectInput joysticks
+	class JoyStickInfo
+	{
+	public:
+		int devId;
+		GUID deviceID;
+		std::string vendor;
+	};
+
+	typedef std::vector< JoyStickInfo > JoyStickInfoList;
+}
+
+#endif //_WIN32_INPUTSYSTEM_PREREQS_H
Index: /code/branches/ceguilua/src/orxonox/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/orxonox/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,110 @@
+SET( ORXONOX_SRC_FILES
+  GraphicsEngine.cc
+  Main.cc
+  Radar.cc
+  RadarListener.cc
+  RadarViewable.cc
+  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
+  overlays/OverlayGroup.cc
+  overlays/OverlayText.cc
+
+  overlays/console/InGameConsole.cc
+
+  overlays/debug/DebugFPSText.cc
+  overlays/debug/DebugRTRText.cc
+
+  overlays/hud/HUDBar.cc
+  overlays/hud/HUDNavigation.cc
+  overlays/hud/HUDRadar.cc
+  overlays/hud/HUDSpeedBar.cc
+
+  tolua/tolua_bind.cc
+
+  tools/BillboardSet.cc
+  tools/Light.cc
+  tools/Mesh.cc
+  tools/ParticleInterface.cc
+  tools/TextureGenerator.cc
+  tools/Timer.cc
+  tools/WindowEventListener.cc
+
+  objects/Ambient.cc
+  objects/Backlight.cc
+  objects/Camera.cc
+  objects/CameraHandler.cc
+  objects/Model.cc
+  objects/NPC.cc
+  objects/ParticleSpawner.cc
+  objects/Skybox.cc
+  objects/SpaceShip.cc
+  objects/SpaceShipAI.cc
+  objects/Tickable.cc
+  objects/WorldEntity.cc
+
+  objects/Projectile.cc
+  objects/BillboardProjectile.cc
+  objects/RotatingProjectile.cc
+  objects/ParticleProjectile.cc
+)
+
+GET_TARGET_PROPERTY(TOLUA_EXE tolua LOCATION)
+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 ${CMAKE_SOURCE_DIR}/src/orxonox/tolua/tolua.pkg
+  WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/lib
+)
+	
+ADD_EXECUTABLE( orxonox ${ORXONOX_SRC_FILES} )
+
+IF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+  SET( ORXONOXS_SRC_FILES
+    GraphicsEngine.cc
+    objects/Ambient.cc
+    objects/Camera.cc
+    objects/CameraHandler.cc
+    objects/Explosion.cc
+    objects/Model.cc
+    objects/NPC.cc
+    objects/Projectile.cc
+    objects/Skybox.cc
+    objects/SpaceShip.cc
+    objects/WorldEntity.cc
+  )
+
+  ADD_LIBRARY(orxonoxs SHARED ${ORXONOX_SRC_FILES})
+ENDIF(NETWORKTRAFFIC_TESTING_ENABLED)
+
+TARGET_LINK_LIBRARIES( orxonox
+  ${OGRE_LIBRARIES}
+  ${Lua_LIBRARIES}
+  ${CEGUI_LIBRARIES}
+  ${CEGUI_SCRIPT_LIBRARIES}
+  tinyxml
+  tolualib
+  ois_orxonox
+  util
+  core
+  audio
+  network
+)
+
Index: /code/branches/ceguilua/src/orxonox/GraphicsEngine.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/GraphicsEngine.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/GraphicsEngine.cc	(revision 1801)
@@ -0,0 +1,147 @@
+/*
+ *   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
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+@file
+@brief
+    Implementation of an partial interface to Ogre.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "GraphicsEngine.h"
+
+#include <OgreRenderWindow.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "util/Debug.h"
+
+#include "tools/ParticleInterface.h"
+
+namespace orxonox
+{
+    //SetConsoleCommand(GraphicsEngine, printScreen, true).setKeybindMode(KeybindMode::OnPress);
+
+    GraphicsEngine* GraphicsEngine::singletonRef_s = 0;
+
+    /**
+    @brief
+        Returns the singleton instance.
+    @return
+        The only instance of GraphicsEngine.
+    */
+    /*static*/ GraphicsEngine& GraphicsEngine::getInstance()
+    {
+        assert(singletonRef_s);
+        return *singletonRef_s;
+    }
+
+    /**
+    @brief
+        Non-initialising constructor.
+    */
+    GraphicsEngine::GraphicsEngine()
+        : root_(0)
+        , renderWindow_(0)
+        , levelSceneManager_(0)
+        , viewport_(0)
+    {
+        RegisterObject(GraphicsEngine);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->detailLevelParticle_ = 0;
+
+        this->setConfigValues();
+        CCOUT(4) << "Constructed" << std::endl;
+    }
+
+    void GraphicsEngine::setConfigValues()
+    {
+        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
+        Destroys all the Ogre related objects
+    */
+    GraphicsEngine::~GraphicsEngine()
+    {
+        singletonRef_s = 0;
+    }
+
+    /**
+    @brief
+        Get the width of the render window
+    @return
+        The width of the render window
+    */
+    int GraphicsEngine::getWindowWidth() const
+    {
+        if (this->renderWindow_)
+            return this->renderWindow_->getWidth();
+        else
+            return 0;
+    }
+
+    /**
+    @brief
+        Get the height of the render window
+    @return
+        The height of the 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 window aspect ratio
+    */
+    float GraphicsEngine::getWindowAspectRatio() const
+    {
+        if (this->renderWindow_)
+            return (float)this->renderWindow_->getHeight() / (float)this->renderWindow_->getWidth();
+        else
+            return 1.0f;
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/GraphicsEngine.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/GraphicsEngine.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/GraphicsEngine.h	(revision 1801)
@@ -0,0 +1,104 @@
+/*
+ *   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
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *   Co-authors:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+  @file
+  @brief Declaration of GraphicsEngine Singleton.
+  @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _GraphicsEngine_H__
+#define _GraphicsEngine_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgrePrerequisites.h>
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+    @brief Graphics engine manager class
+    */
+    class _OrxonoxExport GraphicsEngine : public OrxonoxClass
+    {
+        // HACK: temporary means
+        friend class GSGraphics;
+
+    public:
+        GraphicsEngine();
+        ~GraphicsEngine();
+
+        void setConfigValues();
+        void detailLevelParticleChanged();
+
+        void setLevelSceneManager(Ogre::SceneManager* sceneMgr) { this->levelSceneManager_ = sceneMgr; }
+        Ogre::SceneManager* getLevelSceneManager() { return levelSceneManager_; }
+
+        Ogre::Viewport* getViewport() { return this->viewport_; }
+        Ogre::Root*     getOgreRoot() { return this->root_; }
+
+        // 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_; }
+
+        static GraphicsEngine& getInstance();
+        static GraphicsEngine* getInstancePtr() { return singletonRef_s; }
+
+    private:
+        // don't mess with singletons
+        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
+
+        // stats
+        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
+    };
+}
+
+#endif /* _GraphicsEngine_H__ */
Index: /code/branches/ceguilua/src/orxonox/Main.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/Main.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/Main.cc	(revision 1801)
@@ -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:
+ *      Benjamin Knecht <beni_at_orxonox.net>, (C) 2007
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+ /**
+ @file
+ @brief Entry point of the program. Platform specific code.
+  */
+
+#include "OrxonoxStableHeaders.h"
+
+#include <exception>
+#include <cassert>
+
+#include "util/OrxonoxPlatform.h"
+#include "SignalHandler.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>
+
+// This function will locate the path to our application on OS X,
+// unlike windows you can not rely on the curent working directory
+// for locating your configuration files and resources.
+             std::string macBundlePath()
+{
+    char path[1024];
+    CFBundleRef mainBundle = CFBundleGetMainBundle();
+    assert(mainBundle);
+
+    CFURLRef mainBundleURL = CFBundleCopyBundleURL(mainBundle);
+    assert(mainBundleURL);
+
+    CFStringRef cfStringRef = CFURLCopyFileSystemPath( mainBundleURL, kCFURLPOSIXPathStyle);
+    assert(cfStringRef);
+
+    CFStringGetCString(cfStringRef, path, 1024, kCFStringEncodingASCII);
+
+    CFRelease(mainBundleURL);
+    CFRelease(cfStringRef);
+
+    return std::string(path);
+}
+#endif
+
+
+//#ifdef __cplusplus
+//extern "C" {
+//#endif
+
+int main(int argc, char** argv)
+{
+    // create a signal handler (only works for linux)
+    SignalHandler::getInstance()->doCatch(argv[0], "orxonox.log");
+
+    GSRoot root;
+    GSGraphics graphics;
+    GSStandalone standalone;
+    GSServer server;
+    GSClient client;
+    GSDedicated dedicated;
+    GSGUI gui;
+    GSIOConsole ioConsole;
+
+    root.addChild(&graphics);
+    graphics.addChild(&standalone);
+    graphics.addChild(&server);
+    graphics.addChild(&client);
+    graphics.addChild(&gui);
+
+    root.addChild(&ioConsole);
+    root.addChild(&dedicated);
+
+    root.start(argc, argv);
+
+    return 0;
+}
+
+//#ifdef __cplusplus
+//}
+//#endif
Index: /code/branches/ceguilua/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/OrxonoxPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/OrxonoxPrereqs.h	(revision 1801)
@@ -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:
+ *      ...
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _OrxonoxPrereqs_H__
+#define _OrxonoxPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !(defined(ORXONOX_STATIC_BUILD) || defined(ORXONOX_NO_EXPORTS))
+#  ifdef ORXONOX_SHARED_BUILD
+#    define _OrxonoxExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _OrxonoxExport
+#    else
+#      define _OrxonoxExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _OrxonoxExport  __attribute__ ((visibility("default")))
+#else
+#  define _OrxonoxExport
+#endif
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+namespace orxonox
+{
+    namespace LODParticle
+    {
+        enum LOD
+        {
+            off = 0,
+            low = 1,
+            normal = 2,
+            high = 3
+        };
+    }
+
+    class GraphicsEngine;
+    class Settings;
+
+    class RadarViewable;
+    class Radar;
+    class RadarListener;
+
+    // objects
+    class Ambient;
+    class Backlight;
+    class Camera;
+    class Model;
+    class NPC;
+    class ParticleSpawner;
+    class Skybox;
+    class SpaceShip;
+    class SpaceShipAI;
+    class WorldEntity;
+
+    class Projectile;
+    class BillboardProjectile;
+    class RotatingProjectile;
+    class ParticleProjectile;
+
+    // tools
+    class BillboardSet;
+    class Light;
+    class Mesh;
+    class ParticleInterface;
+    template <class T>
+    class Timer;
+
+    // overlays
+    class BarColour;
+    class DebugFPSText;
+    class DebugRTRText;
+    class HUDBar;
+    class HUDNavigation;
+    class HUDRadar;
+    class HUDSpeedBar;
+    class InGameConsole;
+    class OrxonoxOverlay;
+    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;
+}
+
+namespace Ogre
+{
+    // some got forgotten in OgrePrerequisites
+    class BorderPanelOverlayElement;
+    class PanelOverlayElement;
+    class TextAreaOverlayElement;
+}
+
+namespace CEGUI
+{
+    class LuaScriptModule;
+
+    class OgreCEGUIRenderer;
+    class OgreCEGUIResourceProvider;
+    class OgreCEGUITexture;
+}
+
+struct lua_State;
+
+#endif /* _OrxonoxPrereqs_H__ */
Index: /code/branches/ceguilua/src/orxonox/OrxonoxStableHeaders.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/OrxonoxStableHeaders.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/OrxonoxStableHeaders.h	(revision 1801)
@@ -0,0 +1,103 @@
+/*
+ *   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 Contains the frequently used header files of our own writing
+ */
+
+#ifndef _OrxonoxStableHeaders_H__
+#define _OrxonoxStableHeaders_H__
+
+#include "util/OrxonoxPlatform.h"
+
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) && 0
+
+// including std headers here is useless since they're already precompiled
+
+#ifndef WIN32_LEAN_AND_MEAN
+// prevent Ogre from including winsock.h that messes with winsock2.h from enet
+#  define WIN32_LEAN_AND_MEAN
+#endif
+#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>
+
+#include "tinyxml/ticpp.h"
+#include "tinyxml/tinyxml.h"
+
+//Get around Windows hackery (windows.h is included by Ogre)
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 
+#  ifdef max
+#    undef max
+#  endif
+#  ifdef min
+#    undef min
+#  endif
+#endif
+
+//----------- Our files ----------
+//--------------------------------
+// only include when not debugging so that we may find issues with missing headers quicker
+#if defined(NDEBUG)
+
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "util/Math.h"
+#include "util/Multitype.h"
+#include "util/OutputBuffer.h"
+#include "util/OutputHandler.h"
+#include "util/Sleep.h"
+#include "util/String.h"
+#include "util/SubString.h"
+#include "util/XMLIncludes.h"
+
+#include "core/BaseObject.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CommandExecutor.h"
+#include "core/Executor.h"
+#include "core/XMLPort.h"
+
+#include "network/Synchronisable.h"
+
+//#include "tools/Mesh.h"
+//#include "tools/Timer.h"
+//#include "objects/Model.h"
+//#include "objects/Tickable.h"
+//#include "objects/WorldEntity.h"
+
+#endif /* ifdef NDEBUG */
+
+#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC && !defined(ORXONOX_DISABLE_PCH) */
+
+#endif /* _OrxonoxStableHeaders_H__ */
Index: /code/branches/ceguilua/src/orxonox/PrecompiledHeaderFiles.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/PrecompiledHeaderFiles.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/PrecompiledHeaderFiles.cc	(revision 1801)
@@ -0,0 +1,34 @@
+/*
+ *   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 This file actually generates the precompiled header file
+ */
+
+#include "OrxonoxStableHeaders.h"
Index: /code/branches/ceguilua/src/orxonox/Radar.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/Radar.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/Radar.cc	(revision 1801)
@@ -0,0 +1,213 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+    @file
+    @brief
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "Radar.h"
+#include <cfloat>
+#include <cassert>
+#include "objects/WorldEntity.h"
+#include "objects/SpaceShip.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/Iterator.h"
+#include "RadarListener.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(Radar, cycleNavigationFocus, true).accessLevel(AccessLevel::User);
+    SetConsoleCommand(Radar, releaseNavigationFocus, true).accessLevel(AccessLevel::User);
+
+    Radar* Radar::instance_s = 0;
+
+    Radar::Radar()
+        : focus_(0)
+        , objectTypeCounter_(0)
+    {
+        assert(instance_s == 0);
+        instance_s = this;
+
+        // TODO: make this mapping configurable. Maybe there's a possibility with self configured
+        //       configValues..
+        this->objectTypes_["Asteroid"] = RadarViewable::Dot;
+        this->objectTypes_["SpaceShip"] = RadarViewable::Square;
+        this->objectTypes_["AsdfQwerty"] = RadarViewable::Triangle;
+
+        /*WorldEntity* object;
+        object = new WorldEntity();
+        object->setPosition(2000.0, 0.0, 0.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(0.0, 2000.0, 0.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(0.0, 0.0, 2000.0);
+        addRadarObject(object, ColourValue(0.5, 0, 0, 1));
+        object = new WorldEntity();
+        object->setPosition(10000.0,16000.0,0.0);
+        addRadarObject(object);*/
+
+    }
+
+    Radar::~Radar()
+    {
+        instance_s = 0;
+    }
+
+    const RadarViewable* Radar::getFocus()
+    {
+        return *(this->itFocus_);
+    }
+
+    RadarViewable::Shape Radar::addObjectDescription(const std::string name)
+    {
+        std::map<std::string, RadarViewable::Shape>::iterator it = this->objectTypes_.find(name);
+        if (it == this->objectTypes_.end())
+            return this->objectTypes_[name] = RadarViewable::Square; // default, configure!!
+        else
+            return this->objectTypes_[name];
+    }
+
+
+    void Radar::tick(float dt)
+    {
+        if (this->focus_ != *(this->itFocus_))
+        {
+            // focus object was deleted, release focus
+            this->focus_ = 0;
+            this->itFocus_ = 0;
+        }
+
+        for (ObjectList<RadarListener>::iterator itListener = ObjectList<RadarListener>::begin(); itListener; ++itListener)
+        {
+            (*itListener)->radarTick(dt);
+
+            for (ObjectList<RadarViewable>::iterator itElement = ObjectList<RadarViewable>::begin(); itElement; ++itElement)
+            {
+                if ((*itElement) != SpaceShip::getLocalShip() && (*itListener)->getRadarSensitivity() > (*itElement)->getRadarObjectCamouflage())
+                    (*itListener)->displayObject(*itElement, *itElement == this->focus_);
+            }
+        }
+    }
+
+    void Radar::cycleFocus()
+    {
+        if (ObjectList<RadarViewable>::begin() == 0)
+        {
+            // list is empty
+            this->itFocus_ = 0;
+            this->focus_ = 0;
+        }
+        else
+        {
+            Vector3 localPosition = SpaceShip::getLocalShip()->getPosition();
+            Vector3 targetPosition = localPosition;
+            if (*(this->itFocus_))
+                targetPosition = this->itFocus_->getWorldPosition();
+
+            // find the closed object further away than targetPosition
+            float currentDistance = localPosition.squaredDistance(targetPosition);
+            float nextDistance = FLT_MAX;
+            float minimumDistance = FLT_MAX;
+            ObjectList<RadarViewable>::iterator itFallback = 0;
+
+            for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)
+            {
+                if (*it == SpaceShip::getLocalShip())
+                    continue;
+
+                float targetDistance = localPosition.squaredDistance((*it)->getWorldPosition());
+                if (targetDistance > currentDistance && targetDistance < nextDistance)
+                {
+                    this->itFocus_ = it;
+                    nextDistance = targetDistance;
+                }
+                if (targetDistance < minimumDistance)
+                {
+                    itFallback = it;
+                    minimumDistance = targetDistance;
+                }
+            }
+
+            if (nextDistance == FLT_MAX)
+            {
+                // we already had the furthest object
+                this->itFocus_ = itFallback;
+                this->focus_ = *itFallback;
+            }
+            else
+            {
+                this->focus_ = *(this->itFocus_);
+            }
+        }
+    }
+
+    void Radar::releaseFocus()
+    {
+        this->itFocus_ = 0;
+        this->focus_ = 0;
+    }
+
+    void Radar::listObjects() const
+    {
+        COUT(3) << "List of RadarObjects:\n";
+        // iterate through all Radar Objects
+        unsigned int i = 0;
+        for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it, ++i)
+        {
+            COUT(3) << i++ << ": " << (*it)->getWorldPosition() << std::endl;
+        }
+    }
+
+
+    /*static*/ Radar& Radar::getInstance()
+    {
+        assert(instance_s);
+        return *instance_s;
+    }
+
+    /*static*/ void Radar::cycleNavigationFocus()
+    {
+        // avoid using getInstance because of the assert().
+        // User might call this fuction even if HUDNavigation doesn't exist.
+        if (instance_s)
+            instance_s->cycleFocus();
+    }
+
+    /*static*/ void Radar::releaseNavigationFocus()
+    {
+        // avoid using getInstance because of the assert().
+        // User might call this fuction even if HUDNavigation doesn't exist.
+        if (instance_s)
+            instance_s->releaseFocus();
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/Radar.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/Radar.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/Radar.h	(revision 1801)
@@ -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:
+ *      Felix Schulthess
+ *
+ */
+
+/**
+    @file
+    @brief
+*/
+
+#ifndef _Radar_H__
+#define _Radar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <string>
+#include "core/Iterator.h"
+#include "core/OrxonoxClass.h"
+#include "objects/Tickable.h"
+#include "RadarViewable.h"
+
+namespace orxonox
+{
+    /**
+    @brief This class merely ensures that no one can inherit from Radar.
+    */
+    class _OrxonoxExport RadarBase
+    {
+    private:
+        friend class Radar;
+        RadarBase() { }
+    };
+
+    class _OrxonoxExport Radar : public Tickable, private virtual RadarBase
+    {
+    public:
+        Radar();
+        ~Radar();
+
+        virtual void tick(float dt);
+
+        const RadarViewable* getFocus();
+        RadarViewable::Shape addObjectDescription(const std::string name);
+
+        void listObjects() const;
+
+        static Radar& getInstance();
+        static Radar* getInstancePtr() { return instance_s; }
+
+        static void cycleNavigationFocus();
+        static void releaseNavigationFocus();
+
+    private:
+        Radar(Radar& instance);
+
+        void releaseFocus();
+        void updateFocus();
+        void cycleFocus();
+
+        ObjectListIterator<RadarViewable> itFocus_;
+        RadarViewable* focus_;
+        std::map<std::string, RadarViewable::Shape> objectTypes_;
+        int objectTypeCounter_;
+
+        static Radar* instance_s;
+    };
+}
+#endif /* _Radar_H__ */
Index: /code/branches/ceguilua/src/orxonox/RadarListener.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/RadarListener.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/RadarListener.cc	(revision 1801)
@@ -0,0 +1,39 @@
+/*
+ *   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 "RadarListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    RadarListener::RadarListener()
+    {
+        RegisterRootObject(RadarListener);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/RadarListener.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/RadarListener.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/RadarListener.h	(revision 1801)
@@ -0,0 +1,49 @@
+/*
+ *   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 _RadarListener_H__
+#define _RadarListener_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RadarListener : virtual public OrxonoxClass
+    {
+    public:
+        RadarListener();
+        virtual ~RadarListener() { }
+
+        virtual void displayObject(RadarViewable* viewable, bool bIsMarked) = 0;
+        virtual float getRadarSensitivity() const = 0;
+        virtual void radarTick(float dt) = 0;
+    };
+}
+
+#endif /* _RadarListener_H__ */
Index: /code/branches/ceguilua/src/orxonox/RadarViewable.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/RadarViewable.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/RadarViewable.cc	(revision 1801)
@@ -0,0 +1,73 @@
+/*
+ *   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 "RadarViewable.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "objects/WorldEntity.h"
+#include "Radar.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor.
+    */
+    RadarViewable::RadarViewable()
+        : radarObject_(0)
+        , radarObjectCamouflage_(0.0f)
+        , radarObjectType_(Dot)
+        , radarObjectDescription_("staticObject")
+    {
+        RegisterRootObject(RadarViewable);
+    }
+
+    void RadarViewable::setRadarObjectDescription(const std::string& str)
+    {
+        Radar* radar = Radar::getInstancePtr();
+        if (radar)
+            this->radarObjectType_ = radar->addObjectDescription(str);
+        else
+        {
+            CCOUT(2) << "Attempting to access the radar, but the radar is non existent." << std::endl;
+        }
+        this->radarObjectDescription_ = str;
+    }
+
+    const Vector3& RadarViewable::getWorldPosition() const
+    {
+        validate();
+        return this->radarObject_->getWorldPosition();
+    }
+
+    Vector3 RadarViewable::getOrientedVelocity() const
+    {
+        validate();
+        return this->radarObject_->getOrientation() * this->radarObject_->getVelocity();
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/RadarViewable.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/RadarViewable.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/RadarViewable.h	(revision 1801)
@@ -0,0 +1,87 @@
+/*
+ *   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 _RadarViewable_H__
+#define _RadarViewable_H__
+
+#include "OrxonoxPrereqs.h"
+#include <string>
+#include <cassert>
+#include "util/Math.h"
+#include "util/Debug.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    /**
+    @brief Interface for receiving window events.
+    */
+    class _OrxonoxExport RadarViewable : virtual public OrxonoxClass
+    {
+    public:
+        enum Shape
+        {
+            Square,
+            Dot,
+            Triangle
+        };
+
+    public:
+        RadarViewable();
+        virtual ~RadarViewable() { }
+
+        float getRadarObjectCamouflage() const { return this->radarObjectCamouflage_; }
+        void setRadarObjectCamouflage(float camouflage) { this->radarObjectCamouflage_ = camouflage; }
+
+        const ColourValue& getRadarObjectColour() const { return this->radarObjectColour_; }
+        void setRadarObjectColour(const ColourValue& colour) { this->radarObjectColour_ = colour; }
+
+        const std::string& getRadarObjectDescription() const { return this->radarObjectDescription_; }
+        void setRadarObjectDescription(const std::string& str);
+
+        const WorldEntity* getWorldEntity() const { return this->radarObject_; }
+        const Vector3& getWorldPosition() const;
+        Vector3 getOrientedVelocity() const;
+
+        Shape getRadarObjectType() const { return this->radarObjectType_; }
+
+    protected:
+        WorldEntity* radarObject_;
+
+    private:
+        void validate() const { if (!this->radarObject_)
+        { COUT(1) << "Assertation: Every RadarViewable has to be assigned a WorldEntity pointer!" << std::endl; assert(0); } }
+
+        float radarObjectCamouflage_;
+        Shape radarObjectType_;
+        std::string radarObjectDescription_;
+        ColourValue radarObjectColour_;
+    };
+}
+
+#endif /* _RadarViewable_H__ */
Index: /code/branches/ceguilua/src/orxonox/Settings.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/Settings.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/Settings.cc	(revision 1801)
@@ -0,0 +1,98 @@
+/*
+ *   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 Settings class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "Settings.h"
+
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    Settings* Settings::singletonRef_s = 0;
+
+    /**
+    @brief
+        Constructor: Registers the object and sets the config-values.
+    */
+    Settings::Settings()
+        : bShowsGraphics_(false)
+        , bHasServer_(false)
+    {
+        RegisterRootObject(Settings);
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+        setConfigValues();
+    }
+
+    /**
+    @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] != '/')
+        {
+            ModifyConfigValue(dataPath_, set, dataPath_ + "/");
+        }
+
+        if (dataPath_ == "")
+        {
+            ModifyConfigValue(dataPath_, set, "/");
+            COUT(2) << "Warning: Data path set to \"/\", is that really correct?" << std::endl;
+        }
+    }
+
+    /**
+    @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/branches/ceguilua/src/orxonox/Settings.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/Settings.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/Settings.h	(revision 1801)
@@ -0,0 +1,91 @@
+/*
+ *   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 Core.h
+    @brief Declaration of the Settings class.
+
+    The static Settings class is only used to configure some variables
+    through the config-file.
+*/
+
+#ifndef _Settings_H__
+#define _Settings_H__
+
+#include "OrxonoxPrereqs.h"
+#include <string>
+#include "core/OrxonoxClass.h"
+#include "util/Debug.h"
+#include "util/MultiType.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Settings : public OrxonoxClass
+    {
+        friend class ClassIdentifier<Settings>;
+        friend class GSRoot;
+        friend class GSGraphics;
+        friend class GSServer;
+        friend class GSDedicated;
+
+    public:
+        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); }
+
+        // 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:
+        // 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; }
+
+        Settings();
+        Settings(const Settings& instance);
+        ~Settings() { singletonRef_s = 0; }
+
+        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.
+    };
+
+}
+
+#endif /* _Settings_H__ */
Index: /code/branches/ceguilua/src/orxonox/SignalHandler.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/SignalHandler.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/SignalHandler.cc	(revision 1801)
@@ -0,0 +1,353 @@
+/*
+ *   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:
+ *      Christoph Renner
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file SignalHandler.cc
+    @brief Implementation of the SignalHandler class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "SignalHandler.h"
+#include "util/Debug.h"
+
+#include <assert.h>
+#include <iostream>
+
+SignalHandler * SignalHandler::singletonRef = NULL;
+
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+
+#include <wait.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+
+bool SignalHandler::bXAutoKeyRepeatOn_ = false;
+
+SignalHandler::SignalHandler()
+{
+}
+
+/**
+ * register signal handlers for SIGSEGV and SIGABRT
+ * @param appName path to executable eg argv[0]
+ * @param fileName filename to append backtrace to
+ */
+void SignalHandler::doCatch( const std::string & appName, const std::string & fileName )
+{
+  this->appName = appName;
+  this->fileName = fileName;
+
+  // prepare for restoring XAutoKeyRepeat
+  Display* display;
+  if ((display = XOpenDisplay(0)))
+  {
+    XKeyboardState oldState;
+    XGetKeyboardControl(display, &oldState);
+    if (oldState.global_auto_repeat == AutoRepeatModeOn)
+      bXAutoKeyRepeatOn_ = true;
+    else
+      bXAutoKeyRepeatOn_ = false;
+    XCloseDisplay(display);
+  }
+  else
+  {
+    std::cout << "Warning: couldn't open X display to restore XAutoKeyRepeat." << std::endl;
+    bXAutoKeyRepeatOn_ = false;
+  }
+
+
+  // make sure doCatch is only called once without calling dontCatch
+  assert( sigRecList.size() == 0 );
+
+  catchSignal( SIGSEGV );
+  catchSignal( SIGABRT );
+  catchSignal( SIGILL );
+}
+
+/**
+ * restore previous signal handlers
+ */
+void SignalHandler::dontCatch()
+{
+  for ( SignalRecList::iterator it = sigRecList.begin(); it != sigRecList.end(); it++ )
+  {
+    signal( it->signal, it->handler );
+  }
+
+  sigRecList.clear();
+}
+
+/**
+ * catch signal sig
+ * @param sig signal to catch
+ */
+void SignalHandler::catchSignal( int sig )
+{
+  sig_t handler = signal( sig, SignalHandler::sigHandler );
+
+  assert( handler != SIG_ERR );
+
+  SignalRec rec;
+  rec.signal = sig;
+  rec.handler = handler;
+
+  sigRecList.push_front( rec );
+}
+
+/**
+ * sigHandler is called when receiving signals
+ * @param sig
+ */
+void SignalHandler::sigHandler( int sig )
+{
+  for ( SignalCallbackList::iterator it = SignalHandler::getInstance()->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++  )
+  {
+    (*(it->cb))( it->someData );
+  }
+
+  std::string sigName = "UNKNOWN";
+
+  switch ( sig )
+  {
+    case SIGSEGV:
+      sigName = "SIGSEGV";
+      break;
+    case SIGABRT:
+      sigName = "SIGABRT";
+      break;
+    case SIGILL:
+      sigName = "SIGILL";
+      break;
+  }
+
+  if (bXAutoKeyRepeatOn_)
+  {
+    std::cout << "Trying to restore XAutoKeyRepeat" << std::endl;
+    Display* display;
+    if ((display = XOpenDisplay(0)))
+    {
+      XAutoRepeatOn(display);
+      XCloseDisplay(display);
+    }
+  }
+
+  COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "try to write backtrace to file orxonox.log" << std::endl;
+
+  int sigPipe[2];
+  if ( pipe(sigPipe) == -1 )
+  {
+    perror("pipe failed!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  int sigPid = fork();
+
+  if ( sigPid == -1 )
+  {
+    perror("fork failed!\n");
+    exit(EXIT_FAILURE);
+  }
+
+  // gdb will be attached to this process
+  if ( sigPid == 0 )
+  {
+    getInstance()->dontCatch();
+    // wait for message from parent when it has attached gdb
+    int someData;
+
+    read( sigPipe[0], &someData, sizeof(someData) );
+
+    if ( someData != 0x12345678 )
+    {
+      COUT(0) << "something went wrong :(" << std::endl;
+    }
+
+    return;
+  }
+
+  int gdbIn[2];
+  int gdbOut[2];
+  int gdbErr[2];
+
+  if ( pipe(gdbIn) == -1 || pipe(gdbOut) == -1 || pipe(gdbErr) == -1 )
+  {
+    perror("pipe failed!\n");
+    kill( sigPid, SIGTERM );
+    waitpid( sigPid, NULL, 0 );
+    exit(EXIT_FAILURE);
+  }
+
+  int gdbPid = fork();
+  // this process will run gdb
+
+  if ( gdbPid == -1 )
+  {
+    perror("fork failed\n");
+    kill( sigPid, SIGTERM );
+    waitpid( sigPid, NULL, 0 );
+    exit(EXIT_FAILURE);
+  }
+
+  if ( gdbPid == 0 )
+  {
+    // start gdb
+
+    close(gdbIn[1]);
+    close(gdbOut[0]);
+    close(gdbErr[0]);
+
+    dup2( gdbIn[0], STDIN_FILENO );
+    dup2( gdbOut[1], STDOUT_FILENO );
+    dup2( gdbErr[1], STDERR_FILENO );
+
+    execlp( "sh", "sh", "-c", "gdb", (void*)NULL);
+  }
+
+  char cmd[256];
+  snprintf( cmd, 256, "file %s\nattach %d\nc\n", getInstance()->appName.c_str(), sigPid );
+  write( gdbIn[1], cmd, strlen(cmd) );
+
+  int charsFound = 0;
+  int promptFound = 0;
+  char byte;
+  while ( read( gdbOut[0], &byte, 1 ) == 1 )
+  {
+    if (
+      charsFound == 0 && byte == '(' ||
+      charsFound == 1 && byte == 'g' ||
+      charsFound == 2 && byte == 'd' ||
+      charsFound == 3 && byte == 'b' ||
+      charsFound == 4 && byte == ')' ||
+      charsFound == 5 && byte == ' '
+        )
+          charsFound++;
+    else
+      charsFound = 0;
+
+    if ( charsFound == 6 )
+    {
+      promptFound++;
+      charsFound = 0;
+    }
+
+    if ( promptFound == 3 )
+    {
+      break;
+    }
+  }
+
+  int someData = 0x12345678;
+  write( sigPipe[1], &someData, sizeof(someData) );
+
+  write( gdbIn[1], "bt\nk\nq\n", 7 );
+
+
+  charsFound = 0;
+  promptFound = 0;
+  std::string bt;
+  while ( read( gdbOut[0], &byte, 1 ) == 1 )
+  {
+    bt += std::string( &byte, 1 );
+
+    if (
+      charsFound == 0 && byte == '(' ||
+      charsFound == 1 && byte == 'g' ||
+      charsFound == 2 && byte == 'd' ||
+      charsFound == 3 && byte == 'b' ||
+      charsFound == 4 && byte == ')' ||
+      charsFound == 5 && byte == ' '
+        )
+          charsFound++;
+    else
+      charsFound = 0;
+
+    if ( charsFound == 6 )
+    {
+      promptFound++;
+      charsFound = 0;
+      bt += "\n";
+    }
+
+    if ( promptFound == 3 )
+    {
+      break;
+    }
+  }
+
+
+  waitpid( sigPid, NULL, 0 );
+  waitpid( gdbPid, NULL, 0 );
+
+  int wsRemoved = 0;
+
+  while ( wsRemoved < 2 && bt.length() > 0 )
+  {
+    if ( bt[1] == '\n' )
+      wsRemoved++;
+    bt.erase(0, 1);
+  }
+
+  if ( bt.length() > 0 )
+    bt.erase(0, 1);
+
+  time_t now = time(NULL);
+
+  std::string timeString = "\n\n\n\n"
+                     "=======================================================\n"
+                     "= time: " + std::string(ctime(&now)) +
+         "=======================================================\n";
+  bt.insert(0, timeString);
+
+  FILE * f = fopen( getInstance()->fileName.c_str(), "a" );
+
+  if ( !f )
+  {
+    perror( ( std::string( "could not append to " ) + getInstance()->fileName ).c_str() );
+    exit(EXIT_FAILURE);
+  }
+
+  if ( fwrite( bt.c_str(), 1, bt.length(), f ) != bt.length() )
+  {
+    COUT(0) << "could not write " << bt.length() << " byte to " << getInstance()->fileName << std::endl;
+    exit(EXIT_FAILURE);
+  }
+
+  exit(EXIT_FAILURE);
+}
+
+void SignalHandler::registerCallback( SignalCallback cb, void * someData )
+{
+  SignalCallbackRec rec;
+  rec.cb = cb;
+  rec.someData = someData;
+
+  callbackList.push_back(rec);
+}
+
+#endif /* ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 */
Index: /code/branches/ceguilua/src/orxonox/SignalHandler.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/SignalHandler.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/SignalHandler.h	(revision 1801)
@@ -0,0 +1,109 @@
+/*
+ *   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:
+ *      Christoph Renner
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file SignalHandler.h
+    @brief Declaration of the SignalHandler class.
+*/
+
+#ifndef _SignalHandler_H__
+#define _SignalHandler_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <list>
+#include <string>
+
+typedef int (*SignalCallback)( void * someData );
+
+#if ORXONOX_PLATFORM != ORXONOX_PLATFORM_WIN32
+#include <signal.h>
+
+struct SignalRec
+{
+  int signal;
+  sig_t handler;
+};
+
+struct SignalCallbackRec
+{
+  SignalCallback cb;
+  void * someData;
+};
+
+
+typedef std::list<SignalRec> SignalRecList;
+typedef std::list<SignalCallbackRec> SignalCallbackList;
+
+class SignalHandler
+{
+  private:
+    SignalHandler();
+  public:
+    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
+    ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
+
+    void registerCallback( SignalCallback cb, void * someData );
+
+    void doCatch( const std::string & appName, const std::string & fileName );
+    void dontCatch();
+
+  private:
+    static void sigHandler( int sig );
+
+    void catchSignal( int sig );
+    SignalRecList sigRecList;
+
+    SignalCallbackList callbackList;
+
+    static SignalHandler * singletonRef;
+
+    std::string appName;
+    std::string fileName;
+
+    // used to turn on KeyAutoRepeat if OIS crashes
+    static bool bXAutoKeyRepeatOn_;
+};
+
+#else /* ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 */
+
+class _OrxonoxExport SignalHandler
+{
+  public:
+    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
+    void doCatch( const std::string & appName, const std::string & fileName ) {};
+    void dontCatch() {};
+    void registerCallback( SignalCallback cb, void * someData ) {};
+
+  private:
+    static SignalHandler * singletonRef;
+};
+
+#endif /* ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32 */
+
+#endif /* _SignalHandler_H__ */
Index: /code/branches/ceguilua/src/orxonox/gamestates/GSClient.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSClient.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSClient.cc	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSClient.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSClient.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSClient.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSDedicated.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSDedicated.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSDedicated.cc	(revision 1801)
@@ -0,0 +1,120 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      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 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/branches/ceguilua/src/orxonox/gamestates/GSDedicated.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSDedicated.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSDedicated.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSGUI.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSGUI.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSGUI.cc	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSGUI.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSGUI.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSGUI.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSGraphics.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSGraphics.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSGraphics.cc	(revision 1801)
@@ -0,0 +1,369 @@
+/*
+ *   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 "util/Exception.h"
+#include "core/ConsoleCommand.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/CoreIncludes.h"
+#include "core/input/InputManager.h"
+#include "core/input/KeyBinder.h"
+#include "core/input/ExtendedInputState.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)
+        , masterKeyBinder_(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);
+        // Configure master input state with a KeyBinder
+        //masterKeyBinder_ = new KeyBinder();
+        //inputManager_->getMasterInputState()->addKeyHandler(masterKeyBinder_);
+
+        // 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_;
+
+        //inputManager_->getMasterInputState()->removeKeyHandler(this->masterKeyBinder_);
+        //delete this->masterKeyBinder_;
+        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/branches/ceguilua/src/orxonox/gamestates/GSGraphics.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSGraphics.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSGraphics.h	(revision 1801)
@@ -0,0 +1,94 @@
+/*
+ *   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_;
+
+        KeyBinder*            masterKeyBinder_;
+
+        // 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/branches/ceguilua/src/orxonox/gamestates/GSIOConsole.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSIOConsole.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSIOConsole.cc	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSIOConsole.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSIOConsole.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSIOConsole.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSLevel.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSLevel.cc	(revision 1801)
@@ -0,0 +1,151 @@
+/*
+ *   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 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/branches/ceguilua/src/orxonox/gamestates/GSLevel.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSLevel.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSLevel.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSRoot.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSRoot.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSRoot.cc	(revision 1801)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "GSRoot.h"
+
+#include <OgreLogManager.h>
+#include <OgreRoot.h>
+
+#include "util/Exception.h"
+#include "util/Debug.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 "core/Shell.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)
+        , tclBind_(0)
+        , tclThreadManager_(0)
+        , shell_(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
+        this->tclBind_ = new TclBind(Settings::getDataPath());
+        this->tclThreadManager_ = new TclThreadManager(tclBind_->getTclInterpreter());
+
+        // create a shell
+        this->shell_ = new Shell();
+
+        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()
+    {
+        // TODO: remove and destroy console commands
+
+        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 this->shell_;
+        delete this->tclThreadManager_;
+        delete this->tclBind_;
+
+        delete settings_;
+
+    }
+
+    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/branches/ceguilua/src/orxonox/gamestates/GSRoot.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSRoot.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSRoot.h	(revision 1801)
@@ -0,0 +1,80 @@
+/*
+ *   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
+        TclBind*              tclBind_;
+        TclThreadManager*     tclThreadManager_;
+        Shell*                shell_;
+
+        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/branches/ceguilua/src/orxonox/gamestates/GSServer.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSServer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSServer.cc	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSServer.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSServer.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSServer.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSStandalone.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSStandalone.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSStandalone.cc	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gamestates/GSStandalone.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gamestates/GSStandalone.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gamestates/GSStandalone.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/GUIManager.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/GUIManager.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/GUIManager.cc	(revision 1801)
@@ -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 "util/Exception.h"
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/tolua/tolua_bind.h"
+#include "core/ConsoleCommand.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) << "Initialising 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/branches/ceguilua/src/orxonox/gui/GUIManager.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/GUIManager.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/GUIManager.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/OgreCEGUIRenderer.cpp
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIRenderer.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIRenderer.cpp	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/OgreCEGUIRenderer.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIRenderer.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIRenderer.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/OgreCEGUIResourceProvider.cpp
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIResourceProvider.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIResourceProvider.cpp	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/OgreCEGUIResourceProvider.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIResourceProvider.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/OgreCEGUIResourceProvider.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/OgreCEGUITexture.cpp
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/OgreCEGUITexture.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/OgreCEGUITexture.cpp	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/gui/OgreCEGUITexture.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/gui/OgreCEGUITexture.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/gui/OgreCEGUITexture.h	(revision 1801)
@@ -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/branches/ceguilua/src/orxonox/objects/Ambient.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Ambient.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Ambient.cc	(revision 1801)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Ambient.h"
+
+#include <vector>
+#include <string>
+
+#include <OgreSceneManager.h>
+
+#include "tinyxml/tinyxml.h"
+#include "util/SubString.h"
+#include "util/Math.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+#include "Settings.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    SetConsoleCommandAlias(Ambient, setAmbientLightTest, "setAmbientLight", false).defaultValues(ColourValue(1, 1, 1, 1)).accessLevel(AccessLevel::Offline);
+
+    CreateFactory(Ambient);
+
+    Ambient* Ambient::instance_s;
+
+    Ambient::Ambient()
+    {
+        RegisterObject(Ambient);
+        Ambient::instance_s = this;
+        registerAllVariables();
+    }
+
+    Ambient::~Ambient()
+    {
+    }
+
+    bool Ambient::create()
+    {
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setAmbientLight(ambientLight_);
+        return Synchronisable::create();
+    }
+
+    void Ambient::registerAllVariables()
+    {
+        registerVar(&ambientLight_, sizeof(ColourValue), network::DATA);
+    }
+
+    void Ambient::setAmbientLight(const ColourValue& 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
+    */
+    void Ambient::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Ambient, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Ambient, "colourvalue", setAmbientLight, getAmbienetLight, xmlelement, mode);
+        create();
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Ambient.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Ambient.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Ambient.h	(revision 1801)
@@ -0,0 +1,64 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Ambient_H__
+#define _Ambient_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "util/Math.h"
+#include "core/BaseObject.h"
+#include "network/Synchronisable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Ambient : public BaseObject, public network::Synchronisable
+    {
+        public:
+            Ambient();
+            virtual ~Ambient();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual bool create();
+            void registerAllVariables();
+
+            void setAmbientLight(const ColourValue& colour);
+            inline const ColourValue& getAmbienetLight() const
+                { return this->ambientLight_; }
+
+            static void setAmbientLightTest(const ColourValue& colour)
+                { Ambient::instance_s->setAmbientLight(colour); }
+
+        private:
+            static Ambient* instance_s;
+            ColourValue ambientLight_;
+
+    };
+}
+
+#endif /* _Ambient_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/Backlight.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Backlight.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Backlight.cc	(revision 1801)
@@ -0,0 +1,155 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Backlight.h"
+
+#include <OgreBillboard.h>
+#include <OgreRibbonTrail.h>
+#include <OgreSceneManager.h>
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Executor.h"
+#include "util/Math.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(Backlight);
+
+    float Backlight::timeFactor_s = 1.0;
+
+    Backlight::Backlight(float maxspeed, float brakingtime, float scale)
+    {
+        RegisterObject(Backlight);
+
+        this->setConfigValues();
+        this->traillength_ = 1;
+
+        this->getNode()->setInheritScale(false);
+
+        this->billboard_.setBillboardSet("Flares/backlightflare");
+        this->attachObject(this->billboard_.getBillboardSet());
+
+        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());
+
+        this->configure(maxspeed, brakingtime, scale);
+
+        this->ribbonTrail_->setTrailLength(this->maxTraillength_);
+        this->ribbonTrail_->setMaterialName("Trail/backlighttrail");
+
+        //this->setTimeFactor(Orxonox::getInstance().getTimeFactor());
+        this->setTimeFactor(1.0f);
+    }
+
+    Backlight::~Backlight()
+    {
+        if (this->isInitialized())
+        {
+            this->detachObject(this->billboard_.getBillboardSet());
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName() + "RibbonTrailNode");
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyRibbonTrail(this->ribbonTrail_);
+        }
+    }
+
+    void Backlight::setConfigValues()
+    {
+        SetConfigValue(maxLifeTime_, 4.0).description("The maximal amount of seconds the trail behind a SpaceShip stays visible");
+        SetConfigValue(trailSegmentLength_, 50).description("The length of one segment of the trail behind a SpaceShip (lower values make it more smooth)");
+        SetConfigValue(width_, 7.0).description("The width of the trail");
+    }
+
+    void Backlight::setTimeFactor(float factor)
+    {
+        Backlight::timeFactor_s = factor;
+        float change = Backlight::timeFactor_s / this->maxLifeTime_;
+        this->ribbonTrail_->setWidthChange(0, this->width_ * change);
+        this->updateColourChange();
+    }
+
+    void Backlight::updateColourChange()
+    {
+        this->ribbonTrail_->setColourChange(0, ColourValue(0, 0, 0, this->maxTraillength_ / this->traillength_ / this->maxLifeTime_ * Backlight::timeFactor_s));
+    }
+
+    void Backlight::tick(float dt)
+    {
+        SUPER(Backlight, tick, dt);
+
+        if (this->isActive())
+        {
+            if (this->traillength_ < this->maxTraillength_)
+            {
+                this->traillength_ = min<float>(this->maxTraillength_, this->traillength_ + dt * this->maxTraillength_ / this->maxLifeTime_);
+                this->updateColourChange();
+            }
+        }
+        else
+        {
+            if (this->traillength_ > 1)
+            {
+                this->traillength_ = max<float>(1, this->traillength_ - this->brakefactor_ * dt * this->maxTraillength_ / this->maxLifeTime_);
+                this->updateColourChange();
+            }
+        }
+
+        this->ribbonTrail_->setTrailLength(this->traillength_);
+    }
+
+    void Backlight::setColour(const ColourValue& colour)
+    {
+        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+        this->ribbonTrail_->setInitialColour(0, ColourValue(colour.r / 4 + 0.75, colour.g / 4 + 0.75, colour.b / 4 + 0.75));
+    }
+
+    void Backlight::configure(float maxspeed, float brakingtime, float scale)
+    {
+        this->maxTraillength_ = this->maxLifeTime_ * maxspeed;
+        this->maxTrailsegments_ = (size_t)(this->maxTraillength_ / this->trailSegmentLength_);
+        this->ribbonTrail_->setMaxChainElements(this->maxTrailsegments_);
+        this->ribbonTrail_->setTrailLength(this->traillength_ = 2 * this->maxTrailsegments_);
+
+        this->brakefactor_ = this->maxLifeTime_ / brakingtime;
+
+        this->scale(scale);
+        this->ribbonTrail_->setInitialWidth(0, this->width_ * scale);
+        this->ribbonTrail_->setWidthChange(0, this->width_ * scale / this->maxLifeTime_ * Backlight::timeFactor_s);
+    }
+
+    void Backlight::changedVisibility()
+    {
+        SUPER(Backlight, changedVisibility);
+
+        this->billboard_.setVisible(this->isVisible());
+        this->ribbonTrail_->setVisible(this->isVisible());
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Backlight.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Backlight.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Backlight.h	(revision 1801)
@@ -0,0 +1,75 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Backlight_H__
+#define _Backlight_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "tools/Timer.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Backlight : public WorldEntity
+    {
+        public:
+            Backlight(float maxspeed = 1.0, float brakingtime = 1.0, float scale = 1.0);
+            virtual ~Backlight();
+
+            void setConfigValues();
+            virtual void tick(float dt);
+            virtual void changedVisibility();
+
+            void setColour(const ColourValue& colour);
+            void setTimeFactor(float factor);
+
+        private:
+            void configure(float maxspeed, float brakingtime, float scale = 1);
+            void updateColourChange();
+
+            static float timeFactor_s;
+            BillboardSet billboard_;
+            Ogre::SceneNode* ribbonTrailNode_;
+            Ogre::RibbonTrail* ribbonTrail_;
+
+            float maxLifeTime_;
+            float trailSegmentLength_;
+            float width_;
+
+            float brakefactor_;
+
+            float maxTraillength_;
+            float traillength_;
+
+            size_t maxTrailsegments_;
+    };
+}
+
+#endif /* _Backlight_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/BillboardProjectile.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/BillboardProjectile.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/BillboardProjectile.cc	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BillboardProjectile.h"
+
+#include <OgreBillboard.h>
+
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(BillboardProjectile);
+
+    BillboardProjectile::BillboardProjectile(SpaceShip* owner) : Projectile(owner)
+    {
+        RegisterObject(BillboardProjectile);
+
+        if (this->owner_)
+        {
+            this->billboard_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
+            this->attachObject(this->billboard_.getBillboardSet());
+            this->scale(0.5);
+        }
+    }
+
+    BillboardProjectile::~BillboardProjectile()
+    {
+        if (this->isInitialized() && this->owner_)
+            this->detachObject(this->billboard_.getBillboardSet());
+    }
+
+    void BillboardProjectile::setColour(const ColourValue& colour)
+    {
+        this->billboard_.getBillboardSet()->getBillboard(0)->setColour(colour);
+    }
+
+    void BillboardProjectile::changedVisibility()
+    {
+        SUPER(BillboardProjectile, changedVisibility);
+        this->billboard_.setVisible(this->isVisible());
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/BillboardProjectile.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/BillboardProjectile.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/BillboardProjectile.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _BillboardProjectile_H__
+#define _BillboardProjectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Projectile.h"
+#include "tools/BillboardSet.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BillboardProjectile : public Projectile
+    {
+        public:
+            BillboardProjectile(SpaceShip* owner = 0);
+            virtual ~BillboardProjectile();
+
+            virtual void setColour(const ColourValue& colour);
+            virtual void changedVisibility();
+
+        private:
+            BillboardSet billboard_;
+    };
+}
+
+#endif /* _BillboardProjectile_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/Camera.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Camera.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Camera.cc	(revision 1801)
@@ -0,0 +1,121 @@
+/*
+ *   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:
+ *      Benjamin Knecht
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Camera.h"
+#include "CameraHandler.h"
+
+#include <string>
+
+#include <OgreSceneManager.h>
+#include <OgreSceneNode.h>
+#include <OgreRenderWindow.h>
+#include <OgreViewport.h>
+
+#include "tinyxml/tinyxml.h"
+#include "util/SubString.h"
+#include "util/Math.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+
+  Camera::Camera(Ogre::SceneNode* node)
+  {
+    this->bHasFocus_ = false;
+    this->cameraNode_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(node->getName() + "Camera");
+    if( node != NULL )
+      this->setPositionNode(node);
+  }
+
+  Camera::~Camera()
+  {
+    CameraHandler::getInstance()->releaseFocus(this);
+    GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeAndDestroyChild(cameraNode_->getName());
+  }
+
+  void Camera::setPositionNode(Ogre::SceneNode* node)
+  {
+    this->positionNode_ = node;
+    // set camera to node values according to camera mode
+  }
+
+  void Camera::setTargetNode(Ogre::SceneNode* obj)
+  {
+    this->targetNode_ = obj;
+  }
+
+  void Camera::tick(float dt)
+  {
+    if (this->positionNode_ != NULL)
+    {
+      // this stuff here may need some adjustments
+      Vector3 offset = this->positionNode_->getWorldPosition() - this->cameraNode_->getWorldPosition();
+      float coeff = 15.0f * dt;
+      if (coeff > 1.0f)
+        coeff = 1.0f;
+
+      this->cameraNode_->translate(coeff * offset);
+
+      this->cameraNode_->setOrientation(Quaternion::Slerp(7.0f * dt, this->positionNode_->getWorldOrientation(), this->cameraNode_->getWorldOrientation(), false));
+    }
+  }
+
+  /**
+    don't move anything before here! here the Ogre camera is set to values of this camera
+    always call update after changes
+  */
+  void Camera::update()
+  {
+    if(this->positionNode_ != NULL)
+    {
+      this->cameraNode_->setPosition(this->positionNode_->getWorldPosition());
+      this->cameraNode_->setOrientation(this->positionNode_->getWorldOrientation());
+    }
+  }
+
+  /**
+    what to do when camera loses focus (do not request focus in this function!!)
+    this is called by the CameraHandler singleton class to notify the camera
+  */
+  void Camera::removeFocus()
+  {
+    this->bHasFocus_ = false;
+    this->cameraNode_->detachObject(this->cam_);
+  }
+
+  void Camera::setFocus(Ogre::Camera* ogreCam)
+  {
+    this->bHasFocus_ = true;
+    this->cam_ = ogreCam;
+    this->cam_->setOrientation(this->cameraNode_->getWorldOrientation());
+    this->cameraNode_->attachObject(this->cam_);
+  }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Camera.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Camera.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Camera.h	(revision 1801)
@@ -0,0 +1,71 @@
+/*
+ *   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:
+ *      Benjamin Knecht
+ *
+ */
+
+#ifndef _Camera_H__
+#define _Camera_H__
+
+#include <OgrePrerequisites.h>
+#include <OgreSceneNode.h>
+#include <OgreCamera.h>
+
+#include "OrxonoxPrereqs.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Camera
+    {
+      friend class CameraHandler;
+      public:
+        Camera(Ogre::SceneNode* node = NULL);
+        virtual ~Camera();
+
+        void setPositionNode(Ogre::SceneNode* node);
+        inline Ogre::SceneNode* getCameraNode() { return this->positionNode_; }
+        // maybe also BaseObject
+        void setTargetNode(Ogre::SceneNode* obj);
+
+        Ogre::Camera* cam_;
+
+        void tick(float dt);
+        void update();
+        inline bool hasFocus() { return this->bHasFocus_; }
+
+      private:
+        void removeFocus();
+        void setFocus(Ogre::Camera* ogreCam);
+
+      private:
+        Ogre::SceneNode* targetNode_;
+        Ogre::SceneNode* positionNode_;
+        Ogre::SceneNode* cameraNode_;
+        Ogre::Vector3 oldPos;
+        bool bHasFocus_;
+    };
+}
+
+#endif /* _Camera_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/CameraHandler.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/CameraHandler.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/CameraHandler.cc	(revision 1801)
@@ -0,0 +1,96 @@
+/*
+ *   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:
+ *      ...
+ *
+ */
+#include "OrxonoxStableHeaders.h"
+#include "CameraHandler.h"
+
+#include <OgreSceneManager.h>
+#include <OgreRenderWindow.h>
+
+#include "core/ObjectList.h"
+#include "Camera.h"
+#include "GraphicsEngine.h"
+
+#include <OgreCamera.h>
+
+namespace orxonox {
+
+  CameraHandler* CameraHandler::singletonRef = NULL;
+
+  CameraHandler::CameraHandler()
+  {
+    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_;*/
+  }
+
+  void CameraHandler::requestFocus(Camera* requestCam)
+  {
+    // notify old camera (if it exists)
+    if(focusList_.size() > 0)
+      focusList_.back()->removeFocus();
+    // add to list
+    focusList_.push_back(requestCam);
+    // set focus to new camera and update (if necessary)
+    if(!requestCam->hasFocus()) {
+      requestCam->setFocus(this->cam_);
+      requestCam->update();
+    }
+    // delete dublicates
+    focusList_.unique();
+  }
+
+  void CameraHandler::releaseFocus(Camera* cam)
+  {
+    // notify the cam of releasing the focus
+    if(cam->hasFocus())
+      cam->removeFocus();
+    // delete camera from list
+    focusList_.remove(cam);
+    // set new focus if necessary
+    if(focusList_.size() > 0 && !(focusList_.back()->hasFocus()))
+      focusList_.back()->setFocus(this->cam_);
+  }
+/*
+  void CameraHandler::changeActiveCamera(Camera* setCam)
+  {
+    cam_->getParentSceneNode()->detachObject(cam_);
+    //setCam->attachCamera(cam_);
+    activeCamera_ = setCam;
+  }
+*/
+/*  bool isInVector(Camera* cam)
+  {
+    for(std::vector<Camera*>::iterator it = cams_.begin(); it != cams_.end(); it++)
+    {
+      if (*it == cam) return true;
+    }
+    return false;
+  }*/
+}
Index: /code/branches/ceguilua/src/orxonox/objects/CameraHandler.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/CameraHandler.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/CameraHandler.h	(revision 1801)
@@ -0,0 +1,75 @@
+/*
+ *   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  CameraHandler.h
+ @brief Handles the instances of Camera class
+ @author Benjamin Knecht <beni_at_orxonox.net>
+  */
+
+#ifndef _Camera_Handler_H__
+#define _Camera_Handler_H__
+
+#include <list>
+
+#include <OgreCamera.h>
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+
+#include "Camera.h"
+
+namespace orxonox
+{
+  class _OrxonoxExport CameraHandler
+  {
+
+    public:
+      inline static CameraHandler* getInstance() { if (!CameraHandler::singletonRef) CameraHandler::singletonRef = new CameraHandler(); return CameraHandler::singletonRef; }
+      inline ~CameraHandler() { CameraHandler::singletonRef = NULL; }
+      inline Camera* getActiveCamera() { return this->focusList_.back(); }
+      /*void registerCamera(Camera* newCam);
+      void changeActiveCamera(Camera* setCam);*/
+      void requestFocus(Camera* requestCam);
+      void releaseFocus(Camera* cam);
+
+    private:
+      CameraHandler();
+      //bool isInVector(Camera* cam);
+
+    private:
+      static CameraHandler* singletonRef;
+      Ogre::Camera* cam_;
+      std::list<Camera*> focusList_;
+      //std::vector<Camera*> cams_;
+
+  };
+}
+
+#endif /* _Camera_Handler_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/Model.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Model.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Model.cc	(revision 1801)
@@ -0,0 +1,104 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Model.h"
+
+#include "tinyxml/tinyxml.h"
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+#include "core/XMLPort.h"
+
+#include <OgreEntity.h>
+#include <OgreMesh.h>
+#include <OgreHardwareVertexBuffer.h>
+#include <OgreMeshManager.h>
+
+
+namespace orxonox
+{
+    CreateFactory(Model);
+
+    /**
+     * 
+     */
+    Model::Model()
+    {
+        RegisterObject(Model);
+        registerAllVariables();
+    }
+
+    Model::~Model()
+    {
+        if (this->isInitialized() && (this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
+            this->detachObject(this->mesh_.getEntity());
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void Model::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Model, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Model, "mesh", setMesh, getMesh, xmlelement, mode);
+
+        Model::create();
+    }
+
+    bool Model::create(){
+      if(!WorldEntity::create())
+        return false;
+      if ((this->meshSrc_ != "") && (this->meshSrc_.size() > 0))
+      {
+        this->mesh_.setMesh(meshSrc_);
+        this->attachObject(this->mesh_.getEntity());
+
+        COUT(4) << "Loader (Model.cc): Created model" << std::endl;
+      }
+      if(this->isExactlyA(Class(Model)))
+        setObjectFrequency(300); //sync all 10 seconds (this only applies to asteroids and other isExactlyA(Model)
+      return true;
+    }
+
+    void Model::registerAllVariables(){
+//       WorldEntity::registerAllVariables();
+      COUT(5) << "Model.cc:registering new meshsrc with size: " << meshSrc_.length()+1 << " this: " << this << std::endl;
+      registerVar(&meshSrc_, meshSrc_.length() + 1, network::STRING);
+    }
+
+    void Model::changedVisibility()
+    {
+        SUPER(Model, changedVisibility);
+        if (this->isInitialized())
+            this->mesh_.setVisible(this->isVisible());
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Model.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Model.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Model.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Model_H__
+#define _Model_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "../tools/Mesh.h"
+
+namespace orxonox
+{
+
+    class _OrxonoxExport Model : public WorldEntity
+    {
+        public:
+            Model();
+            virtual ~Model();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void changedVisibility();
+            inline void setMesh(const std::string& meshname)
+                { this->meshSrc_ = meshname; }
+            inline const std::string& getMesh() const
+                { return this->meshSrc_; }
+            virtual bool create();
+
+        protected:
+            void registerAllVariables();
+
+        private:
+            std::string meshSrc_;
+            Mesh mesh_;
+    };
+}
+
+#endif /* _Model_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/NPC.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/NPC.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/NPC.cc	(revision 1801)
@@ -0,0 +1,176 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Benjamin Knecht, beni_at_orxonox.net
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "NPC.h"
+
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+
+namespace orxonox {
+
+  CreateFactory(NPC);
+
+  NPC::NPC() :
+    movable_(true)
+  {
+    RegisterObject(NPC);
+    registerAllVariables();
+  }
+
+  NPC::~NPC()
+  {
+  }
+
+  /**
+   * function to chance values of an element
+   */
+  void NPC::setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable) {
+    this->setAcceleration(acceleration);
+    this->setVelocity(speed);
+    this->translate(location);
+    movable_ = movable;
+  }
+
+  void NPC::registerAllVariables(){
+    Model::registerAllVariables();
+    registerVar(&movable_, sizeof(movable_), network::DATA);
+  }
+
+
+  /**
+   * calculates the distance between the element and an other point given by temp
+   */
+  float NPC::getDistance(WorldEntity* temp)
+  {
+    Vector3 distance = temp->getPosition() - this->getPosition();
+    return distance.length();
+  }
+
+  /**
+   * updates the data of an element
+   */
+  void NPC::update()
+  {
+
+    //if element is movable, calculate acceleration
+    if (this->movable_ == true) calculateAcceleration();
+
+  }
+
+  /**
+   * tick this NPC
+   */
+  void NPC::tick(float dt)
+  {
+    update();
+    this->setVelocity(0.995*this->getVelocity() + this->getAcceleration()*dt);
+    this->translate(this->getVelocity()*dt);
+    this->setAcceleration(Vector3(0,0,0));
+  }
+
+  /**
+   * calculates the new acceleration of an element
+   */
+  void NPC::calculateAcceleration()
+  {
+    //acceleration consisting of flocking-functions
+    this->setAcceleration(separation() + alignment() + cohesion());
+  }
+
+  /**
+   * separation-function (keep elements separated, avoid crashs)
+   */
+  Vector3 NPC::separation()
+  {
+    Vector3 steering = Vector3(0,0,0); //steeringvector
+    Vector3 inverseDistance = Vector3(0,0,0);  //vector pointing away from possible collisions
+    int numberOfNeighbour = 0;  //number of observed neighbours
+    float distance = 0;  // distance to the actual element
+    for(ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it; ++it) {  //go through all elements
+      distance = getDistance(*it);  //get distance between this and actual
+      if ((distance > 0) && (distance < SEPERATIONDISTANCE)) {  //do only if actual is inside detectionradius
+        inverseDistance = Vector3(0,0,0);
+        inverseDistance = this->getPosition() - it->getPosition();  //calculate the distancevector heading towards this
+        //adaptation of the inverseDistance to the distance
+        if ((distance < 200) && (distance >= 120)) {inverseDistance = 2*inverseDistance;}
+        if ((distance < 120) && (distance >= 80)) {inverseDistance = 5*inverseDistance;}
+        if ((distance < 80) && (distance >= 40)) {inverseDistance = 10*inverseDistance;}
+        if ((distance < 40) && (distance > 0)) {inverseDistance = 10*inverseDistance;}
+        steering = steering + inverseDistance;  //add up all significant steeringvectors
+        numberOfNeighbour++;  //counts the elements inside the detectionradius
+      }
+    }
+    if(numberOfNeighbour > 0) { steering = steering / (float)numberOfNeighbour; }  //devide the sum of steeringvectors by the number of elements -> separation steeringvector
+    return steering;
+  }
+
+  /**
+   * alignment-function (lead elements to the same heading)
+   */
+  Vector3 NPC::alignment()
+  {
+    Vector3 steering = Vector3(0,0,0); //steeringvector
+    int numberOfNeighbour = 0;  //number of observed neighbours
+    //float distance = 0;
+    //go through all elements
+    for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
+      float distance = getDistance(*it);  //get distance between this and actual
+      if ((distance > 0) && (distance < ALIGNMENTDISTANCE)) {  //check if actual element is inside detectionradius
+        steering = steering + it->getVelocity();  //add up all speedvectors inside the detectionradius
+        numberOfNeighbour++;  //counts the elements inside the detectionradius
+      }
+    }
+    if(numberOfNeighbour > 0) { steering = steering / (float)numberOfNeighbour; }  //devide the sum of steeringvectors by the number of elements -> alignment steeringvector
+    return steering;
+  }
+
+  /**
+   * cohseion-function (keep elements close to each other)
+   */
+  Vector3 NPC::cohesion()
+  {
+    Vector3 steering = Vector3(0,0,0); //steeringvector
+    int numberOfNeighbour = 0;  //number of observed neighbours
+    //float distance = 0;
+    //go through all elements
+    for(ObjectList<NPC>::iterator it = ObjectList<NPC>::begin(); it; ++it) {  //just working with 3 elements at the moment
+      float distance = getDistance(*it);  //get distance between this and actual
+      if ((distance > 0) && (distance < COHESIONDISTANCE)) {  //check if actual element is inside detectionradius
+        steering = steering + it->getPosition();  //add up all locations of elements inside the detectionradius
+        numberOfNeighbour++;  //counts the elements inside the detectionradius
+      }
+    }
+    if(numberOfNeighbour > 0) {
+      steering = steering  / (float)numberOfNeighbour;  //devide the sum steeringvector by the number of elements -> cohesion steeringvector
+      steering = steering - this->getPosition();  //transform the vector for the ship
+    }
+    return steering;
+  }
+
+} // end of class NPC
Index: /code/branches/ceguilua/src/orxonox/objects/NPC.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/NPC.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/NPC.h	(revision 1801)
@@ -0,0 +1,74 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+  @file NPC.h
+  @brief AI using WorldEntity
+  @author Benjamin Knecht <beni_at_orxonox.net>
+ */
+
+#ifndef _NPC_H__
+#define _NPC_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "Model.h"
+
+namespace orxonox {
+
+  class _OrxonoxExport NPC : public Model
+  {
+    public:
+
+      NPC();
+      virtual ~NPC();
+      virtual void tick(float dt);
+      void update();
+      void setValues(Vector3 location, Vector3 speed, Vector3 acceleration, bool movable);
+      void registerAllVariables();
+      virtual bool create(){return Model::create();}
+
+    private:
+      float getDistance(WorldEntity* temp);
+      void calculateAcceleration();
+      Vector3 separation();
+      Vector3 alignment();
+      Vector3 cohesion();
+
+
+    private:
+      bool movable_;  // movability of the element, (false) gives the possiblity that an object can`t be moved by flocking but still gets into the calculation
+
+      // those values should maybe be controlled by a higher power and should maybe be parameters that can be changed
+      static int const SEPERATIONDISTANCE = 300;  //detectionradius of seperation
+      static int const ALIGNMENTDISTANCE = 300;  //detectionradius of alignment
+      static int const COHESIONDISTANCE = 5000;  //detectionradius of cohesion
+      static int const NUMELEMENTS = 9;  //number of elements
+  };
+}
+#endif /* _NPC_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/ParticleProjectile.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/ParticleProjectile.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/ParticleProjectile.cc	(revision 1801)
@@ -0,0 +1,75 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleProjectile.h"
+
+#include "SpaceShip.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+
+namespace orxonox
+{
+    CreateFactory(ParticleProjectile);
+
+    ParticleProjectile::ParticleProjectile(SpaceShip* owner) : BillboardProjectile(owner)
+    {
+        RegisterObject(ParticleProjectile);
+
+        if (this->owner_)
+        {
+            this->particles_ = new ParticleInterface("Orxonox/shot2", LODParticle::normal);
+            this->particles_->addToSceneNode(this->getNode());
+            this->particles_->getAllEmitters()->setDirection(-this->owner_->getInitialDir());
+            this->particles_->setKeepParticlesInLocalSpace(true);
+        }
+        else
+        {
+            this->particles_ = 0;
+        }
+
+        this->setConfigValues();
+    }
+
+    ParticleProjectile::~ParticleProjectile()
+    {
+        if (this->isInitialized() && this->particles_)
+            delete this->particles_;
+    }
+
+    void ParticleProjectile::setConfigValues()
+    {
+        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback((Projectile*)this, &ParticleProjectile::speedChanged);
+    }
+
+    void ParticleProjectile::changedVisibility()
+    {
+        SUPER(ParticleProjectile, changedVisibility);
+        this->particles_->setEnabled(this->isVisible());
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/ParticleProjectile.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/ParticleProjectile.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/ParticleProjectile.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleProjectile_H__
+#define _ParticleProjectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "BillboardProjectile.h"
+#include "tools/ParticleInterface.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleProjectile : public BillboardProjectile
+    {
+        public:
+            ParticleProjectile(SpaceShip* owner = 0);
+            virtual ~ParticleProjectile();
+            virtual void changedVisibility();
+            void setConfigValues();
+
+        private:
+            ParticleInterface* particles_;
+    };
+}
+
+#endif /* _ParticleProjectile_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/ParticleSpawner.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/ParticleSpawner.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/ParticleSpawner.cc	(revision 1801)
@@ -0,0 +1,106 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleSpawner.h"
+
+#include <OgreSceneManager.h>
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "tools/ParticleInterface.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(ParticleSpawner);
+
+    ParticleSpawner::ParticleSpawner()
+    {
+        RegisterObject(ParticleSpawner);
+        this->particle_ = 0;
+    }
+
+    ParticleSpawner::ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction)
+    {
+        RegisterObject(ParticleSpawner);
+        this->setParticle(templateName, detaillevel, lifetime, startdelay, destroydelay, direction);
+    }
+
+    void ParticleSpawner::setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime, float startdelay, float destroydelay, const Vector3& direction)
+    {
+        ExecutorMember<ParticleSpawner>* executor = createExecutor(createFunctor(&ParticleSpawner::createParticleSpawner));
+        this->destroydelay_ = destroydelay;
+        executor->setDefaultValues(lifetime);
+        this->timer_.setTimer(startdelay, false, this, executor);
+        this->particle_ = new ParticleInterface(templateName, detaillevel);
+        this->particle_->addToSceneNode(this->getNode());
+        this->particle_->setEnabled(false);
+        if (direction != Vector3::ZERO)
+        {
+            this->particle_->getAllEmitters()->setDirection(direction);
+        }
+    }
+
+    ParticleSpawner::~ParticleSpawner()
+    {
+        if (this->isInitialized() && this->particle_)
+        {
+            this->particle_->detachFromSceneNode();
+            delete this->particle_;
+        }
+    };
+
+    void ParticleSpawner::destroy()
+    {
+        this->setPosition(this->getNode()->getParent()->getPosition());
+        this->getNode()->getParent()->removeChild(this->getNode());
+        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->addChild(this->getNode());
+        if (this->particle_)
+            this->particle_->setEnabled(false);
+        if (!this->timer_.isActive() || this->timer_.getRemainingTime() > this->destroydelay_)
+            this->timer_.setTimer(this->destroydelay_, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
+    }
+
+    void ParticleSpawner::createParticleSpawner(float lifetime)
+    {
+        this->particle_->setEnabled(true);
+        if (lifetime != 0)
+            this->timer_.setTimer(lifetime, false, this, createExecutor(createFunctor(&ParticleSpawner::destroyParticleSpawner)));
+    }
+
+    void ParticleSpawner::destroyParticleSpawner()
+    {
+        delete this;
+    }
+
+    void ParticleSpawner::setVisible(bool visible)
+    {
+        if (this->particle_)
+            this->particle_->setEnabled(visible);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/ParticleSpawner.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/ParticleSpawner.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/ParticleSpawner.h	(revision 1801)
@@ -0,0 +1,63 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleSpawner_H__
+#define _ParticleSpawner_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport ParticleSpawner : public WorldEntity
+    {
+        public:
+            ParticleSpawner();
+            ParticleSpawner(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO);
+            virtual ~ParticleSpawner();
+            void destroy();
+
+            void setParticle(const std::string& templateName, LODParticle::LOD detaillevel, float lifetime = 0, float startdelay = 0, float destroydelay = 0, const Vector3& direction = Vector3::ZERO);
+            inline ParticleInterface* getParticleInterface() const
+                { return this->particle_; }
+
+            void setVisible(bool visible);
+
+        private:
+            void createParticleSpawner(float lifetime);
+            void destroyParticleSpawner();
+
+            Timer<ParticleSpawner> timer_;
+            ParticleInterface* particle_;
+            float destroydelay_;
+    };
+}
+
+#endif /* _ParticleSpawner_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/Projectile.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Projectile.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Projectile.cc	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Projectile.h"
+
+#include <OgreBillboard.h>
+
+#include "core/CoreIncludes.h"
+#include "core/Executor.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Iterator.h"
+#include "tools/ParticleInterface.h"
+
+#include "SpaceShipAI.h"
+#include "ParticleSpawner.h"
+#include "Model.h"
+
+namespace orxonox
+{
+    float Projectile::speed_s = 5000;
+
+    Projectile::Projectile(SpaceShip* owner) : owner_(owner)
+    {
+        RegisterObject(Projectile);
+
+        this->setConfigValues();
+        this->explosionTemplateName_ = "Orxonox/explosion3";
+        this->smokeTemplateName_ = "Orxonox/smoke4";
+
+        if (this->owner_)
+        {
+            this->setStatic(false);
+            this->setOrientation(this->owner_->getOrientation());
+            this->setPosition(this->owner_->getPosition());
+            this->translate(Vector3(55, 0, 0), Ogre::Node::TS_LOCAL);
+            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
+        }
+
+        this->destroyTimer_.setTimer(this->lifetime_, false, this, createExecutor(createFunctor(&Projectile::destroyObject)));
+    }
+
+    Projectile::~Projectile()
+    {
+    }
+
+    void Projectile::setConfigValues()
+    {
+        SetConfigValue(damage_, 15.0).description("The damage caused by the projectile");
+        SetConfigValue(lifetime_, 4.0).description("The time in seconds a projectile stays alive");
+        SetConfigValue(speed_, 5000.0).description("The speed of a projectile in units per second").callback(this, &Projectile::speedChanged);
+    }
+
+    void Projectile::speedChanged()
+    {
+        Projectile::speed_s = this->speed_;
+        if (this->owner_)
+            this->setVelocity(this->owner_->getInitialDir() * this->speed_);
+    }
+
+    void Projectile::tick(float dt)
+    {
+        SUPER(Projectile, tick, dt);
+
+        if (!this->isActive())
+            return;
+
+        float radius;
+        for (ObjectList<Model>::iterator it = ObjectList<Model>::begin(); it; ++it)
+        {
+            if ((*it) != this->owner_)
+            {
+                radius = it->getScale3D().x * 3.0;
+
+                if (this->getPosition().squaredDistance(it->getPosition()) <= (radius*radius))
+                {
+                    // hit
+                    if (it->isA(Class(SpaceShipAI)))
+                        ((SpaceShipAI*)(*it))->damage(this->damage_);
+                    ParticleSpawner* explosion = new ParticleSpawner(this->explosionTemplateName_, LODParticle::low, 2.0);
+                    explosion->setPosition(this->getPosition());
+                    explosion->create();
+                    ParticleSpawner* smoke = new ParticleSpawner(this->smokeTemplateName_, LODParticle::normal, 2.0, 0.0);
+                    smoke->setPosition(this->getPosition());
+//                    smoke->getParticleInterface()->setSpeedFactor(3.0);
+                    smoke->create();
+                    delete this;
+                    return;
+                }
+            }
+        }
+    }
+
+    void Projectile::destroyObject()
+    {
+        delete this;
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Projectile.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Projectile.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Projectile.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Projectile_H__
+#define _Projectile_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "WorldEntity.h"
+#include "tools/Timer.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Projectile : public WorldEntity
+    {
+        public:
+            virtual ~Projectile();
+            void setConfigValues();
+            void speedChanged();
+            void destroyObject();
+            virtual void tick(float dt);
+
+            static float getSpeed()
+                { return Projectile::speed_s; }
+
+        protected:
+            Projectile(SpaceShip* owner = 0);
+            SpaceShip* owner_;
+
+        private:
+            std::string explosionTemplateName_;
+            std::string smokeTemplateName_;
+        protected:
+            static float speed_s;
+            float speed_;
+        private:
+            float lifetime_;
+            float damage_;
+            Timer<Projectile> destroyTimer_;
+    };
+}
+
+#endif /* _Projectile_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/RotatingProjectile.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/RotatingProjectile.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/RotatingProjectile.cc	(revision 1801)
@@ -0,0 +1,98 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "RotatingProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include <OgreBillboard.h>
+
+namespace orxonox
+{
+    CreateFactory(RotatingProjectile);
+
+    RotatingProjectile::RotatingProjectile(SpaceShip* owner) : BillboardProjectile(owner)
+    {
+        RegisterObject(RotatingProjectile);
+
+        this->time_ = 0;
+
+        if (/*this->owner_*/true)
+        {
+            this->rotatingBillboard1_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
+            this->rotatingBillboard2_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
+
+            this->rotatingNode1_ = this->getNode()->createChildSceneNode(this->getName() + "rotating1", Vector3(0, 50, 0));
+            this->rotatingNode2_ = this->getNode()->createChildSceneNode(this->getName() + "rotating2", Vector3(0, -50, 0));
+            this->rotatingNode1_->attachObject(this->rotatingBillboard1_.getBillboardSet());
+            this->rotatingNode2_->attachObject(this->rotatingBillboard2_.getBillboardSet());
+            this->rotatingNode1_->scale(0.3, 0.3, 0.3);
+            this->rotatingNode2_->scale(0.3, 0.3, 0.3);
+        }
+
+        this->setConfigValues();
+    }
+
+    RotatingProjectile::~RotatingProjectile()
+    {
+    }
+
+    void RotatingProjectile::setConfigValues()
+    {
+        SetConfigValue(colour_, ColourValue(1.0, 0.0, 0.0)).callback(this, &RotatingProjectile::colourChanged);
+    }
+
+    void RotatingProjectile::colourChanged()
+    {
+        if (this->isInitialized())
+        {
+            this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
+            this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
+        }
+    }
+
+    void RotatingProjectile::tick(float dt)
+    {
+        if (this->isActive())
+        {
+            this->time_ += dt;
+
+            this->rotatingNode1_->setPosition(0, 50 * sin(this->time_ * 20), 50 * cos(this->time_ * 20));
+            this->rotatingNode2_->setPosition(0, -50 * sin(this->time_ * 20), -50 * cos(this->time_ * 20));
+        }
+
+        SUPER(RotatingProjectile, tick, dt);
+    }
+
+    void RotatingProjectile::changedVisibility()
+    {
+        SUPER(RotatingProjectile, changedVisibility);
+        this->rotatingBillboard1_.setVisible(this->isVisible());
+        this->rotatingBillboard2_.setVisible(this->isVisible());
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/RotatingProjectile.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/RotatingProjectile.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/RotatingProjectile.h	(revision 1801)
@@ -0,0 +1,30 @@
+#ifndef _RotatingProjectile_H__
+#define _RotatingProjectile_H__
+
+#include "OrxonoxPrereqs.h"
+#include "util/Math.h"
+#include "BillboardProjectile.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport RotatingProjectile : public BillboardProjectile
+    {
+        public:
+            RotatingProjectile(SpaceShip* owner = 0);
+            virtual ~RotatingProjectile();
+            void setConfigValues();
+            void colourChanged();
+            virtual void tick(float dt);
+            virtual void changedVisibility();
+
+        private:
+            ColourValue colour_;
+            BillboardSet rotatingBillboard1_;
+            BillboardSet rotatingBillboard2_;
+            Ogre::SceneNode* rotatingNode1_;
+            Ogre::SceneNode* rotatingNode2_;
+            float time_;
+    };
+}
+
+#endif /* _RotatingProjectile_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/Skybox.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Skybox.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Skybox.cc	(revision 1801)
@@ -0,0 +1,94 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Skybox.h"
+
+#include <string>
+
+#include <OgreSceneManager.h>
+
+#include "tinyxml/tinyxml.h"
+#include "GraphicsEngine.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "util/Debug.h"
+#include "Settings.h"
+
+namespace orxonox
+{
+    CreateFactory(Skybox);
+
+    Skybox::Skybox()
+    {
+        RegisterObject(Skybox);
+        registerAllVariables();
+    }
+
+    Skybox::~Skybox()
+    {
+    }
+
+    void Skybox::setSkybox(const std::string& skyboxname)
+    {
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(true, skyboxname);
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void Skybox::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(Skybox, XMLPort, xmlelement, mode);
+
+        XMLPortParam(Skybox, "src", setSkyboxSrc, getSkyboxSrc, xmlelement, mode);
+        create();
+    }
+
+    bool Skybox::create()
+    {
+        this->setSkybox(this->skyboxSrc_);
+        return Synchronisable::create();
+    }
+
+    void Skybox::registerAllVariables()
+    {
+        registerVar(&skyboxSrc_, skyboxSrc_.length()+1 ,network::STRING);
+    }
+
+    void Skybox::changedVisibility()
+    {
+        SUPER(Skybox, changedVisibility);
+        if (Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->setSkyBox(this->isVisible(), this->skyboxSrc_);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Skybox.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Skybox.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Skybox.h	(revision 1801)
@@ -0,0 +1,64 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Skybox_H__
+#define _Skybox_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/BaseObject.h"
+#include "network/Synchronisable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Skybox : public BaseObject, public network::Synchronisable
+    {
+        public:
+            Skybox();
+            virtual ~Skybox();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void changedVisibility();
+            void setSkybox(const std::string& skyboxname);
+
+            virtual bool create();
+            void registerAllVariables();
+
+            inline void setSkyboxSrc(const std::string &src)
+                { this->skyboxSrc_ = src; }
+            inline const std::string& getSkyboxSrc() const
+                { return this->skyboxSrc_; }
+
+        private:
+            std::string skyboxSrc_;
+
+
+    };
+}
+
+#endif /* _Skybox_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/SpaceShip.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/SpaceShip.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/SpaceShip.cc	(revision 1801)
@@ -0,0 +1,637 @@
+/*
+ *   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:
+ *      Benjamin Knecht
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "SpaceShip.h"
+
+#include <OgreCamera.h>
+#include <OgreRenderWindow.h>
+#include <OgreParticleSystem.h>
+#include <OgreSceneNode.h>
+
+#include "util/Convert.h"
+#include "util/Math.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/Iterator.h"
+#include "core/input/InputManager.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+#include "tools/ParticleInterface.h"
+#include "network/Client.h"
+#include "Backlight.h"
+#include "CameraHandler.h"
+#include "ParticleSpawner.h"
+#include "Settings.h"
+#include "RotatingProjectile.h"
+#include "ParticleProjectile.h"
+#include "GraphicsEngine.h"
+#include "SpaceShipAI.h"
+
+namespace orxonox
+{
+    SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).accessLevel(AccessLevel::Debug);
+    SetConsoleCommand(SpaceShip, whereAmI, true).accessLevel(AccessLevel::User);
+    SetConsoleCommand(SpaceShip, moveLongitudinal, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, moveLateral, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, moveYaw, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, movePitch, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, moveRoll, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommand(SpaceShip, fire, true).accessLevel(AccessLevel::User).keybindMode(KeybindMode::OnHold);
+    SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setMaxSpeed", 1, false).accessLevel(AccessLevel::Debug);
+    SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setMaxBlubber", 2, false).accessLevel(AccessLevel::Debug);
+    SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setRofl", 3, false).accessLevel(AccessLevel::Debug);
+
+    CreateFactory(SpaceShip);
+
+    SpaceShip* SpaceShip::instance_s;
+
+
+    SpaceShip *SpaceShip::getLocalShip(){
+      ObjectList<SpaceShip>::iterator it;
+      for(it = ObjectList<SpaceShip>::begin(); it; ++it){
+	assert(it->isA(Class(SpaceShip)));
+        if( (it)->myShip_ || (network::Host::running() && network::Host::getShipID()==(it)->objectID) ){
+//	  COUT(1) << "^^^^^^^^^^ myShip_:" << *it << " classname: " << (*it)->getIdentifier()->getName() << " objectid: " << (*it)->objectID << std::endl;
+          return *it;
+	}
+      }
+      return 0;
+    }
+
+    SpaceShip::SpaceShip()
+    {
+        RegisterObject(SpaceShip);
+
+        this->setRotationAxis(1, 0, 0);
+        this->setStatic(false);
+
+        this->zeroRadian_ = 0;
+        this->maxSideAndBackSpeed_ = 0;
+        this->maxSpeed_ = 0;
+        this->maxRotation_ = 0;
+        this->translationAcceleration_ = 0;
+        this->rotationAcceleration_ = 0;
+        this->translationDamping_ = 0;
+        this->rotationDamping_ = 0;
+        this->maxRotationRadian_ = 0;
+        this->rotationAccelerationRadian_ = 0;
+        this->rotationDampingRadian_ = 0;
+
+        this->cam_ = 0;
+        this->tt1_ = 0;
+        this->tt2_ = 0;
+        this->smoke_ = 0;
+        this->fire_ = 0;
+
+        this->backlight_ = 0;
+
+        this->redNode_ = 0;
+        this->greenNode_ = 0;
+        this->blinkTime_ = 0;
+
+        this->timeToReload_ = 0;
+
+        this->bLMousePressed_ = false;
+        this->bRMousePressed_ = false;
+        this->mouseXRotation_ = 0;
+        this->mouseYRotation_ = 0;
+        this->myShip_ = false;
+
+        this->registerAllVariables();
+
+        SpaceShip::instance_s = this;
+
+        this->setConfigValues();
+
+        this->initialDir_ = Vector3(1.0, 0.0, 0.0);
+        this->currentDir_ = initialDir_;
+        this->initialOrth_ = Vector3(0.0, 0.0, 1.0);
+        this->currentOrth_ = initialOrth_;
+
+        this->camName_ = this->getName() + "CamNode";
+
+        this->teamNr_ = 0;
+        this->health_ = 100;
+
+        this->radarObject_ = static_cast<WorldEntity*>(this);
+    }
+
+    SpaceShip::~SpaceShip()
+    {
+        for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; ++it)
+            it->shipDied(this);
+      
+        if (this->isInitialized())
+        {
+            if (this->tt1_)
+                delete this->tt1_;
+            if (this->tt2_)
+                delete this->tt2_;
+
+            if (this->smoke_)
+                this->smoke_->destroy();
+            if (this->fire_)
+                this->fire_->destroy();
+
+            if (this->backlight_)
+                delete this->backlight_;
+
+            if (this->cam_)
+                delete this->cam_;
+        }
+    }
+
+    bool SpaceShip::create()
+    {
+        if (!myShip_)
+        {
+            if (network::Host::running())
+                //COUT(3) << "this id: " << this->objectID << " myShipID: " << network::Host::getShipID() << std::endl;
+                if (network::Host::running() && objectID == network::Host::getShipID())
+                {
+                    if (!network::Host::isServer())
+                        setObjectMode(0x3);
+                    myShip_ = true;
+                }
+        }
+        else
+            this->setRadarObjectColour(this->getProjectileColour());
+        assert(Model::create());
+        this->init();
+        return true;
+    }
+
+    void SpaceShip::registerAllVariables()
+    {
+        registerVar( &camName_, camName_.length()+1, network::STRING, 0x1 );
+        registerVar( &maxSpeed_, sizeof(maxSpeed_), network::DATA, 0x1);
+        registerVar( &maxSideAndBackSpeed_, sizeof(maxSideAndBackSpeed_), network::DATA, 0x1);
+        registerVar( &maxRotation_, sizeof(maxRotation_), network::DATA, 0x1);
+        registerVar( &translationAcceleration_, sizeof(translationAcceleration_), network::DATA, 0x1);
+        registerVar( &rotationAcceleration_, sizeof(rotationAcceleration_), network::DATA, 0x1);
+        registerVar( &rotationAccelerationRadian_, sizeof(rotationAccelerationRadian_), network::DATA, 0x1);
+        registerVar( &translationDamping_, sizeof(translationDamping_), network::DATA, 0x1);
+        registerVar( &rotationDamping_, sizeof(rotationDamping_), network::DATA, 0x1);
+        registerVar( &rotationDampingRadian_, sizeof(rotationDampingRadian_), network::DATA, 0x1);
+    }
+
+    void SpaceShip::init()
+    {
+        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
+
+        createCamera();
+    }
+
+    void SpaceShip::setConfigValues()
+    {
+        SetConfigValue(bInvertYAxis_, false).description("Set this to true for joystick-like mouse behaviour (mouse up = ship down).");
+        SetConfigValue(reloadTime_, 0.125).description("The reload time of the weapon in seconds");
+        SetConfigValue(testvector_, Vector3()).description("asdfblah");
+    }
+
+    void SpaceShip::changedVisibility()
+    {
+        SUPER(SpaceShip, changedVisibility);
+
+        this->tt1_->setEnabled(this->isVisible());
+        this->tt2_->setEnabled(this->isVisible());
+        this->redBillboard_.setVisible(this->isVisible());
+        this->greenBillboard_.setVisible(this->isVisible());
+        this->crosshairNear_.setVisible(this->isVisible());
+        this->crosshairFar_.setVisible(this->isVisible());
+        this->rightThrusterFlare_.setVisible(this->isVisible());
+        this->leftThrusterFlare_.setVisible(this->isVisible());
+        this->smoke_->setVisible(this->isVisible());
+        this->fire_->setVisible(this->isVisible());
+        this->backlight_->setVisible(this->isVisible());
+    }
+
+    void SpaceShip::changedActivity()
+    {
+        SUPER(SpaceShip, changedActivity);
+
+        this->tt1_->setEnabled(this->isVisible());
+        this->tt2_->setEnabled(this->isVisible());
+        this->redBillboard_.setVisible(this->isVisible());
+        this->greenBillboard_.setVisible(this->isVisible());
+        this->crosshairNear_.setVisible(this->isVisible());
+        this->crosshairFar_.setVisible(this->isVisible());
+        this->rightThrusterFlare_.setVisible(this->isVisible());
+        this->leftThrusterFlare_.setVisible(this->isVisible());
+    }
+
+    void SpaceShip::setCamera(const std::string& camera)
+    {
+      camName_=camera;
+      // change camera attributes here, if you want to ;)
+    }
+
+    void SpaceShip::getFocus(){
+      COUT(4) << "requesting focus" << std::endl;
+      //if(!network::Host::running() || network::Host::getShipID()==objectID)
+      if(myShip_)
+        CameraHandler::getInstance()->requestFocus(cam_);
+
+    }
+
+    Camera* SpaceShip::getCamera(){
+        return cam_;
+    }
+
+    void SpaceShip::createCamera(){
+//       COUT(4) << "begin camera creation" << std::endl;
+      this->camNode_ = this->getNode()->createChildSceneNode(camName_);
+      COUT(4) << "position: (this)" << this->getNode()->getPosition() << std::endl;
+      this->camNode_->setPosition(Vector3(-25,0,5));
+//      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));
+//      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,0,-1));
+//      camNode_->setOrientation(q1*q2);
+      COUT(4) << "position: (cam)" << this->camNode_->getPosition() << std::endl;
+      cam_ = new Camera(this->camNode_);
+
+      cam_->setTargetNode(this->getNode());
+//        cam->setPosition(Vector3(0,-350,0));
+//      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,0,1));
+//      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(0,1,0));
+      Quaternion q1 = Quaternion(Radian(Degree(90)),Vector3(0,-1,0));
+      Quaternion q2 = Quaternion(Radian(Degree(90)),Vector3(1,0,0));
+
+       this->camNode_->setOrientation(q2*q1);
+      //if(!network::Host::running() || network::Host::getShipID()==objectID){ //TODO: check this
+      if(myShip_){
+        COUT(4) << "requesting focus for camera" << std::endl;
+        //CameraHandler::getInstance()->requestFocus(cam_);
+        if(this->isExactlyA(Class(SpaceShip))){
+          getFocus();
+          COUT(4) << "getting focus for obj id: " << objectID << std::endl;
+        }else
+          COUT(4) << "not getting focus (not exactly spaceship) for obj id: " << objectID << std::endl;
+      }else
+        COUT(4) << "not getting focus (not my ship) for obj id: " << objectID << std::endl;
+    }
+
+    void SpaceShip::setMaxSpeed(float value)
+    { this->maxSpeed_ = value; }
+    void SpaceShip::setMaxSideAndBackSpeed(float value)
+    { this->maxSideAndBackSpeed_ = value; }
+    void SpaceShip::setMaxRotation(float value)
+    { this->maxRotation_ = value; this->maxRotationRadian_ = Radian(value); }
+    void SpaceShip::setTransAcc(float value)
+    { this->translationAcceleration_ = value; }
+    void SpaceShip::setRotAcc(float value)
+    { this->rotationAcceleration_ = value; this->rotationAccelerationRadian_ = Radian(value); }
+    void SpaceShip::setTransDamp(float value)
+    { this->translationDamping_ = value; }
+    void SpaceShip::setRotDamp(float value)
+    { this->rotationDamping_ = value; this->rotationDampingRadian_ = Radian(value); }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void SpaceShip::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(SpaceShip, XMLPort, xmlelement, mode);
+
+        XMLPortParam(SpaceShip, "camera", setCamera, getCamera, xmlelement, mode);
+        XMLPortParam(SpaceShip, "maxSpeed", setMaxSpeed, getMaxSpeed, xmlelement, mode);
+        XMLPortParam(SpaceShip, "maxSideAndBackSpeed", setMaxSideAndBackSpeed, getMaxSideAndBackSpeed, xmlelement, mode);
+        XMLPortParam(SpaceShip, "maxRotation", setMaxRotation, getMaxRotation, xmlelement, mode);
+        XMLPortParam(SpaceShip, "transAcc", setTransAcc, getTransAcc, xmlelement, mode);
+        XMLPortParam(SpaceShip, "rotAcc", setRotAcc, getRotAcc, xmlelement, mode);
+        XMLPortParam(SpaceShip, "transDamp", setTransDamp, getTransDamp, xmlelement, mode);
+        XMLPortParam(SpaceShip, "rotDamp", setRotDamp, getRotDamp, xmlelement, mode);
+
+        myShip_=true; //TODO: this is a hack
+        SpaceShip::create();
+        /*if (this->isExactlyA(Class(SpaceShip)))
+            getFocus();*/
+    }
+
+    std::string SpaceShip::whereAmI() {
+        return getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().x)
+        + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().y)
+        + "  " + getConvertedValue<float, std::string>(SpaceShip::getLocalShip()->getPosition().z);
+    }
+
+    void SpaceShip::tick(float dt)
+    {
+        if (!this->isActive())
+            return;
+
+        currentDir_ = getOrientation()*initialDir_;
+        currentOrth_ = getOrientation()*initialOrth_;
+
+        if (this->cam_)
+            this->cam_->tick(dt);
+
+        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);
+            }
+        }
+
+        if (this->timeToReload_ > 0)
+            this->timeToReload_ -= dt;
+        else
+            this->timeToReload_ = 0;
+
+        if (this->bLMousePressed_ && this->timeToReload_ <= 0)
+        {
+
+            BillboardProjectile* projectile = new ParticleProjectile(this);
+            projectile->setColour(this->getProjectileColour());
+            projectile->create();
+            if (projectile->classID == 0)
+            {
+              COUT(3) << "generated projectile with classid 0" <<  std::endl; // TODO: remove this output
+            }
+
+            projectile->setObjectMode(0x3);
+            this->timeToReload_ = this->reloadTime_;
+        }
+
+
+        // #####################################
+        // ############# STEERING ##############
+        // #####################################
+
+        if (this->velocity_.x > this->maxSpeed_)
+            this->velocity_.x = this->maxSpeed_;
+        if (this->velocity_.x < -this->maxSideAndBackSpeed_)
+            this->velocity_.x = -this->maxSideAndBackSpeed_;
+        if (this->velocity_.y > this->maxSideAndBackSpeed_)
+            this->velocity_.y = this->maxSideAndBackSpeed_;
+        if (this->velocity_.y < -this->maxSideAndBackSpeed_)
+            this->velocity_.y = -this->maxSideAndBackSpeed_;
+        if (this->rotationRate_ > this->maxRotationRadian_)
+            this->rotationRate_ = this->maxRotationRadian_;
+        if (this->rotationRate_ < -this->maxRotationRadian_)
+            this->rotationRate_ = -this->maxRotationRadian_;
+
+        if (this->acceleration_.x == 0)
+        {
+            if (this->velocity_.x > 0)
+            {
+                this->velocity_.x -= (this->translationDamping_ * dt);
+                if (this->velocity_.x < 0)
+                    this->velocity_.x = 0;
+            }
+            else if (this->velocity_.x < 0)
+            {
+                this->velocity_.x += (this->translationDamping_ * dt);
+                if (this->velocity_.x > 0)
+                    this->velocity_.x = 0;
+            }
+        }
+
+        if (this->acceleration_.y == 0)
+        {
+            if (this->velocity_.y > 0)
+            {
+                this->velocity_.y -= (this->translationDamping_ * dt);
+                if (this->velocity_.y < 0)
+                    this->velocity_.y = 0;
+            }
+            else if (this->velocity_.y < 0)
+            {
+                this->velocity_.y += (this->translationDamping_ * dt);
+                if (this->velocity_.y > 0)
+                    this->velocity_.y = 0;
+            }
+        }
+
+        if (this->momentum_ == this->zeroRadian_)
+        {
+            if (this->rotationRate_ > this->zeroRadian_)
+            {
+                this->rotationRate_ -= (this->rotationDampingRadian_ * dt);
+                if (this->rotationRate_ < this->zeroRadian_)
+                    this->rotationRate_ = 0;
+            }
+            else if (this->rotationRate_ < this->zeroRadian_)
+            {
+                this->rotationRate_ += (this->rotationDampingRadian_ * dt);
+                if (this->rotationRate_ > this->zeroRadian_)
+                    this->rotationRate_ = 0;
+            }
+        }
+
+
+        SUPER(SpaceShip, tick, dt);
+
+        this->roll(this->mouseXRotation_ * dt);
+        if (this->bInvertYAxis_)
+            this->yaw(Radian(-this->mouseYRotation_ * dt));
+        else
+            this->yaw(Radian(this->mouseYRotation_ * dt));
+
+        if (this->acceleration_.x > 0)
+        {
+            this->tt1_->setEnabled(true);
+            this->tt2_->setEnabled(true);
+        }
+        else
+        {
+            this->tt1_->setEnabled(false);
+            this->tt2_->setEnabled(false);
+        }
+
+        COUT(5) << "steering our ship: " << objectID << std::endl;
+        this->acceleration_.x = 0;
+        this->acceleration_.y = 0;
+        this->momentum_ = 0;
+        this->mouseXRotation_ = Radian(0);
+        this->mouseYRotation_ = Radian(0);
+        this->bLMousePressed_ = false;
+    }
+
+    void SpaceShip::movePitch(float val)
+    {   getLocalShip()->setMovePitch(val);   }
+    void SpaceShip::moveYaw(float val)
+    {   getLocalShip()->setMoveYaw(val);   }
+    void SpaceShip::moveRoll(float val)
+    {   getLocalShip()->setMoveRoll(val);   }
+    void SpaceShip::moveLongitudinal(float val)
+    {   getLocalShip()->setMoveLongitudinal(val);   }
+    void SpaceShip::moveLateral(float val)
+    {   getLocalShip()->setMoveLateral(val);   }
+    void SpaceShip::fire()
+    {   getLocalShip()->doFire();   }
+
+    void SpaceShip::setMovePitch(float val)
+    {
+        val = -val * val * sgn(val) * this->rotationAcceleration_;
+        if (val > this->maxRotation_)
+            val = this->maxRotation_;
+        if (val < -this->maxRotation_)
+            val = -this->maxRotation_;
+        this->mouseYRotation_ = Radian(val);
+    }
+
+    void SpaceShip::setMoveYaw(float val)
+    {
+        val = -val * val * sgn(val) * this->rotationAcceleration_;
+        if (val > this->maxRotation_)
+            val = this->maxRotation_;
+        if (val < -this->maxRotation_)
+            val = -this->maxRotation_;
+        this->mouseXRotation_ = Radian(val);
+    }
+
+    void SpaceShip::setMoveRoll(float val)
+    {
+        this->momentum_ = Radian(-this->rotationAccelerationRadian_ * val);
+        //COUT(3) << "rotating val: " << val << " acceleration: " << this->rotationAccelerationRadian_.valueDegrees() << std::endl;
+    }
+
+    void SpaceShip::setMoveLongitudinal(float val)
+    {
+        this->acceleration_.x = this->translationAcceleration_ * val;
+    }
+
+    void SpaceShip::setMoveLateral(float val)
+    {
+        this->acceleration_.y = -this->translationAcceleration_ * val;
+    }
+
+    void SpaceShip::doFire()
+    {
+        this->bLMousePressed_ = true;
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/SpaceShip.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/SpaceShip.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/SpaceShip.h	(revision 1801)
@@ -0,0 +1,193 @@
+/*
+ *   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:
+ *      Benjamin Knecht
+ *
+ */
+
+#ifndef _SpaceShip_H__
+#define _SpaceShip_H__
+#include <string>
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+
+#include "util/Math.h"
+#include "Camera.h"
+#include "Model.h"
+#include "RadarViewable.h"
+#include "tools/BillboardSet.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport SpaceShip : public Model, public RadarViewable
+    {
+        public:
+            static SpaceShip *getLocalShip();
+
+            SpaceShip();
+            ~SpaceShip();
+            virtual bool create();
+            void registerAllVariables();
+            void init();
+            void setConfigValues();
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            virtual void changedVisibility();
+            virtual void changedActivity();
+
+            void setCamera(const std::string& camera = "");
+            void setMaxSpeed(float value);
+            void setMaxSideAndBackSpeed(float value);
+            void setMaxRotation(float value);
+            void setTransAcc(float value);
+            void setRotAcc(float value);
+            void setTransDamp(float value);
+            void setRotDamp(float value);
+            void getFocus();
+
+            inline float getMaxSpeed() const
+                { return this->maxSpeed_; }
+            inline float getMaxSideAndBackSpeed() const
+                { return this->maxSideAndBackSpeed_; }
+            inline float getMaxRotation() const
+                { return this->maxRotation_; }
+            inline float getTransAcc() const
+                { return this->translationAcceleration_; }
+            inline float getRotAcc() const
+                { return this->rotationAcceleration_; }
+            inline float getTransDamp() const
+                { return this->translationDamping_; }
+            inline float getRotDamp() const
+                { return this->rotationDamping_; }
+
+            static std::string whereAmI();
+            static void setMaxSpeedTest(float value)
+                { SpaceShip::instance_s->setMaxSpeed(value); }
+
+            static void movePitch(float value);
+            static void moveYaw(float value);
+            static void moveRoll(float value);
+            static void moveLongitudinal(float value);
+            static void moveLateral(float value);
+            static void fire();
+            void setMovePitch(float value);
+            void setMoveYaw(float value);
+            void setMoveRoll(float value);
+            void setMoveLongitudinal(float value);
+            void setMoveLateral(float value);
+            void doFire();
+
+            inline const Vector3& getDir() const
+                { return this->currentDir_; }
+            inline const Vector3& getInitialDir() const
+                { return this->initialDir_; }
+            inline const Vector3& getOrth() const
+                { return this->currentOrth_; }
+            inline const Vector3& getInitialOrth() const
+                { return this->initialOrth_; }
+
+            Camera* getCamera();
+
+            int getTeamNr() const
+                { return this->teamNr_; }
+            float getHealth() const
+                { return this->health_; }
+
+            bool getMyShip(){return myShip_;}
+
+        protected:
+            void setTeamNr(int teamNr)
+                { this->teamNr_ = teamNr; }
+
+        private:
+            void createCamera();
+            virtual ColourValue getProjectileColour() const
+                { return ColourValue(1.0, 1.0, 0.5); }
+
+            Vector3 testvector_;
+            Vector3 initialDir_;
+            Vector3 currentDir_;
+            Vector3 initialOrth_;
+            Vector3 currentOrth_;
+            bool bInvertYAxis_;
+            bool bLMousePressed_;
+            bool bRMousePressed_;
+
+            Ogre::SceneNode* camNode_;
+            Camera* cam_;
+            std::string camName_;
+
+            ParticleInterface* tt1_;
+            ParticleInterface* tt2_;
+            BillboardSet leftThrusterFlare_;
+            BillboardSet rightThrusterFlare_;
+
+            Backlight* backlight_;
+
+            BillboardSet redBillboard_;
+            BillboardSet greenBillboard_;
+            Ogre::SceneNode* redNode_;
+            Ogre::SceneNode* greenNode_;
+            float blinkTime_;
+
+            ParticleSpawner* smoke_;
+            ParticleSpawner* fire_;
+
+            BillboardSet crosshairNear_;
+            BillboardSet crosshairFar_;
+            Ogre::SceneNode* chNearNode_;
+            Ogre::SceneNode* chFarNode_;
+
+            float timeToReload_;
+            float reloadTime_;
+
+            float maxSideAndBackSpeed_;
+            float maxSpeed_;
+            float maxRotation_;
+            float translationAcceleration_;
+            float rotationAcceleration_;
+            float translationDamping_;
+            float rotationDamping_;
+
+            Radian maxRotationRadian_;
+            Radian rotationAccelerationRadian_;
+            Radian rotationDampingRadian_;
+            Radian zeroRadian_;
+            Radian mouseXRotation_;
+            Radian mouseYRotation_;
+
+            float mouseX_;
+            float mouseY_;
+
+        protected:
+            bool myShip_;
+
+            int teamNr_;
+            float health_;
+
+            static SpaceShip* instance_s;
+    };
+}
+
+#endif /* _SpaceShip_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/SpaceShipAI.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/SpaceShipAI.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/SpaceShipAI.cc	(revision 1801)
@@ -0,0 +1,324 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "SpaceShipAI.h"
+
+#include <OgreMath.h>
+#include "Projectile.h"
+#include "ParticleSpawner.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+#include "core/Executor.h"
+#include "core/ConsoleCommand.h"
+#include "core/XMLPort.h"
+#include "tools/ParticleInterface.h"
+#include "Settings.h"
+
+
+namespace orxonox
+{
+    const float ACTION_INTERVAL = 1.0f;
+
+    SetConsoleCommand(SpaceShipAI, createEnemy, true).defaultValue(0, 1);
+    SetConsoleCommand(SpaceShipAI, killEnemies, true).defaultValue(0, 0);
+
+    CreateFactory(SpaceShipAI);
+
+    SpaceShipAI::SpaceShipAI()
+    {
+        RegisterObject(SpaceShipAI);
+
+        this->target_ = 0;
+        this->bShooting_ = 0;
+        this->bHasTargetPosition_ = false;
+
+        this->setTeamNr((int)rnd(NUM_AI_TEAMS) % NUM_AI_TEAMS + 1);
+
+        if (NUM_AI_TEAMS > 0)
+            this->teamColours_[1] = ColourValue(1, 0, 0, 1);
+        if (NUM_AI_TEAMS > 1)
+            this->teamColours_[2] = ColourValue(0, 1, 0, 1);
+        if (NUM_AI_TEAMS > 2)
+            this->teamColours_[3] = ColourValue(0, 0, 1, 1);
+
+        for (int i = 4; i <= NUM_AI_TEAMS; ++i)
+            this->teamColours_[i] = ColourValue(rnd(), rnd(), rnd(), 1);
+    }
+
+    SpaceShipAI::~SpaceShipAI()
+    {
+    }
+
+    void SpaceShipAI::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(SpaceShipAI, XMLPort, xmlelement, mode);
+
+        this->actionTimer_.setTimer(ACTION_INTERVAL, true, this, createExecutor(createFunctor(&SpaceShipAI::action)));
+    }
+
+    void SpaceShipAI::createEnemy(int num)
+    {
+        for (int i = 0; i < num; ++i)
+        {
+            SpaceShipAI* newenemy = new SpaceShipAI();
+            newenemy->setMesh("assff.mesh");
+//            newenemy->setPosition(0, 0, 0);
+            newenemy->setPosition(Vector3(rnd(-3000, 3000), rnd(-3000, 3000), rnd(-3000, 3000)));
+            newenemy->setScale(10);
+            newenemy->setMaxSpeed(500);
+            newenemy->setMaxSideAndBackSpeed(50);
+            newenemy->setMaxRotation(1.0);
+            newenemy->setTransAcc(200);
+            newenemy->setRotAcc(3.0);
+            newenemy->setTransDamp(75);
+            newenemy->setRotDamp(1.0);
+            Element xmlelement;
+            newenemy->XMLPort(xmlelement, XMLPort::LoadObject);
+
+            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();
+            }
+        }
+    }
+
+    void SpaceShipAI::killEnemies(int num)
+    {
+        int i = 0;
+        for (ObjectList<SpaceShipAI>::iterator it = ObjectList<SpaceShipAI>::begin(); it; )
+        {
+            (it++)->kill();
+            if (num && i >= num)
+                break;
+        }
+    }
+
+    ColourValue SpaceShipAI::getProjectileColour() const
+    {
+        return this->teamColours_[this->getTeamNr()];
+    }
+
+    void SpaceShipAI::action()
+    {
+        float random;
+        float maxrand = 100.0f / ACTION_INTERVAL;
+
+        // search enemy
+        random = rnd(maxrand);
+        if (random < 15 && (!this->target_))
+            this->searchNewTarget();
+
+        // forget enemy
+        random = rnd(maxrand);
+        if (random < 5 && (this->target_))
+            this->forgetTarget();
+
+        // next enemy
+        random = rnd(maxrand);
+        if (random < 10 && (this->target_))
+            this->searchNewTarget();
+
+        // fly somewhere
+        random = rnd(maxrand);
+        if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
+            this->searchNewTargetPosition();
+
+        // stop flying
+        random = rnd(maxrand);
+        if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
+            this->bHasTargetPosition_ = false;
+
+        // fly somewhere else
+        random = rnd(maxrand);
+        if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
+            this->searchNewTargetPosition();
+
+        // shoot
+        random = rnd(maxrand);
+        if (random < 75 && (this->target_ && !this->bShooting_))
+            this->bShooting_ = true;
+
+        // stop shooting
+        random = rnd(maxrand);
+        if (random < 25 && (this->bShooting_))
+            this->bShooting_ = false;
+    }
+
+    void SpaceShipAI::damage(float damage)
+    {
+        this->health_ -= damage;
+        if (this->health_ <= 0)
+        {
+            this->kill();
+            SpaceShipAI::createEnemy(1);
+        }
+    }
+
+    void SpaceShipAI::kill()
+    {
+        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;
+    }
+
+    void SpaceShipAI::tick(float dt)
+    {
+        if (!this->isActive())
+            return;
+
+        if (this->target_)
+            this->aimAtTarget();
+
+        if (this->bHasTargetPosition_)
+            this->moveToTargetPosition(dt);
+
+        if (this->bShooting_ && this->isCloseAtTarget(2500) && this->isLookingAtTarget(Ogre::Math::PI / 20.0))
+            this->doFire();
+
+        SUPER(SpaceShipAI, tick, dt);
+    }
+
+    void SpaceShipAI::moveToTargetPosition(float dt)
+    {
+        Vector2 coord = get2DViewdirection(this->getPosition(), this->getDir(), this->getOrth(), this->targetPosition_);
+
+        float distance = (this->targetPosition_ - this->getPosition()).length();
+        if (this->target_ || distance > 50)
+        {
+            // Multiply with 0.8 to make them a bit slower
+            this->setMoveYaw(0.8 * sgn(coord.x) * coord.x*coord.x);
+            this->setMovePitch(0.8 * sgn(coord.y) * coord.y*coord.y);
+        }
+
+        if (this->target_ && distance < 1000 && this->getVelocity().squaredLength() > this->target_->getVelocity().squaredLength())
+            this->setMoveLongitudinal(-0.5); // They don't brake with full power to give the player a chance
+        else if (!this->target_ && distance <= this->getVelocity().length() / (2 * this->getTransAcc()))
+            this->setMoveLongitudinal(-1.0);
+        else
+            this->setMoveLongitudinal(0.8);
+    }
+
+    void SpaceShipAI::searchNewTargetPosition()
+    {
+        this->targetPosition_ = Vector3(rnd(-5000,5000), rnd(-5000,5000), rnd(-5000,5000));
+        this->bHasTargetPosition_ = true;
+    }
+
+    void SpaceShipAI::searchNewTarget()
+    {
+        this->targetPosition_ = this->getPosition();
+        this->forgetTarget();
+
+        for (ObjectList<SpaceShip>::iterator it = ObjectList<SpaceShip>::begin(); it; ++it)
+        {
+            if (it->getTeamNr() != this->getTeamNr())
+            {
+                float speed = this->getVelocity().length();
+                Vector3 distanceCurrent = this->targetPosition_ - this->getPosition();
+                Vector3 distanceNew = it->getPosition() - this->getPosition();
+                if (!this->target_ || it->getPosition().squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceNew) / speed / distanceNew.length()) / (2 * Ogre::Math::PI))
+                        < this->targetPosition_.squaredDistance(this->getPosition()) * (1.5f + acos((this->getOrientation() * Ogre::Vector3::UNIT_X).dotProduct(distanceCurrent) / speed / distanceCurrent.length()) / (2 * Ogre::Math::PI)) + rnd(-250, 250))
+                {
+                    this->target_ = (*it);
+                    this->targetPosition_ = it->getPosition();
+                }
+            }
+        }
+    }
+
+    void SpaceShipAI::forgetTarget()
+    {
+        this->target_ = 0;
+        this->bShooting_ = false;
+    }
+
+    void SpaceShipAI::aimAtTarget()
+    {
+        if (!this->target_)
+            return;
+
+        this->targetPosition_ = getPredictedPosition(this->getPosition(), Projectile::getSpeed(), this->target_->getPosition(), this->target_->getOrientation() * this->target_->getVelocity());
+        this->bHasTargetPosition_ = (this->targetPosition_ != Vector3::ZERO);
+    }
+
+    bool SpaceShipAI::isCloseAtTarget(float distance)
+    {
+        if (!this->target_)
+            return (this->getPosition().squaredDistance(this->targetPosition_) < distance*distance);
+        else
+            return (this->getPosition().squaredDistance(this->target_->getPosition()) < distance*distance);
+    }
+
+    bool SpaceShipAI::isLookingAtTarget(float angle)
+    {
+        return (getAngle(this->getPosition(), this->getDir(), this->targetPosition_) < angle);
+    }
+
+    void SpaceShipAI::shipDied(SpaceShip* ship)
+    {
+        if (ship == this->target_)
+        {
+            this->forgetTarget();
+            this->searchNewTargetPosition();
+        }
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/SpaceShipAI.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/SpaceShipAI.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/SpaceShipAI.h	(revision 1801)
@@ -0,0 +1,81 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _SpaceShipAI_H__
+#define _SpaceShipAI_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "SpaceShip.h"
+#include "tools/Timer.h"
+#include "util/Math.h"
+
+
+namespace orxonox
+{
+    const int NUM_AI_TEAMS = 3;
+
+    class SpaceShipAI : public SpaceShip
+    {
+        public:
+            SpaceShipAI();
+            virtual ~SpaceShipAI();
+
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt);
+            static void createEnemy(int num);
+            static void killEnemies(int num);
+            void shipDied(SpaceShip* ship);
+            void damage(float damage);
+            void kill();
+
+        private:
+            virtual ColourValue getProjectileColour() const;
+
+            void action();
+
+            void moveToTargetPosition(float dt);
+            void searchNewTargetPosition();
+            void forgetTarget();
+            void searchNewTarget();
+            void aimAtTarget();
+            bool isCloseAtTarget(float distance);
+            bool isLookingAtTarget(float angle);
+
+            Timer<SpaceShipAI> actionTimer_;
+
+            bool bHasTargetPosition_;
+            Vector3 targetPosition_;
+            SpaceShip* target_;
+            bool bShooting_;
+
+            ColourValue teamColours_[NUM_AI_TEAMS + 1];
+    };
+}
+
+#endif /* _SpaceShipAI_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/Tickable.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Tickable.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Tickable.cc	(revision 1801)
@@ -0,0 +1,43 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Tickable.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Registers the object in the Tickable-list
+    */
+    Tickable::Tickable()
+    {
+        RegisterRootObject(Tickable);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/Tickable.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/Tickable.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/Tickable.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*!
+    @file Tickable.h
+    @brief Declaration of the Tickable interface.
+
+    The Tickable interface provides a tick(dt) function, that gets called every frame.
+    float dt is the time since the last frame in seconds.
+
+    Attention:
+    Classes derived from a Tickable that want to have a tick(dt) function on their part, MUST call the
+    parent::tick(dt) function explicitly in their implementation of tick(dt) because it's a virtual function.
+*/
+
+#ifndef _Tickable_H__
+#define _Tickable_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "core/OrxonoxClass.h"
+#include "core/Super.h"
+
+namespace orxonox
+{
+    //! The Tickable interface provides a tick(dt) function, that gets called every frame.
+    class _OrxonoxExport Tickable : virtual public OrxonoxClass
+    {
+        public:
+            /**
+                @brief Gets called every frame.
+                @param dt The time since the last frame in seconds
+            */
+            virtual void tick(float dt) = 0;
+
+        protected:
+            Tickable();
+    };
+
+    SUPER_FUNCTION(1, Tickable, tick, true);
+}
+
+#endif /* _Tickable_H__ */
Index: /code/branches/ceguilua/src/orxonox/objects/WorldEntity.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/WorldEntity.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/WorldEntity.cc	(revision 1801)
@@ -0,0 +1,189 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "WorldEntity.h"
+
+#include <string>
+#include <sstream>
+#include <OgreSceneManager.h>
+
+#include "tinyxml/tinyxml.h"
+#include "util/SubString.h"
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(WorldEntity);
+
+    unsigned int WorldEntity::worldEntityCounter_s = 0;
+
+    WorldEntity::WorldEntity()
+    {
+        RegisterObject(WorldEntity);
+
+        if (GraphicsEngine::getInstance().getLevelSceneManager())
+        {
+            std::ostringstream name;
+            name << (WorldEntity::worldEntityCounter_s++);
+            this->setName("WorldEntity" + name.str());
+            this->node_ = GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->createChildSceneNode(this->getName());
+
+            registerAllVariables();
+        }
+        else
+        {
+            this->node_ = 0;
+        }
+
+        this->bStatic_ = true;
+        this->velocity_ = Vector3(0, 0, 0);
+        this->acceleration_ = Vector3(0, 0, 0);
+        this->rotationAxis_ = Vector3(0, 1, 0);
+        this->rotationRate_ = 0;
+        this->momentum_ = 0;
+    }
+
+
+    WorldEntity::~WorldEntity()
+    {
+        if (this->isInitialized())
+        {
+            this->getNode()->removeAndDestroyAllChildren();
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroySceneNode(this->getName());
+        }
+    }
+
+    void WorldEntity::tick(float dt)
+    {
+        if (!this->bStatic_ && this->isActive())
+        {
+//             COUT(4) << "acceleration: " << this->acceleration_ << " velocity: " << this->velocity_ << std::endl;
+            this->velocity_ += (dt * this->acceleration_);
+            this->translate(dt * this->velocity_, Ogre::Node::TS_LOCAL);
+
+            this->rotationRate_ += (dt * this->momentum_);
+            this->rotate(this->rotationAxis_, dt * this->rotationRate_);
+            //COUT(3) << "rotationrate: " << this->rotationRate_.valueDegrees() << " momentum: " << this->momentum_.valueDegrees() << std::endl;
+        }
+    }
+
+    void WorldEntity::setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll)
+    {
+        this->yaw(yaw);
+        this->pitch(pitch);
+        this->roll(roll);
+    }
+
+    /**
+        @brief XML loading and saving.
+        @param xmlelement The XML-element
+        @param loading Loading (true) or saving (false)
+        @return The XML-element
+    */
+    void WorldEntity::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(WorldEntity, XMLPort, xmlelement, mode);
+
+        XMLPortParamExternTemplate(WorldEntity, Ogre::Node, this->node_, "position", setPosition, getPosition, xmlelement, mode, Ogre::Node, const Vector3&);
+        XMLPortParamLoadOnly(WorldEntity, "direction", setDirectionSimple, xmlelement, mode);
+        XMLPortParamLoadOnly(WorldEntity, "yawpitchroll", setYawPitchRoll, xmlelement, mode);
+        XMLPortParam(WorldEntity, "scale", setScale, getScale, xmlelement, mode);
+        XMLPortParamTemplate(WorldEntity, "rotationAxis", setRotationAxis, getRotationAxis, xmlelement, mode, WorldEntity, const Vector3&);
+        XMLPortParam(WorldEntity, "rotationRate", setRotationRate, getRotationRate, xmlelement, mode);
+
+        XMLPortObject(WorldEntity, WorldEntity, "attached", attachWorldEntity, getAttachedWorldEntity, xmlelement, mode, false, true);
+
+        WorldEntity::create();
+    }
+
+
+    void WorldEntity::registerAllVariables()
+    {
+      // register inheritec variables from BaseObject
+      registerVar( (void*) &(this->bActive_), sizeof(this->bActive_), network::DATA, 0x3);
+      registerVar( (void*) &(this->bVisible_), sizeof(this->bVisible_), network::DATA, 0x3);
+      // register coordinates
+      registerVar( (void*) &(this->getPosition().x), sizeof(this->getPosition().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getPosition().y), sizeof(this->getPosition().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getPosition().z), sizeof(this->getPosition().z), network::DATA, 0x3);
+      // register orientation
+      registerVar( (void*) &(this->getOrientation().w), sizeof(this->getOrientation().w), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().x), sizeof(this->getOrientation().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().y), sizeof(this->getOrientation().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getOrientation().z), sizeof(this->getOrientation().z), network::DATA, 0x3);
+      // register velocity_
+      registerVar( (void*) &(this->getVelocity().x), sizeof(this->getVelocity().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getVelocity().y), sizeof(this->getVelocity().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getVelocity().z), sizeof(this->getVelocity().z), network::DATA, 0x3);
+      // register rotationAxis/rate
+      registerVar( (void*) &(this->getRotationRate()), sizeof(this->getRotationRate()), network::DATA, 0x3);
+      registerVar( (void*) &(this->getRotationAxis().x), sizeof(this->getRotationAxis().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getRotationAxis().y), sizeof(this->getRotationAxis().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getRotationAxis().z), sizeof(this->getRotationAxis().z), network::DATA, 0x3);
+      // register scale of node
+      registerVar( (void*) &(this->getScale3D().x), sizeof(this->getScale3D().x), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale3D().y), sizeof(this->getScale3D().y), network::DATA, 0x3);
+      registerVar( (void*) &(this->getScale3D().z), sizeof(this->getScale3D().z), network::DATA, 0x3);
+      //register staticity
+      registerVar( (void*) &(this->bStatic_), sizeof(this->bStatic_), network::DATA, 0x3);
+      //register acceleration & momentum
+//       registerVar( (void*) &(this->getAcceleration().x), sizeof(this->getAcceleration().x), network::DATA, 0x2);
+//       registerVar( (void*) &(this->getAcceleration().y), sizeof(this->getAcceleration().y), network::DATA, 0x2);
+//       registerVar( (void*) &(this->getAcceleration().z), sizeof(this->getAcceleration().z), network::DATA, 0x2);
+//       registerVar( (void*) &(this->getMomentum()), sizeof(this->getMomentum()), network::DATA, 0x2); // only backsync
+    }
+
+    void WorldEntity::attachWorldEntity(WorldEntity* entity)
+    {
+        this->attachedWorldEntities_.push_back(entity);
+        this->attachObject(entity);
+    }
+
+    const WorldEntity* WorldEntity::getAttachedWorldEntity(unsigned int index) const
+    {
+        if (index < this->attachedWorldEntities_.size())
+            return this->attachedWorldEntities_[index];
+        else
+            return 0;
+    }
+
+    void WorldEntity::attachObject(const WorldEntity& obj) const
+    {
+        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj.getNode());
+        this->getNode()->addChild(obj.getNode());
+    }
+
+    void WorldEntity::attachObject(WorldEntity* obj) const
+    {
+        GraphicsEngine::getInstance().getLevelSceneManager()->getRootSceneNode()->removeChild(obj->getNode());
+        this->getNode()->addChild(obj->getNode());
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/objects/WorldEntity.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/objects/WorldEntity.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/objects/WorldEntity.h	(revision 1801)
@@ -0,0 +1,199 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _WorldEntity_H__
+#define _WorldEntity_H__
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+
+#include <OgreSceneNode.h>
+#include "util/Math.h"
+#include "util/XMLIncludes.h"
+#include "network/Synchronisable.h"
+#include "core/BaseObject.h"
+#include "Tickable.h"
+#include "../tools/Mesh.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport WorldEntity : public BaseObject, public Tickable, public network::Synchronisable
+    {
+        public:
+            WorldEntity();
+            virtual ~WorldEntity();
+
+            virtual void tick(float dt);
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual inline bool create(){ return Synchronisable::create(); }
+
+            void attachWorldEntity(WorldEntity* entity);
+            const WorldEntity* getAttachedWorldEntity(unsigned int index) const;
+
+            inline Ogre::SceneNode* getNode() const
+                { return this->node_; }
+
+            inline void setNode(Ogre::SceneNode* node)
+                { this->node_ = node; }
+
+            inline void setPosition(const Vector3& pos)
+                { this->node_->setPosition(pos); }
+            inline void setPosition(Real x, Real y, Real z)
+                { this->node_->setPosition(x, y, z); }
+            inline const Vector3& getPosition() const
+                { return this->node_->getPosition(); }
+            inline const Vector3& getWorldPosition() const
+                { return this->node_->getWorldPosition(); }
+
+            inline void translate(const Vector3& d, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
+                { this->node_->translate(d, relativeTo); }
+            inline void translate(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
+                { this->node_->translate(x, y, z, relativeTo); }
+            inline void translate(const Matrix3& axes, const Vector3& move, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
+                { this->node_->translate(axes, move, relativeTo); }
+            inline void translate(const Matrix3& axes, Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_PARENT)
+                { this->node_->translate(axes, x, y, z, relativeTo); }
+
+            inline void yaw(const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
+                { this->node_->yaw(angle, relativeTo); }
+            inline void pitch(const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
+                { this->node_->pitch(angle, relativeTo); }
+            inline void roll(const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
+                { this->node_->roll(angle, relativeTo); }
+            void setYawPitchRoll(const Degree& yaw, const Degree& pitch, const Degree& roll);
+
+            inline void setYaw(const Degree& angle)
+                { this->node_->yaw(angle, Ogre::Node::TS_LOCAL); }
+            inline void setPitch(const Degree& angle)
+                { this->node_->pitch(angle, Ogre::Node::TS_LOCAL); }
+            inline void setRoll(const Degree& angle)
+                { this->node_->roll(angle, Ogre::Node::TS_LOCAL); }
+
+            inline const Ogre::Quaternion& getOrientation()
+              { return this->node_->getOrientation(); }
+            inline const Ogre::Quaternion& getWorldOrientation()
+              { return this->node_->getWorldOrientation(); }
+            inline void setOrientation(const Ogre::Quaternion& quat)
+              { this->node_->setOrientation(quat); }
+            inline void rotate(const Vector3& axis, const Radian& angle, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL)
+              { this->node_->rotate(axis, angle, relativeTo); }
+            inline void setDirectionSimple(Real x, Real y, Real z)
+              { this->setDirection(x, y, z); }
+            inline void setDirection(Real x, Real y, Real z, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
+              { this->node_->setDirection(x, y, z, relativeTo, localDirectionVector); }
+            inline void setDirection(const Vector3& vec, Ogre::Node::TransformSpace relativeTo=Ogre::Node::TS_LOCAL, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
+              { this->node_->setDirection(vec, relativeTo, localDirectionVector); }
+            inline void lookAt(const Vector3& targetPoint, Ogre::Node::TransformSpace relativeTo, const Vector3& localDirectionVector=Vector3::NEGATIVE_UNIT_Z)
+              { this->node_->lookAt(targetPoint, relativeTo, localDirectionVector); }
+
+            inline void setScale3D(const Vector3 &scale)
+              { this->node_->setScale(scale); }
+            inline void setScale3D(Real x, Real y, Real z)
+              { this->node_->setScale(x, y, z); }
+            inline const Vector3& getScale3D(void) const
+              { return this->node_->getScale(); }
+            inline void setScale(float scale)
+              { this->node_->setScale(scale, scale, scale); }
+            inline float getScale() const
+              { Vector3 scale = this->getScale3D(); return (scale.x == scale.y && scale.x == scale.z) ? scale.x : 1; }
+            inline void scale3D(const Vector3 &scale)
+              { this->node_->scale(scale); }
+            inline void scale3D(Real x, Real y, Real z)
+              { this->node_->scale(x, y, z); }
+            inline void scale(Real scale)
+              { this->node_->scale(scale, scale, scale); }
+
+            void attachObject(const WorldEntity& obj) const;
+            void attachObject(WorldEntity* obj) const;
+            inline void attachObject(Ogre::MovableObject* obj) const
+              { this->node_->attachObject(obj); }
+            inline void attachObject(Mesh& mesh) const
+              { this->node_->attachObject(mesh.getEntity()); }
+            inline void detachObject(Ogre::MovableObject* obj) const
+              { this->node_->detachObject(obj); }
+            inline void detachAllObjects() const
+              { this->node_->detachAllObjects(); }
+
+            inline void setVelocity(const Vector3& velocity)
+                { this->velocity_ = velocity; }
+            inline void setVelocity(Real x, Real y, Real z)
+                { this->velocity_.x = x; this->velocity_.y = y; this->velocity_.z = z; }
+            inline const Vector3& getVelocity() const
+                { return this->velocity_; }
+
+            inline void setAcceleration(const Vector3& acceleration)
+                { this->acceleration_ = acceleration; }
+            inline void setAcceleration(Real x, Real y, Real z)
+                { this->acceleration_.x = x; this->acceleration_.y = y; this->acceleration_.z = z; }
+            inline const Vector3& getAcceleration() const
+                { return this->acceleration_; }
+
+            inline void setRotationAxis(const Vector3& axis)
+                { this->rotationAxis_ = axis; this->rotationAxis_.normalise(); }
+            inline void setRotationAxis(Real x, Real y, Real z)
+                { this->rotationAxis_.x = x; this->rotationAxis_.y = y; this->rotationAxis_.z = z; rotationAxis_.normalise(); }
+            inline const Vector3& getRotationAxis() const
+                { return this->rotationAxis_; }
+
+//            inline void setRotationRate(const Radian& angle)
+//                { this->rotationRate_ = angle; }
+            inline void setRotationRate(const Degree& angle)
+                { this->rotationRate_ = angle; this->setStatic(angle == Degree(0)); }
+            inline const Radian& getRotationRate() const
+                { return this->rotationRate_; }
+
+            inline void setMomentum(const Radian& angle)
+                { this->momentum_ = angle; }
+            inline void setMomentum(const Degree& angle)
+                { this->momentum_ = angle; }
+            inline const Radian& getMomentum() const
+                { return this->momentum_; }
+
+            inline void setStatic(bool bStatic)
+                { this->bStatic_ = bStatic; }
+            inline bool isStatic() const
+                { return this->bStatic_; }
+
+        protected:
+            void registerAllVariables();
+
+            Vector3 velocity_;
+            Vector3 acceleration_;
+            Vector3 rotationAxis_;
+            Radian rotationRate_;
+            Radian momentum_;
+
+        private:
+            static unsigned int worldEntityCounter_s;
+            Ogre::SceneNode* node_;
+            bool bStatic_;
+            std::vector<WorldEntity*> attachedWorldEntities_;
+    };
+}
+
+#endif /* _WorldEntity_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/OrxonoxOverlay.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/OrxonoxOverlay.cc	(revision 1801)
@@ -0,0 +1,325 @@
+/*
+ *   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 the OrxonoxOverlay class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "OrxonoxOverlay.h"
+
+#include <cmath>
+#include <OgreOverlay.h>
+#include <OgreOverlayManager.h>
+#include <OgrePanelOverlayElement.h>
+#include "util/Convert.h"
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/ConsoleCommand.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    unsigned int OrxonoxOverlay::hudOverlayCounter_s = 0;
+    std::map<std::string, OrxonoxOverlay*> OrxonoxOverlay::overlays_s;
+
+    SetConsoleCommand(OrxonoxOverlay, scaleOverlay, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OrxonoxOverlay, scrollOverlay, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OrxonoxOverlay, rotateOverlay, false).accessLevel(AccessLevel::User);
+
+    OrxonoxOverlay::OrxonoxOverlay()
+        : overlay_(0)
+        , background_(0)
+    {
+        RegisterObject(OrxonoxOverlay);
+    }
+
+    /**
+    @brief
+        Make sure everything gets removed/destroyed.
+    @remark
+        We assume that the Ogre::OverlayManager exists (there is an assert in Ogre for that!)
+    */
+    OrxonoxOverlay::~OrxonoxOverlay()
+    {
+        // erase ourself from the map with all overlays
+        std::map<std::string, OrxonoxOverlay*>::iterator it = overlays_s.find(this->getName());
+        if (it != overlays_s.end())
+            overlays_s.erase(it);
+
+        if (this->background_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->background_);
+        if (this->overlay_)
+            Ogre::OverlayManager::getSingleton().destroy(this->overlay_);
+    }
+
+    /**
+    @brief
+        Loads the OrxonoxOverlay.
+
+        This has to be called before usage, otherwise strange behaviour is
+        guaranteed! (there should be no segfaults however).
+    @copydoc
+        BaseObject::XMLPort()
+    */
+    void OrxonoxOverlay::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(OrxonoxOverlay, XMLPort, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            // add this overlay to the static map of OrxonoxOverlays
+            if (overlays_s.find(this->getName()) != overlays_s.end())
+            {
+                COUT(1) << "Overlay names should be unique or you cannnot access them via console." << std::endl;
+            }
+            overlays_s[this->getName()] = this;
+
+            // create the Ogre::Overlay
+            overlay_ = Ogre::OverlayManager::getSingleton().create("OrxonoxOverlay_overlay_"
+                + convertToString(hudOverlayCounter_s++));
+
+            // create background panel (can be used to show any picture)
+            this->background_ = static_cast<Ogre::PanelOverlayElement*>(
+                Ogre::OverlayManager::getSingleton().createOverlayElement("Panel",
+                "OrxonoxOverlay_background_" + convertToString(hudOverlayCounter_s++)));
+            this->overlay_->add2D(this->background_);
+
+            // We'll have to get the aspect ratio manually for the first time. Afterwards windowResized() gets
+            // called automatically by the GraphicsEngine.
+            this->windowResized(GraphicsEngine::getInstance().getWindowWidth(),
+                GraphicsEngine::getInstance().getWindowHeight());
+
+            this->changedVisibility();
+        }
+
+        XMLPortParam(OrxonoxOverlay, "size",      setSize,      getSize,      xmlElement, mode)
+            .defaultValues(Vector2(1.0f, 1.0f));
+        XMLPortParam(OrxonoxOverlay, "pickPoint", setPickPoint, getPickPoint, xmlElement, mode)
+            .defaultValues(Vector2(0.0f, 0.0f));
+        XMLPortParam(OrxonoxOverlay, "position",  setPosition,  getPosition,  xmlElement, mode)
+            .defaultValues(Vector2(0.0f, 0.0f));
+        XMLPortParam(OrxonoxOverlay, "rotation",  setRotation,  getRotation,  xmlElement, mode)
+            .defaultValues(0.0f);
+        XMLPortParam(OrxonoxOverlay, "correctAspect", setAspectCorrection,   getAspectCorrection,   xmlElement, mode)
+            .defaultValues(true);
+        XMLPortParam(OrxonoxOverlay, "background",    setBackgroundMaterial, getBackgroundMaterial, xmlElement, mode)
+            .defaultValues("");
+    }
+
+    //! Only sets the background material name if not ""
+    void OrxonoxOverlay::setBackgroundMaterial(const std::string& material)
+    {
+        if (this->background_ && material != "")
+            this->background_->setMaterialName(material);
+    }
+
+    //! Returns the the material name of the background
+    const std::string& OrxonoxOverlay::getBackgroundMaterial() const
+    {
+        if (this->background_)
+            return this->background_->getMaterialName();
+        else
+            return blankString;
+    }
+
+    //! Called by BaseObject when visibility has changed.
+    void OrxonoxOverlay::changedVisibility()
+    {
+        if (!this->overlay_)
+            return;
+
+        if (this->isVisible())
+            this->overlay_->show();
+        else
+            this->overlay_->hide();
+    }
+
+    /**
+    @brief
+        Called by the GraphicsEngine whenever the window size changes.
+        Calculates the aspect ratio only.
+    */
+    void OrxonoxOverlay::windowResized(int newWidth, int newHeight)
+    {
+        this->windowAspectRatio_ = newWidth/(float)newHeight;
+        this->sizeCorrectionChanged();
+    }
+
+    /**
+    @brief
+        Called whenever the rotation angle has changed.
+    */
+    void OrxonoxOverlay::angleChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        this->overlay_->setRotate(this->angle_);
+        this->sizeCorrectionChanged();
+    }
+
+    /**
+    @brief
+        Called whenever the aspect ratio or the angle has changed.
+        The method calculates a correction factor for the size to compensate
+        for aspect distortion if desired.
+    @remarks
+        This only works when the angle is about 0 or 90 degrees.
+    */
+    void OrxonoxOverlay::sizeCorrectionChanged()
+    {
+        if (this->bCorrectAspect_)
+        {
+            float angle = this->angle_.valueDegrees();
+            if (angle < 0.0)
+                angle = -angle;
+            angle -= 180.0 * (int)(angle / 180.0);
+
+            // take the reverse if angle is about 90 degrees
+            float tempAspect;
+            if (angle > 89.0 && angle < 91.0)
+            {
+                tempAspect = 1.0 / this->windowAspectRatio_;
+                rotState_ = Vertical;
+            }
+            else if (angle > 179 || angle < 1)
+            {
+                tempAspect = this->windowAspectRatio_;
+                rotState_ = Horizontal;
+            }
+            else
+            {
+                tempAspect = 1.0;
+                rotState_ = Inbetween;
+            }
+
+            // note: this is only an approximation that is mostly valid when the
+            // magnitude of the width is about the magnitude of the height.
+            // Correctly we would have to take the square root of width*height
+            this->sizeCorrection_.x = 2.0 / (tempAspect + 1.0);
+            this->sizeCorrection_.y = tempAspect * this->sizeCorrection_.x;
+        }
+        else
+        {
+            this->sizeCorrection_ = Vector2::UNIT_SCALE;
+        }
+
+        this->sizeChanged();
+    }
+
+    /**
+    @brief
+        Sets the overlay size using the actual corrected size.
+    */
+    void OrxonoxOverlay::sizeChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        this->overlay_->setScale(size_.x * sizeCorrection_.x, size_.y * sizeCorrection_.y);
+        positionChanged();
+    }
+
+    /**
+    @brief
+        Determines the position of the overlay.
+        This works also well when a rotation angle is applied. The overlay always
+        gets aligned correctly as well as possible.
+    */
+    void OrxonoxOverlay::positionChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        // transform the angle to a range of 0 - pi/2 first.
+        float angle = this->angle_.valueRadians();
+        if (angle < 0.0)
+            angle = -angle;
+        angle -= Ogre::Math::PI * (int)(angle / (Ogre::Math::PI));
+        if (angle > Ogre::Math::PI * 0.5)
+            angle = Ogre::Math::PI - angle;
+
+        // do some mathematical fiddling for a bounding box
+        Vector2 actualSize = size_ * sizeCorrection_;
+        float radius = actualSize.length();
+        float phi = atan(actualSize.y / actualSize.x);
+        Vector2 boundingBox(radius * cos(angle - phi), radius * sin(angle + phi));
+
+        // calculate the scrolling offset
+        Vector2 scroll = (position_ - 0.5 - boundingBox * (pickPoint_ - 0.5)) * 2.0;
+        this->overlay_->setScroll(scroll.x, -scroll.y);
+    }
+
+
+    //########### Console commands ############
+
+    /**
+    @brief
+        Scales an overlay by its name.
+    @param name
+        The name of the overlay defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OrxonoxOverlay::scaleOverlay(const std::string& name, float scale)
+    {
+        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
+        if (it != overlays_s.end())
+            (*it).second->scale(Vector2(scale, scale));
+    }
+
+    /**
+    @brief
+        Scrolls an overlay by its name.
+    @param name
+        The name of the overlay defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OrxonoxOverlay::scrollOverlay(const std::string& name, const Vector2& scroll)
+    {
+        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
+        if (it != overlays_s.end())
+            (*it).second->scroll(scroll);
+    }
+
+    /**
+    @brief
+        Rotates an overlay by its name.
+    @param name
+        The name of the overlay defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OrxonoxOverlay::rotateOverlay(const std::string& name, const Degree& angle)
+    {
+        std::map<std::string, OrxonoxOverlay*>::const_iterator it = overlays_s.find(name);
+        if (it != overlays_s.end())
+            (*it).second->rotate(angle);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/OrxonoxOverlay.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/OrxonoxOverlay.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/OrxonoxOverlay.h	(revision 1801)
@@ -0,0 +1,185 @@
+/*
+ *   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 OrxonoxOverlay class.
+*/
+
+#ifndef _OrxonoxOverlay_H__
+#define _OrxonoxOverlay_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "tools/WindowEventListener.h"
+#include "util/Math.h"
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        Base class to display content directly onto the screen.
+        This is merely a wrapper of the Ogre::Overlay to implement more features and integrate it
+        in our class hierarchy for xml loading and config values.
+        The mentioned features are:
+        - Automatic positioning depending on the scale and the rotation angle.
+          You can specify a "pick point" relative to the overlay itself. This point will always be exactly
+          at the position (position_) of the overlay. That allows for margin/corner aligment.
+          It even works when a rotation angle is applied.
+        - Virtual methods for changedVisibilty() (BaseObject), angleChanged(), sizeCorrectionChanged(),
+          sizeChanged() and positionChanged(), that can be overridden by any derivative. This enables for
+          custom configurability of the size, position and rotation attributes. For intance, the HUDNavigation
+          should behave differently to sizeChanged() than a standard overlay.
+        - Console commands for scale, rotate and scroll (accessed by name)
+        - Standard Ogre::PanelOverlayElement for a background image (class doesn't have to be derived
+          only for displaying a picture).
+        - Reacts to changes of the window aspect
+        - Last but not least: On demand you can tell the overlay to automatically resale to correct for
+          aspect distortion. E.g. if you play 1024x768 you wouldn't want a round object to be oval.
+          Remark: This can (due to the Ogre::Overlay transformation order) only work for angle that are
+                  multiples of 90 degrees. But it's only a small drawback.
+    */
+    class _OrxonoxExport OrxonoxOverlay : public BaseObject, public WindowEventListener
+    {
+    public:
+        /**
+        @brief
+            Describes the rotational state of a an overlay.
+            Horizontal means 0/180 degrees, Vertical is 90/270 degrees
+            and Inbetween is everything else.
+        */
+        enum RotationState
+        {
+            Horizontal,
+            Vertical,
+            Inbetween
+        };
+
+    public:
+        OrxonoxOverlay();
+        virtual ~OrxonoxOverlay();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        //! Shows the overlay with an detour to BaseObject::visibility_
+        void show() { this->setVisible(true); }
+        //! Hides the overlay with an detour to BaseObject::visibility_
+        void hide() { this->setVisible(false); }
+
+        /** Sets whether the aspect of the overlay is corrected.
+            This is for instance useful for round objects that should stay round no matter
+            what the screen resolution is. */
+        void setAspectCorrection(bool val)        { this->bCorrectAspect_ = val; this->sizeCorrectionChanged(); }
+        //! Returns whether the window aspect is corrected
+        bool getAspectCorrection() const          { return this->bCorrectAspect_; }
+
+        //! Sets the position of this overlay on the screen.
+        void setPosition(Vector2 pos)             { this->position_ = pos; this->positionChanged(); }
+
+        //! Returns the current position on the screen.
+        const Vector2& getPosition() const        { return this->position_; }
+
+        //! Scrolls the overlay. @param offset The offset given.
+        void scroll(const Vector2& offset)        { this->position_ += offset; this->positionChanged(); }
+
+        /** Sets the point in the overlay where to pick it when translating.
+            For instance setting it to (1.0,1.0) means that the lower right corner of the
+            overlay will be put at position_.
+            This primarily helps aligning an overlay to any corner/margin on the screen. */
+        void setPickPoint(const Vector2& position){ this->pickPoint_ = position; this->positionChanged(); }
+
+        //! Gets the pick point of this overlay. @see setPickPoint()
+        const Vector2& getPickPoint() const       { return this->pickPoint_; }
+
+        //! Sets the rotation angle applied to this overlay in degrees.
+        void setRotation(const Degree& angle)     { this->angle_ = angle; this->angleChanged(); }
+
+        //! Gets the rotation angle applied to this overlay in degrees.
+        const Radian& getRotation() const         { return this->angle_; }
+
+        //! Rotates the overlay by angle degrees.
+        void rotate(const Degree& angle)          { this->angle_ += angle; this->angleChanged(); }
+
+        //! Sets the size of this overlay.
+        void setSize(const Vector2& size)         { this->size_ = size; this->sizeChanged(); }
+
+        //! Gets the current size that was set (uncorrected)
+        const Vector2& getSize() const                   { return this->size_; }
+
+        //! Gets the actual size of the overlay on the screen (corrected)
+        Vector2 getActualSize() const      { return this->size_ * this->sizeCorrection_; }
+
+        //! Gets the current size correction (default: 1.0, 1.0)
+        const Vector2& getSizeCorrection() const  { return this->sizeCorrection_; }
+
+        //! Scales the overlay by scale.
+        void scale(const Vector2& scale)          { this->size_ *= scale; this->sizeChanged(); }
+
+        //! ConsoleCommand: Accesses the overlay by its name and scales it.
+        static void scaleOverlay(const std::string& name, float scale);
+        //! ConsoleCommand: Accesses the overlay by its name and scrolls it.
+        static void scrollOverlay(const std::string& name, const Vector2& scroll);
+        //! ConsoleCommand: Accesses the overlay by its name and rotates it.
+        static void rotateOverlay(const std::string& name, const Degree& angle);
+
+        virtual void changedVisibility();
+
+    protected:
+        virtual void angleChanged();
+        virtual void sizeCorrectionChanged();
+        virtual void sizeChanged();
+        virtual void positionChanged();
+
+        void setBackgroundMaterial(const std::string& material);
+        const std::string& getBackgroundMaterial() const;
+
+        Ogre::Overlay* overlay_;                   //!< The overlay the entire class is about.
+        Ogre::PanelOverlayElement* background_;    //!< Background image (blank per default).
+
+        float windowAspectRatio_;                  //!< Screen.width / screen.height
+        bool bCorrectAspect_;                      //!< Whether or not to correct the size. @see setAspectCorrection()
+        Vector2 size_;                             //!< Internal size of the overlay.
+        Vector2 sizeCorrection_;                   //!< Value to correct the size because of the window aspect.
+        Vector2 position_;                         //!< Position of the pickPoint on the screen.
+        Vector2 pickPoint_;                        //!< Point on the overlay to pick when translating
+        Radian angle_;                             //!< Rotation angle of the overlay
+        RotationState rotState_;             //!< horizontal, vertical or inbetween
+
+    private:
+        void windowResized(int newWidth, int newHeight);
+
+        static unsigned int hudOverlayCounter_s;   //!< Static counter for hud elements
+        /** Contains all the overlays in a map for quick access via console commands.
+            We could also use the ObjectList, but that doesn't guarantee XMLPort(.) was called and is slower. */
+        static std::map<std::string, OrxonoxOverlay*> overlays_s;
+  };
+}
+
+#endif /* _OrxonoxOverlay_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/OverlayGroup.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/OverlayGroup.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/OverlayGroup.cc	(revision 1801)
@@ -0,0 +1,176 @@
+/*
+ *   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 the OverlayGroup class.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "OverlayGroup.h"
+
+#include "util/Debug.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/Iterator.h"
+#include "core/XMLPort.h"
+#include "OrxonoxOverlay.h"
+
+namespace orxonox
+{
+    CreateFactory(OverlayGroup);
+
+    SetConsoleCommand(OverlayGroup, toggleVisibility, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OverlayGroup, scaleGroup, false).accessLevel(AccessLevel::User);
+    SetConsoleCommand(OverlayGroup, scrollGroup, false).accessLevel(AccessLevel::User);
+
+    OverlayGroup::OverlayGroup()
+    {
+        RegisterObject(OverlayGroup);
+    }
+
+    /**
+    @brief
+        Loads the group and all its children OrxonoxOverlays.
+    @copydoc
+        BaseObject::XMLPort()
+    */
+    void OverlayGroup::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(OverlayGroup, XMLPort, xmlElement, mode);
+
+        XMLPortParam(OverlayGroup, "scale",  setScale,  getScale,  xmlElement, mode).defaultValues(Vector2(1.0, 1.0));
+        XMLPortParam(OverlayGroup, "scroll", setScroll, getScroll, xmlElement, mode).defaultValues(Vector2(0.0, 0.0));
+        // loads all the child elements
+        XMLPortObject(OverlayGroup, OrxonoxOverlay, "", addElement, getElement, xmlElement, mode, false, true);
+    }
+
+    //! Scales every element in the map.
+    void OverlayGroup::setScale(const Vector2& scale)
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->scale(scale / this->scale_);
+        this->scale_ = scale;
+    }
+
+    //! Scrolls every element in the map.
+    void OverlayGroup::setScroll(const Vector2& scroll)
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->scroll(scroll - this->scroll_);
+        this->scroll_ = scroll;
+    }
+
+    /**
+    @brief
+        Adds an element to the map (used when loading with XMLPort).
+    @remarks
+        The names of the OrxonoxOverlays have to be unique!
+    */
+    void OverlayGroup::addElement(OrxonoxOverlay* element)
+    {
+        if (hudElements_.find(element->getName()) != hudElements_.end())
+        {
+            COUT(1) << "Ambiguous names encountered while load the HUD overlays" << std::endl;
+        }
+        else
+            hudElements_[element->getName()] = element;
+    }
+
+    //! Returns a different element as long as index < hudElements_.size().
+    OrxonoxOverlay* OverlayGroup::getElement(unsigned int index)
+    {
+        if (index < this->hudElements_.size())
+        {
+            std::map<std::string, OrxonoxOverlay*>::const_iterator it = hudElements_.begin();
+            for (unsigned int i = 0; i != index; ++it, ++i)
+                ;
+            return (*it).second;
+        }
+        else
+            return 0;
+    }
+
+    //! Changes the visibility of all elements
+    void OverlayGroup::changedVisibility()
+    {
+        for (std::map<std::string, OrxonoxOverlay*>::iterator it = hudElements_.begin(); it != hudElements_.end(); ++it)
+            (*it).second->setVisible(this->isVisible());
+    }
+
+
+    //########### Console commands ############
+
+    /**
+    @brief
+        Hides/shows an overlay group by its name.
+    @param name
+        The name of the group defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OverlayGroup::toggleVisibility(const std::string& name)
+    {
+        for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)
+        {
+            if ((*it)->getName() == name)
+                (*it)->setVisible(!((*it)->isVisible()));
+        }
+    }
+
+    /**
+    @brief
+        Scales an overlay group by its name.
+    @param name
+        The name of the group defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OverlayGroup::scaleGroup(const std::string& name, float scale)
+    {
+        for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)
+        {
+            if ((*it)->getName() == name)
+                (*it)->scale(Vector2(scale, scale));
+        }
+    }
+
+    /**
+    @brief
+        Scrolls an overlay group by its name.
+    @param name
+        The name of the group defined BaseObject::setName() (usually done with the "name"
+        attribute in the xml file).
+    */
+    /*static*/ void OverlayGroup::scrollGroup(const std::string& name, const Vector2& scroll)
+    {
+        for (ObjectList<OverlayGroup>::iterator it = ObjectList<OverlayGroup>::begin(); it; ++it)
+        {
+            if ((*it)->getName() == name)
+                (*it)->scroll(scroll);
+        }
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/OverlayGroup.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/OverlayGroup.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/OverlayGroup.h	(revision 1801)
@@ -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 Declaration of the OverlayGroup class.
+*/
+
+#ifndef _OverlayGroup_H__
+#define _OverlayGroup_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <OgrePrerequisites.h>
+#include "core/BaseObject.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    /**
+    @brief
+        OverlayGroup does almost exactly what it says: It groups OrxonoxOverlays together.
+        You can scroll the entire group by a certain amount. Scale however works differently
+        than expected: Each OrxonoxOverlay scales individually. That's quite useful when you
+        create your HUD with an OverlayGroup and then want to alter its size.
+    */
+    class _OrxonoxExport OverlayGroup : public BaseObject
+    {
+    public:
+        OverlayGroup();
+        //! Empty destructor.
+        ~OverlayGroup() { }
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        static void toggleVisibility(const std::string& name);
+        static void scaleGroup(const std::string& name, float scale);
+        static void scrollGroup(const std::string& name, const Vector2& scroll);
+
+        void changedVisibility();
+
+    private:
+        //! Scales each OrxonoxOverlay individually by scale.
+        void scale(const Vector2& scale) { this->setScale(scale * this->scale_); }
+        void setScale(const Vector2& scale);
+        //! Returns the current size of the group.
+        Vector2 getScale() const { return this->scale_; }
+
+        //! Scrolls each OrxonoxOverlay individually by scroll.
+        void scroll(const Vector2& scroll) { this->setScroll(scroll + this->scroll_); }
+        void setScroll(const Vector2& scroll);
+        //! Returns the current scrolling offset of the group.
+        Vector2 getScroll() const { return this->scale_; }
+
+        void addElement(OrxonoxOverlay* element);
+        OrxonoxOverlay* getElement(unsigned int index);
+
+        std::map<std::string, OrxonoxOverlay*> hudElements_;    //!< Contains all the OrxonoxOverlays of the this group.
+        Vector2 scale_;                                         //!< Current scale (independant of the elements).
+        Vector2 scroll_;                                        //!< Current scrolling offset.
+    };
+}
+
+#endif /* _OverlayGroup_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/OverlayText.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/OverlayText.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/OverlayText.cc	(revision 1801)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "OverlayText.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/String.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(OverlayText);
+
+    OverlayText::OverlayText()
+        : text_(0)
+    {
+        RegisterObject(OverlayText);
+    }
+
+    OverlayText::~OverlayText()
+    {
+        if (this->text_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->text_);
+    }
+
+    void OverlayText::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(OverlayText, XMLPort, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            this->text_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("TextArea", "OverlayText_text_" + getUniqueNumberStr()));
+            this->text_->setCharHeight(1.0);
+
+            this->background_->addChild(this->text_);
+        }
+
+        XMLPortParam(OverlayText, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
+        XMLPortParam(OverlayText, "caption",  setCaption,  getCaption,  xmlElement, mode).defaultValues("");
+        XMLPortParam(OverlayText, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(1.0f);
+    }
+
+    void OverlayText::setFont(const std::string& font)
+    {
+        if (this->text_ && font != "")
+            this->text_->setFontName(font);
+    }
+
+    const std::string& OverlayText::getFont() const
+    {
+        if (this->text_)
+            return this->text_->getFontName();
+        else
+            return blankString;
+    }
+
+    void OverlayText::sizeChanged()
+    {
+        if (!this->overlay_)
+            return;
+
+        if (this->rotState_ == Horizontal)
+            this->overlay_->setScale(size_.y * sizeCorrection_.y, size_.y * sizeCorrection_.y);
+        else if (this->rotState_ == Vertical)
+            this->overlay_->setScale(size_.y / (sizeCorrection_.y * sizeCorrection_.y), size_.y * sizeCorrection_.y);
+        else
+            this->overlay_->setScale(size_.y, size_.y);
+
+        positionChanged();
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/OverlayText.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/OverlayText.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/OverlayText.h	(revision 1801)
@@ -0,0 +1,66 @@
+/*
+ *   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 _OverlayText_H__
+#define _OverlayText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgrePrerequisites.h>
+#include "OrxonoxOverlay.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport OverlayText : public OrxonoxOverlay
+    {
+    public:
+        OverlayText();
+        virtual ~OverlayText();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    protected:
+        virtual void sizeChanged();
+
+        void setCaption(const std::string& caption) { this->caption_ = caption; }
+        const std::string& getCaption() const       { return this->caption_; }
+
+        void setFont(const std::string& font);
+        const std::string& getFont() const;
+
+        void setTextSize(float size) { this->setSize(Vector2(size, size)); }
+        float getTextSize() const    { return this->getSize().y; }
+
+        Ogre::TextAreaOverlayElement* text_;
+
+    private:
+        std::string caption_;
+    };
+}
+#endif /* _OverlayText_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/console/InGameConsole.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/console/InGameConsole.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/console/InGameConsole.cc	(revision 1801)
@@ -0,0 +1,602 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+
+#include "InGameConsole.h"
+
+#include <string>
+#include <OgreOverlay.h>
+#include <OgreOverlayElement.h>
+#include <OgreOverlayManager.h>
+#include <OgreOverlayContainer.h>
+#include <OgreFontManager.h>
+#include <OgreFont.h>
+
+#include "util/Math.h"
+#include "util/Convert.h"
+#include "util/Debug.h"
+#include "core/CoreIncludes.h"
+#include "core/ConfigValueIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/input/InputManager.h"
+#include "core/input/SimpleInputState.h"
+#include "core/input/InputBuffer.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    const int LINES = 30;
+    const float CHAR_WIDTH = 7.45f; // fix this please - determine the char-width dynamically
+
+    SetConsoleCommand(InGameConsole, openConsole, true);
+    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)
+    {
+        RegisterObject(InGameConsole);
+
+        assert(singletonRef_s == 0);
+        singletonRef_s = this;
+
+        this->bActive_ = false;
+        this->cursor_ = 0.0f;
+        this->cursorSymbol_ = '|';
+        this->inputWindowStart_ = 0;
+        this->numLinesShifted_ = LINES - 1;
+        // for the beginning, don't scroll
+        this->scroll_ = 0;
+
+        this->setConfigValues();
+    }
+
+    /**
+        @brief Destructor: Destroys the TextAreas.
+    */
+    InGameConsole::~InGameConsole(void)
+    {
+        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)
+        {
+            if (this->consoleOverlayNoise_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayNoise_);
+            if (this->consoleOverlayCursor_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayCursor_);
+            if (this->consoleOverlayBorder_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayBorder_);
+            if (this->consoleOverlayTextAreas_)
+            {
+                for (int i = 0; i < LINES; i++)
+                {
+                    if (this->consoleOverlayTextAreas_[i])
+                      Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayTextAreas_[i]);
+                    this->consoleOverlayTextAreas_[i] = 0;
+                }
+
+            }
+            if (this->consoleOverlayContainer_)
+                Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->consoleOverlayContainer_);
+        }
+        if (this->consoleOverlayTextAreas_)
+        {
+            delete[] this->consoleOverlayTextAreas_;
+            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;
+    }
+
+    // ###############################
+    // ###  ShellListener methods  ###
+    // ###############################
+
+    /**
+        @brief Called if all output-lines have to be redrawn.
+    */
+    void InGameConsole::linesChanged()
+    {
+        std::list<std::string>::const_iterator it = Shell::getInstance().getNewestLineIterator();
+        int max = 0;
+        for (int i = 1; i < LINES; ++i)
+        {
+            if (it != Shell::getInstance().getEndIterator())
+            {
+                ++it;
+                max = i;
+            }
+            else
+                break;
+        }
+
+        for (int i = LINES - 1; i > max; --i)
+            this->print("", i, true);
+
+        for (int i = max; i >= 1; --i)
+        {
+            --it;
+            this->print(*it, i, true);
+        }
+    }
+
+    /**
+        @brief Called if only the last output-line has changed.
+    */
+    void InGameConsole::onlyLastLineChanged()
+    {
+        if (LINES > 1)
+            this->print(*Shell::getInstance().getNewestLineIterator(), 1);
+    }
+
+    /**
+        @brief Called if a new output-line was added.
+    */
+    void InGameConsole::lineAdded()
+    {
+        this->numLinesShifted_ = 0;
+        this->shiftLines();
+        this->onlyLastLineChanged();
+    }
+
+    /**
+        @brief Called if the text in the input-line has changed.
+    */
+    void InGameConsole::inputChanged()
+    {
+        if (LINES > 0)
+            this->print(Shell::getInstance().getInput(), 0);
+
+        if (Shell::getInstance().getInput() == "" || Shell::getInstance().getInput().size() == 0)
+            this->inputWindowStart_ = 0;
+    }
+
+    /**
+        @brief Called if the position of the cursor in the input-line has changed.
+    */
+    void InGameConsole::cursorChanged()
+    {
+        unsigned int pos = Shell::getInstance().getCursorPosition() - inputWindowStart_;
+        if (pos > maxCharsPerLine_)
+            pos = maxCharsPerLine_;
+        else if (pos < 0)
+            pos = 0;
+
+        this->consoleOverlayCursor_->setCaption(std::string(pos,' ') + cursorSymbol_);
+        this->consoleOverlayCursor_->setTop((int) this->windowH_ * this->relativeHeight - 24);
+    }
+
+    /**
+        @brief Called if the console gets closed.
+    */
+    void InGameConsole::exit()
+    {
+        this->deactivate();
+    }
+
+    // ###############################
+    // ###  other external calls   ###
+    // ###############################
+
+    /**
+        @brief Used to control the actual scrolling and the cursor.
+    */
+    void InGameConsole::tick(float dt)
+    {
+        if (this->scroll_ != 0)
+        {
+            float oldTop = this->consoleOverlayContainer_->getTop();
+
+            if (this->scroll_ > 0)
+            {
+                // scrolling down
+                // enlarge oldTop a little bit so that this exponential function
+                // reaches 0 before infinite time has passed...
+                float deltaScroll = (oldTop - 0.01) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll >= 0)
+                {
+                    // window has completely scrolled down
+                    this->consoleOverlayContainer_->setTop(0);
+                    this->scroll_ = 0;
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+
+            else
+            {
+                // scrolling up
+                // note: +0.01 for the same reason as when scrolling down
+                float deltaScroll = (1.2 * this->relativeHeight + 0.01 + oldTop) * dt * this->scrollSpeed_;
+                if (oldTop - deltaScroll <= -1.2 * this->relativeHeight)
+                {
+                    // window has completely scrolled up
+                    this->consoleOverlayContainer_->setTop(-1.2 * this->relativeHeight);
+                    this->scroll_ = 0;
+                    this->consoleOverlay_->hide();
+                }
+                else
+                    this->consoleOverlayContainer_->setTop(oldTop - deltaScroll);
+            }
+        }
+
+        if (this->bActive_)
+        {
+            this->cursor_ += dt;
+            if (this->cursor_ >= this->blinkTime)
+            {
+                this->cursor_ = 0;
+                bShowCursor_ = !bShowCursor_;
+                if (bShowCursor_)
+                    this->consoleOverlayCursor_->show();
+                else
+                    this->consoleOverlayCursor_->hide();
+            }
+
+            // this creates a flickering effect (extracts exactly 80% of the texture at a random location)
+            float uRand = (rand() & 1023) / 1023.0f * 0.2f;
+            float vRand = (rand() & 1023) / 1023.0f * 0.2f;
+            this->consoleOverlayNoise_->setUV(uRand, vRand, 0.8f + uRand, 0.8f + vRand);
+        }
+    }
+
+    /**
+        @brief Resizes the console elements. Call if window size changes.
+    */
+    void InGameConsole::windowResized(int newWidth, int newHeight)
+    {
+        this->windowW_ = newWidth;
+        this->windowH_ = newHeight;
+        this->consoleOverlayBorder_->setWidth((int) this->windowW_* this->relativeWidth);
+        this->consoleOverlayBorder_->setHeight((int) this->windowH_ * this->relativeHeight);
+        this->consoleOverlayNoise_->setWidth((int) this->windowW_ * this->relativeWidth - 10);
+        this->consoleOverlayNoise_->setHeight((int) this->windowH_ * this->relativeHeight - 5);
+        this->consoleOverlayNoise_->setTiling(consoleOverlayNoise_->getWidth() / (50.0f * this->noiseSize_), consoleOverlayNoise_->getHeight() / (50.0f * this->noiseSize_));
+
+        // now adjust the text lines...
+        this->desiredTextWidth_ = (int) (this->windowW_ * this->relativeWidth) - 12;
+
+        if (LINES > 0)
+            this->maxCharsPerLine_ = max((unsigned int)10, (unsigned int) ((float)this->desiredTextWidth_ / CHAR_WIDTH));
+        else
+            this->maxCharsPerLine_ = 10;
+
+        for (int i = 0; i < LINES; i++)
+        {
+            this->consoleOverlayTextAreas_[i]->setWidth(this->desiredTextWidth_);
+            this->consoleOverlayTextAreas_[i]->setTop((int) this->windowH_ * this->relativeHeight - 24 - 14*i);
+        }
+
+        this->linesChanged();
+        this->cursorChanged();
+    }
+
+    // ###############################
+    // ###    internal methods     ###
+    // ###############################
+
+    /**
+        @brief Prints string to bottom line.
+        @param s String to be printed
+    */
+    void InGameConsole::print(const std::string& text, int index, bool alwaysShift)
+    {
+        char level = 0;
+        if (text.size() > 0)
+            level = text[0];
+
+        std::string output = text;
+
+        if (level >= -1 && level <= 5)
+            output.erase(0, 1);
+
+        if (LINES > index)
+        {
+            this->colourLine(level, index);
+
+            if (index > 0)
+            {
+                unsigned int linesUsed = 1;
+                while (output.size() > this->maxCharsPerLine_)
+                {
+                    ++linesUsed;
+                    this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output.substr(0, this->maxCharsPerLine_)));
+                    output.erase(0, this->maxCharsPerLine_);
+                    output.insert(0, 1, ' ');
+                    if (linesUsed > numLinesShifted_ || alwaysShift)
+                        this->shiftLines();
+                    this->colourLine(level, index);
+                }
+                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+                this->displayedText_ = output;
+                this->numLinesShifted_ = linesUsed;
+            }
+            else
+            {
+                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;
+
+                    output = output.substr(this->inputWindowStart_, this->maxCharsPerLine_);
+                }
+                else
+                  this->inputWindowStart_ = 0;
+                this->displayedText_ = output;
+                this->consoleOverlayTextAreas_[index]->setCaption(convert2UTF(output));
+            }
+        }
+    }
+
+    /**
+        @brief Shows the InGameConsole.
+    */
+    void InGameConsole::activate()
+    {
+        if (!this->bActive_)
+        {
+            this->bActive_ = true;
+            InputManager::getInstance().requestEnterState("console");
+            Shell::getInstance().registerListener(this);
+
+            this->windowResized(this->windowW_, this->windowH_);
+            this->linesChanged();
+            this->cursorChanged();
+            this->consoleOverlay_->show();
+
+            // scroll down
+            this->scroll_ = 1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+    @brief Hides the InGameConsole.
+    */
+    void InGameConsole::deactivate()
+    {
+        if (this->bActive_)
+        {
+            this->bActive_ = false;
+            InputManager::getInstance().requestLeaveState("console");
+            Shell::getInstance().unregisterListener(this);
+
+            // scroll up
+            this->scroll_ = -1;
+            // the rest is done by tick
+        }
+    }
+
+    /**
+        @brief Shifts all output lines one line up
+    */
+    void InGameConsole::shiftLines()
+    {
+        for (unsigned int i = LINES - 1; i > 1; --i)
+        {
+            this->consoleOverlayTextAreas_[i]->setCaption(this->consoleOverlayTextAreas_[i - 1]->getCaption());
+            this->consoleOverlayTextAreas_[i]->setColourTop(this->consoleOverlayTextAreas_[i - 1]->getColourTop());
+            this->consoleOverlayTextAreas_[i]->setColourBottom(this->consoleOverlayTextAreas_[i - 1]->getColourBottom());
+        }
+    }
+
+    void InGameConsole::colourLine(int colourcode, int index)
+    {
+        if (colourcode == -1)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.90, 0.90, 0.90, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 1.00, 1.00, 1.00));
+        }
+        else if (colourcode == 1)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.25, 0.25, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.50, 0.50, 1.00));
+        }
+        else if (colourcode == 2)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.95, 0.50, 0.20, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.70, 0.50, 1.00));
+        }
+        else if (colourcode == 3)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.50, 0.50, 0.95, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.80, 1.00, 1.00));
+        }
+        else if (colourcode == 4)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.65, 0.48, 0.44, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(1.00, 0.90, 0.90, 1.00));
+        }
+        else if (colourcode == 5)
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.40, 0.20, 0.40, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 0.60, 0.80, 1.00));
+        }
+        else
+        {
+            this->consoleOverlayTextAreas_[index]->setColourTop   (ColourValue(0.21, 0.69, 0.21, 1.00));
+            this->consoleOverlayTextAreas_[index]->setColourBottom(ColourValue(0.80, 1.00, 0.80, 1.00));
+        }
+    }
+
+    // ###############################
+    // ###      satic methods      ###
+    // ###############################
+
+    /**
+        @brief Activates the console.
+    */
+    /*static*/ void InGameConsole::openConsole()
+    {
+        InGameConsole::getInstance().activate();
+    }
+
+    /**
+        @brief Deactivates the console.
+    */
+    /*static*/ void InGameConsole::closeConsole()
+    {
+        InGameConsole::getInstance().deactivate();
+    }
+
+    /**
+        @brief Converts a string into an Ogre::UTFString.
+        @param s The string to convert
+        @return The converted string
+    */
+    /*static*/ Ogre::UTFString InGameConsole::convert2UTF(std::string s)
+    {
+        Ogre::UTFString utf;
+        Ogre::UTFString::code_point cp;
+        for (unsigned int i = 0; i < s.size(); ++i)
+        {
+          cp = s[i];
+          cp &= 0xFF;
+          utf.append(1, cp);
+        }
+        return utf;
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/console/InGameConsole.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/console/InGameConsole.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/console/InGameConsole.h	(revision 1801)
@@ -0,0 +1,116 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+#ifndef _InGameConsole_H__
+#define _InGameConsole_H__
+
+
+#include "OrxonoxPrereqs.h"
+#include <OgrePrerequisites.h>
+#include <OgreBorderPanelOverlayElement.h>
+#include <OgreTextAreaOverlayElement.h>
+
+#include "core/Shell.h"
+#include "core/OrxonoxClass.h"
+#include "tools/WindowEventListener.h"
+
+
+namespace orxonox
+{
+    class _OrxonoxExport InGameConsole : virtual public OrxonoxClass, public ShellListener, public WindowEventListener
+    {
+    public: // functions
+        InGameConsole();
+        ~InGameConsole();
+
+        void initialise();
+        void destroy();
+        void setConfigValues();
+
+        virtual void tick(float dt);
+
+        static InGameConsole& getInstance() { assert(singletonRef_s); return *singletonRef_s; }
+        static InGameConsole* getInstancePtr() { return singletonRef_s; }
+
+        static void openConsole();
+        static void closeConsole();
+
+    private: // functions
+        InGameConsole(const InGameConsole& other) {}
+
+        void activate();
+        void deactivate();
+
+        void linesChanged();
+        void onlyLastLineChanged();
+        void lineAdded();
+        void inputChanged();
+        void cursorChanged();
+        void exit();
+
+        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 windowResized(int newWidth, int newHeight);
+
+        static Ogre::UTFString convert2UTF(std::string s);
+
+    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;
+    };
+}
+
+#endif /* _InGameConsole_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/debug/DebugFPSText.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/debug/DebugFPSText.cc	(revision 1801)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DebugFPSText.h"
+#include <OgreTextAreaOverlayElement.h>
+#include "core/CoreIncludes.h"
+#include "GraphicsEngine.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+    CreateFactory(DebugFPSText);
+
+    DebugFPSText::DebugFPSText()
+    {
+        RegisterObject(DebugFPSText);
+    }
+
+    DebugFPSText::~DebugFPSText()
+    {
+    }
+
+    void DebugFPSText::tick(float dt)
+    {
+        float fps = GraphicsEngine::getInstance().getAverageFramesPerSecond();
+        this->text_->setCaption(this->getCaption() + convertToString(fps));
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/debug/DebugFPSText.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/debug/DebugFPSText.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/debug/DebugFPSText.h	(revision 1801)
@@ -0,0 +1,48 @@
+/*
+ *   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 _DebugFPSText_H__
+#define _DebugFPSText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport DebugFPSText : public OverlayText, public Tickable
+    {
+    public:
+        DebugFPSText();
+        ~DebugFPSText();
+
+        virtual void tick(float dt);
+    };
+}
+#endif /* _DebugFPSText_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/debug/DebugRTRText.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/debug/DebugRTRText.cc	(revision 1801)
@@ -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:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "DebugRTRText.h"
+#include <OgreTextAreaOverlayElement.h>
+#include "core/CoreIncludes.h"
+#include "util/Convert.h"
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    CreateFactory(DebugRTRText);
+
+    DebugRTRText::DebugRTRText()
+    {
+        RegisterObject(DebugRTRText);
+    }
+
+    DebugRTRText::~DebugRTRText()
+    {
+    }
+
+    void DebugRTRText::tick(float dt)
+    {
+        float rtr = GraphicsEngine::getInstance().getAverageTickTime();
+        this->text_->setCaption(this->getCaption() + convertToString(rtr));
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/debug/DebugRTRText.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/debug/DebugRTRText.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/debug/DebugRTRText.h	(revision 1801)
@@ -0,0 +1,48 @@
+/*
+ *   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 _DebugRTRText_H__
+#define _DebugRTRText_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "overlays/OverlayText.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport DebugRTRText : public OverlayText, public Tickable
+    {
+    public:
+        DebugRTRText();
+        ~DebugRTRText();
+
+        virtual void tick(float dt);
+    };
+}
+#endif /* _DebugRTRText_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDBar.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDBar.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDBar.cc	(revision 1801)
@@ -0,0 +1,179 @@
+/*
+ *   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:
+ *      Yuning Chai
+ *   Co-authors:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDBar.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Convert.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+
+namespace orxonox
+{
+    CreateFactory(BarColour);
+
+    BarColour::BarColour()
+        : position_(0.0)
+    {
+        RegisterObject(BarColour);
+    }
+
+    void BarColour::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(BarColour, XMLPort, xmlElement, mode);
+
+        XMLPortParam(BarColour, "colour", setColour, getColour, xmlElement, mode)
+            .defaultValues(ColourValue(1.0, 1.0, 1.0, 1.0));
+        XMLPortParam(BarColour, "position", setPosition, getPosition, xmlElement, mode).defaultValues(0.0f);
+    }
+
+
+    unsigned int HUDBar::materialcount_s = 0;
+
+    HUDBar::HUDBar()
+        : bar_(0)
+        , textureUnitState_(0)
+    {
+        RegisterObject(HUDBar);
+    }
+
+    HUDBar::~HUDBar()
+    {
+        if (this->bar_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->bar_);
+    }
+
+    void HUDBar::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDBar, XMLPort, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            // create new material
+            std::string materialname = "barmaterial" + getConvertedValue<unsigned int, std::string>(materialcount_s++);
+            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialname, "General");
+            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+            this->textureUnitState_ = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+            this->textureUnitState_->setTextureName("bar2.tga");
+            // use the default colour
+            this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, ColourValue(0.2, 0.7, 0.2));
+
+            this->bar_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("Panel", "HUDBar_bar_" + getUniqueNumberStr()));
+            this->bar_->setMaterialName(materialname);
+            this->background_->addChild(bar_);
+        }
+
+        XMLPortParam(HUDBar, "initialValue", setValue,       getValue,       xmlElement, mode).defaultValues(0.4567654f);
+        XMLPortParam(HUDBar, "rightToLeft",  setRightToLeft, getRightToLeft, xmlElement, mode).defaultValues(false);
+        XMLPortParam(HUDBar, "autoColour",   setAutoColour,  getAutoColour,  xmlElement, mode).defaultValues(true);
+        XMLPortObject(HUDBar, BarColour, "", addColour, getColour, xmlElement, mode, false, true);
+    }
+
+    void HUDBar::valueChanged()
+    {
+        if (this->autoColour_ && this->textureUnitState_)
+        {
+            // set colour
+            if (this->colours_.size() > 0)
+            {
+                ColourValue colour1, colour2 = (*this->colours_.rbegin()).second;
+                float value1, value2 = (*this->colours_.rbegin()).first;
+                for (std::map<float, ColourValue>::reverse_iterator it = this->colours_.rbegin(); it != this->colours_.rend(); ++it)
+                {
+                    colour1 = colour2;
+                    value1 = value2;
+                    colour2 = (*it).second;
+                    value2 = (*it).first;
+
+                    if (value2 < this->value_)
+                        break;
+                }
+
+                if (value2 > this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour2);
+                }
+                else if (value1 < this->value_)
+                {
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1);
+                }
+                else
+                {
+                    //float interpolationfactor = (this->value_ - value2) / (value1 - value2);
+                    float interpolationfactor = interpolateSmooth((this->value_ - value2) / (value1 - value2), 0.0f, 1.0f);
+                    this->textureUnitState_->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour1 * interpolationfactor + colour2 * (1 - interpolationfactor));
+                }
+            }
+        }
+
+        // set value
+        if (this->right2Left_)
+        {
+            // backward casew
+            this->bar_->setPosition(0.06f + 0.88f * (1 - this->value_), 0.0f);
+            this->bar_->setDimensions(0.88f * this->value_, 1.0f);
+        }
+        else
+        {
+            // default case
+            this->bar_->setPosition(0.06f, 0.0f);
+            this->bar_->setDimensions(0.88f * this->value_, 1.0f);
+        }
+        if (this->value_ != 0)
+            this->bar_->setTiling(this->value_, 1.0);
+    }
+
+    void HUDBar::addColour(BarColour* colour)
+    {
+        float value = clamp<float>(colour->getPosition(), 0.0, 1.0);
+        this->colours_[value] = colour->getColour();
+
+        this->barColours_.push_back(colour);
+    }
+
+    BarColour* HUDBar::getColour(unsigned int index)
+    {
+        if (index < this->barColours_.size())
+            return barColours_[index];
+        else
+            return 0;
+    }
+
+    void HUDBar::clearColours()
+    {
+        this->colours_.clear();
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDBar.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDBar.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDBar.h	(revision 1801)
@@ -0,0 +1,101 @@
+/*
+ *   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:
+ *      Yuning Chai
+ *   Co-authors:
+ *      Felix Schulthess
+ *      Fabian 'x3n' Landau
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDBar_H__
+#define _HUDBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <map>
+#include <OgrePrerequisites.h>
+#include "util/Math.h"
+#include "overlays/OrxonoxOverlay.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BarColour : public BaseObject
+    {
+    public:
+        BarColour();
+        ~BarColour() { }
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        void setColour(const ColourValue& colour) { this->colour_ = colour; }
+        const ColourValue& getColour() const { return this->colour_; }
+
+        void setPosition(float pos) { this->position_ = pos; }
+        float getPosition() const    { return this->position_; }
+
+    private:
+        ColourValue colour_;
+        float position_;
+    };
+
+
+    class _OrxonoxExport HUDBar : public OrxonoxOverlay
+    {
+    public:
+        HUDBar();
+        virtual ~HUDBar();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+        void clearColours();
+
+        void setRightToLeft(bool r2l) { this->right2Left_ = r2l; this->valueChanged(); }
+        bool getRightToLeft() const   { return this->right2Left_; }
+
+        void setValue(float value)    { this->value_ = clamp(value, 0.0f, 1.0f); this->valueChanged(); }
+        float getValue() const        { return this->value_; }
+
+        void setAutoColour(bool val)  { this->autoColour_ = val; this->valueChanged(); }
+        bool getAutoColour() const    { return this->autoColour_; }
+
+    protected:
+        virtual void valueChanged();
+
+    private:
+        void addColour(BarColour* colour);
+        BarColour* getColour(unsigned int index);
+
+        bool right2Left_;
+        bool autoColour_;                   //!< whether bar changes colour automatically
+        float value_;                       //!< progress of bar
+
+        Ogre::PanelOverlayElement* bar_;
+        Ogre::TextureUnitState* textureUnitState_;
+        std::map<float, ColourValue> colours_;
+        std::vector<BarColour*> barColours_;
+
+        static unsigned int materialcount_s;
+    };
+}
+#endif /* _HUDBar_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDNavigation.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDNavigation.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDNavigation.cc	(revision 1801)
@@ -0,0 +1,274 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDNavigation.h"
+
+#include <OgreOverlayManager.h>
+#include <OgreTextAreaOverlayElement.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "util/String.h"
+#include "util/Convert.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/SpaceShip.h"
+#include "objects/Projectile.h"
+#include "objects/CameraHandler.h"
+#include "Radar.h"
+
+namespace orxonox
+{
+    CreateFactory(HUDNavigation);
+
+    HUDNavigation::HUDNavigation()
+        : navMarker_(0)
+        , aimMarker_(0)
+        , navText_(0)
+    {
+        RegisterObject(HUDNavigation);
+    }
+
+    HUDNavigation::~HUDNavigation()
+    {
+        if (this->navMarker_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navMarker_);
+        if (this->navText_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->navText_);
+        if (this->aimMarker_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->aimMarker_);
+    }
+
+    void HUDNavigation::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDNavigation, XMLPort, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            // create nav text
+            navText_ = static_cast<Ogre::TextAreaOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("TextArea", "HUDNavigation_navText_" + getUniqueNumberStr()));
+
+            // create nav marker
+            navMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("Panel", "HUDNavigation_navMarker_" + getUniqueNumberStr()));
+            navMarker_->setMaterialName("Orxonox/NavArrows");
+            wasOutOfView_ = true; // just to ensure the material is changed right the first time..
+
+            // create aim marker
+            aimMarker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("Panel", "HUDNavigation_aimMarker_" + getUniqueNumberStr()));
+            aimMarker_->setMaterialName("Orxonox/NavCrosshair");
+
+            background_->addChild(navMarker_);
+            background_->addChild(aimMarker_);
+            background_->addChild(navText_);
+
+            // hide at first
+            this->setVisible(false);
+        }
+
+        XMLPortParam(HUDNavigation, "font",     setFont,     getFont,     xmlElement, mode).defaultValues("Monofur");
+        XMLPortParam(HUDNavigation, "textSize", setTextSize, getTextSize, xmlElement, mode).defaultValues(0.05f);
+        XMLPortParam(HUDNavigation, "navMarkerSize", setNavMarkerSize, getNavMarkerSize, xmlElement, mode)
+            .defaultValues(0.05f);
+        XMLPortParam(HUDNavigation, "aimMarkerSize", setAimMarkerSize, getAimMarkerSize, xmlElement, mode)
+            .defaultValues(0.04f);
+    }
+
+    void HUDNavigation::setFont(const std::string& font)
+    {
+        if (this->navText_ && font != "")
+            this->navText_->setFontName(font);
+    }
+
+    const std::string& HUDNavigation::getFont() const
+    {
+        if (this->navText_)
+            return this->navText_->getFontName();
+        else
+            return blankString;
+    }
+
+    void HUDNavigation::setTextSize(float size)
+    {
+        if (this->navText_ && size >= 0.0f)
+            this->navText_->setCharHeight(size);
+    }
+
+    float HUDNavigation::getTextSize() const
+    {
+        if (this->navText_)
+            return this->navText_->getCharHeight();
+        else
+            return 0.0f;
+    }
+
+    void HUDNavigation::tick(float dt)
+    {
+        if (!Radar::getInstance().getFocus())
+        {
+            this->overlay_->hide();
+            return;
+        }
+        else
+        {
+            this->overlay_->show();
+        }
+
+        // set text
+        int dist = (int) getDist2Focus();
+        navText_->setCaption(convertToString(dist));
+        float textLength = convertToString(dist).size() * navText_->getCharHeight() * 0.3;
+
+        Ogre::Camera* navCam = SpaceShip::getLocalShip()->getCamera()->cam_;
+        Matrix4 transformationMatrix = navCam->getProjectionMatrix() * navCam->getViewMatrix();
+        // transform to screen coordinates
+        Vector3 pos = transformationMatrix * Radar::getInstance().getFocus()->getWorldPosition();
+
+        bool outOfView;
+        if (pos.z > 1.0)
+        {
+            // z > 1.0 means that the object is behind the camera
+            outOfView = true;
+            // we have to switch all coordinates (if you don't know why,
+            // try linear algebra lectures, because I can't explain..)
+            pos.x = -pos.x;
+            pos.y = -pos.y;
+        }
+        else
+            outOfView = pos.x < -1.0 || pos.x > 1.0 || pos.y < -1.0 || pos.y > 1.0;
+
+        if (outOfView)
+        {
+            // object is not in view
+            aimMarker_->hide();
+
+            if (!wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavArrows");
+                wasOutOfView_ = true;
+            }
+
+            if (pos.x < pos.y)
+            {
+                if (pos.y > -pos.x)
+                {
+                    // up
+                    float position = pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 0.0);
+                    navMarker_->setUV(0.5, 0.0, 1.0, 0.5);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(navMarker_->getHeight());
+                }
+                else
+                {
+                    // left
+                    float position = pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(0.0, (position - navMarker_->getWidth()) * 0.5);
+                    navMarker_->setUV(0.0, 0.0, 0.5, 0.5);
+                    navText_->setLeft(navMarker_->getWidth() + 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+            else
+            {
+                if (pos.y < -pos.x)
+                {
+                    // down
+                    float position = -pos.x / pos.y + 1.0;
+                    navMarker_->setPosition((position - navMarker_->getWidth()) * 0.5, 1.0 - navMarker_->getHeight());
+                    navMarker_->setUV(0.0, 0.5, 0.5, 1.0);
+                    navText_->setLeft((position - textLength) * 0.5);
+                    navText_->setTop(1.0 - navMarker_->getHeight() - navText_->getCharHeight());
+                }
+                else
+                {
+                    // right
+                    float position = -pos.y / pos.x + 1.0;
+                    navMarker_->setPosition(1.0 - navMarker_->getWidth(), (position - navMarker_->getHeight()) * 0.5);
+                    navMarker_->setUV(0.5, 0.5, 1.0, 1.0);
+                    navText_->setLeft(1.0 - navMarker_->getWidth() - textLength - 0.01);
+                    navText_->setTop((position - navText_->getCharHeight()) * 0.5);
+                }
+            }
+        }
+        else
+        {
+            // object is in view
+
+            Vector3 aimpos = transformationMatrix * getPredictedPosition(SpaceShip::getLocalShip()->getPosition(),
+                    Projectile::getSpeed(), Radar::getInstance().getFocus()->getWorldPosition(), Radar::getInstance().getFocus()->getOrientedVelocity());
+
+            if (wasOutOfView_)
+            {
+                navMarker_->setMaterialName("Orxonox/NavTDC");
+                wasOutOfView_ = false;
+            }
+
+            // object is in view
+            navMarker_->setUV(0.0, 0.0, 1.0, 1.0);
+            navMarker_->setLeft((pos.x + 1.0 - navMarker_->getWidth()) * 0.5);
+            navMarker_->setTop((-pos.y + 1.0 - navMarker_->getHeight()) * 0.5);
+
+            aimMarker_->show();
+            aimMarker_->setLeft((aimpos.x + 1.0 - aimMarker_->getWidth()) * 0.5);
+            aimMarker_->setTop((-aimpos.y + 1.0 - aimMarker_->getHeight()) * 0.5);
+
+            navText_->setLeft((pos.x + 1.0 + navMarker_->getWidth()) * 0.5);
+            navText_->setTop((-pos.y + 1.0 + navMarker_->getHeight()) * 0.5);
+        }
+    }
+
+    float HUDNavigation::getDist2Focus() const
+    {
+        if (Radar::getInstance().getFocus())
+            return (Radar::getInstance().getFocus()->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+        else
+            return 0;
+    }
+
+    /**
+    @brief Overridden method of OrxonoxOverlay. Usually the entire overlay
+           scales with scale(). Here we obviously have to adjust this.
+    */
+    void HUDNavigation::sizeChanged()
+    {
+        // use size to compensate for apspect ratio if enabled.
+        float xScale = this->getActualSize().x;
+        float yScale = this->getActualSize().y;
+        if (this->navMarker_)
+            navMarker_->setDimensions(navMarkerSize_ * xScale, navMarkerSize_ * yScale);
+        if (this->aimMarker_)
+            aimMarker_->setDimensions(aimMarkerSize_ * xScale, aimMarkerSize_ * yScale);
+        if (this->navText_)
+            navText_->setCharHeight(navText_->getCharHeight() * yScale);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDNavigation.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDNavigation.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDNavigation.h	(revision 1801)
@@ -0,0 +1,80 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDNavigation_H__
+#define _HUDNavigation_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <OgrePrerequisites.h>
+#include "overlays/OrxonoxOverlay.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUDNavigation : public OrxonoxOverlay, public Tickable
+    {
+    public:
+        HUDNavigation();
+        ~HUDNavigation();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+        virtual void tick(float dt);
+
+    private:
+        void sizeChanged();
+        void angleChanged() { }
+        void positionChanged() { }
+
+        // XMLPort accessors
+        void setNavMarkerSize(float size) { this->navMarkerSize_ = size; this->sizeChanged(); }
+        float getNavMarkerSize() const    { return this->navMarkerSize_; }
+
+        void setAimMarkerSize(float size) { this->aimMarkerSize_ = size; this->sizeChanged(); }
+        float getAimMarkerSize() const    { return this->aimMarkerSize_; }
+
+        void setTextSize(float size);
+        float getTextSize() const;
+
+        void setFont(const std::string& font);
+        const std::string& getFont() const;
+
+        void updateMarker();
+        void updateFocus();
+        float getDist2Focus() const;
+
+        Ogre::PanelOverlayElement* navMarker_;      //!< the panel used to show the arrow and the target marker
+        float navMarkerSize_;                       //!< One paramter size of the navigation marker
+        Ogre::PanelOverlayElement* aimMarker_;      //!< Panel used to show the aim Marker
+        float aimMarkerSize_;                       //!< One paramter size of the aim marker
+        Ogre::TextAreaOverlayElement* navText_;     //!< Text overlay to display the target distance
+        bool wasOutOfView_;                         //!< Performance booster variable: setMaterial is not cheap
+    };
+}
+
+#endif /* _HUDNavigation_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDRadar.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDRadar.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDRadar.cc	(revision 1801)
@@ -0,0 +1,155 @@
+/*
+ *   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:
+ *      Yuning Chai
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDRadar.h"
+
+#include <OgreOverlayManager.h>
+#include <OgrePanelOverlayElement.h>
+
+#include "util/Math.h"
+#include "core/ConsoleCommand.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "objects/SpaceShip.h"
+#include "objects/WorldEntity.h"
+#include "tools/TextureGenerator.h"
+#include "Radar.h"
+
+namespace orxonox
+{
+    CreateFactory(HUDRadar);
+
+    HUDRadar::HUDRadar()
+        : marker_(0)
+    {
+        RegisterObject(HUDRadar);
+    }
+
+    HUDRadar::~HUDRadar()
+    {
+        if (this->marker_)
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(this->marker_);
+        for (std::vector<Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.begin();
+            it != this->radarDots_.end(); ++it)
+        {
+            Ogre::OverlayManager::getSingleton().destroyOverlayElement(*it);
+        }
+    }
+
+    void HUDRadar::XMLPort(Element& xmlElement, XMLPort::Mode mode)
+    {
+        SUPER(HUDRadar, XMLPort, xmlElement, mode);
+
+        if (mode == XMLPort::LoadObject)
+        {
+            marker_ = static_cast<Ogre::PanelOverlayElement*>(Ogre::OverlayManager::getSingleton()
+                .createOverlayElement("Panel", "HUDRadar_marker_" + getUniqueNumberStr()));
+            marker_->setMaterialName("Orxonox/RadarMarker");
+            overlay_->add2D(marker_);
+            marker_->hide();
+        }
+
+        XMLPortParam(HUDRadar, "sensitivity", setRadarSensitivity, getRadarSensitivity, xmlElement, mode)
+            .defaultValues(1.0f);
+        XMLPortParam(HUDRadar, "halfDotSizeDistance", setHalfDotSizeDistance, getHalfDotSizeDistance,
+            xmlElement, mode).defaultValues(3000.0f);
+        XMLPortParam(HUDRadar, "maximumDotSize", setMaximumDotSize, getMaximumDotSize, xmlElement, mode)
+            .defaultValues(0.1f);
+
+        shapeMaterials_[RadarViewable::Dot]      = "RadarSquare.tga";
+        shapeMaterials_[RadarViewable::Triangle] = "RadarSquare.tga";
+        shapeMaterials_[RadarViewable::Square]   = "RadarSquare.tga";
+    }
+
+    void HUDRadar::displayObject(RadarViewable* object, bool bIsMarked)
+    {
+        const WorldEntity* wePointer = object->getWorldEntity();
+
+        // Just to be sure that we actually have a WorldEntity.
+        // We could do a dynamic_cast, but that would be a lot slower.
+        if (!wePointer)
+        {
+            CCOUT(4) << "Cannot display a non-WorldEntitiy on the radar" << std::endl;
+            return;
+        }
+
+        // try to find a panel already created
+        Ogre::PanelOverlayElement* panel;
+        //std::map<RadarViewable*, Ogre::PanelOverlayElement*>::iterator it = this->radarDots_.find(object);
+        if (itRadarDots_ == this->radarDots_.end())
+        {
+            // we have to create a new entry
+            panel = static_cast<Ogre::PanelOverlayElement*>(
+                Ogre::OverlayManager::getSingleton().createOverlayElement("Panel", "RadarDot" + getUniqueNumberStr()));
+            radarDots_.push_back(panel);
+            // get right material
+            panel->setMaterialName(TextureGenerator::getMaterialName(
+                shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour()));
+            this->overlay_->add2D(panel);
+            this->itRadarDots_ = this->radarDots_.end();
+        }
+        else
+        {
+            panel = *itRadarDots_;
+            ++itRadarDots_;
+            std::string materialName = TextureGenerator::getMaterialName(
+                shapeMaterials_[object->getRadarObjectType()], object->getRadarObjectColour());
+            if (materialName != panel->getMaterialName())
+                panel->setMaterialName(materialName);
+        }
+        panel->show();
+
+        // set size to fit distance...
+        float distance = (wePointer->getWorldPosition() - SpaceShip::getLocalShip()->getPosition()).length();
+        // calculate the size with 1/distance dependency for simplicity (instead of exp(-distance * lambda)
+        float size = maximumDotSize_ * halfDotSizeDistance_ / (halfDotSizeDistance_ + distance);
+        panel->setDimensions(size, size);
+
+        // calc position on radar...
+        Vector2 coord = get2DViewcoordinates(SpaceShip::getLocalShip()->getPosition(), SpaceShip::getLocalShip()->getDir(), SpaceShip::getLocalShip()->getOrth(), wePointer->getWorldPosition());
+        coord *= Ogre::Math::PI / 3.5; // small adjustment to make it fit the texture
+        panel->setPosition((1.0 + coord.x - size) * 0.5, (1.0 - coord.y - size) * 0.5);
+
+        if (bIsMarked)
+        {
+            this->marker_->show();
+            this->marker_->setDimensions(size * 1.5, size * 1.5);
+            this->marker_->setPosition((1.0 + coord.x - size * 1.5) * 0.5, (1.0 - coord.y - size * 1.5) * 0.5);
+        }
+    }
+
+    void HUDRadar::radarTick(float dt)
+    {
+        for (itRadarDots_ = radarDots_.begin(); itRadarDots_ != radarDots_.end(); ++itRadarDots_)
+            (*itRadarDots_)->hide();
+        this->itRadarDots_ = this->radarDots_.begin();
+        this->marker_->hide();
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDRadar.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDRadar.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDRadar.h	(revision 1801)
@@ -0,0 +1,81 @@
+/*
+ *   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:
+ *      Yuning Chai
+ *      Felix Schulthess
+ *   Co-authors:
+ *      Reto Grieder
+ *
+ */
+
+#ifndef _HUDRadar_H__
+#define _HUDRadar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <vector>
+#include <map>
+#include <OgrePrerequisites.h>
+#include "overlays/OrxonoxOverlay.h"
+#include "RadarListener.h"
+#include "RadarViewable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUDRadar : public OrxonoxOverlay, public RadarListener
+    {
+    public:
+        HUDRadar();
+        ~HUDRadar();
+
+        virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode);
+
+    private:
+        // XML accessors
+        float getHalfDotSizeDistance() const { return this->halfDotSizeDistance_; }
+        void setHalfDotSizeDistance(float distance) { this->halfDotSizeDistance_ = distance; }
+
+        float getMaximumDotSize() const { return this->maximumDotSize_; }
+        void setMaximumDotSize(float size) { this->maximumDotSize_ = size; }
+
+        float getRadarSensitivity() const { return this->sensitivity_; }
+        // used also by RadarListener interface!
+        void setRadarSensitivity(float sensitivity) { this->sensitivity_ = sensitivity; }
+
+        // RadarListener interface
+        void displayObject(RadarViewable* viewable, bool bIsMarked);
+        void radarTick(float dt);
+
+        std::map<RadarViewable::Shape, std::string> shapeMaterials_;
+
+        std::vector<Ogre::PanelOverlayElement*> radarDots_;
+        std::vector<Ogre::PanelOverlayElement*>::iterator itRadarDots_;
+        Ogre::PanelOverlayElement* marker_;
+
+        float halfDotSizeDistance_;
+        float maximumDotSize_;
+
+        float sensitivity_;
+    };
+}
+
+#endif /* _HUDRadar_H__ */
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDSpeedBar.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDSpeedBar.cc	(revision 1801)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Felix Schulthess
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "HUDSpeedBar.h"
+#include "core/CoreIncludes.h"
+#include "objects/SpaceShip.h"
+
+namespace orxonox
+{
+    CreateFactory(HUDSpeedBar);
+
+    HUDSpeedBar::HUDSpeedBar()
+    {
+        RegisterObject(HUDSpeedBar);
+
+    }
+
+    HUDSpeedBar::~HUDSpeedBar()
+    {
+    }
+
+    void HUDSpeedBar::tick(float dt)
+    {
+        SpaceShip* ship = SpaceShip::getLocalShip();
+        if (ship)
+        {
+            float v = ship->getVelocity().length();
+            float value = v / ship->getMaxSpeed();
+            if (value != this->getValue())
+                this->setValue(value);
+        }
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/overlays/hud/HUDSpeedBar.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/overlays/hud/HUDSpeedBar.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/overlays/hud/HUDSpeedBar.h	(revision 1801)
@@ -0,0 +1,49 @@
+/*
+ *   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:
+ *      Felix Schulthess
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _HUDSpeedBar_H__
+#define _HUDSpeedBar_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include "HUDBar.h"
+#include "objects/Tickable.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport HUDSpeedBar : public HUDBar, public Tickable
+    {
+    public:
+        HUDSpeedBar();
+        ~HUDSpeedBar();
+
+        virtual void tick(float dt);
+    };
+}
+#endif /* _HUDSpeedBar_H__ */
Index: /code/branches/ceguilua/src/orxonox/tolua/tolua.pkg
===================================================================
--- /code/branches/ceguilua/src/orxonox/tolua/tolua.pkg	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tolua/tolua.pkg	(revision 1801)
@@ -0,0 +1,1 @@
+$cfile "../../src/orxonox/gui/GUIManager.h"
Index: /code/branches/ceguilua/src/orxonox/tools/BillboardSet.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/BillboardSet.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/BillboardSet.cc	(revision 1801)
@@ -0,0 +1,89 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "BillboardSet.h"
+
+#include <sstream>
+
+#include <OgreSceneManager.h>
+
+#include "GraphicsEngine.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+    unsigned int BillboardSet::billboardSetCounter_s = 0;
+
+    BillboardSet::BillboardSet()
+    {
+        this->billboardSet_ = 0;
+    }
+
+    void BillboardSet::setBillboardSet(const std::string& file, int count)
+    {
+        std::ostringstream name;
+        name << (BillboardSet::billboardSetCounter_s++);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_->createBillboard(Vector3::ZERO);
+        this->billboardSet_->setMaterialName(file);
+    }
+
+    void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, int count)
+    {
+        std::ostringstream name;
+        name << (BillboardSet::billboardSetCounter_s++);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_->createBillboard(Vector3::ZERO, colour);
+        this->billboardSet_->setMaterialName(file);
+    }
+
+    void BillboardSet::setBillboardSet(const std::string& file, const Vector3& position, int count)
+    {
+        std::ostringstream name;
+        name << (BillboardSet::billboardSetCounter_s++);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_->createBillboard(position);
+        this->billboardSet_->setMaterialName(file);
+    }
+
+    void BillboardSet::setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count)
+    {
+        std::ostringstream name;
+        name << (BillboardSet::billboardSetCounter_s++);
+        this->billboardSet_ = GraphicsEngine::getInstance().getLevelSceneManager()->createBillboardSet("Billboard" + name.str(), count);
+        this->billboardSet_->createBillboard(position, colour);
+        this->billboardSet_->setMaterialName(file);
+    }
+
+    BillboardSet::~BillboardSet()
+    {
+        if (this->billboardSet_)
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyBillboardSet(this->billboardSet_);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/BillboardSet.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/BillboardSet.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/BillboardSet.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _BillboardSet_H__
+#define _BillboardSet_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgreBillboardSet.h>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport BillboardSet
+    {
+        public:
+            BillboardSet();
+            ~BillboardSet();
+            void setBillboardSet(const std::string& file, int count = 1);
+            void setBillboardSet(const std::string& file, const ColourValue& colour, int count = 1);
+            void setBillboardSet(const std::string& file, const Vector3& position, int count = 1);
+            void setBillboardSet(const std::string& file, const ColourValue& colour, const Vector3& position, int count = 1);
+
+            inline Ogre::BillboardSet* getBillboardSet()
+                { return this->billboardSet_; }
+
+            inline const std::string& getName() const
+                { return this->billboardSet_->getName(); }
+
+            inline void setVisible(bool visible)
+                { this->billboardSet_->setVisible(visible); }
+            inline bool getVisible() const
+                { return this->billboardSet_->getVisible(); }
+
+        private:
+            static unsigned int billboardSetCounter_s;
+            Ogre::BillboardSet* billboardSet_;
+    };
+}
+
+#endif /* _BillboardSet_H__ */
Index: /code/branches/ceguilua/src/orxonox/tools/Light.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/Light.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/Light.cc	(revision 1801)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Light.h"
+
+#include <sstream>
+
+#include <OgreSceneManager.h>
+
+#include "GraphicsEngine.h"
+
+namespace orxonox
+{
+    unsigned int Light::lightCounter_s = 0;
+
+    Light::Light()
+    {
+        this->light_ = 0;
+    }
+
+    void Light::setLight(Ogre::Light::LightTypes type, const ColourValue& diffuse, const ColourValue& specular)
+    {
+        std::ostringstream name;
+        name << (Light::lightCounter_s++);
+        this->light_ = GraphicsEngine::getInstance().getLevelSceneManager()->createLight("Light" + name.str());
+        this->light_->setType(type);
+        this->light_->setDiffuseColour(diffuse);
+        this->light_->setSpecularColour(specular);
+    }
+
+    Light::~Light()
+    {
+        if (this->light_)
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyLight(this->light_);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/Light.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/Light.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/Light.h	(revision 1801)
@@ -0,0 +1,61 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Light_H__
+#define _Light_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgreLight.h>
+
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport Light
+    {
+        public:
+            Light();
+            ~Light();
+            void setLight(Ogre::Light::LightTypes type = Ogre::Light::LT_POINT, const ColourValue& diffuse = ColourValue(1.0, 1.0, 1.0), const ColourValue& specular = ColourValue(1.0, 1.0, 1.0));
+
+            inline Ogre::Light* getLight()
+                { return this->light_; }
+
+            inline const std::string& getName() const
+                { return this->light_->getName(); }
+
+        private:
+            static unsigned int lightCounter_s;
+            Ogre::Light* light_;
+    };
+}
+
+#endif /* _Light_H__ */
Index: /code/branches/ceguilua/src/orxonox/tools/Mesh.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/Mesh.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/Mesh.cc	(revision 1801)
@@ -0,0 +1,59 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "OrxonoxStableHeaders.h"
+#include "Mesh.h"
+
+#include <sstream>
+#include <OgreSceneManager.h>
+#include "GraphicsEngine.h"
+#include "Settings.h"
+
+namespace orxonox
+{
+    unsigned int Mesh::meshCounter_s = 0;
+
+    Mesh::Mesh() :
+      entity_(0)
+    {
+    }
+
+    void Mesh::setMesh(const std::string& file)
+    {
+        std::ostringstream name;
+        name << (Mesh::meshCounter_s++);
+        if (Settings::showsGraphics())
+            this->entity_ = GraphicsEngine::getInstance().getLevelSceneManager()->createEntity("Mesh" + name.str(), file);
+    }
+
+    Mesh::~Mesh()
+    {
+        if (this->entity_ && Settings::showsGraphics())
+            GraphicsEngine::getInstance().getLevelSceneManager()->destroyEntity(this->entity_);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/Mesh.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/Mesh.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/Mesh.h	(revision 1801)
@@ -0,0 +1,64 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Mesh_H__
+#define _Mesh_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+
+#include <OgreEntity.h>
+
+namespace orxonox
+{
+    class _OrxonoxExport Mesh
+    {
+        public:
+            Mesh();
+            ~Mesh();
+            void setMesh(const std::string& file);
+
+            inline Ogre::Entity* getEntity()
+                { return this->entity_; }
+
+            inline const std::string& getName() const
+                { return this->entity_->getName(); }
+
+            inline void setVisible(bool visible)
+                { if (this->entity_) this->entity_->setVisible(visible); }
+            inline bool getVisible() const
+                { if (this->entity_) return this->entity_->getVisible(); else return false; }
+
+        private:
+            static unsigned int meshCounter_s;
+            Ogre::Entity* entity_;
+    };
+}
+
+#endif /* _Mesh_H__ */
Index: /code/branches/ceguilua/src/orxonox/tools/ParticleInterface.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/ParticleInterface.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/ParticleInterface.cc	(revision 1801)
@@ -0,0 +1,190 @@
+/*
+*   ORXONOX - the hottest 3D action shooter ever to exist
+*
+*
+*   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:
+*      ...
+*   Co-authors:
+*      ...
+*
+*/
+
+/**
+* @file ParticleInterface.cc
+* @brief class to control praticle effects
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "ParticleInterface.h"
+
+#include <OgreParticleSystem.h>
+#include <OgreParticleEmitter.h>
+#include <OgreSceneManager.h>
+
+#include "GraphicsEngine.h"
+#include "core/CoreIncludes.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+  unsigned int ParticleInterface::counter_s = 0;
+  ParticleInterface* ParticleInterface::currentParticleInterface_s = 0;
+
+  ParticleInterface::ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel)
+  {
+    RegisterRootObject(ParticleInterface);
+
+    this->sceneNode_ = 0;
+    this->bEnabled_ = true;
+    this->detaillevel_ = (unsigned int)detaillevel;
+    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::getInstance().getDetailLevelParticle() < (unsigned int)this->detaillevel_)
+    {
+      this->bVisible_ = false;
+      this->updateVisibility();
+    }
+    else
+    {
+      this->bVisible_ = true;
+    }
+  }
+
+  ParticleInterface::~ParticleInterface()
+  {
+    this->particleSystem_->removeAllEmitters();
+    GraphicsEngine::getInstance().getLevelSceneManager()->destroyParticleSystem(particleSystem_);
+  }
+
+  void ParticleInterface::addToSceneNode(Ogre::SceneNode* sceneNode)
+  {
+    this->sceneNode_ = sceneNode;
+    this->sceneNode_->attachObject(this->particleSystem_);
+  }
+
+  void ParticleInterface::detachFromSceneNode()
+  {
+    if (this->sceneNode_)
+    {
+      this->sceneNode_->detachObject(this->particleSystem_);
+      this->sceneNode_ = 0;
+    }
+  }
+
+  Ogre::ParticleEmitter* ParticleInterface::createNewEmitter()
+  {
+    if (this->particleSystem_->getNumEmitters() > 0)
+    {
+      Ogre::ParticleEmitter* newemitter = this->particleSystem_->addEmitter(this->particleSystem_->getEmitter(0)->getType());
+      this->particleSystem_->getEmitter(0)->copyParametersTo(newemitter);
+      return newemitter;
+    }
+    else
+      return 0;
+  }
+  Ogre::ParticleEmitter* ParticleInterface::getEmitter(unsigned int emitterNr) const
+  {
+    if (emitterNr < this->particleSystem_->getNumEmitters())
+      return this->particleSystem_->getEmitter(emitterNr);
+    else
+      return 0;
+  }
+  void ParticleInterface::removeEmitter(unsigned int emitterNr)
+  {
+    if (emitterNr < this->particleSystem_->getNumEmitters())
+      this->particleSystem_->removeEmitter(emitterNr);
+  }
+  void ParticleInterface::removeAllEmitters()
+  {
+    this->particleSystem_->removeAllEmitters();
+  }
+  unsigned int ParticleInterface::getNumEmitters() const
+  {
+    return this->particleSystem_->getNumEmitters();
+  }
+
+  Ogre::ParticleAffector* ParticleInterface::addAffector(const std::string& name)
+  {
+    return this->particleSystem_->addAffector(name);
+  }
+  Ogre::ParticleAffector* ParticleInterface::getAffector(unsigned int affectorNr) const
+  {
+    if (affectorNr < this->particleSystem_->getNumAffectors())
+      return this->particleSystem_->getAffector(affectorNr);
+    else
+      return 0;
+  }
+  void ParticleInterface::removeAffector(unsigned int affectorNr)
+  {
+    if (affectorNr < this->particleSystem_->getNumAffectors())
+      this->particleSystem_->removeAffector(affectorNr);
+  }
+  void ParticleInterface::removeAllAffectors()
+  {
+    this->particleSystem_->removeAllAffectors();
+  }
+  unsigned int ParticleInterface::getNumAffectors() const
+  {
+    return this->particleSystem_->getNumAffectors();
+  }
+
+  void ParticleInterface::setEnabled(bool enable)
+  {
+    this->bEnabled_ = enable;
+    this->updateVisibility();
+  }
+
+  void ParticleInterface::detailLevelChanged(unsigned int newlevel)
+  {
+    if (newlevel >= (unsigned int)this->detaillevel_)
+      this->bVisible_ = true;
+    else
+      this->bVisible_ = false;
+
+    this->updateVisibility();
+  }
+
+  void ParticleInterface::updateVisibility()
+  {
+    for (unsigned int i = 0; i < this->particleSystem_->getNumEmitters(); i++)
+      this->particleSystem_->getEmitter(i)->setEnabled(this->bEnabled_ && this->bVisible_);
+  }
+
+  void ParticleInterface::setSpeedFactor(float factor)
+  {
+    //this->particleSystem_->setSpeedFactor(Orxonox::getInstance().getTimeFactor() * factor);
+    this->particleSystem_->setSpeedFactor(1.0f * factor);
+  }
+  float ParticleInterface::getSpeedFactor() const
+  {
+    //return (this->particleSystem_->getSpeedFactor() / Orxonox::getInstance().getTimeFactor());
+    return (this->particleSystem_->getSpeedFactor() / 1.0f);
+  }
+
+  bool ParticleInterface::getKeepParticlesInLocalSpace() const
+  {
+    return this->particleSystem_->getKeepParticlesInLocalSpace();
+  }
+  void ParticleInterface::setKeepParticlesInLocalSpace(bool keep)
+  {
+    this->particleSystem_->setKeepParticlesInLocalSpace(keep);
+  }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/ParticleInterface.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/ParticleInterface.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/ParticleInterface.h	(revision 1801)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ParticleInterface_H__
+#define _ParticleInterface_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <OgreParticleEmitter.h>
+
+#include "core/OrxonoxClass.h"
+#include "util/Math.h"
+
+#define getAllEmitters() \
+  storeThisAsCurrentParticleInterface(); \
+  for (unsigned int i = 0; i < ParticleInterface::getCurrentParticleInterface()->getNumEmitters(); ++i) \
+    ParticleInterface::getCurrentParticleInterface()->getEmitter(i)
+
+namespace orxonox
+{
+  class _OrxonoxExport ParticleInterface : public OrxonoxClass
+  {
+    public:
+      ParticleInterface(const std::string& templateName, LODParticle::LOD detaillevel);
+      ~ParticleInterface();
+
+      inline Ogre::ParticleSystem* getParticleSystem() const
+        { return this->particleSystem_; }
+
+      void addToSceneNode(Ogre::SceneNode* sceneNode);
+      void detachFromSceneNode();
+
+      Ogre::ParticleEmitter* createNewEmitter();
+      Ogre::ParticleEmitter* getEmitter(unsigned int emitterNr) const;
+      void removeEmitter(unsigned int emitterNr);
+      void removeAllEmitters();
+      unsigned int getNumEmitters() const;
+
+      Ogre::ParticleAffector* addAffector(const std::string& name);
+      Ogre::ParticleAffector* getAffector(unsigned int affectorNr) const;
+      void removeAffector(unsigned int affectorNr);
+      void removeAllAffectors();
+      unsigned int getNumAffectors() const;
+
+      float getSpeedFactor() const;
+      void setSpeedFactor(float factor);
+      bool getKeepParticlesInLocalSpace() const;
+      void setKeepParticlesInLocalSpace(bool keep);
+
+      void setEnabled(bool enable);
+      void detailLevelChanged(unsigned int newlevel);
+
+      inline void storeThisAsCurrentParticleInterface()
+        { ParticleInterface::currentParticleInterface_s = this; }
+      inline static ParticleInterface* getCurrentParticleInterface()
+        { return ParticleInterface::currentParticleInterface_s; }
+
+    private:
+      void updateVisibility();
+
+      static ParticleInterface* currentParticleInterface_s;
+      static unsigned int counter_s;
+      Ogre::SceneNode* sceneNode_;
+      Ogre::ParticleSystem* particleSystem_;
+      bool bVisible_;
+      bool bEnabled_;
+      unsigned int detaillevel_;                            //!< Detail level of this particle effect (0: off, 1: low, 2: normal, 3: high)
+  };
+}
+
+#endif /* _ParticleInterface_H__ */
Index: /code/branches/ceguilua/src/orxonox/tools/TextureGenerator.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/TextureGenerator.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/TextureGenerator.cc	(revision 1801)
@@ -0,0 +1,86 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file
+    @brief Implementation of the TextureGenerator.
+*/
+
+#include "OrxonoxStableHeaders.h"
+#include "TextureGenerator.h"
+#include <OgreMaterialManager.h>
+#include <OgreTechnique.h>
+#include "util/Convert.h"
+
+namespace std
+{
+    template <>
+    bool less<orxonox::ColourValue>::operator()(const orxonox::ColourValue& __x, const orxonox::ColourValue& __y) const
+    {
+        if (__x.r == __y.r)
+        {
+            if (__x.g == __y.g)
+            {
+                if (__x.b == __y.b)
+                {
+                    return __x.a < __y.a;
+                }
+                return __x.b < __y.b;
+            }
+            return __x.g < __y.g;
+        }
+        return __x.r < __y.r;
+    }
+}
+
+namespace orxonox
+{
+    std::map<std::string, std::map<ColourValue, std::string> > TextureGenerator::materials_s;
+    unsigned int TextureGenerator::materialCount_s = 0;
+
+    /*static*/ const std::string& TextureGenerator::getMaterialName(std::string textureName, const ColourValue& colour)
+    {
+        std::map<ColourValue, std::string>& colourMap = materials_s[textureName];
+        std::map<ColourValue, std::string>::const_iterator it = colourMap.find(colour);
+
+        if (it == colourMap.end())
+        {
+            std::string materialName = textureName + "_Material_" + convertToString(materialCount_s++);
+            Ogre::MaterialPtr material = (Ogre::MaterialPtr)Ogre::MaterialManager::getSingleton().create(materialName, "General");
+            material->getTechnique(0)->getPass(0)->setSceneBlending(Ogre::SBT_TRANSPARENT_ALPHA);
+            Ogre::TextureUnitState* textureUnitState = material->getTechnique(0)->getPass(0)->createTextureUnitState();
+            textureUnitState->setTextureName(textureName);
+            textureUnitState->setColourOperationEx(Ogre::LBX_MODULATE, Ogre::LBS_MANUAL, Ogre::LBS_CURRENT, colour);
+            return (colourMap[colour] = materialName);
+        }
+        else
+        {
+            return (*it).second;
+        }
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/TextureGenerator.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/TextureGenerator.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/TextureGenerator.h	(revision 1801)
@@ -0,0 +1,59 @@
+/*
+ *   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
+    @brief
+*/
+
+#ifndef _TextureGenerator_H__
+#define _TextureGenerator_H__
+
+#include "OrxonoxPrereqs.h"
+#include <string>
+#include <map>
+#include "util/Math.h"
+
+namespace orxonox
+{
+    class _OrxonoxExport TextureGenerator
+    {
+    public:
+        static const std::string& getMaterialName(std::string textureName, const ColourValue& colour);
+
+    private:
+        TextureGenerator();
+        TextureGenerator(const TextureGenerator&);
+        ~TextureGenerator();
+
+        static std::map<std::string, std::map<ColourValue, std::string> > materials_s;
+        static unsigned int materialCount_s;
+    };
+}
+
+#endif /* _TextureGenerator_H__ */
Index: /code/branches/ceguilua/src/orxonox/tools/Timer.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/Timer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/Timer.cc	(revision 1801)
@@ -0,0 +1,155 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include <set>
+
+#include "OrxonoxStableHeaders.h"
+#include "Timer.h"
+
+#include "core/Executor.h"
+#include "core/CoreIncludes.h"
+#include "core/ConsoleCommand.h"
+#include "core/CommandExecutor.h"
+#include "core/Clock.h"
+
+namespace orxonox
+{
+    SetConsoleCommandShortcutExtern(delay);
+    SetConsoleCommandShortcutExtern(killdelays);
+
+    static std::set<StaticTimer*> delaytimerset;
+
+    /**
+        @brief Calls a console command after 'delay' seconds.
+        @param delay The delay in seconds
+        @param command The console command
+    */
+    void delay(float delay, const std::string& command)
+    {
+        StaticTimer *delaytimer = new StaticTimer();
+        delaytimerset.insert(delaytimer);
+
+        ExecutorStatic* delayexecutor = createExecutor(createFunctor(&executeDelayedCommand));
+        delayexecutor->setDefaultValues(delaytimer, command);
+        delaytimer->setTimer(delay, false, delayexecutor);
+    }
+
+    /**
+        @brief Executes the command.
+        @param timer The timer to destroy after the command-execution
+        @param command The command to execute
+    */
+    void executeDelayedCommand(StaticTimer* timer, const std::string& command)
+    {
+        CommandExecutor::execute(command);
+        delete timer;
+        delaytimerset.erase(timer);
+    }
+
+    /**
+        @brief Kills all delayed commands.
+    */
+    void killdelays()
+    {
+        for (std::set<StaticTimer*>::iterator it = delaytimerset.begin(); it != delaytimerset.end(); ++it)
+            delete (*it);
+
+        delaytimerset.clear();
+    }
+
+    /**
+        @brief Constructor: Sets the default-values.
+    */
+    TimerBase::TimerBase()
+    {
+        this->executor_ = 0;
+        this->interval_ = 0;
+        this->bLoop_ = false;
+        this->bActive_ = false;
+
+        this->time_ = 0;
+
+        RegisterRootObject(TimerBase);
+    }
+
+    /**
+        @brief Deletes the executor.
+    */
+    TimerBase::~TimerBase()
+    {
+        this->deleteExecutor();
+    }
+
+    /**
+        @brief Executes the executor.
+    */
+    void TimerBase::run() const
+    {
+        (*this->executor_)();
+    }
+
+    /**
+        @brief Deletes the executor.
+    */
+    void TimerBase::deleteExecutor()
+    {
+      if (this->executor_)
+          delete this->executor_;
+    }
+
+    /**
+        @brief Updates the timer before the frames are rendered.
+    */
+    void TimerBase::tick(const Clock& time)
+    {
+        if (this->bActive_)
+        {
+            // If active: Decrease the timer by the duration of the last frame
+            this->time_ -= time.getDeltaTimeMicroseconds();
+
+            if (this->time_ <= 0)
+            {
+                // It's time to call the function
+                if (this->bLoop_)
+                {
+                    this->time_ += this->interval_; // Q: Why '+=' and not '='? A: Think about it. It's more accurate like that. Seriously.
+                    while (this->time_ <= 0)
+                    {
+                        // The interval was shorter than one tick, so execute the function more than once
+                        this->run();
+                        this->time_ += this->interval_;
+                    }
+                }
+                else
+                    this->stopTimer(); // Stop the timer if we don't want to loop
+
+                this->run();
+            }
+        }
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/Timer.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/Timer.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/Timer.h	(revision 1801)
@@ -0,0 +1,206 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/*!
+    @file Timer.h
+    @brief Definition and Implementation of the Timer class.
+
+    The Timer is a callback-object, calling a given function after a given time-interval.
+
+    Usage:
+    header.h:
+        class ClassName
+        {
+            public:
+                ClassName();
+                void functionName();
+                Timer<ClassName> myTimer;
+        };
+
+    source.cc:
+        include "core/Executor.h"
+
+        ClassName::ClassName()
+        {
+            myTimer.setTimer(interval_in_seconds, bLoop, this, createExecutor(createFunctor(&ClassName::functionName)));
+        }
+
+        void ClassName::functionName()
+        {
+            whateveryouwant();
+            something(else);
+        }
+*/
+
+#ifndef _Timer_H__
+#define _Timer_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+    class StaticTimer;
+    void delay(float delay, const std::string& command);
+    void killdelays();
+    void executeDelayedCommand(StaticTimer* timer, const std::string& command);
+
+    //! TimerBase is the parent of the Timer class.
+    class _OrxonoxExport TimerBase : public OrxonoxClass
+    {
+        public:
+            ~TimerBase();
+
+            void run() const;
+            void deleteExecutor();
+
+            /** @brief Starts the Timer: Function-call after 'interval' seconds. */
+            inline void startTimer()
+                { this->bActive_ = true; this->time_ = this->interval_; }
+            /** @brief Stops the Timer. */
+            inline void stopTimer()
+                { this->bActive_ = false; this->time_ = this->interval_; }
+            /** @brief Pauses the Timer - it will continue with the actual state if you unpause it. */
+            inline void pauseTimer()
+                { this->bActive_ = false; }
+            /** @brief Unpauses the Timer - continues with the given state. */
+            inline void unpauseTimer()
+                { this->bActive_ = true; }
+            /** @brief Returns true if the Timer is active (= not stoped, not paused). @return True = Time is active */
+            inline bool isActive() const
+                { return this->bActive_; }
+            /** @brief Returns the remaining time until the Timer calls the function. @return The remaining time */
+            inline float getRemainingTime() const
+                { 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)
+                { 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)
+                { 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_ = (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(const Clock& time);
+
+        protected:
+            TimerBase();
+
+            Executor* executor_; //!< The executor of the function that should be called when the time expires
+
+            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
+
+            long long time_;     //!< Internal variable, counting the time till the next function-call
+    };
+
+    //! The Timer is a callback-object, calling a given function after a given time-interval.
+    template <class T = BaseObject>
+    class Timer : public TimerBase
+    {
+        public:
+            Timer() {}
+
+            /**
+                @brief Constructor: Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param object The object owning the timer and the function
+                @param exeuctor A executor of the function to call
+            */
+            Timer(float interval, bool bLoop, T* object, ExecutorMember<T>* exeuctor)
+            {
+                this->setTimer(interval, bLoop, object, exeuctor);
+            }
+
+            /**
+                @brief Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param object The object owning the timer and the function
+                @param exeuctor A executor of the function to call
+            */
+            void setTimer(float interval, bool bLoop, T* object, ExecutorMember<T>* executor)
+            {
+                this->deleteExecutor();
+
+                this->setInterval(interval);
+                this->bLoop_ = bLoop;
+                executor->setObject(object);
+                this->executor_ = (Executor*)executor;
+                this->bActive_ = true;
+
+                this->time_ = this->interval_;
+            }
+    };
+
+    //! The StaticTimer is a callback-object, calling a static function after a given time-interval.
+    class StaticTimer : public TimerBase
+    {
+        public:
+            StaticTimer() {}
+
+            /**
+                @brief Constructor: Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param exeuctor A executor of the function to call
+            */
+            StaticTimer(float interval, bool bLoop, ExecutorStatic* executor)
+            {
+                this->setTimer(interval, bLoop, executor);
+            }
+
+            /**
+                @brief Initializes the Timer with given values.
+                @param interval The timer-interval in seconds
+                @param bLoop If true, the function gets called every 'interval' seconds
+                @param object The object owning the timer and the function
+                @param executor A executor of the function to call
+            */
+            void setTimer(float interval, bool bLoop, ExecutorStatic* executor)
+            {
+                this->deleteExecutor();
+
+                this->setInterval(interval);
+                this->bLoop_ = bLoop;
+                this->executor_ = (Executor*)executor;
+                this->bActive_ = true;
+
+                this->time_ = this->interval_;
+            }
+    };
+
+}
+
+#endif /* _Timer_H__ */
Index: /code/branches/ceguilua/src/orxonox/tools/WindowEventListener.cc
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/WindowEventListener.cc	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/WindowEventListener.cc	(revision 1801)
@@ -0,0 +1,42 @@
+/*
+ *   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 "WindowEventListener.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor for the WindowEventListener.
+    */
+    WindowEventListener::WindowEventListener()
+    {
+        RegisterRootObject(WindowEventListener);
+    }
+}
Index: /code/branches/ceguilua/src/orxonox/tools/WindowEventListener.h
===================================================================
--- /code/branches/ceguilua/src/orxonox/tools/WindowEventListener.h	(revision 1801)
+++ /code/branches/ceguilua/src/orxonox/tools/WindowEventListener.h	(revision 1801)
@@ -0,0 +1,58 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Reto Grieder
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _WindowEventListener_H__
+#define _WindowEventListener_H__
+
+#include "OrxonoxPrereqs.h"
+#include "core/OrxonoxClass.h"
+
+
+namespace orxonox
+{
+    /**
+        @brief Interface for receiving window events.
+    */
+    class _OrxonoxExport WindowEventListener : virtual public OrxonoxClass
+    {
+    public:
+        WindowEventListener();
+        virtual ~WindowEventListener() { }
+
+            /** Window has moved position */
+            virtual void windowMoved() { }
+
+            /** Window has resized */
+            virtual void windowResized(int newWidth, int newHeight) { }
+
+            /** Window has lost/gained focus */
+            virtual void windowFocusChanged() { }
+    };
+}
+
+#endif /* _WindowEventListener_H__ */
Index: /code/branches/ceguilua/src/tinyxml/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/tinyxml/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,9 @@
+SET( TINYXML_SRC_FILES
+  ticpp.cc
+  tinystr.cc
+  tinyxml.cc
+  tinyxmlerror.cc
+  tinyxmlparser.cc
+)
+
+ADD_LIBRARY(tinyxml SHARED ${TINYXML_SRC_FILES})
Index: /code/branches/ceguilua/src/tinyxml/ticpp.cc
===================================================================
--- /code/branches/ceguilua/src/tinyxml/ticpp.cc	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/ticpp.cc	(revision 1801)
@@ -0,0 +1,1139 @@
+#define TIXML_USE_TICPP
+
+/*
+http://code.google.com/p/ticpp/
+Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/*
+Modifications by the orxonox team:
+In function: void Document::Parse( const std::string& xml, bool throwIfParseError, TiXmlEncoding encoding )
+     change: Added row and column number to the error description.
+     author: Reto Grieder
+*/
+
+#ifdef TIXML_USE_TICPP
+
+#include "ticpp.h"
+#include "ticpprc.h"
+#include "tinyxml.h"
+#include <sstream>
+
+using namespace ticpp;
+
+// In the following Visitor functions, casting away const should be safe, as the object can only be referred to by a const &
+bool Visitor::VisitEnter( const TiXmlDocument& doc )
+{
+	return VisitEnter( Document( const_cast< TiXmlDocument* >( &doc ) ) );
+}
+
+bool Visitor::VisitExit( const TiXmlDocument& doc )
+{
+	return VisitEnter( Document( const_cast< TiXmlDocument* >( &doc ) ) );
+}
+
+bool Visitor::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
+{
+	if ( 0 != firstAttribute )
+	{
+		Attribute attribute( const_cast< TiXmlAttribute* >( firstAttribute ) );
+		return VisitEnter( Element( const_cast< TiXmlElement* >( &element ) ), &attribute );
+	}
+	else
+	{
+		return VisitEnter( Element( const_cast< TiXmlElement* >( &element ) ), 0 );
+	}
+}
+
+bool Visitor::VisitExit( const TiXmlElement& element )
+{
+	return VisitExit( Element( const_cast< TiXmlElement* >( &element ) ) );
+}
+
+bool Visitor::Visit( const TiXmlDeclaration& declaration )
+{
+	return Visit( Declaration( const_cast< TiXmlDeclaration* >( &declaration ) ) );
+}
+
+bool Visitor::Visit( const TiXmlStylesheetReference& stylesheet )
+{
+	return Visit( StylesheetReference( const_cast< TiXmlStylesheetReference* >( &stylesheet ) ) );
+}
+
+bool Visitor::Visit( const TiXmlText& text )
+{
+	return Visit( Text( const_cast< TiXmlText* >( &text ) ) );
+}
+
+bool Visitor::Visit( const TiXmlComment& comment )
+{
+	return Visit( Comment( const_cast< TiXmlComment* >( &comment ) ) );
+}
+
+Attribute::Attribute()
+{
+	SetTiXmlPointer( new TiXmlAttribute() );
+	m_impRC->InitRef();
+}
+
+Attribute::Attribute( TiXmlAttribute* attribute )
+{
+	SetTiXmlPointer( attribute );
+	m_impRC->IncRef();
+}
+
+Attribute::Attribute( const std::string& name, const std::string& value )
+{
+	SetTiXmlPointer( new TiXmlAttribute( name, value ) );
+	m_impRC->InitRef();
+}
+
+void Attribute::operator=( const Attribute& copy )
+{
+	// Dropping the reference to the old object
+	this->m_impRC->DecRef();
+
+	// Pointing to the new Object
+	SetTiXmlPointer( copy.m_tiXmlPointer );
+
+	// The internal tixml pointer changed in the above line
+	this->m_impRC->IncRef();
+}
+
+Attribute::Attribute( const Attribute& copy ) : Base()
+{
+	// Dropping the reference to the old object
+	this->m_impRC->DecRef();
+
+	// Pointing to the new Object
+	SetTiXmlPointer( copy.m_tiXmlPointer );
+
+	// The internal tixml pointer changed in the above line
+	this->m_impRC->IncRef();
+}
+
+Attribute::~Attribute()
+{
+	m_impRC->DecRef();
+}
+
+std::string Attribute::Value() const
+{
+	ValidatePointer();
+	return m_tiXmlPointer->ValueStr();
+}
+
+std::string Attribute::Name() const
+{
+	ValidatePointer();
+	return m_tiXmlPointer->Name();
+}
+
+Attribute* Attribute::Next( bool throwIfNoAttribute ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->Next();
+	if ( 0 == attribute )
+	{
+		if ( throwIfNoAttribute )
+		{
+			TICPPTHROW( "No more attributes found" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Attribute* Attribute::Previous( bool throwIfNoAttribute ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->Previous();
+	if ( 0 == attribute )
+	{
+		if ( throwIfNoAttribute )
+		{
+			TICPPTHROW( "No more attributes found" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+void Attribute::IterateNext( const std::string&, Attribute** next ) const
+{
+	*next = Next( false );
+}
+
+void Attribute::IteratePrevious( const std::string&, Attribute** previous ) const
+{
+	*previous = Previous( false );
+}
+
+void Attribute::Print( FILE* file, int depth ) const
+{
+	ValidatePointer();
+	m_tiXmlPointer->Print( file, depth );
+}
+
+void Attribute::SetTiXmlPointer( TiXmlAttribute* newPointer )
+{
+	m_tiXmlPointer = newPointer;
+	SetImpRC( newPointer );
+}
+
+//*****************************************************************************
+
+Node* Node::NodeFactory( TiXmlNode* tiXmlNode, bool throwIfNull, bool rememberSpawnedWrapper ) const
+{
+	if ( 0 == tiXmlNode )
+	{
+		if ( throwIfNull )
+		{
+			TICPPTHROW( "tiXmlNode is NULL" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Node* temp;
+	switch ( tiXmlNode->Type() )
+	{
+		case TiXmlNode::DOCUMENT:
+			temp = new Document( tiXmlNode->ToDocument() );
+			break;
+
+		case TiXmlNode::ELEMENT:
+			temp = new Element( tiXmlNode->ToElement() );
+			break;
+
+		case TiXmlNode::COMMENT:
+			temp = new Comment( tiXmlNode->ToComment() );
+			break;
+
+		case TiXmlNode::TEXT:
+			temp = new Text( tiXmlNode->ToText() );
+			break;
+
+		case TiXmlNode::DECLARATION:
+			temp = new Declaration( tiXmlNode->ToDeclaration() );
+			break;
+
+		case TiXmlNode::STYLESHEETREFERENCE:
+			temp = new StylesheetReference( tiXmlNode->ToStylesheetReference() );
+			break;
+
+		default:
+			TICPPTHROW( "Type is unsupported" )
+	}
+
+	if ( rememberSpawnedWrapper )
+	{
+		m_spawnedWrappers.push_back( temp );
+	}
+	return temp;
+}
+
+
+std::string Node::Value() const
+{
+	return GetTiXmlPointer()->ValueStr();
+}
+
+void Node::Clear()
+{
+	GetTiXmlPointer()->Clear();
+}
+
+Node* Node::Parent( bool throwIfNoParent ) const
+{
+	TiXmlNode* parent = GetTiXmlPointer()->Parent();
+	if ( ( 0 == parent ) && throwIfNoParent )
+	{
+		TICPPTHROW( "No parent exists" );
+	}
+
+	return NodeFactory( parent, false );
+}
+
+Node* Node::FirstChild( bool throwIfNoChildren ) const
+{
+	return FirstChild( "", throwIfNoChildren );
+}
+
+Node* Node::FirstChild( const std::string& value, bool throwIfNoChildren ) const
+{
+	return FirstChild( value.c_str(), throwIfNoChildren );
+}
+
+Node* Node::FirstChild( const char* value, bool throwIfNoChildren ) const
+{
+	TiXmlNode* childNode;
+	if ( 0 == strlen( value ) )
+	{
+		childNode = GetTiXmlPointer()->FirstChild();
+	}
+	else
+	{
+		childNode = GetTiXmlPointer()->FirstChild( value );
+	}
+
+	if ( ( 0 == childNode ) && throwIfNoChildren )
+	{
+		TICPPTHROW( "Child with the value of \"" << value << "\" not found" );
+	}
+
+	return NodeFactory( childNode, false );
+}
+
+Node* Node::LastChild( bool throwIfNoChildren ) const
+{
+	return LastChild( "", throwIfNoChildren );
+}
+
+Node* Node::LastChild( const std::string& value, bool throwIfNoChildren ) const
+{
+	return LastChild( value.c_str(), throwIfNoChildren );
+}
+
+Node* Node::LastChild( const char* value, bool throwIfNoChildren ) const
+{
+	TiXmlNode* childNode;
+	if ( 0 == strlen( value ) )
+	{
+		childNode = GetTiXmlPointer()->LastChild();
+	}
+	else
+	{
+		childNode = GetTiXmlPointer()->LastChild( value );
+	}
+
+	if ( ( 0 == childNode ) && throwIfNoChildren )
+	{
+		TICPPTHROW( "Child with the value of \"" << value << "\" not found" );
+	}
+
+	return NodeFactory( childNode, false );
+}
+
+Node* Node::IterateChildren ( Node* previous ) const
+{
+	TiXmlNode* pointer;
+	if ( 0 == previous )
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( 0 );
+	}
+	else
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( previous->GetTiXmlPointer() );
+	}
+
+	return NodeFactory( pointer, false );
+}
+
+Node* Node::IterateChildren( const std::string& value, Node* previous ) const
+{
+	TiXmlNode* pointer;
+	if ( 0 == previous )
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( value, 0 );
+	}
+	else
+	{
+		pointer = GetTiXmlPointer()->IterateChildren( value, previous->GetTiXmlPointer() );
+	}
+
+	return NodeFactory( pointer, false );
+}
+
+Node* Node::InsertEndChild( Node& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	addThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->InsertEndChild( *addThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+Node* Node::LinkEndChild( Node* childNode )
+{
+	if ( childNode->Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be linked" );
+	}
+
+	// Increment reference count when adding to the tree
+	childNode->m_impRC->IncRef();
+
+	if ( 0 == GetTiXmlPointer()->LinkEndChild( childNode->GetTiXmlPointer() ) )
+	{
+		TICPPTHROW( "Node can't be linked" );
+	}
+
+	return childNode;
+}
+
+Node* Node::InsertBeforeChild( Node* beforeThis, Node& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	addThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->InsertBeforeChild( beforeThis->GetTiXmlPointer(), *addThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+Node* Node::InsertAfterChild( Node* afterThis, Node& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	addThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->InsertAfterChild( afterThis->GetTiXmlPointer(), *addThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+Node* Node::ReplaceChild( Node* replaceThis, Node& withThis )
+{
+	if ( withThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		TICPPTHROW( "Node is a Document and can't be inserted" );
+	}
+
+	// Increment reference count when adding to the tree
+	withThis.m_impRC->IncRef();
+
+	TiXmlNode* pointer = GetTiXmlPointer()->ReplaceChild( replaceThis->GetTiXmlPointer(), *withThis.GetTiXmlPointer() );
+	if ( 0 == pointer )
+	{
+		TICPPTHROW( "Node can't be inserted" );
+	}
+
+	return NodeFactory( pointer );
+}
+
+void Node::RemoveChild( Node* removeThis )
+{
+	if  ( !GetTiXmlPointer()->RemoveChild( removeThis->GetTiXmlPointer() ) )
+	{
+		TICPPTHROW( "Node to remove (" << removeThis->Value() << ") is not a child of this Node (" << Value() << ")" )
+	}
+}
+
+Node* Node::PreviousSibling( bool throwIfNoSiblings ) const
+{
+	return PreviousSibling( "", throwIfNoSiblings );
+}
+
+Node* Node::PreviousSibling( const std::string& value, bool throwIfNoSiblings ) const
+{
+	return PreviousSibling( value.c_str(), throwIfNoSiblings );
+}
+
+Node* Node::PreviousSibling( const char* value, bool throwIfNoSiblings ) const
+{
+	TiXmlNode* sibling;
+	if ( 0 == strlen( value ) )
+	{
+		sibling = GetTiXmlPointer()->PreviousSibling();
+	}
+	else
+	{
+		sibling = GetTiXmlPointer()->PreviousSibling( value );
+	}
+
+	if ( ( 0 == sibling ) && throwIfNoSiblings )
+	{
+		TICPPTHROW( "No Siblings found with value, '" << value << "', Prior to this Node (" << Value() << ")" )
+	}
+
+	return NodeFactory( sibling, false );
+}
+
+Node* Node::NextSibling( bool throwIfNoSiblings ) const
+{
+	return NextSibling( "", throwIfNoSiblings );
+}
+
+Node* Node::NextSibling( const std::string& value, bool throwIfNoSiblings ) const
+{
+	return NextSibling( value.c_str(), throwIfNoSiblings );
+}
+
+Node* Node::NextSibling( const char* value, bool throwIfNoSiblings ) const
+{
+	TiXmlNode* sibling;
+	if ( 0 == strlen( value ) )
+	{
+		sibling = GetTiXmlPointer()->NextSibling();
+	}
+	else
+	{
+		sibling = GetTiXmlPointer()->NextSibling( value );
+	}
+
+	if ( ( 0 == sibling ) && throwIfNoSiblings )
+	{
+		TICPPTHROW( "No Siblings found with value, '" << value << "', After this Node (" << Value() << ")" )
+	}
+
+	return NodeFactory( sibling, false );
+}
+
+Element* Node::NextSiblingElement( bool throwIfNoSiblings ) const
+{
+	return NextSiblingElement( "", throwIfNoSiblings );
+}
+
+Element* Node::NextSiblingElement( const std::string& value, bool throwIfNoSiblings ) const
+{
+	return NextSiblingElement( value.c_str(), throwIfNoSiblings );
+}
+
+Element* Node::NextSiblingElement( const char* value, bool throwIfNoSiblings ) const
+{
+	TiXmlElement* sibling;
+	if ( 0 == strlen( value ) )
+	{
+		sibling = GetTiXmlPointer()->NextSiblingElement();
+	}
+	else
+	{
+		sibling = GetTiXmlPointer()->NextSiblingElement( value );
+	}
+
+	if ( 0 == sibling )
+	{
+		if ( throwIfNoSiblings )
+		{
+			TICPPTHROW( "No Element Siblings found with value, '" << value << "', After this Node (" << Value() << ")" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Element* temp = new Element( sibling );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Element* Node::FirstChildElement( bool throwIfNoChildren ) const
+{
+	return FirstChildElement( "", throwIfNoChildren );
+}
+
+Element* Node::FirstChildElement( const std::string& value, bool throwIfNoChildren ) const
+{
+	return FirstChildElement( value.c_str(), throwIfNoChildren );
+}
+
+Element* Node::FirstChildElement( const char* value, bool throwIfNoChildren ) const
+{
+	TiXmlElement* element;
+	if ( 0 == strlen( value ) )
+	{
+		element = GetTiXmlPointer()->FirstChildElement();
+	}
+	else
+	{
+		element = GetTiXmlPointer()->FirstChildElement( value );
+	}
+
+	if ( 0 == element )
+	{
+		if( throwIfNoChildren )
+		{
+			TICPPTHROW( "Element (" << Value() << ") does NOT contain a child with the value of '" << value << "'" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Element* temp = new Element( element );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+int Node::Type() const
+{
+	return GetTiXmlPointer()->Type();
+}
+
+Document* Node::GetDocument( bool throwIfNoDocument ) const
+{
+	TiXmlDocument* doc = GetTiXmlPointer()->GetDocument();
+	if ( 0 == doc )
+	{
+		if( throwIfNoDocument )
+		{
+			TICPPTHROW( "This node (" << Value() << ") is not linked under a document" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+	Document* temp = new Document( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+bool Node::NoChildren() const
+{
+	return GetTiXmlPointer()->NoChildren();
+}
+
+Document* Node::ToDocument() const
+{
+	TiXmlDocument* doc = GetTiXmlPointer()->ToDocument();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Document" )
+	}
+	Document* temp = new Document( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Element* Node::ToElement() const
+{
+	TiXmlElement* doc = GetTiXmlPointer()->ToElement();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Element" )
+	}
+	Element* temp = new Element( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Comment* Node::ToComment() const
+{
+	TiXmlComment* doc = GetTiXmlPointer()->ToComment();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Comment" )
+	}
+	Comment* temp = new Comment( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Text* Node::ToText() const
+{
+	TiXmlText* doc = GetTiXmlPointer()->ToText();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Text" )
+	}
+	Text* temp = new Text( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Declaration* Node::ToDeclaration() const
+{
+	TiXmlDeclaration* doc = GetTiXmlPointer()->ToDeclaration();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a Declaration" )
+	}
+	Declaration* temp = new Declaration( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+StylesheetReference* Node::ToStylesheetReference() const
+{
+	TiXmlStylesheetReference* doc = GetTiXmlPointer()->ToStylesheetReference();
+	if ( 0 == doc )
+	{
+		TICPPTHROW( "This node (" << Value() << ") is not a StylesheetReference" )
+	}
+	StylesheetReference* temp = new StylesheetReference( doc );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+std::auto_ptr< Node > Node::Clone() const
+{
+	TiXmlNode* node = GetTiXmlPointer()->Clone();
+	if ( 0 == node )
+	{
+		TICPPTHROW( "Node could not be cloned" );
+	}
+	std::auto_ptr< Node > temp( NodeFactory( node, false, false ) );
+
+	// Take ownership of the memory from TiXml
+	temp->m_impRC->InitRef();
+
+	return temp;
+}
+
+bool Node::Accept( TiXmlVisitor* visitor ) const
+{
+	return GetTiXmlPointer()->Accept( visitor );
+}
+
+//*****************************************************************************
+
+Comment::Comment()
+: NodeImp< TiXmlComment >( new TiXmlComment() )
+{
+	m_impRC->InitRef();
+}
+
+Comment::Comment( TiXmlComment* comment )
+: NodeImp< TiXmlComment >( comment )
+{
+}
+
+Comment::Comment( const std::string& comment )
+: NodeImp< TiXmlComment >( new TiXmlComment() )
+{
+	m_impRC->InitRef();
+	m_tiXmlPointer->SetValue( comment );
+}
+
+//*****************************************************************************
+
+Text::Text()
+: NodeImp< TiXmlText >( new TiXmlText("") )
+{
+	m_impRC->InitRef();
+}
+
+
+Text::Text( const std::string& value )
+: NodeImp< TiXmlText >( new TiXmlText( value ) )
+{
+	m_impRC->InitRef();
+}
+
+Text::Text( TiXmlText* text )
+: NodeImp< TiXmlText >( text )
+{
+}
+
+
+//*****************************************************************************
+
+Document::Document()
+: NodeImp< TiXmlDocument >( new TiXmlDocument() )
+{
+	m_impRC->InitRef();
+}
+
+Document::Document( TiXmlDocument* document )
+: NodeImp< TiXmlDocument >( document )
+{
+}
+
+Document::Document( const char* documentName )
+: NodeImp< TiXmlDocument >( new TiXmlDocument( documentName ) )
+{
+	m_impRC->InitRef();
+}
+
+Document::Document( const std::string& documentName )
+: NodeImp< TiXmlDocument >( new TiXmlDocument( documentName ) )
+{
+	m_impRC->InitRef();
+}
+
+void Document::LoadFile( TiXmlEncoding encoding )
+{
+	if ( !m_tiXmlPointer->LoadFile( encoding ) )
+	{
+		TICPPTHROW( "Couldn't load " << m_tiXmlPointer->Value() );
+	}
+}
+
+void Document::SaveFile( void ) const
+{
+	if ( !m_tiXmlPointer->SaveFile() )
+	{
+		TICPPTHROW( "Couldn't save " << m_tiXmlPointer->Value() );
+	}
+}
+
+void Document::LoadFile( const std::string& filename, TiXmlEncoding encoding )
+{
+	if ( !m_tiXmlPointer->LoadFile( filename.c_str(), encoding ) )
+	{
+		TICPPTHROW( "Couldn't load " << filename );
+	}
+}
+
+void Document::LoadFile( const char* filename, TiXmlEncoding encoding )
+{
+	if ( !m_tiXmlPointer->LoadFile( filename, encoding ) )
+	{
+		TICPPTHROW( "Couldn't load " << filename );
+	}
+}
+
+void Document::SaveFile( const std::string& filename ) const
+{
+	if ( !m_tiXmlPointer->SaveFile( filename.c_str() ) )
+	{
+		TICPPTHROW( "Couldn't save " << filename );
+	}
+}
+
+void Document::Parse( const std::string& xml, bool throwIfParseError, TiXmlEncoding encoding )
+{
+	m_tiXmlPointer->Parse( xml.c_str(), 0, encoding );
+	if( throwIfParseError && m_tiXmlPointer->Error() )
+	{
+		TICPPTHROW( "Error parsing xml: " << m_tiXmlPointer->ErrorDesc()
+            << " In row " << m_tiXmlPointer->ErrorRow() << ", column " << m_tiXmlPointer->ErrorCol() << ".");
+	}
+}
+
+//*****************************************************************************
+
+Element::Element()
+: NodeImp< TiXmlElement >( new TiXmlElement( "DefaultValueCausedByCreatingAnElementWithNoParameters" ) )
+{
+	m_impRC->InitRef();
+}
+
+Element::Element( const std::string& value )
+: NodeImp< TiXmlElement >( new TiXmlElement( value ) )
+{
+	m_impRC->InitRef();
+}
+
+Element::Element( const char* value )
+: NodeImp< TiXmlElement >( new TiXmlElement( value ) )
+{
+	m_impRC->InitRef();
+}
+
+Element::Element( TiXmlElement* element )
+: NodeImp< TiXmlElement >( element )
+{
+}
+
+Attribute* Element::FirstAttribute( bool throwIfNoAttributes ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->FirstAttribute();
+	if ( ( 0 == attribute ) && throwIfNoAttributes )
+	{
+		TICPPTHROW( "This Element (" << Value() << ") has no attributes" )
+	}
+
+	if ( 0 == attribute )
+	{
+		if( throwIfNoAttributes )
+		{
+			TICPPTHROW( "Element (" << Value() << ") has no attributes" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+Attribute* Element::LastAttribute( bool throwIfNoAttributes ) const
+{
+	ValidatePointer();
+	TiXmlAttribute* attribute = m_tiXmlPointer->LastAttribute();
+	if ( ( 0 == attribute ) && throwIfNoAttributes )
+	{
+		TICPPTHROW( "This Element (" << Value() << ") has no attributes" )
+	}
+
+	if ( 0 == attribute )
+	{
+		if( throwIfNoAttributes )
+		{
+			TICPPTHROW( "Element (" << Value() << ") has no attributes" )
+		}
+		else
+		{
+			return 0;
+		}
+	}
+
+	Attribute* temp = new Attribute( attribute );
+	m_spawnedWrappers.push_back( temp );
+
+	return temp;
+}
+
+std::string Element::GetAttributeOrDefault( const std::string& name, const std::string& defaultValue ) const
+{
+	std::string value;
+	if ( !GetAttributeImp( name, &value ) )
+	{
+		return defaultValue;
+	}
+	return value;
+}
+
+std::string Element::GetAttribute( const std::string& name ) const
+{
+	return GetAttributeOrDefault( name, std::string() );
+}
+
+bool Element::GetAttributeImp( const std::string& name, std::string* value ) const
+{
+	ValidatePointer();
+
+	// Get value from TinyXML, if the attribute exists
+	const char* retVal = m_tiXmlPointer->Attribute( name.c_str() );
+
+	// TinyXML returns NULL if the attribute doesn't exist
+	if ( 0 == retVal )
+	{
+		return false;
+	}
+	else
+	{
+		*value = retVal;
+		return true;
+	}
+}
+
+bool Element::GetTextImp( std::string* value ) const
+{
+	ValidatePointer();
+
+	// Get value from TinyXML, if the attribute exists
+	const char* retVal = m_tiXmlPointer->GetText();
+
+	// TinyXML returns NULL if the attribute doesn't exist
+	if ( 0 == retVal )
+	{
+		return false;
+	}
+	else
+	{
+		*value = retVal;
+		return true;
+	}
+}
+
+//*****************************************************************************
+
+Declaration::Declaration()
+: NodeImp< TiXmlDeclaration >( new TiXmlDeclaration() )
+{
+	m_impRC->InitRef();
+}
+
+Declaration::Declaration( TiXmlDeclaration* declaration )
+: NodeImp< TiXmlDeclaration >( declaration )
+{
+}
+
+Declaration::Declaration( const std::string& version, const std::string& encoding, const std::string& standalone )
+: NodeImp< TiXmlDeclaration >( new TiXmlDeclaration( version, encoding, standalone ) )
+{
+	m_impRC->InitRef();
+}
+
+std::string Declaration::Version() const
+{
+	return m_tiXmlPointer->Version();
+}
+
+std::string Declaration::Encoding() const
+{
+	return m_tiXmlPointer->Encoding();
+}
+
+std::string Declaration::Standalone() const
+{
+	return m_tiXmlPointer->Standalone();
+}
+
+//*****************************************************************************
+
+StylesheetReference::StylesheetReference()
+: NodeImp< TiXmlStylesheetReference >( new TiXmlStylesheetReference() )
+{
+	m_impRC->InitRef();
+}
+
+StylesheetReference::StylesheetReference( TiXmlStylesheetReference* stylesheetReference )
+: NodeImp< TiXmlStylesheetReference >( stylesheetReference )
+{
+}
+
+StylesheetReference::StylesheetReference( const std::string& type, const std::string& href )
+: NodeImp< TiXmlStylesheetReference >( new TiXmlStylesheetReference( type, href ) )
+{
+	m_impRC->InitRef();
+}
+
+std::string StylesheetReference::Type() const
+{
+	return m_tiXmlPointer->Type();
+}
+
+std::string StylesheetReference::Href() const
+{
+	return m_tiXmlPointer->Href();
+}
+
+//*****************************************************************************
+
+Exception::Exception(const std::string &details)
+:
+m_details( details )
+{
+
+}
+
+Exception::~Exception() throw()
+{
+}
+
+const char* Exception::what() const throw()
+{
+	return m_details.c_str();
+}
+
+//*****************************************************************************
+
+TiCppRC::TiCppRC()
+{
+	// Spawn reference counter for this object
+	m_tiRC = new TiCppRCImp( this );
+}
+
+TiCppRC::~TiCppRC()
+{
+	// Set pointer held by reference counter to NULL
+	this->m_tiRC->Nullify();
+
+	// Decrement reference - so reference counter will delete itself if necessary
+	this->m_tiRC->DecRef();
+}
+
+//*****************************************************************************
+
+TiCppRCImp::TiCppRCImp( TiCppRC* tiCppRC )
+	: m_count( 1 ), m_tiCppRC ( tiCppRC )
+{
+}
+
+void TiCppRCImp::IncRef()
+{
+	m_count++;
+}
+
+void TiCppRCImp::DecRef()
+{
+	m_count--;
+	if ( 0 == m_count )
+	{
+		delete m_tiCppRC;
+		delete this;
+	}
+}
+
+void TiCppRCImp::InitRef()
+{
+	m_count = 1;
+}
+
+void TiCppRCImp::Nullify()
+{
+	m_tiCppRC = 0;
+}
+
+TiCppRC* TiCppRCImp::Get()
+{
+	return m_tiCppRC;
+}
+
+bool TiCppRCImp::IsNull()
+{
+	return 0 == m_tiCppRC;
+}
+
+#endif // TIXML_USE_TICPP
Index: /code/branches/ceguilua/src/tinyxml/ticpp.h
===================================================================
--- /code/branches/ceguilua/src/tinyxml/ticpp.h	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/ticpp.h	(revision 1801)
@@ -0,0 +1,1810 @@
+#define TIXML_USE_TICPP
+
+/*
+http://code.google.com/p/ticpp/
+Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+/**
+@copydoc ticpp
+@file
+@author		Ryan Pusztai
+@author		Ryan Mulder
+@date		04/11/2006
+
+@version  0.04b by nico@orxonox.net: gcc-4.3 compilation hotfixes
+@version	0.04a by edam@waxworlds.org: based Exception based on std::exception; added stream
+					<< and >> support; added Document::Parse(); bug fix; improved THROW() macro.
+@version	0.04 Added NodeImp class. Also made all the classes inherit from NodeImp.
+@version	0.03 Added Declaration class
+@version	0.02 Added Element class
+@version	0.01 Added Exception class, Document class
+
+@todo add UNKNOWN support. See ticpp::NodeFactory.
+@todo add TYPECOUNT support. See ticpp::NodeFactory.
+@todo Add a quick reference
+*/
+#ifdef TIXML_USE_TICPP
+
+#ifndef TICPP_INCLUDED
+#define TICPP_INCLUDED
+
+#include "tinyxml.h"
+#include <sstream>
+#include <vector>
+#include <memory>
+#include <exception>
+#include <typeinfo>
+
+/**
+@subpage ticpp is a TinyXML wrapper that uses a lot more C++ ideals.
+It throws exceptions, uses templates, is in its own name space, and
+<b>requires</b> STL (Standard Template Library). This is done to ease the use
+of getting values in and out of the xml.
+
+If you don't perfer to use some of the concepts just don't use it.
+It is just a wrapper that extends TinyXML. It doesn't actually change
+any of TinyXML.
+*/
+namespace ticpp
+{
+    /**
+	This is a ticpp exception class
+	*/
+	class Exception : public std::exception
+	{
+	public:
+		/**
+		Construct an exception with a message
+		*/
+		Exception( const std::string& details );
+		~Exception() throw();
+
+		/// Override std::exception::what() to return m_details
+		const char* what() const throw();
+
+		std::string m_details; /**< Exception Details */
+	};
+
+	/**
+	This allows you to stream your exceptions in.
+	It will take care of the conversion	and throwing the exception.
+	*/
+	#define TICPPTHROW( message ) 											\
+	{																		\
+		std::ostringstream full_message;									\
+		std::string file( __FILE__ );										\
+		file = file.substr( file.find_last_of( "\\/" ) + 1 );				\
+		full_message << message << " <" << file << "@" << __LINE__ << ">";	\
+		throw Exception( full_message.str() );								\
+	}
+
+	// Forward Declarations for Visitor, and others.
+	class Document;
+	class Element;
+	class Declaration;
+	class StylesheetReference;
+	class Text;
+	class Comment;
+	class Attribute;
+
+	/** Wrapper around TiXmlVisitor */
+	class Visitor : public TiXmlVisitor
+	{
+	public:
+		// Overload the TiXmlVisitor functions, wrap objects, call ticpp::Visitor functions
+		/// @internal
+		virtual bool VisitEnter( const TiXmlDocument& doc );
+		/// @internal
+		virtual bool VisitExit( const TiXmlDocument& doc );
+		/// @internal
+		virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
+		/// @internal
+		virtual bool VisitExit( const TiXmlElement& element );
+		/// @internal
+		virtual bool Visit( const TiXmlDeclaration& declaration );
+		/// @internal
+		virtual bool Visit( const TiXmlStylesheetReference& stylesheet );
+		/// @internal
+		virtual bool Visit( const TiXmlText& text );
+		/// @internal
+		virtual bool Visit( const TiXmlComment& comment );
+
+	public:
+		/// Visit a document.
+		virtual bool VisitEnter( const Document& /*doc*/ )			{ return true; }
+		/// Visit a document.
+		virtual bool VisitExit( const Document& /*doc*/ )			{ return true; }
+
+		/// Visit an element.
+		virtual bool VisitEnter( const Element& /*element*/, const Attribute* /*firstAttribute*/ )	{ return true; }
+		/// Visit an element.
+		virtual bool VisitExit( const Element& /*element*/ )		{ return true; }
+
+		/// Visit a declaration
+		virtual bool Visit( const Declaration& /*declaration*/ )	{ return true; }
+		/// Visit a stylesheet reference
+		virtual bool Visit( const StylesheetReference& /*stylesheet*/ )	{ return true; }
+		/// Visit a text node
+		virtual bool Visit( const Text& /*text*/ )					{ return true; }
+		/// Visit a comment node
+		virtual bool Visit( const Comment& /*comment*/ )			{ return true; }
+	};
+
+	/** Wrapper around TiXmlBase */
+	class Base
+	{
+	public:
+
+		/**
+		Converts any class with a proper overload of the << opertor to a std::string
+		@param value The value to be converted
+		@throws Exception When value cannot be converted to a std::string
+		*/
+		template < class T >
+			std::string ToString( const T& value ) const
+		{
+			std::stringstream convert;
+			convert << value;
+			if ( convert.fail() )
+			{
+				TICPPTHROW( "Could not convert value to text" );
+			}
+			return convert.str();
+		}
+
+		std::string ToString( const std::string& value ) const
+		{
+			return value;
+		}
+
+		/**
+		Converts a std::string to any class with a proper overload of the >> opertor
+		@param temp			The string to be converted
+		@param out	[OUT]	The container for the returned value
+		@throws Exception When temp cannot be converted to the target type
+		*/
+		template < class T >
+			void FromString( const std::string& temp, T* out ) const
+		{
+			std::istringstream val( temp );
+			val >> *out;
+
+			if ( val.fail() )
+			{
+				TICPPTHROW( "Could not convert \"" << temp << "\" to target type" );
+			}
+		}
+
+		/**
+		Specialization for std::string
+		*/
+		void FromString( const std::string& temp, std::string* out ) const
+		{
+			*out = temp;
+		}
+
+		/**
+		Return the position, in the original source file, of this node or attribute.
+		Wrapper around TiXmlBase::Row()
+		*/
+		int Row() const
+		{
+			return GetBasePointer()->Row();
+		}
+
+		/**
+		Return the position, in the original source file, of this node or attribute.
+		Wrapper around TiXmlBase::Row()
+		*/
+		int Column() const
+		{
+			return GetBasePointer()->Column();
+		}
+
+		/**
+		Destructor
+		*/
+		virtual ~Base()
+		{
+			DeleteSpawnedWrappers();
+		}
+
+	protected:
+		mutable TiCppRCImp* m_impRC;	/**< Holds status of internal TiXmlPointer - use this to determine if object has been deleted already */
+
+		mutable std::vector< Base* > m_spawnedWrappers; /**< Remember all wrappers that we've created with 'new' - ( e.g. NodeFactory, FirstChildElement, etc. )*/
+
+		/**
+		@internal
+		Updates the pointer to the reference counter to point at the counter in the new node.
+
+		@param node TiXmlBase containing the new reference counter
+		*/
+		void SetImpRC( TiXmlBase* node )
+		{
+			m_impRC = node->m_tiRC;
+		}
+
+		void ValidatePointer() const
+		{
+			if ( m_impRC->IsNull() )
+			{
+				TICPPTHROW( "Internal TiXml Pointer is NULL" );
+			}
+		}
+
+		/**
+		@internal
+		Delete all container objects we've spawned with 'new'.
+		*/
+		void DeleteSpawnedWrappers()
+		{
+			std::vector< Base* >::reverse_iterator wrapper;
+			for ( wrapper = m_spawnedWrappers.rbegin(); wrapper != m_spawnedWrappers.rend(); ++wrapper )
+			{
+				delete *wrapper;
+			}
+			m_spawnedWrappers.clear();
+		}
+
+		/**
+		@internal
+		Get internal TiXmlBase*
+		*/
+		virtual TiXmlBase* GetBasePointer() const = 0;
+	};
+
+	/**
+	Wrapper around TiXmlAttribute
+	*/
+	class Attribute : public Base
+	{
+	private:
+		TiXmlAttribute* m_tiXmlPointer;
+		TiXmlBase* GetBasePointer() const
+		{
+			ValidatePointer();
+			return m_tiXmlPointer;
+		}
+
+	public:
+		/**
+		Construct an empty attribute.
+		*/
+		Attribute();
+
+		/**
+		Construct an attribute with @a name and @a value
+
+		@param name The name of the attribute
+		@param value The value of the attribute
+		*/
+		Attribute( const std::string& name, const std::string& value );
+
+		/**
+		@internal
+		Construct an attribute with the internal pointer
+
+		@param attribute The internal pointer
+		*/
+		Attribute( TiXmlAttribute* attribute );
+
+		/**
+		Get the value of this attribute
+		Uses Base::FromString to convert TiXmlAttribute::ValueStr from a std::string,
+		and puts it in the passed pointer.
+
+		@param value [OUT] A pointer to fill with the value
+		*/
+		template < class T >
+			void GetValue( T* value ) const
+		{
+			ValidatePointer();
+			FromString( m_tiXmlPointer->ValueStr(), value );
+		}
+
+		/**
+		Get the value of this attribute.
+		Simple wrapper for TiXmlAttribute::ValueStr.
+
+		@see GetValue
+		*/
+		std::string Value() const;
+
+		/**
+		Set the value of this node.
+		Uses Base::ToString to convert value to a std::string, then calls TiXmlAttribute::SetValue.
+
+		@param value The value to set
+		*/
+		template < class T >
+			void SetValue( const T& value )
+		{
+			ValidatePointer();
+			m_tiXmlPointer->SetValue( ToString( value ) );
+		}
+
+		/**
+		Get the value of this attribute
+		Uses Base::FromString to convert TiXmlAttribute::Name from a std::string,
+		and puts it in the passed pointer.
+
+		@param name [OUT] A pointer to fill with the name
+		*/
+		template < class T >
+			void GetName( T* name ) const
+		{
+			ValidatePointer();
+			FromString( m_tiXmlPointer->Name(), name );
+		}
+
+		/**
+		Get the value of this attribute.
+		Simple wrapper for TiXmlAttribute::Name.
+
+		@see GetName
+		*/
+		std::string Name() const;
+
+		/**
+		Set the value of this attribute.
+		Uses Base::ToString to convert @a name to a std::string, then calls TiXmlAttribute::SetName.
+
+		@param name The name to set
+		*/
+		template < class T >
+			void SetName( const T& name )
+		{
+			ValidatePointer();
+			m_tiXmlPointer->SetName( ToString( name ) );
+		}
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		*/
+		void operator=( const Attribute& copy );
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		*/
+		Attribute( const Attribute& copy );
+
+		/*
+		Decrements reference count.
+		*/
+		~Attribute();
+
+		/**
+		Get the next sibling attribute in the DOM.
+		*/
+		Attribute* Next( bool throwIfNoAttribute = true ) const;
+
+		/**
+		Get the previous sibling attribute in the DOM.
+		*/
+		Attribute* Previous( bool throwIfNoAttribute = true ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param next [OUT] The pointer to the next valid attribute
+		@return true if there is a next attribute, false if not
+		*/
+		void IterateNext( const std::string&, Attribute** next ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param previous [OUT] The pointer to the previous valid attribute
+		@return true if there is a previous attribute, false if not
+		*/
+		void IteratePrevious( const std::string&, Attribute** previous ) const;
+
+		/**
+		All TinyXml classes can print themselves to a filestream.
+		*/
+		virtual void Print( FILE* file, int depth ) const;
+
+	private:
+
+		/**
+		@internal
+		Sets the internal pointer.
+		Saves a copy of the pointer to the RC object.
+
+		@param newPointer TiXmlAttribute* to set.
+		*/
+		void SetTiXmlPointer( TiXmlAttribute* newPointer );
+	};
+
+	/**
+	Wrapper around TiXmlNode
+	*/
+	class Node : public Base
+	{
+	public:
+
+		/**
+		Get the value of this node
+		Uses Base::FromString to convert TiXmlNode::ValueStr from a std::string,
+		and puts it in the passed pointer.
+
+		@param value [OUT] A pointer to fill with the value
+		*/
+		template < class T >
+			void GetValue( T* value) const
+		{
+			FromString( GetTiXmlPointer()->ValueStr(), value );
+		}
+
+		/**
+		Get the value of this node.
+		Simple wrapper for TiXmlNode::ValueStr.
+
+		@see GetValue
+		*/
+		std::string Value() const;
+
+		/**
+		Set the value of this node.
+		Uses Base::ToString to convert value to a std::string, then calls TiXmlNode::SetValue.
+
+		@param value The value to set
+		*/
+		template < class T >
+			void SetValue( const T& value )
+		{
+			GetTiXmlPointer()->SetValue( ToString( value ) );
+		}
+
+		/**
+		Clear all Nodes below this.
+		Simple wrapper for TiXmlNode::Clear.
+		*/
+		void Clear();
+
+		/**
+		The Parent of this Node.
+		Simple wrapper for TiXmlNode::Parent.
+
+		@param throwIfNoParent [DEF] If true, throws when Parent = NULL.
+		@return The parent of this node, NULL if there is no Parent.
+		@throws Exception When throwIfNoParent is true, and TiXmlNode::Parent returns Null.
+		*/
+		Node* Parent( bool throwIfNoParent = true ) const;
+
+		/**
+		The first child of this node.
+
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
+		@return Pointer to child, Null if no children and 'throwIfNoChildren' is false.
+		@throws Exception When throwIfNoChildren is true, and TiXmlNode::FirstChild returns Null.
+
+		@see TiXmlNode::FirstChild
+		*/
+		Node* FirstChild( bool throwIfNoChildren = true ) const;
+
+		/**
+		@internal
+		The first child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see FirstChild( bool throwIfNoChildren = true )
+		*/
+		Node* FirstChild( const char* value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The first child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see FirstChild( const char* value, bool throwIfNoChildren = true )
+		*/
+		Node* FirstChild( const std::string& value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The last child of this node.
+
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no children.
+		@return Pointer to child, Null if no children and 'throwIfNoChildren' is false.
+		@throws Exception When throwIfNoChildren is true, and TiXmlNode::LastChild returns Null.
+
+		@see TiXmlNode::LastChild
+		*/
+		Node* LastChild( bool throwIfNoChildren = true ) const;
+
+		/**
+		@internal
+		The last child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see LastChild( bool throwIfNoChildren = true )
+		*/
+		Node* LastChild( const char* value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The last child of this node with the matching @a value.
+
+		@overload
+		@param value				Value to match.
+		@param throwIfNoChildren	[DEF] If true, will throw an exception if there are no children.
+
+		@see LastChild( const char* value, bool throwIfNoChildren = true )
+		*/
+		Node* LastChild( const std::string& value, bool throwIfNoChildren = true ) const;
+
+		/**
+		An alternate way to walk the children of a node.
+		Simple wrapper for TiXmlNode::IterateChildren.
+
+		@param previous The previous Node* that was returned from IterateChildren.
+		@return NULL When there are no more children.
+		*/
+		Node* IterateChildren( Node* previous ) const;
+
+		/**
+		This flavor of IterateChildren searches for children with a particular @a value.
+		Simple wrapper for TiXmlNode::IterateChildren.
+
+		@param value	The value you want to search for.
+		@param previous The previous Node* that was returned from IterateChildren.
+		@return NULL When there are no more children.
+		*/
+		Node* IterateChildren( const std::string& value, Node* previous ) const;
+
+		/**
+		Adds a child past the LastChild.
+		Throws if you try to insert a document.
+
+		@note This takes a copy of @a addThis so it is not as efficiant as LinkEndChild.
+		@param addThis Node to insert.
+		@throws Exception When TiXmlNode::InsertEndChild returns Null
+
+		@see LinkEndChild
+		@see TiXmlNode::InsertEndChild
+		*/
+		Node* InsertEndChild( Node& addThis );
+
+		/**
+		Adds a child past the LastChild.
+		Throws if you try to link a document.
+
+		@param childNode Node to link.
+		@throws Exception When TiXmlNode::LinkEndChild returns Null.
+
+		@see InsertEndChild
+		@see TiXmlNode::LinkEndChild
+		*/
+		Node* LinkEndChild( Node* childNode );
+
+		/**
+		Adds a child before the specified child.
+		Throws if you try to insert a document.
+
+		@param beforeThis	Node that will have @a addThis linked before.
+		@param addThis		Node to insert before.
+		@throws Exception When TiXmlNode::InsertBeforeChild returns Null.
+
+		@see InsertAfterChild
+		@see TiXmlNode::InsertBeforeChild
+		*/
+		Node* InsertBeforeChild( Node* beforeThis, Node& addThis );
+
+		/**
+		Adds a child after the specified child.
+		Throws if you try to insert a document.
+
+		@param afterThis	Node that will have @a addThis linked after.
+		@param addThis		Node to insert after.
+		@throws Exception When TiXmlNode::InsertAfterChild returns Null.
+
+		@see InsertBeforeChild
+		@see TiXmlNode::InsertAfterChild
+		*/
+		Node* InsertAfterChild( Node* afterThis, Node& addThis );
+
+		/**
+		Replace a child of this node.
+		Throws if you try to replace with a document.
+
+		@param replaceThis	Node to replace.
+		@param withThis		Node that is replacing @a replaceThis.
+		@throws Exception When TiXmlNode::ReplaceChild returns Null.
+
+		@see TiXmlNode::ReplaceChild
+		*/
+		Node* ReplaceChild( Node* replaceThis, Node& withThis );
+
+		/**
+		Delete a child of this node.
+
+		@param removeThis Node to delete.
+		@throws Exception When removeThis is not a child of this Node.
+
+		@see TiXmlNode::RemoveChild
+		*/
+		void RemoveChild( Node* removeThis );
+
+		/**
+		Navigate to a sibling node.
+		Wrapper around TiXmlNode::PreviousSibling.
+
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+		@return Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
+		@throws Exception When TiXmlNode::PreviousSibling returns Null and 'throwIfNoSiblings' is true.
+		*/
+		Node* PreviousSibling( bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see PreviousSibling( bool throwIfNoSiblings )
+		*/
+		Node* PreviousSibling( const std::string& value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see PreviousSibling( const std::string& value, bool throwIfNoSiblings )
+		*/
+		Node* PreviousSibling( const char* value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling node.
+		Wrapper around TiXmlNode::NextSibling.
+
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+		@return Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
+		@throws Exception When TiXmlNode::NextSibling returns Null and 'throwIfNoSiblings' is true.
+		*/
+		Node* NextSibling( bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see NextSibling( bool throwIfNoSiblings )
+		*/
+		Node* NextSibling( const std::string& value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Navigate to a sibling node with the given @a value.
+
+		@overload
+		@param value The value of the node to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no siblings.
+
+		@see NextSibling( const std::string& value, bool throwIfNoSiblings )
+		*/
+		Node* NextSibling( const char* value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param next [OUT] The pointer to the first valid node
+		*/
+		template < class T >
+			void IterateFirst( const std::string& value, T** first ) const
+		{
+			*first = 0;
+			for( Node* child = FirstChild( value, false ); child; child = child->NextSibling( value, false ) )
+			{
+				*first = dynamic_cast< T* >( child );
+				if ( 0 != *first )
+				{
+					return;
+				}
+			}
+		}
+
+		virtual	void IterateFirst( const std::string&, Attribute** ) const
+		{
+			TICPPTHROW( "Attributes can only be iterated with Elements." )
+		}
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param next [OUT] The pointer to the next valid node
+		*/
+		template < class T >
+			void IterateNext( const std::string& value, T** next ) const
+		{
+			Node* sibling = NextSibling( value, false );
+			*next = dynamic_cast< T* >( sibling );
+
+			while ( ( 0 != sibling ) && ( 0 == *next ) )
+			{
+				sibling = sibling->NextSibling( value, false );
+				*next = dynamic_cast< T* >( sibling );
+			}
+		}
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param previous [OUT] The pointer to the previous valid node
+		*/
+		template < class T >
+			void IteratePrevious( const std::string& value, T** previous  ) const
+		{
+			Node* sibling = PreviousSibling( value, false );
+			*previous = dynamic_cast< T* >( sibling );
+
+			while ( ( 0 != sibling ) && ( 0 == *previous ) )
+			{
+				sibling = sibling->PreviousSibling( value, false );
+				*previous = dynamic_cast< T* >( sibling );
+			}
+		}
+
+		/**
+		Navigate to a sibling element.
+		Wrapper around TiXmlNode::NextSibling.
+
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling element.
+		@return Pointer to sibling, Null if no siblings and 'throwIfNoSiblings' is false.
+		@throws Exception When TiXmlNode::NextSibling returns Null and 'throwIfNoSiblings' is true.
+		*/
+		Element* NextSiblingElement( bool throwIfNoSiblings = true ) const;
+
+		/**
+		Navigate to a sibling element with the given @a value.
+
+		@overload
+		@param value The value of the element to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling elements.
+		@see NextSiblingElement( bool throwIfNoSiblings )
+		*/
+		Element* NextSiblingElement( const std::string& value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		@internal
+		Navigate to a sibling element with the given @a value.
+
+		@overload
+		@param value The value of the element to look for.
+		@param throwIfNoSiblings [DEF] If true, will throw an exception if there are no sibling elements.
+
+		@see NextSiblingElement( const std::string& value, bool throwIfNoSiblings )
+		*/
+		Element* NextSiblingElement( const char* value, bool throwIfNoSiblings = true ) const;
+
+		/**
+		The first child element of this node.
+
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
+		@return Pointer to child, Null if no element children and 'throwIfNoChildren' is false.
+		@throws Exception When throwIfNoChildren is true, and TiXmlNode::FirstChildElement returns Null.
+
+		@see TiXmlNode::FirstChildElement
+		*/
+		Element* FirstChildElement( bool throwIfNoChildren = true ) const;
+
+		/**
+		@internal
+		The first child element of this node with the matching @a value.
+
+		@overload
+		@param value Value to match.
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
+
+		@see FirstChildElement( bool throwIfNoChildren = true )
+		*/
+		Element* FirstChildElement( const char* value, bool throwIfNoChildren = true ) const;
+
+		/**
+		The first child element of this node with the matching @a value.
+
+		@overload
+		@param value Value to match.
+		@param throwIfNoChildren [DEF] If true, will throw an exception if there are no element children.
+
+		@see FirstChildElement( const char* value, bool throwIfNoChildren = true )
+		*/
+		Element* FirstChildElement( const std::string& value, bool throwIfNoChildren = true ) const;
+
+		/**
+		Query the type (as TiXmlNode::NodeType ) of this node.
+		*/
+		int Type() const;
+
+		/**
+		Return a pointer to the Document this node lives in.
+
+		@param throwIfNoDocument [DEF] If true, will throw an exception if this node is not linked under a Document.
+		@return A pointer to the Document this node lives in, NULL if not linked under a Document, and 'throwIfNoDocument' is false.
+		@throws Exception When this node is not linked under a Document and 'throwIfNoDocument' is true.
+		*/
+		Document* GetDocument( bool throwIfNoDocument = true ) const;
+
+		/**
+		Check if this node has no children.
+
+		@return true if this node has no children.
+		*/
+		bool NoChildren() const;
+
+		/**
+		Pointer conversion ( NOT OBJECT CONVERSION ) - replaces TiXmlNode::ToElement, TiXmlNode::ToDocument, TiXmlNode::ToComment, etc.
+
+		@throws Exception When the target is not an object of class T
+		@warning Some ancient compilers do not support explicit specification of member template arguments, which this depends on ( e.g. VC6 ).
+		*/
+		template < class T >
+			T* To() const
+		{
+			T* pointer = dynamic_cast< T* >( this );
+			if ( 0 == pointer )
+			{
+				std::string thisType = typeid( this ).name();
+				std::string targetType = typeid( T ).name();
+				std::string thatType = typeid( *this ).name();
+				TICPPTHROW( "The " << thisType.substr( 6 ) << " could not be casted to a " << targetType.substr( 6 )
+					<< " *, because the target object is not a " << targetType.substr( 6 ) << ". (It is a " << thatType.substr( 6 ) << ")" );
+			}
+			return pointer;
+		}
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToDocument.
+
+		@throws Exception When this node is not a Document.
+		*/
+		Document* ToDocument() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToElement.
+
+		@throws Exception When this node is not a Element.
+		*/
+		Element* ToElement() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToComment.
+
+		@throws Exception When this node is not a Comment.
+		*/
+		Comment* ToComment() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToText.
+
+		@throws Exception When this node is not a Text.
+		*/
+		Text* ToText() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToDeclaration.
+
+		@throws Exception When this node is not a Declaration.
+		*/
+		Declaration* ToDeclaration() const;
+
+		/**
+		Pointer conversion - replaces TiXmlNode::ToStylesheetReference.
+
+		@throws Exception When this node is not a StylesheetReference.
+		*/
+		StylesheetReference* ToStylesheetReference() const;
+
+		/**
+		Create an exact duplicate of this node and return it.
+
+		@note Using auto_ptr to manage the memory declared on the heap by TiXmlNode::Clone.
+		@code
+		// Now using clone
+		ticpp::Document doc( "C:\\Test.xml" );
+		ticpp::Node* sectionToClone;
+		sectionToClone = doc.FirstChild( "settings" );
+		std::auto_ptr< ticpp::Node > clonedNode = sectionToClone->Clone();
+		// Now you can use the clone.
+		ticpp::Node* node2 = clonedNode->FirstChildElement()->FirstChild();
+		...
+		// After the variable clonedNode goes out of scope it will automatically be cleaned up.
+		@endcode
+		@return Pointer the duplicate node.
+		*/
+		std::auto_ptr< Node > Clone() const;
+
+		/**
+		Accept a hierchical visit the nodes in the TinyXML DOM.
+		@return The boolean returned by the visitor.
+		*/
+		bool Accept( TiXmlVisitor* visitor ) const;
+
+		/**
+ 		Stream input operator.
+ 		*/
+ 		friend std::istream& operator >>( std::istream& in, Node& base )
+ 		{
+ 			in >> *base.GetTiXmlPointer();
+ 			return in;
+ 		}
+
+ 		/**
+ 		Stream output operator.
+ 		*/
+ 		friend std::ostream& operator <<( std::ostream& out, const Node& base )
+ 		{
+ 			out << *base.GetTiXmlPointer();
+ 			return out;
+ 		}
+
+	protected:
+		/**
+		@internal
+		Allows NodeImp to use Node*'s.
+		*/
+		virtual TiXmlNode* GetTiXmlPointer() const = 0;
+
+		TiXmlBase* GetBasePointer() const
+		{
+			return GetTiXmlPointer();
+		}
+
+		/**
+		@internal
+		Constructs the correct child of Node, based on the Type of the TiXmlNode*.
+		*/
+		Node* NodeFactory( TiXmlNode* tiXmlNode, bool throwIfNull = true, bool rememberSpawnedWrapper = true ) const;
+
+	};
+
+	/** Iterator for conveniently stepping through Nodes and Attributes.
+	TinyXML++ introduces iterators:
+	@code
+	ticpp::Iterator< ticpp::Node > child;
+	for ( child = child.begin( parent ); child != child.end(); child++ )
+	@endcode
+
+	Iterators have the added advantage of filtering by type:
+	@code
+	// Only iterates through Comment nodes
+	ticpp::Iterator< ticpp::Comment > child;
+	for ( child = child.begin( parent ); child != child.end(); child++ )
+	@endcode
+
+	@code
+	// Only iterates through Element nodes with value "ElementValue"
+	ticpp::Iterator< ticpp::Element > child( "ElementValue" );
+	for ( child = child.begin( parent ); child != child.end(); child++ )
+	@endcode
+
+	Finally, Iterators also work with Attributes
+	@code
+	ticpp::Iterator< ticpp::Attribute > attribute;
+	for ( attribute = attribute.begin( element ); attribute != attribute.end(); attribute++ )
+	@endcode
+	*/
+	template < class T = Node >
+		class Iterator
+	{
+	private:
+		T* m_p;					/**< Internal Pointer */
+		std::string m_value;	/**< Value for NextSibling  calls */
+
+	public:
+
+		/**
+		For for loop comparisons.
+		@param parent The parent of the nodes to iterate.
+		@return The first child of type T.
+		@code
+		ticpp::Iterator< ticpp::Node > child;
+		for ( child = child.begin( parent ); child != child.end(); child++ )
+		@endcode
+		*/
+		T* begin( const Node* parent ) const
+		{
+			T* pointer;
+			parent->IterateFirst( m_value, &pointer );
+			return pointer;
+		}
+
+		/**
+		For for loop comparisons.
+		@return NULL
+		@code
+		ticpp::Iterator< ticpp::Node > child;
+		for ( child = child.begin( parent ); child != child.end(); child++ )
+		@endcode
+		*/
+		T* end() const
+		{
+			return 0;
+		}
+
+		/** Constructor.
+		@param value If not empty, this iterator will only visit nodes with matching value.
+		@code
+		// Only iterates through Element nodes with value "ElementValue"
+		ticpp::Iterator< ticpp::Element > child( "ElementValue" );
+		for ( child = child.begin( parent ); child != child.end(); child++ )
+		@endcode
+		*/
+		Iterator( const std::string& value = "" )
+			: m_p( 0 ), m_value( value )
+		{
+		}
+
+		/// Constructor
+		Iterator( T* node, const std::string& value = "" )
+			: m_p( node ), m_value( value )
+		{
+		}
+
+		/// Constructor
+		Iterator( const Iterator& it, const std::string& value  = "" )
+			: m_p( it.m_p ), m_value( value )
+		{
+		}
+
+		/**
+		Gets internal pointer.
+		@return The internal pointer.
+		*/
+		T* Get() const
+		{
+			return m_p;
+		}
+
+		/** Sets internal pointer */
+		Iterator& operator=( const Iterator& it )
+		{
+			m_p = it.m_p;
+			return *this;
+		}
+
+		/** Sets internal pointer */
+		Iterator& operator=( T* p )
+		{
+			m_p = p;
+			return *this;
+		}
+
+		/** Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings */
+		Iterator& operator++()
+		{
+			m_p->IterateNext( m_value, &m_p );
+			return *this;
+		}
+
+		/** Sets internal pointer to the Next Sibling, or Iterator::END, if there are no more siblings */
+		Iterator& operator++(int)
+		{
+			return this->operator ++();
+		}
+
+		/** Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings */
+		Iterator& operator--()
+		{
+			m_p->IteratePrevious( m_value, &m_p );
+			return *this;
+		}
+
+		/** Sets internal pointer to the Previous Sibling, or Iterator::END, if there are no prior siblings */
+		Iterator& operator--(int)
+		{
+			return this->operator --();
+		}
+
+		/** Compares internal pointer */
+		bool operator!=( T* p ) const
+		{
+			return m_p != p;
+		}
+
+		/** Compares internal pointer */
+		bool operator!=( const Iterator& it ) const
+		{
+			return m_p != it.m_p;
+		}
+
+		/** Compares internal pointer* */
+		bool operator==( T* p ) const
+		{
+			return m_p == p;
+		}
+
+		/** Compares internal pointer */
+		bool operator==( const Iterator& it ) const
+		{
+			return m_p == it.m_p;
+		}
+
+		/** So Iterator behaves like a STL iterator */
+		T* operator->() const
+		{
+			return m_p;
+		}
+
+		/** So Iterator behaves like a STL iterator */
+		T& operator*() const
+		{
+			return *m_p;
+		}
+	};
+
+	/** Implementation of Node wrapper */
+	template < class T >
+		class NodeImp : public Node
+	{
+	protected:
+
+		T* m_tiXmlPointer;		/**< Internal pointer to the TiXml Class which is being wrapped */
+
+		/**
+		@internal
+		Gets the internal TinyXML pointer.
+
+		@returns The internal TiXmlNode*.
+		*/
+		TiXmlNode* GetTiXmlPointer() const
+		{
+			ValidatePointer();
+			return m_tiXmlPointer;
+		}
+
+		/**
+		@internal
+		Sets the internal pointer.
+		Saves a copy of the pointer to the RC object.
+
+		@param newPointer TiXmlNode* to set.
+		*/
+		void SetTiXmlPointer( T* newPointer )
+		{
+			m_tiXmlPointer = newPointer;
+			SetImpRC( newPointer );
+		}
+
+		/**
+		@internal
+		Constructor used by child classes.
+		*/
+		NodeImp( T* tiXmlPointer )
+		{
+			// Check for NULL pointers
+			if ( 0 == tiXmlPointer )
+			{
+				TICPPTHROW( "Can not create a " << typeid( T ).name() );
+			}
+			SetTiXmlPointer( tiXmlPointer );
+			m_impRC->IncRef();
+		}
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		In addition, the spawnedWrappers must be cleared out before a new TiXml object is loaded in.
+		*/
+		virtual void operator=( const NodeImp<T>& copy )
+		{
+			DeleteSpawnedWrappers();
+
+			// Dropping the reference to the old object
+			this->m_impRC->DecRef();
+
+			// Pointing to the new Object
+			SetTiXmlPointer( copy.m_tiXmlPointer );
+
+			// The internal tixml pointer changed in the above line
+			this->m_impRC->IncRef();
+		}
+
+		/**
+		@internal
+		Updates the reference count for the old and new pointers.
+		In addition, the spawnedWrappers must be cleared out before a new TiXml object is loaded in
+		*/
+		NodeImp( const NodeImp<T>& copy ) : Node( copy )
+		{
+			// Pointing to the new Object
+			SetTiXmlPointer( copy.m_tiXmlPointer );
+
+			// The internal tixml pointer changed in the above line
+			this->m_impRC->IncRef();
+		}
+
+	public:
+
+		/*
+		Deletes the spawned wrapper objects.
+		Decrements reference count.
+		*/
+		virtual ~NodeImp()
+		{
+			// The spawnedWrappers need to be deleted before m_tiXmlPointer
+			DeleteSpawnedWrappers();
+			m_impRC->DecRef();
+		}
+	};
+
+	/** Wrapper around TiXmlComment */
+	class Comment : public NodeImp< TiXmlComment >
+	{
+	public:
+
+		/**
+		Constructor.
+		*/
+		Comment();
+
+		/**
+		Constructor.
+		*/
+		Comment( TiXmlComment* comment );
+
+		/**
+		Constructor.
+		*/
+		Comment( const std::string& comment );
+	};
+
+	/** Wrapper around TiXmlText */
+	class Text : public NodeImp< TiXmlText >
+	{
+	public:
+
+		/**
+		Constructor.
+		*/
+		Text();
+
+		/**
+		Constructor.
+		@overload
+		*/
+		Text( TiXmlText* text );
+
+		/**
+		Constructor.
+		@overload
+		*/
+		Text( const std::string& value );
+
+		/**
+		Streams value into a string and creates a Text with it.
+		Uses ToString to covert the parameter to a string.
+
+		@param value The value of the Text node.
+		@throws Exception
+
+		@see TiXmlText
+        */
+		template < class T >
+			Text( const T& value )
+				: NodeImp< TiXmlText >( new TiXmlText( ToString( value ) ) )
+		{
+			m_impRC->InitRef();
+		}
+	};
+
+	/** Wrapper around TiXmlDocument */
+	class Document : public NodeImp< TiXmlDocument >
+	{
+	public:
+		/**
+		Default	Constructor.
+		Create an empty document, that has no name.
+		*/
+		Document();
+
+		/**
+		Constructor.
+		*/
+		Document( TiXmlDocument* document );
+
+		/**
+		Constructor.
+		*/
+		Document( const char* documentName );
+
+		/**
+		Constructor.
+		Create a document with a name. The name of the document is also the filename of the xml.
+
+		@param documentName Name to set in the Document.
+		*/
+		Document( const std::string& documentName );
+
+		/**
+		Load a file using the current document value. Throws if load is unsuccessful.
+
+		@param encoding Sets the documents encoding.
+		@see TiXmlEncoding
+		@throws Exception
+		*/
+		void LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+		/**
+		Save a file using the current document value. Throws if it can't save the file.
+
+		@throws Exception
+		*/
+		void SaveFile() const;
+
+		/**
+		Load a file using the given filename. Throws if load is unsuccessful.
+
+		@param filename File to load.
+		@param encoding Sets the documents encoding.
+		@see TiXmlEncoding
+		@throws Exception
+		*/
+		void LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+		/**
+		@copydoc Document::LoadFile( const std::string&, TiXmlEncoding )
+		*/
+		void LoadFile( const char* filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+		/**
+		Save a file using the given filename. Throws if it can't save the file.
+
+		@param filename File to save.
+		@throws Exception
+		*/
+		void SaveFile( const std::string& filename ) const;
+
+		/**
+		Parse the given xml data.
+
+		@param xml Xml to parse.
+		@param throwIfParseError [DEF] If true, throws when there is a parse error.
+		@param encoding Sets the documents encoding.
+		@throws Exception
+		*/
+		void Parse( const std::string& xml, bool throwIfParseError = true, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	};
+
+	/** Wrapper around TiXmlElement */
+	class Element : public NodeImp< TiXmlElement >
+	{
+	public:
+		/**
+		Default Constructor.
+		*/
+		Element();
+
+		/**
+		Default	Constructor. Initializes all the variables.
+		@param value The value of the element.
+		*/
+		Element( const std::string& value );
+
+		/**
+		Default	Constructor. Initializes all the variables.
+		@param value The value of the element.
+		*/
+		Element( const char* value );
+
+		/**
+		Constructor.
+		*/
+		Element( TiXmlElement* element );
+
+		/**
+		Constructor that allows you to set the element text
+		@param value The value of the element.
+		@param text The text to set.
+		*/
+		template < class T >
+			Element( const std::string& value, const T& text )
+			: NodeImp< TiXmlElement >( new TiXmlElement( value ) )
+		{
+			m_impRC->InitRef();
+			SetText( text );
+		}
+
+		/**
+		Access the first attribute in this element.
+
+		@param throwIfNoAttributes [DEF] If true, throws when there are no attributes
+		@return The first attribute, NULL if there are none and @a throwIfNoAttributes is true
+		*/
+		Attribute* FirstAttribute( bool throwIfNoAttributes = true ) const;
+
+		/**
+		Access the last attribute in this element.
+
+		@param throwIfNoAttributes [DEF] If true, throws when there are no attributes
+		@return The last attribute, NULL if there are none and @a throwIfNoAttributes is true
+		*/
+		Attribute* LastAttribute( bool throwIfNoAttributes = true ) const;
+
+		/**
+		@internal
+		Just for Iterator<>
+
+		@param value The value of nodes to iterate through
+		@param next [OUT] The pointer to the first valid node
+		*/
+		void IterateFirst( const std::string&, Attribute** first ) const
+		{
+			*first = 0;
+			for( Attribute* child = FirstAttribute( false ); child; child = child->Next( false ) )
+			{
+				*first = dynamic_cast< Attribute* >( child );
+				if ( 0 != *first )
+				{
+					return;
+				}
+			}
+		}
+
+		/**
+		Sets an attribute of name to a given value.
+		The attribute will be created if it does not exist, or changed if it does.
+		Uses ToString to convert the @a value to a string, so there is no need to use any other SetAttribute methods.
+
+		@see GetAttribute
+		*/
+		template < class T >
+			void SetAttribute ( const std::string& name, const T& value )
+		{
+			ValidatePointer();
+			m_tiXmlPointer->SetAttribute( name, ToString( value ) );
+		}
+
+		/**
+		Gets the text of an Element.
+
+		@param throwIfNotFound	[DEF]	If true, will throw an exception if there is no text in this element
+		@note This only works if the Text is the FirstChild node
+		@throws Exception When there is no text and throwIfNotFound is true
+
+		@see GetText( T* value, bool throwIfNotFound = false )
+		@see GetTextOrDefault
+		@see GetTextOrDefault( T* value, const DefaultT& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		std::string GetText( bool throwIfNotFound = true ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				if ( throwIfNotFound )
+				{
+					TICPPTHROW( "Text does not exists in the current element" );
+				}
+			}
+
+			return temp;
+		}
+
+		/**
+		Gets the text of an Element, if it doesn't exist it will return the defaultValue.
+
+		@param defaultValue			What to put in 'value' if there is no text in this element
+		@note This only works if the Text is the FirstChild node
+
+		@see GetText
+		@see GetText( T* value, bool throwIfNotFound = false )
+		@see GetTextOrDefault( T* value, const DefaultT& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		std::string GetTextOrDefault( const std::string& defaultValue ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				return defaultValue;
+			}
+
+			return temp;
+		}
+
+		/**
+		Gets the text value of an Element, if it doesn't exist it will return the defaultValue.
+		Uses FromString to convert the string to the type of choice
+
+		@param value		[OUT]	The container for the returned value
+		@param defaultValue			What to put in 'value' if there is no text in this element
+		@note This is different than GetText() in that it will covert the text to what ever type you want.
+		@note This only works if the Text is the FirstChild node
+
+		@see GetText
+		@see GetText( T* value, bool throwIfNotFound = false )
+		@see GetTextOrDefault( const std::string& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		template < class T, class DefaultT >
+			void GetTextOrDefault( T* value, const DefaultT& defaultValue ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				// The text value does not exist - set value to the default
+				*value = defaultValue;
+				return;
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Gets the text of an Element.
+		Uses FromString to convert the string to the type of choice.
+
+		@param value			[OUT]	The container for the returned value
+		@param throwIfNotFound	[DEF]	If true, will throw an exception if there is no text in this element
+		@note This is different than GetText() in that it will covert the text to what ever type you want
+		@note This only works if the Text is the FirstChild node
+		@throws Exception When there is no text and throwIfNotFound is true
+
+		@see GetText
+		@see GetTextOrDefault
+		@see GetTextOrDefault( T* value, const DefaultT& defaultValue )
+		@see TiXmlElement::GetText
+		*/
+		template< class T >
+			void GetText( T* value, bool throwIfNotFound = true ) const
+		{
+			// Get the element's text value as a std::string
+			std::string temp;
+			if ( !GetTextImp( &temp ) )
+			{
+				if ( throwIfNotFound )
+				{
+					TICPPTHROW( "Text does not exists in the current element" );
+				}
+				else
+				{
+					return;
+				}
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Convenience function to set the text of an element.
+		Creates a Text node and inserts it as the first child.
+		Uses ToString to convert the parameter to a string.
+
+		@param value The text to set.
+		*/
+		template < class T >
+			void SetText( const T& value )
+		{
+			ValidatePointer();
+			std::string temp = ToString( value );
+
+			if ( m_tiXmlPointer->NoChildren() )
+			{
+				m_tiXmlPointer->LinkEndChild( new TiXmlText( temp ) );
+			}
+			else
+			{
+				if ( 0 == m_tiXmlPointer->GetText() )
+				{
+					m_tiXmlPointer->InsertBeforeChild( m_tiXmlPointer->FirstChild(), TiXmlText( temp ) );
+				}
+				else
+				{
+					// There already is text, so change it
+					m_tiXmlPointer->FirstChild()->SetValue( temp );
+				}
+			}
+		}
+
+		/**
+		Gets an attribute of @a name from an element, if it doesn't exist it will return the defaultValue.
+		Uses FromString to convert the string to the type of choice.
+
+		@param name			The name of the attribute you are querying.
+		@param value		[OUT] The container for the returned value.
+		@param defaultValue	What to put in @a value if there is no attribute in this element.
+		@throws Exception
+
+		@see GetAttribute
+		*/
+		template < class T, class DefaulT >
+			void GetAttributeOrDefault( const std::string& name, T* value, const DefaulT& defaultValue ) const
+		{
+			// Get the attribute's value as a std::string
+			std::string temp;
+			if ( !GetAttributeImp( name, &temp ) )
+			{
+				// The attribute does not exist - set value to the default
+				*value = defaultValue;
+				return;
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Gets an attribute of @a name from an element, if it doesn't exist it will return the defaultValue.
+
+		@param name			The name of the attribute you are querying.
+		@param defaultValue	What to put in @a value if there is no attribute in this element.
+
+		@see GetAttribute
+		*/
+		std::string GetAttributeOrDefault( const std::string& name, const std::string& defaultValue ) const;
+
+		/**
+		Gets an attribute of @a name from an element.
+		Uses FromString to convert the string to the type of choice.
+
+		@param name				The name of the attribute you are querying.
+		@param value			[OUT]	The container for the returned value
+		@param throwIfNotFound	[DEF]	If true, will throw an exception if the attribute doesn't exist
+		@throws Exception When the attribute doesn't exist and throwIfNotFound is true
+
+		@see GetAttributeOrDefault
+		*/
+		template< class T >
+			void GetAttribute( const std::string& name, T* value, bool throwIfNotFound = true ) const
+		{
+			// Get the attribute's value as a std::string
+			std::string temp;
+			if ( !GetAttributeImp( name, &temp ) )
+			{
+				if ( throwIfNotFound )
+				{
+					TICPPTHROW( "Attribute does not exist" );
+				}
+				else
+				{
+					return;
+				}
+			}
+
+			// Stream the value from the string to T
+			FromString( temp, value );
+		}
+
+		/**
+		Gets an attribute of @a name from an element.
+		Returns an empty string if the attribute does not exist.
+
+		@param name	The name of the attribute you are querying.
+		@return The value of the attribute, or an empty string if it does not exist.
+
+		@see GetAttributeOrDefault
+		*/
+		std::string GetAttribute( const std::string& name ) const;
+
+	private:
+
+		/**
+		@internal
+		Implimentation of the GetAttribute and GetAttributeOrDefault template methods.
+		*/
+		bool GetAttributeImp( const std::string& name, std::string* value ) const;
+
+		/**
+		@internal
+		Implimentation of the GetText, GetTextOrDefault, GetTextValue, and GetTextValueOrDefault template methods.
+		*/
+		bool GetTextImp( std::string* value ) const;
+	};
+
+	/** Wrapper around TiXmlDeclaration */
+	class Declaration : public NodeImp< TiXmlDeclaration >
+	{
+	public:
+		/**
+		Default	Constructor. Construct an empty declaration.
+		*/
+		Declaration();
+
+		/**
+		Constructor.
+		*/
+		Declaration( TiXmlDeclaration* declaration );
+
+		/**
+		Constructor.
+		*/
+		Declaration( const std::string& version, const std::string& encoding, const std::string& standalone );
+
+		/**
+		Version. Will return an empty string if none was found.
+		*/
+		std::string Version() const;
+
+		/**
+		Encoding. Will return an empty string if none was found.
+		*/
+		std::string Encoding() const;
+
+		/**
+		StandAlone. Is this a standalone document?
+		*/
+		std::string Standalone() const;
+	};
+
+	/** Wrapper around TiXmlStylesheetReference */
+	class StylesheetReference : public NodeImp< TiXmlStylesheetReference >
+	{
+	public:
+		/**
+		Default	Constructor. Construct an empty declaration.
+		*/
+		StylesheetReference();
+
+		/**
+		Constructor.
+		*/
+		StylesheetReference( TiXmlStylesheetReference* stylesheetReference );
+
+		/**
+		Constructor.
+		*/
+		StylesheetReference( const std::string& type, const std::string& href );
+
+		/**
+		Type. Will return an empty string if none was found.
+		*/
+		std::string Type() const;
+
+		/**
+		Href. Will return an empty string if none was found.
+		*/
+		std::string Href() const;
+	};
+}
+
+#endif	// TICPP_INCLUDED
+
+#endif // TIXML_USE_TICPP
Index: /code/branches/ceguilua/src/tinyxml/ticpprc.h
===================================================================
--- /code/branches/ceguilua/src/tinyxml/ticpprc.h	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/ticpprc.h	(revision 1801)
@@ -0,0 +1,116 @@
+#define TIXML_USE_TICPP
+
+/*
+http://code.google.com/p/ticpp/
+Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*/
+
+#ifdef TIXML_USE_TICPP
+
+#ifndef TICPPRC_INCLUDED
+#define TICPPRC_INCLUDED
+
+
+// Forward declare ticpp::Node, so it can be made a friend of TiCppRC
+namespace ticpp
+{
+	class Base;
+}
+
+// Forward declare TiCppRCImp so TiCppRC can hold a pointer to it
+class TiCppRCImp;
+
+/**
+Base class for reference counting functionality
+*/
+class TiCppRC
+{
+	// Allow ticpp::Node to directly modify reference count
+	friend class ticpp::Base;
+
+private:
+
+	TiCppRCImp* m_tiRC; /**< Pointer to reference counter */
+
+public:
+
+	/**
+	Constructor
+	Spawns new reference counter with a pointer to this
+	*/
+	TiCppRC();
+
+	/**
+	Destructor
+	Nullifies the pointer to this held by the reference counter
+	Decrements reference count
+	*/
+	virtual ~TiCppRC();
+};
+
+class TiCppRCImp
+{
+private:
+
+	int m_count;		/**< Holds reference count to me, and to the node I point to */
+
+	TiCppRC* m_tiCppRC;	/**< Holds pointer to an object inheriting TiCppRC */
+
+public:
+
+	/**
+	Initializes m_tiCppRC pointer, and set reference count to 1
+	*/
+	TiCppRCImp( TiCppRC* tiCppRC );
+
+	/**
+	Allows the TiCppRC object to set the pointer to itself ( m_tiCppRc ) to NULL when the TiCppRC object is deleted
+	*/
+	void Nullify();
+
+	/**
+	Increment Reference Count
+	*/
+	void IncRef();
+
+	/**
+	Decrement Reference Count
+	*/
+	void DecRef();
+
+	/**
+	Set Reference Count to 1 - dangerous! - Use only if you are sure of the consequences
+	*/
+	void InitRef();
+
+	/**
+	Get internal pointer to the TiCppRC object - not reference counted, use at your own risk
+	*/
+	TiCppRC* Get();
+
+	/**
+	Returns state of internal pointer - will be null if the object was deleted
+	*/
+	bool IsNull();
+};
+
+#endif // TICPP_INCLUDED
+
+#endif // TIXML_USE_TICPP
Index: /code/branches/ceguilua/src/tinyxml/tinystr.cc
===================================================================
--- /code/branches/ceguilua/src/tinyxml/tinystr.cc	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/tinystr.cc	(revision 1801)
@@ -0,0 +1,116 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original file by Yves Berquin.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+/*
+ * THIS FILE WAS ALTERED BY Tyge Løvset, 7. April 2005.
+ */
+
+
+#ifndef TIXML_USE_STL
+
+#include "tinystr.h"
+
+// Error value for find primitive
+const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1);
+
+
+// Null rep.
+TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } };
+
+
+void TiXmlString::reserve (size_type cap)
+{
+	if (cap > capacity())
+	{
+		TiXmlString tmp;
+		tmp.init(length(), cap);
+		memcpy(tmp.start(), data(), length());
+		swap(tmp);
+	}
+}
+
+
+TiXmlString& TiXmlString::assign(const char* str, size_type len)
+{
+	size_type cap = capacity();
+	if (len > cap || cap > 3*(len + 8))
+	{
+		TiXmlString tmp;
+		tmp.init(len);
+		memcpy(tmp.start(), str, len);
+		swap(tmp);
+	}
+	else
+	{
+		memmove(start(), str, len);
+		set_size(len);
+	}
+	return *this;
+}
+
+
+TiXmlString& TiXmlString::append(const char* str, size_type len)
+{
+	size_type newsize = length() + len;
+	if (newsize > capacity())
+	{
+		reserve (newsize + capacity());
+	}
+	memmove(finish(), str, len);
+	set_size(newsize);
+	return *this;
+}
+
+
+TiXmlString operator + (const TiXmlString & a, const TiXmlString & b)
+{
+	TiXmlString tmp;
+	tmp.reserve(a.length() + b.length());
+	tmp += a;
+	tmp += b;
+	return tmp;
+}
+
+TiXmlString operator + (const TiXmlString & a, const char* b)
+{
+	TiXmlString tmp;
+	TiXmlString::size_type b_len = static_cast<TiXmlString::size_type>( strlen(b) );
+	tmp.reserve(a.length() + b_len);
+	tmp += a;
+	tmp.append(b, b_len);
+	return tmp;
+}
+
+TiXmlString operator + (const char* a, const TiXmlString & b)
+{
+	TiXmlString tmp;
+	TiXmlString::size_type a_len = static_cast<TiXmlString::size_type>( strlen(a) );
+	tmp.reserve(a_len + b.length());
+	tmp.append(a, a_len);
+	tmp += b;
+	return tmp;
+}
+
+
+#endif	// TIXML_USE_STL
Index: /code/branches/ceguilua/src/tinyxml/tinystr.h
===================================================================
--- /code/branches/ceguilua/src/tinyxml/tinystr.h	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/tinystr.h	(revision 1801)
@@ -0,0 +1,319 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original file by Yves Berquin.
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+/*
+ * THIS FILE WAS ALTERED BY Tyge Lovset, 7. April 2005.
+ *
+ * - completely rewritten. compact, clean, and fast implementation.
+ * - sizeof(TiXmlString) = pointer size (4 bytes on 32-bit systems)
+ * - fixed reserve() to work as per specification.
+ * - fixed buggy compares operator==(), operator<(), and operator>()
+ * - fixed operator+=() to take a const ref argument, following spec.
+ * - added "copy" constructor with length, and most compare operators.
+ * - added swap(), clear(), size(), capacity(), operator+().
+ */
+
+#ifndef TIXML_USE_STL
+
+#ifndef TIXML_STRING_INCLUDED
+#define TIXML_STRING_INCLUDED
+
+#include <assert.h>
+#include <string.h>
+
+/*	The support for explicit isn't that universal, and it isn't really
+	required - it is used to check that the TiXmlString class isn't incorrectly
+	used. Be nice to old compilers and macro it here:
+*/
+#if defined(_MSC_VER) && (_MSC_VER >= 1200 )
+	// Microsoft visual studio, version 6 and higher.
+	#define TIXML_EXPLICIT explicit
+#elif defined(__GNUC__) && (__GNUC__ >= 3 )
+	// GCC version 3 and higher.s
+	#define TIXML_EXPLICIT explicit
+#else
+	#define TIXML_EXPLICIT
+#endif
+
+
+/*
+   TiXmlString is an emulation of a subset of the std::string template.
+   Its purpose is to allow compiling TinyXML on compilers with no or poor STL support.
+   Only the member functions relevant to the TinyXML project have been implemented.
+   The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase
+   a string and there's no more room, we allocate a buffer twice as big as we need.
+*/
+class TiXmlString
+{
+  public :
+	// The size type used
+  	typedef size_t size_type;
+
+	// Error value for find primitive
+	static const size_type npos; // = -1;
+
+
+	// TiXmlString empty constructor
+	TiXmlString () : rep_(&nullrep_)
+	{
+	}
+
+	// TiXmlString copy constructor
+	TiXmlString ( const TiXmlString & copy) : rep_(0)
+	{
+		init(copy.length());
+		memcpy(start(), copy.data(), length());
+	}
+
+	// TiXmlString constructor, based on a string
+	TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0)
+	{
+		init( static_cast<size_type>( strlen(copy) ));
+		memcpy(start(), copy, length());
+	}
+
+	// TiXmlString constructor, based on a string
+	TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0)
+	{
+		init(len);
+		memcpy(start(), str, len);
+	}
+
+	// TiXmlString destructor
+	~TiXmlString ()
+	{
+		quit();
+	}
+
+	// = operator
+	TiXmlString& operator = (const char * copy)
+	{
+		return assign( copy, (size_type)strlen(copy));
+	}
+
+	// = operator
+	TiXmlString& operator = (const TiXmlString & copy)
+	{
+		return assign(copy.start(), copy.length());
+	}
+
+
+	// += operator. Maps to append
+	TiXmlString& operator += (const char * suffix)
+	{
+		return append(suffix, static_cast<size_type>( strlen(suffix) ));
+	}
+
+	// += operator. Maps to append
+	TiXmlString& operator += (char single)
+	{
+		return append(&single, 1);
+	}
+
+	// += operator. Maps to append
+	TiXmlString& operator += (const TiXmlString & suffix)
+	{
+		return append(suffix.data(), suffix.length());
+	}
+
+
+	// Convert a TiXmlString into a null-terminated char *
+	const char * c_str () const { return rep_->str; }
+
+	// Convert a TiXmlString into a char * (need not be null terminated).
+	const char * data () const { return rep_->str; }
+
+	// Return the length of a TiXmlString
+	size_type length () const { return rep_->size; }
+
+	// Alias for length()
+	size_type size () const { return rep_->size; }
+
+	// Checks if a TiXmlString is empty
+	bool empty () const { return rep_->size == 0; }
+
+	// Return capacity of string
+	size_type capacity () const { return rep_->capacity; }
+
+
+	// single char extraction
+	const char& at (size_type index) const
+	{
+		assert( index < length() );
+		return rep_->str[ index ];
+	}
+
+	// [] operator
+	char& operator [] (size_type index) const
+	{
+		assert( index < length() );
+		return rep_->str[ index ];
+	}
+
+	// find a char in a string. Return TiXmlString::npos if not found
+	size_type find (char lookup) const
+	{
+		return find(lookup, 0);
+	}
+
+	// find a char in a string from an offset. Return TiXmlString::npos if not found
+	size_type find (char tofind, size_type offset) const
+	{
+		if (offset >= length()) return npos;
+
+		for (const char* p = c_str() + offset; *p != '\0'; ++p)
+		{
+		   if (*p == tofind) return static_cast< size_type >( p - c_str() );
+		}
+		return npos;
+	}
+
+	void clear ()
+	{
+		//Lee:
+		//The original was just too strange, though correct:
+		//	TiXmlString().swap(*this);
+		//Instead use the quit & re-init:
+		quit();
+		init(0,0);
+	}
+
+	/*	Function to reserve a big amount of data when we know we'll need it. Be aware that this
+		function DOES NOT clear the content of the TiXmlString if any exists.
+	*/
+	void reserve (size_type cap);
+
+	TiXmlString& assign (const char* str, size_type len);
+
+	TiXmlString& append (const char* str, size_type len);
+
+	void swap (TiXmlString& other)
+	{
+		Rep* r = rep_;
+		rep_ = other.rep_;
+		other.rep_ = r;
+	}
+
+  private:
+
+	void init(size_type sz) { init(sz, sz); }
+	void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; }
+	char* start() const { return rep_->str; }
+	char* finish() const { return rep_->str + rep_->size; }
+
+	struct Rep
+	{
+		size_type size, capacity;
+		char str[1];
+	};
+
+	void init(size_type sz, size_type cap)
+	{
+		if (cap)
+		{
+			// Lee: the original form:
+			//	rep_ = static_cast<Rep*>(operator new(sizeof(Rep) + cap));
+			// doesn't work in some cases of new being overloaded. Switching
+			// to the normal allocation, although use an 'int' for systems
+			// that are overly picky about structure alignment.
+			const size_type bytesNeeded = sizeof(Rep) + cap;
+			const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); 
+			rep_ = reinterpret_cast<Rep*>( new int[ intsNeeded ] );
+
+			rep_->str[ rep_->size = sz ] = '\0';
+			rep_->capacity = cap;
+		}
+		else
+		{
+			rep_ = &nullrep_;
+		}
+	}
+
+	void quit()
+	{
+		if (rep_ != &nullrep_)
+		{
+			// The rep_ is really an array of ints. (see the allocator, above).
+			// Cast it back before delete, so the compiler won't incorrectly call destructors.
+			delete [] ( reinterpret_cast<int*>( rep_ ) );
+		}
+	}
+
+	Rep * rep_;
+	static Rep nullrep_;
+
+} ;
+
+
+inline bool operator == (const TiXmlString & a, const TiXmlString & b)
+{
+	return    ( a.length() == b.length() )				// optimization on some platforms
+	       && ( strcmp(a.c_str(), b.c_str()) == 0 );	// actual compare
+}
+inline bool operator < (const TiXmlString & a, const TiXmlString & b)
+{
+	return strcmp(a.c_str(), b.c_str()) < 0;
+}
+
+inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); }
+inline bool operator >  (const TiXmlString & a, const TiXmlString & b) { return b < a; }
+inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); }
+inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); }
+
+inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; }
+inline bool operator == (const char* a, const TiXmlString & b) { return b == a; }
+inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); }
+inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); }
+
+TiXmlString operator + (const TiXmlString & a, const TiXmlString & b);
+TiXmlString operator + (const TiXmlString & a, const char* b);
+TiXmlString operator + (const char* a, const TiXmlString & b);
+
+
+/*
+   TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString.
+   Only the operators that we need for TinyXML have been developped.
+*/
+class TiXmlOutStream : public TiXmlString
+{
+public :
+
+	// TiXmlOutStream << operator.
+	TiXmlOutStream & operator << (const TiXmlString & in)
+	{
+		*this += in;
+		return *this;
+	}
+
+	// TiXmlOutStream << operator.
+	TiXmlOutStream & operator << (const char * in)
+	{
+		*this += in;
+		return *this;
+	}
+
+} ;
+
+#endif	// TIXML_STRING_INCLUDED
+#endif	// TIXML_USE_STL
Index: /code/branches/ceguilua/src/tinyxml/tinyxml.cc
===================================================================
--- /code/branches/ceguilua/src/tinyxml/tinyxml.cc	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/tinyxml.cc	(revision 1801)
@@ -0,0 +1,1961 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+#include "tinyxml.h"
+
+#include <ctype.h>
+
+#ifdef TIXML_USE_STL
+#include <sstream>
+#include <iostream>
+#endif
+
+
+bool TiXmlBase::condenseWhiteSpace = true;
+
+// Microsoft compiler security
+FILE* TiXmlFOpen( const char* filename, const char* mode )
+{
+	#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
+		FILE* fp = 0;
+		errno_t err = fopen_s( &fp, filename, mode );
+		if ( !err && fp )
+			return fp;
+		return 0;
+	#else
+		return fopen( filename, mode );
+	#endif
+}
+
+void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString )
+{
+	int i=0;
+
+	while( i<(int)str.length() )
+	{
+		unsigned char c = (unsigned char) str[i];
+
+		if (    c == '&'
+		     && i < ( (int)str.length() - 2 )
+			 && str[i+1] == '#'
+			 && str[i+2] == 'x' )
+		{
+			// Hexadecimal character reference.
+			// Pass through unchanged.
+			// &#xA9;	-- copyright symbol, for example.
+			//
+			// The -1 is a bug fix from Rob Laveaux. It keeps
+			// an overflow from happening if there is no ';'.
+			// There are actually 2 ways to exit this loop -
+			// while fails (error case) and break (semicolon found).
+			// However, there is no mechanism (currently) for
+			// this function to return an error.
+			while ( i<(int)str.length()-1 )
+			{
+				outString->append( str.c_str() + i, 1 );
+				++i;
+				if ( str[i] == ';' )
+					break;
+			}
+		}
+		else if ( c == '&' )
+		{
+			outString->append( entity[0].str, entity[0].strLength );
+			++i;
+		}
+		else if ( c == '<' )
+		{
+			outString->append( entity[1].str, entity[1].strLength );
+			++i;
+		}
+		else if ( c == '>' )
+		{
+			outString->append( entity[2].str, entity[2].strLength );
+			++i;
+		}
+		else if ( c == '\"' )
+		{
+			outString->append( entity[3].str, entity[3].strLength );
+			++i;
+		}
+		else if ( c == '\'' )
+		{
+			outString->append( entity[4].str, entity[4].strLength );
+			++i;
+		}
+		else if ( c < 32 )
+		{
+			// Easy pass at non-alpha/numeric/symbol
+			// Below 32 is symbolic.
+			char buf[ 32 ];
+
+			#if defined(TIXML_SNPRINTF)
+				TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) );
+			#else
+				sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) );
+			#endif
+
+			//*ME:	warning C4267: convert 'size_t' to 'int'
+			//*ME:	Int-Cast to make compiler happy ...
+			outString->append( buf, (int)strlen( buf ) );
+			++i;
+		}
+		else
+		{
+			//char realc = (char) c;
+			//outString->append( &realc, 1 );
+			*outString += (char) c;	// somewhat more efficient function call.
+			++i;
+		}
+	}
+}
+
+
+TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase()
+{
+	parent = 0;
+	type = _type;
+	firstChild = 0;
+	lastChild = 0;
+	prev = 0;
+	next = 0;
+}
+
+
+TiXmlNode::~TiXmlNode()
+{
+	TiXmlNode* node = firstChild;
+	TiXmlNode* temp = 0;
+
+	while ( node )
+	{
+		temp = node;
+		node = node->next;
+		delete temp;
+	}
+}
+
+
+void TiXmlNode::CopyTo( TiXmlNode* target ) const
+{
+	target->SetValue (value.c_str() );
+	target->userData = userData;
+}
+
+
+void TiXmlNode::Clear()
+{
+	TiXmlNode* node = firstChild;
+	TiXmlNode* temp = 0;
+
+	while ( node )
+	{
+		temp = node;
+		node = node->next;
+		delete temp;
+	}
+
+	firstChild = 0;
+	lastChild = 0;
+}
+
+
+TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node )
+{
+	assert( node->parent == 0 || node->parent == this );
+	assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() );
+
+	if ( node->Type() == TiXmlNode::DOCUMENT )
+	{
+		delete node;
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	node->parent = this;
+
+	node->prev = lastChild;
+	node->next = 0;
+
+	if ( lastChild )
+		lastChild->next = node;
+	else
+		firstChild = node;			// it was an empty list.
+
+	lastChild = node;
+	return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis )
+{
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+	TiXmlNode* node = addThis.Clone();
+	if ( !node )
+		return 0;
+
+	return LinkEndChild( node );
+}
+
+
+TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis )
+{
+	if ( !beforeThis || beforeThis->parent != this ) {
+		return 0;
+	}
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	TiXmlNode* node = addThis.Clone();
+	if ( !node )
+		return 0;
+	node->parent = this;
+
+	node->next = beforeThis;
+	node->prev = beforeThis->prev;
+	if ( beforeThis->prev )
+	{
+		beforeThis->prev->next = node;
+	}
+	else
+	{
+		assert( firstChild == beforeThis );
+		firstChild = node;
+	}
+	beforeThis->prev = node;
+	return node;
+}
+
+
+TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis )
+{
+	if ( !afterThis || afterThis->parent != this ) {
+		return 0;
+	}
+	if ( addThis.Type() == TiXmlNode::DOCUMENT )
+	{
+		if ( GetDocument() ) GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	TiXmlNode* node = addThis.Clone();
+	if ( !node )
+		return 0;
+	node->parent = this;
+
+	node->prev = afterThis;
+	node->next = afterThis->next;
+	if ( afterThis->next )
+	{
+		afterThis->next->prev = node;
+	}
+	else
+	{
+		assert( lastChild == afterThis );
+		lastChild = node;
+	}
+	afterThis->next = node;
+	return node;
+}
+
+
+TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis )
+{
+	if ( replaceThis->parent != this )
+		return 0;
+
+	TiXmlNode* node = withThis.Clone();
+	if ( !node )
+		return 0;
+
+	node->next = replaceThis->next;
+	node->prev = replaceThis->prev;
+
+	if ( replaceThis->next )
+		replaceThis->next->prev = node;
+	else
+		lastChild = node;
+
+	if ( replaceThis->prev )
+		replaceThis->prev->next = node;
+	else
+		firstChild = node;
+
+	delete replaceThis;
+	node->parent = this;
+	return node;
+}
+
+
+bool TiXmlNode::RemoveChild( TiXmlNode* removeThis )
+{
+	if ( removeThis->parent != this )
+	{
+		assert( 0 );
+		return false;
+	}
+
+	if ( removeThis->next )
+		removeThis->next->prev = removeThis->prev;
+	else
+		lastChild = removeThis->prev;
+
+	if ( removeThis->prev )
+		removeThis->prev->next = removeThis->next;
+	else
+		firstChild = removeThis->next;
+
+	delete removeThis;
+	return true;
+}
+
+const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = firstChild; node; node = node->next )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = lastChild; node; node = node->prev )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const
+{
+	if ( !previous )
+	{
+		return FirstChild();
+	}
+	else
+	{
+		assert( previous->parent == this );
+		return previous->NextSibling();
+	}
+}
+
+
+const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const
+{
+	if ( !previous )
+	{
+		return FirstChild( val );
+	}
+	else
+	{
+		assert( previous->parent == this );
+		return previous->NextSibling( val );
+	}
+}
+
+
+const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = next; node; node = node->next )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const
+{
+	const TiXmlNode* node;
+	for ( node = prev; node; node = node->prev )
+	{
+		if ( strcmp( node->Value(), _value ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+
+void TiXmlElement::RemoveAttribute( const char * name )
+{
+    #ifdef TIXML_USE_STL
+	TIXML_STRING str( name );
+	TiXmlAttribute* node = attributeSet.Find( str );
+	#else
+	TiXmlAttribute* node = attributeSet.Find( name );
+	#endif
+	if ( node )
+	{
+		attributeSet.Remove( node );
+		delete node;
+	}
+}
+
+const TiXmlElement* TiXmlNode::FirstChildElement() const
+{
+	const TiXmlNode* node;
+
+	for (	node = FirstChild();
+			node;
+			node = node->NextSibling() )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const
+{
+	const TiXmlNode* node;
+
+	for (	node = FirstChild( _value );
+			node;
+			node = node->NextSibling( _value ) )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlElement* TiXmlNode::NextSiblingElement() const
+{
+	const TiXmlNode* node;
+
+	for (	node = NextSibling();
+			node;
+			node = node->NextSibling() )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const
+{
+	const TiXmlNode* node;
+
+	for (	node = NextSibling( _value );
+			node;
+			node = node->NextSibling( _value ) )
+	{
+		if ( node->ToElement() )
+			return node->ToElement();
+	}
+	return 0;
+}
+
+
+const TiXmlDocument* TiXmlNode::GetDocument() const
+{
+	const TiXmlNode* node;
+
+	for( node = this; node; node = node->parent )
+	{
+		if ( node->ToDocument() )
+			return node->ToDocument();
+	}
+	return 0;
+}
+
+
+TiXmlElement::TiXmlElement (const char * _value)
+	: TiXmlNode( TiXmlNode::ELEMENT )
+{
+	firstChild = lastChild = 0;
+	value = _value;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlElement::TiXmlElement( const std::string& _value )
+	: TiXmlNode( TiXmlNode::ELEMENT )
+{
+	firstChild = lastChild = 0;
+	value = _value;
+}
+#endif
+
+
+TiXmlElement::TiXmlElement( const TiXmlElement& copy)
+	: TiXmlNode( TiXmlNode::ELEMENT )
+{
+	firstChild = lastChild = 0;
+	copy.CopyTo( this );
+}
+
+
+void TiXmlElement::operator=( const TiXmlElement& base )
+{
+	ClearThis();
+	base.CopyTo( this );
+}
+
+
+TiXmlElement::~TiXmlElement()
+{
+	ClearThis();
+}
+
+
+void TiXmlElement::ClearThis()
+{
+	Clear();
+	while( attributeSet.First() )
+	{
+		TiXmlAttribute* node = attributeSet.First();
+		attributeSet.Remove( node );
+		delete node;
+	}
+}
+
+
+const char* TiXmlElement::Attribute( const char* name ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( node )
+		return node->Value();
+	return 0;
+}
+
+
+#ifdef TIXML_USE_STL
+const std::string* TiXmlElement::Attribute( const std::string& name ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( node )
+		return &node->ValueStr();
+	return 0;
+}
+#endif
+
+
+const char* TiXmlElement::Attribute( const char* name, int* i ) const
+{
+	const char* s = Attribute( name );
+	if ( i )
+	{
+		if ( s ) {
+			*i = atoi( s );
+		}
+		else {
+			*i = 0;
+		}
+	}
+	return s;
+}
+
+
+#ifdef TIXML_USE_STL
+const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const
+{
+	const std::string* s = Attribute( name );
+	if ( i )
+	{
+		if ( s ) {
+			*i = atoi( s->c_str() );
+		}
+		else {
+			*i = 0;
+		}
+	}
+	return s;
+}
+#endif
+
+
+const char* TiXmlElement::Attribute( const char* name, double* d ) const
+{
+	const char* s = Attribute( name );
+	if ( d )
+	{
+		if ( s ) {
+			*d = atof( s );
+		}
+		else {
+			*d = 0;
+		}
+	}
+	return s;
+}
+
+
+#ifdef TIXML_USE_STL
+const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const
+{
+	const std::string* s = Attribute( name );
+	if ( d )
+	{
+		if ( s ) {
+			*d = atof( s->c_str() );
+		}
+		else {
+			*d = 0;
+		}
+	}
+	return s;
+}
+#endif
+
+
+int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryIntValue( ival );
+}
+
+
+#ifdef TIXML_USE_STL
+int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryIntValue( ival );
+}
+#endif
+
+
+int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryDoubleValue( dval );
+}
+
+
+#ifdef TIXML_USE_STL
+int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const
+{
+	const TiXmlAttribute* node = attributeSet.Find( name );
+	if ( !node )
+		return TIXML_NO_ATTRIBUTE;
+	return node->QueryDoubleValue( dval );
+}
+#endif
+
+
+void TiXmlElement::SetAttribute( const char * name, int val )
+{
+	char buf[64];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF( buf, sizeof(buf), "%d", val );
+	#else
+		sprintf( buf, "%d", val );
+	#endif
+	SetAttribute( name, buf );
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlElement::SetAttribute( const std::string& name, int val )
+{
+   std::ostringstream oss;
+   oss << val;
+   SetAttribute( name, oss.str() );
+}
+#endif
+
+
+void TiXmlElement::SetDoubleAttribute( const char * name, double val )
+{
+	char buf[256];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF( buf, sizeof(buf), "%f", val );
+	#else
+		sprintf( buf, "%f", val );
+	#endif
+	SetAttribute( name, buf );
+}
+
+
+void TiXmlElement::SetAttribute( const char * cname, const char * cvalue )
+{
+    #ifdef TIXML_USE_STL
+	TIXML_STRING _name( cname );
+	TIXML_STRING _value( cvalue );
+	#else
+	const char* _name = cname;
+	const char* _value = cvalue;
+	#endif
+
+	TiXmlAttribute* node = attributeSet.Find( _name );
+	if ( node )
+	{
+		node->SetValue( _value );
+		return;
+	}
+
+	TiXmlAttribute* attrib = new TiXmlAttribute( cname, cvalue );
+	if ( attrib )
+	{
+		attributeSet.Add( attrib );
+	}
+	else
+	{
+		TiXmlDocument* document = GetDocument();
+		if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+	}
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlElement::SetAttribute( const std::string& name, const std::string& _value )
+{
+	TiXmlAttribute* node = attributeSet.Find( name );
+	if ( node )
+	{
+		node->SetValue( _value );
+		return;
+	}
+
+	TiXmlAttribute* attrib = new TiXmlAttribute( name, _value );
+	if ( attrib )
+	{
+		attributeSet.Add( attrib );
+	}
+	else
+	{
+		TiXmlDocument* document = GetDocument();
+		if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+	}
+}
+#endif
+
+
+void TiXmlElement::Print( FILE* cfile, int depth ) const
+{
+	int i;
+	assert( cfile );
+	for ( i=0; i<depth; i++ ) {
+		fprintf( cfile, "    " );
+	}
+
+	fprintf( cfile, "<%s", value.c_str() );
+
+	const TiXmlAttribute* attrib;
+	for ( attrib = attributeSet.First(); attrib; attrib = attrib->Next() )
+	{
+		fprintf( cfile, " " );
+		attrib->Print( cfile, depth );
+	}
+
+	// There are 3 different formatting approaches:
+	// 1) An element without children is printed as a <foo /> node
+	// 2) An element with only a text child is printed as <foo> text </foo>
+	// 3) An element with children is printed on multiple lines.
+	TiXmlNode* node;
+	if ( !firstChild )
+	{
+		fprintf( cfile, " />" );
+	}
+	else if ( firstChild == lastChild && firstChild->ToText() )
+	{
+		fprintf( cfile, ">" );
+		firstChild->Print( cfile, depth + 1 );
+		fprintf( cfile, "</%s>", value.c_str() );
+	}
+	else
+	{
+		fprintf( cfile, ">" );
+
+		for ( node = firstChild; node; node=node->NextSibling() )
+		{
+			if ( !node->ToText() )
+			{
+				fprintf( cfile, "\n" );
+			}
+			node->Print( cfile, depth+1 );
+		}
+		fprintf( cfile, "\n" );
+		for( i=0; i<depth; ++i ) {
+			fprintf( cfile, "    " );
+		}
+		fprintf( cfile, "</%s>", value.c_str() );
+	}
+}
+
+
+void TiXmlElement::CopyTo( TiXmlElement* target ) const
+{
+	// superclass:
+	TiXmlNode::CopyTo( target );
+
+	// Element class:
+	// Clone the attributes, then clone the children.
+	const TiXmlAttribute* attribute = 0;
+	for(	attribute = attributeSet.First();
+	attribute;
+	attribute = attribute->Next() )
+	{
+		target->SetAttribute( attribute->Name(), attribute->Value() );
+	}
+
+	TiXmlNode* node = 0;
+	for ( node = firstChild; node; node = node->NextSibling() )
+	{
+		target->LinkEndChild( node->Clone() );
+	}
+}
+
+bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const
+{
+	if ( visitor->VisitEnter( *this, attributeSet.First() ) )
+	{
+		for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
+		{
+			if ( !node->Accept( visitor ) )
+				break;
+		}
+	}
+	return visitor->VisitExit( *this );
+}
+
+
+TiXmlNode* TiXmlElement::Clone() const
+{
+	TiXmlElement* clone = new TiXmlElement( Value() );
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+const char* TiXmlElement::GetText() const
+{
+	const TiXmlNode* child = this->FirstChild();
+	if ( child ) {
+		const TiXmlText* childText = child->ToText();
+		if ( childText ) {
+			return childText->Value();
+		}
+	}
+	return 0;
+}
+
+
+TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	tabsize = 4;
+	useMicrosoftBOM = false;
+	ClearError();
+}
+
+TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	tabsize = 4;
+	useMicrosoftBOM = false;
+	value = documentName;
+	ClearError();
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	tabsize = 4;
+	useMicrosoftBOM = false;
+    value = documentName;
+	ClearError();
+}
+#endif
+
+
+TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::DOCUMENT )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlDocument::operator=( const TiXmlDocument& copy )
+{
+	Clear();
+	copy.CopyTo( this );
+}
+
+
+bool TiXmlDocument::LoadFile( TiXmlEncoding encoding )
+{
+	// See STL_STRING_BUG below.
+	//StringToBuffer buf( value );
+
+	return LoadFile( Value(), encoding );
+}
+
+
+bool TiXmlDocument::SaveFile() const
+{
+	// See STL_STRING_BUG below.
+//	StringToBuffer buf( value );
+//
+//	if ( buf.buffer && SaveFile( buf.buffer ) )
+//		return true;
+//
+//	return false;
+	return SaveFile( Value() );
+}
+
+bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding )
+{
+	// There was a really terrifying little bug here. The code:
+	//		value = filename
+	// in the STL case, cause the assignment method of the std::string to
+	// be called. What is strange, is that the std::string had the same
+	// address as it's c_str() method, and so bad things happen. Looks
+	// like a bug in the Microsoft STL implementation.
+	// Add an extra string to avoid the crash.
+	TIXML_STRING filename( _filename );
+	value = filename;
+
+	// reading in binary mode so that tinyxml can normalize the EOL
+	FILE* file = TiXmlFOpen( value.c_str (), "rb" );
+
+	if ( file )
+	{
+		bool result = LoadFile( file, encoding );
+		fclose( file );
+		return result;
+	}
+	else
+	{
+		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+}
+
+bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding )
+{
+	if ( !file )
+	{
+		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+
+	// Delete the existing data:
+	Clear();
+	location.Clear();
+
+	// Get the file size, so we can pre-allocate the string. HUGE speed impact.
+	long length = 0;
+	fseek( file, 0, SEEK_END );
+	length = ftell( file );
+	fseek( file, 0, SEEK_SET );
+
+	// Strange case, but good to handle up front.
+	if ( length <= 0 )
+	{
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+
+	// If we have a file, assume it is all one big XML file, and read it in.
+	// The document parser may decide the document ends sooner than the entire file, however.
+	TIXML_STRING data;
+	data.reserve( length );
+
+	// Subtle bug here. TinyXml did use fgets. But from the XML spec:
+	// 2.11 End-of-Line Handling
+	// <snip>
+	// <quote>
+	// ...the XML processor MUST behave as if it normalized all line breaks in external
+	// parsed entities (including the document entity) on input, before parsing, by translating
+	// both the two-character sequence #xD #xA and any #xD that is not followed by #xA to
+	// a single #xA character.
+	// </quote>
+	//
+	// It is not clear fgets does that, and certainly isn't clear it works cross platform.
+	// Generally, you expect fgets to translate from the convention of the OS to the c/unix
+	// convention, and not work generally.
+
+	/*
+	while( fgets( buf, sizeof(buf), file ) )
+	{
+		data += buf;
+	}
+	*/
+
+	char* buf = new char[ length+1 ];
+	buf[0] = 0;
+
+	if ( fread( buf, length, 1, file ) != 1 ) {
+		delete [] buf;
+		SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return false;
+	}
+
+	const char* lastPos = buf;
+	const char* p = buf;
+
+	buf[length] = 0;
+	while( *p ) {
+		assert( p < (buf+length) );
+		if ( *p == 0xa ) {
+			// Newline character. No special rules for this. Append all the characters
+			// since the last string, and include the newline.
+			data.append( lastPos, (p-lastPos+1) );	// append, include the newline
+			++p;									// move past the newline
+			lastPos = p;							// and point to the new buffer (may be 0)
+			assert( p <= (buf+length) );
+		}
+		else if ( *p == 0xd ) {
+			// Carriage return. Append what we have so far, then
+			// handle moving forward in the buffer.
+			if ( (p-lastPos) > 0 ) {
+				data.append( lastPos, p-lastPos );	// do not add the CR
+			}
+			data += (char)0xa;						// a proper newline
+
+			if ( *(p+1) == 0xa ) {
+				// Carriage return - new line sequence
+				p += 2;
+				lastPos = p;
+				assert( p <= (buf+length) );
+			}
+			else {
+				// it was followed by something else...that is presumably characters again.
+				++p;
+				lastPos = p;
+				assert( p <= (buf+length) );
+			}
+		}
+		else {
+			++p;
+		}
+	}
+	// Handle any left over characters.
+	if ( p-lastPos ) {
+		data.append( lastPos, p-lastPos );
+	}
+	delete [] buf;
+	buf = 0;
+
+	Parse( data.c_str(), 0, encoding );
+
+	if (  Error() )
+        return false;
+    else
+		return true;
+}
+
+
+bool TiXmlDocument::SaveFile( const char * filename ) const
+{
+	// The old c stuff lives on...
+	FILE* fp = TiXmlFOpen( filename, "w" );
+	if ( fp )
+	{
+		bool result = SaveFile( fp );
+		fclose( fp );
+		return result;
+	}
+	return false;
+}
+
+
+bool TiXmlDocument::SaveFile( FILE* fp ) const
+{
+	if ( useMicrosoftBOM )
+	{
+		const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
+		const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
+		const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
+
+		fputc( TIXML_UTF_LEAD_0, fp );
+		fputc( TIXML_UTF_LEAD_1, fp );
+		fputc( TIXML_UTF_LEAD_2, fp );
+	}
+	Print( fp, 0 );
+	return (ferror(fp) == 0);
+}
+
+
+void TiXmlDocument::CopyTo( TiXmlDocument* target ) const
+{
+	TiXmlNode::CopyTo( target );
+
+	target->error = error;
+	target->errorId = errorId;
+	target->errorDesc = errorDesc;
+	target->tabsize = tabsize;
+	target->errorLocation = errorLocation;
+	target->useMicrosoftBOM = useMicrosoftBOM;
+
+	TiXmlNode* node = 0;
+	for ( node = firstChild; node; node = node->NextSibling() )
+	{
+		target->LinkEndChild( node->Clone() );
+	}
+}
+
+
+TiXmlNode* TiXmlDocument::Clone() const
+{
+	TiXmlDocument* clone = new TiXmlDocument();
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+void TiXmlDocument::Print( FILE* cfile, int depth ) const
+{
+	assert( cfile );
+	for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
+	{
+		node->Print( cfile, depth );
+		fprintf( cfile, "\n" );
+	}
+}
+
+
+bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const
+{
+	if ( visitor->VisitEnter( *this ) )
+	{
+		for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() )
+		{
+			if ( !node->Accept( visitor ) )
+				break;
+		}
+	}
+	return visitor->VisitExit( *this );
+}
+
+
+const TiXmlAttribute* TiXmlAttribute::Next() const
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( next->value.empty() && next->name.empty() )
+		return 0;
+	return next;
+}
+
+/*
+TiXmlAttribute* TiXmlAttribute::Next()
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( next->value.empty() && next->name.empty() )
+		return 0;
+	return next;
+}
+*/
+
+const TiXmlAttribute* TiXmlAttribute::Previous() const
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( prev->value.empty() && prev->name.empty() )
+		return 0;
+	return prev;
+}
+
+/*
+TiXmlAttribute* TiXmlAttribute::Previous()
+{
+	// We are using knowledge of the sentinel. The sentinel
+	// have a value or name.
+	if ( prev->value.empty() && prev->name.empty() )
+		return 0;
+	return prev;
+}
+*/
+
+void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
+{
+	TIXML_STRING n, v;
+
+	EncodeString( name, &n );
+	EncodeString( value, &v );
+
+	if (value.find ('\"') == TIXML_STRING::npos) {
+		if ( cfile ) {
+		fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() );
+		}
+		if ( str ) {
+			(*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\"";
+		}
+	}
+	else {
+		if ( cfile ) {
+		fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() );
+		}
+		if ( str ) {
+			(*str) += n; (*str) += "='"; (*str) += v; (*str) += "'";
+		}
+	}
+}
+
+
+int TiXmlAttribute::QueryIntValue( int* ival ) const
+{
+	if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 )
+		return TIXML_SUCCESS;
+	return TIXML_WRONG_TYPE;
+}
+
+int TiXmlAttribute::QueryDoubleValue( double* dval ) const
+{
+	if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 )
+		return TIXML_SUCCESS;
+	return TIXML_WRONG_TYPE;
+}
+
+void TiXmlAttribute::SetIntValue( int _value )
+{
+	char buf [64];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value);
+	#else
+		sprintf (buf, "%d", _value);
+	#endif
+	SetValue (buf);
+}
+
+void TiXmlAttribute::SetDoubleValue( double _value )
+{
+	char buf [256];
+	#if defined(TIXML_SNPRINTF)
+		TIXML_SNPRINTF( buf, sizeof(buf), "%lf", _value);
+	#else
+		sprintf (buf, "%lf", _value);
+	#endif
+	SetValue (buf);
+}
+
+int TiXmlAttribute::IntValue() const
+{
+	return atoi (value.c_str ());
+}
+
+double  TiXmlAttribute::DoubleValue() const
+{
+	return atof (value.c_str ());
+}
+
+
+TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::COMMENT )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlComment::operator=( const TiXmlComment& base )
+{
+	Clear();
+	base.CopyTo( this );
+}
+
+
+void TiXmlComment::Print( FILE* cfile, int depth ) const
+{
+	assert( cfile );
+	for ( int i=0; i<depth; i++ )
+	{
+		fprintf( cfile,  "    " );
+	}
+	fprintf( cfile, "<!--%s-->", value.c_str() );
+}
+
+
+void TiXmlComment::CopyTo( TiXmlComment* target ) const
+{
+	TiXmlNode::CopyTo( target );
+}
+
+
+bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlComment::Clone() const
+{
+	TiXmlComment* clone = new TiXmlComment();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+void TiXmlText::Print( FILE* cfile, int depth ) const
+{
+	assert( cfile );
+	if ( cdata )
+	{
+		int i;
+		fprintf( cfile, "\n" );
+		for ( i=0; i<depth; i++ ) {
+			fprintf( cfile, "    " );
+		}
+		fprintf( cfile, "<![CDATA[%s]]>\n", value.c_str() );	// unformatted output
+	}
+	else
+	{
+		TIXML_STRING buffer;
+		EncodeString( value, &buffer );
+		fprintf( cfile, "%s", buffer.c_str() );
+	}
+}
+
+
+void TiXmlText::CopyTo( TiXmlText* target ) const
+{
+	TiXmlNode::CopyTo( target );
+	target->cdata = cdata;
+}
+
+
+bool TiXmlText::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlText::Clone() const
+{
+	TiXmlText* clone = 0;
+	clone = new TiXmlText( "" );
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+TiXmlDeclaration::TiXmlDeclaration( const char * _version,
+									const char * _encoding,
+									const char * _standalone )
+	: TiXmlNode( TiXmlNode::DECLARATION )
+{
+	version = _version;
+	encoding = _encoding;
+	standalone = _standalone;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlDeclaration::TiXmlDeclaration(	const std::string& _version,
+									const std::string& _encoding,
+									const std::string& _standalone )
+	: TiXmlNode( TiXmlNode::DECLARATION )
+{
+	version = _version;
+	encoding = _encoding;
+	standalone = _standalone;
+}
+#endif
+
+
+TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy )
+	: TiXmlNode( TiXmlNode::DECLARATION )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlDeclaration::operator=( const TiXmlDeclaration& copy )
+{
+	Clear();
+	copy.CopyTo( this );
+}
+
+
+void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
+{
+	if ( cfile ) fprintf( cfile, "<?xml " );
+	if ( str )	 (*str) += "<?xml ";
+
+	if ( !version.empty() ) {
+		if ( cfile ) fprintf (cfile, "version=\"%s\" ", version.c_str ());
+		if ( str ) { (*str) += "version=\""; (*str) += version; (*str) += "\" "; }
+	}
+	if ( !encoding.empty() ) {
+		if ( cfile ) fprintf (cfile, "encoding=\"%s\" ", encoding.c_str ());
+		if ( str ) { (*str) += "encoding=\""; (*str) += encoding; (*str) += "\" "; }
+	}
+	if ( !standalone.empty() ) {
+		if ( cfile ) fprintf (cfile, "standalone=\"%s\" ", standalone.c_str ());
+		if ( str ) { (*str) += "standalone=\""; (*str) += standalone; (*str) += "\" "; }
+	}
+	if ( cfile ) fprintf( cfile, "?>" );
+	if ( str )	 (*str) += "?>";
+}
+
+
+void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const
+{
+	TiXmlNode::CopyTo( target );
+
+	target->version = version;
+	target->encoding = encoding;
+	target->standalone = standalone;
+}
+
+
+bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlDeclaration::Clone() const
+{
+	TiXmlDeclaration* clone = new TiXmlDeclaration();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+TiXmlStylesheetReference::TiXmlStylesheetReference( const char * _type,
+													const char * _href )
+	: TiXmlNode( TiXmlNode::STYLESHEETREFERENCE )
+{
+	type = _type;
+	href = _href;
+}
+
+
+#ifdef TIXML_USE_STL
+TiXmlStylesheetReference::TiXmlStylesheetReference(	const std::string& _type,
+													const std::string& _href )
+	: TiXmlNode( TiXmlNode::STYLESHEETREFERENCE )
+{
+	type = _type;
+	href = _href;
+}
+#endif
+
+
+TiXmlStylesheetReference::TiXmlStylesheetReference( const TiXmlStylesheetReference& copy )
+	: TiXmlNode( TiXmlNode::STYLESHEETREFERENCE )
+{
+	copy.CopyTo( this );
+}
+
+
+void TiXmlStylesheetReference::operator=( const TiXmlStylesheetReference& copy )
+{
+	Clear();
+	copy.CopyTo( this );
+}
+
+
+void TiXmlStylesheetReference::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const
+{
+	if ( cfile ) fprintf( cfile, "<?xml-stylesheet " );
+	if ( str )	 (*str) += "<?xml-stylesheet ";
+
+	if ( !type.empty() ) {
+		if ( cfile ) fprintf (cfile, "type=\"%s\" ", type.c_str ());
+		if ( str ) { (*str) += "type=\""; (*str) += type; (*str) += "\" "; }
+	}
+	if ( !href.empty() ) {
+		if ( cfile ) fprintf (cfile, "href=\"%s\" ", href.c_str ());
+		if ( str ) { (*str) += "href=\""; (*str) += href; (*str) += "\" "; }
+	}
+	if ( cfile ) fprintf (cfile, "?>");
+	if ( str )	 (*str) += "?>";
+}
+
+void TiXmlStylesheetReference::CopyTo( TiXmlStylesheetReference* target ) const
+{
+	TiXmlNode::CopyTo( target );
+
+	target->type = type;
+	target->href = href;
+}
+
+bool TiXmlStylesheetReference::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+TiXmlNode* TiXmlStylesheetReference::Clone() const
+{
+	TiXmlStylesheetReference* clone = new TiXmlStylesheetReference();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+void TiXmlUnknown::Print( FILE* cfile, int depth ) const
+{
+	for ( int i=0; i<depth; i++ )
+		fprintf( cfile, "    " );
+	fprintf( cfile, "<%s>", value.c_str() );
+}
+
+
+void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const
+{
+	TiXmlNode::CopyTo( target );
+}
+
+
+bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const
+{
+	return visitor->Visit( *this );
+}
+
+
+TiXmlNode* TiXmlUnknown::Clone() const
+{
+	TiXmlUnknown* clone = new TiXmlUnknown();
+
+	if ( !clone )
+		return 0;
+
+	CopyTo( clone );
+	return clone;
+}
+
+
+TiXmlAttributeSet::TiXmlAttributeSet()
+{
+	sentinel.next = &sentinel;
+	sentinel.prev = &sentinel;
+}
+
+
+TiXmlAttributeSet::~TiXmlAttributeSet()
+{
+	assert( sentinel.next == &sentinel );
+	assert( sentinel.prev == &sentinel );
+}
+
+
+void TiXmlAttributeSet::Add( TiXmlAttribute* addMe )
+{
+    #ifdef TIXML_USE_STL
+	assert( !Find( TIXML_STRING( addMe->Name() ) ) );	// Shouldn't be multiply adding to the set.
+	#else
+	assert( !Find( addMe->Name() ) );	// Shouldn't be multiply adding to the set.
+	#endif
+
+	addMe->next = &sentinel;
+	addMe->prev = sentinel.prev;
+
+	sentinel.prev->next = addMe;
+	sentinel.prev      = addMe;
+}
+
+void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe )
+{
+	TiXmlAttribute* node;
+
+	for( node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( node == removeMe )
+		{
+			node->prev->next = node->next;
+			node->next->prev = node->prev;
+			node->next = 0;
+			node->prev = 0;
+			return;
+		}
+	}
+	assert( 0 );		// we tried to remove a non-linked attribute.
+}
+
+
+#ifdef TIXML_USE_STL
+const TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const
+{
+	for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( node->name == name )
+			return node;
+	}
+	return 0;
+}
+
+/*
+TiXmlAttribute*	TiXmlAttributeSet::Find( const std::string& name )
+{
+	for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( node->name == name )
+			return node;
+	}
+	return 0;
+}
+*/
+#endif
+
+
+const TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const
+{
+	for( const TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( strcmp( node->name.c_str(), name ) == 0 )
+			return node;
+	}
+	return 0;
+}
+
+/*
+TiXmlAttribute*	TiXmlAttributeSet::Find( const char* name )
+{
+	for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next )
+	{
+		if ( strcmp( node->name.c_str(), name ) == 0 )
+			return node;
+	}
+	return 0;
+}
+*/
+
+#ifdef TIXML_USE_STL
+std::istream& operator>> (std::istream & in, TiXmlNode & base)
+{
+	TIXML_STRING tag;
+	tag.reserve( 8 * 1000 );
+	base.StreamIn( &in, &tag );
+
+	base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING );
+	return in;
+}
+#endif
+
+
+#ifdef TIXML_USE_STL
+std::ostream& operator<< (std::ostream & out, const TiXmlNode & base)
+{
+	TiXmlPrinter printer;
+	printer.SetStreamPrinting();
+	base.Accept( &printer );
+	out << printer.Str();
+
+	return out;
+}
+
+
+std::string& operator<< (std::string& out, const TiXmlNode& base )
+{
+	TiXmlPrinter printer;
+	printer.SetStreamPrinting();
+	base.Accept( &printer );
+	out.append( printer.Str() );
+
+	return out;
+}
+#endif
+
+
+TiXmlHandle TiXmlHandle::FirstChild() const
+{
+	if ( node )
+	{
+		TiXmlNode* child = node->FirstChild();
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const
+{
+	if ( node )
+	{
+		TiXmlNode* child = node->FirstChild( value );
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement() const
+{
+	if ( node )
+	{
+		TiXmlElement* child = node->FirstChildElement();
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const
+{
+	if ( node )
+	{
+		TiXmlElement* child = node->FirstChildElement( value );
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::Child( int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlNode* child = node->FirstChild();
+		for (	i=0;
+				child && i<count;
+				child = child->NextSibling(), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlNode* child = node->FirstChild( value );
+		for (	i=0;
+				child && i<count;
+				child = child->NextSibling( value ), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement( int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlElement* child = node->FirstChildElement();
+		for (	i=0;
+				child && i<count;
+				child = child->NextSiblingElement(), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const
+{
+	if ( node )
+	{
+		int i;
+		TiXmlElement* child = node->FirstChildElement( value );
+		for (	i=0;
+				child && i<count;
+				child = child->NextSiblingElement( value ), ++i )
+		{
+			// nothing
+		}
+		if ( child )
+			return TiXmlHandle( child );
+	}
+	return TiXmlHandle( 0 );
+}
+
+
+bool TiXmlPrinter::VisitEnter( const TiXmlDocument& )
+{
+	return true;
+}
+
+bool TiXmlPrinter::VisitExit( const TiXmlDocument& )
+{
+	return true;
+}
+
+bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
+{
+	DoIndent();
+	buffer += "<";
+	buffer += element.Value();
+
+	for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() )
+	{
+		buffer += " ";
+		attrib->Print( 0, 0, &buffer );
+	}
+
+	if ( !element.FirstChild() )
+	{
+		buffer += " />";
+		DoLineBreak();
+	}
+	else
+	{
+		buffer += ">";
+		if (    element.FirstChild()->ToText()
+			  && element.LastChild() == element.FirstChild()
+			  && element.FirstChild()->ToText()->CDATA() == false )
+		{
+			simpleTextPrint = true;
+			// no DoLineBreak()!
+		}
+		else
+		{
+			DoLineBreak();
+		}
+	}
+	++depth;
+	return true;
+}
+
+
+bool TiXmlPrinter::VisitExit( const TiXmlElement& element )
+{
+	--depth;
+	if ( !element.FirstChild() )
+	{
+		// nothing.
+	}
+	else
+	{
+		if ( simpleTextPrint )
+		{
+			simpleTextPrint = false;
+		}
+		else
+		{
+			DoIndent();
+		}
+		buffer += "</";
+		buffer += element.Value();
+		buffer += ">";
+		DoLineBreak();
+	}
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlText& text )
+{
+	if ( text.CDATA() )
+	{
+		DoIndent();
+		buffer += "<![CDATA[";
+		buffer += text.Value();
+		buffer += "]]>";
+		DoLineBreak();
+	}
+	else if ( simpleTextPrint )
+	{
+		TIXML_STRING str;
+		TiXmlBase::EncodeString( text.ValueTStr(), &str );
+		buffer += str;
+	}
+	else
+	{
+		DoIndent();
+		TIXML_STRING str;
+		TiXmlBase::EncodeString( text.ValueTStr(), &str );
+		buffer += str;
+		DoLineBreak();
+	}
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration )
+{
+	DoIndent();
+	declaration.Print( 0, 0, &buffer );
+	DoLineBreak();
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlComment& comment )
+{
+	DoIndent();
+	buffer += "<!--";
+	buffer += comment.Value();
+	buffer += "-->";
+	DoLineBreak();
+	return true;
+}
+
+
+bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown )
+{
+	DoIndent();
+	buffer += "<";
+	buffer += unknown.Value();
+	buffer += ">";
+	DoLineBreak();
+	return true;
+}
+
Index: /code/branches/ceguilua/src/tinyxml/tinyxml.h
===================================================================
--- /code/branches/ceguilua/src/tinyxml/tinyxml.h	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/tinyxml.h	(revision 1801)
@@ -0,0 +1,1885 @@
+#define TIXML_USE_TICPP
+
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+
+#ifndef TINYXML_INCLUDED
+#define TINYXML_INCLUDED
+
+#ifdef _MSC_VER
+#pragma warning( push )
+#pragma warning( disable : 4530 )
+#pragma warning( disable : 4786 )
+#endif
+
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+// Help out windows:
+#if defined( _DEBUG ) && !defined( DEBUG )
+#define DEBUG
+#endif
+
+#ifdef TIXML_USE_TICPP
+	#ifndef TIXML_USE_STL
+		#define TIXML_USE_STL
+	#endif
+#endif
+
+#ifdef TIXML_USE_STL
+	#include <string>
+ 	#include <iostream>
+	#include <sstream>
+	#define TIXML_STRING		std::string
+#else
+	#include "tinystr.h"
+	#define TIXML_STRING		TiXmlString
+#endif
+
+// Deprecated library function hell. Compilers want to use the
+// new safe versions. This probably doesn't fully address the problem,
+// but it gets closer. There are too many compilers for me to fully
+// test. If you get compilation troubles, undefine TIXML_SAFE
+#define TIXML_SAFE
+
+#ifdef TIXML_SAFE
+	#if defined(_MSC_VER) && (_MSC_VER >= 1400 )
+		// Microsoft visual studio, version 2005 and higher.
+		#define TIXML_SNPRINTF _snprintf_s
+		#define TIXML_SNSCANF  _snscanf_s
+		#define TIXML_SSCANF   sscanf_s
+	#elif defined(_MSC_VER) && (_MSC_VER >= 1200 )
+		// Microsoft visual studio, version 6 and higher.
+		//#pragma message( "Using _sn* functions." )
+		#define TIXML_SNPRINTF _snprintf
+		#define TIXML_SNSCANF  _snscanf
+		#define TIXML_SSCANF   sscanf
+	#elif defined(__GNUC__) && (__GNUC__ >= 3 )
+		// GCC version 3 and higher.s
+		//#warning( "Using sn* functions." )
+		#define TIXML_SNPRINTF snprintf
+		#define TIXML_SNSCANF  snscanf
+		#define TIXML_SSCANF   sscanf
+	#else
+		#define TIXML_SSCANF   sscanf
+	#endif
+#endif
+
+class TiXmlDocument;
+class TiXmlElement;
+class TiXmlComment;
+class TiXmlUnknown;
+class TiXmlAttribute;
+class TiXmlText;
+class TiXmlDeclaration;
+class TiXmlStylesheetReference;
+class TiXmlParsingData;
+
+const int TIXML_MAJOR_VERSION = 2;
+const int TIXML_MINOR_VERSION = 5;
+const int TIXML_PATCH_VERSION = 3;
+
+/*	Internal structure for tracking location of items
+	in the XML file.
+*/
+struct TiXmlCursor
+{
+	TiXmlCursor()		{ Clear(); }
+	void Clear()		{ row = col = -1; }
+
+	int row;	// 0 based.
+	int col;	// 0 based.
+};
+
+
+/**
+	If you call the Accept() method, it requires being passed a TiXmlVisitor
+	class to handle callbacks. For nodes that contain other nodes (Document, Element)
+	you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves
+	are simple called with Visit().
+
+	If you return 'true' from a Visit method, recursive parsing will continue. If you return
+	false, <b>no children of this node or its sibilings</b> will be Visited.
+
+	All flavors of Visit methods have a default implementation that returns 'true' (continue
+	visiting). You need to only override methods that are interesting to you.
+
+	Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting.
+
+	You should never change the document from a callback.
+
+	@sa TiXmlNode::Accept()
+*/
+class TiXmlVisitor
+{
+public:
+	virtual ~TiXmlVisitor() {}
+
+	/// Visit a document.
+	virtual bool VisitEnter( const TiXmlDocument& /*doc*/ )			{ return true; }
+	/// Visit a document.
+	virtual bool VisitExit( const TiXmlDocument& /*doc*/ )			{ return true; }
+
+	/// Visit an element.
+	virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ )	{ return true; }
+	/// Visit an element.
+	virtual bool VisitExit( const TiXmlElement& /*element*/ )		{ return true; }
+
+	/// Visit a declaration
+	virtual bool Visit( const TiXmlDeclaration& /*declaration*/ )	{ return true; }
+	/// Visit a stylesheet reference
+	virtual bool Visit( const TiXmlStylesheetReference& /*stylesheet*/ )	{ return true; }
+	/// Visit a text node
+	virtual bool Visit( const TiXmlText& /*text*/ )					{ return true; }
+	/// Visit a comment node
+	virtual bool Visit( const TiXmlComment& /*comment*/ )			{ return true; }
+	/// Visit an unknow node
+	virtual bool Visit( const TiXmlUnknown& /*unknown*/ )			{ return true; }
+};
+
+// Only used by Attribute::Query functions
+enum
+{
+	TIXML_SUCCESS,
+	TIXML_NO_ATTRIBUTE,
+	TIXML_WRONG_TYPE
+};
+
+
+// Used by the parsing routines.
+enum TiXmlEncoding
+{
+	TIXML_ENCODING_UNKNOWN,
+	TIXML_ENCODING_UTF8,
+	TIXML_ENCODING_LEGACY
+};
+
+const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN;
+
+/** TiXmlBase is a base class for every class in TinyXml.
+	It does little except to establish that TinyXml classes
+	can be printed and provide some utility functions.
+
+	In XML, the document and elements can contain
+	other elements and other types of nodes.
+
+	@verbatim
+	A Document can contain:	Element	(container or leaf)
+							Comment (leaf)
+							Unknown (leaf)
+							Declaration( leaf )
+
+	An Element can contain:	Element (container or leaf)
+							Text	(leaf)
+							Attributes (not on tree)
+							Comment (leaf)
+							Unknown (leaf)
+
+	A Decleration contains: Attributes (not on tree)
+	@endverbatim
+*/
+#ifdef TIXML_USE_TICPP
+#include "ticpprc.h"
+class TiXmlBase : public TiCppRC
+#else
+class TiXmlBase
+#endif
+{
+	friend class TiXmlNode;
+	friend class TiXmlElement;
+	friend class TiXmlDocument;
+
+public:
+	TiXmlBase()	:	userData(0)		{}
+	virtual ~TiXmlBase()			{}
+
+	/**	All TinyXml classes can print themselves to a filestream
+		or the string class (TiXmlString in non-STL mode, std::string
+		in STL mode.) Either or both cfile and str can be null.
+
+		This is a formatted print, and will insert
+		tabs and newlines.
+
+		(For an unformatted stream, use the << operator.)
+	*/
+	virtual void Print( FILE* cfile, int depth ) const = 0;
+
+	/**	The world does not agree on whether white space should be kept or
+		not. In order to make everyone happy, these global, static functions
+		are provided to set whether or not TinyXml will condense all white space
+		into a single space or not. The default is to condense. Note changing this
+		value is not thread safe.
+	*/
+	static void SetCondenseWhiteSpace( bool condense )		{ condenseWhiteSpace = condense; }
+
+	/// Return the current white space setting.
+	static bool IsWhiteSpaceCondensed()						{ return condenseWhiteSpace; }
+
+	/** Return the position, in the original source file, of this node or attribute.
+		The row and column are 1-based. (That is the first row and first column is
+		1,1). If the returns values are 0 or less, then the parser does not have
+		a row and column value.
+
+		Generally, the row and column value will be set when the TiXmlDocument::Load(),
+		TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set
+		when the DOM was created from operator>>.
+
+		The values reflect the initial load. Once the DOM is modified programmatically
+		(by adding or changing nodes and attributes) the new values will NOT update to
+		reflect changes in the document.
+
+		There is a minor performance cost to computing the row and column. Computation
+		can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value.
+
+		@sa TiXmlDocument::SetTabSize()
+	*/
+	int Row() const			{ return location.row + 1; }
+	int Column() const		{ return location.col + 1; }	///< See Row()
+
+	void  SetUserData( void* user )			{ userData = user; }	///< Set a pointer to arbitrary user data.
+	void* GetUserData()						{ return userData; }	///< Get a pointer to arbitrary user data.
+	const void* GetUserData() const 		{ return userData; }	///< Get a pointer to arbitrary user data.
+
+	// Table that returs, for a given lead byte, the total number of bytes
+	// in the UTF-8 sequence.
+	static const int utf8ByteTable[256];
+
+	virtual const char* Parse(	const char* p,
+								TiXmlParsingData* data,
+								TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0;
+
+	/** Expands entities in a string. Note this should not contian the tag's '<', '>', etc,
+		or they will be transformed into entities!
+	*/
+	static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out );
+
+	enum
+	{
+		TIXML_NO_ERROR = 0,
+		TIXML_ERROR,
+		TIXML_ERROR_OPENING_FILE,
+		TIXML_ERROR_OUT_OF_MEMORY,
+		TIXML_ERROR_PARSING_ELEMENT,
+		TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME,
+		TIXML_ERROR_READING_ELEMENT_VALUE,
+		TIXML_ERROR_READING_ATTRIBUTES,
+		TIXML_ERROR_PARSING_EMPTY,
+		TIXML_ERROR_READING_END_TAG,
+		TIXML_ERROR_PARSING_UNKNOWN,
+		TIXML_ERROR_PARSING_COMMENT,
+		TIXML_ERROR_PARSING_DECLARATION,
+		TIXML_ERROR_DOCUMENT_EMPTY,
+		TIXML_ERROR_EMBEDDED_NULL,
+		TIXML_ERROR_PARSING_CDATA,
+		TIXML_ERROR_DOCUMENT_TOP_ONLY,
+
+		TIXML_ERROR_STRING_COUNT
+	};
+
+protected:
+
+	static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding );
+	inline static bool IsWhiteSpace( char c )
+	{
+		return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' );
+	}
+	inline static bool IsWhiteSpace( int c )
+	{
+		if ( c < 256 )
+			return IsWhiteSpace( (char) c );
+		return false;	// Again, only truly correct for English/Latin...but usually works.
+	}
+
+	#ifdef TIXML_USE_STL
+	static bool	StreamWhiteSpace( std::istream * in, TIXML_STRING * tag );
+	static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag );
+	#endif
+
+	/*	Reads an XML name into the string provided. Returns
+		a pointer just past the last character of the name,
+		or 0 if the function has an error.
+	*/
+	static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding );
+
+	/*	Reads text. Returns a pointer past the given end tag.
+		Wickedly complex options, but it keeps the (sensitive) code in one place.
+	*/
+	static const char* ReadText(	const char* in,				// where to start
+									TIXML_STRING* text,			// the string read
+									bool ignoreWhiteSpace,		// whether to keep the white space
+									const char* endTag,			// what ends this text
+									bool ignoreCase,			// whether to ignore case in the end tag
+									TiXmlEncoding encoding );	// the current encoding
+
+	// If an entity has been found, transform it into a character.
+	static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding );
+
+	// Get a character, while interpreting entities.
+	// The length can be from 0 to 4 bytes.
+	inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding )
+	{
+		assert( p );
+		if ( encoding == TIXML_ENCODING_UTF8 )
+		{
+			*length = utf8ByteTable[ *((const unsigned char*)p) ];
+			assert( *length >= 0 && *length < 5 );
+		}
+		else
+		{
+			*length = 1;
+		}
+
+		if ( *length == 1 )
+		{
+			if ( *p == '&' )
+				return GetEntity( p, _value, length, encoding );
+			*_value = *p;
+			return p+1;
+		}
+		else if ( *length )
+		{
+			//strncpy( _value, p, *length );	// lots of compilers don't like this function (unsafe),
+												// and the null terminator isn't needed
+			for( int i=0; p[i] && i<*length; ++i ) {
+				_value[i] = p[i];
+			}
+			return p + (*length);
+		}
+		else
+		{
+			// Not valid text.
+			return 0;
+		}
+	}
+
+	// Return true if the next characters in the stream are any of the endTag sequences.
+	// Ignore case only works for english, and should only be relied on when comparing
+	// to English words: StringEqual( p, "version", true ) is fine.
+	static bool StringEqual(	const char* p,
+								const char* endTag,
+								bool ignoreCase,
+								TiXmlEncoding encoding );
+
+	static const char* errorString[ TIXML_ERROR_STRING_COUNT ];
+
+	TiXmlCursor location;
+
+    /// Field containing a generic user pointer
+	void*			userData;
+
+	// None of these methods are reliable for any language except English.
+	// Good for approximation, not great for accuracy.
+	static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding );
+	static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding );
+	inline static int ToLower( int v, TiXmlEncoding encoding )
+	{
+		if ( encoding == TIXML_ENCODING_UTF8 )
+		{
+			if ( v < 128 ) return tolower( v );
+			return v;
+		}
+		else
+		{
+			return tolower( v );
+		}
+	}
+	static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length );
+
+private:
+	TiXmlBase( const TiXmlBase& );				// not implemented.
+	void operator=( const TiXmlBase& base );	// not allowed.
+
+	struct Entity
+	{
+		const char*     str;
+		unsigned int	strLength;
+		char		    chr;
+	};
+	enum
+	{
+		NUM_ENTITY = 5,
+		MAX_ENTITY_LENGTH = 6
+
+	};
+	static Entity entity[ NUM_ENTITY ];
+	static bool condenseWhiteSpace;
+};
+
+
+/** The parent class for everything in the Document Object Model.
+	(Except for attributes).
+	Nodes have siblings, a parent, and children. A node can be
+	in a document, or stand on its own. The type of a TiXmlNode
+	can be queried, and it can be cast to its more defined type.
+*/
+class TiXmlNode : public TiXmlBase
+{
+	friend class TiXmlDocument;
+	friend class TiXmlElement;
+
+public:
+	#ifdef TIXML_USE_STL
+
+	    /** An input stream operator, for every class. Tolerant of newlines and
+		    formatting, but doesn't expect them.
+	    */
+	    friend std::istream& operator >> (std::istream& in, TiXmlNode& base);
+
+	    /** An output stream operator, for every class. Note that this outputs
+		    without any newlines or formatting, as opposed to Print(), which
+		    includes tabs and new lines.
+
+		    The operator<< and operator>> are not completely symmetric. Writing
+		    a node to a stream is very well defined. You'll get a nice stream
+		    of output, without any extra whitespace or newlines.
+
+		    But reading is not as well defined. (As it always is.) If you create
+		    a TiXmlElement (for example) and read that from an input stream,
+		    the text needs to define an element or junk will result. This is
+		    true of all input streams, but it's worth keeping in mind.
+
+		    A TiXmlDocument will read nodes until it reads a root element, and
+			all the children of that root element.
+	    */
+	    friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base);
+
+		/// Appends the XML node or attribute to a std::string.
+		friend std::string& operator<< (std::string& out, const TiXmlNode& base );
+
+	#endif
+
+	/** The types of XML nodes supported by TinyXml. (All the
+			unsupported types are picked up by UNKNOWN.)
+	*/
+	enum NodeType
+	{
+		DOCUMENT,
+		ELEMENT,
+		COMMENT,
+		UNKNOWN,
+		TEXT,
+		DECLARATION,
+		STYLESHEETREFERENCE,
+		TYPECOUNT
+	};
+
+	virtual ~TiXmlNode();
+
+	/** The meaning of 'value' changes for the specific type of
+		TiXmlNode.
+		@verbatim
+		Document:	filename of the xml file
+		Element:	name of the element
+		Comment:	the comment text
+		Unknown:	the tag contents
+		Text:		the text string
+		@endverbatim
+
+		The subclasses will wrap this function.
+	*/
+	const char *Value() const { return value.c_str (); }
+
+    #ifdef TIXML_USE_STL
+	/** Return Value() as a std::string. If you only use STL,
+	    this is more efficient than calling Value().
+		Only available in STL mode.
+	*/
+	const std::string& ValueStr() const { return value; }
+	#endif
+
+	const TIXML_STRING& ValueTStr() const { return value; }
+
+	/** Changes the value of the node. Defined as:
+		@verbatim
+		Document:	filename of the xml file
+		Element:	name of the element
+		Comment:	the comment text
+		Unknown:	the tag contents
+		Text:		the text string
+		@endverbatim
+	*/
+	void SetValue(const char * _value) { value = _value;}
+
+    #ifdef TIXML_USE_STL
+	/// STL std::string form.
+	void SetValue( const std::string& _value )	{ value = _value; }
+	#endif
+
+	/// Delete all the children of this node. Does not affect 'this'.
+	void Clear();
+
+	/// One step up the DOM.
+	TiXmlNode* Parent()							{ return parent; }
+	const TiXmlNode* Parent() const				{ return parent; }
+
+	const TiXmlNode* FirstChild()	const		{ return firstChild; }	///< The first child of this node. Will be null if there are no children.
+	TiXmlNode* FirstChild()						{ return firstChild; }
+	const TiXmlNode* FirstChild( const char * value ) const;			///< The first child of this node with the matching 'value'. Will be null if none found.
+	/// The first child of this node with the matching 'value'. Will be null if none found.
+	TiXmlNode* FirstChild( const char * _value ) {
+		// Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe)
+		// call the method, cast the return back to non-const.
+		return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value ));
+	}
+	const TiXmlNode* LastChild() const	{ return lastChild; }		/// The last child of this node. Will be null if there are no children.
+	TiXmlNode* LastChild()	{ return lastChild; }
+
+	const TiXmlNode* LastChild( const char * value ) const;			/// The last child of this node matching 'value'. Will be null if there are no children.
+	TiXmlNode* LastChild( const char * _value ) {
+		return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value ));
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlNode* FirstChild( const std::string& _value ) const	{	return FirstChild (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* FirstChild( const std::string& _value )				{	return FirstChild (_value.c_str ());	}	///< STL std::string form.
+	const TiXmlNode* LastChild( const std::string& _value ) const	{	return LastChild (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* LastChild( const std::string& _value )				{	return LastChild (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/** An alternate way to walk the children of a node.
+		One way to iterate over nodes is:
+		@verbatim
+			for( child = parent->FirstChild(); child; child = child->NextSibling() )
+		@endverbatim
+
+		IterateChildren does the same thing with the syntax:
+		@verbatim
+			child = 0;
+			while( child = parent->IterateChildren( child ) )
+		@endverbatim
+
+		IterateChildren takes the previous child as input and finds
+		the next one. If the previous child is null, it returns the
+		first. IterateChildren will return null when done.
+	*/
+	const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const;
+	TiXmlNode* IterateChildren( const TiXmlNode* previous ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) );
+	}
+
+	/// This flavor of IterateChildren searches for children with a particular 'value'
+	const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const;
+	TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const	{	return IterateChildren (_value.c_str (), previous);	}	///< STL std::string form.
+	TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) {	return IterateChildren (_value.c_str (), previous);	}	///< STL std::string form.
+	#endif
+
+	/** Add a new node related to this. Adds a child past the LastChild.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* InsertEndChild( const TiXmlNode& addThis );
+
+
+	/** Add a new node related to this. Adds a child past the LastChild.
+
+		NOTE: the node to be added is passed by pointer, and will be
+		henceforth owned (and deleted) by tinyXml. This method is efficient
+		and avoids an extra copy, but should be used with care as it
+		uses a different memory model than the other insert functions.
+
+		@sa InsertEndChild
+	*/
+	TiXmlNode* LinkEndChild( TiXmlNode* addThis );
+
+	/** Add a new node related to this. Adds a child before the specified child.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis );
+
+	/** Add a new node related to this. Adds a child after the specified child.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* InsertAfterChild(  TiXmlNode* afterThis, const TiXmlNode& addThis );
+
+	/** Replace a child of this node.
+		Returns a pointer to the new object or NULL if an error occured.
+	*/
+	TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis );
+
+	/// Delete a child of this node.
+	bool RemoveChild( TiXmlNode* removeThis );
+
+	/// Navigate to a sibling node.
+	const TiXmlNode* PreviousSibling() const			{ return prev; }
+	TiXmlNode* PreviousSibling()						{ return prev; }
+
+	/// Navigate to a sibling node.
+	const TiXmlNode* PreviousSibling( const char * ) const;
+	TiXmlNode* PreviousSibling( const char *_prev ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlNode* PreviousSibling( const std::string& _value ) const	{	return PreviousSibling (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* PreviousSibling( const std::string& _value ) 			{	return PreviousSibling (_value.c_str ());	}	///< STL std::string form.
+	const TiXmlNode* NextSibling( const std::string& _value) const		{	return NextSibling (_value.c_str ());	}	///< STL std::string form.
+	TiXmlNode* NextSibling( const std::string& _value) 					{	return NextSibling (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/// Navigate to a sibling node.
+	const TiXmlNode* NextSibling() const				{ return next; }
+	TiXmlNode* NextSibling()							{ return next; }
+
+	/// Navigate to a sibling node with the given 'value'.
+	const TiXmlNode* NextSibling( const char * ) const;
+	TiXmlNode* NextSibling( const char* _next ) {
+		return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) );
+	}
+
+	/** Convenience function to get through elements.
+		Calls NextSibling and ToElement. Will skip all non-Element
+		nodes. Returns 0 if there is not another element.
+	*/
+	const TiXmlElement* NextSiblingElement() const;
+	TiXmlElement* NextSiblingElement() {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() );
+	}
+
+	/** Convenience function to get through elements.
+		Calls NextSibling and ToElement. Will skip all non-Element
+		nodes. Returns 0 if there is not another element.
+	*/
+	const TiXmlElement* NextSiblingElement( const char * ) const;
+	TiXmlElement* NextSiblingElement( const char *_next ) {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlElement* NextSiblingElement( const std::string& _value) const	{	return NextSiblingElement (_value.c_str ());	}	///< STL std::string form.
+	TiXmlElement* NextSiblingElement( const std::string& _value)				{	return NextSiblingElement (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/// Convenience function to get through elements.
+	const TiXmlElement* FirstChildElement()	const;
+	TiXmlElement* FirstChildElement() {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() );
+	}
+
+	/// Convenience function to get through elements.
+	const TiXmlElement* FirstChildElement( const char * _value ) const;
+	TiXmlElement* FirstChildElement( const char * _value ) {
+		return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) );
+	}
+
+    #ifdef TIXML_USE_STL
+	const TiXmlElement* FirstChildElement( const std::string& _value ) const	{	return FirstChildElement (_value.c_str ());	}	///< STL std::string form.
+	TiXmlElement* FirstChildElement( const std::string& _value )				{	return FirstChildElement (_value.c_str ());	}	///< STL std::string form.
+	#endif
+
+	/** Query the type (as an enumerated value, above) of this node.
+		The possible types are: DOCUMENT, ELEMENT, COMMENT,
+								UNKNOWN, TEXT, and DECLARATION.
+	*/
+	int Type() const	{ return type; }
+
+	/** Return a pointer to the Document this node lives in.
+		Returns null if not in a document.
+	*/
+	const TiXmlDocument* GetDocument() const;
+	TiXmlDocument* GetDocument() {
+		return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() );
+	}
+
+	/// Returns true if this node has no children.
+	bool NoChildren() const						{ return !firstChild; }
+
+	virtual const TiXmlDocument*    ToDocument()    const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlElement*     ToElement()     const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlComment*     ToComment()     const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlUnknown*     ToUnknown()     const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlText*        ToText()        const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+
+	virtual TiXmlDocument*          ToDocument()    { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlElement*           ToElement()	    { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlComment*           ToComment()     { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlUnknown*           ToUnknown()	    { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlText*	            ToText()        { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlDeclaration*       ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+	virtual TiXmlStylesheetReference*       ToStylesheetReference() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type.
+
+	/** Create an exact duplicate of this node and return it. The memory must be deleted
+		by the caller.
+	*/
+	virtual TiXmlNode* Clone() const = 0;
+
+	/** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the
+		XML tree will be conditionally visited and the host will be called back
+		via the TiXmlVisitor interface.
+
+		This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse
+		the XML for the callbacks, so the performance of TinyXML is unchanged by using this
+		interface versus any other.)
+
+		The interface has been based on ideas from:
+
+		- http://www.saxproject.org/
+		- http://c2.com/cgi/wiki?HierarchicalVisitorPattern
+
+		Which are both good references for "visiting".
+
+		An example of using Accept():
+		@verbatim
+		TiXmlPrinter printer;
+		tinyxmlDoc.Accept( &printer );
+		const char* xmlcstr = printer.CStr();
+		@endverbatim
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const = 0;
+
+protected:
+	TiXmlNode( NodeType _type );
+
+	// Copy to the allocated object. Shared functionality between Clone, Copy constructor,
+	// and the assignment operator.
+	void CopyTo( TiXmlNode* target ) const;
+
+	#ifdef TIXML_USE_STL
+	    // The real work of the input operator.
+	virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0;
+	#endif
+
+	// Figure out what is at *p, and parse it. Returns null if it is not an xml node.
+	TiXmlNode* Identify( const char* start, TiXmlEncoding encoding );
+
+	TiXmlNode*		parent;
+	NodeType		type;
+
+	TiXmlNode*		firstChild;
+	TiXmlNode*		lastChild;
+
+	TIXML_STRING	value;
+
+	TiXmlNode*		prev;
+	TiXmlNode*		next;
+
+private:
+	TiXmlNode( const TiXmlNode& );				// not implemented.
+	void operator=( const TiXmlNode& base );	// not allowed.
+};
+
+
+/** An attribute is a name-value pair. Elements have an arbitrary
+	number of attributes, each with a unique name.
+
+	@note The attributes are not TiXmlNodes, since they are not
+		  part of the tinyXML document object model. There are other
+		  suggested ways to look at this problem.
+*/
+class TiXmlAttribute : public TiXmlBase
+{
+	friend class TiXmlAttributeSet;
+
+public:
+	/// Construct an empty attribute.
+	TiXmlAttribute() : TiXmlBase()
+	{
+		document = 0;
+		prev = next = 0;
+	}
+
+	#ifdef TIXML_USE_STL
+	/// std::string constructor.
+	TiXmlAttribute( const std::string& _name, const std::string& _value )
+	{
+		name = _name;
+		value = _value;
+		document = 0;
+		prev = next = 0;
+	}
+	#endif
+
+	/// Construct an attribute with a name and value.
+	TiXmlAttribute( const char * _name, const char * _value )
+	{
+		name = _name;
+		value = _value;
+		document = 0;
+		prev = next = 0;
+	}
+
+	const char*		Name()  const		{ return name.c_str(); }		///< Return the name of this attribute.
+	const char*		Value() const		{ return value.c_str(); }		///< Return the value of this attribute.
+	#ifdef TIXML_USE_STL
+	const std::string& ValueStr() const	{ return value; }				///< Return the value of this attribute.
+	#endif
+	int				IntValue() const;									///< Return the value of this attribute, converted to an integer.
+	double			DoubleValue() const;								///< Return the value of this attribute, converted to a double.
+
+	// Get the tinyxml string representation
+	const TIXML_STRING& NameTStr() const { return name; }
+
+	/** QueryIntValue examines the value string. It is an alternative to the
+		IntValue() method with richer error checking.
+		If the value is an integer, it is stored in 'value' and
+		the call returns TIXML_SUCCESS. If it is not
+		an integer, it returns TIXML_WRONG_TYPE.
+
+		A specialized but useful call. Note that for success it returns 0,
+		which is the opposite of almost all other TinyXml calls.
+	*/
+	int QueryIntValue( int* _value ) const;
+	/// QueryDoubleValue examines the value string. See QueryIntValue().
+	int QueryDoubleValue( double* _value ) const;
+
+	void SetName( const char* _name )	{ name = _name; }				///< Set the name of this attribute.
+	void SetValue( const char* _value )	{ value = _value; }				///< Set the value.
+
+	void SetIntValue( int _value );										///< Set the value from an integer.
+	void SetDoubleValue( double _value );								///< Set the value from a double.
+
+    #ifdef TIXML_USE_STL
+	/// STL std::string form.
+	void SetName( const std::string& _name )	{ name = _name; }
+	/// STL std::string form.
+	void SetValue( const std::string& _value )	{ value = _value; }
+	#endif
+
+	/// Get the next sibling attribute in the DOM. Returns null at end.
+	const TiXmlAttribute* Next() const;
+	TiXmlAttribute* Next() {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() );
+	}
+
+	/// Get the previous sibling attribute in the DOM. Returns null at beginning.
+	const TiXmlAttribute* Previous() const;
+	TiXmlAttribute* Previous() {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() );
+	}
+
+	bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; }
+	bool operator<( const TiXmlAttribute& rhs )	 const { return name < rhs.name; }
+	bool operator>( const TiXmlAttribute& rhs )  const { return name > rhs.name; }
+
+	/*	Attribute parsing starts: first letter of the name
+						 returns: the next char after the value end quote
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	// Prints this Attribute to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const {
+		Print( cfile, depth, 0 );
+	}
+	void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
+
+	// [internal use]
+	// Set the document pointer so the attribute can report errors.
+	void SetDocument( TiXmlDocument* doc )	{ document = doc; }
+
+private:
+	TiXmlAttribute( const TiXmlAttribute& );				// not implemented.
+	void operator=( const TiXmlAttribute& base );	// not allowed.
+
+	TiXmlDocument*	document;	// A pointer back to a document, for error reporting.
+	TIXML_STRING name;
+	TIXML_STRING value;
+	TiXmlAttribute*	prev;
+	TiXmlAttribute*	next;
+};
+
+
+/*	A class used to manage a group of attributes.
+	It is only used internally, both by the ELEMENT and the DECLARATION.
+
+	The set can be changed transparent to the Element and Declaration
+	classes that use it, but NOT transparent to the Attribute
+	which has to implement a next() and previous() method. Which makes
+	it a bit problematic and prevents the use of STL.
+
+	This version is implemented with circular lists because:
+		- I like circular lists
+		- it demonstrates some independence from the (typical) doubly linked list.
+*/
+class TiXmlAttributeSet
+{
+public:
+	TiXmlAttributeSet();
+	~TiXmlAttributeSet();
+
+	void Add( TiXmlAttribute* attribute );
+	void Remove( TiXmlAttribute* attribute );
+
+	const TiXmlAttribute* First()	const	{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
+	TiXmlAttribute* First()					{ return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; }
+	const TiXmlAttribute* Last() const		{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
+	TiXmlAttribute* Last()					{ return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; }
+
+	const TiXmlAttribute*	Find( const char* _name ) const;
+	TiXmlAttribute*	Find( const char* _name ) {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
+	}
+	#ifdef TIXML_USE_STL
+	const TiXmlAttribute*	Find( const std::string& _name ) const;
+	TiXmlAttribute*	Find( const std::string& _name ) {
+		return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttributeSet* >(this))->Find( _name ) );
+	}
+
+	#endif
+
+private:
+	//*ME:	Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element),
+	//*ME:	this class must be also use a hidden/disabled copy-constructor !!!
+	TiXmlAttributeSet( const TiXmlAttributeSet& );	// not allowed
+	void operator=( const TiXmlAttributeSet& );	// not allowed (as TiXmlAttribute)
+
+	TiXmlAttribute sentinel;
+};
+
+
+/** The element is a container class. It has a value, the element name,
+	and can contain other elements, text, comments, and unknowns.
+	Elements also contain an arbitrary number of attributes.
+*/
+class TiXmlElement : public TiXmlNode
+{
+public:
+	/// Construct an element.
+	TiXmlElement (const char * in_value);
+
+	#ifdef TIXML_USE_STL
+	/// std::string constructor.
+	TiXmlElement( const std::string& _value );
+	#endif
+
+	TiXmlElement( const TiXmlElement& );
+
+	void operator=( const TiXmlElement& base );
+
+	virtual ~TiXmlElement();
+
+	/** Given an attribute name, Attribute() returns the value
+		for the attribute of that name, or null if none exists.
+	*/
+	const char* Attribute( const char* name ) const;
+
+	/** Given an attribute name, Attribute() returns the value
+		for the attribute of that name, or null if none exists.
+		If the attribute exists and can be converted to an integer,
+		the integer value will be put in the return 'i', if 'i'
+		is non-null.
+	*/
+	const char* Attribute( const char* name, int* i ) const;
+
+	/** Given an attribute name, Attribute() returns the value
+		for the attribute of that name, or null if none exists.
+		If the attribute exists and can be converted to an double,
+		the double value will be put in the return 'd', if 'd'
+		is non-null.
+	*/
+	const char* Attribute( const char* name, double* d ) const;
+
+	/** QueryIntAttribute examines the attribute - it is an alternative to the
+		Attribute() method with richer error checking.
+		If the attribute is an integer, it is stored in 'value' and
+		the call returns TIXML_SUCCESS. If it is not
+		an integer, it returns TIXML_WRONG_TYPE. If the attribute
+		does not exist, then TIXML_NO_ATTRIBUTE is returned.
+	*/
+	int QueryIntAttribute( const char* name, int* _value ) const;
+	/// QueryDoubleAttribute examines the attribute - see QueryIntAttribute().
+	int QueryDoubleAttribute( const char* name, double* _value ) const;
+	/// QueryFloatAttribute examines the attribute - see QueryIntAttribute().
+	int QueryFloatAttribute( const char* name, float* _value ) const {
+		double d;
+		int result = QueryDoubleAttribute( name, &d );
+		if ( result == TIXML_SUCCESS ) {
+			*_value = (float)d;
+		}
+		return result;
+	}
+
+    #ifdef TIXML_USE_STL
+	/** Template form of the attribute query which will try to read the
+		attribute into the specified type. Very easy, very powerful, but
+		be careful to make sure to call this with the correct type.
+
+		NOTE: This method doesn't work correctly for 'string' types.
+
+		@return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE
+	*/
+	template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const
+	{
+		const TiXmlAttribute* node = attributeSet.Find( name );
+		if ( !node )
+			return TIXML_NO_ATTRIBUTE;
+
+		std::stringstream sstream( node->ValueStr() );
+		sstream >> *outValue;
+		if ( !sstream.fail() )
+			return TIXML_SUCCESS;
+		return TIXML_WRONG_TYPE;
+	}
+	/*
+	 This is - in theory - a bug fix for "QueryValueAtribute returns truncated std::string"
+	 but template specialization is hard to get working cross-compiler. Leaving the bug for now.
+
+	// The above will fail for std::string because the space character is used as a seperator.
+	// Specialize for strings. Bug [ 1695429 ] QueryValueAtribute returns truncated std::string
+	template<> int QueryValueAttribute( const std::string& name, std::string* outValue ) const
+	{
+		const TiXmlAttribute* node = attributeSet.Find( name );
+		if ( !node )
+			return TIXML_NO_ATTRIBUTE;
+		*outValue = node->ValueStr();
+		return TIXML_SUCCESS;
+	}
+	*/
+	#endif
+
+	/** Sets an attribute of name to a given value. The attribute
+		will be created if it does not exist, or changed if it does.
+	*/
+	void SetAttribute( const char* name, const char * _value );
+
+    #ifdef TIXML_USE_STL
+	const std::string* Attribute( const std::string& name ) const;
+	const std::string* Attribute( const std::string& name, int* i ) const;
+	const std::string* Attribute( const std::string& name, double* d ) const;
+	int QueryIntAttribute( const std::string& name, int* _value ) const;
+	int QueryDoubleAttribute( const std::string& name, double* _value ) const;
+
+	/// STL std::string form.
+	void SetAttribute( const std::string& name, const std::string& _value );
+	///< STL std::string form.
+	void SetAttribute( const std::string& name, int _value );
+	#endif
+
+	/** Sets an attribute of name to a given value. The attribute
+		will be created if it does not exist, or changed if it does.
+	*/
+	void SetAttribute( const char * name, int value );
+
+	/** Sets an attribute of name to a given value. The attribute
+		will be created if it does not exist, or changed if it does.
+	*/
+	void SetDoubleAttribute( const char * name, double value );
+
+	/** Deletes an attribute with the given name.
+	*/
+	void RemoveAttribute( const char * name );
+    #ifdef TIXML_USE_STL
+	void RemoveAttribute( const std::string& name )	{	RemoveAttribute (name.c_str ());	}	///< STL std::string form.
+	#endif
+
+	const TiXmlAttribute* FirstAttribute() const	{ return attributeSet.First(); }		///< Access the first attribute in this element.
+	TiXmlAttribute* FirstAttribute() 				{ return attributeSet.First(); }
+	const TiXmlAttribute* LastAttribute()	const 	{ return attributeSet.Last(); }		///< Access the last attribute in this element.
+	TiXmlAttribute* LastAttribute()					{ return attributeSet.Last(); }
+
+	/** Convenience function for easy access to the text inside an element. Although easy
+		and concise, GetText() is limited compared to getting the TiXmlText child
+		and accessing it directly.
+
+		If the first child of 'this' is a TiXmlText, the GetText()
+		returns the character string of the Text node, else null is returned.
+
+		This is a convenient method for getting the text of simple contained text:
+		@verbatim
+		<foo>This is text</foo>
+		const char* str = fooElement->GetText();
+		@endverbatim
+
+		'str' will be a pointer to "This is text".
+
+		Note that this function can be misleading. If the element foo was created from
+		this XML:
+		@verbatim
+		<foo><b>This is text</b></foo>
+		@endverbatim
+
+		then the value of str would be null. The first child node isn't a text node, it is
+		another element. From this XML:
+		@verbatim
+		<foo>This is <b>text</b></foo>
+		@endverbatim
+		GetText() will return "This is ".
+
+		WARNING: GetText() accesses a child node - don't become confused with the
+				 similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are
+				 safe type casts on the referenced node.
+	*/
+	const char* GetText() const;
+
+	/// Creates a new Element and returns it - the returned element is a copy.
+	virtual TiXmlNode* Clone() const;
+	// Print the Element to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	/*	Attribtue parsing starts: next char past '<'
+						 returns: next char past '>'
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlElement*     ToElement()     const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlElement*           ToElement()	          { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+
+	void CopyTo( TiXmlElement* target ) const;
+	void ClearThis();	// like clear, but initializes 'this' object as well
+
+	// Used to be public [internal use]
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+	/*	[internal use]
+		Reads the "value" of the element -- another element, or text.
+		This should terminate with the current end tag.
+	*/
+	const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding );
+
+private:
+
+	TiXmlAttributeSet attributeSet;
+};
+
+
+/**	An XML comment.
+*/
+class TiXmlComment : public TiXmlNode
+{
+public:
+	/// Constructs an empty comment.
+	TiXmlComment() : TiXmlNode( TiXmlNode::COMMENT ) {}
+	/// Construct a comment from text.
+	TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::COMMENT ) {
+		SetValue( _value );
+	}
+	TiXmlComment( const TiXmlComment& );
+	void operator=( const TiXmlComment& base );
+
+	virtual ~TiXmlComment()	{}
+
+	/// Returns a copy of this Comment.
+	virtual TiXmlNode* Clone() const;
+	// Write this Comment to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	/*	Attribtue parsing starts: at the ! of the !--
+						 returns: next char past '>'
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlComment*  ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlComment*  ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+	void CopyTo( TiXmlComment* target ) const;
+
+	// used to be public
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+//	virtual void StreamOut( TIXML_OSTREAM * out ) const;
+
+private:
+
+};
+
+
+/** XML text. A text node can have 2 ways to output the next. "normal" output
+	and CDATA. It will default to the mode it was parsed from the XML file and
+	you generally want to leave it alone, but you can change the output mode with
+	SetCDATA() and query it with CDATA().
+*/
+class TiXmlText : public TiXmlNode
+{
+	friend class TiXmlElement;
+public:
+	/** Constructor for text element. By default, it is treated as
+		normal, encoded text. If you want it be output as a CDATA text
+		element, set the parameter _cdata to 'true'
+	*/
+	TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TEXT)
+	{
+		SetValue( initValue );
+		cdata = false;
+	}
+	virtual ~TiXmlText() {}
+
+	#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TEXT)
+	{
+		SetValue( initValue );
+		cdata = false;
+	}
+	#endif
+
+	TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TEXT )	{ copy.CopyTo( this ); }
+	void operator=( const TiXmlText& base )							 	{ base.CopyTo( this ); }
+
+	// Write this text object to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	/// Queries whether this represents text using a CDATA section.
+	bool CDATA() const				{ return cdata; }
+	/// Turns on or off a CDATA representation of text.
+	void SetCDATA( bool _cdata )	{ cdata = _cdata; }
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlText*       ToText()       { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* content ) const;
+
+protected :
+	///  [internal use] Creates a new Element and returns it.
+	virtual TiXmlNode* Clone() const;
+	void CopyTo( TiXmlText* target ) const;
+
+	bool Blank() const;	// returns true if all white space and new lines
+	// [internal use]
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+	bool cdata;			// true if this should be input and output as a CDATA style text element
+};
+
+
+/** In correct XML the declaration is the first entry in the file.
+	@verbatim
+		<?xml version="1.0" standalone="yes"?>
+	@endverbatim
+
+	TinyXml will happily read or write files without a declaration,
+	however. There are 3 possible attributes to the declaration:
+	version, encoding, and standalone.
+
+	Note: In this version of the code, the attributes are
+	handled as special cases, not generic attributes, simply
+	because there can only be at most 3 and they are always the same.
+*/
+class TiXmlDeclaration : public TiXmlNode
+{
+public:
+	/// Construct an empty declaration.
+	TiXmlDeclaration()   : TiXmlNode( TiXmlNode::DECLARATION ) {}
+
+#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlDeclaration(	const std::string& _version,
+						const std::string& _encoding,
+						const std::string& _standalone );
+#endif
+
+	/// Construct.
+	TiXmlDeclaration(	const char* _version,
+						const char* _encoding,
+						const char* _standalone );
+
+	TiXmlDeclaration( const TiXmlDeclaration& copy );
+	void operator=( const TiXmlDeclaration& copy );
+
+	virtual ~TiXmlDeclaration()	{}
+
+	/// Version. Will return an empty string if none was found.
+	const char *Version() const			{ return version.c_str (); }
+	/// Encoding. Will return an empty string if none was found.
+	const char *Encoding() const		{ return encoding.c_str (); }
+	/// Is this a standalone document?
+	const char *Standalone() const		{ return standalone.c_str (); }
+
+	/// Creates a copy of this Declaration and returns it.
+	virtual TiXmlNode* Clone() const;
+	// Print this declaration to a FILE stream.
+	virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
+	virtual void Print( FILE* cfile, int depth ) const {
+		Print( cfile, depth, 0 );
+	}
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlDeclaration*       ToDeclaration()       { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+	void CopyTo( TiXmlDeclaration* target ) const;
+	// used to be public
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+
+	TIXML_STRING version;
+	TIXML_STRING encoding;
+	TIXML_STRING standalone;
+};
+
+/** A stylesheet reference looks like this:
+	@verbatim
+		<?xml-stylesheet type="text/xsl" href="style.xsl"?>
+	@endverbatim
+
+	Note: In this version of the code, the attributes are
+	handled as special cases, not generic attributes, simply
+	because there can only be at most 2 and they are always the same.
+*/
+class TiXmlStylesheetReference : public TiXmlNode
+{
+public:
+	/// Construct an empty declaration.
+	TiXmlStylesheetReference()   : TiXmlNode( TiXmlNode::STYLESHEETREFERENCE ) {}
+
+#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlStylesheetReference(	const std::string& _type,
+								const std::string& _href );
+#endif
+
+	/// Construct.
+	TiXmlStylesheetReference(	const char* _type,
+								const char* _href );
+
+	TiXmlStylesheetReference( const TiXmlStylesheetReference& copy );
+	void operator=( const TiXmlStylesheetReference& copy );
+
+	virtual ~TiXmlStylesheetReference()	{}
+
+	/// Type. Will return an empty string if none was found.
+	const char *Type() const { return type.c_str (); }
+	/// Href. Will return an empty string if none was found.
+	const char *Href() const		{ return href.c_str (); }
+
+	/// Creates a copy of this StylesheetReference and returns it.
+	virtual TiXmlNode* Clone() const;
+	// Print this declaration to a FILE stream.
+	virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const;
+	virtual void Print( FILE* cfile, int depth ) const {
+		Print( cfile, depth, 0 );
+	}
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlStylesheetReference* ToStylesheetReference() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlStylesheetReference*       ToStylesheetReference()       { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* visitor ) const;
+
+protected:
+	void CopyTo( TiXmlStylesheetReference* target ) const;
+	// used to be public
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+
+	TIXML_STRING type;
+	TIXML_STRING href;
+};
+
+/** Any tag that tinyXml doesn't recognize is saved as an
+	unknown. It is a tag of text, but should not be modified.
+	It will be written back to the XML, unchanged, when the file
+	is saved.
+
+	DTD tags get thrown into TiXmlUnknowns.
+*/
+class TiXmlUnknown : public TiXmlNode
+{
+public:
+	TiXmlUnknown() : TiXmlNode( TiXmlNode::UNKNOWN )	{}
+	virtual ~TiXmlUnknown() {}
+
+	TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::UNKNOWN )		{ copy.CopyTo( this ); }
+	void operator=( const TiXmlUnknown& copy )										{ copy.CopyTo( this ); }
+
+	/// Creates a copy of this Unknown and returns it.
+	virtual TiXmlNode* Clone() const;
+	// Print this Unknown to a FILE stream.
+	virtual void Print( FILE* cfile, int depth ) const;
+
+	virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding );
+
+	virtual const TiXmlUnknown*     ToUnknown()     const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlUnknown*           ToUnknown()	    { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* content ) const;
+
+protected:
+	void CopyTo( TiXmlUnknown* target ) const;
+
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+
+};
+
+
+/** Always the top level node. A document binds together all the
+	XML pieces. It can be saved, loaded, and printed to the screen.
+	The 'value' of a document node is the xml file name.
+*/
+class TiXmlDocument : public TiXmlNode
+{
+public:
+	/// Create an empty document, that has no name.
+	TiXmlDocument();
+	/// Create a document with a name. The name of the document is also the filename of the xml.
+	TiXmlDocument( const char * documentName );
+
+	#ifdef TIXML_USE_STL
+	/// Constructor.
+	TiXmlDocument( const std::string& documentName );
+	#endif
+
+	TiXmlDocument( const TiXmlDocument& copy );
+	void operator=( const TiXmlDocument& copy );
+
+	virtual ~TiXmlDocument() {}
+
+	/** Load a file using the current document value.
+		Returns true if successful. Will delete any existing
+		document data before loading.
+	*/
+	bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	/// Save a file using the current document value. Returns true if successful.
+	bool SaveFile() const;
+	/// Load a file using the given filename. Returns true if successful.
+	bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	/// Save a file using the given filename. Returns true if successful.
+	bool SaveFile( const char * filename ) const;
+	/** Load a file using the given FILE*. Returns true if successful. Note that this method
+		doesn't stream - the entire object pointed at by the FILE*
+		will be interpreted as an XML file. TinyXML doesn't stream in XML from the current
+		file location. Streaming may be added in the future.
+	*/
+	bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+	/// Save a file using the given FILE*. Returns true if successful.
+	bool SaveFile( FILE* ) const;
+
+	#ifdef TIXML_USE_STL
+	bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING )			///< STL std::string version.
+	{
+//		StringToBuffer f( filename );
+//		return ( f.buffer && LoadFile( f.buffer, encoding ));
+		return LoadFile( filename.c_str(), encoding );
+	}
+	bool SaveFile( const std::string& filename ) const		///< STL std::string version.
+	{
+//		StringToBuffer f( filename );
+//		return ( f.buffer && SaveFile( f.buffer ));
+		return SaveFile( filename.c_str() );
+	}
+	#endif
+
+	/** Parse the given null terminated block of xml data. Passing in an encoding to this
+		method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml
+		to use that encoding, regardless of what TinyXml might otherwise try to detect.
+	*/
+	virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING );
+
+	/** Get the root element -- the only top level element -- of the document.
+		In well formed XML, there should only be one. TinyXml is tolerant of
+		multiple elements at the document level.
+	*/
+	const TiXmlElement* RootElement() const		{ return FirstChildElement(); }
+	TiXmlElement* RootElement()					{ return FirstChildElement(); }
+
+	/** If an error occurs, Error will be set to true. Also,
+		- The ErrorId() will contain the integer identifier of the error (not generally useful)
+		- The ErrorDesc() method will return the name of the error. (very useful)
+		- The ErrorRow() and ErrorCol() will return the location of the error (if known)
+	*/
+	bool Error() const						{ return error; }
+
+	/// Contains a textual (english) description of the error if one occurs.
+	const char * ErrorDesc() const	{ return errorDesc.c_str (); }
+
+	/** Generally, you probably want the error string ( ErrorDesc() ). But if you
+		prefer the ErrorId, this function will fetch it.
+	*/
+	int ErrorId()	const				{ return errorId; }
+
+	/** Returns the location (if known) of the error. The first column is column 1,
+		and the first row is row 1. A value of 0 means the row and column wasn't applicable
+		(memory errors, for example, have no row/column) or the parser lost the error. (An
+		error in the error reporting, in that case.)
+
+		@sa SetTabSize, Row, Column
+	*/
+	int ErrorRow() const	{ return errorLocation.row+1; }
+	int ErrorCol() const	{ return errorLocation.col+1; }	///< The column where the error occured. See ErrorRow()
+
+	/** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol())
+		to report the correct values for row and column. It does not change the output
+		or input in any way.
+
+		By calling this method, with a tab size
+		greater than 0, the row and column of each node and attribute is stored
+		when the file is loaded. Very useful for tracking the DOM back in to
+		the source file.
+
+		The tab size is required for calculating the location of nodes. If not
+		set, the default of 4 is used. The tabsize is set per document. Setting
+		the tabsize to 0 disables row/column tracking.
+
+		Note that row and column tracking is not supported when using operator>>.
+
+		The tab size needs to be enabled before the parse or load. Correct usage:
+		@verbatim
+		TiXmlDocument doc;
+		doc.SetTabSize( 8 );
+		doc.Load( "myfile.xml" );
+		@endverbatim
+
+		@sa Row, Column
+	*/
+	void SetTabSize( int _tabsize )		{ tabsize = _tabsize; }
+
+	int TabSize() const	{ return tabsize; }
+
+	/** If you have handled the error, it can be reset with this call. The error
+		state is automatically cleared if you Parse a new XML block.
+	*/
+	void ClearError()						{	error = false;
+												errorId = 0;
+												errorDesc = "";
+												errorLocation.row = errorLocation.col = 0;
+												//errorLocation.last = 0;
+											}
+
+	/** Write the document to standard out using formatted printing ("pretty print"). */
+	void Print() const						{ Print( stdout, 0 ); }
+
+	/* Write the document to a string using formatted printing ("pretty print"). This
+		will allocate a character array (new char[]) and return it as a pointer. The
+		calling code pust call delete[] on the return char* to avoid a memory leak.
+	*/
+	//char* PrintToMemory() const;
+
+	/// Print this Document to a FILE stream.
+	virtual void Print( FILE* cfile, int depth = 0 ) const;
+	// [internal use]
+	void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding );
+
+	virtual const TiXmlDocument*    ToDocument()    const { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+	virtual TiXmlDocument*          ToDocument()          { return this; } ///< Cast to a more defined type. Will return null not of the requested type.
+
+	/** Walk the XML tree visiting this node and all of its children.
+	*/
+	virtual bool Accept( TiXmlVisitor* content ) const;
+
+protected :
+	// [internal use]
+	virtual TiXmlNode* Clone() const;
+	#ifdef TIXML_USE_STL
+	virtual void StreamIn( std::istream * in, TIXML_STRING * tag );
+	#endif
+
+private:
+	void CopyTo( TiXmlDocument* target ) const;
+
+	bool error;
+	int  errorId;
+	TIXML_STRING errorDesc;
+	int tabsize;
+	TiXmlCursor errorLocation;
+	bool useMicrosoftBOM;		// the UTF-8 BOM were found when read. Note this, and try to write.
+};
+
+
+/**
+	A TiXmlHandle is a class that wraps a node pointer with null checks; this is
+	an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml
+	DOM structure. It is a separate utility class.
+
+	Take an example:
+	@verbatim
+	<Document>
+		<Element attributeA = "valueA">
+			<Child attributeB = "value1" />
+			<Child attributeB = "value2" />
+		</Element>
+	<Document>
+	@endverbatim
+
+	Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very
+	easy to write a *lot* of code that looks like:
+
+	@verbatim
+	TiXmlElement* root = document.FirstChildElement( "Document" );
+	if ( root )
+	{
+		TiXmlElement* element = root->FirstChildElement( "Element" );
+		if ( element )
+		{
+			TiXmlElement* child = element->FirstChildElement( "Child" );
+			if ( child )
+			{
+				TiXmlElement* child2 = child->NextSiblingElement( "Child" );
+				if ( child2 )
+				{
+					// Finally do something useful.
+	@endverbatim
+
+	And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity
+	of such code. A TiXmlHandle checks for null	pointers so it is perfectly safe
+	and correct to use:
+
+	@verbatim
+	TiXmlHandle docHandle( &document );
+	TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement();
+	if ( child2 )
+	{
+		// do something useful
+	@endverbatim
+
+	Which is MUCH more concise and useful.
+
+	It is also safe to copy handles - internally they are nothing more than node pointers.
+	@verbatim
+	TiXmlHandle handleCopy = handle;
+	@endverbatim
+
+	What they should not be used for is iteration:
+
+	@verbatim
+	int i=0;
+	while ( true )
+	{
+		TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement();
+		if ( !child )
+			break;
+		// do something
+		++i;
+	}
+	@endverbatim
+
+	It seems reasonable, but it is in fact two embedded while loops. The Child method is
+	a linear walk to find the element, so this code would iterate much more than it needs
+	to. Instead, prefer:
+
+	@verbatim
+	TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement();
+
+	for( child; child; child=child->NextSiblingElement() )
+	{
+		// do something
+	}
+	@endverbatim
+*/
+class TiXmlHandle
+{
+public:
+	/// Create a handle from any node (at any depth of the tree.) This can be a null pointer.
+	TiXmlHandle( TiXmlNode* _node )					{ this->node = _node; }
+	/// Copy constructor
+	TiXmlHandle( const TiXmlHandle& ref )			{ this->node = ref.node; }
+	TiXmlHandle operator=( const TiXmlHandle& ref ) { this->node = ref.node; return *this; }
+
+	/// Return a handle to the first child node.
+	TiXmlHandle FirstChild() const;
+	/// Return a handle to the first child node with the given name.
+	TiXmlHandle FirstChild( const char * value ) const;
+	/// Return a handle to the first child element.
+	TiXmlHandle FirstChildElement() const;
+	/// Return a handle to the first child element with the given name.
+	TiXmlHandle FirstChildElement( const char * value ) const;
+
+	/** Return a handle to the "index" child with the given name.
+		The first child is 0, the second 1, etc.
+	*/
+	TiXmlHandle Child( const char* value, int index ) const;
+	/** Return a handle to the "index" child.
+		The first child is 0, the second 1, etc.
+	*/
+	TiXmlHandle Child( int index ) const;
+	/** Return a handle to the "index" child element with the given name.
+		The first child element is 0, the second 1, etc. Note that only TiXmlElements
+		are indexed: other types are not counted.
+	*/
+	TiXmlHandle ChildElement( const char* value, int index ) const;
+	/** Return a handle to the "index" child element.
+		The first child element is 0, the second 1, etc. Note that only TiXmlElements
+		are indexed: other types are not counted.
+	*/
+	TiXmlHandle ChildElement( int index ) const;
+
+	#ifdef TIXML_USE_STL
+	TiXmlHandle FirstChild( const std::string& _value ) const				{ return FirstChild( _value.c_str() ); }
+	TiXmlHandle FirstChildElement( const std::string& _value ) const		{ return FirstChildElement( _value.c_str() ); }
+
+	TiXmlHandle Child( const std::string& _value, int index ) const			{ return Child( _value.c_str(), index ); }
+	TiXmlHandle ChildElement( const std::string& _value, int index ) const	{ return ChildElement( _value.c_str(), index ); }
+	#endif
+
+	/** Return the handle as a TiXmlNode. This may return null.
+	*/
+	TiXmlNode* ToNode() const			{ return node; }
+	/** Return the handle as a TiXmlElement. This may return null.
+	*/
+	TiXmlElement* ToElement() const		{ return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); }
+	/**	Return the handle as a TiXmlText. This may return null.
+	*/
+	TiXmlText* ToText() const			{ return ( ( node && node->ToText() ) ? node->ToText() : 0 ); }
+	/** Return the handle as a TiXmlUnknown. This may return null.
+	*/
+	TiXmlUnknown* ToUnknown() const		{ return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); }
+
+	/** @deprecated use ToNode.
+		Return the handle as a TiXmlNode. This may return null.
+	*/
+	TiXmlNode* Node() const			{ return ToNode(); }
+	/** @deprecated use ToElement.
+		Return the handle as a TiXmlElement. This may return null.
+	*/
+	TiXmlElement* Element() const	{ return ToElement(); }
+	/**	@deprecated use ToText()
+		Return the handle as a TiXmlText. This may return null.
+	*/
+	TiXmlText* Text() const			{ return ToText(); }
+	/** @deprecated use ToUnknown()
+		Return the handle as a TiXmlUnknown. This may return null.
+	*/
+	TiXmlUnknown* Unknown() const	{ return ToUnknown(); }
+
+private:
+	TiXmlNode* node;
+};
+
+
+/** Print to memory functionality. The TiXmlPrinter is useful when you need to:
+
+	-# Print to memory (especially in non-STL mode)
+	-# Control formatting (line endings, etc.)
+
+	When constructed, the TiXmlPrinter is in its default "pretty printing" mode.
+	Before calling Accept() you can call methods to control the printing
+	of the XML document. After TiXmlNode::Accept() is called, the printed document can
+	be accessed via the CStr(), Str(), and Size() methods.
+
+	TiXmlPrinter uses the Visitor API.
+	@verbatim
+	TiXmlPrinter printer;
+	printer.SetIndent( "\t" );
+
+	doc.Accept( &printer );
+	fprintf( stdout, "%s", printer.CStr() );
+	@endverbatim
+*/
+class TiXmlPrinter : public TiXmlVisitor
+{
+public:
+	TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ),
+					 buffer(), indent( "    " ), lineBreak( "\n" ) {}
+
+	virtual bool VisitEnter( const TiXmlDocument& doc );
+	virtual bool VisitExit( const TiXmlDocument& doc );
+
+	virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute );
+	virtual bool VisitExit( const TiXmlElement& element );
+
+	virtual bool Visit( const TiXmlDeclaration& declaration );
+	virtual bool Visit( const TiXmlText& text );
+	virtual bool Visit( const TiXmlComment& comment );
+	virtual bool Visit( const TiXmlUnknown& unknown );
+
+	/** Set the indent characters for printing. By default 4 spaces
+		but tab (\t) is also useful, or null/empty string for no indentation.
+	*/
+	void SetIndent( const char* _indent )			{ indent = _indent ? _indent : "" ; }
+	/// Query the indention string.
+	const char* Indent()							{ return indent.c_str(); }
+	/** Set the line breaking string. By default set to newline (\n).
+		Some operating systems prefer other characters, or can be
+		set to the null/empty string for no indenation.
+	*/
+	void SetLineBreak( const char* _lineBreak )		{ lineBreak = _lineBreak ? _lineBreak : ""; }
+	/// Query the current line breaking string.
+	const char* LineBreak()							{ return lineBreak.c_str(); }
+
+	/** Switch over to "stream printing" which is the most dense formatting without
+		linebreaks. Common when the XML is needed for network transmission.
+	*/
+	void SetStreamPrinting()						{ indent = "";
+													  lineBreak = "";
+													}
+	/// Return the result.
+	const char* CStr()								{ return buffer.c_str(); }
+	/// Return the length of the result string.
+	size_t Size()									{ return buffer.size(); }
+
+	#ifdef TIXML_USE_STL
+	/// Return the result.
+	const std::string& Str()						{ return buffer; }
+	#endif
+
+private:
+	void DoIndent()	{
+		for( int i=0; i<depth; ++i )
+			buffer += indent;
+	}
+	void DoLineBreak() {
+		buffer += lineBreak;
+	}
+
+	int depth;
+	bool simpleTextPrint;
+	TIXML_STRING buffer;
+	TIXML_STRING indent;
+	TIXML_STRING lineBreak;
+};
+
+
+#ifdef _MSC_VER
+#pragma warning( pop )
+#endif
+
+#endif
+
Index: /code/branches/ceguilua/src/tinyxml/tinyxmlerror.cc
===================================================================
--- /code/branches/ceguilua/src/tinyxml/tinyxmlerror.cc	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/tinyxmlerror.cc	(revision 1801)
@@ -0,0 +1,53 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2006 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied 
+warranty. In no event will the authors be held liable for any 
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any 
+purpose, including commercial applications, and to alter it and 
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include "tinyxml.h"
+
+// The goal of the seperate error file is to make the first
+// step towards localization. tinyxml (currently) only supports
+// english error messages, but the could now be translated.
+//
+// It also cleans up the code a bit.
+//
+
+const char* TiXmlBase::errorString[ TIXML_ERROR_STRING_COUNT ] =
+{
+	"No error",
+	"Error",
+	"Failed to open file",
+	"Memory allocation failed.",
+	"Error parsing Element.",
+	"Failed to read Element name",
+	"Error reading Element value.",
+	"Error reading Attributes.",
+	"Error: empty tag.",
+	"Error reading end tag.",
+	"Error parsing Unknown.",
+	"Error parsing Comment.",
+	"Error parsing Declaration.",
+	"Error document empty.",
+	"Error null (0) or unexpected EOF found in input stream.",
+	"Error parsing CDATA.",
+	"Error when TiXmlDocument added to document, because TiXmlDocument can only be at the root.",
+};
Index: /code/branches/ceguilua/src/tinyxml/tinyxmlparser.cc
===================================================================
--- /code/branches/ceguilua/src/tinyxml/tinyxmlparser.cc	(revision 1801)
+++ /code/branches/ceguilua/src/tinyxml/tinyxmlparser.cc	(revision 1801)
@@ -0,0 +1,1722 @@
+/*
+www.sourceforge.net/projects/tinyxml
+Original code (2.0 and earlier )copyright (c) 2000-2002 Lee Thomason (www.grinninglizard.com)
+
+This software is provided 'as-is', without any express or implied
+warranty. In no event will the authors be held liable for any
+damages arising from the use of this software.
+
+Permission is granted to anyone to use this software for any
+purpose, including commercial applications, and to alter it and
+redistribute it freely, subject to the following restrictions:
+
+1. The origin of this software must not be misrepresented; you must
+not claim that you wrote the original software. If you use this
+software in a product, an acknowledgment in the product documentation
+would be appreciated but is not required.
+
+2. Altered source versions must be plainly marked as such, and
+must not be misrepresented as being the original software.
+
+3. This notice may not be removed or altered from any source
+distribution.
+*/
+
+#include <ctype.h>
+#include <stddef.h>
+
+#include "tinyxml.h"
+
+//#define DEBUG_PARSER
+#if defined( DEBUG_PARSER )
+#	if defined( DEBUG ) && defined( _MSC_VER )
+#		include <windows.h>
+#		define TIXML_LOG OutputDebugString
+#	else
+#		define TIXML_LOG printf
+#	endif
+#endif
+
+// Note tha "PutString" hardcodes the same list. This
+// is less flexible than it appears. Changing the entries
+// or order will break putstring.
+TiXmlBase::Entity TiXmlBase::entity[ NUM_ENTITY ] =
+{
+	{ "&amp;",  5, '&' },
+	{ "&lt;",   4, '<' },
+	{ "&gt;",   4, '>' },
+	{ "&quot;", 6, '\"' },
+	{ "&apos;", 6, '\'' }
+};
+
+// Bunch of unicode info at:
+//		http://www.unicode.org/faq/utf_bom.html
+// Including the basic of this table, which determines the #bytes in the
+// sequence from the lead byte. 1 placed for invalid sequences --
+// although the result will be junk, pass it through as much as possible.
+// Beware of the non-characters in UTF-8:
+//				ef bb bf (Microsoft "lead bytes")
+//				ef bf be
+//				ef bf bf
+
+const unsigned char TIXML_UTF_LEAD_0 = 0xefU;
+const unsigned char TIXML_UTF_LEAD_1 = 0xbbU;
+const unsigned char TIXML_UTF_LEAD_2 = 0xbfU;
+
+const int TiXmlBase::utf8ByteTable[256] =
+{
+	//	0	1	2	3	4	5	6	7	8	9	a	b	c	d	e	f
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x00
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x10
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x20
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x30
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x40
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x50
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x60
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x70	End of ASCII range
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x80 0x80 to 0xc1 invalid
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0x90
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0xa0
+		1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	// 0xb0
+		1,	1,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	// 0xc0 0xc2 to 0xdf 2 byte
+		2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	2,	// 0xd0
+		3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	3,	// 0xe0 0xe0 to 0xef 3 byte
+		4,	4,	4,	4,	4,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1,	1	// 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid
+};
+
+
+void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length )
+{
+	const unsigned long BYTE_MASK = 0xBF;
+	const unsigned long BYTE_MARK = 0x80;
+	const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
+
+	if (input < 0x80)
+		*length = 1;
+	else if ( input < 0x800 )
+		*length = 2;
+	else if ( input < 0x10000 )
+		*length = 3;
+	else if ( input < 0x200000 )
+		*length = 4;
+	else
+		{ *length = 0; return; }	// This code won't covert this correctly anyway.
+
+	output += *length;
+
+	// Scary scary fall throughs.
+	switch (*length)
+	{
+		case 4:
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
+			input >>= 6;
+		case 3:
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
+			input >>= 6;
+		case 2:
+			--output;
+			*output = (char)((input | BYTE_MARK) & BYTE_MASK);
+			input >>= 6;
+		case 1:
+			--output;
+			*output = (char)(input | FIRST_BYTE_MARK[*length]);
+	}
+}
+
+
+/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
+{
+	// This will only work for low-ascii, everything else is assumed to be a valid
+	// letter. I'm not sure this is the best approach, but it is quite tricky trying
+	// to figure out alhabetical vs. not across encoding. So take a very
+	// conservative approach.
+
+//	if ( encoding == TIXML_ENCODING_UTF8 )
+//	{
+		if ( anyByte < 127 )
+			return isalpha( anyByte );
+		else
+			return 1;	// What else to do? The unicode set is huge...get the english ones right.
+//	}
+//	else
+//	{
+//		return isalpha( anyByte );
+//	}
+}
+
+
+/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ )
+{
+	// This will only work for low-ascii, everything else is assumed to be a valid
+	// letter. I'm not sure this is the best approach, but it is quite tricky trying
+	// to figure out alhabetical vs. not across encoding. So take a very
+	// conservative approach.
+
+//	if ( encoding == TIXML_ENCODING_UTF8 )
+//	{
+		if ( anyByte < 127 )
+			return isalnum( anyByte );
+		else
+			return 1;	// What else to do? The unicode set is huge...get the english ones right.
+//	}
+//	else
+//	{
+//		return isalnum( anyByte );
+//	}
+}
+
+
+class TiXmlParsingData
+{
+	friend class TiXmlDocument;
+  public:
+	void Stamp( const char* now, TiXmlEncoding encoding );
+
+	const TiXmlCursor& Cursor()	{ return cursor; }
+
+  private:
+	// Only used by the document!
+	TiXmlParsingData( const char* start, int _tabsize, int row, int col )
+	{
+		assert( start );
+		stamp = start;
+		tabsize = _tabsize;
+		cursor.row = row;
+		cursor.col = col;
+	}
+
+	TiXmlCursor		cursor;
+	const char*		stamp;
+	int				tabsize;
+};
+
+
+void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding )
+{
+	assert( now );
+
+	// Do nothing if the tabsize is 0.
+	if ( tabsize < 1 )
+	{
+		return;
+	}
+
+	// Get the current row, column.
+	int row = cursor.row;
+	int col = cursor.col;
+	const char* p = stamp;
+	assert( p );
+
+	while ( p < now )
+	{
+		// Treat p as unsigned, so we have a happy compiler.
+		const unsigned char* pU = (const unsigned char*)p;
+
+		// Code contributed by Fletcher Dunn: (modified by lee)
+		switch (*pU) {
+			case 0:
+				// We *should* never get here, but in case we do, don't
+				// advance past the terminating null character, ever
+				return;
+
+			case '\r':
+				// bump down to the next line
+				++row;
+				col = 0;
+				// Eat the character
+				++p;
+
+				// Check for \r\n sequence, and treat this as a single character
+				if (*p == '\n') {
+					++p;
+				}
+				break;
+
+			case '\n':
+				// bump down to the next line
+				++row;
+				col = 0;
+
+				// Eat the character
+				++p;
+
+				// Check for \n\r sequence, and treat this as a single
+				// character.  (Yes, this bizarre thing does occur still
+				// on some arcane platforms...)
+				if (*p == '\r') {
+					++p;
+				}
+				break;
+
+			case '\t':
+				// Eat the character
+				++p;
+
+				// Skip to next tab stop
+				col = (col / tabsize + 1) * tabsize;
+				break;
+
+			case TIXML_UTF_LEAD_0:
+				if ( encoding == TIXML_ENCODING_UTF8 )
+				{
+					if ( *(p+1) && *(p+2) )
+					{
+						// In these cases, don't advance the column. These are
+						// 0-width spaces.
+						if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 )
+							p += 3;
+						else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU )
+							p += 3;
+						else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU )
+							p += 3;
+						else
+							{ p +=3; ++col; }	// A normal character.
+					}
+				}
+				else
+				{
+					++p;
+					++col;
+				}
+				break;
+
+			default:
+				if ( encoding == TIXML_ENCODING_UTF8 )
+				{
+					// Eat the 1 to 4 byte utf8 character.
+					int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)];
+					if ( step == 0 )
+						step = 1;		// Error case from bad encoding, but handle gracefully.
+					p += step;
+
+					// Just advance one column, of course.
+					++col;
+				}
+				else
+				{
+					++p;
+					++col;
+				}
+				break;
+		}
+	}
+	cursor.row = row;
+	cursor.col = col;
+	assert( cursor.row >= -1 );
+	assert( cursor.col >= -1 );
+	stamp = p;
+	assert( stamp );
+}
+
+
+const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding )
+{
+	if ( !p || !*p )
+	{
+		return 0;
+	}
+	if ( encoding == TIXML_ENCODING_UTF8 )
+	{
+		while ( *p )
+		{
+			const unsigned char* pU = (const unsigned char*)p;
+
+			// Skip the stupid Microsoft UTF-8 Byte order marks
+			if (	*(pU+0)==TIXML_UTF_LEAD_0
+				 && *(pU+1)==TIXML_UTF_LEAD_1
+				 && *(pU+2)==TIXML_UTF_LEAD_2 )
+			{
+				p += 3;
+				continue;
+			}
+			else if(*(pU+0)==TIXML_UTF_LEAD_0
+				 && *(pU+1)==0xbfU
+				 && *(pU+2)==0xbeU )
+			{
+				p += 3;
+				continue;
+			}
+			else if(*(pU+0)==TIXML_UTF_LEAD_0
+				 && *(pU+1)==0xbfU
+				 && *(pU+2)==0xbfU )
+			{
+				p += 3;
+				continue;
+			}
+
+			if ( IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )		// Still using old rules for white space.
+				++p;
+			else
+				break;
+		}
+	}
+	else
+	{
+		while ( *p && IsWhiteSpace( *p ) || *p == '\n' || *p =='\r' )
+			++p;
+	}
+
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag )
+{
+	for( ;; )
+	{
+		if ( !in->good() ) return false;
+
+		int c = in->peek();
+		// At this scope, we can't get to a document. So fail silently.
+		if ( !IsWhiteSpace( c ) || c <= 0 )
+			return true;
+
+		*tag += (char) in->get();
+	}
+}
+
+/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag )
+{
+	//assert( character > 0 && character < 128 );	// else it won't work in utf-8
+	while ( in->good() )
+	{
+		int c = in->peek();
+		if ( c == character )
+			return true;
+		if ( c <= 0 )		// Silent failure: can't get document at this scope
+			return false;
+
+		in->get();
+		*tag += (char) c;
+	}
+	return false;
+}
+#endif
+
+// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The
+// "assign" optimization removes over 10% of the execution time.
+//
+const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding )
+{
+	// Oddly, not supported on some comilers,
+	//name->clear();
+	// So use this:
+	*name = "";
+	assert( p );
+
+	// Names start with letters or underscores.
+	// Of course, in unicode, tinyxml has no idea what a letter *is*. The
+	// algorithm is generous.
+	//
+	// After that, they can be letters, underscores, numbers,
+	// hyphens, or colons. (Colons are valid ony for namespaces,
+	// but tinyxml can't tell namespaces from names.)
+	if (    p && *p
+		 && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) )
+	{
+		const char* start = p;
+		while(		p && *p
+				&&	(		IsAlphaNum( (unsigned char ) *p, encoding )
+						 || *p == '_'
+						 || *p == '-'
+						 || *p == '.'
+						 || *p == ':' ) )
+		{
+			//(*name) += *p; // expensive
+			++p;
+		}
+		if ( p-start > 0 ) {
+			name->assign( start, p-start );
+		}
+		return p;
+	}
+	return 0;
+}
+
+const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding )
+{
+	// Presume an entity, and pull it out.
+    TIXML_STRING ent;
+	int i;
+	*length = 0;
+
+	if ( *(p+1) && *(p+1) == '#' && *(p+2) )
+	{
+		unsigned long ucs = 0;
+		ptrdiff_t delta = 0;
+		unsigned mult = 1;
+
+		if ( *(p+2) == 'x' )
+		{
+			// Hexadecimal.
+			if ( !*(p+3) ) return 0;
+
+			const char* q = p+3;
+			q = strchr( q, ';' );
+
+			if ( !q || !*q ) return 0;
+
+			delta = q-p;
+			--q;
+
+			while ( *q != 'x' )
+			{
+				if ( *q >= '0' && *q <= '9' )
+					ucs += mult * (*q - '0');
+				else if ( *q >= 'a' && *q <= 'f' )
+					ucs += mult * (*q - 'a' + 10);
+				else if ( *q >= 'A' && *q <= 'F' )
+					ucs += mult * (*q - 'A' + 10 );
+				else
+					return 0;
+				mult *= 16;
+				--q;
+			}
+		}
+		else
+		{
+			// Decimal.
+			if ( !*(p+2) ) return 0;
+
+			const char* q = p+2;
+			q = strchr( q, ';' );
+
+			if ( !q || !*q ) return 0;
+
+			delta = q-p;
+			--q;
+
+			while ( *q != '#' )
+			{
+				if ( *q >= '0' && *q <= '9' )
+					ucs += mult * (*q - '0');
+				else
+					return 0;
+				mult *= 10;
+				--q;
+			}
+		}
+		if ( encoding == TIXML_ENCODING_UTF8 )
+		{
+			// convert the UCS to UTF-8
+			ConvertUTF32ToUTF8( ucs, value, length );
+		}
+		else
+		{
+			*value = (char)ucs;
+			*length = 1;
+		}
+		return p + delta + 1;
+	}
+
+	// Now try to match it.
+	for( i=0; i<NUM_ENTITY; ++i )
+	{
+		if ( strncmp( entity[i].str, p, entity[i].strLength ) == 0 )
+		{
+			assert( strlen( entity[i].str ) == entity[i].strLength );
+			*value = entity[i].chr;
+			*length = 1;
+			return ( p + entity[i].strLength );
+		}
+	}
+
+	// So it wasn't an entity, its unrecognized, or something like that.
+	*value = *p;	// Don't put back the last one, since we return it!
+	//*length = 1;	// Leave unrecognized entities - this doesn't really work.
+					// Just writes strange XML.
+	return p+1;
+}
+
+
+bool TiXmlBase::StringEqual( const char* p,
+							 const char* tag,
+							 bool ignoreCase,
+							 TiXmlEncoding encoding )
+{
+	assert( p );
+	assert( tag );
+	if ( !p || !*p )
+	{
+		assert( 0 );
+		return false;
+	}
+
+	const char* q = p;
+
+	if ( ignoreCase )
+	{
+		while ( *q && *tag && ToLower( *q, encoding ) == ToLower( *tag, encoding ) )
+		{
+			++q;
+			++tag;
+		}
+
+		if ( *tag == 0 )
+			return true;
+	}
+	else
+	{
+		while ( *q && *tag && *q == *tag )
+		{
+			++q;
+			++tag;
+		}
+
+		if ( *tag == 0 )		// Have we found the end of the tag, and everything equal?
+			return true;
+	}
+	return false;
+}
+
+const char* TiXmlBase::ReadText(	const char* p,
+									TIXML_STRING * text,
+									bool trimWhiteSpace,
+									const char* endTag,
+									bool caseInsensitive,
+									TiXmlEncoding encoding )
+{
+    *text = "";
+	if (    !trimWhiteSpace			// certain tags always keep whitespace
+		 || !condenseWhiteSpace )	// if true, whitespace is always kept
+	{
+		// Keep all the white space.
+		while (	   p && *p
+				&& !StringEqual( p, endTag, caseInsensitive, encoding )
+			  )
+		{
+			int len;
+			char cArr[4] = { 0, 0, 0, 0 };
+			p = GetChar( p, cArr, &len, encoding );
+			text->append( cArr, len );
+		}
+	}
+	else
+	{
+		bool whitespace = false;
+
+		// Remove leading white space:
+		p = SkipWhiteSpace( p, encoding );
+		while (	   p && *p
+				&& !StringEqual( p, endTag, caseInsensitive, encoding ) )
+		{
+			if ( *p == '\r' || *p == '\n' )
+			{
+				whitespace = true;
+				++p;
+			}
+			else if ( IsWhiteSpace( *p ) )
+			{
+				whitespace = true;
+				++p;
+			}
+			else
+			{
+				// If we've found whitespace, add it before the
+				// new character. Any whitespace just becomes a space.
+				if ( whitespace )
+				{
+					(*text) += ' ';
+					whitespace = false;
+				}
+				int len;
+				char cArr[4] = { 0, 0, 0, 0 };
+				p = GetChar( p, cArr, &len, encoding );
+				if ( len == 1 )
+					(*text) += cArr[0];	// more efficient
+				else
+					text->append( cArr, len );
+			}
+		}
+	}
+	if ( p )
+		p += strlen( endTag );
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+
+void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	// The basic issue with a document is that we don't know what we're
+	// streaming. Read something presumed to be a tag (and hope), then
+	// identify it, and call the appropriate stream method on the tag.
+	//
+	// This "pre-streaming" will never read the closing ">" so the
+	// sub-tag can orient itself.
+
+	if ( !StreamTo( in, '<', tag ) )
+	{
+		SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return;
+	}
+
+	while ( in->good() )
+	{
+		int tagIndex = (int) tag->length();
+		while ( in->good() && in->peek() != '>' )
+		{
+			int c = in->get();
+			if ( c <= 0 )
+			{
+				SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+				break;
+			}
+			(*tag) += (char) c;
+		}
+
+		if ( in->good() )
+		{
+			// We now have something we presume to be a node of
+			// some sort. Identify it, and call the node to
+			// continue streaming.
+			TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING );
+
+			if ( node )
+			{
+				node->StreamIn( in, tag );
+				bool isElement = node->ToElement() != 0;
+				delete node;
+				node = 0;
+
+				// If this is the root element, we're done. Parsing will be
+				// done by the >> operator.
+				if ( isElement )
+				{
+					return;
+				}
+			}
+			else
+			{
+				SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
+				return;
+			}
+		}
+	}
+	// We should have returned sooner.
+	SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN );
+}
+
+#endif
+
+const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding )
+{
+	ClearError();
+
+	// Parse away, at the document level. Since a document
+	// contains nothing but other tags, most of what happens
+	// here is skipping white space.
+	if ( !p || !*p )
+	{
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	// Note that, for a document, this needs to come
+	// before the while space skip, so that parsing
+	// starts from the pointer we are given.
+	location.Clear();
+	if ( prevData )
+	{
+		location.row = prevData->cursor.row;
+		location.col = prevData->cursor.col;
+	}
+	else
+	{
+		location.row = 0;
+		location.col = 0;
+	}
+	TiXmlParsingData data( p, TabSize(), location.row, location.col );
+	location = data.Cursor();
+
+	if ( encoding == TIXML_ENCODING_UNKNOWN )
+	{
+		// Check for the Microsoft UTF-8 lead bytes.
+		const unsigned char* pU = (const unsigned char*)p;
+		if (	*(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0
+			 && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1
+			 && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 )
+		{
+			encoding = TIXML_ENCODING_UTF8;
+			useMicrosoftBOM = true;
+		}
+	}
+
+    p = SkipWhiteSpace( p, encoding );
+	if ( !p )
+	{
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN );
+		return 0;
+	}
+
+	while ( p && *p )
+	{
+		TiXmlNode* node = Identify( p, encoding );
+		if ( node )
+		{
+			p = node->Parse( p, &data, encoding );
+			LinkEndChild( node );
+		}
+		else
+		{
+			break;
+		}
+
+		// Did we get encoding info?
+		if (    encoding == TIXML_ENCODING_UNKNOWN
+			 && node->ToDeclaration() )
+		{
+			TiXmlDeclaration* dec = node->ToDeclaration();
+			const char* enc = dec->Encoding();
+			assert( enc );
+
+			if ( *enc == 0 )
+				encoding = TIXML_ENCODING_UTF8;
+			else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) )
+				encoding = TIXML_ENCODING_UTF8;
+			else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) )
+				encoding = TIXML_ENCODING_UTF8;	// incorrect, but be nice
+			else
+				encoding = TIXML_ENCODING_LEGACY;
+		}
+
+		p = SkipWhiteSpace( p, encoding );
+	}
+
+	// Was this empty?
+	if ( !firstChild ) {
+		SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding );
+		return 0;
+	}
+
+	// All is well.
+	return p;
+}
+
+void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	// The first error in a chain is more accurate - don't set again!
+	if ( error )
+		return;
+
+	assert( err > 0 && err < TIXML_ERROR_STRING_COUNT );
+	error   = true;
+	errorId = err;
+	errorDesc = errorString[ errorId ];
+
+	errorLocation.Clear();
+	if ( pError && data )
+	{
+		data->Stamp( pError, encoding );
+		errorLocation = data->Cursor();
+	}
+}
+
+
+TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding )
+{
+	TiXmlNode* returnNode = 0;
+
+	p = SkipWhiteSpace( p, encoding );
+	if( !p || !*p || *p != '<' )
+	{
+		return 0;
+	}
+
+	TiXmlDocument* doc = GetDocument();
+	p = SkipWhiteSpace( p, encoding );
+
+	if ( !p || !*p )
+	{
+		return 0;
+	}
+
+	// What is this thing?
+	// - Elements start with a letter or underscore, but xml is reserved.
+	// - Comments: <!--
+	// - Decleration: <?xml
+	// - StylesheetReference <?xml-stylesheet
+	// - Everthing else is unknown to tinyxml.
+	//
+
+	const char* xmlHeader = { "<?xml" };
+	const char* xmlSSHeader = { "<?xml-stylesheet" };
+	const char* commentHeader = { "<!--" };
+	const char* dtdHeader = { "<!" };
+	const char* cdataHeader = { "<![CDATA[" };
+
+	if ( StringEqual( p, xmlSSHeader, true, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Stylesheet Reference\n" );
+		#endif
+		returnNode = new TiXmlStylesheetReference();
+	}
+	else if ( StringEqual( p, xmlHeader, true, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Declaration\n" );
+		#endif
+		returnNode = new TiXmlDeclaration();
+	}
+	else if ( StringEqual( p, commentHeader, false, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Comment\n" );
+		#endif
+		returnNode = new TiXmlComment();
+	}
+	else if ( StringEqual( p, cdataHeader, false, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing CDATA\n" );
+		#endif
+		TiXmlText* text = new TiXmlText( "" );
+		text->SetCDATA( true );
+		returnNode = text;
+	}
+	else if ( StringEqual( p, dtdHeader, false, encoding ) )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Unknown(1)\n" );
+		#endif
+		returnNode = new TiXmlUnknown();
+	}
+	else if (    IsAlpha( *(p+1), encoding )
+			  || *(p+1) == '_' )
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Element\n" );
+		#endif
+		returnNode = new TiXmlElement( "" );
+	}
+	else
+	{
+		#ifdef DEBUG_PARSER
+			TIXML_LOG( "XML parsing Unknown(2)\n" );
+		#endif
+		returnNode = new TiXmlUnknown();
+	}
+
+	if ( returnNode )
+	{
+		// Set the parent, so it can report errors
+		returnNode->parent = this;
+	}
+	else
+	{
+		if ( doc )
+			doc->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, TIXML_ENCODING_UNKNOWN );
+	}
+	return returnNode;
+}
+
+#ifdef TIXML_USE_STL
+
+void TiXmlElement::StreamIn (std::istream * in, TIXML_STRING * tag)
+{
+	// We're called with some amount of pre-parsing. That is, some of "this"
+	// element is in "tag". Go ahead and stream to the closing ">"
+	while( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c ;
+
+		if ( c == '>' )
+			break;
+	}
+
+	if ( tag->length() < 3 ) return;
+
+	// Okay...if we are a "/>" tag, then we're done. We've read a complete tag.
+	// If not, identify and stream.
+
+	if (    tag->at( tag->length() - 1 ) == '>'
+		 && tag->at( tag->length() - 2 ) == '/' )
+	{
+		// All good!
+		return;
+	}
+	else if ( tag->at( tag->length() - 1 ) == '>' )
+	{
+		// There is more. Could be:
+		//		text
+		//		cdata text (which looks like another node)
+		//		closing tag
+		//		another node.
+		for ( ;; )
+		{
+			StreamWhiteSpace( in, tag );
+
+			// Do we have text?
+			if ( in->good() && in->peek() != '<' )
+			{
+				// Yep, text.
+				TiXmlText text( "" );
+				text.StreamIn( in, tag );
+
+				// What follows text is a closing tag or another node.
+				// Go around again and figure it out.
+				continue;
+			}
+
+			// We now have either a closing tag...or another node.
+			// We should be at a "<", regardless.
+			if ( !in->good() ) return;
+			assert( in->peek() == '<' );
+			int tagIndex = (int) tag->length();
+
+			bool closingTag = false;
+			bool firstCharFound = false;
+
+			for( ;; )
+			{
+				if ( !in->good() )
+					return;
+
+				int c = in->peek();
+				if ( c <= 0 )
+				{
+					TiXmlDocument* document = GetDocument();
+					if ( document )
+						document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+					return;
+				}
+
+				if ( c == '>' )
+					break;
+
+				*tag += (char) c;
+				in->get();
+
+				// Early out if we find the CDATA id.
+				if ( c == '[' && tag->size() >= 9 )
+				{
+					size_t len = tag->size();
+					const char* start = tag->c_str() + len - 9;
+					if ( strcmp( start, "<![CDATA[" ) == 0 ) {
+						assert( !closingTag );
+						break;
+					}
+				}
+
+				if ( !firstCharFound && c != '<' && !IsWhiteSpace( c ) )
+				{
+					firstCharFound = true;
+					if ( c == '/' )
+						closingTag = true;
+				}
+			}
+			// If it was a closing tag, then read in the closing '>' to clean up the input stream.
+			// If it was not, the streaming will be done by the tag.
+			if ( closingTag )
+			{
+				if ( !in->good() )
+					return;
+
+				int c = in->get();
+				if ( c <= 0 )
+				{
+					TiXmlDocument* document = GetDocument();
+					if ( document )
+						document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+					return;
+				}
+				assert( c == '>' );
+				*tag += (char) c;
+
+				// We are done, once we've found our closing tag.
+				return;
+			}
+			else
+			{
+				// If not a closing tag, id it, and stream.
+				const char* tagloc = tag->c_str() + tagIndex;
+				TiXmlNode* node = Identify( tagloc, TIXML_DEFAULT_ENCODING );
+				if ( !node )
+					return;
+				node->StreamIn( in, tag );
+				delete node;
+				node = 0;
+
+				// No return: go around from the beginning: text, closing tag, or node.
+			}
+		}
+	}
+}
+#endif
+
+const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	p = SkipWhiteSpace( p, encoding );
+	TiXmlDocument* document = GetDocument();
+
+	if ( !p || !*p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
+		return 0;
+	}
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+
+	if ( *p != '<' )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
+		return 0;
+	}
+
+	p = SkipWhiteSpace( p+1, encoding );
+
+	// Read the name.
+	const char* pErr = p;
+
+    p = ReadName( p, &value, encoding );
+	if ( !p || !*p )
+	{
+		if ( document )	document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
+		return 0;
+	}
+
+    TIXML_STRING endTag ("</");
+	endTag += value;
+	endTag += ">";
+
+	// Check for and read attributes. Also look for an empty
+	// tag or an end tag.
+	while ( p && *p )
+	{
+		pErr = p;
+		p = SkipWhiteSpace( p, encoding );
+		if ( !p || !*p )
+		{
+			if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
+			return 0;
+		}
+		if ( *p == '/' )
+		{
+			++p;
+			// Empty tag.
+			if ( *p  != '>' )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
+				return 0;
+			}
+			return (p+1);
+		}
+		else if ( *p == '>' )
+		{
+			// Done with attributes (if there were any.)
+			// Read the value -- which can include other
+			// elements -- read the end tag, and return.
+			++p;
+			p = ReadValue( p, data, encoding );		// Note this is an Element method, and will set the error if one happens.
+			if ( !p || !*p ) {
+				// We were looking for the end tag, but found nothing.
+				// Fix for [ 1663758 ] Failure to report error on bad XML
+				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
+				return 0;
+			}
+
+			// We should find the end tag now
+			if ( StringEqual( p, endTag.c_str(), false, encoding ) )
+			{
+				p += endTag.length();
+				return p;
+			}
+			else
+			{
+				if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
+				return 0;
+			}
+		}
+		else
+		{
+			// Try to read an attribute:
+			TiXmlAttribute* attrib = new TiXmlAttribute();
+			if ( !attrib )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
+				return 0;
+			}
+
+			attrib->SetDocument( document );
+			pErr = p;
+			p = attrib->Parse( p, data, encoding );
+
+			if ( !p || !*p )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, pErr, data, encoding );
+				delete attrib;
+				return 0;
+			}
+
+			// Handle the strange case of double attributes:
+			#ifdef TIXML_USE_STL
+			TiXmlAttribute* node = attributeSet.Find( attrib->NameTStr() );
+			#else
+			TiXmlAttribute* node = attributeSet.Find( attrib->Name() );
+			#endif
+			if ( node )
+			{
+				node->SetValue( attrib->Value() );
+				delete attrib;
+				return 0;
+			}
+
+			attributeSet.Add( attrib );
+		}
+	}
+	return p;
+}
+
+
+const char* TiXmlElement::ReadValue( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	TiXmlDocument* document = GetDocument();
+
+	// Read in text and elements in any order.
+	const char* pWithWhiteSpace = p;
+	p = SkipWhiteSpace( p, encoding );
+
+	while ( p && *p )
+	{
+		if ( *p != '<' )
+		{
+			// Take what we have, make a text element.
+			TiXmlText* textNode = new TiXmlText( "" );
+
+			if ( !textNode )
+			{
+				if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, 0, 0, encoding );
+				    return 0;
+			}
+
+			if ( TiXmlBase::IsWhiteSpaceCondensed() )
+			{
+				p = textNode->Parse( p, data, encoding );
+			}
+			else
+			{
+				// Special case: we want to keep the white space
+				// so that leading spaces aren't removed.
+				p = textNode->Parse( pWithWhiteSpace, data, encoding );
+			}
+
+			if ( !textNode->Blank() )
+				LinkEndChild( textNode );
+			else
+				delete textNode;
+		}
+		else
+		{
+			// We hit a '<'
+			// Have we hit a new element or an end tag? This could also be
+			// a TiXmlText in the "CDATA" style.
+			if ( StringEqual( p, "</", false, encoding ) )
+			{
+				return p;
+			}
+			else
+			{
+				TiXmlNode* node = Identify( p, encoding );
+				if ( node )
+				{
+					p = node->Parse( p, data, encoding );
+					LinkEndChild( node );
+				}
+				else
+				{
+					return 0;
+				}
+			}
+		}
+		pWithWhiteSpace = p;
+		p = SkipWhiteSpace( p, encoding );
+	}
+
+	if ( !p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ELEMENT_VALUE, 0, 0, encoding );
+	}
+	return p;
+}
+
+
+#ifdef TIXML_USE_STL
+void TiXmlUnknown::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c;
+
+		if ( c == '>' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+
+const char* TiXmlUnknown::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	TiXmlDocument* document = GetDocument();
+	p = SkipWhiteSpace( p, encoding );
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+	if ( !p || !*p || *p != '<' )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_UNKNOWN, p, data, encoding );
+		return 0;
+	}
+	++p;
+    value = "";
+
+	while ( p && *p && *p != '>' )
+	{
+		value += *p;
+		++p;
+	}
+
+	if ( !p )
+	{
+		if ( document )	document->SetError( TIXML_ERROR_PARSING_UNKNOWN, 0, 0, encoding );
+	}
+	if ( *p == '>' )
+		return p+1;
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlComment::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+
+		(*tag) += (char) c;
+
+		if ( c == '>'
+			 && tag->at( tag->length() - 2 ) == '-'
+			 && tag->at( tag->length() - 3 ) == '-' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+
+const char* TiXmlComment::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	TiXmlDocument* document = GetDocument();
+	value = "";
+
+	p = SkipWhiteSpace( p, encoding );
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+	const char* startTag = "<!--";
+	const char* endTag   = "-->";
+
+	if ( !StringEqual( p, startTag, false, encoding ) )
+	{
+		document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding );
+		return 0;
+	}
+	p += strlen( startTag );
+
+	// [ 1475201 ] TinyXML parses entities in comments
+	// Oops - ReadText doesn't work, because we don't want to parse the entities.
+	// p = ReadText( p, &value, false, endTag, false, encoding );
+	//
+	// from the XML spec:
+	/*
+	 [Definition: Comments may appear anywhere in a document outside other markup; in addition,
+	              they may appear within the document type declaration at places allowed by the grammar.
+				  They are not part of the document's character data; an XML processor MAY, but need not,
+				  make it possible for an application to retrieve the text of comments. For compatibility,
+				  the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity
+				  references MUST NOT be recognized within comments.
+
+				  An example of a comment:
+
+				  <!-- declarations for <head> & <body> -->
+	*/
+
+    value = "";
+	// Keep all the white space.
+	while (	p && *p && !StringEqual( p, endTag, false, encoding ) )
+	{
+		value.append( p, 1 );
+		++p;
+	}
+	if ( p )
+		p += strlen( endTag );
+
+	return p;
+}
+
+
+const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	p = SkipWhiteSpace( p, encoding );
+	if ( !p || !*p ) return 0;
+
+//	int tabsize = 4;
+//	if ( document )
+//		tabsize = document->TabSize();
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+	// Read the name, the '=' and the value.
+	const char* pErr = p;
+	p = ReadName( p, &name, encoding );
+	if ( !p || !*p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
+		return 0;
+	}
+	p = SkipWhiteSpace( p, encoding );
+	if ( !p || !*p || *p != '=' )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+		return 0;
+	}
+
+	++p;	// skip '='
+	p = SkipWhiteSpace( p, encoding );
+	if ( !p || !*p )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+		return 0;
+	}
+
+	const char* end;
+	const char SINGLE_QUOTE = '\'';
+	const char DOUBLE_QUOTE = '\"';
+
+	if ( *p == SINGLE_QUOTE )
+	{
+		++p;
+		end = "\'";		// single quote in string
+		p = ReadText( p, &value, false, end, false, encoding );
+	}
+	else if ( *p == DOUBLE_QUOTE )
+	{
+		++p;
+		end = "\"";		// double quote in string
+		p = ReadText( p, &value, false, end, false, encoding );
+	}
+	else
+	{
+		// All attribute values should be in single or double quotes.
+		// But this is such a common error that the parser will try
+		// its best, even without them.
+		value = "";
+		while (    p && *p											// existence
+				&& !IsWhiteSpace( *p ) && *p != '\n' && *p != '\r'	// whitespace
+				&& *p != '/' && *p != '>' )							// tag end
+		{
+			if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) {
+				// [ 1451649 ] Attribute values with trailing quotes not handled correctly
+				// We did not have an opening quote but seem to have a
+				// closing one. Give up and throw an error.
+				if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding );
+				return 0;
+			}
+			value += *p;
+			++p;
+		}
+	}
+	return p;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->peek();
+		if ( !cdata && (c == '<' ) )
+		{
+			return;
+		}
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+
+		(*tag) += (char) c;
+		in->get();	// "commits" the peek made above
+
+		if ( cdata && c == '>' && tag->size() >= 3 ) {
+			size_t len = tag->size();
+			if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) {
+				// terminator of cdata.
+				return;
+			}
+		}
+	}
+}
+#endif
+
+const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
+{
+	value = "";
+	TiXmlDocument* document = GetDocument();
+
+	if ( data )
+	{
+		data->Stamp( p, encoding );
+		location = data->Cursor();
+	}
+
+	const char* const startTag = "<![CDATA[";
+	const char* const endTag   = "]]>";
+
+	if ( cdata || StringEqual( p, startTag, false, encoding ) )
+	{
+		cdata = true;
+
+		if ( !StringEqual( p, startTag, false, encoding ) )
+		{
+			document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding );
+			return 0;
+		}
+		p += strlen( startTag );
+
+		// Keep all the white space, ignore the encoding, etc.
+		while (	   p && *p
+				&& !StringEqual( p, endTag, false, encoding )
+			  )
+		{
+			value += *p;
+			++p;
+		}
+
+		TIXML_STRING dummy;
+		p = ReadText( p, &dummy, false, endTag, false, encoding );
+		return p;
+	}
+	else
+	{
+		bool ignoreWhite = true;
+
+		const char* end = "<";
+		p = ReadText( p, &value, ignoreWhite, end, false, encoding );
+		if ( p )
+			return p-1;	// don't truncate the '<'
+		return 0;
+	}
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c;
+
+		if ( c == '>' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding )
+{
+	p = SkipWhiteSpace( p, _encoding );
+	// Find the beginning, find the end, and look for
+	// the stuff in-between.
+	TiXmlDocument* document = GetDocument();
+	if ( !p || !*p || !StringEqual( p, "<?xml", true, _encoding ) )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
+		return 0;
+	}
+	if ( data )
+	{
+		data->Stamp( p, _encoding );
+		location = data->Cursor();
+	}
+	p += 5;
+
+	version = "";
+	encoding = "";
+	standalone = "";
+
+	while ( p && *p )
+	{
+		if ( *p == '>' )
+		{
+			++p;
+			return p;
+		}
+
+		p = SkipWhiteSpace( p, _encoding );
+		if ( StringEqual( p, "version", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			version = attrib.Value();
+		}
+		else if ( StringEqual( p, "encoding", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			encoding = attrib.Value();
+		}
+		else if ( StringEqual( p, "standalone", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			standalone = attrib.Value();
+		}
+		else
+		{
+			// Read over whatever it is.
+			while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
+				++p;
+		}
+	}
+	return 0;
+}
+
+bool TiXmlText::Blank() const
+{
+	for ( unsigned i=0; i<value.length(); i++ )
+		if ( !IsWhiteSpace( value[i] ) )
+			return false;
+	return true;
+}
+
+#ifdef TIXML_USE_STL
+void TiXmlStylesheetReference::StreamIn( std::istream * in, TIXML_STRING * tag )
+{
+	while ( in->good() )
+	{
+		int c = in->get();
+		if ( c <= 0 )
+		{
+			TiXmlDocument* document = GetDocument();
+			if ( document )
+				document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN );
+			return;
+		}
+		(*tag) += (char) c;
+
+		if ( c == '>' )
+		{
+			// All is well.
+			return;
+		}
+	}
+}
+#endif
+
+const char* TiXmlStylesheetReference::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding )
+{
+	p = SkipWhiteSpace( p, _encoding );
+	// Find the beginning, find the end, and look for
+	// the stuff in-between.
+	TiXmlDocument* document = GetDocument();
+	if ( !p || !*p || !StringEqual( p, "<?xml-stylesheet", true, _encoding ) )
+	{
+		if ( document ) document->SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding );
+		return 0;
+	}
+	if ( data )
+	{
+		data->Stamp( p, _encoding );
+		location = data->Cursor();
+	}
+	p += 5;
+
+	type = "";
+	href = "";
+
+	while ( p && *p )
+	{
+		if ( *p == '>' )
+		{
+			++p;
+			return p;
+		}
+
+		p = SkipWhiteSpace( p, _encoding );
+		if ( StringEqual( p, "type", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			type = attrib.Value();
+		}
+		else if ( StringEqual( p, "href", true, _encoding ) )
+		{
+			TiXmlAttribute attrib;
+			p = attrib.Parse( p, data, _encoding );
+			href = attrib.Value();
+		}
+		else
+		{
+			// Read over whatever it is.
+			while( p && *p && *p != '>' && !IsWhiteSpace( *p ) )
+				++p;
+		}
+	}
+	return 0;
+}
Index: /code/branches/ceguilua/src/tolua/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/tolua/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,55 @@
+SET (TOLUALIB_SRC_FILES
+  tolua_event.c
+  tolua_is.c
+  tolua_map.c
+  tolua_push.c
+  tolua_to.c
+)
+
+ADD_LIBRARY (tolualib SHARED ${TOLUALIB_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (tolualib
+  ${Lua_LIBRARIES}
+)
+
+
+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_orxonox.c
+)
+
+ADD_EXECUTABLE (tolua ${TOLUAEXE_SRC_FILES})
+
+TARGET_LINK_LIBRARIES (tolua
+  ${Lua_LIBRARIES}
+  tolualib
+  m
+)
Index: /code/branches/ceguilua/src/tolua/lua/array.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/array.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/array.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/basic.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/basic.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/basic.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/class.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/class.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/class.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/clean.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/clean.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/clean.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/code.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/code.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/code.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/compat-5.1.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/compat-5.1.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/compat-5.1.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/compat.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/compat.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/compat.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/container.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/container.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/container.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/custom.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/custom.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/custom.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/custom_hide.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/custom_hide.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/custom_hide.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/declaration.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/declaration.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/declaration.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/define.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/define.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/define.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/doit.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/doit.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/doit.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/enumerate.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/enumerate.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/enumerate.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/feature.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/feature.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/feature.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/function.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/function.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/function.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/module.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/module.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/module.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/namespace.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/namespace.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/namespace.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/operator.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/operator.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/operator.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/package.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/package.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/package.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/typedef.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/typedef.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/typedef.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/variable.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/variable.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/variable.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/lua/verbatim.lua
===================================================================
--- /code/branches/ceguilua/src/tolua/lua/verbatim.lua	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/lua/verbatim.lua	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/tolua++.h
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua++.h	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua++.h	(revision 1801)
@@ -0,0 +1,182 @@
+/* tolua
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+
+#ifndef TOLUA_H
+#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"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define tolua_pushcppstring(x,y)	tolua_pushstring(x,y.c_str())
+#define tolua_iscppstring	tolua_isstring
+
+#define tolua_iscppstringarray tolua_isstringarray
+#define tolua_pushfieldcppstring(L,lo,idx,s) tolua_pushfieldstring(L, lo, idx, s.c_str())
+
+#define TEMPLATE_BIND(p)
+#define TOLUA_TEMPLATE_BIND(p)
+#define TOLUA_PROTECTED_DESTRUCTOR
+#define TOLUA_PROPERTY_TYPE(p)
+
+typedef int lua_Object;
+
+#include "lua.h"
+#include "lauxlib.h"
+
+struct tolua_Error
+{
+	int index;
+	int array;
+	const char* type;
+};
+typedef struct tolua_Error tolua_Error;
+
+#define TOLUA_NOPEER	LUA_REGISTRYINDEX /* for lua 5.1 */
+
+TOLUA_API const char* tolua_typename (lua_State* L, int lo);
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err);
+TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err);
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err);
+TOLUA_API int tolua_isvaluearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isbooleanarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isnumberarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isstringarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_istablearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isuserdataarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err);
+TOLUA_API int tolua_isusertypearray
+ (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err);
+
+TOLUA_API void tolua_open (lua_State* L);
+
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size);
+TOLUA_API int tolua_register_gc (lua_State* L, int lo);
+TOLUA_API int tolua_default_collect (lua_State* tolua_S);
+
+TOLUA_API void tolua_usertype (lua_State* L, char* type);
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name);
+TOLUA_API void tolua_endmodule (lua_State* L);
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar);
+TOLUA_API void tolua_class (lua_State* L, char* name, char* base);
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col);
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func);
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value);
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set);
+TOLUA_API void tolua_array (lua_State* L,char* name, lua_CFunction get, lua_CFunction set);
+
+/* TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type); */
+/* TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base); */
+
+TOLUA_API void tolua_pushvalue (lua_State* L, int lo);
+TOLUA_API void tolua_pushboolean (lua_State* L, int value);
+TOLUA_API void tolua_pushnumber (lua_State* L, double value);
+TOLUA_API void tolua_pushstring (lua_State* L, const char* value);
+TOLUA_API void tolua_pushuserdata (lua_State* L, void* value);
+TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushusertype_and_takeownership(lua_State* L, void* value, const char* type);
+TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v);
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v);
+TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v);
+TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v);
+TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type);
+TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type);
+
+TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def);
+TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def);
+TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def);
+TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def);
+TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def);
+TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def);
+TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def);
+TOLUA_API const char* tolua_tofieldstring (lua_State* L, int lo, int index, const char* def);
+TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def);
+TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def);
+TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def);
+TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def);
+
+TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name);
+
+TOLUA_API int class_gc_event (lua_State* L);
+
+#ifdef __cplusplus
+static inline const char* tolua_tocppstring (lua_State* L, int narg, const char* def) {
+
+	const char* s = tolua_tostring(L, narg, def);
+	return s?s:"";
+};
+
+static inline const char* tolua_tofieldcppstring (lua_State* L, int lo, int index, const char* def) {
+
+	const char* s = tolua_tofieldstring(L, lo, index, def);
+	return s?s:"";
+};
+
+#else
+#define tolua_tocppstring tolua_tostring
+#define tolua_tofieldcppstring tolua_tofieldstring
+#endif
+
+TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Index: /code/branches/ceguilua/src/tolua/tolua-5.0.pkg
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua-5.0.pkg	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua-5.0.pkg	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/tolua-5.1.pkg
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua-5.1.pkg	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua-5.1.pkg	(revision 1801)
@@ -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/branches/ceguilua/src/tolua/tolua.c
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua.c	(revision 1801)
@@ -0,0 +1,167 @@
+/* tolua
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** Aug 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.
+*/
+
+#include "tolua++.h"
+
+#include "lua.h"
+#include "lualib.h"
+#include "lauxlib.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+static void help (void)
+{
+ fprintf(stderr,"\n"
+         "usage: tolua++ [options] input_file\n"
+         "\n"
+         "Command line options are:\n"
+         "  -v       : print version information.\n"
+         "  -o  file : set output file; default is stdout.\n"
+         "  -H  file : create include file.\n"
+         "  -n  name : set package name; default is input file root name.\n"
+         "  -p       : parse only.\n"
+         "  -P       : parse and print structure information (for debug).\n"
+         "  -S       : disable support for c++ strings.\n"
+         "  -1       : substract 1 to operator[] index (for compatibility with tolua5).\n"
+         "  -L  file : run lua file (with dofile()) before doing anything.\n"
+         "  -D       : disable automatic exporting of destructors for classes that have\n"
+         "             constructors (for compatibility with tolua5)\n"
+         "  -W       : disable warnings for unsupported features (for compatibility\n"
+         "             with tolua5)\n"
+         "  -C       : disable cleanup of included lua code (for easier debugging)\n"
+         "  -E  value[=value] : add extra values to the luastate\n"
+         "  -t       : export a list of types asociates with the C++ typeid name\n"
+         "  -h       : print this message.\n"
+         "Should the input file be omitted, stdin is assumed;\n"
+         "in that case, the package name must be explicitly set.\n\n"
+        );
+}
+
+static void version (void)
+{
+ fprintf(stderr, "%s (written by W. Celes, A. Manzur)\n",TOLUA_VERSION);
+}
+
+static void setfield (lua_State* L, int table, char* f, char* v)
+{
+ lua_pushstring(L,f);
+ lua_pushstring(L,v);
+ lua_settable(L,table);
+}
+
+static void add_extra (lua_State* L, char* value) {
+	int len;
+	lua_getglobal(L, "_extra_parameters");
+	len = luaL_getn(L, -1);
+	lua_pushstring(L, value);
+	lua_rawseti(L, -2, len+1);
+	lua_pop(L, 1);
+};
+
+static void error (char* o)
+{
+ fprintf(stderr,"tolua: unknown option '%s'\n",o);
+ help();
+ exit(1);
+}
+
+int main (int argc, char* argv[])
+{
+ #ifdef LUA_VERSION_NUM /* lua 5.1 */
+ lua_State* L = luaL_newstate();
+ luaL_openlibs(L);
+ #else
+ lua_State* L = lua_open();
+ luaopen_base(L);
+ luaopen_io(L);
+ luaopen_string(L);
+ luaopen_table(L);
+ luaopen_math(L);
+ luaopen_debug(L);
+ #endif
+
+ lua_pushstring(L,TOLUA_VERSION); lua_setglobal(L,"TOLUA_VERSION");
+ lua_pushstring(L,LUA_VERSION); lua_setglobal(L,"TOLUA_LUA_VERSION");
+
+ if (argc==1)
+ {
+  help();
+  return 0;
+ }
+ else
+ {
+  int i, t;
+  lua_newtable(L);
+  lua_setglobal(L, "_extra_parameters");
+  lua_newtable(L);
+  lua_pushvalue(L,-1);
+  lua_setglobal(L,"flags");
+  t = lua_gettop(L);
+  for (i=1; i<argc; ++i)
+  {
+   if (*argv[i] == '-')
+   {
+    switch (argv[i][1])
+    {
+     case 'v': version(); return 0;
+     case 'h': help(); return 0;
+     case 'p': setfield(L,t,"p",""); break;
+     case 'P': setfield(L,t,"P",""); break;
+     case 'o': setfield(L,t,"o",argv[++i]); break;
+     case 'n': setfield(L,t,"n",argv[++i]); break;
+     case 'H': setfield(L,t,"H",argv[++i]); break;
+     case 'S': setfield(L,t,"S",""); break;
+     case '1': setfield(L,t,"1",""); break;
+     case 'L': setfield(L,t,"L",argv[++i]); break;
+     case 'D': setfield(L,t,"D",""); break;
+     case 'W': setfield(L,t,"W",""); break;
+     case 'C': setfield(L,t,"C",""); break;
+     case 'E': add_extra(L,argv[++i]); break;
+     case 't': setfield(L,t,"t",""); break;
+     default: error(argv[i]); break;
+    }
+   }
+   else
+   {
+    setfield(L,t,"f",argv[i]);
+    break;
+   }
+  }
+  lua_pop(L,1);
+ }
+/* #define TOLUA_SCRIPT_RUN */
+#ifndef TOLUA_SCRIPT_RUN
+ {
+  int tolua_tolua_open (lua_State* L);
+  tolua_tolua_open(L);
+ }
+#else
+ {
+  char* p;
+  char  path[BUFSIZ];
+  strcpy(path,argv[0]);
+  p = strrchr(path,'/');
+  if (p==NULL) p = strrchr(path,'\\');
+  p = (p==NULL) ? path : p+1;
+  sprintf(p,"%s","../src/bin/lua/");
+  lua_pushstring(L,path); lua_setglobal(L,"path");
+		strcat(path,"all.lua");
+  lua_dofile(L,path);
+ }
+#endif
+ return 0;
+}
Index: /code/branches/ceguilua/src/tolua/tolua_event.c
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua_event.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua_event.c	(revision 1801)
@@ -0,0 +1,513 @@
+/* tolua: event functions
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+#include <stdio.h>
+
+#include "tolua++.h"
+
+/* Store at ubox
+	* It stores, creating the corresponding table if needed,
+	* the pair key/value in the corresponding ubox table
+*/
+static void storeatubox (lua_State* L, int lo)
+{
+	#ifdef LUA_VERSION_NUM
+		lua_getfenv(L, lo);
+		if (lua_rawequal(L, -1, TOLUA_NOPEER)) {
+			lua_pop(L, 1);
+			lua_newtable(L);
+			lua_pushvalue(L, -1);
+			lua_setfenv(L, lo);	/* stack: k,v,table  */
+		};
+		lua_insert(L, -3);
+		lua_settable(L, -3); /* on lua 5.1, we trade the "tolua_peers" lookup for a settable call */
+		lua_pop(L, 1);
+	#else
+	 /* stack: key value (to be stored) */
+		lua_pushstring(L,"tolua_peers");
+		lua_rawget(L,LUA_REGISTRYINDEX);        /* stack: k v ubox */
+		lua_pushvalue(L,lo);
+		lua_rawget(L,-2);                       /* stack: k v ubox ubox[u] */
+		if (!lua_istable(L,-1))
+		{
+			lua_pop(L,1);                          /* stack: k v ubox */
+			lua_newtable(L);                       /* stack: k v ubox table */
+			lua_pushvalue(L,1);
+			lua_pushvalue(L,-2);                   /* stack: k v ubox table u table */
+			lua_rawset(L,-4);                      /* stack: k v ubox ubox[u]=table */
+		}
+		lua_insert(L,-4);                       /* put table before k */
+		lua_pop(L,1);                           /* pop ubox */
+		lua_rawset(L,-3);                       /* store at table */
+		lua_pop(L,1);                           /* pop ubox[u] */
+	#endif
+}
+
+/* Module index function
+*/
+static int module_index_event (lua_State* L)
+{
+	lua_pushstring(L,".get");
+	lua_rawget(L,-3);
+	if (lua_istable(L,-1))
+	{
+		lua_pushvalue(L,2);  /* key */
+		lua_rawget(L,-2);
+		if (lua_iscfunction(L,-1))
+		{
+			lua_call(L,0,1);
+			return 1;
+		}
+		else if (lua_istable(L,-1))
+			return 1;
+	}
+	/* call old index meta event */
+	if (lua_getmetatable(L,1))
+	{
+		lua_pushstring(L,"__index");
+		lua_rawget(L,-2);
+		lua_pushvalue(L,1);
+		lua_pushvalue(L,2);
+		if (lua_isfunction(L,-1))
+		{
+			lua_call(L,2,1);
+			return 1;
+		}
+		else if (lua_istable(L,-1))
+		{
+			lua_gettable(L,-3);
+			return 1;
+		}
+	}
+	lua_pushnil(L);
+	return 1;
+}
+
+/* Module newindex function
+*/
+static int module_newindex_event (lua_State* L)
+{
+	lua_pushstring(L,".set");
+	lua_rawget(L,-4);
+	if (lua_istable(L,-1))
+	{
+		lua_pushvalue(L,2);  /* key */
+		lua_rawget(L,-2);
+		if (lua_iscfunction(L,-1))
+		{
+			lua_pushvalue(L,1); /* only to be compatible with non-static vars */
+			lua_pushvalue(L,3); /* value */
+			lua_call(L,2,0);
+			return 0;
+		}
+	}
+	/* call old newindex meta event */
+	if (lua_getmetatable(L,1) && lua_getmetatable(L,-1))
+	{
+		lua_pushstring(L,"__newindex");
+		lua_rawget(L,-2);
+		if (lua_isfunction(L,-1))
+		{
+		 lua_pushvalue(L,1);
+		 lua_pushvalue(L,2);
+		 lua_pushvalue(L,3);
+			lua_call(L,3,0);
+		}
+	}
+	lua_settop(L,3);
+	lua_rawset(L,-3);
+	return 0;
+}
+
+/* Class index function
+	* If the object is a userdata (ie, an object), it searches the field in
+	* the alternative table stored in the corresponding "ubox" table.
+*/
+static int class_index_event (lua_State* L)
+{
+ int t = lua_type(L,1);
+	if (t == LUA_TUSERDATA)
+	{
+		/* Access alternative table */
+		#ifdef LUA_VERSION_NUM /* new macro on version 5.1 */
+		lua_getfenv(L,1);
+		if (!lua_rawequal(L, -1, TOLUA_NOPEER)) {
+			lua_pushvalue(L, 2); /* key */
+			lua_gettable(L, -2); /* on lua 5.1, we trade the "tolua_peers" lookup for a gettable call */
+			if (!lua_isnil(L, -1))
+				return 1;
+		};
+		#else
+		lua_pushstring(L,"tolua_peers");
+		lua_rawget(L,LUA_REGISTRYINDEX);        /* stack: obj key ubox */
+		lua_pushvalue(L,1);
+		lua_rawget(L,-2);                       /* stack: obj key ubox ubox[u] */
+		if (lua_istable(L,-1))
+		{
+			lua_pushvalue(L,2);  /* key */
+			lua_rawget(L,-2);                      /* stack: obj key ubox ubox[u] value */
+			if (!lua_isnil(L,-1))
+				return 1;
+		}
+		#endif
+		lua_settop(L,2);                        /* stack: obj key */
+		/* Try metatables */
+		lua_pushvalue(L,1);                     /* stack: obj key obj */
+		while (lua_getmetatable(L,-1))
+		{                                       /* stack: obj key obj mt */
+			lua_remove(L,-2);                      /* stack: obj key mt */
+			if (lua_isnumber(L,2))                 /* check if key is a numeric value */
+			{
+				/* try operator[] */
+				lua_pushstring(L,".geti");
+				lua_rawget(L,-2);                      /* stack: obj key mt func */
+				if (lua_isfunction(L,-1))
+				{
+					lua_pushvalue(L,1);
+					lua_pushvalue(L,2);
+					lua_call(L,2,1);
+					return 1;
+				}
+			}
+			else
+			{
+			 lua_pushvalue(L,2);                    /* stack: obj key mt key */
+				lua_rawget(L,-2);                      /* stack: obj key mt value */
+				if (!lua_isnil(L,-1))
+					return 1;
+				else
+					lua_pop(L,1);
+				/* try C/C++ variable */
+				lua_pushstring(L,".get");
+				lua_rawget(L,-2);                      /* stack: obj key mt tget */
+				if (lua_istable(L,-1))
+				{
+					lua_pushvalue(L,2);
+					lua_rawget(L,-2);                      /* stack: obj key mt value */
+					if (lua_iscfunction(L,-1))
+					{
+						lua_pushvalue(L,1);
+						lua_pushvalue(L,2);
+						lua_call(L,2,1);
+						return 1;
+					}
+					else if (lua_istable(L,-1))
+					{
+						/* deal with array: create table to be returned and cache it in ubox */
+						void* u = *((void**)lua_touserdata(L,1));
+						lua_newtable(L);                /* stack: obj key mt value table */
+						lua_pushstring(L,".self");
+						lua_pushlightuserdata(L,u);
+						lua_rawset(L,-3);               /* store usertype in ".self" */
+						lua_insert(L,-2);               /* stack: obj key mt table value */
+						lua_setmetatable(L,-2);         /* set stored value as metatable */
+						lua_pushvalue(L,-1);            /* stack: obj key met table table */
+						lua_pushvalue(L,2);             /* stack: obj key mt table table key */
+						lua_insert(L,-2);               /*  stack: obj key mt table key table */
+						storeatubox(L,1);               /* stack: obj key mt table */
+						return 1;
+					}
+				}
+			}
+			lua_settop(L,3);
+		}
+		lua_pushnil(L);
+		return 1;
+	}
+	else if (t== LUA_TTABLE)
+	{
+		module_index_event(L);
+		return 1;
+	}
+	lua_pushnil(L);
+	return 1;
+}
+
+/* Newindex function
+	* It first searches for a C/C++ varaible to be set.
+	* Then, it either stores it in the alternative ubox table (in the case it is
+	* an object) or in the own table (that represents the class or module).
+*/
+static int class_newindex_event (lua_State* L)
+{
+ int t = lua_type(L,1);
+	if (t == LUA_TUSERDATA)
+	{
+	 /* Try accessing a C/C++ variable to be set */
+		lua_getmetatable(L,1);
+		while (lua_istable(L,-1))                /* stack: t k v mt */
+		{
+			if (lua_isnumber(L,2))                 /* check if key is a numeric value */
+			{
+				/* try operator[] */
+				lua_pushstring(L,".seti");
+				lua_rawget(L,-2);                      /* stack: obj key mt func */
+				if (lua_isfunction(L,-1))
+				{
+					lua_pushvalue(L,1);
+					lua_pushvalue(L,2);
+					lua_pushvalue(L,3);
+					lua_call(L,3,0);
+					return 0;
+				}
+			}
+			else
+			{
+				lua_pushstring(L,".set");
+				lua_rawget(L,-2);                      /* stack: t k v mt tset */
+				if (lua_istable(L,-1))
+				{
+					lua_pushvalue(L,2);
+					lua_rawget(L,-2);                     /* stack: t k v mt tset func */
+					if (lua_iscfunction(L,-1))
+					{
+						lua_pushvalue(L,1);
+						lua_pushvalue(L,3);
+						lua_call(L,2,0);
+						return 0;
+					}
+					lua_pop(L,1);                          /* stack: t k v mt tset */
+				}
+				lua_pop(L,1);                           /* stack: t k v mt */
+				if (!lua_getmetatable(L,-1))            /* stack: t k v mt mt */
+					lua_pushnil(L);
+				lua_remove(L,-2);                       /* stack: t k v mt */
+			}
+		}
+	 lua_settop(L,3);                          /* stack: t k v */
+
+		/* then, store as a new field */
+		storeatubox(L,1);
+	}
+	else if (t== LUA_TTABLE)
+	{
+		module_newindex_event(L);
+	}
+	return 0;
+}
+
+static int class_call_event(lua_State* L) {
+
+	if (lua_istable(L, 1)) {
+		lua_pushstring(L, ".call");
+		lua_rawget(L, 1);
+		if (lua_isfunction(L, -1)) {
+
+			lua_insert(L, 1);
+			lua_call(L, lua_gettop(L)-1, 1);
+
+			return 1;
+		};
+	};
+	tolua_error(L,"Attempt to call a non-callable object.",NULL);
+	return 0;
+};
+
+static int do_operator (lua_State* L, const char* op)
+{
+	if (lua_isuserdata(L,1))
+	{
+		/* Try metatables */
+		lua_pushvalue(L,1);                     /* stack: op1 op2 */
+		while (lua_getmetatable(L,-1))
+		{                                       /* stack: op1 op2 op1 mt */
+			lua_remove(L,-2);                      /* stack: op1 op2 mt */
+			lua_pushstring(L,op);                  /* stack: op1 op2 mt key */
+			lua_rawget(L,-2);                      /* stack: obj key mt func */
+			if (lua_isfunction(L,-1))
+			{
+				lua_pushvalue(L,1);
+				lua_pushvalue(L,2);
+				lua_call(L,2,1);
+				return 1;
+			}
+			lua_settop(L,3);
+		}
+	}
+	tolua_error(L,"Attempt to perform operation on an invalid operand",NULL);
+	return 0;
+}
+
+static int class_add_event (lua_State* L)
+{
+	return do_operator(L,".add");
+}
+
+static int class_sub_event (lua_State* L)
+{
+	return do_operator(L,".sub");
+}
+
+static int class_mul_event (lua_State* L)
+{
+	return do_operator(L,".mul");
+}
+
+static int class_div_event (lua_State* L)
+{
+	return do_operator(L,".div");
+}
+
+static int class_lt_event (lua_State* L)
+{
+	return do_operator(L,".lt");
+}
+
+static int class_le_event (lua_State* L)
+{
+	return do_operator(L,".le");
+}
+
+static int class_eq_event (lua_State* L)
+{
+	return do_operator(L,".eq");
+}
+
+/*
+static int class_gc_event (lua_State* L)
+{
+	void* u = *((void**)lua_touserdata(L,1));
+	fprintf(stderr, "collecting: looking at %p\n", u);
+	lua_pushstring(L,"tolua_gc");
+	lua_rawget(L,LUA_REGISTRYINDEX);
+	lua_pushlightuserdata(L,u);
+	lua_rawget(L,-2);
+	if (lua_isfunction(L,-1))
+	{
+		lua_pushvalue(L,1);
+		lua_call(L,1,0);
+ 		lua_pushlightuserdata(L,u);
+		lua_pushnil(L);
+		lua_rawset(L,-3);
+	}
+	lua_pop(L,2);
+	return 0;
+}
+*/
+TOLUA_API int class_gc_event (lua_State* L)
+{
+	void* u = *((void**)lua_touserdata(L,1));
+	int top;
+	/*fprintf(stderr, "collecting: looking at %p\n", u);*/
+	/*
+	lua_pushstring(L,"tolua_gc");
+	lua_rawget(L,LUA_REGISTRYINDEX);
+	*/
+	lua_pushvalue(L, lua_upvalueindex(1));
+	lua_pushlightuserdata(L,u);
+	lua_rawget(L,-2);            /* stack: gc umt    */
+	lua_getmetatable(L,1);       /* stack: gc umt mt */
+	/*fprintf(stderr, "checking type\n");*/
+	top = lua_gettop(L);
+	if (tolua_fast_isa(L,top,top-1, lua_upvalueindex(2))) /* make sure we collect correct type */
+	{
+		/*fprintf(stderr, "Found type!\n");*/
+		/* get gc function */
+		lua_pushliteral(L,".collector");
+		lua_rawget(L,-2);           /* stack: gc umt mt collector */
+		if (lua_isfunction(L,-1)) {
+			/*fprintf(stderr, "Found .collector!\n");*/
+		}
+		else {
+			lua_pop(L,1);
+			/*fprintf(stderr, "Using default cleanup\n");*/
+			lua_pushcfunction(L,tolua_default_collect);
+		}
+
+		lua_pushvalue(L,1);         /* stack: gc umt mt collector u */
+		lua_call(L,1,0);
+
+		lua_pushlightuserdata(L,u); /* stack: gc umt mt u */
+		lua_pushnil(L);             /* stack: gc umt mt u nil */
+		lua_rawset(L,-5);           /* stack: gc umt mt */
+	}
+	lua_pop(L,3);
+	return 0;
+}
+
+
+/* Register module events
+	* It expects the metatable on the top of the stack
+*/
+TOLUA_API void tolua_moduleevents (lua_State* L)
+{
+	lua_pushstring(L,"__index");
+	lua_pushcfunction(L,module_index_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__newindex");
+	lua_pushcfunction(L,module_newindex_event);
+	lua_rawset(L,-3);
+}
+
+/* Check if the object on the top has a module metatable
+*/
+TOLUA_API int tolua_ismodulemetatable (lua_State* L)
+{
+	int r = 0;
+	if (lua_getmetatable(L,-1))
+	{
+		lua_pushstring(L,"__index");
+		lua_rawget(L,-2);
+		r = (lua_tocfunction(L,-1) == module_index_event);
+		lua_pop(L,2);
+	}
+	return r;
+}
+
+/* Register class events
+	* It expects the metatable on the top of the stack
+*/
+TOLUA_API void tolua_classevents (lua_State* L)
+{
+	lua_pushstring(L,"__index");
+	lua_pushcfunction(L,class_index_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__newindex");
+	lua_pushcfunction(L,class_newindex_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__add");
+	lua_pushcfunction(L,class_add_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__sub");
+	lua_pushcfunction(L,class_sub_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__mul");
+	lua_pushcfunction(L,class_mul_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__div");
+	lua_pushcfunction(L,class_div_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__lt");
+	lua_pushcfunction(L,class_lt_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__le");
+	lua_pushcfunction(L,class_le_event);
+	lua_rawset(L,-3);
+	lua_pushstring(L,"__eq");
+	lua_pushcfunction(L,class_eq_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__call");
+	lua_pushcfunction(L,class_call_event);
+	lua_rawset(L,-3);
+
+	lua_pushstring(L,"__gc");
+	lua_pushstring(L, "tolua_gc_event");
+	lua_rawget(L, LUA_REGISTRYINDEX);
+	/*lua_pushcfunction(L,class_gc_event);*/
+	lua_rawset(L,-3);
+}
+
Index: /code/branches/ceguilua/src/tolua/tolua_event.h
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua_event.h	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua_event.h	(revision 1801)
@@ -0,0 +1,24 @@
+/* tolua: event functions
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+#ifndef TOLUA_EVENT_H
+#define TOLUA_EVENT_H
+
+#include "tolua++.h"
+
+TOLUA_API void tolua_moduleevents (lua_State* L);
+TOLUA_API int tolua_ismodulemetatable (lua_State* L);
+TOLUA_API void tolua_classevents (lua_State* L);
+
+#endif
Index: /code/branches/ceguilua/src/tolua/tolua_is.c
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua_is.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua_is.c	(revision 1801)
@@ -0,0 +1,607 @@
+/* tolua: functions to check types.
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+#include "tolua++.h"
+#include "lauxlib.h"
+
+#include <stdlib.h>
+#include <string.h>
+
+/* a fast check if a is b, without parameter validation
+ i.e. if b is equal to a or a superclass of a. */
+TOLUA_API int tolua_fast_isa(lua_State *L, int mt_indexa, int mt_indexb, int super_index)
+{
+ int result;
+	if (lua_rawequal(L,mt_indexa,mt_indexb))
+		result = 1;
+	else
+	{
+		if (super_index) {
+			lua_pushvalue(L, super_index);
+		} else {
+			lua_pushliteral(L,"tolua_super");
+			lua_rawget(L,LUA_REGISTRYINDEX);  /* stack: super */
+		};
+		lua_pushvalue(L,mt_indexa);       /* stack: super mta */
+		lua_rawget(L,-2);                 /* stack: super super[mta] */
+		lua_pushvalue(L,mt_indexb);       /* stack: super super[mta] mtb */
+		lua_rawget(L,LUA_REGISTRYINDEX);  /* stack: super super[mta] typenameB */
+		lua_rawget(L,-2);                 /* stack: super super[mta] bool */
+		result = lua_toboolean(L,-1);
+		lua_pop(L,3);
+	}
+	return result;
+}
+
+/* Push and returns the corresponding object typename */
+TOLUA_API const char* tolua_typename (lua_State* L, int lo)
+{
+	int tag = lua_type(L,lo);
+ if (tag == LUA_TNONE)
+  lua_pushstring(L,"[no object]");
+ else if (tag != LUA_TUSERDATA && tag != LUA_TTABLE)
+  lua_pushstring(L,lua_typename(L,tag));
+ else if (tag == LUA_TUSERDATA)
+ {
+  if (!lua_getmetatable(L,lo))
+   lua_pushstring(L,lua_typename(L,tag));
+		else
+		{
+		 lua_rawget(L,LUA_REGISTRYINDEX);
+		 if (!lua_isstring(L,-1))
+			{
+		  lua_pop(L,1);
+				lua_pushstring(L,"[undefined]");
+			}
+		}
+	}
+	else  /* is table */
+	{
+		lua_pushvalue(L,lo);
+		lua_rawget(L,LUA_REGISTRYINDEX);
+		if (!lua_isstring(L,-1))
+		{
+			lua_pop(L,1);
+			lua_pushstring(L,"table");
+		}
+		else
+		{
+   lua_pushstring(L,"class ");
+			lua_insert(L,-2);
+			lua_concat(L,2);
+		}
+	}
+	return lua_tostring(L,-1);
+}
+
+TOLUA_API void tolua_error (lua_State* L, char* msg, tolua_Error* err)
+{
+	if (msg[0] == '#')
+	{
+  const char* expected = err->type;
+		const char* provided = tolua_typename(L,err->index);
+  if (msg[1]=='f')
+  {
+   int narg = err->index;
+			if (err->array)
+    luaL_error(L,"%s\n     argument #%d is array of '%s'; array of '%s' expected.\n",
+               msg+2,narg,provided,expected);
+			else
+    luaL_error(L,"%s\n     argument #%d is '%s'; '%s' expected.\n",
+               msg+2,narg,provided,expected);
+  }
+  else if (msg[1]=='v')
+		{
+			if (err->array)
+    luaL_error(L,"%s\n     value is array of '%s'; array of '%s' expected.\n",
+               msg+2,provided,expected);
+			else
+    luaL_error(L,"%s\n     value is '%s'; '%s' expected.\n",
+               msg+2,provided,expected);
+		}
+ }
+ else
+  luaL_error(L,msg);
+}
+
+/* the equivalent of lua_is* for usertable */
+static  int lua_isusertable (lua_State* L, int lo, const char* type)
+{
+	int r = 0;
+	if (lo < 0) lo = lua_gettop(L)+lo+1;
+	lua_pushvalue(L,lo);
+	lua_rawget(L,LUA_REGISTRYINDEX);  /* get registry[t] */
+	if (lua_isstring(L,-1))
+	{
+		r = strcmp(lua_tostring(L,-1),type)==0;
+		if (!r)
+		{
+			/* try const */
+			lua_pushstring(L,"const ");
+			lua_insert(L,-2);
+			lua_concat(L,2);
+			r = lua_isstring(L,-1) && strcmp(lua_tostring(L,-1),type)==0;
+		}
+	}
+	lua_pop(L, 1);
+	return r;
+}
+
+int push_table_instance(lua_State* L, int lo) {
+
+	if (lua_istable(L, lo)) {
+
+		lua_pushstring(L, ".c_instance");
+		lua_gettable(L, lo);
+		if (lua_isuserdata(L, -1)) {
+
+			lua_replace(L, lo);
+			return 1;
+		} else {
+
+			lua_pop(L, 1);
+			return 0;
+		};
+	} else {
+		return 0;
+	};
+
+	return 0;
+};
+
+/* the equivalent of lua_is* for usertype */
+static int lua_isusertype (lua_State* L, int lo, const char* type)
+{
+	if (!lua_isuserdata(L,lo)) {
+		if (!push_table_instance(L, lo)) {
+			return 0;
+		};
+	};
+	{
+		/* check if it is of the same type */
+		int r;
+		const char *tn;
+		if (lua_getmetatable(L,lo))        /* if metatable? */
+		{
+		 lua_rawget(L,LUA_REGISTRYINDEX);  /* get registry[mt] */
+		 tn = lua_tostring(L,-1);
+		 r = tn && (strcmp(tn,type) == 0);
+		 lua_pop(L, 1);
+			if (r)
+			 return 1;
+			else
+			{
+				/* check if it is a specialized class */
+				lua_pushstring(L,"tolua_super");
+				lua_rawget(L,LUA_REGISTRYINDEX); /* get super */
+				lua_getmetatable(L,lo);
+				lua_rawget(L,-2);                /* get super[mt] */
+				if (lua_istable(L,-1))
+				{
+					int b;
+					lua_pushstring(L,type);
+					lua_rawget(L,-2);                /* get super[mt][type] */
+					b = lua_toboolean(L,-1);
+					lua_pop(L,3);
+					if (b)
+					 return 1;
+				}
+			}
+		}
+ }
+	return 0;
+}
+
+TOLUA_API int tolua_isnoobj (lua_State* L, int lo, tolua_Error* err)
+{
+ if (lua_gettop(L)<abs(lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "[no object]";
+ return 0;
+}
+TOLUA_API int tolua_isvalue (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def || abs(lo)<=lua_gettop(L))  /* any valid index */
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "value";
+	return 0;
+}
+
+TOLUA_API int tolua_isboolean (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnil(L,lo) || lua_isboolean(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "boolean";
+	return 0;
+}
+
+TOLUA_API int tolua_isnumber (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnumber(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "number";
+	return 0;
+}
+
+TOLUA_API int tolua_isstring (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+ if (lua_isnil(L,lo) || lua_isstring(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "string";
+	return 0;
+}
+
+TOLUA_API int tolua_istable (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_istable(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "table";
+	return 0;
+}
+
+TOLUA_API int tolua_isusertable (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isusertable(L,lo,type))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = type;
+	return 0;
+}
+
+
+TOLUA_API int tolua_isuserdata (lua_State* L, int lo, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnil(L,lo) || lua_isuserdata(L,lo))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = "userdata";
+	return 0;
+}
+
+TOLUA_API int tolua_isusertype (lua_State* L, int lo, const char* type, int def, tolua_Error* err)
+{
+	if (def && lua_gettop(L)<abs(lo))
+		return 1;
+	if (lua_isnil(L,lo) || lua_isusertype(L,lo,type))
+		return 1;
+	err->index = lo;
+	err->array = 0;
+	err->type = type;
+	return 0;
+}
+
+TOLUA_API int tolua_isvaluearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+		return 1;
+}
+
+TOLUA_API int tolua_isbooleanarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) &&
+					  !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "boolean";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isnumberarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+			if (!lua_isnumber(L,-1) &&
+					  !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "number";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isstringarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+   if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "string";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_istablearray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (! lua_istable(L,-1) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "table";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isuserdataarray
+ (lua_State* L, int lo, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->array = 1;
+				err->type = "userdata";
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+TOLUA_API int tolua_isusertypearray
+ (lua_State* L, int lo, const char* type, int dim, int def, tolua_Error* err)
+{
+	if (!tolua_istable(L,lo,def,err))
+		return 0;
+	else
+	{
+		int i;
+		for (i=1; i<=dim; ++i)
+		{
+			lua_pushnumber(L,i);
+			lua_gettable(L,lo);
+	  if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) &&
+			    !(def && lua_isnil(L,-1))
+						)
+			{
+				err->index = lo;
+				err->type = type;
+				err->array = 1;
+				return 0;
+			}
+			lua_pop(L,1);
+		}
+ }
+ return 1;
+}
+
+#if 0
+int tolua_isbooleanfield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!(lua_isnil(L,-1) || lua_isboolean(L,-1)) &&
+			  !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "boolean";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isnumberfield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!lua_isnumber(L,-1) &&
+			  !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "number";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isstringfield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+ if (!(lua_isnil(L,-1) || lua_isstring(L,-1)) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "string";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_istablefield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i+1);
+	lua_gettable(L,lo);
+	if (! lua_istable(L,-1) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "table";
+		return 0;
+	}
+	lua_pop(L,1);
+}
+
+int tolua_isusertablefield
+ (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (! lua_isusertable(L,-1,type) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = type;
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isuserdatafield
+ (lua_State* L, int lo, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!(lua_isnil(L,-1) || lua_isuserdata(L,-1)) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->array = 1;
+		err->type = "userdata";
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+int tolua_isusertypefield
+ (lua_State* L, int lo, const char* type, int i, int def, tolua_Error* err)
+{
+	lua_pushnumber(L,i);
+	lua_gettable(L,lo);
+	if (!(lua_isnil(L,-1) || lua_isusertype(L,-1,type)) &&
+	    !(def && lua_isnil(L,-1))
+				)
+	{
+		err->index = lo;
+		err->type = type;
+		err->array = 1;
+		return 0;
+	}
+	lua_pop(L,1);
+ return 1;
+}
+
+#endif
Index: /code/branches/ceguilua/src/tolua/tolua_map.c
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua_map.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua_map.c	(revision 1801)
@@ -0,0 +1,704 @@
+/* tolua: functions to map features
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+#include "tolua++.h"
+#include "tolua_event.h"
+#include "lauxlib.h"
+
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+
+/* Create metatable
+	* Create and register new metatable
+*/
+static int tolua_newmetatable (lua_State* L, char* name)
+{
+	int r = luaL_newmetatable(L,name);
+
+	#ifdef LUA_VERSION_NUM /* only lua 5.1 */
+	if (r) {
+		lua_pushvalue(L, -1);
+		lua_pushstring(L, name);
+		lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */
+	};
+	#endif
+
+	if (r)
+		tolua_classevents(L); /* set meta events */
+	lua_pop(L,1);
+	return r;
+}
+
+/* Map super classes
+	* It sets 'name' as being also a 'base', mapping all super classes of 'base' in 'name'
+*/
+static void mapsuper (lua_State* L, const char* name, const char* base)
+{
+	/* push registry.super */
+ lua_pushstring(L,"tolua_super");
+ lua_rawget(L,LUA_REGISTRYINDEX);    /* stack: super */
+	luaL_getmetatable(L,name);          /* stack: super mt */
+ lua_rawget(L,-2);                   /* stack: super table */
+	if (lua_isnil(L,-1))
+	{
+	 /* create table */
+		lua_pop(L,1);
+	 lua_newtable(L);                    /* stack: super table */
+	 luaL_getmetatable(L,name);          /* stack: super table mt */
+		lua_pushvalue(L,-2);                /* stack: super table mt table */
+		lua_rawset(L,-4);                   /* stack: super table */
+	}
+
+	/* set base as super class */
+	lua_pushstring(L,base);
+	lua_pushboolean(L,1);
+	lua_rawset(L,-3);                    /* stack: super table */
+
+	/* set all super class of base as super class of name */
+	luaL_getmetatable(L,base);          /* stack: super table base_mt */
+	lua_rawget(L,-3);                   /* stack: super table base_table */
+	if (lua_istable(L,-1))
+	{
+		/* traverse base table */
+		lua_pushnil(L);  /* first key */
+		while (lua_next(L,-2) != 0)
+		{
+			/* stack: ... base_table key value */
+			lua_pushvalue(L,-2);    /* stack: ... base_table key value key */
+			lua_insert(L,-2);       /* stack: ... base_table key key value */
+			lua_rawset(L,-5);       /* stack: ... base_table key */
+		}
+	}
+	lua_pop(L,3);                       /* stack: <empty> */
+}
+
+/* creates a 'tolua_ubox' table for base clases, and
+// expects the metatable and base metatable on the stack */
+static void set_ubox(lua_State* L) {
+
+	/* mt basemt */
+	if (!lua_isnil(L, -1)) {
+		lua_pushstring(L, "tolua_ubox");
+		lua_rawget(L,-2);
+	} else {
+		lua_pushnil(L);
+	};
+	/* mt basemt base_ubox */
+	if (!lua_isnil(L,-1)) {
+		lua_pushstring(L, "tolua_ubox");
+		lua_insert(L, -2);
+		/* mt basemt key ubox */
+		lua_rawset(L,-4);
+		/* (mt with ubox) basemt */
+	} else {
+		/* mt basemt nil */
+		lua_pop(L, 1);
+		lua_pushstring(L,"tolua_ubox"); lua_newtable(L);
+		/* make weak value metatable for ubox table to allow userdata to be
+		garbage-collected */
+		lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3);               /* stack: string ubox mt */
+		lua_setmetatable(L, -2);  /* stack:mt basemt string ubox */
+		lua_rawset(L,-4);
+	};
+
+};
+
+/* Map inheritance
+	* It sets 'name' as derived from 'base' by setting 'base' as metatable of 'name'
+*/
+static void mapinheritance (lua_State* L, const char* name, const char* base)
+{
+	/* set metatable inheritance */
+	luaL_getmetatable(L,name);
+
+	if (base && *base)
+		luaL_getmetatable(L,base);
+	else {
+
+		if (lua_getmetatable(L, -1)) { /* already has a mt, we don't overwrite it */
+			lua_pop(L, 2);
+			return;
+		};
+		luaL_getmetatable(L,"tolua_commonclass");
+	};
+
+	set_ubox(L);
+
+	lua_setmetatable(L,-2);
+	lua_pop(L,1);
+}
+
+/* Object type
+*/
+static int tolua_bnd_type (lua_State* L)
+{
+	tolua_typename(L,lua_gettop(L));
+	return 1;
+}
+
+/* Take ownership
+*/
+static int tolua_bnd_takeownership (lua_State* L)
+{
+	int success = 0;
+	if (lua_isuserdata(L,1))
+	{
+		if (lua_getmetatable(L,1))        /* if metatable? */
+		{
+			lua_pop(L,1);             /* clear metatable off stack */
+			/* force garbage collection to avoid C to reuse a to-be-collected address */
+			#ifdef LUA_VERSION_NUM
+			lua_gc(L, LUA_GCCOLLECT, 0);
+			#else
+			lua_setgcthreshold(L,0);
+			#endif
+
+			success = tolua_register_gc(L,1);
+		}
+	}
+	lua_pushboolean(L,success!=0);
+	return 1;
+}
+
+/* Release ownership
+*/
+static int tolua_bnd_releaseownership (lua_State* L)
+{
+	int done = 0;
+	if (lua_isuserdata(L,1))
+	{
+		void* u = *((void**)lua_touserdata(L,1));
+		/* force garbage collection to avoid releasing a to-be-collected address */
+		#ifdef LUA_VERSION_NUM
+		lua_gc(L, LUA_GCCOLLECT, 0);
+		#else
+		lua_setgcthreshold(L,0);
+		#endif
+		lua_pushstring(L,"tolua_gc");
+		lua_rawget(L,LUA_REGISTRYINDEX);
+		lua_pushlightuserdata(L,u);
+		lua_rawget(L,-2);
+		lua_getmetatable(L,1);
+		if (lua_rawequal(L,-1,-2))  /* check that we are releasing the correct type */
+		{
+			lua_pushlightuserdata(L,u);
+			lua_pushnil(L);
+			lua_rawset(L,-5);
+			done = 1;
+		}
+	}
+	lua_pushboolean(L,done!=0);
+	return 1;
+}
+
+/* Type casting
+*/
+static int tolua_bnd_cast (lua_State* L)
+{
+
+/* // old code
+        void* v = tolua_tousertype(L,1,NULL);
+        const char* s = tolua_tostring(L,2,NULL);
+        if (v && s)
+         tolua_pushusertype(L,v,s);
+        else
+         lua_pushnil(L);
+        return 1;
+*/
+
+	void* v;
+	const char* s;
+	if (lua_islightuserdata(L, 1)) {
+		v = tolua_touserdata(L, 1, NULL);
+	} else {
+		v = tolua_tousertype(L, 1, 0);
+	};
+
+	s = tolua_tostring(L,2,NULL);
+	if (v && s)
+	 tolua_pushusertype(L,v,s);
+	else
+	 lua_pushnil(L);
+	return 1;
+}
+
+/* Inheritance
+*/
+static int tolua_bnd_inherit (lua_State* L) {
+
+	/* stack: lua object, c object */
+	lua_pushstring(L, ".c_instance");
+	lua_pushvalue(L, -2);
+	lua_rawset(L, -4);
+	/* l_obj[".c_instance"] = c_obj */
+
+	return 0;
+};
+
+#ifdef LUA_VERSION_NUM /* lua 5.1 */
+static int tolua_bnd_setpeer(lua_State* L) {
+
+	/* stack: userdata, table */
+	if (!lua_isuserdata(L, -2)) {
+		lua_pushstring(L, "Invalid argument #1 to setpeer: userdata expected.");
+		lua_error(L);
+	};
+	
+	if (lua_isnil(L, -1)) {
+
+		lua_pop(L, 1);
+		lua_pushvalue(L, TOLUA_NOPEER);
+	};
+	lua_setfenv(L, -2);
+
+	return 0;
+};
+
+static int tolua_bnd_getpeer(lua_State* L) {
+
+	/* stack: userdata */
+	lua_getfenv(L, -1);
+	if (lua_rawequal(L, -1, TOLUA_NOPEER)) {
+		lua_pop(L, 1);
+		lua_pushnil(L);
+	};
+	return 1;
+};
+#endif
+
+/* static int class_gc_event (lua_State* L); */
+
+TOLUA_API void tolua_open (lua_State* L)
+{
+ int top = lua_gettop(L);
+ lua_pushstring(L,"tolua_opened");
+ lua_rawget(L,LUA_REGISTRYINDEX);
+ if (!lua_isboolean(L,-1))
+ {
+  lua_pushstring(L,"tolua_opened"); lua_pushboolean(L,1); lua_rawset(L,LUA_REGISTRYINDEX);
+
+  #ifndef LUA_VERSION_NUM /* only prior to lua 5.1 */
+  /* create peer object table */
+  lua_pushstring(L, "tolua_peers"); lua_newtable(L);
+  /* make weak key metatable for peers indexed by userdata object */
+  lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "k"); lua_rawset(L, -3);                /* stack: string peers mt */
+  lua_setmetatable(L, -2);   /* stack: string peers */
+  lua_rawset(L,LUA_REGISTRYINDEX);
+  #endif
+
+  /* create object ptr -> udata mapping table */
+  lua_pushstring(L,"tolua_ubox"); lua_newtable(L);
+  /* make weak value metatable for ubox table to allow userdata to be
+     garbage-collected */
+  lua_newtable(L); lua_pushliteral(L, "__mode"); lua_pushliteral(L, "v"); lua_rawset(L, -3);               /* stack: string ubox mt */
+  lua_setmetatable(L, -2);  /* stack: string ubox */
+  lua_rawset(L,LUA_REGISTRYINDEX);
+
+  lua_pushstring(L,"tolua_super"); lua_newtable(L); lua_rawset(L,LUA_REGISTRYINDEX);
+  lua_pushstring(L,"tolua_gc"); lua_newtable(L);lua_rawset(L,LUA_REGISTRYINDEX);
+
+  /* create gc_event closure */
+  lua_pushstring(L, "tolua_gc_event");
+  lua_pushstring(L, "tolua_gc");
+  lua_rawget(L, LUA_REGISTRYINDEX);
+  lua_pushstring(L, "tolua_super");
+  lua_rawget(L, LUA_REGISTRYINDEX);
+  lua_pushcclosure(L, class_gc_event, 2);
+  lua_rawset(L, LUA_REGISTRYINDEX);
+
+  tolua_newmetatable(L,"tolua_commonclass");
+
+  tolua_module(L,NULL,0);
+  tolua_beginmodule(L,NULL);
+  tolua_module(L,"tolua",0);
+  tolua_beginmodule(L,"tolua");
+  tolua_function(L,"type",tolua_bnd_type);
+  tolua_function(L,"takeownership",tolua_bnd_takeownership);
+  tolua_function(L,"releaseownership",tolua_bnd_releaseownership);
+  tolua_function(L,"cast",tolua_bnd_cast);
+  tolua_function(L,"inherit", tolua_bnd_inherit);
+  #ifdef LUA_VERSION_NUM /* lua 5.1 */
+  tolua_function(L, "setpeer", tolua_bnd_setpeer);
+  tolua_function(L, "getpeer", tolua_bnd_getpeer);
+  #endif
+
+  tolua_endmodule(L);
+  tolua_endmodule(L);
+ }
+ lua_settop(L,top);
+}
+
+/* Copy a C object
+*/
+TOLUA_API void* tolua_copy (lua_State* L, void* value, unsigned int size)
+{
+	void* clone = (void*)malloc(size);
+	if (clone)
+	 memcpy(clone,value,size);
+	else
+		tolua_error(L,"insuficient memory",NULL);
+	return clone;
+}
+
+/* Default collect function
+*/
+TOLUA_API int tolua_default_collect (lua_State* tolua_S)
+{
+ void* self = tolua_tousertype(tolua_S,1,0);
+ free(self);
+ return 0;
+}
+
+/* Do clone
+*/
+TOLUA_API int tolua_register_gc (lua_State* L, int lo)
+{
+ int success = 1;
+ void *value = *(void **)lua_touserdata(L,lo);
+ lua_pushstring(L,"tolua_gc");
+ lua_rawget(L,LUA_REGISTRYINDEX);
+	lua_pushlightuserdata(L,value);
+	lua_rawget(L,-2);
+	if (!lua_isnil(L,-1)) /* make sure that object is not already owned */
+		success = 0;
+	else
+	{
+		lua_pushlightuserdata(L,value);
+		lua_getmetatable(L,lo);
+		lua_rawset(L,-4);
+	}
+	lua_pop(L,2);
+	return success;
+}
+
+/* Register a usertype
+	* It creates the correspoding metatable in the registry, for both 'type' and 'const type'.
+	* It maps 'const type' as being also a 'type'
+*/
+TOLUA_API void tolua_usertype (lua_State* L, char* type)
+{
+ char ctype[128] = "const ";
+ strncat(ctype,type,120);
+
+	/* create both metatables */
+ if (tolua_newmetatable(L,ctype) && tolua_newmetatable(L,type))
+	 mapsuper(L,type,ctype);             /* 'type' is also a 'const type' */
+}
+
+
+/* Begin module
+	* It pushes the module (or class) table on the stack
+*/
+TOLUA_API void tolua_beginmodule (lua_State* L, char* name)
+{
+	if (name)
+	{
+	 lua_pushstring(L,name);
+		lua_rawget(L,-2);
+	}
+	else
+	 lua_pushvalue(L,LUA_GLOBALSINDEX);
+}
+
+/* End module
+	* It pops the module (or class) from the stack
+*/
+TOLUA_API void tolua_endmodule (lua_State* L)
+{
+	lua_pop(L,1);
+}
+
+/* Map module
+	* It creates a new module
+*/
+#if 1
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
+{
+	if (name)
+	{
+		/* tolua module */
+		lua_pushstring(L,name);
+		lua_rawget(L,-2);
+		if (!lua_istable(L,-1))  /* check if module already exists */
+		{
+			lua_pop(L,1);
+		 lua_newtable(L);
+		 lua_pushstring(L,name);
+			lua_pushvalue(L,-2);
+		 lua_rawset(L,-4);       /* assing module into module */
+		}
+	}
+	else
+	{
+		/* global table */
+		lua_pushvalue(L,LUA_GLOBALSINDEX);
+	}
+	if (hasvar)
+	{
+		if (!tolua_ismodulemetatable(L))  /* check if it already has a module metatable */
+		{
+			/* create metatable to get/set C/C++ variable */
+			lua_newtable(L);
+			tolua_moduleevents(L);
+			if (lua_getmetatable(L,-2))
+				lua_setmetatable(L,-2);  /* set old metatable as metatable of metatable */
+			lua_setmetatable(L,-2);
+		}
+	}
+	lua_pop(L,1);               /* pop module */
+}
+#else
+TOLUA_API void tolua_module (lua_State* L, char* name, int hasvar)
+{
+	if (name)
+	{
+		/* tolua module */
+		lua_pushstring(L,name);
+		lua_newtable(L);
+	}
+	else
+	{
+		/* global table */
+		lua_pushvalue(L,LUA_GLOBALSINDEX);
+	}
+	if (hasvar)
+	{
+		/* create metatable to get/set C/C++ variable */
+		lua_newtable(L);
+		tolua_moduleevents(L);
+		if (lua_getmetatable(L,-2))
+			lua_setmetatable(L,-2);  /* set old metatable as metatable of metatable */
+		lua_setmetatable(L,-2);
+	}
+	if (name)
+		lua_rawset(L,-3);       /* assing module into module */
+	else
+		lua_pop(L,1);           /* pop global table */
+}
+#endif
+
+static void push_collector(lua_State* L, const char* type, lua_CFunction col) {
+
+	/* push collector function, but only if it's not NULL, or if there's no
+	   collector already */
+	if (!col) return;
+	luaL_getmetatable(L,type);
+	lua_pushstring(L,".collector");
+	/*
+	if (!col) {
+		lua_pushvalue(L, -1);
+		lua_rawget(L, -3);
+		if (!lua_isnil(L, -1)) {
+			lua_pop(L, 3);
+			return;
+		};
+		lua_pop(L, 1);
+	};
+	//	*/
+	lua_pushcfunction(L,col);
+
+	lua_rawset(L,-3);
+	lua_pop(L, 1);
+};
+
+/* Map C class
+	* It maps a C class, setting the appropriate inheritance and super classes.
+*/
+TOLUA_API void tolua_cclass (lua_State* L, char* lname, char* name, char* base, lua_CFunction col)
+{
+	char cname[128] = "const ";
+	char cbase[128] = "const ";
+	strncat(cname,name,120);
+	strncat(cbase,base,120);
+
+	mapinheritance(L,name,base);
+	mapinheritance(L,cname,name);
+
+	mapsuper(L,cname,cbase);
+	mapsuper(L,name,base);
+
+	lua_pushstring(L,lname);
+	
+	push_collector(L, name, col);
+	/*
+	luaL_getmetatable(L,name);
+	lua_pushstring(L,".collector");
+	lua_pushcfunction(L,col);
+
+	lua_rawset(L,-3);
+	*/
+	
+	luaL_getmetatable(L,name);
+	lua_rawset(L,-3);              /* assign class metatable to module */
+
+	/* now we also need to store the collector table for the const
+	   instances of the class */
+	push_collector(L, cname, col);
+	/*
+	luaL_getmetatable(L,cname);
+	lua_pushstring(L,".collector");
+	lua_pushcfunction(L,col);
+	lua_rawset(L,-3);
+	lua_pop(L,1);
+	*/
+	
+
+}
+
+/* Add base
+	* It adds additional base classes to a class (for multiple inheritance)
+	* (not for now)
+TOLUA_API void tolua_addbase(lua_State* L, char* name, char* base) {
+
+	char cname[128] = "const ";
+	char cbase[128] = "const ";
+	strncat(cname,name,120);
+	strncat(cbase,base,120);
+
+	mapsuper(L,cname,cbase);
+	mapsuper(L,name,base);
+};
+*/
+
+/* Map function
+	* It assigns a function into the current module (or class)
+*/
+TOLUA_API void tolua_function (lua_State* L, char* name, lua_CFunction func)
+{
+ lua_pushstring(L,name);
+ lua_pushcfunction(L,func);
+	lua_rawset(L,-3);
+}
+
+/* sets the __call event for the class (expects the class' main table on top) */
+/*	never really worked :(
+TOLUA_API void tolua_set_call_event(lua_State* L, lua_CFunction func, char* type) {
+
+	lua_getmetatable(L, -1);
+	//luaL_getmetatable(L, type);
+	lua_pushstring(L,"__call");
+	lua_pushcfunction(L,func);
+	lua_rawset(L,-3);
+	lua_pop(L, 1);
+};
+*/
+
+/* Map constant number
+	* It assigns a constant number into the current module (or class)
+*/
+TOLUA_API void tolua_constant (lua_State* L, char* name, double value)
+{
+	lua_pushstring(L,name);
+	tolua_pushnumber(L,value);
+	lua_rawset(L,-3);
+}
+
+
+/* Map variable
+	* It assigns a variable into the current module (or class)
+*/
+TOLUA_API void tolua_variable (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
+{
+	/* get func */
+	lua_pushstring(L,".get");
+	lua_rawget(L,-2);
+	if (!lua_istable(L,-1))
+	{
+		/* create .get table, leaving it at the top */
+		lua_pop(L,1);
+		lua_newtable(L);
+	 lua_pushstring(L,".get");
+		lua_pushvalue(L,-2);
+		lua_rawset(L,-4);
+	}
+	lua_pushstring(L,name);
+	lua_pushcfunction(L,get);
+ lua_rawset(L,-3);                  /* store variable */
+	lua_pop(L,1);                      /* pop .get table */
+
+	/* set func */
+	if (set)
+	{
+		lua_pushstring(L,".set");
+		lua_rawget(L,-2);
+		if (!lua_istable(L,-1))
+		{
+			/* create .set table, leaving it at the top */
+			lua_pop(L,1);
+			lua_newtable(L);
+			lua_pushstring(L,".set");
+			lua_pushvalue(L,-2);
+			lua_rawset(L,-4);
+		}
+		lua_pushstring(L,name);
+		lua_pushcfunction(L,set);
+		lua_rawset(L,-3);                  /* store variable */
+		lua_pop(L,1);                      /* pop .set table */
+	}
+}
+
+/* Access const array
+	* It reports an error when trying to write into a const array
+*/
+static int const_array (lua_State* L)
+{
+ luaL_error(L,"value of const array cannot be changed");
+ return 0;
+}
+
+/* Map an array
+	* It assigns an array into the current module (or class)
+*/
+TOLUA_API void tolua_array (lua_State* L, char* name, lua_CFunction get, lua_CFunction set)
+{
+	lua_pushstring(L,".get");
+	lua_rawget(L,-2);
+	if (!lua_istable(L,-1))
+	{
+		/* create .get table, leaving it at the top */
+		lua_pop(L,1);
+		lua_newtable(L);
+	 lua_pushstring(L,".get");
+		lua_pushvalue(L,-2);
+		lua_rawset(L,-4);
+	}
+	lua_pushstring(L,name);
+
+ lua_newtable(L);           /* create array metatable */
+ lua_pushvalue(L,-1);
+	lua_setmetatable(L,-2);    /* set the own table as metatable (for modules) */
+ lua_pushstring(L,"__index");
+ lua_pushcfunction(L,get);
+	lua_rawset(L,-3);
+ lua_pushstring(L,"__newindex");
+ lua_pushcfunction(L,set?set:const_array);
+	lua_rawset(L,-3);
+
+ lua_rawset(L,-3);                  /* store variable */
+	lua_pop(L,1);                      /* pop .get table */
+}
+
+
+TOLUA_API void tolua_dobuffer(lua_State* L, char* B, unsigned int size, const char* name) {
+
+ #ifdef LUA_VERSION_NUM /* lua 5.1 */
+ luaL_loadbuffer(L, B, size, name) || lua_pcall(L, 0, 0, 0);
+ #else
+ lua_dobuffer(L, B, size, name);
+ #endif
+};
+
Index: /code/branches/ceguilua/src/tolua/tolua_push.c
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua_push.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua_push.c	(revision 1801)
@@ -0,0 +1,171 @@
+/* tolua: functions to push C values.
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+#include "tolua++.h"
+#include "lauxlib.h"
+
+#include <stdlib.h>
+
+TOLUA_API void tolua_pushvalue (lua_State* L, int lo)
+{
+ lua_pushvalue(L,lo);
+}
+
+TOLUA_API void tolua_pushboolean (lua_State* L, int value)
+{
+ lua_pushboolean(L,value);
+}
+
+TOLUA_API void tolua_pushnumber (lua_State* L, double value)
+{
+ lua_pushnumber(L,value);
+}
+
+TOLUA_API void tolua_pushstring (lua_State* L, const char* value)
+{
+ if (value == NULL)
+  lua_pushnil(L);
+ else
+  lua_pushstring(L,value);
+}
+
+TOLUA_API void tolua_pushuserdata (lua_State* L, void* value)
+{
+ if (value == NULL)
+  lua_pushnil(L);
+ else
+  lua_pushlightuserdata(L,value);
+}
+
+TOLUA_API void tolua_pushusertype (lua_State* L, void* value, const char* type)
+{
+ if (value == NULL)
+  lua_pushnil(L);
+ else
+ {
+  luaL_getmetatable(L, type);
+  lua_pushstring(L,"tolua_ubox");
+  lua_rawget(L,-2);        /* stack: mt ubox */
+  if (lua_isnil(L, -1)) {
+	  lua_pop(L, 1);
+	  lua_pushstring(L, "tolua_ubox");
+	  lua_rawget(L, LUA_REGISTRYINDEX);
+  };
+  lua_pushlightuserdata(L,value);
+  lua_rawget(L,-2);                       /* stack: mt ubox ubox[u] */
+  if (lua_isnil(L,-1))
+  {
+   lua_pop(L,1);                          /* stack: mt ubox */
+   lua_pushlightuserdata(L,value);
+   *(void**)lua_newuserdata(L,sizeof(void *)) = value;   /* stack: mt ubox u newud */
+   lua_pushvalue(L,-1);                   /* stack: mt ubox u newud newud */
+   lua_insert(L,-4);                      /* stack: mt newud ubox u newud */
+   lua_rawset(L,-3);                      /* stack: mt newud ubox */
+   lua_pop(L,1);                          /* stack: mt newud */
+   /*luaL_getmetatable(L,type);*/
+   lua_pushvalue(L, -2);			/* stack: mt newud mt */
+   lua_setmetatable(L,-2);			/* stack: mt newud */
+
+   #ifdef LUA_VERSION_NUM
+   lua_pushvalue(L, TOLUA_NOPEER);
+   lua_setfenv(L, -2);
+   #endif
+  }
+  else
+  {
+   /* check the need of updating the metatable to a more specialized class */
+   lua_insert(L,-2);                       /* stack: mt ubox[u] ubox */
+   lua_pop(L,1);                           /* stack: mt ubox[u] */
+   lua_pushstring(L,"tolua_super");
+   lua_rawget(L,LUA_REGISTRYINDEX);        /* stack: mt ubox[u] super */
+   lua_getmetatable(L,-2);                 /* stack: mt ubox[u] super mt */
+   lua_rawget(L,-2);                       /* stack: mt ubox[u] super super[mt] */
+			if (lua_istable(L,-1))
+			{
+				lua_pushstring(L,type);                 /* stack: mt ubox[u] super super[mt] type */
+				lua_rawget(L,-2);                       /* stack: mt ubox[u] super super[mt] flag */
+				if (lua_toboolean(L,-1) == 1)   /* if true */
+				{
+					lua_pop(L,3);	/* mt ubox[u]*/
+					lua_remove(L, -2);
+					return;
+				}
+			}
+			/* type represents a more specilized type */
+			/*luaL_getmetatable(L,type);             // stack: mt ubox[u] super super[mt] flag mt */
+			lua_pushvalue(L, -5);					/* stack: mt ubox[u] super super[mt] flag mt */
+			lua_setmetatable(L,-5);                /* stack: mt ubox[u] super super[mt] flag */
+			lua_pop(L,3);                          /* stack: mt ubox[u] */
+  }
+  lua_remove(L, -2);	/* stack: ubox[u]*/
+ }
+}
+
+TOLUA_API void tolua_pushusertype_and_takeownership (lua_State* L, void* value, const char* type)
+{
+	tolua_pushusertype(L,value,type);
+	tolua_register_gc(L,lua_gettop(L));
+}
+
+TOLUA_API void tolua_pushfieldvalue (lua_State* L, int lo, int index, int v)
+{
+ lua_pushnumber(L,index);
+ lua_pushvalue(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldboolean (lua_State* L, int lo, int index, int v)
+{
+ lua_pushnumber(L,index);
+ lua_pushboolean(L,v);
+ lua_settable(L,lo);
+}
+
+
+TOLUA_API void tolua_pushfieldnumber (lua_State* L, int lo, int index, double v)
+{
+ lua_pushnumber(L,index);
+ tolua_pushnumber(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldstring (lua_State* L, int lo, int index, const char* v)
+{
+ lua_pushnumber(L,index);
+ tolua_pushstring(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfielduserdata (lua_State* L, int lo, int index, void* v)
+{
+ lua_pushnumber(L,index);
+ tolua_pushuserdata(L,v);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldusertype (lua_State* L, int lo, int index, void* v, const char* type)
+{
+ lua_pushnumber(L,index);
+ tolua_pushusertype(L,v,type);
+ lua_settable(L,lo);
+}
+
+TOLUA_API void tolua_pushfieldusertype_and_takeownership (lua_State* L, int lo, int index, void* v, const char* type)
+{
+ lua_pushnumber(L,index);
+ tolua_pushusertype(L,v,type);
+	tolua_register_gc(L,lua_gettop(L));
+ lua_settable(L,lo);
+}
+
Index: /code/branches/ceguilua/src/tolua/tolua_to.c
===================================================================
--- /code/branches/ceguilua/src/tolua/tolua_to.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/tolua_to.c	(revision 1801)
@@ -0,0 +1,133 @@
+/* tolua: funcitons to convert to C types
+** Support code for Lua bindings.
+** Written by Waldemar Celes
+** TeCGraf/PUC-Rio
+** 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.
+*/
+
+#include "tolua++.h"
+
+#include <string.h>
+#include <stdlib.h>
+
+TOLUA_API double tolua_tonumber (lua_State* L, int narg, double def)
+{
+ return lua_gettop(L)<abs(narg) ? def : lua_tonumber(L,narg);
+}
+
+TOLUA_API const char* tolua_tostring (lua_State* L, int narg, const char* def)
+{
+ return lua_gettop(L)<abs(narg) ? def : lua_tostring(L,narg);
+}
+
+TOLUA_API void* tolua_touserdata (lua_State* L, int narg, void* def)
+{
+	
+	/* return lua_gettop(L)<abs(narg) ? def : lua_touserdata(L,narg); */
+
+	if (lua_gettop(L)<abs(narg)) {
+ 		return def;
+	};
+	 
+	if (lua_islightuserdata(L, narg)) {
+	
+		return lua_touserdata(L,narg);
+	};
+	
+	return tolua_tousertype(L, narg, def);
+}
+
+extern int push_table_instance(lua_State* L, int lo);
+
+TOLUA_API void* tolua_tousertype (lua_State* L, int narg, void* def)
+{
+ if (lua_gettop(L)<abs(narg))
+  return def;
+ else
+ {
+  void* u;
+  if (!lua_isuserdata(L, narg)) {
+	  if (!push_table_instance(L, narg)) return NULL;
+  };
+  u = lua_touserdata(L,narg);
+  return (u==NULL) ? NULL : *((void**)u); /* nil represents NULL */
+ }
+}
+
+TOLUA_API int tolua_tovalue (lua_State* L, int narg, int def)
+{
+ return lua_gettop(L)<abs(narg) ? def : narg;
+}
+
+TOLUA_API int tolua_toboolean (lua_State* L, int narg, int def)
+{
+ return lua_gettop(L)<abs(narg) ?  def : lua_toboolean(L,narg);
+}
+
+TOLUA_API double tolua_tofieldnumber (lua_State* L, int lo, int index, double def)
+{
+ double v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lua_tonumber(L,-1);
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API const char* tolua_tofieldstring
+(lua_State* L, int lo, int index, const char* def)
+{
+ const char* v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lua_tostring(L,-1);
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API void* tolua_tofielduserdata (lua_State* L, int lo, int index, void* def)
+{
+ void* v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lua_touserdata(L,-1);
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API void* tolua_tofieldusertype (lua_State* L, int lo, int index, void* def)
+{
+ void* v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : (*(void **)(lua_touserdata(L, -1))); /* lua_unboxpointer(L,-1); */
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API int tolua_tofieldvalue (lua_State* L, int lo, int index, int def)
+{
+ int v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? def : lo;
+ lua_pop(L,1);
+ return v;
+}
+
+TOLUA_API int tolua_getfieldboolean (lua_State* L, int lo, int index, int def)
+{
+ int v;
+ lua_pushnumber(L,index);
+ lua_gettable(L,lo);
+ v = lua_isnil(L,-1) ? 0 : lua_toboolean(L,-1);
+ lua_pop(L,1);
+ return v;
+}
Index: /code/branches/ceguilua/src/tolua/toluabind.c
===================================================================
--- /code/branches/ceguilua/src/tolua/toluabind.c	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/toluabind.c	(revision 1801)
@@ -0,0 +1,7628 @@
+/*
+** Lua binding: tolua
+** Generated automatically by tolua++-1.0.91 on Wed Apr 26 22:30:14 2006.
+*/
+
+#ifndef __cplusplus
+#include "stdlib.h"
+#endif
+#include "string.h"
+
+#include "tolua++.h"
+
+/* Exported function */
+int  tolua_tolua_open (lua_State* tolua_S);
+
+
+/* function to register type */
+static void tolua_reg_types (lua_State* tolua_S)
+{
+}
+
+/* Open function */
+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[] = {
+   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, 13, 10,  9,114,101,116,117,114,
+    110, 13, 10,101,110,100, 13, 10, 13, 10, 45, 45, 32, 34,108,
+    111, 97,100,102,105,108,101, 34, 13, 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, 13, 10, 13, 10,  9,
+    108,111, 99, 97,108, 32,108,111, 97,100,101,100, 32, 61, 32,
+    102, 97,108,115,101, 13, 10,  9,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, 13, 10, 13, 10,  9,  9,105,102, 32,108,111,
+     97,100,101,100, 32,116,104,101,110, 13, 10,  9,  9,  9,114,
+    101,116,117,114,110, 13, 10,  9,  9,101,108,115,101, 13, 10,
+      9,  9,  9,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, 13, 10,  9,  9,  9,105,102, 32,110,111,116, 32,
+    102,105,108,101, 32,116,104,101,110, 13, 10,  9,  9,  9,  9,
+    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,
+     13, 10,  9,  9,  9,101,110,100, 13, 10,  9,  9,  9,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, 13, 10,  9,  9,  9,
+    102,105,108,101, 58, 99,108,111,115,101, 40, 41, 13, 10, 13,
+     10,  9,  9,  9,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, 13, 10,
+     13, 10,  9,  9,  9,108,111, 97,100,101,100, 32, 61, 32,116,
+    114,117,101, 13, 10,  9,  9,  9,114,101,116,117,114,110, 32,
+    114,101,116, 13, 10,  9,  9,101,110,100, 13, 10,  9,101,110,
+    100, 13, 10, 13, 10,  9,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, 13, 10,  9,114,101,116,117,114,110, 32,
+    102, 40, 41, 13, 10,101,110,100, 13, 10, 13, 10,111,108,100,
+     95,100,111,102,105,108,101, 32, 61, 32,100,111,102,105,108,
+    101, 13, 10,100,111,102,105,108,101, 32, 61, 32,112,112, 95,
+    100,111,102,105,108,101, 13, 10, 13, 10, 13, 10, 45, 45, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 13, 10, 45, 45,
+     91, 91, 13, 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, 13,
+     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, 13, 10, 32, 32,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, 13, 10, 32, 32, 32, 32,108,111, 99,
+     97,108, 32,111, 99, 32, 61, 32, 99, 13, 10, 32, 32, 32, 32,
+     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, 13, 10,
+     32, 32,101,110,100, 13, 10, 32, 32,114,101,116,117,114,110,
+     32,111,103,115,117, 98, 40, 97, 44, 98, 44, 99, 44,100, 41,
+     13, 10,101,110,100, 13, 10,115,116,114,105,110,103, 46,114,
+    101,112,108, 32, 61, 32,111,103,115,117, 98, 13, 10, 45, 45,
+     93, 93, 13, 10, 13, 10, 45, 45,115,116,114,105,110,103, 46,
+    103,115,117, 98, 32, 61, 32, 99,111,109,112,103,115,117, 98,
+     13,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 82,101, 97,108,
+     32,103,108,111, 98, 97,108,115, 10, 45, 45, 32, 95, 65, 76,
+     69, 82, 84, 10, 45, 45, 32, 95, 69, 82, 82, 79, 82, 77, 69,
+     83, 83, 65, 71, 69, 10, 45, 45, 32, 95, 86, 69, 82, 83, 73,
+     79, 78, 10, 45, 45, 32, 95, 71, 10, 45, 45, 32, 97,115,115,
+    101,114,116, 10, 45, 45, 32,101,114,114,111,114, 10, 45, 45,
+     32,109,101,116, 97,116, 97, 98,108,101, 10, 45, 45, 32,110,
+    101,120,116, 10, 45, 45, 32,112,114,105,110,116, 10, 45, 45,
+     32,114,101,113,117,105,114,101, 10, 45, 45, 32,116,111,110,
+    117,109, 98,101,114, 10, 45, 45, 32,116,111,115,116,114,105,
+    110,103, 10, 45, 45, 32,116,121,112,101, 10, 45, 45, 32,117,
+    110,112, 97, 99,107, 10, 10, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
+     45, 45, 32, 99,111,108,108,101, 99,116,103, 97,114, 98, 97,
+    103,101, 10, 45, 45, 32,103, 99,105,110,102,111, 10, 10, 45,
+     45, 32,103,108,111, 98, 97,108,115, 10, 10, 45, 45, 32, 99,
+     97,108,108, 32, 32, 32, 45, 62, 32,112,114,111,116,101, 99,
+    116, 40,102, 44, 32,101,114,114, 41, 10, 45, 45, 32,108,111,
+     97,100,102,105,108,101, 10, 45, 45, 32,108,111, 97,100,115,
+    116,114,105,110,103, 10, 10, 45, 45, 32,114, 97,119,103,101,
+    116, 10, 45, 45, 32,114, 97,119,115,101,116, 10, 10, 45, 45,
+     32,103,101,116, 97,114,103,115, 32, 61, 32, 77, 97,105,110,
+     46,103,101,116, 97,114,103,115, 32, 63, 63, 10, 10,114, 97,
+    119,116,121,112,101, 32, 61, 32,116,121,112,101, 10, 10,102,
+    117,110, 99,116,105,111,110, 32,100,111, 95, 32, 40,102, 44,
+     32,101,114,114, 41, 10, 32, 32,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,
+     32, 32,108,111, 99, 97,108, 32, 97, 44, 98, 32, 61, 32,112,
+     99, 97,108,108, 40,102, 41, 10, 32, 32,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,
+     32, 32,101,108,115,101, 32,114,101,116,117,114,110, 32, 98,
+     32,111,114, 32,116,114,117,101, 10, 32, 32,101,110,100, 10,
+    101,110,100, 10, 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, 45, 45, 32,102,
+    117,110, 99,116,105,111,110, 32,100,111,102,105,108,101, 40,
+    115, 41, 32,114,101,116,117,114,110, 32,100,111, 95, 40,108,
+    111, 97,100,102,105,108,101, 40,115, 41, 41, 32,101,110,100,
+     10, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 84, 97,
+     98,108,101, 32,108,105, 98,114, 97,114,121, 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,
+     10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45, 32, 68,101, 98,
+    117,103, 32,108,105, 98,114, 97,114,121, 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, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 45, 45,
+     32,109, 97,116,104, 32,108,105, 98,114, 97,114,121, 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, 45, 45, 63, 63, 63, 32,112,111,
+    119, 32, 61, 32,109, 97,116,104, 46,112,111,119, 32, 32, 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, 10, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
+     45, 45, 32,115,116,114,105,110,103, 32,108,105, 98,114, 97,
+    114,121, 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, 10, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 10, 45, 45, 32,111,115, 32,108,105,
+     98,114, 97,114,121, 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, 32, 45, 45, 63, 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, 10, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 10, 45, 45, 32, 99,111,109,112, 97,116,105, 98,105,
+    108,105,116,121, 32,111,110,108,121, 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, 10, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 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, 10, 45, 45, 32, 73, 79,
+     32,108,105, 98,114, 97,114,121, 32, 40,102,105,108,101,115,
+     41, 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, 32, 32,
+     32, 45, 45, 32,115,105, 99,107, 32, 59, 45, 41, 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, 10,
+    102,117,110, 99,116,105,111,110, 32,102,108,117,115,104, 32,
+     40,102, 41, 10, 32, 32,105,102, 32,102, 32,116,104,101,110,
+     32,102, 58,102,108,117,115,104, 40, 41, 10, 32, 32,101,108,
+    115,101, 32, 95, 79, 85, 84, 80, 85, 84, 58,102,108,117,115,
+    104, 40, 41, 10, 32, 32,101,110,100, 10,101,110,100, 10, 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, 32, 32,105,102, 32,
+    110, 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,101,
+    110, 10, 32, 32, 32, 32,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, 32, 32,
+     32, 32, 95, 73, 78, 80, 85, 84, 32, 61, 32,105,111, 46,115,
+    116,100,105,110, 10, 32, 32, 32, 32,114,101,116,117,114,110,
+     32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, 32, 32,
+    101,108,115,101, 10, 32, 32, 32, 32,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, 32, 32, 32, 32, 95, 73, 78, 80, 85, 84, 32, 61,
+     32,102, 32,111,114, 32, 95, 73, 78, 80, 85, 84, 10, 32, 32,
+     32, 32,114,101,116,117,114,110, 32,102, 44, 32,101,114,114,
+     44, 32, 99,111,100, 10, 32, 32,101,110,100, 10,101,110,100,
+     10, 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, 32, 32,105,102,
+     32,110, 97,109,101, 32, 61, 61, 32,110,105,108, 32,116,104,
+    101,110, 10, 32, 32, 32, 32,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,
+     32, 32, 32, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,105,
+    111, 46,115,116,100,111,117,116, 10, 32, 32, 32, 32,114,101,
+    116,117,114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,
+    100, 10, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,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, 32, 32, 32, 32, 95, 79, 85, 84,
+     80, 85, 84, 32, 61, 32,102, 32,111,114, 32, 95, 79, 85, 84,
+     80, 85, 84, 10, 32, 32, 32, 32,114,101,116,117,114,110, 32,
+    102, 44, 32,101,114,114, 44, 32, 99,111,100, 10, 32, 32,101,
+    110,100, 10,101,110,100, 10, 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, 32, 32,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, 32,
+     32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,102, 32,111,114,
+     32, 95, 79, 85, 84, 80, 85, 84, 10, 32, 32,114,101,116,117,
+    114,110, 32,102, 44, 32,101,114,114, 44, 32, 99,111,100, 10,
+    101,110,100, 10, 10,102,117,110, 99,116,105,111,110, 32,114,
+    101, 97,100, 32, 40, 46, 46, 46, 41, 10, 32, 32,108,111, 99,
+     97,108, 32,102, 32, 61, 32, 95, 73, 78, 80, 85, 84, 10, 32,
+     32,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, 32, 32, 32, 32,102, 32,
+     61, 32,116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,
+    103, 44, 32, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,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,
+     10,102,117,110, 99,116,105,111,110, 32,119,114,105,116,101,
+     32, 40, 46, 46, 46, 41, 10, 32, 32,108,111, 99, 97,108, 32,
+    102, 32, 61, 32, 95, 79, 85, 84, 80, 85, 84, 10, 32, 32,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, 32, 32, 32, 32,102, 32, 61, 32,
+    116, 97, 98, 46,114,101,109,111,118,101, 40, 97,114,103, 44,
+     32, 49, 41, 10, 32, 32,101,110,100, 10, 32, 32,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 98, 97,115,105, 99,
+     32,117,116,105,108,105,116,121, 32,102,117,110, 99,116,105,
+    111,110,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, 32,
+     98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,108,
+    101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, 80,
+     85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, 49,
+     57, 57, 56, 10, 45, 45, 32, 76, 97,115,116, 32,117,112,100,
+     97,116,101, 58, 32, 65,112,114, 32, 50, 48, 48, 51, 10, 45,
+     45, 32, 36, 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,
+    105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101,
+     32,115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32,
+     99, 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,
+    101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,
+    105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,
+    115,111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,
+    101,100, 32,104,101,114,101,117,110,100,101,114, 32,105,115,
+     32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32,
+     98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,
+    104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,
+    111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111,
+     32,112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,
+    110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44,
+     32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,
+    104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,
+    109,111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10,
+     10, 10, 45, 45, 32, 66, 97,115,105, 99, 32, 67, 32,116,121,
+    112,101,115, 32, 97,110,100, 32,116,104,101,105,114, 32, 99,
+    111,114,114,101,115,112,111,110,100,105,110,103, 32, 76,117,
+     97, 32,116,121,112,101,115, 10, 45, 45, 32, 65,108,108, 32,
+    111, 99, 99,117,114,114,101,110, 99,101,115, 32,111,102, 32,
+     34, 99,104, 97,114, 42, 34, 32,119,105,108,108, 32, 98,101,
+     32,114,101,112,108, 97, 99,101,100, 32, 98,121, 32, 34, 95,
+     99,115,116,114,105,110,103, 34, 44, 10, 45, 45, 32, 97,110,
+    100, 32, 97,108,108, 32,111, 99, 99,117,114,114,101,110, 99,
+    101,115, 32,111,102, 32, 34,118,111,105,100, 42, 34, 32,119,
+    105,108,108, 32, 98,101, 32,114,101,112,108, 97, 99,101,100,
+     32, 98,121, 32, 34, 95,117,115,101,114,100, 97,116, 97, 34,
+     10, 95, 98, 97,115,105, 99, 32, 61, 32,123, 10, 32, 91, 39,
+    118,111,105,100, 39, 93, 32, 61, 32, 39, 39, 44, 10, 32, 91,
+     39, 99,104, 97,114, 39, 93, 32, 61, 32, 39,110,117,109, 98,
+    101,114, 39, 44, 10, 32, 91, 39,105,110,116, 39, 93, 32, 61,
+     32, 39,110,117,109, 98,101,114, 39, 44, 10, 32, 91, 39,115,
+    104,111,114,116, 39, 93, 32, 61, 32, 39,110,117,109, 98,101,
+    114, 39, 44, 10, 32, 91, 39,108,111,110,103, 39, 93, 32, 61,
+     32, 39,110,117,109, 98,101,114, 39, 44, 10, 32, 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, 32, 91, 39,102,108,111, 97,116,
+     39, 93, 32, 61, 32, 39,110,117,109, 98,101,114, 39, 44, 10,
+     32, 91, 39,100,111,117, 98,108,101, 39, 93, 32, 61, 32, 39,
+    110,117,109, 98,101,114, 39, 44, 10, 32, 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, 32, 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, 32, 91, 39, 99,104, 97,114, 42, 39, 93, 32,
+     61, 32, 39,115,116,114,105,110,103, 39, 44, 10, 32, 91, 39,
+    118,111,105,100, 42, 39, 93, 32, 61, 32, 39,117,115,101,114,
+    100, 97,116, 97, 39, 44, 10, 32, 91, 39, 98,111,111,108, 39,
+     93, 32, 61, 32, 39, 98,111,111,108,101, 97,110, 39, 44, 10,
+     32, 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, 32, 91, 39,
+     76, 85, 65, 95, 86, 65, 76, 85, 69, 39, 93, 32, 61, 32, 39,
+    118, 97,108,117,101, 39, 44, 32, 32, 32, 32, 45, 45, 32,102,
+    111,114, 32, 99,111,109,112, 97,116,105, 98,105,108,105,116,
+    121, 32,119,105,116,104, 32,116,111,108,117, 97, 32, 52, 46,
+     48, 10, 32, 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, 32,
+     91, 39, 95,108,115,116, 97,116,101, 39, 93, 32, 61, 32, 39,
+    115,116, 97,116,101, 39, 44, 10, 32, 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, 10, 95, 98, 97,115,105,
+     99, 95, 99,116,121,112,101, 32, 61, 32,123, 10, 32,110,117,
+    109, 98,101,114, 32, 61, 32, 34,108,117, 97, 95, 78,117,109,
+     98,101,114, 34, 44, 10, 32,115,116,114,105,110,103, 32, 61,
+     32, 34, 99,111,110,115,116, 32, 99,104, 97,114, 42, 34, 44,
+     10, 32,117,115,101,114,100, 97,116, 97, 32, 61, 32, 34,118,
+    111,105,100, 42, 34, 44, 10, 32, 98,111,111,108,101, 97,110,
+     32, 61, 32, 34, 98,111,111,108, 34, 44, 10, 32,118, 97,108,
+    117,101, 32, 61, 32, 34,105,110,116, 34, 44, 10, 32,115,116,
+     97,116,101, 32, 61, 32, 34,108,117, 97, 95, 83,116, 97,116,
+    101, 42, 34, 44, 10,125, 10, 10, 45, 45, 32,102,117,110, 99,
+    116,105,111,110,115, 32,116,104,101, 32, 97,114,101, 32,117,
+    115,101,100, 32,116,111, 32,100,111, 32, 97, 32, 39,114, 97,
+    119, 32,112,117,115,104, 39, 32,111,102, 32, 98, 97,115,105,
+     99, 32,116,121,112,101,115, 10, 95, 98, 97,115,105, 99, 95,
+    114, 97,119, 95,112,117,115,104, 32, 61, 32,123,125, 10, 10,
+     45, 45, 32, 76,105,115,116, 32,111,102, 32,117,115,101,114,
+     32,100,101,102,105,110,101,100, 32,116,121,112,101,115, 10,
+     45, 45, 32, 69, 97, 99,104, 32,116,121,112,101, 32, 99,111,
+    114,114,101,115,112,111,110,100,115, 32,116,111, 32, 97, 32,
+    118, 97,114,105, 97, 98,108,101, 32,110, 97,109,101, 32,116,
+    104, 97,116, 32,115,116,111,114,101,115, 32,105,116,115, 32,
+    116, 97,103, 32,118, 97,108,117,101, 46, 10, 95,117,115,101,
+    114,116,121,112,101, 32, 61, 32,123,125, 10, 10, 45, 45, 32,
+     76,105,115,116, 32,111,102, 32,116,121,112,101,115, 32,116,
+    104, 97,116, 32,104, 97,118,101, 32,116,111, 32, 98,101, 32,
+     99,111,108,108,101, 99,116,101,100, 10, 95, 99,111,108,108,
+    101, 99,116, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,105,
+    115,116, 32,111,102, 32,116,121,112,101,115, 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, 10, 45,
+     45, 32,108,105,115,116, 32,111,102, 32, 99,108, 97,115,115,
+    101,115, 10, 95,103,108,111, 98, 97,108, 95, 99,108, 97,115,
+    115,101,115, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,105,
+    115,116, 32,111,102, 32,101,110,117,109, 32, 99,111,110,115,
+    116, 97,110,116,115, 10, 95,103,108,111, 98, 97,108, 95,101,
+    110,117,109,115, 32, 61, 32,123,125, 10, 10, 45, 45, 32, 76,
+    105,115,116, 32,111,102, 32, 97,117,116,111, 32,114,101,110,
+     97,109,105,110,103, 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, 32,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,  9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110,
+     10,  9, 32,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,  9,101,110,100, 10,  9,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, 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,  9,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,  9, 32,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,
+      9,  9,105,102, 32,110, 32,126, 61, 32, 48, 32,116,104,101,
+    110, 10,  9,  9, 32,114,101,116,117,114,110, 32,109, 10,  9,
+      9,101,110,100, 10,  9,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32,110,105,108, 10,101,110,100, 10, 10, 45, 45, 32,
+     69,114,114,111,114, 32,104, 97,110,100,108,101,114, 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,
+      9,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,  9,
+    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, 32,
+    108,111, 99, 97,108, 32,111,117,116, 32, 61, 32, 95, 79, 85,
+     84, 80, 85, 84, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61,
+     32, 95, 83, 84, 68, 69, 82, 82, 10, 32,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, 32, 32,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, 32, 32,105,102, 32,
+     95, 99,117,114,114, 95, 99,111,100,101, 32,116,104,101,110,
+     10, 32, 32, 32,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, 32, 45, 45, 32,101,120,116,114, 97, 99,
+    116, 32,102,105,114,115,116, 32,108,105,110,101, 10, 32, 32,
+     32,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, 32, 32, 32,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, 32, 45, 45, 32,114,101,
+    116,117,114,110, 32,119,105,116,104, 32, 39,118,111,105,100,
+     42, 39, 10, 32, 32, 32,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, 32, 32, 45, 45, 32,114,101,116,117,
+    114,110, 32,119,105,116,104, 32, 39, 99,104, 97,114, 42, 39,
+     10, 32, 32, 32,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, 32, 32, 45, 45, 32,114,101,
+    116,117,114,110, 32,119,105,116,104, 32, 39,108,117, 97, 95,
+     83,116, 97,116,101, 42, 39, 10, 32, 32, 32,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, 32, 32,101,110,100, 10, 32,
+    101,108,115,101, 10, 32,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, 32, 32,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, 32, 32,114,101,116,117,114,110, 10, 32,
+    101,110,100, 10, 32, 95, 79, 85, 84, 80, 85, 84, 32, 61, 32,
+    111,117,116, 10,101,110,100, 10, 10,102,117,110, 99,116,105,
+    111,110, 32,119, 97,114,110,105,110,103, 32, 40,109,115,103,
+     41, 10, 32,108,111, 99, 97,108, 32,111,117,116, 32, 61, 32,
+     95, 79, 85, 84, 80, 85, 84, 10, 32, 95, 79, 85, 84, 80, 85,
+     84, 32, 61, 32, 95, 83, 84, 68, 69, 82, 82, 10, 32,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, 32, 95, 79,
+     85, 84, 80, 85, 84, 32, 61, 32,111,117,116, 10,101,110,100,
+     10, 10, 45, 45, 32,114,101,103,105,115,116,101,114, 32, 97,
+    110, 32,117,115,101,114, 32,100,101,102,105,110,101,100, 32,
+    116,121,112,101, 58, 32,114,101,116,117,114,110,115, 32,102,
+    117,108,108, 32,116,121,112,101, 10,102,117,110, 99,116,105,
+    111,110, 32,114,101,103,116,121,112,101, 32, 40,116, 41, 10,
+      9, 45, 45,105,102, 32,105,115, 98, 97,115,105, 99, 40,116,
+     41, 32,116,104,101,110, 10,  9, 45, 45,  9,114,101,116,117,
+    114,110, 32,116, 10,  9, 45, 45,101,110,100, 10,  9,108,111,
+     99, 97,108, 32,102,116, 32, 61, 32,102,105,110,100,116,121,
+    112,101, 40,116, 41, 10, 10,  9,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,  9,  9,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,  9,101,110,100, 10,  9,114,101,116,117,114,110, 32,102,
+    116, 10,101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,
+    110, 32,116,121,112,101, 32,110, 97,109,101, 58, 32,114,101,
+    116,117,114,110,115, 32,102,117,108,108, 32,116,121,112,101,
+     10,102,117,110, 99,116,105,111,110, 32,116,121,112,101,118,
+     97,114, 40,116,121,112,101, 41, 10,  9,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,  9,  9,114,101,116,117,114,110, 32,116,121,112,101,
+     10,  9,101,108,115,101, 10,  9,  9,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,  9,  9,105,102, 32,102,116, 32,116,104,
+    101,110, 10,  9,  9,  9,114,101,116,117,114,110, 32,102,116,
+     10,  9,  9,101,110,100, 10,  9,  9, 95,117,115,101,114,116,
+    121,112,101, 91,116,121,112,101, 93, 32, 61, 32,116,121,112,
+    101, 10,  9,  9,114,101,116,117,114,110, 32,116,121,112,101,
+     10,  9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 99,
+    104,101, 99,107, 32,105,102, 32, 98, 97,115,105, 99, 32,116,
+    121,112,101, 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, 32,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, 32,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, 32,108,111, 99, 97,108, 32, 98, 32, 61,
+     32, 95, 98, 97,115,105, 99, 91,116, 93, 10, 32,105,102, 32,
+     98, 32,116,104,101,110, 10, 32, 32,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, 32,101,110,100, 10, 32,114,101,116,117,114,
+    110, 32,110,105,108, 10,101,110,100, 10, 10, 45, 45, 32,115,
+    112,108,105,116, 32,115,116,114,105,110,103, 32,117,115,105,
+    110,103, 32, 97, 32,116,111,107,101,110, 10,102,117,110, 99,
+    116,105,111,110, 32,115,112,108,105,116, 32, 40,115, 44,116,
+     41, 10, 32,108,111, 99, 97,108, 32,108, 32, 61, 32,123,110,
+     61, 48,125, 10, 32,108,111, 99, 97,108, 32,102, 32, 61, 32,
+    102,117,110, 99,116,105,111,110, 32, 40,115, 41, 10, 32, 32,
+    108, 46,110, 32, 61, 32,108, 46,110, 32, 43, 32, 49, 10, 32,
+     32,108, 91,108, 46,110, 93, 32, 61, 32,115, 10, 32, 32,114,
+    101,116,117,114,110, 32, 34, 34, 10, 32,101,110,100, 10, 32,
+    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, 32,115, 32, 61, 32,103,115,117, 98, 40,115, 44,
+     34, 94, 37,115, 43, 34, 44, 34, 34, 41, 10, 32,115, 32, 61,
+     32,103,115,117, 98, 40,115, 44, 34, 37,115, 43, 36, 34, 44,
+     34, 34, 41, 10, 32,115, 32, 61, 32,103,115,117, 98, 40,115,
+     44,112, 44,102, 41, 10, 32,108, 46,110, 32, 61, 32,108, 46,
+    110, 32, 43, 32, 49, 10, 32,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, 32,114,101,116,117,114,110,
+     32,108, 10,101,110,100, 10, 10, 45, 45, 32,115,112,108,105,
+    116,115, 32, 97, 32,115,116,114,105,110,103, 32,117,115,105,
+    110,103, 32, 97, 32,112, 97,116,116,101,114,110, 44, 32, 99,
+    111,110,115,105,100,101,114,105,110,103, 32,116,104,101, 32,
+    115,112, 97, 99,105, 97,108, 32, 99, 97,115,101,115, 32,111,
+    102, 32, 67, 32, 99,111,100,101, 32, 40,116,101,109,112,108,
+     97,116,101,115, 44, 32,102,117,110, 99,116,105,111,110, 32,
+    112, 97,114, 97,109,101,116,101,114,115, 44, 32,101,116, 99,
+     41, 10, 45, 45, 32,112, 97,116,116,101,114,110, 32, 99, 97,
+    110, 39,116, 32, 99,111,110,116, 97,105,110, 32,116,104,101,
+     32, 39, 94, 39, 32, 40, 97,115, 32,117,115,101,100, 32,116,
+    111, 32,105,100,101,110,116,105,102,121, 32,116,104,101, 32,
+     98,101,103,105,110,105,110,103, 32,111,102, 32,116,104,101,
+     32,108,105,110,101, 41, 10, 45, 45, 32, 97,108,115,111, 32,
+    115,116,114,105,112,115, 32,119,104,105,116,101,115,112, 97,
+     99,101, 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, 10,  9,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,  9,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, 10,  9,108,111, 99,
+     97,108, 32,116,111,107,101,110, 95, 98,101,103,105,110, 32,
+     61, 32, 49, 10,  9,108,111, 99, 97,108, 32,116,111,107,101,
+    110, 95,101,110,100, 32, 61, 32, 49, 10,  9,108,111, 99, 97,
+    108, 32,111,102,115, 32, 61, 32, 49, 10,  9,108,111, 99, 97,
+    108, 32,114,101,116, 32, 61, 32,123,110, 61, 48,125, 10, 10,
+      9,102,117,110, 99,116,105,111,110, 32, 97,100,100, 95,116,
+    111,107,101,110, 40,111,102,115, 41, 10, 10,  9,  9,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,  9,  9,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,  9,  9,
+    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,  9,  9,114,101,116, 46,110, 32, 61, 32,114,101,116, 46,
+    110, 32, 43, 32, 49, 10,  9,  9,114,101,116, 91,114,101,116,
+     46,110, 93, 32, 61, 32,116, 10,  9,101,110,100, 10, 10,  9,
+    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,
+     10,  9,  9,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,  9,  9,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,  9,  9,105,102, 32, 98, 32,116,104,101,110,
+     10,  9,  9,  9, 97,100,100, 95,116,111,107,101,110, 40,111,
+    102,115, 45, 49, 41, 10,  9,  9,  9,111,102,115, 32, 61, 32,
+    111,102,115, 43,101, 10,  9,  9,  9,116,111,107,101,110, 95,
+     98,101,103,105,110, 32, 61, 32,111,102,115, 10,  9,  9,101,
+    108,115,101, 10,  9,  9,  9,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,  9,
+      9,  9,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, 10,  9,  9,  9,  9,108,111, 99,
+     97,108, 32, 98,108,111, 99,107, 10,  9,  9,  9,  9,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,  9,  9,  9,  9,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, 10,  9,  9,  9,  9, 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,  9,  9,  9,
+      9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10,
+      9,  9,  9,  9,  9, 45, 45, 32,117,110,116,101,114,109,105,
+    110, 97,116,101,100, 32, 98,108,111, 99,107, 63, 10,  9,  9,
+      9,  9,  9,111,102,115, 32, 61, 32,111,102,115, 43, 49, 10,
+      9,  9,  9,  9,101,108,115,101, 10,  9,  9,  9,  9,  9,111,
+    102,115, 32, 61, 32,111,102,115, 32, 43, 32,101, 10,  9,  9,
+      9,  9,101,110,100, 10, 10,  9,  9,  9,101,108,115,101, 10,
+      9,  9,  9,  9,111,102,115, 32, 61, 32,111,102,115, 43, 49,
+     10,  9,  9,  9,101,110,100, 10,  9,  9,101,110,100, 10, 10,
+      9,101,110,100, 10,  9, 97,100,100, 95,116,111,107,101,110,
+     40,111,102,115, 41, 10,  9, 45, 45,105,102, 32,114,101,116,
+     46,110, 32, 61, 61, 32, 48, 32,116,104,101,110, 10, 10,  9,
+     45, 45,  9,114,101,116, 46,110, 61, 49, 10,  9, 45, 45,  9,
+    114,101,116, 91, 49, 93, 32, 61, 32, 34, 34, 10,  9, 45, 45,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,114,101,
+    116, 10, 10,101,110,100, 10, 10, 45, 45, 32, 99,111,110, 99,
+     97,116,101,110, 97,116,101, 32,115,116,114,105,110,103,115,
+     32,111,102, 32, 97, 32,116, 97, 98,108,101, 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,  9,106,115,116,
+    114, 32, 61, 32,106,115,116,114, 32,111,114, 32, 34, 32, 34,
+     10, 32,108,111, 99, 97,108, 32,115, 32, 61, 32, 39, 39, 10,
+     32,108,111, 99, 97,108, 32,105, 61,102, 10, 32,119,104,105,
+    108,101, 32,105, 60, 61,108, 32,100,111, 10, 32, 32,115, 32,
+     61, 32,115, 46, 46,116, 91,105, 93, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32, 32,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, 32,101,110,100, 10, 32,114,
+    101,116,117,114,110, 32,115, 10,101,110,100, 10, 10, 45, 45,
+     32, 99,111,110, 99, 97,116,101,110, 97,116,101, 32, 97,108,
+    108, 32,112, 97,114, 97,109,101,116,101,114,115, 44, 32,102,
+    111,108,108,111,119,105,110,103, 32,111,117,116,112,117,116,
+     32,114,117,108,101,115, 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, 32,108,111, 99, 97,
+    108, 32,105, 61, 49, 10, 32,119,104,105,108,101, 32,105, 60,
+     61, 97,114,103, 46,110, 32,100,111, 10, 32, 32,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, 32, 32, 32,
+     32, 32,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,  9, 32, 32, 32, 32,108,105,110,101, 32, 61, 32,
+    108,105,110,101, 32, 46, 46, 32, 39, 32, 39, 10, 32, 32,101,
+    110,100, 10, 32, 32,108,105,110,101, 32, 61, 32,108,105,110,
+    101, 32, 46, 46, 32, 97,114,103, 91,105, 93, 10, 32, 32,105,
+    102, 32, 97,114,103, 91,105, 93, 32,126, 61, 32, 39, 39, 32,
+    116,104,101,110, 10, 32, 32, 32, 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, 32, 32,101,110,100, 10, 32, 32,
+    105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,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, 32, 32,
+     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,
+     32,101,110,100, 10,  9,114,101,116,117,114,110, 32,108,105,
+    110,101, 10,101,110,100, 10, 10, 45, 45, 32,111,117,116,112,
+    117,116, 32,108,105,110,101, 10,102,117,110, 99,116,105,111,
+    110, 32,111,117,116,112,117,116, 32, 40, 46, 46, 46, 41, 10,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,
+    108,101, 32,105, 60, 61, 97,114,103, 46,110, 32,100,111, 10,
+     32, 32,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, 32, 32, 32, 32, 32,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,  9, 32, 32, 32, 32,119,114,
+    105,116,101, 40, 39, 32, 39, 41, 10, 32, 32,101,110,100, 10,
+     32, 32,119,114,105,116,101, 40, 97,114,103, 91,105, 93, 41,
+     10, 32, 32,105,102, 32, 97,114,103, 91,105, 93, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10, 32, 32, 32, 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, 32, 32,101,110,
+    100, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,
+    100, 10, 32,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, 32, 32, 95, 99,111,110,116, 61,110,105,108, 32,119,
+    114,105,116,101, 40, 39, 92,110, 39, 41, 10, 32,101,110,100,
+     10,101,110,100, 10, 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, 10,  9,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,  9,  9,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,  9,101,110,100, 10,
+     10,  9,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, 32, 45,
+     45, 32,103,101,116, 95,110, 97,109,101, 44, 32,115,101,116,
+     95,110, 97,109,101, 10,  9,  9,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,  9,101,110,
+    100, 10, 10,  9,105,102, 32,112,116,121,112,101, 32, 61, 61,
+     32, 34,113,116, 34, 32,116,104,101,110, 32, 45, 45, 32,110,
+     97,109,101, 44, 32,115,101,116, 78, 97,109,101, 10,  9,  9,
+    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,  9,101,110,100, 10, 10,  9,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, 32, 45, 45, 32,
+    110, 97,109,101, 44, 32,110, 97,109,101, 10,  9,  9,114,101,
+    116,117,114,110, 32,110, 97,109,101, 44,110, 97,109,101, 10,
+      9,101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,110,
+    105,108, 10,101,110,100, 10, 10, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 32,116,104,101, 32,104,111,111,
+    107,115, 10, 10, 45, 45, 32, 99, 97,108,108,101,100, 32,114,
+    105,103,104,116, 32, 97,102,116,101,114, 32,112,114,111, 99,
+    101,115,115,105,110,103, 32,116,104,101, 32, 36, 91,105, 99,
+    104,108, 93,102,105,108,101, 32,100,105,114,101, 99,116,105,
+    118,101,115, 44, 10, 45, 45, 32,114,105,103,104,116, 32, 98,
+    101,102,111,114,101, 32,112,114,111, 99,101,115,115,105,110,
+    103, 32, 97,110,121,116,104,105,110,103, 32,101,108,115,101,
+     10, 45, 45, 32,116, 97,107,101,115, 32,116,104,101, 32,112,
+     97, 99,107, 97,103,101, 32,111, 98,106,101, 99,116, 32, 97,
+    115, 32,116,104,101, 32,112, 97,114, 97,109,101,116,101,114,
+     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,  9,
+     45, 45, 32,112, 46, 99,111,100,101, 32,104, 97,115, 32, 97,
+    108,108, 32,116,104,101, 32,105,110,112,117,116, 32, 99,111,
+    100,101, 32,102,114,111,109, 32,116,104,101, 32,112,107,103,
+     10,101,110,100, 10, 10, 10, 45, 45, 32, 99, 97,108,108,101,
+    100, 32,102,111,114, 32,101,118,101,114,121, 32, 36,105,102,
+    105,108,101, 32,100,105,114,101, 99,116,105,118,101, 10, 45,
+     45, 32,116, 97,107,101,115, 32, 97, 32,116, 97, 98,108,101,
+     32,119,105,116,104, 32, 97, 32,115,116,114,105,110,103, 32,
+     99, 97,108,108,101,100, 32, 39, 99,111,100,101, 39, 32,105,
+    110,115,105,100,101, 44, 32,116,104,101, 32,102,105,108,101,
+    110, 97,109,101, 44, 32, 97,110,100, 32, 97,110,121, 32,101,
+    120,116,114, 97, 32, 97,114,103,117,109,101,110,116,115, 10,
+     45, 45, 32,112, 97,115,115,101,100, 32,116,111, 32, 36,105,
+    102,105,108,101, 46, 32,110,111, 32,114,101,116,117,114,110,
+     32,118, 97,108,117,101, 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, 10,101,110,100, 10, 10, 45, 45,
+     32, 99, 97,108,108,101,100, 32, 97,102,116,101,114, 32,112,
+    114,111, 99,101,115,115,105,110,103, 32, 97,110,121,116,104,
+    105,110,103, 32,116,104, 97,116, 39,115, 32,110,111,116, 32,
+     99,111,100,101, 32, 40,108,105,107,101, 32, 39, 36,114,101,
+    110, 97,109,105,110,103, 39, 44, 32, 99,111,109,109,101,110,
+    116,115, 44, 32,101,116, 99, 41, 10, 45, 45, 32, 97,110,100,
+     32,114,105,103,104,116, 32, 98,101,102,111,114,101, 32,112,
+     97,114,115,105,110,103, 32,116,104,101, 32, 97, 99,116,117,
+     97,108, 32, 99,111,100,101, 46, 10, 45, 45, 32,116, 97,107,
+    101,115, 32,116,104,101, 32, 80, 97, 99,107, 97,103,101, 32,
+    111, 98,106,101, 99,116, 32,119,105,116,104, 32, 97,108,108,
+     32,116,104,101, 32, 99,111,100,101, 32,111,110, 32,116,104,
+    101, 32, 39, 99,111,100,101, 39, 32,107,101,121, 46, 32,110,
+    111, 32,114,101,116,117,114,110, 32,118, 97,108,117,101, 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, 10,101,110,100, 10, 10, 10, 45, 45, 32, 99, 97,108,
+    108,101,100, 32, 97,102,116,101,114, 32,119,114,105,116,105,
+    110,103, 32, 97,108,108, 32,116,104,101, 32,111,117,116,112,
+    117,116, 46, 10, 45, 45, 32,116, 97,107,101,115, 32,116,104,
+    101, 32, 80, 97, 99,107, 97,103,101, 32,111, 98,106,101, 99,
+    116, 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, 10,101,110,100, 10, 10, 10, 45,
+     45, 32, 99, 97,108,108,101,100, 32,102,114,111,109, 32, 39,
+    103,101,116, 95,112,114,111,112,101,114,116,121, 95,109,101,
+    116,104,111,100,115, 39, 32,116,111, 32,103,101,116, 32,116,
+    104,101, 32,109,101,116,104,111,100,115, 32,116,111, 32,114,
+    101,116,114,105,101,118,101, 32, 97, 32,112,114,111,112,101,
+    114,116,121, 10, 45, 45, 32, 97, 99, 99,111,114,100,105,110,
+    103, 32,116,111, 32,105,116,115, 32,116,121,112,101, 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, 10,101,110,100, 10,
+     10, 45, 45, 32, 99, 97,108,108,101,100, 32,102,114,111,109,
+     32, 67,108, 97,115,115, 67,111,110,116, 97,105,110,101,114,
+     58,100,111,112, 97,114,115,101, 32,119,105,116,104, 32,116,
+    104,101, 32,115,116,114,105,110,103, 32, 98,101,105,110,103,
+     32,112, 97,114,115,101,100, 10, 45, 45, 32,114,101,116,117,
+    114,110, 32,110,105,108, 44, 32,111,114, 32, 97, 32,115,117,
+     98,115,116,114,105,110,103, 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, 10,  9,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 97, 98,115,116,114,
+     97, 99,116, 32,102,101, 97,116,117,114,101, 32, 99,108, 97,
+    115,115, 10, 45, 45, 32, 87,114,105,116,116,101,110, 32, 98,
+    121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,108,101,
+    115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47, 80, 85,
+     67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32, 49, 57,
+     57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10, 10, 45,
+     45, 32, 84,104,105,115, 32, 99,111,100,101, 32,105,115, 32,
+    102,114,101,101, 32,115,111,102,116,119, 97,114,101, 59, 32,
+    121,111,117, 32, 99, 97,110, 32,114,101,100,105,115,116,114,
+    105, 98,117,116,101, 32,105,116, 32, 97,110,100, 47,111,114,
+     32,109,111,100,105,102,121, 32,105,116, 46, 10, 45, 45, 32,
+     84,104,101, 32,115,111,102,116,119, 97,114,101, 32,112,114,
+    111,118,105,100,101,100, 32,104,101,114,101,117,110,100,101,
+    114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, 97,115, 32,
+    105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,110,100, 10,
+     45, 45, 32,116,104,101, 32, 97,117,116,104,111,114, 32,104,
+     97,115, 32,110,111, 32,111, 98,108,105,103, 97,116,105,111,
+    110, 32,116,111, 32,112,114,111,118,105,100,101, 32,109, 97,
+    105,110,116,101,110, 97,110, 99,101, 44, 32,115,117,112,112,
+    111,114,116, 44, 32,117,112,100, 97,116,101,115, 44, 10, 45,
+     45, 32,101,110,104, 97,110, 99,101,109,101,110,116,115, 44,
+     32,111,114, 32,109,111,100,105,102,105, 99, 97,116,105,111,
+    110,115, 46, 10, 10, 10, 45, 45, 32, 70,101, 97,116,117,114,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,
+    101,115,101,110,116,115, 32,116,104,101, 32, 98, 97,115,101,
+     32, 99,108, 97,115,115, 32,111,102, 32, 97,108,108, 32,109,
+     97,112,112,101,100, 32,102,101, 97,116,117,114,101, 46, 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, 10, 45, 45, 32,119,
+    114,105,116,101, 32,115,117,112,112,111,114,116, 32, 99,111,
+    100,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, 10, 45, 45, 32,111,
+    117,116,112,117,116, 32,116, 97,103, 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, 10, 45, 45, 32,114,101,103,105,115,116,101,114,
+     32,102,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,114,101,103,105,115,116,101,114, 32, 40,112,114,101, 41,
+     10,101,110,100, 10, 10, 45, 45, 32,116,114, 97,110,115,108,
+     97,116,101, 32,118,101,114, 98, 97,116,105,109, 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, 10, 45, 45, 32, 99,104,101, 99,107,
+     32,105,102, 32,105,116, 32,105,115, 32, 97, 32,118, 97,114,
+    105, 97, 98,108,101, 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, 32,114,101,
+    116,117,114,110, 32,102, 97,108,115,101, 10,101,110,100, 10,
+     10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,105,116,
+     32,114,101,113,117,105,114,101,115, 32, 99,111,108,108,101,
+     99,116,105,111,110, 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, 32,114,101,116,117,114,110, 32,102, 97,
+    108,115,101, 10,101,110,100, 10, 10, 45, 45, 32, 98,117,105,
+    108,100, 32,110, 97,109,101,115, 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,
+     32,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, 32, 32,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, 32, 32,115,101,108,
+    102, 46,110, 97,109,101, 32, 61, 32,110, 91, 49, 93, 10, 32,
+     32,105,102, 32,110,111,116, 32,110, 91, 50, 93, 32,116,104,
+    101,110, 10, 32, 32, 32,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, 32, 32,101,110,100, 10, 32, 32,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, 32, 32,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, 32, 32,
+    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, 32,101,110,100, 10,
+     32,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,  9, 32,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, 32,101,110,100, 10, 10, 32,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, 32,
+    105,102, 32,112, 97,114,101,110,116, 32,116,104,101,110, 10,
+     32,  9,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, 32,101,108,
+    115,101, 10, 32,101,110,100, 10,101,110,100, 10, 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, 10,  9,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,  9,  9,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10,  9,101,110,100, 10,
+     10,  9,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,  9,119,104,105,108,101, 32,112,
+     97,114,101,110,116, 32,100,111, 10,  9,  9,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,  9,  9,  9,114,
+    101,116,117,114,110, 32,102, 97,108,115,101, 10,  9,  9,101,
+    110,100, 10,  9,  9,112, 97,114,101,110,116, 32, 61, 32,112,
+     97,114,101,110,116, 46,112,114,111,120, 10,  9,101,110,100,
+     10,  9,114,101,116,117,114,110, 32,116,114,117,101, 10,101,
+    110,100, 10, 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, 10,  9,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, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    102,101, 97,116,117,114,101, 32,105,115, 32,105,110,115,105,
+    100,101, 32, 97, 32, 99,111,110,116, 97,105,110,101,114, 32,
+    100,101,102,105,110,105,116,105,111,110, 10, 45, 45, 32,105,
+    116, 32,114,101,116,117,114,110,115, 32,116,104,101, 32, 99,
+    111,110,116, 97,105,110,101,114, 32, 99,108, 97,115,115, 32,
+    110, 97,109,101, 32,111,114, 32,110,105,108, 46, 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, 32,105,102, 32,115,
+    101,108,102, 46,112, 97,114,101,110,116, 32,116,104,101,110,
+     10, 32, 32,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,
+     32, 32,119,104,105,108,101, 32,112, 97,114,101,110,116, 32,
+    100,111, 10, 32, 32, 32,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, 32, 32, 32, 32,114,
+    101,116,117,114,110, 32,112, 97,114,101,110,116, 46,110, 97,
+    109,101, 10, 32, 32, 32,101,110,100, 10, 32, 32, 32,112, 97,
+    114,101,110,116, 32, 61, 32,112, 97,114,101,110,116, 46,112,
+     97,114,101,110,116, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 32,114,101,116,117,114,110, 32,110,105,108, 10,101,
+    110,100, 10, 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, 32,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,
+     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, 32,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, 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, 32,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, 10, 45, 45, 32,114,101,116,117,114,110, 32,
+     67, 32, 98,105,110,100,105,110,103, 32,102,117,110, 99,116,
+    105,111,110, 32,110, 97,109,101, 32, 98, 97,115,101,100, 32,
+    111,110, 32,110, 97,109,101, 10, 45, 45, 32,116,104,101, 32,
+     99,108,105,101,110,116, 32,115,112,101, 99,105,102,105,101,
+    115, 32, 97, 32,112,114,101,102,105,120, 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, 10, 32,105,102, 32,115,101,108,102, 46,112, 97,114,
+    101,110,116, 32,116,104,101,110, 10, 32, 32,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, 32,101,110,100, 10,
+     10, 32, 32,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, 10, 32, 32,114,101,116,117,114,110, 32,110, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,118,101,114, 98, 97,
+    116,105,109, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32,118,101,114, 98, 97,116,105,109, 46,108,117, 97,
+     44,118, 32, 49, 46, 51, 32, 50, 48, 48, 48, 47, 48, 49, 47,
+     50, 52, 32, 50, 48, 58, 52, 49, 58, 49, 54, 32, 99,101,108,
+    101,115, 32, 69,120,112, 32, 36, 10, 10, 45, 45, 32, 84,104,
+    105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101,
+     32,115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32,
+     99, 97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,
+    101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,
+    105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,
+    115,111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,
+    101,100, 32,104,101,114,101,117,110,100,101,114, 32,105,115,
+     32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32,
+     98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,
+    104,101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,
+    111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111,
+     32,112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,
+    110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44,
+     32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,
+    104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,
+    109,111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10,
+     10, 10, 10, 45, 45, 32, 86,101,114, 98, 97,116,105,109, 32,
+     99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,115,
+    101,110,116,115, 32, 97, 32,108,105,110,101, 32,116,114, 97,
+    110,115,108, 97,116,101,100, 32,100,105,114,101, 99,116,101,
+    100, 32,116,111, 32,116,104,101, 32, 98,105,110,100,105,110,
+    103, 32,102,105,108,101, 46, 10, 45, 45, 32, 84,104,101, 32,
+    102,111,108,108,111,119,105,110,103, 32,102,105,108,100,115,
+     32, 97,114,101, 32,115,116,111,114,101,100, 58, 10, 45, 45,
+     32, 32, 32,108,105,110,101, 32, 61, 32,108,105,110,101, 32,
+    116,101,120,116, 10, 99,108, 97,115,115, 86,101,114, 98, 97,
+    116,105,109, 32, 61, 32,123, 10, 32,108,105,110,101, 32, 61,
+     32, 39, 39, 44, 10,  9, 99,111,110,100, 32, 61, 32,110,105,
+    108, 44, 32, 32, 32, 32, 45, 45, 32, 99,111,110,100,105,116,
+    105,111,110, 58, 32,119,104,101,114,101, 32,116,111, 32,103,
+    101,110,101,114, 97,116,101, 32,116,104,101, 32, 99,111,100,
+    101, 32, 40,115, 61,115,117,112,111,114,116, 44, 32,114, 61,
+    114,101,103,105,115,116,101,114, 41, 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, 10, 45, 45, 32,112,114,101, 97,109, 98,108,101, 32,118,
+    101,114, 98, 97,116,105,109, 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, 32,105,
+    102, 32,115,101,108,102, 46, 99,111,110,100, 32, 61, 61, 32,
+     39, 39, 32,116,104,101,110, 10, 32, 32,119,114,105,116,101,
+     40,115,101,108,102, 46,108,105,110,101, 41, 10, 32,101,110,
+    100, 10,101,110,100, 10, 10, 45, 45, 32,115,117,112,112,111,
+    114,116, 32, 99,111,100,101, 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, 32,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, 32,
+     32,119,114,105,116,101, 40,115,101,108,102, 46,108,105,110,
+    101, 41, 10, 32, 32,119,114,105,116,101, 40, 39, 92,110, 39,
+     41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+    114,101,103,105,115,116,101,114, 32, 99,111,100,101, 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, 32,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, 32, 32,119,114,105,116,
+    101, 40,115,101,108,102, 46,108,105,110,101, 41, 10, 32,101,
+    110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80,114,105,
+    110,116, 32,109,101,116,104,111,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, 32,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, 32,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, 32,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, 10, 10, 45, 45, 32, 73,110,116,101,114,110,
+     97,108, 32, 99,111,110,115,116,114,117, 99,116,111,114, 10,
+    102,117,110, 99,116,105,111,110, 32, 95, 86,101,114, 98, 97,
+    116,105,109, 32, 40,116, 41, 10, 32,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, 32, 97,112,112,101,110,
+    100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,116, 10,
+    101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,114,117,
+     99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,116,115,
+     32, 97, 32,115,116,114,105,110,103, 32,114,101,112,114,101,
+    115,101,110,116,105,110,103, 32,116,104,101, 32,116,101,120,
+    116, 32,108,105,110,101, 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, 32,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, 32, 32,108, 32, 61, 32,115,116,114,115,117,
+     98, 40,108, 44, 50, 41, 10, 32,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, 32, 32, 99,111,
+    110,100, 32, 61, 32, 39,115,114, 39, 32, 32, 32, 32, 32, 32,
+     32, 45, 45, 32,103,101,110,101,114, 97,116,101,115, 32,105,
+    110, 32, 98,111,116,104, 32,115,117,112,111,114,116, 32, 97,
+    110,100, 32,114,101,103,105,115,116,101,114, 32,102,114, 97,
+    103,109,101,110,116,115, 10, 32, 32,108, 32, 61, 32,115,116,
+    114,115,117, 98, 40,108, 44, 50, 41, 10, 32,101,110,100, 10,
+     32,114,101,116,117,114,110, 32, 95, 86,101,114, 98, 97,116,
+    105,109, 32,123, 10, 32, 32,108,105,110,101, 32, 61, 32,108,
+     44, 10, 32, 32, 99,111,110,100, 32, 61, 32, 99,111,110,100,
+     32,111,114, 32, 39, 39, 44, 10, 32,125, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 99,111,100,101, 32,
+     99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,101,
+    110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,
+    101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102,
+     47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108,
+     32, 49, 57, 57, 57, 10, 45, 45, 32, 36, 73,100, 58, 32, 36,
+     10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,
+    105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,
+    101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,
+    115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100,
+     47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10,
+     45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101,
+     32,112,114,111,118,105,100,101,100, 32,104,101,114,101,117,
+    110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34,
+     97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,
+    110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,
+    114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,
+    116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,101,
+     32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,
+    117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115,
+     44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,
+    116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,
+    116,105,111,110,115, 46, 10, 10, 45, 45, 32,103,108,111, 98,
+     97,108, 10, 99,111,100,101, 95,110, 32, 61, 32, 49, 10, 10,
+     45, 45, 32, 67,111,100,101, 32, 99,108, 97,115,115, 10, 45,
+     45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 76,117,
+     97, 32, 99,111,100,101, 32,116,111, 32, 98,101, 32, 99,111,
+    109,112,105,108,101,100, 32, 97,110,100, 32,105,110, 99,108,
+    117,100,101,100, 10, 45, 45, 32,105,110, 32,116,104,101, 32,
+    105,110,105,116,105, 97,108,105,122, 97,116,105,111,110, 32,
+    102,117,110, 99,116,105,111,110, 46, 10, 45, 45, 32, 84,104,
+    101, 32,102,111,108,108,111,119,105,110,103, 32,102,105,101,
+    108,100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58,
+     10, 45, 45, 32, 32, 32,116,101,120,116, 32, 61, 32,116,101,
+    120,116, 32, 99,111,100,101, 10, 99,108, 97,115,115, 67,111,
+    100,101, 32, 61, 32,123, 10, 32,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, 10, 45,
+     45, 32,114,101,103,105,115,116,101,114, 32, 99,111,100,101,
+     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, 32,112,114,101, 32, 61, 32,112,114,101,
+     32,111,114, 32, 39, 39, 10, 32, 45, 45, 32, 99,108,101, 97,
+    110, 32, 76,117, 97, 32, 99,111,100,101, 10, 32,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, 32,105,102, 32,110,111,
+    116, 32,115, 32,116,104,101,110, 10, 32, 32, 45, 45,112,114,
+    105,110,116, 40,115,101,108,102, 46,116,101,120,116, 41, 10,
+     32, 32,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, 32,101,110,100,
+     10, 10, 32, 45, 45, 32,103,101,116, 32,102,105,114,115,116,
+     32,108,105,110,101, 10, 32,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, 32,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,  9, 32,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,  9,  9,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,  9,  9,105,102, 32,102,108, 97,103,115, 91, 39, 67,
+     39, 93, 32,116,104,101,110, 10,  9,  9,  9,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,  9,  9,101,110,100,
+     10,  9, 32,101,110,100, 10, 32,101,108,115,101, 10, 32,  9,
+    102,105,114,115,116, 95,108,105,110,101, 32, 61, 32, 34, 34,
+     10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,111,110,118,
+    101,114,116, 32,116,111, 32, 67, 10, 32,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, 32,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, 32,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, 32, 32, 39, 41, 10, 32,
+    108,111, 99, 97,108, 32,116, 61,123,110, 61, 48,125, 10, 32,
+    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, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,108,111, 99, 97,108, 32,101, 32, 61, 32, 39, 39, 10, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32,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, 32, 39, 32,101,
+    110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,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, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
+    110,100, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 41, 10, 32,111,117,116,112,117,116, 40, 98, 46,
+     46,115,116,114, 98,121,116,101, 40, 34, 32, 34, 41, 41, 10,
+     32,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, 32,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, 32,  9,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, 32,101,108,115,101, 10, 32,  9,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, 32,101,110,100, 10, 32,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, 32,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,
+     32, 99,111,100,101, 95,110, 32, 61, 32, 99,111,100,101, 95,
+    110, 32, 43, 49, 10,101,110,100, 10, 10, 10, 45, 45, 32, 80,
+    114,105,110,116, 32,109,101,116,104,111,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, 32,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 67,111,100,101,123, 34, 41, 10, 32,
+    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,
+     32,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,
+     10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,
+    111,110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,
+    116,105,111,110, 32, 95, 67,111,100,101, 32, 40,116, 41, 10,
+     32,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, 32, 97,112,
+    112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114,110,
+     32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,
+    116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101,
+     99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114,101,
+    112,114,101,115,101,110,116,105,110,103, 32,116,104,101, 32,
+     99,111,100,101, 32,116,101,120,116, 10,102,117,110, 99,116,
+    105,111,110, 32, 67,111,100,101, 32, 40,108, 41, 10, 32,114,
+    101,116,117,114,110, 32, 95, 67,111,100,101, 32,123, 10, 32,
+     32,116,101,120,116, 32, 61, 32,108, 10, 32,125, 10,101,110,
+    100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,116,121,112,101,100,
+    101,102, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,
+    116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,
+    114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,
+    114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32,
+     74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100,
+     58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,
+    100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,
+    119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,
+    101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32,
+     97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,
+    116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119,
+     97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,
+    114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,
+    110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115,
+     44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,
+    116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,
+    105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,
+    105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101,
+     44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,
+    116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,
+    109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,
+    105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45,
+     32, 84,121,112,101,100,101,102, 32, 99,108, 97,115,115, 10,
+     45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 97,
+     32,116,121,112,101, 32,115,121,110,111,110,121,109, 46, 10,
+     45, 45, 32, 84,104,101, 32, 39,100,101, 32,102, 97, 99,116,
+    111, 39, 32,116,121,112,101, 32,114,101,112,108, 97, 99,101,
+    115, 32,116,104,101, 32,116,121,112,101,100,101,102, 32, 98,
+    101,102,111,114,101, 32,116,104,101, 10, 45, 45, 32,114,101,
+    109, 97,105,110,105,110,103, 32, 99,111,100,101, 32,105,115,
+     32,112, 97,114,115,101,100, 46, 10, 45, 45, 32, 84,104,101,
+     32,102,111,108,108,111,119,105,110,103, 32,102,105,101,108,
+    100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10,
+     45, 45, 32, 32, 32,117,116,121,112,101, 32, 61, 32,116,121,
+    112,101,100,101,102, 32,110, 97,109,101, 10, 45, 45, 32, 32,
+     32,116,121,112,101, 32, 61, 32, 39,116,104,101, 32,102, 97,
+     99,116,111, 39, 32,116,121,112,101, 10, 45, 45, 32, 32, 32,
+    109,111,100, 32, 61, 32,109,111,100,105,102,105,101,114,115,
+     32,116,111, 32,116,104,101, 32, 39,100,101, 32,102, 97, 99,
+    116,111, 39, 32,116,121,112,101, 10, 99,108, 97,115,115, 84,
+    121,112,101,100,101,102, 32, 61, 32,123, 10, 32,117,116,121,
+    112,101, 32, 61, 32, 39, 39, 44, 10, 32,109,111,100, 32, 61,
+     32, 39, 39, 44, 10, 32,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, 10, 45, 45, 32, 80,114,
+    105,110,116, 32,109,101,116,104,111,100, 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, 32,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, 32,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, 32,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, 32,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, 32,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, 10, 45, 45, 32, 82,101,116,117,114,110, 32,105,116, 39,
+    115, 32,110,111,116, 32, 97, 32,118, 97,114,105, 97, 98,108,
+    101, 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, 32,114,101,116,117,114,110,
+     32,102, 97,108,115,101, 10,101,110,100, 10, 10, 45, 45, 32,
+     73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,
+    117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 84,121,112,101,100,101,102, 32, 40,116, 41, 10, 32,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, 32,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, 32, 97,112,112,101,110,
+    100,116,121,112,101,100,101,102, 40,116, 41, 10, 32,114,101,
+    116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,
+     67,111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32,
+     69,120,112,101, 99,116,115, 32,111,110,101, 32,115,116,114,
+    105,110,103, 32,114,101,112,114,101,115,101,110,116,105,110,
+    103, 32,116,104,101, 32,116,121,112,101, 32,100,101,102,105,
+    110,105,116,105,111,110, 46, 10,102,117,110, 99,116,105,111,
+    110, 32, 84,121,112,101,100,101,102, 32, 40,115, 41, 10, 32,
+    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, 32, 32,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, 32,101,110,100,
+     10, 32,108,111, 99, 97,108, 32,111, 32, 61, 32,123,109,111,
+    100, 32, 61, 32, 39, 39,125, 10, 32,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, 32,  9, 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, 32,101,108,115,101, 10, 32,  9,
+    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, 32,  9,111, 32,
+     61, 32,123, 10,  9, 32, 32,117,116,121,112,101, 32, 61, 32,
+    116, 91,116, 46,110, 93, 44, 10,  9, 32, 32,116,121,112,101,
+     32, 61, 32,116, 91,116, 46,110, 45, 49, 93, 44, 10,  9, 32,
+     32,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,  9, 32,125, 10,
+     32,101,110,100, 10, 32,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 99,111,110,116, 97,
+    105,110,101,114, 32, 97, 98,115,116,114, 97, 99,116, 32, 99,
+    108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,101,110,
+     32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32, 67,101,
+    108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,102, 47,
+     80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,108, 32,
+     49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10,
+     10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,105,
+    115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,101,
+     59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,115,
+    116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100, 47,
+    111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10, 45,
+     45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101, 32,
+    112,114,111,118,105,100,101,100, 32,104,101,114,101,117,110,
+    100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34, 97,
+    115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,110,
+    100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,114,
+     32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,116,
+    105,111,110, 32,116,111, 32,112,114,111,118,105,100,101, 32,
+    109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,117,
+    112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115, 44,
+     10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,116,
+    115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,116,
+    105,111,110,115, 46, 10, 10, 45, 45, 32,116, 97, 98,108,101,
+     32,116,111, 32,115,116,111,114,101, 32,110, 97,109,101,115,
+    112, 97, 99,101,100, 32,116,121,112,101,100,101,102,115, 47,
+    101,110,117,109,115, 32,105,110, 32,103,108,111, 98, 97,108,
+     32,115, 99,111,112,101, 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, 10, 45, 45, 32, 67,111,110,116, 97,105,110,101,114, 32,
+     99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,115,
+    101,110,116,115, 32, 97, 32, 99,111,110,116, 97,105,110,101,
+    114, 32,111,102, 32,102,101, 97,116,117,114,101,115, 32,116,
+    111, 32, 98,101, 32, 98,111,117,110,100, 10, 45, 45, 32,116,
+    111, 32,108,117, 97, 46, 10, 99,108, 97,115,115, 67,111,110,
+    116, 97,105,110,101,114, 32, 61, 10,123, 10, 32, 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, 10, 45, 45, 32,111,117,116,112,117,116, 32,116,
+     97,103,115, 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, 32,112,117,115,104,
+     40,115,101,108,102, 41, 10, 32,108,111, 99, 97,108, 32,105,
+     61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91,
+    105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,105, 93,
+     58,100,101, 99,108,116,121,112,101, 40, 41, 10, 32, 32,105,
+     32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,111,
+    112, 40, 41, 10,101,110,100, 10, 10, 10, 45, 45, 32,119,114,
+    105,116,101, 32,115,117,112,112,111,114,116, 32, 99,111,100,
+    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,115,117,112, 99,
+    111,100,101, 32, 40, 41, 10, 10,  9,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,  9,  9,114,101,116,117,114,110, 10,  9,101,110,
+    100, 10, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,
+    108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32,
+     32,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, 32, 32,  9,115,101,108,
+    102, 91,105, 93, 58,115,117,112, 99,111,100,101, 40, 41, 10,
+     32, 32,101,110,100, 10, 32, 32,105, 32, 61, 32,105, 43, 49,
+     10, 32,101,110,100, 10, 32,112,111,112, 40, 41, 10,101,110,
+    100, 10, 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, 32,108,111, 99, 97,108, 32,105,
+     61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,102, 91,
+    105, 93, 32,100,111, 10, 32, 32,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,  9,  9, 32,114,101,116,117,114,
+    110, 32, 49, 10,  9,  9,101,110,100, 10, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32, 48, 10,101,110,100, 10, 10, 45, 45, 32, 73,110,
+    116,101,114,110, 97,108, 32, 99,111,110,116, 97,105,110,101,
+    114, 32, 99,111,110,115,116,114,117, 99,116,111,114, 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, 32,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, 32,115,101,108,102, 46,110, 32, 61, 32, 48, 10, 32,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, 32,115,101,
+    108,102, 46,117,115,101,114,116,121,112,101,115, 32, 61, 32,
+    123,125, 10, 32,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, 32,
+    115,101,108,102, 46,108,110, 97,109,101,115, 32, 61, 32,123,
+    125, 10, 32,114,101,116,117,114,110, 32,115,101,108,102, 10,
+    101,110,100, 10, 10, 45, 45, 32,112,117,115,104, 32, 99,111,
+    110,116, 97,105,110,101,114, 10,102,117,110, 99,116,105,111,
+    110, 32,112,117,115,104, 32, 40,116, 41, 10,  9,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, 32, 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, 10, 45, 45, 32,112,
+    111,112, 32, 99,111,110,116, 97,105,110,101,114, 10,102,117,
+    110, 99,116,105,111,110, 32,112,111,112, 32, 40, 41, 10, 45,
+     45,112,114,105,110,116, 40, 34,110, 97,109,101, 34, 44, 99,
+    108, 97,115,115, 67,111,110,116, 97,105,110,101,114, 46, 99,
+    117,114,114, 46,110, 97,109,101, 41, 10, 45, 45,102,111,114,
+    101, 97, 99,104, 40, 99,108, 97,115,115, 67,111,110,116, 97,
+    105,110,101,114, 46, 99,117,114,114, 46,117,115,101,114,116,
+    121,112,101,115, 44,112,114,105,110,116, 41, 10, 45, 45,112,
+    114,105,110,116, 40, 34, 95, 95, 95, 95, 95, 95, 95, 95, 95,
+     95, 95, 95, 95, 95, 34, 41, 10, 32, 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,
+     10, 45, 45, 32,103,101,116, 32, 99,117,114,114,101,110,116,
+     32,110, 97,109,101,115,112, 97, 99,101, 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,  9,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, 10, 45, 45, 32,
+     97,112,112,101,110,100, 32,116,111, 32, 99,117,114,114,101,
+    110,116, 32, 99,111,110,116, 97,105,110,101,114, 10,102,117,
+    110, 99,116,105,111,110, 32, 97,112,112,101,110,100, 32, 40,
+    116, 41, 10, 32,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,
+     10, 45, 45, 32, 97,112,112,101,110,100, 32,116,121,112,101,
+    100,101,102, 32,116,111, 32, 99,117,114,114,101,110,116, 32,
+     99,111,110,116, 97,105,110,101,114, 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, 32,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, 10, 45, 45, 32,
+     97,112,112,101,110,100, 32,117,115,101,114,116,121,112,101,
+     32,116,111, 32, 99,117,114,114,101,110,116, 32, 99,111,110,
+    116, 97,105,110,101,114, 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, 32,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, 10, 45, 45, 32, 97,
+    112,112,101,110,100, 32,101,110,117,109, 32,116,111, 32, 99,
+    117,114,114,101,110,116, 32, 99,111,110,116, 97,105,110,101,
+    114, 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, 32,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, 10, 45, 45,
+     32,115,117, 98,115,116,105,116,117,116,101, 32,116,121,112,
+    101,100,101,102, 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, 32,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, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102,
+     32,105,115, 32,116,121,112,101, 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, 32,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,  9,114,101,116,117,114,110, 32,116, 10,
+    101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,
+    102, 32,105,115, 32,116,121,112,101,100,101,102, 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, 32,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, 10, 45, 45,
+     32,103,101,116, 32,102,117,108,108,116,121,112,101, 32, 40,
+    119,105,116,104, 32,110, 97,109,101,115,112, 97, 99,101, 41,
+     10,102,117,110, 99,116,105,111,110, 32,102,117,108,108,116,
+    121,112,101, 32, 40,116, 41, 10, 32,108,111, 99, 97,108, 32,
+     99,117,114,114, 32, 61, 32, 32, 99,108, 97,115,115, 67,111,
+    110,116, 97,105,110,101,114, 46, 99,117,114,114, 10,  9,119,
+    104,105,108,101, 32, 99,117,114,114, 32,100,111, 10,  9, 32,
+    105,102, 32, 99,117,114,114, 32,116,104,101,110, 10,  9,  9,
+     32,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,  9,
+      9, 32, 32,114,101,116,117,114,110, 32, 99,117,114,114, 46,
+    116,121,112,101,100,101,102,115, 91,116, 93, 10,  9,  9, 32,
+    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,  9,  9, 32, 32,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,  9,  9,  9,101,110,100, 10,  9,  9,101,110,100,
+     10,  9, 32, 99,117,114,114, 32, 61, 32, 99,117,114,114, 46,
+    112,114,111,120, 10,  9,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,
+    101, 99,107,115, 32,105,102, 32,105,116, 32,114,101,113,117,
+    105,114,101,115, 32, 99,111,108,108,101, 99,116,105,111,110,
+     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, 32,112,117,115,104, 40,115,101,108,102, 41, 10, 32,
+    108,111, 99, 97,108, 32,105, 61, 49, 10,  9,108,111, 99, 97,
+    108, 32,114, 32, 61, 32,102, 97,108,115,101, 10, 32,119,104,
+    105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,
+     32, 32,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, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10,  9,112,111,112, 40,
+     41, 10,  9,114,101,116,117,114,110, 32,114, 10,101,110,100,
+     10, 10, 10, 45, 45, 32,103,101,116, 32,110, 97,109,101,115,
+     97,112, 99,101, 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,  9,108,111, 99, 97,108, 32,110, 97,109,101,
+    115,112, 97, 99,101, 32, 61, 32, 39, 39, 10,  9,119,104,105,
+    108,101, 32, 99,117,114,114, 32,100,111, 10,  9, 32,105,102,
+     32, 99,117,114,114, 32, 97,110,100, 10,  9,  9, 32, 32, 32,
+     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,  9,  9,116,104,101,110, 10,  9,  9, 32,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,  9,  9, 32, 45, 45,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,  9,  9,101,110,100, 10,  9, 32,
+     99,117,114,114, 32, 61, 32, 99,117,114,114, 46,112,114,111,
+    120, 10,  9,101,110,100, 10,  9,114,101,116,117,114,110, 32,
+    110, 97,109,101,115,112, 97, 99,101, 10,101,110,100, 10, 10,
+     45, 45, 32,103,101,116, 32,110, 97,109,101,115,112, 97, 99,
+    101, 32, 40,111,110,108,121, 32,110, 97,109,101,115,112, 97,
+     99,101, 41, 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, 32,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,  9,108,111, 99, 97,108, 32,110,
+     97,109,101,115,112, 97, 99,101, 32, 61, 32, 39, 39, 10,  9,
+    119,104,105,108,101, 32, 99,117,114,114, 32,100,111, 10,  9,
+      9,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,  9,  9, 32,114,101,116,117,114,110, 32,
+    110, 97,109,101,115,112, 97, 99,101, 10,  9,  9,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,  9,  9, 32,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,  9,  9,101,110,100,
+     10,  9, 32, 99,117,114,114, 32, 61, 32, 99,117,114,114, 46,
+    112,114,111,120, 10,  9,101,110,100, 10,  9,114,101,116,117,
+    114,110, 32,110, 97,109,101,115,112, 97, 99,101, 10,101,110,
+    100, 10, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    105,115, 32,101,110,117,109, 10,102,117,110, 99,116,105,111,
+    110, 32,105,115,101,110,117,109, 32, 40,116,121,112,101, 41,
+     10, 32,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, 10, 45, 45, 32, 97,112,112,101,110,100, 32,102,101, 97,
+    116,117,114,101, 32,116,111, 32, 99,111,110,116, 97,105,110,
+    101,114, 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, 32,115,101,108,102, 46,110,
+     32, 61, 32,115,101,108,102, 46,110, 32, 43, 32, 49, 10, 32,
+    115,101,108,102, 91,115,101,108,102, 46,110, 93, 32, 61, 32,
+    116, 10, 32,116, 46,112, 97,114,101,110,116, 32, 61, 32,115,
+    101,108,102, 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112,
+    101,110,100, 32,116,121,112,101,100,101,102, 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, 32,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, 32,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, 32,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,  9,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,  9,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,  9,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,  9, 45, 45,112,
+    114,105,110,116, 40, 34, 97,112,112,101,110,100,105,110,103,
+     32,116,121,112,101,100,101,102, 32, 34, 46, 46,116, 46,117,
+    116,121,112,101, 46, 46, 34, 32, 97,115, 32, 34, 46, 46,110,
+     97,109,101,115,112, 97, 99,101, 46, 46,116, 46,117,116,121,
+    112,101, 46, 46, 34, 32,119,105,116,104, 32,102,116,121,112,
+    101, 32, 34, 46, 46,116, 46,102,116,121,112,101, 41, 10,  9,
+     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,  9,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, 10,  9,  9,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,  9,
+    101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 97,112,112,
+    101,110,100, 32,117,115,101,114,116,121,112,101, 58, 32,114,
+    101,116,117,114,110, 32,102,117,108,108, 32,116,121,112,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, 97,112,112,101,110,
+    100,117,115,101,114,116,121,112,101, 32, 40,116, 41, 10,  9,
+    108,111, 99, 97,108, 32, 99,111,110,116, 97,105,110,101,114,
+     10,  9,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,  9,  9, 99,111,110,116, 97,105,110,101,114,
+     32, 61, 32,115,101,108,102, 46,112,114,111,120, 10,  9,101,
+    108,115,101, 10,  9,  9, 99,111,110,116, 97,105,110,101,114,
+     32, 61, 32,115,101,108,102, 10,  9,101,110,100, 10,  9,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,  9, 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,  9, 95,117,115,101,114,116,
+    121,112,101, 91,102,116, 93, 32, 61, 32,102,116, 10,  9,114,
+    101,116,117,114,110, 32,102,116, 10,101,110,100, 10, 10, 45,
+     45, 32, 97,112,112,101,110,100, 32,101,110,117,109, 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, 32,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, 32,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, 32,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,  9,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, 10, 45, 45, 32,100,101,116,101,114,109,105,110,
+    101, 32,108,117, 97, 32,102,117,110, 99,116,105,111,110, 32,
+    110, 97,109,101, 32,111,118,101,114,108,111, 97,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, 32,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, 32, 32,115,
+    101,108,102, 46,108,110, 97,109,101,115, 91,108,110, 97,109,
+    101, 93, 32, 61, 32, 48, 10, 32,101,108,115,101, 10, 32, 32,
+    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, 32,
+    101,110,100, 10, 32,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, 10, 45, 45, 32, 97,112,112,108,105,101,
+    115, 32,116,121,112,101,100,101,102, 58, 32,114,101,116,117,
+    114,110,115, 32,116,104,101, 32, 39,116,104,101, 32,102, 97,
+     99,116,111, 39, 32,109,111,100,105,102,105,101,114, 32, 97,
+    110,100, 32,116,121,112,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, 97,112,112,108,121,116,121,112,101,100,101,102, 32,
+     40,109,111,100, 44,116,121,112,101, 41, 10,  9,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,  9,  9, 45,
+     45,112,114,105,110,116, 40, 34,102,111,117,110,100, 32,116,
+    121,112,101,100,101,102, 32, 34, 46, 46,103,108,111, 98, 97,
+    108, 95,116,121,112,101,100,101,102,115, 91,116,121,112,101,
+     93, 46,116,121,112,101, 41, 10,  9,  9,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,  9,  9,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,  9,  9, 45, 45,114,101,116,
+    117,114,110, 32,109,111,100, 50, 32, 46, 46, 32, 39, 32, 39,
+     32, 46, 46, 32,109,111,100, 49, 44, 32,116,121,112,101, 50,
+     10,  9,  9,114,101,116,117,114,110, 32,109,111,100, 50, 44,
+     32,116,121,112,101, 50, 10,  9,101,110,100, 10,  9,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, 10, 45, 45, 32, 99,
+    104,101, 99,107, 32,105,102, 32,105,116, 32,105,115, 32, 97,
+     32,116,121,112,101,100,101,102, 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, 32,108,111, 99, 97,108, 32,101,110,118,
+     32, 61, 32,115,101,108,102, 10, 32,119,104,105,108,101, 32,
+    101,110,118, 32,100,111, 10, 32, 32,105,102, 32,101,110,118,
+     46,116,121,112,101,100,101,102,115, 32,116,104,101,110, 10,
+     32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,
+     32,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, 32, 32, 32, 32,
+    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, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,114,101,116,117,114,110, 32,116,121,112,101, 10, 32,
+     32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
+     32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,
+    101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,101,110,118,
+     32, 61, 32,101,110,118, 46,112, 97,114,101,110,116, 10, 32,
+    101,110,100, 10, 32,114,101,116,117,114,110, 32,110,105,108,
+     10,101,110,100, 10, 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, 10,  9,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, 10,  9,
+    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,
+      9,119,104,105,108,101, 32, 99, 32,100,111, 10,  9,  9,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,  9,  9,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,  9,  9,  9,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,  9,  9,  9,  9,114,101,116,117,
+    114,110, 32,118, 10,  9,  9,  9,101,110,100, 10,  9,  9,101,
+    110,100, 10,  9,  9,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,  9,  9,  9, 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,  9,  9,101,108,115,101, 10,  9,  9,  9,
+     99, 32, 61, 32,110,105,108, 10,  9,  9,101,110,100, 10,  9,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,118, 97,
+    114, 10,101,110,100, 10, 10, 45, 45, 32, 99,104,101, 99,107,
+     32,105,102, 32,105,115, 32, 97, 32,114,101,103,105,115,116,
+    101,114,101,100, 32,116,121,112,101, 58, 32,114,101,116,117,
+    114,110, 32,102,117,108,108, 32,116,121,112,101, 32,111,114,
+     32,110,105,108, 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, 10,  9,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,  9,
+    105,102, 32, 95, 98, 97,115,105, 99, 91,116, 93, 32,116,104,
+    101,110, 10,  9, 32,114,101,116,117,114,110, 32,116, 10,  9,
+    101,110,100, 10, 10,  9,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,  9,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,  9,112, 32, 61, 32,115,101,108,102, 10,  9,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,  9,  9,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,
+     10,  9,  9,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, 32, 45, 45, 32,105,110, 32,114,101,118,101,114,115,
+    101, 32,111,114,100,101,114, 10, 10,  9,  9,  9,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,  9,  9,  9,  9,
+    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,  9,  9,  9,101,110,100, 10,  9,  9,
+    101,110,100, 10,  9,  9,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,  9,  9,  9, 45, 45,112,
+    114,105,110,116, 40, 34,116,121,112,101, 32,105,115, 32, 34,
+     46, 46,116, 46, 46, 34, 44, 32,112, 32,105,115, 32, 34, 46,
+     46,112, 46, 98, 97,115,101, 46, 46, 34, 32,115,101,108,102,
+     46,116,121,112,101, 32,105,115, 32, 34, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 34, 32,115,101,108,102, 46,
+    110, 97,109,101, 32,105,115, 32, 34, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 41, 10,  9,  9,  9,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,  9,  9,101,108,115,101, 10,  9,  9,  9,
+    112, 32, 61, 32,110,105,108, 10,  9,  9,101,110,100, 10,  9,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,110,105,
+    108, 10,101,110,100, 10, 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,
+      9, 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,  9, 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,  9,
+     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,  9,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, 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,  9,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,  9,  9, 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,  9,  9, 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,  9,  9,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,  9,  9,  9, 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,  9,  9,101,110,100, 10,  9,101,110,100,
+     10,  9, 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,  9,
+     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, 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, 45, 45,112,114,105,110,116, 40, 34,
+    102,105,110,100,116,121,112,101, 32, 34, 46, 46, 99,104,105,
+    108,100,116,121,112,101, 46, 46, 34, 44, 32, 34, 46, 46,114,
+    101,103,116,121,112,101, 46, 46, 34, 44, 32, 34, 46, 46,115,
+    116, 41, 10,  9,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,  9,105,102, 32, 98, 32,116,104,101,110, 10, 10,
+      9,  9,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,  9,  9,  9,  9, 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,  9,  9,  9,  9,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,  9,  9,  9,114,101,116,117,114,110,
+     32,116,114,117,101, 10,  9,  9,101,110,100, 10,  9,101,110,
+    100, 10, 10,  9,114,101,116,117,114,110, 32,102, 97,108,115,
+    101, 10,101,110,100, 10, 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, 10,
+      9,108,111, 99, 97,108, 32,116, 99,104,105,108,100, 10,  9,
+    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,  9,  9,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,  9,  9,  9,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,  9,  9,  9,  9,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,  9,  9,  9,  9, 32,114,101,116,117,
+    114,110, 32,118, 46,116,121,112,101,100,101,102,115, 91,116,
+     93, 10,  9,  9,  9,  9,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,  9,  9,  9,  9, 32,114,101,116,117,114,110,
+     32,118, 46,117,115,101,114,116,121,112,101,115, 91,116, 93,
+     10,  9,  9,  9,  9,101,110,100, 10,  9,  9,  9,  9,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,  9,  9,  9,  9,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,  9,  9,  9,101,110,100,
+     10,  9,  9,101,110,100, 10,  9,101,110,100, 10,  9,114,101,
+    116,117,114,110, 32,110,105,108, 10, 10,101,110,100, 10, 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, 32,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,  9,114,101,116,117,114,110, 32,116,
+    121,112,101, 10, 32,101,108,115,101, 10, 32,  9,114,101,116,
+    117,114,110, 32,102, 97,108,115,101, 10, 32,101,110,100, 10,
+     10, 32,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, 32,108,111, 99,
+     97,108, 32,101,110,118, 32, 61, 32,115,101,108,102, 10, 32,
+    119,104,105,108,101, 32,101,110,118, 32,100,111, 10, 32, 32,
+    105,102, 32,101,110,118, 46,101,110,117,109,115, 32,116,104,
+    101,110, 10, 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49,
+     10, 32, 32, 32,119,104,105,108,101, 32,101,110,118, 46,101,
+    110,117,109,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32,
+    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, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,114,101,116,117,114,110, 32,116,114,117,101, 10, 32,
+     32, 32, 32, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32, 32,
+     32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,
+    101,110,100, 10, 32, 32,101,110,100, 10, 32, 32,101,110,118,
+     32, 61, 32,101,110,118, 46,112, 97,114,101,110,116, 10, 32,
+    101,110,100, 10, 32,114,101,116,117,114,110, 32,102, 97,108,
+    115,101, 10,101,110,100, 10, 10,109,101,116,104,111,100,105,
+    115,118,105,114,116,117, 97,108, 32, 61, 32,102, 97,108,115,
+    101, 32, 45, 45, 32, 97, 32,103,108,111, 98, 97,108, 10, 10,
+     45, 45, 32,112, 97,114,115,101, 32, 99,104,117,110,107, 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, 45, 45,112,114,105,110,116, 32, 40,
+     34,112, 97,114,115,101, 32, 34, 46, 46,115, 41, 10, 10, 32,
+     45, 45, 32,116,114,121, 32,116,104,101, 32,112, 97,114,115,
+    101,114, 32,104,111,111,107, 10, 32,100,111, 10, 32,  9,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, 32,  9,105,102,
+     32,115,117, 98, 32,116,104,101,110, 10, 32,  9,  9,114,101,
+    116,117,114,110, 32,115,117, 98, 10, 32,  9,101,110,100, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,116,
+    104,101, 32,110,117,108,108, 32,115,116, 97,116,101,109,101,
+    110,116, 10, 32,100,111, 10, 32,  9,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, 32,  9,105,102, 32, 98, 32,116,104,101,
+    110, 10, 32,  9,  9,114,101,116,117,114,110, 32,115,116,114,
+    115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32,  9,101,110,
+    100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121,
+     32,101,109,112,116,121, 32,118,101,114, 98, 97,116,105,109,
+     32,108,105,110,101, 10, 32,100,111, 10, 32,  9,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, 32,  9,105,102, 32,
+     98, 32,116,104,101,110, 10, 32,  9,  9,114,101,116,117,114,
+    110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41,
+     10, 32,  9,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45,
+     45, 32,116,114,121, 32, 76,117, 97, 32, 99,111,100,101, 10,
+     32,100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98, 32,116,104,101,110,
+     10, 32, 32, 32, 67,111,100,101, 40,115,116,114,115,117, 98,
+     40, 99,111,100,101, 44, 50, 44, 45, 50, 41, 41, 10, 32, 32,
+     32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32, 67, 32, 99,
+    111,100,101, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98, 32,
+    116,104,101,110, 10,  9, 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,
+      9, 86,101,114, 98, 97,116,105,109, 40, 99,111,100,101, 44,
+     39,114, 39, 41, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32,
+    118,101,114, 98, 97,116,105,109, 32, 99,111,100,101, 32,102,
+    111,114, 32, 39,114, 39,101,103,105,115,116,101,114, 32,102,
+    114, 97,103,109,101,110,116, 10,  9,114,101,116,117,114,110,
+     32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45,
+     32,116,114,121, 32, 67, 32, 99,111,100,101, 32,102,111,114,
+     32,112,114,101, 97,109, 98,108,101, 32,115,101, 99,116,105,
+    111,110, 10, 32,100,111, 10, 32,  9,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, 32,  9,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32,  9,  9, 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,  9,  9, 86,101,114, 98, 97,116,105,109, 40,
+     99,111,100,101, 44, 32, 39, 39, 41, 10,  9,  9,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, 32,  9,101,110,100, 10, 32,
+    101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,100,101,
+    102, 97,117,108,116, 95,112,114,111,112,101,114,116,121, 32,
+    100,105,114,101, 99,116,105,118,101, 10, 32,100,111, 10, 32,
+      9,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, 32,  9,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32,  9,  9,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,
+     32,  9,  9,  9,112,116,121,112,101, 32, 61, 32, 34,100,101,
+    102, 97,117,108,116, 34, 10, 32,  9,  9,101,110,100, 10, 32,
+      9,  9,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,  9, 32,  9,114,101,116,117,114,110, 32,115,116,114,
+    115,117, 98, 40,115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,
+    110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,
+    121, 32,112,114,111,116,101, 99,116,101,100, 95,100,101,115,
+    116,114,117, 99,116,111,114, 32,100,105,114,101, 99,116,105,
+    118,101, 10, 32,100,111, 10, 32,  9,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,
+      9,105,102, 32, 98, 32,116,104,101,110, 10,  9,  9,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,  9, 32,  9,  9,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,  9, 32,  9,101,110,100, 10, 32,  9,  9,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44, 32,101, 43,
+     49, 41, 10, 32,  9,101,110,100, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32,116,114,121, 32, 39,101,120,116,101,114,110,
+     39, 32,107,101,121,119,111,114,100, 10, 32,100,111, 10, 32,
+      9,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,
+     32,  9,105,102, 32, 98, 32,116,104,101,110, 10,  9,  9, 45,
+     45, 32,100,111, 32,110,111,116,104,105,110,103, 10, 32,  9,
+      9,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,110,100, 10, 32,
+    101,110,100, 10,  9, 10, 32, 45, 45, 32,116,114,121, 32, 39,
+    118,105,114,116,117, 97,108, 39, 32,107,101,121,119,111,114,
+    107,100, 10, 32,100,111, 10, 32,  9,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, 32,  9,105,102, 32, 98,
+     32,116,104,101,110, 10, 32,  9,  9,109,101,116,104,111,100,
+    105,115,118,105,114,116,117, 97,108, 32, 61, 32,116,114,117,
+    101, 10, 32,  9,  9,114,101,116,117,114,110, 32,115,116,114,
+    115,117, 98, 40,115, 44, 32,101, 43, 49, 41, 10, 32,  9,101,
+    110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,116,114,
+    121, 32,108, 97, 98,101,108,115, 32, 40,112,117, 98,108,105,
+     99, 44, 32,112,114,105,118, 97,116,101, 44, 32,101,116, 99,
+     41, 10, 32,100,111, 10, 32,  9,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, 32,  9,105,102, 32, 98,
+     32,116,104,101,110, 10, 32,  9,  9,114,101,116,117,114,110,
+     32,115,116,114,115,117, 98, 40,115, 44, 32,101, 41, 32, 45,
+     45, 32,112,114,101,115,101,114,118,101, 32,116,104,101, 32,
+     91, 94, 58, 93, 10, 32,  9,101,110,100, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32,116,114,121, 32,109,111,100,117,108,
+    101, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98,
+     32,116,104,101,110, 10, 32, 32, 32, 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, 32, 32, 32, 77,111,100,117,108,101,
+     40,110, 97,109,101, 44, 98,111,100,121, 41, 10, 32, 32, 32,
+    114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115,
+     44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 10, 32, 45, 45, 32,116,114,121, 32,110, 97,109,101,
+    115, 97,112, 99,101, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10,
+     32, 32, 32, 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,
+     32, 32, 32, 78, 97,109,101,115,112, 97, 99,101, 40,110, 97,
+    109,101, 44, 98,111,100,121, 41, 10, 32, 32, 32,114,101,116,
+    117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43,
+     49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32,116,114,121, 32,100,101,102,105,110,101, 10,
+     32,100,111, 10, 32, 32,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, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, 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, 32, 32, 32, 68,101,102,
+    105,110,101, 40,110, 97,109,101, 41, 10, 32, 32, 32,114,101,
+    116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10,
+     10, 32, 45, 45, 32,116,114,121, 32,101,110,117,109,101,114,
+     97,116,101,115, 10, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102,
+     32, 98, 32,116,104,101,110, 10, 32, 32, 32, 45, 45,101,114,
+    114,111,114, 40, 34, 35, 83,111,114,114,121, 44, 32,100,101,
+     99,108, 97,114, 97,116,105,111,110, 32,111,102, 32,101,110,
+    117,109,115, 32, 97,110,100, 32,118, 97,114,105, 97, 98,108,
+    101,115, 32,111,110, 32,116,104,101, 32,115, 97,109,101, 32,
+    115,116, 97,116,101,109,101,110,116, 32,105,115, 32,110,111,
+    116, 32,115,117,112,112,111,114,116,101,100, 46, 92,110, 68,
+    101, 99,108, 97,114,101, 32,121,111,117,114, 32,118, 97,114,
+    105, 97, 98,108,101, 32,115,101,112, 97,114, 97,116,101,108,
+    121, 32, 40,101,120, 97,109,112,108,101, 58, 32, 39, 34, 46,
+     46,110, 97,109,101, 46, 46, 34, 32, 34, 46, 46,118, 97,114,
+    110, 97,109,101, 46, 46, 34, 59, 39, 41, 34, 41, 10, 32, 32,
+     32, 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, 32, 32,
+     32, 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,
+     32, 32, 32,114,101,116,117,114,110, 32,115,116,114,115,117,
+     98, 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10,
+     32,101,110,100, 10, 10, 45, 45, 32,100,111, 10, 45, 45, 32,
+     32,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,101,110,117,109, 37,115, 43,
+     40, 37, 83, 42, 41, 37,115, 42, 40, 37, 98,123,125, 41, 37,
+    115, 42, 59, 63, 37,115, 42, 34, 41, 10, 45, 45, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 45, 45, 32, 32, 32, 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, 45, 45, 32, 32,
+     32, 69,110,117,109,101,114, 97,116,101, 40,110, 97,109,101,
+     44, 98,111,100,121, 41, 10, 45, 45, 32, 32,114,101,116,117,
+    114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49,
+     41, 10, 45, 45, 32, 32,101,110,100, 10, 45, 45, 32,101,110,
+    100, 10, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98, 32,116,
+    104,101,110, 10, 32, 32, 32, 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, 32, 32, 32, 69,110,117,109,101,114, 97,116,
+    101, 40,110, 97,109,101, 44, 98,111,100,121, 41, 10, 32, 32,
+     32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,111,112,101,
+    114, 97,116,111,114, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32,110,111,116,
+     32, 98, 32,116,104,101,110, 10,  9,  9, 32, 45, 45, 32,116,
+    114,121, 32,105,110,108,105,110,101, 10, 32, 32, 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, 91, 37,115, 92,110, 93, 42, 37,
+     98,123,125, 37,115, 42, 59, 63, 37,115, 42, 34, 41, 10, 32,
+     32,101,110,100, 10, 32, 32,105,102, 32,110,111,116, 32, 98,
+     32,116,104,101,110, 10, 32, 32,  9, 45, 45, 32,116,114,121,
+     32, 99, 97,115,116, 32,111,112,101,114, 97,116,111,114, 10,
+     32, 32,  9, 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,
+     32, 32,  9,105,102, 32, 98, 32,116,104,101,110, 10, 32, 32,
+      9,  9,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, 32, 32,  9,  9,105,102, 32,105,101, 32,116,104,101,
+    110, 10, 32, 32,  9,  9,  9,101, 32, 61, 32,105,101, 10, 32,
+     32,  9,  9,101,110,100, 10, 32, 32,  9,101,110,100, 10, 32,
+     32,101,110,100, 10, 32, 32,105,102, 32, 98, 32,116,104,101,
+    110, 10, 32, 32, 32, 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, 32, 32, 32, 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, 32, 32, 32,114,101,116,117,114,110, 32,
+    115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32,
+     32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32,
+    116,114,121, 32,102,117,110, 99,116,105,111,110, 10, 32,100,
+    111, 10, 32, 32, 45, 45,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,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,
+     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,
+     32, 32,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,
+     32, 32,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110,
+     10, 32, 32,  9, 45, 45, 32,116,114,121, 32,102,117,110, 99,
+    116,105,111,110, 32,119,105,116,104, 32,116,101,109,112,108,
+     97,116,101, 10, 32, 32,  9, 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, 32,
+     32,101,110,100, 10, 32, 32,105,102, 32,110,111,116, 32, 98,
+     32,116,104,101,110, 10, 32, 32, 32, 45, 45, 32,116,114,121,
+     32, 97, 32,115,105,110,103,108,101, 32,108,101,116,116,101,
+    114, 32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101,
+     10, 32, 32, 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, 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, 32, 32,101,110,100, 10, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32, 32,  9,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, 32, 32,  9,  9,105,
+    102, 32,115,101,108,102, 46,102,108, 97,103,115, 32,116,104,
+    101,110, 10, 32, 32,  9,  9,  9,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, 32, 32,  9,  9,101,110,
+    100, 10, 32, 32,  9,101,110,100, 10, 32, 32, 32, 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, 32, 32, 32, 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, 32, 32, 32,114,101,116,117,114,
+    110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43, 49, 41,
+     10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45,
+     45, 32,116,114,121, 32,105,110,108,105,110,101, 32,102,117,
+    110, 99,116,105,111,110, 10, 32,100,111, 10, 32, 32,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, 32, 32, 45, 45,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,126, 95, 37,119, 93, 91, 95,
+     64, 37,119, 37,115, 37, 42, 38, 58, 60, 62, 93, 42, 91, 95,
+     37,119, 62, 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, 91,
+     94, 59, 93, 42, 37, 98,123,125, 37,115, 42, 59, 63, 37,115,
+     42, 34, 41, 10, 32, 32,105,102, 32,110,111,116, 32, 98, 32,
+    116,104,101,110, 10, 32, 32, 32, 45, 45, 32,116,114,121, 32,
+     97, 32,115,105,110,103,108,101, 32,108,101,116,116,101,114,
+     32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101, 10,
+     32, 32, 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, 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, 32, 32,101,
+    110,100, 10, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10,
+     32, 32, 32, 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,
+     32, 32, 32, 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, 32, 32,
+     32,114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,
+    115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32, 99,108, 97,
+    115,115, 10, 32,100,111, 10,  9, 32,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,  9,  9, 98, 97,115,101, 32, 61, 32, 39, 39,
+     32, 98,111,100,121, 32, 61, 32, 39, 39, 10,  9,  9, 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, 32, 32, 45, 45, 32,100,117,109,
+    109,121, 32, 99,108, 97,115,115, 10,  9,  9,105,102, 32,110,
+    111,116, 32, 98, 32,116,104,101,110, 10,  9,  9,  9, 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, 32, 32, 32, 32, 45, 45, 32,
+    100,117,109,109,121, 32,115,116,114,117, 99,116, 10,  9,  9,
+      9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110, 10,
+      9,  9,  9,  9, 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,  9,  9,
+      9,  9,105,102, 32,110,111,116, 32, 98, 32,116,104,101,110,
+     10,  9,  9,  9,  9,  9, 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,  9,  9,  9,  9,  9,105,102, 32,110,111,116, 32, 98, 32,
+    116,104,101,110, 10,  9,  9,  9,  9,  9,  9, 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,  9,  9,  9,  9,  9,  9,105,102, 32,110,
+    111,116, 32, 98, 32,116,104,101,110, 10,  9,  9,  9,  9,  9,
+      9,  9, 98, 97,115,101, 32, 61, 32, 39, 39, 10,  9,  9,  9,
+      9,  9,  9,  9, 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,  9,  9,  9,  9,  9,
+      9,101,110,100, 10,  9,  9,  9,  9,  9,101,110,100, 10,  9,
+      9,  9,  9,101,110,100, 10,  9,  9,  9,101,110,100, 10,  9,
+      9,101,110,100, 10,  9,  9,105,102, 32, 98, 32,116,104,101,
+    110, 10,  9,  9,  9,105,102, 32, 98, 97,115,101, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10,  9,  9,  9,  9, 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,  9,  9,  9,  9, 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,  9,  9,
+      9,  9, 98, 97,115,101, 32, 61, 32,115,112,108,105,116, 40,
+     98, 97,115,101, 44, 32, 34, 44, 34, 41, 10,  9,  9,  9,  9,
+     45, 45,108,111, 99, 97,108, 32, 98, 44,101, 10,  9,  9,  9,
+      9, 45, 45, 98, 44,101, 44, 98, 97,115,101, 32, 61, 32,115,
+    116,114,102,105,110,100, 40, 98, 97,115,101, 44, 34, 46, 45,
+     40, 91, 95, 37,119, 93, 91, 95, 37,119, 60, 62, 44, 58, 93,
+     42, 41, 36, 34, 41, 10,  9,  9,  9,101,108,115,101, 10,  9,
+      9,  9,  9, 98, 97,115,101, 32, 61, 32,123,125, 10,  9,  9,
+      9,101,110,100, 10,  9,  9,  9, 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,  9,  9,  9, 67,108, 97,115,115, 40,110,
+     97,109,101, 44, 98, 97,115,101, 44, 98,111,100,121, 41, 10,
+      9,  9,  9,114,101,116,117,114,110, 32,115,116,114,115,117,
+     98, 40,115, 44,101, 43, 49, 41, 10,  9,  9,101,110,100, 10,
+      9,101,110,100, 10, 10, 32, 45, 45, 32,116,114,121, 32,116,
+    121,112,101,100,101,102, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,
+    102, 32, 98, 32,116,104,101,110, 10, 32, 32, 32, 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, 32, 32, 32, 84,121,112,
+    101,100,101,102, 40,116,121,112,101,115, 41, 10, 32, 32, 32,
+    114,101,116,117,114,110, 32,115,116,114,115,117, 98, 40,115,
+     44,101, 43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 10, 32, 45, 45, 32,116,114,121, 32,118, 97,114,105,
+     97, 98,108,101, 10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32,
+     98, 32,116,104,101,110, 10, 32, 32, 32, 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, 10,  9,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,  9, 86, 97,114,105, 97, 98,108,101, 40,108,105,
+    115,116, 91, 49, 93, 41, 10,  9,105,102, 32,108,105,115,116,
+     46,110, 32, 62, 32, 49, 32,116,104,101,110, 10,  9,  9,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, 10,  9,  9,108,111, 99,
+     97,108, 32,105, 32, 61, 50, 59, 10,  9,  9,119,104,105,108,
+    101, 32,108,105,115,116, 91,105, 93, 32,100,111, 10,  9,  9,
+      9, 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,
+      9,  9,  9,105, 61,105, 43, 49, 10,  9,  9,101,110,100, 10,
+      9,101,110,100, 10, 32, 32, 32, 45, 45, 86, 97,114,105, 97,
+     98,108,101, 40,100,101, 99,108, 41, 10, 32, 32, 32,114,101,
+    116,117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10,
+     10,  9, 45, 45, 32,116,114,121, 32,115,116,114,105,110,103,
+     10, 32,100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98,
+     32,116,104,101,110, 10, 32, 32, 32, 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, 32, 32, 32, 86, 97,114,105, 97, 98,
+    108,101, 40,100,101, 99,108, 41, 10, 32, 32, 32,114,101,116,
+    117,114,110, 32,115,116,114,115,117, 98, 40,115, 44,101, 43,
+     49, 41, 10, 32, 32,101,110,100, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32,116,114,121, 32, 97,114,114, 97,121, 10, 32,
+    100,111, 10, 32, 32,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, 32, 32,105,102, 32, 98, 32,116,104,101,110,
+     10, 32, 32, 32, 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, 32, 32, 32, 65,114,114, 97,121, 40,100,101, 99,108, 41,
+     10, 32, 32, 32,114,101,116,117,114,110, 32,115,116,114,115,
+    117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32,101,110,100,
+     10, 32,101,110,100, 10, 10, 32, 45, 45, 32,110,111, 32,109,
+     97,116, 99,104,105,110,103, 10, 32,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, 32, 32, 95,
+     99,117,114,114, 95, 99,111,100,101, 32, 61, 32,115, 10, 32,
+     32,101,114,114,111,114, 40, 34, 35,112, 97,114,115,101, 32,
+    101,114,114,111,114, 34, 41, 10, 32,101,108,115,101, 10, 32,
+     32,114,101,116,117,114,110, 32, 34, 34, 10, 32,101,110,100,
+     10, 10,101,110,100, 10, 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, 10,  9,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, 10, 32,
+    119,104,105,108,101, 32,115, 32,126, 61, 32, 39, 39, 32,100,
+    111, 10, 32, 32,115, 32, 61, 32,115,101,108,102, 58,100,111,
+    112, 97,114,115,101, 40,115, 41, 10, 32, 32,109,101,116,104,
+    111,100,105,115,118,105,114,116,117, 97,108, 32, 61, 32,102,
+     97,108,115,101, 10, 32,101,110,100, 10,101,110,100, 10, 10,
+     10, 45, 45, 32,112,114,111,112,101,114,116,121, 32,116,121,
+    112,101,115, 10, 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, 10,  9,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, 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,  9,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,  9,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, 10,  9,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, 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,  9,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,112, 97, 99,107, 97,
+    103,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,
+    116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,
+    114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,
+    114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32,
+     74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100,
+     58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,
+    100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,
+    119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,
+    101,100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32,
+     97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,
+    116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119,
+     97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,
+    114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,
+    110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115,
+     44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,
+    116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,
+    105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,
+    105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101,
+     44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,
+    116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,
+    109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,
+    105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45,
+     32, 80, 97, 99,107, 97,103,101, 32, 99,108, 97,115,115, 10,
+     45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,116,
+    104,101, 32,119,104,111,108,101, 32,112, 97, 99,107, 97,103,
+    101, 32, 98,101,105,110,103, 32, 98,111,117,110,100, 46, 10,
+     45, 45, 32, 84,104,101, 32,102,111,108,108,111,119,105,110,
+    103, 32,102,105,101,108,100,115, 32, 97,114,101, 32,115,116,
+    111,114,101,100, 58, 10, 45, 45, 32, 32, 32, 32,123,105,125,
+     32, 61, 32,108,105,115,116, 32,111,102, 32,111, 98,106,101,
+     99,116,115, 32,105,110, 32,116,104,101, 32,112, 97, 99,107,
+     97,103,101, 46, 10, 99,108, 97,115,115, 80, 97, 99,107, 97,
+    103,101, 32, 61, 32,123, 10, 32, 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, 10, 45, 45, 32, 80,114,105,110,116, 32,
+    109,101,116,104,111,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,105,110,116, 32, 40, 41, 10, 32,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, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 91,
+    105, 93, 58,112,114,105,110,116, 40, 34, 34, 44, 34, 34, 41,
+     10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100,
+     10,101,110,100, 10, 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, 10, 32, 45,
+     45, 32, 97,118,111,105,100, 32,112,114,101,112,114,111, 99,
+    101,115,115,105,110,103, 32,101,109, 98,101,100,100,101,100,
+     32, 76,117, 97, 32, 99,111,100,101, 10, 32,108,111, 99, 97,
+    108, 32, 76, 32, 61, 32,123,125, 10, 32,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, 32, 45, 45, 32,100,101,
+     97,108, 32,119,105,116,104, 32,101,109, 98,101,100,100,101,
+    100, 32,108,117, 97, 32, 99,111,100,101, 10, 32,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, 32,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, 32, 32, 32, 32, 32, 32,102,117,
+    110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,105,
+    110,115,101,114,116, 40, 76, 44, 99, 41, 10, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,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, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,110,
+    100, 41, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,114,
+    101,112,114,111, 99,101,115,115,105,110,103, 32,101,109, 98,
+    101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,108,
+    111, 99, 97,108, 32, 67, 32, 61, 32,123,125, 10, 32,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, 32, 45, 45,
+     32,100,101, 97,108, 32,119,105,116,104, 32,101,109, 98,101,
+    100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,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, 32,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, 32, 32, 32, 32, 32, 32,102,
+    117,110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,116,
+    105,110,115,101,114,116, 40, 67, 44, 99, 41, 10, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,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, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,101,
+    110,100, 41, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,
+    114,101,112,114,111, 99,101,115,115,105,110,103, 32,101,109,
+     98,101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,
+    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, 32,
+     45, 45, 32,100,101, 97,108, 32,119,105,116,104, 32,101,109,
+     98,101,100,100,101,100, 32, 67, 32, 99,111,100,101, 10, 32,
+    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,
+     32,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, 32, 32, 32, 32, 32,
+     32,102,117,110, 99,116,105,111,110, 32, 40, 99, 41, 10, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,116,105,110,115,101,114,116, 40, 67, 44, 99, 41, 10, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,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,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,101,110,100, 41, 10, 10, 32, 45, 45,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, 35, 91,
+     94,100, 93, 91, 94, 92,110, 93, 42, 92,110, 34, 44, 32, 34,
+     92,110, 92,110, 34, 41, 32, 45, 45, 32,101,108,105,109,105,
+    110, 97,116,101, 32,112,114,101,112,114,111, 99,101,115,115,
+    111,114, 32,100,105,114,101, 99,116,105,118,101,115, 32,116,
+    104, 97,116, 32,100,111,110, 39,116, 32,115,116, 97,114,116,
+     32,119,105,116,104, 32, 39,100, 39, 10, 32,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, 32, 45, 45,
+     32,101,108,105,109,105,110, 97,116,101, 32,112,114,101,112,
+    114,111, 99,101,115,115,111,114, 32,100,105,114,101, 99,116,
+    105,118,101,115, 32,116,104, 97,116, 32,100,111,110, 39,116,
+     32,115,116, 97,114,116, 32,119,105,116,104, 32, 39,100, 39,
+     10, 10, 32, 45, 45, 32, 97,118,111,105,100, 32,112,114,101,
+    112,114,111, 99,101,115,115,105,110,103, 32,118,101,114, 98,
+     97,116,105,109, 32,108,105,110,101,115, 10, 32,108,111, 99,
+     97,108, 32, 86, 32, 61, 32,123,125, 10, 32,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, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32,116,105,110,115,101,114,116, 40, 86, 44,118, 41,
+     10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32,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,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,101,110,100, 41, 10, 10, 32, 45, 45, 32,112,101,114,102,
+    111,114,109, 32,103,108,111, 98, 97,108, 32,115,117, 98,115,
+    116,105,116,117,116,105,111,110, 10, 10, 32,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, 32, 32, 32, 32, 32, 45,
+     45, 32,101,108,105,109,105,110, 97,116,101, 32, 67, 43, 43,
+     32, 99,111,109,109,101,110,116,115, 10, 32,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, 32,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,
+     32,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, 32,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, 32,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, 32,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, 32, 45,
+     45, 32,101,108,105,109,105,110, 97,116,101, 32,115,112, 97,
+     99,101,115, 32, 98,101,115,105,100,101, 32, 64, 10, 32,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, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 39,105,110,108,105,110,101, 39, 32,107,101,121,119,111,
+    114,100, 10, 32, 45, 45,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,101,120,116,101,114,110, 40, 37,
+    115, 41, 34, 44, 34, 37, 49, 34, 41, 32, 45, 45, 32,101,108,
+    105,109,105,110, 97,116,101, 32, 39,101,120,116,101,114,110,
+     39, 32,107,101,121,119,111,114,100, 10, 32, 45, 45,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,118,
+    105,114,116,117, 97,108, 40, 37,115, 41, 34, 44, 34, 37, 49,
+     34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 39,118,105,114,116,117, 97,108, 39, 32,107,101,121,119,
+    111,114,100, 10, 32, 45, 45,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,112,117, 98,108,105, 99, 58, 34, 44, 34,
+     34, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 39,112,117, 98,108,105, 99, 58, 39, 32,107,101,121,119,
+    111,114,100, 10, 32,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, 32, 45, 45, 32,115,117, 98,115,
+    116,105,116,117,116,101, 32, 39,118,111,105,100, 42, 39, 10,
+     32,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, 32, 45, 45, 32,115,117, 98,115,116,105,116,117,
+    116,101, 32, 39,118,111,105,100, 42, 39, 10, 32,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, 32, 32,
+     45, 45, 32,115,117, 98,115,116,105,116,117,116,101, 32, 39,
+     99,104, 97,114, 42, 39, 10, 32,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, 32, 32,
+     45, 45, 32,115,117, 98,115,116,105,116,117,116,101, 32, 39,
+    108,117, 97, 95, 83,116, 97,116,101, 42, 39, 10, 10, 32, 45,
+     45, 32,114,101,115,116,111,114,101, 32,101,109, 98,101,100,
+    100,101,100, 32, 76,117, 97, 32, 99,111,100,101, 10, 32,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, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,101,116,117,
+    114,110, 32, 76, 91,116,111,110,117,109, 98,101,114, 40,110,
+     41, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,101,110,100, 41, 10, 32, 45, 45, 32,114,101,115,116,
+    111,114,101, 32,101,109, 98,101,100,100,101,100, 32, 67, 32,
+     99,111,100,101, 10, 32,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, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32,114,101,116,117,114,110, 32, 67, 91,116,111,110,117,
+    109, 98,101,114, 40,110, 41, 93, 10, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32,101,110,100, 41, 10, 32, 45,
+     45, 32,114,101,115,116,111,114,101, 32,118,101,114, 98, 97,
+    116,105,109, 32,108,105,110,101,115, 10, 32,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, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,114,
+    101,116,117,114,110, 32, 86, 91,116,111,110,117,109, 98,101,
+    114, 40,110, 41, 93, 10, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
+     32,101,110,100, 41, 10, 10, 32,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,
+      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,  9, 86,101,114, 98,
+     97,116,105,109, 40,108, 46, 46, 34, 92,110, 34, 41, 10,  9,
+      9,  9,  9,  9,  9,  9,  9,  9,  9,  9,114,101,116,117,114,
+    110, 32, 34, 92,110, 34, 10,  9,  9,  9,  9,  9,  9,  9,  9,
+      9,  9, 32, 32,101,110,100, 41, 10,101,110,100, 10, 10, 45,
+     45, 32,116,114, 97,110,115,108, 97,116,101, 32,118,101,114,
+     98, 97,116,105,109, 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, 32,111,117,116,112,
+    117,116, 40, 39, 47, 42, 92,110, 39, 41, 10, 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, 32,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, 32,111,117,116,112,117,116, 40, 39, 42, 47, 92,110, 92,
+    110, 39, 41, 10, 10,  9,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,  9,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,  9,111,117,116,
+    112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41,
+     10,  9,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, 32,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, 10, 32,105,
+    102, 32,110,111,116, 32,102,108, 97,103,115, 46,104, 32,116,
+    104,101,110, 10, 32, 32,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, 32, 32,111,117,116,
+    112,117,116, 40, 39, 84, 79, 76, 85, 65, 95, 65, 80, 73, 32,
+    105,110,116, 32, 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, 32, 32,111,117,
+    116,112,117,116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100,
+     10, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,
+    104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111,
+     10, 32, 32,115,101,108,102, 91,105, 93, 58,112,114,101, 97,
+    109, 98,108,101, 40, 41, 10, 32, 32,105, 32, 61, 32,105, 43,
+     49, 10, 32,101,110,100, 10, 10,  9,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,  9,  9,111,117,116,112,117,116, 40, 39,
+     92,110, 39, 41, 10,  9,  9,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,
+      9,  9,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,  9,  9,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,  9,  9, 32,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,
+      9,  9,  9,111,117,116,112,117,116, 40, 39,123, 39, 41, 10,
+      9,  9,  9,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,  9,  9,  9,
+    111,117,116,112,117,116, 40, 39,  9,100,101,108,101,116,101,
+     32,115,101,108,102, 59, 39, 41, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39,  9,114,101,116,117,114,110, 32, 48, 59,
+     39, 41, 10,  9,  9,  9,111,117,116,112,117,116, 40, 39,125,
+     39, 41, 10,  9,  9,101,110,100, 10,  9,  9,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 92,110, 39,
+     41, 10,  9,101,110,100, 10, 10, 32,111,117,116,112,117,116,
+     40, 39, 92,110, 39, 41, 10, 32,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, 32,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, 32,111,117,116,112,117,116, 40, 39,123,
+     39, 41, 10, 32,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,  9,105,102, 32,102,
+    108, 97,103,115, 46,116, 32,116,104,101,110, 10,  9,  9,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,  9,  9,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,  9,101,110,100, 10, 32,111,117,116,112,117,
+    116, 40, 39,125, 39, 41, 10, 32,111,117,116,112,117,116, 40,
+     39, 92,110, 39, 41, 10,101,110,100, 10, 10, 45, 45, 32,114,
+    101,103,105,115,116,101,114, 32,112, 97, 99,107, 97,103,101,
+     10, 45, 45, 32,119,114,105,116,101, 32,112, 97, 99,107, 97,
+    103,101, 32,111,112,101,110, 32,102,117,110, 99,116,105,111,
+    110, 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, 32,112,114,101, 32, 61,
+     32,112,114,101, 32,111,114, 32, 39, 39, 10, 32,112,117,115,
+    104, 40,115,101,108,102, 41, 10, 32,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, 32,
+    111,117,116,112,117,116, 40,112,114,101, 46, 46, 34, 84, 79,
+     76, 85, 65, 95, 65, 80, 73, 32,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, 32,111,117,116,112,117,116, 40,112,114,101, 46, 46,
+     34,123, 34, 41, 10, 32,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, 32,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, 32,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, 32,
+    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, 32,108,111, 99, 97,108, 32,105, 61, 49, 10,
+     32,119,104,105,108,101, 32,115,101,108,102, 91,105, 93, 32,
+    100,111, 10, 32, 32,115,101,108,102, 91,105, 93, 58,114,101,
+    103,105,115,116,101,114, 40,112,114,101, 46, 46, 34, 32, 32,
+     34, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,
+    110,100, 10, 32,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, 32,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, 32,111,
+    117,116,112,117,116, 40,112,114,101, 46, 46, 34,125, 34, 41,
+     10, 10, 32,111,117,116,112,117,116, 40, 34, 92,110, 92,110,
+     34, 41, 10, 32,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, 32,111,117,
+    116,112,117,116, 40,112,114,101, 46, 46, 34, 84, 79, 76, 85,
+     65, 95, 65, 80, 73, 32,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, 32,
+    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,
+     32,111,117,116,112,117,116, 40,112,114,101, 46, 46, 34,125,
+     59, 34, 41, 10, 32,111,117,116,112,117,116, 40, 34, 35,101,
+    110,100,105,102, 92,110, 92,110, 34, 41, 10, 10,  9,112,111,
+    112, 40, 41, 10,101,110,100, 10, 10, 45, 45, 32,119,114,105,
+    116,101, 32,104,101, 97,100,101,114, 32,102,105,108,101, 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, 32,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, 32,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, 32,111,117,116,112,117,116, 40,
+     39, 42, 47, 92,110, 92,110, 39, 41, 10, 10, 32,105,102, 32,
+    110,111,116, 32,102,108, 97,103,115, 46,104, 32,116,104,101,
+    110, 10, 32, 32,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, 32, 32,111,117,116,112,117,
+    116, 40, 39, 84, 79, 76, 85, 65, 95, 65, 80, 73, 32,105,110,
+    116, 32, 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, 32, 32,111,117,116,112,
+    117,116, 40, 39, 92,110, 39, 41, 10, 32,101,110,100, 10,101,
+    110,100, 10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108,
+     32, 99,111,110,115,116,114,117, 99,116,111,114, 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, 32,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, 32,114,101,116,
+    117,114,110, 32,115,101,108,102, 10,101,110,100, 10, 10, 45,
+     45, 32, 80, 97,114,115,101, 32, 67, 32,104,101, 97,100,101,
+    114, 32,102,105,108,101, 32,119,105,116,104, 32,116,111,108,
+    117, 97, 32,100,105,114,101, 99,116,105,118,101,115, 10, 45,
+     45, 32, 42, 42, 42, 32, 84,104, 97,110,107,115, 32,116,111,
+     32, 65,114,105,101,108, 32, 77, 97,110,122,117,114, 32,102,
+    111,114, 32,102,105,120,105,110,103, 32, 98,117,103,115, 32,
+    105,110, 32,110,101,115,116,101,100, 32,100,105,114,101, 99,
+    116,105,118,101,115, 32, 42, 42, 42, 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,  9,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,  9,115, 61, 32, 34, 92,110, 34, 32, 46, 46,
+     32,115, 32, 46, 46, 32, 34, 92,110, 34, 32, 45, 45, 32, 97,
+    100,100, 32, 98,108, 97,110,107, 32,108,105,110,101,115, 32,
+     97,115, 32,115,101,110,116,105,110,101,108,115, 10,  9,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,  9,119,104,105,108,101, 32,101, 32,100,111, 10,  9,
+      9,116, 32, 61, 32,115,116,114,108,111,119,101,114, 40,116,
+     41, 10,  9,  9,105,102, 32,116, 32, 61, 61, 32, 34, 98,101,
+    103,105,110, 34, 32,116,104,101,110, 10,  9,  9,  9, 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,
+      9,  9,  9,105,102, 32,110,111,116, 32,101, 32,116,104,101,
+    110, 10,  9,  9,  9, 32,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,  9,  9,  9,101,
+    110,100, 10,  9,  9,101,110,100, 10,  9,  9, 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,  9, 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, 44,101, 41, 10,  9,101,110,100, 10,  9,114,101,
+    116,117,114,110, 32, 99,111,100,101, 10,101,110,100, 10, 10,
+     45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, 10,
+     45, 45, 32, 69,120,112,101, 99,116,115, 32,116,104,101, 32,
+    112, 97, 99,107, 97,103,101, 32,110, 97,109,101, 44, 32,116,
+    104,101, 32,102,105,108,101, 32,101,120,116,101,110,115,105,
+    111,110, 44, 32, 97,110,100, 32,116,104,101, 32,102,105,108,
+    101, 32,116,101,120,116, 46, 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, 32,108,111, 99, 97,108, 32,101,120,116,
+     32, 61, 32, 34,112,107,103, 34, 10, 10, 32, 45, 45, 32,111,
+    112,101,110, 32,105,110,112,117,116, 32,102,105,108,101, 44,
+     32,105,102, 32, 97,110,121, 10, 32,105,102, 32,102,110, 32,
+    116,104,101,110, 10, 32, 32,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, 32, 32,105,102,
+     32,110,111,116, 32,115,116, 32,116,104,101,110, 10, 32, 32,
+     32,101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,115,103,
+     41, 10, 32, 32,101,110,100, 10,  9,  9,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, 32,101,110,100, 10,
+     32,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,  9,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,  9, 32, 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,  9,101,110,100, 10,
+     10, 32, 45, 45, 32, 99,108,111,115,101, 32,102,105,108,101,
+     10, 32,105,102, 32,102,110, 32,116,104,101,110, 10, 32, 32,
+    114,101, 97,100,102,114,111,109, 40, 41, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32,100,101, 97,108, 32,119,105,116,104,
+     32,105,110, 99,108,117,100,101, 32,100,105,114,101, 99,116,
+    105,118,101, 10, 32,108,111, 99, 97,108, 32,110,115,117, 98,
+    115,116, 10, 32,114,101,112,101, 97,116, 10, 32, 32, 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,  9,
+      9,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,  9,  9,  9,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,  9,  9,  9,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,  9,  9,  9,105,102, 32,110,111,116, 32,102,112, 32,116,
+    104,101,110, 10,  9,  9,  9,  9,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,  9,  9,  9,101,110,100, 10,  9,  9,  9,108,
+    111, 99, 97,108, 32,115, 32, 61, 32,114,101, 97,100, 40,102,
+    112, 44, 39, 42, 97, 39, 41, 10,  9,  9,  9, 99,108,111,115,
+    101,102,105,108,101, 40,102,112, 41, 10,  9,  9,  9,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,  9,  9,  9,  9,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,  9,  9,  9,101,108,115,101,105,102, 32,107,105,
+    110,100, 32, 61, 61, 32, 39,112, 39, 32,116,104,101,110, 10,
+      9,  9,  9,  9,114,101,116,117,114,110, 32, 34, 92,110, 92,
+    110, 34, 32, 46, 46, 32,115, 10,  9,  9,  9,101,108,115,101,
+    105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,108, 39, 32,
+    116,104,101,110, 10,  9,  9,  9,  9,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,  9,  9,  9,101,108,115,
+    101,105,102, 32,107,105,110,100, 32, 61, 61, 32, 39,105, 39,
+     32,116,104,101,110, 10,  9,  9,  9,  9,108,111, 99, 97,108,
+     32,116, 32, 61, 32,123, 99,111,100,101, 61,115,125, 10,  9,
+      9,  9,  9,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,  9,  9,  9,  9,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,
+      9,  9,  9,  9,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,  9,  9,
+      9,  9,114,101,116,117,114,110, 32, 34, 92,110, 92,110, 34,
+     32, 46, 46, 32,116, 46, 99,111,100,101, 10,  9,  9,  9,101,
+    108,115,101, 10,  9,  9,  9,  9,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,  9,  9,  9,101,110,100, 10,
+      9,  9,101,110,100, 41, 10, 32,117,110,116,105,108, 32,110,
+    115,117, 98,115,116, 61, 61, 48, 10, 10, 32, 45, 45, 32,100,
+    101, 97,108, 32,119,105,116,104, 32,114,101,110, 97,109,105,
+    110,103, 32,100,105,114,101, 99,116,105,118,101, 10, 32,114,
+    101,112,101, 97,116, 32, 45, 45, 32, 73, 32,100,111,110, 39,
+    116, 32,107,110,111,119, 32,119,104,121, 32,116,104,105,115,
+     32,105,115, 32,110,101, 99,101,115, 97,114,121, 10,  9, 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, 32,117,110,
+    116,105,108, 32,110,115,117, 98,115,116, 32, 61, 61, 32, 48,
+     10, 10, 32,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, 32,112,117,115,
+    104, 40,116, 41, 10, 32,112,114,101,112,114,111, 99,101,115,
+    115, 95,104,111,111,107, 40,116, 41, 10, 32,116, 58,112,114,
+    101,112,114,111, 99,101,115,115, 40, 41, 10, 32,112,114,101,
+    112, 97,114,115,101, 95,104,111,111,107, 40,116, 41, 10, 32,
+    116, 58,112, 97,114,115,101, 40,116, 46, 99,111,100,101, 41,
+     10, 32,112,111,112, 40, 41, 10, 32,114,101,116,117,114,110,
+     32,116, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,109,111,100,117,108,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,
+    116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114,
+     32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114,
+     97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,
+    117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58,
+     32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,
+    101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119,
+     97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,
+    100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,
+    110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116,
+     46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,
+    114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,
+    101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110,
+     32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44,
+     32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,
+    104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,
+    103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,
+    100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44,
+     32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,
+    101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,
+    101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105,
+     99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45, 45, 32,
+     77,111,100,117,108,101, 32, 99,108, 97,115,115, 10, 45, 45,
+     32, 82,101,112,114,101,115,101,110,116,115, 32,109,111,100,
+    117,108,101, 46, 10, 45, 45, 32, 84,104,101, 32,102,111,108,
+    108,111,119,105,110,103, 32,102,105,101,108,100,115, 32, 97,
+    114,101, 32,115,116,111,114,101,100, 58, 10, 45, 45, 32, 32,
+     32, 32,123,105,125, 32, 61, 32,108,105,115,116, 32,111,102,
+     32,111, 98,106,101, 99,116,115, 32,105,110, 32,116,104,101,
+     32,109,111,100,117,108,101, 46, 10, 99,108, 97,115,115, 77,
+    111,100,117,108,101, 32, 61, 32,123, 10, 32, 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, 10, 45, 45, 32,114,101,103,105,115,116,101,
+    114, 32,109,111,100,117,108,101, 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,
+     32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39,
+     39, 10, 32,112,117,115,104, 40,115,101,108,102, 41, 10, 32,
+    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, 32,
+    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, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,
+    105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,
+     32, 32,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, 32,
+     32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,
+    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,  9,112,111,112,
+     40, 41, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110,
+    116, 32,109,101,116,104,111,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, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 77,111,100,117,108,101,123, 34, 41, 10,
+     32,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, 32,
+    108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,
+    101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32,
+    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,
+     32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10,
+     32,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,
+     10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,
+    110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,
+    105,111,110, 32, 95, 77,111,100,117,108,101, 32, 40,116, 41,
+     10, 32,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,
+     32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,
+    117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,
+    111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,
+    120,112,101, 99,116,115, 32,116,119,111, 32,115,116,114,105,
+    110,103, 32,114,101,112,114,101,115,101,110,116,105,110,103,
+     32,116,104,101, 32,109,111,100,117,108,101, 32,110, 97,109,
+    101, 32, 97,110,100, 32, 98,111,100,121, 46, 10,102,117,110,
+     99,116,105,111,110, 32, 77,111,100,117,108,101, 32, 40,110,
+     44, 98, 41, 10, 32,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, 32,112,
+    117,115,104, 40,116, 41, 10, 32,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, 32, 45, 45, 32,101,
+    108,105,109,105,110, 97,116,101, 32, 98,114, 97, 99,101,115,
+     10, 32,112,111,112, 40, 41, 10, 32,114,101,116,117,114,110,
+     32,116, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,110, 97,109,101,115,
+    112, 97, 99,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,
+    114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,
+    109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101,
+     67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45,
+     45, 32, 74,117,108, 32, 50, 48, 48, 51, 10, 45, 45, 32, 36,
+     73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32,
+     99,111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,
+    102,116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110,
+     32,114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,
+    116, 32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121,
+     32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,
+    116,119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,
+    104,101,114,101,117,110,100,101,114, 32,105,115, 32,111,110,
+     32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,
+    105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32,
+     97,117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111,
+     98,108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,
+    111,118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110,
+     99,101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,
+    100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110,
+     99,101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,
+    105,102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45,
+     45, 32, 78, 97,109,101,115,112, 97, 99,101, 32, 99,108, 97,
+    115,115, 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,
+    115, 32, 97, 32,110, 97,109,101,115, 97,112, 99,101, 32,100,
+    101,102,105,110,105,116,105,111,110, 46, 10, 45, 45, 32, 83,
+    116,111,114,101,115, 32,116,104,101, 32,102,111,108,108,111,
+    119,105,110,103, 32,102,105,101,108,100,115, 58, 10, 45, 45,
+     32, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,108, 97,115,
+    115, 32,110, 97,109,101, 10, 45, 45, 32, 32, 32, 32,123,105,
+    125, 32, 32, 61, 32,108,105,115,116, 32,111,102, 32,109,101,
+    109, 98,101,114,115, 10, 99,108, 97,115,115, 78, 97,109,101,
+    115,112, 97, 99,101, 32, 61, 32,123, 10, 32, 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, 32,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, 10, 45, 45, 32,
+     80,114,105,110,116, 32,109,101,116,104,111,100, 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, 32,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, 32,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, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,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, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10, 32,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, 10, 45, 45, 32, 73,
+    110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,117,
+     99,116,111,114, 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, 32,
+    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, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,
+    116,117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32,
+     67,111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32,
+     69,120,112,101, 99,116,115, 32,116,104,101, 32,110, 97,109,
+    101, 32, 97,110,100, 32,116,104,101, 32, 98,111,100,121, 32,
+    111,102, 32,116,104,101, 32,110, 97,109,101,115,112, 97, 99,
+    101, 46, 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, 32,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, 32,112,117,115,104,
+     40, 99, 41, 10, 32, 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, 32, 45, 45, 32,101,108,105,109,
+    105,110, 97,116,101, 32, 98,114, 97, 99,101,115, 10, 32,112,
+    111,112, 40, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,100,101,102,105,110,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,
+    116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114,
+     32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114,
+     97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,
+    117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58,
+     32,100,101,102,105,110,101, 46,108,117, 97, 44,118, 32, 49,
+     46, 50, 32, 49, 57, 57, 57, 47, 48, 55, 47, 50, 56, 32, 50,
+     50, 58, 50, 49, 58, 48, 56, 32, 99,101,108,101,115, 32, 69,
+    120,112, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45,
+     32, 68,101,102,105,110,101, 32, 99,108, 97,115,115, 10, 45,
+     45, 32, 82,101,112,114,101,115,101,110,116,115, 32, 97, 32,
+    110,117,109,101,114,105, 99, 32, 99,111,110,115,116, 32,100,
+    101,102,105,110,105,116,105,111,110, 10, 45, 45, 32, 84,104,
+    101, 32,102,111,108,108,111,119,105,110,103, 32,102,105,108,
+    100,115, 32, 97,114,101, 32,115,116,111,114,101,100, 58, 10,
+     45, 45, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,111,110,
+    115,116, 97,110,116, 32,110, 97,109,101, 10, 99,108, 97,115,
+    115, 68,101,102,105,110,101, 32, 61, 32,123, 10, 32,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, 10, 45, 45, 32,114,101,
+    103,105,115,116,101,114, 32,100,101,102,105,110,101, 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,  9,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,
+      9,  9,114,101,116,117,114,110, 10,  9,101,110,100, 10, 10,
+     32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39,
+     39, 10, 32,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, 10, 45, 45, 32, 80,114,105,110,
+    116, 32,109,101,116,104,111,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, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 68,101,102,105,110,101,123, 34, 41, 10,
+     32,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, 32,
+    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,
+     32,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,
+     10, 10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,
+    111,110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,
+    116,105,111,110, 32, 95, 68,101,102,105,110,101, 32, 40,116,
+     41, 10, 32,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, 32,116, 58, 98,117,105,108,100,110, 97,109,101,115, 40,
+     41, 10, 10, 32,105,102, 32,116, 46,110, 97,109,101, 32, 61,
+     61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,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, 32,101,110,100, 10, 10, 32, 97,
+    112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,114,
+    110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,
+    115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,
+    101, 99,116,115, 32, 97, 32,115,116,114,105,110,103, 32,114,
+    101,112,114,101,115,101,110,116,105,110,103, 32,116,104,101,
+     32, 99,111,110,115,116, 97,110,116, 32,110, 97,109,101, 10,
+    102,117,110, 99,116,105,111,110, 32, 68,101,102,105,110,101,
+     32, 40,110, 41, 10, 32,114,101,116,117,114,110, 32, 95, 68,
+    101,102,105,110,101,123, 10, 32, 32,110, 97,109,101, 32, 61,
+     32,110, 10, 32,125, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,101,110,117,109,101,
+    114, 97,116,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,
+    114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,
+    109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101,
+     67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45,
+     45, 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36,
+     73,100, 58, 32,101,110,117,109,101,114, 97,116,101, 46,108,
+    117, 97, 44,118, 32, 49, 46, 51, 32, 50, 48, 48, 48, 47, 48,
+     49, 47, 50, 52, 32, 50, 48, 58, 52, 49, 58, 49, 53, 32, 99,
+    101,108,101,115, 32, 69,120,112, 32, 36, 10, 10, 45, 45, 32,
+     84,104,105,115, 32, 99,111,100,101, 32,105,115, 32,102,114,
+    101,101, 32,115,111,102,116,119, 97,114,101, 59, 32,121,111,
+    117, 32, 99, 97,110, 32,114,101,100,105,115,116,114,105, 98,
+    117,116,101, 32,105,116, 32, 97,110,100, 47,111,114, 32,109,
+    111,100,105,102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,
+    101, 32,115,111,102,116,119, 97,114,101, 32,112,114,111,118,
+    105,100,101,100, 32,104,101,114,101,117,110,100,101,114, 32,
+    105,115, 32,111,110, 32, 97,110, 32, 34, 97,115, 32,105,115,
+     34, 32, 98, 97,115,105,115, 44, 32, 97,110,100, 10, 45, 45,
+     32,116,104,101, 32, 97,117,116,104,111,114, 32,104, 97,115,
+     32,110,111, 32,111, 98,108,105,103, 97,116,105,111,110, 32,
+    116,111, 32,112,114,111,118,105,100,101, 32,109, 97,105,110,
+    116,101,110, 97,110, 99,101, 44, 32,115,117,112,112,111,114,
+    116, 44, 32,117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,
+    101,110,104, 97,110, 99,101,109,101,110,116,115, 44, 32,111,
+    114, 32,109,111,100,105,102,105, 99, 97,116,105,111,110,115,
+     46, 10, 10, 10, 45, 45, 32, 69,110,117,109,101,114, 97,116,
+    101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,
+    101,115,101,110,116,115, 32,101,110,117,109,101,114, 97,116,
+    105,111,110, 10, 45, 45, 32, 84,104,101, 32,102,111,108,108,
+    111,119,105,110,103, 32,102,105,101,108,100,115, 32, 97,114,
+    101, 32,115,116,111,114,101,100, 58, 10, 45, 45, 32, 32, 32,
+     32,123,105,125, 32, 61, 32,108,105,115,116, 32,111,102, 32,
+     99,111,110,115,116, 97,110,116, 32,110, 97,109,101,115, 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, 10, 45,
+     45, 32,114,101,103,105,115,116,101,114, 32,101,110,117,109,
+    101,114, 97,116,105,111,110, 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, 32,112,114,101, 32, 61, 32,112,114,101, 32,111,114,
+     32, 39, 39, 10, 32,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, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,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, 32, 32,105, 32, 61, 32,105, 43, 49, 10,
+     32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 80,114,
+    105,110,116, 32,109,101,116,104,111,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, 32,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, 32,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,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,
+    108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32,
+     32,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, 32, 32,105,
+     32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,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, 10, 45, 45,
+     32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,
+    114,117, 99,116,111,114, 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, 32,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, 32, 97,112,112,
+    101,110,100, 40,116, 41, 10, 32, 97,112,112,101,110,100,101,
+    110,117,109, 40,116, 41, 10,  9, 32,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,  9,  9,
+    105,102, 32,116, 46,110, 97,109,101, 32,126, 61, 32, 34, 34,
+     32,116,104,101,110, 10,  9,  9,  9, 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,  9,  9,101,108,115,
+    101, 10,  9,  9,  9,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,  9,  9,  9,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,  9,  9,  9, 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,  9,  9,101,110,100, 10,  9,101,110,100,
+     10,114,101,116,117,114,110, 32,116, 10,101,110,100, 10, 10,
+     45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114, 10,
+     45, 45, 32, 69,120,112,101, 99,116,115, 32, 97, 32,115,116,
+    114,105,110,103, 32,114,101,112,114,101,115,101,110,116,105,
+    110,103, 32,116,104,101, 32,101,110,117,109,101,114, 97,116,
+    101, 32, 98,111,100,121, 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,  9, 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, 32, 45, 45, 32,101,108,105,109,105,110, 97,
+    116,101, 32,108, 97,115,116, 32, 39, 44, 39, 10, 32,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, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,
+    101, 32, 98,114, 97, 99,101,115, 10, 32,108,111, 99, 97,108,
+     32,105, 32, 61, 32, 49, 10, 32,108,111, 99, 97,108, 32,101,
+     32, 61, 32,123,110, 61, 48,125, 10, 32,119,104,105,108,101,
+     32,116, 91,105, 93, 32,100,111, 10, 32, 32,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, 32, 32, 45, 45, 32,100,105,115,
+     99, 97,114,100, 32,105,110,105,116,105, 97,108, 32,118, 97,
+    108,117,101, 10, 32, 32,101, 46,110, 32, 61, 32,101, 46,110,
+     32, 43, 32, 49, 10, 32, 32,101, 91,101, 46,110, 93, 32, 61,
+     32,116,116, 91, 49, 93, 10, 32, 32,105, 32, 61, 32,105, 43,
+     49, 10, 32,101,110,100, 10, 32, 45, 45, 32,115,101,116, 32,
+    108,117, 97, 32,110, 97,109,101,115, 10, 32,105, 32, 32, 61,
+     32, 49, 10, 32,101, 46,108,110, 97,109,101,115, 32, 61, 32,
+    123,125, 10, 32,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, 32,119,104,105,108,101, 32,101, 91,105, 93,
+     32,100,111, 10, 32, 32,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, 32, 32,101, 91,105, 93, 32, 61, 32,116, 91, 49, 93,
+     10,  9,  9,105,102, 32,110,111,116, 32,116, 91, 50, 93, 32,
+    116,104,101,110, 10,  9,  9, 32,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,  9,  9,101,110,100, 10, 32, 32,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, 32, 32, 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, 32, 32,105, 32, 61, 32,105, 43, 49,
+     10, 32,101,110,100, 10,  9,101, 46,110, 97,109,101, 32, 61,
+     32,110, 10,  9,105,102, 32,110, 32,126, 61, 32, 34, 34, 32,
+    116,104,101,110, 10,  9,  9, 84,121,112,101,100,101,102, 40,
+     34,105,110,116, 32, 34, 46, 46,110, 41, 10,  9,101,110,100,
+     10, 32,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,100,101, 99,108, 97,
+    114, 97,116,105,111,110, 32, 99,108, 97,115,115, 10, 45, 45,
+     32, 87,114,105,116,116,101,110, 32, 98,121, 32, 87, 97,108,
+    100,101,109, 97,114, 32, 67,101,108,101,115, 10, 45, 45, 32,
+     84,101, 67, 71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111,
+     10, 45, 45, 32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45,
+     32, 36, 73,100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,
+    115, 32, 99,111,100,101, 32,105,115, 32,102,114,101,101, 32,
+    115,111,102,116,119, 97,114,101, 59, 32,121,111,117, 32, 99,
+     97,110, 32,114,101,100,105,115,116,114,105, 98,117,116,101,
+     32,105,116, 32, 97,110,100, 47,111,114, 32,109,111,100,105,
+    102,121, 32,105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,
+    111,102,116,119, 97,114,101, 32,112,114,111,118,105,100,101,
+    100, 32,104,101,114,101,117,110,100,101,114, 32,105,115, 32,
+    111,110, 32, 97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98,
+     97,115,105,115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,
+    101, 32, 97,117,116,104,111,114, 32,104, 97,115, 32,110,111,
+     32,111, 98,108,105,103, 97,116,105,111,110, 32,116,111, 32,
+    112,114,111,118,105,100,101, 32,109, 97,105,110,116,101,110,
+     97,110, 99,101, 44, 32,115,117,112,112,111,114,116, 44, 32,
+    117,112,100, 97,116,101,115, 44, 10, 45, 45, 32,101,110,104,
+     97,110, 99,101,109,101,110,116,115, 44, 32,111,114, 32,109,
+    111,100,105,102,105, 99, 97,116,105,111,110,115, 46, 10, 10,
+     10, 45, 45, 32, 68,101, 99,108, 97,114, 97,116,105,111,110,
+     32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,112,114,101,
+    115,101,110,116,115, 32,118, 97,114,105, 97, 98,108,101, 44,
+     32,102,117,110, 99,116,105,111,110, 44, 32,111,114, 32, 97,
+    114,103,117,109,101,110,116, 32,100,101, 99,108, 97,114, 97,
+    116,105,111,110, 46, 10, 45, 45, 32, 83,116,111,114,101,115,
+     32,116,104,101, 32,102,111,108,108,111,119,105,110,103, 32,
+    102,105,101,108,100,115, 58, 10, 45, 45, 32, 32,109,111,100,
+     32, 32, 61, 32,116,121,112,101, 32,109,111,100,105,102,105,
+    101,114,115, 10, 45, 45, 32, 32,116,121,112,101, 32, 61, 32,
+    116,121,112,101, 10, 45, 45, 32, 32,112,116,114, 32, 32, 61,
+     32, 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, 32,105,102,
+     32,114,101,112,114,101,115,101,110,116,105,110,103, 32, 97,
+     32,112,111,105,110,116,101,114, 32,111,114, 32, 97, 32,114,
+    101,102,101,114,101,110, 99,101, 10, 45, 45, 32, 32,110, 97,
+    109,101, 32, 61, 32,110, 97,109,101, 10, 45, 45, 32, 32,100,
+    105,109, 32, 32, 61, 32,100,105,109,101,110,115,105,111,110,
+     44, 32,105,102, 32, 97, 32,118,101, 99,116,111,114, 10, 45,
+     45, 32, 32,100,101,102, 32, 32, 61, 32,100,101,102, 97,117,
+    108,116, 32,118, 97,108,117,101, 44, 32,105,102, 32, 97,110,
+    121, 32, 40,111,110,108,121, 32,102,111,114, 32, 97,114,103,
+    117,109,101,110,116,115, 41, 10, 45, 45, 32, 32,114,101,116,
+     32, 32, 61, 32, 34, 42, 34, 32,111,114, 32, 34, 38, 34, 44,
+     32,105,102, 32,118, 97,108,117,101, 32,105,115, 32,116,111,
+     32, 98,101, 32,114,101,116,117,114,110,101,100, 32, 40,111,
+    110,108,121, 32,102,111,114, 32, 97,114,103,117,109,101,110,
+    116,115, 41, 10, 99,108, 97,115,115, 68,101, 99,108, 97,114,
+     97,116,105,111,110, 32, 61, 32,123, 10, 32,109,111,100, 32,
+     61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39,
+     39, 44, 10, 32,112,116,114, 32, 61, 32, 39, 39, 44, 10, 32,
+    110, 97,109,101, 32, 61, 32, 39, 39, 44, 10, 32,100,105,109,
+     32, 61, 32, 39, 39, 44, 10, 32,114,101,116, 32, 61, 32, 39,
+     39, 44, 10, 32,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, 10, 45,
+     45, 32, 67,114,101, 97,116,101, 32, 97,110, 32,117,110,105,
+    113,117,101, 32,118, 97,114,105, 97, 98,108,101, 32,110, 97,
+    109,101, 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,
+     32,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, 32, 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, 32,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, 10, 45, 45, 32, 67,104,101, 99,107, 32,100,
+    101, 99,108, 97,114, 97,116,105,111,110, 32,110, 97,109,101,
+     10, 45, 45, 32, 73,116, 32, 97,108,115,111, 32,105,100,101,
+    110,116,105,102,105,101,115, 32,100,101,102, 97,117,108,116,
+     32,118, 97,108,117,101,115, 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, 10, 32,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, 32, 32,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, 32,
+     32,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, 32, 32,115,101,108,102, 46,116,121,112,
+    101, 32, 61, 32,109, 91,109, 46,110, 93, 10, 32, 32,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, 32,101,110,
+    100, 10, 10, 32,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, 32,105,102, 32,116, 46,110, 61, 61, 50,
+     32,116,104,101,110, 10, 32, 32,115,101,108,102, 46,110, 97,
+    109,101, 32, 61, 32,116, 91, 49, 93, 10, 32, 32,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,
+     32,101,110,100, 10, 10, 32,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, 32,105,102, 32, 98, 32,116,104,101,
+    110, 10, 32, 32,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, 32, 32,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, 32,101,110,100, 10,
+     10, 10, 32,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, 32, 32,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, 32,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, 32, 32,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, 32, 32, 32,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,
+     32, 32, 32,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, 32, 32,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, 32, 32, 32,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, 32, 32, 32,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, 32, 32,
+     32,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,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45,
+     32, 97,100,106,117,115,116, 32,116,121,112,101, 32,111,102,
+     32,115,116,114,105,110,103, 10, 32,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,  9, 32,115,101,
+    108,102, 46,116,121,112,101, 32, 61, 32, 39, 99,104, 97,114,
+     42, 39, 10, 32,101,110,100, 10, 10,  9,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,  9,  9,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, 32, 45, 45, 32, 63, 63,
+     63, 10,  9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     67,104,101, 99,107, 32,100,101, 99,108, 97,114, 97,116,105,
+    111,110, 32,116,121,112,101, 10, 45, 45, 32, 83,117, 98,115,
+    116,105,116,117,116,101,115, 32,116,121,112,101,100,101,102,
+     39,115, 46, 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, 10, 32,
+     45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,116,104,101,
+    114,101, 32,105,115, 32, 97, 32,112,111,105,110,116,101,114,
+     32,116,111, 32, 98, 97,115,105, 99, 32,116,121,112,101, 10,
+     32,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, 32,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, 32,  9,115,101,108,
+    102, 46,116,121,112,101, 32, 61, 32, 39, 95,117,115,101,114,
+    100, 97,116, 97, 39, 10, 32,  9,115,101,108,102, 46,112,116,
+    114, 32, 61, 32, 34, 34, 10, 32,101,110,100, 10, 32,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, 32,
+     32,115,101,108,102, 46,114,101,116, 32, 61, 32,115,101,108,
+    102, 46,112,116,114, 10, 32, 32,115,101,108,102, 46,112,116,
+    114, 32, 61, 32,110,105,108, 10, 32, 32,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, 32, 32,  9,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, 32, 32,101,110,100, 10, 32,101,110,100,
+     10, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    116,104,101,114,101, 32,105,115, 32, 97,114,114, 97,121, 32,
+    116,111, 32, 98,101, 32,114,101,116,117,114,110,101,100, 10,
+     32,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, 32, 32, 32,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, 32,
+    101,110,100, 10, 32, 45, 45, 32,114,101,115,116,111,114,101,
+     32, 39,118,111,105,100, 42, 39, 32, 97,110,100, 32, 39,115,
+    116,114,105,110,103, 42, 39, 10, 32,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, 32,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, 32,
+    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,
+     32,101,110,100, 10, 10, 32, 45, 45, 32,114,101,115,111,108,
+    118,101, 32,116,121,112,101,115, 32,105,110,115,105,100,101,
+     32,116,104,101, 32,116,101,109,112,108, 97,116,101,115, 10,
+     32,105,102, 32,115,101,108,102, 46,116,121,112,101, 32,116,
+    104,101,110, 10,  9, 32,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, 32,101,110,100, 10, 10, 45, 45,
+     10, 45, 45, 32, 45, 45, 32,105,102, 32,114,101,116,117,114,
+    110,105,110,103, 32,118, 97,108,117,101, 44, 32, 97,117,116,
+    111,109, 97,116,105, 99, 97,108,108,121, 32,115,101,116, 32,
+    100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 10, 45,
+     45, 32,105,102, 32,115,101,108,102, 46,114,101,116, 32,126,
+     61, 32, 39, 39, 32, 97,110,100, 32,115,101,108,102, 46,100,
+    101,102, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 45,
+     45, 32, 32,115,101,108,102, 46,100,101,102, 32, 61, 32, 39,
+     48, 39, 10, 45, 45, 32,101,110,100, 10, 45, 45, 10, 10,101,
+    110,100, 10, 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, 10,  9,105,
+    102, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41,
+     32,116,104,101,110, 10,  9,  9,114,101,116,117,114,110, 32,
+    116,121,112,101, 10,  9,101,110,100, 10,  9,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,  9,105,102, 32, 98, 32,116,
+    104,101,110, 10, 10,  9,  9,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,  9,  9,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,  9,  9,  9,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,  9,  9,  9,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,  9,  9,  9,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,  9,  9,101,110,100, 10, 10,  9,  9,108,
+    111, 99, 97,108, 32, 98, 44,105, 10,  9,  9,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,  9,  9,
+    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,  9,  9,
+    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,  9,  9,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,  9,101,
+    110,100, 10,  9,114,101,116,117,114,110, 32,116,121,112,101,
+     10,101,110,100, 10, 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,  9,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,  9,105,102, 32,116,105,109,112,108, 32,116,104,101,
+    110, 10,  9,  9,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,  9,  9,114,101,116,117,114,110, 32,115,
+     44, 32, 98, 44, 32,116,105,109,112,108, 10,  9,101,108,115,
+    101, 10,  9,  9,114,101,116,117,114,110, 32,115, 44, 32, 48,
+     44, 32,110,105,108, 10,  9,101,110,100, 10,101,110,100, 10,
+     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, 10,  9,105,102, 32,
+     98, 32, 61, 61, 32, 48, 32,116,104,101,110, 10,  9,  9,114,
+    101,116,117,114,110, 32,115, 10,  9,101,110,100, 10, 10,  9,
+    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, 10, 45, 45, 32, 80,114,105,110,116, 32,109,101,116,
+    104,111,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, 32,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, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44,
+     34, 41, 10, 32,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, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,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, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    100,105,109, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,100,105,109, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,100,101,
+    102, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,100,
+    101,102, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,105,110,
+    116, 40,105,100,101,110,116, 46, 46, 34, 32,114,101,116, 32,
+     32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,114,101,116,
+     46, 46, 34, 39, 44, 34, 41, 10, 32,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, 10, 45, 45, 32, 99,104,101,
+     99,107, 32,105,102, 32, 97,114,114, 97,121, 32,111,102, 32,
+    118, 97,108,117,101,115, 32, 97,114,101, 32,114,101,116,117,
+    114,110,101,100, 32,116,111, 32, 76,117, 97, 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,
+     32,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,  9, 32,
+     32, 32, 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, 97,110,100, 10,  9,  9,  9,  9, 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, 10,  9,  9,  9,  9, 32,115,101,108,
+    102, 46,112,116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,
+    110, 10,  9,  9,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,  9,  9,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,  9,  9,
+    114,101,116,117,114,110, 32,116,114,117,101, 10,  9,101,110,
+    100, 10,  9,114,101,116,117,114,110, 32,102, 97,108,115,101,
+     10,101,110,100, 10, 10, 45, 45, 32,100,101, 99,108, 97,114,
+    101, 32,116, 97,103, 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, 10,
+      9,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,  9,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,  9,  9,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,  9,  9,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,  9,101,110,100, 10,101,110,
+    100, 10, 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116,
+    121,112,101, 32, 99,104,101, 99,107,105,110,103, 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, 32,
+    108,111, 99, 97,108, 32,100,101,102, 10, 32,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, 32,105,102, 32,115,
+    101,108,102, 46,100,101,102,126, 61, 39, 39, 32,116,104,101,
+    110, 10, 32, 32,100,101,102, 32, 61, 32, 49, 10, 32,101,108,
+    115,101, 10, 32, 32,100,101,102, 32, 61, 32, 48, 10, 32,101,
+    110,100, 10, 32,105,102, 32,115,101,108,102, 46,100,105,109,
+     32,126, 61, 32, 39, 39, 32,116,104,101,110, 10,  9, 45, 45,
+    105,102, 32,116, 61, 61, 39,115,116,114,105,110,103, 39, 32,
+    116,104,101,110, 10,  9, 45, 45,  9,114,101,116,117,114,110,
+     32, 39,116,111,108,117, 97, 95,105,115,115,116,114,105,110,
+    103, 97,114,114, 97,121, 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,  9, 45, 45,101,108,115,101, 10,  9,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, 32,  9, 45, 45,101,110,
+    100, 10, 32,101,108,115,101,105,102, 32,116, 32,116,104,101,
+    110, 10,  9,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, 32,101,108,115,101, 10,
+     32, 32,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, 32,101,110,
+    100, 10,101,110,100, 10, 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, 32,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,  9,108,111, 99, 97,108, 32,108,105,
+    110,101, 32, 61, 32, 34, 34, 10, 32,108,111, 99, 97,108, 32,
+    112,116,114, 32, 61, 32, 39, 39, 10,  9,108,111, 99, 97,108,
+     32,109,111,100, 10,  9,108,111, 99, 97,108, 32,116,121,112,
+    101, 32, 61, 32,115,101,108,102, 46,116,121,112,101, 10, 32,
+    105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61, 32,
+     39, 39, 32,116,104,101,110, 10,  9, 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, 37,115, 43, 39, 44, 39, 39,
+     41, 32, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+    115, 32, 99,111,110,115,116, 32,109,111,100,105,102,105,101,
+    114, 32,102,111,114, 32, 97,114,114, 97,121,115, 10, 32,101,
+    110,100, 10, 32,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, 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, 34, 32, 34, 44,
+    115,101,108,102, 46,109,111,100, 44,116,121,112,101, 44,112,
+    116,114, 41, 10, 32,105,102, 32, 97,114,114, 97,121, 32,116,
+    104,101,110, 10, 32, 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, 10, 32,101,110,100, 10, 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,115,101,108,102, 46,110, 97,109,101, 41,
+     10, 32,105,102, 32,115,101,108,102, 46,100,105,109, 32,126,
+     61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32,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, 32,
+     32, 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, 91, 39, 44,
+    115,101,108,102, 46,100,105,109, 44, 39, 93, 59, 39, 41, 10,
+     32, 32,101,108,115,101, 10,  9,105,102, 32, 99,112,108,117,
+    115,112,108,117,115, 32,116,104,101,110, 10,  9,  9,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,  9,101,108,115,101, 10,  9,  9,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,  9,  9, 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,
+      9,101,110,100, 10, 32, 32,101,110,100, 10, 32,101,108,115,
+    101, 10, 32, 32,108,111, 99, 97,108, 32,116, 32, 61, 32,105,
+    115, 98, 97,115,105, 99, 40,116,121,112,101, 41, 10, 32, 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, 32, 61, 32, 39, 41,
+     10, 32, 32,105,102, 32,116, 32, 61, 61, 32, 39,115,116, 97,
+    116,101, 39, 32,116,104,101,110, 10, 32, 32,  9,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, 32, 32,101,108,115,101, 10, 32, 32,  9, 45,
+     45,112,114,105,110,116, 40, 34,116, 32,105,115, 32, 34, 46,
+     46,116,111,115,116,114,105,110,103, 40,116, 41, 46, 46, 34,
+     44, 32,112,116,114, 32,105,115, 32, 34, 46, 46,116,111,115,
+    116,114,105,110,103, 40,115,101,108,102, 46,112,116,114, 41,
+     41, 10, 32, 32,  9,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, 32,
+     32,  9,  9,116, 32, 61, 32, 39,117,115,101,114,100, 97,116,
+     97, 39, 10, 32, 32,  9,101,110,100, 10,  9,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,  9,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,  9,105,102, 32,110,
+    111,116, 32,116, 32,116,104,101,110, 10,  9,  9,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,  9,101,110,100,
+     10,  9,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,  9,  9,  9,105,102, 32,105,115,101,110,117,109, 40,
+    116,121,112,101, 41, 32,116,104,101,110, 10,  9,  9,  9,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,  9,  9,  9,101,110,100, 10,  9,108,111, 99, 97,
+    108, 32,100,101,102, 32, 61, 32, 48, 10,  9,105,102, 32,115,
+    101,108,102, 46,100,101,102, 32,126, 61, 32, 39, 39, 32,116,
+    104,101,110, 10,  9,  9,100,101,102, 32, 61, 32,115,101,108,
+    102, 46,100,101,102, 10,  9,  9,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,  9,  9,  9,
+    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,  9,  9,101,110,100,
+     10,  9,101,110,100, 10,  9,105,102, 32,116, 32,116,104,101,
+    110, 10,  9,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,  9,101,
+    108,115,101, 10,  9,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,  9,101,110,100, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10,  9,114,101,116,117,114,110, 32,108,105,110,101,
+     10,101,110,100, 10, 10, 45, 45, 32, 68,101, 99,108, 97,114,
+    101, 32,118, 97,114,105, 97, 98,108,101, 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, 32,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,  9,
+     32,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,  9,  9,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,
+      9,  9,111,117,116,112,117,116, 40, 39, 35,101,108,115,101,
+     92,110, 39, 41, 10,  9,  9,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,  9, 32,111,117,116,112,117,116, 40, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10,  9,101,108,115,101,
+     10,  9,  9,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,
+      9,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32, 71,101,
+    116, 32,112, 97,114, 97,109,101,116,101,114, 32,118, 97,108,
+    117,101, 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,
+     32,105,102, 32,115,101,108,102, 46,100,105,109, 32,126, 61,
+     32, 39, 39, 32,116,104,101,110, 10,  9, 32,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, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,123, 39, 41, 10,  9, 32,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, 32,
+     32,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,  9,  9,108,111, 99, 97,
+    108, 32,116, 32, 61, 32,105,115, 98, 97,115,105, 99, 40,116,
+    121,112,101, 41, 10,  9,  9,105,102, 32, 40,116, 41, 32,116,
+    104,101,110, 10, 32, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 32, 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,  9,  9,101,108,115,101, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 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,  9,
+      9,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 32, 32, 32,103,111,116,111, 32,116,111,108,117, 97, 95,
+    108,101,114,114,111,114, 59, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32,101,108,115,101, 92,110, 39,
+     41, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 32, 32,123, 39, 41, 10, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32, 32,105,110,116, 32,105, 59,
+     39, 41, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,
+     32, 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, 32, 32,108,111, 99, 97,108, 32,116, 32,
+     61, 32,105,115, 98, 97,115,105, 99, 40,116,121,112,101, 41,
+     10, 32, 32,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32,
+     39, 39, 10, 32, 32,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, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32, 39, 44,115,101,108,102, 46,
+    110, 97,109,101, 46, 46, 39, 91,105, 93, 32, 61, 32, 39, 41,
+     10, 32, 32,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,
+     32, 32,111,117,116,112,117,116, 40, 39, 40, 40, 39, 44,116,
+    121,112,101, 41, 10, 32, 32,105,102, 32,110,111,116, 32,116,
+     32,116,104,101,110, 10, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 42, 39, 41, 10, 32, 32,101,110,100, 10, 32, 32,111,
+    117,116,112,117,116, 40, 39, 41, 32, 39, 41, 10, 32, 32,108,
+    111, 99, 97,108, 32,100,101,102, 32, 61, 32, 48, 10, 32, 32,
+    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, 32, 32,105,
+    102, 32,116, 32,116,104,101,110, 10, 32, 32, 32,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,
+     32, 32,101,108,115,101, 10, 32, 32, 32,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, 32,
+     32,101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 32, 32,125, 39, 41, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 32,125, 39, 41, 10, 32,101,110,100, 10,101,110,
+    100, 10, 10, 45, 45, 32, 71,101,116, 32,112, 97,114, 97,109,
+    101,116,101,114, 32,118, 97,108,117,101, 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, 32,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,  9, 32,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, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 32,123, 39, 41, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32,105,110,116, 32,105, 59, 39, 41,
+     10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 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, 32, 32,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, 32, 32,105,102, 32,116, 32,116,104,101,110, 10, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32,101,108,
+    115,101, 10, 32, 32, 32,105,102, 32,115,101,108,102, 46,112,
+    116,114, 32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32,
+     32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,
+    123, 39, 41, 10, 32, 32, 32, 32, 32,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, 32, 32, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40,
+     39, 32, 32, 32, 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, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40,
+     39, 35,101,108,115,101, 92,110, 39, 41, 10, 32, 32, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32, 32, 32,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,125, 39,
+     41, 10, 32, 32, 32,101,108,115,101, 10, 32, 32, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32, 32, 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, 32, 32, 32,101,110,100, 10, 32, 32,101,110,
+    100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,125,
+     39, 41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
+     32, 70,114,101,101, 32,100,121,110, 97,109,105, 99, 97,108,
+    108,121, 32, 97,108,108,111, 99, 97,116,101,100, 32, 97,114,
+    114, 97,121, 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, 32,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,  9, 32,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,  9,  9,111,117,116,112,117,
+    116, 40, 39, 32, 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,  9, 32,111,117,116,112,117,116, 40, 39, 35,101,108,115,
+    101, 92,110, 39, 41, 10, 32, 32,111,117,116,112,117,116, 40,
+     39, 32, 32,102,114,101,101, 40, 39, 44,115,101,108,102, 46,
+    110, 97,109,101, 44, 39, 41, 59, 39, 41, 10,  9, 32,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39,
+     41, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     80, 97,115,115, 32,112, 97,114, 97,109,101,116,101,114, 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, 32,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, 32, 32,111,
+    117,116,112,117,116, 40, 39, 42, 39, 46, 46,115,101,108,102,
+     46,110, 97,109,101, 41, 10, 32,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, 32, 32,111,117,116,112,117,116, 40, 39, 38,
+     39, 46, 46,115,101,108,102, 46,110, 97,109,101, 41, 10, 32,
+    101,108,115,101, 10, 32, 32,111,117,116,112,117,116, 40,115,
+    101,108,102, 46,110, 97,109,101, 41, 10, 32,101,110,100, 10,
+    101,110,100, 10, 10, 45, 45, 32, 82,101,116,117,114,110, 32,
+    112, 97,114, 97,109,101,116,101,114, 32,118, 97,108,117,101,
+     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, 32,105,102, 32,115,101,
+    108,102, 46,114,101,116, 32,126, 61, 32, 39, 39, 32,116,104,
+    101,110, 10, 32, 32,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, 32, 32,105,102, 32,116, 32, 97,
+    110,100, 32,116,126, 61, 39, 39, 32,116,104,101,110, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 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, 32, 32,101,108,115,101, 10, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 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, 32, 32,101,110,100, 10, 32,
+     32,114,101,116,117,114,110, 32, 49, 10, 32,101,110,100, 10,
+     32,114,101,116,117,114,110, 32, 48, 10,101,110,100, 10, 10,
+     45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,
+    115,116,114,117, 99,116,111,114, 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, 10, 32,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, 32,116, 58, 98,117,
+    105,108,100,110, 97,109,101,115, 40, 41, 10, 32,116, 58, 99,
+    104,101, 99,107,110, 97,109,101, 40, 41, 10, 32,116, 58, 99,
+    104,101, 99,107,116,121,112,101, 40, 41, 10, 32,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, 32,105,102, 32,110,111,116, 32,105,115,
+    101,110,117,109, 40,102,116, 41, 32,116,104,101,110, 10,  9,
+    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, 32,101,110,100, 10,
+     10, 32,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, 32,  9,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, 32,101,110,100, 10, 10, 32,114,101,116,117,114,
+    110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,
+    115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,
+    101, 99,116,115, 32,116,104,101, 32,115,116,114,105,110,103,
+     32,100,101, 99,108, 97,114, 97,116,105,111,110, 46, 10, 45,
+     45, 32, 84,104,101, 32,107,105,110,100, 32,111,102, 32,100,
+    101, 99,108, 97,114, 97,116,105,111,110, 32, 99, 97,110, 32,
+     98,101, 32, 34,118, 97,114, 34, 32,111,114, 32, 34,102,117,
+    110, 99, 34, 46, 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, 10, 32, 45, 45, 32,101,108,105,109,105,110, 97,
+    116,101, 32,115,112, 97, 99,101,115, 32,105,102, 32,100,101,
+    102, 97,117,108,116, 32,118, 97,108,117,101, 32,105,115, 32,
+    112,114,111,118,105,100,101,100, 10, 32,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, 32,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, 10, 32,108,111, 99, 97,108, 32,100,101,102, 98, 44,
+    116,109,112,100,101,102, 10, 32,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, 32,105,102, 32,100,101,102, 98, 32,116,104,
+    101,110, 10, 32,  9,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, 32,101,108,115,101, 10, 32,  9,116,
+    109,112,100,101,102, 32, 61, 32, 39, 39, 10, 32,101,110,100,
+     10, 32,105,102, 32,107,105,110,100, 32, 61, 61, 32, 34,118,
+     97,114, 34, 32,116,104,101,110, 10, 32, 32, 45, 45, 32, 99,
+    104,101, 99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,
+    118,111,105,100, 10, 32, 32,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, 32, 32, 32,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, 32, 32,
+    101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45, 32, 99,
+    104,101, 99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,
+    109,111,100, 32,116,121,112,101, 42, 38, 32,110, 97,109,101,
+     10, 32,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, 32,105,102, 32,116, 46,
+    110, 32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32,105,
+    102, 32,107,105,110,100, 32, 61, 61, 32, 39,102,117,110, 99,
+     39, 32,116,104,101,110, 10, 32, 32, 32,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, 32, 32,101,110,100, 10,
+     32, 32, 45, 45,108,111, 99, 97,108, 32,109, 32, 61, 32,115,
+    112,108,105,116, 40,116, 91, 49, 93, 44, 39, 37,115, 37,115,
+     42, 39, 41, 10, 32, 32,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, 32, 32,
+    114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,114, 97,
+    116,105,111,110,123, 10, 32, 32, 32,110, 97,109,101, 32, 61,
+     32,116, 91, 50, 93, 46, 46,116,109,112,100,101,102, 44, 10,
+     32, 32, 32,112,116,114, 32, 61, 32, 39, 42, 39, 44, 10, 32,
+     32, 32,114,101,116, 32, 61, 32, 39, 38, 39, 44, 10, 32, 32,
+     32, 45, 45,116,121,112,101, 32, 61, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,109, 91,109,
+     46,110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,108, 41,
+     44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109,
+     46,110, 93, 44, 10, 32, 32, 32,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, 32, 32, 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, 44, 10, 32, 32, 32,107,105,110,100, 32, 61, 32,
+    107,105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,102,
+    111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 42, 42,
+     32,110, 97,109,101, 10, 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, 37, 42, 39, 41, 10, 32,105,102, 32,116, 46,
+    110, 32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32,105,
+    102, 32,107,105,110,100, 32, 61, 61, 32, 39,102,117,110, 99,
+     39, 32,116,104,101,110, 10, 32, 32, 32,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, 32, 32,101,110,100, 10,
+     32, 32, 45, 45,108,111, 99, 97,108, 32,109, 32, 61, 32,115,
+    112,108,105,116, 40,116, 91, 49, 93, 44, 39, 37,115, 37,115,
+     42, 39, 41, 10, 32, 32,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, 32, 32,
+    114,101,116,117,114,110, 32, 95, 68,101, 99,108, 97,114, 97,
+    116,105,111,110,123, 10, 32, 32, 32,110, 97,109,101, 32, 61,
+     32,116, 91, 50, 93, 46, 46,116,109,112,100,101,102, 44, 10,
+     32, 32, 32,112,116,114, 32, 61, 32, 39, 42, 39, 44, 10, 32,
+     32, 32,114,101,116, 32, 61, 32, 39, 42, 39, 44, 10, 32, 32,
+     32, 45, 45,116,121,112,101, 32, 61, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,109, 91,109,
+     46,110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,108, 41,
+     44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109,
+     46,110, 93, 44, 10, 32, 32, 32,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, 32, 32, 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, 44, 10, 32, 32, 32,107,105,110,100, 32, 61, 32,
+    107,105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10, 10,
+     32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,102,
+    111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 38, 32,
+    110, 97,109,101, 10, 32,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, 32,105,102, 32,116, 46,110, 32, 61, 61, 32, 50, 32,
+    116,104,101,110, 10, 32, 32, 45, 45,108,111, 99, 97,108, 32,
+    109, 32, 61, 32,115,112,108,105,116, 40,116, 91, 49, 93, 44,
+     39, 37,115, 37,115, 42, 39, 41, 10, 32, 32,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, 32, 32,114,101,116,117,114,110, 32, 95, 68,101,
+     99,108, 97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110,
+     97,109,101, 32, 61, 32,116, 91, 50, 93, 46, 46,116,109,112,
+    100,101,102, 44, 10, 32, 32, 32,112,116,114, 32, 61, 32, 39,
+     38, 39, 44, 10, 32, 32, 32, 45, 45,116,121,112,101, 32, 61,
+     32,114,101, 98,117,105,108,100, 95,116,101,109,112,108, 97,
+    116,101, 40,109, 91,109, 46,110, 93, 44, 32,116, 98, 44, 32,
+    116,105,109,112,108, 41, 44, 10, 32, 32, 32,116,121,112,101,
+     32, 61, 32,109, 91,109, 46,110, 93, 44, 10, 32, 32, 32,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, 32, 32, 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, 44, 10, 32, 32, 32,107,
+    105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32,125, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99,107,
+     32,116,104,101, 32,102,111,114,109, 58, 32,109,111,100, 32,
+    116,121,112,101, 42, 32,110, 97,109,101, 10, 32,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, 32,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, 32,105,102, 32,116, 46,110,
+     32, 61, 61, 32, 50, 32,116,104,101,110, 10, 32, 32,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, 32, 45, 45, 32,114,
+    101,115,116,111,114,101, 32, 42, 32,105,110, 32,100,105,109,
+    101,110,115,105,111,110, 32,101,120,112,114,101,115,115,105,
+    111,110, 10, 32, 32, 45, 45,108,111, 99, 97,108, 32,109, 32,
+     61, 32,115,112,108,105,116, 40,116, 91, 49, 93, 44, 39, 37,
+    115, 37,115, 42, 39, 41, 10, 32, 32,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, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110, 97,109,
+    101, 32, 61, 32,116, 91, 50, 93, 46, 46,116,109,112,100,101,
+    102, 44, 10, 32, 32, 32,112,116,114, 32, 61, 32, 39, 42, 39,
+     44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,109, 91,109,
+     46,110, 93, 44, 10, 32, 32, 32, 45, 45,116,121,112,101, 32,
+     61, 32,114,101, 98,117,105,108,100, 95,116,101,109,112,108,
+     97,116,101, 40,109, 91,109, 46,110, 93, 44, 32,116, 98, 44,
+     32,116,105,109,112,108, 41, 44, 10, 32, 32, 32,109,111,100,
+     32, 61, 32, 99,111,110, 99, 97,116, 40,109, 44, 49, 44,109,
+     46,110, 45, 49, 41, 32, 32, 32, 44, 10, 32, 32, 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, 44, 10, 32, 32, 32,
+    107,105,110,100, 32, 61, 32,107,105,110,100, 10, 32, 32,125,
+     10, 32,101,110,100, 10, 10, 32,105,102, 32,107,105,110,100,
+     32, 61, 61, 32, 39,118, 97,114, 39, 32,116,104,101,110, 10,
+     32, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,104,101, 32,
+    102,111,114,109, 58, 32,109,111,100, 32,116,121,112,101, 32,
+    110, 97,109,101, 10, 32, 32, 45, 45,116, 32, 61, 32,115,112,
+    108,105,116, 40,115, 44, 39, 37,115, 37,115, 42, 39, 41, 10,
+     32, 32,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,
+     32, 32,108,111, 99, 97,108, 32,118, 10, 32, 32,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, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110, 97,109,
+    101, 32, 61, 32,118, 46, 46,116,109,112,100,101,102, 44, 10,
+     32, 32, 32, 45, 45,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,
+     91,116, 46,110, 93, 44, 32,116, 98, 44, 32,116,105,109,112,
+    108, 41, 44, 10, 32, 32, 32,116,121,112,101, 32, 61, 32,116,
+     91,116, 46,110, 93, 44, 10, 32, 32, 32,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, 32, 32, 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, 44, 10, 32, 32, 32,107,105,110,100, 32,
+     61, 32,107,105,110,100, 10, 32, 32,125, 10, 10, 32,101,108,
+    115,101, 32, 45, 45, 32,107,105,110,100, 32, 61, 61, 32, 34,
+    102,117,110, 99, 34, 10, 10, 32, 32, 45, 45, 32, 99,104,101,
+     99,107, 32,116,104,101, 32,102,111,114,109, 58, 32,109,111,
+    100, 32,116,121,112,101, 32,110, 97,109,101, 10, 32, 32, 45,
+     45,116, 32, 61, 32,115,112,108,105,116, 40,115, 44, 39, 37,
+    115, 37,115, 42, 39, 41, 10, 32, 32,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, 32, 32,108,111, 99, 97,108, 32,
+    118, 32, 61, 32,116, 91,116, 46,110, 93, 32, 32, 45, 45, 32,
+    108, 97,115,116, 32,119,111,114,100, 32,105,115, 32,116,104,
+    101, 32,102,117,110, 99,116,105,111,110, 32,110, 97,109,101,
+     10, 32, 32,108,111, 99, 97,108, 32,116,112, 44,109,100, 10,
+     32, 32,105,102, 32,116, 46,110, 62, 49, 32,116,104,101,110,
+     10, 32, 32, 32,116,112, 32, 61, 32,116, 91,116, 46,110, 45,
+     49, 93, 10, 32, 32, 32,109,100, 32, 61, 32, 99,111,110, 99,
+     97,116, 40,116, 44, 49, 44,116, 46,110, 45, 50, 41, 10, 32,
+     32,101,110,100, 10, 32, 32, 45, 45,105,102, 32,116,112, 32,
+    116,104,101,110, 32,116,112, 32, 61, 32,114,101, 98,117,105,
+    108,100, 95,116,101,109,112,108, 97,116,101, 40,116,112, 44,
+     32,116, 98, 44, 32,116,105,109,112,108, 41, 32,101,110,100,
+     10, 32, 32,114,101,116,117,114,110, 32, 95, 68,101, 99,108,
+     97,114, 97,116,105,111,110,123, 10, 32, 32, 32,110, 97,109,
+    101, 32, 61, 32,118, 44, 10, 32, 32, 32,116,121,112,101, 32,
+     61, 32,116,112, 44, 10, 32, 32, 32,109,111,100, 32, 61, 32,
+    109,100, 44, 10, 32, 32, 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, 44, 10, 32, 32, 32,107,105,110,100, 32, 61,
+     32,107,105,110,100, 10, 32, 32,125, 10, 32,101,110,100, 10,
+     10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,118, 97,114,105, 97,
+     98,108,101, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45,
+     32, 86, 97,114,105, 97, 98,108,101, 32, 99,108, 97,115,115,
+     10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,
+     97, 32,101,120,116,101,114,110, 32,118, 97,114,105, 97, 98,
+    108,101, 32,111,114, 32, 97, 32,112,117, 98,108,105, 99, 32,
+    109,101,109, 98,101,114, 32,111,102, 32, 97, 32, 99,108, 97,
+    115,115, 46, 10, 45, 45, 32, 83,116,111,114,101,115, 32, 97,
+    108,108, 32,102,105,101,108,100,115, 32,112,114,101,115,101,
+    110,116, 32,105,110, 32, 97, 32,100,101, 99,108, 97,114, 97,
+    116,105,111,110, 46, 10, 99,108, 97,115,115, 86, 97,114,105,
+     97, 98,108,101, 32, 61, 32,123, 10, 32, 95,103,101,116, 32,
+     61, 32,123,125, 44, 32, 32, 32, 45, 45, 32,109, 97,112,112,
+    101,100, 32,103,101,116, 32,102,117,110, 99,116,105,111,110,
+    115, 10, 32, 95,115,101,116, 32, 61, 32,123,125, 44, 32, 32,
+     32, 45, 45, 32,109, 97,112,112,101,100, 32,115,101,116, 32,
+    102,117,110, 99,116,105,111,110,115, 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, 10, 45, 45, 32, 80,114,105,110,116, 32,
+    109,101,116,104,111,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,
+    112,114,105,110,116, 32, 40,105,100,101,110,116, 44, 99,108,
+    111,115,101, 41, 10, 32,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, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,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, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, 32,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, 32,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, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    100,101,102, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,100,101,102, 46, 46, 34, 39, 44, 34, 41, 10, 32,112,114,
+    105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,114,101,
+    116, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,114,
+    101,116, 46, 46, 34, 39, 44, 34, 41, 10, 32,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, 10, 45, 45, 32, 71,
+    101,110,101,114, 97,116,101,115, 32, 67, 32,102,117,110, 99,
+    116,105,111,110, 32,110, 97,109,101, 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, 32,108,111, 99, 97,108, 32,112,
+     97,114,101,110,116, 32, 61, 32, 34, 34, 10, 32,108,111, 99,
+     97,108, 32,117,110,115,105,103,110,101,100, 32, 61, 32, 34,
+     34, 10, 32,108,111, 99, 97,108, 32,112,116,114, 32, 61, 32,
+     34, 34, 10, 10, 32,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, 10, 32,105,102,
+     32,112, 32,116,104,101,110, 10, 32,  9,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,  9,  9,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,  9,101,108,115,
+    101, 10,  9, 32, 32,112, 97,114,101,110,116, 32, 61, 32, 34,
+     95, 34, 32, 46, 46, 32,112, 10,  9,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32,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, 32,
+     32,117,110,115,105,103,110,101,100, 32, 61, 32, 34, 95,117,
+    110,115,105,103,110,101,100, 34, 10, 32,101,110,100, 10, 10,
+     32,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, 32,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, 32,101,110,100, 10, 10, 32,108,111, 99,
+     97,108, 32,110, 97,109,101, 32, 61, 32, 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, 10,  9,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, 32,114,101,116,117,114,110, 32,
+    110, 97,109,101, 10, 10,101,110,100, 10, 10, 45, 45, 32, 99,
+    104,101, 99,107, 32,105,102, 32,105,116, 32,105,115, 32, 97,
+     32,118, 97,114,105, 97, 98,108,101, 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, 32,114,101,116,117,114,110, 32,116,114,117,101, 10,
+    101,110,100, 10, 10, 45, 45, 32,103,101,116, 32,118, 97,114,
+    105, 97, 98,108,101, 32,118, 97,108,117,101, 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, 10,  9,108,111, 99, 97,
+    108, 32,110, 97,109,101, 10,  9,105,102, 32,112,114,111,112,
+     95,103,101,116, 32,116,104,101,110, 10, 10,  9,  9,110, 97,
+    109,101, 32, 61, 32,112,114,111,112, 95,103,101,116, 46, 46,
+     34, 40, 41, 34, 10,  9,101,108,115,101, 10,  9,  9,110, 97,
+    109,101, 32, 61, 32,115,101,108,102, 46,110, 97,109,101, 10,
+      9,101,110,100, 10, 10,  9,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,  9, 32,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,  9,101,108,115,101,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,  9,
+     32,114,101,116,117,114,110, 32, 39,115,101,108,102, 45, 62,
+     39, 46, 46,110, 97,109,101, 10,  9,101,108,115,101, 10,  9,
+     32,114,101,116,117,114,110, 32,110, 97,109,101, 10,  9,101,
+    110,100, 10,101,110,100, 10, 10, 45, 45, 32,103,101,116, 32,
+    118, 97,114,105, 97, 98,108,101, 32,112,111,105,110,116,101,
+    114, 32,118, 97,108,117,101, 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, 32,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, 32, 32,
+    114,101,116,117,114,110, 32, 99,108, 97,115,115, 46, 46, 39,
+     58, 58,112, 39, 10, 32,101,108,115,101,105,102, 32, 99,108,
+     97,115,115, 32,116,104,101,110, 10, 32, 32,114,101,116,117,
+    114,110, 32, 39,115,101,108,102, 45, 62,112, 39, 10, 32,101,
+    108,115,101, 10, 32, 32,114,101,116,117,114,110, 32, 39,112,
+     39, 10, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     87,114,105,116,101, 32, 98,105,110,100,105,110,103, 32,102,
+    117,110, 99,116,105,111,110,115, 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, 10, 32,
+    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, 10,
+      9,108,111, 99, 97,108, 32,112,114,111,112, 95,103,101,116,
+     44,112,114,111,112, 95,115,101,116, 10,  9,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, 10,
+      9,  9, 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,  9,  9,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,
+      9,  9,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,
+      9,  9,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,  9,101,110,100, 10, 10, 32, 45, 45, 32,103,101,
+    116, 32,102,117,110, 99,116,105,111,110, 32, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10,
+     32,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,
+     32, 32,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, 32,101,108,115,101, 10, 32, 32,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, 32,101,110,100, 10,
+     32,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,
+     32,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, 32,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, 32,111,117,116,112,117,116, 40, 34,123,
+     34, 41, 10, 10, 32, 45, 45, 32,100,101, 99,108, 97,114,101,
+     32,115,101,108,102, 44, 32,105,102, 32,116,104,101, 32, 99,
+     97,115,101, 10, 32,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, 32,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, 32, 32,
+    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, 32, 32,
+    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, 32, 32,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, 32,101,108,115,101,105,102, 32,115,116, 97,116,
+    105, 99, 32,116,104,101,110, 10, 32, 32, 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, 32,101,110,100, 10, 10, 10, 32, 45, 45,
+     32, 99,104,101, 99,107, 32,115,101,108,102, 32,118, 97,108,
+    117,101, 10, 32,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,  9, 32,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, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 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,  9,  9,111,117,116,112,117,116, 40, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10, 32,101,110,100, 10,
+     10, 32, 45, 45, 32,114,101,116,117,114,110, 32,118, 97,108,
+    117,101, 10, 32,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, 32,  9,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,  9,111,117,116,112,
+    117,116, 40, 39, 32, 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,  9,111,117,116,112,117,116, 40,
+     39, 35,101,108,115,101, 92,110, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 32, 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,  9,111,117,
+    116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39,
+     41, 10, 32,101,108,115,101, 10,  9,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,  9,105,102, 32,
+    116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 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,  9,101,108,115,101,
+     10,  9,  9,116, 32, 61, 32,115,101,108,102, 46,116,121,112,
+    101, 10,  9,  9,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,  9,  9,  9,111,117,116,112,117,116, 40, 39, 32, 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,  9,
+      9,101,108,115,101, 10,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 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,  9,  9,101,110,100, 10,  9,101,110,100, 10, 32,
+    101,110,100, 10, 32,111,117,116,112,117,116, 40, 39, 32,114,
+    101,116,117,114,110, 32, 49, 59, 39, 41, 10, 32,111,117,116,
+    112,117,116, 40, 39,125, 39, 41, 10, 32,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, 32,111,117,116,112,117,116,
+     40, 39, 92,110, 39, 41, 10, 10, 32, 45, 45, 32,115,101,116,
+     32,102,117,110, 99,116,105,111,110, 32, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 32,
+    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, 32,116,104,101,110, 10, 32, 32,105,102,
+     32, 99,108, 97,115,115, 32,116,104,101,110, 10, 32, 32, 32,
+    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, 32, 32,101,108,115,101, 10, 32, 32, 32,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, 32, 32,101,110,100,
+     10, 32, 32,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, 32, 32,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, 32, 32,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, 32, 32,111,117,116,112,
+    117,116, 40, 34,123, 34, 41, 10, 10, 32, 32, 45, 45, 32,100,
+    101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32,105,102,
+     32,116,104,101, 32, 99, 97,115,101, 10, 32, 32,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, 32, 32, 32,
+    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, 32, 32,
+     32,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, 32, 32, 32,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, 32, 32, 32, 45, 45, 32, 99,104,101, 99,
+    107, 32,115,101,108,102, 32,118, 97,108,117,101, 10,  9,  9,
+    101,110,100, 10, 32, 32, 45, 45, 32, 99,104,101, 99,107, 32,
+    116,121,112,101,115, 10,  9,  9,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,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 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, 32, 32,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, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 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, 32, 32,101,108,115,101,105,102, 32,115,116, 97,116,105,
+     99, 32,116,104,101,110, 10, 32, 32, 32, 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, 32, 32,101,110,100, 10, 10, 32, 32, 45,
+     45, 32, 99,104,101, 99,107, 32,118, 97,114,105, 97, 98,108,
+    101, 32,116,121,112,101, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 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, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32, 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,  9,  9,111,117,116,112,117,
+    116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 10,
+     32, 32, 45, 45, 32, 97,115,115,105,103,110, 32,118, 97,108,
+    117,101, 10,  9,  9,108,111, 99, 97,108, 32,100,101,102, 32,
+     61, 32, 48, 10,  9,  9,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,  9,  9,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, 32, 45, 45, 32,105,115, 32,115,
+    116,114,105,110,103, 10,  9,  9, 32,111,117,116,112,117,116,
+     40, 39, 32,115,116,114,110, 99,112,121, 40, 39, 41, 10,  9,
+      9,  9,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,  9,  9,  9,
+      9,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,  9,  9,
+      9,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32,116,
+    104,101,110, 10,  9,  9,  9,  9,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,  9,  9,  9,101,108,115,101, 10,  9,
+      9,  9,  9,111,117,116,112,117,116, 40,115,101,108,102, 46,
+    110, 97,109,101, 41, 10,  9,  9,  9,101,110,100, 10,  9,  9,
+      9,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,  9,  9,101,108,115,101, 10,  9,  9,  9,108,111,
+     99, 97,108, 32,112,116,114, 32, 61, 32, 39, 39, 10,  9,  9,
+      9,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,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 39, 41, 10,  9,  9,  9,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,  9,
+      9,  9,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,  9,  9,  9,
+      9,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,  9,  9,  9,101,108,115,101,
+    105,102, 32, 99,108, 97,115,115, 32,116,104,101,110, 10,  9,
+      9,  9,  9,111,117,116,112,117,116, 40, 39,115,101,108,102,
+     45, 62, 39, 46, 46,110, 97,109,101, 41, 10,  9,  9,  9,101,
+    108,115,101, 10,  9,  9,  9,  9,111,117,116,112,117,116, 40,
+    110, 97,109,101, 41, 10,  9,  9,  9,101,110,100, 10,  9,  9,
+      9,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,
+      9,  9,  9,105,102, 32,112,114,111,112, 95,115,101,116, 32,
+    116,104,101,110, 10,  9,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 40, 39, 41, 10,  9,  9,  9,101,108,115,101, 10,  9,
+      9,  9,  9,111,117,116,112,117,116, 40, 39, 32, 61, 32, 39,
+     41, 10,  9,  9,  9,101,110,100, 10,  9,  9,  9,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,  9,  9,  9,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,  9,
+      9,  9,105,102, 32,110,111,116, 32,116, 32,116,104,101,110,
+     10,  9,  9,  9,  9,111,117,116,112,117,116, 40, 39, 42, 39,
+     41, 10,  9,  9,  9,101,110,100, 10,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39, 41, 32, 39, 41, 10,  9,  9,  9,105,102,
+     32,116, 32,116,104,101,110, 10,  9,  9,  9,  9,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,  9,  9,  9,  9,  9,111,117,
+    116,112,117,116, 40, 39, 40,105,110,116, 41, 32, 39, 41, 10,
+      9,  9,  9,  9,101,110,100, 10,  9,  9,  9,  9,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,  9,  9,  9,
+    101,108,115,101, 10,  9,  9,  9,  9,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,  9,  9,  9,101,
+    110,100, 10,  9,  9,  9,105,102, 32,112,114,111,112, 95,115,
+    101,116, 32,116,104,101,110, 10,  9,  9,  9,  9,111,117,116,
+    112,117,116, 40, 34, 41, 34, 41, 10,  9,  9,  9,101,110,100,
+     10,  9,  9,  9,111,117,116,112,117,116, 40, 34, 59, 34, 41,
+     10,  9,  9,101,110,100, 10, 32, 32,111,117,116,112,117,116,
+     40, 39, 32,114,101,116,117,114,110, 32, 48, 59, 39, 41, 10,
+     32, 32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10, 32,
+     32,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, 32,
+     32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10, 32,
+    101,110,100, 10, 10,101,110,100, 10, 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, 10,  9,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,  9,
+      9,114,101,116,117,114,110, 10,  9,101,110,100, 10, 32,112,
+    114,101, 32, 61, 32,112,114,101, 32,111,114, 32, 39, 39, 10,
+     32,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, 32,105,102,
+     32,110,111,116, 32,112, 97,114,101,110,116, 32,116,104,101,
+    110, 10, 32, 32,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, 32, 32, 32,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,
+     32, 32, 32, 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,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 32,105,102, 32,
+    115,101,108,102, 46, 99,115,101,116,110, 97,109,101, 32,116,
+    104,101,110, 10, 32, 32,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,
+     32,101,108,115,101, 10, 32, 32,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, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45, 32,
+     73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,114,
+    117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110, 32,
+     95, 86, 97,114,105, 97, 98,108,101, 32, 40,116, 41, 10, 32,
+    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,
+     32, 97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,
+    117,114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,
+    111,110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,
+    120,112,101, 99,116,115, 32, 97, 32,115,116,114,105,110,103,
+     32,114,101,112,114,101,115,101,110,116,105,110,103, 32,116,
+    104,101, 32,118, 97,114,105, 97, 98,108,101, 32,100,101, 99,
+    108, 97,114, 97,116,105,111,110, 46, 10,102,117,110, 99,116,
+    105,111,110, 32, 86, 97,114,105, 97, 98,108,101, 32, 40,115,
+     41, 10, 32,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 97,114,114, 97,121,
+     32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,
+    101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32,
+     67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,
+    102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,
+    108, 32, 49, 57, 57, 57, 10, 45, 45, 32, 36, 73,100, 58, 32,
+     97,114,114, 97,121, 46,108,117, 97, 44,118, 32, 49, 46, 49,
+     32, 50, 48, 48, 48, 47, 49, 49, 47, 48, 54, 32, 50, 50, 58,
+     48, 51, 58, 53, 55, 32, 99,101,108,101,115, 32, 69,120,112,
+     32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,
+    101, 32,105,115, 32,102,114,101,101, 32,115,111,102,116,119,
+     97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,
+    100,105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,
+    110,100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116,
+     46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,
+    114,101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,
+    101,117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110,
+     32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44,
+     32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,
+    104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,
+    103, 97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,
+    100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44,
+     32,115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,
+    101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,
+    101,110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105,
+     99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, 32, 65,
+    114,114, 97,121, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,
+    101,112,114,101,115,101,110,116,115, 32, 97, 32,101,120,116,
+    101,114,110, 32, 97,114,114, 97,121, 32,118, 97,114,105, 97,
+     98,108,101, 32,111,114, 32, 97, 32,112,117, 98,108,105, 99,
+     32,109,101,109, 98,101,114, 32,111,102, 32, 97, 32, 99,108,
+     97,115,115, 46, 10, 45, 45, 32, 83,116,111,114,101,115, 32,
+     97,108,108, 32,102,105,101,108,100,115, 32,112,114,101,115,
+    101,110,116, 32,105,110, 32, 97, 32,100,101, 99,108, 97,114,
+     97,116,105,111,110, 46, 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, 10, 45, 45, 32, 80,114,105,
+    110,116, 32,109,101,116,104,111,100, 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, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 65,114,114, 97,121,123, 34, 41, 10, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10, 32,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, 32,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32,112,116,114,
+     32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102, 46,112,116,
+    114, 46, 46, 34, 39, 44, 34, 41, 10, 32,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, 32,112,114,105,110,116, 40,
+    105,100,101,110,116, 46, 46, 34, 32,100,101,102, 32, 32, 61,
+     32, 39, 34, 46, 46,115,101,108,102, 46,100,101,102, 46, 46,
+     34, 39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,
+    101,110,116, 46, 46, 34, 32,100,105,109, 32, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,100,105,109, 46, 46, 34, 39,
+     44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,110,
+    116, 46, 46, 34, 32,114,101,116, 32, 32, 61, 32, 39, 34, 46,
+     46,115,101,108,102, 46,114,101,116, 46, 46, 34, 39, 44, 34,
+     41, 10, 32,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, 10, 45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,
+    105,116, 32,105,115, 32, 97, 32,118, 97,114,105, 97, 98,108,
+    101, 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, 32,114,101,116,117,114,110, 32,116,
+    114,117,101, 10,101,110,100, 10, 10, 10, 45, 45, 32,103,101,
+    116, 32,118, 97,114,105, 97, 98,108,101, 32,118, 97,108,117,
+    101, 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, 32,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, 32, 32,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, 32,101,108,115,101,105,102, 32, 99,108, 97,115,115, 32,
+    116,104,101,110, 10, 32, 32,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, 32,101,108,115,101, 10, 32, 32,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, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
+     32, 87,114,105,116,101, 32, 98,105,110,100,105,110,103, 32,
+    102,117,110, 99,116,105,111,110,115, 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, 32,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, 10, 32, 45, 45,
+     32,103,101,116, 32,102,117,110, 99,116,105,111,110, 32, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 10, 32,105,102, 32, 99,108, 97,115,115, 32,116,104,
+    101,110, 10, 32, 32,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, 32,101,108,115,101, 10, 32, 32,
+    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, 32,101,
+    110,100, 10, 32,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, 32,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, 32,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, 32,111,117,116,112,117,116,
+     40, 34,123, 34, 41, 10, 32,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, 10, 32, 45, 45, 32,100,101, 99,108, 97,
+    114,101, 32,115,101,108,102, 44, 32,105,102, 32,116,104,101,
+     32, 99, 97,115,101, 10, 32,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, 32,
+    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,
+     32, 32,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, 32, 32,
+    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, 32,
+     32,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, 32, 32,111,117,116,112,117,116, 40, 39,
+     32,115,101,108,102, 32, 61, 32, 39, 41, 10, 32, 32,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, 32, 32,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, 32,101,
+    108,115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,
+    101,110, 10, 32, 32, 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,
+     32,101,110,100, 10, 10, 32, 45, 45, 32, 99,104,101, 99,107,
+     32,105,110,100,101,120, 10,  9,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,  9,111,117,
+    116,112,117,116, 40, 39, 32,123, 39, 41, 10,  9,111,117,116,
+    112,117,116, 40, 39, 32, 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, 32,111,117,116,112,117,116, 40, 39, 32, 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,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 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,  9,111,117,116,112,117,116,
+     40, 39, 32,125, 39, 41, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10,  9,105,102,
+     32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,104,101,
+    110, 32, 45, 45, 32,102,111,114, 32, 99,111,109,112, 97,116,
+    105, 98,105,108,105,116,121, 32,119,105,116,104, 32,116,111,
+    108,117, 97, 53, 32, 63, 10,  9,  9,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,  9,101,108,115,101,
+     10,  9,  9,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,  9,101,110,100, 10,  9,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,  9,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,  9, 32, 32,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,  9,101,108,115,101, 10,  9,
+     32, 32,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,  9,101,110,100, 10, 32,111,117,116,112,117,116, 40,
+     39, 32, 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,  9,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10, 10, 32, 45, 45, 32,114,101,
+    116,117,114,110, 32,118, 97,108,117,101, 10, 32,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, 32,
+    105,102, 32,116, 32,116,104,101,110, 10, 32, 32,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, 32,101,108,115,101, 10,  9,  9,116, 32, 61, 32,
+    115,101,108,102, 46,116,121,112,101, 10, 32, 32,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, 32, 32, 32,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, 32, 32,101,
+    108,115,101, 10, 32, 32, 32,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, 32, 32,101,110,100, 10, 32,101,110,
+    100, 10, 32,111,117,116,112,117,116, 40, 39, 32,114,101,116,
+    117,114,110, 32, 49, 59, 39, 41, 10, 32,111,117,116,112,117,
+    116, 40, 39,125, 39, 41, 10, 32,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, 32,111,117,116,112,117,116, 40, 39,
+     92,110, 39, 41, 10, 10, 32, 45, 45, 32,115,101,116, 32,102,
+    117,110, 99,116,105,111,110, 32, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
+     45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 10, 32,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, 32, 32,105,102, 32, 99,108, 97,
+    115,115, 32,116,104,101,110, 10, 32, 32, 32,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, 32, 32,
+    101,108,115,101, 10, 32, 32, 32,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, 32, 32,101,110,100, 10, 32, 32,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, 32, 32,
+    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, 32, 32,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, 32, 32,111,117,116,112,117,116, 40, 34,
+    123, 34, 41, 10, 10, 32, 32, 45, 45, 32,100,101, 99,108, 97,
+    114,101, 32,105,110,100,101,120, 10, 32, 32,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, 10, 32, 32, 45, 45, 32,
+    100,101, 99,108, 97,114,101, 32,115,101,108,102, 44, 32,105,
+    102, 32,116,104,101, 32, 99, 97,115,101, 10, 32, 32,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, 32, 32,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, 32, 32, 32,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, 32, 32, 32,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, 32, 32, 32,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,
+     32, 32, 32,111,117,116,112,117,116, 40, 39, 32,115,101,108,
+    102, 32, 61, 32, 39, 41, 10, 32, 32, 32,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,
+     32, 32, 32,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, 32, 32,101,108,
+    115,101,105,102, 32,115,116, 97,116,105, 99, 32,116,104,101,
+    110, 10, 32, 32, 32, 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,
+     32, 32,101,110,100, 10, 10, 32, 32, 45, 45, 32, 99,104,101,
+     99,107, 32,105,110,100,101,120, 10,  9, 32,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,
+      9, 32,111,117,116,112,117,116, 40, 39, 32,123, 39, 41, 10,
+      9, 32,111,117,116,112,117,116, 40, 39, 32, 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, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 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, 32, 32,111,117,116,112,117,116, 40,
+     39, 32, 32, 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,
+      9,  9,111,117,116,112,117,116, 40, 39, 32,125, 39, 41, 10,
+      9,  9,111,117,116,112,117,116, 40, 39, 35,101,110,100,105,
+    102, 92,110, 39, 41, 10, 10,  9,105,102, 32,102,108, 97,103,
+    115, 91, 39, 49, 39, 93, 32,116,104,101,110, 32, 45, 45, 32,
+    102,111,114, 32, 99,111,109,112, 97,116,105, 98,105,108,105,
+    116,121, 32,119,105,116,104, 32,116,111,108,117, 97, 53, 32,
+     63, 10,  9,  9,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,  9,101,108,115,101, 10,  9,  9,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,  9,101,110,
+    100, 10, 10,  9, 32,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,  9,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,  9, 32, 32,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,  9,101,108,115,101, 10,  9, 32, 32,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,  9,
+    101,110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 32,
+     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,  9,  9,111,117,116,112,117,116, 40, 39, 35,101,110,100,
+    105,102, 92,110, 39, 41, 10, 10, 32, 32, 45, 45, 32, 97,115,
+    115,105,103,110, 32,118, 97,108,117,101, 10, 32, 32,108,111,
+     99, 97,108, 32,112,116,114, 32, 61, 32, 39, 39, 10, 32, 32,
+    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, 32, 32,111,117,116,112,117,116, 40, 39,
+     32, 39, 41, 10, 32, 32,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, 32, 32, 32,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, 32, 32,101,108,115,101,105,102,
+     32, 99,108, 97,115,115, 32,116,104,101,110, 10, 32, 32, 32,
+    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,
+     32, 32,101,108,115,101, 10, 32, 32, 32,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,
+     32, 32,101,110,100, 10, 32, 32,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, 32, 32,111,117,116,112,117,116,
+     40, 39, 32, 61, 32, 39, 41, 10, 32, 32,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, 32, 32,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, 32, 32,105,102,
+     32,110,111,116, 32,116, 32,116,104,101,110, 10, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 42, 39, 41, 10, 32, 32,101,
+    110,100, 10, 32, 32,111,117,116,112,117,116, 40, 39, 41, 32,
+     39, 41, 10, 32, 32,108,111, 99, 97,108, 32,100,101,102, 32,
+     61, 32, 48, 10, 32, 32,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, 32, 32,105,102, 32,116, 32,116,104,101,110, 10,
+     32, 32, 32,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, 32, 32,101,108,115,101, 10, 32, 32, 32,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, 32, 32,101,110,100, 10, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32,114,101,116,117,114,110, 32, 48, 59, 39, 41,
+     10, 32, 32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10,
+     32, 32,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,
+     32, 32,111,117,116,112,117,116, 40, 39, 92,110, 39, 41, 10,
+     32,101,110,100, 10, 10,101,110,100, 10, 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, 32,112,114,101, 32, 61, 32,112,114,101, 32,111,114, 32,
+     39, 39, 10, 32,105,102, 32,115,101,108,102, 46, 99,115,101,
+    116,110, 97,109,101, 32,116,104,101,110, 10, 32, 32,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, 32,101,108,115,101, 10, 32, 32,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, 32,101,110,100, 10,101,110,100, 10, 10, 45, 45,
+     32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,115,116,
+    114,117, 99,116,111,114, 10,102,117,110, 99,116,105,111,110,
+     32, 95, 65,114,114, 97,121, 32, 40,116, 41, 10, 32,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, 32, 97,112,112,101,
+    110,100, 40,116, 41, 10, 32,114,101,116,117,114,110, 32,116,
+     10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,114,
+    117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,116,
+    115, 32, 97, 32,115,116,114,105,110,103, 32,114,101,112,114,
+    101,115,101,110,116,105,110,103, 32,116,104,101, 32,118, 97,
+    114,105, 97, 98,108,101, 32,100,101, 99,108, 97,114, 97,116,
+    105,111,110, 46, 10,102,117,110, 99,116,105,111,110, 32, 65,
+    114,114, 97,121, 32, 40,115, 41, 10, 32,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,102,117,110, 99,116,
+    105,111,110, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 10, 45,
+     45, 32, 70,117,110, 99,116,105,111,110, 32, 99,108, 97,115,
+    115, 10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115,
+     32, 97, 32,102,117,110, 99,116,105,111,110, 32,111,114, 32,
+     97, 32, 99,108, 97,115,115, 32,109,101,116,104,111,100, 46,
+     10, 45, 45, 32, 84,104,101, 32,102,111,108,108,111,119,105,
+    110,103, 32,102,105,101,108,100,115, 32, 97,114,101, 32,115,
+    116,111,114,101,100, 58, 10, 45, 45, 32, 32,109,111,100, 32,
+     32, 61, 32,116,121,112,101, 32,109,111,100,105,102,105,101,
+    114,115, 10, 45, 45, 32, 32,116,121,112,101, 32, 61, 32,116,
+    121,112,101, 10, 45, 45, 32, 32,112,116,114, 32, 32, 61, 32,
+     34, 42, 34, 32,111,114, 32, 34, 38, 34, 44, 32,105,102, 32,
+    114,101,112,114,101,115,101,110,116,105,110,103, 32, 97, 32,
+    112,111,105,110,116,101,114, 32,111,114, 32, 97, 32,114,101,
+    102,101,114,101,110, 99,101, 10, 45, 45, 32, 32,110, 97,109,
+    101, 32, 61, 32,110, 97,109,101, 10, 45, 45, 32, 32,108,110,
+     97,109,101, 32, 61, 32,108,117, 97, 32,110, 97,109,101, 10,
+     45, 45, 32, 32, 97,114,103,115, 32, 32, 61, 32,108,105,115,
+    116, 32,111,102, 32, 97,114,103,117,109,101,110,116, 32,100,
+    101, 99,108, 97,114, 97,116,105,111,110,115, 10, 45, 45, 32,
+     32, 99,111,110,115,116, 32, 61, 32,105,102, 32,105,116, 32,
+    105,115, 32, 97, 32,109,101,116,104,111,100, 32,114,101, 99,
+    101,105,118,105,110,103, 32, 97, 32, 99,111,110,115,116, 32,
+     34,116,104,105,115, 34, 46, 10, 99,108, 97,115,115, 70,117,
+    110, 99,116,105,111,110, 32, 61, 32,123, 10, 32,109,111,100,
+     32, 61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32,
+     39, 39, 44, 10, 32,112,116,114, 32, 61, 32, 39, 39, 44, 10,
+     32,110, 97,109,101, 32, 61, 32, 39, 39, 44, 10, 32, 97,114,
+    103,115, 32, 61, 32,123,110, 61, 48,125, 44, 10, 32, 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, 10, 45, 45, 32,100,101, 99,108, 97,114,101, 32,116, 97,
+    103,115, 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, 32,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, 32,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,
+      9, 32,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,  9,  9,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,  9,101,
+    110,100, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10, 32, 32,115,101,108,102, 46, 97,
+    114,103,115, 91,105, 93, 58,100,101, 99,108,116,121,112,101,
+     40, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,
+    110,100, 10,101,110,100, 10, 10, 10, 45, 45, 32, 87,114,105,
+    116,101, 32, 98,105,110,100,105,110,103, 32,102,117,110, 99,
+    116,105,111,110, 10, 45, 45, 32, 79,117,116,112,117,116,115,
+     32, 67, 47, 67, 43, 43, 32, 98,105,110,100,105,110,103, 32,
+    102,117,110, 99,116,105,111,110, 46, 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, 10, 32,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, 32, 32, 45, 45, 32,105,110,100,105, 99, 97,116,
+    101, 32,111,118,101,114,108,111, 97,100,101,100, 32,102,117,
+    110, 99, 10, 32,108,111, 99, 97,108, 32,110,114,101,116, 32,
+     61, 32, 48, 32, 32, 32, 32, 32, 32, 45, 45, 32,110,117,109,
+     98,101,114, 32,111,102, 32,114,101,116,117,114,110,101,100,
+     32,118, 97,108,117,101,115, 10, 32,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, 32,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, 32,105,102, 32, 99,108, 97,115,115, 32,116,104,101,110,
+     10, 10, 32,  9,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, 32,  9,  9, 45, 45, 32,110,111, 32,
+     99,111,110,115,116,114,117, 99,116,111,114, 32,102,111,114,
+     32, 99,108, 97,115,115,101,115, 32,119,105,116,104, 32,112,
+    117,114,101, 32,118,105,114,116,117, 97,108, 32,109,101,116,
+    104,111,100,115, 10, 32,  9,  9,114,101,116,117,114,110, 10,
+     32,  9,101,110,100, 10, 10, 32,  9,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,  9,  9,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,
+      9,101,108,115,101, 10,  9,  9,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,  9,101,110,100, 10, 32,101,108,115,101, 10,
+     32, 32,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, 32,101,110,100,
+     10, 10, 32,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, 32,
+     32,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, 32, 32,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, 32,101,108,115,101, 10, 32, 32,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, 32, 32,
+    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, 32,101,110,
+    100, 10, 32,111,117,116,112,117,116, 40, 34,123, 34, 41, 10,
+     10, 32, 45, 45, 32, 99,104,101, 99,107, 32,116,121,112,101,
+    115, 10,  9,105,102, 32,111,118,101,114,108,111, 97,100, 32,
+     60, 32, 48, 32,116,104,101,110, 10,  9, 32,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,
+      9,101,110,100, 10,  9,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, 32,111,117,116,112,
+    117,116, 40, 39, 32,105,102, 32, 40, 92,110, 39, 41, 10, 32,
+     45, 45, 32, 99,104,101, 99,107, 32,115,101,108,102, 10, 32,
+    108,111, 99, 97,108, 32,110, 97,114,103, 10, 32,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, 32,105,102, 32, 99,108, 97,115,115, 32,116,
+    104,101,110, 10,  9,  9,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,  9,  9,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,  9,  9,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,  9,  9,  9,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,  9,  9,  9,116,121,112,101, 32,
+     61, 32,115,101,108,102, 46,112, 97,114,101,110,116, 46,116,
+    121,112,101, 10,  9,  9,101,110,100, 10,  9,  9,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,  9,  9,  9,116,121,112,101, 32,
+     61, 32, 34, 99,111,110,115,116, 32, 34, 46, 46,116,121,112,
+    101, 10,  9,  9,101,110,100, 10,  9,  9,111,117,116,112,117,
+    116, 40, 39, 32, 32, 32, 32, 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, 32,101,110,100, 10, 32, 45, 45, 32, 99,104,
+    101, 99,107, 32, 97,114,103,115, 10, 32,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, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,
+    119,104,105,108,101, 32,115,101,108,102, 46, 97,114,103,115,
+     91,105, 93, 32,100,111, 10, 32, 32, 32,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, 32, 32, 32,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, 32, 32, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32, 32, 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, 32, 32,
+     32,101,110,100, 10, 32, 32, 32,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,  9, 32, 32, 32,110, 97,114,103, 32, 61, 32,110,
+     97,114,103, 43, 49, 10, 32, 32, 32,101,110,100, 10, 32, 32,
+     32,105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100, 10,
+     32,101,110,100, 10, 32, 45, 45, 32, 99,104,101, 99,107, 32,
+    101,110,100, 32,111,102, 32,108,105,115,116, 10, 32,111,117,
+    116,112,117,116, 40, 39, 32, 32, 32, 32, 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,  9,111,117,116,112,117,116, 40, 39, 32, 32,103,
+    111,116,111, 32,116,111,108,117, 97, 95,108,101,114,114,111,
+    114, 59, 39, 41, 10, 10, 32,111,117,116,112,117,116, 40, 39,
+     32,101,108,115,101, 92,110, 39, 41, 10,  9,105,102, 32,111,
+    118,101,114,108,111, 97,100, 32, 60, 32, 48, 32,116,104,101,
+    110, 10,  9, 32,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10,  9,101,110,100, 10,  9,111,
+    117,116,112,117,116, 40, 39, 32,123, 39, 41, 10, 10, 32, 45,
+     45, 32,100,101, 99,108, 97,114,101, 32,115,101,108,102, 44,
+     32,105,102, 32,116,104,101, 32, 99, 97,115,101, 10, 32,108,
+    111, 99, 97,108, 32,110, 97,114,103, 10, 32,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, 32,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, 32, 32,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, 32, 32,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, 32, 32,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, 32,101,108,115,101,105,102, 32,
+    115,116, 97,116,105, 99, 32,116,104,101,110, 10, 32, 32, 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, 32,101,110,100, 10, 32,
+     45, 45, 32,100,101, 99,108, 97,114,101, 32,112, 97,114, 97,
+    109,101,116,101,114,115, 10, 32,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, 32,
+     32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32, 32,119,104,
+    105,108,101, 32,115,101,108,102, 46, 97,114,103,115, 91,105,
+     93, 32,100,111, 10, 32, 32, 32,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, 32, 32, 32,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,  9, 32, 32, 32,110, 97,
+    114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32, 32, 32,
+    101,110,100, 10, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10,
+     32, 32,101,110,100, 10, 32,101,110,100, 10, 10, 32, 45, 45,
+     32, 99,104,101, 99,107, 32,115,101,108,102, 10, 32,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,  9, 32,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, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 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,  9, 32,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+     32,101,110,100, 10, 10, 32, 45, 45, 32,103,101,116, 32, 97,
+    114,114, 97,121, 32,101,108,101,109,101,110,116, 32,118, 97,
+    108,117,101,115, 10, 32,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, 32,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, 32, 32,108,111, 99, 97,108, 32,105, 61,
+     49, 10, 32, 32,119,104,105,108,101, 32,115,101,108,102, 46,
+     97,114,103,115, 91,105, 93, 32,100,111, 10, 32, 32, 32,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, 32, 32, 32,
+    110, 97,114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32,
+     32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32,101,110,100,
+     10, 32,101,110,100, 10, 10, 32,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, 32,
+     45, 45, 32, 99, 97,108,108, 32,102,117,110, 99,116,105,111,
+    110, 10, 32,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, 32, 32,111,117,
+    116,112,117,116, 40, 39, 32, 32,100,101,108,101,116,101, 32,
+    115,101,108,102, 59, 39, 41, 10, 32,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, 32, 32,
+    105,102, 32,102,108, 97,103,115, 91, 39, 49, 39, 93, 32,116,
+    104,101,110, 32, 45, 45, 32,102,111,114, 32, 99,111,109,112,
+     97,116,105, 98,105,108,105,116,121, 32,119,105,116,104, 32,
+    116,111,108,117, 97, 53, 32, 63, 10,  9,111,117,116,112,117,
+    116, 40, 39, 32, 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, 32,
+     32,101,108,115,101, 10, 32, 32, 32, 32,111,117,116,112,117,
+    116, 40, 39, 32, 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, 32, 32,101,
+    110,100, 10, 32,101,108,115,101, 10, 32, 32,111,117,116,112,
+    117,116, 40, 39, 32, 32,123, 39, 41, 10, 32, 32,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,
+     32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 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, 32,
+     32, 32,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, 32, 32,101,108,115,101, 10, 32, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 39, 41, 10, 32, 32,101,110,100,
+     10, 32, 32,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, 32, 32, 32,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, 32, 32,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,  9,105,102, 32,111,
+    117,116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,
+    116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, 39,
+     41, 10,  9,101,108,115,101, 10,  9,  9,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,
+      9,101,110,100, 10, 32, 32,101,108,115,101,105,102, 32, 99,
+    108, 97,115,115, 32,116,104,101,110, 10,  9,105,102, 32,111,
+    117,116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,
+    116, 40,115,101,108,102, 46,110, 97,109,101, 44, 39, 40, 39,
+     41, 10,  9,101,108,115,101, 10,  9, 32, 32,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,  9, 32, 32,  9,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,  9, 32,
+     32,101,108,115,101, 10,  9,  9,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,  9, 32, 32,101,110,
+    100, 10,  9,101,110,100, 10, 32, 32,101,108,115,101, 10, 32,
+     32, 32,111,117,116,112,117,116, 40,115,101,108,102, 46,110,
+     97,109,101, 44, 39, 40, 39, 41, 10, 32, 32,101,110,100, 10,
+     10, 32, 32,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,
+     32, 32,  9,111,117,116,112,117,116, 40, 39,115,101,108,102,
+     39, 41, 10,  9,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,  9,  9,111,117,116,112,117,
+    116, 40, 39, 44, 39, 41, 10,  9,101,110,100, 10, 32, 32,101,
+    110,100, 10, 32, 32, 45, 45, 32,119,114,105,116,101, 32,112,
+     97,114, 97,109,101,116,101,114,115, 10, 32, 32,108,111, 99,
+     97,108, 32,105, 61, 49, 10, 32, 32,119,104,105,108,101, 32,
+    115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,100,111,
+     10, 32, 32, 32,115,101,108,102, 46, 97,114,103,115, 91,105,
+     93, 58,112, 97,115,115,112, 97,114, 40, 41, 10, 32, 32, 32,
+    105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,105,102, 32,115,
+    101,108,102, 46, 97,114,103,115, 91,105, 93, 32,116,104,101,
+    110, 10, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 44,
+     39, 41, 10, 32, 32, 32,101,110,100, 10, 32, 32,101,110,100,
+     10, 10, 32, 32,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,  9,111,117,116,112,117,116, 40, 39, 45, 49, 41,
+     59, 39, 41, 10, 32, 32,101,108,115,101, 10,  9,111,117,116,
+    112,117,116, 40, 39, 41, 59, 39, 41, 10, 32, 32,101,110,100,
+     10, 10, 32, 32, 45, 45, 32,114,101,116,117,114,110, 32,118,
+     97,108,117,101,115, 10, 32, 32,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, 32, 32, 32,110,
+    114,101,116, 32, 61, 32,110,114,101,116, 32, 43, 32, 49, 10,
+     32, 32, 32,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, 32, 32, 32,105,102, 32,116, 32,116,104,
+    101,110, 10, 32, 32, 32,  9,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,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32, 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, 32, 32, 32,  9,101,108,115,101, 10,  9, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 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,  9,101,110,100, 10, 32, 32, 32,101,108,115,101, 10,  9,
+      9,  9, 32,116, 32, 61, 32,115,101,108,102, 46,116,121,112,
+    101, 10,  9,  9,  9, 32,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,
+     32, 32, 32, 32,105,102, 32,115,101,108,102, 46,112,116,114,
+     32, 61, 61, 32, 39, 39, 32,116,104,101,110, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32,123, 39,
+     41, 10, 32, 32, 32, 32, 32,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, 32, 32, 32, 32, 32,111,117,
+    116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32, 32, 32,
+    111,117,116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32, 32, 32,111,117,116,112,117,116,
+     40, 39, 35,101,108,115,101, 92,110, 39, 41, 10, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32,
+     32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 32, 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, 32, 32, 32, 32, 32,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+     32, 32, 32, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32,
+     32,125, 39, 41, 10, 32, 32, 32, 32,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, 32, 32, 32, 32, 32,111,117,116,
+    112,117,116, 40, 39, 32, 32, 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, 32, 32, 32, 32,101,108,115,101, 10, 32,
+     32, 32, 32,  9,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,
+      9, 32, 32,111,117,116,112,117,116, 40, 39, 32, 32, 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, 32,
+     32, 32, 32,  9,101,108,115,101, 10,  9,  9, 32, 32, 32, 32,
+     32,111,117,116,112,117,116, 40, 39, 32, 32, 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,  9, 32, 32, 32, 32,101,110,
+    100, 10, 32, 32, 32, 32,101,110,100, 10, 32, 32, 32,101,110,
+    100, 10, 32, 32,101,110,100, 10, 32, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32, 32,119,104,105,108,101, 32,115,101,
+    108,102, 46, 97,114,103,115, 91,105, 93, 32,100,111, 10, 32,
+     32, 32,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, 32, 32, 32,105, 32,
+     61, 32,105, 43, 49, 10, 32, 32,101,110,100, 10, 32, 32,111,
+    117,116,112,117,116, 40, 39, 32, 32,125, 39, 41, 10, 10, 32,
+     32, 45, 45, 32,115,101,116, 32, 97,114,114, 97,121, 32,101,
+    108,101,109,101,110,116, 32,118, 97,108,117,101,115, 10, 32,
+     32,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, 32, 32,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, 32, 32, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,
+     32, 32,119,104,105,108,101, 32,115,101,108,102, 46, 97,114,
+    103,115, 91,105, 93, 32,100,111, 10, 32, 32, 32, 32,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, 32, 32, 32, 32,
+    110, 97,114,103, 32, 61, 32,110, 97,114,103, 43, 49, 10, 32,
+     32, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32, 32, 32,101,
+    110,100, 10, 32, 32,101,110,100, 10, 10, 32, 32, 45, 45, 32,
+    102,114,101,101, 32,100,121,110, 97,109,105, 99, 97,108,108,
+    121, 32, 97,108,108,111, 99, 97,116,101,100, 32, 97,114,114,
+     97,121, 10, 32, 32,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, 32, 32, 32,108,
+    111, 99, 97,108, 32,105, 61, 49, 10, 32, 32, 32,119,104,105,
+    108,101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93,
+     32,100,111, 10, 32, 32, 32, 32,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, 32, 32, 32, 32,105, 32, 61, 32,105, 43, 49, 10,
+     32, 32, 32,101,110,100, 10, 32, 32,101,110,100, 10, 32,101,
+    110,100, 10, 10, 32,111,117,116,112,117,116, 40, 39, 32,125,
+     39, 41, 10, 32,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, 10, 32, 45, 45, 32, 99, 97,108,108, 32,111,
+    118,101,114,108,111, 97,100,101,100, 32,102,117,110, 99,116,
+    105,111,110, 32,111,114, 32,103,101,110,101,114, 97,116,101,
+     32,101,114,114,111,114, 10,  9,105,102, 32,111,118,101,114,
+    108,111, 97,100, 32, 60, 32, 48, 32,116,104,101,110, 10, 10,
+      9,  9,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,  9,  9,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,  9,  9,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,  9,  9,111,117,116,112,117,116, 40, 39, 32,
+    114,101,116,117,114,110, 32, 48, 59, 39, 41, 10,  9,  9,111,
+    117,116,112,117,116, 40, 39, 35,101,110,100,105,102, 92,110,
+     39, 41, 10,  9,101,108,115,101, 10,  9,  9,108,111, 99, 97,
+    108, 32, 95,108,111, 99, 97,108, 32, 61, 32, 34, 34, 10,  9,
+      9,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,  9,  9,  9,
+     95,108,111, 99, 97,108, 32, 61, 32, 34, 95,108,111, 99, 97,
+    108, 34, 10,  9,  9,101,110,100, 10,  9,  9,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,  9,  9,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,  9,101,110,100, 10,
+     32,111,117,116,112,117,116, 40, 39,125, 39, 41, 10, 32,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, 32,111,117,
+    116,112,117,116, 40, 39, 92,110, 39, 41, 10, 10,  9, 45, 45,
+     32,114,101, 99,117,114,115,105,118,101, 32, 99, 97,108,108,
+     32,116,111, 32,119,114,105,116,101, 32,108,111, 99, 97,108,
+     32, 99,111,110,115,116,114,117, 99,116,111,114, 10,  9,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,
+     10,  9,  9,115,101,108,102, 58,115,117,112, 99,111,100,101,
+     40, 49, 41, 10,  9,101,110,100, 10, 10,101,110,100, 10, 10,
+     10, 45, 45, 32,114,101,103,105,115,116,101,114, 32,102,117,
+    110, 99,116,105,111,110, 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,
+     10,  9,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,  9,  9,114,101,
+    116,117,114,110, 10,  9,101,110,100, 10, 10, 32,  9,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,
+     32,  9,  9, 45, 45, 32,110,111, 32, 99,111,110,115,116,114,
+    117, 99,116,111,114, 32,102,111,114, 32, 99,108, 97,115,115,
+    101,115, 32,119,105,116,104, 32,112,117,114,101, 32,118,105,
+    114,116,117, 97,108, 32,109,101,116,104,111,100,115, 10, 32,
+      9,  9,114,101,116,117,114,110, 10, 32,  9,101,110,100, 10,
+     10, 32,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, 32, 32,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,  9, 32, 32,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,  9, 32, 32,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,  9, 32, 32, 45, 45,111,117,116,112,117,116,
+     40, 39, 32,116,111,108,117, 97, 95,115,101,116, 95, 99, 97,
+    108,108, 95,101,118,101,110,116, 40,116,111,108,117, 97, 95,
+     83, 44, 39, 46, 46,115,101,108,102, 46, 99,110, 97,109,101,
+     46, 46, 39, 95,108,111, 99, 97,108, 44, 32, 34, 39, 46, 46,
+    115,101,108,102, 46,112, 97,114,101,110,116, 46,116,121,112,
+    101, 46, 46, 39, 34, 41, 59, 39, 41, 10, 32, 32,101,110,100,
+     10,101,110,100, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,
+    109,101,116,104,111,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, 32,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, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,109,111,100, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,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, 32,
+    112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34, 32,
+    112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,101,108,102,
+     46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10, 32,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, 32,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, 32,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, 32,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, 32,
+    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,
+     32,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, 32,108,111,
+     99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,101, 32,
+    115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,100,111,
+     10, 32, 32,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, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32, 61, 32,
+    105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,110,116,
+     40,105,100,101,110,116, 46, 46, 34, 32,125, 34, 41, 10, 32,
+    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, 10,
+     45, 45, 32, 99,104,101, 99,107, 32,105,102, 32,105,116, 32,
+    114,101,116,117,114,110,115, 32, 97,110, 32,111, 98,106,101,
+     99,116, 32, 98,121, 32,118, 97,108,117,101, 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,  9,108,111,
+     99, 97,108, 32,114, 32, 61, 32,102, 97,108,115,101, 10,  9,
+    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,  9,  9,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,  9, 32,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,  9, 32,114, 32, 61, 32,116,114,117,101, 10,
+      9,101,110,100, 10,  9,108,111, 99, 97,108, 32,105, 61, 49,
+     10,  9,119,104,105,108,101, 32,115,101,108,102, 46, 97,114,
+    103,115, 91,105, 93, 32,100,111, 10,  9,  9,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,  9,  9,105, 32, 61, 32,
+    105, 43, 49, 10,  9,101,110,100, 10,  9,114,101,116,117,114,
+    110, 32,114, 10,101,110,100, 10, 10, 45, 45, 32,100,101,116,
+    101,114,109,105,110,101, 32,108,117, 97, 32,102,117,110, 99,
+    116,105,111,110, 32,110, 97,109,101, 32,111,118,101,114,108,
+    111, 97,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, 32,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, 10, 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, 32, 45, 45, 32,114,101,116,117,
+    114,110,115, 32,116,114,117,101, 32,105,102, 32,116,104,101,
+     32,112, 97,114, 97,109,101,116,101,114, 32,104, 97,115, 32,
+     97,110, 32,111, 98,106,101, 99,116, 32, 97,115, 32,105,116,
+    115, 32,100,101,102, 97,117,108,116, 32,118, 97,108,117,101,
+     10, 10,  9,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, 32, 45, 45, 32,105,116, 32,
+    104, 97,115, 32,110,111, 32,100,101,102, 97,117,108,116, 32,
+    118, 97,108,117,101, 10, 10,  9,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, 10,  9,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, 32, 45, 45, 32, 97, 32,108,105,
+    115,116, 32,111,102, 32,102,108, 97,103,115, 10, 10,  9,  9,
+    114,101,116,117,114,110, 32,116,114,117,101, 10,  9,101,110,
+    100, 10, 10,  9,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, 32, 45, 45, 32,105,116, 39,115, 32, 97, 32,
+    112,111,105,110,116,101,114, 32,119,105,116,104, 32, 97, 32,
+    100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 10, 10,
+      9,  9,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, 32, 45, 45, 32,105,116, 39,115,
+     32, 97, 32,112,111,105,110,116,101,114, 32,119,105,116,104,
+     32, 97,110, 32,105,110,115,116, 97,110, 99,101, 32, 97,115,
+     32,100,101,102, 97,117,108,116, 32,112, 97,114, 97,109,101,
+    116,101,114, 46, 46, 32,105,115, 32,116,104, 97,116, 32,118,
+     97,108,105,100, 63, 10,  9,  9,  9,114,101,116,117,114,110,
+     32,116,114,117,101, 10,  9,  9,101,110,100, 10,  9,  9,114,
+    101,116,117,114,110, 32,102, 97,108,115,101, 32, 45, 45, 32,
+    100,101,102, 97,117,108,116, 32,118, 97,108,117,101, 32,105,
+    115, 32, 39, 78, 85, 76, 76, 39, 32,111,114, 32,115,111,109,
+    101,116,104,105,110,103, 10,  9,101,110,100, 10, 10, 10,  9,
+    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,  9,  9,114,101,116,117,114,110, 32,116,114,
+    117,101, 10,  9,101,110,100, 32, 45, 45, 32,100,101,102, 97,
+    117,108,116, 32,118, 97,108,117,101, 32,105,115, 32, 97, 32,
+     99,111,110,115,116,114,117, 99,116,111,114, 32, 99, 97,108,
+    108, 32, 40,109,111,115,116, 32,108,105,107,101,108,121, 32,
+    102,111,114, 32, 97, 32, 99,111,110,115,116, 32,114,101,102,
+    101,114,101,110, 99,101, 41, 10, 10,  9, 45, 45,105,102, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,112, 97,114,
+     44, 32, 34, 38, 34, 41, 32,116,104,101,110, 10, 10,  9, 45,
+     45,  9,105,102, 32,115,116,114,105,110,103, 46,102,105,110,
+    100, 40,100,101,102, 44, 32, 34, 58, 34, 41, 32,111,114, 32,
+    115,116,114,105,110,103, 46,102,105,110,100, 40,100,101,102,
+     44, 32, 34, 94, 37,115, 42,110,101,119, 37,115, 43, 34, 41,
+     32,116,104,101,110, 10, 10,  9, 45, 45,  9,  9, 45, 45, 32,
+    105,116, 39,115, 32, 97, 32,114,101,102,101,114,101,110, 99,
+    101, 32,119,105,116,104, 32,100,101,102, 97,117,108,116, 32,
+    116,111, 32,115,111,109,101,116,104,105,110,103, 32,108,105,
+    107,101, 32, 67,108, 97,115,115, 58, 58,109,101,109, 98,101,
+    114, 44, 32,111,114, 32, 39,110,101,119, 32, 67,108, 97,115,
+    115, 39, 10,  9, 45, 45,  9,  9,114,101,116,117,114,110, 32,
+    116,114,117,101, 10,  9, 45, 45,  9,101,110,100, 10,  9, 45,
+     45,101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,102,
+     97,108,115,101, 32, 45, 45, 32, 63, 10,101,110,100, 10, 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, 32, 45,
+     45, 32,115,116,114,105,112,115, 32,116,104,101, 32,100,101,
+    102, 97,117,108,116, 32,118, 97,108,117,101, 32,102,114,111,
+    109, 32,116,104,101, 32,108, 97,115,116, 32, 97,114,103,117,
+    109,101,110,116, 10, 10,  9,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,  9,
+    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,  9, 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,  9,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, 10, 10, 10, 45, 45, 32, 73,110,
+    116,101,114,110, 97,108, 32, 99,111,110,115,116,114,117, 99,
+    116,111,114, 10,102,117,110, 99,116,105,111,110, 32, 95, 70,
+    117,110, 99,116,105,111,110, 32, 40,116, 41, 10, 32,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, 10, 32,
+    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,
+     32, 32,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, 32,101,110,
+    100, 10, 10, 32, 97,112,112,101,110,100, 40,116, 41, 10, 32,
+    105,102, 32,116, 58,105,110, 99,108, 97,115,115, 40, 41, 32,
+    116,104,101,110, 10, 32, 45, 45,112,114,105,110,116, 32, 40,
+     39,116, 46,110, 97,109,101, 32,105,115, 32, 39, 46, 46,116,
+     46,110, 97,109,101, 46, 46, 39, 44, 32,112, 97,114,101,110,
+    116, 46,110, 97,109,101, 32,105,115, 32, 39, 46, 46,116, 46,
+    112, 97,114,101,110,116, 46,110, 97,109,101, 41, 10, 32, 32,
+    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, 32, 32, 32,116, 46,110, 97,109,101, 32, 61, 32,
+     39,110,101,119, 39, 10, 32, 32, 32,116, 46,108,110, 97,109,
+    101, 32, 61, 32, 39,110,101,119, 39, 10, 32, 32, 32,116, 46,
+    112, 97,114,101,110,116, 46, 95,110,101,119, 32, 61, 32,116,
+    114,117,101, 10, 32, 32, 32,116, 46,116,121,112,101, 32, 61,
+     32,116, 46,112, 97,114,101,110,116, 46,110, 97,109,101, 10,
+     32, 32, 32,116, 46,112,116,114, 32, 61, 32, 39, 42, 39, 10,
+     32, 32,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, 32,
+     32, 32,116, 46,110, 97,109,101, 32, 61, 32, 39,100,101,108,
+    101,116,101, 39, 10, 32, 32, 32,116, 46,108,110, 97,109,101,
+     32, 61, 32, 39,100,101,108,101,116,101, 39, 10, 32, 32, 32,
+    116, 46,112, 97,114,101,110,116, 46, 95,100,101,108,101,116,
+    101, 32, 61, 32,116,114,117,101, 10, 32, 32,101,110,100, 10,
+     32,101,110,100, 10, 32,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, 32,114,101,116,117,114,110, 32,
+    116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,110,115,116,
+    114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,112,101, 99,
+    116,115, 32,116,104,114,101,101, 32,115,116,114,105,110,103,
+    115, 58, 32,111,110,101, 32,114,101,112,114,101,115,101,110,
+    116,105,110,103, 32,116,104,101, 32,102,117,110, 99,116,105,
+    111,110, 32,100,101, 99,108, 97,114, 97,116,105,111,110, 44,
+     10, 45, 45, 32, 97,110,111,116,104,101,114, 32,114,101,112,
+    114,101,115,101,110,116,105,110,103, 32,116,104,101, 32, 97,
+    114,103,117,109,101,110,116, 32,108,105,115,116, 44, 32, 97,
+    110,100, 32,116,104,101, 32,116,104,105,114,100, 32,114,101,
+    112,114,101,115,101,110,116,105,110,103, 10, 45, 45, 32,116,
+    104,101, 32, 34, 99,111,110,115,116, 34, 32,111,114, 32,101,
+    109,112,116,121, 32,115,116,114,105,110,103, 46, 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, 32, 45, 45,108,111, 99,
+     97,108, 32,116, 32, 61, 32,115,112,108,105,116, 40,115,116,
+    114,115,117, 98, 40, 97, 44, 50, 44, 45, 50, 41, 44, 39, 44,
+     39, 41, 32, 45, 45, 32,101,108,105,109,105,110, 97,116,101,
+     32, 98,114, 97, 99,101,115, 10, 32, 45, 45,108,111, 99, 97,
+    108, 32,116, 32, 61, 32,115,112,108,105,116, 95,112, 97,114,
+     97,109,115, 40,115,116,114,115,117, 98, 40, 97, 44, 50, 44,
+     45, 50, 41, 41, 10, 10,  9,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, 10,  9,  9,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,  9,  9,114,101,116,117,114,
+    110, 32,110,105,108, 10,  9,101,110,100, 10, 10, 10, 32,108,
+    111, 99, 97,108, 32,105, 61, 49, 10, 32,108,111, 99, 97,108,
+     32,108, 32, 61, 32,123,110, 61, 48,125, 10, 10, 32,  9, 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,  9,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,  9,105,102, 32,115,116,114,105,112, 32,116,104,101,
+    110, 10,  9,  9, 45, 45,108,111, 99, 97,108, 32,110,115, 32,
+     61, 32,115,116,114,105,110,103, 46,115,117, 98, 40,115,116,
+    114,115,117, 98, 40, 97, 44, 49, 44, 45, 50, 41, 44, 32, 49,
+     44, 32, 45, 40,115,116,114,105,110,103, 46,108,101,110, 40,
+    108, 97,115,116, 41, 43, 49, 41, 41, 10,  9,  9,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, 10,  9,  9,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,  9,  9, 45, 45,110,115, 32, 61,
+     32,115,116,114,105,112, 95,100,101,102, 97,117,108,116,115,
+     40,110,115, 41, 10, 10,  9,  9, 70,117,110, 99,116,105,111,
+    110, 40,100, 44, 32,110,115, 44, 32, 99, 41, 10,  9,  9,102,
+    111,114, 32,105, 61, 49, 44,108, 97,115,116, 32,100,111, 10,
+      9,  9,  9,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,  9,  9,101,110,100,
+     10,  9,101,110,100, 10, 10, 32,119,104,105,108,101, 32,116,
+     91,105, 93, 32,100,111, 10, 32, 32,108, 46,110, 32, 61, 32,
+    108, 46,110, 43, 49, 10, 32, 32,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, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100,
+     10, 32,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, 32,102, 46, 97,114,103,115, 32, 61, 32,108,
+     10, 32,102, 46, 99,111,110,115,116, 32, 61, 32, 99, 10, 32,
+    114,101,116,117,114,110, 32, 95, 70,117,110, 99,116,105,111,
+    110, 40,102, 41, 10,101,110,100, 10, 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,
+     10,  9,102,105,114,115,116, 32, 61, 32,102,105,114,115,116,
+     32,111,114, 32, 49, 10,  9,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,  9,108,111, 99, 97,108, 32,108,115,
+    101,112, 32, 61, 32, 34, 34, 10,  9,108,111, 99, 97,108, 32,
+    114,101,116, 32, 61, 32, 34, 34, 10,  9,108,111, 99, 97,108,
+     32,108,111,111,112, 32, 61, 32,102, 97,108,115,101, 10,  9,
+    102,111,114, 32,105, 32, 61, 32,102,105,114,115,116, 44,108,
+     97,115,116, 32,100,111, 10, 10,  9,  9,114,101,116, 32, 61,
+     32,114,101,116, 46, 46,108,115,101,112, 46, 46,116, 91,105,
+     93, 10,  9,  9,108,115,101,112, 32, 61, 32,115,101,112, 10,
+      9,  9,108,111,111,112, 32, 61, 32,116,114,117,101, 10,  9,
+    101,110,100, 10,  9,105,102, 32,110,111,116, 32,108,111,111,
+    112, 32,116,104,101,110, 10,  9,  9,114,101,116,117,114,110,
+     32, 34, 34, 10,  9,101,110,100, 10, 10,  9,114,101,116,117,
+    114,110, 32,114,101,116, 10,101,110,100, 10, 10,102,117,110,
+     99,116,105,111,110, 32,115,116,114,105,112, 95,112, 97,114,
+    115, 40,115, 41, 10, 10,  9,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,  9,108,111, 99, 97,
+    108, 32,115,116,114,105,112, 32, 61, 32,102, 97,108,115,101,
+     10,  9,108,111, 99, 97,108, 32,108, 97,115,116, 10, 10,  9,
+    102,111,114, 32,105, 61,116, 46,110, 44, 49, 44, 45, 49, 32,
+    100,111, 10, 10,  9,  9,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,  9,  9,  9,108, 97,115,116, 32, 61, 32,105, 10,  9,
+      9,  9,115,116,114,105,112, 32, 61, 32,116,114,117,101, 10,
+      9,  9,101,110,100, 10,  9,  9, 45, 45,105,102, 32,115,116,
+    114,105,112, 32,116,104,101,110, 10,  9,  9, 45, 45,  9,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,  9,  9, 45, 45,101,110,100, 10,  9,
+    101,110,100, 10, 10,  9,114,101,116,117,114,110, 32,116, 44,
+    115,116,114,105,112, 44,108, 97,115,116, 10, 10,101,110,100,
+     10, 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, 10,
+      9,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,  9,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, 10,  9,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,  9,108,111, 99, 97,108, 32,115,
+    101,112, 44, 32,114,101,116, 32, 61, 32, 34, 34, 44, 34, 34,
+     10,  9,102,111,114, 32,105, 61, 49, 44,116, 46,110, 32,100,
+    111, 10,  9,  9,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,  9,  9,114,101,
+    116, 32, 61, 32,114,101,116, 46, 46,115,101,112, 46, 46,116,
+     91,105, 93, 10,  9,  9,115,101,112, 32, 61, 32, 34, 44, 34,
+     10,  9,101,110,100, 10, 10,  9,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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32,111,112,101,114, 97,
+    116,111,114, 32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,
+    100, 58, 32, 36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,
+    111,100,101, 32,105,115, 32,102,114,101,101, 32,115,111,102,
+    116,119, 97,114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,
+    114,101,100,105,115,116,114,105, 98,117,116,101, 32,105,116,
+     32, 97,110,100, 47,111,114, 32,109,111,100,105,102,121, 32,
+    105,116, 46, 10, 45, 45, 32, 84,104,101, 32,115,111,102,116,
+    119, 97,114,101, 32,112,114,111,118,105,100,101,100, 32,104,
+    101,114,101,117,110,100,101,114, 32,105,115, 32,111,110, 32,
+     97,110, 32, 34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,
+    115, 44, 32, 97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,
+    117,116,104,111,114, 32,104, 97,115, 32,110,111, 32,111, 98,
+    108,105,103, 97,116,105,111,110, 32,116,111, 32,112,114,111,
+    118,105,100,101, 32,109, 97,105,110,116,101,110, 97,110, 99,
+    101, 44, 32,115,117,112,112,111,114,116, 44, 32,117,112,100,
+     97,116,101,115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,
+    101,109,101,110,116,115, 44, 32,111,114, 32,109,111,100,105,
+    102,105, 99, 97,116,105,111,110,115, 46, 10, 10, 10, 45, 45,
+     32, 79,112,101,114, 97,116,111,114, 32, 99,108, 97,115,115,
+     10, 45, 45, 32, 82,101,112,114,101,115,101,110,116,115, 32,
+     97,110, 32,111,112,101,114, 97,116,111,114, 32,102,117,110,
+     99,116,105,111,110, 32,111,114, 32, 97, 32, 99,108, 97,115,
+    115, 32,111,112,101,114, 97,116,111,114, 32,109,101,116,104,
+    111,100, 46, 10, 45, 45, 32, 73,116, 32,115,116,111,114,101,
+    115, 32,116,104,101, 32,115, 97,109,101, 32,102,105,101,108,
+    100,115, 32, 97,115, 32,102,117,110, 99,116,105,111,110,115,
+     32,100,111, 32,112,108,117,115, 58, 10, 45, 45, 32, 32,107,
+    105,110,100, 32, 61, 32,115,101,116, 32,111,102, 32, 99,104,
+     97,114, 97, 99,116,101,114, 32,114,101,112,114,101,115,101,
+    110,116,105,110,103, 32,116,104,101, 32,111,112,101,114, 97,
+    116,111,114, 32, 40, 97,115, 32,105,116, 32, 97,112,112,101,
+    114,115, 32,105,110, 32, 67, 43, 43, 32, 99,111,100,101, 41,
+     10, 99,108, 97,115,115, 79,112,101,114, 97,116,111,114, 32,
+     61, 32,123, 10, 32,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, 10, 45, 45, 32,116, 97, 98,
+    108,101, 32,116,111, 32,116,114, 97,110,115,102,111,114,109,
+     32,111,112,101,114, 97,116,111,114, 32,107,105,110,100, 32,
+    105,110,116,111, 32,116,104,101, 32, 97,112,112,114,111,112,
+    114,105, 97,116,101, 32,116, 97,103, 32,109,101,116,104,111,
+    100, 32,110, 97,109,101, 10, 95, 84, 77, 32, 61, 32,123, 91,
+     39, 43, 39, 93, 32, 61, 32, 39, 97,100,100, 39, 44, 10, 32,
+     32, 32, 32, 32, 32, 32, 91, 39, 45, 39, 93, 32, 61, 32, 39,
+    115,117, 98, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39,
+     42, 39, 93, 32, 61, 32, 39,109,117,108, 39, 44, 10, 32, 32,
+     32, 32, 32, 32, 32, 91, 39, 47, 39, 93, 32, 61, 32, 39,100,
+    105,118, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 60,
+     39, 93, 32, 61, 32, 39,108,116, 39, 44, 10, 32, 32, 32, 32,
+     32, 32, 32, 91, 39, 60, 61, 39, 93, 32, 61, 32, 39,108,101,
+     39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 61, 61, 39,
+     93, 32, 61, 32, 39,101,113, 39, 44, 10, 32, 32, 32, 32, 32,
+     32, 32, 91, 39, 91, 93, 39, 93, 32, 61, 32, 39,103,101,116,
+    105, 39, 44, 10, 32, 32, 32, 32, 32, 32, 32, 91, 39, 38, 91,
+     93, 39, 93, 32, 61, 32, 39,115,101,116,105, 39, 44, 10, 32,
+     32, 32, 32, 32, 32, 32, 45, 45, 91, 39, 45, 62, 39, 93, 32,
+     61, 32, 39,102,108,101, 99,104,105,116, 97, 39, 44, 10, 32,
+     32, 32, 32, 32, 32,125, 10, 10, 10, 45, 45, 32, 80,114,105,
+    110,116, 32,109,101,116,104,111,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,112,114,105,110,116, 32, 40,105,100,101,110,116,
+     44, 99,108,111,115,101, 41, 10, 32,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, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,107,105,110,100, 32, 32, 61, 32, 39,
+     34, 46, 46,115,101,108,102, 46,107,105,110,100, 46, 46, 34,
+     39, 44, 34, 41, 10, 32,112,114,105,110,116, 40,105,100,101,
+    110,116, 46, 46, 34, 32,109,111,100, 32, 32, 61, 32, 39, 34,
+     46, 46,115,101,108,102, 46,109,111,100, 46, 46, 34, 39, 44,
+     34, 41, 10, 32,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, 32,112,114,105,110,116, 40,105,100,101,110,116, 46,
+     46, 34, 32,112,116,114, 32, 32, 61, 32, 39, 34, 46, 46,115,
+    101,108,102, 46,112,116,114, 46, 46, 34, 39, 44, 34, 41, 10,
+     32,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, 32,
+    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,
+     32,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, 32,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, 32,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, 32,
+    108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,
+    101, 32,115,101,108,102, 46, 97,114,103,115, 91,105, 93, 32,
+    100,111, 10, 32, 32,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, 32, 34, 44, 34, 44, 34, 41, 10, 32, 32,105, 32,
+     61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,112,114,105,
+    110,116, 40,105,100,101,110,116, 46, 46, 34, 32,125, 34, 41,
+     10, 32,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, 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, 10,  9,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,  9,  9,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,
+      9,101,110,100, 10, 10,  9, 45, 45, 32,110,111, 32,111,118,
+    101,114,108,111, 97,100, 44, 32,110,111, 32,112, 97,114, 97,
+    109,101,116,101,114,115, 44, 32, 97,108,119, 97,121,115, 32,
+    105,110, 99,108, 97,115,115, 10,  9,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, 10,
+      9,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,  9,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, 10,
+      9,105,102, 32,111,118,101,114,108,111, 97,100, 32, 60, 32,
+     48, 32,116,104,101,110, 10,  9, 32,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,  9,101,
+    110,100, 10,  9,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,  9,111,117,116,112,117,116,
+     40, 39, 32,105,102, 32, 40, 92,110, 39, 41, 10,  9, 45, 45,
+     32, 99,104,101, 99,107, 32,115,101,108,102, 10,  9,111,117,
+    116,112,117,116, 40, 39, 32, 32, 32, 32, 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,  9,
+    111,117,116,112,117,116, 40, 39, 32, 32, 32, 32, 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,  9,111,117,116,
+    112,117,116, 40, 39, 32, 32,103,111,116,111, 32,116,111,108,
+    117, 97, 95,108,101,114,114,111,114, 59, 39, 41, 10, 10,  9,
+    111,117,116,112,117,116, 40, 39, 32,101,108,115,101, 92,110,
+     39, 41, 10,  9,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 32, 45, 45, 32,116,111,108,117,
+     97, 95,114,101,108,101, 97,115,101, 10,  9,111,117,116,112,
+    117,116, 40, 39, 32,123, 39, 41, 10, 10,  9, 45, 45, 32,100,
+    101, 99,108, 97,114,101, 32,115,101,108,102, 10,  9,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,  9,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,  9,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, 10,  9, 45, 45, 32, 99,104,101, 99,
+    107, 32,115,101,108,102, 10,  9,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,  9,111,117,
+    116,112,117,116, 40, 39, 32, 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,  9,111,117,116,112,
+    117,116, 40, 39, 35,101,110,100,105,102, 92,110, 39, 41, 10,
+     10,  9, 45, 45, 32, 99, 97,115,116, 32,115,101,108,102, 10,
+      9,111,117,116,112,117,116, 40, 39, 32, 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,  9,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, 10,  9, 45, 45, 32,114,101,116,117,114,
+    110, 32,118, 97,108,117,101, 10,  9,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,  9,105,102, 32,
+    116, 32,116,104,101,110, 10,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 32, 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,  9,101,108,115,101, 10,  9,
+      9,116, 32, 61, 32,115,101,108,102, 46,116,121,112,101, 10,
+      9,  9,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,  9,  9,105,102,
+     32,115,101,108,102, 46,112,116,114, 32, 61, 61, 32, 39, 39,
+     32,116,104,101,110, 10,  9,  9,  9,111,117,116,112,117,116,
+     40, 39, 32, 32, 32,123, 39, 41, 10,  9,  9,  9,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,  9,  9,
+      9,111,117,116,112,117,116, 40, 39, 32, 32, 32, 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,  9,  9,
+      9,111,117,116,112,117,116, 40, 39, 32, 32, 32, 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,  9,  9,  9,111,117,116,112,117,116, 40,
+     39, 35,101,108,115,101, 92,110, 39, 41, 10,  9,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32, 32, 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,  9,  9,  9,111,117,116,
+    112,117,116, 40, 39, 32, 32, 32, 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,  9,  9,  9,111,117,116,112,117,116, 40, 39, 35,101,110,
+    100,105,102, 92,110, 39, 41, 10,  9,  9,  9,111,117,116,112,
+    117,116, 40, 39, 32, 32, 32,125, 39, 41, 10,  9,  9,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,  9,  9,  9,111,
+    117,116,112,117,116, 40, 39, 32, 32, 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,  9,  9,101,108,115,101, 10,  9,
+      9,  9,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,  9,  9,
+      9,  9,111,117,116,112,117,116, 40, 39, 32, 32, 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,  9,  9,
+      9,101,108,115,101, 10,  9,  9,  9,  9,111,117,116,112,117,
+    116, 40, 39, 32, 32, 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,  9,  9,  9,101,110,100, 10,  9,  9,101,110,100, 10,
+      9,101,110,100, 10, 10,  9,111,117,116,112,117,116, 40, 39,
+     32, 32,125, 39, 41, 10,  9,111,117,116,112,117,116, 40, 39,
+     32,114,101,116,117,114,110, 32, 49, 59, 39, 41, 10, 10,  9,
+    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,  9,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,  9,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,
+      9,111,117,116,112,117,116, 40, 39, 32,114,101,116,117,114,
+    110, 32, 48, 59, 39, 41, 10,  9,111,117,116,112,117,116, 40,
+     39, 35,101,110,100,105,102, 92,110, 39, 41, 10, 10, 10,  9,
+    111,117,116,112,117,116, 40, 39,125, 39, 41, 10,  9,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,  9,111,117,116,
+    112,117,116, 40, 39, 92,110, 39, 41, 10,101,110,100, 10, 10,
+     45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,110,
+    115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,105,
+    111,110, 32, 95, 79,112,101,114, 97,116,111,114, 32, 40,116,
+     41, 10, 32,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, 10, 32,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, 32, 32,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, 32,101,110,100, 10, 10, 32, 97,112,112,101,110,100,
+     40,116, 41, 10, 32,105,102, 32,110,111,116, 32,116, 58,105,
+    110, 99,108, 97,115,115, 40, 41, 32,116,104,101,110, 10, 32,
+     32,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, 32,101,110,100,
+     10, 10, 32, 45, 45,116, 46,110, 97,109,101, 32, 61, 32,116,
+     46,110, 97,109,101, 32, 46, 46, 32, 34, 95, 34, 32, 46, 46,
+     32, 40, 95, 84, 77, 91,116, 46,107,105,110,100, 93, 32,111,
+    114, 32,116, 46,107,105,110,100, 41, 10, 32,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, 32,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, 32, 32, 45,
+     45, 32,115,101,116, 32, 97,112,112,114,111,112,114,105, 97,
+    116,101, 32, 99, 97,108,108,105,110,103, 32,110, 97,109,101,
+     10, 32,114,101,116,117,114,110, 32,116, 10,101,110,100, 10,
+     10, 45, 45, 32, 67,111,110,115,116,114,117, 99,116,111,114,
+     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, 10,
+      9,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,  9,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,  9, 45, 45,105,102, 32,115,116,114,105,110,103, 46,102,
+    105,110,100, 40,107, 44, 32, 34, 94, 91, 37,119, 95, 58, 37,
+    100, 60, 62, 37, 42, 37, 38, 93, 43, 36, 34, 41, 32,116,104,
+    101,110, 10,  9,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, 10,  9,  9,100, 32,
+     61, 32,107, 46, 46, 34, 32,111,112,101,114, 97,116,111,114,
+     34, 10,  9,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, 10,
+      9,  9,105,102, 32,102,108, 97,103,115, 91, 39, 87, 39, 93,
+     32,116,104,101,110, 10,  9,  9,  9,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,  9,
+      9,101,108,115,101, 10,  9,  9,  9,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,  9,  9,  9,114,101,116,117,114,110, 32,
+    110,105,108, 10,  9,  9,101,110,100, 10,  9,101,110,100, 10,
+     10,  9,108,111, 99, 97,108, 32,114,101,102, 32, 61, 32, 39,
+     39, 10, 32,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, 32, 45, 45, 32,
+    101,108,105,109,105,110, 97,116,101, 32, 98,114, 97, 99,101,
+    115, 10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,108,
+    111, 99, 97,108, 32,108, 32, 61, 32,123,110, 61, 48,125, 10,
+     32,119,104,105,108,101, 32,116, 91,105, 93, 32,100,111, 10,
+     32, 32,108, 46,110, 32, 61, 32,108, 46,110, 43, 49, 10, 32,
+     32,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, 32, 32,105, 32, 61, 32,105, 43, 49, 10, 32,
+    101,110,100, 10, 32,105,102, 32,107, 32, 61, 61, 32, 39, 91,
+     93, 39, 32,116,104,101,110, 10,  9, 32,108,111, 99, 97,108,
+     32, 95, 10,  9, 32, 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, 32, 32,100, 32, 61, 32,103,115,117, 98, 40,
+    100, 44, 39, 38, 39, 44, 39, 39, 41, 10, 32,101,108,115,101,
+    105,102, 32,107, 61, 61, 39, 38, 91, 93, 39, 32,116,104,101,
+    110, 10, 32, 32,108, 46,110, 32, 61, 32,108, 46,110, 43, 49,
+     10, 32, 32,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, 32, 32,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, 32,101,110,100, 10, 32,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, 32,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, 32, 32,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, 32,101,110,100, 10, 32,102, 46, 97,114,103,
+    115, 32, 61, 32,108, 10, 32,102, 46, 99,111,110,115,116, 32,
+     61, 32, 99, 10, 32,102, 46,107,105,110,100, 32, 61, 32,111,
+    112, 95,107, 10, 32,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, 32,
+    105,102, 32,110,111,116, 32, 95, 84, 77, 91,102, 46,107,105,
+    110,100, 93, 32,116,104,101,110, 10, 32,  9,102, 46, 99, 97,
+    115,116, 95,111,112,101,114, 97,116,111,114, 32, 61, 32,116,
+    114,117,101, 10, 32,101,110,100, 10, 32,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, 32, 32, 79,112,101,114, 97,116,
+    111,114, 40,100, 44, 39, 38, 39, 46, 46,107, 44, 97, 44, 99,
+     41, 32,  9, 45, 45, 32, 99,114,101, 97,116,101, 32, 99,111,
+    114,114,101,115,112,111,100,105,110,103, 32,115,101,116, 32,
+    111,112,101,114, 97,116,111,114, 10, 32,101,110,100, 10, 32,
+    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/bin/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[] = {
+    45, 45, 32,116,111,108,117, 97, 58, 32, 99,108, 97,115,115,
+     32, 99,108, 97,115,115, 10, 45, 45, 32, 87,114,105,116,116,
+    101,110, 32, 98,121, 32, 87, 97,108,100,101,109, 97,114, 32,
+     67,101,108,101,115, 10, 45, 45, 32, 84,101, 67, 71,114, 97,
+    102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45, 32, 74,117,
+    108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 36, 73,100, 58, 32,
+     36, 10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101,
+     32,105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,
+    114,101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,
+    105,115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,
+    100, 47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46,
+     10, 45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,
+    101, 32,112,114,111,118,105,100,101,100, 32,104,101,114,101,
+    117,110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32,
+     34, 97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32,
+     97,110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,
+    111,114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103,
+     97,116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,
+    101, 32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,
+    115,117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,
+    115, 44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,
+    110,116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99,
+     97,116,105,111,110,115, 46, 10, 10, 10, 45, 45, 32, 67,108,
+     97,115,115, 32, 99,108, 97,115,115, 10, 45, 45, 32, 82,101,
+    112,114,101,115,101,110,116,115, 32, 97, 32, 99,108, 97,115,
+    115, 32,100,101,102,105,110,105,116,105,111,110, 46, 10, 45,
+     45, 32, 83,116,111,114,101,115, 32,116,104,101, 32,102,111,
+    108,108,111,119,105,110,103, 32,102,105,101,108,100,115, 58,
+     10, 45, 45, 32, 32, 32, 32,110, 97,109,101, 32, 61, 32, 99,
+    108, 97,115,115, 32,110, 97,109,101, 10, 45, 45, 32, 32, 32,
+     32, 98, 97,115,101, 32, 61, 32, 99,108, 97,115,115, 32, 98,
+     97,115,101, 44, 32,105,102, 32, 97,110,121, 32, 40,111,110,
+    108,121, 32,115,105,110,103,108,101, 32,105,110,104,101,114,
+    105,116, 97,110, 99,101, 32,105,115, 32,115,117,112,112,111,
+    114,116,101,100, 41, 10, 45, 45, 32, 32, 32, 32,123,105,125,
+     32, 32, 61, 32,108,105,115,116, 32,111,102, 32,109,101,109,
+     98,101,114,115, 10, 99,108, 97,115,115, 67,108, 97,115,115,
+     32, 61, 32,123, 10, 32, 99,108, 97,115,115,116,121,112,101,
+     32, 61, 32, 39, 99,108, 97,115,115, 39, 44, 10, 32,110, 97,
+    109,101, 32, 61, 32, 39, 39, 44, 10, 32, 98, 97,115,101, 32,
+     61, 32, 39, 39, 44, 10, 32,116,121,112,101, 32, 61, 32, 39,
+     39, 44, 10, 32, 98,116,121,112,101, 32, 61, 32, 39, 39, 44,
+     10, 32, 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, 10, 10,
+     45, 45, 32,114,101,103,105,115,116,101,114, 32, 99,108, 97,
+    115,115, 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,  9,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,  9,  9,114,101,116,117,114,110, 10,  9,101,110,
+    100, 10, 10, 32,112,114,101, 32, 61, 32,112,114,101, 32,111,
+    114, 32, 39, 39, 10, 32,112,117,115,104, 40,115,101,108,102,
+     41, 10,  9,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,  9,  9,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, 32, 32,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,  9,  9,111,117,116,
+    112,117,116, 40,112,114,101, 44, 39, 35,101,108,115,101, 92,
+    110, 39, 41, 10, 32, 32,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,
+      9,  9,111,117,116,112,117,116, 40,112,114,101, 44, 39, 35,
+    101,110,100,105,102, 92,110, 39, 41, 10,  9,101,108,115,101,
+     10, 32, 32,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,  9,101,110,
+    100, 10,  9,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,  9,  9,
+    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,  9,  9,  9,
+     45, 45, 32,110,111,116, 32,110,111,119, 10, 32, 32, 32, 45,
+     45,111,117,116,112,117,116, 40,112,114,101, 46, 46, 39, 32,
+    116,111,108,117, 97, 95, 97,100,100, 98, 97,115,101, 40,116,
+    111,108,117, 97, 95, 83, 44, 32, 34, 39, 46, 46,115,101,108,
+    102, 46,116,121,112,101, 46, 46, 39, 34, 44, 32, 34, 39, 46,
+     46, 98, 97,115,101, 46, 46, 39, 34, 41, 59, 39, 41, 10,  9,
+      9,101,110,100, 10,  9,101,110,100, 10, 32,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, 32,108,
+    111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,105,108,101,
+     32,115,101,108,102, 91,105, 93, 32,100,111, 10, 32, 32,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, 32, 32,105, 32,
+     61, 32,105, 43, 49, 10, 32,101,110,100, 10, 32,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,  9,112,111,112, 40, 41, 10,
+    101,110,100, 10, 10, 45, 45, 32,114,101,116,117,114,110, 32,
+     99,111,108,108,101, 99,116,105,111,110, 32,114,101,113,117,
+    105,114,101,109,101,110,116, 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,  9,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,  9,  9,114,101,116,117,114,110, 32,102, 97,108,115,101,
+     10,  9,101,110,100, 10, 32,112,117,115,104, 40,115,101,108,
+    102, 41, 10,  9,108,111, 99, 97,108, 32,114, 32, 61, 32,102,
+     97,108,115,101, 10, 32,108,111, 99, 97,108, 32,105, 61, 49,
+     10, 32,119,104,105,108,101, 32,115,101,108,102, 91,105, 93,
+     32,100,111, 10, 32, 32,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, 32,
+     32,105, 32, 61, 32,105, 43, 49, 10, 32,101,110,100, 10,  9,
+    112,111,112, 40, 41, 10,  9, 45, 45, 32,111,110,108,121, 32,
+     99,108, 97,115,115, 32,116,104, 97,116, 32,101,120,112,111,
+    114,116,115, 32,100,101,115,116,114,117, 99,116,111,114, 32,
+     99, 97,110, 32, 98,101, 32, 97,112,112,114,111,112,114,105,
+     97,116,101,108,121, 32, 99,111,108,108,101, 99,116,101,100,
+     10,  9, 45, 45, 32, 99,108, 97,115,115,101,115, 32,116,104,
+     97,116, 32,101,120,112,111,114,116, 32, 99,111,110,115,116,
+    114,117, 99,116,111,114,115, 32,110,101,101,100, 32,116,111,
+     32,104, 97,118,101, 32, 97, 32, 99,111,108,108,101, 99,116,
+    111,114, 32, 40,111,118,101,114,114,105,100,101,100, 32, 98,
+    121, 32, 45, 68, 32,102,108, 97,103, 32,111,110, 32, 99,111,
+    109,109, 97,110,100, 32,108,105,110,101, 41, 10,  9,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,  9,  9, 45, 45,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,103,115,117, 98, 40,115,101,108,102, 46,116,
+    121,112,101, 44, 34, 58, 58, 34, 44, 34, 95, 34, 41, 10,  9,
+      9,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,  9,  9,114, 32, 61, 32,116,114,117,101, 10,  9,101,
+    110,100, 10, 32,114,101,116,117,114,110, 32,114, 10,101,110,
+    100, 10, 10, 45, 45, 32,111,117,116,112,117,116, 32,116, 97,
+    103,115, 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, 32,112,117,115,104, 40,115,101,108,102,
+     41, 10,  9,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,  9,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,  9,
+    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,  9,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,  9,
+      9,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,  9,  9,  9,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,  9,  9,101,110,100, 10,  9,101,110,100,
+     10, 32,108,111, 99, 97,108, 32,105, 61, 49, 10, 32,119,104,
+    105,108,101, 32,115,101,108,102, 91,105, 93, 32,100,111, 10,
+     32, 32,115,101,108,102, 91,105, 93, 58,100,101, 99,108,116,
+    121,112,101, 40, 41, 10, 32, 32,105, 32, 61, 32,105, 43, 49,
+     10, 32,101,110,100, 10,  9,112,111,112, 40, 41, 10,101,110,
+    100, 10, 10, 10, 45, 45, 32, 80,114,105,110,116, 32,109,101,
+    116,104,111,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,
+     32,112,114,105,110,116, 40,105,100,101,110,116, 46, 46, 34,
+     67,108, 97,115,115,123, 34, 41, 10, 32,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, 32,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, 32,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, 32,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, 32,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, 32,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, 32,108,111, 99, 97,108,
+     32,105, 61, 49, 10, 32,119,104,105,108,101, 32,115,101,108,
+    102, 91,105, 93, 32,100,111, 10, 32, 32,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, 32, 32,105, 32, 61,
+     32,105, 43, 49, 10, 32,101,110,100, 10, 32,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, 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,  9,
+    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,
+     10, 45, 45, 32, 73,110,116,101,114,110, 97,108, 32, 99,111,
+    110,115,116,114,117, 99,116,111,114, 10,102,117,110, 99,116,
+    105,111,110, 32, 95, 67,108, 97,115,115, 32, 40,116, 41, 10,
+     32,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, 32,116,
+     58, 98,117,105,108,100,110, 97,109,101,115, 40, 41, 10, 32,
+     97,112,112,101,110,100, 40,116, 41, 10, 32,114,101,116,117,
+    114,110, 32,116, 10,101,110,100, 10, 10, 45, 45, 32, 67,111,
+    110,115,116,114,117, 99,116,111,114, 10, 45, 45, 32, 69,120,
+    112,101, 99,116,115, 32,116,104,101, 32,110, 97,109,101, 44,
+     32,116,104,101, 32, 98, 97,115,101, 32, 40, 97,114,114, 97,
+    121, 41, 32, 97,110,100, 32,116,104,101, 32, 98,111,100,121,
+     32,111,102, 32,116,104,101, 32, 99,108, 97,115,115, 46, 10,
+    102,117,110, 99,116,105,111,110, 32, 67,108, 97,115,115, 32,
+     40,110, 44,112, 44, 98, 41, 10, 10,  9,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,  9,  9, 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,  9,  9,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,  9,  9,  9, 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,  9,  9,101,110,100, 10,  9,  9, 98, 32, 61, 32, 98, 46,
+     46, 34, 92,110,125, 34, 10,  9,101,110,100, 10, 10,  9, 45,
+     45, 32, 99,104,101, 99,107, 32,102,111,114, 32,116,101,109,
+    112,108, 97,116,101, 10,  9, 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,  9,
+    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,  9,
+    105,102, 32,116, 32,116,104,101,110, 10, 10,  9,  9, 45, 45,
+     32,114,101,109,111,118,101, 32,113,117,111,116,101,115, 10,
+      9,  9, 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,  9,  9, 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,  9,  9, 45, 45, 32,103,101,116, 32,116,121,112,101,
+     32,108,105,115,116, 10,  9,  9,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,
+      9,  9, 45, 45, 32,114,101,109,111,118,101, 32, 84, 69, 77,
+     80, 76, 65, 84, 69, 95, 66, 73, 78, 68, 32,108,105,110,101,
+     10,  9,  9,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, 10,  9,  9,
+     45, 45, 32,114,101,112,108, 97, 99,101, 10,  9,  9,102,111,
+    114, 32,105, 32, 61, 49, 32, 44, 32,116,121,112,101,115, 46,
+    110, 32,100,111, 10, 10,  9,  9,  9,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,  9,  9,  9,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,  9,  9,  9,108,111, 99, 97,108, 32, 98, 73, 32,
+     61, 32, 98,115, 10,  9,  9,  9,108,111, 99, 97,108, 32,112,
+     73, 32, 61, 32,123,125, 10,  9,  9,  9,102,111,114, 32,106,
+     32, 61, 32, 49, 44, 84,108, 46,110, 32,100,111, 10,  9,  9,
+      9,  9, 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,  9,  9,  9,  9, 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,  9,  9,  9,  9,105,102, 32,112, 32,116,
+    104,101,110, 10,  9,  9,  9,  9,  9,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,  9,  9,  9,  9,  9,  9,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,  9,  9,
+      9,  9,  9,101,110,100, 10,  9,  9,  9,  9,101,110,100, 10,
+      9,  9,  9,101,110,100, 10,  9,  9,  9, 45, 45,108,111, 99,
+     97,108, 32, 97,112,112,101,110,100, 32, 61, 32, 34, 60, 34,
+     46, 46,115,116,114,105,110,103, 46,103,115,117, 98, 40,116,
+    121,112,101,115, 91,105, 93, 44, 32, 34, 37,115, 43, 34, 44,
+     32, 34, 44, 34, 41, 46, 46, 34, 62, 34, 10,  9,  9,  9,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,  9,
+      9,  9, 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,  9,  9,  9, 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,  9,  9,  9,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,  9,  9,  9,  9, 45, 45,112, 73, 91,105, 93, 32, 61, 32,
+    115,116,114,105,110,103, 46,103,115,117, 98, 40,112, 73, 91,
+    105, 93, 44, 32, 34, 62, 62, 34, 44, 32, 34, 62, 32, 62, 34,
+     41, 10,  9,  9,  9,  9,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,  9,
+      9,  9,101,110,100, 10,  9,  9,  9, 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,  9,  9,
+      9, 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,  9,  9,101,110,
+    100, 10,  9,  9,114,101,116,117,114,110, 10,  9,101,110,100,
+     10, 10,  9,108,111, 99, 97,108, 32,109, 98, 97,115,101, 10,
+     10,  9,105,102, 32,112, 32,116,104,101,110, 10,  9,  9,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,  9,  9,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,  9,101,110,
+    100, 10, 10,  9,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, 10,  9,108,111, 99, 97,108, 32,
+     99, 10,  9,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,  9,
+    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, 10,  9,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,  9,  9, 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,  9,  9,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,  9,  9,  9,
+     99, 46, 98, 97,115,101, 32, 61, 32,109, 98, 97,115,101, 10,
+      9,  9,101,110,100, 10,  9,101,108,115,101, 10,  9,  9, 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, 10,  9,  9,
+    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,  9,  9, 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,  9,101,110,100, 10, 10,  9,112,117,115,104,
+     40, 99, 41, 10,  9, 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, 32, 45, 45, 32,101,108,105,109,
+    105,110, 97,116,101, 32, 98,114, 97, 99,101,115, 10,  9,112,
+    111,112, 40, 41, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32,109, 97,114,107, 32,117,112, 32, 99,111,109,109,
+    101,110,116,115, 32, 97,110,100, 32,115,116,114,105,110,103,
+    115, 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, 32, 61, 32, 34, 92, 48, 48, 53, 34, 10, 65, 78, 89,
+     32, 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, 10, 77, 65, 83, 75, 32, 61, 32,123, 32, 45, 45,
+     32,116,104,101, 32,115,117, 98,115,116,105,116,117,116,105,
+    111,110, 32,111,114,100,101,114, 32,105,115, 32,105,109,112,
+    111,114,116, 97,110,116, 10, 32,123, 69, 83, 67, 49, 44, 32,
+     34, 92, 92, 39, 34,125, 44, 10, 32,123, 69, 83, 67, 50, 44,
+     32, 39, 92, 92, 34, 39,125, 44, 10, 32,123, 83, 84, 82, 49,
+     44, 32, 34, 39, 34,125, 44, 10, 32,123, 83, 84, 82, 50, 44,
+     32, 39, 34, 39,125, 44, 10, 32,123, 83, 84, 82, 51, 44, 32,
+     34, 37, 91, 37, 91, 34,125, 44, 10, 32,123, 83, 84, 82, 52,
+     44, 32, 34, 37, 93, 37, 93, 34,125, 44, 10, 32,123, 82, 69,
+     77, 32, 44, 32, 34, 37, 45, 37, 45, 34,125, 44, 10,125, 10,
+     10,102,117,110, 99,116,105,111,110, 32,109, 97,115,107, 32,
+     40,115, 41, 10, 32,102,111,114, 32,105, 32, 61, 32, 49, 44,
+    103,101,116,110, 40, 77, 65, 83, 75, 41, 32, 32,100,111, 10,
+     32, 32,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, 32,101,110,100, 10, 32,114,101,116,
+    117,114,110, 32,115, 10,101,110,100, 10, 10,102,117,110, 99,
+    116,105,111,110, 32,117,110,109, 97,115,107, 32, 40,115, 41,
+     10, 32,102,111,114, 32,105, 32, 61, 32, 49, 44,103,101,116,
+    110, 40, 77, 65, 83, 75, 41, 32, 32,100,111, 10, 32, 32,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, 32,101,110,100, 10, 32,114,101,116,117,114,110,
+     32,115, 10,101,110,100, 10, 10,102,117,110, 99,116,105,111,
+    110, 32, 99,108,101, 97,110, 32, 40,115, 41, 10, 32, 45, 45,
+     32, 99,104,101, 99,107, 32,102,111,114, 32, 99,111,109,112,
+    105,108, 97,116,105,111,110, 32,101,114,114,111,114, 10, 32,
+    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, 32,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, 32, 32,114,101,116,117,114,110, 32,
+    110,105,108, 10, 32,101,110,100, 10, 10, 32,105,102, 32,102,
+    108, 97,103,115, 91, 39, 67, 39, 93, 32,116,104,101,110, 10,
+     32,  9,114,101,116,117,114,110, 32,115, 10, 32,101,110,100,
+     10, 10, 32,108,111, 99, 97,108, 32, 83, 32, 61, 32, 34, 34,
+     32, 45, 45, 32,115, 97,118,101,100, 32,115,116,114,105,110,
+    103, 10, 10, 32,115, 32, 61, 32,109, 97,115,107, 40,115, 41,
+     10, 10, 32, 45, 45, 32,114,101,109,111,118,101, 32, 98,108,
+     97,110,107,115, 32, 97,110,100, 32, 99,111,109,109,101,110,
+    116,115, 10, 32,119,104,105,108,101, 32, 49, 32,100,111, 10,
+     32, 32,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, 32, 32,105,102, 32, 98, 32,116,104,101,110, 10, 32, 32,
+     32, 83, 32, 61, 32, 83, 46, 46,115,116,114,115,117, 98, 40,
+    115, 44, 49, 44, 98, 45, 49, 41, 10, 32, 32, 32,115, 32, 61,
+     32,115,116,114,115,117, 98, 40,115, 44, 98, 43, 49, 41, 10,
+     32, 32, 32,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,
+     32, 32, 32, 32,101, 32, 61, 32,115,116,114,102,105,110,100,
+     40,115, 44,100, 41, 10, 32, 32, 32, 32, 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, 32, 32, 32, 32,115, 32, 61, 32,115,116,
+    114,115,117, 98, 40,115, 44,101, 43, 49, 41, 10, 32, 32, 32,
+    101,108,115,101,105,102, 32,100, 61, 61, 83, 84, 82, 51, 32,
+    116,104,101,110, 10, 32, 32, 32, 32,101, 32, 61, 32,115,116,
+    114,102,105,110,100, 40,115, 44, 83, 84, 82, 52, 41, 10, 32,
+     32, 32, 32, 83, 32, 61, 32, 83, 46, 46,100, 46, 46,115,116,
+    114,115,117, 98, 40,115, 44, 49, 44,101, 41, 10, 32, 32, 32,
+     32,115, 32, 61, 32,115,116,114,115,117, 98, 40,115, 44,101,
+     43, 49, 41, 10, 32, 32, 32,101,108,115,101,105,102, 32,100,
+     61, 61, 82, 69, 77, 32,116,104,101,110, 10, 32, 32, 32, 32,
+    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, 32, 32, 32,101,110,100, 10, 32, 32,101,108,115,
+    101, 10, 32, 32, 32, 83, 32, 61, 32, 83, 46, 46,115, 10, 32,
+     32, 32, 98,114,101, 97,107, 10, 32, 32,101,110,100, 10, 32,
+    101,110,100, 10, 32, 45, 45, 32,101,108,105,109,105,110, 97,
+    116,101, 32,117,110,101, 99,101,115,115, 97,114,121, 32,115,
+    112, 97, 99,101,115, 10, 32, 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, 32, 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,  9, 83, 32, 61, 32,103,115,117,
+     98, 40, 83, 44, 34, 92,110, 43, 34, 44, 34, 92,110, 34, 41,
+     10, 32, 83, 32, 61, 32,117,110,109, 97,115,107, 40, 83, 41,
+     10, 32,114,101,116,117,114,110, 32, 83, 10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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[] = {
+    45, 45, 32, 71,101,110,101,114, 97,116,101, 32, 98,105,110,
+    100,105,110,103, 32, 99,111,100,101, 10, 45, 45, 32, 87,114,
+    105,116,116,101,110, 32, 98,121, 32, 87, 97,108,100,101,109,
+     97,114, 32, 67,101,108,101,115, 10, 45, 45, 32, 84,101, 67,
+     71,114, 97,102, 47, 80, 85, 67, 45, 82,105,111, 10, 45, 45,
+     32, 74,117,108, 32, 49, 57, 57, 56, 10, 45, 45, 32, 76, 97,
+    115,116, 32,117,112,100, 97,116,101, 58, 32, 65,112,114, 32,
+     50, 48, 48, 51, 10, 45, 45, 32, 36, 73,100, 58, 32, 36, 10,
+     10, 10, 45, 45, 32, 84,104,105,115, 32, 99,111,100,101, 32,
+    105,115, 32,102,114,101,101, 32,115,111,102,116,119, 97,114,
+    101, 59, 32,121,111,117, 32, 99, 97,110, 32,114,101,100,105,
+    115,116,114,105, 98,117,116,101, 32,105,116, 32, 97,110,100,
+     47,111,114, 32,109,111,100,105,102,121, 32,105,116, 46, 10,
+     45, 45, 32, 84,104,101, 32,115,111,102,116,119, 97,114,101,
+     32,112,114,111,118,105,100,101,100, 32,104,101,114,101,117,
+    110,100,101,114, 32,105,115, 32,111,110, 32, 97,110, 32, 34,
+     97,115, 32,105,115, 34, 32, 98, 97,115,105,115, 44, 32, 97,
+    110,100, 10, 45, 45, 32,116,104,101, 32, 97,117,116,104,111,
+    114, 32,104, 97,115, 32,110,111, 32,111, 98,108,105,103, 97,
+    116,105,111,110, 32,116,111, 32,112,114,111,118,105,100,101,
+     32,109, 97,105,110,116,101,110, 97,110, 99,101, 44, 32,115,
+    117,112,112,111,114,116, 44, 32,117,112,100, 97,116,101,115,
+     44, 10, 45, 45, 32,101,110,104, 97,110, 99,101,109,101,110,
+    116,115, 44, 32,111,114, 32,109,111,100,105,102,105, 99, 97,
+    116,105,111,110,115, 46, 10, 10,102,117,110, 99,116,105,111,
+    110, 32,112, 97,114,115,101, 95,101,120,116,114, 97, 40, 41,
+     10, 10,  9,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,  9,  9, 10,  9,  9,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,  9,  9,105,102, 32, 98, 32,116,104,101,110,
+     10,  9,  9,  9, 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,  9,  9,101,108,115,101, 10,  9,  9,
+      9, 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,  9,
+      9,101,110,100, 10,  9,101,110,100, 10,101,110,100, 10, 10,
+    102,117,110, 99,116,105,111,110, 32,100,111,105,116, 32, 40,
+     41, 10,  9, 45, 45, 32,100,101,102,105,110,101, 32,112, 97,
+     99,107, 97,103,101, 32,110, 97,109,101, 44, 32,105,102, 32,
+    110,111,116, 32,112,114,111,118,105,100,101,100, 10,  9,105,
+    102, 32,110,111,116, 32,102,108, 97,103,115, 46,110, 32,116,
+    104,101,110, 10,  9,  9,105,102, 32,102,108, 97,103,115, 46,
+    102, 32,116,104,101,110, 10,  9,  9,  9,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,
+      9,  9,  9, 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,  9,  9,101,108,115,101, 10,  9,
+      9,  9,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,  9,  9,101,110,100, 10,  9,101,
+    110,100, 10, 10,  9, 45, 45, 32,112, 97,114,115,101, 32,116,
+     97, 98,108,101, 32,119,105,116,104, 32,101,120,116,114, 97,
+     32,112, 97,114, 97,109,116,101,114,115, 10,  9,112, 97,114,
+    115,101, 95,101,120,116,114, 97, 40, 41, 10, 10,  9, 45, 45,
+     32,100,111, 32,116,104,105,115, 32, 97,102,116,101,114, 32,
+    115,101,116,116,105,110,103, 32,116,104,101, 32,112, 97, 99,
+    107, 97,103,101, 32,110, 97,109,101, 10,  9,105,102, 32,102,
+    108, 97,103,115, 91, 39, 76, 39, 93, 32,116,104,101,110, 10,
+      9,  9,100,111,102,105,108,101, 40,102,108, 97,103,115, 91,
+     39, 76, 39, 93, 41, 10,  9,101,110,100, 10, 10,  9, 45, 45,
+     32, 97,100,100, 32, 99,112,112,115,116,114,105,110,103, 10,
+      9,105,102, 32,110,111,116, 32,102,108, 97,103,115, 91, 39,
+     83, 39, 93, 32,116,104,101,110, 10,  9,  9, 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,  9,  9, 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,  9,  9, 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,  9,101,110,100, 10, 10,  9, 45, 45, 32,112,114,111, 99,
+     99,101,115,115, 32,112, 97, 99,107, 97,103,101, 10,  9,108,
+    111, 99, 97,108, 32,112, 32, 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, 10,  9,105,102, 32,102,108, 97,103,115,
+     46,112, 32,116,104,101,110, 10,  9,  9,114,101,116,117,114,
+    110, 32, 32, 32, 32, 32, 32, 32, 32, 45, 45, 32,111,110,108,
+    121, 32,112, 97,114,115,101, 10,  9,101,110,100, 10, 10,  9,
+    105,102, 32,102,108, 97,103,115, 46,111, 32,116,104,101,110,
+     10,  9,  9,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,  9,  9,105,102, 32,110,111,116, 32,115,
+    116, 32,116,104,101,110, 10,  9,  9,  9,101,114,114,111,114,
+     40, 39, 35, 39, 46, 46,109,115,103, 41, 10,  9,  9,101,110,
+    100, 10,  9,101,110,100, 10, 10,  9,112, 58,100,101, 99,108,
+    116,121,112,101, 40, 41, 10,  9,105,102, 32,102,108, 97,103,
+    115, 46, 80, 32,116,104,101,110, 10,  9,  9,112, 58,112,114,
+    105,110,116, 40, 41, 10,  9,101,108,115,101, 10,  9,  9,112,
+     58,112,114,101, 97,109, 98,108,101, 40, 41, 10,  9,  9,112,
+     58,115,117,112, 99,111,100,101, 40, 41, 10,  9,  9,112, 58,
+    114,101,103,105,115,116,101,114, 40, 41, 10,  9,  9,112,117,
+    115,104, 40,112, 41, 10,  9,  9,112,111,115,116, 95,111,117,
+    116,112,117,116, 95,104,111,111,107, 40,112, 41, 10,  9,  9,
+    112,111,112, 40, 41, 10,  9,101,110,100, 10, 10,  9,105,102,
+     32,102,108, 97,103,115, 46,111, 32,116,104,101,110, 10,  9,
+      9,119,114,105,116,101,116,111, 40, 41, 10,  9,101,110,100,
+     10, 10,  9, 45, 45, 32,119,114,105,116,101, 32,104,101, 97,
+    100,101,114, 32,102,105,108,101, 10,  9,105,102, 32,110,111,
+    116, 32,102,108, 97,103,115, 46, 80, 32,116,104,101,110, 10,
+      9,  9,105,102, 32,102,108, 97,103,115, 46, 72, 32,116,104,
+    101,110, 10,  9,  9,  9,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,  9,  9,  9,105,102, 32,110,
+    111,116, 32,115,116, 32,116,104,101,110, 10,  9,  9,  9,  9,
+    101,114,114,111,114, 40, 39, 35, 39, 46, 46,109,115,103, 41,
+     10,  9,  9,  9,101,110,100, 10,  9,  9,  9,112, 58,104,101,
+     97,100,101,114, 40, 41, 10,  9,  9,  9,119,114,105,116,101,
+    116,111, 40, 41, 10,  9,  9,101,110,100, 10,  9,101,110,100,
+     10,101,110,100,32
+   };
+   tolua_dobuffer(tolua_S,(char*)B,sizeof(B),"tolua embedded: src/bin/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,
+     32,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, 32,116,111,108,117, 97,
+     95,101,114,114,111,114, 40,109,115,103, 44,108, 97, 98,101,
+    108, 41, 10, 32,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
+ int luaopen_tolua (lua_State* tolua_S) {
+ return tolua_tolua_open(tolua_S);
+};
+#endif
+
Index: /code/branches/ceguilua/src/tolua/toluabind.h
===================================================================
--- /code/branches/ceguilua/src/tolua/toluabind.h	(revision 1801)
+++ /code/branches/ceguilua/src/tolua/toluabind.h	(revision 1801)
@@ -0,0 +1,8 @@
+/*
+** Lua binding: tolua
+** Generated automatically by tolua++-1.0.91 on Wed Apr 26 22:30:15 2006.
+*/
+
+/* Exported function */
+TOLUA_API int  tolua_tolua_open (lua_State* tolua_S);
+
Index: /code/branches/ceguilua/src/util/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/util/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/util/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,24 @@
+SET(UTIL_SRC_FILES
+  Clipboard.cc
+  Error.cc
+  CRC32.cc
+  Exception.cc
+  ExprParser.cc
+  Math.cc
+  MultiType.cc
+  OutputBuffer.cc
+  OutputHandler.cc
+  String.cc
+  SubString.cc
+)
+
+ADD_LIBRARY(util SHARED ${UTIL_SRC_FILES})
+
+IF(TESTING_ENABLED)
+  ADD_SUBDIRECTORY(testing)
+ENDIF(TESTING_ENABLED)
+
+TARGET_LINK_LIBRARIES(util
+  ${OGRE_LIBRARIES}
+  ${Lua_LIBRARIES}
+)
Index: /code/branches/ceguilua/src/util/CRC32.cc
===================================================================
--- /code/branches/ceguilua/src/util/CRC32.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/CRC32.cc	(revision 1801)
@@ -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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "CRC32.h"
+
+
+void calcCRCBit(uint32_t &crc32, int bit){
+    int hbit;
+
+    hbit=(crc32 & 0x80000000) ? 1 : 0;
+    if (hbit != bit)
+      crc32=(crc32<<1) ^ UTIL_CRC32POLY;
+    else
+      crc32=crc32<<1;
+  }
+
+  uint32_t calcCRC(unsigned char *data, unsigned int dataLength){
+    uint32_t crc32=0;
+    for(unsigned int i=0; i<dataLength; i++){
+      calcCRCBit(crc32, (data[i]&0x1)>>0); // 1st bit
+      calcCRCBit(crc32, (data[i]&0x2)>>1); // 2nd bit
+      calcCRCBit(crc32, (data[i]&0x3)>>2); // 3rd bit
+      calcCRCBit(crc32, (data[i]&0x4)>>3); // 4th bit
+      calcCRCBit(crc32, (data[i]&0x5)>>4); // 5th bit
+      calcCRCBit(crc32, (data[i]&0x6)>>5); // 6th bit
+      calcCRCBit(crc32, (data[i]&0x7)>>6); // 7th bit
+      calcCRCBit(crc32, (data[i]&0x8)>>7); // 8th bit
+    }
+    return crc32;
+  }
+
Index: /code/branches/ceguilua/src/util/CRC32.h
===================================================================
--- /code/branches/ceguilua/src/util/CRC32.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/CRC32.h	(revision 1801)
@@ -0,0 +1,43 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _Util_CRC_H__
+#define _Util_CRC_H__
+
+#include "UtilPrereqs.h"
+#include <iostream>
+#include "Integers.h"
+
+const unsigned int UTIL_CRC32POLY = 0x04C11DB7; /* CRC-32 Polynom */
+
+_UtilExport void calcCRCBit(uint32_t &crc32, int bit);
+
+_UtilExport uint32_t calcCRC(unsigned char *data, unsigned int dataLength);
+
+
+#endif /* _Util_CRC_H__ */
Index: /code/branches/ceguilua/src/util/Clipboard.cc
===================================================================
--- /code/branches/ceguilua/src/util/Clipboard.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/Clipboard.cc	(revision 1801)
@@ -0,0 +1,125 @@
+/*
+ *   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:
+ *      ...
+ *
+ *   Windows version inspired by "Copy Text To Clipboard" by Laszlo Szathmary, 2007
+ *      http://www.loria.fr/~szathmar/off/projects/C/CopyTextToClipboard/index.php
+ */
+
+/**
+    @file Clipboard.cc
+    @brief OS-specific implementations of the clipboard functions.
+*/
+
+#include "Clipboard.h"
+
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+    /////////////
+    // Windows //
+    /////////////
+    #include <windows.h>
+    #include "Debug.h"
+
+    /**
+        @brief Puts text into the windows-clipboard
+        @param text The text
+        @return True if the action was successful
+    */
+    bool toClipboard(const std::string& text)
+    {
+        try
+        {
+            if (OpenClipboard(0))
+            {
+                EmptyClipboard();
+                HGLOBAL clipbuffer = GlobalAlloc(GMEM_DDESHARE, text.size() + 1);
+                char* buffer = (char*)GlobalLock(clipbuffer);
+                strcpy(buffer, text.c_str());
+                GlobalUnlock(clipbuffer);
+                SetClipboardData(CF_TEXT, clipbuffer);
+                CloseClipboard();
+
+                return true;
+            }
+        }
+        catch (...)
+        {
+            COUT(1) << "Error: Unable to copy the following text to the clipboard:" << std::endl;
+            COUT(1) << "       \"" << text << "\"" << std::endl;
+        }
+        return false;
+    }
+
+    /**
+        @brief Gets text from the windows-clipboard if there is any text.
+        @return The retrieved text
+    */
+    std::string fromClipboard()
+    {
+        try
+        {
+            if (OpenClipboard(0))
+            {
+                HANDLE hData = GetClipboardData(CF_TEXT);
+                std::string output = (char*)GlobalLock(hData);
+                GlobalUnlock(hData);
+                CloseClipboard();
+
+                return output;
+            }
+        }
+        catch (...)
+        {
+            COUT(1) << "Error: Unable to retrieve text from the clipboard." << std::endl;
+        }
+        return "";
+    }
+#else
+    /////////////
+    // Default //
+    /////////////
+
+    std::string clipboard = ""; //!< Keeps the text of our internal clipboard
+
+    /**
+        @brief Default implementation if there is no OS-specific implementation or no clipboard. Copies the text into an internal clipboard.
+        @param text The text
+        @return True
+    */
+    bool toClipboard(const std::string& text)
+    {
+        clipboard = text;
+        return true;
+    }
+
+    /**
+        @brief Default implementation if there is no OS-specific implementation or no clipboard. Gets the text from the internal clipboard.
+        @return The text
+    */
+    std::string fromClipboard()
+    {
+        return clipboard;
+    }
+#endif
Index: /code/branches/ceguilua/src/util/Clipboard.h
===================================================================
--- /code/branches/ceguilua/src/util/Clipboard.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Clipboard.h	(revision 1801)
@@ -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:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Clipboard.h
+    @brief Some functions to exchange text between the OS clipboard and Orxonox.
+
+    Use fromClipboard() to get text from the clipboard (if there is any text) and
+    toClipboard(text) to put text into the clipboard.
+
+    Those functions can only work properly if there's an OS-specific implementation.
+    If an OS isn't supported, the clipboard only works within Orxonox, but exchange
+    with other programs isn't possible.
+*/
+
+#ifndef _Clipboard_H__
+#define _Clipboard_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+
+
+_UtilExport bool toClipboard(const std::string& text);
+_UtilExport std::string fromClipboard();
+
+
+#endif /* _Clipboard_H__ */
+
Index: /code/branches/ceguilua/src/util/Convert.h
===================================================================
--- /code/branches/ceguilua/src/util/Convert.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Convert.h	(revision 1801)
@@ -0,0 +1,672 @@
+/*
+ *   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
+ *      Benjamin Grauer
+ *   Co-authors:
+ *      ...
+ */
+
+/*!
+    @file Convert.h
+    @brief Definition and Implementation of the Convert class.
+*/
+
+#ifndef _Convert_H__
+#define _Convert_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <sstream>
+
+#include "Math.h"
+#include "Debug.h"
+#include "SubString.h"
+#include "String.h"
+
+// disable annoying warning about forcing value to boolean
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#pragma warning(push)
+#pragma warning(disable:4100 4800)
+#endif
+
+
+//////////
+// MAIN //
+//////////
+
+// Enum to declare the wanted conversion preference in case of equal type-levels
+enum ConversionPreference
+{
+    CP_PreferToType,
+    CP_PreferFromType,
+};
+
+// Helper classes to determine the preferred partial template specialization
+class _ToType_   {};
+class _FromType_ {};
+class _Explicit_ {};
+
+
+// The default convert functions
+template <class FromType, class ToType, class Type>
+struct ConverterSpecialized
+{
+    enum { specialized = false };
+    static bool convert(ToType* output, const FromType& input)
+    {
+        COUT(2) << "Warning: Couldn't convert a value: From \"" << typeid(FromType).name() << "\" to \"" << typeid(ToType).name() << "\"" << std::endl;
+        return false;
+    }
+};
+
+
+// The default convert function if both types are the same
+template <class BothTypes>
+struct ConverterSpecialized<BothTypes, BothTypes, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(BothTypes* output, const BothTypes& input)
+    { (*output) = input; return true; }
+};
+
+
+// The possible levels
+#define __low__  0 // Everything that is or behaves like a primitive type (an can be converted with a typecast to every other low-level type)
+#define __mid__  1 // Everything that has overloaded << and >> operators to operate on a std::stream
+#define __high__ 2 // Everything that doesn't fullfill the lowerlevel-requirements and therefore needs specialized conversions
+
+// Defines the levels of all types: Default is __high__ so you don't have to define every high-level type
+template <class T> struct ConverterLevel              { enum { level = __high__ }; };
+template <> struct ConverterLevel<std::string>        { enum { level = __mid__ }; };
+template <> struct ConverterLevel<orxonox::Radian>    { enum { level = __mid__ }; };
+template <> struct ConverterLevel<orxonox::Degree>    { enum { level = __mid__ }; };
+template <> struct ConverterLevel<int>                { enum { level = __low__ }; };
+template <> struct ConverterLevel<unsigned int>       { enum { level = __low__ }; };
+template <> struct ConverterLevel<char>               { enum { level = __low__ }; };
+template <> struct ConverterLevel<unsigned char>      { enum { level = __low__ }; };
+template <> struct ConverterLevel<short>              { enum { level = __low__ }; };
+template <> struct ConverterLevel<unsigned short>     { enum { level = __low__ }; };
+template <> struct ConverterLevel<long>               { enum { level = __low__ }; };
+template <> struct ConverterLevel<unsigned long>      { enum { level = __low__ }; };
+template <> struct ConverterLevel<long long>          { enum { level = __low__ }; };
+template <> struct ConverterLevel<unsigned long long> { enum { level = __low__ }; };
+template <> struct ConverterLevel<float>              { enum { level = __low__ }; };
+template <> struct ConverterLevel<double>             { enum { level = __low__ }; };
+template <> struct ConverterLevel<long double>        { enum { level = __low__ }; };
+template <> struct ConverterLevel<bool>               { enum { level = __low__ }; };
+
+
+// Calculates the preference based on the levels of FromType and ToType
+template <int from, int to>
+struct ConverterPreference
+{
+    enum
+    {
+        // The maximum of both levels: element of {0, 1, 2}
+        // max 0: Both types are primitives or have a similar behaviour
+        // max 1: At least one type is not a primitive, but both can be put on a std::stream
+        // max 2: There is at least one generic type that needs specialized conversions
+        max = (from > to) ? from : to,
+
+        // The difference between both levels limited to +-1: element of {-1, 0, 1}
+        // diff -1: The FromType has higher level than the ToType
+        // diff  0: Both types have the same level
+        // diff  1: The ToType has higher level than the FromType
+        diff = ((to - from) > 1) ? 1 : (((to - from) < -1) ? -1 : to - from)
+    };
+};
+
+
+// The default conversion: This usually does nothing
+template <int max, class FromType, class ToType>
+struct ConverterDefault
+{
+    static bool convert(ToType* output, const FromType& input)
+    {
+        COUT(2) << "Warning: Couldn't convert a value: From \"" << typeid(FromType).name() << "\" to \"" << typeid(ToType).name() << "\"" << std::endl;
+        return false;
+    }
+};
+// The default conversion for primitives: A typecast (defined over two partial specialized templates to exclude all non-primitive types and classes)    template <int max, class FromType, class ToType>
+template <class FromType, class ToType>
+struct ConverterDefault<0, FromType, ToType>
+{
+    static bool convert(ToType* output, const FromType& input)
+    {
+        (*output) = (ToType)input;
+        return true;
+    }
+};
+
+
+// Converter: Converts input of FromType into output of ToType
+template <int diff, int max, class FromType, class ToType, ConversionPreference pref>
+struct Converter
+{
+    static bool convert(ToType* output, const FromType& input)
+    {
+        return false;
+    }
+};
+// Converter: level{FromType} > level{ToType}
+template <int max, class FromType, class ToType, ConversionPreference pref>
+struct Converter<-1, max, FromType, ToType, pref>
+{   static bool convert(ToType* output, const FromType& input)
+    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
+// Converter: level{FromType} < level{ToType}
+template <int max, class FromType, class ToType, ConversionPreference pref>
+struct Converter<1, max, FromType, ToType, pref>
+{   static bool convert(ToType* output, const FromType& input)
+    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
+// Converter: level{FromType} = level{ToType}
+// CP_PreferToType
+template <int max, class FromType, class ToType>
+struct Converter<0, max, FromType, ToType, CP_PreferToType>
+{   static bool convert(ToType* output, const FromType& input)
+    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
+// CP_PreferFromType
+template <int max, class FromType, class ToType>
+struct Converter<0, max, FromType, ToType, CP_PreferFromType>
+{   static bool convert(ToType* output, const FromType& input)
+    { return (ConverterSpecialized<FromType, ToType, _Explicit_>::specialized) ? (ConverterSpecialized<FromType, ToType, _Explicit_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _FromType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _FromType_>::convert(output, input)) : (ConverterSpecialized<FromType, ToType, _ToType_>::specialized) ? (ConverterSpecialized<FromType, ToType, _ToType_>::convert(output, input)) : (ConverterDefault<max, FromType, ToType>::convert(output, input)); } };
+
+
+// Calls the Converter::convertValue function with the correct template type parameters calculated by ConverterPreference
+template <class FromType, class ToType>
+static bool convertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType)
+{
+    return (preference == CP_PreferToType) ?
+           Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,
+                     ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,
+                     FromType,
+                     ToType,
+                     CP_PreferToType>::convert(output, input)
+         : Converter<ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::diff,
+                     ConverterPreference<ConverterLevel<FromType>::level, ConverterLevel<ToType>::level>::max,
+                     FromType,
+                     ToType,
+                     CP_PreferFromType>::convert(output, input);
+}
+
+
+//////////////////////
+// HELPER FUNCTIONS //
+//////////////////////
+
+// Helper function: Calls convertValue with and without default value and returns true if the conversion was successful
+template<class FromType, class ToType>
+static bool ConvertValue(ToType* output, const FromType& input, ConversionPreference preference = CP_PreferToType)
+{
+    return convertValue(output, input, preference);
+}
+template<class FromType, class ToType>
+static bool ConvertValue(ToType* output, const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType)
+{
+    if (convertValue(output, input, preference))
+        return true;
+
+    (*output) = fallback;
+    return false;
+}
+
+// Helper function: Calls convertValue with and without default value and returns the converted value
+template<class FromType, class ToType>
+static ToType getConvertedValue(const FromType& input, ConversionPreference preference = CP_PreferToType)
+{
+    ToType output = ToType();
+    ConvertValue(&output, input, preference);
+    return output;
+}
+template<class FromType, class ToType>
+static ToType getConvertedValue(const FromType& input, const ToType& fallback, ConversionPreference preference = CP_PreferToType)
+{
+    ToType output = fallback;
+    ConvertValue(&output, input, fallback, preference);
+    return output;
+}
+
+
+/////////////////////
+// SPECIALIZATIONS //
+/////////////////////
+
+/////////////
+// SAMPLES //
+/////////////
+/*
+// convert everything to xyz
+template <class FromType>
+struct ConverterSpecialized<FromType, xyz, _ToType_>
+{
+    enum { specialized = true };
+    static bool convert(xyz* output, const FromType& input)
+    { return ...; }
+};
+
+// convert xyz to everything
+template <class ToType>
+struct ConverterSpecialized<xyz, ToType, _FromType_>
+{
+    enum { specialized = true };
+    static bool convert(ToType* output, const xyz& input)
+    { return ...; }
+};
+
+// convert abc to xyz
+template <>
+struct ConverterSpecialized<abc, xyz, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(xyz* output, const abc& input)
+    { return ...; }
+};
+*/
+
+////////////
+// STRING //
+////////////
+
+// convert to string
+template <class FromType>
+struct ConverterSpecialized<FromType, std::string, _ToType_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const FromType& input)
+    {
+        std::ostringstream oss;
+        if (oss << input)
+        {
+            (*output) = oss.str();
+            return true;
+        }
+        else
+            return false;
+    }
+};
+
+// convert to string Shortcut
+template <class FromType>
+std::string convertToString(FromType value)
+{
+  return getConvertedValue<FromType, std::string>(value);
+}
+
+// convert from string
+template <class ToType>
+struct ConverterSpecialized<std::string, ToType, _FromType_>
+{
+    enum { specialized = true };
+    static bool convert(ToType* output, const std::string& input)
+    {
+        std::istringstream iss(input);
+        if (iss >> (*output))
+            return true;
+        else
+            return false;
+    }
+};
+
+// convert from string Shortcut
+template <class ToType>
+ToType convertFromString(std::string str)
+{
+  return getConvertedValue<std::string, ToType>(str);
+}
+
+
+//////////
+// MATH //
+//////////
+// convert everything to Degree
+template <class FromType>
+struct ConverterSpecialized<FromType, Ogre::Degree, _ToType_>
+{
+    enum { specialized = true };
+    static bool convert(Ogre::Degree* output, const FromType& input)
+    {
+        float angle = 0;
+        bool success = ConvertValue<FromType, float>(&angle, input);
+        (*output) = angle;
+        return success;
+    }
+};
+
+// convert everything to Radian
+template <class FromType>
+struct ConverterSpecialized<FromType, Ogre::Radian, _ToType_>
+{
+    enum { specialized = true };
+    static bool convert(Ogre::Radian* output, const FromType& input)
+    {
+        float angle = 0;
+        bool success = ConvertValue<FromType, float>(&angle, input);
+        (*output) = angle;
+        return success;
+    }
+};
+
+
+////////////////////
+// MATH TO STRING //
+////////////////////
+
+// bool to std::string
+template <>
+struct ConverterSpecialized<bool, std::string, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const bool& input)
+    {
+        if (input)
+          *output = "true";
+        else
+          *output = "false";
+        return false;
+    }
+};
+
+// Vector2 to std::string
+template <>
+struct ConverterSpecialized<orxonox::Vector2, std::string, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const orxonox::Vector2& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.x << "," << input.y)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// Vector3 to std::string
+template <>
+struct ConverterSpecialized<orxonox::Vector3, std::string, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const orxonox::Vector3& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.x << "," << input.y << "," << input.z)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// Vector4 to std::string
+template <>
+struct ConverterSpecialized<orxonox::Vector4, std::string, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const orxonox::Vector4& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.x << "," << input.y << "," << input.z << "," << input.w)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// Quaternion to std::string
+template <>
+struct ConverterSpecialized<orxonox::Quaternion, std::string, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const orxonox::Quaternion& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.w << "," << input.x << "," << input.y << "," << input.z)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+// ColourValue to std::string
+template <>
+struct ConverterSpecialized<orxonox::ColourValue, std::string, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(std::string* output, const orxonox::ColourValue& input)
+    {
+        std::ostringstream ostream;
+        if (ostream << input.r << "," << input.g << "," << input.b << "," << input.a)
+        {
+            (*output) = ostream.str();
+            return true;
+        }
+        return false;
+    }
+};
+
+
+////////////////////
+// STRING TO MATH //
+////////////////////
+
+// std::string to bool
+template <>
+struct ConverterSpecialized<std::string, bool, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(bool* output, const std::string& input)
+    {
+        std::string stripped = getLowercase(removeTrailingWhitespaces(input));
+        if (stripped == "true" || stripped == "on" || stripped == "yes")
+        {
+          *output = true;
+          return true;
+        }
+        else if (stripped == "false" || stripped == "off" || stripped == "no")
+        {
+          *output = false;
+          return true;
+        }
+
+        std::istringstream iss(input);
+        if (iss >> (*output))
+            return true;
+        else
+            return false;
+    }
+};
+
+// std::string to Vector2
+template <>
+struct ConverterSpecialized<std::string, orxonox::Vector2, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(orxonox::Vector2* output, const std::string& input)
+    {
+        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
+        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (tokens.size() >= 2)
+        {
+            if (!ConvertValue(&(output->x), tokens[0]))
+                return false;
+            if (!ConvertValue(&(output->y), tokens[1]))
+                return false;
+
+            return true;
+        }
+        return false;
+    }
+};
+
+// std::string to Vector3
+template <>
+struct ConverterSpecialized<std::string, orxonox::Vector3, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(orxonox::Vector3* output, const std::string& input)
+    {
+        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
+        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (tokens.size() >= 3)
+        {
+            if (!ConvertValue(&(output->x), tokens[0]))
+                return false;
+            if (!ConvertValue(&(output->y), tokens[1]))
+                return false;
+            if (!ConvertValue(&(output->z), tokens[2]))
+                return false;
+
+            return true;
+        }
+        return false;
+    }
+};
+
+// std::string to Vector4
+template <>
+struct ConverterSpecialized<std::string, orxonox::Vector4, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(orxonox::Vector4* output, const std::string& input)
+    {
+        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
+        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (tokens.size() >= 4)
+        {
+            if (!ConvertValue(&(output->x), tokens[0]))
+                return false;
+            if (!ConvertValue(&(output->y), tokens[1]))
+                return false;
+            if (!ConvertValue(&(output->z), tokens[2]))
+                return false;
+            if (!ConvertValue(&(output->w), tokens[3]))
+                return false;
+
+            return true;
+        }
+        return false;
+    }
+};
+
+// std::string to Quaternion
+template <>
+struct ConverterSpecialized<std::string, orxonox::Quaternion, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(orxonox::Quaternion* output, const std::string& input)
+    {
+        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
+        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (tokens.size() >= 4)
+        {
+            if (!ConvertValue(&(output->w), tokens[0]))
+                return false;
+            if (!ConvertValue(&(output->x), tokens[1]))
+                return false;
+            if (!ConvertValue(&(output->y), tokens[2]))
+                return false;
+            if (!ConvertValue(&(output->z), tokens[3]))
+                return false;
+
+            return true;
+        }
+        return false;
+    }
+};
+
+// std::string to ColourValue
+template <>
+struct ConverterSpecialized<std::string, orxonox::ColourValue, _Explicit_>
+{
+    enum { specialized = true };
+    static bool convert(orxonox::ColourValue* output, const std::string& input)
+    {
+        unsigned int opening_parenthesis, closing_parenthesis = input.find(')');
+        if ((opening_parenthesis = input.find('(')) == std::string::npos) { opening_parenthesis = 0; } else { opening_parenthesis++; }
+
+        SubString tokens(input.substr(opening_parenthesis, closing_parenthesis - opening_parenthesis), ",", SubString::WhiteSpaces, false, '\\', true, '"', true, '\0', '\0', true, '\0');
+        if (tokens.size() >= 3)
+        {
+            if (!ConvertValue(&(output->r), tokens[0]))
+                return false;
+            if (!ConvertValue(&(output->g), tokens[1]))
+                return false;
+            if (!ConvertValue(&(output->b), tokens[2]))
+                return false;
+            if (tokens.size() >= 4)
+            {
+                if (!ConvertValue(&(output->a), tokens[3]))
+                    return false;
+            }
+            else
+                output->a = 1.0;
+
+            return true;
+        }
+        return false;
+    }
+};
+
+
+///////////////////////////
+// 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)
+#endif
+
+#endif /* _Convert_H__ */
Index: /code/branches/ceguilua/src/util/Debug.h
===================================================================
--- /code/branches/ceguilua/src/util/Debug.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Debug.h	(revision 1801)
@@ -0,0 +1,258 @@
+/*
+ *   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 Grauer
+ *   Co-authors:
+ *      Fabian 'x3n' Landau
+ *
+ */
+
+/**
+    @file Debug.h
+    @brief Handles different output-levels of errors, warnings, infos and debug informations.
+
+    The COUT(level) macro acts like std::cout, but the output is only performed if the given
+    level is <= the soft debug level.
+
+    There are two used values in this file:
+     - The hard debug level is used during compiletime. It describes the highest allowed output level.
+     - The soft debug level is used during runtime and is the maximum of the three configurable
+       output-levels for console, logfile and ingame shell.
+
+    The separation between the three devices is done by the OutputHandler.
+
+    Possible levels are:
+     0: Very important output
+     1: Errors
+     2: Warnings
+     3: Informations
+     4: Debug information
+     5: More debug information
+     6: Crazy debug informations
+
+    @example
+    COUT(0) << "Very important output" << std::endl;
+    COUT(1) << "Error: Something went wrong!" << std::endl;
+    COUT(2) << "Warning: There might be a problem." << std::endl;
+    COUT(3) << "Info: It's monday" << std::endl;
+    COUT(4) << "Debug: x is 1.23456" << std::endl;
+ */
+
+#ifndef _Debug_H__
+#define _Debug_H__
+
+#include "UtilPrereqs.h"
+
+#include <stdio.h>
+
+#include "OutputHandler.h"
+
+
+/**
+    @brief Returns the soft debug level, stored in the only existing instance of the OutputHandler class, configured in the config-file.
+    @return The soft debug level
+*/
+static inline int getSoftDebugLevel()
+{
+    return orxonox::OutputHandler::getSoftDebugLevel();
+}
+
+
+// DEFINE ERROR MODES
+#define ORX_NONE            0
+#define ORX_ERROR           1
+#define ORX_WARNING         2
+#define ORX_INFO            3
+#define ORX_DEBUG           4
+#define ORX_VERBOSE         5
+#define ORX_ULTRA           6
+
+//definitions
+#define ORX_PRINT_DEBUG_OUTPUT 1
+#define ORX_HARD_DEBUG_LEVEL ORX_VERBOSE
+
+#define COUT_EXEC(x) orxonox::OutputHandler::getOutStream().setOutputLevel(x)
+
+////////////////////////////////////////////////////////
+///  COUT: just prints output as is with std::cout   ///
+////////////////////////////////////////////////////////
+#define COUTORX_NONE    COUT0
+#define COUTORX_ERROR   COUT1
+#define COUTORX_WARNING COUT2
+#define COUTORX_INFO    COUT3
+#define COUTORX_DEBUG   COUT4
+#define COUTORX_VERBOSE COUT5
+#define COUTORX_ULTRA   COUT6
+
+#ifndef COUT
+ #if ORX_PRINT_DEBUG_OUTPUT
+  #define COUT(x) \
+   COUT ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
+   #define COUT0 \
+    (getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : COUT_EXEC(0)
+  #else
+   #define COUT0 \
+    false ? COUT_EXEC(0) : COUT_EXEC(0)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define COUT1 \
+    (getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : COUT_EXEC(1)
+  #else
+   #define COUT1 \
+    false ? COUT_EXEC(1) : COUT_EXEC(1)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define COUT2 \
+    (getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : COUT_EXEC(2)
+  #else
+   #define COUT2 \
+    false ? COUT_EXEC(2) : COUT_EXEC(2)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define COUT3 \
+    (getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : COUT_EXEC(3)
+  #else
+   #define COUT3 \
+    false ? COUT_EXEC(3) : COUT_EXEC(3)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define COUT4 \
+    (getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : COUT_EXEC(4)
+  #else
+   #define COUT4 \
+    false ? COUT_EXEC(4) : COUT_EXEC(4)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
+   #define COUT5 \
+    (getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : COUT_EXEC(5)
+  #else
+   #define COUT5 \
+    false ? COUT_EXEC(5) : COUT_EXEC(5)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
+   #define COUT6 \
+    (getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : COUT_EXEC(6)
+  #else
+   #define COUT6 \
+    false ? COUT_EXEC(6) : COUT_EXEC(6)
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define COUT(x) \
+    false ? COUT_EXEC(6) : COUT_EXEC(6)
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+#endif /* ifndef COUT */
+
+
+/////////////////////////////////////////////////////////////////////
+///  CCOUT: Prints output with std::cout and adds the classname   ///
+/////////////////////////////////////////////////////////////////////
+#define CCOUTORX_NONE    CCOUT0
+#define CCOUTORX_ERROR   CCOUT1
+#define CCOUTORX_WARNING CCOUT2
+#define CCOUTORX_INFO    CCOUT3
+#define CCOUTORX_DEBUG   CCOUT4
+#define CCOUTORX_VERBOSE CCOUT5
+#define CCOUTORX_ULTRA   CCOUT6
+
+#define CCOUT_EXEC(x) \
+  orxonox::OutputHandler::getOutStream().setOutputLevel(x) \
+  << this->getIdentifier()->getName() << ": "
+
+#ifndef CCOUT
+ #if ORX_PRINT_DEBUG_OUTPUT
+  #define CCOUT(x) \
+   CCOUT ## x
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_NONE
+   #define CCOUT0 \
+    (getSoftDebugLevel() < ORX_NONE) ? COUT_EXEC(0) : CCOUT_EXEC(0)
+  #else
+   #define CCOUT0 \
+    false ? COUT_EXEC(0) : CCOUT_EXEC(0)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ERROR
+   #define CCOUT1 \
+    (getSoftDebugLevel() < ORX_ERROR) ? COUT_EXEC(1) : CCOUT_EXEC(1)
+  #else
+   #define CCOUT1 \
+    false ? COUT_EXEC(1) : CCOUT_EXEC(1)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_WARNING
+   #define CCOUT2 \
+    (getSoftDebugLevel() < ORX_WARNING) ? COUT_EXEC(2) : CCOUT_EXEC(2)
+  #else
+   #define CCOUT2 \
+    false ? COUT_EXEC(2) : CCOUT_EXEC(2)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_INFO
+   #define CCOUT3 \
+    (getSoftDebugLevel() < ORX_INFO) ? COUT_EXEC(3) : CCOUT_EXEC(3)
+  #else
+   #define CCOUT3 \
+    false ? COUT_EXEC(3) : CCOUT_EXEC(3)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_DEBUG
+   #define CCOUT4 \
+    (getSoftDebugLevel() < ORX_DEBUG) ? COUT_EXEC(4) : CCOUT_EXEC(4)
+  #else
+   #define CCOUT4 \
+    false ? COUT_EXEC(4) : CCOUT_EXEC(4)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_VERBOSE
+   #define CCOUT5 \
+    (getSoftDebugLevel() < ORX_VERBOSE) ? COUT_EXEC(5) : CCOUT_EXEC(5)
+  #else
+   #define CCOUT5 \
+    false ? COUT_EXEC(5) : CCOUT_EXEC(5)
+  #endif
+
+  #if ORX_HARD_DEBUG_LEVEL >= ORX_ULTRA
+   #define CCOUT6 \
+    (getSoftDebugLevel() < ORX_ULTRA) ? COUT_EXEC(6) : CCOUT_EXEC(6)
+  #else
+   #define CCOUT6 \
+    false ? COUT_EXEC(6) : CCOUT_EXEC(6)
+  #endif
+
+ #else /* if ORX_PRINT_DEBUG_OUTPUT */
+  #define CCOUT(x) \
+   false ? CCOUT_EXEC(6) : CCOUT_EXEC(6)
+ #endif /* if ORX_PRINT_DEBUG_OUTPUT */
+
+#endif /* ifndef CCOUT */
+
+#endif /* _Debug_H__ */
Index: /code/branches/ceguilua/src/util/Error.cc
===================================================================
--- /code/branches/ceguilua/src/util/Error.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/Error.cc	(revision 1801)
@@ -0,0 +1,60 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Nicolas Perrenoud
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Error.cc
+    @brief Implementation of the Error class.
+*/
+
+#include "Error.h"
+#include "Debug.h"
+
+namespace orxonox
+{
+	Error::Error(std::string errorMsg, int errorCode)
+	{
+		COUT(1) << "############################ " << std::endl
+					  << "#         Error " << errorCode << "          #" << std::endl
+						<< "############################ " << std::endl
+						<< "An error occured in Orxonox: " << std::endl;
+
+		if (errorMsg == "")
+		{
+			switch (errorCode)
+			{
+				case 1:
+					errorMsg = "Some error!";
+					break;
+
+				default:
+					errorMsg = "Unknown error!";
+			}
+		}
+		COUT(1) << errorMsg << std::endl << std::endl;
+	}
+}
Index: /code/branches/ceguilua/src/util/Error.h
===================================================================
--- /code/branches/ceguilua/src/util/Error.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Error.h	(revision 1801)
@@ -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:
+ *      Nicolas Perrenoud
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Error.h
+    @brief Definition of the Error class.
+*/
+
+#ifndef _Error_H__
+#define _Error_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+
+namespace orxonox
+{
+	class _UtilExport Error
+	{
+	public:
+		Error(std::string errorMsg = "", int errorCode = 0);
+	private:
+
+	};
+}
+
+#endif /* _Error_H__ */
Index: /code/branches/ceguilua/src/util/Exception.cc
===================================================================
--- /code/branches/ceguilua/src/util/Exception.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/Exception.cc	(revision 1801)
@@ -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/branches/ceguilua/src/util/Exception.h
===================================================================
--- /code/branches/ceguilua/src/util/Exception.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Exception.h	(revision 1801)
@@ -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 "UtilPrereqs.h"
+
+#include <string>
+#include <exception>
+#include <cassert>
+#include "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 _UtilExport 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/branches/ceguilua/src/util/ExprParser.cc
===================================================================
--- /code/branches/ceguilua/src/util/ExprParser.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/ExprParser.cc	(revision 1801)
@@ -0,0 +1,452 @@
+/*
+ *   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 FloatParser
+*/
+
+#include "ExprParser.h"
+#include <cmath>
+#include <cstring>
+#include <stdlib.h>
+
+// macros for easier if, else statements
+#define CASE_1(var) if (!strcmp(SWITCH,var))
+#define CASE(var) else if (!strcmp(SWITCH,var))
+#define CASE_ELSE else
+
+//! skip white spaces
+#define PARSE_BLANKS while (*reading_stream == ' ') ++reading_stream;
+
+ExprParser::ExprParser(const std::string& str)
+{
+  this->failed_ = false;
+  this->reading_stream = str.c_str();
+  if (str.size() == 0 || *reading_stream == '\0')
+  {
+    this->failed_ = true;
+    this->result_ = 0.0;
+  }
+  else
+  {
+    this->result_ = parse_expr_8();
+    this->remains_ = reading_stream;
+  }
+}
+
+//Private functions:
+/******************/
+double ExprParser::parse_argument()
+{
+   double value = parse_expr_8();
+   if (*reading_stream == ',')
+   {
+      ++reading_stream;
+      return value;
+   }
+   else
+   {
+     this->failed_ = true;
+     return 0;
+   }
+}
+
+double ExprParser::parse_last_argument()
+{
+   double value = parse_expr_8();
+   if (*reading_stream == ')')
+   {
+      ++reading_stream;
+      return value;
+   }
+   else
+   {
+     this->failed_ = true;
+     return 0;
+   }
+}
+
+double ExprParser::parse_expr_8()
+{
+   double value = parse_expr_7();
+   for(;;)
+   {
+      switch (op)
+      {
+         case oder:
+            value = parse_expr_7() || value;
+            break;
+         default: return value;
+      }
+   };
+}
+
+
+double ExprParser::parse_expr_7()
+{
+   double value = parse_expr_6();
+   for(;;)
+   {
+      switch (op)
+      {
+         case und:
+            value = value && parse_expr_6();
+            break;
+         default: return value;
+      }
+   };
+}
+
+double ExprParser::parse_expr_6()
+{
+   double value = parse_expr_5();
+   for(;;)
+   {
+      switch (op)
+      {
+         case gleich:
+            value = (value == parse_expr_5());
+            break;
+         case ungleich:
+            value = (value != parse_expr_5());
+            break;
+         default:
+            return value;
+      }
+   };
+}
+
+double ExprParser::parse_expr_5()
+{
+   double value = parse_expr_4();
+   for(;;)
+   {
+      switch (op)
+      {
+         case kleiner:
+            value = (value < parse_expr_4());
+            break;
+         case kleinergleich:
+            value = (value <= parse_expr_4());
+            break;
+         case groesser:
+            value = (value > parse_expr_4());
+            break;
+         case groessergleich:
+            value = (value >= parse_expr_4());
+            break;
+         default:
+            return value;
+      }
+   };
+}
+
+double ExprParser::parse_expr_4()
+{
+   double value = parse_expr_3();
+   for(;;)
+   {
+      switch (op)
+      {
+         case b_plus:
+            value += parse_expr_3();
+            break;
+         case b_minus:
+            value -= parse_expr_3();
+            break;
+         default:
+            return value;
+      }
+   };
+}
+
+double ExprParser::parse_expr_3()
+{
+   double value = parse_expr_2();
+   for(;;)
+   {
+      switch (op)
+      {
+         case mal:
+            value *= parse_expr_2();
+            break;
+         case durch:
+            value /= parse_expr_2();
+            break;
+         case modulo:
+         {
+            double temp = parse_expr_2();
+            value = value - floor(value/temp)*temp;
+            break;
+         }
+         default:
+            return value;
+      }
+   };
+}
+
+double ExprParser::parse_expr_2()
+{
+   double value = parse_expr_1();
+   while (*reading_stream != '\0')
+   {
+      op = parse_binary_operator();
+      switch (op)
+      {
+         case hoch:
+            value = pow(value,parse_expr_1());
+            break;
+         default:
+            return value;
+      }
+   };
+   op = undef;
+   return value;
+}
+
+double ExprParser::parse_expr_1()
+{
+   PARSE_BLANKS
+   double value;
+
+   unary_operator op = parse_unary_operator();
+   PARSE_BLANKS
+
+   if (*reading_stream == '\0')
+   {
+     // end of string
+     this->failed_ = true;
+     return 0;
+   }
+   else if (*reading_stream > 47 && *reading_stream < 59 || *reading_stream == 46)
+   {  // number
+      value = strtod(reading_stream, const_cast<char**>(&reading_stream));
+   }
+   else if (*reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)
+   {  // variable or function
+      char* word = new char[256];
+      parse_word(word);
+      PARSE_BLANKS
+      if (*reading_stream == '(')
+      {
+         ++reading_stream;
+#define SWITCH word
+         CASE_1("sin")
+            value = sin(parse_last_argument());
+         CASE("asin")
+            value = asin(parse_last_argument());
+         CASE("sinh")
+            value = sinh(parse_last_argument());
+         CASE("asinh")
+         {
+            value = parse_last_argument();
+            value = log(sqrt(pow(value, 2) + 1) + value);
+         }
+         CASE("cos")
+            value = cos(parse_last_argument());
+         CASE("acos")
+            value = acos(parse_last_argument());
+         CASE("cosh")
+            value = cosh(parse_last_argument());
+         CASE("acosh")
+         {
+            value = parse_last_argument();
+            value = log(sqrt(pow(value, 2) - 1) + value);
+         }
+         CASE("tan")
+            value = tan(parse_last_argument());
+         CASE("atan")
+            value = atan(parse_last_argument());
+         CASE("atan2")
+            value = atan2(parse_argument(),parse_last_argument());
+         CASE("tanh")
+            value = tanh(parse_last_argument());
+         CASE("atanh")
+         {
+            value = parse_last_argument();
+            value = 0.5*log((value + 1)/(value - 1));
+         }
+         CASE("int")
+            value = floor(parse_last_argument());
+         CASE("floor")
+            value = floor(parse_last_argument());
+         CASE("ceil")
+            value = ceil(parse_last_argument());
+         CASE("abs")
+            value = fabs(parse_last_argument());
+         CASE("exp")
+            value = exp(parse_last_argument());
+         CASE("log")
+            value = log10(parse_last_argument());
+         CASE("ln")
+            value = log(parse_last_argument());
+         CASE("sign")
+         {
+            value = parse_last_argument();
+            value = (value>0 ? 1 : (value<0 ? -1 : 0));
+         }
+         CASE("sqrt")
+            value = sqrt(parse_last_argument());
+         CASE("degrees")
+            value = parse_last_argument()*180/3.1415926535897932;
+         CASE("radians")
+            value = parse_last_argument()*3.1415926535897932/180;
+         CASE("mod")
+         {
+            value = parse_argument();
+            double value2 = parse_last_argument();
+            value = value - floor(value/value2)*value2;
+         }
+         CASE("pow")
+            value = pow(parse_argument(),parse_last_argument());
+         CASE("div")
+            value = floor(parse_argument()/parse_last_argument());
+         CASE("max")
+           value = std::max(parse_argument(),parse_last_argument());
+         CASE("min")
+           value = std::min(parse_argument(),parse_last_argument());
+         CASE_ELSE
+         {
+           this->failed_ = true;
+           delete[] word;
+           return 0;
+         }
+      }
+      else
+      {
+#define SWITCH word
+         CASE_1("pi")
+           value = 3.1415926535897932;
+         CASE("e")
+           value = 2.7182818284590452;
+         CASE_ELSE
+         {
+           this->failed_ = true;
+           delete[] word;
+           return 0;
+         }
+      }
+      delete[] word;
+   }
+   else if (*reading_stream == 40)
+   {  // expresion in paranthesis
+      ++reading_stream;
+      value = parse_last_argument();
+   }
+   else
+   {
+     this->failed_ = true;
+     return 0;
+   }
+
+   PARSE_BLANKS
+   switch (op)
+   {
+      case u_nicht: return !value;
+      case u_plus:  return  value;
+      case u_minus: return -value;
+      default:
+        {
+          this->failed_ = true;
+          return 0;
+        }
+   }
+}
+
+char* ExprParser::parse_word(char* str)
+{
+   char* word = str;
+   int counter = 0;
+   while (*reading_stream > 47 && *reading_stream < 58 || *reading_stream > 64 && *reading_stream < 91 || *reading_stream > 96 && *reading_stream < 123 || *reading_stream == 46)
+   {
+      *word++ = *reading_stream++;
+      counter++;
+      if (counter > 255)
+      {
+        this->failed_ = true;
+        return '\0';
+      }
+   };
+   *word = '\0';
+   return str;
+}
+
+ExprParser::binary_operator ExprParser::parse_binary_operator()
+{
+   binary_operator op;
+   switch (*reading_stream)
+   {
+      case '+': op = b_plus; break;
+      case '-': op = b_minus; break;
+      case '*': op = mal; break;
+      case '/': op = durch; break;
+      case '^': op = hoch; break;
+      case '%': op = modulo; break;
+      case '&': op = und; break;
+      case '|': op = oder; break;
+      case '=': op = gleich; break;
+      case '!': op = b_nicht; break;
+      case '<': op = kleiner; break;
+      case '>': op = groesser; break;
+      default: return undef;
+   }
+   if (*++reading_stream == '=')
+   {
+      if (op > 9)
+      {
+         ++reading_stream;
+         return (binary_operator)(op + 3);
+      }
+      else
+      {
+         --reading_stream;
+         return undef;
+      }
+   }
+   else
+      return op;
+}
+
+ExprParser::unary_operator ExprParser::parse_unary_operator()
+{
+   switch (*reading_stream)
+   {
+      case '!':
+         ++reading_stream;
+         return u_nicht;
+      case '+':
+         ++reading_stream;
+         return u_plus;
+      case '-':
+         ++reading_stream;
+         return u_minus;
+      default :
+         return u_plus;
+   }
+}
Index: /code/branches/ceguilua/src/util/ExprParser.h
===================================================================
--- /code/branches/ceguilua/src/util/ExprParser.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/ExprParser.h	(revision 1801)
@@ -0,0 +1,107 @@
+/*
+ *   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 FloatParser
+*/
+
+#ifndef _FloatParser_H__
+#define _FloatParser_H__
+
+#include "UtilPrereqs.h"
+#include <string>
+
+class _UtilExport ExprParser
+{
+public:
+  enum binary_operator
+  {
+    b_plus,
+    b_minus,
+    mal,
+    durch,
+    modulo,
+    hoch,
+    undef,
+    oder,
+    und,
+    gleich,
+    b_nicht,
+    kleiner,
+    groesser,
+    ungleich,
+    kleinergleich,
+    groessergleich
+  };
+
+  enum unary_operator
+  {
+    u_plus,
+    u_minus,
+    u_nicht
+  };
+
+
+  ExprParser(const std::string& str);
+  std::string& getRemains() { return  this->remains_; }
+  double       getResult()  { return  this->result_; }
+  bool         getSuccess() { return !this->failed_; }
+
+private:
+  double parse_expr_1();
+  double parse_expr_2();
+  double parse_expr_3();
+  double parse_expr_4();
+  double parse_expr_5();
+  double parse_expr_6();
+  double parse_expr_7();
+  double parse_expr_8();
+  char* parse_word(char* str);
+  binary_operator parse_binary_operator();
+  unary_operator parse_unary_operator();
+
+  double parse_argument();
+  double parse_last_argument();
+
+  binary_operator op;
+  const char* reading_stream;
+  bool failed_;
+  double result_;
+  std::string remains_;
+
+};
+
+//Endzeichen für float expression: ')', '}', ']', ',', ';'
+_UtilExport bool parse_float(char* const, char**, double*);
+//Endzeichen angegeben
+_UtilExport bool parse_float(char* const, char**, char, double*);
+//Letzter Teil-float eines Vektors parsen (keine Vergleichs- und Logikoperationen)
+_UtilExport bool parse_vector_float(char* const, char**, bool, double*);
+
+#endif /* _FloatParser_H__ */
Index: /code/branches/ceguilua/src/util/Integers.h
===================================================================
--- /code/branches/ceguilua/src/util/Integers.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Integers.h	(revision 1801)
@@ -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/branches/ceguilua/src/util/Math.cc
===================================================================
--- /code/branches/ceguilua/src/util/Math.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/Math.cc	(revision 1801)
@@ -0,0 +1,206 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Math.cc
+    @brief Implementation of several math-functions.
+*/
+
+#include <OgrePlane.h>
+
+#include "Math.h"
+#include "Convert.h"
+
+/**
+    @brief Function for writing a Radian to a stream.
+*/
+std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian)
+{
+    out << radian.valueRadians();
+    return out;
+}
+
+/**
+    @brief Function for reading a Radian from a stream.
+*/
+std::istream& operator>>(std::istream& in, orxonox::Radian& radian)
+{
+    float temp;
+    in >> temp;
+    radian = temp;
+    return in;
+}
+
+/**
+    @brief Function for writing a Degree to a stream.
+*/
+std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree)
+{
+    out << degree.valueDegrees();
+    return out;
+}
+
+/**
+    @brief Function for reading a Degree from a stream.
+*/
+std::istream& operator>>(std::istream& in, orxonox::Degree& degree)
+{
+    float temp;
+    in >> temp;
+    degree = temp;
+    return in;
+}
+
+
+/**
+    @brief Gets the angle between my viewing direction and the direction to the position of the other object.
+    @param myposition My position
+    @param mydirection My viewing direction
+    @param otherposition The position of the other object
+    @return The angle
+
+    @example
+    If the other object is exactly in front of me, the function returns 0.
+    If the other object is exactly behind me, the function returns pi.
+    If the other object is exactly right/left to me (or above/below), the function returns pi/2.
+*/
+float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition)
+{
+    orxonox::Vector3 distance = otherposition - myposition;
+    float distancelength = distance.length();
+    if (distancelength == 0)
+        return 0;
+    else
+        return acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1));
+}
+
+/**
+    @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object.
+    @param myposition My position
+    @param mydirection My viewing direction
+    @param myorthonormal My orthonormalvector (pointing upwards through my head)
+    @param otherposition The position of the other object
+    @return The viewing direction
+
+    @example
+    If the other object is exactly in front of me, the function returns Vector2(0, 0).
+    If the other object is exactly at my left, the function returns Vector2(-1, 0).
+    If the other object is exactly at my right, the function returns Vector2(1, 0).
+    If the other object is only a bit at my right, the function still returns Vector2(1, 0).
+    If the other object is exactly above me, the function returns Vector2(0, 1).
+*/
+orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
+{
+    orxonox::Vector3 distance = otherposition - myposition;
+
+    // project difference vector on our plane
+    orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
+
+    float projectionlength = projection.length();
+    if (projectionlength == 0) return orxonox::Vector2(0, 0);
+    float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
+
+    if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
+        return orxonox::Vector2(sin(angle), cos(angle));
+    else
+        return orxonox::Vector2(-sin(angle), cos(angle));
+}
+
+/**
+    @brief Gets the 2D viewing direction (up/down, left/right) to the position of the other object, multiplied with the viewing distance to the object (0° = 0, 180° = 1).
+    @param myposition My position
+    @param mydirection My viewing direction
+    @param myorthonormal My orthonormalvector (pointing upwards through my head)
+    @param otherposition The position of the other object
+    @return The viewing direction
+
+    @example
+    If the other object is exactly in front of me, the function returns Vector2(0, 0).
+    If the other object is exactly at my left, the function returns Vector2(-0.5, 0).
+    If the other object is exactly at my right, the function returns Vector2(0.5, 0).
+    If the other object is only a bit at my right, the function still returns Vector2(0.01, 0).
+    If the other object is exactly above me, the function returns Vector2(0, 0.5).
+*/
+orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
+{
+    orxonox::Vector3 distance = otherposition - myposition;
+
+    // project difference vector on our plane
+    orxonox::Vector3 projection = Ogre::Plane(mydirection, myposition).projectVector(distance);
+
+    float projectionlength = projection.length();
+    if (projectionlength == 0) return orxonox::Vector2(0, 0);
+    float angle = acos(clamp<float>(myorthonormal.dotProduct(projection) / projectionlength, -1, 1));
+
+    float distancelength = distance.length();
+    if (distancelength == 0) return orxonox::Vector2(0, 0);
+    float radius = acos(clamp<float>(mydirection.dotProduct(distance) / distancelength, -1, 1)) / Ogre::Math::PI;
+
+    if ((mydirection.crossProduct(myorthonormal)).dotProduct(distance) > 0)
+        return orxonox::Vector2(sin(angle) * radius, cos(angle) * radius);
+    else
+        return orxonox::Vector2(-sin(angle) * radius, cos(angle) * radius);
+}
+
+/**
+    @brief Returns the predicted position I have to aim at, if I want to hit a moving target with a moving projectile.
+    @param myposition My position
+    @param projectilespeed The speed of my projectile
+    @param targetposition The position of my target
+    @param targetvelocity The velocity of my target
+    @return The predicted position
+
+    The function predicts the position based on a linear velocity of the target. If the target changes speed or direction, the projectile will miss.
+*/
+orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity)
+{
+    float squaredProjectilespeed = projectilespeed * projectilespeed;
+    orxonox::Vector3 distance = targetposition - myposition;
+    float a = distance.squaredLength();
+    float b = 2 * (distance.x + distance.y + distance.z) * (targetvelocity.x + targetvelocity.y + targetvelocity.z);
+    float c = targetvelocity.squaredLength();
+
+    float temp = 4*squaredProjectilespeed*c + a*a - 4*b*c;
+    if (temp < 0)
+        return orxonox::Vector3::ZERO;
+
+    temp = sqrt(temp);
+    float time = (temp + a) / (2 * (squaredProjectilespeed - b));
+    return (targetposition + targetvelocity * time);
+}
+
+unsigned long getUniqueNumber()
+{
+    static unsigned long aNumber = 135;
+    return aNumber++;
+}
+
+std::string getUniqueNumberStr()
+{
+    return convertToString(getUniqueNumber());
+}
Index: /code/branches/ceguilua/src/util/Math.h
===================================================================
--- /code/branches/ceguilua/src/util/Math.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Math.h	(revision 1801)
@@ -0,0 +1,266 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file Math.h
+    @brief Declaration and implementation of several math-functions, typedefs of some Ogre::Math classes to the orxonox namespace.
+*/
+
+#ifndef _Util_Math_H__
+#define _Util_Math_H__
+
+#include "UtilPrereqs.h"
+
+#include <ostream>
+#include <string>
+
+#include <OgreMath.h>
+#include <OgreVector2.h>
+#include <OgreVector3.h>
+#include <OgreVector4.h>
+#include <OgreMatrix3.h>
+#include <OgreMatrix4.h>
+#include <OgreQuaternion.h>
+#include <OgreColourValue.h>
+
+namespace orxonox
+{
+  typedef Ogre::Radian Radian;
+  typedef Ogre::Degree Degree;
+  typedef Ogre::Vector2 Vector2;
+  typedef Ogre::Vector3 Vector3;
+  typedef Ogre::Vector4 Vector4;
+  typedef Ogre::Matrix3 Matrix3;
+  typedef Ogre::Matrix4 Matrix4;
+  typedef Ogre::Quaternion Quaternion;
+  typedef Ogre::ColourValue ColourValue;
+}
+
+_UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Radian& radian);
+_UtilExport std::istream& operator>>(std::istream& in, orxonox::Radian& radian);
+_UtilExport std::ostream& operator<<(std::ostream& out, const orxonox::Degree& degree);
+_UtilExport std::istream& operator>>(std::istream& in, orxonox::Degree& degree);
+
+_UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
+_UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
+_UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
+_UtilExport orxonox::Vector3 getPredictedPosition(const orxonox::Vector3& myposition, float projectilespeed, const orxonox::Vector3& targetposition, const orxonox::Vector3& targetvelocity);
+
+//Get around Windows hackery
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32
+#  ifdef max
+#    undef max
+#  endif
+#  ifdef min
+#    undef min
+#  endif
+#endif
+
+/**
+    @brief Returns the sign of the given value.
+    @param x The value
+    @return 1 if the value is positive or zero, -1 if the value is negative
+*/
+template <typename T>
+inline T sgn(T x)
+{
+    return (x >= 0) ? 1 : -1;
+}
+
+/**
+    @brief Returns the smaller of two values.
+*/
+template <typename T>
+inline T min(T a, T b)
+{
+    return (a <= b) ? a : b;
+}
+
+/**
+    @brief Returns the greater of two values.
+*/
+template <typename T>
+inline T max(T a, T b)
+{
+    return (a >= b) ? a : b;
+}
+
+/**
+    @brief Keeps a value between a lower and an upper limit.
+    @param x The value
+    @param min The lower limit
+    @param max The upper limit
+*/
+template <typename T>
+inline T clamp(T x, T min, T max)
+{
+    if (x < min)
+        return min;
+
+    if (x > max)
+        return max;
+
+    return x;
+}
+
+/**
+    @brief Returns the square value (x^2).
+*/
+template <typename T>
+inline T square(T x)
+{
+    return x*x;
+}
+
+/**
+    @brief Returns the cube value (x^3).
+*/
+template <typename T>
+inline T cube(T x)
+{
+    return x*x*x;
+}
+
+/**
+    @brief Rounds the value down.
+*/
+template <typename T>
+inline int floor(T x)
+{
+    return (int)(x);
+}
+
+/**
+    @brief Rounds the value up.
+*/
+template <typename T>
+inline int ceil(T x)
+{
+    int temp = floor(x);
+    return (temp != x) ? (temp + 1) : temp;
+}
+
+/**
+    @brief Rounds the value.
+*/
+template <typename T>
+inline int round(T x)
+{
+    return (int)(x + 0.5);
+}
+
+/**
+    @brief The modulo operation, enhanced to work properly with negative values.
+    @param x The value
+    @param max The operand
+*/
+template <typename T>
+inline int mod(T x, int max)
+{
+    if (x >= 0)
+        return (x % max);
+    else
+        return ((x % max) + max);
+}
+
+/**
+    @brief Interpolates between two values for a time between 0 and 1.
+    @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
+    @param start The value at time = 0
+    @param end The value at time = 1
+    @return The interpolation at a given time
+*/
+template <typename T>
+T interpolate(float time, const T& start, const T& end)
+{
+    return time * (end - start) + start;
+}
+
+/**
+    @brief Interpolates smoothly between two values for a time between 0 and 1. The function starts slowly, increases faster and stops slowly again.
+    @param time The time is a value between 0 and 1 - the function returns start if time is 0 and end if time is 1 and interpolates if time is between 0 and 1.
+    @param start The value at time = 0
+    @param end The value at time = 1
+    @return The smoothed interpolation at a given time
+*/
+template <typename T>
+T interpolateSmooth(float time, const T& start, const T& end)
+{
+    return (-2 * (end - start) * cube(time)) + (3 * (end - start) * square(time)) + start;
+}
+
+/**
+    @brief Returns a random number between 0 and 1.
+*/
+inline _UtilExport float rnd()
+{
+    return ((float)rand() / RAND_MAX);
+}
+
+/**
+    @brief Returns a random number between 0 and max.
+    @param max The maximum
+*/
+inline _UtilExport float rnd(float max)
+{
+    return rnd() * max;
+}
+
+/**
+    @brief Returns a random number between min and max.
+    @param min The minimum
+    @param max The maximum
+*/
+inline _UtilExport float rnd(float min, float max)
+{
+    return rnd(max - min) + min;
+}
+
+_UtilExport unsigned long getUniqueNumber();
+_UtilExport std::string getUniqueNumberStr();
+
+class _UtilExport IntVector2
+{
+public:
+  IntVector2() : x(0), y(0) { }
+  IntVector2(int _x, int _y) : x(_x), y(_y) { }
+  int x;
+  int y;
+};
+
+class _UtilExport IntVector3
+{
+public:
+  IntVector3() : x(0), y(0), z(0) { }
+  IntVector3(int _x, int _y, int _z) : x(_x), y(_y), z(_z) { }
+  int x;
+  int y;
+  int z;
+};
+
+#endif /* _Util_Math_H__ */
Index: /code/branches/ceguilua/src/util/MultiType.cc
===================================================================
--- /code/branches/ceguilua/src/util/MultiType.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/MultiType.cc	(revision 1801)
@@ -0,0 +1,203 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MultiType.cc
+    @brief Implementation of the MultiType.
+*/
+
+#include "MultiType.h"
+#include "MultiTypeValue.h"
+
+/**
+    @brief Converts the current value of the MultiType to a new type.
+    @param type The type
+*/
+void MultiType::convert(MT_Type type)
+{
+    switch (type)
+    {
+        case MT_char:
+            this->convert<char>(); break;
+        case MT_uchar:
+            this->convert<unsigned char>(); break;
+        case MT_short:
+            this->convert<short>(); break;
+        case MT_ushort:
+            this->convert<unsigned short>(); break;
+        case MT_int:
+            this->convert<int>(); break;
+        case MT_uint:
+            this->convert<unsigned int>(); break;
+        case MT_long:
+            this->convert<long>(); break;
+        case MT_ulong:
+            this->convert<unsigned long>(); break;
+        case MT_longlong:
+            this->convert<long long>(); break;
+        case MT_ulonglong:
+            this->convert<unsigned long long>(); break;
+        case MT_float:
+            this->convert<float>(); break;
+        case MT_double:
+            this->convert<double>(); break;
+        case MT_longdouble:
+            this->convert<long double>(); break;
+        case MT_bool:
+            this->convert<bool>(); break;
+        case MT_void:
+            this->convert<void*>(); break;
+        case MT_string:
+            this->convert<std::string>(); break;
+        case MT_vector2:
+            this->convert<orxonox::Vector2>(); break;
+        case MT_vector3:
+            this->convert<orxonox::Vector3>(); break;
+        case MT_vector4:
+            this->convert<orxonox::Vector4>(); break;
+        case MT_colourvalue:
+            this->convert<orxonox::ColourValue>(); break;
+        case MT_quaternion:
+            this->convert<orxonox::Quaternion>(); break;
+        case MT_radian:
+            this->convert<orxonox::Radian>(); break;
+        case MT_degree:
+            this->convert<orxonox::Degree>(); break;
+        default:
+            this->reset(); break;
+    };
+}
+
+/**
+    @brief Returns the name of the current type.
+    @return The name
+*/
+std::string MultiType::getTypename() const
+{
+    MT_Type type = (this->value_) ? this->value_->type_ : MT_null;
+
+    switch (type)
+    {
+        case MT_char:
+            return "char"; break;
+        case MT_uchar:
+            return "unsigned char"; break;
+        case MT_short:
+            return "short"; break;
+        case MT_ushort:
+            return "unsigned short"; break;
+        case MT_int:
+            return "int"; break;
+        case MT_uint:
+            return "unsigned int"; break;
+        case MT_long:
+            return "long"; break;
+        case MT_ulong:
+            return "unsigned long"; break;
+        case MT_longlong:
+            return "long long"; break;
+        case MT_ulonglong:
+            return "unsigned long long"; break;
+        case MT_float:
+            return "float"; break;
+        case MT_double:
+            return "double"; break;
+        case MT_longdouble:
+            return "long double"; break;
+        case MT_bool:
+            return "bool"; break;
+        case MT_void:
+            return "void*"; break;
+        case MT_string:
+            return "std::string"; break;
+        case MT_vector2:
+            return "orxonox::Vector2"; break;
+        case MT_vector3:
+            return "orxonox::Vector3"; break;
+        case MT_vector4:
+            return "orxonox::Vector4"; break;
+        case MT_colourvalue:
+            return "orxonox::ColourValue"; break;
+        case MT_quaternion:
+            return "orxonox::Quaternion"; break;
+        case MT_radian:
+            return "orxonox::Radian"; break;
+        case MT_degree:
+            return "orxonox::Degree"; break;
+        default:
+            return "unknown"; break;
+    };
+}
+
+MultiType::operator char()                 const { return (this->value_) ? ((this->value_->type_ == MT_char       ) ? ((MT_Value<char>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned char()        const { return (this->value_) ? ((this->value_->type_ == MT_uchar      ) ? ((MT_Value<unsigned char>       *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator short()                const { return (this->value_) ? ((this->value_->type_ == MT_short      ) ? ((MT_Value<short>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned short()       const { return (this->value_) ? ((this->value_->type_ == MT_ushort     ) ? ((MT_Value<unsigned short>      *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator int()                  const { return (this->value_) ? ((this->value_->type_ == MT_int        ) ? ((MT_Value<int>                 *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned int()         const { return (this->value_) ? ((this->value_->type_ == MT_uint       ) ? ((MT_Value<unsigned int>        *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator long()                 const { return (this->value_) ? ((this->value_->type_ == MT_long       ) ? ((MT_Value<long>                *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned long()        const { return (this->value_) ? ((this->value_->type_ == MT_ulong      ) ? ((MT_Value<unsigned long>       *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator long long()            const { return (this->value_) ? ((this->value_->type_ == MT_longlong   ) ? ((MT_Value<long long>           *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator unsigned long long()   const { return (this->value_) ? ((this->value_->type_ == MT_ulonglong  ) ? ((MT_Value<unsigned long long>  *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator float()                const { return (this->value_) ? ((this->value_->type_ == MT_float      ) ? ((MT_Value<float>               *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator double()               const { return (this->value_) ? ((this->value_->type_ == MT_double     ) ? ((MT_Value<double>              *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator long double()          const { return (this->value_) ? ((this->value_->type_ == MT_longdouble ) ? ((MT_Value<long double>         *)this->value_)->value_ : (*this->value_)) : 0;                      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator bool()                 const { return (this->value_) ? ((this->value_->type_ == MT_bool       ) ? ((MT_Value<bool>                *)this->value_)->value_ : (*this->value_)) : false;                  } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator void*()                const { return (this->value_) ? ((this->value_->type_ == MT_void       ) ? ((MT_Value<void*>               *)this->value_)->value_ : (*this->value_)) : (void*)0;               } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator std::string()          const { return (this->value_) ? ((this->value_->type_ == MT_string     ) ? ((MT_Value<std::string>         *)this->value_)->value_ : (*this->value_)) : std::string();          } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Vector2()     const { return (this->value_) ? ((this->value_->type_ == MT_vector2    ) ? ((MT_Value<orxonox::Vector2>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Vector3()     const { return (this->value_) ? ((this->value_->type_ == MT_vector3    ) ? ((MT_Value<orxonox::Vector3>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Vector4()     const { return (this->value_) ? ((this->value_->type_ == MT_vector4    ) ? ((MT_Value<orxonox::Vector4>    *)this->value_)->value_ : (*this->value_)) : orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::ColourValue() const { return (this->value_) ? ((this->value_->type_ == MT_colourvalue) ? ((MT_Value<orxonox::ColourValue>*)this->value_)->value_ : (*this->value_)) : orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Quaternion()  const { return (this->value_) ? ((this->value_->type_ == MT_quaternion ) ? ((MT_Value<orxonox::Quaternion> *)this->value_)->value_ : (*this->value_)) : orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Radian()      const { return (this->value_) ? ((this->value_->type_ == MT_radian     ) ? ((MT_Value<orxonox::Radian>     *)this->value_)->value_ : (*this->value_)) : orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
+MultiType::operator orxonox::Degree()      const { return (this->value_) ? ((this->value_->type_ == MT_degree     ) ? ((MT_Value<orxonox::Degree>     *)this->value_)->value_ : (*this->value_)) : orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
+
+template <> void MultiType::createNewValueContainer(const char& value)                 { this->value_ = new MT_Value<char>                (value, MT_char       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned char& value)        { this->value_ = new MT_Value<unsigned char>       (value, MT_uchar      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const short& value)                { this->value_ = new MT_Value<short>               (value, MT_short      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned short& value)       { this->value_ = new MT_Value<unsigned short>      (value, MT_ushort     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const int& value)                  { this->value_ = new MT_Value<int>                 (value, MT_int        ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned int& value)         { this->value_ = new MT_Value<unsigned int>        (value, MT_uint       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const long& value)                 { this->value_ = new MT_Value<long>                (value, MT_long       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned long& value)        { this->value_ = new MT_Value<unsigned long>       (value, MT_ulong      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const long long& value)            { this->value_ = new MT_Value<long long>           (value, MT_longlong   ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const unsigned long long& value)   { this->value_ = new MT_Value<unsigned long long>  (value, MT_ulonglong  ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const float& value)                { this->value_ = new MT_Value<float>               (value, MT_float      ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const double& value)               { this->value_ = new MT_Value<double>              (value, MT_double     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const long double& value)          { this->value_ = new MT_Value<long double>         (value, MT_longdouble ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const bool& value)                 { this->value_ = new MT_Value<bool>                (value, MT_bool       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(      void* const& value)          { this->value_ = new MT_Value<void*>               (value, MT_void       ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const std::string& value)          { this->value_ = new MT_Value<std::string>         (value, MT_string     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value)     { this->value_ = new MT_Value<orxonox::Vector2>    (value, MT_vector2    ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value)     { this->value_ = new MT_Value<orxonox::Vector3>    (value, MT_vector3    ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value)     { this->value_ = new MT_Value<orxonox::Vector4>    (value, MT_vector4    ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value) { this->value_ = new MT_Value<orxonox::ColourValue>(value, MT_colourvalue); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value)  { this->value_ = new MT_Value<orxonox::Quaternion> (value, MT_quaternion ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Radian& value)      { this->value_ = new MT_Value<orxonox::Radian>     (value, MT_radian     ); } /** @brief Creates a new value container for the given type. */
+template <> void MultiType::createNewValueContainer(const orxonox::Degree& value)      { this->value_ = new MT_Value<orxonox::Degree>     (value, MT_degree     ); } /** @brief Creates a new value container for the given type. */
Index: /code/branches/ceguilua/src/util/MultiType.h
===================================================================
--- /code/branches/ceguilua/src/util/MultiType.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/MultiType.h	(revision 1801)
@@ -0,0 +1,490 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MultiType.h
+    @brief Declaration of the MultiType and some helper constructs.
+
+    The MultiType can hold a value of one of the following types:
+     - all primitives
+     - all pointers
+     - string
+     - Vector2, Vector3, Vector4
+     - Quaternion
+     - ColourValue
+     - Radian, Degree
+
+    The MultiType has a "type" determined by the first assigned value, either through
+     - the constructor,
+     - the assignment operator= or
+     - setValue(value).
+    If you assign another value of another type, the MultiType keeps "it's" type and
+    converts the new value to this type.
+
+    If you want to change the type, there are three possibilities:
+     - convert<T>() set's the type to T and converts the currently assigned value
+     - setType<T>() set's the type to T and resets the value
+     - setValue<T>(value) assigns a new value and changes the type to T.
+
+    @example
+    MultiType a = 10;;         // a has now the type int and the value 10
+    a.setValue("3.14");        // a has still the type int and "3.14" gets converted, therefore the value is now 3
+    a.setValue<float>("3.14"); // a has now the type float and "3.14" gets converted to 3.14
+    a.convert<bool>();         // converts 3.14 to bool, which is true
+    a = false;                 // assigns false, this is equivalent to a.setValue(false)
+*/
+
+#ifndef _MultiType_H__
+#define _MultiType_H__
+
+#include "UtilPrereqs.h"
+
+#include <boost/static_assert.hpp>
+
+#include "Math.h"
+
+/**
+    @brief Enum of all possible types of a MultiType.
+*/
+enum MT_Type
+{
+    MT_null,
+    MT_char,
+    MT_uchar,
+    MT_short,
+    MT_ushort,
+    MT_int,
+    MT_uint,
+    MT_long,
+    MT_ulong,
+    MT_longlong,
+    MT_ulonglong,
+    MT_float,
+    MT_double,
+    MT_longdouble,
+    MT_bool,
+    MT_void,
+    MT_string,
+    MT_vector2,
+    MT_vector3,
+    MT_vector4,
+    MT_colourvalue,
+    MT_quaternion,
+    MT_radian,
+    MT_degree
+};
+
+/**
+    @brief The MultiType can hold a value of many possible types and convert them to other types.
+
+    The following types are supported by the MultiType:
+     - all primitves
+     - all pointers
+     - string
+     - Vector2, Vector3, Vector4
+     - Quaternion
+     - ColourValue
+     - Radian, Degree
+
+    The internal type of a MultiType is determined by the first assigned value, but can be
+    changed by using setType<T>(), convert<T>() or setValue<T>(value). If a value gets assigned
+    the normal way (operator=, setValue(value)), the value gets converted to the current internal
+    type of the MultiType.
+*/
+class _UtilExport MultiType
+{
+    _UtilExport friend std::ostream& operator<<(std::ostream& outstream, const MultiType& mt);
+    template <typename T> friend struct MT_Value;
+
+    /**
+        @brief MT_ValueBase is an almost pure virtual baseclass of MT_Value<T>, which holds the value of the MultiType.
+        This class is only used within the MultiType.
+    */
+    struct _UtilExport MT_ValueBase
+    {
+        MT_ValueBase(MT_Type type) : type_(type) {}
+        virtual ~MT_ValueBase() {}
+
+        virtual MT_ValueBase* clone() const = 0;
+
+        virtual void reset() = 0;
+        virtual void assimilate(const MultiType& other) = 0;
+
+        /** @brief Returns the type of the current value. */
+        const MT_Type& getType() const { return this->type_; }
+
+        virtual void setValue(const char& value)                 = 0;
+        virtual void setValue(const unsigned char& value)        = 0;
+        virtual void setValue(const short& value)                = 0;
+        virtual void setValue(const unsigned short& value)       = 0;
+        virtual void setValue(const int& value)                  = 0;
+        virtual void setValue(const unsigned int& value)         = 0;
+        virtual void setValue(const long& value)                 = 0;
+        virtual void setValue(const unsigned long& value)        = 0;
+        virtual void setValue(const long long& value)            = 0;
+        virtual void setValue(const unsigned long long& value)   = 0;
+        virtual void setValue(const float& value)                = 0;
+        virtual void setValue(const double& value)               = 0;
+        virtual void setValue(const long double& value)          = 0;
+        virtual void setValue(const bool& value)                 = 0;
+        virtual void setValue(      void* const& value)          = 0;
+        virtual void setValue(const std::string& value)          = 0;
+        virtual void setValue(const orxonox::Vector2& value)     = 0;
+        virtual void setValue(const orxonox::Vector3& value)     = 0;
+        virtual void setValue(const orxonox::Vector4& value)     = 0;
+        virtual void setValue(const orxonox::ColourValue& value) = 0;
+        virtual void setValue(const orxonox::Quaternion& value)  = 0;
+        virtual void setValue(const orxonox::Radian& value)      = 0;
+        virtual void setValue(const orxonox::Degree& value)      = 0;
+
+        virtual operator char()                 const = 0;
+        virtual operator unsigned char()        const = 0;
+        virtual operator short()                const = 0;
+        virtual operator unsigned short()       const = 0;
+        virtual operator int()                  const = 0;
+        virtual operator unsigned int()         const = 0;
+        virtual operator long()                 const = 0;
+        virtual operator unsigned long()        const = 0;
+        virtual operator long long()            const = 0;
+        virtual operator unsigned long long()   const = 0;
+        virtual operator float()                const = 0;
+        virtual operator double()               const = 0;
+        virtual operator long double()          const = 0;
+        virtual operator bool()                 const = 0;
+        virtual operator void*()                const = 0;
+        virtual operator std::string()          const = 0;
+        virtual operator orxonox::Vector2()     const = 0;
+        virtual operator orxonox::Vector3()     const = 0;
+        virtual operator orxonox::Vector4()     const = 0;
+        virtual operator orxonox::ColourValue() const = 0;
+        virtual operator orxonox::Quaternion()  const = 0;
+        virtual operator orxonox::Radian()      const = 0;
+        virtual operator orxonox::Degree()      const = 0;
+
+        virtual void toString(std::ostream& outstream) const = 0;
+
+        MT_Type type_; //! The type of the current value
+    };
+
+    public:
+        inline MultiType()                                  : value_(0) {}                                      /** @brief Default constructor: Assigns no value and no type. The type will be determined by the first assignment of a value. */
+        inline MultiType(const char& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned char& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const short& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned short& value)       : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const int& value)                  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned int& value)         : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const long& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned long& value)        : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const long long& value)            : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const unsigned long long& value)   : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const float& value)                : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const double& value)               : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const long double& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const bool& value)                 : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(      void* const& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const std::string& value)          : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Vector2& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Vector3& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Vector4& value)     : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::ColourValue& value) : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Quaternion& value)  : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Radian& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const orxonox::Degree& value)      : value_(0) { this->assignValue(value); }           /** @brief Constructor: Assigns the given value and sets the type. */
+        inline MultiType(const char* value)                 : value_(0) { this->setValue(std::string(value)); } /** @brief Constructor: Converts the char array to a std::string, assigns the value and sets the type. */
+        inline MultiType(const MultiType& other)            : value_(0) { this->setValue(other); }              /** @brief Copyconstructor: Assigns value and type of the other MultiType. */
+        inline MultiType(MT_Type type)                      : value_(0) { this->setType(type); }                /** @brief Constructor: Sets the type, the next assignment will determine the value. */
+
+        /** @brief Destructor: Deletes the MT_Value. */
+        inline ~MultiType() { if (this->value_) { delete this->value_; } }
+
+        template <typename V> inline const MultiType& operator=(const V& value)         { this->setValue(value); return (*this); } /** @brief Assigns a new value. The value will be converted to the current type of the MultiType. */
+        template <typename V> inline const MultiType& operator=(V* value)               { this->setValue(value); return (*this); } /** @brief Assigns a pointer. */
+        inline                       const MultiType& operator=(const MultiType& other) { this->setValue(other); return (*this); } /** @brief Assigns the value of the other MultiType and converts it to the current type of the MultiType. */
+        inline                       const MultiType& operator=(MT_Type type)           { this->setType(type);   return (*this); } /** @brief Resets the value and changes the type. */
+
+        inline void                                   setValue(const char& value);
+        inline void                                   setValue(const unsigned char& value);
+        inline void                                   setValue(const short& value);
+        inline void                                   setValue(const unsigned short& value);
+        inline void                                   setValue(const int& value);
+        inline void                                   setValue(const unsigned int& value);
+        inline void                                   setValue(const long& value);
+        inline void                                   setValue(const unsigned long& value);
+        inline void                                   setValue(const long long& value);
+        inline void                                   setValue(const unsigned long long& value);
+        inline void                                   setValue(const float& value);
+        inline void                                   setValue(const double& value);
+        inline void                                   setValue(const long double& value);
+        inline void                                   setValue(const bool& value);
+        inline void                                   setValue(      void* const& value);
+        inline void                                   setValue(const std::string& value);
+        inline void                                   setValue(const orxonox::Vector2& value);
+        inline void                                   setValue(const orxonox::Vector3& value);
+        inline void                                   setValue(const orxonox::Vector4& value);
+        inline void                                   setValue(const orxonox::ColourValue& value);
+        inline void                                   setValue(const orxonox::Quaternion& value);
+        inline void                                   setValue(const orxonox::Radian& value);
+        inline void                                   setValue(const orxonox::Degree& value);
+        inline void                                   setValue(const char* value);
+        /** @brief Assigns a pointer. */
+        template <typename V> inline void             setValue(V* value)               { if (this->value_) { this->value_->setValue((void*)value); } else { this->assignValue((void*)value); } }
+        /** @brief Assigns the value of the other MultiType and converts it to the current type. */
+        void                                          setValue(const MultiType& other) { if (this->value_) { this->value_->assimilate(other); } else { if (other.value_) { this->value_ = other.value_->clone(); } } }
+        /** @brief Changes the type to T and assigns the new value (which might be of another type than T - it gets converted). */
+        template <typename T, typename V> inline void setValue(const V& value)         { this->setType<T>(); this->setValue(value); }
+
+
+        /** @brief Copies the other MultiType by assigning value and type. */
+        inline void                       copy(const MultiType& other)    { if (this == &other) { return; } if (this->value_) { delete this->value_; } this->value_ = (other.value_) ? other.value_->clone() : 0; }
+
+        template <typename T> inline void convert()                       { this->setValue<T>((T)(*this));  } /** @brief Converts the current value to type T. */
+        inline void                       convert(const MultiType& other) { this->convert(other.getType()); } /** @brief Converts the current value to the type of the other MultiType. */
+        void                              convert(MT_Type type);
+
+        /** @brief Resets the value to the defaultvalue of the current type. */
+        inline void                       reset()                         { if (this->value_) { delete this->value_; this->value_ = 0; } }
+
+        template <typename T> inline void setType()                       { this->assignValue(T());                            } /** @brief Resets the value and changes the internal type to T. */
+        inline void                       setType(const MultiType& other) { this->setType(other.getType());                    } /** @brief Resets the value and changes the internal type to the type of the other MultiType. */
+        inline void                       setType(MT_Type type)           { this->reset(); this->convert(type); this->reset(); } /** @brief Resets the value and changes the internal type to the given type. */
+
+        /** @brief Returns the current type. */
+        inline MT_Type                    getType()                 const { return (this->value_) ? this->value_->type_ : MT_null; }
+        /** @brief Returns true if the current type equals the given type. */
+        inline bool                       isType(MT_Type type)      const { return (this->value_) ? (this->value_->type_ == type) : (type == MT_null); }
+        /** @brief Returns true if the current type is T. */
+        template <typename T> inline bool isType()                  const { return false; } // Only works for specialized values - see below
+        std::string                       getTypename()             const;
+
+        operator char()                  const;
+        operator unsigned char()         const;
+        operator short()                 const;
+        operator unsigned short()        const;
+        operator int()                   const;
+        operator unsigned int()          const;
+        operator long()                  const;
+        operator unsigned long()         const;
+        operator long long()             const;
+        operator unsigned long long()    const;
+        operator float()                 const;
+        operator double()                const;
+        operator long double()           const;
+        operator bool()                  const;
+        operator void*()                 const;
+        operator std::string()           const;
+        operator orxonox::Vector2()      const;
+        operator orxonox::Vector3()      const;
+        operator orxonox::Vector4()      const;
+        operator orxonox::ColourValue()  const;
+        operator orxonox::Quaternion()   const;
+        operator orxonox::Radian()       const;
+        operator orxonox::Degree()       const;
+        /** @brief Returns the current value, converted to a T* pointer. */
+        template <class T> operator T*() const { return ((T*)this->operator void*()); }
+
+        inline void getValue(char*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(unsigned char*        value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(short*                value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(unsigned short*       value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(int*                  value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(unsigned int*         value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(long*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(unsigned long*        value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(long long*            value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(unsigned long long*   value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(float*                value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(double*               value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(long double*          value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(bool*                 value) const { if (this->value_) { (*value) = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(void*                 value) const { if (this->value_) {   value  = (*this->value_); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(std::string*          value) const { if (this->value_) { (*value) = this->value_->operator std::string();          } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::Vector2*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector2();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::Vector3*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector3();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::Vector4*     value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Vector4();     } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::ColourValue* value) const { if (this->value_) { (*value) = this->value_->operator orxonox::ColourValue(); } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::Quaternion*  value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Quaternion();  } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::Radian*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Radian();      } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+        inline void getValue(orxonox::Degree*      value) const { if (this->value_) { (*value) = this->value_->operator orxonox::Degree();      } } /** @brief Assigns the value to the given pointer. The value gets converted if the types don't match. */
+
+        inline char                     getChar()             const { return this->operator char();                 } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned char            getUnsignedChar()     const { return this->operator unsigned char();        } /** @brief Returns the current value, converted to the requested type. */
+        inline short                    getShort()            const { return this->operator short();                } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned short           getUnsignedShort()    const { return this->operator unsigned short();       } /** @brief Returns the current value, converted to the requested type. */
+        inline int                      getInt()              const { return this->operator int();                  } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned int             getUnsignedInt()      const { return this->operator unsigned int();         } /** @brief Returns the current value, converted to the requested type. */
+        inline long                     getLong()             const { return this->operator long();                 } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned long            getUnsignedLong()     const { return this->operator unsigned long();        } /** @brief Returns the current value, converted to the requested type. */
+        inline long long                getLongLong()         const { return this->operator long long();            } /** @brief Returns the current value, converted to the requested type. */
+        inline unsigned long long       getUnsignedLongLong() const { return this->operator unsigned long long();   } /** @brief Returns the current value, converted to the requested type. */
+        inline float                    getFloat()            const { return this->operator float();                } /** @brief Returns the current value, converted to the requested type. */
+        inline double                   getDouble()           const { return this->operator double();               } /** @brief Returns the current value, converted to the requested type. */
+        inline long double              getLongDouble()       const { return this->operator long double();          } /** @brief Returns the current value, converted to the requested type. */
+        inline bool                     getBool()             const { return this->operator bool();                 } /** @brief Returns the current value, converted to the requested type. */
+        inline void*                    getVoid()             const { return this->operator void*();                } /** @brief Returns the current value, converted to the requested type. */
+        inline std::string              getString()           const { return this->operator std::string();          } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Vector2         getVector2()          const { return this->operator orxonox::Vector2();     } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Vector3         getVector3()          const { return this->operator orxonox::Vector3();     } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Vector4         getVector4()          const { return this->operator orxonox::Vector4();     } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::ColourValue     getColourValue()      const { return this->operator orxonox::ColourValue(); } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Quaternion      getQuaternion()       const { return this->operator orxonox::Quaternion();  } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Radian          getRadian()           const { return this->operator orxonox::Radian();      } /** @brief Returns the current value, converted to the requested type. */
+        inline orxonox::Degree          getDegree()           const { return this->operator orxonox::Degree();      } /** @brief Returns the current value, converted to the requested type. */
+        template <typename T> inline T* getPointer()          const { return ((T*)this->getVoid());                 } /** @brief Returns the current value, converted to a T* pointer. */
+
+    private:
+        inline void assignValue(const char& value)                 { if (this->value_ && this->value_->type_ == MT_char)        { this->value_->setValue(value); } else { this->changeValueContainer<char>(value);                 } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const unsigned char& value)        { if (this->value_ && this->value_->type_ == MT_uchar)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned char>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const short& value)                { if (this->value_ && this->value_->type_ == MT_short)       { this->value_->setValue(value); } else { this->changeValueContainer<short>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const unsigned short& value)       { if (this->value_ && this->value_->type_ == MT_ushort)      { this->value_->setValue(value); } else { this->changeValueContainer<unsigned short>(value);       } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const int& value)                  { if (this->value_ && this->value_->type_ == MT_int)         { this->value_->setValue(value); } else { this->changeValueContainer<int>(value);                  } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const unsigned int& value)         { if (this->value_ && this->value_->type_ == MT_uint)        { this->value_->setValue(value); } else { this->changeValueContainer<unsigned int>(value);         } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const long& value)                 { if (this->value_ && this->value_->type_ == MT_long)        { this->value_->setValue(value); } else { this->changeValueContainer<long>(value);                 } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const unsigned long& value)        { if (this->value_ && this->value_->type_ == MT_ulong)       { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long>(value);        } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const long long& value)            { if (this->value_ && this->value_->type_ == MT_longlong)    { this->value_->setValue(value); } else { this->changeValueContainer<long long>(value);            } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const unsigned long long& value)   { if (this->value_ && this->value_->type_ == MT_ulonglong)   { this->value_->setValue(value); } else { this->changeValueContainer<unsigned long long>(value);   } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const float& value)                { if (this->value_ && this->value_->type_ == MT_float)       { this->value_->setValue(value); } else { this->changeValueContainer<float>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const double& value)               { if (this->value_ && this->value_->type_ == MT_double)      { this->value_->setValue(value); } else { this->changeValueContainer<double>(value);               } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const long double& value)          { if (this->value_ && this->value_->type_ == MT_longdouble)  { this->value_->setValue(value); } else { this->changeValueContainer<long double>(value);          } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const bool& value)                 { if (this->value_ && this->value_->type_ == MT_bool)        { this->value_->setValue(value); } else { this->changeValueContainer<bool>(value);                 } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(      void* const& value)          { if (this->value_ && this->value_->type_ == MT_void)        { this->value_->setValue(value); } else { this->changeValueContainer<void*>(value);                } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const std::string& value)          { if (this->value_ && this->value_->type_ == MT_string)      { this->value_->setValue(value); } else { this->changeValueContainer<std::string>(value);          } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::Vector2& value)     { if (this->value_ && this->value_->type_ == MT_vector2)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector2>(value);     } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::Vector3& value)     { if (this->value_ && this->value_->type_ == MT_vector3)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector3>(value);     } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::Vector4& value)     { if (this->value_ && this->value_->type_ == MT_vector4)     { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Vector4>(value);     } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::ColourValue& value) { if (this->value_ && this->value_->type_ == MT_colourvalue) { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::ColourValue>(value); } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::Quaternion& value)  { if (this->value_ && this->value_->type_ == MT_quaternion)  { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Quaternion>(value);  } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::Radian& value)      { if (this->value_ && this->value_->type_ == MT_radian)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Radian>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
+        inline void assignValue(const orxonox::Degree& value)      { if (this->value_ && this->value_->type_ == MT_degree)      { this->value_->setValue(value); } else { this->changeValueContainer<orxonox::Degree>(value);      } } /** @brief Assigns a new value by changing type and creating a new container. */
+
+        /** @brief Changes the value container. */
+        template <typename T> inline void changeValueContainer(const T& value) { if (this->value_) { delete this->value_; } this->createNewValueContainer<T>(value); }
+        /** @brief Creates a new value container (works only with specialized types). */
+        template <typename T>        void createNewValueContainer(const T& value) { BOOST_STATIC_ASSERT(sizeof(T) == 0); }
+
+        MT_ValueBase* value_; //! A pointer to the value container
+};
+
+/** @brief Puts the MultiType on a stream by using the native << operator of the current type. */
+_UtilExport inline std::ostream& operator<<(std::ostream& outstream, const MultiType& mt) { if (mt.value_) { mt.value_->toString(outstream); } return outstream; }
+
+template <> inline bool MultiType::isType<char>()                 const { return (this->value_ && this->value_->type_ == MT_char);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned char>()        const { return (this->value_ && this->value_->type_ == MT_uchar);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<short>()                const { return (this->value_ && this->value_->type_ == MT_short);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned short>()       const { return (this->value_ && this->value_->type_ == MT_ushort);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<int>()                  const { return (this->value_ && this->value_->type_ == MT_int);         } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned int>()         const { return (this->value_ && this->value_->type_ == MT_uint);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<long>()                 const { return (this->value_ && this->value_->type_ == MT_long);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned long>()        const { return (this->value_ && this->value_->type_ == MT_ulong);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<long long>()            const { return (this->value_ && this->value_->type_ == MT_longlong);    } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<unsigned long long>()   const { return (this->value_ && this->value_->type_ == MT_ulonglong);   } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<float>()                const { return (this->value_ && this->value_->type_ == MT_float);       } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<double>()               const { return (this->value_ && this->value_->type_ == MT_double);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<long double>()          const { return (this->value_ && this->value_->type_ == MT_longdouble);  } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<bool>()                 const { return (this->value_ && this->value_->type_ == MT_bool);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<void*>()                const { return (this->value_ && this->value_->type_ == MT_void);        } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<std::string>()          const { return (this->value_ && this->value_->type_ == MT_string);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Vector2>()     const { return (this->value_ && this->value_->type_ == MT_vector2);     } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Vector3>()     const { return (this->value_ && this->value_->type_ == MT_vector3);     } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Vector4>()     const { return (this->value_ && this->value_->type_ == MT_vector4);     } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::ColourValue>() const { return (this->value_ && this->value_->type_ == MT_colourvalue); } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Quaternion>()  const { return (this->value_ && this->value_->type_ == MT_quaternion);  } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Radian>()      const { return (this->value_ && this->value_->type_ == MT_radian);      } /** @brief Returns true if the current type equals the given type. */
+template <> inline bool MultiType::isType<orxonox::Degree>()      const { return (this->value_ && this->value_->type_ == MT_degree);      } /** @brief Returns true if the current type equals the given type. */
+
+// Specialization to avoid ambiguities with the conversion operator
+template <> inline void MultiType::convert<std::string>()          { this->setValue<std::string>         (this->operator std::string());          } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::Vector2>()     { this->setValue<orxonox::Vector2>    (this->operator orxonox::Vector2());     } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::Vector3>()     { this->setValue<orxonox::Vector3>    (this->operator orxonox::Vector3());     } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::Vector4>()     { this->setValue<orxonox::Vector4>    (this->operator orxonox::Vector4());     } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::ColourValue>() { this->setValue<orxonox::ColourValue>(this->operator orxonox::ColourValue()); } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::Quaternion>()  { this->setValue<orxonox::Quaternion> (this->operator orxonox::Quaternion());  } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::Radian>()      { this->setValue<orxonox::Radian>     (this->operator orxonox::Radian());      } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<orxonox::Degree>()      { this->setValue<orxonox::Degree>     (this->operator orxonox::Degree());      } /** @brief Converts the current value to the given type. */
+
+// Specialization to avoid ambiguities with the conversion operator
+template <> inline void MultiType::convert<const std::string&>()          { this->convert<std::string>();          } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::Vector2&>()     { this->convert<orxonox::Vector2>();     } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::Vector3&>()     { this->convert<orxonox::Vector3>();     } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::Vector4&>()     { this->convert<orxonox::Vector4>();     } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::ColourValue&>() { this->convert<orxonox::ColourValue>(); } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::Quaternion&>()  { this->convert<orxonox::Quaternion>();  } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::Radian&>()      { this->convert<orxonox::Radian>();      } /** @brief Converts the current value to the given type. */
+template <> inline void MultiType::convert<const orxonox::Degree&>()      { this->convert<orxonox::Degree>();      } /** @brief Converts the current value to the given type. */
+
+template <> void MultiType::createNewValueContainer(const char& value);
+template <> void MultiType::createNewValueContainer(const unsigned char& value);
+template <> void MultiType::createNewValueContainer(const short& value);
+template <> void MultiType::createNewValueContainer(const unsigned short& value);
+template <> void MultiType::createNewValueContainer(const int& value);
+template <> void MultiType::createNewValueContainer(const unsigned int& value);
+template <> void MultiType::createNewValueContainer(const long& value);
+template <> void MultiType::createNewValueContainer(const unsigned long& value);
+template <> void MultiType::createNewValueContainer(const long long& value);
+template <> void MultiType::createNewValueContainer(const unsigned long long& value);
+template <> void MultiType::createNewValueContainer(const float& value);
+template <> void MultiType::createNewValueContainer(const double& value);
+template <> void MultiType::createNewValueContainer(const bool& value);
+template <> void MultiType::createNewValueContainer(const long double& value);
+template <> void MultiType::createNewValueContainer(      void* const& value);
+template <> void MultiType::createNewValueContainer(const std::string& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Vector2& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Vector3& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Vector4& value);
+template <> void MultiType::createNewValueContainer(const orxonox::ColourValue& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Quaternion& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Radian& value);
+template <> void MultiType::createNewValueContainer(const orxonox::Degree& value);
+
+inline void MultiType::setValue(const char& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const unsigned char& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const short& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const unsigned short& value)        { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const int& value)                   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const unsigned int& value)          { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const long& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const unsigned long& value)         { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const long long& value)             { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const unsigned long long& value)    { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const float& value)                 { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const double& value)                { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const long double& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const bool& value)                  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(      void* const& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const std::string& value)           { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::Vector2& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::Vector3& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::Vector4& value)      { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::ColourValue& value)  { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::Quaternion& value)   { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::Radian& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+inline void MultiType::setValue(const orxonox::Degree& value)       { if (this->value_) { this->value_->setValue(value); } else { this->assignValue(value); } } /** @brief Assigns the given value and converts it to the current type. */
+
+inline void MultiType::setValue(const char* value)                  { if (this->value_) { this->value_->setValue(std::string(value)); } else { this->assignValue(std::string(value)); } }  /** @brief Assigns the given value and converts it to the current type. */
+
+#endif /* _MultiType_H__ */
Index: /code/branches/ceguilua/src/util/MultiTypeValue.h
===================================================================
--- /code/branches/ceguilua/src/util/MultiTypeValue.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/MultiTypeValue.h	(revision 1801)
@@ -0,0 +1,115 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file MultiTypeValue.h
+    @brief Declaration and Implementation of the MT_Value<T> class.
+
+    The MT_Value<T> class is used to hold a value of type T within a MultiType.
+*/
+
+#ifndef _MultiTypeValue_H__
+#define _MultiTypeValue_H__
+
+#include "UtilPrereqs.h"
+#include "Convert.h"
+#include "MultiType.h"
+
+/**
+    @brief The MT_Value<T> class is used to hold a value of type T within a MultiType.
+*/
+template <typename T>
+struct MT_Value : public MultiType::MT_ValueBase
+{
+    /** @brief Constructor: Assigns the value and the type identifier. */
+    MT_Value(const T& value, MT_Type type) : MT_ValueBase(type), value_(value) {}
+
+    /** @brief Creates a copy of itself. */
+    inline MT_ValueBase* clone() const { return new MT_Value<T>(this->value_, this->type_); }
+
+    /** @brief Resets the current value to the default. */
+    inline void reset() { this->value_ = T(); }
+
+    /** @brief Assigns the value of the other MultiType, converted to T. @param other The other MultiType */
+    inline void assimilate(const MultiType& other) { if (other.value_) { T temp; other.getValue(&temp); this->value_ = temp; } else { this->value_ = T(); } }
+
+    inline void setValue(const char& value)                 { this->value_ = getConvertedValue<char,                 T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const unsigned char& value)        { this->value_ = getConvertedValue<unsigned char,        T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const short& value)                { this->value_ = getConvertedValue<short,                T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const unsigned short& value)       { this->value_ = getConvertedValue<unsigned short,       T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const int& value)                  { this->value_ = getConvertedValue<int,                  T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const unsigned int& value)         { this->value_ = getConvertedValue<unsigned int,         T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const long& value)                 { this->value_ = getConvertedValue<long,                 T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const unsigned long& value)        { this->value_ = getConvertedValue<unsigned long,        T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const long long& value)            { this->value_ = getConvertedValue<long long,            T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const unsigned long long& value)   { this->value_ = getConvertedValue<unsigned long long,   T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const float& value)                { this->value_ = getConvertedValue<float,                T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const double& value)               { this->value_ = getConvertedValue<double,               T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const long double& value)          { this->value_ = getConvertedValue<long double,          T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const bool& value)                 { this->value_ = getConvertedValue<bool,                 T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(      void* const& value)          { this->value_ = getConvertedValue<void*,                T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const std::string& value)          { this->value_ = getConvertedValue<std::string,          T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::Vector2& value)     { this->value_ = getConvertedValue<orxonox::Vector2,     T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::Vector3& value)     { this->value_ = getConvertedValue<orxonox::Vector3,     T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::Vector4& value)     { this->value_ = getConvertedValue<orxonox::Vector4,     T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::ColourValue& value) { this->value_ = getConvertedValue<orxonox::ColourValue, T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::Quaternion& value)  { this->value_ = getConvertedValue<orxonox::Quaternion,  T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::Radian& value)      { this->value_ = getConvertedValue<orxonox::Radian,      T>(value); } /** @brief Assigns the value by converting it to T. */
+    inline void setValue(const orxonox::Degree& value)      { this->value_ = getConvertedValue<orxonox::Degree,      T>(value); } /** @brief Assigns the value by converting it to T. */
+
+    inline operator char()                 const { return getConvertedValue<T, char>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned char()        const { return getConvertedValue<T, unsigned char>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator short()                const { return getConvertedValue<T, short>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned short()       const { return getConvertedValue<T, unsigned short>      (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator int()                  const { return getConvertedValue<T, int>                 (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned int()         const { return getConvertedValue<T, unsigned int>        (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator long()                 const { return getConvertedValue<T, long>                (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned long()        const { return getConvertedValue<T, unsigned long>       (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator long long()            const { return getConvertedValue<T, long long>           (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator unsigned long long()   const { return getConvertedValue<T, unsigned long long>  (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator float()                const { return getConvertedValue<T, float>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator double()               const { return getConvertedValue<T, double>              (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator long double()          const { return getConvertedValue<T, long double>         (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator bool()                 const { return getConvertedValue<T, bool>                (this->value_, false); } /** @brief Returns the current value, converted to the requested type. */
+    inline operator void*()                const { return getConvertedValue<T, void*>               (this->value_, 0); }     /** @brief Returns the current value, converted to the requested type. */
+    inline operator std::string()          const { return getConvertedValue<T, std::string>         (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Vector2()     const { return getConvertedValue<T, orxonox::Vector2>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Vector3()     const { return getConvertedValue<T, orxonox::Vector3>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Vector4()     const { return getConvertedValue<T, orxonox::Vector4>    (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::ColourValue() const { return getConvertedValue<T, orxonox::ColourValue>(this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Quaternion()  const { return getConvertedValue<T, orxonox::Quaternion> (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Radian()      const { return getConvertedValue<T, orxonox::Radian>     (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+    inline operator orxonox::Degree()      const { return getConvertedValue<T, orxonox::Degree>     (this->value_); }        /** @brief Returns the current value, converted to the requested type. */
+
+    /** @brief Puts the current value on the stream */
+    inline void toString(std::ostream& outstream) const { outstream << this->value_; }
+
+    T value_; //! The stored value
+};
+
+#endif /* _MultiTypeValue_H__ */
Index: /code/branches/ceguilua/src/util/OrxonoxPlatform.h
===================================================================
--- /code/branches/ceguilua/src/util/OrxonoxPlatform.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/OrxonoxPlatform.h	(revision 1801)
@@ -0,0 +1,263 @@
+/*
+ *   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:
+ *      ...
+ *   Co-authors:
+ *      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.
+ */
+
+#ifndef _OrxonoxPlatform_H__
+#define _OrxonoxPlatform_H__
+
+/* Initial platform/compiler-related stuff to set. */
+
+#define ORXONOX_PLATFORM_WIN32 1
+#define ORXONOX_PLATFORM_LINUX 2
+#define ORXONOX_PLATFORM_APPLE 3
+
+#define ORXONOX_COMPILER_MSVC 1
+#define ORXONOX_COMPILER_GNUC 2
+#define ORXONOX_COMPILER_BORL 3
+
+#define ORXONOX_ENDIAN_LITTLE 1
+#define ORXONOX_ENDIAN_BIG 2
+
+#define ORXONOX_ARCHITECTURE_32 1
+#define ORXONOX_ARCHITECTURE_64 2
+
+
+/* Finds the compiler type and version. */
+
+#if defined( _MSC_VER )
+#  define ORXONOX_COMPILER ORXONOX_COMPILER_MSVC
+#  define ORXONOX_COMP_VER _MSC_VER
+
+#elif defined( __GNUC__ )
+#  define ORXONOX_COMPILER ORXONOX_COMPILER_GNUC
+#  define ORXONOX_COMP_VER (((__GNUC__)*100) + \
+        (__GNUC_MINOR__*10) + \
+        __GNUC_PATCHLEVEL__)
+
+#elif defined( __BORLANDC__ )
+#  define ORXONOX_COMPILER ORXONOX_COMPILER_BORL
+#  define ORXONOX_COMP_VER __BCPLUSPLUS__
+
+#else
+#  pragma error "No known compiler. Abort! Abort!"
+
+#endif
+
+
+/* See if we can use __forceinline or if we need to use __inline instead */
+#if ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC
+#  if ORXONOX_COMP_VER >= 1200
+#    define FORCEINLINE __forceinline
+#  endif
+#elif defined(__MINGW32__)
+#  if !defined(FORCEINLINE)
+#    define FORCEINLINE __inline
+#  endif
+#else
+#  define FORCEINLINE __inline
+#endif
+
+/* 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 */
+#if defined(__x86_64__) || defined(_M_X64) || defined(__powerpc64__) || defined(__alpha__) || defined(__ia64__) || defined(__s390__) || defined(__s390x__)
+#  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_64
+#else
+#  define ORXONOX_ARCH_TYPE ORXONOX_ARCHITECTURE_32
+#endif
+
+/* 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
+/* 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>
+#    if defined(__MINGW32_TOOLBOX_UNICODE__)
+#      define ORXONOX_UNICODE_SUPPORT 1
+#    else
+#      define ORXONOX_UNICODE_SUPPORT 0
+#    endif
+#  else
+#    define ORXONOX_UNICODE_SUPPORT 1
+#  endif
+#endif /* Platform Win32 */
+
+
+/*---------------------------------
+ * 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 */
+#  define stricmp strcasecmp
+
+/* 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 */
+#    define ORXONOX_PLATFORM_LIB "libOrxonoxPlatform.so"
+#  endif
+#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 */
+
+
+/*---------------------------------
+ * Apple Settings
+ *-------------------------------*/
+/* For apple, we always have a custom config.h file */
+#if ORXONOX_PLATFORM == ORXONOX_PLATFORM_APPLE
+#  include "config.h"
+#endif
+
+
+/*---------------------------------
+ * Visual Studio Settings
+ *-------------------------------*/
+#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 */
+#   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 */
+#include <iso646.h>
+
+/* include visual leak detector to search for memory leaks */
+/* #include <vld.h> */
+
+#endif /* ORXONOX_COMPILER == ORXONOX_COMPILER_MSVC */
+
+#endif /* _OrxonoxPlatform_H__ */
Index: /code/branches/ceguilua/src/util/OutputBuffer.cc
===================================================================
--- /code/branches/ceguilua/src/util/OutputBuffer.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/OutputBuffer.cc	(revision 1801)
@@ -0,0 +1,132 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputBuffer.cc
+    @brief Implementation of the OutputBuffer.
+*/
+
+#include "OutputBuffer.h"
+
+namespace orxonox
+{
+    const int OUTPUTBUFFER_MAX_LINE_LENGTH = 16384; //! The maximal number of lines that can be stored within the OutputBuffer.
+
+    /**
+        @brief Adds a new listener to the list.
+        @param listener The new listener
+    */
+    void OutputBuffer::registerListener(OutputBufferListener* listener)
+    {
+        this->listeners_.insert(this->listeners_.end(), listener);
+    }
+
+    /**
+        @brief Removes a listener from the list.
+        @param listener The listener
+    */
+    void OutputBuffer::unregisterListener(OutputBufferListener* listener)
+    {
+        for (std::list<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); )
+        {
+            if ((*it) == listener)
+                this->listeners_.erase(it++);
+            else
+                ++it;
+        }
+    }
+
+    /**
+        @brief Puts a stream manipulator to the stream.
+        @param manipulator The manipulator
+    */
+    OutputBuffer& OutputBuffer::operator<<(std::ostream& (*manipulator)(std::ostream&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    /**
+        @brief Puts a stream manipulator to the stream.
+        @param manipulator The manipulator
+    */
+    OutputBuffer& OutputBuffer::operator<<(std::ios& (*manipulator)(std::ios&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    /**
+        @brief Puts a stream manipulator to the stream.
+        @param manipulator The manipulator
+    */
+    OutputBuffer& OutputBuffer::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
+    {
+                this->stream_ << manipulator;
+                this->callListeners();
+                return *this;
+    }
+
+    /**
+        @brief Removes the first line from the stream and assigns it to a given string object.
+        @param output The string object to assign the first line
+        @return True if there was at least one line in the stream and this line was successfully assigned
+
+        It's important to know the returned line will be removed from the stream. If there are more than one
+        listener, they have to cooperate to avoid conflicts.
+    */
+    bool OutputBuffer::getLine(std::string* output)
+    {
+        char line[OUTPUTBUFFER_MAX_LINE_LENGTH];
+
+        this->stream_.getline(line, OUTPUTBUFFER_MAX_LINE_LENGTH);
+        (*output) = std::string(line);
+
+        bool eof = this->stream_.eof();
+        bool fail = this->stream_.fail();
+
+        if (eof)
+            this->stream_.flush();
+
+        if (eof || fail)
+            this->stream_.clear();
+
+        return (!eof && !fail);
+    }
+
+    /**
+        @brief Calls the outputChanged() function of all registered listeners.
+    */
+    void OutputBuffer::callListeners()
+    {
+        for (std::list<OutputBufferListener*>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
+            (*it)->outputChanged();
+    }
+}
Index: /code/branches/ceguilua/src/util/OutputBuffer.h
===================================================================
--- /code/branches/ceguilua/src/util/OutputBuffer.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/OutputBuffer.h	(revision 1801)
@@ -0,0 +1,174 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputBuffer.h
+    @brief Declaration of the OutputBuffer class.
+
+    The OutputBuffer acts almost like std::ostream. You can put text and other values to the
+    OutputBuffer by using the << operator. The OutputBuffer stores the text and calls registerd
+    listeners if new text gets assigned.
+    The listeners are then able to retrieve the text line by line.
+
+    It's important to know that getLine actually removes the line from the OutputBuffer, so it's
+    better to only have one "active" listener.
+*/
+
+#ifndef _OutputBuffer_H__
+#define _OutputBuffer_H__
+
+#include <list>
+#include <sstream>
+#include <iostream>
+
+#include "UtilPrereqs.h"
+
+namespace orxonox
+{
+    /**
+        @brief A pure virtual baseclass for classes that want to register as listener to an OutputBuffer.
+
+        This class is pure virtual, so an inheriting class has to implement the function on it's own.
+        The function get's called, if an instance of the inheriting class registers as a listener at
+        an OutputBuffer and this buffer changes.
+    */
+    class _UtilExport OutputBufferListener
+    {
+        friend class OutputBuffer;
+
+        public:
+            virtual ~OutputBufferListener() {}
+
+        private:
+            virtual void outputChanged() = 0;
+    };
+
+    /**
+        @brief The OutputBuffer acts almost like std::ostream and stores the assigned text.
+
+        If text gets assigned by using the << operator or another function, the OutputBuffer
+        calls it's listeners, allowing them to retrieve the text line by line.
+
+        It's important to know that getLine actually removes the line from the OutputBuffer, so it's
+        better to only have one "active" listener.
+    */
+    class _UtilExport OutputBuffer
+    {
+        public:
+            OutputBuffer() {}
+            ~OutputBuffer() {}
+
+            /**
+                @brief Puts some object/value to the OutputBuffer. The text gets assigned and the OutputBuffer calls it's listeners.
+                @param object The object/value to assign
+            */
+            template <class T>
+            inline OutputBuffer& operator<<(T object)
+            {
+                this->stream_ << object;
+                this->callListeners();
+                return *this;
+            }
+
+            /**
+                @brief Reads the stored text of the other OutputBuffer and calls the listeners.
+                @param object The other OutputBuffer
+            */
+            template <const OutputBuffer&>
+            inline OutputBuffer& operator<<(const OutputBuffer& object)
+            {
+                this->stream_ << object.stream_.rdbuf();
+                this->callListeners();
+                return *this;
+            }
+
+            OutputBuffer& operator<<(std::ostream& (*manipulator)(std::ostream&));
+            OutputBuffer& operator<<(std::ios& (*manipulator)(std::ios&));
+            OutputBuffer& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
+
+            /**
+                @brief Does the same like operator<<: Assigns the object to the stream and calls the listeners.
+                @param object The object/value
+            */
+            template <class T>
+            inline void add(T object)
+            {
+                this->stream_ << object;
+                this->callListeners();
+            }
+
+            /**
+                @brief Assigns an object/value and adds std::endl.
+                @param object The object/value
+            */
+            template <class T>
+            inline void addLine(T object)
+            {
+                this->stream_ << object << std::endl;
+                this->callListeners();
+            }
+
+            /**
+                @brief Puts std::endl to the stream and calls the listeners.
+            */
+            inline void newline()
+            {
+                this->stream_ << std::endl;
+                this->callListeners();
+            }
+
+            /**
+                @brief Flushes the stored text (~empties the OutputBuffer).
+            */
+            inline void flush()
+            {
+                this->stream_.flush();
+            }
+
+            bool getLine(std::string* output);
+
+            void registerListener(OutputBufferListener* listener);
+            void unregisterListener(OutputBufferListener* listener);
+
+            /**
+                @brief Returns the internal stringstream object.
+            */
+            inline std::stringstream& getStream()
+            {
+                return this->stream_;
+            }
+
+        private:
+            void callListeners();
+
+            std::stringstream stream_;                   //! The stringstream that stores the assigned text
+            std::list<OutputBufferListener*> listeners_; //! A list of all listeners
+    };
+}
+
+#endif /* _OutputBuffer_H__ */
Index: /code/branches/ceguilua/src/util/OutputHandler.cc
===================================================================
--- /code/branches/ceguilua/src/util/OutputHandler.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/OutputHandler.cc	(revision 1801)
@@ -0,0 +1,188 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputHandler.cc
+    @brief Implementation of the OutputHandler class.
+*/
+
+#include "OutputHandler.h"
+
+namespace orxonox
+{
+    /**
+        @brief Constructor: Opens the logfile and writes the first line.
+        @param logfilename The name of the logfile
+    */
+    OutputHandler::OutputHandler(const std::string& logfilename)
+    {
+        this->outputBuffer_ = &this->fallbackBuffer_;
+        this->softDebugLevel_[0] = this->softDebugLevel_[1] = this->softDebugLevel_[2] = this->softDebugLevel_[3] = 2;
+        this->logfilename_ = logfilename;
+        this->logfile_.open(this->logfilename_.c_str(), std::fstream::out);
+        this->logfile_ << "Started log at yyyy/mm/dd hh:mm:ss" << std::endl; // Todo: Get date and time
+        this->logfile_.flush();
+    }
+
+    /**
+        @brief Destructor: Writes the last line to the logfile and closes it.
+    */
+    OutputHandler::~OutputHandler()
+    {
+        this->logfile_ << "Closed log" << std::endl;
+        this->logfile_.close();
+    }
+
+    /**
+        @brief Returns a reference to the only existing instance of the OutputHandler class.
+        @return The instance
+    */
+    OutputHandler& OutputHandler::getOutStream()
+    {
+        static OutputHandler orxout("orxonox.log");
+        return orxout;
+    }
+
+    /**
+        @brief Sets the soft debug level for a given output device.
+        @param device The output device
+        @param level The debug level
+    */
+    void OutputHandler::setSoftDebugLevel(OutputHandler::OutputDevice device, int level)
+    {
+        OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device] = level;
+    }
+
+    /**
+        @brief Returns the soft debug level for a given output device.
+        @param device The output device
+        @return The debug level
+    */
+    int OutputHandler::getSoftDebugLevel(OutputHandler::OutputDevice device)
+    {
+        return OutputHandler::getOutStream().softDebugLevel_[(unsigned int)device];
+    }
+
+    /**
+        @brief Sets the OutputBuffer, representing the third output stream.
+        @param buffer The OutputBuffer
+    */
+    void OutputHandler::setOutputBuffer(OutputBuffer& buffer)
+    {
+        buffer.getStream() >> this->outputBuffer_->getStream().rdbuf();
+        this->outputBuffer_ = &buffer;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console and the logfile.
+        @param sb The streambuffer that should be shown in the console
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::streambuf* sb)
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            std::cout << sb;
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            this->logfile_ << sb;
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << sb;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
+        @param manipulator A function, manipulating the outstream.
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::ostream& (*manipulator)(std::ostream&))
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            manipulator(std::cout);
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            manipulator(this->logfile_);
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << manipulator;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
+        @param manipulator A function, manipulating the outstream.
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::ios& (*manipulator)(std::ios&))
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            manipulator(std::cout);
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            manipulator(this->logfile_);
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << manipulator;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloaded << operator, redirects the output to the console, the logfile and the ingame shell.
+        @param manipulator A function, manipulating the outstream.
+        @return A reference to the OutputHandler itself
+    */
+    OutputHandler& OutputHandler::operator<<(std::ios_base& (*manipulator)(std::ios_base&))
+    {
+        if (getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            manipulator(std::cout);
+
+        if (getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            manipulator(this->logfile_);
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << manipulator;
+
+        return *this;
+    }
+}
Index: /code/branches/ceguilua/src/util/OutputHandler.h
===================================================================
--- /code/branches/ceguilua/src/util/OutputHandler.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/OutputHandler.h	(revision 1801)
@@ -0,0 +1,204 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file OutputHandler.h
+    @brief Definition of the OutputHandler class.
+
+    The OutputHandler acts like std::cout, but output isn't only shown in the console,
+    but also written to the logfile and the ingame shell.
+*/
+
+#ifndef _OutputHandler_H__
+#define _OutputHandler_H__
+
+#include "UtilPrereqs.h"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#include "OutputBuffer.h"
+
+namespace orxonox
+{
+    //! The OutputHandler acts like std::cout, but redirects output to the console, the logfile and the ingame shell.
+    class _UtilExport OutputHandler
+    {
+        public:
+            enum OutputDevice
+            {
+                LD_All = 0,
+                LD_Console = 1,
+                LD_Logfile = 2,
+                LD_Shell = 3
+            };
+
+            static OutputHandler& getOutStream();
+
+            /** @brief Puts some text on the outstream. @param text The text */
+            static inline std::string log(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(0); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts an error on the outstream. @param text The text */
+            static inline std::string error(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(1); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts a warning on the outstream. @param text The text */
+            static inline std::string warning(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(2); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts an info on the outstream. @param text The text */
+            static inline std::string info(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(3); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Puts some debug output on the outstream. @param text The text */
+            static inline std::string debug(const std::string& text)
+                { OutputHandler::getOutStream().setOutputLevel(4); OutputHandler::getOutStream().output(text + "\n"); return text; }
+
+            /** @brief Returns a reference to the logfile. @return The logfile */
+            inline std::ofstream& getLogfile()
+                { return this->logfile_; }
+
+            /** @brief Returns a pointer to the OutputBuffer. @return The OutputBuffer */
+            inline OutputBuffer* getOutputBuffer()
+                { return this->outputBuffer_; }
+
+            /** @brief Sets the level of the incoming output. @param level The level of the incoming output @return The OutputHandler itself */
+            inline OutputHandler& setOutputLevel(int level)
+                { this->outputLevel_ = level; return *this; }
+
+            /** @brief Returns the level of the incoming output. @return The level */
+            inline int getOutputLevel() const
+                { return this->outputLevel_; }
+
+            static void setSoftDebugLevel(OutputHandler::OutputDevice device, int level);
+            static int getSoftDebugLevel(OutputHandler::OutputDevice device = OutputHandler::LD_All);
+
+            void setOutputBuffer(OutputBuffer& buffer);
+
+            template <class T>
+            OutputHandler& output(const T& output);
+
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned char val)      { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(short val)              { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned short val)     { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(int val)                { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned int val)       { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(long val)               { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned long val)      { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(long long val)          { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(unsigned long long val) { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(float val)              { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(double val)             { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(long double val)        { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(const void* val)        { return this->output(val); }
+            /** @brief Overloaded << operator, redirects the output to the console and the logfile. @param val The value that should be shown in the console @return A reference to the OutputHandler itself */
+            inline OutputHandler& operator<<(bool val)               { return this->output(val); }
+
+            OutputHandler& operator<<(std::streambuf* sb);
+
+            OutputHandler& operator<<(std::ostream& (*manipulator)(std::ostream&));
+            OutputHandler& operator<<(std::ios& (*manipulator)(std::ios&));
+            OutputHandler& operator<<(std::ios_base& (*manipulator)(std::ios_base&));
+
+        private:
+            explicit OutputHandler(const std::string& logfilename);
+            OutputHandler(const OutputHandler& oh);  // don't copy
+            virtual ~OutputHandler();
+
+            std::ofstream logfile_;              //!< The logfile where the output is logged
+            std::string logfilename_;            //!< The name of the logfile
+            OutputBuffer fallbackBuffer_;        //!< The OutputBuffer that gets used if there is no other OutputBuffer
+            OutputBuffer* outputBuffer_;         //!< The OutputBuffer to put output in (usually used by the Shell)
+            int outputLevel_;                    //!< The level of the incoming output
+            int softDebugLevel_[4];              //!< The soft debug level for each OutputDevice - the configurable maximal output level
+    };
+
+    /**
+        @brief Redirects the output to the console and the logfile.
+        @param output The value that should be shown in the console
+        @return A reference to the OutputHandler itself
+    */
+    template<class T>
+    OutputHandler& OutputHandler::output(const T& output)
+    {
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= this->outputLevel_)
+            std::cout << output;
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= this->outputLevel_)
+        {
+            this->logfile_ << output;
+            this->logfile_.flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= this->outputLevel_)
+            (*this->outputBuffer_) << output;
+
+        return *this;
+    }
+
+    /**
+        @brief Overloading of the non-member << operator to redirect the output of classes with self defined '<< to std::ostream' operators to the console and the logfile.
+        @param out The OutputHandler itself
+        @param output The class that should be shown in the console
+        @return The OutputHandler itself
+    */
+    template<class T>
+    OutputHandler& operator<<(OutputHandler& out, const T& output)
+    {
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Console) >= out.getOutputLevel())
+            std::cout << output;
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Logfile) >= out.getOutputLevel())
+        {
+            out.getLogfile() << output;
+            out.getLogfile().flush();
+        }
+
+        if (OutputHandler::getSoftDebugLevel(OutputHandler::LD_Shell) >= out.getOutputLevel())
+            (*out.getOutputBuffer()) << output;
+
+        return out;
+    }
+}
+
+#endif /* _OutputHandler_H__ */
Index: /code/branches/ceguilua/src/util/Sleep.h
===================================================================
--- /code/branches/ceguilua/src/util/Sleep.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/Sleep.h	(revision 1801)
@@ -0,0 +1,73 @@
+/*
+ *   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
+    Functions for using sleep() and usleep() under windows.
+ */
+
+#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>
+
+inline void usleep(DWORD dwMicroseconds)
+{
+  Sleep(dwMicroseconds / 1000);
+}
+
+inline void msleep(DWORD dwMilliseconds)
+{
+  Sleep(dwMilliseconds);
+}
+
+inline void sleep(DWORD dwSeconds)
+{
+  Sleep(dwSeconds * 1000);
+}
+
+#else /* Linux/Apple */
+
+#include <unistd.h>
+
+inline void msleep(unsigned long msec)
+{
+  usleep(msec * 1000);
+}
+
+#endif
+
+#endif /* _Sleep_H__ */
Index: /code/branches/ceguilua/src/util/String.cc
===================================================================
--- /code/branches/ceguilua/src/util/String.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/String.cc	(revision 1801)
@@ -0,0 +1,482 @@
+/*
+ *   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:
+ *      Benjamin Grauer
+ *
+ */
+
+/**
+    @file String.cc
+    @brief Implementation of several string manipulation functions.
+*/
+
+#include "String.h"
+
+#include <cctype>
+#include <iostream>
+
+/**
+    @brief Blank string as variable so you can use const std::string& even if you have to return "".
+*/
+std::string blankString = "";
+
+/**
+    @brief Removes all whitespaces from a string.
+    @param str The string to strip
+*/
+void strip(std::string* str)
+{
+    unsigned int pos;
+    while ((pos = (*str).find(" ")) < (*str).length())
+        (*str).erase(pos, 1);
+    while ((pos = (*str).find("\t")) < (*str).length())
+        (*str).erase(pos, 1);
+}
+
+/**
+    @brief Returns a copy of a string without whitespaces.
+    @param str The string to strip
+    @return The stripped line
+*/
+std::string getStripped(const std::string& str)
+{
+    std::string output = std::string(str);
+    strip(&output);
+    return output;
+}
+
+/**
+    @brief Returns a copy of a string without trailing whitespaces.
+    @param str The string
+    @return The modified copy
+*/
+std::string removeTrailingWhitespaces(const std::string& str)
+{
+    unsigned int pos1 = 0;
+    int pos2 = str.size() - 1;
+    for (; pos1 < str.size() && (str[pos1] == ' ' || str[pos1] == '\t' || str[pos1] == '\n'); pos1++);
+    for (; pos2 > 0          && (str[pos2] == ' ' || str[pos2] == '\t' || str[pos2] == '\n'); pos2--);
+    return str.substr(pos1, pos2 - pos1 + 1);
+}
+
+/**
+    @brief Returns the position of the next quote in the string, starting with start.
+    @param str The string
+    @param start The startposition
+    @return The position of the next quote (std::string::npos if there is no next quote)
+*/
+unsigned int getNextQuote(const std::string& str, unsigned int start)
+{
+    unsigned int quote = start - 1;
+
+    while ((quote = str.find('\"', quote + 1)) != std::string::npos)
+    {
+        unsigned int backslash = quote;
+        unsigned int numbackslashes = 0;
+        for (; backslash > 0; backslash--, numbackslashes++)
+            if (str[backslash - 1] != '\\')
+                break;
+
+        if (numbackslashes % 2 == 0)
+            break;
+    }
+
+    return quote;
+}
+
+/**
+    @brief Returns true if pos is between two quotes.
+    @param str The string
+    @param pos The position to check
+    @return True if pos is between two quotes
+*/
+bool isBetweenQuotes(const std::string& str, unsigned int pos)
+{
+    if (pos == std::string::npos)
+        return false;
+
+    unsigned int quotecount = 0;
+    unsigned int quote = (unsigned int)-1;
+    while ((quote = getNextQuote(str, quote + 1)) < pos)
+    {
+        quotecount++;
+    }
+
+    if (quote == std::string::npos)
+        return false;
+
+    return ((quotecount % 2) == 1);
+}
+
+/**
+    @brief Returns true if the string contains something like '..."between quotes"...'
+    @param The string
+    @return True if there is something between quotes
+*/
+bool hasStringBetweenQuotes(const std::string& str)
+{
+    unsigned int pos1 = getNextQuote(str, 0);
+    unsigned int pos2 = getNextQuote(str, pos1 + 1);
+    return (pos1 != std::string::npos && pos2 != std::string::npos && pos2 > pos1 + 1);
+}
+
+/**
+    @brief If the string contains something like '..."between quotes"...' then 'between quotes' gets returned (without quotes).
+    @param The string
+    @param The string between the quotes
+*/
+std::string getStringBetweenQuotes(const std::string& str)
+{
+    unsigned int pos1 = getNextQuote(str, 0);
+    unsigned int pos2 = getNextQuote(str, pos1 + 1);
+    if (pos1 != std::string::npos && pos2 != std::string::npos)
+        return str.substr(pos1, pos2 - pos1 + 1);
+    else
+        return "";
+}
+
+/**
+    @brief Removes enclosing quotes if available.
+    @brief str The string to strip
+    @return The string with removed quotes
+*/
+std::string stripEnclosingQuotes(const std::string& str)
+{
+    unsigned int start = std::string::npos;
+    unsigned int end = 0;
+
+    for (unsigned int pos = 0; (pos < str.size()) && (pos < std::string::npos); pos++)
+    {
+        if (str[pos] == '"')
+        {
+            start = pos;
+            break;
+        }
+
+        if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+            return str;
+    }
+
+    for (unsigned int pos = str.size() - 1; pos < std::string::npos; pos--)
+    {
+        if (str[pos] == '"')
+        {
+            end = pos;
+            break;
+        }
+
+        if ((str[pos] != ' ') && (str[pos] != '\t') && (str[pos] != '\n'))
+            return str;
+    }
+
+    if ((start != std::string::npos) && (end != 0))
+        return str.substr(start + 1, end - start - 1);
+    else
+        return str;
+}
+
+/**
+    @brief Removes enclosing {braces}.
+    @param str The string to strip
+    @return The striped string
+*/
+std::string stripEnclosingBraces(const std::string& str)
+{
+    std::string output = str;
+
+    while (output.size() >= 2 && output[0] == '{' && output[output.size() - 1] == '}')
+        output = output.substr(1, output.size() - 2);
+
+    return output;
+}
+
+/**
+    @brief Determines if a string in is a comment.
+    @param str The string to check
+    @return True = it's a comment
+
+    A comment is defined by a leading '#', '%', ';' or '//'.
+*/
+bool isComment(const std::string& str)
+{
+    // Strip the line, whitespaces are disturbing
+    std::string teststring = getStripped(str);
+
+    // There are four possible comment-symbols:
+    //  1) #comment in script-language style
+    //  2) %comment in matlab style
+    //  3) ;comment in unreal tournament config-file style
+    //  4) //comment in code style
+    if (teststring.size() >= 2)
+    {
+        if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';' || (teststring[0] == '/' && teststring[1] == '/'))
+            return true;
+    }
+    else if (teststring.size() == 1)
+    {
+        if (teststring[0] == '#' || teststring[0] == '%' || teststring[0] == ';')
+            return true;
+    }
+
+    return false;
+}
+
+/**
+    @brief Determines if a string is empty (contains only whitespaces).
+    @param str The string to check
+    @return True = it's empty
+*/
+bool isEmpty(const std::string& str)
+{
+    std::string temp = getStripped(str);
+    return ((temp == "") || (temp.size() == 0));
+}
+
+/**
+    @brief Determines if a string contains only numbers and maximal one '.'.
+    @param str The string to check
+    @return True = it's a number
+*/
+bool isNumeric(const std::string& str)
+{
+    bool foundPoint = false;
+
+    for (std::string::const_iterator it = str.begin(); it != str.end(); ++it)
+    {
+        if (((*it) < '0' || (*it) > '9'))
+        {
+            if ((*it) != '.' && !foundPoint)
+                foundPoint = true;
+            else
+                return false;
+        }
+    }
+
+    return true;
+}
+
+/**
+    @brief Adds backslashes to the given string which makes special chars visible. Existing slashes will be doubled.
+    @param str The string to manipulate
+    @return The string with added slashes
+*/
+std::string addSlashes(const std::string& str)
+{
+    std::string output = str;
+
+    for (unsigned int pos = 0; (pos = output.find('\\', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\\"); }
+    for (unsigned int pos = 0; (pos = output.find('\n', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\n"); }
+    for (unsigned int pos = 0; (pos = output.find('\t', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\t"); }
+    for (unsigned int pos = 0; (pos = output.find('\v', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\v"); }
+    for (unsigned int pos = 0; (pos = output.find('\b', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\b"); }
+    for (unsigned int pos = 0; (pos = output.find('\r', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\r"); }
+    for (unsigned int pos = 0; (pos = output.find('\f', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\f"); }
+    for (unsigned int pos = 0; (pos = output.find('\a', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\a"); }
+    for (unsigned int pos = 0; (pos = output.find('"', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\\""); }
+    for (unsigned int pos = 0; (pos = output.find('\0', pos)) < std::string::npos; pos += 2) { output.replace(pos, 1, "\\0"); }
+
+    return output;
+}
+
+/**
+    @brief Removes backslashes from the given string. Double backslashes are interpreted as one backslash.
+    @param str The string to manipulate
+    @return The string with removed slashes
+*/
+std::string removeSlashes(const std::string& str)
+{
+    if (str.size() <= 1)
+        return str;
+
+    std::string output = "";
+    for (unsigned int pos = 0; pos < str.size() - 1; )
+    {
+        if (str[pos] == '\\')
+        {
+            if (str[pos + 1] == '\\') { output += '\\'; pos += 2; continue; }
+            else if (str[pos + 1] == 'n') { output += '\n'; pos += 2; continue; }
+            else if (str[pos + 1] == 't') { output += '\t'; pos += 2; continue; }
+            else if (str[pos + 1] == 'v') { output += '\v'; pos += 2; continue; }
+            else if (str[pos + 1] == 'b') { output += '\b'; pos += 2; continue; }
+            else if (str[pos + 1] == 'r') { output += '\r'; pos += 2; continue; }
+            else if (str[pos + 1] == 'f') { output += '\f'; pos += 2; continue; }
+            else if (str[pos + 1] == 'a') { output += '\a'; pos += 2; continue; }
+            else if (str[pos + 1] == '"') { output += '"'; pos += 2; continue; }
+            else if (str[pos + 1] == '0') { output += '\0'; pos += 2; continue; }
+        }
+        output += str[pos];
+        pos++;
+        if (pos == str.size() - 1)
+            output += str[pos];
+    }
+
+    return output;
+}
+
+/**
+    @brief Replaces each char between A and Z with its lowercase equivalent.
+    @param str The string to convert
+*/
+void lowercase(std::string* str)
+{
+    for (unsigned int i = 0; i < str->size(); ++i)
+    {
+        (*str)[i] = (char)tolower((*str)[i]);
+    }
+}
+
+/**
+    @brief Returns a copy of the given string without uppercase chars.
+    @param str The string
+    @return The copy
+*/
+std::string getLowercase(const std::string& str)
+{
+    std::string output = std::string(str);
+    lowercase(&output);
+    return output;
+}
+
+/**
+    @brief Replaces each char between a and z with its uppercase equivalent.
+    @param str The string to convert
+*/
+void uppercase(std::string* str)
+{
+    for (unsigned int i = 0; i < str->size(); ++i)
+    {
+        (*str)[i] = (char)toupper((*str)[i]);
+    }
+}
+
+/**
+    @brief Returns a copy of the given string without lowercase chars.
+    @param str The string
+    @return The copy
+*/
+std::string getUppercase(const std::string& str)
+{
+    std::string output = std::string(str);
+    uppercase(&output);
+    return output;
+}
+
+/**
+    @brief compares two strings without ignoring the case
+    @param s1 first string
+    @param s2 second string
+*/
+int nocaseCmp(const std::string& s1, const std::string& s2)
+{
+    std::string::const_iterator it1=s1.begin();
+    std::string::const_iterator it2=s2.begin();
+
+    //stop when either string's end has been reached
+    while ( (it1!=s1.end()) && (it2!=s2.end()) )
+    {
+        if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+            // return -1 to indicate smaller than, 1 otherwise
+            return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
+        //proceed to the next character in each string
+        ++it1;
+        ++it2;
+    }
+    size_t size1=s1.size(), size2=s2.size();// cache lengths
+    //return -1,0 or 1 according to strings' lengths
+    if (size1==size2)
+        return 0;
+    return (size1<size2) ? -1 : 1;
+}
+
+
+/**
+    @brief compares two strings without ignoring the case
+    @param s1 first string
+    @param s2 second string
+    @param len how far from the beginning to start.
+*/
+int nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len)
+{
+    if (len == 0)
+        return 0;
+    std::string::const_iterator it1=s1.begin();
+    std::string::const_iterator it2=s2.begin();
+
+    //stop when either string's end has been reached
+    while ( (it1!=s1.end()) && (it2!=s2.end()) && len-- > 0)
+    {
+        if(::toupper(*it1) != ::toupper(*it2)) //letters differ?
+            // return -1 to indicate smaller than, 1 otherwise
+            return (::toupper(*it1)  < ::toupper(*it2)) ? -1 : 1;
+        //proceed to the next character in each string
+        ++it1;
+        ++it2;
+    }
+    return 0;
+}
+
+/**
+    @brief Returns true if the string contains a comment, introduced by #, %, ; or //.
+    @param str The string
+    @return True if the string contains a comment
+*/
+bool hasComment(const std::string& str)
+{
+    return (getCommentPosition(str) != std::string::npos);
+}
+
+/**
+    @brief If the string contains a comment, the comment gets returned (including the comment symbol), an empty string otherwise.
+    @param str The string
+    @return The comment
+*/
+std::string getComment(const std::string& str)
+{
+    return str.substr(getCommentPosition(str));
+}
+
+/**
+    @brief If the string contains a comment, the position of the comment-symbol gets returned, std::string::npos otherwise.
+    @param str The string
+    @return The position
+*/
+unsigned int getCommentPosition(const std::string& str)
+{
+    return getNextCommentPosition(str, 0);
+}
+
+/**
+    @brief Returns the position of the next comment-symbol, starting with start.
+    @param str The string
+    @param start The startposition
+    @return The position
+*/
+unsigned int getNextCommentPosition(const std::string& str, unsigned int start)
+{
+    for (unsigned int i = start; i < str.size(); i++)
+        if (isComment(str.substr(i)))
+            return i;
+
+    return std::string::npos;
+}
Index: /code/branches/ceguilua/src/util/String.h
===================================================================
--- /code/branches/ceguilua/src/util/String.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/String.h	(revision 1801)
@@ -0,0 +1,79 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file String.h
+    @brief Declaration of several string manipulation functions, used in many parts of the game.
+*/
+
+#ifndef _Util_String_H__
+#define _Util_String_H__
+
+#include "UtilPrereqs.h"
+
+#include <string>
+#include <sstream>
+
+extern _UtilExport std::string blankString;
+
+_UtilExport void         strip(std::string* str);
+_UtilExport std::string  getStripped(const std::string& str);
+
+_UtilExport std::string  removeTrailingWhitespaces(const std::string& str);
+
+_UtilExport unsigned int getNextQuote(const std::string& str, unsigned int start);
+_UtilExport bool         isBetweenQuotes(const std::string& str, unsigned int pos);
+
+_UtilExport bool         hasStringBetweenQuotes(const std::string& str);
+_UtilExport std::string  getStringBetweenQuotes(const std::string& str);
+
+_UtilExport std::string  stripEnclosingQuotes(const std::string& str);
+_UtilExport std::string  stripEnclosingBraces(const std::string& str);
+
+_UtilExport bool         isEmpty(const std::string& str);
+_UtilExport bool         isComment(const std::string& str);
+_UtilExport bool         isNumeric(const std::string& str);
+
+_UtilExport std::string  addSlashes(const std::string& str);
+_UtilExport std::string  removeSlashes(const std::string& str);
+
+_UtilExport void         lowercase(std::string* str);
+_UtilExport std::string  getLowercase(const std::string& str);
+
+_UtilExport void         uppercase(std::string* str);
+_UtilExport std::string  getUppercase(const std::string& str);
+
+_UtilExport int          nocaseCmp(const std::string& s1, const std::string& s2);
+_UtilExport int          nocaseCmp(const std::string& s1, const std::string& s2, unsigned int len);
+
+_UtilExport bool         hasComment(const std::string& str);
+_UtilExport std::string  getComment(const std::string& str);
+_UtilExport unsigned int getCommentPosition(const std::string& str);
+_UtilExport unsigned int getNextCommentPosition(const std::string& str, unsigned int start = 0);
+
+#endif /* _Util_String_H__ */
Index: /code/branches/ceguilua/src/util/SubString.cc
===================================================================
--- /code/branches/ceguilua/src/util/SubString.cc	(revision 1801)
+++ /code/branches/ceguilua/src/util/SubString.cc	(revision 1801)
@@ -0,0 +1,560 @@
+/*
+ *   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:
+ *      Christian Meyer
+ *   Co-authors:
+ *      Benjamin Grauer
+ *
+
+//
+//  splitLine
+//  STL string tokenizer
+//
+//  Created by Clemens Wacha.
+//  Version 1.0
+//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
+//
+
+ *   Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode.
+ */
+
+#include "SubString.h"
+
+/**
+ * @brief default constructor
+ */
+SubString::SubString()
+{}
+
+
+/**
+ * @brief create a SubString from
+ * @param string the String to Split
+ * @param delimiter the Character at which to split string (delimiter)
+ */
+SubString::SubString(const std::string& string, char delimiter)
+{
+  this->split(string, delimiter);
+}
+
+
+/**
+ * @brief Splits a String into multiple splitters.
+ * @param string the String to split
+ * @param delimiters multiple set of characters at what to split. (delimiters)
+ * @param delimiterNeighbours neighbours of the delimiters, that will be erased only when near a delimiter.
+ * @param emptyEntries If empty entries should be allewed or removed.
+ * @param escapeChar The Escape Character that overrides splitters commends and so on...
+ * @param safemode_char within these characters splitting won't happen
+ * @param comment_char the Comment character.
+ */
+SubString::SubString(const std::string& string,
+                     const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
+                     char escapeChar, bool removeEscapeChar, char safemode_char, bool removeSafemodeChar,
+                     char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
+{
+  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeEscapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
+}
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subString the SubString to take a set from.
+ * @param subSetBegin the beginning to the end
+ */
+SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+{
+  for (unsigned int i = subSetBegin; i < subString.size(); i++)
+  {
+    this->strings.push_back(subString[i]);
+    this->bInSafemode.push_back(subString.isInSafemode(i));
+  }
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subString the SubString to take a Set from
+ * @param subSetBegin the beginning to the end
+ * @param subSetEnd the end of the SubSet (max subString.size() will be checked internaly)
+ */
+SubString::SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd)
+{
+  for (unsigned int i = subSetBegin; i < subString.size() && i < subSetEnd; i++)
+  {
+    this->strings.push_back(subString[i]);
+    this->bInSafemode.push_back(subString.isInSafemode(i));
+  }
+}
+
+/**
+ * @brief creates a Substring from a count and values set.
+ * @param argc: the Arguments Count.
+ * @param argv: Argument Values.
+ */
+SubString::SubString(unsigned int argc, const char** argv)
+{
+  for(unsigned int i = 0; i < argc; ++i)
+  {
+    this->strings.push_back(std::string(argv[i]));
+    this->bInSafemode.push_back(false);
+  }
+}
+
+/**
+ * @brief removes the object from memory
+ */
+SubString::~SubString()
+{ }
+
+/** @brief An empty String */
+// const std::string SubString::emptyString = "";
+/** @brief Helper that gets you a String consisting of all White Spaces */
+const std::string SubString::WhiteSpaces = " \n\t";
+/** @brief Helper that gets you a String consisting of all WhiteSpaces and the Comma */
+const std::string SubString::WhiteSpacesWithComma = " \n\t,";
+/** An Empty SubString */
+const SubString SubString::NullSubString = SubString();
+
+/**
+ * @brief stores the Value of subString in this SubString
+ * @param subString will be copied into this String.
+ * @returns this SubString.
+ */
+SubString& SubString::operator=(const SubString& subString)
+{
+  this->strings = subString.strings;
+  this->bInSafemode = subString.bInSafemode;
+  return *this;
+}
+
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @returns true if the Stored Strings match
+ */
+bool SubString::operator==(const SubString& subString) const
+{
+  return ((this->strings == subString.strings) && (this->bInSafemode == subString.bInSafemode));
+}
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @returns true if the Stored Strings match
+ */
+bool SubString::compare(const SubString& subString) const
+{
+  return (*this == subString);
+}
+
+/**
+ * @brief comparator.
+ * @param subString the SubString to compare against this one.
+ * @param length how many entries to compare. (from 0 to length)
+ * @returns true if the Stored Strings match
+ */
+bool SubString::compare(const SubString& subString, unsigned int length) const
+{
+  if (length > this->size() || length > subString.size())
+    return false;
+
+  for (unsigned int i = 0; i < length; i++)
+    if ((this->strings[i] != subString.strings[i]) || (this->bInSafemode[i] != subString.bInSafemode[i]))
+      return false;
+  return true;
+}
+
+
+/**
+ * @brief append operator
+ * @param subString the String to append.
+ * @returns a SubString where this and subString are appended.
+ */
+SubString SubString::operator+(const SubString& subString) const
+{
+  return SubString(*this) += subString;
+}
+
+
+/**
+ * @brief append operator.
+ * @param subString append subString to this SubString.
+ * @returns this substring appended with subString
+ */
+SubString& SubString::operator+=(const SubString& subString)
+{
+  for (unsigned int i = 0; i < subString.size(); i++)
+  {
+    this->strings.push_back(subString[i]);
+    this->bInSafemode.push_back(subString.isInSafemode(i));
+  }
+  return *this;
+}
+
+
+/**
+ * @brief Split the String at
+ * @param string where to split
+ * @param splitter delimiter.
+ */
+unsigned int SubString::split(const std::string& string, char splitter)
+{
+  this->strings.clear();
+  this->bInSafemode.clear();
+  char split[2];
+  split[0] = splitter;
+  split[1] = '\0';
+  SubString::splitLine(this->strings, this->bInSafemode, string, split);
+  return strings.size();
+}
+
+
+/**
+ * @brief Splits a String into multiple splitters.
+ * @param string the String to split
+ * @param delimiters multiple set of characters at what to split. (delimiters)
+ * @param delimiterNeighbours: Neighbours to the Delimiters that will be erased too.
+ * @param emptyEntries: If empty entries are added to the List of SubStrings
+ * @param escapeChar The Escape Character that overrides splitters commends and so on...
+ * @param safemode_char within these characters splitting won't happen
+ * @param comment_char the Comment character.
+ */
+unsigned int SubString::split(const std::string& string,
+                              const std::string& delimiters, const std::string& delimiterNeighbours, bool emptyEntries,
+                              char escapeChar, bool removeExcapeChar, char safemode_char, bool removeSafemodeChar,
+                              char openparenthesis_char, char closeparenthesis_char, bool removeParenthesisChars, char comment_char)
+{
+  this->strings.clear();
+  this->bInSafemode.clear();
+  SubString::splitLine(this->strings, this->bInSafemode, string, delimiters, delimiterNeighbours, emptyEntries, escapeChar, removeExcapeChar, safemode_char, removeSafemodeChar, openparenthesis_char, closeparenthesis_char, removeParenthesisChars, comment_char);
+  return this->strings.size();
+}
+
+
+/**
+ * @brief joins together all Strings of this Substring.
+ * @param delimiter the String between the subStrings.
+ * @returns the joined String.
+ */
+std::string SubString::join(const std::string& delimiter) const
+{
+  if (!this->strings.empty())
+  {
+    std::string retVal = this->strings[0];
+    for (unsigned int i = 1; i < this->strings.size(); i++)
+      retVal += delimiter + this->strings[i];
+    return retVal;
+  }
+  else
+  {
+    static std::string empty;
+    return empty;
+  }
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subSetBegin the beginning to the end
+ * @returns the SubSet
+ *
+ * This function is added for your convenience, and does the same as
+ * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+ */
+SubString SubString::subSet(unsigned int subSetBegin) const
+{
+  return SubString(*this, subSetBegin);
+}
+
+
+/**
+ * @brief creates a SubSet of a SubString.
+ * @param subSetBegin the beginning to
+ * @param subSetEnd the end of the SubSet to select (if bigger than subString.size() it will be downset.)
+ * @returns the SubSet
+ *
+ * This function is added for your convenience, and does the same as
+ * SubString::SubString(const SubString& subString, unsigned int subSetBegin)
+ */
+SubString SubString::subSet(unsigned int subSetBegin, unsigned int subSetEnd) const
+{
+  return SubString(*this, subSetBegin, subSetEnd);
+}
+
+
+/**
+ * @brief splits line into tokens and stores them in ret.
+ * @param ret the Array, where the Splitted strings will be stored in
+ * to the beginning of the current token is stored
+ * @param line the inputLine to split
+ * @param delimiters a String of Delimiters (here the input will be splitted)
+ * @param delimiterNeighbours Naighbours to the Delimitter, that will be removed if they are to the left or the right of a Delimiter.
+ * @param emptyEntries: if empty Strings are added to the List of Strings.
+ * @param escape_char: Escape carater (escapes splitters)
+ * @param safemode_char: the beginning of the safemode is marked with this
+ * @param removeSafemodeChar removes the safemode_char from the beginning and the ending of a token
+ * @param openparenthesis_char the beginning of a safemode is marked with this
+ * @param closeparenthesis_char the ending of a safemode is marked with this
+ * @param removeParenthesisChars removes the parenthesis from the beginning and the ending of a token
+ * @param comment_char: the beginning of a comment is marked with this: (until the end of a Line)
+ * @param start_state: the Initial state on how to parse the String.
+ * @return SPLIT_LINE_STATE the parser was in when returning
+ *
+ * This is the Actual Splitting Algorithm from Clemens Wacha
+ * Supports delimiters, escape characters,
+ * ignores special  characters between safemode_char and between comment_char and linend '\n'.
+ */
+SubString::SPLIT_LINE_STATE
+SubString::splitLine(std::vector<std::string>& ret,
+                     std::vector<bool>& bInSafemode,
+                     const std::string& line,
+                     const std::string& delimiters,
+                     const std::string& delimiterNeighbours,
+                     bool emptyEntries,
+                     char escape_char,
+                     bool removeExcapeChar,
+                     char safemode_char,
+                     bool removeSafemodeChar,
+                     char openparenthesis_char,
+                     char closeparenthesis_char,
+                     bool removeParenthesisChars,
+                     char comment_char,
+                     SPLIT_LINE_STATE start_state)
+{
+  SPLIT_LINE_STATE state = start_state;
+  unsigned int i = 0;
+  unsigned int fallBackNeighbours = 0;
+
+  std::string token;
+  bool inSafemode = false;
+
+  if(start_state != SL_NORMAL && ret.size() > 0)
+  {
+    token = ret[ret.size()-1];
+    ret.pop_back();
+  }
+  if(start_state != SL_NORMAL && bInSafemode.size() > 0)
+  {
+    inSafemode = bInSafemode[bInSafemode.size()-1];
+    bInSafemode.pop_back();
+  }
+
+  while(i < line.size())
+  {
+    switch(state)
+    {
+      case SL_NORMAL:
+        if(line[i] == escape_char)
+        {
+          state = SL_ESCAPE;
+          if (!removeExcapeChar)
+            token += line[i];
+        }
+        else if(line[i] == safemode_char)
+        {
+          state = SL_SAFEMODE;
+          inSafemode = true;
+          if (!removeSafemodeChar)
+            token += line[i];
+        }
+        else if(line[i] == openparenthesis_char)
+        {
+          state = SL_PARENTHESES;
+          inSafemode = true;
+          if (!removeParenthesisChars)
+            token += line[i];
+        }
+        else if(line[i] == comment_char)
+        {
+          if (fallBackNeighbours > 0)
+            token = token.substr(0, token.size() - fallBackNeighbours);
+          /// FINISH
+          if(emptyEntries || token.size() > 0)
+          {
+            ret.push_back(token);
+            token.clear();
+            bInSafemode.push_back(inSafemode);
+            inSafemode = false;
+          }
+          token += line[i];       // EAT
+          state = SL_COMMENT;
+        }
+        else if(delimiters.find(line[i]) != std::string::npos)
+        {
+          // line[i] is a delimiter
+          if (fallBackNeighbours > 0)
+            token = token.substr(0, token.size() - fallBackNeighbours);
+          /// FINISH
+          if(emptyEntries || token.size() > 0)
+          {
+            ret.push_back(token);
+            token.clear();
+            bInSafemode.push_back(inSafemode);
+            inSafemode = false;
+          }
+          state = SL_NORMAL;
+        }
+        else
+        {
+          if (delimiterNeighbours.find(line[i]) != std::string::npos)
+          {
+            if (token.size() > 0)
+              ++fallBackNeighbours;
+            else
+            {
+              i++;
+              continue;
+            }
+          }
+          else
+            fallBackNeighbours = 0;
+          token += line[i];       // EAT
+        }
+        break;
+      case SL_ESCAPE:
+        if (!removeSafemodeChar)
+          token += line[i];
+        else
+        {
+          if(line[i] == 'n') token += '\n';
+          else if(line[i] == 't') token += '\t';
+          else if(line[i] == 'v') token += '\v';
+          else if(line[i] == 'b') token += '\b';
+          else if(line[i] == 'r') token += '\r';
+          else if(line[i] == 'f') token += '\f';
+          else if(line[i] == 'a') token += '\a';
+          else if(line[i] == '?') token += '\?';
+          else token += line[i];  // EAT
+        }
+        state = SL_NORMAL;
+        break;
+      case SL_SAFEMODE:
+        if(line[i] == safemode_char)
+        {
+          state = SL_NORMAL;
+          if (!removeSafemodeChar)
+            token += line[i];
+        }
+        else if(line[i] == escape_char)
+        {
+          state = SL_SAFEESCAPE;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+
+      case SL_SAFEESCAPE:
+        if(line[i] == 'n') token += '\n';
+        else if(line[i] == 't') token += '\t';
+        else if(line[i] == 'v') token += '\v';
+        else if(line[i] == 'b') token += '\b';
+        else if(line[i] == 'r') token += '\r';
+        else if(line[i] == 'f') token += '\f';
+        else if(line[i] == 'a') token += '\a';
+        else if(line[i] == '?') token += '\?';
+        else token += line[i];  // EAT
+        state = SL_SAFEMODE;
+        break;
+
+      case SL_PARENTHESES:
+        if(line[i] == closeparenthesis_char)
+        {
+          state = SL_NORMAL;
+          if (!removeParenthesisChars)
+            token += line[i];
+        }
+        else if(line[i] == escape_char)
+        {
+          state = SL_PARENTHESESESCAPE;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+
+      case SL_PARENTHESESESCAPE:
+        if(line[i] == 'n') token += '\n';
+        else if(line[i] == 't') token += '\t';
+        else if(line[i] == 'v') token += '\v';
+        else if(line[i] == 'b') token += '\b';
+        else if(line[i] == 'r') token += '\r';
+        else if(line[i] == 'f') token += '\f';
+        else if(line[i] == 'a') token += '\a';
+        else if(line[i] == '?') token += '\?';
+        else token += line[i];  // EAT
+        state = SL_PARENTHESES;
+        break;
+
+      case SL_COMMENT:
+        if(line[i] == '\n')
+        {
+          /// FINISH
+          if(token.size() > 0)
+          {
+            ret.push_back(token);
+            token.clear();
+            bInSafemode.push_back(inSafemode);
+            inSafemode = false;
+          }
+          state = SL_NORMAL;
+        }
+        else
+        {
+          token += line[i];       // EAT
+        }
+        break;
+
+      default:
+        // nothing
+        break;
+    }
+    i++;
+  }
+
+  /// FINISH
+  if (fallBackNeighbours > 0)
+    token = token.substr(0, token.size() - fallBackNeighbours);
+  if(emptyEntries || token.size() > 0)
+  {
+    ret.push_back(token);
+    token.clear();
+    bInSafemode.push_back(inSafemode);
+    inSafemode = false;
+  }
+  return(state);
+}
+
+
+/**
+ * @brief Some nice debug information about this SubString
+ */
+void SubString::debug() const
+{
+  printf("Substring-information::count=%d ::", this->strings.size());
+  for (unsigned int i = 0; i < this->strings.size(); i++)
+    printf("s%d='%s'::", i, this->strings[i].c_str());
+  printf("\n");
+}
Index: /code/branches/ceguilua/src/util/SubString.h
===================================================================
--- /code/branches/ceguilua/src/util/SubString.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/SubString.h	(revision 1801)
@@ -0,0 +1,173 @@
+/*
+ *   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:
+ *      Christian Meyer
+ *   Co-authors:
+ *      Benjamin Grauer
+ *      Fabian 'x3n' Landau
+ *
+
+//  splitLine
+//  STL string tokenizer
+//
+//  Created by Clemens Wacha.
+//  Version 1.0
+//  Copyright (c) 2005 Clemens Wacha. All rights reserved.
+
+ *   Extended by Fabian 'x3n' Landau by the SL_PARENTHESES mode.
+ */
+
+ /*!
+ * @file substring.h
+ * @brief a small class to get the parts of a string separated by commas
+ *
+ * This class is also identified as a Tokenizer. It splits up one long
+ * String into multiple small ones by a designated Delimiter.
+ *
+ * Substring is Advanced, and it is possible, to split a string by ','
+ * but also removing leading and trailing spaces around the comma.
+ *
+ * @example
+ * Split the String std::string st = "1345, The new empire   , is , orxonox"
+ * is splitted with:
+ * SubString(st, ',', " \n\t")
+ * into
+ * "1345", "The new empire", "is", "orxonox"
+ * As you can see, the useless spaces around ',' were removed.
+ */
+
+#ifndef __SubString_H__
+#define __SubString_H__
+
+#include "UtilPrereqs.h"
+
+#include <vector>
+#include <string>
+
+//! A class that can load one string and split it in multipe ones
+/**
+ * SubString is a very Powerfull way to create a SubSet from a String
+ * It can be used, to Split strings append them and join them again.
+ */
+class _UtilExport SubString
+{
+public:
+  //! An enumerator for the State the Parser is in
+  typedef enum {
+    SL_NORMAL,            //!< Normal state
+    SL_ESCAPE,            //!< After an escape character
+    SL_SAFEMODE,          //!< In safe mode (between "" mostly).
+    SL_SAFEESCAPE,        //!< In safe mode with the internal escape character, that escapes even the savemode character.
+    SL_COMMENT,           //!< In Comment mode.
+    SL_PARENTHESES,       //!< Between parentheses (usually '(' and ')')
+    SL_PARENTHESESESCAPE, //!< Between parentheses with the internal escape character, that escapes even the closing paranthesis character.
+  } SPLIT_LINE_STATE;
+
+
+public:
+  SubString();
+  SubString(const std::string& string, char delimiter = ',');
+  SubString(const std::string& string,
+            const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries=false,
+            char escapeChar ='\\', bool removeEscapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
+            char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
+  SubString(unsigned int argc, const char** argv);
+  /** @brief create a Substring as a copy of another one. @param subString the SubString to copy. */
+  SubString(const SubString& subString) { *this = subString; };
+  SubString(const SubString& subString, unsigned int subSetBegin);
+  SubString(const SubString& subString, unsigned int subSetBegin, unsigned int subSetEnd);
+  ~SubString();
+
+  // operate on the SubString
+  SubString& operator=(const SubString& subString);
+  bool operator==(const SubString& subString) const;
+  bool compare(const SubString& subString) const;
+  bool compare(const SubString& subString, unsigned int length) const;
+  SubString operator+(const SubString& subString) const;
+  SubString& operator+=(const SubString& subString);
+  /** @param subString the String to append @returns appended String. @brief added for convenience */
+  SubString& append(const SubString subString) { return (*this += subString); };
+
+  /////////////////////////////////////////
+  // Split and Join the any String. ///////
+  unsigned int split(const std::string& string = "", char delimiter = ',');
+  unsigned int split(const std::string& string,
+                     const std::string& delimiters, const std::string& delimiterNeighbours = "", bool emptyEntries = false,
+                     char escapeChar ='\\', bool removeExcapeChar = true, char safemode_char = '"', bool removeSafemodeChar = true,
+                     char openparenthesis_char = '(', char closeparenthesis_char = ')',  bool removeParenthesisChars = true, char comment_char = '\0');
+  std::string join(const std::string& delimiter = " ") const;
+  ////////////////////////////////////////
+
+  // retrieve a SubSet from the String
+  SubString subSet(unsigned int subSetBegin) const;
+  SubString subSet(unsigned int subSetBegin, unsigned int subSetEnd) const;
+
+  // retrieve Information from within
+  /** @brief Returns true if the SubString is empty */
+  inline bool empty() const { return this->strings.empty(); };
+  /** @brief Returns the count of Strings stored in this substring */
+  inline unsigned int size() const { return this->strings.size(); };
+  /** @brief Returns the i'th string from the subset of Strings @param i the i'th String */
+  inline const std::string& operator[](unsigned int i) const { return this->strings[i]; };
+  /** @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]; }
+  /** @brief Returns the front of the StringList. */
+  inline const std::string& front() const { return this->strings.front(); };
+  /** @brief Returns the back of the StringList. */
+  inline const std::string& back() const { return this->strings.back(); };
+  /** @brief removes the back of the strings list. */
+  inline void pop_back() { this->strings.pop_back(); this->bInSafemode.pop_back(); };
+
+  // the almighty algorithm.
+  static SPLIT_LINE_STATE splitLine(std::vector<std::string>& ret,
+                                    std::vector<bool>& bInSafemode,
+                                    const std::string& line,
+                                    const std::string& delimiters = SubString::WhiteSpaces,
+                                    const std::string& delimiterNeighbours = "",
+                                    bool emptyEntries = false,
+                                    char escape_char = '\\',
+                                    bool removeExcapeChar = true,
+                                    char safemode_char = '"',
+                                    bool removeSafemodeChar = true,
+                                    char openparenthesis_char = '(',
+                                    char closeparenthesis_char = ')',
+                                    bool removeParenthesisChars = true,
+                                    char comment_char = '\0',
+                                    SPLIT_LINE_STATE start_state = SL_NORMAL);
+  // debugging.
+  void debug() const;
+
+public:
+  static const std::string WhiteSpaces;
+  static const std::string WhiteSpacesWithComma;
+  static const SubString   NullSubString;
+
+private:
+  std::vector<std::string>  strings;                      //!< strings produced from a single string splitted in multiple strings
+  std::vector<bool>         bInSafemode;
+};
+
+#endif /* __SubString_H__ */
Index: /code/branches/ceguilua/src/util/UtilPrereqs.h
===================================================================
--- /code/branches/ceguilua/src/util/UtilPrereqs.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/UtilPrereqs.h	(revision 1801)
@@ -0,0 +1,75 @@
+/*
+ *   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
+ *
+ */
+
+/**
+  @file
+  @brief Contains all the necessary forward declarations for all classes and structs.
+*/
+
+#ifndef _UtilPrereqs_H__
+#define _UtilPrereqs_H__
+
+#include "util/OrxonoxPlatform.h"
+
+//-----------------------------------------------------------------------
+// Shared library settings
+//-----------------------------------------------------------------------
+#if (ORXONOX_PLATFORM == ORXONOX_PLATFORM_WIN32) && !defined( UTIL_STATIC_BUILD )
+#  ifdef UTIL_SHARED_BUILD
+#    define _UtilExport __declspec(dllexport)
+#  else
+#    if defined( __MINGW32__ )
+#      define _UtilExport
+#    else
+#      define _UtilExport __declspec(dllimport)
+#    endif
+#  endif
+#elif defined ( ORXONOX_GCC_VISIBILITY )
+#  define _UtilExport  __attribute__ ((visibility("default")))
+#else
+#  define _UtilExport
+#endif
+
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+class ArgReader;
+class Convert;
+class ExprParser;
+class MultiType;
+class SubString;
+namespace orxonox
+{
+    class OutputBuffer;
+    class OutputBufferListener;
+    class Error;
+    class OutputHandler;
+}
+
+#endif /* _UtilPrereqs_H__ */
Index: /code/branches/ceguilua/src/util/XMLIncludes.h
===================================================================
--- /code/branches/ceguilua/src/util/XMLIncludes.h	(revision 1801)
+++ /code/branches/ceguilua/src/util/XMLIncludes.h	(revision 1801)
@@ -0,0 +1,73 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+/**
+    @file XMLIncludes.h
+    @brief Forward declarations of some XML classes.
+*/
+
+#include "UtilPrereqs.h"
+
+//-----------------------------------------------------------------------
+// Forward declarations
+//-----------------------------------------------------------------------
+
+class TiXmlString;
+class TiXmlOutStream;
+class TiXmlNode;
+class TiXmlHandle;
+class TiXmlDocument;
+class TiXmlElement;
+class TiXmlComment;
+class TiXmlUnknown;
+class TiXmlAttribute;
+class TiXmlText;
+class TiXmlDeclaration;
+class TiXmlParsingData;
+
+namespace ticpp
+{
+    class Document;
+    class Element;
+    class Declaration;
+    class StylesheetReference;
+    class Text;
+    class Comment;
+    class Attribute;
+}
+
+namespace orxonox
+{
+    typedef ticpp::Document Document;
+    typedef ticpp::Element Element;
+    typedef ticpp::Declaration Declaration;
+    typedef ticpp::StylesheetReference StylesheetReference;
+    typedef ticpp::Text Text;
+    typedef ticpp::Comment Comment;
+    typedef ticpp::Attribute Attribute;
+}
Index: /code/branches/ceguilua/src/util/testing/CMakeLists.txt
===================================================================
--- /code/branches/ceguilua/src/util/testing/CMakeLists.txt	(revision 1801)
+++ /code/branches/ceguilua/src/util/testing/CMakeLists.txt	(revision 1801)
@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(${INCLUDE_DIRECTORIES}
+	../
+)
+
+ADD_EXECUTABLE(TestConverter
+ TestConverter.cpp
+)
+
+
+ADD_TEST(TestConverter
+	${EXECUTABLE_OUTPUT_PATH}/TestConverter
+)
Index: /code/branches/ceguilua/src/util/testing/TestConverter.cpp
===================================================================
--- /code/branches/ceguilua/src/util/testing/TestConverter.cpp	(revision 1801)
+++ /code/branches/ceguilua/src/util/testing/TestConverter.cpp	(revision 1801)
@@ -0,0 +1,17 @@
+#include "Convert.h"
+#include <iostream>
+
+int main(int argc, char** argv)
+{
+  int input = rand();
+  std::string sub;
+  int output = 0;
+
+  ConvertValue(&sub, input);
+  ConvertValue(&output, sub);
+
+  if (input == output)
+    return 0;
+  else
+    return -1;
+}
Index: /code/branches/ceguilua/updateMedia.sh
===================================================================
--- /code/branches/ceguilua/updateMedia.sh	(revision 1801)
+++ /code/branches/ceguilua/updateMedia.sh	(revision 1801)
@@ -0,0 +1,5 @@
+#!/bin/bash
+dir=${pwd}
+cd ../Media
+svn up
+cd $dir
Index: /code/branches/ceguilua/visual_studio/audio_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/audio_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/audio_properties.vsprops	(revision 1801)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="audio_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="AUDIO_SHARED_BUILD"
+		DisableSpecificWarnings="4244"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="libvorbisfile-1.2.0$(CSS).lib alut$(CS).lib OpenAL32$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/base_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/base_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/base_properties.vsprops	(revision 1801)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="base_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<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)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"
+		DisableSpecificWarnings="4522;4251;4800"
+	/>
+	<Tool
+		Name="VCLibrarianTool"
+		OutputFile="$(LibOutDir)$(ProjectName)$(CS).lib"
+		AdditionalLibraryDirectories="$(RootDir)dependencies\lib"
+		IgnoreAllDefaultLibraries="true"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		OutputFile="$(OutDir)$(ProjectName)$(CS).dll"
+		AdditionalLibraryDirectories="$(DependencyDir)lib"
+		SubSystem="1"
+		ImportLibrary="$(LibOutDir)$(TargetName).lib"
+		TargetMachine="1"
+	/>
+	<UserMacro
+		Name="LibOutDir"
+		Value="$(RootDir)lib\"
+	/>
+	<UserMacro
+		Name="DependencyDir"
+		Value="$(RootDir)..\lib_precompiled\"
+	/>
+	<UserMacro
+		Name="CS"
+		Value=""
+	/>
+	<UserMacro
+		Name="CSS"
+		Value=""
+	/>
+	<UserMacro
+		Name="LibDir"
+		Value="$(RootDir)..\lib_precompiled\include\"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/base_properties_debug.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/base_properties_debug.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/base_properties_debug.vsprops	(revision 1801)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="base_properties_debug"
+	InheritedPropertySheets="$(SolutionDir)base_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		Optimization="0"
+		PreprocessorDefinitions="_DEBUG"
+		MinimalRebuild="true"
+		BasicRuntimeChecks="3"
+		RuntimeLibrary="3"
+		DebugInformationFormat="3"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		LinkIncremental="2"
+		GenerateDebugInformation="true"
+	/>
+	<UserMacro
+		Name="CS"
+		Value="_d"
+	/>
+	<UserMacro
+		Name="CSS"
+		Value="_d"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/base_properties_release.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/base_properties_release.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/base_properties_release.vsprops	(revision 1801)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="base_properties_release"
+	InheritedPropertySheets=".\base_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		Optimization="2"
+		PreprocessorDefinitions="NDEBUG"
+		RuntimeLibrary="2"
+		DebugInformationFormat="3"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		LinkIncremental="1"
+		GenerateDebugInformation="true"
+		OptimizeReferences="2"
+		EnableCOMDATFolding="2"
+	/>
+	<UserMacro
+		Name="CS"
+		Value=""
+	/>
+	<UserMacro
+		Name="CSS"
+		Value=""
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/core_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/core_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/core_properties.vsprops	(revision 1801)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="core_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="CORE_SHARED_BUILD"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CSS).lib tcl85t.lib lua-5.1.3$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/cpptcl_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/cpptcl_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/cpptcl_properties.vsprops	(revision 1801)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="cpptcl_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/directory_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/directory_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/directory_properties.vsprops	(revision 1801)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="directory_properties"
+	OutputDirectory="$(RootDir)bin\"
+	IntermediateDirectory="$(RootDir)obj\$(ProjectName)\$(ConfigurationName)"
+	>
+	<UserMacro
+		Name="RootDir"
+		Value="$(SolutionDir)..\"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/network_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/network_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/network_properties.vsprops	(revision 1801)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="network_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;WIN32_LEAN_AND_MEAN"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="enet$(CS).lib zlib$(CS).lib"
+		IgnoreDefaultLibraryNames="LIBCMT;LIBCMTD"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/orxonox_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/orxonox_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/orxonox_properties.vsprops	(revision 1801)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="orxonox_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="ORXONOX_NO_EXPORTS;NETWORK_STATIC_BUILD;OGRE_GUIRENDERER_EXPORTS"
+		UsePrecompiledHeader="2"
+		PrecompiledHeaderThrough="OrxonoxStableHeaders.h"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		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"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/orxonox_vc8.sln
===================================================================
--- /code/branches/ceguilua/visual_studio/orxonox_vc8.sln	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/orxonox_vc8.sln	(revision 1801)
@@ -0,0 +1,110 @@
+﻿
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual Studio 2005
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cpptcl", "vc8\cpptcl.vcproj", "{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ois", "vc8\ois.vcproj", "{9CC704CB-4956-4479-BDEC-57CBC03F700E}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tixml", "vc8\tixml.vcproj", "{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
+EndProject
+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
+		{271715F3-5B90-4110-A552-70C788084A86} = {271715F3-5B90-4110-A552-70C788084A86}
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC} = {2240ECD7-2F48-4431-8E1B-25466A384CCC}
+	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}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "orxonox", "vc8\orxonox.vcproj", "{0B6C5CFD-F91B-432A-80A3-2610F61E060B}"
+	ProjectSection(ProjectDependencies) = postProject
+		{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
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.ActiveCfg = Debug|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Debug|Win32.Build.0 = Debug|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Release|Win32.ActiveCfg = Release|Win32
+		{53C56131-E2AA-4A27-B460-7AC05D61A0E6}.Release|Win32.Build.0 = Release|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.Debug|Win32.ActiveCfg = Debug|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.Debug|Win32.Build.0 = Debug|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.Release|Win32.ActiveCfg = Release|Win32
+		{9CC704CB-4956-4479-BDEC-57CBC03F700E}.Release|Win32.Build.0 = Release|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Debug|Win32.Build.0 = Debug|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.ActiveCfg = Release|Win32
+		{F101C2F0-1CB9-4A57-827B-6C399A99B28F}.Release|Win32.Build.0 = Release|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.ActiveCfg = Debug|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Debug|Win32.Build.0 = Debug|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.Release|Win32.ActiveCfg = Release|Win32
+		{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}.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
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Release|Win32.ActiveCfg = Release|Win32
+		{A0724246-CB7C-420B-BCF0-68EF205AFE34}.Release|Win32.Build.0 = Release|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Debug|Win32.ActiveCfg = Debug|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Debug|Win32.Build.0 = Debug|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Release|Win32.ActiveCfg = Release|Win32
+		{2240ECD7-2F48-4431-8E1B-25466A384CCC}.Release|Win32.Build.0 = Release|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.Debug|Win32.ActiveCfg = Debug|Win32
+		{271715F3-5B90-4110-A552-70C788084A86}.Debug|Win32.Build.0 = Debug|Win32
+		{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
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.ActiveCfg = Release|Win32
+		{35575B59-E1AE-40E8-89C4-2862B5B09B68}.Release|Win32.Build.0 = Release|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.ActiveCfg = Debug|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Debug|Win32.Build.0 = Debug|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.ActiveCfg = Release|Win32
+		{0B6C5CFD-F91B-432A-80A3-2610F61E060B}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal
Index: /code/branches/ceguilua/visual_studio/tixml_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/tixml_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/tixml_properties.vsprops	(revision 1801)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tixml_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/tolua_app_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/tolua_app_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/tolua_app_properties.vsprops	(revision 1801)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_app_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_STATIC_BUILD"
+		CompileAs="1"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="lua-5.1.3$(CS).lib"
+		OutputFile="$(OutDir)$(ProjectName)$(CS).exe"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/tolua_gen_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/tolua_gen_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/tolua_gen_properties.vsprops	(revision 1801)
@@ -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/branches/ceguilua/visual_studio/tolua_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/tolua_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/tolua_properties.vsprops	(revision 1801)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		PreprocessorDefinitions="TOLUA_SHARED_BUILD"
+		CompileAs="2"
+		DisableSpecificWarnings="4996"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="lua-5.1.3$(CS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/util_properties.vsprops
===================================================================
--- /code/branches/ceguilua/visual_studio/util_properties.vsprops	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/util_properties.vsprops	(revision 1801)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioPropertySheet
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="util_properties"
+	InheritedPropertySheets=".\directory_properties.vsprops"
+	>
+	<Tool
+		Name="VCCLCompilerTool"
+		AdditionalOptions="/MP2"
+		PreprocessorDefinitions="UTIL_SHARED_BUILD"
+	/>
+	<Tool
+		Name="VCLinkerTool"
+		AdditionalDependencies="OgreMain$(CSS).lib"
+	/>
+</VisualStudioPropertySheet>
Index: /code/branches/ceguilua/visual_studio/vc8/audio.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/audio.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/audio.vcproj	(revision 1801)
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="audio"
+	ProjectGUID="{4733BD1A-E04C-458D-8BFB-5010250EA497}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\audio_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="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\audio_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\audio\AudioBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioSource.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioStream.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\audio\AudioBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioIncludes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioSource.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\AudioStream.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/core.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/core.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/core.vcproj	(revision 1801)
@@ -0,0 +1,617 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="core"
+	ProjectGUID="{271715F3-5B90-4110-A552-70C788084A86}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\core_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="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\core_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\core\Clock.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigFileManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueContainer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Core.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\GameState.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Language.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OrxonoxClass.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\RootGameState.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Script.cc"
+				>
+			</File>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					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"
+						>
+						<Tool
+							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&#x0D;&#x0A;"
+							Outputs="$(RootDir)\src\core\tolua\tolua_bind.cc; $(RootDir)\src\core\tolua\tolua_bind.h"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\core\tolua\tolua_bind.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="command"
+				>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompletionFunctions.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandEvaluation.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandExecutor.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandLine.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommand.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommandCompilation.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Executor.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="hierarchy"
+				>
+				<File
+					RelativePath="..\..\src\core\Factory.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Identifier.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\MetaObjectList.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectListBase.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="level"
+				>
+				<File
+					RelativePath="..\..\src\core\BaseObject.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ClassTreeMask.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Loader.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Namespace.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\NamespaceNode.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\XMLPort.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="input"
+				>
+				<File
+					RelativePath="..\..\src\core\input\Button.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\CalibratorCallback.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\ExtendedInputState.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\HalfAxis.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputBuffer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputCommands.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputManager.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyBinder.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyDetector.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\SimpleInputState.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="shell"
+				>
+				<File
+					RelativePath="..\..\src\core\IRC.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Shell.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclBind.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclThreadManager.cc"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\core\Clock.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigFileManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueContainer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\ConfigValueIncludes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Core.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\CorePrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\GameState.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Language.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\OrxonoxClass.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\RootGameState.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Script.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\Super.h"
+				>
+			</File>
+			<Filter
+				Name="input"
+				>
+				<File
+					RelativePath="..\..\src\core\input\Button.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\CalibratorCallback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\ExtendedInputState.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\HalfAxis.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputBuffer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputCommands.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputInterfaces.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\InputState.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyBinder.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\KeyDetector.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\input\SimpleInputState.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="command"
+				>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompleter.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompletionFunctions.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ArgumentCompletionListElement.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandEvaluation.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandExecutor.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CommandLine.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommand.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ConsoleCommandCompilation.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Executor.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Functor.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="shell"
+				>
+				<File
+					RelativePath="..\..\src\core\IRC.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Shell.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclBind.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\TclThreadManager.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="hierarchy"
+				>
+				<File
+					RelativePath="..\..\src\core\ClassFactory.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\CoreIncludes.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Factory.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Identifier.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Iterator.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\IteratorBase.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\MetaObjectList.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectList.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ObjectListBase.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="level"
+				>
+				<File
+					RelativePath="..\..\src\core\BaseObject.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\ClassTreeMask.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Level.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Loader.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\Namespace.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\NamespaceNode.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\core\XMLPort.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\core\tolua\tolua_bind.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/cpptcl.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/cpptcl.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/cpptcl.vcproj	(revision 1801)
@@ -0,0 +1,150 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="cpptcl"
+	ProjectGUID="{53C56131-E2AA-4A27-B460-7AC05D61A0E6}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\cpptcl_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="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\cpptcl_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="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<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\cpptcl\CppTcl.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\cpptcl\CppTcl.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/network.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/network.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/network.vcproj	(revision 1801)
@@ -0,0 +1,294 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="network"
+	ProjectGUID="{35575B59-E1AE-40E8-89C4-2862B5B09B68}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\network_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="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\network_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="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<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\network\Client.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientConnection.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientInformation.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ConnectionManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateClient.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateManager.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Host.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Server.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Synchronisable.cc"
+				>
+			</File>
+			<Filter
+				Name="packet"
+				>
+				<File
+					RelativePath="..\..\src\network\packet\Acknowledgement.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Chat.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\ClassID.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Gamestate.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Packet.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Welcome.cc"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\network\Client.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientConnection.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ClientInformation.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\ConnectionManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateClient.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateHandler.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\GamestateManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Host.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\NetworkCallback.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\NetworkPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\PacketBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Server.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\network\Synchronisable.h"
+				>
+			</File>
+			<Filter
+				Name="packet"
+				>
+				<File
+					RelativePath="..\..\src\network\packet\Acknowledgement.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Chat.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\ClassID.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Gamestate.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Packet.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\network\packet\Welcome.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/ois.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/ois.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/ois.vcproj	(revision 1801)
@@ -0,0 +1,817 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="ois"
+	ProjectGUID="{9CC704CB-4956-4479-BDEC-57CBC03F700E}"
+	RootNamespace="OIS"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+		<Platform
+			Name="x64"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="..\directory_properties.vsprops"
+			CharacterSet="2"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/MP2"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				OmitFramePointers="true"
+				AdditionalIncludeDirectories="$(RootDir)src\ois"
+				PreprocessorDefinitions="WIN32;NDEBUG;OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="false"
+				FloatingPointModel="2"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile="$(IntDir)/$(TargetName).pch"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="dxguid.lib dinput8.lib"
+				AdditionalLibraryDirectories=""
+				GenerateDebugInformation="true"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
+				ImportLibrary="$(RootDir)lib\$(TargetName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="..\directory_properties.vsprops"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/MP2"
+				Optimization="0"
+				AdditionalIncludeDirectories="$(RootDir)\src\ois"
+				PreprocessorDefinitions="WIN32;_DEBUG;_STLP_DEBUG;OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				FloatingPointModel="2"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderThrough="StdAfx.h"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="4"
+				CallingConvention="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="dxguid.lib dinput8.lib"
+				OutputFile="$(OutDir)\$(ProjectName)_d.dll"
+				AdditionalLibraryDirectories=""
+				GenerateDebugInformation="true"
+				ImportLibrary="$(RootDir)lib\$(TargetName).lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			OutputDirectory="..\lib64\"
+			IntermediateDirectory="..\lib64\obj\$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\includes"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_STLP_DEBUG"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				FloatingPointModel="2"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderThrough="StdAfx.h"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+				CallingConvention="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				AdditionalDependencies="dxguid.lib dinput8.lib"
+				OutputFile="$(OutDir)/OIS_d.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			OutputDirectory="..\lib64\"
+			IntermediateDirectory="..\lib64\obj\$(ConfigurationName)"
+			ConfigurationType="4"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				EnableFiberSafeOptimizations="true"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="..\includes"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				FloatingPointModel="2"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile="$(IntDir)/$(TargetName).pch"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLibrarianTool"
+				AdditionalDependencies="dxguid.lib dinput8.lib"
+				OutputFile="$(OutDir)/OIS.lib"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="OIS_ReleaseDll|x64"
+			OutputDirectory="..\dll64"
+			IntermediateDirectory="..\dll64\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="2"
+				InlineFunctionExpansion="1"
+				FavorSizeOrSpeed="1"
+				OmitFramePointers="true"
+				EnableFiberSafeOptimizations="true"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="..\includes"
+				PreprocessorDefinitions="WIN32;NDEBUG;OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				FloatingPointModel="2"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile="$(IntDir)/$(TargetName).pch"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="dxguid.lib dinput8.lib"
+				GenerateDebugInformation="true"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="OIS_DebugDll|x64"
+			OutputDirectory="..\dll64"
+			IntermediateDirectory="..\dll64\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\includes"
+				PreprocessorDefinitions="WIN32;_DEBUG;_STLP_DEBUG;OIS_NONCLIENT_BUILD;OIS_DYNAMIC_LIB"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				FloatingPointModel="2"
+				RuntimeTypeInfo="true"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderThrough="StdAfx.h"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="true"
+				DebugInformationFormat="3"
+				CallingConvention="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="dxguid.lib dinput8.lib"
+				OutputFile="$(OutDir)/OIS_d.dll"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCWebDeploymentTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				CommandLine=""
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
+			>
+			<File
+				RelativePath="..\..\src\ois\OISEffect.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISException.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISForceFeedback.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISInputManager.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISJoyStick.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISKeyboard.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISObject.cpp"
+				>
+			</File>
+			<Filter
+				Name="Win32"
+				>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32ForceFeedback.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32InputManager.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32JoyStick.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32KeyBoard.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32Mouse.cpp"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="linux"
+				>
+				<File
+					RelativePath="..\..\src\ois\linux\EventHelpers.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxForceFeedback.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxInputManager.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxKeyboard.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxMouse.cpp"
+					>
+					<FileConfiguration
+						Name="Release|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Debug|Win32"
+						ExcludedFromBuild="true"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc"
+			>
+			<File
+				RelativePath="..\..\src\ois\OIS.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISConfig.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISEvents.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISException.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISFactoryCreator.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISInputManager.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISJoyStick.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISKeyboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISMouse.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISObject.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\ois\OISPrereqs.h"
+				>
+			</File>
+			<Filter
+				Name="Win32"
+				>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32ForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32InputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32JoyStick.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32KeyBoard.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32Mouse.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\win32\Win32Prereqs.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="Interface"
+				>
+				<File
+					RelativePath="..\..\src\ois\OISEffect.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\OISForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\OISInterface.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="linux"
+				>
+				<File
+					RelativePath="..\..\src\ois\linux\EventHelpers.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxForceFeedback.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxInputManager.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxJoyStickEvents.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxKeyboard.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxMouse.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\ois\linux\LinuxPrereqs.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/orxonox.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/orxonox.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/orxonox.vcproj	(revision 1801)
@@ -0,0 +1,810 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="orxonox"
+	ProjectGUID="{0B6C5CFD-F91B-432A-80A3-2610F61E060B}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\orxonox_properties.vsprops"
+			CharacterSet="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/Zm200"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				EntryPointSymbol=""
+			/>
+			<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;..\orxonox_properties.vsprops"
+			CharacterSet="1"
+			WholeProgramOptimization="0"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/Zm200"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				EntryPointSymbol=""
+			/>
+			<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\orxonox\GraphicsEngine.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Main.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\PrecompiledHeaderFiles.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						UsePrecompiledHeader="1"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Radar.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\SignalHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\RadarListener.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\RadarViewable.cc"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\$(InputName)1.obj"
+						XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					>
+					<Tool
+						Name="VCCLCompilerTool"
+						ObjectFile="$(IntDir)\$(InputName)1.obj"
+						XMLDocumentationFileName="$(IntDir)\$(InputName)1.xdc"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Settings.cc"
+				>
+			</File>
+			<Filter
+				Name="objects"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Ambient.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Backlight.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\BillboardProjectile.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Camera.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\CameraHandler.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Model.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\NPC.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\ParticleProjectile.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\ParticleSpawner.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Projectile.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\RotatingProjectile.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Skybox.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\SpaceShip.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\SpaceShipAI.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Tickable.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\WorldEntity.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tools"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tools\BillboardSet.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Light.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Mesh.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\ParticleInterface.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\TextureGenerator.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Timer.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\WindowEventListener.cc"
+					>
+				</File>
+			</Filter>
+			<Filter
+				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"
+					>
+					<FileConfiguration
+						Name="Debug|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+					<FileConfiguration
+						Name="Release|Win32"
+						>
+						<Tool
+							Name="VCCLCompilerTool"
+							UsePrecompiledHeader="0"
+						/>
+					</FileConfiguration>
+				</File>
+			</Filter>
+			<Filter
+				Name="overlays"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OrxonoxOverlay.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayGroup.cc"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayText.cc"
+					>
+				</File>
+				<Filter
+					Name="console"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\console\InGameConsole.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="hud"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDRadar.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDSpeedBar.cc"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="debug"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugFPSText.cc"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.cc"
+						>
+					</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>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\orxonox\GraphicsEngine.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxLibraryHeaders.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\OrxonoxStableHeaders.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Radar.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\RadarListener.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\RadarViewable.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\Settings.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\orxonox\SignalHandler.h"
+				>
+			</File>
+			<Filter
+				Name="objects"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Ambient.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Backlight.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\BillboardProjectile.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Camera.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\CameraHandler.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Model.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\NPC.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\ParticleProjectile.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\ParticleSpawner.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Projectile.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\RotatingProjectile.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Skybox.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\SpaceShip.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\SpaceShipAI.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\Tickable.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\objects\WorldEntity.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tools"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tools\BillboardSet.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Light.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Mesh.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\ParticleInterface.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\TextureGenerator.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\Timer.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\tools\WindowEventListener.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="tolua"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\tolua\tolua_bind.h"
+					>
+				</File>
+			</Filter>
+			<Filter
+				Name="overlays"
+				>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OrxonoxOverlay.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayGroup.h"
+					>
+				</File>
+				<File
+					RelativePath="..\..\src\orxonox\overlays\OverlayText.h"
+					>
+				</File>
+				<Filter
+					Name="hud"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDBar.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDNavigation.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDRadar.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\hud\HUDSpeedBar.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="console"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\console\InGameConsole.h"
+						>
+					</File>
+				</Filter>
+				<Filter
+					Name="debug"
+					>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugFPSText.h"
+						>
+					</File>
+					<File
+						RelativePath="..\..\src\orxonox\overlays\debug\DebugRTRText.h"
+						>
+					</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>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/tixml.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/tixml.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/tixml.vcproj	(revision 1801)
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tixml"
+	ProjectGUID="{F101C2F0-1CB9-4A57-827B-6C399A99B28F}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\tixml_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="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			ConfigurationType="4"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tixml_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="VCLibrarianTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<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\tinyxml\ticpp.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinystr.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxml.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxmlerror.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxmlparser.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\tinyxml\ticpp.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\ticpprc.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinystr.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tinyxml\tinyxml.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/tolua.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/tolua.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/tolua.vcproj	(revision 1801)
@@ -0,0 +1,188 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua"
+	ProjectGUID="{35E36A06-0A5C-4A0D-9AB6-5A05EAA87626}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\tolua_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="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\tolua_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_event.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_is.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_map.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_push.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\tolua\tolua_to.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\tolua_event.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/tolua_app.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/tolua_app.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/tolua_app.vcproj	(revision 1801)
@@ -0,0 +1,200 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="tolua_app"
+	ProjectGUID="{A0724246-CB7C-420B-BCF0-68EF205AFE34}"
+	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_app_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_app_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\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>
+		</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_orxonox.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /code/branches/ceguilua/visual_studio/vc8/tolua_gen.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/tolua_gen.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/tolua_gen.vcproj	(revision 1801)
@@ -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/branches/ceguilua/visual_studio/vc8/util.vcproj
===================================================================
--- /code/branches/ceguilua/visual_studio/vc8/util.vcproj	(revision 1801)
+++ /code/branches/ceguilua/visual_studio/vc8/util.vcproj	(revision 1801)
@@ -0,0 +1,280 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="util"
+	ProjectGUID="{2240ECD7-2F48-4431-8E1B-25466A384CCC}"
+	RootNamespace="FICN"
+	Keyword="Win32Proj"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			ConfigurationType="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_debug.vsprops;..\util_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="2"
+			InheritedPropertySheets="$(SolutionDir)base_properties_release.vsprops;..\util_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\util\Clipboard.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\CRC32.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Error.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Exception.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\ExprParser.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Math.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiType.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputBuffer.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputHandler.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\String.cc"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\SubString.cc"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+			>
+			<File
+				RelativePath="..\..\src\util\Clipboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Convert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\CRC32.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Debug.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Error.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Exception.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\ExprParser.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Integers.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Math.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiType.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\MultiTypeValue.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OrxonoxPlatform.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputBuffer.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\OutputHandler.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\Sleep.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\String.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\SubString.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\UtilPrereqs.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\util\XMLIncludes.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
